Read Array of Struct from Server
Posted: 26 Sep 2013, 10:18
Hello guys!
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:
As you see on this second snipped, i'm addressing the array position [1] directly while creating the NodeId. Unfortunately, this array has 10'000 members... I'm searching for a command to read out this array of structs directly in an ArrayList for example.
Can anybody help me? Thanks in advance.
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.