Merge pull request #1676 from TebbeUbben/dev
Insight: Enforce using first profile
This commit is contained in:
commit
cc3b50c12d
|
@ -8,6 +8,8 @@ import android.os.Handler;
|
|||
import android.os.IBinder;
|
||||
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.JSONObject;
|
||||
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.TotalDailyDoseEvent;
|
||||
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.CancelTBRMessage;
|
||||
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.InsightHistoryOffset;
|
||||
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.app_layer_errors.AppLayerErrorException;
|
||||
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 int bolusID;
|
||||
private boolean bolusCancelled;
|
||||
private BasalProfile activeBasalProfile;
|
||||
private List<BasalProfileBlock> profileBlocks;
|
||||
private boolean limitsFetched;
|
||||
private double maximumBolusAmount;
|
||||
|
@ -345,6 +330,7 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
|||
}
|
||||
|
||||
private void fetchBasalProfile() throws Exception {
|
||||
activeBasalProfile = ParameterBlockUtil.readParameterBlock(connectionService, Service.CONFIGURATION, ActiveBRProfileBlock.class).getActiveBasalProfile();
|
||||
profileBlocks = ParameterBlockUtil.readParameterBlock(connectionService, Service.CONFIGURATION, BRProfile1Block.class).getProfileBlocks();
|
||||
}
|
||||
|
||||
|
@ -438,6 +424,10 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
|||
profileBlocks.add(profileBlock);
|
||||
}
|
||||
try {
|
||||
ActiveBRProfileBlock activeBRProfileBlock = new ActiveBRProfileBlock();
|
||||
activeBRProfileBlock.setActiveBasalProfile(BasalProfile.PROFILE_1);
|
||||
ParameterBlockUtil.writeConfigurationBlock(connectionService, activeBRProfileBlock);
|
||||
activeBasalProfile = BasalProfile.PROFILE_1;
|
||||
BRProfileBlock profileBlock = new BRProfile1Block();
|
||||
profileBlock.setProfileBlocks(profileBlocks);
|
||||
ParameterBlockUtil.writeConfigurationBlock(connectionService, profileBlock);
|
||||
|
@ -475,6 +465,7 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
|||
public boolean isThisProfileSet(Profile profile) {
|
||||
if (!isInitialized() || profileBlocks == null) return true;
|
||||
if (profile.getBasalValues().length != profileBlocks.size()) return false;
|
||||
if (activeBasalProfile != BasalProfile.PROFILE_1) return false;
|
||||
for (int i = 0; i < profileBlocks.size(); i++) {
|
||||
BasalProfileBlock profileBlock = profileBlocks.get(i);
|
||||
Profile.BasalValue basalValue = profile.getBasalValues()[i];
|
||||
|
|
|
@ -1,57 +1,60 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<Preference android:title="@string/insight_pairing">
|
||||
<intent
|
||||
android:targetClass="info.nightscout.androidaps.plugins.pump.insight.activities.InsightPairingInformationActivity"
|
||||
android:targetPackage="info.nightscout.androidaps" />
|
||||
</Preference>
|
||||
<PreferenceCategory android:title="@string/insight_local">
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="insight_log_site_changes"
|
||||
android:title="@string/log_site_changes" />
|
||||
<Preference android:title="@string/insight_pairing">
|
||||
<intent
|
||||
android:targetClass="info.nightscout.androidaps.plugins.pump.insight.activities.InsightPairingInformationActivity"
|
||||
android:targetPackage="info.nightscout.androidaps" />
|
||||
</Preference>
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="insight_log_tube_changes"
|
||||
android:title="@string/log_tube_changes" />
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="insight_log_site_changes"
|
||||
android:title="@string/log_site_changes" />
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="insight_log_battery_changes"
|
||||
android:title="@string/log_battery_changes" />
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="insight_log_tube_changes"
|
||||
android:title="@string/log_tube_changes" />
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="insight_log_operating_mode_changes"
|
||||
android:title="@string/log_operating_mode_changes" />
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="insight_log_battery_changes"
|
||||
android:title="@string/log_battery_changes" />
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="insight_log_alerts"
|
||||
android:title="@string/log_alerts" />
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="insight_log_operating_mode_changes"
|
||||
android:title="@string/log_operating_mode_changes" />
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="insight_enable_tbr_emulation"
|
||||
android:summary="@string/enable_tbr_emulation_summary"
|
||||
android:title="@string/enable_tbr_emulation" />
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="insight_log_alerts"
|
||||
android:title="@string/log_alerts" />
|
||||
|
||||
<EditTextPreference
|
||||
android:defaultValue="5"
|
||||
android:inputType="number"
|
||||
android:key="insight_min_recovery_duration"
|
||||
android:title="@string/min_recovery_duration" />
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="insight_enable_tbr_emulation"
|
||||
android:summary="@string/enable_tbr_emulation_summary"
|
||||
android:title="@string/enable_tbr_emulation" />
|
||||
|
||||
<EditTextPreference
|
||||
android:defaultValue="20"
|
||||
android:inputType="number"
|
||||
android:key="insight_max_recovery_duration"
|
||||
android:title="@string/max_recovery_duration" />
|
||||
<EditTextPreference
|
||||
android:defaultValue="5"
|
||||
android:inputType="number"
|
||||
android:key="insight_min_recovery_duration"
|
||||
android:title="@string/min_recovery_duration" />
|
||||
|
||||
<EditTextPreference
|
||||
android:defaultValue="5"
|
||||
android:inputType="number"
|
||||
android:key="insight_disconnect_delay"
|
||||
android:title="@string/disconnect_delay" />
|
||||
<EditTextPreference
|
||||
android:defaultValue="20"
|
||||
android:inputType="number"
|
||||
android:key="insight_max_recovery_duration"
|
||||
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>
|
||||
|
|
Loading…
Reference in a new issue