From 9e61964393518f530257137e891ba64d73654324 Mon Sep 17 00:00:00 2001 From: "ADMINISTRATOR\\Administrator" <951937200@qq.com> Date: Wed, 31 Jan 2024 14:10:23 +0800 Subject: [PATCH] =?UTF-8?q?0131=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model/ProjectModel/DeviceManage.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/model/ProjectModel/DeviceManage.py b/model/ProjectModel/DeviceManage.py index ec346d3..e9008e6 100644 --- a/model/ProjectModel/DeviceManage.py +++ b/model/ProjectModel/DeviceManage.py @@ -142,7 +142,7 @@ class DevicesManange(): self.paSlaveDevices = collections.OrderedDict() self.dpSlaveModbus = TcpMaster(host = '192.168.2.10', port = 502) self.paSlaveModbus = TcpMaster(host = '192.168.4.10', port = 502) - self.dpMasterModbus = TcpMaster(host = '192.168.1.10', port = 502) + self.dpMasterModbus = TcpMaster(host = '192.168.0.40', port = 502) self.paMasterModbus = TcpMaster(host = '192.168.3.10', port = 502) @@ -226,7 +226,9 @@ class DevicesManange(): # print(values) for area, value in zip(areas, values): area.forceValue = value - if area.type in ['DI', 'DO']: + if area.type in ['DO', 'DI'] and device.type == 'PA': + area.forceValue = value[8:] + value[:8] + elif area.type in ['DO', 'DI'] and device.type == 'DP' and device.masterOrSlave == "主站": area.forceValue = value[8:] + value[:8] for device in curProDict.values(): @@ -296,7 +298,10 @@ class DevicesManange(): area.currentValue[i] = round(struct.unpack('!f', reorderBytes(byte, area.order))[0], 4) # print(round(struct.unpack('!f', reorderBytes(byte, area.order))[0], 4)) elif area.type in ['DI', 'DO']: - bytes = bytes[::-1] + if device.masterOrSlave == '主站' and device.type == 'DP': + bytes = bytes + else: + bytes = bytes[::-1] area.currentValue = bytesToCoils(bytes) # print(area.currentValue) @classmethod