Browse Source

update mainform

weijw 5 months ago
parent
commit
0ce36ef436
12 changed files with 969 additions and 103 deletions
  1. 13 10
      ConfigHelper.cs
  2. 26 0
      HomeModule.cs
  3. 602 53
      MainForm.Designer.cs
  4. 146 37
      MainForm.cs
  5. 90 0
      MainForm.resx
  6. 11 1
      Program.cs
  7. 1 1
      README.md
  8. 54 0
      WashRecord.cs
  9. 2 0
      config.xml
  10. 18 0
      xicheji.csproj
  11. 5 0
      xicheji.csproj.user
  12. 1 1
      xicheji.sln

+ 13 - 10
ConfigHelper.cs

@@ -28,10 +28,12 @@ namespace xicheji
                 return new Config();
             }
 
-            var config = new Config();
+            var config = new Config
+            {
+                ServicePort = xdoc.Root!.Element("Service")?.Attribute("Port")?.Value ?? "9999",
 
-            var platform = xdoc.Root!.Element("Platform");
-            config.Server = platform?.Attribute("Server")?.Value ?? "";
+                Server = xdoc.Root!.Element("Platform")?.Attribute("Server")?.Value ?? ""
+            };
 
             var device = xdoc.Root!.Element("Device");
             config.PLCIP = device?.Attribute("IP")?.Value ?? "";
