Esempio n. 1
0
    def Connect(self):
        already_connected = self.DeltaCPClient.if_connected
        if already_connected:
            PopUpNotifier.Info(f'Client is already connected!')
            return

        ConnectionParameters = self.ConnectionParameters.GetConnectionParameters(
        )

        try:
            self.DeltaCPClient.CreateClient(
                Protocol=ConnectionParameters['Protocol'],
                COMPort=ConnectionParameters['COMPort'],
                Timeout=ConnectionParameters['Timeout'],
                StopBits=ConnectionParameters['StopBits'],
                ByteSize=ConnectionParameters['ByteSize'],
                Parity=ConnectionParameters['Parity'],
                BaudRate=ConnectionParameters['BaudRate'])
        except:
            loggers['Debug'].debug(f'Exception while creating DeltaCP Client')
            return
        if_connected = self.DeltaCPClient.Connect()
        self.notify_connection_success(if_connected)
        loggers['Application'].info(f'Connection successful? {if_connected}')
        loggers['Debug'].debug(f'If client connected: {if_connected}')
Esempio n. 2
0
    def AutoConnect(self):
        already_connected = self.DeltaCPClient.if_connected
        if already_connected:
            PopUpNotifier.Info('Client already connected!')
            return

        for index, config in self.ConnectionConfigs.iterrows():
            self.set_config_into_comboboxes\
            (
                [config['Protocol'],        self.window.ProtocolcomboBox],
                [str(config['Byte Size']),  self.window.ByteSizecomboBox],
                [config['Parity'],          self.window.ParitycomboBox],
                [str(config['Stop Bits']),  self.window.StopBitscomboBox],
                [str(config['Baud Rate']),  self.window.BaudRatecomboBox]
            )

            ConnectionParameters = self.ConnectionParameters.GetConnectionParameters(
            )

            self.DeltaCPClient.CreateClient(
                Protocol=ConnectionParameters['Protocol'],
                COMPort=ConnectionParameters['COMPort'],
                Timeout=ConnectionParameters['Timeout'],
                StopBits=ConnectionParameters['StopBits'],
                ByteSize=ConnectionParameters['ByteSize'],
                Parity=ConnectionParameters['Parity'],
                BaudRate=ConnectionParameters['BaudRate'])

            if_connected = self.DeltaCPClient.Connect()
            if if_connected:
                msg_success = 'Auto connection successful!'
                loggers['Application'].info(msg_success)
                PopUpNotifier.Info(msg_success)
                return

        msg = f'Auto Connect unsuccessful. Please write other configs into ConnectionConfigs.xlsx' \
              f' file or set parameters manually'
        loggers['Application'].info(msg)
        PopUpNotifier.Warning(msg)
Esempio n. 3
0
 def notify_connection_success(self, if_connected):
     if if_connected:
         PopUpNotifier.Info(f'Client connection successful!')
     else:
         PopUpNotifier.Error(f'Client connection failed!')