@@ -57,7 +57,7 @@ def test_custom_structs(self):
5757 #self.GuidValue = uuid.uudib"14"
5858 v .ByteStringValue = b"fifteen"
5959 v .XmlElementValue = ua .XmlElement ("<toto>titi</toto>" )
60- v .NodeIdValue = ua .NodeId ("ns=4;i=9999" )
60+ v .NodeIdValue = ua .NodeId . from_string ("ns=4;i=9999" )
6161 #self.ExpandedNodeIdValue =
6262 #self.QualifiedNameValue =
6363 #self.LocalizedTextValue =
@@ -74,6 +74,54 @@ def test_custom_structs(self):
7474 v2 = s .ScalarValueDataType .from_binary (ua .utils .Buffer (data ))
7575 self .assertEqual (v .NodeIdValue , v2 .NodeIdValue )
7676
77+ def test_custom_structs_array (self ):
78+ xmlpath = "tests/example.bsd"
79+ c = StructGenerator (xmlpath , "structures.py" )
80+ c .run ()
81+ import structures as s
82+
83+ # test with default values
84+ v = s .ArrayValueDataType ()
85+ data = v .to_binary ()
86+ v2 = s .ArrayValueDataType .from_binary (ua .utils .Buffer (data ))
87+
88+
89+ # set some values
90+ v = s .ArrayValueDataType ()
91+ v .SbyteValue = [1 ]
92+ v .ByteValue = [2 ]
93+ v .Int16Value = [3 ]
94+ v .UInt16Value = [4 ]
95+ v .Int32Value = [5 ]
96+ v .UInt32Value = [6 ]
97+ v .Int64Value = [7 ]
98+ v .UInt64Value = [8 ]
99+ v .FloatValue = [9.0 ]
100+ v .DoubleValue = [10.0 ]
101+ v .StringValue = ["elleven" ]
102+ v .DateTimeValue = [datetime .utcnow ()]
103+ #self.GuidValue = uuid.uudib"14"
104+ v .ByteStringValue = [b"fifteen" , b"sixteen" ]
105+ v .XmlElementValue = [ua .XmlElement ("<toto>titi</toto>" )]
106+ v .NodeIdValue = [ua .NodeId .from_string ("ns=4;i=9999" ), ua .NodeId .from_string ("i=6" )]
107+ #self.ExpandedNodeIdValue =
108+ #self.QualifiedNameValue =
109+ #self.LocalizedTextValue =
110+ #self.StatusCodeValue =
111+ #self.VariantValue =
112+ #self.EnumerationValue =
113+ #self.StructureValue =
114+ #self.Number =
115+ #self.Integer =
116+ #self.UInteger =
117+
118+
119+ data = v .to_binary ()
120+ v2 = s .ArrayValueDataType .from_binary (ua .utils .Buffer (data ))
121+ self .assertEqual (v .NodeIdValue , v2 .NodeIdValue )
122+ print (v2 .NodeIdValue )
123+
124+
77125 def test_nodeid_ordering (self ):
78126 a = ua .NodeId (2000 , 1 )
79127 b = ua .NodeId (3000 , 1 )
0 commit comments