From 13309de68e4460281d2ff62bb61f2492aac510f6 Mon Sep 17 00:00:00 2001 From: zcwBit Date: Mon, 30 Jun 2025 15:08:03 +0800 Subject: [PATCH] =?UTF-8?q?0630=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- UI/VarManages/AnalogModel.py | 2 +- protocol/ProtocolManage.py | 3 ++- protocol/TCP/IOTCPClinet.py | 4 +++- protocol/TCP/TCPVarManage.py | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/UI/VarManages/AnalogModel.py b/UI/VarManages/AnalogModel.py index 2f0d3ec..9f489c7 100644 --- a/UI/VarManages/AnalogModel.py +++ b/UI/VarManages/AnalogModel.py @@ -3,7 +3,7 @@ import qtawesome from PyQt5 import QtGui from PyQt5.QtCore import Qt, QVariant, QTimer from PyQt5.QtWidgets import QMessageBox -from websocket import send +# from websocket import send from protocol.TCP.Analog import getRealAO from model.ProjectModel.VarManage import * from UI.VarManages.ModbusModel import * diff --git a/protocol/ProtocolManage.py b/protocol/ProtocolManage.py index 4923eb0..16208ce 100644 --- a/protocol/ProtocolManage.py +++ b/protocol/ProtocolManage.py @@ -17,7 +17,7 @@ class ProtocolManage(object): ] def __init__(self): - self.tcpVarManager = TCPVarManager('127.0.0.1', 8000) + self.tcpVarManager = TCPVarManager('192.168.1.50', 5055) self.writeTC = [0] * 8 self.writeRTD = [0] * 8 @@ -189,6 +189,7 @@ class ProtocolManage(object): model = self.getModelType(varModel) value = self.tcpVarManager.readValue(varType, channel, model=model) if varType in ['AI','AO']: + # print(value) value = self.getRealAI(value, info['max'], info['min']) return value # print(1) diff --git a/protocol/TCP/IOTCPClinet.py b/protocol/TCP/IOTCPClinet.py index 4822e18..2f37698 100644 --- a/protocol/TCP/IOTCPClinet.py +++ b/protocol/TCP/IOTCPClinet.py @@ -112,6 +112,7 @@ class TCPCommunicator: self.sock.sendall(packet) self.packetCounter += 1 + return current_counter except Exception as e: logging.error(f"Send error: {e}") @@ -299,6 +300,7 @@ class TCPCommunicator: def writeAo(self, aoData): """同步写入AO数据并返回结果""" packetNum = self.sendCommand(self.CMD_WRITE_AO, aoData) + # print(packetNum) if packetNum is None: return False return self.waitForResponse(packetNum, self.CMD_WRITE_AO) or False @@ -425,7 +427,7 @@ def write_worker(communicator, interval): ] # 写入AO数据 - print(len(ao_data), ao_data) + # print(len(ao_data), ao_data) communicator.writeAo(ao_data) # 等待指定间隔 diff --git a/protocol/TCP/TCPVarManage.py b/protocol/TCP/TCPVarManage.py index 9a99003..a1e9b50 100644 --- a/protocol/TCP/TCPVarManage.py +++ b/protocol/TCP/TCPVarManage.py @@ -143,6 +143,7 @@ class TCPVarManager: success = self.communicator.writeAo(data) if not success: logging.warning("AO/DO write operation failed") + # print(success) return success except Exception as e: logging.error(f"Error writing AO/DO: {e}") @@ -203,7 +204,7 @@ class TCPVarManager: *self.AODATA, # 16: 输出模式(0:无输出/1:正常输出/2:触发输出) - 2, # 正常输出 + 1, # 正常输出 # 17: 触发类型(0:无触发 1:fpga触发/2:TC触发/3:RTD触发) 0, # 正常写入