From 2ddbf5261288c81beb27a3dcb0f14a2bda3836b4 Mon Sep 17 00:00:00 2001 From: Autonomy Server Date: Thu, 17 Oct 2024 17:27:21 -0400 Subject: [PATCH] Added ability to write to coils on monitoring --- webserver/monitoring.py | 11 +++++++++++ webserver/pages.py | 32 +++++++++++++++++++++++++++----- webserver/webserver.py | 31 ++++++++++++++++++++++++------- 3 files changed, 62 insertions(+), 12 deletions(-) diff --git a/webserver/monitoring.py b/webserver/monitoring.py index 18b6184..c3062c1 100644 --- a/webserver/monitoring.py +++ b/webserver/monitoring.py @@ -122,6 +122,17 @@ def modbus_monitor(): if (monitor_active == True): threading.Timer(0.5, modbus_monitor).start() + +def write_value(point_address, point_value): + global mb_client + + # COILS + if (point_address.find('QX')) > 0: + mb_address = point_address.split('%QX')[1].split('.') + if (len(mb_address) < 2): + result = mb_client.write_coil(int(mb_address[0])*8, int(point_value)) + else: + result = mb_client.write_coil(int(mb_address[0])*8 + int(mb_address[1]), int(point_value)) def start_monitor(modbus_port_cfg): global monitor_active diff --git a/webserver/pages.py b/webserver/pages.py index dfcfd96..c5e7495 100644 --- a/webserver/pages.py +++ b/webserver/pages.py @@ -741,10 +741,6 @@ monitoring_head = """ background-color: #eeeeee; } - tr:hover { - cursor: hand;background-color: slategray; - } - label { font-family: arial, sans-serif; } @@ -802,6 +798,32 @@ monitoring_head = """ align-items: stretch; } } + + .write-button + { + display: inline-block; + width: 50px; + height: 30px; + margin-right: 5px; + padding: 0; + font-size: 12px; + cursor: pointer; + border: 1px solid #000000; + } + .write-button:last-child + { + margin-right: 0; + } + .write-button.true + { + background-color: #2366fc; + color: #ffffff; + } + .write-button.false + { + background-color: #ffffff; + color: #000000; + } """ @@ -814,7 +836,7 @@ monitoring_tail = """