1103更新

main
“zcw” 2 years ago
parent 489224378b
commit 0a2d14441d

@ -95,6 +95,7 @@ class MessageWidget(QWidget):
self.reButton.setText('停止刷新')
def addText(self):
try:
self.recvEdit.clear()
self.sendEdit.clear()
if self.decima == 16:
@ -111,3 +112,5 @@ class MessageWidget(QWidget):
for x in app.backend.client.lrange("10S" , 0 , -1):
text = str(x)[2:-1]
self.sendEdit.append(text)
except:
pass

@ -7,8 +7,8 @@ from protocol.Celery.MBRTUSlave import app
def afterRecv(args):
request16 = ' '.join(hex(x) for x in args[-1])
request10 = ' '.join(str(int(x, 16)) for x in request16.split(' '))
request16 = ' '.join([hex(value)[2:].zfill(2) if index not in [0, 1] else str(int(hex(value), 16)).zfill(2) for index, value in enumerate(args[-1])])
request10 = ' '.join(str(int(hex(value), 16)).zfill(2) for index, value in enumerate(args[-1]))
app.backend.client.rpush("16R", request16)
app.backend.client.rpush("10R", request10)
if app.backend.client.llen('16R') == 81:
@ -21,8 +21,8 @@ def afterRecv(args):
# print(request10)
def afterSend(args):
request16 = ' '.join(hex(x) for x in args[-1])
request10 = ' '.join(str(int(x, 16)) for x in request16.split(' '))
request16 = ' '.join([hex(value)[2:].zfill(2) if index not in [0, 1] else str(int(hex(value), 16)).zfill(2) for index, value in enumerate(args[-1])])
request10 = ' '.join(str(int(hex(value), 16)).zfill(2) for index, value in enumerate(args[-1]))
app.backend.client.rpush("16S", request16)
app.backend.client.rpush("10S", request10)
if app.backend.client.llen('16S') == 81:

@ -18,8 +18,8 @@ class RTUSlave():
self.server = modbus_rtu.RtuServer(serial.Serial(port = port, baudrate = baudrate, bytesize = bytesize, parity = parity, stopbits = stopbits, xonxoff = xonxoff))
except Exception as e:
return
hooks.install_hook("modbus_rtu.RtuServer.after_recv", afterRecv)
hooks.install_hook("modbus_rtu.RtuServer.after_send", afterSend)
hooks.install_hook('modbus.Server.before_handle_request', afterRecv)
hooks.install_hook("modbus.Server.after_handle_request", afterSend)
# self.server.set_timeout(5.0)
# self.server.set_verbose(True)

@ -17,7 +17,7 @@ class TcpMaster():
pass
hooks.install_hook("modbus_tcp.TcpMaster.after_recv", afterRecv)
hooks.install_hook("modbus_tcp.TcpMaster.after_send", afterSend)
hooks.install_hook("modbus_tcp.TcpMaster.before_send", afterSend)
def writeSingleRegister(self, slaveId, address, outputValue, order = 'ABCD'):
try:

@ -17,8 +17,8 @@ class TCPSlave():
except Exception as e:
pass
hooks.install_hook("modbus_tcp.TcpServer.after_recv", afterRecv)
hooks.install_hook("modbus_tcp.TcpServer.after_send", afterSend)
hooks.install_hook('modbus.Server.before_handle_request', afterRecv)
hooks.install_hook("modbus.Server.after_handle_request", afterSend)
# 创建从站
# 添加存储区

Loading…
Cancel
Save