Skip to main content

startModeStep

Short Summary

This method starts the operation mode if the start button from the HMI is pressed.

  • Return type: DINT

Parameters

none

Code

Declaration

METHOD PRIVATE startModeStep : DINT
VAR
modeNode :CNM_OpModeHandlingInterfaces.IModeNode;
END_VAR

Implementation

startModeStep := START_MODE;
// clear stepping on all nodes
THIS^.modeHandler.rootNode.enableStepping := FALSE;
THIS^.enableModeSelection := TRUE;
IF (THIS^.nodeSelectionChanged OR_ELSE (THIS^.nextOpMode <> THIS^.currentOpMode)) THEN
startModeStep := SELECT_MODE;
RETURN;
END_IF

THIS^.buttons.Start.enabled :=
THIS^.enableModeSelection := (
(THIS^.selectedNode = THIS^.modeHandler.rootNode)
OR_ELSE __QUERYINTERFACE(THIS^.selectedNode, modeNode)
);

IF (THIS^.buttons.Start.pressed) THEN
IF THIS^.modeHandler.rootNode <> THIS^.selectedNode THEN
// set all nodes to no operation
THIS^.modeHandler.setMode(mode := THIS^.getMode(OpMode.NO_OPERATION));
// override the selected node and its subtree
THIS^.selectModeStep();
END_IF

IF THIS^.modeHandler.startMode() = CNM_ReturnTypes.SingleExecutionResult.SUCCESS THEN
// set buttons
THIS^.enableModeSelection := FALSE;
THIS^.currentNode := THIS^.selectedNode;
THIS^.buttons.Start.enabled := FALSE;
THIS^.buttons.Stop.enabled := TRUE;
THIS^.buttons.StopRequest.enabled := TRUE;
THIS^.buttons.Pause.visible := TRUE;
THIS^.buttons.StepMode.visible := TRUE;
THIS^.pause := FALSE;
startModeStep := RUN_MODE;
END_IF
END_IF