Update hexapod.py

master
Zhengyu Peng 3 years ago
parent c14fceb4ff
commit 2ff2e2b79e

@ -81,6 +81,9 @@ class MyApp(QtWidgets.QMainWindow):
self.init_ui() self.init_ui()
self.is_tcp_connected = False
self.is_bluetooth_connected = False
self.ui.comboBox_Interface.currentIndexChanged.connect( self.ui.comboBox_Interface.currentIndexChanged.connect(
self.on_interface_selection_changed self.on_interface_selection_changed
) )
@ -326,6 +329,7 @@ class MyApp(QtWidgets.QMainWindow):
def on_tcp_client_status_update(self, status, addr): def on_tcp_client_status_update(self, status, addr):
if status == TCPClient.STOP: if status == TCPClient.STOP:
self.is_tcp_connected = False
self.tcp_client.status.disconnect() self.tcp_client.status.disconnect()
self.tcp_client.message.disconnect() self.tcp_client.message.disconnect()
@ -338,6 +342,7 @@ class MyApp(QtWidgets.QMainWindow):
self.ui.lineEdit_TcpClientTargetIP.setEnabled(True) self.ui.lineEdit_TcpClientTargetIP.setEnabled(True)
self.ui.lineEdit_TcpClientTargetPort.setEnabled(True) self.ui.lineEdit_TcpClientTargetPort.setEnabled(True)
if not self.is_bluetooth_connected:
self.ui.textBrowserMessage.setEnabled(False) self.ui.textBrowserMessage.setEnabled(False)
self.ui.groupBox_Control.setEnabled(False) self.ui.groupBox_Control.setEnabled(False)
@ -346,6 +351,8 @@ class MyApp(QtWidgets.QMainWindow):
self.ui.status_bar.showMessage('● Idle') self.ui.status_bar.showMessage('● Idle')
elif status == TCPClient.CONNECTED: elif status == TCPClient.CONNECTED:
self.is_tcp_connected = True
self.on_bt_client_connect_button_clicked()
self.ui.buttonTcpConnect.setText('Disconnect') self.ui.buttonTcpConnect.setText('Disconnect')
self.ui.button_Refresh.setEnabled(False) self.ui.button_Refresh.setEnabled(False)
@ -407,6 +414,7 @@ class MyApp(QtWidgets.QMainWindow):
def on_bt_client_status_update(self, status, addr): def on_bt_client_status_update(self, status, addr):
if status == BluetoothClient.STOP: if status == BluetoothClient.STOP:
self.is_bluetooth_connected = False
self.bt_client.status.disconnect() self.bt_client.status.disconnect()
self.bt_client.message.disconnect() self.bt_client.message.disconnect()
@ -416,12 +424,15 @@ class MyApp(QtWidgets.QMainWindow):
self.ui.lineEditBtMac.setEnabled(True) self.ui.lineEditBtMac.setEnabled(True)
self.ui.lineEditBtPort.setEnabled(True) self.ui.lineEditBtPort.setEnabled(True)
if not self.is_tcp_connected:
self.ui.textBrowserMessage.setEnabled(False) self.ui.textBrowserMessage.setEnabled(False)
self.ui.groupBox_Control.setEnabled(False) self.ui.groupBox_Control.setEnabled(False)
# self.status['Bluetooth']['Client'] = '[CLIENT] Idle' # self.status['Bluetooth']['Client'] = '[CLIENT] Idle'
elif status == BluetoothClient.CONNECTED: elif status == BluetoothClient.CONNECTED:
self.is_bluetooth_connected = True
self.on_tcp_client_connect_button_clicked()
self.ui.buttonBtConnect.setText('Disconnect') self.ui.buttonBtConnect.setText('Disconnect')
self.ui.groupBox_Control.setEnabled(True) self.ui.groupBox_Control.setEnabled(True)
self.ui.textBrowserMessage.setEnabled(True) self.ui.textBrowserMessage.setEnabled(True)

Loading…
Cancel
Save