Skip to main content

OpModeHandler

Short Summary

This class distributes node requests and operation modes to the node tree. It automatically enables/disables all nodes depending on the safety release.

Attention:: the run method should be called cyclically!

AccessAbstractFinalExtendsImplements
NoYesCNM_AbstractObject.ObjectCNM_OpModeHandlingInterfaces.IOpModeHandler

UML Diagram

Parameters

none

Properties

className

Type: CNM_AbstractObject.ClassName

This abstract property returns the class name of the concrete object,

globalMessageService

Type: CNM_MessageInterfaces.IMessageService

This property can be used to inject a message service. Messages will be forwarded to that message service if it is set.

globalOverride

Type: LREAL

This property can be used to set the global override from the HMI and to read back the current override for the HMI.

isSwitchedOn

Type: BOOL

This property indicates that the unit is enabled and all safety requirements are met.

modeIsExecuting

Type: BOOL

This property indicates that a operation is being executed.

pause

Type: BOOL

This property can be used to pause the currently running operation mode from the HMI and to read back if the mode is paused.

requests

Type: CNM_OpModeHandlingInterfaces.INodeRequestProvider

This property returns fluent interfaces for the default node requests: disable, enable, initialize and stopImmediate.

rootnode

Type: CNM_OpModeHandlingInterfaces.INode

This property returns the INodeHmiApi interface of the root node from this opmode handler.

Methods

enableStepping

This methods enables the stepping operation on a given node and all of its subnodes.

FB_init

  • Parameters:
    • bInitRetains (BOOL): if TRUE, the retain variables are initialized (warm start / cold start)
    • bInCopyCode (BOOL): if TRUE, the instance afterwards gets moved into the copy code (online change)
    • rootNode (INodeApi): first node, e.g. Workflow or Station (can be 0)
    • safety (CNM_OpModeHandlingInterfaces.ISafetyReleaseDistributor): safety to subscribe
  • Return type: BOOL

The constructor FB_init is needed to create an unique hash code.

run

  • Return type: VOID

This method should be called in every cycle as it calls recursively every single node in the hierarical composition tree.

setMode

  • Parameters:
    • mode (CNM_OpModeHandlingInterfaces.IModeBehaviour): the mode instance that should be set
    • node (CNM_OpModeHandlingInterfaces.IModeNode): optionally: a specified node in the tree that is not the subtree (if 0, the rootNode will be adressed)
  • Return type: CNM_ReturnTypes.SingleExecutionResult

This method sets a mode for the rootnode or, if specified, for a single node and its subnodes.

setReferences

  • Return type: VOID

This method distributes the global control signals to the node tree.

startMode

  • Parameters:
    • node (CNM_OpModeHandlingInterfaces.INode): optionally: a specified node in the tree that is not the subtree (if 0, the rootNode will be adressed)
  • Return type: CNM_ReturnTypes.SingleExecutionResult

This method starts the currently selected operation mode if all safety requirements are met.

stopMode

  • Parameters:
    • immediately (BOOL): if this flag is set, the current operation mode will be aborted and the machine will execute a fast stop
  • Return type: CNM_ReturnTypes.SingleExecutionState

This method stops the currently running operation mode.

switchOff

  • Return type: VOID

This method disables the unit if not all safety requirements are met. It Should be called only from the safety management.

switchOn

  • Return type: VOID

This method enables the unit if all safety requirements are met. It Should be called only from the safety management.

Code

Declaration

FUNCTION_BLOCK FINAL OpModeHandler EXTENDS CNM_AbstractObject.Object IMPLEMENTS CNM_OpModeHandlingInterfaces.IOpModeHandler
VAR
root :INodeApi;
runMode :BOOL := FALSE;
pauseMode :BOOL := FALSE;
steppingEnabled :BOOL := FALSE;
(* this mode delegate does just nothing, but will be passed through all nodes to make sure the cyclic nodes are called *)
idleMode :EmptyMode;
currentMode :CNM_OpModeHandlingInterfaces.IModeBehaviour := THIS^.idleMode;
safetyRelease :BOOL;
enableTrigger :R_TRIG;
disableTrigger :F_TRIG;
stopTrigger :Tc2_Standard.R_TRIG;
modeControlGlobal :CNM_OpModeHandlingInterfaces.NodeHandlerControlStruct := (override := 100.0);
messageService :OperationHandlerMessageService(THIS^);
stopImmediateRequired :BOOL := FALSE;
modeRunning :BOOL;
END_VAR