DeviceAR (FB)
FUNCTION_BLOCK DeviceAR
Update Diagnosis
PROGRAM PLC_PRG VAR ar : ProfinetCommon.DeviceAR; // FB for controlling the AR establishment i : DINT; checkExp : ProfinetCommon.CheckExpSubmodule; moduleDiffCounter : DINT; prmDelay : TON; // some delay for parameterizing the device (example) output : DINT; // a counter variable END_VAR ar(xEnable := TRUE, DeviceID := pnDevice.DeviceID); IF(ar.xAborted) THEN // connection has been aborted ar(xConfirmConnect := FALSE, xConfirmPrmEnd := FALSE, xApplReady := FALSE); //reset commands moduleDiffCounter := 0; // reset counter prmDelay(IN := FALSE); // reset timer ELSIF(ar.xData) THEN // connection estblishment phase sucessful, AR in data exchange output := output + 1; ELSIF(ar.xConnect) THEN // received Connect-req., the AR establishment started IF(NOT ar.xConfirmConnect) THEN // not yet confirmed ? // check submodule config the controller expects: checkExp(xEnable := TRUE, AR_ID := ar.AR_ID); FOR i := 0 TO checkExp.ExpectedSubmoduleCount - 1 DO checkExp(Index := i); IF(checkExp.xModuleDiff) THEN //some module mismatch, see details moduleDiffCounter := moduleDiffCounter + 1; // count mismatching modules END_IF END_FOR ar(xConfirmConnect := TRUE); // confirm Connect-req. from controller END_IF IF(ar.xPrmEnd) THEN // received PrmEnd-req. from controller ar(xConfirmPrmEnd := TRUE); // confirm PrmEnd-req. prmDelay(IN := TRUE, PT := T#2S); // start prm-delay timer END_IF prmDelay(); IF(prmDelay.Q) THEN // timer expired ar(xApplReady := TRUE); // Send Application-Ready to Controller --> AR will get into 'Data' state END_IF END_IF
- InOut:
Scope
Name
Type
Initial
Comment
Input
xEnableBOOLEnable function
DeviceIDBYTEID of the Profinet Device in the local Profinet Device application.
xConfirmConnectBOOLSend Connect-cnf to controller
xConfirmPrmEndBOOLSend PrmEnd confirmation to controller
xApplReadyBOOLSend Application-Ready to controller
Output
xBusyBOOLDeviceAR is operating and will receive connection related request and events.
xErrorBOOLDeviceAR does not operate due to internal error.
AR_IDDWORDCommFB.Constants.INVALID_ID
ID of this AR endpoint.
AR_StatusStatus of this AR endpoint.
xConnectBOOLReceived Connect-Req. from Controller.
xPrmEndBOOLReceived PrmEnd-Ind from Controller: All data-records / parameters have been transmitted.
xDataBOOLAR is in Data-Exchange
xAbortedBOOLAR has been Aborted. (Abort reason see PNIOStatus)
PNIOStatusUDINTProfinet specific protocol status/error code.
ARInfoSome information on the current AR
Methods:
CM_Abort_req
Structure: