import { LoadedMachineConfiguration } from "../../src/types"; import { StateMachine } from "../../src/state-machines/state-machine"; export class VR_METRO_TRAIN_STOP_V2_STATE_MACHINE extends StateMachine { constructor(options: LoadedMachineConfiguration) { const { context } = options; super([ { "context": { "errorCounter": 0, "stop": 0, "stopCounter": 0, ...context }, "id": "VR_METRO_TRAIN_STOP_V2", "initial": "ready", "states": { "END_TASK": { "exit": [], "meta": { "VR": [ { "name": "task_completed" } ] }, "on": { "INSTANT": "end" }, "type": "" }, "IDLE": { "exit": [], "meta": {}, "on": { "INSTANT": [ { "actions": [ "stopINCREMENT" ], "cond": "", "target": "TRANSIT" } ] }, "type": "" }, "NEGATIVE_REINFORCEMENT": { "exit": [], "meta": { "VR": [ { "name": "negative_reinforcement" } ] }, "on": { "INSTANT": "TRANSIT" }, "type": "" }, "POSITIVE_REINFORCEMENT": { "exit": [], "meta": { "VR": [ { "name": "positive_reinforcement" } ] }, "on": { "INSTANT": "TRANSIT" }, "type": "" }, "STOP": { "exit": [], "meta": { "CA": { "utterance": "ASK_FOR_STOP" } }, "on": { "AFFIRMATIVE": [ { "actions": [ "" ], "cond": "stopCounterLOWERcontext_stationsList_length", "target": "NEGATIVE_REINFORCEMENT" }, { "actions": [ "" ], "cond": "stopCounterEQUALcontext_stationsList_length", "target": "END_TASK" } ], "NEGATIVE": [ { "actions": [ "" ], "cond": "stopCounterLOWERcontext_stationsList_length", "target": "POSITIVE_REINFORCEMENT" } ], "SILENT": [ { "actions": [ "" ], "cond": "stopCounterLOWERcontext_stationsList_length", "target": "POSITIVE_REINFORCEMENT" } ] }, "type": "" }, "TRANSIT": { "exit": [], "meta": { "VR": [ { "name": "loop" } ] }, "on": { "MOVE(*)": [ { "actions": [ "stopINCREMENT" ], "cond": "", "target": "STOP" } ] }, "type": "" }, "end": { "exit": [], "meta": { "VR": [ { "name": "task_completed" } ] }, "on": { "INSTANT": "end" }, "type": "final" }, "ready": { "exit": [], "meta": {}, "on": { "READY": "IDLE" }, "type": "" } } }, { actions: { stopINCREMENT: (context:any) => {context.stop=context.stationsList[context.stopCounter]; context.stopCounter++; ;} }, guards: { stopCounterEQUALcontext_stationsList_length: (context:any) => {return context.stopCounter === context.stationsList.length;}, stopCounterLOWERcontext_stationsList_length: (context:any) => {return context.stopCounter < context.stationsList.length;} } } ]); } }