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
);
- Return type: CNM_ReturnTypes.SingleExecutionResult
Parameters
| Name | Type | Comment | Kind |
|---|---|---|---|
| mode | CNM_OpModeHandlingInterfaces.IModeBehaviour | the mode instance that should be set | input |
| node | CNM_OpModeHandlingInterfaces.IModeNode | optionally: 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