From 2dea4615c0dc5f267d8ba8cf7ce1255f1f438611 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 6 Dec 2016 23:46:36 +0100 Subject: [PATCH] basal rates set --- .../plugins/DanaR/comm/MessageHashTable.java | 3 +- .../DanaR/comm/MessageOriginalNames.java | 2 +- .../DanaR/comm/MsgSetSingleBasalProfile.java | 38 +++++++++++++++++++ .../Services/ExecutionService.java | 4 +- .../DanaRKorean/comm/MessageHashTable.java | 4 +- ...ile.java => MsgSetSingleBasalProfile.java} | 13 +++---- wear/wear.iml | 20 ++++------ 7 files changed, 58 insertions(+), 26 deletions(-) create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/DanaR/comm/MsgSetSingleBasalProfile.java rename app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/comm/{MsgSetBasalProfile.java => MsgSetSingleBasalProfile.java} (70%) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/comm/MessageHashTable.java b/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/comm/MessageHashTable.java index 5081bf81d6..8650ea5e8b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/comm/MessageHashTable.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/comm/MessageHashTable.java @@ -33,7 +33,7 @@ public class MessageHashTable { put(new MsgSetTempBasalStop()); // 0x0403 CMD_PUMPSET_EXERCISE_STOP put(new MsgSetExtendedBolusStop()); // 0x0406 CMD_PUMPSET_EXPANS_INS_STOP put(new MsgSetExtendedBolusStart()); // 0x0407 CMD_PUMPSET_EXPANS_INS_S - put(new MsgError()); // 0x0601 CMD_PUMPOWAY_SYSTEM_STATUS + put(new MsgError()); // 0x0601 CMD_PUMPOWAY_SYSTEM_STATUS put(new MsgPCCommStart()); // 0x3001 CMD_CONNECT put(new MsgPCCommStop()); // 0x3002 CMD_DISCONNECT put(new MsgHistoryBolus()); // 0x3101 CMD_HISTORY_MEAL_INS @@ -56,6 +56,7 @@ public class MessageHashTable { put(new MsgSettingUserOptions()); // 0x320B CMD_SETTING_V_USER_OPTIONS put(new MsgSettingActiveProfile()); // 0x320C CMD_SETTING_V_PROFILE_NUMBER put(new MsgSettingProfileRatiosAll()); // 0x320D CMD_SETTING_V_CIR_CF_VALUE + put(new MsgSetSingleBasalProfile()); // 0x3302 CMD_SETTING_BASAL_INS_S put(new MsgSetBasalProfile()); // 0x3306 CMD_SETTING_BASAL_PROFILE_S put(new MsgSetActivateBasalProfile()); // 0x330C CMD_SETTING_PROFILE_NUMBER_S put(new MsgHistoryAllDone()); // 0x41F1 CMD_HISTORY_ALL_DONE diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/comm/MessageOriginalNames.java b/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/comm/MessageOriginalNames.java index 66f4ac71bf..5aba354812 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/comm/MessageOriginalNames.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/comm/MessageOriginalNames.java @@ -62,7 +62,7 @@ public class MessageOriginalNames { messageNames.put(0x320d, "CMD_SETTING_V_CIR_CF_VALUE"); messageNames.put(0x3301, "CMD_SETTING_MEAL_INS_S"); - messageNames.put(0x3302, "CMD_SETTING_Based_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"); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/comm/MsgSetSingleBasalProfile.java b/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/comm/MsgSetSingleBasalProfile.java new file mode 100644 index 0000000000..bde02afa21 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/comm/MsgSetSingleBasalProfile.java @@ -0,0 +1,38 @@ +package info.nightscout.androidaps.plugins.DanaR.comm; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import info.nightscout.androidaps.Config; + +public class MsgSetSingleBasalProfile extends MessageBase { + private static Logger log = LoggerFactory.getLogger(MsgSetSingleBasalProfile.class); + + 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 (Config.logDanaMessageDetail) + log.debug("Set basal profile"); + } + + @Override + public void handleMessage(byte[] bytes) { + int result = intFromBuff(bytes, 0, 1); + if (result != 1) { + failed = true; + log.debug("Set basal profile result: " + result + " FAILED!!!"); + } else { + if (Config.logDanaMessageDetail) + log.debug("Set basal profile result: " + result); + } + } + + +} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/Services/ExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/Services/ExecutionService.java index 96ef699c21..13435a0855 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/Services/ExecutionService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/Services/ExecutionService.java @@ -428,10 +428,8 @@ public class ExecutionService extends Service { connect("updateBasalsInPump"); if (!isConnected()) return false; double[] basal = buildDanaRProfileRecord(profile); - MsgSetBasalProfile msgSet = new MsgSetBasalProfile((byte) 0, basal); + MsgSetSingleBasalProfile msgSet = new MsgSetSingleBasalProfile(basal); mSerialIOThread.sendMessage(msgSet); - //MsgSetActivateBasalProfile msgActivate = new MsgSetActivateBasalProfile((byte) 0); - //mSerialIOThread.sendMessage(msgActivate); getPumpStatus(); return true; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/comm/MessageHashTable.java b/app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/comm/MessageHashTable.java index 048074ab37..6effa0e374 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/comm/MessageHashTable.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/comm/MessageHashTable.java @@ -34,7 +34,7 @@ public class MessageHashTable { put(new MsgSetTempBasalStop()); // 0x0403 CMD_PUMPSET_EXERCISE_STOP put(new MsgSetExtendedBolusStop()); // 0x0406 CMD_PUMPSET_EXPANS_INS_STOP put(new MsgSetExtendedBolusStart()); // 0x0407 CMD_PUMPSET_EXPANS_INS_S - put(new MsgError()); // 0x0601 CMD_PUMPOWAY_SYSTEM_STATUS + put(new MsgError()); // 0x0601 CMD_PUMPOWAY_SYSTEM_STATUS put(new MsgPCCommStart()); // 0x3001 CMD_CONNECT put(new MsgPCCommStop()); // 0x3002 CMD_DISCONNECT put(new MsgHistoryBolus()); // 0x3101 CMD_HISTORY_MEAL_INS @@ -54,7 +54,7 @@ public class MessageHashTable { put(new MsgSettingShippingInfo()); // 0x3207 CMD_SETTING_V_SHIPPING_I put(new MsgSettingGlucose()); // 0x3209 CMD_SETTING_V_GLUCOSEandEASY put(new MsgSettingPumpTime()); // 0x320A CMD_SETTING_V_TIME_I - put(new MsgSetBasalProfile()); // 0x3306 CMD_SETTING_BASAL_PROFILE_S + put(new MsgSetSingleBasalProfile()); // 0x3302 CMD_SETTING_BASAL_INS_S put(new MsgHistoryAll()); // 0x41F2 CMD_HISTORY_ALL put(new MsgHistoryNewDone()); // 0x42F1 CMD_HISTORY_NEW_DONE put(new MsgHistoryNew()); // 0x42F2 CMD_HISTORY_NEW diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/comm/MsgSetBasalProfile.java b/app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/comm/MsgSetSingleBasalProfile.java similarity index 70% rename from app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/comm/MsgSetBasalProfile.java rename to app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/comm/MsgSetSingleBasalProfile.java index 8d9b13bf85..3163ae5c50 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/comm/MsgSetBasalProfile.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/comm/MsgSetSingleBasalProfile.java @@ -6,22 +6,21 @@ import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; import info.nightscout.androidaps.plugins.DanaR.comm.MessageBase; -public class MsgSetBasalProfile extends MessageBase { - private static Logger log = LoggerFactory.getLogger(MsgSetBasalProfile.class); +public class MsgSetSingleBasalProfile extends MessageBase { + private static Logger log = LoggerFactory.getLogger(MsgSetSingleBasalProfile.class); - public MsgSetBasalProfile() { - SetCommand(0x3306); + public MsgSetSingleBasalProfile() { + SetCommand(0x3302); } // index 0-3 - public MsgSetBasalProfile(byte index, double[] values) { + public MsgSetSingleBasalProfile(double[] values) { this(); - AddParamByte(index); for (Integer i = 0; i < 24; i++) { AddParamInt((int) (values[i] * 100)); } if (Config.logDanaMessageDetail) - log.debug("Set basal profile: " + index); + log.debug("Set basal profile"); } @Override diff --git a/wear/wear.iml b/wear/wear.iml index 40a96e0eab..2acebc7d20 100644 --- a/wear/wear.iml +++ b/wear/wear.iml @@ -106,14 +106,6 @@ - - - - - - - - @@ -122,9 +114,15 @@ + + + + + + + + - - @@ -133,13 +131,11 @@ - -