From 8d3773368ebd3d241429c5aca2c793ca331336f6 Mon Sep 17 00:00:00 2001 From: nikzori Date: Tue, 24 Jun 2025 10:09:11 +0300 Subject: [PATCH] added WSP+ checkboxes for Premium Plus Wi-Fi --- Datasheet.cs | 54 +++++++++++++++++++++++++++++++------- Main.cs | 10 +++++++ Model.cs | 3 ++- Properties/AssemblyInfo.cs | 4 +-- 4 files changed, 58 insertions(+), 13 deletions(-) diff --git a/Datasheet.cs b/Datasheet.cs index 939d3ae..e304a06 100644 --- a/Datasheet.cs +++ b/Datasheet.cs @@ -83,10 +83,23 @@ namespace Gidrolock_Modbus_Scanner for (int i = 0; i < device.wiredSensors; i++) { - WiredSensor ws = new WiredSensor(i) { Width = 495, Height = 24 }; + WiredSensor ws = new WiredSensor(i,device) { Width = 495, Height = 24 }; sensorPanel.Controls.Add(ws); ws.Visible = true; + if (device.modelName == "PRPLS1") + { + ws.wspPlusEntry = device.wspPlusMode[i]; + ws.wspPlusCheckbox.CheckedChanged += (s, e) => + { + try + { + ushort value = ws.wspPlusCheckbox.Checked ? (ushort)0xFF00 : (ushort)0x0000; + SetEntry(ws.wspPlusEntry, value); + } + catch (Exception err) { MessageBox.Show(err.Message, "WSP+ toggle error"); } + }; + } } if (device.hasScenarioSensor) { @@ -197,6 +210,20 @@ namespace Gidrolock_Modbus_Scanner } } + if (device.wspPlusMode != null || device.wspPlusMode.Count > 0) + { + for(int i = 0; i < device.wspPlusMode.Count; i++) + { + res = PollEntry(device.wspPlusMode[i]); + if (res) + { + bool value = latestMessage.Data[0] > 0x00 ? true : false; + WiredSensor snsr = sensorPanel.Controls[i] as WiredSensor; + snsr.Invoke(new MethodInvoker(delegate { snsr.wspPlusCheckbox.Checked = value; })); + } + } + } + if (device.wiredLineBreak != null || device.wiredLineBreak.Count > 0) { for (int i = 0; i < device.wiredLineBreak.Count; i++) @@ -591,6 +618,8 @@ namespace Gidrolock_Modbus_Scanner } } + +#region Sensor Classes public class Sensor : FlowLayoutPanel { public Label labelName = new Label() { Width = 60, Height = 24 }; @@ -602,9 +631,10 @@ namespace Gidrolock_Modbus_Scanner public Label labelBreakFluff = new Label() { Width = 45, Height = 24 }; public Label labelBreak = new Label() { Width = 55, Height = 24 }; // обрыв линии для WSP+ - //public Label labelWSPPlusFluff = new Label() { Width = 45, Height = 24 }; - //public CheckBox wspPlusCheckbox = new CheckBox() { Width = 20, Height = 14 }; - public WiredSensor(int count) + public Label labelWSPPlusFluff; + public CheckBox wspPlusCheckbox; + public Entry wspPlusEntry; // for WSP+ control + public WiredSensor(int count, Device device) { this.Margin = Padding.Empty; this.Padding = new Padding(0, 5, 0, 0); @@ -620,9 +650,6 @@ namespace Gidrolock_Modbus_Scanner this.Controls.Add(labelLeakFluff); this.Controls.Add(labelLeak); - //this.Controls.Add(labelWSPPlusFluff); - //this.Controls.Add(wspPlusCheckbox); - labelName.Text = "WSP " + (count + 1); labelLeakFluff.Text = "Протечка:"; @@ -630,9 +657,15 @@ namespace Gidrolock_Modbus_Scanner labelBreakFluff.Text = "Обрыв:"; labelBreak.Text = "неизвестно"; + if (device.wspPlusMode != null || device.wspPlusMode.Count > 0) + { + labelWSPPlusFluff = new Label() { Width = 45, Height = 24, Text = "WSP+:" }; + wspPlusCheckbox = new CheckBox() { Width = 20, Height = 14, Margin = Padding.Empty }; + + this.Controls.Add(labelWSPPlusFluff); + this.Controls.Add(wspPlusCheckbox); + } - //labelWSPPlusFluff.Text = "WSP+:"; - //wspPlusCheckbox.Margin = Padding.Empty; } } @@ -686,4 +719,5 @@ namespace Gidrolock_Modbus_Scanner labelLeak.Text = "неизвестно"; } } -} \ No newline at end of file +} +#endregion \ No newline at end of file diff --git a/Main.cs b/Main.cs index b76e4d4..6cad569 100644 --- a/Main.cs +++ b/Main.cs @@ -376,6 +376,16 @@ namespace Gidrolock_Modbus_Scanner d.wiredSensors = 7; d.hasScenarioSensor = true; d.sensorAlarm = new Entry(RegisterType.Discrete, 1343, 29); + d.wspPlusMode = new List() + { + new Entry(RegisterType.Coil, 1041), + new Entry(RegisterType.Coil, 1042), + new Entry(RegisterType.Coil, 1043), + new Entry(RegisterType.Coil, 1044), + new Entry(RegisterType.Coil, 1045), + new Entry(RegisterType.Coil, 1046), + new Entry(RegisterType.Coil, 1047), + }; d.wiredLineBreak = new List() { new Entry(RegisterType.Discrete, 1025), diff --git a/Model.cs b/Model.cs index 8e89d13..dfe3ea2 100644 --- a/Model.cs +++ b/Model.cs @@ -25,8 +25,9 @@ namespace Gidrolock_Modbus_Scanner public bool hasScenarioSensor; public Entry sensorAlarm; + public List wspPlusMode; // Premium Plus only for now public List wiredLineBreak; - + public Entry radioStatus; } diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 82917e8..3c842a1 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -30,6 +30,6 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("0.9.5.0")] -[assembly: AssemblyFileVersion("0.9.5.0")] +[assembly: AssemblyVersion("1.1.0.0")] +[assembly: AssemblyFileVersion("1.1.0.0")] [assembly: NeutralResourcesLanguage("en")]