Module sopExecutor

Contains the logic for executing a checklist.

A SOP needs to be set in order to execute a checklist. Any checklist of the active SOP can be started or stopped at any time. The state of the active checklist and its checklist items is updated during execution. All the required sounds are played using the active voices of the SOP. Execution of a checklist can be paused and resumed.

The update function needs to be called regularly to continue the execution of the current checklist.

Callbacks can be added to react to SOPs getting activated and deactivated, checklists being started, cancelled and completed and checklist items getting started, failed and completed.

Info:

  • Copyright: 2022 Patrick Lang
  • Author: Patrick Lang

Functions

setExecutionMode (number) Sets the execution mode.
getExecutionMode () Gets the current execution mode.
setActiveSOP (sop) Sets the active standard operating procedure.
getActiveSOP () Gets the active standard operating procedure.
startChecklist (checklist) Starts the execution of a checklist.
stopChecklist () Stops the execution of the active checklist.
doOften () Executes the do_often callback of the active SOP.
doEveryFrame () Executes the do_every_frame callback of the active SOP.
update () Executes the active SOP and its checklist.
pause () Pauses the execution of a checklist.
resume () Resumes the execution of a checklist.
isPaused () Checks whether execution of the checklist is currently paused.
setCurrentChecklistItemDone () Sets the current checklist item to manually done.
setResponseDelay (delay) Sets the delay for playing the response sound.
getResponseDelay () Gets the delay for playing the response sound.
setNextChecklistItemDelay (delay) Sets the delay for the execution of the next checklist item.
getNextChecklistItemDelay () Gets the delay for the execution of the next checklist item.
setVoiceVolume (volume) Sets the volume of the challenge and response voices.
getVoiceVolume () Gets the volume of the challenge and response voices.
addSOPActivatedCallback (callback) Adds a callback which is executed if a SOP is activated.
addSOPDeactivatedCallback (callback) Adds a callback which is executed if a SOP is deactivated.
addChecklistStartedCallback (callback) Adds a callback which is executed if a checklist is started.
addChecklistCancelledCallback (callback) Adds a callback which is executed if a checklist is cancelled.
addChecklistCompletedCallback (callback) Adds a callback which is executed if a checklist is completed.
addChecklistItemStartedCallback (callback) Adds a callback which is executed if a checklist item is started.
addChecklistItemFailedCallback (callback) Adds a callback which is executed if a checklist item has failed.
addChecklistItemCompletedCallback (callback) Adds a callback which is executed if a checklist item is completed.


Functions

setExecutionMode (number)
Sets the execution mode.

Supported modes:

0: Default execution mode. Automatic checks are performed and manual checklist items needs to be completed manually. 1: Auto Done. Automatic checks are performed and manual checklist items are automatically completed. 2: Manual. No automatic checks are performed and each checklist item needs to be completed manually. Also does not play any response sound.

Parameters:

  • number mode The new execution mode.
getExecutionMode ()
Gets the current execution mode.

Returns:

    number The current execution mode.
setActiveSOP (sop)
Sets the active standard operating procedure. This deactivates the previously active standard operating procedure.

Parameters:

Raises:

An error is thrown if the standard operating procedure has no active challenge voice or no active response voice set.
getActiveSOP ()
Gets the active standard operating procedure.

Returns:

    optional standardOperatingProcedure The active standard operating procedure.
startChecklist (checklist)
Starts the execution of a checklist. The checklist must be part of the active SOP. If there has already been a checklist started, then the previous execution is stopped.

Parameters:

  • checklist checklist The checklist to execute.

Raises:

An error is thrown if there is no active SOP or the checklist does not belong to the active SOP.
stopChecklist ()
Stops the execution of the active checklist. It also resets the pause of the active checklist. This function does nothing if no checklist has been started.
doOften ()
Executes the do_often callback of the active SOP. This function does nothing if no SOP has been activated.
doEveryFrame ()
Executes the do_every_frame callback of the active SOP. This function does nothing if no SOP has been activated.
update ()
Executes the active SOP and its checklist. This function needs to be called regularly in order to execute the checklist. This function does nothing if no SOP has been activated, no checklist has been started or the execution is paused.
pause ()
Pauses the execution of a checklist. This function does nothing if no checklist has been started.
resume ()
Resumes the execution of a checklist. This function does nothing if the execution is not paused.
isPaused ()
Checks whether execution of the checklist is currently paused.

