MCPcopy Create free account
hub / github.com/FreeOpcUa/python-opcua / create_subscription

Method create_subscription

opcua/client/client.py:540–565  ·  view source on GitHub ↗

Create a subscription. returns a Subscription object which allow to subscribe to events or data on server handler argument is a class with data_change and/or event methods. period argument is either a publishing interval in milliseconds or a CreateSub

(self, period, handler)

Source from the content-addressed store, hash-verified

538 return Node(self.uaclient, nodeid)
539
540 def create_subscription(self, period, handler):
541 """
542 Create a subscription.
543 returns a Subscription object which allow
544 to subscribe to events or data on server
545 handler argument is a class with data_change and/or event methods.
546 period argument is either a publishing interval in milliseconds or a
547 CreateSubscriptionParameters instance. The second option should be used,
548 if the opcua-server has problems with the default options.
549 These methods will be called when notfication from server are received.
550 See example-client.py.
551 Do not do expensive/slow or network operation from these methods
552 since they are called directly from receiving thread. This is a design choice,
553 start another thread if you need to do such a thing.
554 """
555
556 if isinstance(period, ua.CreateSubscriptionParameters):
557 return Subscription(self.uaclient, period, handler)
558 params = ua.CreateSubscriptionParameters()
559 params.RequestedPublishingInterval = period
560 params.RequestedLifetimeCount = 10000
561 params.RequestedMaxKeepAliveCount = 3000
562 params.MaxNotificationsPerPublish = 10000
563 params.PublishingEnabled = True
564 params.Priority = 0
565 return Subscription(self.uaclient, params, handler)
566
567 def reconciliate_subscription(self, subscription):
568 """

Callers 9

uasubscribeFunction · 0.95
__init__Method · 0.45
client-example.pyFile · 0.45
client-events.pyFile · 0.45
__init__Method · 0.45

Calls 1

SubscriptionClass · 0.90

Tested by 1