Merge pull request #61 from jotomo/commandQueueblcok

block writing profile if no switch exists
This commit is contained in:
Johannes Mockenhaupt 2018-02-18 02:20:35 +01:00 committed by GitHub
commit 00d02802ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 0 deletions

View file

@ -40,6 +40,7 @@ import info.nightscout.androidaps.interfaces.SensitivityInterface;
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
import info.nightscout.androidaps.plugins.Loop.APSResult;
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
@ -721,6 +722,7 @@ public class ConfigBuilderPlugin implements PluginBase, ConstraintsInterface, Tr
@Override
public void addToHistoryProfileSwitch(ProfileSwitch profileSwitch) {
MainApp.bus().post(new EventDismissNotification(Notification.PROFILE_SWITCH_MISSING));
activeTreatments.addToHistoryProfileSwitch(profileSwitch);
NSUpload.uploadProfileSwitch(profileSwitch);
}

View file

@ -60,6 +60,8 @@ public class Notification {
public static final int MINIMAL_BASAL_VALUE_REPLACED = 29;
public static final int BASAL_PROFILE_NOT_ALIGNED_TO_HOURS = 30;
public static final int ZERO_VALUE_IN_PROFILE = 31;
public static final int PROFILE_SWITCH_MISSING = 32;
public int id;
public Date date;

View file

@ -287,6 +287,17 @@ public class CommandQueue {
return false;
}
// Check that there is a valid profileSwitch NOW
if (MainApp.getConfigBuilder().getProfileSwitchFromHistory(System.currentTimeMillis())==null) {
Notification noProfileSwitchNotif = new Notification(Notification.PROFILE_SWITCH_MISSING, MainApp.sResources.getString(R.string.profileswitch_ismissing), Notification.NORMAL);
MainApp.bus().post(new EventNewNotification(noProfileSwitchNotif));
if (callback != null) {
PumpEnactResult result = new PumpEnactResult().success(false).enacted(false).comment("Refuse to send profile to pump! No ProfileSwitch!");
callback.result(result).run();
}
return false;
}
// Compare with pump limits
Profile.BasalValue[] basalValues = profile.getBasalValues();
PumpInterface pump = ConfigBuilderPlugin.getActivePump();

View file

@ -882,5 +882,6 @@
<string name="ns_create_announcements_from_errors_title">Create announcements from errors</string>
<string name="ns_create_announcements_from_errors_summary">Create Nightscout announcement for error dialogs and local alerts (also viewable in Careportal under Treatments)</string>
<string name="combo_suspious_bolus_time">Time/date of the delivered bolus on pump seems wrong, IOB is likely incorrect. Please check pump time/date.</string>
<string name="profileswitch_ismissing">ProfileSwitch missing. Please do a profile switch or press \"Activate Profile\" in the LocalProfile.</string>
</resources>