@@ -52,10 +54,12 @@ namespace xicheji
                 var variables = variablesRoot.Elements("Variable");
                 foreach (XElement item in variables)
                 {
-                    var variable = new Variable();
-                    variable.Name = item.Attribute("Name")?.Value ?? "";
-                    variable.Key = item.Attribute("Key")?.Value ?? "";
-                    variable.Desc = item.Attribute("Desc")?.Value ?? "";
+                    var variable = new Variable
+                    {
+                        Name = item.Attribute("Name")?.Value ?? "",
+                        Key = config.DBName + "." + item.Attribute("Key")?.Value ?? "",
+                        Desc = item.Attribute("Desc")?.Value ?? ""
+                    };
                     if (string.IsNullOrEmpty(variable.Name) || string.IsNullOrEmpty(variable.Key))
                     {
                         continue;
@@ -70,9 +74,7 @@ namespace xicheji
 
         public static void SaveConfig(Config config)
         {
-            _config = config;
-
-
+            //TODO: 写入xml
         }
 
         public static Variable? FindVariable(string variableName)
@@ -87,6 +89,7 @@ namespace xicheji
 
     public class Config
     {
+        public string ServicePort { get; set; } = string.Empty;
         public string Server { get; set; } = string.Empty;
         public string PLCIP { get; set; } = string.Empty;
         public string PLCPort { get; set; } = string.Empty;

+ 26 - 0
HomeModule.cs

@@ -0,0 +1,26 @@
+using Nancy;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace xicheji
+{
+    public class HomeModule : NancyModule
+    {
+        public HomeModule()
+        {
+            Get("/hello", (req) =>
+            {
+                return "ok~";
+            });
+
+            Post("/update-car", (req) =>
+            {
+                Program.MainForm.UpdateCarInfo(DateTime.Now);
+                return "ok~";
+            });
+        }
+    }
+}

+ 602 - 53
MainForm.Designer.cs

@@ -29,7 +29,7 @@
         private void InitializeComponent()
         {
             components = new System.ComponentModel.Container();
-            button4 = new Button();
+            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
             pictureBox1 = new PictureBox();
             nowTimer = new System.Windows.Forms.Timer(components);
             uploadTimer = new System.Windows.Forms.Timer(components);
@@ -37,26 +37,77 @@
             lblTime = new Label();
             btnSetting = new Button();
             btnConnectCamera = new Button();
-            button2 = new Button();
-            button3 = new Button();
+            panel1 = new Panel();
+            pictureBox7 = new PictureBox();
+            panel2 = new Panel();
+            panel11 = new Panel();
+            lblCurrentElectricity = new Label();
+            lblCurrentWaterP = new Label();
+            label6 = new Label();
+            label5 = new Label();
+            pictureBox3 = new PictureBox();
+            pictureBox2 = new PictureBox();
+            label4 = new Label();
+            panel8 = new Panel();
+            panel9 = new Panel();
+            lblTotalElectricity = new Label();
+            lblTotalWater = new Label();
+            lblWashCount = new Label();
+            label7 = new Label();
+            label9 = new Label();
+            pictureBox6 = new PictureBox();
+            label8 = new Label();
+            pictureBox4 = new PictureBox();
+            pictureBox5 = new PictureBox();
+            label3 = new Label();
+            panel6 = new Panel();
+            panel7 = new Panel();
+            label2 = new Label();
+            panel5 = new Panel();
+            panel4 = new Panel();
+            lblError = new Label();
+            label1 = new Label();
+            panel3 = new Panel();
+            panel10 = new Panel();
+            dataGridView1 = new DataGridView();
+            colCarNum = new DataGridViewTextBoxColumn();
+            colStartTime = new DataGridViewTextBoxColumn();
+            colEndTime = new DataGridViewTextBoxColumn();
+            colWashTime = new DataGridViewTextBoxColumn();
+            colDryTime = new DataGridViewTextBoxColumn();
+            colTotalWater = new DataGridViewTextBoxColumn();
+            colTotalElectricity = new DataGridViewTextBoxColumn();
+            colWaterPressure = new DataGridViewTextBoxColumn();
+            panel12 = new Panel();
+            label12 = new Label();
+            lblStatus = new Label();
+            label11 = new Label();
+            label13 = new Label();
+            label10 = new Label();
             ((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit();
+            panel1.SuspendLayout();
+            ((System.ComponentModel.ISupportInitialize)pictureBox7).BeginInit();
+            panel2.SuspendLayout();
+            panel11.SuspendLayout();
+            ((System.ComponentModel.ISupportInitialize)pictureBox3).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)pictureBox2).BeginInit();
+            panel9.SuspendLayout();
+            ((System.ComponentModel.ISupportInitialize)pictureBox6).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)pictureBox4).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)pictureBox5).BeginInit();
+            panel7.SuspendLayout();
+            panel4.SuspendLayout();
+            panel3.SuspendLayout();
+            panel10.SuspendLayout();
+            ((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
             SuspendLayout();
             // 
-            // button4
-            // 
-            button4.Location = new Point(199, 55);
-            button4.Name = "button4";
-            button4.Size = new Size(75, 23);
-            button4.TabIndex = 5;
-            button4.Text = "button4";
-            button4.UseVisualStyleBackColor = true;
-            button4.Click += button4_Click;
-            // 
             // pictureBox1
             // 
-            pictureBox1.Location = new Point(690, 131);
+            pictureBox1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+            pictureBox1.Location = new Point(29, 53);
             pictureBox1.Name = "pictureBox1";
-            pictureBox1.Size = new Size(365, 463);
+            pictureBox1.Size = new Size(811, 286);
             pictureBox1.TabIndex = 6;
             pictureBox1.TabStop = false;
             // 
@@ -79,76 +130,529 @@
             lblTime.Anchor = AnchorStyles.Top | AnchorStyles.Right;
             lblTime.AutoSize = true;
             lblTime.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
-            lblTime.Location = new Point(871, 25);
+            lblTime.Location = new Point(1003, 9);
             lblTime.Name = "lblTime";
-            lblTime.Size = new Size(203, 21);
+            lblTime.Size = new Size(124, 21);
             lblTime.TabIndex = 7;
-            lblTime.Text = "0000年 0月 00日  00:00:00";
+            lblTime.Text = "0月 00日  00:00";
             // 
             // btnSetting
             // 
             btnSetting.Anchor = AnchorStyles.Top | AnchorStyles.Right;
-            btnSetting.Location = new Point(815, 26);
+            btnSetting.FlatAppearance.BorderSize = 0;
+            btnSetting.FlatAppearance.MouseOverBackColor = Color.WhiteSmoke;
+            btnSetting.FlatStyle = FlatStyle.Flat;
+            btnSetting.Image = (Image)resources.GetObject("btnSetting.Image");
+            btnSetting.Location = new Point(1146, 7);
             btnSetting.Name = "btnSetting";
-            btnSetting.Size = new Size(50, 23);
+            btnSetting.Size = new Size(24, 24);
             btnSetting.TabIndex = 8;
-            btnSetting.Text = "配置";
             btnSetting.UseVisualStyleBackColor = true;
             btnSetting.Click += btnSetting_Click;
             // 
             // btnConnectCamera
             // 
-            btnConnectCamera.Location = new Point(975, 102);
+            btnConnectCamera.Anchor = AnchorStyles.Top | AnchorStyles.Right;
+            btnConnectCamera.FlatAppearance.BorderSize = 0;
+            btnConnectCamera.FlatStyle = FlatStyle.Flat;
+            btnConnectCamera.Image = (Image)resources.GetObject("btnConnectCamera.Image");
+            btnConnectCamera.Location = new Point(846, 59);
             btnConnectCamera.Name = "btnConnectCamera";
-            btnConnectCamera.Size = new Size(80, 23);
+            btnConnectCamera.Size = new Size(24, 24);
             btnConnectCamera.TabIndex = 0;
-            btnConnectCamera.Text = "重连摄像头";
             btnConnectCamera.UseVisualStyleBackColor = true;
-            btnConnectCamera.Click += button1_Click;
+            btnConnectCamera.Click += btnConnectCamera_Click;
+            // 
+            // panel1
+            // 
+            panel1.Controls.Add(lblTime);
+            panel1.Controls.Add(btnSetting);
+            panel1.Controls.Add(pictureBox7);
+            panel1.Dock = DockStyle.Top;
+            panel1.Location = new Point(0, 0);
+            panel1.Name = "panel1";
+            panel1.Size = new Size(1193, 48);
+            panel1.TabIndex = 9;
+            // 
+            // pictureBox7
+            // 
+            pictureBox7.Anchor = AnchorStyles.None;
+            pictureBox7.Location = new Point(541, 4);
+            pictureBox7.Name = "pictureBox7";
+            pictureBox7.Size = new Size(111, 40);
+            pictureBox7.TabIndex = 9;
+            pictureBox7.TabStop = false;
+            // 
+            // panel2
+            // 
+            panel2.Controls.Add(panel11);
+            panel2.Controls.Add(panel8);
+            panel2.Controls.Add(panel9);
+            panel2.Controls.Add(panel6);
+            panel2.Controls.Add(panel7);
+            panel2.Controls.Add(panel5);
+            panel2.Controls.Add(panel4);
+            panel2.Dock = DockStyle.Right;
+            panel2.Location = new Point(931, 48);
+            panel2.Name = "panel2";
+            panel2.Padding = new Padding(16);
+            panel2.Size = new Size(262, 624);
+            panel2.TabIndex = 10;
+            // 
+            // panel11
+            // 
+            panel11.BackColor = Color.WhiteSmoke;
+            panel11.Controls.Add(lblCurrentElectricity);
+            panel11.Controls.Add(lblCurrentWaterP);
+            panel11.Controls.Add(label6);
+            panel11.Controls.Add(label5);
+            panel11.Controls.Add(pictureBox3);
+            panel11.Controls.Add(pictureBox2);
+            panel11.Controls.Add(label4);
+            panel11.Dock = DockStyle.Top;
+            panel11.Location = new Point(16, 390);
+            panel11.Name = "panel11";
+            panel11.Size = new Size(230, 111);
+            panel11.TabIndex = 6;
+            // 
+            // lblCurrentElectricity
+            // 
+            lblCurrentElectricity.AutoSize = true;
+            lblCurrentElectricity.Location = new Point(130, 74);
+            lblCurrentElectricity.Name = "lblCurrentElectricity";
+            lblCurrentElectricity.Size = new Size(20, 17);
+            lblCurrentElectricity.TabIndex = 9;
+            lblCurrentElectricity.Text = "无";
+            // 
+            // lblCurrentWaterP
+            // 
+            lblCurrentWaterP.AutoSize = true;
+            lblCurrentWaterP.Location = new Point(130, 45);
+            lblCurrentWaterP.Name = "lblCurrentWaterP";
+            lblCurrentWaterP.Size = new Size(20, 17);
+            lblCurrentWaterP.TabIndex = 9;
+            lblCurrentWaterP.Text = "无";
+            // 
+            // label6
+            // 
+            label6.AutoSize = true;
+            label6.Location = new Point(40, 45);
+            label6.Name = "label6";
+            label6.Size = new Size(68, 17);
+            label6.TabIndex = 2;
+            label6.Text = "当前压力值";
+            // 
+            // label5
+            // 
+            label5.AutoSize = true;
+            label5.Location = new Point(40, 74);
+            label5.Name = "label5";
+            label5.Size = new Size(68, 17);
+            label5.TabIndex = 2;
+            label5.Text = "当前用电量";
+            // 
+            // pictureBox3
+            // 
+            pictureBox3.Image = (Image)resources.GetObject("pictureBox3.Image");
+            pictureBox3.Location = new Point(14, 72);
+            pictureBox3.Name = "pictureBox3";
+            pictureBox3.Size = new Size(20, 20);
+            pictureBox3.TabIndex = 1;
+            pictureBox3.TabStop = false;
+            // 
+            // pictureBox2
+            // 
+            pictureBox2.Image = (Image)resources.GetObject("pictureBox2.Image");
+            pictureBox2.Location = new Point(14, 42);
+            pictureBox2.Name = "pictureBox2";
+            pictureBox2.Size = new Size(20, 20);
+            pictureBox2.TabIndex = 1;
+            pictureBox2.TabStop = false;
+            // 
+            // label4
+            // 
+            label4.AutoSize = true;
+            label4.Font = new Font("Microsoft YaHei UI", 10F, FontStyle.Bold, GraphicsUnit.Point);
+            label4.Location = new Point(10, 15);
+            label4.Name = "label4";
+            label4.Size = new Size(51, 19);
+            label4.TabIndex = 0;
+            label4.Text = "传感器";
+            // 
+            // panel8
+            // 
+            panel8.Dock = DockStyle.Top;
+            panel8.Location = new Point(16, 370);
+            panel8.Name = "panel8";
+            panel8.Size = new Size(230, 20);
+            panel8.TabIndex = 5;
+            // 
+            // panel9
+            // 
+            panel9.BackColor = Color.WhiteSmoke;
+            panel9.Controls.Add(lblTotalElectricity);
+            panel9.Controls.Add(lblTotalWater);
+            panel9.Controls.Add(lblWashCount);
+            panel9.Controls.Add(label7);
+            panel9.Controls.Add(label9);
+            panel9.Controls.Add(pictureBox6);
+            panel9.Controls.Add(label8);
+            panel9.Controls.Add(pictureBox4);
+            panel9.Controls.Add(pictureBox5);
+            panel9.Controls.Add(label3);
+            panel9.Dock = DockStyle.Top;
+            panel9.Location = new Point(16, 230);
+            panel9.Name = "panel9";
+            panel9.Size = new Size(230, 140);
+            panel9.TabIndex = 4;
+            // 
+            // lblTotalElectricity
+            // 
+            lblTotalElectricity.AutoSize = true;
+            lblTotalElectricity.Location = new Point(130, 109);
+            lblTotalElectricity.Name = "lblTotalElectricity";
+            lblTotalElectricity.Size = new Size(20, 17);
+            lblTotalElectricity.TabIndex = 9;
+            lblTotalElectricity.Text = "无";
+            // 
+            // lblTotalWater
+            // 
+            lblTotalWater.AutoSize = true;
+            lblTotalWater.Location = new Point(130, 79);
+            lblTotalWater.Name = "lblTotalWater";
+            lblTotalWater.Size = new Size(20, 17);
+            lblTotalWater.TabIndex = 9;
+            lblTotalWater.Text = "无";
+            // 
+            // lblWashCount
+            // 
+            lblWashCount.AutoSize = true;
+            lblWashCount.Location = new Point(130, 49);
+            lblWashCount.Name = "lblWashCount";
+            lblWashCount.Size = new Size(20, 17);
+            lblWashCount.TabIndex = 9;
+            lblWashCount.Text = "无";
+            // 
+            // label7
+            // 
+            label7.AutoSize = true;
+            label7.Location = new Point(40, 49);
+            label7.Name = "label7";
+            label7.Size = new Size(56, 17);
+            label7.TabIndex = 5;
+            label7.Text = "累计洗车";
+            // 
+            // label9
+            // 
+            label9.AutoSize = true;
+            label9.Location = new Point(40, 109);
+            label9.Name = "label9";
+            label9.Size = new Size(68, 17);
+            label9.TabIndex = 6;
+            label9.Text = "累计用电量";
+            // 
+            // pictureBox6
+            // 
+            pictureBox6.Image = (Image)resources.GetObject("pictureBox6.Image");
+            pictureBox6.Location = new Point(14, 107);
+            pictureBox6.Name = "pictureBox6";
+            pictureBox6.Size = new Size(20, 20);
+            pictureBox6.TabIndex = 3;
+            pictureBox6.TabStop = false;
+            // 
+            // label8
+            // 
+            label8.AutoSize = true;
+            label8.Location = new Point(40, 79);
+            label8.Name = "label8";
+            label8.Size = new Size(68, 17);
+            label8.TabIndex = 6;
+            label8.Text = "累计用水量";
+            // 
+            // pictureBox4
+            // 
+            pictureBox4.Image = (Image)resources.GetObject("pictureBox4.Image");
+            pictureBox4.Location = new Point(14, 77);
+            pictureBox4.Name = "pictureBox4";
+            pictureBox4.Size = new Size(20, 20);
+            pictureBox4.TabIndex = 3;
+            pictureBox4.TabStop = false;
+            // 
+            // pictureBox5
+            // 
+            pictureBox5.Image = (Image)resources.GetObject("pictureBox5.Image");
+            pictureBox5.Location = new Point(14, 47);
+            pictureBox5.Name = "pictureBox5";
+            pictureBox5.Size = new Size(20, 20);
+            pictureBox5.TabIndex = 4;
+            pictureBox5.TabStop = false;
+            // 
+            // label3
+            // 
+            label3.AutoSize = true;
+            label3.Font = new Font("Microsoft YaHei UI", 10F, FontStyle.Bold, GraphicsUnit.Point);
+            label3.Location = new Point(10, 15);
+            label3.Name = "label3";
+            label3.Size = new Size(37, 19);
+            label3.TabIndex = 0;
+            label3.Text = "统计";
+            // 
+            // panel6
+            // 
+            panel6.Dock = DockStyle.Top;
+            panel6.Location = new Point(16, 210);
+            panel6.Name = "panel6";
+            panel6.Size = new Size(230, 20);
+            panel6.TabIndex = 3;
+            // 
+            // panel7
+            // 
+            panel7.BackColor = Color.WhiteSmoke;
+            panel7.Controls.Add(label2);
+            panel7.Dock = DockStyle.Top;
+            panel7.Location = new Point(16, 95);
+            panel7.Name = "panel7";
+            panel7.Size = new Size(230, 115);
+            panel7.TabIndex = 2;
+            // 
+            // label2
+            // 
+            label2.AutoSize = true;
+            label2.Font = new Font("Microsoft YaHei UI", 10F, FontStyle.Bold, GraphicsUnit.Point);
+            label2.Location = new Point(10, 15);
+            label2.Name = "label2";
+            label2.Size = new Size(65, 19);
+            label2.TabIndex = 0;
+            label2.Text = "安防监控";
+            // 
+            // panel5
+            // 
+            panel5.Dock = DockStyle.Top;
+            panel5.Location = new Point(16, 75);
+            panel5.Name = "panel5";
+            panel5.Size = new Size(230, 20);
+            panel5.TabIndex = 1;
+            // 
+            // panel4
+            // 
+            panel4.BackColor = Color.WhiteSmoke;
+            panel4.Controls.Add(lblError);
+            panel4.Controls.Add(label1);
+            panel4.Dock = DockStyle.Top;
+            panel4.Location = new Point(16, 16);
+            panel4.Name = "panel4";
+            panel4.Size = new Size(230, 59);
+            panel4.TabIndex = 0;
+            // 
+            // lblError
+            // 
+            lblError.AutoSize = true;
+            lblError.Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
+            lblError.ForeColor = Color.Red;
+            lblError.Location = new Point(58, 22);
+            lblError.Name = "lblError";
+            lblError.Size = new Size(20, 17);
+            lblError.TabIndex = 1;
+            lblError.Text = "无";
+            // 
+            // label1
+            // 
+            label1.AutoSize = true;
+            label1.Font = new Font("Microsoft YaHei UI", 10F, FontStyle.Bold, GraphicsUnit.Point);
+            label1.Location = new Point(10, 20);
+            label1.Name = "label1";
+            label1.Size = new Size(37, 19);
+            label1.TabIndex = 0;
+            label1.Text = "故障";
+            // 
+            // panel3
+            // 
+            panel3.Controls.Add(panel10);
+            panel3.Dock = DockStyle.Fill;
+            panel3.Location = new Point(0, 48);
+            panel3.Name = "panel3";
+            panel3.Padding = new Padding(16);
+            panel3.Size = new Size(931, 624);
+            panel3.TabIndex = 0;
+            // 
+            // panel10
+            // 
+            panel10.BackColor = Color.WhiteSmoke;
+            panel10.Controls.Add(dataGridView1);
+            panel10.Controls.Add(panel12);
+            panel10.Controls.Add(label12);
+            panel10.Controls.Add(lblStatus);
+            panel10.Controls.Add(label11);
+            panel10.Controls.Add(label13);
+            panel10.Controls.Add(label10);
+            panel10.Controls.Add(pictureBox1);
+            panel10.Controls.Add(btnConnectCamera);
+            panel10.Dock = DockStyle.Fill;
+            panel10.Location = new Point(16, 16);
+            panel10.Name = "panel10";
+            panel10.Size = new Size(899, 592);
+            panel10.TabIndex = 7;
+            // 
+            // dataGridView1
+            // 
+            dataGridView1.AllowUserToAddRows = false;
+            dataGridView1.AllowUserToDeleteRows = false;
+            dataGridView1.AllowUserToResizeRows = false;
+            dataGridView1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
+            dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+            dataGridView1.Columns.AddRange(new DataGridViewColumn[] { colCarNum, colStartTime, colEndTime, colWashTime, colDryTime, colTotalWater, colTotalElectricity, colWaterPressure });
+            dataGridView1.Location = new Point(29, 383);
+            dataGridView1.Name = "dataGridView1";
+            dataGridView1.RowTemplate.Height = 25;
+            dataGridView1.Size = new Size(843, 196);
+            dataGridView1.TabIndex = 8;
+            // 
+            // colCarNum
+            // 
+            colCarNum.DataPropertyName = "CarNum";
+            colCarNum.HeaderText = "车牌号";
+            colCarNum.Name = "colCarNum";
+            // 
+            // colStartTime
+            // 
+            colStartTime.DataPropertyName = "StartTime";
+            colStartTime.HeaderText = "开始时间";
+            colStartTime.Name = "colStartTime";
+            // 
+            // colEndTime
+            // 
+            colEndTime.DataPropertyName = "EndTime";
+            colEndTime.HeaderText = "结束时间";
+            colEndTime.Name = "colEndTime";
+            // 
+            // colWashTime
+            // 
+            colWashTime.DataPropertyName = "WashTime";
+            colWashTime.HeaderText = "洗车时长";
+            colWashTime.Name = "colWashTime";
+            // 
+            // colDryTime
+            // 
+            colDryTime.DataPropertyName = "DryTime";
+            colDryTime.HeaderText = "风干时长";
+            colDryTime.Name = "colDryTime";
+            // 
+            // colTotalWater
+            // 
+            colTotalWater.DataPropertyName = "TotalWater";
+            colTotalWater.HeaderText = "用水量";
+            colTotalWater.Name = "colTotalWater";
+            // 
+            // colTotalElectricity
+            // 
+            colTotalElectricity.DataPropertyName = "TotalElectricity";
+            colTotalElectricity.HeaderText = "用电量";
+            colTotalElectricity.Name = "colTotalElectricity";
+            // 
+            // colWaterPressure
+            // 
+            colWaterPressure.DataPropertyName = "WaterPressure";
+            colWaterPressure.HeaderText = "水压";
+            colWaterPressure.Name = "colWaterPressure";
+            // 
+            // panel12
+            // 
+            panel12.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+            panel12.BackColor = Color.FromArgb(64, 64, 64);
+            panel12.Location = new Point(29, 372);
+            panel12.Name = "panel12";
+            panel12.Size = new Size(843, 5);
+            panel12.TabIndex = 7;
+            // 
+            // label12
+            // 
+            label12.AutoSize = true;
+            label12.Font = new Font("Microsoft YaHei UI", 10F, FontStyle.Bold, GraphicsUnit.Point);
+            label12.Location = new Point(454, 20);
+            label12.Name = "label12";
+            label12.Size = new Size(45, 19);
+            label12.TabIndex = 0;
+            label12.Text = "状态: ";
+            // 
+            // lblStatus
+            // 
+            lblStatus.AutoSize = true;
+            lblStatus.Location = new Point(500, 22);
+            lblStatus.Name = "lblStatus";
+            lblStatus.Size = new Size(20, 17);
+            lblStatus.TabIndex = 9;
+            lblStatus.Text = "无";
+            // 
+            // label11
+            // 
+            label11.AutoSize = true;
+            label11.Font = new Font("Microsoft YaHei UI", 10F, FontStyle.Bold, GraphicsUnit.Point);
+            label11.Location = new Point(245, 20);
+            label11.Name = "label11";
+            label11.Size = new Size(45, 19);
+            label11.TabIndex = 0;
+            label11.Text = "车辆: ";
             // 
-            // button2
+            // label13
             // 
-            button2.Location = new Point(23, 55);
-            button2.Name = "button2";
-            button2.Size = new Size(75, 23);
-            button2.TabIndex = 3;
-            button2.Text = "button2";
-            button2.UseVisualStyleBackColor = true;
-            button2.Click += button2_Click;
+            label13.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
+            label13.AutoSize = true;
+            label13.Font = new Font("Microsoft YaHei UI", 10F, FontStyle.Bold, GraphicsUnit.Point);
+            label13.Location = new Point(29, 347);
+            label13.Name = "label13";
+            label13.Size = new Size(65, 19);
+            label13.TabIndex = 0;
+            label13.Text = "工作记录";
             // 
-            // button3
+            // label10
             // 
-            button3.Location = new Point(104, 55);
-            button3.Name = "button3";
-            button3.Size = new Size(75, 23);
-            button3.TabIndex = 4;
-            button3.Text = "button3";
-            button3.UseVisualStyleBackColor = true;
-            button3.Click += button3_Click;
+            label10.AutoSize = true;
+            label10.Font = new Font("Microsoft YaHei UI", 10F, FontStyle.Bold, GraphicsUnit.Point);
+            label10.Location = new Point(29, 20);
+            label10.Name = "label10";
+            label10.Size = new Size(45, 19);
+            label10.TabIndex = 0;
+            label10.Text = "编号: ";
             // 
             // MainForm
             // 
             AutoScaleDimensions = new SizeF(7F, 17F);
             AutoScaleMode = AutoScaleMode.Font;
-            ClientSize = new Size(1086, 662);
-            Controls.Add(btnSetting);
-            Controls.Add(lblTime);
-            Controls.Add(pictureBox1);
-            Controls.Add(button4);
-            Controls.Add(button3);
-            Controls.Add(button2);
-            Controls.Add(btnConnectCamera);
+            BackColor = Color.White;
+            ClientSize = new Size(1193, 672);
+            Controls.Add(panel3);
+            Controls.Add(panel2);
+            Controls.Add(panel1);
             Name = "MainForm";
             ShowIcon = false;
             Text = "Form1";
             Load += MainForm_Load;
             ((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit();
+            panel1.ResumeLayout(false);
+            panel1.PerformLayout();
+            ((System.ComponentModel.ISupportInitialize)pictureBox7).EndInit();
+            panel2.ResumeLayout(false);
+            panel11.ResumeLayout(false);
+            panel11.PerformLayout();
+            ((System.ComponentModel.ISupportInitialize)pictureBox3).EndInit();
+            ((System.ComponentModel.ISupportInitialize)pictureBox2).EndInit();
+            panel9.ResumeLayout(false);
+            panel9.PerformLayout();
+            ((System.ComponentModel.ISupportInitialize)pictureBox6).EndInit();
+            ((System.ComponentModel.ISupportInitialize)pictureBox4).EndInit();
+            ((System.ComponentModel.ISupportInitialize)pictureBox5).EndInit();
+            panel7.ResumeLayout(false);
+            panel7.PerformLayout();
+            panel4.ResumeLayout(false);
+            panel4.PerformLayout();
+            panel3.ResumeLayout(false);
+            panel10.ResumeLayout(false);
+            panel10.PerformLayout();
+            ((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
             ResumeLayout(false);
-            PerformLayout();
         }
 
         #endregion
-        private Button button4;
         private PictureBox pictureBox1;
         private System.Windows.Forms.Timer nowTimer;
         private System.Windows.Forms.Timer uploadTimer;
@@ -156,7 +660,52 @@
         private Label lblTime;
         private Button btnSetting;
         private Button btnConnectCamera;
-        private Button button2;
-        private Button button3;
+        private Panel panel1;
+        private Panel panel2;
+        private Panel panel3;
+        private Panel panel5;
+        private Panel panel4;
+        private Label label1;
+        private Panel panel11;
+        private Label label4;
+        private Panel panel8;
+        private Panel panel9;
+        private Label label3;
+        private Panel panel6;
+        private Panel panel7;
+        private Label label2;
+        private PictureBox pictureBox3;
+        private PictureBox pictureBox2;
+        private Label label6;
+        private Label label5;
+        private Label label7;
+        private Label label9;
+        private PictureBox pictureBox6;
+        private Label label8;
+        private PictureBox pictureBox4;
+        private PictureBox pictureBox5;
+        private Panel panel10;
+        private Label label12;
+        private Label label11;
+        private Label label10;
+        private Panel panel12;
+        private Label label13;
+        private PictureBox pictureBox7;
+        private DataGridView dataGridView1;
+        private DataGridViewTextBoxColumn colCarNum;
+        private DataGridViewTextBoxColumn colStartTime;
+        private DataGridViewTextBoxColumn colEndTime;
+        private DataGridViewTextBoxColumn colWashTime;
+        private DataGridViewTextBoxColumn colDryTime;
+        private DataGridViewTextBoxColumn colTotalWater;
+        private DataGridViewTextBoxColumn colTotalElectricity;
+        private DataGridViewTextBoxColumn colWaterPressure;
+        private Label lblError;
+        private Label lblStatus;
+        private Label lblTotalElectricity;
+        private Label lblTotalWater;
+        private Label lblWashCount;
+        private Label lblCurrentElectricity;
+        private Label lblCurrentWaterP;
     }
 }

+ 146 - 37
MainForm.cs

@@ -1,4 +1,5 @@
 using Hik.Api;
+using Newtonsoft.Json.Linq;
 using S7.Net;
 using System.Threading.Channels;
 using System.Windows.Forms;
@@ -7,26 +8,50 @@ namespace xicheji
 {
     public partial class MainForm : Form
     {
+        private readonly Config config;
+        private readonly List<WashRecord> washRecords = new();
+        private DateTime lastReceiveTime = DateTime.MinValue;
         private Plc? plc = null;
         private HikApi? hikApi = null;
+
         public MainForm()
         {
             InitializeComponent();
+            config = ConfigHelper.GetConfig();
         }
 
+
         private void MainForm_Load(object sender, EventArgs e)
         {
             try
             {
-
+                //测试数据
+                washRecords.Add(new WashRecord()
+                {
+                    CarNum = "京123456",
+                    StartTime = new DateTime(2024, 6, 1, 12, 00, 00),
+                    EndTime = new DateTime(2024, 6, 1, 12, 30, 00),
+                    WashTime = 15,
+                    DryTime = 15,
+                    TotalElectricity = 10,
+                    TotalWater = 2,
+                    WaterPressure = 6,
+                });
+
+                dataGridView1.DataSource = washRecords;
+
+                ConnectPLC();
+                //ConnectCamera();
+
+                receivePLCTimer.Enabled = true;
+                uploadTimer.Enabled = true;
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message + ex.StackTrace);
             }
         }
-
-        private void button1_Click(object sender, EventArgs e)
+        private void btnConnectCamera_Click(object sender, EventArgs e)
         {
             try
             {
@@ -38,26 +63,27 @@ namespace xicheji
             }
         }
 
-        private void button2_Click(object sender, EventArgs e)
+        private void nowTimer_Tick(object sender, EventArgs e)
         {
-            if (plc == null || !plc.IsConnected)
+            try
             {
-                Log("连接成功!");
-                return;
+                var now = DateTime.Now;
+                lblTime.Text = $"{now.Month}月 {now.Day}日  {now.Hour}:{now:mm}:{now:ss}";
             }
-
-        }
-
-        private void button3_Click(object sender, EventArgs e)
-        {
-            plc?.Close();
+            catch { }
         }
 
-        private void button4_Click(object sender, EventArgs e)
+        private void receivePLCTimer_Tick(object sender, EventArgs e)
         {
             try
             {
+                if (plc == null || !plc.IsConnected)
+                {
+                    receivePLCTimer.Enabled = false;
+                    return;
+                }
 
+                ReadPLCData();
             }
             catch (Exception ex)
             {
@@ -65,27 +91,102 @@ namespace xicheji
             }
         }
 
-        private void nowTimer_Tick(object sender, EventArgs e)
+        private void ReadPLCData()
         {
-            try
+            lblWashCount.Text = ReadPLCString("洗车次数");
+            return;
+
+            var time = new DateTime(
+                DateTime.Now.Year,
+                ReadPLCInt("当前月"),
+                ReadPLCInt("当前日"),
+                ReadPLCInt("当前时"),
+                ReadPLCInt("当前分"),
+                ReadPLCInt("当前秒"));
+
+            if (time <= lastReceiveTime)
             {
-                var now = DateTime.Now;
-                lblTime.Text = $"{now.Year}年 {now.Month}月 {now.Day}日  {now.Hour}:{now.Minute}:{now.Second}";
+                //已经读过这个时间的了
+                return;
             }
-            catch { }
+
+            lastReceiveTime = time;
+
+            ReadError();
+            ReadStatus();
+
+            lblWashCount.Text = ReadPLCString("洗车次数");
+            lblTotalWater.Text = ReadPLCString("累计用水量");
+            lblTotalElectricity.Text = ReadPLCString("累计用电量");
+            //.Text = ReadPLCStringValue("当前流量");
+            lblCurrentElectricity.Text = ReadPLCString("当前功率");
+            lblCurrentWaterP.Text = ReadPLCString("当前压力");
         }
 
-        private void receivePLCTimer_Tick(object sender, EventArgs e)
+        private void ReadStatus()
         {
-            try
+            lblStatus.Text = string.Empty;
+
+            var statuses = new List<string>() {
+                "洗车中", "清洗中", "沥水中",
+                "出车中", "风干中"};
+
+            foreach (var status in statuses)
             {
-                if (plc == null || !plc.IsConnected)
+                if (ReadPLCBool(status))
                 {
-                    receivePLCTimer.Enabled = false;
-                    return;
+                    lblStatus.Text = status;
+                    break;
+                }
+            }
+        }
+
+        private void ReadError()
+        {
+            lblError.Text = string.Empty;
+
+            var errors = new List<string>() {
+                "急停", "冲洗泵故障", "反洗泵故障",
+                "清淤泵故障", "伴热故障", "风刀故障" };
+
+            foreach (var error in errors)
+            {
+                if (ReadPLCBool(error))
+                {
+                    lblError.Text = error;
+                    break;
                 }
             }
-            catch { }
+        }
+
+        private string ReadPLCString(string name)
+        {
+            var variable = ConfigHelper.FindVariable(name);
+            if (plc == null || variable == null)
+                return string.Empty;
+
+            var value = plc.Read(variable.Key);
+            return $"{value} {variable.Desc}";
+        }
+
+        private int ReadPLCInt(string name)
+        {
+            var variable = ConfigHelper.FindVariable(name);
+            if (plc == null || variable == null)
+                return 0;
+
+            var value = plc.Read(variable.Key);
+            return int.Parse(value?.ToString() ?? "0");
+        }
+
+        private bool ReadPLCBool(string name)
+        {
+            var variable = ConfigHelper.FindVariable(name);
+            if (plc == null || variable == null)
+                return false;
+
+            var value = plc.Read(variable.Key);
+            return value?.ToString()?.ToLower() == "true";
         }
 
         private void uploadTimer_Tick(object sender, EventArgs e)
@@ -112,7 +213,7 @@ namespace xicheji
 
         private void ConnectPLC()
         {
-            plc = new Plc(CpuType.S7200, "127.0.0.1", 1502, 0, 1);
+            plc = new Plc(config.PLCType, config.PLCIP, int.Parse(config.PLCPort), 0, 1);
             plc.Open();
 
             if (plc == null || !plc.IsConnected)
@@ -124,23 +225,31 @@ namespace xicheji
 
         private void ConnectCamera()
         {
-            hikApi = HikApi.Login("192.168.1.64", 8000, "admin", "password") as HikApi;
+            try
+            {
+                hikApi = HikApi.Login(config.CameraIP, int.Parse(config.CameraPort),
+                    config.CameraUserName, config.CameraPassword) as HikApi;
 
-            if (hikApi == null || !hikApi.Connected)
+                if (hikApi == null || !hikApi.Connected)
+                {
+                    MessageBox.Show("摄像头连接失败!");
+                    return;
+                }
+
+                hikApi.PlaybackService.StartPlayBack(hikApi.DefaultIpChannel, pictureBox1.Handle);
+            }
+            catch (Exception ex)
             {
-                MessageBox.Show("摄像头连接失败!");
-                return;
+                MessageBox.Show(ex.Message + ex.StackTrace);
             }
-
-            hikApi.PlaybackService.StartPlayBack(hikApi.DefaultIpChannel, pictureBox1.Handle);
         }
 
-        private void Log(params object[] msgs)
+        public void UpdateCarInfo(DateTime now)
         {
-            //richTextBox1.AppendText(string.Join(" ", msgs));
-            //richTextBox1.AppendText("\n\n");
-            //richTextBox1.ScrollToCaret();
-            Console.WriteLine(string.Join(" ", msgs));
+            this.Invoke(() =>
+            {
+                this.Text = now.ToString();
+            });
         }
     }
 }

+ 90 - 0
MainForm.resx

@@ -126,4 +126,94 @@
   <metadata name="receivePLCTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     <value>136, 20</value>
   </metadata>
+  <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
+  <data name="btnSetting.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+    <value>
+        iVBORw0KGgoAAAANSUhEUgAAABUAAAAUCAYAAABiS3YzAAAABGdBTUEAALGPC/xhBQAAATZJREFUOE+d
+        U8ERgzAMY5R+GlgA6JNRugmjMEpHYZQ2ciwwiZtCdcdBLEU2dtJ46LrHrb33rzYM7xCGGWulwE0xvoK3
+        8SpCGBeYyaPGeMPcrsVYko5L1by7909uolAqowniUSPiCBZgYwX01+oiAyRO1Q6zhkpQdMH0dxHSN4jO
+        DiAi6qUtutyBjNuAMgESgEvP8SQALETnMAm/Bb8YWo7f2KwSgfVA8q38vAJAuPiQg1kes6A5NrrTwyaP
+        40bPFAOj6fqn6aEFQGbq3wpweMhpIomJIAOHXTTZmhsT8HxXBwWdBCHSLEUrYIwYeE3qGnqcQI2vHv69
+        Og/IJKYX735Vf0pkcKoIHgntT5o4YrxNuCRxTW7vZ3kkD9C+pklnZlxbDb51ax3yW8mgPA3pb3i2y2k3
+        TfMBsVzobDD5cwQAAAAASUVORK5CYII=
+</value>
+  </data>
+  <data name="btnConnectCamera.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+    <value>
+        iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAABGdBTUEAALGPC/xhBQAAANZJREFUOE+9
+        VNsNwyAMzCj9RAJ2YJRu0lEyCqNklNYXnZUHGEoi5SQrtvHj7CCmx+Gce0FCCImua5ACH5HsvV+gy3fe
+        2wzrg2yylcRzNFig012HBCYy6I63a2zHdgNOQFEQoHmEFMLO/t8NYeaZnTowWUqXTHUYRW6M8S1dZprD
+        QK4U3XYP4w7D4vo0/9ZV3Bm5Chl56Nro3iHQ6d7AsY/LbQDx3P3XJKK7LJZcAQvisQAJezINbAXhDI3l
+        m5Qpj+pg0PpkIVFZiIw/X2coAwh0up/CNP0AVzZV5NWBuZ4AAAAASUVORK5CYII=
+</value>
+  </data>
+  <data name="pictureBox3.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+    <value>
+        iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAABGdBTUEAALGPC/xhBQAAAJVJREFUOE+t
+        lIEJgDAQAzuKoziKmziKoziKo+iHGpBQa/3/g0ARTN8mtfxkupUCjM66zGE3HXUZZzVhuhTDxQQzaMOD
+        CDw3CpO6UbOwIUJQw9nkgiGo2ENVl2cII+pOjd1aL70Jm3fRT4EwQcvMXaGWIQJzowGFb4sauqtDcFY0
+        +wxhBBY8fI8JzEIhKGn/QMAeDlLKBZQ0TrFKZ9UEAAAAAElFTkSuQmCC
+</value>
+  </data>
+  <data name="pictureBox2.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+    <value>
+        iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAABGdBTUEAALGPC/xhBQAAAMtJREFUOE/t
+        U9sNwyAQY5STckgdo6N0k47SUTJKRmnvjCFUBfLoZ2vpJLgYY4tL+KMJkYuI6pXbc4DIFB+i8Vlqigt6
+        9o20fXA3RUD1TuFZYrxh7X1bkz5GilfEELN2RFF3uuxyCgfupkGGGOIjwezFT3204sB1JYaeixoXhBFw
+        yFxyCyShVczBJG+9D8AJiPYQjIxeuqS4afEO4dShDNw6quzc11ujw3h4vX7ZY9S8b9wfBm9OQ53Xo9oa
+        7iTiQ7v+IXnfKxz8ZYTwAvsQbg8V26c2AAAAAElFTkSuQmCC
+</value>
+  </data>
+  <data name="pictureBox6.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+    <value>
+        iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAABGdBTUEAALGPC/xhBQAAAIlJREFUOE9j
+        GAW0Azo6Ov9xYW1t7fsaGhoKUKV0BCBbQbZjcxU2TNClIEmgwv1QLkEAUku2gSA5dM0UGQgSR5cj2kAQ
+        DQofaHjWQ/nzQRjId4AqJ92F6AZBMdylIJokA0FAV1c3AeRSKBcFkGUgSAyXJrIMxAcIGggCIO8Ri4EG
+        /odqGwVUAwwMABNvY/mQYlG1AAAAAElFTkSuQmCC
+</value>
+  </data>
+  <data name="pictureBox4.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+    <value>
+        iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAABGdBTUEAALGPC/xhBQAAANVJREFUOE/F
+        U8ENwyAMZJQ+kYAdGCWbdJSOwigdpfUhW4LEpg6fnnQSxucLGCf8BTnnRvwQn7y1j8FMuG86mDXEKaX3
+        timKRjPBlmmM8aGZCcQUOt5aA0arAspV5Im/TwmRRyy6UsrBWzogwpU4XIKvrralY+idq+Ewg57DKygp
+        valsjrivWTKBcv3a5uOIwCBOg3xF30C68gs5s48i2KDeInxJEXtY2WIGEiehi1yuQ/6CG1xPBF7Mawod
+        l63hNLUH2gIVYUzaaE5rTIL+CHdgDu+EEL7tZs/mQJ+K4AAAAABJRU5ErkJggg==
+</value>
+  </data>
+  <data name="pictureBox5.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+    <value>
+        iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAABGdBTUEAALGPC/xhBQAAASpJREFUOE+V
+        VIENwiAQ7CiO4iiOUG1NKjFxFEdxFEdR7vijQKCllxDluD+e/9ehhXFZTre7u4yze13nxwdrnNw7cM+z
+        yfYBo2DiflyT+8IomBrnFzQW0gZujiaNgOxC6hrZRjOfiVGbgDEMm6aqk227kJoaFaAnQGDUJlIdTRHr
+        62wUsiuIDag06TPZNGUZBZ3ZYWygx6dR+SUS2FkVqK0Mqob2bHJZuhXEGtkY1QyB0G2vYUMKQ3AK6DaU
+        Ru83nsBeI9RjKA9ya8DaNe6t66VhFmzQJdCSKIcawekF6R5BMhcYn5ZNt5bCHiAmxK4JEDxgp4qDDcRE
+        aj8K1sobxvbvQJmVE5JB9ZEQ35EFeb9QfL3kUImYLRuF8SkWzfy/94HSZFBm6Zi0MQx/A5NbYM+/LJQA
+        AAAASUVORK5CYII=
+</value>
+  </data>
+  <metadata name="colCarNum.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="colStartTime.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="colEndTime.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="colWashTime.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="colDryTime.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="colTotalWater.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="colTotalElectricity.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="colWaterPressure.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
 </root>

+ 11 - 1
Program.cs

@@ -1,9 +1,14 @@
 using Hik.Api;
+using Nancy.Hosting.Self;
 
 namespace xicheji
 {
     internal static class Program
     {
+#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
+        public static MainForm MainForm { get; set; }
+#pragma warning restore CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
+
         /// <summary>
         ///  The main entry point for the application.
         /// </summary>
@@ -13,8 +18,13 @@ namespace xicheji
             // To customize application configuration such as set high DPI settings or default font,
             // see https://aka.ms/applicationconfiguration.
             ApplicationConfiguration.Initialize();
+
             HikApi.Initialize();
-            Application.Run(new MainForm());
+
+            new NancyHost(new Uri($"http://localhost:{ConfigHelper.GetConfig().ServicePort}/")).Start();
+
+            MainForm = new MainForm();
+            Application.Run(MainForm);
         }
     }
 }

+ 1 - 1
README.md

@@ -1,5 +1,5 @@
 ·¢²¼
 
 ```
-dotnet publish "xicheji.csproj" -c Release -o ./release/ -r win-x64 --self-contained /p:PublishSingleFile=true
+dotnet publish "xicheji.csproj" -c Release -o ./release/ -r win-x64 --no-self-contained /p:PublishSingleFile=true
 ```

+ 54 - 0
WashRecord.cs

@@ -0,0 +1,54 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace xicheji
+{
+    /// <summary>
+    /// 洗车记录
+    /// </summary>
+    public class WashRecord
+    {
+        /// <summary>
+        /// 车牌号
+        /// </summary>
+        public string CarNum { get; set; } = string.Empty;
+
+        /// <summary>
+        /// 开始时间
+        /// </summary>
+        public DateTime StartTime { get; set; }
+
+        /// <summary>
+        /// 结束时间
+        /// </summary>
+        public DateTime EndTime { get; set; }
+
+        /// <summary>
+        /// 洗车时长
+        /// </summary>
+        public int WashTime { get; set; }
+
+        /// <summary>
+        /// 风干时长
+        /// </summary>
+        public int DryTime { get; set; }
+
+        /// <summary>
+        /// 用水量
+        /// </summary>
+        public int TotalWater { get; set; }
+
+        /// <summary>
+        /// 用电量
+        /// </summary>
+        public int TotalElectricity { get; set; }
+
+        /// <summary>
+        /// 水压
+        /// </summary>
+        public int WaterPressure { get; set; }
+    }
+}

+ 2 - 0
config.xml

@@ -1,5 +1,7 @@
 <?xml version="1.0" encoding="utf-8" ?>
 <Config>
+	<!--Service Port只能从配置文件修改, 然后重新运行程序-->
+	<Service Port="9999"/>
 	<Platform Server="http[s]://+IP+Port+BasePath"  UploadInterval="2"/>
 	<!--Type: S7200,Logo0BA8,S7200Smart,S7300,S7400,S71200,S71500-->
 	<Device IP="127.0.0.1" Port="1502" Type="S7200" ReceiveInterval="2" MacVariable="" Gateway="" Netmask="" />

+ 18 - 0
xicheji.csproj

@@ -12,9 +12,27 @@
     <PackageReference Include="FreeSql" Version="3.2.825" />
     <PackageReference Include="FreeSql.Provider.Sqlite" Version="3.2.825" />
     <PackageReference Include="Hik.Api" Version="2.0.0" />
+    <PackageReference Include="Nancy" Version="2.0.0" />
+    <PackageReference Include="Nancy.Hosting.Self" Version="2.0.0" />
+    <PackageReference Include="RestClient" Version="3.1024.23771" />
     <PackageReference Include="S7netplus" Version="0.20.0" />
   </ItemGroup>
 
+  <ItemGroup>
+    <Compile Update="Properties\Resources.Designer.cs">
+      <DesignTime>True</DesignTime>
+      <AutoGen>True</AutoGen>
+      <DependentUpon>Resources.resx</DependentUpon>
+    </Compile>
+  </ItemGroup>
+
+  <ItemGroup>
+    <EmbeddedResource Update="Properties\Resources.resx">
+      <Generator>ResXFileCodeGenerator</Generator>
+      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
+    </EmbeddedResource>
+  </ItemGroup>
+
   <ItemGroup>
     <None Update="config.xml">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>

+ 5 - 0
xicheji.csproj.user

@@ -8,4 +8,9 @@
       <SubType>Form</SubType>
     </Compile>
   </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Update="MainForm.resx">
+      <SubType>Designer</SubType>
+    </EmbeddedResource>
+  </ItemGroup>
 </Project>

+ 1 - 1
xicheji.sln

@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
 # Visual Studio Version 17
 VisualStudioVersion = 17.8.34316.72
 MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "xicheji", "xicheji.csproj", "{6BAB5EB5-68FC-4C50-A36A-9BBD96FCD7FF}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "xicheji", "xicheji.csproj", "{6BAB5EB5-68FC-4C50-A36A-9BBD96FCD7FF}"
 EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution