From d70e5b155e42724a66221c4a1588c0c3e2adced6 Mon Sep 17 00:00:00 2001 From: nikzori Date: Fri, 17 Jan 2025 10:40:18 +0300 Subject: [PATCH] ui drafted --- Datasheet.Designer.cs | 329 ++++++++++++++---- Datasheet.cs | 14 + ...oj => Gidrolock Modbus Configurator.csproj | 2 +- ... Gidrolock Modbus Configurator.csproj.user | 0 ...r.sln => Gidrolock Modbus Configurator.sln | 2 +- Main.cs | 8 - Json.cs => Model.cs | 27 +- 7 files changed, 295 insertions(+), 87 deletions(-) rename Gidrolock Modbus Scanner.csproj => Gidrolock Modbus Configurator.csproj (96%) rename Gidrolock Modbus Scanner.csproj.user => Gidrolock Modbus Configurator.csproj.user (100%) rename Gidrolock Modbus Scanner.sln => Gidrolock Modbus Configurator.sln (89%) rename Json.cs => Model.cs (79%) diff --git a/Datasheet.Designer.cs b/Datasheet.Designer.cs index a94201d..000d59c 100644 --- a/Datasheet.Designer.cs +++ b/Datasheet.Designer.cs @@ -30,16 +30,32 @@ { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Datasheet)); this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.label1 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.label3 = new System.Windows.Forms.Label(); - this.nudModbusID = new System.Windows.Forms.NumericUpDown(); - this.labelModel = new System.Windows.Forms.Label(); - this.labelFirmware = new System.Windows.Forms.Label(); - this.buttonSetID = new System.Windows.Forms.Button(); this.buttonPoll = new System.Windows.Forms.Button(); + this.buttonSetID = new System.Windows.Forms.Button(); + this.labelFirmware = new System.Windows.Forms.Label(); + this.labelModel = new System.Windows.Forms.Label(); + this.nudModbusID = new System.Windows.Forms.NumericUpDown(); + this.label3 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.labelValve = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + this.buttonValve = new System.Windows.Forms.Button(); + this.buttonAlarm = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); + this.label5 = new System.Windows.Forms.Label(); + this.label6 = new System.Windows.Forms.Label(); + this.label7 = new System.Windows.Forms.Label(); + this.buttonCleaning = new System.Windows.Forms.Button(); + this.label8 = new System.Windows.Forms.Label(); + this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); + this.label9 = new System.Windows.Forms.Label(); + this.label10 = new System.Windows.Forms.Label(); + this.flowLayoutPanel2 = new System.Windows.Forms.FlowLayoutPanel(); this.groupBox1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.nudModbusID)).BeginInit(); + this.groupBox2.SuspendLayout(); this.SuspendLayout(); // // groupBox1 @@ -59,68 +75,6 @@ this.groupBox1.TabStop = false; this.groupBox1.Text = "Инфо"; // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(6, 16); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(49, 13); - this.label1.TabIndex = 0; - this.label1.Text = "Модель:"; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(6, 31); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(62, 13); - this.label2.TabIndex = 1; - this.label2.Text = "Прошивка:"; - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(6, 55); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(62, 13); - this.label3.TabIndex = 2; - this.label3.Text = "Modbus ID:"; - // - // nudModbusID - // - this.nudModbusID.Location = new System.Drawing.Point(9, 71); - this.nudModbusID.Name = "nudModbusID"; - this.nudModbusID.Size = new System.Drawing.Size(59, 20); - this.nudModbusID.TabIndex = 3; - // - // labelModel - // - this.labelModel.AutoSize = true; - this.labelModel.Location = new System.Drawing.Point(61, 16); - this.labelModel.Name = "labelModel"; - this.labelModel.Size = new System.Drawing.Size(50, 13); - this.labelModel.TabIndex = 4; - this.labelModel.Text = "Standard"; - // - // labelFirmware - // - this.labelFirmware.AutoSize = true; - this.labelFirmware.Location = new System.Drawing.Point(74, 31); - this.labelFirmware.Name = "labelFirmware"; - this.labelFirmware.Size = new System.Drawing.Size(37, 13); - this.labelFirmware.TabIndex = 5; - this.labelFirmware.Text = "v1.0.4"; - // - // buttonSetID - // - this.buttonSetID.Location = new System.Drawing.Point(74, 68); - this.buttonSetID.Name = "buttonSetID"; - this.buttonSetID.Size = new System.Drawing.Size(75, 23); - this.buttonSetID.TabIndex = 6; - this.buttonSetID.Text = "Изменить"; - this.buttonSetID.UseVisualStyleBackColor = true; - this.buttonSetID.Click += new System.EventHandler(this.buttonSetID_Click); - // // buttonPoll // this.buttonPoll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); @@ -131,19 +85,239 @@ this.buttonPoll.Text = "Опрос"; this.buttonPoll.UseVisualStyleBackColor = true; // + // buttonSetID + // + this.buttonSetID.Location = new System.Drawing.Point(130, 55); + this.buttonSetID.Name = "buttonSetID"; + this.buttonSetID.Size = new System.Drawing.Size(75, 23); + this.buttonSetID.TabIndex = 6; + this.buttonSetID.Text = "Изменить"; + this.buttonSetID.UseVisualStyleBackColor = true; + this.buttonSetID.Click += new System.EventHandler(this.buttonSetID_Click); + // + // labelFirmware + // + this.labelFirmware.AutoSize = true; + this.labelFirmware.Location = new System.Drawing.Point(74, 31); + this.labelFirmware.Name = "labelFirmware"; + this.labelFirmware.Size = new System.Drawing.Size(37, 13); + this.labelFirmware.TabIndex = 5; + this.labelFirmware.Text = "v1.0.4"; + // + // labelModel + // + this.labelModel.AutoSize = true; + this.labelModel.Location = new System.Drawing.Point(61, 16); + this.labelModel.Name = "labelModel"; + this.labelModel.Size = new System.Drawing.Size(50, 13); + this.labelModel.TabIndex = 4; + this.labelModel.Text = "Standard"; + // + // nudModbusID + // + this.nudModbusID.Location = new System.Drawing.Point(74, 58); + this.nudModbusID.Name = "nudModbusID"; + this.nudModbusID.Size = new System.Drawing.Size(50, 20); + this.nudModbusID.TabIndex = 3; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(6, 60); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(62, 13); + this.label3.TabIndex = 2; + this.label3.Text = "Modbus ID:"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(6, 31); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(62, 13); + this.label2.TabIndex = 1; + this.label2.Text = "Прошивка:"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(6, 16); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(49, 13); + this.label1.TabIndex = 0; + this.label1.Text = "Модель:"; + // + // groupBox2 + // + this.groupBox2.Controls.Add(this.label8); + this.groupBox2.Controls.Add(this.buttonCleaning); + this.groupBox2.Controls.Add(this.label7); + this.groupBox2.Controls.Add(this.label6); + this.groupBox2.Controls.Add(this.label5); + this.groupBox2.Controls.Add(this.button2); + this.groupBox2.Controls.Add(this.buttonAlarm); + this.groupBox2.Controls.Add(this.buttonValve); + this.groupBox2.Controls.Add(this.labelValve); + this.groupBox2.Controls.Add(this.label4); + this.groupBox2.Location = new System.Drawing.Point(13, 12); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(350, 100); + this.groupBox2.TabIndex = 1; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "Общее"; + // + // labelValve + // + this.labelValve.AutoSize = true; + this.labelValve.Location = new System.Drawing.Point(39, 19); + this.labelValve.Name = "labelValve"; + this.labelValve.Size = new System.Drawing.Size(45, 13); + this.labelValve.TabIndex = 1; + this.labelValve.Text = "Открыт"; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(6, 19); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(35, 13); + this.label4.TabIndex = 0; + this.label4.Text = "Кран:"; + // + // buttonValve + // + this.buttonValve.Location = new System.Drawing.Point(192, 14); + this.buttonValve.Name = "buttonValve"; + this.buttonValve.Size = new System.Drawing.Size(73, 23); + this.buttonValve.TabIndex = 2; + this.buttonValve.Text = "Закрыть"; + this.buttonValve.UseVisualStyleBackColor = true; + this.buttonValve.Click += new System.EventHandler(this.buttonValve_Click); + // + // buttonAlarm + // + this.buttonAlarm.Location = new System.Drawing.Point(192, 43); + this.buttonAlarm.Name = "buttonAlarm"; + this.buttonAlarm.Size = new System.Drawing.Size(73, 23); + this.buttonAlarm.TabIndex = 3; + this.buttonAlarm.Text = "Авария"; + this.buttonAlarm.UseVisualStyleBackColor = true; + this.buttonAlarm.Click += new System.EventHandler(this.buttonAlarm_Click); + // + // button2 + // + this.button2.Location = new System.Drawing.Point(271, 14); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(73, 52); + this.button2.TabIndex = 4; + this.button2.Text = "Аварийное открытие"; + this.button2.UseVisualStyleBackColor = true; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(6, 48); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(58, 13); + this.label5.TabIndex = 5; + this.label5.Text = "Протечка:"; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(61, 48); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(24, 13); + this.label6.TabIndex = 6; + this.label6.Text = "нет"; + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Location = new System.Drawing.Point(6, 78); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(48, 13); + this.label7.TabIndex = 7; + this.label7.Text = "Уборка:"; + // + // buttonCleaning + // + this.buttonCleaning.Location = new System.Drawing.Point(192, 73); + this.buttonCleaning.Name = "buttonCleaning"; + this.buttonCleaning.Size = new System.Drawing.Size(73, 23); + this.buttonCleaning.TabIndex = 8; + this.buttonCleaning.Text = "Включить"; + this.buttonCleaning.UseVisualStyleBackColor = true; + // + // label8 + // + this.label8.AutoSize = true; + this.label8.Location = new System.Drawing.Point(52, 78); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(33, 13); + this.label8.TabIndex = 9; + this.label8.Text = "выкл"; + // + // flowLayoutPanel1 + // + this.flowLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.TopDown; + this.flowLayoutPanel1.Location = new System.Drawing.Point(13, 135); + this.flowLayoutPanel1.Name = "flowLayoutPanel1"; + this.flowLayoutPanel1.Size = new System.Drawing.Size(280, 175); + this.flowLayoutPanel1.TabIndex = 4; + // + // label9 + // + this.label9.AutoSize = true; + this.label9.Location = new System.Drawing.Point(10, 119); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(108, 13); + this.label9.TabIndex = 5; + 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 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(592, 500); + this.ClientSize = new System.Drawing.Size(592, 322); + this.Controls.Add(this.label10); + this.Controls.Add(this.flowLayoutPanel2); + this.Controls.Add(this.label9); + this.Controls.Add(this.flowLayoutPanel1); + this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox1); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MaximizeBox = false; this.Name = "Datasheet"; this.Text = "Datasheet"; this.groupBox1.ResumeLayout(false); this.groupBox1.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.nudModbusID)).EndInit(); + this.groupBox2.ResumeLayout(false); + this.groupBox2.PerformLayout(); this.ResumeLayout(false); + this.PerformLayout(); } @@ -158,5 +332,20 @@ private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label1; private System.Windows.Forms.Button buttonPoll; + private System.Windows.Forms.GroupBox groupBox2; + private System.Windows.Forms.Label labelValve; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Button buttonValve; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.Button buttonAlarm; + private System.Windows.Forms.Label label8; + private System.Windows.Forms.Button buttonCleaning; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; + private System.Windows.Forms.Label label9; + private System.Windows.Forms.Label label10; + private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel2; } } \ No newline at end of file diff --git a/Datasheet.cs b/Datasheet.cs index ff96c94..7944bbc 100644 --- a/Datasheet.cs +++ b/Datasheet.cs @@ -11,6 +11,10 @@ using System.Xml; 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 { byte modbusID; @@ -45,5 +49,15 @@ namespace Gidrolock_Modbus_Scanner }); } + + private void buttonValve_Click(object sender, EventArgs e) + { + + } + + private void buttonAlarm_Click(object sender, EventArgs e) + { + + } } } \ No newline at end of file diff --git a/Gidrolock Modbus Scanner.csproj b/Gidrolock Modbus Configurator.csproj similarity index 96% rename from Gidrolock Modbus Scanner.csproj rename to Gidrolock Modbus Configurator.csproj index 7ab61e6..553e1f6 100644 --- a/Gidrolock Modbus Scanner.csproj +++ b/Gidrolock Modbus Configurator.csproj @@ -74,7 +74,7 @@ Datasheet.cs - + Form diff --git a/Gidrolock Modbus Scanner.csproj.user b/Gidrolock Modbus Configurator.csproj.user similarity index 100% rename from Gidrolock Modbus Scanner.csproj.user rename to Gidrolock Modbus Configurator.csproj.user diff --git a/Gidrolock Modbus Scanner.sln b/Gidrolock Modbus Configurator.sln similarity index 89% rename from Gidrolock Modbus Scanner.sln rename to Gidrolock Modbus Configurator.sln index 5830cdb..604e649 100644 --- a/Gidrolock Modbus Scanner.sln +++ b/Gidrolock Modbus Configurator.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.11.35327.3 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gidrolock Modbus Scanner", "Gidrolock Modbus Scanner.csproj", "{47A399D3-30C1-4EF4-9E94-F3518919A59C}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gidrolock Modbus Configurator", "Gidrolock Modbus Configurator.csproj", "{47A399D3-30C1-4EF4-9E94-F3518919A59C}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/Main.cs b/Main.cs index bae5310..ace4d81 100644 --- a/Main.cs +++ b/Main.cs @@ -16,14 +16,6 @@ namespace Gidrolock_Modbus_Scanner public short[] res = new short[12]; SerialPort port = Modbus.port; public int expectedLength = 0; - Datasheet datasheet; - public SelectedPath selectedPath = SelectedPath.Folder; - - public static Device device; // Deserialized .json object - string defaultPath = Application.StartupPath + "\\Configs"; // Default folder path - - Dictionary> juju = new Dictionary>(); // dictionary for device identification - string[] configs; public byte[] latestMessage; public Dictionary models = new Dictionary(); diff --git a/Json.cs b/Model.cs similarity index 79% rename from Json.cs rename to Model.cs index 04a49d4..32180e4 100644 --- a/Json.cs +++ b/Model.cs @@ -8,22 +8,35 @@ using System.Windows.Forms; namespace Gidrolock_Modbus_Scanner { - public class Device + public class Device : { public string name; - public string description; public byte id; + public string modelName; public List entries; - public CheckEntry checkEntry; - public Device(string name, string description, CheckEntry checkEntry, List entries) + public Device(string name, string modelName) { this.name = name; - this.description = description; - this.checkEntry = checkEntry; - this.entries = entries; } + } + + public interface IHasWiredSensors + { + Entry GetAlarmStatuses(); + Entry GetSignalLoss(); + } + public interface IHasWirelessSensors + { + Entry GetWirelessSensors(); + Entry GetSensors(); + } + public interface IHasEmergencyOpen + { + void EmergencyOpen(); + } + public struct Entry { public string name;