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
| Name | Type | Comment | Kind |
|---|---|---|---|
| execute | BOOL | - | input |
| pause | BOOL | - | input |
| mode | CNM_OpModeHandlingInterfaces.IModeBehaviour | - | input |
Code
Declaration
METHOD FINAL handleMode
VAR_INPUT
execute : BOOL;
pause : BOOL;
mode : CNM_OpModeHandlingInterfaces.IModeBehaviour;
END_VAR
VAR
selectMode :CNM_OpModeHandlingInterfaces.IModeBehaviour;
END_VAR
Implementation
THIS^.monitorAndUpdate();
(* either use the own overwritten mode or use the mode from the parent node *)
selectMode := SEL( THIS^.isObjectValid(THIS^.modeOverwrite), mode, THIS^.modeOverwrite );
THIS^.activeModeId := selectMode.id;
THIS^.manageEntryExit( execute := execute, mode := selectMode );
THIS^.initSubnodeFlags();
// update cycle manager
THIS^.cycleManager(execute := execute, pause := pause );
THIS^.currentNodeState := CNM_ReturnTypes.SingleExecutionState.IDLE;
// check if we have subnodes
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, selectMode );
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 := selectMode.run( execute := execute, pause := pause, node := THIS^), THIS^.currentNodeState );
THIS^.updateHmiState();
THIS^.stepSignal := FALSE;