feat(connector): add VDM type data class for ItemObject

This commit is contained in:
Anthony Berg 2024-05-07 12:14:32 +01:00
parent 34904c4bf8
commit 51269484af
3 changed files with 15 additions and 11 deletions

View File

@ -4,7 +4,7 @@ package io.anthonyberg.connector.shared.vdmj.type
* Aircraft record type in the VDM-SL model * Aircraft record type in the VDM-SL model
*/ */
data class Aircraft( data class Aircraft(
val items: Map<String, Switch>, // TODO value should be ItemObject type val items: Map<String, ItemObject>,
val procedure: MutableList<ProcedureItem> val procedure: MutableList<ProcedureItem>
) { ) {
/** /**

View File

@ -0,0 +1,13 @@
package io.anthonyberg.connector.shared.vdmj.type
data class ItemObject(val type: ItemType, val item: Switch) { // TODO add types for other items
/**
* Converts to String for a VDM representation of an ItemObject record
*
* @return String representation for VDM ItemObject
*/
fun toVDMString(): String {
return "mk_ItemObject(${type.toVDMString()}, ${item.toVDMString()})"
}
}

View File

@ -12,21 +12,12 @@ data class Switch(val position: Int, val middlePosition: Boolean = false) {
require((position >= 0) and ((position <= 1) and !middlePosition) or ((position <= 2) and middlePosition)) require((position >= 0) and ((position <= 1) and !middlePosition) or ((position <= 2) and middlePosition))
} }
/**
* Converts to String for a VDM representation of an ItemObject record
*
* @return String representation for VDM ItemObject
*/
fun toVDMString(): String {
return "mk_ItemObject(<SWITCH>, ${toSwitchVDMString()})"
}
/** /**
* Converts to String for a VDM representation of a Switch record * Converts to String for a VDM representation of a Switch record
* *
* @return String representation for VDM Switch * @return String representation for VDM Switch
*/ */
private fun toSwitchVDMString(): String { fun toVDMString(): String {
return "mk_Switch(${getSwitchState()}, $middlePosition)" return "mk_Switch(${getSwitchState()}, $middlePosition)"
} }