Skip to main content

setMode

Short Summary

This method sets a mode for the rootnode or, if specified, for a single node and its subnodes.
It is only allowed to overwrite the mode if the rootNode or the specified node is not in busy state.

Example

set it for the whole machine:
myOpmodeHandler.setMode(
mode := automaticMode
);

overwrite the mode of specified node:
myOpmodeHandler.setMode(
mode := serviceMode,
node := despensingUnit
);

Parameters

NameTypeCommentKind
modeCNM_OpModeHandlingInterfaces.IModeBehaviourthe mode instance that should be setinput
nodeCNM_OpModeHandlingInterfaces.IModeNodeoptionally: a specified node in the tree that is not the subtree (if 0, the rootNode will be adressed)input

Code

Declaration

METHOD setMode :CNM_ReturnTypes.SingleExecutionResult
VAR_INPUT
(* the mode instance that should be set *)
mode : CNM_OpModeHandlingInterfaces.IModeBehaviour;
(* optionally: a specified node in the tree that is not the subtree (if 0, the rootNode will be adressed) *)
node : CNM_OpModeHandlingInterfaces.IModeNode := 0;
END_VAR
VAR
exc : __SYSTEM.ExceptionCode;
END_VAR

Implementation

setMode := CNM_ReturnTypes.SingleExecutionResult.ABORTED;
RETURN (THIS^.isObjectNull(mode));
IF (THIS^.root.nodeState <> CNM_ReturnTypes.SingleExecutionState.BUSY) THEN
IF THIS^.isObjectValid(node) THEN
node.overwriteMode(mode);
ELSE
THIS^.root.resetLocalModes();
THIS^.currentMode := mode;
END_IF
THIS^.pauseMode := FALSE;
setMode := CNM_ReturnTypes.SingleExecutionResult.SUCCESS;
END_IF