bolus progress in virtual pump
This commit is contained in:
parent
0ad856bed1
commit
acbd028465
11 changed files with 66 additions and 48 deletions
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
|
@ -37,7 +37,7 @@
|
|||
<ConfirmationsSetting value="0" id="Add" />
|
||||
<ConfirmationsSetting value="0" id="Remove" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
|
|
@ -31,7 +31,6 @@ import info.nightscout.androidaps.R;
|
|||
import info.nightscout.androidaps.db.Treatment;
|
||||
import info.nightscout.androidaps.events.EventAppExit;
|
||||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||
import info.nightscout.androidaps.plugins.DanaR.DanaRFragment;
|
||||
import info.nightscout.androidaps.plugins.DanaR.DanaRPlugin;
|
||||
import info.nightscout.androidaps.plugins.DanaR.DanaRPump;
|
||||
import info.nightscout.androidaps.plugins.DanaR.SerialIOThread;
|
||||
|
@ -72,7 +71,6 @@ import info.nightscout.androidaps.plugins.DanaR.comm.MsgStatusBasic;
|
|||
import info.nightscout.androidaps.plugins.DanaR.comm.MsgStatusBolusExtended;
|
||||
import info.nightscout.androidaps.plugins.DanaR.comm.MsgStatusTempBasal;
|
||||
import info.nightscout.androidaps.plugins.DanaR.comm.RecordTypes;
|
||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRBolusProgress;
|
||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRBolusStart;
|
||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRConnectionStatus;
|
||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRNewStatus;
|
||||
|
|
|
@ -6,9 +6,10 @@ 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.db.Treatment;
|
||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRBolusProgress;
|
||||
import info.nightscout.utils.DecimalFormatter;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
|
||||
|
||||
public class MsgBolusProgress extends MessageBase {
|
||||
private static Logger log = LoggerFactory.getLogger(MsgBolusProgress.class);
|
||||
|
@ -35,8 +36,8 @@ public class MsgBolusProgress extends MessageBase {
|
|||
progress = intFromBuff(bytes, 0, 2);
|
||||
Double done = (amount * 100 - progress) / 100d;
|
||||
t.insulin = done;
|
||||
EventDanaRBolusProgress bolusingEvent = EventDanaRBolusProgress.getInstance();
|
||||
bolusingEvent.status = "Delivering " + DecimalFormatter.to1Decimal(done) + "U";
|
||||
EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance();
|
||||
bolusingEvent.status = String.format(MainApp.sResources.getString(R.string.bolusdelivering), done);
|
||||
bolusingEvent.t = t;
|
||||
bolusingEvent.percent = Math.min((int) (done / amount * 100), 100);
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import org.slf4j.LoggerFactory;
|
|||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.db.Treatment;
|
||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRBolusProgress;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
|
||||
|
||||
public class MsgBolusStop extends MessageBase {
|
||||
private static Logger log = LoggerFactory.getLogger(MsgBolusStop.class);
|
||||
|
@ -34,7 +34,7 @@ public class MsgBolusStop extends MessageBase {
|
|||
|
||||
@Override
|
||||
public void handleMessage(byte[] bytes) {
|
||||
EventDanaRBolusProgress bolusingEvent = EventDanaRBolusProgress.getInstance();
|
||||
EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance();
|
||||
stopped = true;
|
||||
if (!forced) {
|
||||
t.insulin = amount;
|
||||
|
|
|
@ -15,7 +15,7 @@ import info.nightscout.androidaps.Config;
|
|||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.Services.Intents;
|
||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRBolusProgress;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
|
||||
import info.nightscout.client.data.DbLogger;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
|
||||
|
@ -30,7 +30,7 @@ public class MsgOcclusion extends MessageBase {
|
|||
public void handleMessage(byte[] bytes) {
|
||||
if (Config.logDanaMessageDetail)
|
||||
log.debug("Oclusion detected");
|
||||
EventDanaRBolusProgress bolusingEvent = EventDanaRBolusProgress.getInstance();
|
||||
EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance();
|
||||
MsgBolusStop.stopped = true;
|
||||
bolusingEvent.status = MainApp.sResources.getString(R.string.overview_bolusiprogress_occlusion);
|
||||
MainApp.bus().post(bolusingEvent);
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.DanaR.events;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.Services.Intents;
|
||||
import info.nightscout.androidaps.db.Treatment;
|
||||
import info.nightscout.client.data.DbLogger;
|
||||
|
||||
public class EventDanaRBolusProgress {
|
||||
private static Logger log = LoggerFactory.getLogger(EventDanaRBolusProgress.class);
|
||||
public String status = "";
|
||||
public Treatment t = null;
|
||||
public int percent = 0;
|
||||
private static EventDanaRBolusProgress eventDanaRBolusProgress = null;
|
||||
|
||||
public EventDanaRBolusProgress() {
|
||||
}
|
||||
|
||||
public static EventDanaRBolusProgress getInstance() {
|
||||
if(eventDanaRBolusProgress == null) {
|
||||
eventDanaRBolusProgress = new EventDanaRBolusProgress();
|
||||
}
|
||||
return eventDanaRBolusProgress;
|
||||
}
|
||||
|
||||
}
|
|
@ -19,7 +19,7 @@ import org.slf4j.LoggerFactory;
|
|||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRBolusProgress;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
|
||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRBolusStart;
|
||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRConnectionStatus;
|
||||
|
||||
|
@ -80,7 +80,7 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
|
|||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventDanaRBolusProgress ev) {
|
||||
public void onStatusEvent(final EventOverviewBolusProgress ev) {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null) {
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
package info.nightscout.androidaps.plugins.Overview.events;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.db.Treatment;
|
||||
|
||||
public class EventOverviewBolusProgress {
|
||||
private static Logger log = LoggerFactory.getLogger(EventOverviewBolusProgress.class);
|
||||
public String status = "";
|
||||
public Treatment t = null;
|
||||
public int percent = 0;
|
||||
private static EventOverviewBolusProgress eventOverviewBolusProgress = null;
|
||||
|
||||
public EventOverviewBolusProgress() {
|
||||
}
|
||||
|
||||
public static EventOverviewBolusProgress getInstance() {
|
||||
if(eventOverviewBolusProgress == null) {
|
||||
eventOverviewBolusProgress = new EventOverviewBolusProgress();
|
||||
}
|
||||
return eventOverviewBolusProgress;
|
||||
}
|
||||
|
||||
}
|
|
@ -17,6 +17,7 @@ import info.nightscout.androidaps.data.PumpEnactResult;
|
|||
import info.nightscout.androidaps.db.TempBasal;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
|
||||
import info.nightscout.androidaps.plugins.VirtualPump.events.EventVirtualPumpUpdateGui;
|
||||
import info.nightscout.client.data.NSProfile;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
|
@ -144,6 +145,32 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
|
|||
result.carbsDelivered = carbs;
|
||||
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
|
||||
|
||||
Double delivering = 0d;
|
||||
|
||||
while (delivering < insulin) {
|
||||
try {
|
||||
Thread.sleep(200);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance();
|
||||
bolusingEvent.status = String.format(MainApp.sResources.getString(R.string.bolusdelivering), delivering);
|
||||
bolusingEvent.percent = Math.min((int) (delivering / insulin * 100), 100);
|
||||
MainApp.bus().post(bolusingEvent);
|
||||
delivering += 0.1d;
|
||||
}
|
||||
try {
|
||||
Thread.sleep(200);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance();
|
||||
bolusingEvent.status = String.format(MainApp.sResources.getString(R.string.bolusdelivered), insulin);
|
||||
bolusingEvent.percent = 100;
|
||||
MainApp.bus().post(bolusingEvent);
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
|
||||
if (Config.logPumpComm)
|
||||
log.debug("Delivering treatment insulin: " + insulin + "U carbs: " + carbs + "g " + result);
|
||||
MainApp.bus().post(new EventVirtualPumpUpdateGui());
|
||||
|
|
|
@ -301,4 +301,5 @@
|
|||
<string name="objectives_6_objective">Povolit další fukce pro běžné používání jako AMA</string>
|
||||
<string name="youareonallowedlimit">Dosaženo limitu</string>
|
||||
<string name="openapsma_target_bg">Cílová hodnota pro výpočty</string>
|
||||
<string name="bolusdelivering" formatted="false">Aplikováno %.2fU</string>
|
||||
</resources>
|
|
@ -243,6 +243,7 @@
|
|||
<string name="replywithcode" formatted="false">To deliver bolus %.2fU reply with code %s</string>
|
||||
<string name="bolusfailed">Bolus failed</string>
|
||||
<string name="bolusdelivered" formatted="false">Bolus %.2fU delivered successfully</string>
|
||||
<string name="bolusdelivering" formatted="false">Delivering %.2fU</string>
|
||||
<string name="smscommunicator_remotebolusingallowed">Allow remote bolusing via SMS</string>
|
||||
<string name="remotebolusnotallowed">Remote bolus not allowed</string>
|
||||
<string name="glucosetype_finger">Finger</string>
|
||||
|
|
Loading…
Add table
Reference in a new issue