Read Array of Struct from Server

Questions regarding the use of the .NET SDK 2.0 for Server or Client development or integration into customer products ...

Moderator: uasdknet

Post Reply
stefan.guillebeau
Jr. Member
Jr. Member
Posts: 1
Joined: 26 Sep 2013, 08:37

Read Array of Struct from Server

Post by stefan.guillebeau »

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:

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;
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.

User avatar
Support Team
Hero Member
Hero Member
Posts: 2666
Joined: 18 Mar 2011, 15:09

Re: Read Array of Struct from Server

Post by Support Team »

Hello Stefan,

currently the requested feature is not supported. We are considering it for some future version, but it has minor priority, because it is comfort functionality on a rare use case only.

Best Regards
Support Team

Post Reply