mirror of
https://github.com/smyalygames/checklist-tester.git
synced 2025-12-21 03:57:59 +01:00
feat(connector): add VDM type data class for ProcedureItem and enums for ItemType objects
This commit is contained in:
@@ -5,7 +5,7 @@ package io.anthonyberg.connector.shared.vdmj.type
|
|||||||
*/
|
*/
|
||||||
data class Aircraft(
|
data class Aircraft(
|
||||||
val items: Map<String, Switch>, // TODO value should be ItemObject type
|
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
|
* Converts variables in object to a String that can be passed into VDM
|
||||||
@@ -52,9 +52,8 @@ data class Aircraft(
|
|||||||
private fun procedureToVDMString(): String {
|
private fun procedureToVDMString(): String {
|
||||||
var output = "["
|
var output = "["
|
||||||
|
|
||||||
// TODO change item type to Procedure type
|
for (item: ProcedureItem in procedure) {
|
||||||
for (item: String in procedure) {
|
output += item.toVDMString()
|
||||||
output += item
|
|
||||||
output += ","
|
output += ","
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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>"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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)"
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user