Dana messages
This commit is contained in:
parent
000cf31deb
commit
18de3f70b5
81 changed files with 1370 additions and 1625 deletions
|
@ -7,6 +7,7 @@ import info.nightscout.androidaps.data.Profile
|
||||||
import info.nightscout.androidaps.data.ProfileStore
|
import info.nightscout.androidaps.data.ProfileStore
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
import info.nightscout.androidaps.plugins.treatments.Treatment
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import org.json.JSONArray
|
import org.json.JSONArray
|
||||||
import org.json.JSONException
|
import org.json.JSONException
|
||||||
|
@ -123,8 +124,15 @@ class DanaRPump @Inject constructor(
|
||||||
return if (units == UNITS_MGDL) Constants.MGDL else Constants.MMOL
|
return if (units == UNITS_MGDL) Constants.MGDL else Constants.MMOL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DanaR,Rv2,RK specific flags
|
||||||
// last start bolus erroCode
|
// last start bolus erroCode
|
||||||
var messageStartErrorCode: Int = 0
|
var messageStartErrorCode: Int = 0
|
||||||
|
var historyDoneReceived: Boolean = false
|
||||||
|
var bolusingTreatment: Treatment? = null // actually delivered treatment
|
||||||
|
var bolusAmountToBeDelivered = 0.0 // amount to be delivered
|
||||||
|
var bolusProgressLastTimeStamp: Long = 0 // timestamp of last bolus progress message
|
||||||
|
var bolusStopped = false // bolus finished
|
||||||
|
var bolusStopForced = false // bolus forced to stop by user
|
||||||
|
|
||||||
fun createConvertedProfile(): ProfileStore? {
|
fun createConvertedProfile(): ProfileStore? {
|
||||||
pumpProfiles?.let {
|
pumpProfiles?.let {
|
||||||
|
|
|
@ -92,7 +92,7 @@ public class MessageBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMessageName() {
|
public String getMessageName() {
|
||||||
return MessageOriginalNames.getName(getCommand());
|
return MessageOriginalNames.INSTANCE.getName(getCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleMessage(byte[] bytes) {
|
public void handleMessage(byte[] bytes) {
|
||||||
|
|
|
@ -31,10 +31,10 @@ class MessageHashTableR @Inject constructor(
|
||||||
var messages: HashMap<Int, MessageBase> = HashMap()
|
var messages: HashMap<Int, MessageBase> = HashMap()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
put(MsgBolusStop()) // 0x0101 CMD_MEALINS_STOP
|
put(MsgBolusStop(aapsLogger, rxBus, resourceHelper, danaRPump)) // 0x0101 CMD_MEALINS_STOP
|
||||||
put(MsgBolusStart(aapsLogger, constraintChecker, danaRPump, 0.0)) // 0x0102 CMD_MEALINS_START_DATA
|
put(MsgBolusStart(aapsLogger, constraintChecker, danaRPump, 0.0)) // 0x0102 CMD_MEALINS_START_DATA
|
||||||
put(MsgBolusStartWithSpeed(aapsLogger, constraintChecker, danaRPump, 0.0, 0)) // 0x0104 CMD_MEALINS_START_DATA_SPEED
|
put(MsgBolusStartWithSpeed(aapsLogger, constraintChecker, danaRPump, 0.0, 0)) // 0x0104 CMD_MEALINS_START_DATA_SPEED
|
||||||
put(MsgBolusProgress()) // 0x0202 CMD_PUMP_THIS_REMAINDER_MEAL_INS
|
put(MsgBolusProgress(aapsLogger, resourceHelper, rxBus, danaRPump)) // 0x0202 CMD_PUMP_THIS_REMAINDER_MEAL_INS
|
||||||
put(MsgStatusProfile(aapsLogger, danaRPump)) // 0x0204 CMD_PUMP_CALCULATION_SETTING
|
put(MsgStatusProfile(aapsLogger, danaRPump)) // 0x0204 CMD_PUMP_CALCULATION_SETTING
|
||||||
put(MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin)) // 0x0205 CMD_PUMP_EXERCISE_MODE
|
put(MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin)) // 0x0205 CMD_PUMP_EXERCISE_MODE
|
||||||
put(MsgStatusBolusExtended(aapsLogger, danaRPump, activePlugin)) // 0x0207 CMD_PUMP_EXPANS_INS_I
|
put(MsgStatusBolusExtended(aapsLogger, danaRPump, activePlugin)) // 0x0207 CMD_PUMP_EXPANS_INS_I
|
||||||
|
@ -45,24 +45,24 @@ class MessageHashTableR @Inject constructor(
|
||||||
put(MsgInitConnStatusBolus(aapsLogger, rxBus, resourceHelper, danaRPump)) // 0x0302 CMD_PUMPINIT_BOLUS_INFO
|
put(MsgInitConnStatusBolus(aapsLogger, rxBus, resourceHelper, danaRPump)) // 0x0302 CMD_PUMPINIT_BOLUS_INFO
|
||||||
put(MsgInitConnStatusBasic(aapsLogger, danaRPump)) // 0x0303 CMD_PUMPINIT_INIT_INFO
|
put(MsgInitConnStatusBasic(aapsLogger, danaRPump)) // 0x0303 CMD_PUMPINIT_INIT_INFO
|
||||||
put(MsgInitConnStatusOption(aapsLogger, rxBus, resourceHelper, danaRPump, activePlugin)) // 0x0304 CMD_PUMPINIT_OPTION
|
put(MsgInitConnStatusOption(aapsLogger, rxBus, resourceHelper, danaRPump, activePlugin)) // 0x0304 CMD_PUMPINIT_OPTION
|
||||||
put(MsgSetTempBasalStart()) // 0x0401 CMD_PUMPSET_EXERCISE_S
|
put(MsgSetTempBasalStart(aapsLogger, 0, 0)) // 0x0401 CMD_PUMPSET_EXERCISE_S
|
||||||
put(MsgSetCarbsEntry()) // 0x0402 CMD_PUMPSET_HIS_S
|
put(MsgSetCarbsEntry(aapsLogger, 0, 0)) // 0x0402 CMD_PUMPSET_HIS_S
|
||||||
put(MsgSetTempBasalStop()) // 0x0403 CMD_PUMPSET_EXERCISE_STOP
|
put(MsgSetTempBasalStop(aapsLogger)) // 0x0403 CMD_PUMPSET_EXERCISE_STOP
|
||||||
put(MsgSetExtendedBolusStop()) // 0x0406 CMD_PUMPSET_EXPANS_INS_STOP
|
put(MsgSetExtendedBolusStop(aapsLogger)) // 0x0406 CMD_PUMPSET_EXPANS_INS_STOP
|
||||||
put(MsgSetExtendedBolusStart(aapsLogger, constraintChecker, 0.0, 0)) // 0x0407 CMD_PUMPSET_EXPANS_INS_S
|
put(MsgSetExtendedBolusStart(aapsLogger, constraintChecker, 0.0, 0)) // 0x0407 CMD_PUMPSET_EXPANS_INS_S
|
||||||
put(MsgError()) // 0x0601 CMD_PUMPOWAY_SYSTEM_STATUS
|
put(MsgError(aapsLogger, rxBus, resourceHelper, danaRPump)) // 0x0601 CMD_PUMPOWAY_SYSTEM_STATUS
|
||||||
put(MsgPCCommStart()) // 0x3001 CMD_CONNECT
|
put(MsgPCCommStart(aapsLogger)) // 0x3001 CMD_CONNECT
|
||||||
put(MsgPCCommStop()) // 0x3002 CMD_DISCONNECT
|
put(MsgPCCommStop(aapsLogger)) // 0x3002 CMD_DISCONNECT
|
||||||
put(MsgHistoryBolus()) // 0x3101 CMD_HISTORY_MEAL_INS
|
put(MsgHistoryBolus(aapsLogger, rxBus)) // 0x3101 CMD_HISTORY_MEAL_INS
|
||||||
put(MsgHistoryDailyInsulin()) // 0x3102 CMD_HISTORY_DAY_INS
|
put(MsgHistoryDailyInsulin(aapsLogger, rxBus)) // 0x3102 CMD_HISTORY_DAY_INS
|
||||||
put(MsgHistoryGlucose()) // 0x3104 CMD_HISTORY_GLUCOSE
|
put(MsgHistoryGlucose(aapsLogger, rxBus)) // 0x3104 CMD_HISTORY_GLUCOSE
|
||||||
put(MsgHistoryAlarm()) // 0x3105 CMD_HISTORY_ALARM
|
put(MsgHistoryAlarm(aapsLogger, rxBus)) // 0x3105 CMD_HISTORY_ALARM
|
||||||
put(MsgHistoryError()) // 0x3106 CMD_HISTORY_ERROR
|
put(MsgHistoryError(aapsLogger, rxBus)) // 0x3106 CMD_HISTORY_ERROR
|
||||||
put(MsgHistoryCarbo()) // 0x3107 CMD_HISTORY_CARBOHY
|
put(MsgHistoryCarbo(aapsLogger, rxBus)) // 0x3107 CMD_HISTORY_CARBOHY
|
||||||
put(MsgHistoryRefill()) // 0x3108 CMD_HISTORY_REFILL
|
put(MsgHistoryRefill(aapsLogger, rxBus)) // 0x3108 CMD_HISTORY_REFILL
|
||||||
put(MsgHistorySuspend()) // 0x3109 CMD_HISTORY_SUSPEND
|
put(MsgHistorySuspend(aapsLogger, rxBus)) // 0x3109 CMD_HISTORY_SUSPEND
|
||||||
put(MsgHistoryBasalHour()) // 0x310A CMD_HISTORY_BASAL_HOUR
|
put(MsgHistoryBasalHour(aapsLogger, rxBus)) // 0x310A CMD_HISTORY_BASAL_HOUR
|
||||||
put(MsgHistoryDone()) // 0x31F1 CMD_HISTORY_DONT_USED
|
put(MsgHistoryDone(aapsLogger, danaRPump)) // 0x31F1 CMD_HISTORY_DONT_USED
|
||||||
// 0x3202 CMD_SETTING_V_BASAL_INS_I
|
// 0x3202 CMD_SETTING_V_BASAL_INS_I
|
||||||
put(MsgSettingBasal(aapsLogger, danaRPump, danaRPlugin))
|
put(MsgSettingBasal(aapsLogger, danaRPump, danaRPlugin))
|
||||||
// 0x3203 CMD_SETTING_V_MEAL_SETTING_I
|
// 0x3203 CMD_SETTING_V_MEAL_SETTING_I
|
||||||
|
@ -76,14 +76,14 @@ class MessageHashTableR @Inject constructor(
|
||||||
put(MsgSettingUserOptions(aapsLogger, danaRPump)) // 0x320B CMD_SETTING_V_USER_OPTIONS
|
put(MsgSettingUserOptions(aapsLogger, danaRPump)) // 0x320B CMD_SETTING_V_USER_OPTIONS
|
||||||
put(MsgSettingActiveProfile(aapsLogger, danaRPump)) // 0x320C CMD_SETTING_V_PROFILE_NUMBER
|
put(MsgSettingActiveProfile(aapsLogger, danaRPump)) // 0x320C CMD_SETTING_V_PROFILE_NUMBER
|
||||||
put(MsgSettingProfileRatiosAll(aapsLogger, danaRPump)) // 0x320D CMD_SETTING_V_CIR_CF_VALUE
|
put(MsgSettingProfileRatiosAll(aapsLogger, danaRPump)) // 0x320D CMD_SETTING_V_CIR_CF_VALUE
|
||||||
put(MsgSetSingleBasalProfile()) // 0x3302 CMD_SETTING_BASAL_INS_S
|
put(MsgSetSingleBasalProfile(aapsLogger, rxBus, resourceHelper, Array(24) { 0.0 })) // 0x3302 CMD_SETTING_BASAL_INS_S
|
||||||
put(MsgSetBasalProfile()) // 0x3306 CMD_SETTING_BASAL_PROFILE_S
|
put(MsgSetBasalProfile(aapsLogger, rxBus, resourceHelper, 0.toByte(), Array(24) { 0.0 })) // 0x3306 CMD_SETTING_BASAL_PROFILE_S
|
||||||
put(MsgSetUserOptions(aapsLogger, danaRPump)) // 0x330B CMD_SETTING_USER_OPTIONS_S
|
put(MsgSetUserOptions(aapsLogger, danaRPump)) // 0x330B CMD_SETTING_USER_OPTIONS_S
|
||||||
put(MsgSetActivateBasalProfile()) // 0x330C CMD_SETTING_PROFILE_NUMBER_S
|
put(MsgSetActivateBasalProfile(aapsLogger, 0.toByte())) // 0x330C CMD_SETTING_PROFILE_NUMBER_S
|
||||||
put(MsgHistoryAllDone()) // 0x41F1 CMD_HISTORY_ALL_DONE
|
put(MsgHistoryAllDone(aapsLogger, danaRPump)) // 0x41F1 CMD_HISTORY_ALL_DONE
|
||||||
put(MsgHistoryAll()) // 0x41F2 CMD_HISTORY_ALL
|
put(MsgHistoryAll(aapsLogger, rxBus)) // 0x41F2 CMD_HISTORY_ALL
|
||||||
put(MsgHistoryNewDone()) // 0x42F1 CMD_HISTORY_NEW_DONE
|
put(MsgHistoryNewDone(aapsLogger, danaRPump)) // 0x42F1 CMD_HISTORY_NEW_DONE
|
||||||
put(MsgHistoryNew()) // 0x42F2 CMD_HISTORY_NEW
|
put(MsgHistoryNew(aapsLogger, rxBus)) // 0x42F2 CMD_HISTORY_NEW
|
||||||
// 0xF0F1 CMD_PUMP_CHECK_VALUE
|
// 0xF0F1 CMD_PUMP_CHECK_VALUE
|
||||||
put(MsgCheckValue(aapsLogger, danaRPump, danaRPlugin))
|
put(MsgCheckValue(aapsLogger, danaRPump, danaRPlugin))
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,172 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 28.05.2016.
|
|
||||||
*/
|
|
||||||
public class MessageOriginalNames {
|
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(L.PUMPCOMM);
|
|
||||||
|
|
||||||
private static HashMap<Integer, String> messageNames;
|
|
||||||
|
|
||||||
static {
|
|
||||||
messageNames = new HashMap<>();
|
|
||||||
|
|
||||||
messageNames.put(0x3001, "CMD_CONNECT");
|
|
||||||
messageNames.put(0x3002, "CMD_DISCONNECT");
|
|
||||||
|
|
||||||
messageNames.put(0x3101, "CMD_HISTORY_MEAL_INS");
|
|
||||||
messageNames.put(0x3102, "CMD_HISTORY_DAY_INS");
|
|
||||||
messageNames.put(0x3103, "CMD_HISTORY_AIR_SUB");
|
|
||||||
messageNames.put(0x3104, "CMD_HISTORY_GLUCOSE");
|
|
||||||
messageNames.put(0x3105, "CMD_HISTORY_ALARM");
|
|
||||||
messageNames.put(0x3106, "CMD_HISTORY_ERROR");
|
|
||||||
messageNames.put(0x3107, "CMD_HISTORY_CARBOHY");
|
|
||||||
messageNames.put(0x3108, "CMD_HISTORY_REFILL");
|
|
||||||
messageNames.put(0x3109, "CMD_HISTORY_SUSPEND");
|
|
||||||
messageNames.put(0x310a, "CMD_HISTORY_BASAL_HOUR");
|
|
||||||
messageNames.put(0x310b, "CMD_HISTORY_TB");
|
|
||||||
messageNames.put(0x31f1, "CMD_HISTORY_STOP");
|
|
||||||
messageNames.put(0x31f2, "CMD_HISTORY_LAST_T_R");
|
|
||||||
messageNames.put(0x31f3, "CMD_HISTORY_LAST_T_S");
|
|
||||||
|
|
||||||
messageNames.put(0x0501, "CMD_HISPAGE_MEAL_INS");
|
|
||||||
messageNames.put(0x0502, "CMD_HISPAGE_DAY_INS");
|
|
||||||
messageNames.put(0x0503, "CMD_HISPAGE_AIR_SUB");
|
|
||||||
messageNames.put(0x0504, "CMD_HISPAGE_GLUCOSE");
|
|
||||||
messageNames.put(0x0505, "CMD_HISPAGE_ALARM");
|
|
||||||
messageNames.put(0x0506, "CMD_HISPAGE_ERROR");
|
|
||||||
messageNames.put(0x0507, "CMD_HISPAGE_CARBOHY");
|
|
||||||
messageNames.put(0x0508, "CMD_HISPAGE_REFILL");
|
|
||||||
messageNames.put(0x050a, "CMD_HISPAGE_DAILTY_PRE_DATA");
|
|
||||||
messageNames.put(0x050b, "CMD_HISPAGE_BOLUS_AVG");
|
|
||||||
messageNames.put(0x050c, "CMD_HISPAGE_BASAL_RECORD");
|
|
||||||
messageNames.put(0x050d, "CMD_HISPAGE_TB");
|
|
||||||
|
|
||||||
messageNames.put(0x3201, "CMD_SETTING_V_MEAL_INS_I");
|
|
||||||
messageNames.put(0x3202, "CMD_SETTING_V_BASAL_INS_I");
|
|
||||||
messageNames.put(0x3203, "CMD_SETTING_V_MEAL_SETTING_I");
|
|
||||||
messageNames.put(0x3204, "CMD_SETTING_V_CCC_I");
|
|
||||||
messageNames.put(0x3205, "CMD_SETTING_V_MAX_VALUE_I");
|
|
||||||
messageNames.put(0x3206, "CMD_SETTING_V_BASAL_PROFILE_ALL");
|
|
||||||
messageNames.put(0x3207, "CMD_SETTING_V_SHIPPING_I");
|
|
||||||
messageNames.put(0x3208, "CMD_SETTING_V_CLOGGIN_SENS_I");
|
|
||||||
messageNames.put(0x3209, "CMD_SETTING_V_GLUCOSEandEASY");
|
|
||||||
messageNames.put(0x320a, "CMD_SETTING_V_TIME_I");
|
|
||||||
messageNames.put(0x320b, "CMD_SETTING_V_USER_OPTIONS");
|
|
||||||
messageNames.put(0x320c, "CMD_SETTING_V_PROFILE_NUMBER");
|
|
||||||
messageNames.put(0x320d, "CMD_SETTING_V_CIR_CF_VALUE");
|
|
||||||
|
|
||||||
messageNames.put(0x3301, "CMD_SETTING_MEAL_INS_S");
|
|
||||||
messageNames.put(0x3302, "CMD_SETTING_BASAL_INS_S");
|
|
||||||
messageNames.put(0x3303, "CMD_SETTING_MEAL_SETTING_S");
|
|
||||||
messageNames.put(0x3304, "CMD_SETTING_CCC_S");
|
|
||||||
messageNames.put(0x3305, "CMD_SETTING_MAX_VALUE_S");
|
|
||||||
messageNames.put(0x3306, "CMD_SETTING_BASAL_PROFILE_S");
|
|
||||||
messageNames.put(0x3307, "CMD_SETTING_SHIPPING_S");
|
|
||||||
messageNames.put(0x3308, "CMD_SETTING_CLOGGIN_SENS_S");
|
|
||||||
messageNames.put(0x3309, "CMD_SETTING_GLUCOSEandEASY_S");
|
|
||||||
messageNames.put(0x330a, "CMD_SETTING_TIME_S");
|
|
||||||
messageNames.put(0x330b, "CMD_SETTING_USER_OPTIONS_S");
|
|
||||||
messageNames.put(0x330c, "CMD_SETTING_PROFILE_NUMBER_S");
|
|
||||||
messageNames.put(0x330d, "CMD_SETTING_CIR_CF_VALUE_S");
|
|
||||||
|
|
||||||
messageNames.put(0x0101, "CMD_MEALINS_STOP");
|
|
||||||
messageNames.put(0x0102, "CMD_MEALINS_START_DATA");
|
|
||||||
messageNames.put(0x0103, "CMD_MEALINS_START_NODATA");
|
|
||||||
messageNames.put(0x0104, "CMD_MEALINS_START_DATA_SPEED");
|
|
||||||
messageNames.put(0x0105, "CMD_MEALINS_START_NODATA_SPEED");
|
|
||||||
|
|
||||||
messageNames.put(0x0201, "CMD_PUMP_ACT_INS_VALUE");
|
|
||||||
messageNames.put(0x0202, "CMD_PUMP_THIS_REMAINDER_MEAL_INS");
|
|
||||||
messageNames.put(0x0203, "CMD_PUMP_BASE_SET");
|
|
||||||
messageNames.put(0x0204, "CMD_PUMP_CALCULATION_SETTING");
|
|
||||||
messageNames.put(0x0205, "CMD_PUMP_EXERCISE_MODE");
|
|
||||||
messageNames.put(0x0206, "CMD_PUMP_MEAL_INS_I");
|
|
||||||
|
|
||||||
messageNames.put(0x0207, "CMD_PUMP_EXPANS_INS_I");
|
|
||||||
messageNames.put(0x0208, "CMD_PUMP_EXPANS_INS_RQ");
|
|
||||||
|
|
||||||
messageNames.put(0x0209, "CMD_PUMP_DUAL_INS_RQ");
|
|
||||||
messageNames.put(0x020a, "CMD_PUMP_INITVIEW_I");
|
|
||||||
messageNames.put(0x020b, "CMD_PUMP_STATUS");
|
|
||||||
messageNames.put(0x020c, "CMD_PUMP_CAR_N_CIR");
|
|
||||||
|
|
||||||
messageNames.put(0x0301, "CMD_PUMPINIT_TIME_INFO");
|
|
||||||
messageNames.put(0x0302, "CMD_PUMPINIT_BOLUS_INFO");
|
|
||||||
messageNames.put(0x0303, "CMD_PUMPINIT_INIT_INFO");
|
|
||||||
messageNames.put(0x0304, "CMD_PUMPINIT_OPTION");
|
|
||||||
|
|
||||||
messageNames.put(0x0401, "CMD_PUMPSET_EXERCISE_S");
|
|
||||||
messageNames.put(0x0402, "CMD_PUMPSET_HIS_S");
|
|
||||||
messageNames.put(0x0403, "CMD_PUMPSET_EXERCISE_STOP");
|
|
||||||
|
|
||||||
messageNames.put(0x0404, "CMD_PUMPSET_PAUSE");
|
|
||||||
messageNames.put(0x0405, "CMD_PUMPSET_PAUSE_STOP");
|
|
||||||
|
|
||||||
messageNames.put(0x0406, "CMD_PUMPSET_EXPANS_INS_STOP");
|
|
||||||
messageNames.put(0x0407, "CMD_PUMPSET_EXPANS_INS_S");
|
|
||||||
|
|
||||||
messageNames.put(0x0408, "CMD_PUMPSET_DUAL_S");
|
|
||||||
messageNames.put(0x0409, "CMD_PUMPSET_EASY_OFF");
|
|
||||||
|
|
||||||
|
|
||||||
messageNames.put(0x0601, "CMD_PUMPOWAY_SYSTEM_STATUS");
|
|
||||||
messageNames.put(0x0602, "CMD_PUMPOWAY_GLUCOSE_ALARM");
|
|
||||||
messageNames.put(0x0603, "CMD_PUMPOWAY_LOW_INSULIN_ALARM");
|
|
||||||
messageNames.put(0x0610, "CMD_PUMP_ALARM_TIEOUT");
|
|
||||||
|
|
||||||
messageNames.put(0x0701, "CMD_MSGRECEP_TAKE_SUGAR");
|
|
||||||
messageNames.put(0x0702, "CMD_MSGRECEP_GO_TO_DOCTOR");
|
|
||||||
messageNames.put(0x0703, "CMD_MSGRECEP_CALL_TO_CAREGIVER");
|
|
||||||
messageNames.put(0x0704, "CMD_MSGRECEP_CHECK_GLUCOSE_AGAIN");
|
|
||||||
messageNames.put(0x0705, "CMD_MSGRECEP_CALL_TO_HOME");
|
|
||||||
messageNames.put(0x0706, "CMD_MSGRECEP_DO_DELIVER");
|
|
||||||
|
|
||||||
messageNames.put(0x0801, "CMD_MSGSEND_YES_I_DO");
|
|
||||||
messageNames.put(0x0802, "CMD_MSGSEND_NO_I_CANNOT");
|
|
||||||
messageNames.put(0x0803, "CMD_MSGSEND_CALL_TO_ME_MOM");
|
|
||||||
messageNames.put(0x0804, "CMD_MSGSEND_DO_NOT_INFUSE");
|
|
||||||
|
|
||||||
messageNames.put(0x0901, "CMD_FILL_REFILL_COUNT");
|
|
||||||
messageNames.put(0x0902, "CMD_FILL_PRIME_CHECK");
|
|
||||||
messageNames.put(0x0903, "CMD_FILL_PRIME_END");
|
|
||||||
messageNames.put(0x0904, "CMD_FILL_PRIME_STOP");
|
|
||||||
messageNames.put(0x0905, "CMD_FILL_PRIME_PAUSE");
|
|
||||||
messageNames.put(0x0906, "CMD_FILL_PRIME_RATE");
|
|
||||||
|
|
||||||
messageNames.put(0x41f2, "CMD_HISTORY_ALL");
|
|
||||||
messageNames.put(0x42f2, "CMD_HISTORY_NEW");
|
|
||||||
|
|
||||||
messageNames.put(0x41f1, "CMD_HISTORY_ALL_DONE");
|
|
||||||
messageNames.put(0x42f1, "CMD_HISTORY_NEW_DONE");
|
|
||||||
|
|
||||||
messageNames.put(0xF0F1, "CMD_PUMP_CHECK_VALUE");
|
|
||||||
messageNames.put(0xF0F2, "CMD_PUMP_TIMECHANGE_CHECK");
|
|
||||||
messageNames.put(0xF0F3, "CMD_PUMP_TIMECHANGE_CLEAR");
|
|
||||||
messageNames.put(0x43F2, "CMD_HISTORY_DATEOVER_ALL");
|
|
||||||
messageNames.put(0x4300, "CMD_HISTORY_DATEOVER_DONE");
|
|
||||||
|
|
||||||
messageNames.put(0xE001, "CMD_PUMPSTATUS_APS");
|
|
||||||
messageNames.put(0xE002, "CMD_PUMPSET_APSTEMP");
|
|
||||||
messageNames.put(0xE003, "CMD_GET_HISTORY");
|
|
||||||
messageNames.put(0xE004, "CMD_SET_HISTORY_ENTRY");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static String getName(Integer command) {
|
|
||||||
if (messageNames.containsKey(command))
|
|
||||||
return messageNames.get(command);
|
|
||||||
else {
|
|
||||||
log.error("Unknown command: " + String.format("%04X", command));
|
|
||||||
return "UNKNOWN_COMMAND";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,135 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||||
|
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
object MessageOriginalNames {
|
||||||
|
|
||||||
|
private var messageNames: HashMap<Int, String> = HashMap()
|
||||||
|
|
||||||
|
fun getName(command: Int): String? {
|
||||||
|
return if (messageNames.containsKey(command))
|
||||||
|
messageNames[command]
|
||||||
|
else
|
||||||
|
throw IllegalStateException("Unknown command: " + String.format("%04X", command))
|
||||||
|
}
|
||||||
|
|
||||||
|
init {
|
||||||
|
messageNames[0x3001] = "CMD_CONNECT"
|
||||||
|
messageNames[0x3002] = "CMD_DISCONNECT"
|
||||||
|
messageNames[0x3101] = "CMD_HISTORY_MEAL_INS"
|
||||||
|
messageNames[0x3102] = "CMD_HISTORY_DAY_INS"
|
||||||
|
messageNames[0x3103] = "CMD_HISTORY_AIR_SUB"
|
||||||
|
messageNames[0x3104] = "CMD_HISTORY_GLUCOSE"
|
||||||
|
messageNames[0x3105] = "CMD_HISTORY_ALARM"
|
||||||
|
messageNames[0x3106] = "CMD_HISTORY_ERROR"
|
||||||
|
messageNames[0x3107] = "CMD_HISTORY_CARBOHY"
|
||||||
|
messageNames[0x3108] = "CMD_HISTORY_REFILL"
|
||||||
|
messageNames[0x3109] = "CMD_HISTORY_SUSPEND"
|
||||||
|
messageNames[0x310a] = "CMD_HISTORY_BASAL_HOUR"
|
||||||
|
messageNames[0x310b] = "CMD_HISTORY_TB"
|
||||||
|
messageNames[0x31f1] = "CMD_HISTORY_STOP"
|
||||||
|
messageNames[0x31f2] = "CMD_HISTORY_LAST_T_R"
|
||||||
|
messageNames[0x31f3] = "CMD_HISTORY_LAST_T_S"
|
||||||
|
messageNames[0x0501] = "CMD_HISPAGE_MEAL_INS"
|
||||||
|
messageNames[0x0502] = "CMD_HISPAGE_DAY_INS"
|
||||||
|
messageNames[0x0503] = "CMD_HISPAGE_AIR_SUB"
|
||||||
|
messageNames[0x0504] = "CMD_HISPAGE_GLUCOSE"
|
||||||
|
messageNames[0x0505] = "CMD_HISPAGE_ALARM"
|
||||||
|
messageNames[0x0506] = "CMD_HISPAGE_ERROR"
|
||||||
|
messageNames[0x0507] = "CMD_HISPAGE_CARBOHY"
|
||||||
|
messageNames[0x0508] = "CMD_HISPAGE_REFILL"
|
||||||
|
messageNames[0x050a] = "CMD_HISPAGE_DAILTY_PRE_DATA"
|
||||||
|
messageNames[0x050b] = "CMD_HISPAGE_BOLUS_AVG"
|
||||||
|
messageNames[0x050c] = "CMD_HISPAGE_BASAL_RECORD"
|
||||||
|
messageNames[0x050d] = "CMD_HISPAGE_TB"
|
||||||
|
messageNames[0x3201] = "CMD_SETTING_V_MEAL_INS_I"
|
||||||
|
messageNames[0x3202] = "CMD_SETTING_V_BASAL_INS_I"
|
||||||
|
messageNames[0x3203] = "CMD_SETTING_V_MEAL_SETTING_I"
|
||||||
|
messageNames[0x3204] = "CMD_SETTING_V_CCC_I"
|
||||||
|
messageNames[0x3205] = "CMD_SETTING_V_MAX_VALUE_I"
|
||||||
|
messageNames[0x3206] = "CMD_SETTING_V_BASAL_PROFILE_ALL"
|
||||||
|
messageNames[0x3207] = "CMD_SETTING_V_SHIPPING_I"
|
||||||
|
messageNames[0x3208] = "CMD_SETTING_V_CLOGGIN_SENS_I"
|
||||||
|
messageNames[0x3209] = "CMD_SETTING_V_GLUCOSEandEASY"
|
||||||
|
messageNames[0x320a] = "CMD_SETTING_V_TIME_I"
|
||||||
|
messageNames[0x320b] = "CMD_SETTING_V_USER_OPTIONS"
|
||||||
|
messageNames[0x320c] = "CMD_SETTING_V_PROFILE_NUMBER"
|
||||||
|
messageNames[0x320d] = "CMD_SETTING_V_CIR_CF_VALUE"
|
||||||
|
messageNames[0x3301] = "CMD_SETTING_MEAL_INS_S"
|
||||||
|
messageNames[0x3302] = "CMD_SETTING_BASAL_INS_S"
|
||||||
|
messageNames[0x3303] = "CMD_SETTING_MEAL_SETTING_S"
|
||||||
|
messageNames[0x3304] = "CMD_SETTING_CCC_S"
|
||||||
|
messageNames[0x3305] = "CMD_SETTING_MAX_VALUE_S"
|
||||||
|
messageNames[0x3306] = "CMD_SETTING_BASAL_PROFILE_S"
|
||||||
|
messageNames[0x3307] = "CMD_SETTING_SHIPPING_S"
|
||||||
|
messageNames[0x3308] = "CMD_SETTING_CLOGGIN_SENS_S"
|
||||||
|
messageNames[0x3309] = "CMD_SETTING_GLUCOSEandEASY_S"
|
||||||
|
messageNames[0x330a] = "CMD_SETTING_TIME_S"
|
||||||
|
messageNames[0x330b] = "CMD_SETTING_USER_OPTIONS_S"
|
||||||
|
messageNames[0x330c] = "CMD_SETTING_PROFILE_NUMBER_S"
|
||||||
|
messageNames[0x330d] = "CMD_SETTING_CIR_CF_VALUE_S"
|
||||||
|
messageNames[0x0101] = "CMD_MEALINS_STOP"
|
||||||
|
messageNames[0x0102] = "CMD_MEALINS_START_DATA"
|
||||||
|
messageNames[0x0103] = "CMD_MEALINS_START_NODATA"
|
||||||
|
messageNames[0x0104] = "CMD_MEALINS_START_DATA_SPEED"
|
||||||
|
messageNames[0x0105] = "CMD_MEALINS_START_NODATA_SPEED"
|
||||||
|
messageNames[0x0201] = "CMD_PUMP_ACT_INS_VALUE"
|
||||||
|
messageNames[0x0202] = "CMD_PUMP_THIS_REMAINDER_MEAL_INS"
|
||||||
|
messageNames[0x0203] = "CMD_PUMP_BASE_SET"
|
||||||
|
messageNames[0x0204] = "CMD_PUMP_CALCULATION_SETTING"
|
||||||
|
messageNames[0x0205] = "CMD_PUMP_EXERCISE_MODE"
|
||||||
|
messageNames[0x0206] = "CMD_PUMP_MEAL_INS_I"
|
||||||
|
messageNames[0x0207] = "CMD_PUMP_EXPANS_INS_I"
|
||||||
|
messageNames[0x0208] = "CMD_PUMP_EXPANS_INS_RQ"
|
||||||
|
messageNames[0x0209] = "CMD_PUMP_DUAL_INS_RQ"
|
||||||
|
messageNames[0x020a] = "CMD_PUMP_INITVIEW_I"
|
||||||
|
messageNames[0x020b] = "CMD_PUMP_STATUS"
|
||||||
|
messageNames[0x020c] = "CMD_PUMP_CAR_N_CIR"
|
||||||
|
messageNames[0x0301] = "CMD_PUMPINIT_TIME_INFO"
|
||||||
|
messageNames[0x0302] = "CMD_PUMPINIT_BOLUS_INFO"
|
||||||
|
messageNames[0x0303] = "CMD_PUMPINIT_INIT_INFO"
|
||||||
|
messageNames[0x0304] = "CMD_PUMPINIT_OPTION"
|
||||||
|
messageNames[0x0401] = "CMD_PUMPSET_EXERCISE_S"
|
||||||
|
messageNames[0x0402] = "CMD_PUMPSET_HIS_S"
|
||||||
|
messageNames[0x0403] = "CMD_PUMPSET_EXERCISE_STOP"
|
||||||
|
messageNames[0x0404] = "CMD_PUMPSET_PAUSE"
|
||||||
|
messageNames[0x0405] = "CMD_PUMPSET_PAUSE_STOP"
|
||||||
|
messageNames[0x0406] = "CMD_PUMPSET_EXPANS_INS_STOP"
|
||||||
|
messageNames[0x0407] = "CMD_PUMPSET_EXPANS_INS_S"
|
||||||
|
messageNames[0x0408] = "CMD_PUMPSET_DUAL_S"
|
||||||
|
messageNames[0x0409] = "CMD_PUMPSET_EASY_OFF"
|
||||||
|
messageNames[0x0601] = "CMD_PUMPOWAY_SYSTEM_STATUS"
|
||||||
|
messageNames[0x0602] = "CMD_PUMPOWAY_GLUCOSE_ALARM"
|
||||||
|
messageNames[0x0603] = "CMD_PUMPOWAY_LOW_INSULIN_ALARM"
|
||||||
|
messageNames[0x0610] = "CMD_PUMP_ALARM_TIEOUT"
|
||||||
|
messageNames[0x0701] = "CMD_MSGRECEP_TAKE_SUGAR"
|
||||||
|
messageNames[0x0702] = "CMD_MSGRECEP_GO_TO_DOCTOR"
|
||||||
|
messageNames[0x0703] = "CMD_MSGRECEP_CALL_TO_CAREGIVER"
|
||||||
|
messageNames[0x0704] = "CMD_MSGRECEP_CHECK_GLUCOSE_AGAIN"
|
||||||
|
messageNames[0x0705] = "CMD_MSGRECEP_CALL_TO_HOME"
|
||||||
|
messageNames[0x0706] = "CMD_MSGRECEP_DO_DELIVER"
|
||||||
|
messageNames[0x0801] = "CMD_MSGSEND_YES_I_DO"
|
||||||
|
messageNames[0x0802] = "CMD_MSGSEND_NO_I_CANNOT"
|
||||||
|
messageNames[0x0803] = "CMD_MSGSEND_CALL_TO_ME_MOM"
|
||||||
|
messageNames[0x0804] = "CMD_MSGSEND_DO_NOT_INFUSE"
|
||||||
|
messageNames[0x0901] = "CMD_FILL_REFILL_COUNT"
|
||||||
|
messageNames[0x0902] = "CMD_FILL_PRIME_CHECK"
|
||||||
|
messageNames[0x0903] = "CMD_FILL_PRIME_END"
|
||||||
|
messageNames[0x0904] = "CMD_FILL_PRIME_STOP"
|
||||||
|
messageNames[0x0905] = "CMD_FILL_PRIME_PAUSE"
|
||||||
|
messageNames[0x0906] = "CMD_FILL_PRIME_RATE"
|
||||||
|
messageNames[0x41f2] = "CMD_HISTORY_ALL"
|
||||||
|
messageNames[0x42f2] = "CMD_HISTORY_NEW"
|
||||||
|
messageNames[0x41f1] = "CMD_HISTORY_ALL_DONE"
|
||||||
|
messageNames[0x42f1] = "CMD_HISTORY_NEW_DONE"
|
||||||
|
messageNames[0xF0F1] = "CMD_PUMP_CHECK_VALUE"
|
||||||
|
messageNames[0xF0F2] = "CMD_PUMP_TIMECHANGE_CHECK"
|
||||||
|
messageNames[0xF0F3] = "CMD_PUMP_TIMECHANGE_CLEAR"
|
||||||
|
messageNames[0x43F2] = "CMD_HISTORY_DATEOVER_ALL"
|
||||||
|
messageNames[0x4300] = "CMD_HISTORY_DATEOVER_DONE"
|
||||||
|
messageNames[0xE001] = "CMD_PUMPSTATUS_APS"
|
||||||
|
messageNames[0xE002] = "CMD_PUMPSET_APSTEMP"
|
||||||
|
messageNames[0xE003] = "CMD_GET_HISTORY"
|
||||||
|
messageNames[0xE004] = "CMD_SET_HISTORY_ENTRY"
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,53 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
import info.nightscout.androidaps.R;
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress;
|
|
||||||
import info.nightscout.androidaps.plugins.treatments.Treatment;
|
|
||||||
|
|
||||||
public class MsgBolusProgress extends MessageBase {
|
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(L.PUMPCOMM);
|
|
||||||
|
|
||||||
private static Treatment t;
|
|
||||||
private static double amount;
|
|
||||||
|
|
||||||
public static long lastReceive = 0;
|
|
||||||
public int progress = -1;
|
|
||||||
|
|
||||||
public MsgBolusProgress() {
|
|
||||||
SetCommand(0x0202);
|
|
||||||
}
|
|
||||||
|
|
||||||
public MsgBolusProgress(double amount, Treatment t) {
|
|
||||||
this();
|
|
||||||
this.amount = amount;
|
|
||||||
this.t = t;
|
|
||||||
lastReceive = System.currentTimeMillis();
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("New message: amount: " + amount + " treatment: " + t.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleMessage(byte[] bytes) {
|
|
||||||
progress = intFromBuff(bytes, 0, 2);
|
|
||||||
lastReceive = System.currentTimeMillis();
|
|
||||||
Double done = (amount * 100 - progress) / 100d;
|
|
||||||
t.insulin = done;
|
|
||||||
EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.INSTANCE;
|
|
||||||
bolusingEvent.setStatus(String.format(MainApp.gs(R.string.bolusdelivering), done));
|
|
||||||
bolusingEvent.setT(t);
|
|
||||||
bolusingEvent.setPercent(Math.min((int) (done / amount * 100), 100));
|
|
||||||
|
|
||||||
if (L.isEnabled(L.PUMPCOMM)) {
|
|
||||||
log.debug("Bolus remaining: " + progress + " delivered: " + done);
|
|
||||||
}
|
|
||||||
|
|
||||||
RxBus.Companion.getINSTANCE().send(bolusingEvent);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.R
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress
|
||||||
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import kotlin.math.min
|
||||||
|
|
||||||
|
class MsgBolusProgress(
|
||||||
|
private val aapsLogger: AAPSLogger,
|
||||||
|
private val resourceHelper: ResourceHelper,
|
||||||
|
private val rxBus: RxBusWrapper,
|
||||||
|
private val danaRPump: DanaRPump
|
||||||
|
) : MessageBase() {
|
||||||
|
|
||||||
|
init {
|
||||||
|
SetCommand(0x0202)
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun handleMessage(bytes: ByteArray) {
|
||||||
|
val deliveredInsulin = danaRPump.bolusAmountToBeDelivered - intFromBuff(bytes, 0, 2) / 100.0
|
||||||
|
danaRPump.bolusProgressLastTimeStamp = System.currentTimeMillis()
|
||||||
|
danaRPump.bolusingTreatment?.insulin = deliveredInsulin
|
||||||
|
val bolusingEvent = EventOverviewBolusProgress
|
||||||
|
bolusingEvent.status = resourceHelper.gs(R.string.bolusdelivering, deliveredInsulin)
|
||||||
|
bolusingEvent.t = danaRPump.bolusingTreatment
|
||||||
|
bolusingEvent.percent = min((deliveredInsulin / danaRPump.bolusAmountToBeDelivered * 100).toInt(), 100)
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "Delivered insulin so far: $deliveredInsulin")
|
||||||
|
rxBus.send(bolusingEvent)
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,51 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
import info.nightscout.androidaps.R;
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress;
|
|
||||||
import info.nightscout.androidaps.plugins.treatments.Treatment;
|
|
||||||
|
|
||||||
public class MsgBolusStop extends MessageBase {
|
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(L.PUMPCOMM);
|
|
||||||
private static Treatment t;
|
|
||||||
private static Double amount;
|
|
||||||
|
|
||||||
public static boolean stopped = false;
|
|
||||||
public static boolean forced = false;
|
|
||||||
|
|
||||||
public MsgBolusStop() {
|
|
||||||
SetCommand(0x0101);
|
|
||||||
stopped = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MsgBolusStop(Double amount, Treatment t) {
|
|
||||||
this();
|
|
||||||
this.t = t;
|
|
||||||
this.amount = amount;
|
|
||||||
forced = false;
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("Bolus stop: amount: " + amount + " treatment: " + t.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleMessage(byte[] bytes) {
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("Messsage received");
|
|
||||||
EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.INSTANCE;
|
|
||||||
stopped = true;
|
|
||||||
if (!forced) {
|
|
||||||
t.insulin = amount;
|
|
||||||
bolusingEvent.setStatus(MainApp.gs(R.string.overview_bolusprogress_delivered));
|
|
||||||
bolusingEvent.setPercent(100);
|
|
||||||
} else {
|
|
||||||
bolusingEvent.setStatus(MainApp.gs(R.string.overview_bolusprogress_stoped));
|
|
||||||
}
|
|
||||||
RxBus.Companion.getINSTANCE().send(bolusingEvent);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainApp
|
||||||
|
import info.nightscout.androidaps.R
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress
|
||||||
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
|
||||||
|
class MsgBolusStop(
|
||||||
|
private val aapsLogger: AAPSLogger,
|
||||||
|
private val rxBus: RxBusWrapper,
|
||||||
|
private val resourceHelper: ResourceHelper,
|
||||||
|
private val danaRPump: DanaRPump
|
||||||
|
) : MessageBase() {
|
||||||
|
|
||||||
|
init {
|
||||||
|
SetCommand(0x0101)
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun handleMessage(bytes: ByteArray) {
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "Messsage received")
|
||||||
|
val bolusingEvent = EventOverviewBolusProgress
|
||||||
|
danaRPump.bolusStopped = true
|
||||||
|
if (!danaRPump.bolusStopForced) {
|
||||||
|
danaRPump.bolusingTreatment?.insulin = danaRPump.bolusAmountToBeDelivered
|
||||||
|
bolusingEvent.status = resourceHelper.gs(R.string.overview_bolusprogress_delivered)
|
||||||
|
bolusingEvent.percent = 100
|
||||||
|
} else {
|
||||||
|
bolusingEvent.status = MainApp.gs(R.string.overview_bolusprogress_stoped)
|
||||||
|
}
|
||||||
|
rxBus.send(bolusingEvent)
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,60 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
import info.nightscout.androidaps.R;
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress;
|
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
|
||||||
|
|
||||||
public class MsgError extends MessageBase {
|
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(L.PUMPCOMM);
|
|
||||||
|
|
||||||
public MsgError() {
|
|
||||||
SetCommand(0x0601);
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("New message");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleMessage(byte[] bytes) {
|
|
||||||
int errorCode = intFromBuff(bytes, 0, 1);
|
|
||||||
String errorString = "";
|
|
||||||
|
|
||||||
switch (errorCode) {
|
|
||||||
case 1:
|
|
||||||
case 2:
|
|
||||||
case 3: // Pump error
|
|
||||||
errorString = MainApp.gs(R.string.pumperror) + " " + errorCode;
|
|
||||||
break;
|
|
||||||
case 4: // Shutdown
|
|
||||||
errorString = MainApp.gs(R.string.pumpshutdown);
|
|
||||||
break;
|
|
||||||
case 5: // Occlusion
|
|
||||||
errorString = MainApp.gs(R.string.occlusion);
|
|
||||||
break;
|
|
||||||
case 7: // Low Battery
|
|
||||||
errorString = MainApp.gs(R.string.lowbattery);
|
|
||||||
break;
|
|
||||||
case 8: // Battery 0%
|
|
||||||
errorString = MainApp.gs(R.string.batterydischarged);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (errorCode < 8) { // bolus delivering stopped
|
|
||||||
EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.INSTANCE;
|
|
||||||
MsgBolusStop.stopped = true;
|
|
||||||
bolusingEvent.setStatus(errorString);
|
|
||||||
RxBus.Companion.getINSTANCE().send(bolusingEvent);
|
|
||||||
failed=true;
|
|
||||||
}
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("Error detected: " + errorString);
|
|
||||||
NSUpload.uploadError(errorString);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.R
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
||||||
|
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress
|
||||||
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
|
||||||
|
class MsgError(
|
||||||
|
private val aapsLogger: AAPSLogger,
|
||||||
|
private val rxBus: RxBusWrapper,
|
||||||
|
private val resourceHelper: ResourceHelper,
|
||||||
|
private val danaRPump: DanaRPump
|
||||||
|
) : MessageBase() {
|
||||||
|
|
||||||
|
init {
|
||||||
|
SetCommand(0x0601)
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun handleMessage(bytes: ByteArray) {
|
||||||
|
val errorCode = intFromBuff(bytes, 0, 1)
|
||||||
|
var errorString = ""
|
||||||
|
when (errorCode) {
|
||||||
|
1, 2, 3 -> errorString = resourceHelper.gs(R.string.pumperror) + " " + errorCode
|
||||||
|
4 -> errorString = resourceHelper.gs(R.string.pumpshutdown)
|
||||||
|
5 -> errorString = resourceHelper.gs(R.string.occlusion)
|
||||||
|
7 -> errorString = resourceHelper.gs(R.string.lowbattery)
|
||||||
|
8 -> errorString = resourceHelper.gs(R.string.batterydischarged)
|
||||||
|
}
|
||||||
|
if (errorCode < 8) { // bolus delivering stopped
|
||||||
|
val bolusingEvent = EventOverviewBolusProgress
|
||||||
|
danaRPump.bolusStopped = true
|
||||||
|
bolusingEvent.status = errorString
|
||||||
|
rxBus.send(bolusingEvent)
|
||||||
|
failed = true
|
||||||
|
} else {
|
||||||
|
failed = false
|
||||||
|
}
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "Error detected: $errorString")
|
||||||
|
NSUpload.uploadError(errorString)
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,20 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 20.07.2016.
|
|
||||||
*/
|
|
||||||
public class MsgHistoryAlarm extends MsgHistoryAll {
|
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(L.PUMPCOMM);
|
|
||||||
public MsgHistoryAlarm() {
|
|
||||||
SetCommand(0x3105);
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("New message");
|
|
||||||
}
|
|
||||||
// Handle message taken from MsgHistoryAll
|
|
||||||
}
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
|
||||||
|
class MsgHistoryAlarm(
|
||||||
|
aapsLogger: AAPSLogger,
|
||||||
|
rxBus: RxBusWrapper
|
||||||
|
) : MsgHistoryAll(aapsLogger, rxBus) {
|
||||||
|
|
||||||
|
init {
|
||||||
|
SetCommand(0x3105)
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
|
}
|
||||||
|
// Handle message taken from MsgHistoryAll
|
||||||
|
}
|
|
@ -1,150 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
import info.nightscout.androidaps.db.DanaRHistoryRecord;
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.events.EventDanaRSyncStatus;
|
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
|
||||||
|
|
||||||
public class MsgHistoryAll extends MessageBase {
|
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(L.PUMPCOMM);
|
|
||||||
|
|
||||||
public MsgHistoryAll() {
|
|
||||||
SetCommand(0x41F2);
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("New message");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleMessage(byte[] bytes) {
|
|
||||||
byte recordCode = (byte) intFromBuff(bytes, 0, 1);
|
|
||||||
long date = dateFromBuff(bytes, 1); // 3 bytes
|
|
||||||
long datetime = dateTimeFromBuff(bytes, 1); // 5 bytes
|
|
||||||
long datetimewihtsec = dateTimeSecFromBuff(bytes, 1); // 6 bytes
|
|
||||||
|
|
||||||
double dailyBasal = intFromBuff(bytes, 4, 2) * 0.01d;
|
|
||||||
double dailyBolus = intFromBuff(bytes, 6, 2) * 0.01d;
|
|
||||||
byte paramByte5 = (byte) intFromBuff(bytes, 4, 1);
|
|
||||||
byte paramByte6 = (byte) intFromBuff(bytes, 5, 1);
|
|
||||||
byte paramByte7 = (byte) intFromBuff(bytes, 6, 1);
|
|
||||||
byte paramByte8 = (byte) intFromBuff(bytes, 7, 1);
|
|
||||||
double value = (double) intFromBuff(bytes, 8, 2);
|
|
||||||
|
|
||||||
DanaRHistoryRecord danaRHistoryRecord = new DanaRHistoryRecord();
|
|
||||||
|
|
||||||
danaRHistoryRecord.recordCode = recordCode;
|
|
||||||
danaRHistoryRecord.setBytes(bytes);
|
|
||||||
|
|
||||||
String messageType = "";
|
|
||||||
|
|
||||||
switch (recordCode) {
|
|
||||||
case RecordTypes.RECORD_TYPE_BOLUS:
|
|
||||||
danaRHistoryRecord.recordDate = datetime;
|
|
||||||
switch (0xF0 & paramByte8) {
|
|
||||||
case 0xA0:
|
|
||||||
danaRHistoryRecord.bolusType = "DS";
|
|
||||||
messageType += "DS bolus";
|
|
||||||
break;
|
|
||||||
case 0xC0:
|
|
||||||
danaRHistoryRecord.bolusType = "E";
|
|
||||||
messageType += "E bolus";
|
|
||||||
break;
|
|
||||||
case 0x80:
|
|
||||||
danaRHistoryRecord.bolusType = "S";
|
|
||||||
messageType += "S bolus";
|
|
||||||
break;
|
|
||||||
case 0x90:
|
|
||||||
danaRHistoryRecord.bolusType = "DE";
|
|
||||||
messageType += "DE bolus";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
danaRHistoryRecord.bolusType = "None";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
danaRHistoryRecord.recordDuration = ((int) paramByte8 & 0x0F) * 60 + (int) paramByte7;
|
|
||||||
danaRHistoryRecord.recordValue = value * 0.01;
|
|
||||||
break;
|
|
||||||
case RecordTypes.RECORD_TYPE_DAILY:
|
|
||||||
messageType += "dailyinsulin";
|
|
||||||
danaRHistoryRecord.recordDate = date;
|
|
||||||
danaRHistoryRecord.recordDailyBasal = dailyBasal;
|
|
||||||
danaRHistoryRecord.recordDailyBolus = dailyBolus;
|
|
||||||
break;
|
|
||||||
case RecordTypes.RECORD_TYPE_PRIME:
|
|
||||||
messageType += "prime";
|
|
||||||
danaRHistoryRecord.recordDate = datetimewihtsec;
|
|
||||||
danaRHistoryRecord.recordValue = value * 0.01;
|
|
||||||
break;
|
|
||||||
case RecordTypes.RECORD_TYPE_ERROR:
|
|
||||||
messageType += "error";
|
|
||||||
danaRHistoryRecord.recordDate = datetimewihtsec;
|
|
||||||
danaRHistoryRecord.recordValue = value * 0.01;
|
|
||||||
break;
|
|
||||||
case RecordTypes.RECORD_TYPE_REFILL:
|
|
||||||
messageType += "refill";
|
|
||||||
danaRHistoryRecord.recordDate = datetimewihtsec;
|
|
||||||
danaRHistoryRecord.recordValue = value * 0.01;
|
|
||||||
break;
|
|
||||||
case RecordTypes.RECORD_TYPE_BASALHOUR:
|
|
||||||
messageType += "basal hour";
|
|
||||||
danaRHistoryRecord.recordDate = datetimewihtsec;
|
|
||||||
danaRHistoryRecord.recordValue = value * 0.01;
|
|
||||||
break;
|
|
||||||
case RecordTypes.RECORD_TYPE_TB:
|
|
||||||
messageType += "tb";
|
|
||||||
danaRHistoryRecord.recordDate = datetimewihtsec;
|
|
||||||
danaRHistoryRecord.recordValue = value * 0.01;
|
|
||||||
break;
|
|
||||||
case RecordTypes.RECORD_TYPE_GLUCOSE:
|
|
||||||
messageType += "glucose";
|
|
||||||
danaRHistoryRecord.recordDate = datetimewihtsec;
|
|
||||||
danaRHistoryRecord.recordValue = value;
|
|
||||||
break;
|
|
||||||
case RecordTypes.RECORD_TYPE_CARBO:
|
|
||||||
messageType += "carbo";
|
|
||||||
danaRHistoryRecord.recordDate = datetimewihtsec;
|
|
||||||
danaRHistoryRecord.recordValue = value;
|
|
||||||
break;
|
|
||||||
case RecordTypes.RECORD_TYPE_ALARM:
|
|
||||||
messageType += "alarm";
|
|
||||||
danaRHistoryRecord.recordDate = datetimewihtsec;
|
|
||||||
String strAlarm = "None";
|
|
||||||
switch ((int) paramByte8) {
|
|
||||||
case 67:
|
|
||||||
strAlarm = "Check";
|
|
||||||
break;
|
|
||||||
case 79:
|
|
||||||
strAlarm = "Occlusion";
|
|
||||||
break;
|
|
||||||
case 66:
|
|
||||||
strAlarm = "Low Battery";
|
|
||||||
break;
|
|
||||||
case 83:
|
|
||||||
strAlarm = "Shutdown";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
danaRHistoryRecord.recordAlarm = strAlarm;
|
|
||||||
danaRHistoryRecord.recordValue = value * 0.01;
|
|
||||||
break;
|
|
||||||
case RecordTypes.RECORD_TYPE_SUSPEND:
|
|
||||||
messageType += "suspend";
|
|
||||||
danaRHistoryRecord.recordDate = datetimewihtsec;
|
|
||||||
String strRecordValue = "Off";
|
|
||||||
if ((int) paramByte8 == 79)
|
|
||||||
strRecordValue = "On";
|
|
||||||
danaRHistoryRecord.stringRecordValue = strRecordValue;
|
|
||||||
break;
|
|
||||||
case 17:
|
|
||||||
failed = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
MainApp.getDbHelper().createOrUpdate(danaRHistoryRecord);
|
|
||||||
RxBus.Companion.getINSTANCE().send(new EventDanaRSyncStatus(DateUtil.dateAndTimeString(danaRHistoryRecord.recordDate) + " " + messageType));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,143 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainApp
|
||||||
|
import info.nightscout.androidaps.db.DanaRHistoryRecord
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
import info.nightscout.androidaps.plugins.pump.danaR.events.EventDanaRSyncStatus
|
||||||
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
|
|
||||||
|
open class MsgHistoryAll(
|
||||||
|
val aapsLogger: AAPSLogger,
|
||||||
|
val rxBus: RxBusWrapper
|
||||||
|
) : MessageBase() {
|
||||||
|
|
||||||
|
init {
|
||||||
|
SetCommand(0x41F2)
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun handleMessage(bytes: ByteArray) {
|
||||||
|
val recordCode = intFromBuff(bytes, 0, 1).toByte()
|
||||||
|
val date = dateFromBuff(bytes, 1) // 3 bytes
|
||||||
|
val datetime = dateTimeFromBuff(bytes, 1) // 5 bytes
|
||||||
|
val datetimewihtsec = dateTimeSecFromBuff(bytes, 1) // 6 bytes
|
||||||
|
val dailyBasal = intFromBuff(bytes, 4, 2) * 0.01
|
||||||
|
val dailyBolus = intFromBuff(bytes, 6, 2) * 0.01
|
||||||
|
val paramByte5 = intFromBuff(bytes, 4, 1).toByte()
|
||||||
|
val paramByte6 = intFromBuff(bytes, 5, 1).toByte()
|
||||||
|
val paramByte7 = intFromBuff(bytes, 6, 1).toByte()
|
||||||
|
val paramByte8 = intFromBuff(bytes, 7, 1).toByte()
|
||||||
|
val value = intFromBuff(bytes, 8, 2).toDouble()
|
||||||
|
val danaRHistoryRecord = DanaRHistoryRecord()
|
||||||
|
danaRHistoryRecord.recordCode = recordCode
|
||||||
|
danaRHistoryRecord.setBytes(bytes)
|
||||||
|
var messageType = ""
|
||||||
|
when (recordCode) {
|
||||||
|
RecordTypes.RECORD_TYPE_BOLUS -> {
|
||||||
|
danaRHistoryRecord.recordDate = datetime
|
||||||
|
when (0xF0 and paramByte8.toInt()) {
|
||||||
|
0xA0 -> {
|
||||||
|
danaRHistoryRecord.bolusType = "DS"
|
||||||
|
messageType += "DS bolus"
|
||||||
|
}
|
||||||
|
|
||||||
|
0xC0 -> {
|
||||||
|
danaRHistoryRecord.bolusType = "E"
|
||||||
|
messageType += "E bolus"
|
||||||
|
}
|
||||||
|
|
||||||
|
0x80 -> {
|
||||||
|
danaRHistoryRecord.bolusType = "S"
|
||||||
|
messageType += "S bolus"
|
||||||
|
}
|
||||||
|
|
||||||
|
0x90 -> {
|
||||||
|
danaRHistoryRecord.bolusType = "DE"
|
||||||
|
messageType += "DE bolus"
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> danaRHistoryRecord.bolusType = "None"
|
||||||
|
}
|
||||||
|
danaRHistoryRecord.recordDuration = (paramByte8.toInt() and 0x0F) * 60 + paramByte7.toInt()
|
||||||
|
danaRHistoryRecord.recordValue = value * 0.01
|
||||||
|
}
|
||||||
|
|
||||||
|
RecordTypes.RECORD_TYPE_DAILY -> {
|
||||||
|
messageType += "dailyinsulin"
|
||||||
|
danaRHistoryRecord.recordDate = date
|
||||||
|
danaRHistoryRecord.recordDailyBasal = dailyBasal
|
||||||
|
danaRHistoryRecord.recordDailyBolus = dailyBolus
|
||||||
|
}
|
||||||
|
|
||||||
|
RecordTypes.RECORD_TYPE_PRIME -> {
|
||||||
|
messageType += "prime"
|
||||||
|
danaRHistoryRecord.recordDate = datetimewihtsec
|
||||||
|
danaRHistoryRecord.recordValue = value * 0.01
|
||||||
|
}
|
||||||
|
|
||||||
|
RecordTypes.RECORD_TYPE_ERROR -> {
|
||||||
|
messageType += "error"
|
||||||
|
danaRHistoryRecord.recordDate = datetimewihtsec
|
||||||
|
danaRHistoryRecord.recordValue = value * 0.01
|
||||||
|
}
|
||||||
|
|
||||||
|
RecordTypes.RECORD_TYPE_REFILL -> {
|
||||||
|
messageType += "refill"
|
||||||
|
danaRHistoryRecord.recordDate = datetimewihtsec
|
||||||
|
danaRHistoryRecord.recordValue = value * 0.01
|
||||||
|
}
|
||||||
|
|
||||||
|
RecordTypes.RECORD_TYPE_BASALHOUR -> {
|
||||||
|
messageType += "basal hour"
|
||||||
|
danaRHistoryRecord.recordDate = datetimewihtsec
|
||||||
|
danaRHistoryRecord.recordValue = value * 0.01
|
||||||
|
}
|
||||||
|
|
||||||
|
RecordTypes.RECORD_TYPE_TB -> {
|
||||||
|
messageType += "tb"
|
||||||
|
danaRHistoryRecord.recordDate = datetimewihtsec
|
||||||
|
danaRHistoryRecord.recordValue = value * 0.01
|
||||||
|
}
|
||||||
|
|
||||||
|
RecordTypes.RECORD_TYPE_GLUCOSE -> {
|
||||||
|
messageType += "glucose"
|
||||||
|
danaRHistoryRecord.recordDate = datetimewihtsec
|
||||||
|
danaRHistoryRecord.recordValue = value
|
||||||
|
}
|
||||||
|
|
||||||
|
RecordTypes.RECORD_TYPE_CARBO -> {
|
||||||
|
messageType += "carbo"
|
||||||
|
danaRHistoryRecord.recordDate = datetimewihtsec
|
||||||
|
danaRHistoryRecord.recordValue = value
|
||||||
|
}
|
||||||
|
|
||||||
|
RecordTypes.RECORD_TYPE_ALARM -> {
|
||||||
|
messageType += "alarm"
|
||||||
|
danaRHistoryRecord.recordDate = datetimewihtsec
|
||||||
|
var strAlarm = "None"
|
||||||
|
when (paramByte8.toInt()) {
|
||||||
|
67 -> strAlarm = "Check"
|
||||||
|
79 -> strAlarm = "Occlusion"
|
||||||
|
66 -> strAlarm = "Low Battery"
|
||||||
|
83 -> strAlarm = "Shutdown"
|
||||||
|
}
|
||||||
|
danaRHistoryRecord.recordAlarm = strAlarm
|
||||||
|
danaRHistoryRecord.recordValue = value * 0.01
|
||||||
|
}
|
||||||
|
|
||||||
|
RecordTypes.RECORD_TYPE_SUSPEND -> {
|
||||||
|
messageType += "suspend"
|
||||||
|
danaRHistoryRecord.recordDate = datetimewihtsec
|
||||||
|
var strRecordValue = "Off"
|
||||||
|
if (paramByte8.toInt() == 79) strRecordValue = "On"
|
||||||
|
danaRHistoryRecord.stringRecordValue = strRecordValue
|
||||||
|
}
|
||||||
|
|
||||||
|
17.toByte() -> failed = true
|
||||||
|
}
|
||||||
|
MainApp.getDbHelper().createOrUpdate(danaRHistoryRecord)
|
||||||
|
rxBus.send(EventDanaRSyncStatus(DateUtil.dateAndTimeString(danaRHistoryRecord.recordDate) + " " + messageType))
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,26 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
|
||||||
|
|
||||||
public class MsgHistoryAllDone extends MessageBase {
|
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(L.PUMPCOMM);
|
|
||||||
public static boolean received = false;
|
|
||||||
|
|
||||||
public MsgHistoryAllDone() {
|
|
||||||
SetCommand(0x41F1);
|
|
||||||
received = false;
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("New message");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleMessage(byte[] bytes) {
|
|
||||||
received = true;
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("History all done received");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||||
|
|
||||||
|
class MsgHistoryAllDone(
|
||||||
|
private val aapsLogger: AAPSLogger,
|
||||||
|
private val danaRPump: DanaRPump
|
||||||
|
) : MessageBase() {
|
||||||
|
|
||||||
|
init {
|
||||||
|
SetCommand(0x41F1)
|
||||||
|
danaRPump.historyDoneReceived = false
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun handleMessage(bytes: ByteArray) {
|
||||||
|
danaRPump.historyDoneReceived = true
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "History all done received")
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,20 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 20.07.2016.
|
|
||||||
*/
|
|
||||||
public class MsgHistoryBasalHour extends MsgHistoryAll {
|
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(L.PUMPCOMM);
|
|
||||||
public MsgHistoryBasalHour() {
|
|
||||||
SetCommand(0x310A);
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("New message");
|
|
||||||
}
|
|
||||||
// Handle message taken from MsgHistoryAll
|
|
||||||
}
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
|
||||||
|
class MsgHistoryBasalHour(
|
||||||
|
aapsLogger: AAPSLogger,
|
||||||
|
rxBus: RxBusWrapper
|
||||||
|
) : MsgHistoryAll(aapsLogger, rxBus) {
|
||||||
|
|
||||||
|
init {
|
||||||
|
SetCommand(0x310A)
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
|
}
|
||||||
|
// Handle message taken from MsgHistoryAll
|
||||||
|
}
|
|
@ -1,21 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 20.07.2016.
|
|
||||||
*/
|
|
||||||
public class MsgHistoryBolus extends MsgHistoryAll {
|
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(L.PUMPCOMM);
|
|
||||||
|
|
||||||
public MsgHistoryBolus() {
|
|
||||||
SetCommand(0x3101);
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("New message");
|
|
||||||
}
|
|
||||||
// Handle message taken from MsgHistoryAll
|
|
||||||
}
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
|
||||||
|
class MsgHistoryBolus(
|
||||||
|
aapsLogger: AAPSLogger,
|
||||||
|
rxBus: RxBusWrapper
|
||||||
|
) : MsgHistoryAll(aapsLogger, rxBus) {
|
||||||
|
|
||||||
|
init {
|
||||||
|
SetCommand(0x3101)
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
|
}
|
||||||
|
// Handle message taken from MsgHistoryAll
|
||||||
|
}
|
|
@ -1,20 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 20.07.2016.
|
|
||||||
*/
|
|
||||||
public class MsgHistoryCarbo extends MsgHistoryAll {
|
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(L.PUMPCOMM);
|
|
||||||
public MsgHistoryCarbo() {
|
|
||||||
SetCommand(0x3107);
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("New message");
|
|
||||||
}
|
|
||||||
// Handle message taken from MsgHistoryAll
|
|
||||||
}
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
|
||||||
|
class MsgHistoryCarbo(
|
||||||
|
aapsLogger: AAPSLogger,
|
||||||
|
rxBus: RxBusWrapper
|
||||||
|
) : MsgHistoryAll(aapsLogger, rxBus) {
|
||||||
|
|
||||||
|
init {
|
||||||
|
SetCommand(0x3107)
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
|
}
|
||||||
|
// Handle message taken from MsgHistoryAll
|
||||||
|
}
|
|
@ -1,20 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 20.07.2016.
|
|
||||||
*/
|
|
||||||
public class MsgHistoryDailyInsulin extends MsgHistoryAll {
|
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(L.PUMPCOMM);
|
|
||||||
public MsgHistoryDailyInsulin() {
|
|
||||||
SetCommand(0x3102);
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("New message");
|
|
||||||
}
|
|
||||||
// Handle message taken from MsgHistoryAll
|
|
||||||
}
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
|
||||||
|
class MsgHistoryDailyInsulin(
|
||||||
|
aapsLogger: AAPSLogger,
|
||||||
|
rxBus: RxBusWrapper
|
||||||
|
) : MsgHistoryAll(aapsLogger, rxBus) {
|
||||||
|
|
||||||
|
init {
|
||||||
|
SetCommand(0x3102)
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
|
}
|
||||||
|
// Handle message taken from MsgHistoryAll
|
||||||
|
}
|
|
@ -1,30 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 20.07.2016.
|
|
||||||
*/
|
|
||||||
public class MsgHistoryDone extends MessageBase {
|
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(L.PUMPCOMM);
|
|
||||||
public static boolean received = false;
|
|
||||||
|
|
||||||
public MsgHistoryDone() {
|
|
||||||
SetCommand(0x31F1);
|
|
||||||
received = false;
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("New message");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleMessage(byte[] bytes) {
|
|
||||||
received = true;
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("History done received");
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||||
|
|
||||||
|
class MsgHistoryDone(
|
||||||
|
private val aapsLogger: AAPSLogger,
|
||||||
|
private val danaRPump: DanaRPump
|
||||||
|
) : MessageBase() {
|
||||||
|
|
||||||
|
init {
|
||||||
|
SetCommand(0x31F1)
|
||||||
|
danaRPump.historyDoneReceived = false
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun handleMessage(bytes: ByteArray) {
|
||||||
|
danaRPump.historyDoneReceived = true
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "History done received")
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,21 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 20.07.2016.
|
|
||||||
*/
|
|
||||||
public class MsgHistoryError extends MsgHistoryAll {
|
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(L.PUMPCOMM);
|
|
||||||
|
|
||||||
public MsgHistoryError() {
|
|
||||||
SetCommand(0x3106);
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("New message");
|
|
||||||
}
|
|
||||||
// Handle message taken from MsgHistoryAll
|
|
||||||
}
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
|
||||||
|
class MsgHistoryError(
|
||||||
|
aapsLogger: AAPSLogger,
|
||||||
|
rxBus: RxBusWrapper
|
||||||
|
) : MsgHistoryAll(aapsLogger, rxBus) {
|
||||||
|
|
||||||
|
init {
|
||||||
|
SetCommand(0x3106)
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
|
}
|
||||||
|
// Handle message taken from MsgHistoryAll
|
||||||
|
}
|
|
@ -1,21 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 20.07.2016.
|
|
||||||
*/
|
|
||||||
public class MsgHistoryGlucose extends MsgHistoryAll {
|
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(L.PUMPCOMM);
|
|
||||||
|
|
||||||
public MsgHistoryGlucose() {
|
|
||||||
SetCommand(0x3104);
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("New message");
|
|
||||||
}
|
|
||||||
// Handle message taken from MsgHistoryAll
|
|
||||||
}
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
|
||||||
|
class MsgHistoryGlucose(
|
||||||
|
aapsLogger: AAPSLogger,
|
||||||
|
rxBus: RxBusWrapper
|
||||||
|
) : MsgHistoryAll(aapsLogger, rxBus) {
|
||||||
|
|
||||||
|
init {
|
||||||
|
SetCommand(0x3104)
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
|
}
|
||||||
|
// Handle message taken from MsgHistoryAll
|
||||||
|
}
|
|
@ -1,21 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 20.07.2016.
|
|
||||||
*/
|
|
||||||
public class MsgHistoryNew extends MsgHistoryAll {
|
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(L.PUMPCOMM);
|
|
||||||
|
|
||||||
public MsgHistoryNew() {
|
|
||||||
SetCommand(0x42F2);
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("New message");
|
|
||||||
}
|
|
||||||
// Handle message taken from MsgHistoryAll
|
|
||||||
}
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
|
||||||
|
class MsgHistoryNew(
|
||||||
|
aapsLogger: AAPSLogger,
|
||||||
|
rxBus: RxBusWrapper
|
||||||
|
) : MsgHistoryAll(aapsLogger, rxBus) {
|
||||||
|
|
||||||
|
init {
|
||||||
|
SetCommand(0x42F2)
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
|
}
|
||||||
|
// Handle message taken from MsgHistoryAll
|
||||||
|
}
|
|
@ -1,29 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 20.07.2016.
|
|
||||||
*/
|
|
||||||
public class MsgHistoryNewDone extends MessageBase {
|
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(L.PUMPCOMM);
|
|
||||||
public static boolean received = false;
|
|
||||||
|
|
||||||
public MsgHistoryNewDone() {
|
|
||||||
SetCommand(0x42F1);
|
|
||||||
received = false;
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("New message");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleMessage(byte[] bytes) {
|
|
||||||
received = true;
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("History new done received");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||||
|
|
||||||
|
class MsgHistoryNewDone(
|
||||||
|
private val aapsLogger: AAPSLogger,
|
||||||
|
private val danaRPump: DanaRPump
|
||||||
|
) : MessageBase() {
|
||||||
|
|
||||||
|
init {
|
||||||
|
SetCommand(0x42F1)
|
||||||
|
danaRPump.historyDoneReceived = false
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun handleMessage(bytes: ByteArray) {
|
||||||
|
danaRPump.historyDoneReceived = true
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "History new done received")
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,21 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 20.07.2016.
|
|
||||||
*/
|
|
||||||
public class MsgHistoryRefill extends MsgHistoryAll {
|
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(L.PUMPCOMM);
|
|
||||||
|
|
||||||
public MsgHistoryRefill() {
|
|
||||||
SetCommand(0x3108);
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("New message");
|
|
||||||
}
|
|
||||||
// Handle message taken from MsgHistoryAll
|
|
||||||
}
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
|
||||||
|
class MsgHistoryRefill(
|
||||||
|
aapsLogger: AAPSLogger,
|
||||||
|
rxBus: RxBusWrapper
|
||||||
|
) : MsgHistoryAll(aapsLogger, rxBus) {
|
||||||
|
|
||||||
|
init {
|
||||||
|
SetCommand(0x3108)
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
|
}
|
||||||
|
// Handle message taken from MsgHistoryAll
|
||||||
|
}
|
|
@ -1,21 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 20.07.2016.
|
|
||||||
*/
|
|
||||||
public class MsgHistorySuspend extends MsgHistoryAll {
|
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(L.PUMPCOMM);
|
|
||||||
|
|
||||||
public MsgHistorySuspend() {
|
|
||||||
SetCommand(0x3109);
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("New message");
|
|
||||||
}
|
|
||||||
// Handle message taken from MsgHistoryAll
|
|
||||||
}
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
|
||||||
|
class MsgHistorySuspend(
|
||||||
|
aapsLogger: AAPSLogger,
|
||||||
|
rxBus: RxBusWrapper
|
||||||
|
) : MsgHistoryAll(aapsLogger, rxBus) {
|
||||||
|
|
||||||
|
init {
|
||||||
|
SetCommand(0x3109)
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
|
}
|
||||||
|
// Handle message taken from MsgHistoryAll
|
||||||
|
}
|
|
@ -1,23 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
|
||||||
|
|
||||||
public class MsgPCCommStart extends MessageBase {
|
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(L.PUMPCOMM);
|
|
||||||
|
|
||||||
public MsgPCCommStart() {
|
|
||||||
SetCommand(0x3001);
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("New message");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleMessage(byte[] bytes) {
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("PC comm start received");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
|
||||||
|
class MsgPCCommStart constructor(
|
||||||
|
private val aapsLogger: AAPSLogger
|
||||||
|
) : MessageBase() {
|
||||||
|
|
||||||
|
init {
|
||||||
|
SetCommand(0x3001)
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun handleMessage(bytes: ByteArray) {
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "PC comm start received")
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,22 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
|
||||||
|
|
||||||
public class MsgPCCommStop extends MessageBase {
|
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(L.PUMPCOMM);
|
|
||||||
public MsgPCCommStop() {
|
|
||||||
SetCommand(0x3002);
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("New message");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleMessage(byte[] bytes) {
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("PC comm stop received");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
|
||||||
|
class MsgPCCommStop(
|
||||||
|
private val aapsLogger: AAPSLogger
|
||||||
|
) : MessageBase() {
|
||||||
|
|
||||||
|
init {
|
||||||
|
SetCommand(0x3002)
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun handleMessage(bytes: ByteArray) {
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "PC comm stop received")
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,38 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
|
||||||
|
|
||||||
public class MsgSetActivateBasalProfile extends MessageBase {
|
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(L.PUMPCOMM);
|
|
||||||
|
|
||||||
public MsgSetActivateBasalProfile() {
|
|
||||||
SetCommand(0x330C);
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("New message");
|
|
||||||
}
|
|
||||||
|
|
||||||
// index 0-3
|
|
||||||
public MsgSetActivateBasalProfile(byte index) {
|
|
||||||
this();
|
|
||||||
AddParamByte(index);
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("Activate basal profile: " + index);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleMessage(byte[] bytes) {
|
|
||||||
int result = intFromBuff(bytes, 0, 1);
|
|
||||||
if (result != 1) {
|
|
||||||
failed = true;
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("Activate basal profile result: " + result + " FAILED!!!");
|
|
||||||
} else {
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("Activate basal profile result: " + result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
|
||||||
|
class MsgSetActivateBasalProfile(
|
||||||
|
private val aapsLogger: AAPSLogger,
|
||||||
|
index: Byte
|
||||||
|
) : MessageBase() {
|
||||||
|
|
||||||
|
// index 0-3
|
||||||
|
init {
|
||||||
|
SetCommand(0x330C)
|
||||||
|
AddParamByte(index)
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "Activate basal profile: $index")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun handleMessage(bytes: ByteArray) {
|
||||||
|
val result = intFromBuff(bytes, 0, 1)
|
||||||
|
if (result != 1) {
|
||||||
|
failed = true
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "Activate basal profile result: $result FAILED!!!")
|
||||||
|
} else {
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "Activate basal profile result: $result")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,52 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
import info.nightscout.androidaps.R;
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
|
|
||||||
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
|
|
||||||
|
|
||||||
public class MsgSetBasalProfile extends MessageBase {
|
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(L.PUMPCOMM);
|
|
||||||
|
|
||||||
public MsgSetBasalProfile() {
|
|
||||||
SetCommand(0x3306);
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("New message");
|
|
||||||
}
|
|
||||||
|
|
||||||
// index 0-3
|
|
||||||
public MsgSetBasalProfile(byte index, Double[] values) {
|
|
||||||
this();
|
|
||||||
AddParamByte(index);
|
|
||||||
for (Integer i = 0; i < 24; i++) {
|
|
||||||
AddParamInt((int) (values[i] * 100));
|
|
||||||
}
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("Set basal profile: " + index);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleMessage(byte[] bytes) {
|
|
||||||
int result = intFromBuff(bytes, 0, 1);
|
|
||||||
if (result != 1) {
|
|
||||||
failed = true;
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("Set basal profile result: " + result + " FAILED!!!");
|
|
||||||
Notification reportFail = new Notification(Notification.PROFILE_SET_FAILED, MainApp.gs(R.string.profile_set_failed), Notification.URGENT);
|
|
||||||
RxBus.Companion.getINSTANCE().send(new EventNewNotification(reportFail));
|
|
||||||
} else {
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("Set basal profile result: " + result);
|
|
||||||
Notification reportOK = new Notification(Notification.PROFILE_SET_OK, MainApp.gs(R.string.profile_set_ok), Notification.INFO, 60);
|
|
||||||
RxBus.Companion.getINSTANCE().send(new EventNewNotification(reportOK));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.R
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
|
||||||
|
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
|
||||||
|
class MsgSetBasalProfile(
|
||||||
|
private val aapsLogger: AAPSLogger,
|
||||||
|
private val rxBus: RxBusWrapper,
|
||||||
|
private val resourceHelper: ResourceHelper,
|
||||||
|
index: Byte,
|
||||||
|
values: Array<Double>
|
||||||
|
) : MessageBase() {
|
||||||
|
|
||||||
|
// index 0-3
|
||||||
|
init {
|
||||||
|
SetCommand(0x3306)
|
||||||
|
AddParamByte(index)
|
||||||
|
for (i in 0..23) {
|
||||||
|
AddParamInt((values[i] * 100).toInt())
|
||||||
|
}
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "Set basal profile: $index")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun handleMessage(bytes: ByteArray) {
|
||||||
|
val result = intFromBuff(bytes, 0, 1)
|
||||||
|
if (result != 1) {
|
||||||
|
failed = true
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "Set basal profile result: $result FAILED!!!")
|
||||||
|
val reportFail = Notification(Notification.PROFILE_SET_FAILED, resourceHelper.gs(R.string.profile_set_failed), Notification.URGENT)
|
||||||
|
rxBus.send(EventNewNotification(reportFail))
|
||||||
|
} else {
|
||||||
|
failed = false
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "Set basal profile result: $result")
|
||||||
|
val reportOK = Notification(Notification.PROFILE_SET_OK, resourceHelper.gs(R.string.profile_set_ok), Notification.INFO, 60)
|
||||||
|
rxBus.send(EventNewNotification(reportOK))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,49 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.util.Calendar;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
|
||||||
|
|
||||||
public class MsgSetCarbsEntry extends MessageBase {
|
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(L.PUMPCOMM);
|
|
||||||
|
|
||||||
public MsgSetCarbsEntry() {
|
|
||||||
SetCommand(0x0402);
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("New message");
|
|
||||||
}
|
|
||||||
|
|
||||||
public MsgSetCarbsEntry(long time, int amount) {
|
|
||||||
this();
|
|
||||||
Calendar calendar = Calendar.getInstance();
|
|
||||||
calendar.setTimeInMillis(time);
|
|
||||||
AddParamByte((byte) RecordTypes.RECORD_TYPE_CARBO);
|
|
||||||
AddParamByte((byte) (calendar.get(Calendar.YEAR) % 100));
|
|
||||||
AddParamByte((byte) (calendar.get(Calendar.MONTH) + 1));
|
|
||||||
AddParamByte((byte) (calendar.get(Calendar.DAY_OF_MONTH)));
|
|
||||||
AddParamByte((byte) (calendar.get(Calendar.HOUR_OF_DAY)));
|
|
||||||
AddParamByte((byte) (calendar.get(Calendar.MINUTE)));
|
|
||||||
AddParamByte((byte) (calendar.get(Calendar.SECOND)));
|
|
||||||
AddParamByte((byte) 0x43); //??
|
|
||||||
AddParamInt(amount);
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("Set carb entry: " + amount + " date " + calendar.getTime().toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleMessage(byte[] bytes) {
|
|
||||||
int result = intFromBuff(bytes, 0, 1);
|
|
||||||
if (result != 1) {
|
|
||||||
failed = true;
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("Set carb entry result: " + result + " FAILED!!!");
|
|
||||||
} else {
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("Set carb entry result: " + result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
class MsgSetCarbsEntry(
|
||||||
|
private val aapsLogger: AAPSLogger,
|
||||||
|
val time: Long,
|
||||||
|
val amount: Int
|
||||||
|
) : MessageBase() {
|
||||||
|
|
||||||
|
init {
|
||||||
|
SetCommand(0x0402)
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, "New message")
|
||||||
|
val calendar = Calendar.getInstance()
|
||||||
|
calendar.timeInMillis = time
|
||||||
|
AddParamByte(RecordTypes.RECORD_TYPE_CARBO)
|
||||||
|
AddParamByte((calendar[Calendar.YEAR] % 100).toByte())
|
||||||
|
AddParamByte((calendar[Calendar.MONTH] + 1).toByte())
|
||||||
|
AddParamByte(calendar[Calendar.DAY_OF_MONTH].toByte())
|
||||||
|
AddParamByte(calendar[Calendar.HOUR_OF_DAY].toByte())
|
||||||
|
AddParamByte(calendar[Calendar.MINUTE].toByte())
|
||||||
|
AddParamByte(calendar[Calendar.SECOND].toByte())
|
||||||
|
AddParamByte(0x43.toByte()) //??
|
||||||
|
AddParamInt(amount)
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, "Set carb entry: " + amount + " date " + calendar.time.toString())
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun handleMessage(bytes: ByteArray) {
|
||||||
|
val result = intFromBuff(bytes, 0, 1)
|
||||||
|
if (result != 1) {
|
||||||
|
failed = true
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, "Set carb entry result: $result FAILED!!!")
|
||||||
|
} else {
|
||||||
|
failed = false
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, "Set carb entry result: $result")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,32 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
|
||||||
|
|
||||||
public class MsgSetExtendedBolusStop extends MessageBase {
|
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(L.PUMPCOMM);
|
|
||||||
|
|
||||||
public MsgSetExtendedBolusStop() {
|
|
||||||
SetCommand(0x0406);
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("New message");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleMessage(byte[] bytes) {
|
|
||||||
int result = intFromBuff(bytes, 0, 1);
|
|
||||||
if (result != 1) {
|
|
||||||
failed = true;
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("Set extended bolus stop result: " + result + " FAILED!!!");
|
|
||||||
} else {
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("Set extended bolus stop result: " + result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
|
||||||
|
class MsgSetExtendedBolusStop(
|
||||||
|
private val aapsLogger: AAPSLogger
|
||||||
|
) : MessageBase() {
|
||||||
|
|
||||||
|
init {
|
||||||
|
SetCommand(0x0406)
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, "New message")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun handleMessage(bytes: ByteArray) {
|
||||||
|
val result = intFromBuff(bytes, 0, 1)
|
||||||
|
if (result != 1) {
|
||||||
|
failed = true
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, "Set extended bolus stop result: $result FAILED!!!")
|
||||||
|
} else {
|
||||||
|
failed = false
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, "Set extended bolus stop result: $result")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,49 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
import info.nightscout.androidaps.R;
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
|
||||||
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
|
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
|
|
||||||
|
|
||||||
public class MsgSetSingleBasalProfile extends MessageBase {
|
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(L.PUMPCOMM);
|
|
||||||
|
|
||||||
public MsgSetSingleBasalProfile() {
|
|
||||||
SetCommand(0x3302);
|
|
||||||
}
|
|
||||||
|
|
||||||
// index 0-3
|
|
||||||
public MsgSetSingleBasalProfile(Double[] values) {
|
|
||||||
this();
|
|
||||||
for (Integer i = 0; i < 24; i++) {
|
|
||||||
AddParamInt((int) (values[i] * 100));
|
|
||||||
}
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("New message");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleMessage(byte[] bytes) {
|
|
||||||
int result = intFromBuff(bytes, 0, 1);
|
|
||||||
if (result != 1) {
|
|
||||||
failed = true;
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("Set basal profile result: " + result + " FAILED!!!");
|
|
||||||
Notification reportFail = new Notification(Notification.PROFILE_SET_FAILED, MainApp.gs(R.string.profile_set_failed), Notification.URGENT);
|
|
||||||
RxBus.Companion.getINSTANCE().send(new EventNewNotification(reportFail));
|
|
||||||
} else {
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("Set basal profile result: " + result);
|
|
||||||
Notification reportOK = new Notification(Notification.PROFILE_SET_OK, MainApp.gs(R.string.profile_set_ok), Notification.INFO, 60);
|
|
||||||
RxBus.Companion.getINSTANCE().send(new EventNewNotification(reportOK));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.R
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
|
||||||
|
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
|
||||||
|
class MsgSetSingleBasalProfile(
|
||||||
|
private val aapsLogger: AAPSLogger,
|
||||||
|
private val rxBus: RxBusWrapper,
|
||||||
|
private val resourceHelper: ResourceHelper,
|
||||||
|
values: Array<Double>
|
||||||
|
) : MessageBase() {
|
||||||
|
|
||||||
|
// index 0-3
|
||||||
|
init {
|
||||||
|
SetCommand(0x3302)
|
||||||
|
for (i in 0..23) {
|
||||||
|
AddParamInt((values[i] * 100).toInt())
|
||||||
|
}
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun handleMessage(bytes: ByteArray) {
|
||||||
|
val result = intFromBuff(bytes, 0, 1)
|
||||||
|
if (result != 1) {
|
||||||
|
failed = true
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "Set basal profile result: $result FAILED!!!")
|
||||||
|
val reportFail = Notification(Notification.PROFILE_SET_FAILED, resourceHelper.gs(R.string.profile_set_failed), Notification.URGENT)
|
||||||
|
rxBus.send(EventNewNotification(reportFail))
|
||||||
|
} else {
|
||||||
|
failed = false
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "Set basal profile result: $result")
|
||||||
|
val reportOK = Notification(Notification.PROFILE_SET_OK, resourceHelper.gs(R.string.profile_set_ok), Notification.INFO, 60)
|
||||||
|
rxBus.send(EventNewNotification(reportOK))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,45 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
|
||||||
|
|
||||||
public class MsgSetTempBasalStart extends MessageBase {
|
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(L.PUMPCOMM);
|
|
||||||
|
|
||||||
public MsgSetTempBasalStart() {
|
|
||||||
SetCommand(0x0401);
|
|
||||||
}
|
|
||||||
|
|
||||||
public MsgSetTempBasalStart(int percent, int durationInHours) {
|
|
||||||
this();
|
|
||||||
|
|
||||||
//HARDCODED LIMITS
|
|
||||||
if (percent < 0) percent = 0;
|
|
||||||
if (percent > 200) percent = 200;
|
|
||||||
if (durationInHours < 1) durationInHours = 1;
|
|
||||||
if (durationInHours > 24) durationInHours = 24;
|
|
||||||
|
|
||||||
AddParamByte((byte) (percent & 255));
|
|
||||||
AddParamByte((byte) (durationInHours & 255));
|
|
||||||
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("Temp basal start percent: " + percent + " duration hours: " + durationInHours);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void handleMessage(byte[] bytes) {
|
|
||||||
int result = intFromBuff(bytes, 0, 1);
|
|
||||||
if (result != 1) {
|
|
||||||
failed = true;
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("Set temp basal start result: " + result + " FAILED!!!");
|
|
||||||
} else {
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("Set temp basal start result: " + result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
|
||||||
|
class MsgSetTempBasalStart(
|
||||||
|
private val aapsLogger: AAPSLogger,
|
||||||
|
private var percent: Int,
|
||||||
|
private var durationInHours: Int
|
||||||
|
) : MessageBase() {
|
||||||
|
|
||||||
|
init {
|
||||||
|
SetCommand(0x0401)
|
||||||
|
|
||||||
|
//HARDCODED LIMITS
|
||||||
|
if (percent < 0) percent = 0
|
||||||
|
if (percent > 200) percent = 200
|
||||||
|
if (durationInHours < 1) durationInHours = 1
|
||||||
|
if (durationInHours > 24) durationInHours = 24
|
||||||
|
AddParamByte((percent and 255).toByte())
|
||||||
|
AddParamByte((durationInHours and 255).toByte())
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "Temp basal start percent: $percent duration hours: $durationInHours")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun handleMessage(bytes: ByteArray) {
|
||||||
|
val result = intFromBuff(bytes, 0, 1)
|
||||||
|
if (result != 1) {
|
||||||
|
failed = true
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "Set temp basal start result: $result FAILED!!!")
|
||||||
|
} else {
|
||||||
|
failed = false
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "Set temp basal start result: $result")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,31 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
|
||||||
|
|
||||||
public class MsgSetTempBasalStop extends MessageBase {
|
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(L.PUMPCOMM);
|
|
||||||
|
|
||||||
public MsgSetTempBasalStop() {
|
|
||||||
SetCommand(0x0403);
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("Temp basal stop");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void handleMessage(byte[] bytes) {
|
|
||||||
int result = intFromBuff(bytes, 0, 1);
|
|
||||||
if (result != 1) {
|
|
||||||
failed = true;
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("Set temp basal stop result: " + result + " FAILED!!!");
|
|
||||||
} else {
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("Set temp basal stop result: " + result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
import info.nightscout.androidaps.logging.L
|
||||||
|
import info.nightscout.androidaps.logging.L.isEnabled
|
||||||
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper.Companion.getLogger
|
||||||
|
import org.slf4j.Logger
|
||||||
|
|
||||||
|
class MsgSetTempBasalStop(
|
||||||
|
private val aapsLogger: AAPSLogger
|
||||||
|
) : MessageBase() {
|
||||||
|
|
||||||
|
init {
|
||||||
|
SetCommand(0x0403)
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, "Temp basal stop")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun handleMessage(bytes: ByteArray) {
|
||||||
|
val result = intFromBuff(bytes, 0, 1)
|
||||||
|
if (result != 1) {
|
||||||
|
failed = true
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, "Set temp basal stop result: $result FAILED!!!")
|
||||||
|
} else {
|
||||||
|
failed = false
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, "Set temp basal stop result: $result")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,37 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 09.12.2016.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class MsgSetTime extends MessageBase {
|
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(L.PUMPCOMM);
|
|
||||||
private static Date time;
|
|
||||||
|
|
||||||
public MsgSetTime(Date time) {
|
|
||||||
SetCommand(0x330a);
|
|
||||||
this.time = time;
|
|
||||||
AddParamDateTime(time);
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("New message: time:" + DateUtil.dateAndTimeString(time));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void handleMessage(byte[] bytes) {
|
|
||||||
int result = intFromBuff(bytes, 0, 1);
|
|
||||||
if (result != 1) {
|
|
||||||
failed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("Result of setting time: " + time + " is " + result);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
class MsgSetTime(
|
||||||
|
private val aapsLogger: AAPSLogger,
|
||||||
|
time: Date
|
||||||
|
) : MessageBase() {
|
||||||
|
|
||||||
|
init {
|
||||||
|
SetCommand(0x330a)
|
||||||
|
AddParamDateTime(time)
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "New message: time:" + DateUtil.dateAndTimeString(time))
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun handleMessage(bytes: ByteArray) {
|
||||||
|
val result = intFromBuff(bytes, 0, 1)
|
||||||
|
failed = result != 1
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "Result of setting time: $result")
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,19 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 28.05.2016.
|
|
||||||
*/
|
|
||||||
public class RecordTypes {
|
|
||||||
public static final byte RECORD_TYPE_BOLUS = (byte) 0x01;
|
|
||||||
public static final byte RECORD_TYPE_DAILY = (byte) 0x02;
|
|
||||||
public static final byte RECORD_TYPE_PRIME = (byte) 0x03;
|
|
||||||
public static final byte RECORD_TYPE_ERROR = (byte) 0x04;
|
|
||||||
public static final byte RECORD_TYPE_ALARM = (byte) 0x05;
|
|
||||||
public static final byte RECORD_TYPE_GLUCOSE = (byte) 0x06;
|
|
||||||
public static final byte RECORD_TYPE_CARBO = (byte) 0x08;
|
|
||||||
public static final byte RECORD_TYPE_REFILL = (byte) 0x09;
|
|
||||||
public static final byte RECORD_TYPE_SUSPEND = (byte) 0x0B;
|
|
||||||
public static final byte RECORD_TYPE_BASALHOUR = (byte) 0x0C;
|
|
||||||
public static final byte RECORD_TYPE_TB = (byte) 0x0D;
|
|
||||||
public static final byte RECORD_TYPE_TEMP_BASAL = (byte) 0x14;
|
|
||||||
}
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||||
|
|
||||||
|
object RecordTypes {
|
||||||
|
const val RECORD_TYPE_BOLUS = 0x01.toByte()
|
||||||
|
const val RECORD_TYPE_DAILY = 0x02.toByte()
|
||||||
|
const val RECORD_TYPE_PRIME = 0x03.toByte()
|
||||||
|
const val RECORD_TYPE_ERROR = 0x04.toByte()
|
||||||
|
const val RECORD_TYPE_ALARM = 0x05.toByte()
|
||||||
|
const val RECORD_TYPE_GLUCOSE = 0x06.toByte()
|
||||||
|
const val RECORD_TYPE_CARBO = 0x08.toByte()
|
||||||
|
const val RECORD_TYPE_REFILL = 0x09.toByte()
|
||||||
|
const val RECORD_TYPE_SUSPEND = 0x0B.toByte()
|
||||||
|
const val RECORD_TYPE_BASALHOUR = 0x0C.toByte()
|
||||||
|
const val RECORD_TYPE_TB = 0x0D.toByte()
|
||||||
|
const val RECORD_TYPE_TEMP_BASAL = 0x14.toByte()
|
||||||
|
}
|
|
@ -1,6 +1,5 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.services;
|
package info.nightscout.androidaps.plugins.pump.danaR.services;
|
||||||
|
|
||||||
import android.app.Service;
|
|
||||||
import android.bluetooth.BluetoothAdapter;
|
import android.bluetooth.BluetoothAdapter;
|
||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
import android.bluetooth.BluetoothSocket;
|
import android.bluetooth.BluetoothSocket;
|
||||||
|
@ -10,9 +9,6 @@ import android.content.Intent;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
@ -21,16 +17,14 @@ import javax.inject.Inject;
|
||||||
|
|
||||||
import dagger.android.DaggerService;
|
import dagger.android.DaggerService;
|
||||||
import dagger.android.HasAndroidInjector;
|
import dagger.android.HasAndroidInjector;
|
||||||
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.events.EventPumpStatusChanged;
|
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
import info.nightscout.androidaps.logging.L;
|
|
||||||
import info.nightscout.androidaps.logging.LTag;
|
import info.nightscout.androidaps.logging.LTag;
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.MessageBase;
|
import info.nightscout.androidaps.plugins.pump.danaR.comm.MessageBase;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgBolusStop;
|
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgBolusStop;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgHistoryAlarm;
|
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgHistoryAlarm;
|
||||||
|
@ -38,7 +32,6 @@ import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgHistoryBasalHour;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgHistoryBolus;
|
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgHistoryBolus;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgHistoryCarbo;
|
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgHistoryCarbo;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgHistoryDailyInsulin;
|
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgHistoryDailyInsulin;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgHistoryDone;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgHistoryError;
|
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgHistoryError;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgHistoryGlucose;
|
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgHistoryGlucose;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgHistoryRefill;
|
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgHistoryRefill;
|
||||||
|
@ -48,8 +41,9 @@ import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgPCCommStop;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.RecordTypes;
|
import info.nightscout.androidaps.plugins.pump.danaR.comm.RecordTypes;
|
||||||
import info.nightscout.androidaps.plugins.treatments.Treatment;
|
import info.nightscout.androidaps.plugins.treatments.Treatment;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
|
||||||
import info.nightscout.androidaps.utils.ToastUtils;
|
import info.nightscout.androidaps.utils.ToastUtils;
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 28.01.2018.
|
* Created by mike on 28.01.2018.
|
||||||
|
@ -58,6 +52,11 @@ import info.nightscout.androidaps.utils.ToastUtils;
|
||||||
public abstract class AbstractDanaRExecutionService extends DaggerService {
|
public abstract class AbstractDanaRExecutionService extends DaggerService {
|
||||||
@Inject HasAndroidInjector injector;
|
@Inject HasAndroidInjector injector;
|
||||||
@Inject AAPSLogger aapsLogger;
|
@Inject AAPSLogger aapsLogger;
|
||||||
|
@Inject RxBusWrapper rxBus;
|
||||||
|
@Inject SP sp;
|
||||||
|
@Inject Context context;
|
||||||
|
@Inject ResourceHelper resourceHelper;
|
||||||
|
@Inject DanaRPump danaRPump;
|
||||||
|
|
||||||
protected String mDevName;
|
protected String mDevName;
|
||||||
|
|
||||||
|
@ -88,7 +87,7 @@ public abstract class AbstractDanaRExecutionService extends DaggerService {
|
||||||
|
|
||||||
public abstract boolean bolus(double amount, int carbs, long carbtime, final Treatment t);
|
public abstract boolean bolus(double amount, int carbs, long carbtime, final Treatment t);
|
||||||
|
|
||||||
public abstract boolean highTempBasal(int percent); // Rv2 only
|
public abstract boolean highTempBasal(int percent, int durationInMinutes); // Rv2 only
|
||||||
|
|
||||||
public abstract boolean tempBasalShortDuration(int percent, int durationInMinutes); // Rv2 only
|
public abstract boolean tempBasalShortDuration(int percent, int durationInMinutes); // Rv2 only
|
||||||
|
|
||||||
|
@ -113,7 +112,7 @@ public abstract class AbstractDanaRExecutionService extends DaggerService {
|
||||||
if (mSerialIOThread != null) {
|
if (mSerialIOThread != null) {
|
||||||
mSerialIOThread.disconnect("BT disconnection broadcast");
|
mSerialIOThread.disconnect("BT disconnection broadcast");
|
||||||
}
|
}
|
||||||
RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED));
|
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -143,7 +142,7 @@ public abstract class AbstractDanaRExecutionService extends DaggerService {
|
||||||
|
|
||||||
public void finishHandshaking() {
|
public void finishHandshaking() {
|
||||||
mHandshakeInProgress = false;
|
mHandshakeInProgress = false;
|
||||||
RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.CONNECTED, 0));
|
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.CONNECTED, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disconnect(String from) {
|
public void disconnect(String from) {
|
||||||
|
@ -157,7 +156,7 @@ public abstract class AbstractDanaRExecutionService extends DaggerService {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void getBTSocketForSelectedPump() {
|
protected void getBTSocketForSelectedPump() {
|
||||||
mDevName = SP.getString(MainApp.gs(R.string.key_danar_bt_name), "");
|
mDevName = sp.getString(resourceHelper.gs(R.string.key_danar_bt_name), "");
|
||||||
BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||||
|
|
||||||
if (bluetoothAdapter != null) {
|
if (bluetoothAdapter != null) {
|
||||||
|
@ -175,25 +174,25 @@ public abstract class AbstractDanaRExecutionService extends DaggerService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.nobtadapter));
|
ToastUtils.showToastInUiThread(context.getApplicationContext(), resourceHelper.gs(R.string.nobtadapter));
|
||||||
}
|
}
|
||||||
if (mBTDevice == null) {
|
if (mBTDevice == null) {
|
||||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.devicenotfound));
|
ToastUtils.showToastInUiThread(context.getApplicationContext(), resourceHelper.gs(R.string.devicenotfound));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void bolusStop() {
|
public void bolusStop() {
|
||||||
aapsLogger.debug(LTag.PUMP, "bolusStop >>>>> @ " + (mBolusingTreatment == null ? "" : mBolusingTreatment.insulin));
|
aapsLogger.debug(LTag.PUMP, "bolusStop >>>>> @ " + (mBolusingTreatment == null ? "" : mBolusingTreatment.insulin));
|
||||||
MsgBolusStop stop = new MsgBolusStop();
|
MsgBolusStop stop = new MsgBolusStop(aapsLogger, rxBus, resourceHelper, danaRPump);
|
||||||
stop.forced = true;
|
danaRPump.setBolusStopForced(true);
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
mSerialIOThread.sendMessage(stop);
|
mSerialIOThread.sendMessage(stop);
|
||||||
while (!stop.stopped) {
|
while (!danaRPump.getBolusStopped()) {
|
||||||
mSerialIOThread.sendMessage(stop);
|
mSerialIOThread.sendMessage(stop);
|
||||||
SystemClock.sleep(200);
|
SystemClock.sleep(200);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
stop.stopped = true;
|
danaRPump.setBolusStopped(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,42 +202,42 @@ public abstract class AbstractDanaRExecutionService extends DaggerService {
|
||||||
MessageBase msg = null;
|
MessageBase msg = null;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case RecordTypes.RECORD_TYPE_ALARM:
|
case RecordTypes.RECORD_TYPE_ALARM:
|
||||||
msg = new MsgHistoryAlarm();
|
msg = new MsgHistoryAlarm(aapsLogger, rxBus);
|
||||||
break;
|
break;
|
||||||
case RecordTypes.RECORD_TYPE_BASALHOUR:
|
case RecordTypes.RECORD_TYPE_BASALHOUR:
|
||||||
msg = new MsgHistoryBasalHour();
|
msg = new MsgHistoryBasalHour(aapsLogger, rxBus);
|
||||||
break;
|
break;
|
||||||
case RecordTypes.RECORD_TYPE_BOLUS:
|
case RecordTypes.RECORD_TYPE_BOLUS:
|
||||||
msg = new MsgHistoryBolus();
|
msg = new MsgHistoryBolus(aapsLogger, rxBus);
|
||||||
break;
|
break;
|
||||||
case RecordTypes.RECORD_TYPE_CARBO:
|
case RecordTypes.RECORD_TYPE_CARBO:
|
||||||
msg = new MsgHistoryCarbo();
|
msg = new MsgHistoryCarbo(aapsLogger, rxBus);
|
||||||
break;
|
break;
|
||||||
case RecordTypes.RECORD_TYPE_DAILY:
|
case RecordTypes.RECORD_TYPE_DAILY:
|
||||||
msg = new MsgHistoryDailyInsulin();
|
msg = new MsgHistoryDailyInsulin(aapsLogger, rxBus);
|
||||||
break;
|
break;
|
||||||
case RecordTypes.RECORD_TYPE_ERROR:
|
case RecordTypes.RECORD_TYPE_ERROR:
|
||||||
msg = new MsgHistoryError();
|
msg = new MsgHistoryError(aapsLogger, rxBus);
|
||||||
break;
|
break;
|
||||||
case RecordTypes.RECORD_TYPE_GLUCOSE:
|
case RecordTypes.RECORD_TYPE_GLUCOSE:
|
||||||
msg = new MsgHistoryGlucose();
|
msg = new MsgHistoryGlucose(aapsLogger, rxBus);
|
||||||
break;
|
break;
|
||||||
case RecordTypes.RECORD_TYPE_REFILL:
|
case RecordTypes.RECORD_TYPE_REFILL:
|
||||||
msg = new MsgHistoryRefill();
|
msg = new MsgHistoryRefill(aapsLogger, rxBus);
|
||||||
break;
|
break;
|
||||||
case RecordTypes.RECORD_TYPE_SUSPEND:
|
case RecordTypes.RECORD_TYPE_SUSPEND:
|
||||||
msg = new MsgHistorySuspend();
|
msg = new MsgHistorySuspend(aapsLogger, rxBus);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
MsgHistoryDone done = new MsgHistoryDone();
|
danaRPump.setHistoryDoneReceived(false);
|
||||||
mSerialIOThread.sendMessage(new MsgPCCommStart());
|
mSerialIOThread.sendMessage(new MsgPCCommStart(aapsLogger));
|
||||||
SystemClock.sleep(400);
|
SystemClock.sleep(400);
|
||||||
mSerialIOThread.sendMessage(msg);
|
mSerialIOThread.sendMessage(msg);
|
||||||
while (!done.received && mRfcommSocket.isConnected()) {
|
while (!danaRPump.getHistoryDoneReceived() && mRfcommSocket.isConnected()) {
|
||||||
SystemClock.sleep(100);
|
SystemClock.sleep(100);
|
||||||
}
|
}
|
||||||
SystemClock.sleep(200);
|
SystemClock.sleep(200);
|
||||||
mSerialIOThread.sendMessage(new MsgPCCommStop());
|
mSerialIOThread.sendMessage(new MsgPCCommStop(aapsLogger));
|
||||||
result.success = true;
|
result.success = true;
|
||||||
result.comment = "OK";
|
result.comment = "OK";
|
||||||
return result;
|
return result;
|
||||||
|
@ -250,7 +249,7 @@ public abstract class AbstractDanaRExecutionService extends DaggerService {
|
||||||
long timeToWholeMinute = (60000 - time % 60000);
|
long timeToWholeMinute = (60000 - time % 60000);
|
||||||
if (timeToWholeMinute > 59800 || timeToWholeMinute < 3000)
|
if (timeToWholeMinute > 59800 || timeToWholeMinute < 3000)
|
||||||
break;
|
break;
|
||||||
RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(MainApp.gs(R.string.waitingfortimesynchronization, (int) (timeToWholeMinute / 1000))));
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.waitingfortimesynchronization, (int) (timeToWholeMinute / 1000))));
|
||||||
SystemClock.sleep(Math.min(timeToWholeMinute, 100));
|
SystemClock.sleep(Math.min(timeToWholeMinute, 100));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,10 +38,8 @@ import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.SerialIOThread;
|
import info.nightscout.androidaps.plugins.pump.danaR.SerialIOThread;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.MessageBase;
|
import info.nightscout.androidaps.plugins.pump.danaR.comm.MessageBase;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.MessageHashTableR;
|
import info.nightscout.androidaps.plugins.pump.danaR.comm.MessageHashTableR;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgBolusProgress;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgBolusStart;
|
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgBolusStart;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgBolusStartWithSpeed;
|
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgBolusStartWithSpeed;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgBolusStop;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgCheckValue;
|
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgCheckValue;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgSetActivateBasalProfile;
|
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgSetActivateBasalProfile;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgSetBasalProfile;
|
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgSetBasalProfile;
|
||||||
|
@ -236,7 +234,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
||||||
long timeDiff = (danaRPump.getPumpTime() - System.currentTimeMillis()) / 1000L;
|
long timeDiff = (danaRPump.getPumpTime() - System.currentTimeMillis()) / 1000L;
|
||||||
aapsLogger.debug(LTag.PUMP, "Pump time difference: " + timeDiff + " seconds");
|
aapsLogger.debug(LTag.PUMP, "Pump time difference: " + timeDiff + " seconds");
|
||||||
if (Math.abs(timeDiff) > 10) {
|
if (Math.abs(timeDiff) > 10) {
|
||||||
mSerialIOThread.sendMessage(new MsgSetTime(new Date()));
|
mSerialIOThread.sendMessage(new MsgSetTime(aapsLogger, new Date()));
|
||||||
mSerialIOThread.sendMessage(new MsgSettingPumpTime(aapsLogger, danaRPump));
|
mSerialIOThread.sendMessage(new MsgSettingPumpTime(aapsLogger, danaRPump));
|
||||||
timeDiff = (danaRPump.getPumpTime() - System.currentTimeMillis()) / 1000L;
|
timeDiff = (danaRPump.getPumpTime() - System.currentTimeMillis()) / 1000L;
|
||||||
aapsLogger.debug(LTag.PUMP, "Pump time difference: " + timeDiff + " seconds");
|
aapsLogger.debug(LTag.PUMP, "Pump time difference: " + timeDiff + " seconds");
|
||||||
|
@ -265,11 +263,11 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
if (danaRPump.isTempBasalInProgress()) {
|
if (danaRPump.isTempBasalInProgress()) {
|
||||||
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal)));
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
|
mSerialIOThread.sendMessage(new MsgSetTempBasalStop(aapsLogger));
|
||||||
SystemClock.sleep(500);
|
SystemClock.sleep(500);
|
||||||
}
|
}
|
||||||
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal)));
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetTempBasalStart(percent, durationInHours));
|
mSerialIOThread.sendMessage(new MsgSetTempBasalStart(aapsLogger, percent, durationInHours));
|
||||||
mSerialIOThread.sendMessage(new MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin));
|
mSerialIOThread.sendMessage(new MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin));
|
||||||
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
|
@ -278,7 +276,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
||||||
public boolean tempBasalStop() {
|
public boolean tempBasalStop() {
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal)));
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
|
mSerialIOThread.sendMessage(new MsgSetTempBasalStop(aapsLogger));
|
||||||
mSerialIOThread.sendMessage(new MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin));
|
mSerialIOThread.sendMessage(new MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin));
|
||||||
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
|
@ -296,7 +294,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
||||||
public boolean extendedBolusStop() {
|
public boolean extendedBolusStop() {
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingextendedbolus)));
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingextendedbolus)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStop());
|
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStop(aapsLogger));
|
||||||
mSerialIOThread.sendMessage(new MsgStatusBolusExtended(aapsLogger, danaRPump, activePlugin));
|
mSerialIOThread.sendMessage(new MsgStatusBolusExtended(aapsLogger, danaRPump, activePlugin));
|
||||||
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
|
@ -318,27 +316,29 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
||||||
start = new MsgBolusStart(aapsLogger, constraintChecker, danaRPump, amount);
|
start = new MsgBolusStart(aapsLogger, constraintChecker, danaRPump, amount);
|
||||||
else
|
else
|
||||||
start = new MsgBolusStartWithSpeed(aapsLogger, constraintChecker, danaRPump, amount, preferencesSpeed);
|
start = new MsgBolusStartWithSpeed(aapsLogger, constraintChecker, danaRPump, amount, preferencesSpeed);
|
||||||
MsgBolusStop stop = new MsgBolusStop(amount, t);
|
danaRPump.setBolusStopped(false);
|
||||||
|
danaRPump.setBolusStopForced(false);
|
||||||
|
|
||||||
if (carbs > 0) {
|
if (carbs > 0) {
|
||||||
mSerialIOThread.sendMessage(new MsgSetCarbsEntry(carbtime, carbs));
|
mSerialIOThread.sendMessage(new MsgSetCarbsEntry(aapsLogger, carbtime, carbs));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (amount > 0) {
|
if (amount > 0) {
|
||||||
MsgBolusProgress progress = new MsgBolusProgress(amount, t); // initialize static variables
|
danaRPump.setBolusingTreatment(t);
|
||||||
|
danaRPump.setBolusAmountToBeDelivered(amount);
|
||||||
long bolusStart = System.currentTimeMillis();
|
long bolusStart = System.currentTimeMillis();
|
||||||
|
|
||||||
if (!stop.stopped) {
|
if (!danaRPump.getBolusStopped()) {
|
||||||
mSerialIOThread.sendMessage(start);
|
mSerialIOThread.sendMessage(start);
|
||||||
} else {
|
} else {
|
||||||
t.insulin = 0d;
|
t.insulin = 0d;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
while (!stop.stopped && !start.failed) {
|
while (!danaRPump.getBolusStopped() && !start.failed) {
|
||||||
SystemClock.sleep(100);
|
SystemClock.sleep(100);
|
||||||
if ((System.currentTimeMillis() - progress.lastReceive) > 15 * 1000L) { // if i didn't receive status for more than 15 sec expecting broken comm
|
if ((System.currentTimeMillis() - danaRPump.getBolusProgressLastTimeStamp()) > 15 * 1000L) { // if i didn't receive status for more than 15 sec expecting broken comm
|
||||||
stop.stopped = true;
|
danaRPump.setBolusStopped(true);
|
||||||
stop.forced = true;
|
danaRPump.setBolusStopForced(true);
|
||||||
aapsLogger.debug(LTag.PUMP, "Communication stopped");
|
aapsLogger.debug(LTag.PUMP, "Communication stopped");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -406,13 +406,13 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
||||||
|
|
||||||
public boolean carbsEntry(int amount) {
|
public boolean carbsEntry(int amount) {
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
MsgSetCarbsEntry msg = new MsgSetCarbsEntry(System.currentTimeMillis(), amount);
|
MsgSetCarbsEntry msg = new MsgSetCarbsEntry(aapsLogger, System.currentTimeMillis(), amount);
|
||||||
mSerialIOThread.sendMessage(msg);
|
mSerialIOThread.sendMessage(msg);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean highTempBasal(int percent) {
|
public boolean highTempBasal(int percent, int durationInMinutes) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -425,9 +425,9 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.updatingbasalrates)));
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.updatingbasalrates)));
|
||||||
Double[] basal = danaRPump.buildDanaRProfileRecord(profile);
|
Double[] basal = danaRPump.buildDanaRProfileRecord(profile);
|
||||||
MsgSetBasalProfile msgSet = new MsgSetBasalProfile((byte) 0, basal);
|
MsgSetBasalProfile msgSet = new MsgSetBasalProfile(aapsLogger, rxBus, resourceHelper, (byte) 0, basal);
|
||||||
mSerialIOThread.sendMessage(msgSet);
|
mSerialIOThread.sendMessage(msgSet);
|
||||||
MsgSetActivateBasalProfile msgActivate = new MsgSetActivateBasalProfile((byte) 0);
|
MsgSetActivateBasalProfile msgActivate = new MsgSetActivateBasalProfile(aapsLogger, (byte) 0);
|
||||||
mSerialIOThread.sendMessage(msgActivate);
|
mSerialIOThread.sendMessage(msgActivate);
|
||||||
danaRPump.setLastSettingsRead(0); // force read full settings
|
danaRPump.setLastSettingsRead(0); // force read full settings
|
||||||
getPumpStatus();
|
getPumpStatus();
|
||||||
|
|
|
@ -32,9 +32,9 @@ class MessageHashTableRKorean @Inject constructor(
|
||||||
var messages: HashMap<Int, MessageBase> = HashMap()
|
var messages: HashMap<Int, MessageBase> = HashMap()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
put(MsgBolusStop()) // 0x0101 CMD_MEALINS_STOP
|
put(MsgBolusStop(aapsLogger, rxBus, resourceHelper, danaRPump)) // 0x0101 CMD_MEALINS_STOP
|
||||||
put(MsgBolusStart(aapsLogger, constraintChecker, danaRPump, 0.0)) // 0x0102 CMD_MEALINS_START_DATA
|
put(MsgBolusStart(aapsLogger, constraintChecker, danaRPump, 0.0)) // 0x0102 CMD_MEALINS_START_DATA
|
||||||
put(MsgBolusProgress()) // 0x0202 CMD_PUMP_THIS_REMAINDER_MEAL_INS
|
put(MsgBolusProgress(aapsLogger, resourceHelper, rxBus, danaRPump)) // 0x0202 CMD_PUMP_THIS_REMAINDER_MEAL_INS
|
||||||
put(MsgStatusProfile(aapsLogger, danaRPump)) // 0x0204 CMD_PUMP_CALCULATION_SETTING
|
put(MsgStatusProfile(aapsLogger, danaRPump)) // 0x0204 CMD_PUMP_CALCULATION_SETTING
|
||||||
put(MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin)) // 0x0205 CMD_PUMP_EXERCISE_MODE
|
put(MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin)) // 0x0205 CMD_PUMP_EXERCISE_MODE
|
||||||
put(MsgStatusBolusExtended(aapsLogger, danaRPump, activePlugin)) // 0x0207 CMD_PUMP_EXPANS_INS_I
|
put(MsgStatusBolusExtended(aapsLogger, danaRPump, activePlugin)) // 0x0207 CMD_PUMP_EXPANS_INS_I
|
||||||
|
@ -43,19 +43,19 @@ class MessageHashTableRKorean @Inject constructor(
|
||||||
put(MsgInitConnStatusTime_k(aapsLogger, rxBus, resourceHelper, danaRPump, danaRPlugin, danaRKoreanPlugin, configBuilderPlugin, commandQueue)) // 0x0301 CMD_PUMPINIT_TIME_INFO
|
put(MsgInitConnStatusTime_k(aapsLogger, rxBus, resourceHelper, danaRPump, danaRPlugin, danaRKoreanPlugin, configBuilderPlugin, commandQueue)) // 0x0301 CMD_PUMPINIT_TIME_INFO
|
||||||
put(MsgInitConnStatusBolus_k(aapsLogger, rxBus, resourceHelper, danaRPump, activePlugin)) // 0x0302 CMD_PUMPINIT_BOLUS_INFO
|
put(MsgInitConnStatusBolus_k(aapsLogger, rxBus, resourceHelper, danaRPump, activePlugin)) // 0x0302 CMD_PUMPINIT_BOLUS_INFO
|
||||||
put(MsgInitConnStatusBasic_k(aapsLogger, rxBus, resourceHelper, danaRPump)) // 0x0303 CMD_PUMPINIT_INIT_INFO
|
put(MsgInitConnStatusBasic_k(aapsLogger, rxBus, resourceHelper, danaRPump)) // 0x0303 CMD_PUMPINIT_INIT_INFO
|
||||||
put(MsgSetTempBasalStart()) // 0x0401 CMD_PUMPSET_EXERCISE_S
|
put(MsgSetTempBasalStart(aapsLogger, 0, 0)) // 0x0401 CMD_PUMPSET_EXERCISE_S
|
||||||
put(MsgSetCarbsEntry()) // 0x0402 CMD_PUMPSET_HIS_S
|
put(MsgSetCarbsEntry(aapsLogger, 0, 0)) // 0x0402 CMD_PUMPSET_HIS_S
|
||||||
put(MsgSetTempBasalStop()) // 0x0403 CMD_PUMPSET_EXERCISE_STOP
|
put(MsgSetTempBasalStop(aapsLogger)) // 0x0403 CMD_PUMPSET_EXERCISE_STOP
|
||||||
put(MsgSetExtendedBolusStop()) // 0x0406 CMD_PUMPSET_EXPANS_INS_STOP
|
put(MsgSetExtendedBolusStop(aapsLogger)) // 0x0406 CMD_PUMPSET_EXPANS_INS_STOP
|
||||||
put(MsgSetExtendedBolusStart(aapsLogger, constraintChecker, 0.0, 0)) // 0x0407 CMD_PUMPSET_EXPANS_INS_S
|
put(MsgSetExtendedBolusStart(aapsLogger, constraintChecker, 0.0, 0)) // 0x0407 CMD_PUMPSET_EXPANS_INS_S
|
||||||
put(MsgError()) // 0x0601 CMD_PUMPOWAY_SYSTEM_STATUS
|
put(MsgError(aapsLogger, rxBus, resourceHelper, danaRPump)) // 0x0601 CMD_PUMPOWAY_SYSTEM_STATUS
|
||||||
put(MsgPCCommStart()) // 0x3001 CMD_CONNECT
|
put(MsgPCCommStart(aapsLogger)) // 0x3001 CMD_CONNECT
|
||||||
put(MsgPCCommStop()) // 0x3002 CMD_DISCONNECT
|
put(MsgPCCommStop(aapsLogger)) // 0x3002 CMD_DISCONNECT
|
||||||
put(MsgHistoryBolus()) // 0x3101 CMD_HISTORY_MEAL_INS
|
put(MsgHistoryBolus(aapsLogger, rxBus)) // 0x3101 CMD_HISTORY_MEAL_INS
|
||||||
put(MsgHistoryDailyInsulin()) // 0x3102 CMD_HISTORY_DAY_INS
|
put(MsgHistoryDailyInsulin(aapsLogger, rxBus)) // 0x3102 CMD_HISTORY_DAY_INS
|
||||||
put(MsgHistoryGlucose()) // 0x3104 CMD_HISTORY_GLUCOSE
|
put(MsgHistoryGlucose(aapsLogger, rxBus)) // 0x3104 CMD_HISTORY_GLUCOSE
|
||||||
put(MsgHistoryAlarm()) // 0x3105 CMD_HISTORY_ALARM
|
put(MsgHistoryAlarm(aapsLogger, rxBus)) // 0x3105 CMD_HISTORY_ALARM
|
||||||
put(MsgHistoryCarbo()) // 0x3107 CMD_HISTORY_CARBOHY
|
put(MsgHistoryCarbo(aapsLogger, rxBus)) // 0x3107 CMD_HISTORY_CARBOHY
|
||||||
put(MsgSettingBasal_k(aapsLogger, danaRPump, danaRKoreanPlugin)) // 0x3202 CMD_SETTING_V_BASAL_INS_I
|
put(MsgSettingBasal_k(aapsLogger, danaRPump, danaRKoreanPlugin)) // 0x3202 CMD_SETTING_V_BASAL_INS_I
|
||||||
put(MsgSettingMeal(aapsLogger, rxBus, resourceHelper, danaRPump, danaRKoreanPlugin)) // 0x3203 CMD_SETTING_V_MEAL_SETTING_I
|
put(MsgSettingMeal(aapsLogger, rxBus, resourceHelper, danaRPump, danaRKoreanPlugin)) // 0x3203 CMD_SETTING_V_MEAL_SETTING_I
|
||||||
put(MsgSettingProfileRatios(aapsLogger, danaRPump)) // 0x3204 CMD_SETTING_V_CCC_I
|
put(MsgSettingProfileRatios(aapsLogger, danaRPump)) // 0x3204 CMD_SETTING_V_CCC_I
|
||||||
|
@ -64,10 +64,10 @@ class MessageHashTableRKorean @Inject constructor(
|
||||||
put(MsgSettingShippingInfo(aapsLogger, danaRPump)) // 0x3207 CMD_SETTING_V_SHIPPING_I
|
put(MsgSettingShippingInfo(aapsLogger, danaRPump)) // 0x3207 CMD_SETTING_V_SHIPPING_I
|
||||||
put(MsgSettingGlucose(aapsLogger, danaRPump)) // 0x3209 CMD_SETTING_V_GLUCOSEandEASY
|
put(MsgSettingGlucose(aapsLogger, danaRPump)) // 0x3209 CMD_SETTING_V_GLUCOSEandEASY
|
||||||
put(MsgSettingPumpTime(aapsLogger, danaRPump)) // 0x320A CMD_SETTING_V_TIME_I
|
put(MsgSettingPumpTime(aapsLogger, danaRPump)) // 0x320A CMD_SETTING_V_TIME_I
|
||||||
put(MsgSetSingleBasalProfile()) // 0x3302 CMD_SETTING_BASAL_INS_S
|
put(MsgSetSingleBasalProfile(aapsLogger, rxBus, resourceHelper, Array(24) { 0.0 })) // 0x3302 CMD_SETTING_BASAL_INS_S
|
||||||
put(MsgHistoryAll()) // 0x41F2 CMD_HISTORY_ALL
|
put(MsgHistoryAll(aapsLogger, rxBus)) // 0x41F2 CMD_HISTORY_ALL
|
||||||
put(MsgHistoryNewDone()) // 0x42F1 CMD_HISTORY_NEW_DONE
|
put(MsgHistoryNewDone(aapsLogger, danaRPump)) // 0x42F1 CMD_HISTORY_NEW_DONE
|
||||||
put(MsgHistoryNew()) // 0x42F2 CMD_HISTORY_NEW
|
put(MsgHistoryNew(aapsLogger, rxBus)) // 0x42F2 CMD_HISTORY_NEW
|
||||||
put(MsgCheckValue_k(aapsLogger, danaRPump, danaRKoreanPlugin)) // 0xF0F1 CMD_PUMP_CHECK_VALUE
|
put(MsgCheckValue_k(aapsLogger, danaRPump, danaRKoreanPlugin)) // 0xF0F1 CMD_PUMP_CHECK_VALUE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,9 +35,7 @@ import info.nightscout.androidaps.plugins.general.overview.notifications.Notific
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin;
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump;
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.SerialIOThread;
|
import info.nightscout.androidaps.plugins.pump.danaR.SerialIOThread;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgBolusProgress;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgBolusStart;
|
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgBolusStart;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgBolusStop;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgSetCarbsEntry;
|
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgSetCarbsEntry;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgSetExtendedBolusStart;
|
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgSetExtendedBolusStart;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgSetExtendedBolusStop;
|
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgSetExtendedBolusStop;
|
||||||
|
@ -225,7 +223,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
||||||
if (Math.abs(timeDiff) > 10) {
|
if (Math.abs(timeDiff) > 10) {
|
||||||
waitForWholeMinute(); // Dana can set only whole minute
|
waitForWholeMinute(); // Dana can set only whole minute
|
||||||
// add 10sec to be sure we are over minute (will be cutted off anyway)
|
// 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 MsgSetTime(aapsLogger, new Date(DateUtil.now() + T.secs(10).msecs())));
|
||||||
mSerialIOThread.sendMessage(new MsgSettingPumpTime(aapsLogger, danaRPump));
|
mSerialIOThread.sendMessage(new MsgSettingPumpTime(aapsLogger, danaRPump));
|
||||||
timeDiff = (danaRPump.getPumpTime() - System.currentTimeMillis()) / 1000L;
|
timeDiff = (danaRPump.getPumpTime() - System.currentTimeMillis()) / 1000L;
|
||||||
aapsLogger.debug(LTag.PUMP, "Pump time difference: " + timeDiff + " seconds");
|
aapsLogger.debug(LTag.PUMP, "Pump time difference: " + timeDiff + " seconds");
|
||||||
|
@ -254,11 +252,11 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
if (danaRPump.isTempBasalInProgress()) {
|
if (danaRPump.isTempBasalInProgress()) {
|
||||||
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal)));
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
|
mSerialIOThread.sendMessage(new MsgSetTempBasalStop(aapsLogger));
|
||||||
SystemClock.sleep(500);
|
SystemClock.sleep(500);
|
||||||
}
|
}
|
||||||
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal)));
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetTempBasalStart(percent, durationInHours));
|
mSerialIOThread.sendMessage(new MsgSetTempBasalStart(aapsLogger, percent, durationInHours));
|
||||||
mSerialIOThread.sendMessage(new MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin));
|
mSerialIOThread.sendMessage(new MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin));
|
||||||
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
|
@ -267,7 +265,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
||||||
public boolean tempBasalStop() {
|
public boolean tempBasalStop() {
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal)));
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
|
mSerialIOThread.sendMessage(new MsgSetTempBasalStop(aapsLogger));
|
||||||
mSerialIOThread.sendMessage(new MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin));
|
mSerialIOThread.sendMessage(new MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin));
|
||||||
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
|
@ -285,7 +283,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
||||||
public boolean extendedBolusStop() {
|
public boolean extendedBolusStop() {
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingextendedbolus)));
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingextendedbolus)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStop());
|
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStop(aapsLogger));
|
||||||
mSerialIOThread.sendMessage(new MsgStatusBolusExtended(aapsLogger, danaRPump, activePlugin));
|
mSerialIOThread.sendMessage(new MsgStatusBolusExtended(aapsLogger, danaRPump, activePlugin));
|
||||||
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
|
@ -302,26 +300,28 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
||||||
|
|
||||||
mBolusingTreatment = t;
|
mBolusingTreatment = t;
|
||||||
MsgBolusStart start = new MsgBolusStart(aapsLogger, constraintChecker, danaRPump, amount);
|
MsgBolusStart start = new MsgBolusStart(aapsLogger, constraintChecker, danaRPump, amount);
|
||||||
MsgBolusStop stop = new MsgBolusStop(amount, t);
|
danaRPump.setBolusStopped(false);
|
||||||
|
danaRPump.setBolusStopForced(false);
|
||||||
|
|
||||||
if (carbs > 0) {
|
if (carbs > 0) {
|
||||||
mSerialIOThread.sendMessage(new MsgSetCarbsEntry(carbtime, carbs));
|
mSerialIOThread.sendMessage(new MsgSetCarbsEntry(aapsLogger, carbtime, carbs));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (amount > 0) {
|
if (amount > 0) {
|
||||||
MsgBolusProgress progress = new MsgBolusProgress(amount, t); // initialize static variables
|
danaRPump.setBolusingTreatment(t);
|
||||||
|
danaRPump.setBolusAmountToBeDelivered(amount);
|
||||||
|
|
||||||
if (!stop.stopped) {
|
if (!danaRPump.getBolusStopped()) {
|
||||||
mSerialIOThread.sendMessage(start);
|
mSerialIOThread.sendMessage(start);
|
||||||
} else {
|
} else {
|
||||||
t.insulin = 0d;
|
t.insulin = 0d;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
while (!stop.stopped && !start.failed) {
|
while (!danaRPump.getBolusStopped() && !start.failed) {
|
||||||
SystemClock.sleep(100);
|
SystemClock.sleep(100);
|
||||||
if ((System.currentTimeMillis() - progress.lastReceive) > 15 * 1000L) { // if i didn't receive status for more than 15 sec expecting broken comm
|
if ((System.currentTimeMillis() - danaRPump.getBolusProgressLastTimeStamp()) > 15 * 1000L) { // if i didn't receive status for more than 15 sec expecting broken comm
|
||||||
stop.stopped = true;
|
danaRPump.setBolusStopped(true);
|
||||||
stop.forced = true;
|
danaRPump.setBolusStopForced(true);
|
||||||
aapsLogger.debug(LTag.PUMP, "Communication stopped");
|
aapsLogger.debug(LTag.PUMP, "Communication stopped");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -336,13 +336,13 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
||||||
|
|
||||||
public boolean carbsEntry(int amount) {
|
public boolean carbsEntry(int amount) {
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
MsgSetCarbsEntry msg = new MsgSetCarbsEntry(System.currentTimeMillis(), amount);
|
MsgSetCarbsEntry msg = new MsgSetCarbsEntry(aapsLogger, System.currentTimeMillis(), amount);
|
||||||
mSerialIOThread.sendMessage(msg);
|
mSerialIOThread.sendMessage(msg);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean highTempBasal(int percent) {
|
public boolean highTempBasal(int percent, int durationInMinutes) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -355,7 +355,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.updatingbasalrates)));
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.updatingbasalrates)));
|
||||||
Double[] basal = danaRPump.buildDanaRProfileRecord(profile);
|
Double[] basal = danaRPump.buildDanaRProfileRecord(profile);
|
||||||
MsgSetSingleBasalProfile msgSet = new MsgSetSingleBasalProfile(basal);
|
MsgSetSingleBasalProfile msgSet = new MsgSetSingleBasalProfile(aapsLogger, rxBus, resourceHelper, basal);
|
||||||
mSerialIOThread.sendMessage(msgSet);
|
mSerialIOThread.sendMessage(msgSet);
|
||||||
danaRPump.setLastSettingsRead(0); // force read full settings
|
danaRPump.setLastSettingsRead(0); // force read full settings
|
||||||
getPumpStatus();
|
getPumpStatus();
|
||||||
|
|
|
@ -275,7 +275,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
|
||||||
result = setTempBasalPercent(percentRate, durationInMinutes, profile, enforceNew);
|
result = setTempBasalPercent(percentRate, durationInMinutes, profile, enforceNew);
|
||||||
} else {
|
} else {
|
||||||
// use special APS temp basal call ... 100+/15min .... 100-/30min
|
// use special APS temp basal call ... 100+/15min .... 100-/30min
|
||||||
result = setHighTempBasalPercent(percentRate);
|
result = setHighTempBasalPercent(percentRate, durationInMinutes);
|
||||||
}
|
}
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
aapsLogger.error("setTempBasalAbsolute: Failed to set hightemp basal");
|
aapsLogger.error("setTempBasalAbsolute: Failed to set hightemp basal");
|
||||||
|
@ -344,10 +344,10 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PumpEnactResult setHighTempBasalPercent(Integer percent) {
|
private PumpEnactResult setHighTempBasalPercent(Integer percent, int durationInMinutes) {
|
||||||
DanaRPump pump = danaRPump;
|
DanaRPump pump = danaRPump;
|
||||||
PumpEnactResult result = new PumpEnactResult(getInjector());
|
PumpEnactResult result = new PumpEnactResult(getInjector());
|
||||||
boolean connectionOK = sExecutionService.highTempBasal(percent);
|
boolean connectionOK = sExecutionService.highTempBasal(percent, durationInMinutes);
|
||||||
if (connectionOK && pump.isTempBasalInProgress() && pump.getTempBasalPercent() == percent) {
|
if (connectionOK && pump.isTempBasalInProgress() && pump.getTempBasalPercent() == percent) {
|
||||||
result.enacted = true;
|
result.enacted = true;
|
||||||
result.success = true;
|
result.success = true;
|
||||||
|
|
|
@ -38,10 +38,10 @@ class MessageHashTableRv2 @Inject constructor(
|
||||||
var messages: HashMap<Int, MessageBase> = HashMap()
|
var messages: HashMap<Int, MessageBase> = HashMap()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
put(MsgBolusStop()) // 0x0101 CMD_MEALINS_STOP
|
put(MsgBolusStop(aapsLogger, rxBus, resourceHelper, danaRPump)) // 0x0101 CMD_MEALINS_STOP
|
||||||
put(MsgBolusStart(aapsLogger, constraintChecker, danaRPump, 0.0)) // 0x0102 CMD_MEALINS_START_DATA
|
put(MsgBolusStart(aapsLogger, constraintChecker, danaRPump, 0.0)) // 0x0102 CMD_MEALINS_START_DATA
|
||||||
put(MsgBolusStartWithSpeed(aapsLogger, constraintChecker, danaRPump, 0.0, 0)) // 0x0104 CMD_MEALINS_START_DATA_SPEED
|
put(MsgBolusStartWithSpeed(aapsLogger, constraintChecker, danaRPump, 0.0, 0)) // 0x0104 CMD_MEALINS_START_DATA_SPEED
|
||||||
put(MsgBolusProgress()) // 0x0202 CMD_PUMP_THIS_REMAINDER_MEAL_INS
|
put(MsgBolusProgress(aapsLogger, resourceHelper, rxBus, danaRPump)) // 0x0202 CMD_PUMP_THIS_REMAINDER_MEAL_INS
|
||||||
put(MsgStatusProfile(aapsLogger, danaRPump)) // 0x0204 CMD_PUMP_CALCULATION_SETTING
|
put(MsgStatusProfile(aapsLogger, danaRPump)) // 0x0204 CMD_PUMP_CALCULATION_SETTING
|
||||||
put(MsgStatusTempBasal_v2(aapsLogger, danaRPump)) // 0x0205 CMD_PUMP_EXERCISE_MODE
|
put(MsgStatusTempBasal_v2(aapsLogger, danaRPump)) // 0x0205 CMD_PUMP_EXERCISE_MODE
|
||||||
put(MsgStatusBolusExtended_v2(aapsLogger, danaRPump)) // 0x0207 CMD_PUMP_EXPANS_INS_I
|
put(MsgStatusBolusExtended_v2(aapsLogger, danaRPump)) // 0x0207 CMD_PUMP_EXPANS_INS_I
|
||||||
|
@ -51,24 +51,24 @@ class MessageHashTableRv2 @Inject constructor(
|
||||||
put(MsgInitConnStatusBolus(aapsLogger, rxBus, resourceHelper, danaRPump)) // 0x0302 CMD_PUMPINIT_BOLUS_INFO
|
put(MsgInitConnStatusBolus(aapsLogger, rxBus, resourceHelper, danaRPump)) // 0x0302 CMD_PUMPINIT_BOLUS_INFO
|
||||||
put(MsgInitConnStatusBasic(aapsLogger, danaRPump)) // 0x0303 CMD_PUMPINIT_INIT_INFO
|
put(MsgInitConnStatusBasic(aapsLogger, danaRPump)) // 0x0303 CMD_PUMPINIT_INIT_INFO
|
||||||
put(MsgInitConnStatusOption(aapsLogger, rxBus, resourceHelper, danaRPump, activePlugin)) // 0x0304 CMD_PUMPINIT_OPTION
|
put(MsgInitConnStatusOption(aapsLogger, rxBus, resourceHelper, danaRPump, activePlugin)) // 0x0304 CMD_PUMPINIT_OPTION
|
||||||
put(MsgSetTempBasalStart()) // 0x0401 CMD_PUMPSET_EXERCISE_S
|
put(MsgSetTempBasalStart(aapsLogger, 0, 0)) // 0x0401 CMD_PUMPSET_EXERCISE_S
|
||||||
put(MsgSetCarbsEntry()) // 0x0402 CMD_PUMPSET_HIS_S
|
put(MsgSetCarbsEntry(aapsLogger, 0, 0)) // 0x0402 CMD_PUMPSET_HIS_S
|
||||||
put(MsgSetTempBasalStop()) // 0x0403 CMD_PUMPSET_EXERCISE_STOP
|
put(MsgSetTempBasalStop(aapsLogger)) // 0x0403 CMD_PUMPSET_EXERCISE_STOP
|
||||||
put(MsgSetExtendedBolusStop()) // 0x0406 CMD_PUMPSET_EXPANS_INS_STOP
|
put(MsgSetExtendedBolusStop(aapsLogger)) // 0x0406 CMD_PUMPSET_EXPANS_INS_STOP
|
||||||
put(MsgSetExtendedBolusStart(aapsLogger, constraintChecker, 0.0, 0)) // 0x0407 CMD_PUMPSET_EXPANS_INS_S
|
put(MsgSetExtendedBolusStart(aapsLogger, constraintChecker, 0.0, 0)) // 0x0407 CMD_PUMPSET_EXPANS_INS_S
|
||||||
put(MsgError()) // 0x0601 CMD_PUMPOWAY_SYSTEM_STATUS
|
put(MsgError(aapsLogger, rxBus, resourceHelper, danaRPump)) // 0x0601 CMD_PUMPOWAY_SYSTEM_STATUS
|
||||||
put(MsgPCCommStart()) // 0x3001 CMD_CONNECT
|
put(MsgPCCommStart(aapsLogger)) // 0x3001 CMD_CONNECT
|
||||||
put(MsgPCCommStop()) // 0x3002 CMD_DISCONNECT
|
put(MsgPCCommStop(aapsLogger)) // 0x3002 CMD_DISCONNECT
|
||||||
put(MsgHistoryBolus()) // 0x3101 CMD_HISTORY_MEAL_INS
|
put(MsgHistoryBolus(aapsLogger, rxBus)) // 0x3101 CMD_HISTORY_MEAL_INS
|
||||||
put(MsgHistoryDailyInsulin()) // 0x3102 CMD_HISTORY_DAY_INS
|
put(MsgHistoryDailyInsulin(aapsLogger, rxBus)) // 0x3102 CMD_HISTORY_DAY_INS
|
||||||
put(MsgHistoryGlucose()) // 0x3104 CMD_HISTORY_GLUCOSE
|
put(MsgHistoryGlucose(aapsLogger, rxBus)) // 0x3104 CMD_HISTORY_GLUCOSE
|
||||||
put(MsgHistoryAlarm()) // 0x3105 CMD_HISTORY_ALARM
|
put(MsgHistoryAlarm(aapsLogger, rxBus)) // 0x3105 CMD_HISTORY_ALARM
|
||||||
put(MsgHistoryError()) // 0x3106 CMD_HISTORY_ERROR
|
put(MsgHistoryError(aapsLogger, rxBus)) // 0x3106 CMD_HISTORY_ERROR
|
||||||
put(MsgHistoryCarbo()) // 0x3107 CMD_HISTORY_CARBOHY
|
put(MsgHistoryCarbo(aapsLogger, rxBus)) // 0x3107 CMD_HISTORY_CARBOHY
|
||||||
put(MsgHistoryRefill()) // 0x3108 CMD_HISTORY_REFILL
|
put(MsgHistoryRefill(aapsLogger, rxBus)) // 0x3108 CMD_HISTORY_REFILL
|
||||||
put(MsgHistorySuspend()) // 0x3109 CMD_HISTORY_SUSPEND
|
put(MsgHistorySuspend(aapsLogger, rxBus)) // 0x3109 CMD_HISTORY_SUSPEND
|
||||||
put(MsgHistoryBasalHour()) // 0x310A CMD_HISTORY_BASAL_HOUR
|
put(MsgHistoryBasalHour(aapsLogger, rxBus)) // 0x310A CMD_HISTORY_BASAL_HOUR
|
||||||
put(MsgHistoryDone()) // 0x31F1 CMD_HISTORY_DONT_USED
|
put(MsgHistoryDone(aapsLogger, danaRPump)) // 0x31F1 CMD_HISTORY_DONT_USED
|
||||||
put(MsgSettingBasal(aapsLogger, danaRPump, danaRPlugin)) // 0x3202 CMD_SETTING_V_BASAL_INS_I
|
put(MsgSettingBasal(aapsLogger, danaRPump, danaRPlugin)) // 0x3202 CMD_SETTING_V_BASAL_INS_I
|
||||||
put(MsgSettingMeal(aapsLogger, rxBus, resourceHelper, danaRPump, danaRKoreanPlugin)) // 0x3203 CMD_SETTING_V_MEAL_SETTING_I
|
put(MsgSettingMeal(aapsLogger, rxBus, resourceHelper, danaRPump, danaRKoreanPlugin)) // 0x3203 CMD_SETTING_V_MEAL_SETTING_I
|
||||||
put(MsgSettingProfileRatios(aapsLogger, danaRPump)) // 0x3204 CMD_SETTING_V_CCC_I
|
put(MsgSettingProfileRatios(aapsLogger, danaRPump)) // 0x3204 CMD_SETTING_V_CCC_I
|
||||||
|
@ -80,19 +80,19 @@ class MessageHashTableRv2 @Inject constructor(
|
||||||
put(MsgSettingUserOptions(aapsLogger, danaRPump)) // 0x320B CMD_SETTING_V_USER_OPTIONS
|
put(MsgSettingUserOptions(aapsLogger, danaRPump)) // 0x320B CMD_SETTING_V_USER_OPTIONS
|
||||||
put(MsgSettingActiveProfile(aapsLogger, danaRPump)) // 0x320C CMD_SETTING_V_PROFILE_NUMBER
|
put(MsgSettingActiveProfile(aapsLogger, danaRPump)) // 0x320C CMD_SETTING_V_PROFILE_NUMBER
|
||||||
put(MsgSettingProfileRatiosAll(aapsLogger, danaRPump)) // 0x320D CMD_SETTING_V_CIR_CF_VALUE
|
put(MsgSettingProfileRatiosAll(aapsLogger, danaRPump)) // 0x320D CMD_SETTING_V_CIR_CF_VALUE
|
||||||
put(MsgSetSingleBasalProfile()) // 0x3302 CMD_SETTING_BASAL_INS_S
|
put(MsgSetSingleBasalProfile(aapsLogger, rxBus, resourceHelper, Array(24) { 0.0 })) // 0x3302 CMD_SETTING_BASAL_INS_S
|
||||||
put(MsgSetBasalProfile()) // 0x3306 CMD_SETTING_BASAL_PROFILE_S
|
put(MsgSetBasalProfile(aapsLogger, rxBus, resourceHelper, 0.toByte(), Array(24) { 0.0 })) // 0x3306 CMD_SETTING_BASAL_PROFILE_S
|
||||||
put(MsgSetUserOptions(aapsLogger, danaRPump)) // 0x330B CMD_SETTING_USER_OPTIONS_S
|
put(MsgSetUserOptions(aapsLogger, danaRPump)) // 0x330B CMD_SETTING_USER_OPTIONS_S
|
||||||
put(MsgSetActivateBasalProfile()) // 0x330C CMD_SETTING_PROFILE_NUMBER_S
|
put(MsgSetActivateBasalProfile(aapsLogger, 0.toByte())) // 0x330C CMD_SETTING_PROFILE_NUMBER_S
|
||||||
put(MsgHistoryAllDone()) // 0x41F1 CMD_HISTORY_ALL_DONE
|
put(MsgHistoryAllDone(aapsLogger, danaRPump)) // 0x41F1 CMD_HISTORY_ALL_DONE
|
||||||
put(MsgHistoryAll()) // 0x41F2 CMD_HISTORY_ALL
|
put(MsgHistoryAll(aapsLogger, rxBus)) // 0x41F2 CMD_HISTORY_ALL
|
||||||
put(MsgHistoryNewDone()) // 0x42F1 CMD_HISTORY_NEW_DONE
|
put(MsgHistoryNewDone(aapsLogger, danaRPump)) // 0x42F1 CMD_HISTORY_NEW_DONE
|
||||||
put(MsgHistoryNew()) // 0x42F2 CMD_HISTORY_NEW
|
put(MsgHistoryNew(aapsLogger, rxBus)) // 0x42F2 CMD_HISTORY_NEW
|
||||||
put(MsgCheckValue_v2(aapsLogger, rxBus, resourceHelper, danaRPump, danaRPlugin, danaRKoreanPlugin, danaRv2Plugin, configBuilderPlugin, commandQueue)) // 0xF0F1 CMD_PUMP_CHECK_VALUE
|
put(MsgCheckValue_v2(aapsLogger, rxBus, resourceHelper, danaRPump, danaRPlugin, danaRKoreanPlugin, danaRv2Plugin, configBuilderPlugin, commandQueue)) // 0xF0F1 CMD_PUMP_CHECK_VALUE
|
||||||
put(MsgStatusAPS_v2(aapsLogger, danaRPump)) // 0xE001 CMD_PUMPSTATUS_APS
|
put(MsgStatusAPS_v2(aapsLogger, danaRPump)) // 0xE001 CMD_PUMPSTATUS_APS
|
||||||
put(MsgSetAPSTempBasalStart_v2()) // 0xE002 CMD_PUMPSET_APSTEMP
|
put(MsgSetAPSTempBasalStart_v2(aapsLogger, 0, false, false)) // 0xE002 CMD_PUMPSET_APSTEMP
|
||||||
put(MsgHistoryEvents_v2(aapsLogger, resourceHelper, detailedBolusInfoStorage, danaRv2Plugin, rxBus, treatmentsPlugin)) // 0xE003 CMD_GET_HISTORY
|
put(MsgHistoryEvents_v2(aapsLogger, resourceHelper, detailedBolusInfoStorage, danaRv2Plugin, rxBus, treatmentsPlugin)) // 0xE003 CMD_GET_HISTORY
|
||||||
put(MsgSetHistoryEntry_v2()) // 0xE004 CMD_SET_HISTORY_ENTRY
|
put(MsgSetHistoryEntry_v2(aapsLogger, 0, 0, 0, 0)) // 0xE004 CMD_SET_HISTORY_ENTRY
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun put(message: MessageBase) {
|
override fun put(message: MessageBase) {
|
||||||
|
|
|
@ -1,80 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRv2.comm;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.MessageBase;
|
|
||||||
|
|
||||||
public class MsgSetAPSTempBasalStart_v2 extends MessageBase {
|
|
||||||
private Logger log = StacktraceLoggerWrapper.getLogger(L.PUMPCOMM);
|
|
||||||
|
|
||||||
protected final int PARAM30MIN = 160;
|
|
||||||
protected final int PARAM15MIN = 150;
|
|
||||||
|
|
||||||
public MsgSetAPSTempBasalStart_v2() {
|
|
||||||
SetCommand(0xE002);
|
|
||||||
}
|
|
||||||
|
|
||||||
public MsgSetAPSTempBasalStart_v2(int percent) {
|
|
||||||
this();
|
|
||||||
setParams(percent);
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("New message: percent: " + percent);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void setParams(int percent) {
|
|
||||||
//HARDCODED LIMITS
|
|
||||||
if (percent < 0) percent = 0;
|
|
||||||
if (percent > 500) percent = 500;
|
|
||||||
|
|
||||||
AddParamInt(percent);
|
|
||||||
if (percent < 100) {
|
|
||||||
AddParamByte((byte) PARAM30MIN);
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("APS Temp basal start percent: " + percent + " duration 30 min");
|
|
||||||
} else {
|
|
||||||
AddParamByte((byte) PARAM15MIN);
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("APS Temp basal start percent: " + percent + " duration 15 min");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public MsgSetAPSTempBasalStart_v2(int percent, boolean fifteenMinutes, boolean thirtyMinutes) {
|
|
||||||
this();
|
|
||||||
setParams(percent, fifteenMinutes, thirtyMinutes);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void setParams(int percent, boolean fifteenMinutes, boolean thirtyMinutes) {
|
|
||||||
//HARDCODED LIMITS
|
|
||||||
if (percent < 0) percent = 0;
|
|
||||||
if (percent > 500) percent = 500;
|
|
||||||
|
|
||||||
AddParamInt(percent);
|
|
||||||
if (thirtyMinutes && percent <= 200) { // 30 min is allowed up to 200%
|
|
||||||
AddParamByte((byte) PARAM30MIN);
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("APS Temp basal start percent: " + percent + " duration 30 min");
|
|
||||||
} else {
|
|
||||||
AddParamByte((byte) PARAM15MIN);
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("APS Temp basal start percent: " + percent + " duration 15 min");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void handleMessage(byte[] bytes) {
|
|
||||||
int result = intFromBuff(bytes, 0, 1);
|
|
||||||
if (result != 1) {
|
|
||||||
failed = true;
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("Set APS temp basal start result: " + result + " FAILED!!!");
|
|
||||||
} else {
|
|
||||||
failed = false;
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("Set APS temp basal start result: " + result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaRv2.comm
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
import info.nightscout.androidaps.plugins.pump.danaR.comm.MessageBase
|
||||||
|
|
||||||
|
class MsgSetAPSTempBasalStart_v2(
|
||||||
|
private val aapsLogger: AAPSLogger,
|
||||||
|
private var percent: Int,
|
||||||
|
fifteenMinutes: Boolean,
|
||||||
|
thirtyMinutes: Boolean
|
||||||
|
) : MessageBase() {
|
||||||
|
|
||||||
|
private val PARAM30MIN = 160
|
||||||
|
private val PARAM15MIN = 150
|
||||||
|
|
||||||
|
init {
|
||||||
|
SetCommand(0xE002)
|
||||||
|
//HARDCODED LIMITS
|
||||||
|
if (percent < 0) percent = 0
|
||||||
|
if (percent > 500) percent = 500
|
||||||
|
AddParamInt(percent)
|
||||||
|
if (thirtyMinutes && percent <= 200) { // 30 min is allowed up to 200%
|
||||||
|
AddParamByte(PARAM30MIN.toByte())
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "APS Temp basal start percent: $percent duration 30 min")
|
||||||
|
} else {
|
||||||
|
AddParamByte(PARAM15MIN.toByte())
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "APS Temp basal start percent: $percent duration 15 min")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun handleMessage(bytes: ByteArray) {
|
||||||
|
val result = intFromBuff(bytes, 0, 1)
|
||||||
|
if (result != 1) {
|
||||||
|
failed = true
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "Set APS temp basal start result: $result FAILED!!!")
|
||||||
|
} else {
|
||||||
|
failed = false
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "Set APS temp basal start result: $result")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,45 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRv2.comm;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.GregorianCalendar;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.MessageBase;
|
|
||||||
|
|
||||||
public class MsgSetHistoryEntry_v2 extends MessageBase {
|
|
||||||
private Logger log = StacktraceLoggerWrapper.getLogger(L.PUMPCOMM);
|
|
||||||
|
|
||||||
public MsgSetHistoryEntry_v2() {
|
|
||||||
SetCommand(0xE004);
|
|
||||||
}
|
|
||||||
|
|
||||||
public MsgSetHistoryEntry_v2(int type, long time, int param1, int param2) {
|
|
||||||
this();
|
|
||||||
|
|
||||||
AddParamByte((byte) type);
|
|
||||||
GregorianCalendar gtime = new GregorianCalendar();
|
|
||||||
gtime.setTimeInMillis(time);
|
|
||||||
AddParamDateTime(gtime);
|
|
||||||
AddParamInt(param1);
|
|
||||||
AddParamInt(param2);
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("Set history entry: type: " + type + " date: " + new Date(time).toString() + " param1: " + param1 + " param2: " + param2);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleMessage(byte[] bytes) {
|
|
||||||
int result = intFromBuff(bytes, 0, 1);
|
|
||||||
if (result != 1) {
|
|
||||||
failed = true;
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("Set history entry result: " + result + " FAILED!!!");
|
|
||||||
} else {
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("Set history entry result: " + result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaRv2.comm
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
import info.nightscout.androidaps.plugins.pump.danaR.comm.MessageBase
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
class MsgSetHistoryEntry_v2(
|
||||||
|
private val aapsLogger: AAPSLogger,
|
||||||
|
type: Int, time: Long, param1: Int, param2: Int
|
||||||
|
) : MessageBase() {
|
||||||
|
|
||||||
|
init {
|
||||||
|
SetCommand(0xE004)
|
||||||
|
AddParamByte(type.toByte())
|
||||||
|
val gtime = GregorianCalendar()
|
||||||
|
gtime.timeInMillis = time
|
||||||
|
AddParamDateTime(gtime)
|
||||||
|
AddParamInt(param1)
|
||||||
|
AddParamInt(param2)
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "Set history entry: type: " + type + " date: " + Date(time).toString() + " param1: " + param1 + " param2: " + param2)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun handleMessage(bytes: ByteArray) {
|
||||||
|
val result = intFromBuff(bytes, 0, 1)
|
||||||
|
if (result != 1) {
|
||||||
|
failed = true
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "Set history entry result: $result FAILED!!!")
|
||||||
|
} else {
|
||||||
|
failed = false
|
||||||
|
aapsLogger.debug(LTag.PUMPCOMM, "Set history entry result: $result")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -42,10 +42,8 @@ import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump;
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.SerialIOThread;
|
import info.nightscout.androidaps.plugins.pump.danaR.SerialIOThread;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.MessageBase;
|
import info.nightscout.androidaps.plugins.pump.danaR.comm.MessageBase;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgBolusProgress;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgBolusStart;
|
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgBolusStart;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgBolusStartWithSpeed;
|
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgBolusStartWithSpeed;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgBolusStop;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgSetActivateBasalProfile;
|
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgSetActivateBasalProfile;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgSetBasalProfile;
|
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgSetBasalProfile;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgSetCarbsEntry;
|
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgSetCarbsEntry;
|
||||||
|
@ -84,9 +82,9 @@ import info.nightscout.androidaps.queue.Callback;
|
||||||
import info.nightscout.androidaps.queue.commands.Command;
|
import info.nightscout.androidaps.queue.commands.Command;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
|
||||||
import info.nightscout.androidaps.utils.T;
|
import info.nightscout.androidaps.utils.T;
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
import io.reactivex.schedulers.Schedulers;
|
||||||
|
|
||||||
|
@ -259,7 +257,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
||||||
} else {
|
} else {
|
||||||
waitForWholeMinute(); // Dana can set only whole minute
|
waitForWholeMinute(); // Dana can set only whole minute
|
||||||
// add 10sec to be sure we are over minute (will be cutted off anyway)
|
// 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 MsgSetTime(aapsLogger, new Date(DateUtil.now() + T.secs(10).msecs())));
|
||||||
mSerialIOThread.sendMessage(new MsgSettingPumpTime(aapsLogger, danaRPump));
|
mSerialIOThread.sendMessage(new MsgSettingPumpTime(aapsLogger, danaRPump));
|
||||||
timeDiff = (danaRPump.getPumpTime() - System.currentTimeMillis()) / 1000L;
|
timeDiff = (danaRPump.getPumpTime() - System.currentTimeMillis()) / 1000L;
|
||||||
aapsLogger.debug(LTag.PUMP, "Pump time difference: " + timeDiff + " seconds");
|
aapsLogger.debug(LTag.PUMP, "Pump time difference: " + timeDiff + " seconds");
|
||||||
|
@ -306,26 +304,26 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
if (danaRPump.isTempBasalInProgress()) {
|
if (danaRPump.isTempBasalInProgress()) {
|
||||||
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal)));
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
|
mSerialIOThread.sendMessage(new MsgSetTempBasalStop(aapsLogger));
|
||||||
SystemClock.sleep(500);
|
SystemClock.sleep(500);
|
||||||
}
|
}
|
||||||
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal)));
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetTempBasalStart(percent, durationInHours));
|
mSerialIOThread.sendMessage(new MsgSetTempBasalStart(aapsLogger, percent, durationInHours));
|
||||||
mSerialIOThread.sendMessage(new MsgStatusTempBasal_v2(aapsLogger, danaRPump));
|
mSerialIOThread.sendMessage(new MsgStatusTempBasal_v2(aapsLogger, danaRPump));
|
||||||
loadEvents();
|
loadEvents();
|
||||||
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean highTempBasal(int percent) {
|
public boolean highTempBasal(int percent, int durationInMinutes) {
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
if (danaRPump.isTempBasalInProgress()) {
|
if (danaRPump.isTempBasalInProgress()) {
|
||||||
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal)));
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
|
mSerialIOThread.sendMessage(new MsgSetTempBasalStop(aapsLogger));
|
||||||
SystemClock.sleep(500);
|
SystemClock.sleep(500);
|
||||||
}
|
}
|
||||||
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal)));
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetAPSTempBasalStart_v2(percent));
|
mSerialIOThread.sendMessage(new MsgSetAPSTempBasalStart_v2(aapsLogger, percent, durationInMinutes == 15, durationInMinutes == 30));
|
||||||
mSerialIOThread.sendMessage(new MsgStatusTempBasal_v2(aapsLogger, danaRPump));
|
mSerialIOThread.sendMessage(new MsgStatusTempBasal_v2(aapsLogger, danaRPump));
|
||||||
loadEvents();
|
loadEvents();
|
||||||
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||||
|
@ -341,11 +339,11 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
if (danaRPump.isTempBasalInProgress()) {
|
if (danaRPump.isTempBasalInProgress()) {
|
||||||
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal)));
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
|
mSerialIOThread.sendMessage(new MsgSetTempBasalStop(aapsLogger));
|
||||||
SystemClock.sleep(500);
|
SystemClock.sleep(500);
|
||||||
}
|
}
|
||||||
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal)));
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetAPSTempBasalStart_v2(percent, durationInMinutes == 15, durationInMinutes == 30));
|
mSerialIOThread.sendMessage(new MsgSetAPSTempBasalStart_v2(aapsLogger, percent, durationInMinutes == 15, durationInMinutes == 30));
|
||||||
mSerialIOThread.sendMessage(new MsgStatusTempBasal_v2(aapsLogger, danaRPump));
|
mSerialIOThread.sendMessage(new MsgStatusTempBasal_v2(aapsLogger, danaRPump));
|
||||||
loadEvents();
|
loadEvents();
|
||||||
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||||
|
@ -355,7 +353,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
||||||
public boolean tempBasalStop() {
|
public boolean tempBasalStop() {
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal)));
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
|
mSerialIOThread.sendMessage(new MsgSetTempBasalStop(aapsLogger));
|
||||||
mSerialIOThread.sendMessage(new MsgStatusTempBasal_v2(aapsLogger, danaRPump));
|
mSerialIOThread.sendMessage(new MsgStatusTempBasal_v2(aapsLogger, danaRPump));
|
||||||
loadEvents();
|
loadEvents();
|
||||||
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||||
|
@ -375,7 +373,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
||||||
public boolean extendedBolusStop() {
|
public boolean extendedBolusStop() {
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingextendedbolus)));
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingextendedbolus)));
|
||||||
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStop());
|
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStop(aapsLogger));
|
||||||
mSerialIOThread.sendMessage(new MsgStatusBolusExtended_v2(aapsLogger, danaRPump));
|
mSerialIOThread.sendMessage(new MsgStatusBolusExtended_v2(aapsLogger, danaRPump));
|
||||||
loadEvents();
|
loadEvents();
|
||||||
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||||
|
@ -394,31 +392,33 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
||||||
start = new MsgBolusStart(aapsLogger, constraintChecker, danaRPump, amount);
|
start = new MsgBolusStart(aapsLogger, constraintChecker, danaRPump, amount);
|
||||||
else
|
else
|
||||||
start = new MsgBolusStartWithSpeed(aapsLogger, constraintChecker, danaRPump, amount, preferencesSpeed);
|
start = new MsgBolusStartWithSpeed(aapsLogger, constraintChecker, danaRPump, amount, preferencesSpeed);
|
||||||
MsgBolusStop stop = new MsgBolusStop(amount, t);
|
danaRPump.setBolusStopped(false);
|
||||||
|
danaRPump.setBolusStopForced(false);
|
||||||
|
|
||||||
if (carbs > 0) {
|
if (carbs > 0) {
|
||||||
MsgSetCarbsEntry msg = new MsgSetCarbsEntry(carbtime, carbs);
|
MsgSetCarbsEntry msg = new MsgSetCarbsEntry(aapsLogger, carbtime, carbs);
|
||||||
mSerialIOThread.sendMessage(msg);
|
mSerialIOThread.sendMessage(msg);
|
||||||
MsgSetHistoryEntry_v2 msgSetHistoryEntry_v2 = new MsgSetHistoryEntry_v2(DanaRPump.CARBS, carbtime, carbs, 0);
|
MsgSetHistoryEntry_v2 msgSetHistoryEntry_v2 = new MsgSetHistoryEntry_v2(aapsLogger, DanaRPump.CARBS, carbtime, carbs, 0);
|
||||||
mSerialIOThread.sendMessage(msgSetHistoryEntry_v2);
|
mSerialIOThread.sendMessage(msgSetHistoryEntry_v2);
|
||||||
lastHistoryFetched = Math.min(lastHistoryFetched, carbtime - T.mins(1).msecs());
|
lastHistoryFetched = Math.min(lastHistoryFetched, carbtime - T.mins(1).msecs());
|
||||||
}
|
}
|
||||||
|
|
||||||
final long bolusStart = System.currentTimeMillis();
|
final long bolusStart = System.currentTimeMillis();
|
||||||
if (amount > 0) {
|
if (amount > 0) {
|
||||||
MsgBolusProgress progress = new MsgBolusProgress(amount, t); // initialize static variables
|
danaRPump.setBolusingTreatment(t);
|
||||||
|
danaRPump.setBolusAmountToBeDelivered(amount);
|
||||||
|
|
||||||
if (!stop.stopped) {
|
if (!danaRPump.getBolusStopped()) {
|
||||||
mSerialIOThread.sendMessage(start);
|
mSerialIOThread.sendMessage(start);
|
||||||
} else {
|
} else {
|
||||||
t.insulin = 0d;
|
t.insulin = 0d;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
while (!stop.stopped && !start.failed) {
|
while (!danaRPump.getBolusStopped() && !start.failed) {
|
||||||
SystemClock.sleep(100);
|
SystemClock.sleep(100);
|
||||||
if ((System.currentTimeMillis() - progress.lastReceive) > 15 * 1000L) { // if i didn't receive status for more than 15 sec expecting broken comm
|
if ((System.currentTimeMillis() - danaRPump.getBolusProgressLastTimeStamp()) > 15 * 1000L) { // if i didn't receive status for more than 15 sec expecting broken comm
|
||||||
stop.stopped = true;
|
danaRPump.setBolusStopped(true);
|
||||||
stop.forced = true;
|
danaRPump.setBolusStopForced(true);
|
||||||
aapsLogger.error("Communication stopped");
|
aapsLogger.error("Communication stopped");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -463,26 +463,11 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
||||||
return !start.failed;
|
return !start.failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void bolusStop() {
|
|
||||||
aapsLogger.debug(LTag.PUMP, "bolusStop >>>>> @ " + (mBolusingTreatment == null ? "" : mBolusingTreatment.insulin));
|
|
||||||
MsgBolusStop stop = new MsgBolusStop();
|
|
||||||
stop.forced = true;
|
|
||||||
if (isConnected()) {
|
|
||||||
mSerialIOThread.sendMessage(stop);
|
|
||||||
while (!stop.stopped) {
|
|
||||||
mSerialIOThread.sendMessage(stop);
|
|
||||||
SystemClock.sleep(200);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
stop.stopped = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean carbsEntry(int amount, long time) {
|
public boolean carbsEntry(int amount, long time) {
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
MsgSetCarbsEntry msg = new MsgSetCarbsEntry(time, amount);
|
MsgSetCarbsEntry msg = new MsgSetCarbsEntry(aapsLogger, time, amount);
|
||||||
mSerialIOThread.sendMessage(msg);
|
mSerialIOThread.sendMessage(msg);
|
||||||
MsgSetHistoryEntry_v2 msgSetHistoryEntry_v2 = new MsgSetHistoryEntry_v2(DanaRPump.CARBS, time, amount, 0);
|
MsgSetHistoryEntry_v2 msgSetHistoryEntry_v2 = new MsgSetHistoryEntry_v2(aapsLogger, DanaRPump.CARBS, time, amount, 0);
|
||||||
mSerialIOThread.sendMessage(msgSetHistoryEntry_v2);
|
mSerialIOThread.sendMessage(msgSetHistoryEntry_v2);
|
||||||
lastHistoryFetched = Math.min(lastHistoryFetched, time - T.mins(1).msecs());
|
lastHistoryFetched = Math.min(lastHistoryFetched, time - T.mins(1).msecs());
|
||||||
return true;
|
return true;
|
||||||
|
@ -519,9 +504,9 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.updatingbasalrates)));
|
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.updatingbasalrates)));
|
||||||
Double[] basal = danaRPump.buildDanaRProfileRecord(profile);
|
Double[] basal = danaRPump.buildDanaRProfileRecord(profile);
|
||||||
MsgSetBasalProfile msgSet = new MsgSetBasalProfile((byte) 0, basal);
|
MsgSetBasalProfile msgSet = new MsgSetBasalProfile(aapsLogger, rxBus, resourceHelper, (byte) 0, basal);
|
||||||
mSerialIOThread.sendMessage(msgSet);
|
mSerialIOThread.sendMessage(msgSet);
|
||||||
MsgSetActivateBasalProfile msgActivate = new MsgSetActivateBasalProfile((byte) 0);
|
MsgSetActivateBasalProfile msgActivate = new MsgSetActivateBasalProfile(aapsLogger, (byte) 0);
|
||||||
mSerialIOThread.sendMessage(msgActivate);
|
mSerialIOThread.sendMessage(msgActivate);
|
||||||
danaRPump.setLastSettingsRead(0); // force read full settings
|
danaRPump.setLastSettingsRead(0); // force read full settings
|
||||||
getPumpStatus();
|
getPumpStatus();
|
||||||
|
|
|
@ -1,35 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
|
||||||
import org.powermock.modules.junit4.PowerMockRunner;
|
|
||||||
|
|
||||||
import info.AAPSMocker;
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
|
||||||
import info.nightscout.androidaps.utils.SP;
|
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Rumen Georgiev on 8/31/2018.
|
|
||||||
*/
|
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
|
||||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
|
||||||
public class MessageHashTableRTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void runTest() {
|
|
||||||
AAPSMocker.mockMainApp();
|
|
||||||
AAPSMocker.mockSP();
|
|
||||||
AAPSMocker.mockL();
|
|
||||||
MessageHashTableR messageHashTable = MessageHashTableR.INSTANCE;
|
|
||||||
MessageBase testMessage = messageHashTable.findMessage(0x41f2);
|
|
||||||
assertEquals("CMD_HISTORY_ALL", testMessage.getMessageName());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
|
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||||
|
import info.nightscout.androidaps.interfaces.Constraint
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||||
|
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
||||||
|
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage
|
||||||
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin
|
||||||
|
import info.nightscout.androidaps.plugins.pump.danaRKorean.DanaRKoreanPlugin
|
||||||
|
import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRSTestBase
|
||||||
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import org.junit.Assert
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
import org.mockito.Mock
|
||||||
|
import org.mockito.Mockito
|
||||||
|
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||||
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
|
@RunWith(PowerMockRunner::class)
|
||||||
|
@PrepareForTest(ConstraintChecker::class, DetailedBolusInfoStorage::class)
|
||||||
|
class MessageHashTableRTest : DanaRSTestBase() {
|
||||||
|
|
||||||
|
@Mock lateinit var rxBus: RxBusWrapper
|
||||||
|
@Mock lateinit var resourceHelper: ResourceHelper
|
||||||
|
@Mock lateinit var constraintChecker: ConstraintChecker
|
||||||
|
@Mock lateinit var danaRPlugin: DanaRPlugin
|
||||||
|
@Mock lateinit var danaRKoreanPlugin: DanaRKoreanPlugin
|
||||||
|
@Mock lateinit var configBuilderPlugin: ConfigBuilderPlugin
|
||||||
|
@Mock lateinit var commandQueue: CommandQueueProvider
|
||||||
|
@Mock lateinit var activePlugin: ActivePluginProvider
|
||||||
|
@Mock lateinit var detailedBolusInfoStorage: DetailedBolusInfoStorage
|
||||||
|
@Mock lateinit var treatmentsPlugin: TreatmentsPlugin
|
||||||
|
|
||||||
|
@Test fun runTest() {
|
||||||
|
Mockito.`when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(0.0))
|
||||||
|
val messageHashTable = MessageHashTableR(aapsLogger, rxBus, resourceHelper, constraintChecker, danaRPump, danaRPlugin, danaRKoreanPlugin, configBuilderPlugin, commandQueue, activePlugin)
|
||||||
|
val testMessage = messageHashTable.findMessage(0x41f2)
|
||||||
|
Assert.assertEquals("CMD_HISTORY_ALL", testMessage.messageName)
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,30 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
|
||||||
import org.powermock.modules.junit4.PowerMockRunner;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
|
||||||
import info.nightscout.androidaps.utils.SP;
|
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Rumen Georgiev on 8/28/2018.
|
|
||||||
*/
|
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
|
||||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
|
||||||
public class MessageOriginalNamesTest {
|
|
||||||
@Test
|
|
||||||
public void runTest() {
|
|
||||||
MessageOriginalNames packet = new MessageOriginalNames();
|
|
||||||
String testName = packet.getName(0x41f2);
|
|
||||||
assertEquals("CMD_HISTORY_ALL", testName);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.TestBase
|
||||||
|
import org.junit.Assert
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class MessageOriginalNamesTest : TestBase() {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun getNameTest() {
|
||||||
|
Assert.assertEquals("CMD_CONNECT", MessageOriginalNames.getName(0x3001))
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,16 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaR.comm;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Rumen Georgiev on 8/31/2018.
|
|
||||||
*/
|
|
||||||
public class RecordTypesTest {
|
|
||||||
@Test
|
|
||||||
public void runTest() {
|
|
||||||
RecordTypes packet = new RecordTypes();
|
|
||||||
assertEquals((byte) 0x01, packet.RECORD_TYPE_BOLUS);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||||
|
|
||||||
|
import org.junit.Assert
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class RecordTypesTest {
|
||||||
|
|
||||||
|
@Test fun runTest() {
|
||||||
|
Assert.assertEquals(1.toByte(), RecordTypes.RECORD_TYPE_BOLUS)
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaRKorean.comm
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
|
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||||
|
import info.nightscout.androidaps.interfaces.Constraint
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||||
|
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
||||||
|
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage
|
||||||
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin
|
||||||
|
import info.nightscout.androidaps.plugins.pump.danaRKorean.DanaRKoreanPlugin
|
||||||
|
import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRSTestBase
|
||||||
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import org.junit.Assert
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
import org.mockito.Mock
|
||||||
|
import org.mockito.Mockito
|
||||||
|
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||||
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
|
@RunWith(PowerMockRunner::class)
|
||||||
|
@PrepareForTest(ConstraintChecker::class, DetailedBolusInfoStorage::class)
|
||||||
|
class MessageHashTableRKoreanTest : DanaRSTestBase() {
|
||||||
|
|
||||||
|
@Mock lateinit var rxBus: RxBusWrapper
|
||||||
|
@Mock lateinit var resourceHelper: ResourceHelper
|
||||||
|
@Mock lateinit var constraintChecker: ConstraintChecker
|
||||||
|
@Mock lateinit var danaRPlugin: DanaRPlugin
|
||||||
|
@Mock lateinit var danaRKoreanPlugin: DanaRKoreanPlugin
|
||||||
|
@Mock lateinit var configBuilderPlugin: ConfigBuilderPlugin
|
||||||
|
@Mock lateinit var commandQueue: CommandQueueProvider
|
||||||
|
@Mock lateinit var activePlugin: ActivePluginProvider
|
||||||
|
@Mock lateinit var detailedBolusInfoStorage: DetailedBolusInfoStorage
|
||||||
|
@Mock lateinit var treatmentsPlugin: TreatmentsPlugin
|
||||||
|
|
||||||
|
@Test fun runTest() {
|
||||||
|
Mockito.`when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(0.0))
|
||||||
|
val messageHashTable = MessageHashTableRKorean(aapsLogger, rxBus, resourceHelper, constraintChecker, danaRPump, danaRPlugin, danaRKoreanPlugin, configBuilderPlugin, commandQueue, activePlugin)
|
||||||
|
val testMessage = messageHashTable.findMessage(0x41f2)
|
||||||
|
Assert.assertEquals("CMD_HISTORY_ALL", testMessage.messageName)
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,57 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRv2.comm;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
|
||||||
import org.powermock.modules.junit4.PowerMockRunner;
|
|
||||||
|
|
||||||
import info.AAPSMocker;
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.comm.MessageBase;
|
|
||||||
import info.nightscout.androidaps.utils.SP;
|
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
/**
|
|
||||||
* Created by Rumen Georgiev on 30.10.2018.
|
|
||||||
*/
|
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
|
||||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
|
||||||
public class MessageHashTable_rv2Test {
|
|
||||||
@Test
|
|
||||||
public void runTest() {
|
|
||||||
AAPSMocker.mockMainApp();
|
|
||||||
AAPSMocker.mockApplicationContext();
|
|
||||||
AAPSMocker.mockSP();
|
|
||||||
AAPSMocker.mockL();
|
|
||||||
|
|
||||||
MessageHashTableRv2 hashTableRv2 = MessageHashTableRv2.INSTANCE;
|
|
||||||
|
|
||||||
MessageBase forTesting = new MsgStatusAPS_v2();
|
|
||||||
MessageBase testPacket = MessageHashTableRv2.INSTANCE.findMessage(forTesting.getCommand());
|
|
||||||
assertEquals(0xE001, testPacket.getCommand());
|
|
||||||
// try putting another command
|
|
||||||
MessageBase testMessage = new MessageBase();
|
|
||||||
testMessage.SetCommand(0xE005);
|
|
||||||
hashTableRv2.put(testMessage);
|
|
||||||
assertEquals(0xE005, hashTableRv2.findMessage(0xE005).getCommand());
|
|
||||||
}
|
|
||||||
|
|
||||||
byte[] createArray(int length, byte fillWith){
|
|
||||||
byte[] ret = new byte[length];
|
|
||||||
for(int i = 0; i<length; i++){
|
|
||||||
ret[i] = fillWith;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
double[] createArray(int length, double fillWith){
|
|
||||||
double[] ret = new double[length];
|
|
||||||
for(int i = 0; i<length; i++){
|
|
||||||
ret[i] = fillWith;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaRv2.comm
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
|
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||||
|
import info.nightscout.androidaps.interfaces.Constraint
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||||
|
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
||||||
|
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage
|
||||||
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin
|
||||||
|
import info.nightscout.androidaps.plugins.pump.danaR.comm.MessageBase
|
||||||
|
import info.nightscout.androidaps.plugins.pump.danaRKorean.DanaRKoreanPlugin
|
||||||
|
import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRSTestBase
|
||||||
|
import info.nightscout.androidaps.plugins.pump.danaRv2.DanaRv2Plugin
|
||||||
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import org.junit.Assert
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
import org.mockito.Mock
|
||||||
|
import org.mockito.Mockito.`when`
|
||||||
|
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||||
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
|
@RunWith(PowerMockRunner::class)
|
||||||
|
@PrepareForTest(ConstraintChecker::class, DetailedBolusInfoStorage::class)
|
||||||
|
class MessageHashTable_rv2Test : DanaRSTestBase() {
|
||||||
|
|
||||||
|
@Mock lateinit var rxBus: RxBusWrapper
|
||||||
|
@Mock lateinit var resourceHelper: ResourceHelper
|
||||||
|
@Mock lateinit var constraintChecker: ConstraintChecker
|
||||||
|
@Mock lateinit var danaRPlugin: DanaRPlugin
|
||||||
|
@Mock lateinit var danaRKoreanPlugin: DanaRKoreanPlugin
|
||||||
|
@Mock lateinit var danaRv2Plugin: DanaRv2Plugin
|
||||||
|
@Mock lateinit var configBuilderPlugin: ConfigBuilderPlugin
|
||||||
|
@Mock lateinit var commandQueue: CommandQueueProvider
|
||||||
|
@Mock lateinit var activePlugin: ActivePluginProvider
|
||||||
|
@Mock lateinit var detailedBolusInfoStorage: DetailedBolusInfoStorage
|
||||||
|
@Mock lateinit var treatmentsPlugin: TreatmentsPlugin
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun runTest() {
|
||||||
|
`when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(0.0))
|
||||||
|
val messageHashTableRv2 = MessageHashTableRv2(aapsLogger, rxBus, resourceHelper, constraintChecker, danaRPump, danaRPlugin, danaRKoreanPlugin, danaRv2Plugin, configBuilderPlugin, commandQueue, activePlugin, detailedBolusInfoStorage, treatmentsPlugin)
|
||||||
|
val forTesting: MessageBase = MsgStatusAPS_v2(aapsLogger, danaRPump)
|
||||||
|
val testPacket: MessageBase = messageHashTableRv2.findMessage(forTesting.command)
|
||||||
|
Assert.assertEquals(0xE001, testPacket.command.toLong())
|
||||||
|
// try putting another command
|
||||||
|
val testMessage = MessageBase()
|
||||||
|
testMessage.SetCommand(0xE005)
|
||||||
|
messageHashTableRv2.put(testMessage)
|
||||||
|
Assert.assertEquals(0xE005, messageHashTableRv2.findMessage(0xE005).command.toLong())
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue