update 更新界面显示_3

This commit is contained in:
FrankCV2048
2024-09-13 23:45:15 +08:00
parent cf4f114609
commit 96da34f983
59 changed files with 648 additions and 27743 deletions

View File

@ -1,8 +1,12 @@
import json
import logging
import socket
import threading
import time
import Constant
from Util.util_log import log
class TCPClient:
def __init__(self, ip, port):
self.error_count=0
@ -29,7 +33,7 @@ class TCPClient:
def run(self):
while True:
time.sleep(0.2)
self.connected = (self.error_count > 3)
self.connected = (self.error_count <= 3)
try:
if (self.send_Status() and self.send_Command()):
self.error_count = 0
@ -37,12 +41,15 @@ class TCPClient:
self.error_count += 1
if self.error_count> 5:
print("Error: TCPClient is not connected")
log.log_message(logging.ERROR,Constant.str_tcp_connect_no_reply)
try:
self.CreatConnect()
log.log_message(logging.INFO, Constant.str_tcp_reconnect)
except OSError as e1:
if e1.errno == 10056:
self.client_socket.close()
print("Error: TCPClient is not connected")
log.log_message(logging.ERROR,Constant.str_tcp_connect_error)
except Exception as e2:
print(e2)