Skip to main content

evaluate

Short summary

This method evaluates an execution state to calculate the next step.

Parameters

NameTypeCommentKind
stateCNM_ReturnTypes.SingleExecutionStatethe state which is to be evaluatedinput
errorStepDINTstep to proceed with in case of errorinput

Code

Declaration

METHOD evaluate
VAR_INPUT
(* the state which is to be evaluated *)
state :CNM_ReturnTypes.SingleExecutionState;
(* step to proceed with in case of error *)
errorStep :DINT := CNM_ReturnTypes.DefaultSteps.STEP.ERROR;
END_VAR

Implementation

THIS^.registeredEval := TRUE;

RETURN (
THIS^.wasError
OR_ELSE
(THIS^.state <> CNM_ReturnTypes.SingleExecutionState.BUSY)
OR_ELSE
NOT THIS^.executeStep
);

CASE state OF
CNM_ReturnTypes.SingleExecutionState.ERROR, CNM_ReturnTypes.SingleExecutionState.ABORTED:
THIS^.wasError := TRUE;
THIS^.wasSuccess := FALSE;
IF ((errorStep <> CNM_ReturnTypes.DefaultSteps.STEP.ERROR)
AND_THEN (errorStep <> THIS^.currentErrorStep)
) THEN
THIS^.currentErrorStep := errorStep;
END_IF
CNM_ReturnTypes.SingleExecutionState.BUSY:
THIS^.wasNotSuccess := TRUE;
IF(NOT THIS^.wasError)THEN
THIS^.wasSuccess := FALSE;
END_IF
CNM_ReturnTypes.SingleExecutionState.SUCCESS:
IF(NOT THIS^.wasError AND NOT THIS^.wasNotSuccess)THEN
THIS^.wasSuccess := TRUE;
END_IF
CNM_ReturnTypes.SingleExecutionState.IDLE, CNM_ReturnTypes.SingleExecutionState.PAUSED:
THIS^.wasNotSuccess := TRUE;
IF(NOT THIS^.wasError)THEN
THIS^.wasSuccess := FALSE;
END_IF
END_CASE