Skip to content

Commit

Permalink
add connecting status
Browse files Browse the repository at this point in the history
  • Loading branch information
Neutree committed Mar 18, 2022
1 parent 3f4d443 commit 2d7365c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 2 deletions.
8 changes: 6 additions & 2 deletions COMTool/Main.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,9 +519,13 @@ def onUpdateCountUi(self, send, receive):

def onShowConnStatus(self, status, msg):
if status == ConnectionStatus.CONNECTED:
self.onstatusBarText("info", msg)
self.onstatusBarText("info", '{} {}'.format(_("Connected"), msg))
elif status == ConnectionStatus.CLOSED:
self.onstatusBarText("info", msg)
self.onstatusBarText("info", '{} {}'.format(_("Closed"), msg))
elif status == ConnectionStatus.CONNECTING:
self.onstatusBarText("info", '{} {}'.format(_("Connecting"), msg))
elif status == ConnectionStatus.LOSE:
self.onstatusBarText("warning", '{} {}'.format(_("Connection lose"), msg))
else:
self.onstatusBarText("warning", msg)
for plugin in self.plugins:
Expand Down
1 change: 1 addition & 0 deletions COMTool/conn/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class ConnectionStatus(Enum):
CLOSED = 0
CONNECTED = 1
LOSE = 2
CONNECTING = 3


class COMM(QObject):
Expand Down
2 changes: 2 additions & 0 deletions COMTool/conn/conn_serial.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ def openCloseSerialProcess(self):
else:
try:
print("-- open serial")
self.onConnectionStatus.emit(ConnectionStatus.CONNECTING, "")
self.com.open()
self.status = ConnectionStatus.CONNECTED
self.onConnectionStatus.emit(self.status, "")
Expand Down Expand Up @@ -414,6 +415,7 @@ def receiveDataProcess(self):
if waitingReconnect:
if self.portExits(self.com.port):
try:
self.onConnectionStatus.emit(ConnectionStatus.CONNECTING, "")
self.com.open()
print("-- reopen serial")
waitingReconnect = False
Expand Down
2 changes: 2 additions & 0 deletions COMTool/conn/conn_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ def openCloseSerialProcess(self):
self.showSwitchSignal.emit(self.status)
else:
try:
self.onConnectionStatus.emit(ConnectionStatus.CONNECTING, "")
self.checkAndConnect()
self.status = ConnectionStatus.CONNECTED
print("-- connect success")
Expand Down Expand Up @@ -342,6 +343,7 @@ def receiveDataProcess(self, conn, remote_addr:tuple = None):
while self.status != ConnectionStatus.CLOSED:
if waitingReconnect:
try:
self.onConnectionStatus.emit(ConnectionStatus.CONNECTING, "")
self.checkAndConnect()
conn = self.conn
conn.settimeout(0.1)
Expand Down
2 changes: 2 additions & 0 deletions COMTool/conn/conn_tcp_udp.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ def openCloseSerialProcess(self):
if not target:
raise Exception(_("Target error") + ": " + self.config["target"][0])
print("-- connect", target)
self.onConnectionStatus.emit(ConnectionStatus.CONNECTING, "")
self.conn = socket.socket()
self.conn.connect(target)
self.status = ConnectionStatus.CONNECTED
Expand Down Expand Up @@ -479,6 +480,7 @@ def receiveDataProcess(self, conn, remote_addr:tuple = None):
target = self.checkTarget(self.config["target"][0])
if not target:
raise Exception(_("Target error") + ": " + self.config["target"][0])
self.onConnectionStatus.emit(ConnectionStatus.CONNECTING, "")
conn = socket.socket()
conn.connect(target)
conn.settimeout(0.1)
Expand Down

0 comments on commit 2d7365c

Please sign in to comment.