示例#1
0
 def test_create_custom_event_type_Node(self):
     etype = self.opc.create_custom_event_type(
         2, 'MyEvent',
         opcua.Node(self.opc.iserver.isession,
                    ua.NodeId(ua.ObjectIds.BaseEventType)),
         [('PropertyNum', ua.VariantType.Int32),
          ('PropertyString', ua.VariantType.String)])
     check_custom_type(self, etype, ua.ObjectIds.BaseEventType)
示例#2
0
 def test_eventgenerator_source_collision(self):
     objects = self.opc.get_objects_node()
     o = objects.add_object(3, 'MyObject')
     event = BaseEvent(sourcenode=o.nodeid)
     evgen = self.opc.get_event_generator(event, ua.ObjectIds.Server)
     evgen.event.SourceNode = o.nodeid
     evgen.event.SourceName = o.get_browse_name().Name
     check_eventgenerator_BaseEvent(self, evgen)
     check_event_generator_object(self, evgen, o, emitting_node=opcua.Node(self.opc.iserver.isession, ua.ObjectIds.Server))
示例#3
0
def check_custom_event_type(test, ev):
    base = opcua.Node(test.opc.iserver.isession, ua.NodeId(ua.ObjectIds.BaseEventType))
    test.assertTrue(ev in base.get_children())
    nodes = ev.get_referenced_nodes(refs=ua.ObjectIds.HasSubtype, direction=ua.BrowseDirection.Inverse, includesubtypes=False)
    test.assertEqual(base, nodes[0])
    properties = ev.get_properties()
    test.assertIsNot(properties, None)
    test.assertEqual(len(properties), 2)
    test.assertTrue(ev.get_child("2:PropertyNum") in properties)
    test.assertEqual(ev.get_child("2:PropertyNum").get_data_value().Value.VariantType, ua.VariantType.Float)
    test.assertTrue(ev.get_child("2:PropertyString") in properties)
    test.assertEqual(ev.get_child("2:PropertyString").get_data_value().Value.VariantType, ua.VariantType.String)
示例#4
0
 def test_get_event_from_type_node_Inhereted_AuditEvent(self):
     ev = opcua.common.events.get_event_obj_from_type_node(opcua.Node(self.opc.iserver.isession, ua.NodeId(ua.ObjectIds.AuditEventType)))
     self.assertIsNot(ev, None)  # we did not receive event
     self.assertIsInstance(ev, BaseEvent)
     self.assertIsInstance(ev, AuditEvent)
     self.assertEqual(ev.EventType, ua.NodeId(ua.ObjectIds.AuditEventType))
     self.assertEqual(ev.Severity, 1)
     self.assertEqual(ev.ActionTimeStamp, None)
     self.assertEqual(ev.Status, False)
     self.assertEqual(ev.ServerId, None)
     self.assertEqual(ev.ClientAuditEntryId, None)
     self.assertEqual(ev.ClientUserId, None)
示例#5
0
 def test_get_event_from_type_node_Inhereted_AuditEvent(self):
     ev = opcua.server.event.get_event_from_type_node(opcua.Node(self.opc.iserver.isession, ua.NodeId(ua.ObjectIds.AuditEventType)))
     self.assertIsNot(ev, None)  # we did not receive event
     self.assertIsInstance(ev, ua.BaseEvent)
     self.assertIsInstance(ev, ua.AuditEvent)
     self.assertEqual(ev.EventType, ua.NodeId(ua.ObjectIds.AuditEventType))
     self.assertEqual(ev.Severity, ua.Variant(1, ua.VariantType.UInt16))
     self.assertEqual(ev.ActionTimeStamp, None)
     self.assertEqual(ev.Status, False)
     self.assertEqual(ev.ServerId, None)
     self.assertEqual(ev.ClientAuditEntryId, None)
     self.assertEqual(ev.ClientUserId, None)
     self.assertEqual(ev._freeze, True)
示例#6
0
 def test_get_event_from_type_node_MultiInhereted_AuditOpenSecureChannelEvent(self):
     ev = opcua.common.events.get_event_obj_from_type_node(opcua.Node(self.opc.iserver.isession, ua.NodeId(ua.ObjectIds.AuditOpenSecureChannelEventType)))
     self.assertIsNot(ev, None)
     self.assertIsInstance(ev, BaseEvent)
     self.assertIsInstance(ev, AuditEvent)
     self.assertIsInstance(ev, AuditSecurityEvent)
     self.assertIsInstance(ev, AuditChannelEvent)
     self.assertIsInstance(ev, AuditOpenSecureChannelEvent)
     self.assertEqual(ev.EventType, ua.NodeId(ua.ObjectIds.AuditOpenSecureChannelEventType))
     self.assertEqual(ev.Severity, 1),
     self.assertEqual(ev.ClientCertificate, None)
     self.assertEqual(ev.ClientCertificateThumbprint, None)
     self.assertEqual(ev.RequestType, None)
     self.assertEqual(ev.SecurityPolicyUri, None)
     self.assertEqual(ev.SecurityMode, None)
     self.assertEqual(ev.RequestedLifetime, None)
示例#7
0
def check_custom_type(test, type, base_type, node_class=None):
    base = opcua.Node(test.opc.iserver.isession, ua.NodeId(base_type))
    test.assertTrue(type in base.get_children())
    nodes = type.get_referenced_nodes(refs=ua.ObjectIds.HasSubtype,
                                      direction=ua.BrowseDirection.Inverse,
                                      includesubtypes=True)
    test.assertEqual(base, nodes[0])
    properties = type.get_properties()

    if node_class:
        test.assertEqual(node_class, type.get_node_class())

    test.assertIsNot(properties, None)
    test.assertEqual(len(properties), 2)
    test.assertTrue(type.get_child("2:PropertyNum") in properties)
    test.assertEqual(
        type.get_child("2:PropertyNum").get_data_value().Value.VariantType,
        ua.VariantType.Int32)
    test.assertTrue(type.get_child("2:PropertyString") in properties)
    test.assertEqual(
        type.get_child("2:PropertyString").get_data_value().Value.VariantType,
        ua.VariantType.String)
示例#8
0
 def test_eventgenerator_sourceServer_Node(self):
     evgen = self.opc.get_event_generator(source=opcua.Node(self.opc.iserver.isession, ua.NodeId(ua.ObjectIds.Server)))
     check_eventgenerator_BaseEvent(self, evgen)
     check_eventgenerator_SourceServer(self, evgen)
示例#9
0
 def test_get_event_from_type_node_BaseEvent(self):
     ev = opcua.server.event.get_event_from_type_node(opcua.Node(self.opc.iserver.isession, ua.NodeId(ua.ObjectIds.BaseEventType)))
     check_base_event(self, ev)