use notifications for profile update
This commit is contained in:
parent
132f82b484
commit
7719e2ac63
|
@ -38,6 +38,7 @@ 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.EventDismissNotification;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||
import info.nightscout.client.data.NSProfile;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
|
@ -223,14 +224,21 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
|||
log.error("setNewBasalProfile sExecutionService is null");
|
||||
return;
|
||||
}
|
||||
if (!isInitialized()) {
|
||||
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));
|
||||
Notification notification = new Notification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED, MainApp.sResources.getString(R.string.pumpNotInitializedProfileNotSet), Notification.URGENT);
|
||||
MainApp.bus().post(new EventNewNotification(notification));
|
||||
return;
|
||||
} else {
|
||||
MainApp.bus().post(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED));
|
||||
}
|
||||
if (!sExecutionService.updateBasalsInPump(profile)) {
|
||||
Notification notification = new Notification(Notification.FAILED_UDPATE_PROFILE, MainApp.sResources.getString(R.string.failedupdatebasalprofile), Notification.URGENT);
|
||||
MainApp.bus().post(new EventNewNotification(notification));
|
||||
} else {
|
||||
MainApp.bus().post(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED));
|
||||
MainApp.bus().post(new EventDismissNotification(Notification.FAILED_UDPATE_PROFILE));
|
||||
}
|
||||
if (!sExecutionService.updateBasalsInPump(profile))
|
||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.failedupdatebasalprofile));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -38,6 +38,7 @@ 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.EventDismissNotification;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||
import info.nightscout.client.data.NSProfile;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
|
@ -225,12 +226,19 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
|
|||
}
|
||||
if (!isInitialized()) {
|
||||
log.error("setNewBasalProfile not initialized");
|
||||
Notification notification = new Notification(Notification.NOT_INITIALIZED, MainApp.sResources.getString(R.string.canceledPumpNotInitialized), Notification.URGENT);
|
||||
Notification notification = new Notification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED, MainApp.sResources.getString(R.string.pumpNotInitializedProfileNotSet), Notification.URGENT);
|
||||
MainApp.bus().post(new EventNewNotification(notification));
|
||||
return;
|
||||
} else {
|
||||
MainApp.bus().post(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED));
|
||||
}
|
||||
if (!sExecutionService.updateBasalsInPump(profile)) {
|
||||
Notification notification = new Notification(Notification.FAILED_UDPATE_PROFILE, MainApp.sResources.getString(R.string.failedupdatebasalprofile), Notification.URGENT);
|
||||
MainApp.bus().post(new EventNewNotification(notification));
|
||||
} else {
|
||||
MainApp.bus().post(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED));
|
||||
MainApp.bus().post(new EventDismissNotification(Notification.FAILED_UDPATE_PROFILE));
|
||||
}
|
||||
if (!sExecutionService.updateBasalsInPump(profile))
|
||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.failedupdatebasalprofile));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,7 +17,8 @@ public class Notification {
|
|||
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 static final int PROFILE_NOT_SET_NOT_INITIALIZED = 5;
|
||||
public static final int FAILED_UDPATE_PROFILE = 6;
|
||||
|
||||
public int id;
|
||||
public Date date;
|
||||
|
|
|
@ -340,7 +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="pumpNotInitializedProfileNotSet">Pump not initialized, profile not set!</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>
|
||||
|
|
Loading…
Reference in a new issue