Beispiel #1
0
 def get_client_to_discovery(self, url="opc.tcp://localhost:4840"):
     """
     Create a client to discovery server and return it
     """
     client = Client(url)
     client.connect()
     return client
Beispiel #2
0
 def get_client_to_discovery(self, url="opc.tcp://localhost:4840"):
     """
     Create a client to discovery server and return it
     """
     client = Client(url)
     client.connect()
     return client
Beispiel #3
0
 def register_to_discovery(self,
                           serverToRegister=None,
                           discoveryUrl=DEF_DISCOVERY_URL,
                           period=DEF_REGINT):
     """
     Register to an OPC-UA Discovery server. Registering must be renewed at
     least every 10 minutes, so this method will use our asyncio thread to
     re-register every period seconds
     if period is 0 registration is not automatically renewed
     """
     # Detect accidental registration loops.
     if len(self._registration_clients) >= self.MAX_CLIENT:
         raise Exception('Max. discovery servers reached: {:d}'.format(
             self.MAX_CLIENT))
     # Prevent multiple registrations to one discovery server.
     netloc = urlparse(discoveryUrl).netloc
     for client in self._registration_clients:
         if client.server_url.netloc != netloc:
             continue
         raise Exception(
             'Already registering to discovery server: {:s}'.format(
                 discoveryUrl))
     # Create and store client connection to discovery server.
     registrationClient = Client(discoveryUrl)
     registrationClient.connect()
     self._registration_clients.append(registrationClient)
     self._renew_registration(serverToRegister,
                              registrationClient,
                              period=period)
 def register_to_discovery(self, serverToRegister=None, discoveryUrl=DEF_DISCOVERY_URL, period=DEF_REGINT):
     """
     Register to an OPC-UA Discovery server. Registering must be renewed at
     least every 10 minutes, so this method will use our asyncio thread to
     re-register every period seconds
     if period is 0 registration is not automatically renewed
     """
     # Detect accidental registration loops.
     if len(self._registration_clients) >= self.MAX_CLIENT:
         raise Exception('Max. discovery servers reached: {:d}'.format(self.MAX_CLIENT))
     # Prevent multiple registrations to one discovery server.
     netloc = urlparse(discoveryUrl).netloc
     for client in self._registration_clients:
         if client.server_url.netloc != netloc:
             continue
         raise Exception('Already registering to discovery server: {:s}'.format(discoveryUrl))
     # Create and store client connection to discovery server.
     registrationClient = Client(discoveryUrl)
     registrationClient.connect()
     self._registration_clients.append(registrationClient)
     self._renew_registration(serverToRegister, registrationClient, period=period)