Premium Plus support added
This commit is contained in:
129
Datasheet.Designer.cs
generated
129
Datasheet.Designer.cs
generated
@@ -30,6 +30,8 @@
|
|||||||
{
|
{
|
||||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Datasheet));
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Datasheet));
|
||||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||||
|
this.labelBattery = new System.Windows.Forms.Label();
|
||||||
|
this.label6 = new System.Windows.Forms.Label();
|
||||||
this.buttonPoll = new System.Windows.Forms.Button();
|
this.buttonPoll = new System.Windows.Forms.Button();
|
||||||
this.buttonSetID = new System.Windows.Forms.Button();
|
this.buttonSetID = new System.Windows.Forms.Button();
|
||||||
this.labelFirmware = new System.Windows.Forms.Label();
|
this.labelFirmware = new System.Windows.Forms.Label();
|
||||||
@@ -42,17 +44,15 @@
|
|||||||
this.labelCleaning = new System.Windows.Forms.Label();
|
this.labelCleaning = new System.Windows.Forms.Label();
|
||||||
this.buttonCleaning = new System.Windows.Forms.Button();
|
this.buttonCleaning = new System.Windows.Forms.Button();
|
||||||
this.label7 = new System.Windows.Forms.Label();
|
this.label7 = new System.Windows.Forms.Label();
|
||||||
this.label6 = new System.Windows.Forms.Label();
|
this.labelAlarm = new System.Windows.Forms.Label();
|
||||||
this.label5 = new System.Windows.Forms.Label();
|
this.label5 = new System.Windows.Forms.Label();
|
||||||
this.button2 = new System.Windows.Forms.Button();
|
this.button2 = new System.Windows.Forms.Button();
|
||||||
this.buttonAlarm = new System.Windows.Forms.Button();
|
this.buttonAlarm = new System.Windows.Forms.Button();
|
||||||
this.buttonValve = new System.Windows.Forms.Button();
|
this.buttonValve = new System.Windows.Forms.Button();
|
||||||
this.labelValve = new System.Windows.Forms.Label();
|
this.labelValve = new System.Windows.Forms.Label();
|
||||||
this.label4 = new System.Windows.Forms.Label();
|
this.label4 = new System.Windows.Forms.Label();
|
||||||
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
|
this.sensorPanel = new System.Windows.Forms.FlowLayoutPanel();
|
||||||
this.label9 = new System.Windows.Forms.Label();
|
this.label9 = new System.Windows.Forms.Label();
|
||||||
this.label10 = new System.Windows.Forms.Label();
|
|
||||||
this.flowLayoutPanel2 = new System.Windows.Forms.FlowLayoutPanel();
|
|
||||||
this.groupBox1.SuspendLayout();
|
this.groupBox1.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.nudModbusID)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.nudModbusID)).BeginInit();
|
||||||
this.groupBox2.SuspendLayout();
|
this.groupBox2.SuspendLayout();
|
||||||
@@ -60,6 +60,8 @@
|
|||||||
//
|
//
|
||||||
// groupBox1
|
// groupBox1
|
||||||
//
|
//
|
||||||
|
this.groupBox1.Controls.Add(this.labelBattery);
|
||||||
|
this.groupBox1.Controls.Add(this.label6);
|
||||||
this.groupBox1.Controls.Add(this.buttonPoll);
|
this.groupBox1.Controls.Add(this.buttonPoll);
|
||||||
this.groupBox1.Controls.Add(this.buttonSetID);
|
this.groupBox1.Controls.Add(this.buttonSetID);
|
||||||
this.groupBox1.Controls.Add(this.labelFirmware);
|
this.groupBox1.Controls.Add(this.labelFirmware);
|
||||||
@@ -68,17 +70,35 @@
|
|||||||
this.groupBox1.Controls.Add(this.label3);
|
this.groupBox1.Controls.Add(this.label3);
|
||||||
this.groupBox1.Controls.Add(this.label2);
|
this.groupBox1.Controls.Add(this.label2);
|
||||||
this.groupBox1.Controls.Add(this.label1);
|
this.groupBox1.Controls.Add(this.label1);
|
||||||
this.groupBox1.Location = new System.Drawing.Point(369, 12);
|
this.groupBox1.Location = new System.Drawing.Point(304, 12);
|
||||||
this.groupBox1.Name = "groupBox1";
|
this.groupBox1.Name = "groupBox1";
|
||||||
this.groupBox1.Size = new System.Drawing.Size(211, 101);
|
this.groupBox1.Size = new System.Drawing.Size(221, 101);
|
||||||
this.groupBox1.TabIndex = 0;
|
this.groupBox1.TabIndex = 0;
|
||||||
this.groupBox1.TabStop = false;
|
this.groupBox1.TabStop = false;
|
||||||
this.groupBox1.Text = "Инфо";
|
this.groupBox1.Text = "Инфо";
|
||||||
//
|
//
|
||||||
|
// labelBattery
|
||||||
|
//
|
||||||
|
this.labelBattery.AutoSize = true;
|
||||||
|
this.labelBattery.Location = new System.Drawing.Point(59, 48);
|
||||||
|
this.labelBattery.Name = "labelBattery";
|
||||||
|
this.labelBattery.Size = new System.Drawing.Size(15, 13);
|
||||||
|
this.labelBattery.TabIndex = 9;
|
||||||
|
this.labelBattery.Text = "%";
|
||||||
|
//
|
||||||
|
// label6
|
||||||
|
//
|
||||||
|
this.label6.AutoSize = true;
|
||||||
|
this.label6.Location = new System.Drawing.Point(6, 48);
|
||||||
|
this.label6.Name = "label6";
|
||||||
|
this.label6.Size = new System.Drawing.Size(52, 13);
|
||||||
|
this.label6.TabIndex = 8;
|
||||||
|
this.label6.Text = "Батарея:";
|
||||||
|
//
|
||||||
// buttonPoll
|
// buttonPoll
|
||||||
//
|
//
|
||||||
this.buttonPoll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
this.buttonPoll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.buttonPoll.Location = new System.Drawing.Point(130, 19);
|
this.buttonPoll.Location = new System.Drawing.Point(140, 43);
|
||||||
this.buttonPoll.Name = "buttonPoll";
|
this.buttonPoll.Name = "buttonPoll";
|
||||||
this.buttonPoll.Size = new System.Drawing.Size(75, 23);
|
this.buttonPoll.Size = new System.Drawing.Size(75, 23);
|
||||||
this.buttonPoll.TabIndex = 7;
|
this.buttonPoll.TabIndex = 7;
|
||||||
@@ -88,7 +108,7 @@
|
|||||||
//
|
//
|
||||||
// buttonSetID
|
// buttonSetID
|
||||||
//
|
//
|
||||||
this.buttonSetID.Location = new System.Drawing.Point(130, 55);
|
this.buttonSetID.Location = new System.Drawing.Point(140, 68);
|
||||||
this.buttonSetID.Name = "buttonSetID";
|
this.buttonSetID.Name = "buttonSetID";
|
||||||
this.buttonSetID.Size = new System.Drawing.Size(75, 23);
|
this.buttonSetID.Size = new System.Drawing.Size(75, 23);
|
||||||
this.buttonSetID.TabIndex = 6;
|
this.buttonSetID.TabIndex = 6;
|
||||||
@@ -110,13 +130,13 @@
|
|||||||
this.labelModel.AutoSize = true;
|
this.labelModel.AutoSize = true;
|
||||||
this.labelModel.Location = new System.Drawing.Point(61, 16);
|
this.labelModel.Location = new System.Drawing.Point(61, 16);
|
||||||
this.labelModel.Name = "labelModel";
|
this.labelModel.Name = "labelModel";
|
||||||
this.labelModel.Size = new System.Drawing.Size(50, 13);
|
this.labelModel.Size = new System.Drawing.Size(46, 13);
|
||||||
this.labelModel.TabIndex = 4;
|
this.labelModel.TabIndex = 4;
|
||||||
this.labelModel.Text = "Standard";
|
this.labelModel.Text = "Модель";
|
||||||
//
|
//
|
||||||
// nudModbusID
|
// nudModbusID
|
||||||
//
|
//
|
||||||
this.nudModbusID.Location = new System.Drawing.Point(74, 58);
|
this.nudModbusID.Location = new System.Drawing.Point(74, 71);
|
||||||
this.nudModbusID.Name = "nudModbusID";
|
this.nudModbusID.Name = "nudModbusID";
|
||||||
this.nudModbusID.Size = new System.Drawing.Size(50, 20);
|
this.nudModbusID.Size = new System.Drawing.Size(50, 20);
|
||||||
this.nudModbusID.TabIndex = 3;
|
this.nudModbusID.TabIndex = 3;
|
||||||
@@ -124,7 +144,7 @@
|
|||||||
// label3
|
// label3
|
||||||
//
|
//
|
||||||
this.label3.AutoSize = true;
|
this.label3.AutoSize = true;
|
||||||
this.label3.Location = new System.Drawing.Point(6, 60);
|
this.label3.Location = new System.Drawing.Point(6, 73);
|
||||||
this.label3.Name = "label3";
|
this.label3.Name = "label3";
|
||||||
this.label3.Size = new System.Drawing.Size(62, 13);
|
this.label3.Size = new System.Drawing.Size(62, 13);
|
||||||
this.label3.TabIndex = 2;
|
this.label3.TabIndex = 2;
|
||||||
@@ -153,7 +173,7 @@
|
|||||||
this.groupBox2.Controls.Add(this.labelCleaning);
|
this.groupBox2.Controls.Add(this.labelCleaning);
|
||||||
this.groupBox2.Controls.Add(this.buttonCleaning);
|
this.groupBox2.Controls.Add(this.buttonCleaning);
|
||||||
this.groupBox2.Controls.Add(this.label7);
|
this.groupBox2.Controls.Add(this.label7);
|
||||||
this.groupBox2.Controls.Add(this.label6);
|
this.groupBox2.Controls.Add(this.labelAlarm);
|
||||||
this.groupBox2.Controls.Add(this.label5);
|
this.groupBox2.Controls.Add(this.label5);
|
||||||
this.groupBox2.Controls.Add(this.button2);
|
this.groupBox2.Controls.Add(this.button2);
|
||||||
this.groupBox2.Controls.Add(this.buttonAlarm);
|
this.groupBox2.Controls.Add(this.buttonAlarm);
|
||||||
@@ -162,7 +182,7 @@
|
|||||||
this.groupBox2.Controls.Add(this.label4);
|
this.groupBox2.Controls.Add(this.label4);
|
||||||
this.groupBox2.Location = new System.Drawing.Point(13, 12);
|
this.groupBox2.Location = new System.Drawing.Point(13, 12);
|
||||||
this.groupBox2.Name = "groupBox2";
|
this.groupBox2.Name = "groupBox2";
|
||||||
this.groupBox2.Size = new System.Drawing.Size(350, 100);
|
this.groupBox2.Size = new System.Drawing.Size(285, 100);
|
||||||
this.groupBox2.TabIndex = 1;
|
this.groupBox2.TabIndex = 1;
|
||||||
this.groupBox2.TabStop = false;
|
this.groupBox2.TabStop = false;
|
||||||
this.groupBox2.Text = "Общее";
|
this.groupBox2.Text = "Общее";
|
||||||
@@ -170,7 +190,7 @@
|
|||||||
// labelCleaning
|
// labelCleaning
|
||||||
//
|
//
|
||||||
this.labelCleaning.AutoSize = true;
|
this.labelCleaning.AutoSize = true;
|
||||||
this.labelCleaning.Location = new System.Drawing.Point(52, 78);
|
this.labelCleaning.Location = new System.Drawing.Point(52, 77);
|
||||||
this.labelCleaning.Name = "labelCleaning";
|
this.labelCleaning.Name = "labelCleaning";
|
||||||
this.labelCleaning.Size = new System.Drawing.Size(33, 13);
|
this.labelCleaning.Size = new System.Drawing.Size(33, 13);
|
||||||
this.labelCleaning.TabIndex = 9;
|
this.labelCleaning.TabIndex = 9;
|
||||||
@@ -178,7 +198,7 @@
|
|||||||
//
|
//
|
||||||
// buttonCleaning
|
// buttonCleaning
|
||||||
//
|
//
|
||||||
this.buttonCleaning.Location = new System.Drawing.Point(192, 73);
|
this.buttonCleaning.Location = new System.Drawing.Point(125, 72);
|
||||||
this.buttonCleaning.Name = "buttonCleaning";
|
this.buttonCleaning.Name = "buttonCleaning";
|
||||||
this.buttonCleaning.Size = new System.Drawing.Size(73, 23);
|
this.buttonCleaning.Size = new System.Drawing.Size(73, 23);
|
||||||
this.buttonCleaning.TabIndex = 8;
|
this.buttonCleaning.TabIndex = 8;
|
||||||
@@ -189,20 +209,20 @@
|
|||||||
// label7
|
// label7
|
||||||
//
|
//
|
||||||
this.label7.AutoSize = true;
|
this.label7.AutoSize = true;
|
||||||
this.label7.Location = new System.Drawing.Point(6, 78);
|
this.label7.Location = new System.Drawing.Point(6, 77);
|
||||||
this.label7.Name = "label7";
|
this.label7.Name = "label7";
|
||||||
this.label7.Size = new System.Drawing.Size(48, 13);
|
this.label7.Size = new System.Drawing.Size(48, 13);
|
||||||
this.label7.TabIndex = 7;
|
this.label7.TabIndex = 7;
|
||||||
this.label7.Text = "Уборка:";
|
this.label7.Text = "Уборка:";
|
||||||
//
|
//
|
||||||
// label6
|
// labelAlarm
|
||||||
//
|
//
|
||||||
this.label6.AutoSize = true;
|
this.labelAlarm.AutoSize = true;
|
||||||
this.label6.Location = new System.Drawing.Point(61, 48);
|
this.labelAlarm.Location = new System.Drawing.Point(61, 48);
|
||||||
this.label6.Name = "label6";
|
this.labelAlarm.Name = "labelAlarm";
|
||||||
this.label6.Size = new System.Drawing.Size(24, 13);
|
this.labelAlarm.Size = new System.Drawing.Size(24, 13);
|
||||||
this.label6.TabIndex = 6;
|
this.labelAlarm.TabIndex = 6;
|
||||||
this.label6.Text = "нет";
|
this.labelAlarm.Text = "нет";
|
||||||
//
|
//
|
||||||
// label5
|
// label5
|
||||||
//
|
//
|
||||||
@@ -215,7 +235,7 @@
|
|||||||
//
|
//
|
||||||
// button2
|
// button2
|
||||||
//
|
//
|
||||||
this.button2.Location = new System.Drawing.Point(271, 14);
|
this.button2.Location = new System.Drawing.Point(204, 14);
|
||||||
this.button2.Name = "button2";
|
this.button2.Name = "button2";
|
||||||
this.button2.Size = new System.Drawing.Size(73, 52);
|
this.button2.Size = new System.Drawing.Size(73, 52);
|
||||||
this.button2.TabIndex = 4;
|
this.button2.TabIndex = 4;
|
||||||
@@ -224,7 +244,7 @@
|
|||||||
//
|
//
|
||||||
// buttonAlarm
|
// buttonAlarm
|
||||||
//
|
//
|
||||||
this.buttonAlarm.Location = new System.Drawing.Point(192, 43);
|
this.buttonAlarm.Location = new System.Drawing.Point(125, 43);
|
||||||
this.buttonAlarm.Name = "buttonAlarm";
|
this.buttonAlarm.Name = "buttonAlarm";
|
||||||
this.buttonAlarm.Size = new System.Drawing.Size(73, 23);
|
this.buttonAlarm.Size = new System.Drawing.Size(73, 23);
|
||||||
this.buttonAlarm.TabIndex = 3;
|
this.buttonAlarm.TabIndex = 3;
|
||||||
@@ -234,7 +254,7 @@
|
|||||||
//
|
//
|
||||||
// buttonValve
|
// buttonValve
|
||||||
//
|
//
|
||||||
this.buttonValve.Location = new System.Drawing.Point(192, 14);
|
this.buttonValve.Location = new System.Drawing.Point(125, 14);
|
||||||
this.buttonValve.Name = "buttonValve";
|
this.buttonValve.Name = "buttonValve";
|
||||||
this.buttonValve.Size = new System.Drawing.Size(73, 23);
|
this.buttonValve.Size = new System.Drawing.Size(73, 23);
|
||||||
this.buttonValve.TabIndex = 2;
|
this.buttonValve.TabIndex = 2;
|
||||||
@@ -260,58 +280,41 @@
|
|||||||
this.label4.TabIndex = 0;
|
this.label4.TabIndex = 0;
|
||||||
this.label4.Text = "Кран:";
|
this.label4.Text = "Кран:";
|
||||||
//
|
//
|
||||||
// flowLayoutPanel1
|
// sensorPanel
|
||||||
//
|
//
|
||||||
this.flowLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
this.sensorPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||||
| System.Windows.Forms.AnchorStyles.Left)));
|
| System.Windows.Forms.AnchorStyles.Left)));
|
||||||
this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
|
this.sensorPanel.AutoScroll = true;
|
||||||
this.flowLayoutPanel1.Location = new System.Drawing.Point(13, 135);
|
this.sensorPanel.BackColor = System.Drawing.Color.Gainsboro;
|
||||||
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
|
this.sensorPanel.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
|
||||||
this.flowLayoutPanel1.Size = new System.Drawing.Size(280, 175);
|
this.sensorPanel.Location = new System.Drawing.Point(13, 135);
|
||||||
this.flowLayoutPanel1.TabIndex = 4;
|
this.sensorPanel.Name = "sensorPanel";
|
||||||
|
this.sensorPanel.Size = new System.Drawing.Size(512, 175);
|
||||||
|
this.sensorPanel.TabIndex = 4;
|
||||||
|
this.sensorPanel.WrapContents = false;
|
||||||
//
|
//
|
||||||
// label9
|
// label9
|
||||||
//
|
//
|
||||||
this.label9.AutoSize = true;
|
this.label9.AutoSize = true;
|
||||||
this.label9.Location = new System.Drawing.Point(10, 119);
|
this.label9.Location = new System.Drawing.Point(10, 119);
|
||||||
this.label9.Name = "label9";
|
this.label9.Name = "label9";
|
||||||
this.label9.Size = new System.Drawing.Size(108, 13);
|
this.label9.Size = new System.Drawing.Size(50, 13);
|
||||||
this.label9.TabIndex = 5;
|
this.label9.TabIndex = 5;
|
||||||
this.label9.Text = "Проводные датчики";
|
this.label9.Text = "Датчики";
|
||||||
//
|
|
||||||
// label10
|
|
||||||
//
|
|
||||||
this.label10.AutoSize = true;
|
|
||||||
this.label10.Location = new System.Drawing.Point(297, 119);
|
|
||||||
this.label10.Name = "label10";
|
|
||||||
this.label10.Size = new System.Drawing.Size(78, 13);
|
|
||||||
this.label10.TabIndex = 7;
|
|
||||||
this.label10.Text = "Радиодатчики";
|
|
||||||
//
|
|
||||||
// flowLayoutPanel2
|
|
||||||
//
|
|
||||||
this.flowLayoutPanel2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
|
||||||
| System.Windows.Forms.AnchorStyles.Left)));
|
|
||||||
this.flowLayoutPanel2.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
|
|
||||||
this.flowLayoutPanel2.Location = new System.Drawing.Point(300, 135);
|
|
||||||
this.flowLayoutPanel2.Name = "flowLayoutPanel2";
|
|
||||||
this.flowLayoutPanel2.Size = new System.Drawing.Size(280, 175);
|
|
||||||
this.flowLayoutPanel2.TabIndex = 6;
|
|
||||||
//
|
//
|
||||||
// Datasheet
|
// Datasheet
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(592, 322);
|
this.ClientSize = new System.Drawing.Size(537, 322);
|
||||||
this.Controls.Add(this.label10);
|
|
||||||
this.Controls.Add(this.flowLayoutPanel2);
|
|
||||||
this.Controls.Add(this.label9);
|
this.Controls.Add(this.label9);
|
||||||
this.Controls.Add(this.flowLayoutPanel1);
|
this.Controls.Add(this.sensorPanel);
|
||||||
this.Controls.Add(this.groupBox2);
|
this.Controls.Add(this.groupBox2);
|
||||||
this.Controls.Add(this.groupBox1);
|
this.Controls.Add(this.groupBox1);
|
||||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||||
this.MaximizeBox = false;
|
this.MaximizeBox = false;
|
||||||
this.Name = "Datasheet";
|
this.Name = "Datasheet";
|
||||||
|
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
|
||||||
this.Text = "Datasheet";
|
this.Text = "Datasheet";
|
||||||
this.groupBox1.ResumeLayout(false);
|
this.groupBox1.ResumeLayout(false);
|
||||||
this.groupBox1.PerformLayout();
|
this.groupBox1.PerformLayout();
|
||||||
@@ -344,10 +347,10 @@
|
|||||||
private System.Windows.Forms.Label labelCleaning;
|
private System.Windows.Forms.Label labelCleaning;
|
||||||
private System.Windows.Forms.Button buttonCleaning;
|
private System.Windows.Forms.Button buttonCleaning;
|
||||||
private System.Windows.Forms.Label label7;
|
private System.Windows.Forms.Label label7;
|
||||||
private System.Windows.Forms.Label label6;
|
private System.Windows.Forms.Label labelAlarm;
|
||||||
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
|
private System.Windows.Forms.FlowLayoutPanel sensorPanel;
|
||||||
private System.Windows.Forms.Label label9;
|
private System.Windows.Forms.Label label9;
|
||||||
private System.Windows.Forms.Label label10;
|
private System.Windows.Forms.Label label6;
|
||||||
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel2;
|
private System.Windows.Forms.Label labelBattery;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
373
Datasheet.cs
373
Datasheet.cs
@@ -1,28 +1,21 @@
|
|||||||
using System;
|
using Newtonsoft.Json.Linq;
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO.Ports;
|
using System.IO.Ports;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using System.Xml;
|
|
||||||
|
|
||||||
|
|
||||||
namespace Gidrolock_Modbus_Scanner
|
namespace Gidrolock_Modbus_Scanner
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
* This is more of a View than a View-Controller
|
|
||||||
* Relegate everything to interface functions for models
|
|
||||||
*/
|
|
||||||
public partial class Datasheet : Form
|
public partial class Datasheet : Form
|
||||||
{
|
{
|
||||||
byte modbusID;
|
byte modbusID;
|
||||||
Device device;
|
Device device;
|
||||||
|
|
||||||
byte[] message;
|
ModbusResponseEventArgs latestMessage;
|
||||||
byte[] data;
|
|
||||||
EventHandler<ModbusResponseEventArgs> handler;
|
|
||||||
|
|
||||||
SerialPort port = Modbus.port;
|
SerialPort port = Modbus.port;
|
||||||
bool isPolling = false;
|
bool isPolling = false;
|
||||||
@@ -33,86 +26,378 @@ namespace Gidrolock_Modbus_Scanner
|
|||||||
bool alarmStatus = false;
|
bool alarmStatus = false;
|
||||||
bool cleaningStatus = false;
|
bool cleaningStatus = false;
|
||||||
|
|
||||||
public Datasheet(byte modbusID, Device device)
|
List<WiredSensor> wiredSensors = new List<WiredSensor>();
|
||||||
|
List<WirelessSensor> wirelessSensors;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public Datasheet(byte modbusID, Device device) : base()
|
||||||
{
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
nudModbusID.Minimum = 1;
|
nudModbusID.Minimum = 1;
|
||||||
nudModbusID.Maximum = 246;
|
nudModbusID.Maximum = 246;
|
||||||
|
nudModbusID.Value = modbusID;
|
||||||
this.modbusID = modbusID;
|
this.modbusID = modbusID;
|
||||||
this.device = device;
|
this.device = device;
|
||||||
|
|
||||||
|
labelModel.Text = device.name;
|
||||||
|
labelFirmware.Text = "v???";
|
||||||
|
|
||||||
if (!device.hasCleaningMode)
|
if (!device.hasCleaningMode)
|
||||||
{
|
{
|
||||||
labelCleaning.Text = "Недоступна.";
|
labelCleaning.Text = "Недоступна.";
|
||||||
buttonCleaning.Enabled = false;
|
buttonCleaning.Enabled = false;
|
||||||
}
|
}
|
||||||
|
if (!device.hasBattery)
|
||||||
|
labelBattery.Text = "Нет";
|
||||||
|
else labelBattery.Text = "???%";
|
||||||
|
|
||||||
handler = (sndr, msg) =>
|
Modbus.ResponseReceived += (sndr, msg) => { isAwaitingResponse = false; latestMessage = msg; };
|
||||||
|
|
||||||
|
for (int i = 0; i < device.wiredSensors; i++)
|
||||||
{
|
{
|
||||||
message = msg.Message;
|
WiredSensor ws = new WiredSensor(i) { Width = 495, Height = 24 };
|
||||||
data = msg.Data;
|
sensorPanel.Controls.Add(ws);
|
||||||
};
|
ws.Visible = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
if (device.hasScenarioSensor)
|
||||||
|
{
|
||||||
|
ScenarioSensor scenSen = new ScenarioSensor() { Width = 495, Height = 24 };
|
||||||
|
sensorPanel.Controls.Add(scenSen);
|
||||||
|
scenSen.Visible = true;
|
||||||
|
}
|
||||||
|
if (device.wiredSensors < device.sensorsAlarm.length)
|
||||||
|
{
|
||||||
|
wirelessSensors = new List<WirelessSensor>();
|
||||||
|
int wsrIndex = device.sensorsAlarm.length - device.wiredSensors - (device.hasScenarioSensor ? 1 : 0);
|
||||||
|
for (int i = 0; i < wsrIndex; i++)
|
||||||
|
{
|
||||||
|
WirelessSensor wsr = new WirelessSensor(i) { Width = 495, Height = 24 };
|
||||||
|
sensorPanel.Controls.Add(wsr);
|
||||||
|
wsr.Visible = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < sensorPanel.Controls.Count; i++)
|
||||||
|
sensorPanel.Controls[i].BackColor = i % 2 == 0 ? Color.White : Color.LightGray;
|
||||||
|
|
||||||
|
|
||||||
|
sensorPanel.Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void buttonPoll_Click(object sender, EventArgs e)
|
private async void buttonPoll_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
// hardcoded for now, probably easier to keep it like this in the future
|
// hardcoded for now, probably easier to keep it like this in the future
|
||||||
if (await PollEntry(device.valveStatus))
|
try
|
||||||
{
|
{
|
||||||
if (data.Last() > 0)
|
bool res = await PollEntry(device.valveStatus); // for some reason main thread doesn't go
|
||||||
labelValve.Text = "Закрыт";
|
Console.WriteLine("Polling for valve status, poll success: " + res);
|
||||||
else labelValve.Text = "Открыт";
|
if (res)
|
||||||
|
{
|
||||||
|
if (latestMessage.Data.Last() > 0)
|
||||||
|
{
|
||||||
|
isValveClosed = true;
|
||||||
|
labelValve.Text = "Закрыт";
|
||||||
|
buttonValve.Text = "Открыть";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
isValveClosed = false;
|
||||||
|
labelValve.Text = "Открыт";
|
||||||
|
buttonValve.Text = "Закрыть";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
res = await PollEntry(device.alarmStatus);
|
||||||
|
Console.WriteLine("Polling for alarm status, poll success: " + res);
|
||||||
|
if (res)
|
||||||
|
{
|
||||||
|
if (latestMessage.Data.Last() > 0)
|
||||||
|
{
|
||||||
|
alarmStatus = true;
|
||||||
|
buttonAlarm.Text = "Выключить";
|
||||||
|
labelAlarm.Text = "Протечка!";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
alarmStatus = false;
|
||||||
|
buttonAlarm.Text = "Авария";
|
||||||
|
labelAlarm.Text = "нет";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (device.hasCleaningMode)
|
||||||
|
{
|
||||||
|
res = await PollEntry(device.cleaningMode);
|
||||||
|
if (res)
|
||||||
|
{
|
||||||
|
if (latestMessage.Data.Last() > 0)
|
||||||
|
{
|
||||||
|
cleaningStatus = true;
|
||||||
|
buttonAlarm.Text = "Выключить";
|
||||||
|
labelAlarm.Text = "вкл";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cleaningStatus = false;
|
||||||
|
buttonAlarm.Text = "Включить";
|
||||||
|
labelAlarm.Text = "выкл";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (device.hasBattery)
|
||||||
|
{
|
||||||
|
res = await PollEntry(device.batteryCharge);
|
||||||
|
if (res)
|
||||||
|
{
|
||||||
|
labelBattery.Text = latestMessage.Data.Last().ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (device.hasCleaningMode)
|
||||||
|
{
|
||||||
|
res = await PollEntry(device.cleaningMode);
|
||||||
|
if (res)
|
||||||
|
{
|
||||||
|
if (latestMessage.Data.Last() > 0)
|
||||||
|
{
|
||||||
|
cleaningStatus = true;
|
||||||
|
buttonAlarm.Text = "Выключить";
|
||||||
|
labelAlarm.Text = "вкл";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cleaningStatus = false;
|
||||||
|
buttonAlarm.Text = "Включить";
|
||||||
|
labelAlarm.Text = "выкл";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
res = await PollEntry(device.sensorsAlarm);
|
||||||
|
if (res)
|
||||||
|
{
|
||||||
|
BitArray bArray = new BitArray(latestMessage.Data);
|
||||||
|
bool[] bools = new bool[bArray.Length];
|
||||||
|
bArray.CopyTo(bools, 0);
|
||||||
|
for (int i = 0; i < device.sensorsAlarm.length; i++)
|
||||||
|
{
|
||||||
|
Sensor snsr = sensorPanel.Controls[i] as Sensor;
|
||||||
|
snsr.labelLeak.Text = bools[i] ? "Протечка!" : "нет";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception err) { MessageBox.Show(err.Message); }
|
||||||
}
|
}
|
||||||
|
|
||||||
async Task<bool> PollEntry(Entry entry)
|
async Task<bool> PollEntry(Entry entry)
|
||||||
{
|
{
|
||||||
var send = Modbus.ReadRegAsync(modbusID, (FunctionCode)entry.registerType, entry.address, entry.length);
|
bool res = false;
|
||||||
|
Modbus.ReadRegAsync(modbusID, (FunctionCode)entry.registerType, entry.address, entry.length);
|
||||||
isAwaitingResponse = true;
|
isAwaitingResponse = true;
|
||||||
|
await Task.Delay(2000).ContinueWith(_ =>
|
||||||
Task<bool> delay = Task.WhenAny(Task.Delay(2000), Task.Run(() => { while (isAwaitingResponse) { } return true; })).ContinueWith((t) =>
|
|
||||||
{
|
{
|
||||||
if (isAwaitingResponse)
|
if (isAwaitingResponse)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Response timed out.");
|
MessageBox.Show("Превышено время ожидания ответа от устройства.");
|
||||||
|
isAwaitingResponse = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
while (isAwaitingResponse) { continue; }
|
||||||
|
|
||||||
|
if (latestMessage != null && latestMessage.Status != ModbusStatus.Error)
|
||||||
|
res = true;
|
||||||
|
|
||||||
|
Console.WriteLine("Poll attempt finished");
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void buttonSetID_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
byte newID = (byte)nudModbusID.Value; // should prevent assigning wrong ID if UpDown is fiddled with in the middle of request
|
||||||
|
Modbus.WriteSingleAsync(FunctionCode.WriteRegister, modbusID, 128, newID);
|
||||||
|
await Task.Delay(2000).ContinueWith(_ =>
|
||||||
|
{
|
||||||
|
if (isAwaitingResponse)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Превышено время ожидания ответа от устройства.");
|
||||||
isAwaitingResponse = false;
|
isAwaitingResponse = false;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
while (isAwaitingResponse) { continue; }
|
||||||
|
|
||||||
return await delay;
|
if (latestMessage != null && latestMessage.Status != ModbusStatus.Error)
|
||||||
|
modbusID = newID;
|
||||||
}
|
}
|
||||||
private async void buttonSetID_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Modbus.WriteSingleAsync(FunctionCode.WriteRegister, modbusID, 200, (byte)nudModbusID.Value);
|
|
||||||
|
|
||||||
await Task.Run(() =>
|
private async void buttonValve_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
ushort value = isValveClosed ? (ushort)0: (ushort)0xFF00;
|
||||||
|
Modbus.WriteSingleAsync(FunctionCode.WriteCoil, modbusID, device.valveStatus.address, value);
|
||||||
|
|
||||||
|
await Task.Delay(2000).ContinueWith(_ =>
|
||||||
{
|
{
|
||||||
while (data is null) { continue; }
|
if (isAwaitingResponse)
|
||||||
if (message[1] > 0x10) //exception code check
|
{
|
||||||
return;
|
MessageBox.Show("Превышено время ожидания ответа от устройства.");
|
||||||
this.modbusID = data[1]; //no exception, can just take the byte
|
isAwaitingResponse = false;
|
||||||
message = null;
|
}
|
||||||
data = null;
|
return false;
|
||||||
});
|
});
|
||||||
|
while (isAwaitingResponse) { continue; }
|
||||||
|
|
||||||
|
if (latestMessage != null && latestMessage.Status != ModbusStatus.Error)
|
||||||
|
{
|
||||||
|
isValveClosed = !isValveClosed;
|
||||||
|
labelValve.Text = isValveClosed ? "Закрыт" : "Открыт";
|
||||||
|
buttonValve.Text = isValveClosed ? "Открыть" : "Закрыть";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonValve_Click(object sender, EventArgs e)
|
private async void buttonAlarm_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
ushort value = isValveClosed ? (ushort)0 : (ushort)1;
|
ushort value = alarmStatus ? (ushort)0 : (ushort)0xFF00;
|
||||||
Modbus.WriteSingleAsync((FunctionCode)device.valveStatus.registerType, modbusID, device.valveStatus.address, value);
|
Modbus.WriteSingleAsync(FunctionCode.WriteCoil, modbusID, device.alarmStatus.address, value);
|
||||||
|
|
||||||
|
await Task.Delay(2000).ContinueWith(_ =>
|
||||||
|
{
|
||||||
|
if (isAwaitingResponse)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Превышено время ожидания ответа от устройства.");
|
||||||
|
isAwaitingResponse = false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
while (isAwaitingResponse) { continue; }
|
||||||
|
|
||||||
|
if (latestMessage != null && latestMessage.Status != ModbusStatus.Error)
|
||||||
|
{
|
||||||
|
alarmStatus = !alarmStatus;
|
||||||
|
labelAlarm.Text = alarmStatus ? "Протечка!" : "Нет";
|
||||||
|
buttonAlarm.Text = alarmStatus ? "Выключить" : "Авария";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonAlarm_Click(object sender, EventArgs e)
|
private async void buttonCleaning_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
ushort value = alarmStatus ? (ushort)0 : (ushort)1;
|
ushort value = cleaningStatus ? (ushort)0 : (ushort)0xFF00;
|
||||||
Modbus.WriteSingleAsync((FunctionCode)device.valveStatus.registerType, modbusID, device.alarmStatus.address, value);
|
Modbus.WriteSingleAsync(FunctionCode.WriteCoil, modbusID, device.cleaningMode.address, value);
|
||||||
|
|
||||||
|
await Task.Delay(2000).ContinueWith(_ =>
|
||||||
|
{
|
||||||
|
if (isAwaitingResponse)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Превышено время ожидания ответа от устройства.");
|
||||||
|
isAwaitingResponse = false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
while (isAwaitingResponse) { continue; }
|
||||||
|
|
||||||
|
if (latestMessage != null && latestMessage.Status != ModbusStatus.Error)
|
||||||
|
{
|
||||||
|
cleaningStatus = !cleaningStatus;
|
||||||
|
labelCleaning.Text = cleaningStatus ? "вкл" : "выкл";
|
||||||
|
buttonCleaning.Text = cleaningStatus ? "Выключить" : "Включить";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
public class Sensor : FlowLayoutPanel
|
||||||
|
{
|
||||||
|
public Label labelName = new Label() { Width = 60, Height = 24 };
|
||||||
|
public Label labelLeakFluff = new Label() { Width = 60, Height = 24 };
|
||||||
|
public Label labelLeak = new Label() { Width = 50, Height = 24 };
|
||||||
|
}
|
||||||
|
public class WiredSensor : Sensor
|
||||||
|
{
|
||||||
|
|
||||||
private void buttonCleaning_Click(object sender, EventArgs e)
|
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 = 20 };
|
||||||
|
public WiredSensor(int count)
|
||||||
{
|
{
|
||||||
|
this.Margin = Padding.Empty;
|
||||||
|
this.Padding = new Padding(0, 5, 0, 0);
|
||||||
|
this.WrapContents = false;
|
||||||
|
this.BackColor = Color.White;
|
||||||
|
this.Height = 15;
|
||||||
|
this.FlowDirection = FlowDirection.LeftToRight;
|
||||||
|
this.Controls.Add(labelName);
|
||||||
|
|
||||||
}
|
this.Controls.Add(labelBreakFluff);
|
||||||
|
this.Controls.Add(labelBreak);
|
||||||
|
|
||||||
|
this.Controls.Add(labelLeakFluff);
|
||||||
|
this.Controls.Add(labelLeak);
|
||||||
|
|
||||||
|
this.Controls.Add(labelWSPPlusFluff);
|
||||||
|
this.Controls.Add(wspPlusCheckbox);
|
||||||
|
|
||||||
|
labelName.Text = "WSP " + (count + 1);
|
||||||
|
|
||||||
|
labelLeakFluff.Text = "Протечка:";
|
||||||
|
labelLeak.Text = "неизвестно";
|
||||||
|
|
||||||
|
labelBreakFluff.Text = "Обрыв:";
|
||||||
|
labelBreak.Text = "неизвестно";
|
||||||
|
|
||||||
|
labelWSPPlusFluff.Text = "WSP+:";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class WirelessSensor : Sensor
|
||||||
|
{
|
||||||
|
|
||||||
|
public Label labelBatteryFluff = new Label() { Width = 55, Height = 24 };
|
||||||
|
public Label labelBattery = new Label() { Width = 45, Height = 24 };
|
||||||
|
|
||||||
|
public WirelessSensor(int count)
|
||||||
|
{
|
||||||
|
this.Margin = Padding.Empty;
|
||||||
|
this.Padding = new Padding(0, 5, 0, 0);
|
||||||
|
this.BackColor = Color.White;
|
||||||
|
this.FlowDirection = FlowDirection.LeftToRight;
|
||||||
|
this.WrapContents = false;
|
||||||
|
|
||||||
|
this.Controls.Add(labelName);
|
||||||
|
this.Controls.Add(labelBatteryFluff);
|
||||||
|
this.Controls.Add(labelBattery);
|
||||||
|
this.Controls.Add(labelLeakFluff);
|
||||||
|
this.Controls.Add(labelLeak);
|
||||||
|
|
||||||
|
labelName.Text = "WSR " + (count + 1);
|
||||||
|
|
||||||
|
labelLeakFluff.Text = "Протечка:";
|
||||||
|
labelLeak.Text = "неизвестно";
|
||||||
|
|
||||||
|
labelBatteryFluff.Text = "Батарея:";
|
||||||
|
labelBattery.Text = "???%";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ScenarioSensor : Sensor
|
||||||
|
{
|
||||||
|
public ScenarioSensor()
|
||||||
|
{
|
||||||
|
labelName.Width = 172;
|
||||||
|
this.Margin = Padding.Empty;
|
||||||
|
this.Padding = new Padding(0, 5, 0, 0);
|
||||||
|
this.FlowDirection = FlowDirection.LeftToRight;
|
||||||
|
this.WrapContents = false;
|
||||||
|
|
||||||
|
this.Controls.Add(labelName);
|
||||||
|
this.Controls.Add(labelLeakFluff);
|
||||||
|
this.Controls.Add(labelLeak);
|
||||||
|
|
||||||
|
labelName.Text = "Сценарный датчик";
|
||||||
|
|
||||||
|
labelLeakFluff.Text = "Протечка:";
|
||||||
|
labelLeak.Text = "неизвестно";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,8 +6,8 @@
|
|||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
<ProjectGuid>{47A399D3-30C1-4EF4-9E94-F3518919A59C}</ProjectGuid>
|
<ProjectGuid>{47A399D3-30C1-4EF4-9E94-F3518919A59C}</ProjectGuid>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<RootNamespace>Gidrolock_Modbus_Scanner</RootNamespace>
|
<RootNamespace>Gidrolock_Modbus_Configurator</RootNamespace>
|
||||||
<AssemblyName>Gidrolock Modbus Scanner</AssemblyName>
|
<AssemblyName>Gidrolock Modbus Configurator</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
@@ -98,6 +98,7 @@
|
|||||||
<Compile Include="Properties\Resources.Designer.cs">
|
<Compile Include="Properties\Resources.Designer.cs">
|
||||||
<AutoGen>True</AutoGen>
|
<AutoGen>True</AutoGen>
|
||||||
<DependentUpon>Resources.resx</DependentUpon>
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
|
<DesignTime>True</DesignTime>
|
||||||
</Compile>
|
</Compile>
|
||||||
<None Include=".gitignore" />
|
<None Include=".gitignore" />
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
|
|||||||
114
Main.cs
114
Main.cs
@@ -16,15 +16,11 @@ namespace Gidrolock_Modbus_Scanner
|
|||||||
public short[] res = new short[12];
|
public short[] res = new short[12];
|
||||||
SerialPort port = Modbus.port;
|
SerialPort port = Modbus.port;
|
||||||
public int expectedLength = 0;
|
public int expectedLength = 0;
|
||||||
|
ModbusResponseEventArgs latestMessage;
|
||||||
|
|
||||||
public byte[] latestMessage;
|
|
||||||
public Dictionary<string, string> models = new Dictionary<string, string>();
|
public Dictionary<string, string> models = new Dictionary<string, string>();
|
||||||
|
|
||||||
byte[] message = null;
|
DateTime dateTime;
|
||||||
byte[] data = null;
|
|
||||||
|
|
||||||
|
|
||||||
DateTime dateTime;
|
|
||||||
|
|
||||||
Datasheet datasheet;
|
Datasheet datasheet;
|
||||||
#region Initialization
|
#region Initialization
|
||||||
@@ -38,9 +34,9 @@ namespace Gidrolock_Modbus_Scanner
|
|||||||
TextBox_Log.Text = "Приложение готово к работе.";
|
TextBox_Log.Text = "Приложение готово к работе.";
|
||||||
|
|
||||||
cBoxDevice.Items.Add("Standard");
|
cBoxDevice.Items.Add("Standard");
|
||||||
cBoxDevice.Items.Add("Inteli");
|
|
||||||
cBoxDevice.Items.Add("Premium Plus");
|
cBoxDevice.Items.Add("Premium Plus");
|
||||||
cBoxDevice.Items.Add("Premium");
|
//cBoxDevice.Items.Add("Inteli");
|
||||||
|
//cBoxDevice.Items.Add("Premium");
|
||||||
cBoxDevice.SelectedIndex = 0;
|
cBoxDevice.SelectedIndex = 0;
|
||||||
|
|
||||||
checkboxID.Checked = false;
|
checkboxID.Checked = false;
|
||||||
@@ -50,8 +46,8 @@ namespace Gidrolock_Modbus_Scanner
|
|||||||
UpDown_ModbusID.Maximum = 247;
|
UpDown_ModbusID.Maximum = 247;
|
||||||
|
|
||||||
models.Add("Standard", "STW485");
|
models.Add("Standard", "STW485");
|
||||||
|
models.Add("Premium Plus", "PRPLS1");
|
||||||
models.Add("Inteli", "INTELI");
|
models.Add("Inteli", "INTELI");
|
||||||
models.Add("Premuim Plus", "BUP485");
|
|
||||||
models.Add("Premium", "BUP485");
|
models.Add("Premium", "BUP485");
|
||||||
|
|
||||||
/* - Version Check - */
|
/* - Version Check - */
|
||||||
@@ -62,8 +58,8 @@ namespace Gidrolock_Modbus_Scanner
|
|||||||
|
|
||||||
Modbus.ResponseReceived += (sndr, msg) =>
|
Modbus.ResponseReceived += (sndr, msg) =>
|
||||||
{
|
{
|
||||||
message = msg.Message;
|
latestMessage = msg;
|
||||||
data = msg.Data;
|
isAwaitingResponse = false;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,18 +115,43 @@ namespace Gidrolock_Modbus_Scanner
|
|||||||
// else parse response to unicode and go through every .json
|
// else parse response to unicode and go through every .json
|
||||||
// if matching model is found, instantiate device window
|
// if matching model is found, instantiate device window
|
||||||
|
|
||||||
// setup event listener
|
|
||||||
|
|
||||||
|
string selectedModel = models[cBoxDevice.SelectedItem.ToString()];
|
||||||
// send message
|
int selectedIndex = cBoxDevice.SelectedIndex;
|
||||||
AddLog("Проверка модели устройства.");
|
AddLog("Проверка модели устройства.");
|
||||||
|
await Task.Run(async () =>
|
||||||
if (await PollModel())
|
|
||||||
{
|
{
|
||||||
Console.WriteLine("true");
|
// send message
|
||||||
|
latestMessage = null;
|
||||||
|
isAwaitingResponse = true;
|
||||||
|
var send = Modbus.ReadRegAsync((byte)UpDown_ModbusID.Value, FunctionCode.ReadInput, 200, 6);
|
||||||
|
await Task.Delay(2000).ContinueWith(_ =>
|
||||||
|
{
|
||||||
|
if (isAwaitingResponse)
|
||||||
|
{
|
||||||
|
isAwaitingResponse = false;
|
||||||
|
MessageBox.Show("Истекло время ожидания ответа от устройства.");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
});
|
||||||
|
|
||||||
|
while (isAwaitingResponse) { continue; }
|
||||||
|
|
||||||
|
if (latestMessage is null)
|
||||||
|
{
|
||||||
|
Console.WriteLine("latestMessage is still null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (latestMessage.Status == ModbusStatus.Error)
|
||||||
|
return;
|
||||||
|
|
||||||
|
|
||||||
// confirm the model
|
// confirm the model
|
||||||
string response = ByteArrayToUnicode(data);
|
string response = ByteArrayToUnicode(latestMessage.Data);
|
||||||
if (response != models[cBoxDevice.SelectedItem.ToString()])
|
Console.WriteLine("device model response: " + response);
|
||||||
|
Console.WriteLine("expected response: " + selectedModel);
|
||||||
|
if (response != selectedModel)
|
||||||
{
|
{
|
||||||
// response doesn't match expected model
|
// response doesn't match expected model
|
||||||
AddLog("Ответ устройства не соответствует выбранной модели. Поиск подходящей модели.");
|
AddLog("Ответ устройства не соответствует выбранной модели. Поиск подходящей модели.");
|
||||||
@@ -169,39 +190,22 @@ namespace Gidrolock_Modbus_Scanner
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// model is correct, instantiate config panel
|
// model is correct, instantiate config panel
|
||||||
int index = cBoxDevice.SelectedIndex;
|
|
||||||
AddLog("Устройство соответстует модели, открываю панель конфигурации.");
|
AddLog("Устройство соответстует модели, открываю панель конфигурации.");
|
||||||
Device device = GetDevice((DeviceType)index);
|
Device device = GetDevice((DeviceType)selectedIndex);
|
||||||
StartDatasheet(device);
|
StartDatasheet(device);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
MessageBox.Show(ex.Message);
|
MessageBox.Show(ex.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async Task<bool> PollModel()
|
|
||||||
{
|
|
||||||
var send = Modbus.ReadRegAsync((byte)UpDown_ModbusID.Value, FunctionCode.ReadInput, 200, 6);
|
|
||||||
isAwaitingResponse = true;
|
|
||||||
|
|
||||||
Task<bool> delay = Task.WhenAny(Task.Delay(2000), Task.Run(() => { while (isAwaitingResponse) { } return true; })).ContinueWith((t) =>
|
|
||||||
{
|
|
||||||
if (isAwaitingResponse)
|
|
||||||
{
|
|
||||||
Console.WriteLine("Response timed out.");
|
|
||||||
isAwaitingResponse = false;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
return await delay;
|
|
||||||
}
|
|
||||||
void StartDatasheet(Device device)
|
void StartDatasheet(Device device)
|
||||||
{
|
{
|
||||||
datasheet = new Datasheet((byte)UpDown_ModbusID.Value, device);
|
datasheet = new Datasheet((byte)UpDown_ModbusID.Value, device);
|
||||||
datasheet.Show();
|
Application.Run(datasheet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -296,12 +300,14 @@ namespace Gidrolock_Modbus_Scanner
|
|||||||
// stupid fucking Encoding class does byte-by-byte conversion
|
// stupid fucking Encoding class does byte-by-byte conversion
|
||||||
List<char> result = new List<char>(input.Length / 2);
|
List<char> result = new List<char>(input.Length / 2);
|
||||||
byte[] flip = input;
|
byte[] flip = input;
|
||||||
Array.Reverse(flip); // stupid fucking BitConverter is little-endian and spits out chinese nonsense otherwise
|
//Array.Reverse(flip); // stupid fucking BitConverter is little-endian and spits out chinese nonsense otherwise
|
||||||
for (int i = 0; i < flip.Length; i += 2)
|
for (int i = 0; i < flip.Length; i++)
|
||||||
{
|
{
|
||||||
result.Add(BitConverter.ToChar(flip, i));
|
if (flip[i] == 0x00)
|
||||||
|
continue;
|
||||||
|
else result.Add(Convert.ToChar(flip[i]));
|
||||||
}
|
}
|
||||||
result.Reverse();
|
//result.Reverse();
|
||||||
return new string(result.ToArray());
|
return new string(result.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -338,8 +344,7 @@ namespace Gidrolock_Modbus_Scanner
|
|||||||
switch (dt)
|
switch (dt)
|
||||||
{
|
{
|
||||||
case DeviceType.Standard:
|
case DeviceType.Standard:
|
||||||
d.modelName = "Standard";
|
d.name = "Standard Wi-Fi RS485";
|
||||||
d.name = "Gidrolock Standard Wi-Fi RS485";
|
|
||||||
d.id = 30;
|
d.id = 30;
|
||||||
d.modelName = "STW485";
|
d.modelName = "STW485";
|
||||||
|
|
||||||
@@ -362,7 +367,22 @@ namespace Gidrolock_Modbus_Scanner
|
|||||||
d.modelName = "Inteli";
|
d.modelName = "Inteli";
|
||||||
break;
|
break;
|
||||||
case DeviceType.PremiumPlus:
|
case DeviceType.PremiumPlus:
|
||||||
d.modelName = "Premium Plus";
|
d.name = "Premium Plus Wi-Fi";
|
||||||
|
d.id = 30;
|
||||||
|
d.modelName = "PRPLS1";
|
||||||
|
|
||||||
|
d.valveStatus = new Entry(RegisterType.Coil, 1202);
|
||||||
|
d.alarmStatus = new Entry(RegisterType.Coil, 1201);
|
||||||
|
|
||||||
|
d.hasCleaningMode = true;
|
||||||
|
d.cleaningMode = new Entry(RegisterType.Coil, 3);
|
||||||
|
|
||||||
|
d.hasBattery = true;
|
||||||
|
d.batteryCharge = new Entry(RegisterType.Input, 1207);
|
||||||
|
|
||||||
|
d.wiredSensors = 7;
|
||||||
|
d.hasScenarioSensor = true;
|
||||||
|
d.sensorsAlarm = new Entry(RegisterType.Discrete, 1343, 29);
|
||||||
break;
|
break;
|
||||||
case DeviceType.Premium:
|
case DeviceType.Premium:
|
||||||
d.modelName = "Premium";
|
d.modelName = "Premium";
|
||||||
@@ -378,4 +398,4 @@ namespace Gidrolock_Modbus_Scanner
|
|||||||
|
|
||||||
public enum FunctionCode { ReadCoil = 1, ReadDiscrete = 2, ReadHolding = 3, ReadInput = 4, WriteCoil = 5, WriteRegister = 6, WriteMultCoils = 15, WriteMultRegisters = 16 };
|
public enum FunctionCode { ReadCoil = 1, ReadDiscrete = 2, ReadHolding = 3, ReadInput = 4, WriteCoil = 5, WriteRegister = 6, WriteMultCoils = 15, WriteMultRegisters = 16 };
|
||||||
//public enum SelectedPath { File, Folder };
|
//public enum SelectedPath { File, Folder };
|
||||||
public enum DeviceType { Standard, Inteli, PremiumPlus, Premium };
|
public enum DeviceType { Standard, PremiumPlus, Inteli, Premium };
|
||||||
|
|||||||
2
Model.cs
2
Model.cs
@@ -23,7 +23,7 @@ namespace Gidrolock_Modbus_Scanner
|
|||||||
public bool hasScenarioSensor;
|
public bool hasScenarioSensor;
|
||||||
public Entry sensorsAlarm;
|
public Entry sensorsAlarm;
|
||||||
|
|
||||||
public Entry wiredLineBreak;
|
public List<Entry> wiredLineBreak;
|
||||||
|
|
||||||
public Entry radioStatus;
|
public Entry radioStatus;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,12 +6,12 @@ using System.Runtime.InteropServices;
|
|||||||
// General Information about an assembly is controlled through the following
|
// General Information about an assembly is controlled through the following
|
||||||
// set of attributes. Change these attribute values to modify the information
|
// set of attributes. Change these attribute values to modify the information
|
||||||
// associated with an assembly.
|
// associated with an assembly.
|
||||||
[assembly: AssemblyTitle("Gidrolock Modbus Scanner")]
|
[assembly: AssemblyTitle("Gidrolock Modbus Configurator")]
|
||||||
[assembly: AssemblyDescription("A collection of Modbus tools.")]
|
[assembly: AssemblyDescription("A diagnosting modbus tool for Gidrolock valve controllers.")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCompany("nikzori")]
|
[assembly: AssemblyCompany("Gidrolock")]
|
||||||
[assembly: AssemblyProduct("Gidrolock Modbus Scanner")]
|
[assembly: AssemblyProduct("Gidrolock Modbus Configurator")]
|
||||||
[assembly: AssemblyCopyright("Copyright © 2024")]
|
[assembly: AssemblyCopyright("Copyright © 2025")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
|||||||
46
Properties/Resources.Designer.cs
generated
46
Properties/Resources.Designer.cs
generated
@@ -8,10 +8,10 @@
|
|||||||
// </auto-generated>
|
// </auto-generated>
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace Gidrolock_Modbus_Scanner.Properties
|
namespace Gidrolock_Modbus_Configurator.Properties {
|
||||||
{
|
using System;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -19,51 +19,43 @@ namespace Gidrolock_Modbus_Scanner.Properties
|
|||||||
// class via a tool like ResGen or Visual Studio.
|
// class via a tool like ResGen or Visual Studio.
|
||||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||||
// with the /str option, or rebuild your VS project.
|
// with the /str option, or rebuild your VS project.
|
||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
internal class Resources
|
internal class Resources {
|
||||||
{
|
|
||||||
|
|
||||||
private static global::System.Resources.ResourceManager resourceMan;
|
private static global::System.Resources.ResourceManager resourceMan;
|
||||||
|
|
||||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||||
|
|
||||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||||
internal Resources()
|
internal Resources() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the cached ResourceManager instance used by this class.
|
/// Returns the cached ResourceManager instance used by this class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
internal static global::System.Resources.ResourceManager ResourceManager
|
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||||
{
|
get {
|
||||||
get
|
if (object.ReferenceEquals(resourceMan, null)) {
|
||||||
{
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Gidrolock_Modbus_Configurator.Properties.Resources", typeof(Resources).Assembly);
|
||||||
if ((resourceMan == null))
|
|
||||||
{
|
|
||||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Gidrolock_Modbus_Scanner.Properties.Resources", typeof(Resources).Assembly);
|
|
||||||
resourceMan = temp;
|
resourceMan = temp;
|
||||||
}
|
}
|
||||||
return resourceMan;
|
return resourceMan;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Overrides the current thread's CurrentUICulture property for all
|
/// Overrides the current thread's CurrentUICulture property for all
|
||||||
/// resource lookups using this strongly typed resource class.
|
/// resource lookups using this strongly typed resource class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
internal static global::System.Globalization.CultureInfo Culture
|
internal static global::System.Globalization.CultureInfo Culture {
|
||||||
{
|
get {
|
||||||
get
|
|
||||||
{
|
|
||||||
return resourceCulture;
|
return resourceCulture;
|
||||||
}
|
}
|
||||||
set
|
set {
|
||||||
{
|
|
||||||
resourceCulture = value;
|
resourceCulture = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
22
Properties/Settings.Designer.cs
generated
22
Properties/Settings.Designer.cs
generated
@@ -8,21 +8,17 @@
|
|||||||
// </auto-generated>
|
// </auto-generated>
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace Gidrolock_Modbus_Scanner.Properties
|
namespace Gidrolock_Modbus_Configurator.Properties {
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.11.0.0")]
|
||||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
|
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||||
{
|
|
||||||
|
|
||||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||||
|
|
||||||
public static Settings Default
|
public static Settings Default {
|
||||||
{
|
get {
|
||||||
get
|
|
||||||
{
|
|
||||||
return defaultInstance;
|
return defaultInstance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user