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
xEnable
BOOL
Enable function
DeviceID
BYTE
ID of the Profinet Device in the local Profinet Device application.
xConfirmConnect
BOOL
Send Connect-cnf to controller
xConfirmPrmEnd
BOOL
Send PrmEnd confirmation to controller
xApplReady
BOOL
Send Application-Ready to controller
Output
xBusy
BOOL
DeviceAR is operating and will receive connection related request and events.
xError
BOOL
DeviceAR does not operate due to internal error.
AR_ID
DWORD
CommFB.Constants.INVALID_ID
ID of this AR endpoint.
AR_Status
Status of this AR endpoint.
xConnect
BOOL
Received Connect-Req. from Controller.
xPrmEnd
BOOL
Received PrmEnd-Ind from Controller: All data-records / parameters have been transmitted.
xData
BOOL
AR is in Data-Exchange
xAborted
BOOL
AR has been Aborted. (Abort reason see PNIOStatus)
PNIOStatus
UDINT
Profinet specific protocol status/error code.
ARInfo
Some information on the current AR