(self)
| 801 | prop_parent = mydevicederived.get_child(["0:sensor_id"]) |
| 802 | |
| 803 | def test_instantiate_string_nodeid(self): |
| 804 | # Create device type |
| 805 | dev_t = self.opc.nodes.base_object_type.add_object_type(0, "MyDevice2") |
| 806 | v_t = dev_t.add_variable(0, "sensor", 1.0) |
| 807 | v_t.set_modelling_rule(True) |
| 808 | p_t = dev_t.add_property(0, "sensor_id", "0340") |
| 809 | p_t.set_modelling_rule(True) |
| 810 | ctrl_t = dev_t.add_object(0, "controller") |
| 811 | ctrl_t.set_modelling_rule(True) |
| 812 | prop_t = ctrl_t.add_property(0, "state", "Running") |
| 813 | prop_t.set_modelling_rule(True) |
| 814 | |
| 815 | # instanciate device |
| 816 | nodes = instantiate(self.opc.nodes.objects, dev_t, nodeid=ua.NodeId("InstDevice", 2, ua.NodeIdType.String), bname="2:InstDevice") |
| 817 | mydevice = nodes[0] |
| 818 | |
| 819 | self.assertEqual(mydevice.get_node_class(), ua.NodeClass.Object) |
| 820 | self.assertEqual(mydevice.get_type_definition(), dev_t.nodeid) |
| 821 | obj = mydevice.get_child(["0:controller"]) |
| 822 | obj_nodeid_ident = obj.nodeid.Identifier |
| 823 | prop = mydevice.get_child(["0:controller", "0:state"]) |
| 824 | self.assertEqual(obj_nodeid_ident, "InstDevice.controller") |
| 825 | self.assertEqual(prop.get_type_definition().Identifier, ua.ObjectIds.PropertyType) |
| 826 | self.assertEqual(prop.get_value(), "Running") |
| 827 | self.assertNotEqual(prop.nodeid, prop_t.nodeid) |
| 828 | |
| 829 | def test_variable_with_datatype(self): |
| 830 | v1 = self.opc.nodes.objects.add_variable(3, 'VariableEnumType1', ua.ApplicationType.ClientAndServer, datatype=ua.NodeId(ua.ObjectIds.ApplicationType)) |
nothing calls this directly
no test coverage detected