FUNCTION_BLOCK DiagnosisDataBuffer
This function block is be used for reading the diagnosis data which is received from a profinet device.
Example: check diagnosis data of a device
PROGRAM PLC_PRG VAR diagBuffer : ProfinetCommon.DiagnosisDataBuffer; slot : UINT; channelError : ProfinetCommon.ChannelErrorType := 0; i : DINT; END_VAR diagBuffer(xEnable := pnDevice.xDiagnosis, ID := pnDevice.ID, DiagnosisIndex := 0); // check diagnosis of device 'pnDevice' IF(diagBuffer.UpdatedDiagnosis) THEN // some diagnosis data changed ? FOR i := 0 TO diagBuffer.DiagnosisCount - 1 DO // iterate all diagnosis entries diagBuffer(DiagnosisIndex := i); // select next Diagnosis Entry that shall be shown in outputs IF(diagBuffer.IsStandardFormat) THEN //e.g slot 2 has channel error 'Line Break' slot := diagBuffer.Source.Slot; channelError := diagBuffer.Diagnosis.ChannelErrorType; END_IF END_FOR diagBuffer.DiagnosisIndex := 0; //reset to first entry END_IF
InOut: |
|