renaming before adding AMA

This commit is contained in:
Milos Kozak 2017-01-03 21:01:01 +01:00
parent fe75298263
commit faf8e07248
15 changed files with 69 additions and 86 deletions

View file

@ -7,7 +7,7 @@ public class Config {
// MAIN FUCTIONALITY // MAIN FUCTIONALITY
public static final boolean APS = BuildConfig.APS; public static final boolean APS = BuildConfig.APS;
// PLUGINS // PLUGINS
public static final boolean OPENAPSMAENABLED = APS; public static final boolean OPENAPSENABLED = APS;
public static final boolean LOOPENABLED = APS; public static final boolean LOOPENABLED = APS;
public static final boolean WEAR = BuildConfig.WEAR; public static final boolean WEAR = BuildConfig.WEAR;

View file

@ -82,7 +82,7 @@ public class MainApp extends Application {
pluginsList.add(MDIFragment.getPlugin()); pluginsList.add(MDIFragment.getPlugin());
pluginsList.add(VirtualPumpFragment.getPlugin()); pluginsList.add(VirtualPumpFragment.getPlugin());
if (Config.LOOPENABLED) pluginsList.add(LoopFragment.getPlugin()); if (Config.LOOPENABLED) pluginsList.add(LoopFragment.getPlugin());
if (Config.OPENAPSMAENABLED) pluginsList.add(OpenAPSMAFragment.getPlugin()); if (Config.OPENAPSENABLED) pluginsList.add(OpenAPSMAFragment.getPlugin());
pluginsList.add(NSProfileFragment.getPlugin()); pluginsList.add(NSProfileFragment.getPlugin());
pluginsList.add(SimpleProfileFragment.getPlugin()); pluginsList.add(SimpleProfileFragment.getPlugin());
pluginsList.add(LocalProfileFragment.getPlugin()); pluginsList.add(LocalProfileFragment.getPlugin());

View file

@ -15,7 +15,6 @@ import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.events.EventRefreshGui; import info.nightscout.androidaps.events.EventRefreshGui;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.plugins.DanaR.BluetoothDevicePreference; import info.nightscout.androidaps.plugins.DanaR.BluetoothDevicePreference;
import info.nightscout.androidaps.plugins.DanaR.DanaRFragment;
import info.nightscout.androidaps.plugins.DanaR.DanaRPlugin; import info.nightscout.androidaps.plugins.DanaR.DanaRPlugin;
import info.nightscout.androidaps.plugins.DanaRKorean.DanaRKoreanPlugin; import info.nightscout.androidaps.plugins.DanaRKorean.DanaRKoreanPlugin;
import info.nightscout.utils.LocaleHelper; import info.nightscout.utils.LocaleHelper;
@ -85,7 +84,7 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
addPreferencesFromResource(R.xml.pref_treatments); addPreferencesFromResource(R.xml.pref_treatments);
if (Config.APS) if (Config.APS)
addPreferencesFromResource(R.xml.pref_closedmode); addPreferencesFromResource(R.xml.pref_closedmode);
if (Config.OPENAPSMAENABLED) if (Config.OPENAPSENABLED)
addPreferencesFromResource(R.xml.pref_openapsma); addPreferencesFromResource(R.xml.pref_openapsma);
addPreferencesFromResource(R.xml.pref_nightscout); addPreferencesFromResource(R.xml.pref_nightscout);
if (Config.DANAR) { if (Config.DANAR) {

View file

@ -4,7 +4,6 @@ import java.util.List;
import info.nightscout.androidaps.db.Treatment; import info.nightscout.androidaps.db.Treatment;
import info.nightscout.androidaps.plugins.OpenAPSMA.IobTotal; import info.nightscout.androidaps.plugins.OpenAPSMA.IobTotal;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsFragment;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin; import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
/** /**

View file

@ -15,7 +15,6 @@ import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.ProfileInterface; import info.nightscout.androidaps.interfaces.ProfileInterface;
import info.nightscout.androidaps.plugins.OpenAPSMA.OpenAPSMAPlugin;
import info.nightscout.client.data.NSProfile; import info.nightscout.client.data.NSProfile;
import info.nightscout.utils.DecimalFormatter; import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.SafeParse; import info.nightscout.utils.SafeParse;

View file

@ -43,13 +43,12 @@ import info.nightscout.androidaps.plugins.DanaR.comm.MsgError;
import info.nightscout.androidaps.plugins.Loop.APSResult; import info.nightscout.androidaps.plugins.Loop.APSResult;
import info.nightscout.androidaps.plugins.Loop.DeviceStatus; import info.nightscout.androidaps.plugins.Loop.DeviceStatus;
import info.nightscout.androidaps.plugins.Loop.LoopPlugin; import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
import info.nightscout.androidaps.plugins.OpenAPSMA.DetermineBasalResult; import info.nightscout.androidaps.plugins.OpenAPSMA.DetermineBasalResultMA;
import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressDialog; import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressDialog;
import info.nightscout.androidaps.plugins.Actions.dialogs.NewExtendedBolusDialog; import info.nightscout.androidaps.plugins.Actions.dialogs.NewExtendedBolusDialog;
import info.nightscout.androidaps.plugins.Overview.Notification; import info.nightscout.androidaps.plugins.Overview.Notification;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification; import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.SmsCommunicator.SmsCommunicatorPlugin;
import info.nightscout.client.data.DbLogger; import info.nightscout.client.data.DbLogger;
import info.nightscout.client.data.NSProfile; import info.nightscout.client.data.NSProfile;
import info.nightscout.utils.DateUtil; import info.nightscout.utils.DateUtil;
@ -901,8 +900,8 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
apsResult.json().put("timestamp", DateUtil.toISOString(lastRun.lastAPSRun)); apsResult.json().put("timestamp", DateUtil.toISOString(lastRun.lastAPSRun));
deviceStatus.suggested = apsResult.json(); deviceStatus.suggested = apsResult.json();
if (lastRun.request instanceof DetermineBasalResult) { if (lastRun.request instanceof DetermineBasalResultMA) {
DetermineBasalResult result = (DetermineBasalResult) lastRun.request; DetermineBasalResultMA result = (DetermineBasalResultMA) lastRun.request;
deviceStatus.iob = result.iob.json(); deviceStatus.iob = result.iob.json();
deviceStatus.iob.put("time", DateUtil.toISOString(lastRun.lastAPSRun)); deviceStatus.iob.put("time", DateUtil.toISOString(lastRun.lastAPSRun));
} }

View file

@ -19,12 +19,11 @@ import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.db.DatabaseHelper; import info.nightscout.androidaps.db.DatabaseHelper;
import info.nightscout.androidaps.plugins.Loop.ScriptReader; import info.nightscout.androidaps.plugins.Loop.ScriptReader;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsFragment;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin; import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.client.data.NSProfile; import info.nightscout.client.data.NSProfile;
public class DetermineBasalAdapterJS implements Parcelable { public class DetermineBasalAdapterMAJS implements Parcelable {
private static Logger log = LoggerFactory.getLogger(DetermineBasalAdapterJS.class); private static Logger log = LoggerFactory.getLogger(DetermineBasalAdapterMAJS.class);
private ScriptReader mScriptReader = null; private ScriptReader mScriptReader = null;
@ -51,7 +50,7 @@ public class DetermineBasalAdapterJS implements Parcelable {
* Parcelable implementation * Parcelable implementation
* result string for display only * result string for display only
**/ **/
protected DetermineBasalAdapterJS(Parcel in) { protected DetermineBasalAdapterMAJS(Parcel in) {
storedCurrentTemp = in.readString(); storedCurrentTemp = in.readString();
storedIobData = in.readString(); storedIobData = in.readString();
storedGlucoseStatus = in.readString(); storedGlucoseStatus = in.readString();
@ -73,15 +72,15 @@ public class DetermineBasalAdapterJS implements Parcelable {
return 0; return 0;
} }
public static final Creator<DetermineBasalAdapterJS> CREATOR = new Creator<DetermineBasalAdapterJS>() { public static final Creator<DetermineBasalAdapterMAJS> CREATOR = new Creator<DetermineBasalAdapterMAJS>() {
@Override @Override
public DetermineBasalAdapterJS createFromParcel(Parcel in) { public DetermineBasalAdapterMAJS createFromParcel(Parcel in) {
return new DetermineBasalAdapterJS(in); return new DetermineBasalAdapterMAJS(in);
} }
@Override @Override
public DetermineBasalAdapterJS[] newArray(int size) { public DetermineBasalAdapterMAJS[] newArray(int size) {
return new DetermineBasalAdapterJS[size]; return new DetermineBasalAdapterMAJS[size];
} }
}; };
@ -89,7 +88,7 @@ public class DetermineBasalAdapterJS implements Parcelable {
* Main code * Main code
*/ */
public DetermineBasalAdapterJS(ScriptReader scriptReader) throws IOException { public DetermineBasalAdapterMAJS(ScriptReader scriptReader) throws IOException {
mV8rt = V8.createV8Runtime(); mV8rt = V8.createV8Runtime();
mScriptReader = scriptReader; mScriptReader = scriptReader;
@ -143,7 +142,7 @@ public class DetermineBasalAdapterJS implements Parcelable {
mV8rt.add(PARAM_meal_data, mMealData); mV8rt.add(PARAM_meal_data, mMealData);
} }
public DetermineBasalResult invoke() { public DetermineBasalResultMA invoke() {
mV8rt.executeVoidScript( mV8rt.executeVoidScript(
"console.error(\"determine_basal(\"+\n" + "console.error(\"determine_basal(\"+\n" +
"JSON.stringify(" + PARAM_glucoseStatus + ")+ \", \" +\n" + "JSON.stringify(" + PARAM_glucoseStatus + ")+ \", \" +\n" +
@ -170,9 +169,9 @@ public class DetermineBasalAdapterJS implements Parcelable {
V8Object v8ObjectReuslt = mV8rt.getObject("rT"); V8Object v8ObjectReuslt = mV8rt.getObject("rT");
DetermineBasalResult result = null; DetermineBasalResultMA result = null;
try { try {
result = new DetermineBasalResult(v8ObjectReuslt, new JSONObject(ret)); result = new DetermineBasalResultMA(v8ObjectReuslt, new JSONObject(ret));
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
} }

View file

@ -10,7 +10,7 @@ import org.json.JSONObject;
import info.nightscout.androidaps.plugins.Loop.APSResult; import info.nightscout.androidaps.plugins.Loop.APSResult;
public class DetermineBasalResult extends APSResult { public class DetermineBasalResultMA extends APSResult {
public JSONObject json = new JSONObject(); public JSONObject json = new JSONObject();
public double eventualBG; public double eventualBG;
@ -18,7 +18,7 @@ public class DetermineBasalResult extends APSResult {
public String mealAssist; public String mealAssist;
public IobTotal iob; public IobTotal iob;
public DetermineBasalResult(V8Object result, JSONObject j) { public DetermineBasalResultMA(V8Object result, JSONObject j) {
json = j; json = j;
if (result.contains("error")) { if (result.contains("error")) {
reason = result.getString("error"); reason = result.getString("error");
@ -61,17 +61,17 @@ public class DetermineBasalResult extends APSResult {
dest.writeString(mealAssist); dest.writeString(mealAssist);
} }
public final Parcelable.Creator<DetermineBasalResult> CREATOR = new Parcelable.Creator<DetermineBasalResult>() { public final Parcelable.Creator<DetermineBasalResultMA> CREATOR = new Parcelable.Creator<DetermineBasalResultMA>() {
public DetermineBasalResult createFromParcel(Parcel in) { public DetermineBasalResultMA createFromParcel(Parcel in) {
return new DetermineBasalResult(in); return new DetermineBasalResultMA(in);
} }
public DetermineBasalResult[] newArray(int size) { public DetermineBasalResultMA[] newArray(int size) {
return new DetermineBasalResult[size]; return new DetermineBasalResultMA[size];
} }
}; };
private DetermineBasalResult(Parcel in) { private DetermineBasalResultMA(Parcel in) {
super(in); super(in);
try { try {
json = new JSONObject(in.readString()); json = new JSONObject(in.readString());
@ -83,12 +83,12 @@ public class DetermineBasalResult extends APSResult {
mealAssist = in.readString(); mealAssist = in.readString();
} }
public DetermineBasalResult() { public DetermineBasalResultMA() {
} }
@Override @Override
public DetermineBasalResult clone() { public DetermineBasalResultMA clone() {
DetermineBasalResult newResult = new DetermineBasalResult(); DetermineBasalResultMA newResult = new DetermineBasalResultMA();
newResult.reason = new String(reason); newResult.reason = new String(reason);
newResult.rate = rate; newResult.rate = rate;
newResult.duration = duration; newResult.duration = duration;

View file

@ -17,9 +17,8 @@ import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.interfaces.FragmentBase; import info.nightscout.androidaps.interfaces.FragmentBase;
import info.nightscout.androidaps.plugins.Loop.APSResult; import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui;
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSMAUpdateGui; import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateResultGui;
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSMAUpdateResultGui;
import info.nightscout.utils.JSONFormatter; import info.nightscout.utils.JSONFormatter;
public class OpenAPSMAFragment extends Fragment implements View.OnClickListener, FragmentBase { public class OpenAPSMAFragment extends Fragment implements View.OnClickListener, FragmentBase {
@ -87,12 +86,12 @@ public class OpenAPSMAFragment extends Fragment implements View.OnClickListener,
} }
@Subscribe @Subscribe
public void onStatusEvent(final EventOpenAPSMAUpdateGui ev) { public void onStatusEvent(final EventOpenAPSUpdateGui ev) {
updateGUI(); updateGUI();
} }
@Subscribe @Subscribe
public void onStatusEvent(final EventOpenAPSMAUpdateResultGui ev) { public void onStatusEvent(final EventOpenAPSUpdateResultGui ev) {
updateResultGUI(ev.text); updateResultGUI(ev.text);
} }
@ -102,18 +101,18 @@ public class OpenAPSMAFragment extends Fragment implements View.OnClickListener,
activity.runOnUiThread(new Runnable() { activity.runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
DetermineBasalResult lastAPSResult = getPlugin().lastAPSResult; DetermineBasalResultMA lastAPSResult = getPlugin().lastAPSResult;
if (lastAPSResult != null) { if (lastAPSResult != null) {
resultView.setText(JSONFormatter.format(lastAPSResult.json)); resultView.setText(JSONFormatter.format(lastAPSResult.json));
requestView.setText(lastAPSResult.toSpanned()); requestView.setText(lastAPSResult.toSpanned());
} }
DetermineBasalAdapterJS determineBasalAdapterJS = getPlugin().lastDetermineBasalAdapterJS; DetermineBasalAdapterMAJS determineBasalAdapterMAJS = getPlugin().lastDetermineBasalAdapterMAJS;
if (determineBasalAdapterJS != null) { if (determineBasalAdapterMAJS != null) {
glucoseStatusView.setText(JSONFormatter.format(determineBasalAdapterJS.getGlucoseStatusParam())); glucoseStatusView.setText(JSONFormatter.format(determineBasalAdapterMAJS.getGlucoseStatusParam()));
currentTempView.setText(JSONFormatter.format(determineBasalAdapterJS.getCurrentTempParam())); currentTempView.setText(JSONFormatter.format(determineBasalAdapterMAJS.getCurrentTempParam()));
iobDataView.setText(JSONFormatter.format(determineBasalAdapterJS.getIobDataParam())); iobDataView.setText(JSONFormatter.format(determineBasalAdapterMAJS.getIobDataParam()));
profileView.setText(JSONFormatter.format(determineBasalAdapterJS.getProfileParam())); profileView.setText(JSONFormatter.format(determineBasalAdapterMAJS.getProfileParam()));
mealDataView.setText(JSONFormatter.format(determineBasalAdapterJS.getMealDataParam())); mealDataView.setText(JSONFormatter.format(determineBasalAdapterMAJS.getMealDataParam()));
} }
if (getPlugin().lastAPSRun != null) { if (getPlugin().lastAPSRun != null) {
lastRunView.setText(getPlugin().lastAPSRun.toLocaleString()); lastRunView.setText(getPlugin().lastAPSRun.toLocaleString());

View file

@ -1,13 +1,9 @@
package info.nightscout.androidaps.plugins.OpenAPSMA; package info.nightscout.androidaps.plugins.OpenAPSMA;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -18,7 +14,6 @@ import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.Services.Intents;
import info.nightscout.androidaps.db.DatabaseHelper; import info.nightscout.androidaps.db.DatabaseHelper;
import info.nightscout.androidaps.interfaces.APSInterface; import info.nightscout.androidaps.interfaces.APSInterface;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
@ -27,10 +22,9 @@ import info.nightscout.androidaps.interfaces.TempBasalsInterface;
import info.nightscout.androidaps.interfaces.TreatmentsInterface; import info.nightscout.androidaps.interfaces.TreatmentsInterface;
import info.nightscout.androidaps.plugins.Loop.APSResult; import info.nightscout.androidaps.plugins.Loop.APSResult;
import info.nightscout.androidaps.plugins.Loop.ScriptReader; import info.nightscout.androidaps.plugins.Loop.ScriptReader;
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSMAUpdateGui; import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui;
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSMAUpdateResultGui; import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateResultGui;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin; import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.client.data.DbLogger;
import info.nightscout.client.data.NSProfile; import info.nightscout.client.data.NSProfile;
import info.nightscout.utils.DateUtil; import info.nightscout.utils.DateUtil;
import info.nightscout.utils.Round; import info.nightscout.utils.Round;
@ -44,9 +38,9 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
private static Logger log = LoggerFactory.getLogger(OpenAPSMAPlugin.class); private static Logger log = LoggerFactory.getLogger(OpenAPSMAPlugin.class);
// last values // last values
DetermineBasalAdapterJS lastDetermineBasalAdapterJS = null; DetermineBasalAdapterMAJS lastDetermineBasalAdapterMAJS = null;
Date lastAPSRun = null; Date lastAPSRun = null;
DetermineBasalResult lastAPSResult = null; DetermineBasalResultMA lastAPSResult = null;
boolean fragmentEnabled = false; boolean fragmentEnabled = false;
boolean fragmentVisible = true; boolean fragmentVisible = true;
@ -104,9 +98,9 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
@Override @Override
public void invoke() { public void invoke() {
lastAPSResult = null; lastAPSResult = null;
DetermineBasalAdapterJS determineBasalAdapterJS = null; DetermineBasalAdapterMAJS determineBasalAdapterMAJS = null;
try { try {
determineBasalAdapterJS = new DetermineBasalAdapterJS(new ScriptReader(MainApp.instance().getBaseContext())); determineBasalAdapterMAJS = new DetermineBasalAdapterMAJS(new ScriptReader(MainApp.instance().getBaseContext()));
} catch (IOException e) { } catch (IOException e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
return; return;
@ -117,28 +111,28 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
PumpInterface pump = MainApp.getConfigBuilder(); PumpInterface pump = MainApp.getConfigBuilder();
if (!isEnabled(PluginBase.APS)) { if (!isEnabled(PluginBase.APS)) {
MainApp.bus().post(new EventOpenAPSMAUpdateResultGui(MainApp.instance().getString(R.string.openapsma_disabled))); MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.instance().getString(R.string.openapsma_disabled)));
if (Config.logAPSResult) if (Config.logAPSResult)
log.debug(MainApp.instance().getString(R.string.openapsma_disabled)); log.debug(MainApp.instance().getString(R.string.openapsma_disabled));
return; return;
} }
if (glucoseStatus == null) { if (glucoseStatus == null) {
MainApp.bus().post(new EventOpenAPSMAUpdateResultGui(MainApp.instance().getString(R.string.openapsma_noglucosedata))); MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.instance().getString(R.string.openapsma_noglucosedata)));
if (Config.logAPSResult) if (Config.logAPSResult)
log.debug(MainApp.instance().getString(R.string.openapsma_noglucosedata)); log.debug(MainApp.instance().getString(R.string.openapsma_noglucosedata));
return; return;
} }
if (profile == null) { if (profile == null) {
MainApp.bus().post(new EventOpenAPSMAUpdateResultGui(MainApp.instance().getString(R.string.openapsma_noprofile))); MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.instance().getString(R.string.openapsma_noprofile)));
if (Config.logAPSResult) if (Config.logAPSResult)
log.debug(MainApp.instance().getString(R.string.openapsma_noprofile)); log.debug(MainApp.instance().getString(R.string.openapsma_noprofile));
return; return;
} }
if (pump == null) { if (pump == null) {
MainApp.bus().post(new EventOpenAPSMAUpdateResultGui(MainApp.instance().getString(R.string.openapsma_nopump))); MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.instance().getString(R.string.openapsma_nopump)));
if (Config.logAPSResult) if (Config.logAPSResult)
log.debug(MainApp.instance().getString(R.string.openapsma_nopump)); log.debug(MainApp.instance().getString(R.string.openapsma_nopump));
return; return;
@ -193,37 +187,37 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
if (!checkOnlyHardLimits(profile.getMaxDailyBasal(), "max_daily_basal", 0.1, 10)) return; if (!checkOnlyHardLimits(profile.getMaxDailyBasal(), "max_daily_basal", 0.1, 10)) return;
if (!checkOnlyHardLimits(pump.getBaseBasalRate(), "current_basal", 0.01, 5)) return; if (!checkOnlyHardLimits(pump.getBaseBasalRate(), "current_basal", 0.01, 5)) return;
determineBasalAdapterJS.setData(profile, maxIob, maxBasal, minBg, maxBg, targetBg, pump, iobTotal, glucoseStatus, mealData); determineBasalAdapterMAJS.setData(profile, maxIob, maxBasal, minBg, maxBg, targetBg, pump, iobTotal, glucoseStatus, mealData);
DetermineBasalResult determineBasalResult = determineBasalAdapterJS.invoke(); DetermineBasalResultMA determineBasalResultMA = determineBasalAdapterMAJS.invoke();
// Fix bug determine basal // Fix bug determine basal
if (determineBasalResult.rate == 0d && determineBasalResult.duration == 0 && !MainApp.getConfigBuilder().isTempBasalInProgress()) if (determineBasalResultMA.rate == 0d && determineBasalResultMA.duration == 0 && !MainApp.getConfigBuilder().isTempBasalInProgress())
determineBasalResult.changeRequested = false; determineBasalResultMA.changeRequested = false;
// limit requests on openloop mode // limit requests on openloop mode
if (!MainApp.getConfigBuilder().isClosedModeEnabled()) { if (!MainApp.getConfigBuilder().isClosedModeEnabled()) {
if (MainApp.getConfigBuilder().isTempBasalInProgress() && Math.abs(determineBasalResult.rate - MainApp.getConfigBuilder().getTempBasalAbsoluteRate()) < 0.1) if (MainApp.getConfigBuilder().isTempBasalInProgress() && Math.abs(determineBasalResultMA.rate - MainApp.getConfigBuilder().getTempBasalAbsoluteRate()) < 0.1)
determineBasalResult.changeRequested = false; determineBasalResultMA.changeRequested = false;
if (!MainApp.getConfigBuilder().isTempBasalInProgress() && Math.abs(determineBasalResult.rate - MainApp.getConfigBuilder().getBaseBasalRate()) < 0.1) if (!MainApp.getConfigBuilder().isTempBasalInProgress() && Math.abs(determineBasalResultMA.rate - MainApp.getConfigBuilder().getBaseBasalRate()) < 0.1)
determineBasalResult.changeRequested = false; determineBasalResultMA.changeRequested = false;
} }
determineBasalResult.iob = iobTotal; determineBasalResultMA.iob = iobTotal;
determineBasalAdapterJS.release(); determineBasalAdapterMAJS.release();
try { try {
determineBasalResult.json.put("timestamp", DateUtil.toISOString(now)); determineBasalResultMA.json.put("timestamp", DateUtil.toISOString(now));
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
} }
lastDetermineBasalAdapterJS = determineBasalAdapterJS; lastDetermineBasalAdapterMAJS = determineBasalAdapterMAJS;
lastAPSResult = determineBasalResult; lastAPSResult = determineBasalResultMA;
lastAPSRun = now; lastAPSRun = now;
MainApp.bus().post(new EventOpenAPSMAUpdateGui()); MainApp.bus().post(new EventOpenAPSUpdateGui());
//deviceStatus.suggested = determineBasalResult.json; //deviceStatus.suggested = determineBasalResultMA.json;
} }
// safety checks // safety checks

View file

@ -3,5 +3,5 @@ package info.nightscout.androidaps.plugins.OpenAPSMA.events;
/** /**
* Created by mike on 05.08.2016. * Created by mike on 05.08.2016.
*/ */
public class EventOpenAPSMAUpdateGui { public class EventOpenAPSUpdateGui {
} }

View file

@ -3,10 +3,10 @@ package info.nightscout.androidaps.plugins.OpenAPSMA.events;
/** /**
* Created by mike on 05.08.2016. * Created by mike on 05.08.2016.
*/ */
public class EventOpenAPSMAUpdateResultGui { public class EventOpenAPSUpdateResultGui {
public String text = null; public String text = null;
public EventOpenAPSMAUpdateResultGui(String text) { public EventOpenAPSUpdateResultGui(String text) {
this.text = text; this.text = text;
} }
} }

View file

@ -38,10 +38,8 @@ import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.db.BgReading; import info.nightscout.androidaps.db.BgReading;
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.interfaces.TempBasalsInterface; import info.nightscout.androidaps.interfaces.TempBasalsInterface;
import info.nightscout.androidaps.interfaces.TreatmentsInterface; import info.nightscout.androidaps.interfaces.TreatmentsInterface;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.OpenAPSMA.IobTotal; import info.nightscout.androidaps.plugins.OpenAPSMA.IobTotal;
import info.nightscout.client.data.NSProfile; import info.nightscout.client.data.NSProfile;
@ -49,7 +47,6 @@ import info.nightscout.utils.BolusWizard;
import info.nightscout.utils.DateUtil; import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter; import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.PlusMinusEditText; import info.nightscout.utils.PlusMinusEditText;
import info.nightscout.utils.Round;
import info.nightscout.utils.SafeParse; import info.nightscout.utils.SafeParse;
import info.nightscout.utils.ToastUtils; import info.nightscout.utils.ToastUtils;

View file

@ -28,7 +28,6 @@ import info.nightscout.androidaps.events.EventTreatmentChange;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.OpenAPSMA.IobTotal; import info.nightscout.androidaps.plugins.OpenAPSMA.IobTotal;
import info.nightscout.androidaps.plugins.Overview.Notification;
import info.nightscout.client.data.NSProfile; import info.nightscout.client.data.NSProfile;
import info.nightscout.utils.DecimalFormatter; import info.nightscout.utils.DecimalFormatter;

View file

@ -3,7 +3,6 @@ package info.nightscout.utils;
import org.json.JSONObject; import org.json.JSONObject;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.interfaces.TempBasalsInterface; import info.nightscout.androidaps.interfaces.TempBasalsInterface;
import info.nightscout.androidaps.interfaces.TreatmentsInterface; import info.nightscout.androidaps.interfaces.TreatmentsInterface;
import info.nightscout.androidaps.plugins.OpenAPSMA.IobTotal; import info.nightscout.androidaps.plugins.OpenAPSMA.IobTotal;