mirror of
				https://github.com/smyalygames/checklist-tester.git
				synced 2025-11-04 04:49:49 +01:00 
			
		
		
		
	feat(connector): add VDM type data class for ProcedureItem and enums for ItemType objects
This commit is contained in:
		
							parent
							
								
									21c597b3dc
								
							
						
					
					
						commit
						34904c4bf8
					
				@ -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 += ","
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -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)"
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user