I'm trying to read an array of structs from my OPC server with the .NET OPC UA SDK. I was able to read out a single struct with the following code:
Code: Select all
[UaTypeDefinition(NodeId = ObjectTypes.ServerType, NamespaceUri = "urn:PLCopen/pv/")]
internal partial class singleStructModel
{
[UaInstanceDeclaration(BrowseName = "AlarmID", NamespaceUri = "urn:PLCopen/pv/")]
public UInt16 AlarmID { get; set; }
[UaInstanceDeclaration(BrowseName = "Attribute", NamespaceUri = "urn:PLCopen/pv/")]
public Byte Attribute { get; set; }
[UaInstanceDeclaration(BrowseName = "DeviceID", NamespaceUri = "urn:PLCopen/pv/")]
public Byte DeviceID { get; set; }
[UaInstanceDeclaration(BrowseName = "HecTimeStamp", NamespaceUri = "urn:PLCopen/pv/")]
public UInt16 HecTimeStamp { get; set; }
[UaInstanceDeclaration(BrowseName = "PlattformID", NamespaceUri = "urn:PLCopen/pv/")]
public Byte PlattformID { get; set; }
[UaInstanceDeclaration(BrowseName = "Spare", NamespaceUri = "urn:PLCopen/pv/")]
public Byte Spare { get; set; }
[UaInstanceDeclaration(BrowseName = "UxTimeStamp", NamespaceUri = "urn:PLCopen/pv/")]
public UInt32 UxTimeStamp { get; set; }
}
Code: Select all
m_session.Model.RegisterMappedObject(ObjectTypeIds.ServerType, typeof(singleStructModel));
singleStructModel instance = new singleStructModel();
ModelHandle handle = ModelMapper.GetModelHandle(m_session.NamespaceUris, instance);
List<StatusCode> errors = m_session.Model.Read(new NodeId("::AsGlobalPV:HistoryBuffer[1]", m_NameSpaceIndex), handle, null);
instance = handle.Instance as singleStructModel;
Can anybody help me? Thanks in advance.