pump status tweaking
This commit is contained in:
parent
de124b8e3e
commit
5f4eb1e4c4
21 changed files with 263 additions and 286 deletions
|
@ -0,0 +1,50 @@
|
||||||
|
package info.nightscout.androidaps.events;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
import info.nightscout.androidaps.R;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by mike on 19.02.2017.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class EventPumpStatusChanged {
|
||||||
|
public static final int CONNECTING = 0;
|
||||||
|
public static final int CONNECTED = 1;
|
||||||
|
public static final int PERFORMING = 2;
|
||||||
|
public static final int DISCONNECTING = 3;
|
||||||
|
public static final int DISCONNECTED = 4;
|
||||||
|
|
||||||
|
public int sStatus = DISCONNECTED;
|
||||||
|
public int sSecondsElapsed = 0;
|
||||||
|
public String sPerfomingAction = "";
|
||||||
|
|
||||||
|
public EventPumpStatusChanged(int status) {
|
||||||
|
sStatus = status;
|
||||||
|
sSecondsElapsed = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EventPumpStatusChanged(int status, int secondsElapsed) {
|
||||||
|
sStatus = status;
|
||||||
|
sSecondsElapsed = secondsElapsed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EventPumpStatusChanged(String action) {
|
||||||
|
sStatus = PERFORMING;
|
||||||
|
sSecondsElapsed = 0;
|
||||||
|
sPerfomingAction = action;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String textStatus() {
|
||||||
|
if (sStatus == CONNECTING)
|
||||||
|
return String.format(MainApp.sResources.getString(R.string.danar_history_connectingfor), sSecondsElapsed);
|
||||||
|
else if (sStatus == CONNECTED)
|
||||||
|
return MainApp.sResources.getString(R.string.connected);
|
||||||
|
else if (sStatus == PERFORMING)
|
||||||
|
return sPerfomingAction;
|
||||||
|
else if (sStatus == DISCONNECTING)
|
||||||
|
return MainApp.sResources.getString(R.string.disconnecting);
|
||||||
|
else if (sStatus == DISCONNECTED)
|
||||||
|
return "";
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
|
@ -29,8 +29,8 @@ public interface PumpInterface {
|
||||||
int setNewBasalProfile(NSProfile profile);
|
int setNewBasalProfile(NSProfile profile);
|
||||||
boolean isThisProfileSet(NSProfile profile);
|
boolean isThisProfileSet(NSProfile profile);
|
||||||
|
|
||||||
Date lastStatusTime();
|
Date lastDataTime();
|
||||||
void updateStatus(String reason);
|
void refreshDataFromPump(String reason);
|
||||||
|
|
||||||
double getBaseBasalRate(); // base basal rate, not temp basal
|
double getBaseBasalRate(); // base basal rate, not temp basal
|
||||||
double getTempBasalAbsoluteRate();
|
double getTempBasalAbsoluteRate();
|
||||||
|
@ -51,7 +51,9 @@ public interface PumpInterface {
|
||||||
JSONObject getJSONStatus();
|
JSONObject getJSONStatus();
|
||||||
String deviceID();
|
String deviceID();
|
||||||
|
|
||||||
|
// Pump capabilities
|
||||||
PumpDescription getPumpDescription();
|
PumpDescription getPumpDescription();
|
||||||
|
|
||||||
public String shortStatus(boolean veryShort);
|
// Short info for SMS, Wear etc
|
||||||
|
String shortStatus(boolean veryShort);
|
||||||
}
|
}
|
||||||
|
|
|
@ -390,13 +390,13 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Date lastStatusTime() {
|
public Date lastDataTime() {
|
||||||
return activePump.lastStatusTime();
|
return activePump.lastDataTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateStatus(String reason) {
|
public void refreshDataFromPump(String reason) {
|
||||||
activePump.updateStatus(reason);
|
activePump.refreshDataFromPump(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -682,7 +682,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
||||||
public String deviceID() {
|
public String deviceID() {
|
||||||
if (activePump != null)
|
if (activePump != null)
|
||||||
return activePump.deviceID();
|
return activePump.deviceID();
|
||||||
else return "Unknown";
|
else return "No Pump active!";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -24,12 +24,12 @@ import java.util.Date;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||||
import info.nightscout.androidaps.interfaces.FragmentBase;
|
import info.nightscout.androidaps.interfaces.FragmentBase;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.Dialogs.ProfileViewDialog;
|
import info.nightscout.androidaps.plugins.DanaR.Dialogs.ProfileViewDialog;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.History.DanaRHistoryActivity;
|
import info.nightscout.androidaps.plugins.DanaR.History.DanaRHistoryActivity;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.History.DanaRStatsActivity;
|
import info.nightscout.androidaps.plugins.DanaR.History.DanaRStatsActivity;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRConnectionStatus;
|
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRNewStatus;
|
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRNewStatus;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
|
@ -165,18 +165,18 @@ public class DanaRFragment extends Fragment implements FragmentBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventDanaRConnectionStatus c) {
|
public void onStatusEvent(final EventPumpStatusChanged c) {
|
||||||
Activity activity = getActivity();
|
Activity activity = getActivity();
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
activity.runOnUiThread(
|
activity.runOnUiThread(
|
||||||
new Runnable() {
|
new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (c.sStatus == EventDanaRConnectionStatus.CONNECTING)
|
if (c.sStatus == EventPumpStatusChanged.CONNECTING)
|
||||||
btConnectionView.setText("{fa-bluetooth-b spin} " + c.sSecondsElapsed + "s");
|
btConnectionView.setText("{fa-bluetooth-b spin} " + c.sSecondsElapsed + "s");
|
||||||
else if (c.sStatus == EventDanaRConnectionStatus.CONNECTED)
|
else if (c.sStatus == EventPumpStatusChanged.CONNECTED)
|
||||||
btConnectionView.setText("{fa-bluetooth}");
|
btConnectionView.setText("{fa-bluetooth}");
|
||||||
else
|
else if (c.sStatus == EventPumpStatusChanged.DISCONNECTED)
|
||||||
btConnectionView.setText("{fa-bluetooth-b}");
|
btConnectionView.setText("{fa-bluetooth-b}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -285,12 +285,12 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Date lastStatusTime() {
|
public Date lastDataTime() {
|
||||||
return getDanaRPump().lastConnection;
|
return getDanaRPump().lastConnection;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateStatus(String reason) {
|
public void refreshDataFromPump(String reason) {
|
||||||
if (!isConnected() && !isConnecting()) {
|
if (!isConnected() && !isConnecting()) {
|
||||||
doConnect(reason);
|
doConnect(reason);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,10 +38,10 @@ 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.db.DanaRHistoryRecord;
|
import info.nightscout.androidaps.db.DanaRHistoryRecord;
|
||||||
|
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.Services.ExecutionService;
|
import info.nightscout.androidaps.plugins.DanaR.Services.ExecutionService;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.comm.RecordTypes;
|
import info.nightscout.androidaps.plugins.DanaR.comm.RecordTypes;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRConnectionStatus;
|
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRSyncStatus;
|
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRSyncStatus;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
|
@ -434,21 +434,12 @@ public class DanaRHistoryActivity extends Activity {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventDanaRConnectionStatus c) {
|
public void onStatusEvent(final EventPumpStatusChanged s) {
|
||||||
runOnUiThread(
|
runOnUiThread(
|
||||||
new Runnable() {
|
new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (c.sStatus == EventDanaRConnectionStatus.CONNECTING) {
|
statusView.setText(s.textStatus());
|
||||||
statusView.setText(String.format(getString(R.string.danar_history_connectingfor), c.sSecondsElapsed));
|
|
||||||
log.debug("EventDanaRConnectionStatus: " + "Connecting for " + c.sSecondsElapsed + "s");
|
|
||||||
} else if (c.sStatus == EventDanaRConnectionStatus.CONNECTED) {
|
|
||||||
statusView.setText(MainApp.sResources.getString(R.string.connected));
|
|
||||||
log.debug("EventDanaRConnectionStatus: Connected");
|
|
||||||
} else {
|
|
||||||
statusView.setText(MainApp.sResources.getString(R.string.disconnected));
|
|
||||||
log.debug("EventDanaRConnectionStatus: Disconnected");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -48,12 +48,12 @@ import java.util.List;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.db.DanaRHistoryRecord;
|
import info.nightscout.androidaps.db.DanaRHistoryRecord;
|
||||||
|
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||||
import info.nightscout.androidaps.plugins.CircadianPercentageProfile.CircadianPercentageProfilePlugin;
|
import info.nightscout.androidaps.plugins.CircadianPercentageProfile.CircadianPercentageProfilePlugin;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.Services.ExecutionService;
|
import info.nightscout.androidaps.plugins.DanaR.Services.ExecutionService;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.comm.RecordTypes;
|
import info.nightscout.androidaps.plugins.DanaR.comm.RecordTypes;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRConnectionStatus;
|
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRSyncStatus;
|
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRSyncStatus;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
import info.nightscout.utils.SafeParse;
|
import info.nightscout.utils.SafeParse;
|
||||||
|
@ -365,8 +365,7 @@ public class DanaRStatsActivity extends Activity {
|
||||||
if (TextUtils.isEmpty(TBB)) {
|
if (TextUtils.isEmpty(TBB)) {
|
||||||
totalBaseBasal.setError("Please Enter Total Base Basal");
|
totalBaseBasal.setError("Please Enter Total Base Basal");
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
magicNumber = SafeParse.stringToDouble(TBB);
|
magicNumber = SafeParse.stringToDouble(TBB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -549,21 +548,12 @@ public class DanaRStatsActivity extends Activity {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventDanaRConnectionStatus c) {
|
public void onStatusEvent(final EventPumpStatusChanged c) {
|
||||||
runOnUiThread(
|
runOnUiThread(
|
||||||
new Runnable() {
|
new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (c.sStatus == EventDanaRConnectionStatus.CONNECTING) {
|
statusView.setText(c.textStatus());
|
||||||
statusView.setText(String.format(getString(R.string.danar_history_connectingfor), c.sSecondsElapsed));
|
|
||||||
log.debug("EventDanaRConnectionStatus: " + "Connecting for " + c.sSecondsElapsed + "s");
|
|
||||||
} else if (c.sStatus == EventDanaRConnectionStatus.CONNECTED) {
|
|
||||||
statusView.setText(MainApp.sResources.getString(R.string.connected));
|
|
||||||
log.debug("EventDanaRConnectionStatus: Connected");
|
|
||||||
} else {
|
|
||||||
statusView.setText(MainApp.sResources.getString(R.string.disconnected));
|
|
||||||
log.debug("EventDanaRConnectionStatus: Disconnected");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -33,6 +33,7 @@ import info.nightscout.androidaps.db.Treatment;
|
||||||
import info.nightscout.androidaps.events.EventAppExit;
|
import info.nightscout.androidaps.events.EventAppExit;
|
||||||
import info.nightscout.androidaps.events.EventInitializationChanged;
|
import info.nightscout.androidaps.events.EventInitializationChanged;
|
||||||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||||
|
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.DanaRPlugin;
|
import info.nightscout.androidaps.plugins.DanaR.DanaRPlugin;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.DanaRPump;
|
import info.nightscout.androidaps.plugins.DanaR.DanaRPump;
|
||||||
|
@ -77,7 +78,6 @@ import info.nightscout.androidaps.plugins.DanaR.comm.MsgStatusBolusExtended;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.comm.MsgStatusTempBasal;
|
import info.nightscout.androidaps.plugins.DanaR.comm.MsgStatusTempBasal;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.comm.RecordTypes;
|
import info.nightscout.androidaps.plugins.DanaR.comm.RecordTypes;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRBolusStart;
|
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRBolusStart;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRConnectionStatus;
|
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRNewStatus;
|
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRNewStatus;
|
||||||
import info.nightscout.androidaps.plugins.Overview.Notification;
|
import info.nightscout.androidaps.plugins.Overview.Notification;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||||
|
@ -117,7 +117,7 @@ public class ExecutionService extends Service {
|
||||||
if (mSerialIOThread != null) {
|
if (mSerialIOThread != null) {
|
||||||
mSerialIOThread.disconnect("BT disconnection broadcast");
|
mSerialIOThread.disconnect("BT disconnection broadcast");
|
||||||
}
|
}
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.DISCONNECTED, 0));
|
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTED));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -207,7 +207,7 @@ public class ExecutionService extends Service {
|
||||||
long startTime = new Date().getTime();
|
long startTime = new Date().getTime();
|
||||||
while (!isConnected() && startTime + maxConnectionTime >= new Date().getTime()) {
|
while (!isConnected() && startTime + maxConnectionTime >= new Date().getTime()) {
|
||||||
long secondsElapsed = (new Date().getTime() - startTime) / 1000L;
|
long secondsElapsed = (new Date().getTime() - startTime) / 1000L;
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.CONNECTING, (int) secondsElapsed));
|
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTING, (int) secondsElapsed));
|
||||||
if (Config.logDanaBTComm)
|
if (Config.logDanaBTComm)
|
||||||
log.debug("connect waiting " + secondsElapsed + "sec from: " + from);
|
log.debug("connect waiting " + secondsElapsed + "sec from: " + from);
|
||||||
try {
|
try {
|
||||||
|
@ -226,18 +226,19 @@ public class ExecutionService extends Service {
|
||||||
mSerialIOThread.disconnect("Recreate SerialIOThread");
|
mSerialIOThread.disconnect("Recreate SerialIOThread");
|
||||||
}
|
}
|
||||||
mSerialIOThread = new SerialIOThread(mRfcommSocket);
|
mSerialIOThread = new SerialIOThread(mRfcommSocket);
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.CONNECTED, 0));
|
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTED, 0));
|
||||||
if (!getPumpStatus()) {
|
if (!getPumpStatus()) {
|
||||||
mSerialIOThread.disconnect("getPumpStatus failed");
|
mSerialIOThread.disconnect("getPumpStatus failed");
|
||||||
waitMsec(3000);
|
waitMsec(3000);
|
||||||
if (!MainApp.getSpecificPlugin(DanaRPlugin.class).isEnabled(PluginBase.PUMP))
|
if (!MainApp.getSpecificPlugin(DanaRPlugin.class).isEnabled(PluginBase.PUMP))
|
||||||
return;
|
return;
|
||||||
getBTSocketForSelectedPump();
|
getBTSocketForSelectedPump();
|
||||||
|
startTime = new Date().getTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!isConnected()) {
|
if (!isConnected()) {
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.DISCONNECTED, 0));
|
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTED));
|
||||||
log.error("Pump connection timed out");
|
log.error("Pump connection timed out");
|
||||||
}
|
}
|
||||||
connectionInProgress = false;
|
connectionInProgress = false;
|
||||||
|
@ -279,7 +280,7 @@ public class ExecutionService extends Service {
|
||||||
|
|
||||||
private boolean getPumpStatus() {
|
private boolean getPumpStatus() {
|
||||||
try {
|
try {
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.gettingpumpstatus)));
|
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingpumpstatus)));
|
||||||
MsgStatus statusMsg = new MsgStatus();
|
MsgStatus statusMsg = new MsgStatus();
|
||||||
MsgStatusBasic statusBasicMsg = new MsgStatusBasic();
|
MsgStatusBasic statusBasicMsg = new MsgStatusBasic();
|
||||||
MsgStatusTempBasal tempStatusMsg = new MsgStatusTempBasal();
|
MsgStatusTempBasal tempStatusMsg = new MsgStatusTempBasal();
|
||||||
|
@ -356,39 +357,40 @@ public class ExecutionService extends Service {
|
||||||
public boolean tempBasal(int percent, int durationInHours) {
|
public boolean tempBasal(int percent, int durationInHours) {
|
||||||
connect("tempBasal");
|
connect("tempBasal");
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.settingtempbasal)));
|
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.settingtempbasal)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetTempBasalStart(percent, durationInHours));
|
mSerialIOThread.sendMessage(new MsgSetTempBasalStart(percent, durationInHours));
|
||||||
mSerialIOThread.sendMessage(new MsgStatusTempBasal());
|
mSerialIOThread.sendMessage(new MsgStatusTempBasal());
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.disconnecting)));
|
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean tempBasalStop() {
|
public boolean tempBasalStop() {
|
||||||
connect("tempBasalStop");
|
connect("tempBasalStop");
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.stoppingtempbasal)));
|
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.stoppingtempbasal)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
|
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
|
||||||
mSerialIOThread.sendMessage(new MsgStatusTempBasal());
|
mSerialIOThread.sendMessage(new MsgStatusTempBasal());
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.disconnecting)));
|
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean extendedBolus(double insulin, int durationInHalfHours) {
|
public boolean extendedBolus(double insulin, int durationInHalfHours) {
|
||||||
connect("extendedBolus");
|
connect("extendedBolus");
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.settingextendedbolus)));
|
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.settingextendedbolus)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStart(insulin, (byte) (durationInHalfHours & 0xFF)));
|
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStart(insulin, (byte) (durationInHalfHours & 0xFF)));
|
||||||
mSerialIOThread.sendMessage(new MsgStatusBolusExtended());
|
mSerialIOThread.sendMessage(new MsgStatusBolusExtended());
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.disconnecting)));
|
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean extendedBolusStop() {
|
public boolean extendedBolusStop() {
|
||||||
connect("extendedBolusStop");
|
connect("extendedBolusStop");
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.stoppingextendedbolus)));
|
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.stoppingextendedbolus)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStop());
|
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStop());
|
||||||
mSerialIOThread.sendMessage(new MsgStatusBolusExtended());
|
mSerialIOThread.sendMessage(new MsgStatusBolusExtended());
|
||||||
|
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -500,7 +502,7 @@ public class ExecutionService extends Service {
|
||||||
public boolean updateBasalsInPump(final NSProfile profile) {
|
public boolean updateBasalsInPump(final NSProfile profile) {
|
||||||
connect("updateBasalsInPump");
|
connect("updateBasalsInPump");
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.updatingbasalrates)));
|
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.updatingbasalrates)));
|
||||||
double[] basal = buildDanaRProfileRecord(profile);
|
double[] basal = buildDanaRProfileRecord(profile);
|
||||||
MsgSetBasalProfile msgSet = new MsgSetBasalProfile((byte) 0, basal);
|
MsgSetBasalProfile msgSet = new MsgSetBasalProfile((byte) 0, basal);
|
||||||
mSerialIOThread.sendMessage(msgSet);
|
mSerialIOThread.sendMessage(msgSet);
|
||||||
|
@ -508,7 +510,7 @@ public class ExecutionService extends Service {
|
||||||
mSerialIOThread.sendMessage(msgActivate);
|
mSerialIOThread.sendMessage(msgActivate);
|
||||||
danaRPump.lastSettingsRead = new Date(0); // force read full settings
|
danaRPump.lastSettingsRead = new Date(0); // force read full settings
|
||||||
getPumpStatus();
|
getPumpStatus();
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.disconnecting)));
|
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.DanaR.events;
|
|
||||||
|
|
||||||
public class EventDanaRConnectionStatus {
|
|
||||||
public static final int CONNECTING = 0;
|
|
||||||
public static final int CONNECTED = 1;
|
|
||||||
public static final int DISCONNECTED = 2;
|
|
||||||
public static final int PERFORMING = 3;
|
|
||||||
|
|
||||||
public int sStatus = DISCONNECTED;
|
|
||||||
public int sSecondsElapsed = 0;
|
|
||||||
public String sAction = "";
|
|
||||||
|
|
||||||
public EventDanaRConnectionStatus(int status, int secondsElapsed) {
|
|
||||||
sStatus = status;
|
|
||||||
sSecondsElapsed = secondsElapsed;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EventDanaRConnectionStatus(int status, int secondsElapsed, String action) {
|
|
||||||
sStatus = status;
|
|
||||||
sSecondsElapsed = secondsElapsed;
|
|
||||||
sAction = action;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -24,10 +24,10 @@ import java.util.Date;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||||
import info.nightscout.androidaps.interfaces.FragmentBase;
|
import info.nightscout.androidaps.interfaces.FragmentBase;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.Dialogs.ProfileViewDialog;
|
import info.nightscout.androidaps.plugins.DanaR.Dialogs.ProfileViewDialog;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRConnectionStatus;
|
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRNewStatus;
|
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRNewStatus;
|
||||||
import info.nightscout.androidaps.plugins.DanaRKorean.History.DanaRHistoryActivity;
|
import info.nightscout.androidaps.plugins.DanaRKorean.History.DanaRHistoryActivity;
|
||||||
import info.nightscout.androidaps.plugins.DanaRKorean.History.DanaRStatsActivity;
|
import info.nightscout.androidaps.plugins.DanaRKorean.History.DanaRStatsActivity;
|
||||||
|
@ -162,18 +162,18 @@ public class DanaRKoreanFragment extends Fragment implements FragmentBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventDanaRConnectionStatus c) {
|
public void onStatusEvent(final EventPumpStatusChanged c) {
|
||||||
Activity activity = getActivity();
|
Activity activity = getActivity();
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
activity.runOnUiThread(
|
activity.runOnUiThread(
|
||||||
new Runnable() {
|
new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (c.sStatus == EventDanaRConnectionStatus.CONNECTING)
|
if (c.sStatus == EventPumpStatusChanged.CONNECTING)
|
||||||
btConnectionView.setText("{fa-bluetooth-b spin} " + c.sSecondsElapsed + "s");
|
btConnectionView.setText("{fa-bluetooth-b spin} " + c.sSecondsElapsed + "s");
|
||||||
else if (c.sStatus == EventDanaRConnectionStatus.CONNECTED)
|
else if (c.sStatus == EventPumpStatusChanged.CONNECTED)
|
||||||
btConnectionView.setText("{fa-bluetooth}");
|
btConnectionView.setText("{fa-bluetooth}");
|
||||||
else
|
else if (c.sStatus == EventPumpStatusChanged.DISCONNECTED)
|
||||||
btConnectionView.setText("{fa-bluetooth-b}");
|
btConnectionView.setText("{fa-bluetooth-b}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,6 +72,8 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
|
||||||
return sDanaRKoreanPump;
|
return sDanaRKoreanPump;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String textStatus = "";
|
||||||
|
|
||||||
public DanaRKoreanPlugin() {
|
public DanaRKoreanPlugin() {
|
||||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
||||||
useExtendedBoluses = sharedPreferences.getBoolean("danar_useextended", false);
|
useExtendedBoluses = sharedPreferences.getBoolean("danar_useextended", false);
|
||||||
|
@ -285,12 +287,12 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Date lastStatusTime() {
|
public Date lastDataTime() {
|
||||||
return getDanaRPump().lastConnection;
|
return getDanaRPump().lastConnection;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateStatus(String reason) {
|
public void refreshDataFromPump(String reason) {
|
||||||
if (!isConnected() && !isConnecting()) {
|
if (!isConnected() && !isConnecting()) {
|
||||||
doConnect(reason);
|
doConnect(reason);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,10 +38,10 @@ 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.db.DanaRHistoryRecord;
|
import info.nightscout.androidaps.db.DanaRHistoryRecord;
|
||||||
|
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.History.DanaRNSHistorySync;
|
import info.nightscout.androidaps.plugins.DanaR.History.DanaRNSHistorySync;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.comm.RecordTypes;
|
import info.nightscout.androidaps.plugins.DanaR.comm.RecordTypes;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRConnectionStatus;
|
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRSyncStatus;
|
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRSyncStatus;
|
||||||
import info.nightscout.androidaps.plugins.DanaRKorean.Services.ExecutionService;
|
import info.nightscout.androidaps.plugins.DanaRKorean.Services.ExecutionService;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
||||||
|
@ -433,21 +433,12 @@ public class DanaRHistoryActivity extends Activity {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventDanaRConnectionStatus c) {
|
public void onStatusEvent(final EventPumpStatusChanged c) {
|
||||||
runOnUiThread(
|
runOnUiThread(
|
||||||
new Runnable() {
|
new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (c.sStatus == EventDanaRConnectionStatus.CONNECTING) {
|
statusView.setText(c.textStatus());
|
||||||
statusView.setText(String.format(getString(R.string.danar_history_connectingfor), c.sSecondsElapsed));
|
|
||||||
log.debug("EventDanaRConnectionStatus: " + "Connecting for " + c.sSecondsElapsed + "s");
|
|
||||||
} else if (c.sStatus == EventDanaRConnectionStatus.CONNECTED) {
|
|
||||||
statusView.setText(MainApp.sResources.getString(R.string.connected));
|
|
||||||
log.debug("EventDanaRConnectionStatus: Connected");
|
|
||||||
} else {
|
|
||||||
statusView.setText(MainApp.sResources.getString(R.string.disconnected));
|
|
||||||
log.debug("EventDanaRConnectionStatus: Disconnected");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -48,11 +48,11 @@ import java.util.List;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.db.DanaRHistoryRecord;
|
import info.nightscout.androidaps.db.DanaRHistoryRecord;
|
||||||
|
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||||
import info.nightscout.androidaps.plugins.CircadianPercentageProfile.CircadianPercentageProfilePlugin;
|
import info.nightscout.androidaps.plugins.CircadianPercentageProfile.CircadianPercentageProfilePlugin;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.comm.RecordTypes;
|
import info.nightscout.androidaps.plugins.DanaR.comm.RecordTypes;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRConnectionStatus;
|
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRSyncStatus;
|
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRSyncStatus;
|
||||||
import info.nightscout.androidaps.plugins.DanaRKorean.Services.ExecutionService;
|
import info.nightscout.androidaps.plugins.DanaRKorean.Services.ExecutionService;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
|
@ -365,8 +365,7 @@ public class DanaRStatsActivity extends Activity {
|
||||||
if (TextUtils.isEmpty(TBB)) {
|
if (TextUtils.isEmpty(TBB)) {
|
||||||
totalBaseBasal.setError("Please Enter Total Base Basal");
|
totalBaseBasal.setError("Please Enter Total Base Basal");
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
magicNumber = SafeParse.stringToDouble(TBB);
|
magicNumber = SafeParse.stringToDouble(TBB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -549,21 +548,12 @@ public class DanaRStatsActivity extends Activity {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventDanaRConnectionStatus c) {
|
public void onStatusEvent(final EventPumpStatusChanged c) {
|
||||||
runOnUiThread(
|
runOnUiThread(
|
||||||
new Runnable() {
|
new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (c.sStatus == EventDanaRConnectionStatus.CONNECTING) {
|
statusView.setText(c.textStatus());
|
||||||
statusView.setText(String.format(getString(R.string.danar_history_connectingfor), c.sSecondsElapsed));
|
|
||||||
log.debug("EventDanaRConnectionStatus: " + "Connecting for " + c.sSecondsElapsed + "s");
|
|
||||||
} else if (c.sStatus == EventDanaRConnectionStatus.CONNECTED) {
|
|
||||||
statusView.setText(MainApp.sResources.getString(R.string.connected));
|
|
||||||
log.debug("EventDanaRConnectionStatus: Connected");
|
|
||||||
} else {
|
|
||||||
statusView.setText(MainApp.sResources.getString(R.string.disconnected));
|
|
||||||
log.debug("EventDanaRConnectionStatus: Disconnected");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -31,6 +31,7 @@ import info.nightscout.androidaps.db.Treatment;
|
||||||
import info.nightscout.androidaps.events.EventAppExit;
|
import info.nightscout.androidaps.events.EventAppExit;
|
||||||
import info.nightscout.androidaps.events.EventInitializationChanged;
|
import info.nightscout.androidaps.events.EventInitializationChanged;
|
||||||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||||
|
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.comm.MessageBase;
|
import info.nightscout.androidaps.plugins.DanaR.comm.MessageBase;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.comm.MsgBolusProgress;
|
import info.nightscout.androidaps.plugins.DanaR.comm.MsgBolusProgress;
|
||||||
|
@ -57,7 +58,6 @@ import info.nightscout.androidaps.plugins.DanaR.comm.MsgSetTempBasalStop;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.comm.MsgSetTime;
|
import info.nightscout.androidaps.plugins.DanaR.comm.MsgSetTime;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.comm.RecordTypes;
|
import info.nightscout.androidaps.plugins.DanaR.comm.RecordTypes;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRBolusStart;
|
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRBolusStart;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRConnectionStatus;
|
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRNewStatus;
|
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRNewStatus;
|
||||||
import info.nightscout.androidaps.plugins.DanaRKorean.DanaRKoreanPlugin;
|
import info.nightscout.androidaps.plugins.DanaRKorean.DanaRKoreanPlugin;
|
||||||
import info.nightscout.androidaps.plugins.DanaRKorean.DanaRKoreanPump;
|
import info.nightscout.androidaps.plugins.DanaRKorean.DanaRKoreanPump;
|
||||||
|
@ -110,7 +110,7 @@ public class ExecutionService extends Service {
|
||||||
if (mSerialIOThread != null) {
|
if (mSerialIOThread != null) {
|
||||||
mSerialIOThread.disconnect("BT disconnection broadcast");
|
mSerialIOThread.disconnect("BT disconnection broadcast");
|
||||||
}
|
}
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.DISCONNECTED, 0));
|
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTED));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -200,7 +200,7 @@ public class ExecutionService extends Service {
|
||||||
long startTime = new Date().getTime();
|
long startTime = new Date().getTime();
|
||||||
while (!isConnected() && startTime + maxConnectionTime >= new Date().getTime()) {
|
while (!isConnected() && startTime + maxConnectionTime >= new Date().getTime()) {
|
||||||
long secondsElapsed = (new Date().getTime() - startTime) / 1000L;
|
long secondsElapsed = (new Date().getTime() - startTime) / 1000L;
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.CONNECTING, (int) secondsElapsed));
|
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTING, (int) secondsElapsed));
|
||||||
if (Config.logDanaBTComm)
|
if (Config.logDanaBTComm)
|
||||||
log.debug("connect waiting " + secondsElapsed + "sec from: " + from);
|
log.debug("connect waiting " + secondsElapsed + "sec from: " + from);
|
||||||
try {
|
try {
|
||||||
|
@ -219,18 +219,19 @@ public class ExecutionService extends Service {
|
||||||
mSerialIOThread.disconnect("Recreate SerialIOThread");
|
mSerialIOThread.disconnect("Recreate SerialIOThread");
|
||||||
}
|
}
|
||||||
mSerialIOThread = new SerialIOThread(mRfcommSocket);
|
mSerialIOThread = new SerialIOThread(mRfcommSocket);
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.CONNECTED, 0));
|
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTED));
|
||||||
if (!getPumpStatus()) {
|
if (!getPumpStatus()) {
|
||||||
mSerialIOThread.disconnect("getPumpStatus failed");
|
mSerialIOThread.disconnect("getPumpStatus failed");
|
||||||
waitMsec(3000);
|
waitMsec(3000);
|
||||||
if (!MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).isEnabled(PluginBase.PUMP))
|
if (!MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).isEnabled(PluginBase.PUMP))
|
||||||
return;
|
return;
|
||||||
getBTSocketForSelectedPump();
|
getBTSocketForSelectedPump();
|
||||||
|
startTime = new Date().getTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!isConnected()) {
|
if (!isConnected()) {
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.DISCONNECTED, 0));
|
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTED));
|
||||||
log.error("Pump connection timed out");
|
log.error("Pump connection timed out");
|
||||||
}
|
}
|
||||||
connectionInProgress = false;
|
connectionInProgress = false;
|
||||||
|
@ -272,7 +273,7 @@ public class ExecutionService extends Service {
|
||||||
|
|
||||||
private boolean getPumpStatus() {
|
private boolean getPumpStatus() {
|
||||||
try {
|
try {
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.gettingpumpstatus)));
|
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingpumpstatus)));
|
||||||
//MsgStatus statusMsg = new MsgStatus();
|
//MsgStatus statusMsg = new MsgStatus();
|
||||||
MsgStatusBasic statusBasicMsg = new MsgStatusBasic();
|
MsgStatusBasic statusBasicMsg = new MsgStatusBasic();
|
||||||
MsgStatusTempBasal tempStatusMsg = new MsgStatusTempBasal();
|
MsgStatusTempBasal tempStatusMsg = new MsgStatusTempBasal();
|
||||||
|
@ -347,40 +348,40 @@ public class ExecutionService extends Service {
|
||||||
public boolean tempBasal(int percent, int durationInHours) {
|
public boolean tempBasal(int percent, int durationInHours) {
|
||||||
connect("tempBasal");
|
connect("tempBasal");
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.settingtempbasal)));
|
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.settingtempbasal)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetTempBasalStart(percent, durationInHours));
|
mSerialIOThread.sendMessage(new MsgSetTempBasalStart(percent, durationInHours));
|
||||||
mSerialIOThread.sendMessage(new MsgStatusTempBasal());
|
mSerialIOThread.sendMessage(new MsgStatusTempBasal());
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.disconnecting)));
|
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean tempBasalStop() {
|
public boolean tempBasalStop() {
|
||||||
connect("tempBasalStop");
|
connect("tempBasalStop");
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.stoppingtempbasal)));
|
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.stoppingtempbasal)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
|
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
|
||||||
mSerialIOThread.sendMessage(new MsgStatusTempBasal());
|
mSerialIOThread.sendMessage(new MsgStatusTempBasal());
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.disconnecting)));
|
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean extendedBolus(double insulin, int durationInHalfHours) {
|
public boolean extendedBolus(double insulin, int durationInHalfHours) {
|
||||||
connect("extendedBolus");
|
connect("extendedBolus");
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.settingextendedbolus)));
|
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.settingextendedbolus)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStart(insulin, (byte) (durationInHalfHours & 0xFF)));
|
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStart(insulin, (byte) (durationInHalfHours & 0xFF)));
|
||||||
mSerialIOThread.sendMessage(new MsgStatusBolusExtended());
|
mSerialIOThread.sendMessage(new MsgStatusBolusExtended());
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.disconnecting)));
|
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean extendedBolusStop() {
|
public boolean extendedBolusStop() {
|
||||||
connect("extendedBolusStop");
|
connect("extendedBolusStop");
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.stoppingextendedbolus)));
|
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.stoppingextendedbolus)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStop());
|
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStop());
|
||||||
mSerialIOThread.sendMessage(new MsgStatusBolusExtended());
|
mSerialIOThread.sendMessage(new MsgStatusBolusExtended());
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.disconnecting)));
|
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -493,13 +494,13 @@ public class ExecutionService extends Service {
|
||||||
public boolean updateBasalsInPump(final NSProfile profile) {
|
public boolean updateBasalsInPump(final NSProfile profile) {
|
||||||
connect("updateBasalsInPump");
|
connect("updateBasalsInPump");
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.updatingbasalrates)));
|
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.updatingbasalrates)));
|
||||||
double[] basal = buildDanaRProfileRecord(profile);
|
double[] basal = buildDanaRProfileRecord(profile);
|
||||||
MsgSetSingleBasalProfile msgSet = new MsgSetSingleBasalProfile(basal);
|
MsgSetSingleBasalProfile msgSet = new MsgSetSingleBasalProfile(basal);
|
||||||
mSerialIOThread.sendMessage(msgSet);
|
mSerialIOThread.sendMessage(msgSet);
|
||||||
danaRKoreanPump.lastSettingsRead = new Date(0); // force read full settings
|
danaRKoreanPump.lastSettingsRead = new Date(0); // force read full settings
|
||||||
getPumpStatus();
|
getPumpStatus();
|
||||||
MainApp.bus().post(new EventDanaRConnectionStatus(EventDanaRConnectionStatus.PERFORMING, 0, MainApp.sResources.getString(R.string.disconnecting)));
|
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -143,12 +143,12 @@ public class MDIPlugin implements PluginBase, PumpInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Date lastStatusTime() {
|
public Date lastDataTime() {
|
||||||
return new Date();
|
return new Date();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateStatus(String reason) {
|
public void refreshDataFromPump(String reason) {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,10 +18,10 @@ 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.events.EventPumpStatusChanged;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
|
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRBolusStart;
|
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRBolusStart;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRConnectionStatus;
|
|
||||||
|
|
||||||
public class BolusProgressDialog extends DialogFragment implements View.OnClickListener {
|
public class BolusProgressDialog extends DialogFragment implements View.OnClickListener {
|
||||||
private static Logger log = LoggerFactory.getLogger(BolusProgressDialog.class);
|
private static Logger log = LoggerFactory.getLogger(BolusProgressDialog.class);
|
||||||
|
@ -128,7 +128,7 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventDanaRConnectionStatus c) {
|
public void onStatusEvent(final EventPumpStatusChanged c) {
|
||||||
|
|
||||||
Activity activity = getActivity();
|
Activity activity = getActivity();
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
|
@ -136,14 +136,7 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
|
||||||
new Runnable() {
|
new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (c.sStatus == c.CONNECTING) {
|
statusView.setText(c.textStatus());
|
||||||
statusView.setText(String.format(MainApp.sResources.getString(R.string.danar_history_connectingfor), c.sSecondsElapsed));
|
|
||||||
} else if (c.sStatus == c.CONNECTED) {
|
|
||||||
statusView.setText(MainApp.sResources.getString(R.string.connected));
|
|
||||||
} else {
|
|
||||||
statusView.setText(MainApp.sResources.getString(R.string.disconnected));
|
|
||||||
if (started) scheduleDismiss();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -63,6 +63,7 @@ import info.nightscout.androidaps.events.EventInitializationChanged;
|
||||||
import info.nightscout.androidaps.events.EventNewBG;
|
import info.nightscout.androidaps.events.EventNewBG;
|
||||||
import info.nightscout.androidaps.events.EventNewBasalProfile;
|
import info.nightscout.androidaps.events.EventNewBasalProfile;
|
||||||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||||
|
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||||
import info.nightscout.androidaps.events.EventRefreshGui;
|
import info.nightscout.androidaps.events.EventRefreshGui;
|
||||||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||||
import info.nightscout.androidaps.events.EventTreatmentChange;
|
import info.nightscout.androidaps.events.EventTreatmentChange;
|
||||||
|
@ -71,7 +72,6 @@ import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
|
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
|
||||||
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
|
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRConnectionStatus;
|
|
||||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Loop.events.EventNewOpenLoopNotification;
|
import info.nightscout.androidaps.plugins.Loop.events.EventNewOpenLoopNotification;
|
||||||
import info.nightscout.androidaps.plugins.Objectives.ObjectivesPlugin;
|
import info.nightscout.androidaps.plugins.Objectives.ObjectivesPlugin;
|
||||||
|
@ -93,7 +93,6 @@ import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
import info.nightscout.utils.Round;
|
import info.nightscout.utils.Round;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
import info.nightscout.utils.SafeParse;
|
|
||||||
|
|
||||||
|
|
||||||
public class OverviewFragment extends Fragment {
|
public class OverviewFragment extends Fragment {
|
||||||
|
@ -118,6 +117,8 @@ public class OverviewFragment extends Fragment {
|
||||||
TextView apsModeView;
|
TextView apsModeView;
|
||||||
TextView tempTargetView;
|
TextView tempTargetView;
|
||||||
TextView pumpStatusView;
|
TextView pumpStatusView;
|
||||||
|
LinearLayout loopStatusLayout;
|
||||||
|
LinearLayout pumpStatusLayout;
|
||||||
GraphView bgGraph;
|
GraphView bgGraph;
|
||||||
CheckBox showPredictionView;
|
CheckBox showPredictionView;
|
||||||
|
|
||||||
|
@ -162,7 +163,9 @@ public class OverviewFragment extends Fragment {
|
||||||
baseBasalView = (TextView) view.findViewById(R.id.overview_basebasal);
|
baseBasalView = (TextView) view.findViewById(R.id.overview_basebasal);
|
||||||
basalLayout = (LinearLayout) view.findViewById(R.id.overview_basallayout);
|
basalLayout = (LinearLayout) view.findViewById(R.id.overview_basallayout);
|
||||||
activeProfileView = (TextView) view.findViewById(R.id.overview_activeprofile);
|
activeProfileView = (TextView) view.findViewById(R.id.overview_activeprofile);
|
||||||
pumpStatusView = (TextView) view.findViewById(R.id.overview_initializing);
|
pumpStatusView = (TextView) view.findViewById(R.id.overview_pumpstatus);
|
||||||
|
loopStatusLayout = (LinearLayout) view.findViewById(R.id.overview_looplayout);
|
||||||
|
pumpStatusLayout = (LinearLayout) view.findViewById(R.id.overview_pumpstatuslayout);
|
||||||
|
|
||||||
iobView = (TextView) view.findViewById(R.id.overview_iob);
|
iobView = (TextView) view.findViewById(R.id.overview_iob);
|
||||||
apsModeView = (TextView) view.findViewById(R.id.overview_apsmode);
|
apsModeView = (TextView) view.findViewById(R.id.overview_apsmode);
|
||||||
|
@ -295,7 +298,7 @@ public class OverviewFragment extends Fragment {
|
||||||
sHandler.post(new Runnable() {
|
sHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
MainApp.getConfigBuilder().updateStatus("RefreshClicked");
|
MainApp.getConfigBuilder().refreshDataFromPump("RefreshClicked");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -477,18 +480,13 @@ public class OverviewFragment extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventDanaRConnectionStatus s) {
|
public void onStatusEvent(final EventPumpStatusChanged s) {
|
||||||
Activity activity = getActivity();
|
Activity activity = getActivity();
|
||||||
if (activity != null)
|
if (activity != null)
|
||||||
activity.runOnUiThread(new Runnable() {
|
activity.runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (s.sStatus == EventDanaRConnectionStatus.CONNECTING)
|
updatePumpStatus(s.textStatus());
|
||||||
updatePumpStatus(String.format(getString(R.string.danar_history_connectingfor), s.sSecondsElapsed));
|
|
||||||
else if (s.sStatus == EventDanaRConnectionStatus.PERFORMING)
|
|
||||||
updatePumpStatus(s.sAction);
|
|
||||||
else if (s.sStatus == EventDanaRConnectionStatus.DISCONNECTED)
|
|
||||||
updatePumpStatus(null);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -517,30 +515,15 @@ public class OverviewFragment extends Fragment {
|
||||||
|
|
||||||
private void updatePumpStatus(String status) {
|
private void updatePumpStatus(String status) {
|
||||||
PumpInterface pump = MainApp.getConfigBuilder();
|
PumpInterface pump = MainApp.getConfigBuilder();
|
||||||
if (status != null) {
|
if (!status.equals("")) {
|
||||||
pumpStatusView.setText(status);
|
pumpStatusView.setText(status);
|
||||||
pumpStatusView.setVisibility(View.VISIBLE);
|
pumpStatusLayout.setVisibility(View.VISIBLE);
|
||||||
} else if (pump.isBusy()) {
|
loopStatusLayout.setVisibility(View.GONE);
|
||||||
pumpStatusView.setText(R.string.pumpbusy);
|
|
||||||
pumpStatusView.setVisibility(View.VISIBLE);
|
|
||||||
} else if (pump.isSuspended()) {
|
|
||||||
// disable all treatment buttons because we are not able to check constraints without profile
|
|
||||||
wizardButton.setVisibility(View.INVISIBLE);
|
|
||||||
treatmentButton.setVisibility(View.INVISIBLE);
|
|
||||||
quickWizardButton.setVisibility(View.INVISIBLE);
|
|
||||||
pumpStatusView.setText(R.string.pumpsuspendedclicktorefresh);
|
|
||||||
pumpStatusView.setVisibility(View.VISIBLE);
|
|
||||||
} else if (!pump.isInitialized()) {
|
|
||||||
// disable all treatment buttons because we are not able to check constraints without profile
|
|
||||||
wizardButton.setVisibility(View.INVISIBLE);
|
|
||||||
treatmentButton.setVisibility(View.INVISIBLE);
|
|
||||||
quickWizardButton.setVisibility(View.INVISIBLE);
|
|
||||||
pumpStatusView.setText(R.string.waitingforpumpclicktorefresh);
|
|
||||||
pumpStatusView.setVisibility(View.VISIBLE);
|
|
||||||
} else {
|
} else {
|
||||||
wizardButton.setVisibility(View.VISIBLE);
|
wizardButton.setVisibility(View.VISIBLE);
|
||||||
treatmentButton.setVisibility(View.VISIBLE);
|
treatmentButton.setVisibility(View.VISIBLE);
|
||||||
pumpStatusView.setVisibility(View.GONE);
|
pumpStatusLayout.setVisibility(View.GONE);
|
||||||
|
loopStatusLayout.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -552,10 +535,12 @@ public class OverviewFragment extends Fragment {
|
||||||
|
|
||||||
if (MainApp.getConfigBuilder() == null || MainApp.getConfigBuilder().getActiveProfile() == null || MainApp.getConfigBuilder().getActiveProfile().getProfile() == null) {// app not initialized yet
|
if (MainApp.getConfigBuilder() == null || MainApp.getConfigBuilder().getActiveProfile() == null || MainApp.getConfigBuilder().getActiveProfile().getProfile() == null) {// app not initialized yet
|
||||||
pumpStatusView.setText(R.string.noprofileset);
|
pumpStatusView.setText(R.string.noprofileset);
|
||||||
pumpStatusView.setVisibility(View.VISIBLE);
|
pumpStatusLayout.setVisibility(View.VISIBLE);
|
||||||
|
loopStatusLayout.setVisibility(View.GONE);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
pumpStatusView.setVisibility(View.GONE);
|
pumpStatusLayout.setVisibility(View.GONE);
|
||||||
|
loopStatusLayout.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip if not initialized yet
|
// Skip if not initialized yet
|
||||||
|
@ -1003,7 +988,7 @@ public class OverviewFragment extends Fragment {
|
||||||
bgGraph.getGridLabelRenderer().setVerticalLabelsSecondScaleColor(ContextCompat.getColor(MainApp.instance(), R.color.background_material_dark)); // same color as backround = hide
|
bgGraph.getGridLabelRenderer().setVerticalLabelsSecondScaleColor(ContextCompat.getColor(MainApp.instance(), R.color.background_material_dark)); // same color as backround = hide
|
||||||
}
|
}
|
||||||
|
|
||||||
updatePumpStatus(null);
|
//updatePumpStatus(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Notifications
|
//Notifications
|
||||||
|
|
|
@ -158,12 +158,12 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Date lastStatusTime() {
|
public Date lastDataTime() {
|
||||||
return new Date();
|
return new Date();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateStatus(String reason) {
|
public void refreshDataFromPump(String reason) {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class KeepAliveReceiver extends BroadcastReceiver {
|
||||||
boolean isBasalOutdated = false;
|
boolean isBasalOutdated = false;
|
||||||
boolean isStatusOutdated = false;
|
boolean isStatusOutdated = false;
|
||||||
|
|
||||||
Date lastConnection = pump.lastStatusTime();
|
Date lastConnection = pump.lastDataTime();
|
||||||
if (lastConnection.getTime() + 30 * 60 * 1000L < new Date().getTime())
|
if (lastConnection.getTime() + 30 * 60 * 1000L < new Date().getTime())
|
||||||
isStatusOutdated = true;
|
isStatusOutdated = true;
|
||||||
if (Math.abs(profile.getBasal(NSProfile.secondsFromMidnight()) - pump.getBaseBasalRate()) > pump.getPumpDescription().basalStep)
|
if (Math.abs(profile.getBasal(NSProfile.secondsFromMidnight()) - pump.getBaseBasalRate()) > pump.getPumpDescription().basalStep)
|
||||||
|
@ -58,7 +58,7 @@ public class KeepAliveReceiver extends BroadcastReceiver {
|
||||||
Thread t = new Thread(new Runnable() {
|
Thread t = new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
pump.updateStatus("KeepAlive. Status outdated.");
|
pump.refreshDataFromPump("KeepAlive. Status outdated.");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
t.start();
|
t.start();
|
||||||
|
@ -66,7 +66,7 @@ public class KeepAliveReceiver extends BroadcastReceiver {
|
||||||
Thread t = new Thread(new Runnable() {
|
Thread t = new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
pump.updateStatus("KeepAlive. Basal outdated.");
|
pump.refreshDataFromPump("KeepAlive. Basal outdated.");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
t.start();
|
t.start();
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
</android.support.v7.widget.RecyclerView>
|
</android.support.v7.widget.RecyclerView>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/overview_looplayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
|
@ -32,13 +33,13 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginLeft="10dp"
|
android:layout_marginLeft="10dp"
|
||||||
android:layout_marginRight="10dp"
|
android:layout_marginRight="10dp"
|
||||||
|
android:layout_weight="0.1"
|
||||||
android:background="@drawable/loopmodeborder"
|
android:background="@drawable/loopmodeborder"
|
||||||
android:gravity="center_vertical|center_horizontal"
|
android:gravity="center_vertical|center_horizontal"
|
||||||
android:paddingLeft="10dp"
|
android:paddingLeft="10dp"
|
||||||
android:paddingRight="10dp"
|
android:paddingRight="10dp"
|
||||||
android:text="Open Loop"
|
android:text="Open Loop"
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||||
android:layout_weight="0.1" />
|
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -62,38 +63,40 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="right"
|
android:layout_gravity="right"
|
||||||
android:layout_marginRight="10dp"
|
android:layout_marginRight="10dp"
|
||||||
|
android:layout_weight="0.2"
|
||||||
android:background="@drawable/temptargetborder"
|
android:background="@drawable/temptargetborder"
|
||||||
android:gravity="center_vertical|center_horizontal"
|
android:gravity="center_vertical|center_horizontal"
|
||||||
android:text="TempTarget"
|
|
||||||
android:paddingLeft="10dp"
|
android:paddingLeft="10dp"
|
||||||
android:paddingRight="10dp"
|
android:paddingRight="10dp"
|
||||||
|
android:text="TempTarget"
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
android:textColor="@color/mdtp_white"
|
android:textColor="@color/mdtp_white" />
|
||||||
android:layout_weight="0.2" />
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/overview_pumpstatuslayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:paddingTop="2dp">
|
android:paddingTop="2dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/overview_initializing"
|
android:id="@+id/overview_pumpstatus"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@drawable/initializingborder"
|
android:background="@drawable/initializingborder"
|
||||||
android:gravity="center_vertical|center_horizontal"
|
android:gravity="center_vertical|center_horizontal"
|
||||||
|
android:layout_marginLeft="10dp"
|
||||||
|
android:layout_marginRight="10dp"
|
||||||
android:text="@string/initializing"
|
android:text="@string/initializing"
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||||
android:layout_marginTop="10dp" />
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:gravity="center_horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/overview_bg"
|
android:id="@+id/overview_bg"
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<color name="colorPrimary">#3F51B5</color>
|
<color name="colorPrimary">#3F51B5</color>
|
||||||
<color name="colorPrimaryDark">#303F9F</color>
|
<color name="colorPrimaryDark">#303F9F</color>
|
||||||
<color name="colorAccent">#FF4081</color>
|
<color name="colorAccent">#FF4081</color>
|
||||||
<color name="colorInitializingBorder">#ff2630</color>
|
<color name="colorInitializingBorder">#00695c</color>
|
||||||
|
|
||||||
<color name="cardColorBackground">#121212</color>
|
<color name="cardColorBackground">#121212</color>
|
||||||
<color name="cardObjectiveText">#779ECB</color>
|
<color name="cardObjectiveText">#779ECB</color>
|
||||||
|
|
Loading…
Reference in a new issue