import { LoadedMachineConfiguration } from "../../src/types"; import { StateMachine } from "../../src/state-machines/state-machine"; export class VR_SELECT_STATE_MACHINE extends StateMachine { constructor(options: LoadedMachineConfiguration) { const { context } = options; super([ { "context": { "errorCounter": 0, ...context }, "id": "VR_SELECT", "initial": "ready", "states": { "DOUBT": { "exit": [], "meta": { "CA": { "utterance": "ARE_YOU_SURE" } }, "on": { "AFFIRMATIVE": "WARNING", "NEGATIVE": "GOAL", "SELECT(target)": "POSITIVE_REINFORCEMENT", "SILENT": "GOAL" }, "type": "" }, "GOAL": { "exit": [], "meta": { "CA": { "utterance": context.intro || "SELECT_AT" } }, "on": { "INSTANT": [ { "actions": [ "" ], "cond": "errorCounterGREATER5", "target": "NEGATIVE_REINFORCEMENT" } ], "SELECT(*)": "DOUBT", "SELECT(target)": "POSITIVE_REINFORCEMENT" }, "type": "" }, "NEGATIVE_REINFORCEMENT": { "exit": [], "meta": { "CA": { "utterance": "NEGATIVE_REINFORCEMENT" }, "VR": [ { "name": "task_completed" }, { "name": "negative_reinforcement" } ] }, "on": { "INSTANT": "end" }, "type": "" }, "POSITIVE_REINFORCEMENT": { "exit": [], "meta": { "CA": { "utterance": "POSITIVE_REINFORCEMENT" }, "VR": [ { "name": "task_completed" }, { "name": "positive_reinforcement" } ] }, "on": { "INSTANT": "end" }, "type": "" }, "WARNING": { "exit": [], "meta": { "CA": { "utterance": "ATTENTION" } }, "on": { "INSTANT": [ { "actions": [ "errorCounterINCREMENT" ], "cond": "", "target": "GOAL" } ] }, "type": "" }, "end": { "exit": [], "meta": { "VR": [ { "name": "task_completed" } ] }, "on": { "INSTANT": "end" }, "type": "final" }, "ready": { "exit": [], "meta": {}, "on": { "READY": "GOAL" }, "type": "" } } }, { actions: { errorCounterINCREMENT: (context:any) => {context.errorCounter++;} }, guards: { errorCounterGREATER5: (context:any) => {return context.errorCounter > 5;} } } ]); } }