From 56852ac60e3ad7df77c011d363f2b6e1c3a71552 Mon Sep 17 00:00:00 2001 From: Andrei Vereha Date: Fri, 6 Aug 2021 20:55:16 +0200 Subject: [PATCH 1/3] hide buttons if the pod is not activated --- .../plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt index bca8146c00..c502c4b71a 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/OmnipodDashPumpPlugin.kt @@ -183,7 +183,7 @@ class OmnipodDashPumpPlugin @Inject constructor( } override fun isInitialized(): Boolean { - return true + return podStateManager.isPodRunning } override fun isSuspended(): Boolean { From cca9324eff011523f8f4cf73632007b4f8037ff1 Mon Sep 17 00:00:00 2001 From: Andrei Vereha Date: Sat, 7 Aug 2021 20:29:06 +0200 Subject: [PATCH 2/3] add more tests for basal rate --- .../pod/command/ProgramBasalCommandTest.kt | 125 ++++++++++++++++++ 1 file changed, 125 insertions(+) diff --git a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBasalCommandTest.kt b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBasalCommandTest.kt index 4b1c48060a..74ed773246 100644 --- a/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBasalCommandTest.kt +++ b/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/command/ProgramBasalCommandTest.kt @@ -55,4 +55,129 @@ class ProgramBasalCommandTest { encoded ) } + + @Test @Throws(DecoderException::class) fun testProgramBasalCommandAllSegments() { + val segments = mutableListOf() + for (segment in 0..23) { + val rate = when (segment) { + 21 -> + 110 + 22 -> + 120 + 23 -> + 135 + else -> + segment * 5 + } + segments.add( + BasalProgram.Segment((segment * 2).toShort(), ((segment + 1) * 2).toShort(), rate) + ) + } + + val basalProgram = BasalProgram(segments) + val date = Date(2021, 8, 7, 11, 9, 6) + + val cmd = ProgramBasalCommand.Builder() + .setUniqueId(5) + .setNonce(1229869870) + .setSequenceNumber(2.toShort()) + .setBasalProgram(basalProgram) + .setCurrentTime(date) + .setMultiCommandFlag(false) + .setProgramReminder(ProgramReminder(atStart = false, atEnd = true, atInterval = 0.toByte())) + .build() + + val encoded = cmd.encoded + val expected = + "0000000508C41A28494E532E00018B16273000032000300130023003300430053006300730083009200A100B100C180D1398400B005E009E22E80002EB49D200000A15752A0000140ABA9500001E07270E000028055D4A800032044AA200003C0393870000460310BCDB005002AEA540005A02625A00006402255100006E01F360E8007801C9C380008201A68D13008C01885E6D0096016E360000A0015752A000AA0143209600B401312D0000BE01211D2800C80112A88000DC00F9B07400F000E4E1C0010E00CB73558158".lowercase() + + Assert.assertArrayEquals( + Hex.decodeHex( + expected + ), + encoded + ) + } + + @Test @Throws(DecoderException::class) fun testProgramBasalCommandHighRates() { + val segments = listOf( + BasalProgram.Segment(0.toShort(), 2.toShort(), 300), + BasalProgram.Segment(2.toShort(), 4.toShort(), 290), + BasalProgram.Segment(4.toShort(), 6.toShort(), 280), + BasalProgram.Segment(6.toShort(), 8.toShort(), 270), + BasalProgram.Segment(8.toShort(), 10.toShort(), 260), + BasalProgram.Segment(10.toShort(), 14.toShort(), 250), + BasalProgram.Segment(14.toShort(), 18.toShort(), 235), + BasalProgram.Segment(18.toShort(), 22.toShort(), 225), + BasalProgram.Segment(22.toShort(), 24.toShort(), 200), + BasalProgram.Segment(24.toShort(), 30.toShort(), 185), + BasalProgram.Segment(30.toShort(), 34.toShort(), 165), + BasalProgram.Segment(34.toShort(), 38.toShort(), 145), + BasalProgram.Segment(38.toShort(), 42.toShort(), 130), + BasalProgram.Segment(42.toShort(), 44.toShort(), 115), + BasalProgram.Segment(44.toShort(), 46.toShort(), 100), + BasalProgram.Segment(46.toShort(), 48.toShort(), 65), + ) + + val basalProgram = BasalProgram(segments) + val date = Date(2021, 8, 7, 11, 12, 9) + + val cmd = ProgramBasalCommand.Builder() + .setUniqueId(5) + .setNonce(1229869870) + .setSequenceNumber(7.toShort()) + .setBasalProgram(basalProgram) + .setCurrentTime(date) + .setMultiCommandFlag(false) + .setProgramReminder(ProgramReminder(atStart = false, atEnd = true, atInterval = 0.toByte())) + .build() + + val encoded = cmd.encoded + val expected = + "000000051C981A2C494E532E00046D162178000B101E101D101C101B101A301938173816101458123810380E300D180B100A180613684008013F008954400258005B8D800244005EB5B002300062179B021C0065B9AA02080069A34403E8006DDD0003AC0074E0360384007A12000190008954400456009476C1029400A675A2024400BD6B61020800D3468900E600EED54D00C80112A880008201A68D13809b" + + Assert.assertArrayEquals( + Hex.decodeHex( + expected + ), + encoded + ) + } + + @Test @Throws(DecoderException::class) fun testProgramBasalCommandDifferentInterval() { + val segments = listOf( + BasalProgram.Segment(0.toShort(), 2.toShort(), 50), + BasalProgram.Segment(2.toShort(), 6.toShort(), 75), + BasalProgram.Segment(6.toShort(), 12.toShort(), 0), + BasalProgram.Segment(12.toShort(), 20.toShort(), 135), + BasalProgram.Segment(20.toShort(), 32.toShort(), 270), + BasalProgram.Segment(32.toShort(), 40.toShort(), 290), + BasalProgram.Segment(40.toShort(), 46.toShort(), 95), + BasalProgram.Segment(46.toShort(), 48.toShort(), 15), + ) + + val basalProgram = BasalProgram(segments) + val date = Date(2021, 8, 7, 11, 13, 50) + + val cmd = ProgramBasalCommand.Builder() + .setUniqueId(5) + .setNonce(1229869870) + .setSequenceNumber(10.toShort()) + .setBasalProgram(basalProgram) + .setCurrentTime(date) + .setMultiCommandFlag(false) + .setProgramReminder(ProgramReminder(atStart = false, atEnd = true, atInterval = 0.toByte())) + .build() + + val encoded = cmd.encoded + val expected = + "0000000528581A1C494E532E00038E161E50000E100538075000780DB01B701D58091801133840040A100032DC82006402255100012C016E36000006EB49D200043800CB73550CA80065B9AA0910005EB5B0023A01211D28001E07270E000065" + + Assert.assertArrayEquals( + Hex.decodeHex( + expected + ), + encoded + ) + } } From e318a1a23d09864a2a8c97d424a126ef5e207b51 Mon Sep 17 00:00:00 2001 From: Andrei Vereha Date: Tue, 10 Aug 2021 20:38:23 +0200 Subject: [PATCH 3/3] store normalized TimeZone --- .../dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt index 6ff2887b39..7dfa96c8b3 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/pod/state/OmnipodDashPodStateManagerImpl.kt @@ -117,7 +117,7 @@ class OmnipodDashPodStateManagerImpl @Inject constructor( override var timeZone: TimeZone get() = TimeZone.getTimeZone(podState.timeZone) set(tz) { - podState.timeZone = tz.getDisplayName(true, TimeZone.SHORT) + podState.timeZone = tz.toZoneId().normalized().id store() }