Some Actions
This commit is contained in:
parent
2bf07eb0d4
commit
efec01c6e5
37 changed files with 344 additions and 54 deletions
|
@ -48,6 +48,11 @@ public class PumpEnactResult {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PumpEnactResult comment(int comment) {
|
||||||
|
this.comment = MainApp.gs(comment);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public PumpEnactResult duration(int duration) {
|
public PumpEnactResult duration(int duration) {
|
||||||
this.duration = duration;
|
this.duration = duration;
|
||||||
return this;
|
return this;
|
||||||
|
|
|
@ -421,7 +421,7 @@ public class Connector {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lastStatus == null) {
|
if (lastStatus == null) {
|
||||||
return MainApp.gs(R.string.insight_unknown);
|
return MainApp.gs(R.string.unknown);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (lastStatus) {
|
switch (lastStatus) {
|
||||||
|
|
|
@ -242,6 +242,7 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
||||||
LoopPlugin loopPlugin = MainApp.getSpecificPlugin(LoopPlugin.class);
|
LoopPlugin loopPlugin = MainApp.getSpecificPlugin(LoopPlugin.class);
|
||||||
if (loopPlugin != null && loopPlugin.isEnabled(PluginType.LOOP)) {
|
if (loopPlugin != null && loopPlugin.isEnabled(PluginType.LOOP)) {
|
||||||
loopPlugin.setPluginEnabled(PluginType.LOOP, false);
|
loopPlugin.setPluginEnabled(PluginType.LOOP, false);
|
||||||
|
ConfigBuilderPlugin.getPlugin().storeSettings("SMS_LOOP_STOP");
|
||||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().cancelTempBasal(true, new Callback() {
|
ConfigBuilderPlugin.getPlugin().getCommandQueue().cancelTempBasal(true, new Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -260,6 +261,7 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
||||||
loopPlugin = MainApp.getSpecificPlugin(LoopPlugin.class);
|
loopPlugin = MainApp.getSpecificPlugin(LoopPlugin.class);
|
||||||
if (loopPlugin != null && !loopPlugin.isEnabled(PluginType.LOOP)) {
|
if (loopPlugin != null && !loopPlugin.isEnabled(PluginType.LOOP)) {
|
||||||
loopPlugin.setPluginEnabled(PluginType.LOOP, true);
|
loopPlugin.setPluginEnabled(PluginType.LOOP, true);
|
||||||
|
ConfigBuilderPlugin.getPlugin().storeSettings("SMS_LOOP_START");
|
||||||
reply = MainApp.gs(R.string.smscommunicator_loophasbeenenabled);
|
reply = MainApp.gs(R.string.smscommunicator_loophasbeenenabled);
|
||||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, System.currentTimeMillis()));
|
sendSMS(new Sms(receivedSms.phoneNumber, reply, System.currentTimeMillis()));
|
||||||
MainApp.bus().post(new EventRefreshOverview("SMS_LOOP_START"));
|
MainApp.bus().post(new EventRefreshOverview("SMS_LOOP_START"));
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
package info.nightscout.androidaps.plugins.general.automation;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.plugins.general.automation.actions.Action;
|
||||||
|
import info.nightscout.androidaps.plugins.general.automation.triggers.Trigger;
|
||||||
|
|
||||||
|
public class AutomationEvent {
|
||||||
|
|
||||||
|
Trigger trigger;
|
||||||
|
List<Action> actions = new ArrayList<>();
|
||||||
|
|
||||||
|
AutomationEvent() {
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,7 +19,7 @@ public class AutomationPlugin extends PluginBase {
|
||||||
return plugin;
|
return plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Action> actions = new ArrayList<>();
|
List<AutomationEvent> automationEvents = new ArrayList<>();
|
||||||
|
|
||||||
private AutomationPlugin() {
|
private AutomationPlugin() {
|
||||||
super(new PluginDescription()
|
super(new PluginDescription()
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
package info.nightscout.androidaps.plugins.general.automation.actions;
|
package info.nightscout.androidaps.plugins.general.automation.actions;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.queue.Callback;
|
||||||
|
|
||||||
public abstract class Action {
|
public abstract class Action {
|
||||||
|
|
||||||
abstract void doAction();
|
abstract int friendlyName();
|
||||||
|
abstract void doAction(Callback callback);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
package info.nightscout.androidaps.plugins.general.automation.actions;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
|
import info.nightscout.androidaps.events.EventRefreshOverview;
|
||||||
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||||
|
import info.nightscout.androidaps.queue.Callback;
|
||||||
|
|
||||||
|
public class ActionLoopDisable extends Action {
|
||||||
|
@Override
|
||||||
|
int friendlyName() {
|
||||||
|
return R.string.disableloop;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void doAction(Callback callback) {
|
||||||
|
if (LoopPlugin.getPlugin().isEnabled(PluginType.LOOP)) {
|
||||||
|
LoopPlugin.getPlugin().setPluginEnabled(PluginType.LOOP, false);
|
||||||
|
ConfigBuilderPlugin.getPlugin().storeSettings("ActionLoopDisable");
|
||||||
|
ConfigBuilderPlugin.getPlugin().getCommandQueue().cancelTempBasal(true, new Callback() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
MainApp.bus().post(new EventRefreshOverview("ActionLoopDisable"));
|
||||||
|
if (callback != null)
|
||||||
|
callback.result(result).run();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
if (callback != null)
|
||||||
|
callback.result(new PumpEnactResult().success(true).comment(R.string.alreadydisabled)).run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
package info.nightscout.androidaps.plugins.general.automation.actions;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
|
import info.nightscout.androidaps.events.EventRefreshOverview;
|
||||||
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||||
|
import info.nightscout.androidaps.queue.Callback;
|
||||||
|
|
||||||
|
public class ActionLoopEnable extends Action {
|
||||||
|
@Override
|
||||||
|
int friendlyName() {
|
||||||
|
return R.string.enableloop;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void doAction(Callback callback) {
|
||||||
|
if (!LoopPlugin.getPlugin().isEnabled(PluginType.LOOP)) {
|
||||||
|
LoopPlugin.getPlugin().setPluginEnabled(PluginType.LOOP, true);
|
||||||
|
ConfigBuilderPlugin.getPlugin().storeSettings("ActionLoopEnable");
|
||||||
|
MainApp.bus().post(new EventRefreshOverview("ActionLoopEnable"));
|
||||||
|
if (callback != null)
|
||||||
|
callback.result(new PumpEnactResult().success(true).comment(R.string.ok)).run();
|
||||||
|
} else {
|
||||||
|
if (callback != null)
|
||||||
|
callback.result(new PumpEnactResult().success(true).comment(R.string.alreadyenabled)).run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
package info.nightscout.androidaps.plugins.general.automation.actions;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
|
import info.nightscout.androidaps.events.EventRefreshOverview;
|
||||||
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
|
||||||
|
import info.nightscout.androidaps.queue.Callback;
|
||||||
|
|
||||||
|
public class ActionLoopResume extends Action {
|
||||||
|
@Override
|
||||||
|
int friendlyName() {
|
||||||
|
return R.string.resumeloop;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void doAction(Callback callback) {
|
||||||
|
if (LoopPlugin.getPlugin().isSuspended()) {
|
||||||
|
LoopPlugin.getPlugin().suspendTo(0);
|
||||||
|
ConfigBuilderPlugin.getPlugin().storeSettings("ActionLoopResume");
|
||||||
|
NSUpload.uploadOpenAPSOffline(0);
|
||||||
|
MainApp.bus().post(new EventRefreshOverview("ActionLoopResume"));
|
||||||
|
if (callback != null)
|
||||||
|
callback.result(new PumpEnactResult().success(true).comment(R.string.ok)).run();
|
||||||
|
} else {
|
||||||
|
if (callback != null)
|
||||||
|
callback.result(new PumpEnactResult().success(true).comment(R.string.notsuspended)).run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
package info.nightscout.androidaps.plugins.general.automation.actions;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
|
import info.nightscout.androidaps.events.EventRefreshOverview;
|
||||||
|
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||||
|
import info.nightscout.androidaps.queue.Callback;
|
||||||
|
|
||||||
|
public class ActionLoopSuspend extends Action {
|
||||||
|
int minutes;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
int friendlyName() {
|
||||||
|
return R.string.disableloop;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void doAction(Callback callback) {
|
||||||
|
if (!LoopPlugin.getPlugin().isSuspended()) {
|
||||||
|
LoopPlugin.getPlugin().suspendLoop(minutes);
|
||||||
|
MainApp.bus().post(new EventRefreshOverview("ActionLoopSuspend"));
|
||||||
|
if (callback != null)
|
||||||
|
callback.result(new PumpEnactResult().success(true).comment(R.string.ok)).run();
|
||||||
|
} else {
|
||||||
|
if (callback != null)
|
||||||
|
callback.result(new PumpEnactResult().success(true).comment(R.string.alreadysuspended)).run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
package info.nightscout.androidaps.plugins.general.automation.actions;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.Constants;
|
||||||
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.data.Profile;
|
||||||
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
|
import info.nightscout.androidaps.db.Source;
|
||||||
|
import info.nightscout.androidaps.db.TempTarget;
|
||||||
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
|
import info.nightscout.androidaps.queue.Callback;
|
||||||
|
import info.nightscout.utils.DateUtil;
|
||||||
|
|
||||||
|
public class ActionStartTempTarget extends Action {
|
||||||
|
|
||||||
|
double value;
|
||||||
|
int durationInMinutes;
|
||||||
|
String reason;
|
||||||
|
String units = Constants.MGDL;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
int friendlyName() {
|
||||||
|
return R.string.starttemptarget;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void doAction(Callback callback) {
|
||||||
|
double converted = Profile.toMgdl(value, units);
|
||||||
|
TempTarget tempTarget = new TempTarget().date(DateUtil.now()).duration(durationInMinutes).reason(reason).source(Source.USER).low(converted).high(converted);
|
||||||
|
TreatmentsPlugin.getPlugin().addToHistoryTempTarget(tempTarget);
|
||||||
|
if (callback != null)
|
||||||
|
callback.result(new PumpEnactResult().success(true).comment(R.string.ok)).run();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,13 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.general.automation.actions;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class AutomationEvent {
|
|
||||||
|
|
||||||
Trigger trigger;
|
|
||||||
List<Action> actions = new ArrayList<>();
|
|
||||||
|
|
||||||
AutomationEvent() {
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,9 +1,11 @@
|
||||||
package info.nightscout.androidaps.plugins.general.automation.actions;
|
package info.nightscout.androidaps.plugins.general.automation.triggers;
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
abstract class Trigger {
|
import info.nightscout.androidaps.R;
|
||||||
|
|
||||||
|
public abstract class Trigger {
|
||||||
|
|
||||||
protected static final int ISLOWER = -2;
|
protected static final int ISLOWER = -2;
|
||||||
protected static final int ISEQUALORLOWER = -1;
|
protected static final int ISEQUALORLOWER = -1;
|
||||||
|
@ -11,7 +13,7 @@ abstract class Trigger {
|
||||||
protected static final int ISEQUALORGREATER = 1;
|
protected static final int ISEQUALORGREATER = 1;
|
||||||
protected static final int ISGREATER = 2;
|
protected static final int ISGREATER = 2;
|
||||||
|
|
||||||
protected static final int NOTAVAILABLE = 10;
|
protected static final int ISNOTAVAILABLE = 10;
|
||||||
|
|
||||||
Trigger() {
|
Trigger() {
|
||||||
}
|
}
|
||||||
|
@ -22,6 +24,10 @@ abstract class Trigger {
|
||||||
|
|
||||||
abstract Trigger fromJSON(String data);
|
abstract Trigger fromJSON(String data);
|
||||||
|
|
||||||
|
abstract int friendlyName();
|
||||||
|
|
||||||
|
abstract String friendlyDescription();
|
||||||
|
|
||||||
void notifyAboutRun(long time) {
|
void notifyAboutRun(long time) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,4 +44,21 @@ abstract class Trigger {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int toComparatorString(int comparator) {
|
||||||
|
switch (comparator) {
|
||||||
|
case ISLOWER:
|
||||||
|
return R.string.islower;
|
||||||
|
case ISEQUALORLOWER:
|
||||||
|
return R.string.isequalorlower;
|
||||||
|
case ISEQUAL:
|
||||||
|
return R.string.isequal;
|
||||||
|
case ISEQUALORGREATER:
|
||||||
|
return R.string.isequalorgreater;
|
||||||
|
case ISGREATER:
|
||||||
|
return R.string.isgreater;
|
||||||
|
case ISNOTAVAILABLE:
|
||||||
|
return R.string.isnotavailable;
|
||||||
|
}
|
||||||
|
return R.string.unknown;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.plugins.general.automation.actions;
|
package info.nightscout.androidaps.plugins.general.automation.triggers;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
|
@ -7,6 +7,8 @@ import org.json.JSONObject;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.R;
|
||||||
|
|
||||||
public class TriggerAnd extends Trigger {
|
public class TriggerAnd extends Trigger {
|
||||||
|
|
||||||
private List<Trigger> list = new ArrayList<>();
|
private List<Trigger> list = new ArrayList<>();
|
||||||
|
@ -51,6 +53,22 @@ public class TriggerAnd extends Trigger {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
int friendlyName() {
|
||||||
|
return R.string.and;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
String friendlyDescription() {
|
||||||
|
int counter = 0;
|
||||||
|
StringBuilder result = new StringBuilder();
|
||||||
|
for (Trigger t : list) {
|
||||||
|
if (counter++ > 0) result.append(R.string.and);
|
||||||
|
result.append(t.friendlyDescription());
|
||||||
|
}
|
||||||
|
return result.toString();
|
||||||
|
}
|
||||||
|
|
||||||
synchronized void add(Trigger t) {
|
synchronized void add(Trigger t) {
|
||||||
list.add(t);
|
list.add(t);
|
||||||
}
|
}
|
|
@ -1,8 +1,10 @@
|
||||||
package info.nightscout.androidaps.plugins.general.automation.actions;
|
package info.nightscout.androidaps.plugins.general.automation.triggers;
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.GlucoseStatus;
|
import info.nightscout.androidaps.data.GlucoseStatus;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
||||||
|
@ -18,7 +20,7 @@ public class TriggerBg extends Trigger {
|
||||||
synchronized boolean shouldRun() {
|
synchronized boolean shouldRun() {
|
||||||
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
|
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
|
||||||
|
|
||||||
if (glucoseStatus == null && comparator == NOTAVAILABLE)
|
if (glucoseStatus == null && comparator == ISNOTAVAILABLE)
|
||||||
return true;
|
return true;
|
||||||
if (glucoseStatus == null)
|
if (glucoseStatus == null)
|
||||||
return false;
|
return false;
|
||||||
|
@ -67,6 +69,19 @@ public class TriggerBg extends Trigger {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
int friendlyName() {
|
||||||
|
return R.string.glucose;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
String friendlyDescription() {
|
||||||
|
if (comparator == Trigger.ISNOTAVAILABLE)
|
||||||
|
return MainApp.gs(R.string.glucoseisnotavailable);
|
||||||
|
else
|
||||||
|
return MainApp.gs(R.string.glucosecompared, Trigger.toComparatorString(comparator), threshold, units);
|
||||||
|
}
|
||||||
|
|
||||||
TriggerBg threshold(double threshold) {
|
TriggerBg threshold(double threshold) {
|
||||||
this.threshold = threshold;
|
this.threshold = threshold;
|
||||||
return this;
|
return this;
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.plugins.general.automation.actions;
|
package info.nightscout.androidaps.plugins.general.automation.triggers;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
|
@ -7,6 +7,8 @@ import org.json.JSONObject;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.R;
|
||||||
|
|
||||||
public class TriggerOr extends Trigger {
|
public class TriggerOr extends Trigger {
|
||||||
|
|
||||||
private List<Trigger> list = new ArrayList<>();
|
private List<Trigger> list = new ArrayList<>();
|
||||||
|
@ -51,6 +53,22 @@ public class TriggerOr extends Trigger {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
int friendlyName() {
|
||||||
|
return R.string.or;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
String friendlyDescription() {
|
||||||
|
int counter = 0;
|
||||||
|
StringBuilder result = new StringBuilder();
|
||||||
|
for (Trigger t : list) {
|
||||||
|
if (counter++ > 0) result.append(R.string.or);
|
||||||
|
result.append(t.friendlyDescription());
|
||||||
|
}
|
||||||
|
return result.toString();
|
||||||
|
}
|
||||||
|
|
||||||
synchronized void add(Trigger t) {
|
synchronized void add(Trigger t) {
|
||||||
list.add(t);
|
list.add(t);
|
||||||
}
|
}
|
|
@ -1,10 +1,12 @@
|
||||||
package info.nightscout.androidaps.plugins.general.automation.actions;
|
package info.nightscout.androidaps.plugins.general.automation.triggers;
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.JsonHelper;
|
import info.nightscout.utils.JsonHelper;
|
||||||
import info.nightscout.utils.T;
|
import info.nightscout.utils.T;
|
||||||
|
@ -115,6 +117,21 @@ public class TriggerTime extends Trigger {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
int friendlyName() {
|
||||||
|
return R.string.time;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
String friendlyDescription() {
|
||||||
|
if (recurring) {
|
||||||
|
// TODO
|
||||||
|
return "Every ";
|
||||||
|
} else {
|
||||||
|
return MainApp.gs(R.string.atspecifiedtime, DateUtil.dateAndTimeString(runAt));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void notifyAboutRun(long time) {
|
void notifyAboutRun(long time) {
|
||||||
lastRun = time;
|
lastRun = time;
|
|
@ -796,7 +796,7 @@
|
||||||
<string name="insight_not_connected_to_companion_app">Не е свързан към приложението!</string>
|
<string name="insight_not_connected_to_companion_app">Не е свързан към приложението!</string>
|
||||||
<string name="insight_companion_app_not_installed">Приложението изглежда не е инсталирано!</string>
|
<string name="insight_companion_app_not_installed">Приложението изглежда не е инсталирано!</string>
|
||||||
<string name="insight_incompatible_compantion_app_we_need_version">Несъвместимо приложение, нужна е версия</string>
|
<string name="insight_incompatible_compantion_app_we_need_version">Несъвместимо приложение, нужна е версия</string>
|
||||||
<string name="insight_unknown">Неизвестно</string>
|
<string name="unknown">Неизвестно</string>
|
||||||
<string name="insight_waiting_for_code">Изчаква се потвърждение на кода</string>
|
<string name="insight_waiting_for_code">Изчаква се потвърждение на кода</string>
|
||||||
<string name="insight_code_rejected">Кодът е отхвърлен</string>
|
<string name="insight_code_rejected">Кодът е отхвърлен</string>
|
||||||
<string name="insight_app_binding">Свързване с апликацията</string>
|
<string name="insight_app_binding">Свързване с апликацията</string>
|
||||||
|
|
|
@ -796,7 +796,7 @@
|
||||||
<string name="insight_not_connected_to_companion_app">Nepřipojen k podpůrné aplikaci!</string>
|
<string name="insight_not_connected_to_companion_app">Nepřipojen k podpůrné aplikaci!</string>
|
||||||
<string name="insight_companion_app_not_installed">Podpůrná aplikace patrně není nainstalovaná!</string>
|
<string name="insight_companion_app_not_installed">Podpůrná aplikace patrně není nainstalovaná!</string>
|
||||||
<string name="insight_incompatible_compantion_app_we_need_version">Nekompatibilní podpůrná aplikace, je požadována verze</string>
|
<string name="insight_incompatible_compantion_app_we_need_version">Nekompatibilní podpůrná aplikace, je požadována verze</string>
|
||||||
<string name="insight_unknown">Neznámý</string>
|
<string name="unknown">Neznámý</string>
|
||||||
<string name="insight_waiting_for_code">Čekám na potvrzení kódu</string>
|
<string name="insight_waiting_for_code">Čekám na potvrzení kódu</string>
|
||||||
<string name="insight_code_rejected">Kód odmítnut</string>
|
<string name="insight_code_rejected">Kód odmítnut</string>
|
||||||
<string name="insight_app_binding">Připojování aplikace</string>
|
<string name="insight_app_binding">Připojování aplikace</string>
|
||||||
|
|
|
@ -797,7 +797,7 @@ maxIOB = durchschnittlicher Essensbolus + 3 x maximale Basalrate</string>
|
||||||
<string name="insight_not_connected_to_companion_app">Keine Verbindung zur Begleit-App!</string>
|
<string name="insight_not_connected_to_companion_app">Keine Verbindung zur Begleit-App!</string>
|
||||||
<string name="insight_companion_app_not_installed">Begleit-App scheint nicht installiert zu sein!</string>
|
<string name="insight_companion_app_not_installed">Begleit-App scheint nicht installiert zu sein!</string>
|
||||||
<string name="insight_incompatible_compantion_app_we_need_version">Nicht kompatible Begleit-App, wir benötigen Version</string>
|
<string name="insight_incompatible_compantion_app_we_need_version">Nicht kompatible Begleit-App, wir benötigen Version</string>
|
||||||
<string name="insight_unknown">Unbekannt</string>
|
<string name="unknown">Unbekannt</string>
|
||||||
<string name="insight_waiting_for_code">Warte auf Code-Bestätigung</string>
|
<string name="insight_waiting_for_code">Warte auf Code-Bestätigung</string>
|
||||||
<string name="insight_code_rejected">Code abgelehnt</string>
|
<string name="insight_code_rejected">Code abgelehnt</string>
|
||||||
<string name="insight_app_binding">Verbinden zur App</string>
|
<string name="insight_app_binding">Verbinden zur App</string>
|
||||||
|
|
|
@ -793,7 +793,7 @@
|
||||||
<string name="insight_not_connected_to_companion_app">No conectado a la aplicación companion!</string>
|
<string name="insight_not_connected_to_companion_app">No conectado a la aplicación companion!</string>
|
||||||
<string name="insight_companion_app_not_installed">¡La aplicación Companion no parece estar instalada!</string>
|
<string name="insight_companion_app_not_installed">¡La aplicación Companion no parece estar instalada!</string>
|
||||||
<string name="insight_incompatible_compantion_app_we_need_version">Aplicación Companion incompatible, necesitamos la versión</string>
|
<string name="insight_incompatible_compantion_app_we_need_version">Aplicación Companion incompatible, necesitamos la versión</string>
|
||||||
<string name="insight_unknown">Desconocido</string>
|
<string name="unknown">Desconocido</string>
|
||||||
<string name="insight_waiting_for_code">Esperando código de confirmación</string>
|
<string name="insight_waiting_for_code">Esperando código de confirmación</string>
|
||||||
<string name="insight_code_rejected">Código rechazado</string>
|
<string name="insight_code_rejected">Código rechazado</string>
|
||||||
<string name="insight_app_binding">Vincular con aplicación</string>
|
<string name="insight_app_binding">Vincular con aplicación</string>
|
||||||
|
|
|
@ -755,7 +755,7 @@ L\'ENSEMBLE DES RISQUES LIÉS À LA QUALITÉ ET À LA PERFORMANCE DU PROGRAMME S
|
||||||
<string name="insight_not_connected_to_companion_app">Non connectée à l\'application compagnon</string>
|
<string name="insight_not_connected_to_companion_app">Non connectée à l\'application compagnon</string>
|
||||||
<string name="insight_companion_app_not_installed">L\'application compagnon ne semble pas être installée</string>
|
<string name="insight_companion_app_not_installed">L\'application compagnon ne semble pas être installée</string>
|
||||||
<string name="insight_incompatible_compantion_app_we_need_version">Application compagnon incompatible, besoin d\'une autre version</string>
|
<string name="insight_incompatible_compantion_app_we_need_version">Application compagnon incompatible, besoin d\'une autre version</string>
|
||||||
<string name="insight_unknown">Inconnue</string>
|
<string name="unknown">Inconnue</string>
|
||||||
<string name="insight_waiting_for_code">Attente du code de confirmation</string>
|
<string name="insight_waiting_for_code">Attente du code de confirmation</string>
|
||||||
<string name="insight_code_rejected">Code rejeté</string>
|
<string name="insight_code_rejected">Code rejeté</string>
|
||||||
<string name="insight_app_binding">Liaison avec app</string>
|
<string name="insight_app_binding">Liaison avec app</string>
|
||||||
|
|
|
@ -796,7 +796,7 @@
|
||||||
<string name="insight_not_connected_to_companion_app">Non collegato all\'app!</string>
|
<string name="insight_not_connected_to_companion_app">Non collegato all\'app!</string>
|
||||||
<string name="insight_companion_app_not_installed">Gruppo dell\'app non sembra essere installato!</string>
|
<string name="insight_companion_app_not_installed">Gruppo dell\'app non sembra essere installato!</string>
|
||||||
<string name="insight_incompatible_compantion_app_we_need_version">App incompatibili, abbiamo bisogno di versione</string>
|
<string name="insight_incompatible_compantion_app_we_need_version">App incompatibili, abbiamo bisogno di versione</string>
|
||||||
<string name="insight_unknown">Sconosciuto</string>
|
<string name="unknown">Sconosciuto</string>
|
||||||
<string name="insight_waiting_for_code">In attesa di conferma</string>
|
<string name="insight_waiting_for_code">In attesa di conferma</string>
|
||||||
<string name="insight_code_rejected">Codice rifiutato</string>
|
<string name="insight_code_rejected">Codice rifiutato</string>
|
||||||
<string name="insight_app_binding">App di unione</string>
|
<string name="insight_app_binding">App di unione</string>
|
||||||
|
|
|
@ -796,7 +796,7 @@
|
||||||
<string name="insight_not_connected_to_companion_app">앱에 연결되지 않았습니다.</string>
|
<string name="insight_not_connected_to_companion_app">앱에 연결되지 않았습니다.</string>
|
||||||
<string name="insight_companion_app_not_installed">앱이 설치되지 않았습니다.</string>
|
<string name="insight_companion_app_not_installed">앱이 설치되지 않았습니다.</string>
|
||||||
<string name="insight_incompatible_compantion_app_we_need_version">호환되지 않는 앱입니다. 이 버전이 필요합니다</string>
|
<string name="insight_incompatible_compantion_app_we_need_version">호환되지 않는 앱입니다. 이 버전이 필요합니다</string>
|
||||||
<string name="insight_unknown">알 수 없는</string>
|
<string name="unknown">알 수 없는</string>
|
||||||
<string name="insight_waiting_for_code">코드 승인 대기중</string>
|
<string name="insight_waiting_for_code">코드 승인 대기중</string>
|
||||||
<string name="insight_code_rejected">코드가 거부되었습니다.</string>
|
<string name="insight_code_rejected">코드가 거부되었습니다.</string>
|
||||||
<string name="insight_app_binding">앱 연결중</string>
|
<string name="insight_app_binding">앱 연결중</string>
|
||||||
|
|
|
@ -797,7 +797,7 @@ Stel in en gebruik tijdelijk en standaard tijdelijke streefdoelen (bv. bij sport
|
||||||
<string name="insight_not_connected_to_companion_app">Niet verbonden met de Companion app!</string>
|
<string name="insight_not_connected_to_companion_app">Niet verbonden met de Companion app!</string>
|
||||||
<string name="insight_companion_app_not_installed">Companion app lijkt niet geïnstalleerd!</string>
|
<string name="insight_companion_app_not_installed">Companion app lijkt niet geïnstalleerd!</string>
|
||||||
<string name="insight_incompatible_compantion_app_we_need_version">Incompatiebele Companion app, we hebben deze versie nodig</string>
|
<string name="insight_incompatible_compantion_app_we_need_version">Incompatiebele Companion app, we hebben deze versie nodig</string>
|
||||||
<string name="insight_unknown">Onbekend</string>
|
<string name="unknown">Onbekend</string>
|
||||||
<string name="insight_waiting_for_code">Wacht op confirmatie van code</string>
|
<string name="insight_waiting_for_code">Wacht op confirmatie van code</string>
|
||||||
<string name="insight_code_rejected">Code geweigerd</string>
|
<string name="insight_code_rejected">Code geweigerd</string>
|
||||||
<string name="insight_app_binding">app koppeling</string>
|
<string name="insight_app_binding">app koppeling</string>
|
||||||
|
|
|
@ -797,7 +797,7 @@
|
||||||
<string name="insight_not_connected_to_companion_app">Brak połączenia z aplikacją towarzyszącą!</string>
|
<string name="insight_not_connected_to_companion_app">Brak połączenia z aplikacją towarzyszącą!</string>
|
||||||
<string name="insight_companion_app_not_installed">Aplikacja towarzysząca prawdopodobnie nie jest zainstalowana!</string>
|
<string name="insight_companion_app_not_installed">Aplikacja towarzysząca prawdopodobnie nie jest zainstalowana!</string>
|
||||||
<string name="insight_incompatible_compantion_app_we_need_version">Niezgodna aplikacja towarzysząca, potrzebujemy wersji</string>
|
<string name="insight_incompatible_compantion_app_we_need_version">Niezgodna aplikacja towarzysząca, potrzebujemy wersji</string>
|
||||||
<string name="insight_unknown">Nieznany</string>
|
<string name="unknown">Nieznany</string>
|
||||||
<string name="insight_waiting_for_code">Oczekuję na potwierdzenie kodu</string>
|
<string name="insight_waiting_for_code">Oczekuję na potwierdzenie kodu</string>
|
||||||
<string name="insight_code_rejected">Kod odrzucony</string>
|
<string name="insight_code_rejected">Kod odrzucony</string>
|
||||||
<string name="insight_app_binding">Wiązanie aplikacji</string>
|
<string name="insight_app_binding">Wiązanie aplikacji</string>
|
||||||
|
|
|
@ -796,7 +796,7 @@
|
||||||
<string name="insight_not_connected_to_companion_app">Nãp conectado com a aplicação acompanhante!</string>
|
<string name="insight_not_connected_to_companion_app">Nãp conectado com a aplicação acompanhante!</string>
|
||||||
<string name="insight_companion_app_not_installed">Aplicação acompanhante aparentemente não instalada!</string>
|
<string name="insight_companion_app_not_installed">Aplicação acompanhante aparentemente não instalada!</string>
|
||||||
<string name="insight_incompatible_compantion_app_we_need_version">Aplicação acompanhante incompatível. Versão necessitada</string>
|
<string name="insight_incompatible_compantion_app_we_need_version">Aplicação acompanhante incompatível. Versão necessitada</string>
|
||||||
<string name="insight_unknown">Desconhecido</string>
|
<string name="unknown">Desconhecido</string>
|
||||||
<string name="insight_waiting_for_code">A aguardar por código de confirmação</string>
|
<string name="insight_waiting_for_code">A aguardar por código de confirmação</string>
|
||||||
<string name="insight_code_rejected">Codigo rejeitado</string>
|
<string name="insight_code_rejected">Codigo rejeitado</string>
|
||||||
<string name="insight_app_binding">Associação de aplicação</string>
|
<string name="insight_app_binding">Associação de aplicação</string>
|
||||||
|
|
|
@ -796,7 +796,7 @@
|
||||||
<string name="insight_not_connected_to_companion_app">Aplicația nu este conectată!</string>
|
<string name="insight_not_connected_to_companion_app">Aplicația nu este conectată!</string>
|
||||||
<string name="insight_companion_app_not_installed">Aplicația pare să nu fie instalată!</string>
|
<string name="insight_companion_app_not_installed">Aplicația pare să nu fie instalată!</string>
|
||||||
<string name="insight_incompatible_compantion_app_we_need_version">Aplicație incompatibila, este necesară versiunea</string>
|
<string name="insight_incompatible_compantion_app_we_need_version">Aplicație incompatibila, este necesară versiunea</string>
|
||||||
<string name="insight_unknown">Necunoscut</string>
|
<string name="unknown">Necunoscut</string>
|
||||||
<string name="insight_waiting_for_code">Se așteaptă confirmarea codului</string>
|
<string name="insight_waiting_for_code">Se așteaptă confirmarea codului</string>
|
||||||
<string name="insight_code_rejected">Cod respins</string>
|
<string name="insight_code_rejected">Cod respins</string>
|
||||||
<string name="insight_app_binding">Conectare aplicație</string>
|
<string name="insight_app_binding">Conectare aplicație</string>
|
||||||
|
|
|
@ -796,7 +796,7 @@
|
||||||
<string name="insight_not_connected_to_companion_app">Нет подключения к сопутствующему приложению!</string>
|
<string name="insight_not_connected_to_companion_app">Нет подключения к сопутствующему приложению!</string>
|
||||||
<string name="insight_companion_app_not_installed">Сопутствующее приложение по-видимому не установлено!</string>
|
<string name="insight_companion_app_not_installed">Сопутствующее приложение по-видимому не установлено!</string>
|
||||||
<string name="insight_incompatible_compantion_app_we_need_version">Несовместимое сопутствующее приложение, нужна версия</string>
|
<string name="insight_incompatible_compantion_app_we_need_version">Несовместимое сопутствующее приложение, нужна версия</string>
|
||||||
<string name="insight_unknown">Неизвестно</string>
|
<string name="unknown">Неизвестно</string>
|
||||||
<string name="insight_waiting_for_code">Ожидание подтверждения кода</string>
|
<string name="insight_waiting_for_code">Ожидание подтверждения кода</string>
|
||||||
<string name="insight_code_rejected">Код отклонен</string>
|
<string name="insight_code_rejected">Код отклонен</string>
|
||||||
<string name="insight_app_binding">Соединение с приложением</string>
|
<string name="insight_app_binding">Соединение с приложением</string>
|
||||||
|
|
|
@ -797,7 +797,7 @@
|
||||||
<string name="insight_not_connected_to_companion_app">Nepripojený k sprievodnej aplikácii!</string>
|
<string name="insight_not_connected_to_companion_app">Nepripojený k sprievodnej aplikácii!</string>
|
||||||
<string name="insight_companion_app_not_installed">Sprievodná aplikácia pravdepodobne nie je nainštalovaná!</string>
|
<string name="insight_companion_app_not_installed">Sprievodná aplikácia pravdepodobne nie je nainštalovaná!</string>
|
||||||
<string name="insight_incompatible_compantion_app_we_need_version">Nekompatibilná sprievodná aplikácia, je požadovaná verzia</string>
|
<string name="insight_incompatible_compantion_app_we_need_version">Nekompatibilná sprievodná aplikácia, je požadovaná verzia</string>
|
||||||
<string name="insight_unknown">Neznámy</string>
|
<string name="unknown">Neznámy</string>
|
||||||
<string name="insight_waiting_for_code">Čakám na potvrdenie kódu</string>
|
<string name="insight_waiting_for_code">Čakám na potvrdenie kódu</string>
|
||||||
<string name="insight_code_rejected">Kód odmietnutý</string>
|
<string name="insight_code_rejected">Kód odmietnutý</string>
|
||||||
<string name="insight_app_binding">Pripájanie aplikácie</string>
|
<string name="insight_app_binding">Pripájanie aplikácie</string>
|
||||||
|
|
|
@ -796,7 +796,7 @@
|
||||||
<string name="insight_not_connected_to_companion_app">Inte ansluten till hjälp-app!</string>
|
<string name="insight_not_connected_to_companion_app">Inte ansluten till hjälp-app!</string>
|
||||||
<string name="insight_companion_app_not_installed">Hjälp-app verkar inte vara installerad!</string>
|
<string name="insight_companion_app_not_installed">Hjälp-app verkar inte vara installerad!</string>
|
||||||
<string name="insight_incompatible_compantion_app_we_need_version">Inkompatibel hjälp-app. Vi behöver version</string>
|
<string name="insight_incompatible_compantion_app_we_need_version">Inkompatibel hjälp-app. Vi behöver version</string>
|
||||||
<string name="insight_unknown">Okänd</string>
|
<string name="unknown">Okänd</string>
|
||||||
<string name="insight_waiting_for_code">Inväntar kodverifiering</string>
|
<string name="insight_waiting_for_code">Inväntar kodverifiering</string>
|
||||||
<string name="insight_code_rejected">Kod ej godkänd</string>
|
<string name="insight_code_rejected">Kod ej godkänd</string>
|
||||||
<string name="insight_app_binding">Appbindning</string>
|
<string name="insight_app_binding">Appbindning</string>
|
||||||
|
|
|
@ -796,7 +796,7 @@
|
||||||
<string name="insight_not_connected_to_companion_app">没有连接到companion app!</string>
|
<string name="insight_not_connected_to_companion_app">没有连接到companion app!</string>
|
||||||
<string name="insight_companion_app_not_installed">好像没有安装companion app!</string>
|
<string name="insight_companion_app_not_installed">好像没有安装companion app!</string>
|
||||||
<string name="insight_incompatible_compantion_app_we_need_version">和companion app不兼容,我们需要版本</string>
|
<string name="insight_incompatible_compantion_app_we_need_version">和companion app不兼容,我们需要版本</string>
|
||||||
<string name="insight_unknown">未知的</string>
|
<string name="unknown">未知的</string>
|
||||||
<string name="insight_waiting_for_code">正在等待代码确认</string>
|
<string name="insight_waiting_for_code">正在等待代码确认</string>
|
||||||
<string name="insight_code_rejected">代码被拒绝</string>
|
<string name="insight_code_rejected">代码被拒绝</string>
|
||||||
<string name="insight_app_binding">App绑定中</string>
|
<string name="insight_app_binding">App绑定中</string>
|
||||||
|
|
|
@ -893,7 +893,7 @@
|
||||||
<string name="insight_not_connected_to_companion_app">Not connected to companion app!</string>
|
<string name="insight_not_connected_to_companion_app">Not connected to companion app!</string>
|
||||||
<string name="insight_companion_app_not_installed">Companion app does not appear to be installed!</string>
|
<string name="insight_companion_app_not_installed">Companion app does not appear to be installed!</string>
|
||||||
<string name="insight_incompatible_compantion_app_we_need_version">Incompatible companion app, we need version</string>
|
<string name="insight_incompatible_compantion_app_we_need_version">Incompatible companion app, we need version</string>
|
||||||
<string name="insight_unknown">Unknown</string>
|
<string name="unknown">Unknown</string>
|
||||||
<string name="insight_waiting_for_code">Waiting for code confirmation</string>
|
<string name="insight_waiting_for_code">Waiting for code confirmation</string>
|
||||||
<string name="insight_code_rejected">Code rejected</string>
|
<string name="insight_code_rejected">Code rejected</string>
|
||||||
<string name="insight_app_binding">App binding</string>
|
<string name="insight_app_binding">App binding</string>
|
||||||
|
@ -1208,6 +1208,23 @@
|
||||||
<string name="automation">Automation</string>
|
<string name="automation">Automation</string>
|
||||||
<string name="automation_short">Auto</string>
|
<string name="automation_short">Auto</string>
|
||||||
<string name="automation_description">User defined automation tasks</string>
|
<string name="automation_description">User defined automation tasks</string>
|
||||||
|
<string name="alreadyenabled">Already enabled</string>
|
||||||
|
<string name="alreadydisabled">Already disabled</string>
|
||||||
|
<string name="alreadysuspended">Already suspended</string>
|
||||||
|
<string name="resumeloop">Resume loop</string>
|
||||||
|
<string name="notsuspended">Not suspended</string>
|
||||||
|
<string name="starttemptarget">Start temp target</string>
|
||||||
|
<string name="islower">is lower than</string>
|
||||||
|
<string name="isequalorlower">is equal or lower than</string>
|
||||||
|
<string name="isequal">is equal to</string>
|
||||||
|
<string name="isequalorgreater">is equal or greater than</string>
|
||||||
|
<string name="isgreater">is greater than</string>
|
||||||
|
<string name="isnotavailable">is not available</string>
|
||||||
|
<string name="glucoseisnotavailable">Glucose is not available</string>
|
||||||
|
<string name="glucosecompared">Glucose %1$s %2$.2f %3$s</string>
|
||||||
|
<string name="and">And</string>
|
||||||
|
<string name="or">Or</string>
|
||||||
|
<string name="atspecifiedtime">At %1$s</string>
|
||||||
|
|
||||||
<plurals name="objective_days">
|
<plurals name="objective_days">
|
||||||
<item quantity="one">%1$d day</item>
|
<item quantity="one">%1$d day</item>
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
package info.nightscout.androidaps.plugins.general.automation.actions;
|
package info.nightscout.androidaps.plugins.general.automation.triggers;
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||||
import org.powermock.modules.junit4.PowerMockRunner;
|
import org.powermock.modules.junit4.PowerMockRunner;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.plugins.general.automation.triggers.Trigger;
|
||||||
|
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerAnd;
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({})
|
@PrepareForTest({})
|
||||||
public class TriggerAndTest {
|
public class TriggerAndTest {
|
||||||
|
@ -37,8 +39,8 @@ public class TriggerAndTest {
|
||||||
Assert.assertTrue(t.shouldRun());
|
Assert.assertTrue(t.shouldRun());
|
||||||
}
|
}
|
||||||
|
|
||||||
String empty = "{\"data\":\"[]\",\"type\":\"info.nightscout.androidaps.plugins.general.automation.actions.TriggerAnd\"}";
|
String empty = "{\"data\":\"[]\",\"type\":\"info.nightscout.androidaps.plugins.general.automation.triggers.TriggerAnd\"}";
|
||||||
String oneItem = "{\"data\":\"[\\\"{\\\\\\\"data\\\\\\\":\\\\\\\"[]\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"info.nightscout.androidaps.plugins.general.automation.actions.TriggerAnd\\\\\\\"}\\\"]\",\"type\":\"info.nightscout.androidaps.plugins.general.automation.actions.TriggerAnd\"}";
|
String oneItem = "{\"data\":\"[\\\"{\\\\\\\"data\\\\\\\":\\\\\\\"[]\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"info.nightscout.androidaps.plugins.general.automation.triggers.TriggerAnd\\\\\\\"}\\\"]\",\"type\":\"info.nightscout.androidaps.plugins.general.automation.triggers.TriggerAnd\"}";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void toJSONTest() {
|
public void toJSONTest() {
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.plugins.general.automation.actions;
|
package info.nightscout.androidaps.plugins.general.automation.triggers;
|
||||||
|
|
||||||
import com.squareup.otto.Bus;
|
import com.squareup.otto.Bus;
|
||||||
|
|
||||||
|
@ -58,11 +58,11 @@ public class TriggerBgTest {
|
||||||
when(MainApp.getDbHelper().getBgreadingsDataFromTime(anyLong(), anyBoolean())).thenReturn(new ArrayList<>());
|
when(MainApp.getDbHelper().getBgreadingsDataFromTime(anyLong(), anyBoolean())).thenReturn(new ArrayList<>());
|
||||||
t = new TriggerBg().units(Constants.MGDL).threshold(213).comparator(Trigger.ISEQUALORLOWER);
|
t = new TriggerBg().units(Constants.MGDL).threshold(213).comparator(Trigger.ISEQUALORLOWER);
|
||||||
Assert.assertFalse(t.shouldRun());
|
Assert.assertFalse(t.shouldRun());
|
||||||
t = new TriggerBg().comparator(Trigger.NOTAVAILABLE);
|
t = new TriggerBg().comparator(Trigger.ISNOTAVAILABLE);
|
||||||
Assert.assertTrue(t.shouldRun());
|
Assert.assertTrue(t.shouldRun());
|
||||||
}
|
}
|
||||||
|
|
||||||
String bgJson = "{\"data\":\"{\\\"comparator\\\":0,\\\"threshold\\\":4.1,\\\"units\\\":\\\"mmol\\\"}\",\"type\":\"info.nightscout.androidaps.plugins.general.automation.actions.TriggerBg\"}";
|
String bgJson = "{\"data\":\"{\\\"comparator\\\":0,\\\"threshold\\\":4.1,\\\"units\\\":\\\"mmol\\\"}\",\"type\":\"info.nightscout.androidaps.plugins.general.automation.triggers.TriggerBg\"}";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void toJSONTest() {
|
public void toJSONTest() {
|
|
@ -1,14 +1,16 @@
|
||||||
package info.nightscout.androidaps.plugins.general.automation.actions;
|
package info.nightscout.androidaps.plugins.general.automation.triggers;
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||||
import org.powermock.modules.junit4.PowerMockRunner;
|
import org.powermock.modules.junit4.PowerMockRunner;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.plugins.general.automation.triggers.Trigger;
|
||||||
|
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerOr;
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({})
|
@PrepareForTest({})
|
||||||
public class TriggerOrTest {
|
public class TriggerOrTest {
|
||||||
|
@ -37,8 +39,8 @@ public class TriggerOrTest {
|
||||||
Assert.assertFalse(t.shouldRun());
|
Assert.assertFalse(t.shouldRun());
|
||||||
}
|
}
|
||||||
|
|
||||||
String empty = "{\"data\":\"[]\",\"type\":\"info.nightscout.androidaps.plugins.general.automation.actions.TriggerOr\"}";
|
String empty = "{\"data\":\"[]\",\"type\":\"info.nightscout.androidaps.plugins.general.automation.triggers.TriggerOr\"}";
|
||||||
String oneItem = "{\"data\":\"[\\\"{\\\\\\\"data\\\\\\\":\\\\\\\"[]\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"info.nightscout.androidaps.plugins.general.automation.actions.TriggerOr\\\\\\\"}\\\"]\",\"type\":\"info.nightscout.androidaps.plugins.general.automation.actions.TriggerOr\"}";
|
String oneItem = "{\"data\":\"[\\\"{\\\\\\\"data\\\\\\\":\\\\\\\"[]\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"info.nightscout.androidaps.plugins.general.automation.triggers.TriggerOr\\\\\\\"}\\\"]\",\"type\":\"info.nightscout.androidaps.plugins.general.automation.triggers.TriggerOr\"}";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void toJSONTest() {
|
public void toJSONTest() {
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.plugins.general.automation.actions;
|
package info.nightscout.androidaps.plugins.general.automation.triggers;
|
||||||
|
|
||||||
import com.squareup.otto.Bus;
|
import com.squareup.otto.Bus;
|
||||||
|
|
||||||
|
@ -16,6 +16,8 @@ import java.util.GregorianCalendar;
|
||||||
|
|
||||||
import info.AAPSMocker;
|
import info.AAPSMocker;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
import info.nightscout.androidaps.plugins.general.automation.triggers.Trigger;
|
||||||
|
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerTime;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.T;
|
import info.nightscout.utils.T;
|
||||||
|
|
||||||
|
@ -51,7 +53,7 @@ public class TriggerTimeTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String timeJson = "{\"data\":\"{\\\"saturday\\\":true,\\\"runAt\\\":1514766840000,\\\"lastRun\\\":0,\\\"recurring\\\":false,\\\"thursday\\\":true,\\\"minute\\\":0,\\\"sunday\\\":true,\\\"tuesday\\\":true,\\\"hour\\\":0,\\\"wednesday\\\":true,\\\"friday\\\":true,\\\"monday\\\":true,\\\"validTo\\\":0}\",\"type\":\"info.nightscout.androidaps.plugins.general.automation.actions.TriggerTime\"}";
|
String timeJson = "{\"data\":\"{\\\"saturday\\\":true,\\\"runAt\\\":1514766840000,\\\"lastRun\\\":0,\\\"recurring\\\":false,\\\"thursday\\\":true,\\\"minute\\\":0,\\\"sunday\\\":true,\\\"tuesday\\\":true,\\\"hour\\\":0,\\\"wednesday\\\":true,\\\"friday\\\":true,\\\"monday\\\":true,\\\"validTo\\\":0}\",\"type\":\"info.nightscout.androidaps.plugins.general.automation.triggers.TriggerTime\"}";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void toJSONTest() {
|
public void toJSONTest() {
|
Loading…
Reference in a new issue