From 9fd9744f3a4abc1c54c1bdfa4b512fec0e3b09b4 Mon Sep 17 00:00:00 2001 From: Anthony Berg Date: Thu, 9 May 2024 09:48:51 +0100 Subject: [PATCH] feat(connector): add xpc commands --- .../kotlin/tab/test/TestScreenModel.kt | 25 ++++++++++++------- .../anthonyberg/connector/shared/xpc/XPC.kt | 4 +++ 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/connector/composeApp/src/desktopMain/kotlin/tab/test/TestScreenModel.kt b/connector/composeApp/src/desktopMain/kotlin/tab/test/TestScreenModel.kt index 287fd3e..b65ee78 100644 --- a/connector/composeApp/src/desktopMain/kotlin/tab/test/TestScreenModel.kt +++ b/connector/composeApp/src/desktopMain/kotlin/tab/test/TestScreenModel.kt @@ -48,14 +48,14 @@ class TestScreenModel ( posi[2] = altitude.toDouble() posi[6] = 0.0 xpc.setPOSI(posi) + delay(60000L) } - val vdm = VDMJTransaction(actions = actions, xpc = xpc) - val expected = vdm.expectedEndState() - logger.debug { expected } - - delay(5000L) +// val vdm = VDMJTransaction(actions = actions, xpc = xpc) +// val expected = vdm.expectedEndState() +// +// logger.debug { expected } // Starts the test in the database interfaceState.testId = db.startTest(procedureId) @@ -89,20 +89,27 @@ class TestScreenModel ( return@launch } + val goal = action.goal.toInt() + val isCommand = goal == -998 + // Prerequisite before testing the action - val initDref = xpc.getState(action.type)[0] + val initDref = if (isCommand) goal else xpc.getState(action.type)[0] val actionTestId = db.startAction( testId = testId, actionId = action.id, initState = initDref.toString() ) - delay(1500L) + delay(8000L) // Running the action in the simulator // TODO deal with action.goal being a String in the database - val goal = action.goal.toInt() - val result = xpc.runChecklist(action.type, goal)[0] + val result: Float = if (!isCommand) { + xpc.runChecklist(action.type, goal)[0] + } else { + xpc.sendCOMM(action.type) + goal.toFloat() + } // Saving result to the database db.finishAction( diff --git a/connector/shared/src/commonMain/kotlin/io/anthonyberg/connector/shared/xpc/XPC.kt b/connector/shared/src/commonMain/kotlin/io/anthonyberg/connector/shared/xpc/XPC.kt index 5dab53a..afc4dbd 100644 --- a/connector/shared/src/commonMain/kotlin/io/anthonyberg/connector/shared/xpc/XPC.kt +++ b/connector/shared/src/commonMain/kotlin/io/anthonyberg/connector/shared/xpc/XPC.kt @@ -74,6 +74,10 @@ class XPC { return result } + fun sendCOMM(dref: String) { + xpc.sendCOMM(dref) + } + fun getPOSI(): DoubleArray { return xpc.getPOSI(0) }