mirror of
https://github.com/smyalygames/checklist-tester.git
synced 2025-05-18 14:34:12 +02:00
feat(formal): start logic for completing items in checklist in aircraft
This commit is contained in:
parent
53ee06cfd6
commit
efd5588085
@ -6,7 +6,7 @@ values
|
|||||||
-- Before Start Checklist
|
-- Before Start Checklist
|
||||||
-- Items in Aircraft
|
-- Items in Aircraft
|
||||||
-- Flight Deck... (can't check)
|
-- Flight Deck... (can't check)
|
||||||
fuel: Item = mk_Item("Fuek Pump", <SWITCH>, mk_Switch(<OFF>, false));
|
fuel: Item = mk_Item("Fuel Pump", <SWITCH>, mk_Switch(<OFF>, false));
|
||||||
pax_sign: Item = mk_Item("Passenger Signs", <SWITCH>, mk_Switch(<OFF>, true));
|
pax_sign: Item = mk_Item("Passenger Signs", <SWITCH>, mk_Switch(<OFF>, true));
|
||||||
windows: Item = mk_Item("Windows", <SWITCH>, mk_Switch(<ON>, false));
|
windows: Item = mk_Item("Windows", <SWITCH>, mk_Switch(<ON>, false));
|
||||||
-- Preflight steps
|
-- Preflight steps
|
||||||
@ -33,6 +33,8 @@ types
|
|||||||
-- 1 means off
|
-- 1 means off
|
||||||
SwitchState = <OFF> | <MIDDLE> | <ON>;
|
SwitchState = <OFF> | <MIDDLE> | <ON>;
|
||||||
|
|
||||||
|
ItemState = SwitchState;
|
||||||
|
|
||||||
--@doc A switch, with the possible states it can be in, and the state that it is in
|
--@doc A switch, with the possible states it can be in, and the state that it is in
|
||||||
Switch ::
|
Switch ::
|
||||||
position : SwitchState
|
position : SwitchState
|
||||||
@ -95,6 +97,7 @@ types
|
|||||||
Checklist = seq of Procedure;
|
Checklist = seq of Procedure;
|
||||||
|
|
||||||
functions
|
functions
|
||||||
|
-- PROCEDURES
|
||||||
--@doc Finds the index of the next item in the procedure that needs to be completed
|
--@doc Finds the index of the next item in the procedure that needs to be completed
|
||||||
procedure_next_index: Procedure -> nat1
|
procedure_next_index: Procedure -> nat1
|
||||||
procedure_next_index(p) ==
|
procedure_next_index(p) ==
|
||||||
@ -135,6 +138,15 @@ functions
|
|||||||
pre
|
pre
|
||||||
procedure_completed(p) = false;
|
procedure_completed(p) = false;
|
||||||
|
|
||||||
|
--@doc Completes an Item in the procedure on the Aircraft
|
||||||
|
do_proc_item: ChecklistItem * Aircraft -> Aircraft
|
||||||
|
do_proc_item(p, a) ==
|
||||||
|
let itemIndex = index_of_item(p.procedure, a) in
|
||||||
|
a ++ {itemIndex |-> move_item(a(itemIndex), p.check)}
|
||||||
|
pre
|
||||||
|
p.checked = false;
|
||||||
|
|
||||||
|
-- AIRCRAFT ITEMS
|
||||||
--@doc Marks ChecklistItem as complete
|
--@doc Marks ChecklistItem as complete
|
||||||
complete_item: ChecklistItem -> ChecklistItem
|
complete_item: ChecklistItem -> ChecklistItem
|
||||||
complete_item(i) ==
|
complete_item(i) ==
|
||||||
@ -145,21 +157,33 @@ functions
|
|||||||
--@doc Find index of an item in Aircraft
|
--@doc Find index of an item in Aircraft
|
||||||
index_of_item: String * Aircraft -> nat1
|
index_of_item: String * Aircraft -> nat1
|
||||||
index_of_item(i, a) ==
|
index_of_item(i, a) ==
|
||||||
if (hd a).name = i then 1
|
if (hd a).name = i then
|
||||||
|
1
|
||||||
else
|
else
|
||||||
index_of_item(i, tl a) + 1
|
index_of_item(i, tl a) + 1
|
||||||
pre
|
pre
|
||||||
len a > 0
|
len a > 0
|
||||||
-- Checks if the last item in the aircraft is the item that is being searched for
|
-- Checks the Item being searched for is in the Aircraft
|
||||||
and (len a = 1 and a(1).name = i)
|
and i in set { a(x).name | x in set {1,...,len a} }
|
||||||
post
|
post
|
||||||
-- Checks that the index is correct
|
-- Checks that the index is correct
|
||||||
--TODO this does not check if it is the first item in the list
|
--TODO this does not check if it is the first item in the list
|
||||||
if RESULT > 1 then
|
if RESULT > 1 then
|
||||||
a(RESULT).name = i
|
a(RESULT).name = i
|
||||||
else
|
else
|
||||||
true
|
true
|
||||||
measure len a;
|
measure len a;
|
||||||
|
|
||||||
|
--@doc Moves any type of Item
|
||||||
|
move_item: Item * ItemState -> Item
|
||||||
|
move_item(i, s) ==
|
||||||
|
-- if is_Switch(i) then (implement later)
|
||||||
|
mk_Item(i.name, i.type, move_switch(i.object, s))
|
||||||
|
pre
|
||||||
|
(is_Switch(i.object) and is_SwitchState(s))
|
||||||
|
--TODO check that the item has not already been completed before moving item
|
||||||
|
--TODO add other types of Items
|
||||||
|
;
|
||||||
|
|
||||||
--@doc Moves a specific switch in the aircraft
|
--@doc Moves a specific switch in the aircraft
|
||||||
move_switch: Switch * SwitchState -> Switch
|
move_switch: Switch * SwitchState -> Switch
|
||||||
|
Loading…
x
Reference in New Issue
Block a user