コード例 #1
0
ファイル: main.py プロジェクト: ussserrr/maglev-client
def connLostHandler():
    if not tivaConn.OFFLINE_MODE:
        tivaConn.OFFLINE_MODE = True
        mainWindow.statusBar().addWidget(connLostStatusBarLabel)
        MessageWindow(
            text=
            'Connection was lost. App going to Offline mode and will be trying to reconnect',
            type='Warning')
コード例 #2
0
ファイル: main.py プロジェクト: ussserrr/maglev-client
 def setpointWriteButtonClicked(self):
     try:
         if float(self.setpointWriteLine.text()) <= 3.3 and float(
                 self.setpointWriteLine.text()) >= 0:
             tivaConn.write('setpoint',
                            float(self.setpointWriteLine.text()))
         else:
             MessageWindow(
                 text=
                 "Setpoint value must be in interval [0; 3.3] Volts!",
                 type="Warning")
     except ValueError:
         pass
     self.setpointWriteLine.clear()
     self.setpointRefresh()
コード例 #3
0
ファイル: main.py プロジェクト: ussserrr/maglev-client
 def setIerrLimits(self):
     try:
         if float(self.IerrMaxLineEdit.text()) < float(
                 self.IerrMinLineEdit.text()):
             MessageWindow(text="Upper limit value is less than lower",
                           type='Error')
         else:
             tivaConn.write('IerrLimits',
                            float(self.IerrMinLineEdit.text()),
                            float(self.IerrMaxLineEdit.text()))
     except ValueError:
         pass
     self.IerrMin, self.IerrMax = tivaConn.read('IerrLimits')
     self.IerrMinLineEdit.setText('{}'.format(self.IerrMin))
     self.IerrMaxLineEdit.setText('{}'.format(self.IerrMax))
コード例 #4
0
ファイル: main.py プロジェクト: ussserrr/maglev-client
 def saveToEEPROM(self):
     if not tivaConn.saveToEEPROM():
         MessageWindow(text='Successfully saved', type='Info')
         refreshAllPIDvalues()
     else:
         MessageWindow(text='Saving failed!', type='Warning')
コード例 #5
0
ファイル: main.py プロジェクト: ussserrr/maglev-client
 def resetIerr(self):
     tivaConn.resetIerr()
     MessageWindow(text='Success. Current I-error: {}'.format(
         tivaConn.read('Ierr')[0]),
                   type='Info')
コード例 #6
0
ファイル: main.py プロジェクト: ussserrr/maglev-client
                break
        except ValueError:
            print("Wrong input! Must be like: 192.168.1.110/1200. Try again.")

    app = QApplication(sys.argv)

    tivaConn = MCUconn(IP, PORT)
    # widget for showing in statusbar when connection lost
    connLostStatusBarLabel = QLabel(
        "<font color='red'>Connection was lost. Trying to reconnect...</font>")
    DEMO_MODE = False
    if tivaConn.checkConnection():
        tivaConn.OFFLINE_MODE = True
        DEMO_MODE = True
        print("\nDemo mode entered")
        MessageWindow(text="Due to no connection to regulator the application will start in Demo mode. All values are random. "\
                           "To exit Demo mode please restart application.")
    else:
        # if connection is present and no demo mode then create timer for connection checking
        checkConnectionTimer = QTimer()
        checkConnectionTimer.timeout.connect(checkConnectionTimerHandler)
        checkConnectionTimer.start(5000)  # every 5 seconds
        # also create handler function for connection lost (for example, when reading some coefficient from MCU)
        tivaConn.connLost.signal.connect(connLostHandler)
    # save values for restoring
    tivaConn.saveCurrentValues()

    mainWindow = MainWindow()
    mainWindow.show()

    print('\nloaded.\n')
    sys.exit(app.exec_())