mirror of
https://github.com/smyalygames/checklist-tester.git
synced 2025-05-18 14:34:12 +02:00
fix(connector): vdm type errors
This commit is contained in:
parent
3e31294b27
commit
85ca7b11f4
1
connector/composeApp/src/commonMain/resources/checklist.vdmsl
Symbolic link
1
connector/composeApp/src/commonMain/resources/checklist.vdmsl
Symbolic link
@ -0,0 +1 @@
|
||||
../../../../../formal/checklist.vdmsl
|
@ -57,7 +57,7 @@ class VDMJ {
|
||||
* Creates VDMJ Lifecycle with interpreter mode
|
||||
*/
|
||||
private fun createLifecycle(): Lifecycle {
|
||||
val vdmPath = Paths.get("src/main/resources/checklist.vdmsl")
|
||||
val vdmPath = Paths.get("src/commonMain/resources/checklist.vdmsl")
|
||||
|
||||
// Creates the arguments for VDMJ - i.e. where the file is located
|
||||
val vdmArgs = arrayOf(vdmPath.pathString, "-vdmsl", "-i", "-q")
|
||||
@ -94,8 +94,8 @@ class VDMJ {
|
||||
|
||||
var output = byteArrayOutputStream.toString()
|
||||
|
||||
while(!this::exitStatus.isInitialized and output.isEmpty()) {
|
||||
delay(10)
|
||||
while(!this::exitStatus.isInitialized and (output.isEmpty() or (output.length <=2))) {
|
||||
delay(100)
|
||||
|
||||
// Convert the captured output to a string
|
||||
output = byteArrayOutputStream.toString()
|
||||
|
@ -15,6 +15,7 @@ class VDMJTransaction(val actions: List<Action>, private val xpc: XPC) {
|
||||
private val drefs: Array<String> = actions.map { it.type }.toTypedArray()
|
||||
|
||||
private var aircraft: Aircraft
|
||||
private var step = 1
|
||||
|
||||
init {
|
||||
// Check X-Plane is running
|
||||
@ -37,10 +38,20 @@ class VDMJTransaction(val actions: List<Action>, private val xpc: XPC) {
|
||||
aircraft = Aircraft(items = items, procedure = procedures)
|
||||
}
|
||||
|
||||
fun nextStep() {
|
||||
suspend fun expectedEndState(): String {
|
||||
val command = "p complete_procedure(${aircraft.toVDMString()})"
|
||||
|
||||
println(command)
|
||||
|
||||
val result = vdmj.run(command = command)
|
||||
|
||||
return result.output
|
||||
}
|
||||
|
||||
// fun nextStep() {
|
||||
// val command = "do_proc_item("
|
||||
// }
|
||||
|
||||
/**
|
||||
* Gets the state of all the DREFs in X-Plane for [Aircraft.items]
|
||||
*
|
||||
|
@ -37,7 +37,7 @@ data class Aircraft(
|
||||
}
|
||||
|
||||
// Removes the last comma in the VDM map as it will error otherwise
|
||||
output.dropLast(1)
|
||||
output = output.dropLast(1)
|
||||
|
||||
output += "}"
|
||||
|
||||
@ -58,7 +58,7 @@ data class Aircraft(
|
||||
}
|
||||
|
||||
// Removes the last comma in the VDM sequence as it will error otherwise
|
||||
output.dropLast(1)
|
||||
output = output.dropLast(1)
|
||||
|
||||
output += "]"
|
||||
|
||||
|
@ -12,6 +12,20 @@ data class ProcedureItem(
|
||||
* @return String record for VDM ChecklistItem
|
||||
*/
|
||||
fun toVDMString(): String {
|
||||
return "mk_ChecklistItem(\"$dref\", ${type.toVDMString()}, $goal, $complete)"
|
||||
return "mk_ChecklistItem(\"$dref\", ${type.toVDMString()}, ${getSwitchState()}, $complete)"
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the VDM object for the switch state
|
||||
*
|
||||
* @return String representation for switch state
|
||||
*/
|
||||
private fun getSwitchState(): String {
|
||||
return when (goal) {
|
||||
0 -> "<OFF>"
|
||||
1 -> "<ON>" // TODO add middle button
|
||||
2 -> "<ON>"
|
||||
else -> throw IllegalArgumentException("Position must be between 0 and 2")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user