commit
97606a4dd8
3 changed files with 83 additions and 25 deletions
|
@ -19,6 +19,7 @@ import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
|
import info.nightscout.androidaps.plugins.Overview.Dialogs.ErrorHelperActivity;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRS.comm.DanaRS_Packet_Option_Get_User_Option;
|
import info.nightscout.androidaps.plugins.PumpDanaRS.comm.DanaRS_Packet_Option_Get_User_Option;
|
||||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||||
import info.nightscout.androidaps.events.EventAppExit;
|
import info.nightscout.androidaps.events.EventAppExit;
|
||||||
|
@ -135,6 +136,37 @@ public class DanaRSService extends Service {
|
||||||
bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Step_Bolus_Information()); // last bolus, bolusStep, maxBolus
|
bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Step_Bolus_Information()); // last bolus, bolusStep, maxBolus
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingtempbasalstatus)));
|
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingtempbasalstatus)));
|
||||||
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State());
|
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State());
|
||||||
|
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumptime)));
|
||||||
|
bleComm.sendMessage(new DanaRS_Packet_Option_Get_Pump_Time());
|
||||||
|
|
||||||
|
long timeDiff = (danaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
|
||||||
|
log.debug("Pump time difference: " + timeDiff + " seconds");
|
||||||
|
if (Math.abs(timeDiff) > 3) {
|
||||||
|
if (Math.abs(timeDiff) > 60*60*1.5) {
|
||||||
|
log.debug("Pump time difference: " + timeDiff + " seconds - large difference");
|
||||||
|
//If time-diff is very large, warn user until we can synchronize history readings properly
|
||||||
|
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
|
||||||
|
i.putExtra("soundid", R.raw.error);
|
||||||
|
i.putExtra("status", MainApp.gs(R.string.largetimediff));
|
||||||
|
i.putExtra("title", MainApp.gs(R.string.largetimedifftitle));
|
||||||
|
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
MainApp.instance().startActivity(i);
|
||||||
|
|
||||||
|
//deinitialize pump
|
||||||
|
danaRPump.lastConnection = 0;
|
||||||
|
MainApp.bus().post(new EventDanaRNewStatus());
|
||||||
|
MainApp.bus().post(new EventInitializationChanged());
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
waitForWholeMinute(); // Dana can set only whole minute
|
||||||
|
// add 10sec to be sure we are over minute (will be cutted off anyway)
|
||||||
|
bleComm.sendMessage(new DanaRS_Packet_Option_Set_Pump_Time(new Date(DateUtil.now() + T.secs(10).msecs())));
|
||||||
|
bleComm.sendMessage(new DanaRS_Packet_Option_Get_Pump_Time());
|
||||||
|
timeDiff = (danaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
|
||||||
|
log.debug("Pump time difference: " + timeDiff + " seconds");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
danaRPump.lastConnection = System.currentTimeMillis();
|
||||||
|
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
if (danaRPump.lastSettingsRead + 60 * 60 * 1000L < now || !MainApp.getSpecificPlugin(DanaRSPlugin.class).isInitialized()) {
|
if (danaRPump.lastSettingsRead + 60 * 60 * 1000L < now || !MainApp.getSpecificPlugin(DanaRSPlugin.class).isInitialized()) {
|
||||||
|
@ -146,19 +178,7 @@ public class DanaRSService extends Service {
|
||||||
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Basal_Rate()); // basal profile, basalStep, maxBasal
|
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Basal_Rate()); // basal profile, basalStep, maxBasal
|
||||||
bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Calculation_Information()); // target
|
bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Calculation_Information()); // target
|
||||||
bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_CIR_CF_Array());
|
bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_CIR_CF_Array());
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumptime)));
|
|
||||||
bleComm.sendMessage(new DanaRS_Packet_Option_Get_Pump_Time());
|
|
||||||
bleComm.sendMessage(new DanaRS_Packet_Option_Get_User_Option()); // Getting user options
|
bleComm.sendMessage(new DanaRS_Packet_Option_Get_User_Option()); // Getting user options
|
||||||
long timeDiff = (danaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
|
|
||||||
log.debug("Pump time difference: " + timeDiff + " seconds");
|
|
||||||
if (Math.abs(timeDiff) > 3) {
|
|
||||||
waitForWholeMinute(); // Dana can set only whole minute
|
|
||||||
// add 10sec to be sure we are over minute (will be cutted off anyway)
|
|
||||||
bleComm.sendMessage(new DanaRS_Packet_Option_Set_Pump_Time(new Date(DateUtil.now() + T.secs(10).msecs())));
|
|
||||||
bleComm.sendMessage(new DanaRS_Packet_Option_Get_Pump_Time());
|
|
||||||
timeDiff = (danaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
|
|
||||||
log.debug("Pump time difference: " + timeDiff + " seconds");
|
|
||||||
}
|
|
||||||
danaRPump.lastSettingsRead = now;
|
danaRPump.lastSettingsRead = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,6 +203,13 @@ public class DanaRSService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
public PumpEnactResult loadEvents() {
|
public PumpEnactResult loadEvents() {
|
||||||
|
|
||||||
|
if(!MainApp.getSpecificPlugin(DanaRSPlugin.class).isInitialized()){
|
||||||
|
PumpEnactResult result = new PumpEnactResult().success(false);
|
||||||
|
result.comment = "pump not initialized";
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
DanaRS_Packet_APS_History_Events msg;
|
DanaRS_Packet_APS_History_Events msg;
|
||||||
if (lastHistoryFetched == 0) {
|
if (lastHistoryFetched == 0) {
|
||||||
msg = new DanaRS_Packet_APS_History_Events(0);
|
msg = new DanaRS_Packet_APS_History_Events(0);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.PumpDanaRv2.services;
|
package info.nightscout.androidaps.plugins.PumpDanaRv2.services;
|
||||||
|
|
||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
|
@ -18,6 +19,7 @@ import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
|
import info.nightscout.androidaps.plugins.Overview.Dialogs.ErrorHelperActivity;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgSettingUserOptions;
|
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgSettingUserOptions;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgSetUserOptions;
|
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgSetUserOptions;
|
||||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||||
|
@ -187,6 +189,36 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
||||||
mSerialIOThread.sendMessage(tempStatusMsg);
|
mSerialIOThread.sendMessage(tempStatusMsg);
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingextendedbolusstatus)));
|
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingextendedbolusstatus)));
|
||||||
mSerialIOThread.sendMessage(exStatusMsg);
|
mSerialIOThread.sendMessage(exStatusMsg);
|
||||||
|
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumptime)));
|
||||||
|
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
|
||||||
|
long timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
|
||||||
|
log.debug("Pump time difference: " + timeDiff + " seconds");
|
||||||
|
if (Math.abs(timeDiff) > 3) {
|
||||||
|
if (Math.abs(timeDiff) > 60*60*1.5) {
|
||||||
|
log.debug("Pump time difference: " + timeDiff + " seconds - large difference");
|
||||||
|
//If time-diff is very large, warn user until we can synchronize history readings properly
|
||||||
|
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
|
||||||
|
i.putExtra("soundid", R.raw.error);
|
||||||
|
i.putExtra("status", MainApp.gs(R.string.largetimediff));
|
||||||
|
i.putExtra("title", MainApp.gs(R.string.largetimedifftitle));
|
||||||
|
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
MainApp.instance().startActivity(i);
|
||||||
|
|
||||||
|
//deinitialize pump
|
||||||
|
mDanaRPump.lastConnection = 0;
|
||||||
|
MainApp.bus().post(new EventDanaRNewStatus());
|
||||||
|
MainApp.bus().post(new EventInitializationChanged());
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
waitForWholeMinute(); // Dana can set only whole minute
|
||||||
|
// add 10sec to be sure we are over minute (will be cutted off anyway)
|
||||||
|
mSerialIOThread.sendMessage(new MsgSetTime(new Date(DateUtil.now() + T.secs(10).msecs())));
|
||||||
|
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
|
||||||
|
timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
|
||||||
|
log.debug("Pump time difference: " + timeDiff + " seconds");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mDanaRPump.lastConnection = System.currentTimeMillis();
|
||||||
|
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
if (mDanaRPump.lastSettingsRead + 60 * 60 * 1000L < now || !MainApp.getSpecificPlugin(DanaRv2Plugin.class).isInitialized()) {
|
if (mDanaRPump.lastSettingsRead + 60 * 60 * 1000L < now || !MainApp.getSpecificPlugin(DanaRv2Plugin.class).isInitialized()) {
|
||||||
|
@ -202,18 +234,6 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
||||||
mSerialIOThread.sendMessage(new MsgSettingProfileRatios());
|
mSerialIOThread.sendMessage(new MsgSettingProfileRatios());
|
||||||
mSerialIOThread.sendMessage(new MsgSettingUserOptions());
|
mSerialIOThread.sendMessage(new MsgSettingUserOptions());
|
||||||
mSerialIOThread.sendMessage(new MsgSettingProfileRatiosAll());
|
mSerialIOThread.sendMessage(new MsgSettingProfileRatiosAll());
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumptime)));
|
|
||||||
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
|
|
||||||
long timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
|
|
||||||
log.debug("Pump time difference: " + timeDiff + " seconds");
|
|
||||||
if (Math.abs(timeDiff) > 3) {
|
|
||||||
waitForWholeMinute(); // Dana can set only whole minute
|
|
||||||
// add 10sec to be sure we are over minute (will be cutted off anyway)
|
|
||||||
mSerialIOThread.sendMessage(new MsgSetTime(new Date(DateUtil.now() + T.secs(10).msecs())));
|
|
||||||
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
|
|
||||||
timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
|
|
||||||
log.debug("Pump time difference: " + timeDiff + " seconds");
|
|
||||||
}
|
|
||||||
mDanaRPump.lastSettingsRead = now;
|
mDanaRPump.lastSettingsRead = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -425,6 +445,14 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public PumpEnactResult loadEvents() {
|
public PumpEnactResult loadEvents() {
|
||||||
|
|
||||||
|
if(!MainApp.getSpecificPlugin(DanaRv2Plugin.class).isInitialized()){
|
||||||
|
PumpEnactResult result = new PumpEnactResult().success(false);
|
||||||
|
result.comment = "pump not initialized";
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!isConnected())
|
if (!isConnected())
|
||||||
return new PumpEnactResult().success(false);
|
return new PumpEnactResult().success(false);
|
||||||
SystemClock.sleep(300);
|
SystemClock.sleep(300);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<resources>
|
<resources>
|
||||||
<string name="treatmentssafety_title">Treatments safety</string>
|
<string name="treatmentssafety_title">Treatments safety</string>
|
||||||
<string name="treatmentssafety_maxbolus_title">Max allowed bolus [U]</string>
|
<string name="treatmentssafety_maxbolus_title">Max allowed bolus [U]</string>
|
||||||
<string name="treatmentssafety_maxcarbs_title">Max allowed carbs [g]</string>
|
<string name="treatmentssafety_maxcarbs_title">Max allowed carbs [g]</string>
|
||||||
|
@ -1173,6 +1173,9 @@
|
||||||
<string name="low_temptarget_lowers_sensitivity_summary"><![CDATA[Lower sensitivity for temptargets < 100]]></string>
|
<string name="low_temptarget_lowers_sensitivity_summary"><![CDATA[Lower sensitivity for temptargets < 100]]></string>
|
||||||
<string name="combo_invalid_setup">Invalid pump setup, check the docs and verify that the Quick Info menu is named "QUICK INFO" using the 360 configuration software.</string>
|
<string name="combo_invalid_setup">Invalid pump setup, check the docs and verify that the Quick Info menu is named "QUICK INFO" using the 360 configuration software.</string>
|
||||||
<string name="custom">Custom</string>
|
<string name="custom">Custom</string>
|
||||||
|
<string name="key_lockscreen" translatable="false">lockscreen</string>
|
||||||
|
<string name="largetimedifftitle">Large Time Difference</string>
|
||||||
|
<string name="largetimediff">Large time difference:\nTime in pump is off by more than 1.5 hours.\nPlease adjust the time manually on the pump and make sure that reading the history from the pump does not cause unexpected behaviour.\nIf possible, remove the history from the pump before changing the time or disable the closed loop for one DIA after the last wrong history entry but minimum one DIA from now.</string>
|
||||||
<string name="key_keep_screen_on" translatable="false">keep_screen_on</string>
|
<string name="key_keep_screen_on" translatable="false">keep_screen_on</string>
|
||||||
<string name="careportal_removestartedevents">Clean AndroidAPS started</string>
|
<string name="careportal_removestartedevents">Clean AndroidAPS started</string>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue