notify when pump settings is wrong

This commit is contained in:
Milos Kozak 2016-12-13 22:10:13 +01:00
parent 407ea423cb
commit cb4330ddcd
11 changed files with 67 additions and 6 deletions

View file

@ -37,6 +37,8 @@ import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.DanaR.Services.ExecutionService;
import info.nightscout.androidaps.plugins.NSProfileViewer.NSProfileViewerPlugin;
import info.nightscout.androidaps.plugins.Overview.Notification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.client.data.NSProfile;
import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter;
@ -195,7 +197,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
@Override
public boolean isInitialized() {
return getDanaRPump().lastConnection.getTime() > 0;
return getDanaRPump().lastConnection.getTime() > 0 && getDanaRPump().isExtendedBolusEnabled;
}
// Pump interface
@ -220,6 +222,12 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
if (sExecutionService == null) {
log.error("setNewBasalProfile sExecutionService is null");
return;
}
if (!isInitialized()) {
log.error("setNewBasalProfile not initialized");
Notification notification = new Notification(Notification.NOT_INITIALIZED, MainApp.sResources.getString(R.string.canceledPumpNotInitialized), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification));
return;
}
if (!sExecutionService.updateBasalsInPump(profile))
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.failedupdatebasalprofile));

View file

@ -310,7 +310,7 @@ public class ExecutionService extends Service {
}
Date now = new Date();
if (danaRPump.lastSettingsRead.getTime() + 60 * 60 * 1000L < now.getTime()) {
if (danaRPump.lastSettingsRead.getTime() + 60 * 60 * 1000L < now.getTime() || !((DanaRPlugin)MainApp.getSpecificPlugin(DanaRPlugin.class)).isInitialized()) {
mSerialIOThread.sendMessage(new MsgSettingShippingInfo());
mSerialIOThread.sendMessage(new MsgSettingActiveProfile());
mSerialIOThread.sendMessage(new MsgSettingMeal());

View file

@ -4,8 +4,12 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.DanaR.DanaRPlugin;
import info.nightscout.androidaps.plugins.DanaR.DanaRPump;
import info.nightscout.androidaps.plugins.Overview.Notification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
/**
* Created by mike on 28.05.2016.
@ -35,5 +39,10 @@ public class MsgInitConnStatusBolus extends MessageBase {
log.debug("Bolus increment: " + pump.bolusStep);
log.debug("Bolus max: " + pump.maxBolus);
}
if (!pump.isExtendedBolusEnabled) {
Notification notification = new Notification(Notification.EXTENDED_BOLUS_DISABLED, MainApp.sResources.getString(R.string.danar_enableextendedbolus), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification));
}
}
}

View file

@ -37,6 +37,8 @@ import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.DanaRKorean.Services.ExecutionService;
import info.nightscout.androidaps.plugins.NSProfileViewer.NSProfileViewerPlugin;
import info.nightscout.androidaps.plugins.Overview.Notification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.client.data.NSProfile;
import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter;
@ -195,7 +197,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
@Override
public boolean isInitialized() {
return getDanaRPump().lastConnection.getTime() > 0;
return getDanaRPump().lastConnection.getTime() > 0 && !getDanaRPump().isConfigUD && !getDanaRPump().isEasyModeEnabled && getDanaRPump().isExtendedBolusEnabled;
}
// Pump interface
@ -221,6 +223,12 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
log.error("setNewBasalProfile sExecutionService is null");
return;
}
if (!isInitialized()) {
log.error("setNewBasalProfile not initialized");
Notification notification = new Notification(Notification.NOT_INITIALIZED, MainApp.sResources.getString(R.string.canceledPumpNotInitialized), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification));
return;
}
if (!sExecutionService.updateBasalsInPump(profile))
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.failedupdatebasalprofile));
}

View file

@ -48,6 +48,7 @@ public class DanaRKoreanPump {
public boolean isConfigUD;
public boolean isExtendedBolusEnabled;
public boolean isEasyModeEnabled;
// Status
public double dailyTotalUnits;

View file

@ -304,7 +304,7 @@ public class ExecutionService extends Service {
}
Date now = new Date();
if (danaRKoreanPump.lastSettingsRead.getTime() + 60 * 60 * 1000L < now.getTime()) {
if (danaRKoreanPump.lastSettingsRead.getTime() + 60 * 60 * 1000L < now.getTime() || !((DanaRKoreanPlugin)MainApp.getSpecificPlugin(DanaRKoreanPlugin.class)).isInitialized()) {
mSerialIOThread.sendMessage(new MsgSettingShippingInfo());
mSerialIOThread.sendMessage(new MsgSettingMeal());
mSerialIOThread.sendMessage(new MsgSettingBasal());

View file

@ -4,9 +4,13 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.DanaR.comm.MessageBase;
import info.nightscout.androidaps.plugins.DanaRKorean.DanaRKoreanPlugin;
import info.nightscout.androidaps.plugins.DanaRKorean.DanaRKoreanPump;
import info.nightscout.androidaps.plugins.Overview.Notification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
public class MsgInitConnStatusBasic extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgInitConnStatusBasic.class);
@ -23,15 +27,20 @@ public class MsgInitConnStatusBasic extends MessageBase {
DanaRKoreanPump pump = DanaRKoreanPlugin.getDanaRPump();
int isStatusSuspendOn = intFromBuff(bytes, 0, 1);
int isUtilityEnable = intFromBuff(bytes, 1, 1);
int isEasyUIEnable = intFromBuff(bytes, 2, 1);
pump.isEasyModeEnabled = intFromBuff(bytes, 2, 1) == 1;
int easyUIMode = intFromBuff(bytes, 3, 1);
pump.password = intFromBuff(bytes, 4, 2) ^ 0x3463;
if (Config.logDanaMessageDetail) {
log.debug("isStatusSuspendOn: " + isStatusSuspendOn);
log.debug("isUtilityEnable: " + isUtilityEnable);
log.debug("isEasyUIEnable: " + isEasyUIEnable);
log.debug("Is EasyUI Enabled: " + pump.isEasyModeEnabled);
log.debug("easyUIMode: " + easyUIMode);
log.debug("Pump password: " + pump.password);
}
if (pump.isEasyModeEnabled) {
Notification notification = new Notification(Notification.EASYMODE_ENABLED, MainApp.sResources.getString(R.string.danar_disableeasymode), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification));
}
}
}

View file

@ -4,9 +4,13 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.DanaR.comm.MessageBase;
import info.nightscout.androidaps.plugins.DanaRKorean.DanaRKoreanPlugin;
import info.nightscout.androidaps.plugins.DanaRKorean.DanaRKoreanPump;
import info.nightscout.androidaps.plugins.Overview.Notification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
/**
* Created by mike on 28.05.2016.
@ -38,5 +42,10 @@ public class MsgInitConnStatusBolus extends MessageBase {
log.debug("Bolus max: " + pump.maxBolus);
log.debug("Delivery status: " + deliveryStatus);
}
if (!pump.isExtendedBolusEnabled) {
Notification notification = new Notification(Notification.EXTENDED_BOLUS_DISABLED, MainApp.sResources.getString(R.string.danar_enableextendedbolus), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification));
}
}
}

View file

@ -4,9 +4,13 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.DanaR.DanaRPlugin;
import info.nightscout.androidaps.plugins.DanaR.DanaRPump;
import info.nightscout.androidaps.plugins.DanaR.comm.MessageBase;
import info.nightscout.androidaps.plugins.Overview.Notification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
/**
* Created by mike on 13.12.2016.
@ -36,6 +40,11 @@ public class MsgSettingMeal extends MessageBase {
log.debug("Block time: " + blockTime);
log.debug("Is Config U/d: " + pump.isConfigUD);
}
if (pump.isConfigUD) {
Notification notification = new Notification(Notification.UD_MODE_ENABLED, MainApp.sResources.getString(R.string.danar_switchtouhmode), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification));
}
}
}

View file

@ -14,6 +14,10 @@ public class Notification {
public static final int PROFILE_SET_FAILED = 0;
public static final int PROFILE_SET_OK = 1;
public static final int EASYMODE_ENABLED = 2;
public static final int EXTENDED_BOLUS_DISABLED = 3;
public static final int UD_MODE_ENABLED = 4;
public static final int NOT_INITIALIZED = 5;
public int id;
public Date date;

View file

@ -340,6 +340,7 @@
<string name="ns_upload_only_summary">NS upload only. Not effective on SGV unless a local source like xDrip is selected. Not effective on Profiles while NS-Profiles is used.</string>
<string name="ns_upload_only_enabled">Please deactivate "NS upload only" to use this feature.</string>
<string name="pumpNotInitialized">Pump not initialized!</string>
<string name="canceledPumpNotInitialized">Canceled. Pump not initialized!</string>
<string name="primefill">Prime/Fill</string>
<string name="fillwarning">Please make sure the amount matches the specification of your infusion set!</string>
<string name="othersettings_title">Other</string>
@ -379,4 +380,7 @@
<string name="basal_rate">Basal rate:</string>
<string name="profile_set_failed">Setting of basal profile failed</string>
<string name="profile_set_ok">Basal profile in pump updated</string>
<string name="danar_disableeasymode">Disable EasyUI mode in pump</string>
<string name="danar_enableextendedbolus">Enable extended boluses on pump</string>
<string name="danar_switchtouhmode">Change mode from U/d to U/h on pump</string>
</resources>