Esempio n. 1
0
    def create_subscription(self, period, handler):
        """
        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
        CreateSubscriptionParameters instance. The second option should be used,
        if the opcua-server has problems with the default options.
        These methods will be called when notfication from server are received.
        See example-client.py.
        Do not do expensive/slow or network operation from these methods
        since they are called directly from receiving thread. This is a design choice,
        start another thread if you need to do such a thing.
        """

        if isinstance(period, ua.CreateSubscriptionParameters):
            return Subscription(self.uaclient, period, handler)
        params = ua.CreateSubscriptionParameters()
        params.RequestedPublishingInterval = period
        params.RequestedLifetimeCount = 10000
        params.RequestedMaxKeepAliveCount = 3000
        params.MaxNotificationsPerPublish = 10000
        params.PublishingEnabled = True
        params.Priority = 0
        return Subscription(self.uaclient, params, handler)
    def create_subscription(self):
        try:
            #if not self._datachange_sub:
            params = ua.CreateSubscriptionParameters()
            params.RequestedPublishingInterval = self.pub_interval
            params.RequestedLifetimeCount = self.lifetime_count
            params.RequestedMaxKeepAliveCount = self.max_keep_alive_count
            params.MaxNotificationsPerPublish = self.max_notifications_per_publish
            params.PublishingEnabled = True
            params.Priority = self.priority
            sub = Subscription(self.window.client.uaclient, params,
                               self._subhandler)

            self._datachange_sub[sub.subscription_id] = sub
            self.model.setHorizontalHeaderLabels(
                ["Subscription Id", "Publishing Interval"])
            row = [
                QStandardItem(str(sub.subscription_id)),
                QStandardItem(str(sub.parameters.RequestedPublishingInterval))
            ]
            row[0].setData(sub)
            self.model.appendRow(row)
        except Exception as ex:
            self.window.log_window.ui.logTextEdit.append(str(ex))
            raise
Esempio n. 3
0
 def create_subscription(self, period, handler):
     """
     Create a subscription.
     returns a Subscription object which allow
     to subscribe to events or data on server
     """
     params = ua.CreateSubscriptionParameters()
     params.RequestedPublishingInterval = period
     params.RequestedLifetimeCount = 3000
     params.RequestedMaxKeepAliveCount = 10000
     params.MaxNotificationsPerPublish = 0
     params.PublishingEnabled = True
     params.Priority = 0
     return Subscription(self.iserver.isession, params, handler)
Esempio n. 4
0
 def create_subscription(self, period, handler):
     """
     Create a subscription.
     returns a Subscription object which allow
     to subscribe to events or data on server
     period is in milliseconds
     handler is a python object with following methods:
         def datachange_notification(self, node, val, data):
         def event_notification(self, event):
         def status_change_notification(self, status):
     """
     params = ua.CreateSubscriptionParameters()
     params.RequestedPublishingInterval = period
     params.RequestedLifetimeCount = 3000
     params.RequestedMaxKeepAliveCount = 10000
     params.MaxNotificationsPerPublish = 0
     params.PublishingEnabled = True
     params.Priority = 0
     return Subscription(self.iserver.isession, params, handler)