2 Commits

Author SHA1 Message Date
nikzori
a283537d5e fixed app crash for Standard Radio 2025-06-24 12:05:20 +03:00
nikzori
8d3773368e added WSP+ checkboxes for Premium Plus Wi-Fi 2025-06-24 10:09:11 +03:00
4 changed files with 71 additions and 23 deletions

View File

@@ -83,10 +83,23 @@ namespace Gidrolock_Modbus_Scanner
for (int i = 0; i < device.wiredSensors; i++) 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); sensorPanel.Controls.Add(ws);
ws.Visible = true; 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) if (device.hasScenarioSensor)
{ {
@@ -197,7 +210,23 @@ namespace Gidrolock_Modbus_Scanner
} }
} }
if (device.wiredLineBreak != null || device.wiredLineBreak.Count > 0) if (device.wspPlusMode != null)
if (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)
if(device.wiredLineBreak.Count > 0)
{ {
for (int i = 0; i < device.wiredLineBreak.Count; i++) for (int i = 0; i < device.wiredLineBreak.Count; i++)
{ {
@@ -591,6 +620,8 @@ namespace Gidrolock_Modbus_Scanner
} }
} }
#region Sensor Classes
public class Sensor : FlowLayoutPanel public class Sensor : FlowLayoutPanel
{ {
public Label labelName = new Label() { Width = 60, Height = 24 }; public Label labelName = new Label() { Width = 60, Height = 24 };
@@ -602,9 +633,10 @@ namespace Gidrolock_Modbus_Scanner
public Label labelBreakFluff = new Label() { Width = 45, Height = 24 }; public Label labelBreakFluff = new Label() { Width = 45, Height = 24 };
public Label labelBreak = new Label() { Width = 55, Height = 24 }; // обрыв линии для WSP+ public Label labelBreak = new Label() { Width = 55, Height = 24 }; // обрыв линии для WSP+
//public Label labelWSPPlusFluff = new Label() { Width = 45, Height = 24 }; public Label labelWSPPlusFluff;
//public CheckBox wspPlusCheckbox = new CheckBox() { Width = 20, Height = 14 }; public CheckBox wspPlusCheckbox;
public WiredSensor(int count) public Entry wspPlusEntry; // for WSP+ control
public WiredSensor(int count, Device device)
{ {
this.Margin = Padding.Empty; this.Margin = Padding.Empty;
this.Padding = new Padding(0, 5, 0, 0); this.Padding = new Padding(0, 5, 0, 0);
@@ -620,9 +652,6 @@ namespace Gidrolock_Modbus_Scanner
this.Controls.Add(labelLeakFluff); this.Controls.Add(labelLeakFluff);
this.Controls.Add(labelLeak); this.Controls.Add(labelLeak);
//this.Controls.Add(labelWSPPlusFluff);
//this.Controls.Add(wspPlusCheckbox);
labelName.Text = "WSP " + (count + 1); labelName.Text = "WSP " + (count + 1);
labelLeakFluff.Text = "Протечка:"; labelLeakFluff.Text = "Протечка:";
@@ -630,9 +659,16 @@ namespace Gidrolock_Modbus_Scanner
labelBreakFluff.Text = "Обрыв:"; labelBreakFluff.Text = "Обрыв:";
labelBreak.Text = "неизвестно"; labelBreak.Text = "неизвестно";
if (device.wspPlusMode != null)
if (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;
} }
} }
@@ -687,3 +723,4 @@ namespace Gidrolock_Modbus_Scanner
} }
} }
} }
#endregion

10
Main.cs
View File

@@ -376,6 +376,16 @@ namespace Gidrolock_Modbus_Scanner
d.wiredSensors = 7; d.wiredSensors = 7;
d.hasScenarioSensor = true; d.hasScenarioSensor = true;
d.sensorAlarm = new Entry(RegisterType.Discrete, 1343, 29); d.sensorAlarm = new Entry(RegisterType.Discrete, 1343, 29);
d.wspPlusMode = new List<Entry>()
{
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<Entry>() d.wiredLineBreak = new List<Entry>()
{ {
new Entry(RegisterType.Discrete, 1025), new Entry(RegisterType.Discrete, 1025),

View File

@@ -25,6 +25,7 @@ namespace Gidrolock_Modbus_Scanner
public bool hasScenarioSensor; public bool hasScenarioSensor;
public Entry sensorAlarm; public Entry sensorAlarm;
public List<Entry> wspPlusMode; // Premium Plus only for now
public List<Entry> wiredLineBreak; public List<Entry> wiredLineBreak;
public Entry radioStatus; public Entry radioStatus;

View File

@@ -30,6 +30,6 @@ using System.Runtime.InteropServices;
// Build Number // Build Number
// Revision // Revision
// //
[assembly: AssemblyVersion("0.9.5.0")] [assembly: AssemblyVersion("1.1.1.0")]
[assembly: AssemblyFileVersion("0.9.5.0")] [assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: NeutralResourcesLanguage("en")] [assembly: NeutralResourcesLanguage("en")]