Hello,
From the documentation on DL_ReadNode: "This function must only be used on simple data types! For complex types please use DL_ReadNodeValue(). To use this function correctly you need to know the type of the returned value. If you don’t know the value type, the DL_ReadNodeValue() function will provide a NodeValue-object which can be used to request the specific type."
In your case, you will need to include the CXA_AUTOMATIONCORE_FBS library to access the system state flatbuffer definitions.
Here is an example...
Declaration:
PROGRAM PLC_PRG
VAR
Result: CXA_Datalayer.DL_RESULT;
m_fbReadNodeValue: CXA_Datalayer.DL_ReadNodeValue;
m_Execute : BOOL;
m_NodeValue : DL_NodeValue;
m_address : STRING;
fbs_system_state: common_systemhandler_fbs_CurrentState;
get_system_state: common_systemhandler_fbs_State;
END_VAR
Implementation:
m_address := 'system/state';
m_Execute := TRUE;
m_fbReadNodeValue(Execute:= m_Execute, NodeName:= m_address, NodeValue:= m_NodeValue);
IF m_fbReadNodeValue.Done = TRUE THEN
get_system_state.getRootAsState(m_NodeValue.GetData(), m_NodeValue.GetSize());
fbs_system_state := get_system_state.getState();
END_IF
IF (m_fbReadNodeValue.Done = TRUE) OR (m_fbReadNodeValue.Error = TRUE) THEN
m_Execute := FALSE;
m_fbReadNodeValue(Execute:= m_Execute, NodeName:= m_address, NodeValue:= m_NodeValue);
END_IF
See DL-ReadNode-DL-ReadNodeValue-in-CoDeSys for additional discussion on this topic.
... View more