IF NOT xInitGraphConveyor1 THEN
preCondition1(in_name:='Conveyor1WPAtRamp1',in_value:=FALSE); preCondition2(in_name:='Conveyor1SensorStart',in_value:=TRUE); preConditionArray.addObject(preCondition1); preConditionArray.addObject(preCondition2); postCondition1(in_name:='Conveyor1WPAtRamp1',in_value:=TRUE); postCondition2(in_name:='Conveyer1Pusher1MovedIn',in_value:=TRUE); postConditionArray.addObject(postCondition1); postConditionArray.addObject(postCondition2); oper(in_name:='Conveyor1TransportWPToRamp1',in_operation:='Conveyor1TransportWPToRamp1',in_preConditions:=preConditionArray,in_postConditions:=postConditionArray,in_inverseOperation:='Conveyor1TransportWPBackToStart',in_isRecoveryState:=TRUE); nextGraphElem.addObject('End'); previousGraphElem.addObject('Start'); graphElem(in_name:='Conveyor1TransportWPToRamp1',in_dataType:=tOPERATION,in_nextElements:=nextGraphElem,in_previousElements:=previousGraphElem); graphElem.operation:=oper; graphElemArray.addObject(graphElem);
graphConveyor1(in_allGraphElements:=graphElemArray,in_name:='Conveyor1TransportWPToRamp1');
xInitGraphConveyor1 := TRUE;
END_IF
execute := tOPERATING; isStopped := FALSE; holdingTimer(IN:=FALSE,PT:=T#2S);
currentGraphElementArray := graphConveyor1.getCurrentNodes(); allGraphElementArray := graphConveyor1.getAllGraphElements(); graphConveyor1.updateCurrentNodes();
FOR i:=1 TOcurrentGraphElementArray.numberOfObjects() BY 1 DO graphElement := currentGraphElementArray.objectAtIndex(i); operation := graphElement.operation;
IFoperation.getOperation() = 'Conveyor1TransportWPToRamp1' THEN operationState := THIS^.transportWPToRamp1(); END_IF
IFoperationState = tOPERATINGTHEN graphElement.timeUpdated := FALSE; graphElement.updateTimer(); ELSIFoperationState = tFINISHEDTHEN IF NOTgraphElement.timeUpdatedTHEN
timeOperation := operation.timeOperation; timeOperation.updateTime(graphElement.returnTime()); operation.timeOperation := timeOperation; graphElement.timeUpdated := TRUE; graphElement.operation := operation; graphElement.resetTimer(); allGraphElementArray.replaceObject(graphElement); graphConveyor1.setAllGraphElements(allGraphElementArray);
END_IF END_IF
currentTimeOperation := graphElement.returnTime(); timeOperation := operation.timeOperation; averageTimeOperation := timeOperation.getAverage();
IFaverageTimeOperation> 1 THEN IF currentTimeOperation> (averageTimeOperation + 200) THEN errorDetected := TRUE; ELSE errorDetected := errorDetected OR FALSE; END_IF END_IF
graphConveyor1.updateCurrentGraphElement(graphElement);
END_FOR
IFerrorDetectedTHEN execute := tERROR; ELSIFgraphConveyor1.isFinished() THEN execute := tFINISHED; END_IF |