From 9e2074433e97c8647e4b8c74401eeea9d68dbf6d Mon Sep 17 00:00:00 2001 From: Roumen Georgiev Date: Thu, 7 Jun 2018 09:26:33 +0300 Subject: [PATCH 1/4] remove button if pump is DanaR Korean --- .../androidaps/plugins/PumpDanaR/DanaRFragment.java | 10 ++++++++++ app/src/main/res/xml/pref_openapssmb.xml | 1 + 2 files changed, 11 insertions(+) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java index 65ad1056ef..463e2aaca6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java @@ -11,6 +11,7 @@ import android.text.Spanned; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.Button; import android.widget.LinearLayout; import android.widget.TextView; @@ -29,12 +30,14 @@ import info.nightscout.androidaps.db.ExtendedBolus; import info.nightscout.androidaps.events.EventExtendedBolusChange; import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.events.EventTempBasalChange; +import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.plugins.Common.SubscriberFragment; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.PumpDanaR.Dialogs.ProfileViewDialog; import info.nightscout.androidaps.plugins.PumpDanaR.activities.DanaRHistoryActivity; import info.nightscout.androidaps.plugins.PumpDanaR.activities.DanaRUserOptionsActivity; import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRNewStatus; +import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin; import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin; import info.nightscout.androidaps.queue.events.EventQueueChanged; import info.nightscout.utils.DateUtil; @@ -89,6 +92,8 @@ public class DanaRFragment extends SubscriberFragment { LinearLayout pumpStatusLayout; @BindView(R.id.overview_pumpstatus) TextView pumpStatusView; + @BindView(R.id.danar_user_options) + Button danar_user_options; public DanaRFragment() { } @@ -267,6 +272,11 @@ public class DanaRFragment extends SubscriberFragment { queueView.setText(status); } } + //hide user options button if not an RS pump + boolean isKorean = MainApp.getSpecificPlugin(DanaRKoreanPlugin.class) != null && MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).isEnabled(PluginType.PUMP); + if(isKorean){ + danar_user_options.setVisibility(View.GONE); + } } }); } diff --git a/app/src/main/res/xml/pref_openapssmb.xml b/app/src/main/res/xml/pref_openapssmb.xml index d5db368eac..c2eee2bc62 100644 --- a/app/src/main/res/xml/pref_openapssmb.xml +++ b/app/src/main/res/xml/pref_openapssmb.xml @@ -23,6 +23,7 @@ android:defaultValue="false" android:key="openapsama_useautosens" android:title="@string/openapsama_useautosens" /> + Date: Thu, 7 Jun 2018 09:33:29 +0300 Subject: [PATCH 2/4] remove button if pump is DanaR Korean --- app/src/main/res/drawable/icon_danar-useropt.png | Bin 0 -> 974 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 app/src/main/res/drawable/icon_danar-useropt.png diff --git a/app/src/main/res/drawable/icon_danar-useropt.png b/app/src/main/res/drawable/icon_danar-useropt.png new file mode 100644 index 0000000000000000000000000000000000000000..1fadcd446be0340737c1c7997a79fae7789e4589 GIT binary patch literal 974 zcmV;<12O!GP)zn|30>}yC8`SJ9d6D!4r6<5y zSn@991R*D=dxGE_z|y;L0;;Ee6FnwlGal^LLjEK#m>I_J^ZVY<7(N^h2f7q|yci|} znI2;x(^m{+`if6o+ZC1ZgosA?xXHZqwX1t|S~R0F4vFYN3>8E)>xxikGJ{7RwBa!k zt-88rmoYPHIDR&qVC zKG$rqgWM93&b9UP%u5@~(UlB8xf_e6dw$a5^VBd;6~w=0Ub-=iSHe|hb-Lf8-U#pUVa~*Omnlkmidy0_Z6tdciDJ8LqT#p!2HESA`v2~4-a3v$XvNg=B zr<=>cinR)B;T_#`RVl>mIIxt;{AB<3=)>m*$YnR0TWYK*dFsN2`psszqmY%_m&1GE{=>mmq1}H*HgF zVN1q%^QeqxHQ(9717FZg&Y=Ig2C{0uqGJ3AR%FnE%neiTQYgnoRL1PF7gY8gJh6sc zUU;6{8F;LAKa~J%?6l5isPHQ~?wSMnq|tBPqFAazs^;(D;Sr3xMJ!4~RZ9M;w>_)kl+La@~@R`~Ja#Nn* zLhO_voIHa9w}MpIJ0WBkAiX|CWn6&t7MBlM1xN~eA+ZEw>VY_+^&^0IHxLQ~CEkwA z;-R#11aKvj8;-z?dzOo;KOiRKXCvl(kTUJVxJL1{M%yP%mR*3Xwnkz&G6-G`an&80 z8^e`MovvA0OEimxw$?XDZ(l*GaqOIP1kkH8AH1%$Q{xyiQkNpK$NDRo)dc1)EsyiN z=DL@F;v~8>eDz%&`mZkmZGgV*mtiT_5v%s3DY|^uT&4NWe$wcS3^cDdr-kXAL0jnj wPYoCIW7EIJ@B?jMF_7si1~Prc<&YtwKfx`30dj}THUIzs07*qoM6N<$f^F!>M*si- literal 0 HcmV?d00001 From 17a0aba2e5fcc2a9b8fa6e10c3960b469577f1fd Mon Sep 17 00:00:00 2001 From: Roumen Georgiev Date: Thu, 7 Jun 2018 09:34:12 +0300 Subject: [PATCH 3/4] remove button if pump is DanaR Korean --- app/src/main/res/drawable/icon_danar-useropt.png | Bin 974 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 app/src/main/res/drawable/icon_danar-useropt.png diff --git a/app/src/main/res/drawable/icon_danar-useropt.png b/app/src/main/res/drawable/icon_danar-useropt.png deleted file mode 100644 index 1fadcd446be0340737c1c7997a79fae7789e4589..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 974 zcmV;<12O!GP)zn|30>}yC8`SJ9d6D!4r6<5y zSn@991R*D=dxGE_z|y;L0;;Ee6FnwlGal^LLjEK#m>I_J^ZVY<7(N^h2f7q|yci|} znI2;x(^m{+`if6o+ZC1ZgosA?xXHZqwX1t|S~R0F4vFYN3>8E)>xxikGJ{7RwBa!k zt-88rmoYPHIDR&qVC zKG$rqgWM93&b9UP%u5@~(UlB8xf_e6dw$a5^VBd;6~w=0Ub-=iSHe|hb-Lf8-U#pUVa~*Omnlkmidy0_Z6tdciDJ8LqT#p!2HESA`v2~4-a3v$XvNg=B zr<=>cinR)B;T_#`RVl>mIIxt;{AB<3=)>m*$YnR0TWYK*dFsN2`psszqmY%_m&1GE{=>mmq1}H*HgF zVN1q%^QeqxHQ(9717FZg&Y=Ig2C{0uqGJ3AR%FnE%neiTQYgnoRL1PF7gY8gJh6sc zUU;6{8F;LAKa~J%?6l5isPHQ~?wSMnq|tBPqFAazs^;(D;Sr3xMJ!4~RZ9M;w>_)kl+La@~@R`~Ja#Nn* zLhO_voIHa9w}MpIJ0WBkAiX|CWn6&t7MBlM1xN~eA+ZEw>VY_+^&^0IHxLQ~CEkwA z;-R#11aKvj8;-z?dzOo;KOiRKXCvl(kTUJVxJL1{M%yP%mR*3Xwnkz&G6-G`an&80 z8^e`MovvA0OEimxw$?XDZ(l*GaqOIP1kkH8AH1%$Q{xyiQkNpK$NDRo)dc1)EsyiN z=DL@F;v~8>eDz%&`mZkmZGgV*mtiT_5v%s3DY|^uT&4NWe$wcS3^cDdr-kXAL0jnj wPYoCIW7EIJ@B?jMF_7si1~Prc<&YtwKfx`30dj}THUIzs07*qoM6N<$f^F!>M*si- From 2441214bb8f21f224f6ab1e4c9d4969f5296f6f0 Mon Sep 17 00:00:00 2001 From: Roumen Georgiev Date: Mon, 11 Jun 2018 11:36:32 +0300 Subject: [PATCH 4/4] added SetUserOptions for DanaR --- .../androidaps/db/ProfileSwitch.java | 13 ++-- .../plugins/PumpDanaR/DanaRFragment.java | 2 +- .../PumpDanaR/comm/MsgGetUserOptions.java | 67 +++++++++++++++++++ .../PumpDanaR/comm/MsgSettingUserOptions.java | 59 +++++++++++++++- .../services/DanaRv2ExecutionService.java | 16 +++++ 5 files changed, 149 insertions(+), 8 deletions(-) create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgGetUserOptions.java diff --git a/app/src/main/java/info/nightscout/androidaps/db/ProfileSwitch.java b/app/src/main/java/info/nightscout/androidaps/db/ProfileSwitch.java index 40c8e50c6d..6022525afb 100644 --- a/app/src/main/java/info/nightscout/androidaps/db/ProfileSwitch.java +++ b/app/src/main/java/info/nightscout/androidaps/db/ProfileSwitch.java @@ -103,11 +103,14 @@ public class ProfileSwitch implements Interval, DataPointWithLabelInterface { if(LocalProfilePlugin.LOCAL_PROFILE.equals(name)){ name = DecimalFormatter.to2Decimal(getProfileObject().percentageBasalSum()) + "U "; } - if (isCPP) { - name += "(" + percentage + "%"; - if (timeshift != 0) - name += "," + timeshift + "h"; - name += ")"; + //Test if name is already containing percentage or timeshift + if (!name.endsWith("h)") || !name.endsWith("%)")) { + if (isCPP) { + name += "(" + percentage + "%"; + if (timeshift != 0) + name += "," + timeshift + "h"; + name += ")"; + } } return name; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java index 463e2aaca6..b37d0e945f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java @@ -274,7 +274,7 @@ public class DanaRFragment extends SubscriberFragment { } //hide user options button if not an RS pump boolean isKorean = MainApp.getSpecificPlugin(DanaRKoreanPlugin.class) != null && MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).isEnabled(PluginType.PUMP); - if(isKorean){ + if (isKorean ) { danar_user_options.setVisibility(View.GONE); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgGetUserOptions.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgGetUserOptions.java new file mode 100644 index 0000000000..33ab6b27e9 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgGetUserOptions.java @@ -0,0 +1,67 @@ +package info.nightscout.androidaps.plugins.PumpDanaR.comm; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; + +/** + * Created by Rumen Georgiev on 6/11/2018. + */ + +public class MsgGetUserOptions extends MessageBase { + private int backlightOnTimeSec; + private int beepAndAlarm; + private int buttonScrollOnOff; + private int cannulaVolume; + private int glucoseUnit; + private int lcdOnTimeSec; + private int lowReservoirRate; + private int refillRate; + private int selectableLanguage1; + private int selectableLanguage2; + private int selectableLanguage3; + private int selectableLanguage4; + private int selectableLanguage5; + private int selectedLanguage; + private int shutdownHour; + private int timeDisplayType; + + private static Logger log = LoggerFactory.getLogger(MsgGetUserOptions.class); + + public MsgGetUserOptions() { + SetCommand(0x320B); + } + + public void handleMessage(byte[] bytes) { + DanaRPump pump = DanaRPump.getInstance(); + pump.timeDisplayType = bytes[0] == (byte) 1 ? 0 : 1; + pump.buttonScrollOnOff = bytes[1]; + pump.beepAndAlarm = bytes[2]; + pump.lcdOnTimeSec = bytes[3] & 255; + pump.backlightOnTimeSec = bytes[4] & 255; + pump.selectedLanguage = bytes[5]; + pump.units = bytes[8]; + pump.shutdownHour = bytes[9] & 255; + pump.lowReservoirRate = bytes[32] & 255; + /* int selectableLanguage1 = bytes[10]; + int selectableLanguage2 = bytes[11]; + int selectableLanguage3 = bytes[12]; + int selectableLanguage4 = bytes[13]; + int selectableLanguage5 = bytes[14]; + */ + + if (Config.logDanaMessageDetail) { + log.debug("timeDisplayType: " + pump.timeDisplayType); + log.debug("Button scroll: " + pump.buttonScrollOnOff); + log.debug("BeepAndAlarm: " + pump.beepAndAlarm); + log.debug("screen timeout: " + pump.lcdOnTimeSec); + log.debug("Backlight: " + pump.backlightOnTimeSec); + log.debug("Selected language: " + pump.selectedLanguage); + log.debug("Units: " + pump.getUnits()); + log.debug("Shutdown: " + pump.shutdownHour); + log.debug("Low reservoir: " + pump.lowReservoirRate); + } + } +} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingUserOptions.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingUserOptions.java index 8fb1e4f712..f7af73f13f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingUserOptions.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingUserOptions.java @@ -3,18 +3,73 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.MainApp; +import info.nightscout.androidaps.R; +import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; +import info.nightscout.androidaps.plugins.Overview.notifications.Notification; +import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; + /** * Created by mike on 05.07.2016. */ public class MsgSettingUserOptions extends MessageBase { - private static Logger log = LoggerFactory.getLogger(MsgSettingShippingInfo.class); + + private int backlightOnTimeSec; + private int beepAndAlarm; + private int buttonScrollOnOff; + private int cannulaVolume; + private int error; + private int glucoseUnit; + private int lcdOnTimeSec; + private int lowReservoirRate; + private int refillRate; + private int selectedLanguage; + private int shutdownHour; + private int timeDisplayType; + + public boolean done; + + public MsgSettingUserOptions(int timeDisplayType, int buttonScrollOnOff, int beepAndAlarm, int lcdOnTimeSec, int backlightOnTimeSec, int selectedLanguage, int glucoseUnit, int shutdownHour, int lowReservoirRate, int cannulaVolume, int refillRate) { + this(); + this.timeDisplayType = timeDisplayType; + this.buttonScrollOnOff = buttonScrollOnOff; + this.beepAndAlarm = beepAndAlarm; + this.lcdOnTimeSec = lcdOnTimeSec; + this.backlightOnTimeSec = backlightOnTimeSec; + this.selectedLanguage = selectedLanguage; + this.glucoseUnit = glucoseUnit; + this.shutdownHour = shutdownHour; + this.lowReservoirRate = lowReservoirRate; + this.cannulaVolume = cannulaVolume; + this.refillRate = refillRate; + + AddParamByte((byte) timeDisplayType); + AddParamByte((byte) buttonScrollOnOff); + AddParamByte((byte) beepAndAlarm); + AddParamByte((byte) lcdOnTimeSec); + AddParamByte((byte) backlightOnTimeSec); + AddParamByte((byte) selectedLanguage); + AddParamByte((byte) glucoseUnit); + AddParamByte((byte) shutdownHour); + AddParamByte((byte) lowReservoirRate); + } + + private static Logger log = LoggerFactory.getLogger(MsgSettingUserOptions.class); public MsgSettingUserOptions() { SetCommand(0x320B); } public void handleMessage(byte[] bytes) { - + int result = intFromBuff(bytes, 0, 1); + if (result != 1) { + failed = true; + log.debug("Setting user options: " + result + " FAILED!!!"); + } else { + if (Config.logDanaMessageDetail) + log.debug("Setting user options: " + result); + } } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java index 2e27122abb..b16312a38c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java @@ -18,6 +18,7 @@ import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.PumpEnactResult; +import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgSettingUserOptions; import info.nightscout.androidaps.plugins.Treatments.Treatment; import info.nightscout.androidaps.events.EventAppExit; import info.nightscout.androidaps.events.EventInitializationChanged; @@ -471,4 +472,19 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { SystemClock.sleep(Math.min(timeToWholeMinute, 100)); } } + + public PumpEnactResult updateUserSettings() { + if (!isConnected()) + return new PumpEnactResult().success(false); + SystemClock.sleep(300); + MsgSettingUserOptions msg; + + mSerialIOThread.sendMessage(msg); + while (!msg.done && mRfcommSocket.isConnected()) { + SystemClock.sleep(100); + } + SystemClock.sleep(200); + mDanaRPump.lastConnection = System.currentTimeMillis(); + return new PumpEnactResult().success(true); + } }