Exemplo n.º 1
0
    def setUp(self):
        # creates the 4diac manager
        self.manager_4diac = manager.Manager()
        # creates the opc-ua manager
        self.manager_4diac.build_ua_manager(self.address, self.port_server,
                                            self.file_name)

        # creates the tcp server to communicate with the 4diac
        self.handler = tcp_server.TcpServer(self.address, 61499, 10,
                                            self.manager_4diac)
        # creates the handler
        thread = Thread(target=self.handler.handle_client)
        thread.start()

        # get the path for the config
        config_path = os.path.join(os.path.dirname(sys.path[0]), 'tests',
                                   'configurations', self.config2upload)
        # sends the configuration to the
        sender_simulator = diac_simulator.DiacSimulator(self.address, 61499)
        sender_simulator.upload_dinasore(config_path)
        sender_simulator.disconnect()

        # stops the work at the
        self.manager_4diac.manager_ua.stop_ua()
        # stops the tcp server
        self.handler.stop_server()

        # creates the 4diac manager
        self.manager_4diac = manager.Manager()
        # creates the opc-ua manager
        self.manager_4diac.build_ua_manager(self.address, self.port_server,
                                            self.file_name)
Exemplo n.º 2
0
    def setUp(self):
        # Gets the file path to the configuration request (xml) file
        path = os.path.join(os.path.dirname(sys.path[0]), 'tests', 'xml_data',
                            'configuration_request.xml')
        tree = ETree.parse(path)
        self.config_request = ETree.tostring(tree.getroot(), encoding='utf-8')

        # Gets the file path to the fb request (xml) file
        path = os.path.join(os.path.dirname(sys.path[0]), 'tests', 'xml_data',
                            'fb_request.xml')
        tree = ETree.parse(path)
        self.fb_request = ETree.tostring(tree.getroot(), encoding='utf-8')

        # Gets the file path to the watch create (xml) file
        path = os.path.join(os.path.dirname(sys.path[0]), 'tests', 'xml_data',
                            'watch_create.xml')
        tree = ETree.parse(path)
        self.watch_create = ETree.tostring(tree.getroot(), encoding='utf-8')

        # Gets the file path to the watch request (xml) file
        path = os.path.join(os.path.dirname(sys.path[0]), 'tests', 'xml_data',
                            'watch_request.xml')
        tree = ETree.parse(path)
        self.watch_request = ETree.tostring(tree.getroot(), encoding='utf-8')

        # Gets the file path to the watch response (xml) file
        path = os.path.join(os.path.dirname(sys.path[0]), 'tests', 'xml_data',
                            'event_request.xml')
        tree = ETree.parse(path)
        self.event_request = ETree.tostring(tree.getroot(), encoding='utf-8')

        # Gets the file path to the hardcoded connection (xml) file
        path = os.path.join(os.path.dirname(sys.path[0]), 'tests', 'xml_data',
                            'hardcoded_connection.xml')
        tree = ETree.parse(path)
        self.hardcoded_connection = ETree.tostring(tree.getroot(),
                                                   encoding='utf-8')

        # Gets the file path to the connection request (xml) file
        path = os.path.join(os.path.dirname(sys.path[0]), 'tests', 'xml_data',
                            'connection_request.xml')
        tree = ETree.parse(path)
        self.connection_request = ETree.tostring(tree.getroot(),
                                                 encoding='utf-8')

        # Gets the file path to the start request (xml) file
        path = os.path.join(os.path.dirname(sys.path[0]), 'tests', 'xml_data',
                            'start_request.xml')
        tree = ETree.parse(path)
        self.start_request = ETree.tostring(tree.getroot(), encoding='utf-8')

        # Gets the file path to the kill resource request (xml) file
        path = os.path.join(os.path.dirname(sys.path[0]), 'tests', 'xml_data',
                            'kill_request.xml')
        tree = ETree.parse(path)
        self.kill_request = ETree.tostring(tree.getroot(), encoding='utf-8')

        # Gets the file path to the delete resource request (xml) file
        path = os.path.join(os.path.dirname(sys.path[0]), 'tests', 'xml_data',
                            'delete_request.xml')
        tree = ETree.parse(path)
        self.delete_request = ETree.tostring(tree.getroot(), encoding='utf-8')

        self.manager_instance = manager.Manager()
Exemplo n.º 3
0
 def setUp(self):
     # creates the 4diac manager
     self.manager_4diac = manager.Manager()
     # creates the opc-ua manager
     self.manager_4diac.build_ua_manager(self.address, self.port_server,
                                         self.file_name)
    for f in files:
        os.remove(f)
    ##############################################################

    # Configure the logging output
    log_path = os.path.join(os.path.dirname(sys.path[0]), 'resources',
                            'error_list.log')
    if os.path.isfile(log_path):
        os.remove(log_path)
    logging.basicConfig(
        filename=log_path,
        level=log_level,
        format='[%(asctime)s][%(levelname)s][%(threadName)s] %(message)s')

    # creates the 4diac manager
    m = manager.Manager(monitor=monitor)
    # sets the ua integration option
    m.build_ua_manager(address, port_opc, 'data_model.xml')

    # creates the tcp server to communicate with the 4diac
    hand = tcp_server.TcpServer(address, port_diac, 10, m)

    try:
        # handles every client
        marketplace_bridge.MarketplaceBridge.announce(m.manager_ua.base_name)
        while True:
            hand.handle_client()
    except KeyboardInterrupt:
        logging.info('interrupted server')
        m.manager_ua.stop_ua()
        hand.stop_server()