diff --git a/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/parser/Parser.kt b/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/parser/Parser.kt index 2c2d7be005..7ad91437a5 100644 --- a/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/parser/Parser.kt +++ b/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/parser/Parser.kt @@ -84,6 +84,9 @@ sealed class AlertScreenContent { enum class AlertScreenState { TO_SNOOZE, TO_CONFIRM, + // Used when the alert is an error. The text in error screens is not + // interpreted, since it is anyway fully up to the user to interpret it. + ERROR_TEXT, HISTORY_ENTRY } @@ -1156,15 +1159,14 @@ class AlertScreenParser : Parser() { parseResult as ParseResult.Sequence - val stateString = parseResult.valueAt(4) - val alertState = when (knownScreenTitles[stateString]) { - TitleID.ALERT_TO_SNOOZE -> AlertScreenContent.AlertScreenState.TO_SNOOZE - TitleID.ALERT_TO_CONFIRM -> AlertScreenContent.AlertScreenState.TO_CONFIRM - else -> return ParseResult.Failed - } - return when (parseResult.valueAtOrNull(0)) { Glyph.LargeSymbol(LargeSymbol.WARNING) -> { + val stateString = parseResult.valueAt(4) + val alertState = when (knownScreenTitles[stateString]) { + TitleID.ALERT_TO_SNOOZE -> AlertScreenContent.AlertScreenState.TO_SNOOZE + TitleID.ALERT_TO_CONFIRM -> AlertScreenContent.AlertScreenState.TO_CONFIRM + else -> return ParseResult.Failed + } ParseResult.Value(ParsedScreen.AlertScreen( AlertScreenContent.Warning(parseResult.valueAt(2), alertState) )) @@ -1172,7 +1174,14 @@ class AlertScreenParser : Parser() { Glyph.LargeSymbol(LargeSymbol.ERROR) -> { ParseResult.Value(ParsedScreen.AlertScreen( - AlertScreenContent.Error(parseResult.valueAt(2), alertState) + AlertScreenContent.Error( + parseResult.valueAt(2), + // We don't really care about the state string if an error is shown. + // It's not like any logic here will interpret it; that text is + // purely for the user. So, don't bother interpreting it here, and + // just assign a generic ERROR_TEXT state value instead. + AlertScreenContent.AlertScreenState.ERROR_TEXT + ) )) } diff --git a/pump/combov2/comboctl/src/jvmTest/kotlin/info/nightscout/comboctl/parser/ParserTest.kt b/pump/combov2/comboctl/src/jvmTest/kotlin/info/nightscout/comboctl/parser/ParserTest.kt index 03421aec21..b3a0c4d584 100644 --- a/pump/combov2/comboctl/src/jvmTest/kotlin/info/nightscout/comboctl/parser/ParserTest.kt +++ b/pump/combov2/comboctl/src/jvmTest/kotlin/info/nightscout/comboctl/parser/ParserTest.kt @@ -716,6 +716,24 @@ class ParserTest { } } + @Test + fun checkE4OcclusionErrorScreenParsing() { + val testScreens = listOf( + Pair(testFrameE4OcclusionErrorScreen0, AlertScreenContent.Error(4, AlertScreenContent.AlertScreenState.ERROR_TEXT)), + Pair(testFrameE4OcclusionErrorScreen1, AlertScreenContent.None), + Pair(testFrameE4OcclusionErrorScreen2, AlertScreenContent.Error(4, AlertScreenContent.AlertScreenState.ERROR_TEXT)), + Pair(testFrameE4OcclusionErrorScreen3, AlertScreenContent.None), + ) + + for (testScreen in testScreens) { + val testContext = TestContext(testScreen.first, 0, skipTitleString = true) + val result = AlertScreenParser().parse(testContext.parseContext) + assertEquals(ParseResult.Value::class, result::class) + val screen = (result as ParseResult.Value<*>).value as ParsedScreen.AlertScreen + assertEquals(testScreen.second, screen.content) + } + } + @Test fun checkTemporaryBasalRatePercentageScreenParsing() { val testScreens = listOf( diff --git a/pump/combov2/comboctl/src/jvmTest/kotlin/info/nightscout/comboctl/parser/TestDisplayFrames.kt b/pump/combov2/comboctl/src/jvmTest/kotlin/info/nightscout/comboctl/parser/TestDisplayFrames.kt index 0830f7b08b..9ed1dae19a 100644 --- a/pump/combov2/comboctl/src/jvmTest/kotlin/info/nightscout/comboctl/parser/TestDisplayFrames.kt +++ b/pump/combov2/comboctl/src/jvmTest/kotlin/info/nightscout/comboctl/parser/TestDisplayFrames.kt @@ -1700,6 +1700,146 @@ val testFrameE2BatteryEmptyErrorScreen1 = makeDisplayFrame(arrayOf( " ████ █████ ████ █ █ █ █ ███ ████ █████ █ █ " )) +val testFrameE4OcclusionErrorScreen0 = makeDisplayFrame(arrayOf( + "█ █ █████ ████ ████ █████ ███ ████ █████ █ █ █ █ ███ ", + "█ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ ", + "█ █ █ █ █ █ █ █ █ █ █ █ █ █ ██ █ █ ", + "█ █ ████ ████ ███ █ █ █ ████ ████ █ █ █ █ █ █ ███ ", + "█ █ █ █ █ █ █ █ █ █ █ █ █ █ ██ █ █ ", + " █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ ", + " █ █████ █ █ ████ █ ███ █ █ ███ █ █ ████ ", + " ", + " █████ ████████ ██ ████████ ", + " █████████ ██ ███ ██████████ ", + " ███████████ ██ ███ ████████████ ", + " ███ █████ ███ ██ ████ ██████████████ ", + " ██ ███ ██ ██ █ ██ ████████████████ ", + " ████ █ ████ ██ ██ ██ █ █ █ █ ██ ", + " █████ █████ ██ █ ██ █ ███ ██ █ █ █ █ ", + " ██████ ██████ ███████ ██ ██ █ ██ ██ █ █ ██ ", + " █████ █████ ██ ██ ██ ██ ██ ██ █ █ ███ ", + " ████ █ ████ ██ ████████ █ ██ ██ █ ███ ", + " ██ ███ ██ ██ ██ ████████████████ ", + " ███ █████ ███ ██ ██ ██████████████ ", + " ███████████ ██ ██ ████████████ ", + " █████████ ██ ██ ██████████ ", + " █████ ████████ ██ ████████ ", + " ", + " ", + " █ ████ █████ █ █ █ █ █ █ ████ ███ █ █ █ █ █████ █████ █ █ ", + " ██ █ █ █ █ ██ ██ ██ ██ █ █ █ █ █ █ █ █ █ █ █ █ ", + "█ ██ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ ██ █ ", + "███ ███ █ █ █ █ █ █ █ █ █ ███ █ █████ █████ █ █ ████ █ █ █ ", + " █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ ██ ", + " █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ ", + " ████ █ ███ █ █ █ █ ████ ███ █ █ █ █ █████ █ █████ █ █ " +)) + +val testFrameE4OcclusionErrorScreen1 = makeDisplayFrame(arrayOf( + "█ █ █████ ████ ████ █████ ███ ████ █████ █ █ █ █ ███ ", + "█ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ ", + "█ █ █ █ █ █ █ █ █ █ █ █ █ █ ██ █ █ ", + "█ █ ████ ████ ███ █ █ █ ████ ████ █ █ █ █ █ █ ███ ", + "█ █ █ █ █ █ █ █ █ █ █ █ █ █ ██ █ █ ", + " █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ ", + " █ █████ █ █ ████ █ ███ █ █ ███ █ █ ████ ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " █ ████ █████ █ █ █ █ █ █ ████ ███ █ █ █ █ █████ █████ █ █ ", + " ██ █ █ █ █ ██ ██ ██ ██ █ █ █ █ █ █ █ █ █ █ █ █ ", + "█ ██ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ ██ █ ", + "███ ███ █ █ █ █ █ █ █ █ █ ███ █ █████ █████ █ █ ████ █ █ █ ", + " █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ ██ ", + " █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ ", + " ████ █ ███ █ █ █ █ ████ ███ █ █ █ █ █████ █ █████ █ █ " +)) + +val testFrameE4OcclusionErrorScreen2 = makeDisplayFrame(arrayOf( + "█ █ █████ ████ ████ █████ ███ ████ █████ █ █ █ █ ███ ", + "█ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ ", + "█ █ █ █ █ █ █ █ █ █ █ █ █ █ ██ █ █ ", + "█ █ ████ ████ ███ █ █ █ ████ ████ █ █ █ █ █ █ ███ ", + "█ █ █ █ █ █ █ █ █ █ █ █ █ █ ██ █ █ ", + " █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ ", + " █ █████ █ █ ████ █ ███ █ █ ███ █ █ ████ ", + " ", + " █████ ████████ ██ ████████ ", + " █████████ ██ ███ ██████████ ", + " ███████████ ██ ███ ████████████ ", + " ███ █████ ███ ██ ████ ██████████████ ", + " ██ ███ ██ ██ █ ██ ████████████████ ", + " ████ █ ████ ██ ██ ██ █ █ █ █ ██ ", + " █████ █████ ██ █ ██ █ ███ ██ █ █ █ █ ", + " ██████ ██████ ███████ ██ ██ █ ██ ██ █ █ ██ ", + " █████ █████ ██ ██ ██ ██ ██ ██ █ █ ███ ", + " ████ █ ████ ██ ████████ █ ██ ██ █ ███ ", + " ██ ███ ██ ██ ██ ████████████████ ", + " ███ █████ ███ ██ ██ ██████████████ ", + " ███████████ ██ ██ ████████████ ", + " █████████ ██ ██ ██████████ ", + " █████ ████████ ██ ████████ ", + " ", + " ", + " █ ████ █████ ████ █████ █ █ █████ ███ ███ █████ █ █ ", + " ██ █ █ █ █ █ ███ █ █ █ █ █ █ █ ", + "█ ██ █ █ █ █ █ █ █ █ █ █ █ ██ █ ", + "███ ████ ████ ███ █ █ █ █ █ █ ███ ████ █ █ █ ", + " █ █ █ █ █ █ █████ █ █ █ █ █ █ ██ ", + " █ █ █ █ █ █ █ █ █ █ █ █ █ █ ", + " ████ █████ ████ █ █ █ █ ███ ████ █████ █ █ " +)) + +val testFrameE4OcclusionErrorScreen3 = makeDisplayFrame(arrayOf( + "█ █ █████ ████ ████ █████ ███ ████ █████ █ █ █ █ ███ ", + "█ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ ", + "█ █ █ █ █ █ █ █ █ █ █ █ █ █ ██ █ █ ", + "█ █ ████ ████ ███ █ █ █ ████ ████ █ █ █ █ █ █ ███ ", + "█ █ █ █ █ █ █ █ █ █ █ █ █ █ ██ █ █ ", + " █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ ", + " █ █████ █ █ ████ █ ███ █ █ ███ █ █ ████ ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " █ ████ █████ ████ █████ █ █ █████ ███ ███ █████ █ █ ", + " ██ █ █ █ █ █ ███ █ █ █ █ █ █ █ ", + "█ ██ █ █ █ █ █ █ █ █ █ █ █ ██ █ ", + "███ ████ ████ ███ █ █ █ █ █ █ ███ ████ █ █ █ ", + " █ █ █ █ █ █ █████ █ █ █ █ █ █ ██ ", + " █ █ █ █ █ █ █ █ █ █ █ █ █ █ ", + " ████ █████ ████ █ █ █ █ ███ ████ █████ █ █ " +)) + val testFrameTemporaryBasalRatePercentage100Screen = makeDisplayFrame(arrayOf( "█████ ████ ████ █ █ █████ ████ █████ ", " █ █ █ █ █ █ █ █ █ █ █ ",