@@ -70,7 +70,7 @@ def test_custom_structs(self):
7070 #self.GuidValue = uuid.uudib"14"
7171 v .ByteStringValue = b"fifteen"
7272 v .XmlElementValue = ua .XmlElement ("<toto>titi</toto>" )
73- v .NodeIdValue = ua .NodeId ("ns=4;i=9999" )
73+ v .NodeIdValue = ua .NodeId . from_string ("ns=4;i=9999" )
7474 #self.ExpandedNodeIdValue =
7575 #self.QualifiedNameValue =
7676 #self.LocalizedTextValue =
@@ -87,6 +87,54 @@ def test_custom_structs(self):
8787 v2 = s .ScalarValueDataType .from_binary (ua .utils .Buffer (data ))
8888 self .assertEqual (v .NodeIdValue , v2 .NodeIdValue )
8989
90+ def test_custom_structs_array (self ):
91+ xmlpath = "tests/example.bsd"
92+ c = StructGenerator (xmlpath , "structures.py" )
93+ c .run ()
94+ import structures as s
95+
96+ # test with default values
97+ v = s .ArrayValueDataType ()
98+ data = v .to_binary ()
99+ v2 = s .ArrayValueDataType .from_binary (ua .utils .Buffer (data ))
100+
101+
102+ # set some values
103+ v = s .ArrayValueDataType ()
104+ v .SbyteValue = [1 ]
105+ v .ByteValue = [2 ]
106+ v .Int16Value = [3 ]
107+ v .UInt16Value = [4 ]
108+ v .Int32Value = [5 ]
109+ v .UInt32Value = [6 ]
110+ v .Int64Value = [7 ]
111+ v .UInt64Value = [8 ]
112+ v .FloatValue = [9.0 ]
113+ v .DoubleValue = [10.0 ]
114+ v .StringValue = ["elleven" ]
115+ v .DateTimeValue = [datetime .utcnow ()]
116+ #self.GuidValue = uuid.uudib"14"
117+ v .ByteStringValue = [b"fifteen" , b"sixteen" ]
118+ v .XmlElementValue = [ua .XmlElement ("<toto>titi</toto>" )]
119+ v .NodeIdValue = [ua .NodeId .from_string ("ns=4;i=9999" ), ua .NodeId .from_string ("i=6" )]
120+ #self.ExpandedNodeIdValue =
121+ #self.QualifiedNameValue =
122+ #self.LocalizedTextValue =
123+ #self.StatusCodeValue =
124+ #self.VariantValue =
125+ #self.EnumerationValue =
126+ #self.StructureValue =
127+ #self.Number =
128+ #self.Integer =
129+ #self.UInteger =
130+
131+
132+ data = v .to_binary ()
133+ v2 = s .ArrayValueDataType .from_binary (ua .utils .Buffer (data ))
134+ self .assertEqual (v .NodeIdValue , v2 .NodeIdValue )
135+ print (v2 .NodeIdValue )
136+
137+
90138 def test_nodeid_ordering (self ):
91139 a = ua .NodeId (2000 , 1 )
92140 b = ua .NodeId (3000 , 1 )
0 commit comments