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)
| 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 | """ |