Merge pull request #1676 from TebbeUbben/dev
Insight: Enforce using first profile
This commit is contained in:
commit
cc3b50c12d
2 changed files with 57 additions and 63 deletions
|
@ -8,6 +8,8 @@ import android.os.Handler;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.plugins.pump.insight.app_layer.parameter_blocks.*;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.insight.descriptors.*;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -69,12 +71,6 @@ import info.nightscout.androidaps.plugins.pump.insight.app_layer.history.history
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.app_layer.history.history_events.StartOfTBREvent;
|
import info.nightscout.androidaps.plugins.pump.insight.app_layer.history.history_events.StartOfTBREvent;
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.app_layer.history.history_events.TotalDailyDoseEvent;
|
import info.nightscout.androidaps.plugins.pump.insight.app_layer.history.history_events.TotalDailyDoseEvent;
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.app_layer.history.history_events.TubeFilledEvent;
|
import info.nightscout.androidaps.plugins.pump.insight.app_layer.history.history_events.TubeFilledEvent;
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.app_layer.parameter_blocks.BRProfile1Block;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.app_layer.parameter_blocks.BRProfileBlock;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.app_layer.parameter_blocks.FactoryMinBolusAmountBlock;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.app_layer.parameter_blocks.MaxBasalAmountBlock;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.app_layer.parameter_blocks.MaxBolusAmountBlock;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.app_layer.parameter_blocks.TBROverNotificationBlock;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.app_layer.remote_control.CancelBolusMessage;
|
import info.nightscout.androidaps.plugins.pump.insight.app_layer.remote_control.CancelBolusMessage;
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.app_layer.remote_control.CancelTBRMessage;
|
import info.nightscout.androidaps.plugins.pump.insight.app_layer.remote_control.CancelTBRMessage;
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.app_layer.remote_control.ChangeTBRMessage;
|
import info.nightscout.androidaps.plugins.pump.insight.app_layer.remote_control.ChangeTBRMessage;
|
||||||
|
@ -98,18 +94,6 @@ import info.nightscout.androidaps.plugins.pump.insight.connection_service.Insigh
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.database.InsightBolusID;
|
import info.nightscout.androidaps.plugins.pump.insight.database.InsightBolusID;
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.database.InsightHistoryOffset;
|
import info.nightscout.androidaps.plugins.pump.insight.database.InsightHistoryOffset;
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.database.InsightPumpID;
|
import info.nightscout.androidaps.plugins.pump.insight.database.InsightPumpID;
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.descriptors.ActiveBasalRate;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.descriptors.ActiveBolus;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.descriptors.ActiveTBR;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.descriptors.AlertType;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.descriptors.BasalProfileBlock;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.descriptors.BatteryStatus;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.descriptors.BolusType;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.descriptors.CartridgeStatus;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.descriptors.InsightState;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.descriptors.OperatingMode;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.descriptors.PumpTime;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.descriptors.TotalDailyDose;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.exceptions.InsightException;
|
import info.nightscout.androidaps.plugins.pump.insight.exceptions.InsightException;
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.exceptions.app_layer_errors.AppLayerErrorException;
|
import info.nightscout.androidaps.plugins.pump.insight.exceptions.app_layer_errors.AppLayerErrorException;
|
||||||
import info.nightscout.androidaps.plugins.pump.insight.exceptions.app_layer_errors.NoActiveTBRToCanceLException;
|
import info.nightscout.androidaps.plugins.pump.insight.exceptions.app_layer_errors.NoActiveTBRToCanceLException;
|
||||||
|
@ -152,6 +136,7 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
||||||
private final Object $bolusLock = new Object[0];
|
private final Object $bolusLock = new Object[0];
|
||||||
private int bolusID;
|
private int bolusID;
|
||||||
private boolean bolusCancelled;
|
private boolean bolusCancelled;
|
||||||
|
private BasalProfile activeBasalProfile;
|
||||||
private List<BasalProfileBlock> profileBlocks;
|
private List<BasalProfileBlock> profileBlocks;
|
||||||
private boolean limitsFetched;
|
private boolean limitsFetched;
|
||||||
private double maximumBolusAmount;
|
private double maximumBolusAmount;
|
||||||
|
@ -345,6 +330,7 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fetchBasalProfile() throws Exception {
|
private void fetchBasalProfile() throws Exception {
|
||||||
|
activeBasalProfile = ParameterBlockUtil.readParameterBlock(connectionService, Service.CONFIGURATION, ActiveBRProfileBlock.class).getActiveBasalProfile();
|
||||||
profileBlocks = ParameterBlockUtil.readParameterBlock(connectionService, Service.CONFIGURATION, BRProfile1Block.class).getProfileBlocks();
|
profileBlocks = ParameterBlockUtil.readParameterBlock(connectionService, Service.CONFIGURATION, BRProfile1Block.class).getProfileBlocks();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -438,6 +424,10 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
||||||
profileBlocks.add(profileBlock);
|
profileBlocks.add(profileBlock);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
ActiveBRProfileBlock activeBRProfileBlock = new ActiveBRProfileBlock();
|
||||||
|
activeBRProfileBlock.setActiveBasalProfile(BasalProfile.PROFILE_1);
|
||||||
|
ParameterBlockUtil.writeConfigurationBlock(connectionService, activeBRProfileBlock);
|
||||||
|
activeBasalProfile = BasalProfile.PROFILE_1;
|
||||||
BRProfileBlock profileBlock = new BRProfile1Block();
|
BRProfileBlock profileBlock = new BRProfile1Block();
|
||||||
profileBlock.setProfileBlocks(profileBlocks);
|
profileBlock.setProfileBlocks(profileBlocks);
|
||||||
ParameterBlockUtil.writeConfigurationBlock(connectionService, profileBlock);
|
ParameterBlockUtil.writeConfigurationBlock(connectionService, profileBlock);
|
||||||
|
@ -475,6 +465,7 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
||||||
public boolean isThisProfileSet(Profile profile) {
|
public boolean isThisProfileSet(Profile profile) {
|
||||||
if (!isInitialized() || profileBlocks == null) return true;
|
if (!isInitialized() || profileBlocks == null) return true;
|
||||||
if (profile.getBasalValues().length != profileBlocks.size()) return false;
|
if (profile.getBasalValues().length != profileBlocks.size()) return false;
|
||||||
|
if (activeBasalProfile != BasalProfile.PROFILE_1) return false;
|
||||||
for (int i = 0; i < profileBlocks.size(); i++) {
|
for (int i = 0; i < profileBlocks.size(); i++) {
|
||||||
BasalProfileBlock profileBlock = profileBlocks.get(i);
|
BasalProfileBlock profileBlock = profileBlocks.get(i);
|
||||||
Profile.BasalValue basalValue = profile.getBasalValues()[i];
|
Profile.BasalValue basalValue = profile.getBasalValues()[i];
|
||||||
|
|
|
@ -1,57 +1,60 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<Preference android:title="@string/insight_pairing">
|
<PreferenceCategory android:title="@string/insight_local">
|
||||||
<intent
|
|
||||||
android:targetClass="info.nightscout.androidaps.plugins.pump.insight.activities.InsightPairingInformationActivity"
|
|
||||||
android:targetPackage="info.nightscout.androidaps" />
|
|
||||||
</Preference>
|
|
||||||
|
|
||||||
<SwitchPreference
|
<Preference android:title="@string/insight_pairing">
|
||||||
android:defaultValue="false"
|
<intent
|
||||||
android:key="insight_log_site_changes"
|
android:targetClass="info.nightscout.androidaps.plugins.pump.insight.activities.InsightPairingInformationActivity"
|
||||||
android:title="@string/log_site_changes" />
|
android:targetPackage="info.nightscout.androidaps" />
|
||||||
|
</Preference>
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="insight_log_tube_changes"
|
android:key="insight_log_site_changes"
|
||||||
android:title="@string/log_tube_changes" />
|
android:title="@string/log_site_changes" />
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="insight_log_battery_changes"
|
android:key="insight_log_tube_changes"
|
||||||
android:title="@string/log_battery_changes" />
|
android:title="@string/log_tube_changes" />
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="insight_log_operating_mode_changes"
|
android:key="insight_log_battery_changes"
|
||||||
android:title="@string/log_operating_mode_changes" />
|
android:title="@string/log_battery_changes" />
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="insight_log_alerts"
|
android:key="insight_log_operating_mode_changes"
|
||||||
android:title="@string/log_alerts" />
|
android:title="@string/log_operating_mode_changes" />
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="insight_enable_tbr_emulation"
|
android:key="insight_log_alerts"
|
||||||
android:summary="@string/enable_tbr_emulation_summary"
|
android:title="@string/log_alerts" />
|
||||||
android:title="@string/enable_tbr_emulation" />
|
|
||||||
|
|
||||||
<EditTextPreference
|
<SwitchPreference
|
||||||
android:defaultValue="5"
|
android:defaultValue="false"
|
||||||
android:inputType="number"
|
android:key="insight_enable_tbr_emulation"
|
||||||
android:key="insight_min_recovery_duration"
|
android:summary="@string/enable_tbr_emulation_summary"
|
||||||
android:title="@string/min_recovery_duration" />
|
android:title="@string/enable_tbr_emulation" />
|
||||||
|
|
||||||
<EditTextPreference
|
<EditTextPreference
|
||||||
android:defaultValue="20"
|
android:defaultValue="5"
|
||||||
android:inputType="number"
|
android:inputType="number"
|
||||||
android:key="insight_max_recovery_duration"
|
android:key="insight_min_recovery_duration"
|
||||||
android:title="@string/max_recovery_duration" />
|
android:title="@string/min_recovery_duration" />
|
||||||
|
|
||||||
<EditTextPreference
|
<EditTextPreference
|
||||||
android:defaultValue="5"
|
android:defaultValue="20"
|
||||||
android:inputType="number"
|
android:inputType="number"
|
||||||
android:key="insight_disconnect_delay"
|
android:key="insight_max_recovery_duration"
|
||||||
android:title="@string/disconnect_delay" />
|
android:title="@string/max_recovery_duration" />
|
||||||
|
|
||||||
|
<EditTextPreference
|
||||||
|
android:defaultValue="5"
|
||||||
|
android:inputType="number"
|
||||||
|
android:key="insight_disconnect_delay"
|
||||||
|
android:title="@string/disconnect_delay" />
|
||||||
|
</PreferenceCategory>
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|
Loading…
Reference in a new issue