Returns:

    bool True if the execution is paused, otherwise false.
setCurrentChecklistItemDone ()
Sets the current checklist item to manually done. This function does nothing if there is no checklist item active. It can be used to complete the manual checklist items or to skip failed automatic checklist items.
setResponseDelay (delay)
Sets the delay for playing the response sound. This also delays the evaluation of the checklist item.

Parameters:

  • delay number The delay to use in seconds. Must be greater or equal to zero.
getResponseDelay ()
Gets the delay for playing the response sound.

Returns:

    number The currently used delay.
setNextChecklistItemDelay (delay)
Sets the delay for the execution of the next checklist item.

Parameters:

  • delay number The delay to use in seconds. Must be greater or equal to zero.
getNextChecklistItemDelay ()
Gets the delay for the execution of the next checklist item.

Returns:

    number The currently used delay.
setVoiceVolume (volume)
Sets the volume of the challenge and response voices. A value of 1 means 100% (full volume), a value of 0.5 means 50% (half the volume).

Parameters:

  • volume numer The volume to use.
getVoiceVolume ()
Gets the volume of the challenge and response voices. A value of 1 means 100% (full volume), a value of 0.5 means 50% (half the volume).

Returns:

    number The currently used volume.
addSOPActivatedCallback (callback)
Adds a callback which is executed if a SOP is activated. The activated SOP is passed as parameter to the callback.

Parameters:

  • callback func The callback to add.

Usage:

    sopExecutor.addSOPActivatedCallback(function(sop) end)
addSOPDeactivatedCallback (callback)
Adds a callback which is executed if a SOP is deactivated. The SOP is passed as parameter to the callback.

Parameters:

  • callback func The callback to add.

Usage:

    sopExecutor.addSOPDeactivatedCallback(function(sop) end)
addChecklistStartedCallback (callback)
Adds a callback which is executed if a checklist is started. The started checklist and the active SOP are passed as parameters to the callback.

Parameters:

  • callback func The callback to add.

Usage:

    sopExecutor.addChecklistStartedCallback(function(checklist, sop) end)
addChecklistCancelledCallback (callback)
Adds a callback which is executed if a checklist is cancelled. The cancelled checklist and the active SOP are passed as parameters to the callback.

Parameters:

  • callback func The callback to add.

Usage:

    sopExecutor.addChecklistCancelledCallback(function(checklist, sop) end)
addChecklistCompletedCallback (callback)
Adds a callback which is executed if a checklist is completed. The completed checklist and the active SOP are passed as parameters to the callback.

Parameters:

  • callback func The callback to add.

Usage:

    sopExecutor.addChecklistCompletedCallback(function(checklist, sop) end)
addChecklistItemStartedCallback (callback)
Adds a callback which is executed if a checklist item is started. The started checklist item, its checklist and the active SOP are passed as parameters to the callback.

Parameters:

  • callback func The callback to add.

Usage:

    sopExecutor.addChecklistItemStartedCallback(function(checklistItem, checklist, sop) end)
addChecklistItemFailedCallback (callback)
Adds a callback which is executed if a checklist item has failed. The failed checklist item, its checklist and the active SOP are passed as parameters to the callback.

Parameters:

  • callback func The callback to add.

Usage:

    sopExecutor.addChecklistItemFailedCallback(function(checklistItem, checklist, sop) end)
addChecklistItemCompletedCallback (callback)
Adds a callback which is executed if a checklist item is completed. The completed checklist item, its checklist and the active SOP are passed as parameters to the callback.

Parameters:

  • callback func The callback to add.

Usage:

    sopExecutor.addChecklistItemCompletedCallback(function(checklistItem, checklist, sop) end)
generated by LDoc 1.4.6 Last updated 2022-05-28 12:58:52