Пример #1
0
    def __init__(self, nets=[]):
        super().__init__()

        self.imgToPredict = None
        self.imgToPredictClass = None
        self.imgPredictedClass = None
        self.imgTrueClassLabel = QLabel()
        self.imgPredictedClassLabel = QLabel()

        self.model = convModel()
        self.nets = nets

        host = 'localhost'
        serverPort = getServerPort()
        self.clientsInNet = getClientsNumber()
        self.firstPort = getTesterPort()

        self.serverConnection = ServerConnection(host, serverPort, serverPort + 1)

        self.clients = []
        self.accBtns = []
        for i in range(self.clientsInNet):
            self.clients.append(ClientConnection('client-' + str(i), self.firstPort + (i * 2),
                                                 self.firstPort + (i * 2) + 1, self))

        for client in self.clients:
            client.start()

        self.setWindowTitle('Federated learning controller')

        self.mainWidget = QWidget()

        self.setCentralWidget(self.mainWidget)

        qss_file = open('style.qss').read()
        self.centralWidget().setStyleSheet(qss_file)

        self.layout = QGridLayout()
        self.layout.setAlignment(Qt.AlignTop)

        self.mainWidget.setLayout(self.layout)

        self.__addDropdown(nets)
        self.addClientInfo()
        self.__addImageFrame()
        self.addTrainButton()
        self.addPredictImage()

        self.serverConnection.addQtControls(self.preTrainVal, self.postTrainVal, self.trainBtn, self.netBtn,
                                                self.accBtns, self.downloadBtn, self.currentModel, self.modelDownloadedAcc)
        self.serverConnection.addModelRef(self.model)
        self.serverConnection.setCallbacks(self.imageIsSet, lambda: self.predictChangeState(True))
        self.serverConnection.start()

        self.disableButtons()

        self.show()
Пример #2
0
def SetupClientConnection():
    client = ClientConnection()
    EggClient = PLCClient()
    EggClient.ClientName = 'SenorEgg'
    EggClient.ClientID = 10245

    EggControlz = ControlValue()
    EggControlz.ControlValueType = EggControlz.Range
    EggControlz.ControlName = 'Yolk'
    EggClient.ControlList.append(EggControlz)
    client.SetClientData(EggClient)
    return client
Пример #3
0
def SetupClientConnection():
    client = ClientConnection()
    CuckooClient = PLCClient()
    CuckooClient.ClientName = 'CuckooConductor'
    CuckooClient.ClientID = 1175278
    CuckooClient.IconName = 'cuckoo-clock'

    tock = ControlValue()
    tock.ControlName = 'Tock'
    tock.ControlDirection = tock.Output
    tock.ControlValueType = tock.OnOff
    CuckooClient.ControlList.append(tock)

    client.SetClientData(CuckooClient)
    return client
Пример #4
0
def SetupClientConnection():
    client = ClientConnection()
    BlinkyLEDClient = PLCClient()
    BlinkyLEDClient.ClientName = 'HueBulbs'
    BlinkyLEDClient.ClientID = 5123085
    BlinkyLEDClient.IconName = 'light-bulb'

    Hue1OnOff = ControlValue()
    Hue1OnOff.ControlName = 'HueLight1'
    Hue1OnOff.ControlValueType = Hue1OnOff.OnOff
    BlinkyLEDClient.ControlList.append(Hue1OnOff)

    Hue2OnOff = ControlValue()
    Hue2OnOff.ControlName = 'HueLight2'
    Hue2OnOff.ControlValueType = Hue2OnOff.OnOff
    BlinkyLEDClient.ControlList.append(Hue2OnOff)

    client.SetClientData(BlinkyLEDClient)
    return client
Пример #5
0
    def start(self):

        self._db_cursor.execute(self.DB_INIT)

        self.__socket.bind(self._address)
        self.__socket.listen(5)

        while True:
            (destination_socket, destination_address) = self.__socket.accept()

            print(
                f'{datetime.now().strftime("%Y-%m-%d %H:%M:%S")} - {destination_address[0]}'
            )

            thread_session = ClientSession()

            t = ClientConnection(destination_socket, self, thread_session)
            t.start()

            print(f'Currently logged: {len(self._sessions)}')
 def connect(self, IP, PORT):
     connection = ClientConnection()
     connection.connect_to_server(IP, PORT)
     return connection