feat(connector): add VDM type data class for ProcedureItem and enums for ItemType objects

This commit is contained in:
Anthony Berg 2024-05-07 00:57:02 +01:00
parent 21c597b3dc
commit 34904c4bf8
3 changed files with 41 additions and 4 deletions

View File

@ -5,7 +5,7 @@ package io.anthonyberg.connector.shared.vdmj.type
*/
data class Aircraft(
val items: Map<String, Switch>, // TODO value should be ItemObject type
val procedure: MutableList<String> // TODO change String to a ProcedureItem type
val procedure: MutableList<ProcedureItem>
) {
/**
* Converts variables in object to a String that can be passed into VDM
@ -52,9 +52,8 @@ data class Aircraft(
private fun procedureToVDMString(): String {
var output = "["
// TODO change item type to Procedure type
for (item: String in procedure) {
output += item
for (item: ProcedureItem in procedure) {
output += item.toVDMString()
output += ","
}

View File

@ -0,0 +1,21 @@
package io.anthonyberg.connector.shared.vdmj.type
/**
* Item type to identify what an Item is in an aircraft
* and therefore used to change the logic for testing the item
*/
enum class ItemType {
SWITCH,
KNOB,
BUTTON,
THROTTLE;
/**
* Returns a VDM Object as a string
*
* @return String that is a VDM representation, for example `<SWITCH>`
*/
fun toVDMString(): String {
return "<$name>"
}
}

View File

@ -0,0 +1,17 @@
package io.anthonyberg.connector.shared.vdmj.type
data class ProcedureItem(
val dref: String,
val type: ItemType,
val goal: Int, // TODO add checks for goal
val complete: Boolean,
) {
/**
* Converts to a String for a VDM representation of a ChecklistItem record
*
* @return String record for VDM ChecklistItem
*/
fun toVDMString(): String {
return "mk_ChecklistItem(\"$dref\", ${type.toVDMString()}, $goal, $complete)"
}
}