How can I read pending diagnostic in PLC

I already checked the examples described in the forum. 

/ctrlx-plc-ctxo5cm7/post/cxa-datalayer-how-to-write-a-flatbuffer-dlKyajQncuYip4N

But all examples described here, have methods, which returns a "pointer to real" or "pointer to string", ... so an easy datatype.

 

My task is, to read the pending diagnostic and in this case, the method returns an object "pointer to DiagnosticInformation from the table"

And I donĀ“t know, how to get access to this returned table. I have no chance to the information to the returned diagnostic string.

HereĀ“s my example:

Declaration:

 

PROGRAM PLC_PRG2
VAR
 	strMyInstancename : STRING := 'MyInstance';
	bRead: BOOL;
	bExecute: BOOL;
	strNodePath: STRING(255) := 'diagnosis/get/actual/log';
	fbDL_ReadNodeValue: DL_ReadNodeValue;
	DataRead: CXA_Datalayer.DL_NodeValue;	
	fbDiagInfo : CXA_AutomationCore_fbs.common_log_diagnosis_fbs_DiagnosisIdentificationWithTimestamp;
	
	pendingDiag: CXA_AutomationCore_fbs.common_log_diagnosis_fbs_DiagnosisIdentification;
	strTimeStamp: STRING;
	pendingDiag2: POINTER TO CXA_AutomationCore_fbs.common_log_diagnosis_fbs_DiagnosisIdentification;
END_VAR

 

Implementation:

 

IF bRead THEN
	bRead := FALSE;
	bExecute := TRUE;
END_IF	
IF fbDL_ReadNodeValue.Done THEN	
	fbDiagInfo.getRootAsDiagnosisIdentificationWithTimestamp(data:= DataRead.GetData(), size:= DataRead.GetSize());
	
	pendingDiag2 := fbDiagInfo.getDiagnosisIdentification();
	pendingDiag := pendingDiag2^;
	
	strTimeStamp := fbDiagInfo.getTimestamp();
	bExecute := FALSE;
END_IF

fbDL_ReadNodeValue(
	Execute:= bExecute, ClientId:= , NodeName:= strNodePath, NodeValue:= DataRead);

 

 

I get access to the Pointer, but I donĀ“t know, how to get access to special content of this table:

What can i do to see the actual diagnostic?

 

Best reply by HellCoder

IĀ“ve got in on my own.

You have to extend the code with: 

	myDiagnosisNumber := pendingDiag.getMainDiagnosisNumber();
	myDetailDiagnosis := pendingDiag.getDetailedDiagnosisNumber();
	
	myDiagTimestamp           := fbDiagInfo.getTimestamp();

You have to use the pointer you return from method fbDiagInfo.getDiagnosisIndentification() to call additional methods.

For example "pendingDiag.getMainDiagnosisNumber()" to get the diagnosis number.  

View original
5 replies