Skip to main content

handleMode

Short Summary

This method manages the operation of a mode, handling the execution and pausing states, while coordinating with subnodes and evaluating their states. It ensures the selected mode is active and updates the node's state based on the subnodes and its own operation.

Parameters

NameTypeCommentKind
executeBOOL-input
pauseBOOL-input
modeCNM_OpModeHandlingInterfaces.IModeBehaviour-input

Code

Declaration

METHOD FINAL handleMode
VAR_INPUT
execute : BOOL;
pause : BOOL;
mode : CNM_OpModeHandlingInterfaces.IModeBehaviour;
END_VAR

Implementation

THIS^.currentNodeState := CNM_ReturnTypes.SingleExecutionState.IDLE;
THIS^.activeModeId := mode.id;
THIS^.initSubnodeFlags();
// enable manual command handling
THIS^.manualCmdsEnabled := mode.enableManCmds;
IF THIS^.isObjectValid(THIS^.subNode) THEN
// call subNodes, distribute the mode delegate and evaluate their states
THIS^.subnode.reset();
WHILE ( THIS^.subnode.moveNextNode() ) DO
THIS^.subnode.handleMode( execute, pause, mode );
THIS^.evaluateStates( newState := THIS^.subnode.nodeState, currentState := THIS^.currentNodeState );
THIS^.updateSubnodeFlags(subnode := THIS^.subnode);
END_WHILE
END_IF
// run this node and evaluate own state
THIS^.evaluateStates( newState := THIS^.run(), THIS^.currentNodeState );
THIS^.updateHmiState();