当前位置: 首页>>代码示例>>Python>>正文


Python Server.create_custom_event_type方法代码示例

本文整理汇总了Python中opcua.Server.create_custom_event_type方法的典型用法代码示例。如果您正苦于以下问题:Python Server.create_custom_event_type方法的具体用法?Python Server.create_custom_event_type怎么用?Python Server.create_custom_event_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在opcua.Server的用法示例。


在下文中一共展示了Server.create_custom_event_type方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: parent

# 需要导入模块: from opcua import Server [as 别名]
# 或者: from opcua.Server import create_custom_event_type [as 别名]
    # setup our own namespace, not really necessary but should as spec
    uri = "http://examples.freeopcua.github.io"
    idx = server.register_namespace(uri)

    # get Objects node, this is where we should put our custom stuff
    objects = server.get_objects_node()

    # populating our address space
    myobj = objects.add_object(idx, "MyObject")
    myvar = myobj.add_variable(idx, "MyVariable", ua.Variant(0, ua.VariantType.Double))
    myvar.set_writable()  # Set MyVariable to be writable by clients

    # Creating a custom event: Approach 1
    # The custom event object automatically will have members from its parent (BaseEventType)
    etype = server.create_custom_event_type(2, 'MyFirstEvent', ua.ObjectIds.BaseEventType,
                                            [('MyNumericProperty', ua.VariantType.Float),
                                             ('MyStringProperty', ua.VariantType.String)])
    # create second event
    etype2 = server.create_custom_event_type(2, 'MySecondEvent', ua.ObjectIds.BaseEventType,
                                             [('MyOtherProperty', ua.VariantType.Float)])

    myevgen = server.get_event_generator(etype, myobj)
    myevgen.event.Severity = 500
    myevgen.event.MyStringProperty = ua.Variant("hello world")

    myevgen2 = server.get_event_generator(etype2, myobj)
    myevgen2.event.Severity = 123
    myevgen2.event.MyOtherProperty = ua.Variant(1.337)

    serverevgen = server.get_event_generator()
    serverevgen.event.Severity = 111
开发者ID:stanti,项目名称:python-opcua,代码行数:33,代码来源:server-history.py

示例2: parent

# 需要导入模块: from opcua import Server [as 别名]
# 或者: from opcua.Server import create_custom_event_type [as 别名]
    # setup our own namespace, not really necessary but should as spec
    uri = "http://examples.freeopcua.github.io"
    idx = server.register_namespace(uri)

    # get Objects node, this is where we should put our custom stuff
    objects = server.get_objects_node()

    # populating our address space
    myobj = objects.add_object(idx, "MyObject")

    # Creating a custom event: Approach 1
    # The custom event object automatically will have members from its parent (BaseEventType)
    etype = server.create_custom_event_type(
        2,
        "MyFirstEvent",
        ua.ObjectIds.BaseEventType,
        [("MyNumericProperty", ua.VariantType.Float), ("MyStringProperty", ua.VariantType.String)],
    )

    myevgen = server.get_event_generator(etype, myobj)
    myevgen.event.Severity = 500

    # Creating a custom event: Approach 2
    base_etype = server.get_node(ua.ObjectIds.BaseEventType)
    custom_etype = base_etype.add_subtype(2, "MySecondEvent")
    custom_etype.add_property(2, "MyIntProperty", ua.Variant(None, ua.VariantType.Int32))
    custom_etype.add_property(2, "MyBoolProperty", ua.Variant(None, ua.VariantType.Boolean))

    mysecondevgen = server.get_event_generator(custom_etype, myobj)

    # starting!
开发者ID:stanti,项目名称:python-opcua,代码行数:33,代码来源:server-events.py


注:本文中的opcua.Server.create_custom_event_type方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。