2 Commits ebbc5a9a97 ... 2cebf0979e

Tác giả SHA1 Thông báo Ngày
  weijw 2cebf0979e setting form 5 tháng trước cách đây
  weijw f826041842 update .netcore 6.0 5 tháng trước cách đây

+ 0 - 6
App.config

@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<configuration>
-    <startup> 
-        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
-    </startup>
-</configuration>

+ 109 - 0
ConfigHelper.cs

@@ -0,0 +1,109 @@
+
+using S7.Net;
+using System.Xml.Linq;
+
+namespace xicheji
+{
+    public class ConfigHelper
+    {
+        private const string configFileName = "config.xml";
+        private static Config? _config;
+
+        public static Config GetConfig()
+        {
+            _config ??= LoadConfig();
+            return _config;
+        }
+
+        private static Config LoadConfig()
+        {
+            if (!File.Exists(configFileName))
+            {
+                return new Config();
+            }
+
+            var xdoc = XDocument.Load(configFileName);
+            if (xdoc.Root == null)
+            {
+                return new Config();
+            }
+
+            var config = new Config();
+
+            var platform = xdoc.Root!.Element("Platform");
+            config.Server = platform?.Attribute("Server")?.Value ?? "";
+
+            var device = xdoc.Root!.Element("Device");
+            config.PLCIP = device?.Attribute("IP")?.Value ?? "";
+            config.PLCPort = device?.Attribute("Port")?.Value ?? "";
+            config.PLCType = Enum.Parse<CpuType>(device?.Attribute("Type")?.Value ?? "S7200");
+            config.PLCReceiveInterval = int.Parse(device?.Attribute("ReceiveInterval")?.Value ?? "2");
+
+            var camera = xdoc.Root!.Element("Camera");
+            config.CameraIP = camera?.Attribute("IP")?.Value ?? "";
+            config.CameraPort = camera?.Attribute("Port")?.Value ?? "";
+            config.CameraUserName = camera?.Attribute("UserName")?.Value ?? "";
+            config.CameraPassword = camera?.Attribute("Password")?.Value ?? "";
+
+            var variablesRoot = xdoc.Root!.Element("Variables");
+            if (variablesRoot != null)
+            {
+                config.DBName = variablesRoot.Attribute("DBName")?.Value ?? "DB1";
+                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 ?? "";
+                    if (string.IsNullOrEmpty(variable.Name) || string.IsNullOrEmpty(variable.Key))
+                    {
+                        continue;
+                    }
+
+                    config.Variables.Add(variable);
+                }
+            }
+
+            return config;
+        }
+
+        public static void SaveConfig(Config config)
+        {
+            _config = config;
+
+
+        }
+
+        public static Variable? FindVariable(string variableName)
+        {
+            var config = GetConfig();
+
+            var variable = config.Variables.Find(x => x.Name == variableName);
+
+            return variable;
+        }
+    }
+
+    public class Config
+    {
+        public string Server { get; set; } = string.Empty;
+        public string PLCIP { get; set; } = string.Empty;
+        public string PLCPort { get; set; } = string.Empty;
+        public CpuType PLCType { get; set; } = CpuType.S7200;
+        public int PLCReceiveInterval { get; set; } = 2;
+        public string CameraIP { get; set; } = string.Empty;
+        public string CameraPort { get; set; } = string.Empty;
+        public string CameraUserName { get; set; } = string.Empty;
+        public string CameraPassword { get; set; } = string.Empty;
+        public string DBName { get; set; } = string.Empty;
+        public List<Variable> Variables { get; set; } = new();
+    }
+
+    public class Variable
+    {
+        public string Name { get; set; } = string.Empty;
+        public string Key { get; set; } = string.Empty;
+        public string Desc { get; set; } = string.Empty;
+    }
+}

+ 128 - 76
MainForm.Designer.cs

@@ -1,17 +1,16 @@
-
-namespace xicheji
+namespace xicheji
 {
     partial class MainForm
     {
         /// <summary>
-        /// 必需的设计器变量。
+        ///  Required designer variable.
         /// </summary>
         private System.ComponentModel.IContainer components = null;
 
         /// <summary>
-        /// 清理所有正在使用的资源。
+        ///  Clean up any resources being used.
         /// </summary>
-        /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
         protected override void Dispose(bool disposing)
         {
             if (disposing && (components != null))
@@ -21,90 +20,143 @@ namespace xicheji
             base.Dispose(disposing);
         }
 
-        #region Windows 窗体设计器生成的代码
+        #region Windows Form Designer generated code
 
         /// <summary>
-        /// 设计器支持所需的方法 - 不要修改
-        /// 使用代码编辑器修改此方法的内容。
+        ///  Required method for Designer support - do not modify
+        ///  the contents of this method with the code editor.
         /// </summary>
         private void InitializeComponent()
         {
-            this.button1 = new System.Windows.Forms.Button();
-            this.textBox1 = new System.Windows.Forms.TextBox();
-            this.button2 = new System.Windows.Forms.Button();
-            this.button3 = new System.Windows.Forms.Button();
-            this.richTextBox1 = new System.Windows.Forms.RichTextBox();
-            this.SuspendLayout();
-            // 
-            // button1
-            // 
-            this.button1.Location = new System.Drawing.Point(197, 74);
-            this.button1.Name = "button1";
-            this.button1.Size = new System.Drawing.Size(75, 23);
-            this.button1.TabIndex = 0;
-            this.button1.Text = "open";
-            this.button1.UseVisualStyleBackColor = true;
-            this.button1.Click += new System.EventHandler(this.button1_Click);
-            // 
-            // textBox1
-            // 
-            this.textBox1.Location = new System.Drawing.Point(134, 127);
-            this.textBox1.Name = "textBox1";
-            this.textBox1.Size = new System.Drawing.Size(100, 21);
-            this.textBox1.TabIndex = 1;
+            components = new System.ComponentModel.Container();
+            button4 = new Button();
+            pictureBox1 = new PictureBox();
+            nowTimer = new System.Windows.Forms.Timer(components);
+            uploadTimer = new System.Windows.Forms.Timer(components);
+            receivePLCTimer = new System.Windows.Forms.Timer(components);
+            lblTime = new Label();
+            btnSetting = new Button();
+            btnConnectCamera = new Button();
+            button2 = new Button();
+            button3 = new Button();
+            ((System.ComponentModel.ISupportInitialize)pictureBox1).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.Name = "pictureBox1";
+            pictureBox1.Size = new Size(365, 463);
+            pictureBox1.TabIndex = 6;
+            pictureBox1.TabStop = false;
+            // 
+            // nowTimer
+            // 
+            nowTimer.Enabled = true;
+            nowTimer.Interval = 1000;
+            nowTimer.Tick += nowTimer_Tick;
+            // 
+            // uploadTimer
+            // 
+            uploadTimer.Tick += uploadTimer_Tick;
+            // 
+            // receivePLCTimer
+            // 
+            receivePLCTimer.Tick += receivePLCTimer_Tick;
+            // 
+            // lblTime
+            // 
+            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.Name = "lblTime";
+            lblTime.Size = new Size(203, 21);
+            lblTime.TabIndex = 7;
+            lblTime.Text = "0000年 0月 00日  00:00:00";
+            // 
+            // btnSetting
+            // 
+            btnSetting.Anchor = AnchorStyles.Top | AnchorStyles.Right;
+            btnSetting.Location = new Point(815, 26);
+            btnSetting.Name = "btnSetting";
+            btnSetting.Size = new Size(50, 23);
+            btnSetting.TabIndex = 8;
+            btnSetting.Text = "配置";
+            btnSetting.UseVisualStyleBackColor = true;
+            btnSetting.Click += btnSetting_Click;
+            // 
+            // btnConnectCamera
+            // 
+            btnConnectCamera.Location = new Point(975, 102);
+            btnConnectCamera.Name = "btnConnectCamera";
+            btnConnectCamera.Size = new Size(80, 23);
+            btnConnectCamera.TabIndex = 0;
+            btnConnectCamera.Text = "重连摄像头";
+            btnConnectCamera.UseVisualStyleBackColor = true;
+            btnConnectCamera.Click += button1_Click;
             // 
             // button2
             // 
-            this.button2.Location = new System.Drawing.Point(259, 125);
-            this.button2.Name = "button2";
-            this.button2.Size = new System.Drawing.Size(75, 23);
-            this.button2.TabIndex = 2;
-            this.button2.Text = "read";
-            this.button2.UseVisualStyleBackColor = true;
-            this.button2.Click += new System.EventHandler(this.button2_Click);
+            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;
             // 
             // button3
             // 
-            this.button3.Location = new System.Drawing.Point(197, 177);
-            this.button3.Name = "button3";
-            this.button3.Size = new System.Drawing.Size(75, 23);
-            this.button3.TabIndex = 3;
-            this.button3.Text = "close";
-            this.button3.UseVisualStyleBackColor = true;
-            this.button3.Click += new System.EventHandler(this.button3_Click);
-            // 
-            // richTextBox1
-            // 
-            this.richTextBox1.Location = new System.Drawing.Point(458, 104);
-            this.richTextBox1.Name = "richTextBox1";
-            this.richTextBox1.Size = new System.Drawing.Size(330, 315);
-            this.richTextBox1.TabIndex = 4;
-            this.richTextBox1.Text = "";
-            // 
-            // Form1
-            // 
-            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
-            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(800, 450);
-            this.Controls.Add(this.richTextBox1);
-            this.Controls.Add(this.button3);
-            this.Controls.Add(this.button2);
-            this.Controls.Add(this.textBox1);
-            this.Controls.Add(this.button1);
-            this.Name = "Form1";
-            this.Text = "Form1";
-            this.ResumeLayout(false);
-            this.PerformLayout();
-
+            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;
+            // 
+            // 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);
+            Name = "MainForm";
+            ShowIcon = false;
+            Text = "Form1";
+            Load += MainForm_Load;
+            ((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit();
+            ResumeLayout(false);
+            PerformLayout();
         }
 
         #endregion
-
-        private System.Windows.Forms.Button button1;
-        private System.Windows.Forms.TextBox textBox1;
-        private System.Windows.Forms.Button button2;
-        private System.Windows.Forms.Button button3;
-        private System.Windows.Forms.RichTextBox richTextBox1;
+        private Button button4;
+        private PictureBox pictureBox1;
+        private System.Windows.Forms.Timer nowTimer;
+        private System.Windows.Forms.Timer uploadTimer;
+        private System.Windows.Forms.Timer receivePLCTimer;
+        private Label lblTime;
+        private Button btnSetting;
+        private Button btnConnectCamera;
+        private Button button2;
+        private Button button3;
     }
 }
-

+ 105 - 66
MainForm.cs

@@ -1,34 +1,36 @@
-using S7.Net;
-using S7.Net.Types;
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using Hik.Api;
+using S7.Net;
+using System.Threading.Channels;
 using System.Windows.Forms;
 
 namespace xicheji
 {
     public partial class MainForm : Form
     {
-        private Plc plc;
-
+        private Plc? plc = null;
+        private HikApi? hikApi = null;
         public MainForm()
         {
             InitializeComponent();
         }
 
+        private void MainForm_Load(object sender, EventArgs e)
+        {
+            try
+            {
+
+            }
+            catch (Exception ex)
+            {
+                MessageBox.Show(ex.Message + ex.StackTrace);
+            }
+        }
+
         private void button1_Click(object sender, EventArgs e)
         {
             try
             {
-                plc = new Plc(CpuType.S7200, "127.0.0.1", 1502, 0, 1);
-                plc.Open();
-                richTextBox1.AppendText("连接成功!\n\n");
-                richTextBox1.ScrollToCaret();
+                ConnectCamera();
             }
             catch (Exception ex)
             {
@@ -38,53 +40,24 @@ namespace xicheji
 
         private void button2_Click(object sender, EventArgs e)
         {
-            if (plc == null || !plc.IsConnected) return;
-            //plc中类型与c#类型 bool => Bit
-            //Byte => byte
-            //word => ushort
-            //DWord => uint
-            //Int => short
-            //DInt => int
-            //Real => float
-            //LReal => double
-            //String => string
-            //DateTimeLong=>datetime
-            //s7wstring=>string
-
-            //PLCAddress.Parse
-            //1、DB100.DBB0 一个字节有8个位,分别为0-- - 7!例:0.0----0.7共8位   --Byte,byte
-            //2、DB100.DBW0一个字有两个字节,分别为 DB100.DBB0和 DB100.DBB1       --Word,ushort
-            //3、DB100.DBD0一个双字有两个字,分别为 DB100.DBW0和 DB100.DBW2       --DWord,uint
-            //4、DB100.DBX0.0 一个位,这是最小单位     --Bit,bool
+            if (plc == null || !plc.IsConnected)
+            {
+                Log("连接成功!");
+                return;
+            }
+
+        }
+
+        private void button3_Click(object sender, EventArgs e)
+        {
+            plc?.Close();
+        }
 
+        private void button4_Click(object sender, EventArgs e)
+        {
             try
             {
-                
-                var db = 1;
-                var start = plc.Read(DataType.DataBlock, db, 0, VarType.Byte, 1);
-                Log("start:", start);
-                var start2 = plc.Read("DB1.DBB0");
-                Log("start2:", start2);
-                var length = plc.Read(DataType.DataBlock, db, 1, VarType.Byte, 1);
-                Log("length:", length);
-                var length2 = plc.Read("DB1.DBB1");
-                Log("length2:", length2);
-                var mac = plc.Read(DataType.DataBlock, db, 2, VarType.Byte, 6);
-                Log("mac:", string.Join(":", (mac as byte[]).ToList().ConvertAll(a => "0x" + a.ToString("X2"))));
-                var mac2 = plc.Read("DB1.DBD2-6");
-                Log("mac2:", mac2);
-                var val = plc.Read(DataType.DataBlock, db, 10, VarType.Bit, 1, 1);
-                Log("DB1.DBX10.1的值为:", val);
-                val = plc.Read(DataType.DataBlock, db, 10, VarType.Bit, 1, 2);
-                Log("DB1.DBX10.2的值为:", val);
-                val = plc.Read(DataType.DataBlock, db, 20, VarType.DWord, 1);
-                Log("读取DB1.DBX20 DWORD的洗车次数值为:", val);
-
-                var bbb = (bool)plc.Read("DB1.DBX10.1");
-                Log("bbb:", bbb);
-                var ccc = plc.Read("DB1.DBD20");
-                Log("ccc:", ccc);
-                //DWord.FromByteArray
+
             }
             catch (Exception ex)
             {
@@ -92,16 +65,82 @@ namespace xicheji
             }
         }
 
-        private void Log(params object[] msgs)
+        private void nowTimer_Tick(object sender, EventArgs e)
         {
-            richTextBox1.AppendText(string.Join(" ", msgs));
-            richTextBox1.AppendText("\n\n");
-            richTextBox1.ScrollToCaret();
+            try
+            {
+                var now = DateTime.Now;
+                lblTime.Text = $"{now.Year}年 {now.Month}月 {now.Day}日  {now.Hour}:{now.Minute}:{now.Second}";
+            }
+            catch { }
         }
 
-        private void button3_Click(object sender, EventArgs e)
+        private void receivePLCTimer_Tick(object sender, EventArgs e)
         {
-            plc?.Close();
+            try
+            {
+                if (plc == null || !plc.IsConnected)
+                {
+                    receivePLCTimer.Enabled = false;
+                    return;
+                }
+            }
+            catch { }
+        }
+
+        private void uploadTimer_Tick(object sender, EventArgs e)
+        {
+
+        }
+
+        private void btnSetting_Click(object sender, EventArgs e)
+        {
+            try
+            {
+                var settingForm = new SettingForm();
+                if (settingForm.ShowDialog() == DialogResult.OK)
+                {
+                    ConnectPLC();
+                    ConnectCamera();
+
+                    receivePLCTimer.Enabled = true;
+                    uploadTimer.Enabled = true;
+                }
+            }
+            catch { }
+        }
+
+        private void ConnectPLC()
+        {
+            plc = new Plc(CpuType.S7200, "127.0.0.1", 1502, 0, 1);
+            plc.Open();
+
+            if (plc == null || !plc.IsConnected)
+            {
+                MessageBox.Show("PLC连接失败!");
+                return;
+            }
+        }
+
+        private void ConnectCamera()
+        {
+            hikApi = HikApi.Login("192.168.1.64", 8000, "admin", "password") as HikApi;
+
+            if (hikApi == null || !hikApi.Connected)
+            {
+                MessageBox.Show("摄像头连接失败!");
+                return;
+            }
+
+            hikApi.PlaybackService.StartPlayBack(hikApi.DefaultIpChannel, pictureBox1.Handle);
+        }
+
+        private void Log(params object[] msgs)
+        {
+            //richTextBox1.AppendText(string.Join(" ", msgs));
+            //richTextBox1.AppendText("\n\n");
+            //richTextBox1.ScrollToCaret();
+            Console.WriteLine(string.Join(" ", msgs));
         }
     }
 }

+ 34 - 25
MainForm.resx

@@ -1,17 +1,17 @@
 <?xml version="1.0" encoding="utf-8"?>
 <root>
-  <!-- 
+  <!--
     Microsoft ResX Schema 
-    
+
     Version 2.0
-    
-    The primary goals of this format is to allow a simple XML format 
-    that is mostly human readable. The generation and parsing of the 
-    various data types are done through the TypeConverter classes 
+
+    The primary goals of this format is to allow a simple XML format
+    that is mostly human readable. The generation and parsing of the
+    various data types are done through the TypeConverter classes
     associated with the data types.
-    
+
     Example:
-    
+
     ... ado.net/XML headers & schema ...
     <resheader name="resmimetype">text/microsoft-resx</resheader>
     <resheader name="version">2.0</resheader>
@@ -26,36 +26,36 @@
         <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
         <comment>This is a comment</comment>
     </data>
-                
-    There are any number of "resheader" rows that contain simple 
+
+    There are any number of "resheader" rows that contain simple
     name/value pairs.
-    
-    Each data row contains a name, and value. The row also contains a 
-    type or mimetype. Type corresponds to a .NET class that support 
-    text/value conversion through the TypeConverter architecture. 
-    Classes that don't support this are serialized and stored with the 
+
+    Each data row contains a name, and value. The row also contains a
+    type or mimetype. Type corresponds to a .NET class that support
+    text/value conversion through the TypeConverter architecture.
+    Classes that don't support this are serialized and stored with the
     mimetype set.
-    
-    The mimetype is used for serialized objects, and tells the 
-    ResXResourceReader how to depersist the object. This is currently not 
+
+    The mimetype is used for serialized objects, and tells the
+    ResXResourceReader how to depersist the object. This is currently not
     extensible. For a given mimetype the value must be set accordingly:
-    
-    Note - application/x-microsoft.net.object.binary.base64 is the format 
-    that the ResXResourceWriter will generate, however the reader can 
+
+    Note - application/x-microsoft.net.object.binary.base64 is the format
+    that the ResXResourceWriter will generate, however the reader can
     read any of the formats listed below.
-    
+
     mimetype: application/x-microsoft.net.object.binary.base64
-    value   : The object must be serialized with 
+    value   : The object must be serialized with
             : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
             : and then encoded with base64 encoding.
     
     mimetype: application/x-microsoft.net.object.soap.base64
-    value   : The object must be serialized with 
+    value   : The object must be serialized with
             : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
             : and then encoded with base64 encoding.
 
     mimetype: application/x-microsoft.net.object.bytearray.base64
-    value   : The object must be serialized into a byte array 
+    value   : The object must be serialized into a byte array
             : using a System.ComponentModel.TypeConverter
             : and then encoded with base64 encoding.
     -->
@@ -117,4 +117,13 @@
   <resheader name="writer">
     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
+  <metadata name="nowTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>17, 17</value>
+  </metadata>
+  <metadata name="uploadTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>286, 24</value>
+  </metadata>
+  <metadata name="receivePLCTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>136, 20</value>
+  </metadata>
 </root>

+ 8 - 10
Program.cs

@@ -1,22 +1,20 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-using System.Windows.Forms;
+using Hik.Api;
 
 namespace xicheji
 {
-    static class Program
+    internal static class Program
     {
         /// <summary>
-        /// 应用程序的主入口点。
+        ///  The main entry point for the application.
         /// </summary>
         [STAThread]
         static void Main()
         {
-            Application.EnableVisualStyles();
-            Application.SetCompatibleTextRenderingDefault(false);
+            // 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());
         }
     }
-}
+}

+ 0 - 36
Properties/AssemblyInfo.cs

@@ -1,36 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// 有关程序集的一般信息由以下
-// 控制。更改这些特性值可修改
-// 与程序集关联的信息。
-[assembly: AssemblyTitle("xicheji")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("xicheji")]
-[assembly: AssemblyCopyright("Copyright ©  2024")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// 将 ComVisible 设置为 false 会使此程序集中的类型
-//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
-//请将此类型的 ComVisible 特性设置为 true。
-[assembly: ComVisible(false)]
-
-// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
-[assembly: Guid("28604952-3afa-451d-891c-091b273fcb7a")]
-
-// 程序集的版本信息由下列四个值组成: 
-//
-//      主版本
-//      次版本
-//      生成号
-//      修订号
-//
-//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
-//通过使用 "*",如下所示:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]

+ 0 - 70
Properties/Resources.Designer.cs

@@ -1,70 +0,0 @@
-//------------------------------------------------------------------------------
-// <auto-generated>
-//     此代码由工具生成。
-//     运行时版本: 4.0.30319.42000
-//
-//     对此文件的更改可能导致不正确的行为,如果
-//     重新生成代码,则所做更改将丢失。
-// </auto-generated>
-//------------------------------------------------------------------------------
-
-
-namespace xicheji.Properties
-{
-    /// <summary>
-    ///   强类型资源类,用于查找本地化字符串等。
-    /// </summary>
-    // 此类是由 StronglyTypedResourceBuilder
-    // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
-    // 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen
-    // (以 /str 作为命令选项),或重新生成 VS 项目。
-    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
-    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
-    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
-    internal class Resources
-    {
-
-        private static global::System.Resources.ResourceManager resourceMan;
-
-        private static global::System.Globalization.CultureInfo resourceCulture;
-
-        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
-        internal Resources()
-        {
-        }
-
-        /// <summary>
-        ///   返回此类使用的缓存 ResourceManager 实例。
-        /// </summary>
-        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
-        internal static global::System.Resources.ResourceManager ResourceManager
-        {
-            get
-            {
-                if ((resourceMan == null))
-                {
-                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("xicheji.Properties.Resources", typeof(Resources).Assembly);
-                    resourceMan = temp;
-                }
-                return resourceMan;
-            }
-        }
-
-        /// <summary>
-        ///   重写当前线程的 CurrentUICulture 属性,对
-        ///   使用此强类型资源类的所有资源查找执行重写。
-        /// </summary>
-        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
-        internal static global::System.Globalization.CultureInfo Culture
-        {
-            get
-            {
-                return resourceCulture;
-            }
-            set
-            {
-                resourceCulture = value;
-            }
-        }
-    }
-}

+ 0 - 29
Properties/Settings.Designer.cs

@@ -1,29 +0,0 @@
-//------------------------------------------------------------------------------
-// <auto-generated>
-//     This code was generated by a tool.
-//     Runtime Version:4.0.30319.42000
-//
-//     Changes to this file may cause incorrect behavior and will be lost if
-//     the code is regenerated.
-// </auto-generated>
-//------------------------------------------------------------------------------
-
-
-namespace xicheji.Properties
-{
-    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
-    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
-    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
-    {
-
-        private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
-
-        public static Settings Default
-        {
-            get
-            {
-                return defaultInstance;
-            }
-        }
-    }
-}

+ 0 - 7
Properties/Settings.settings

@@ -1,7 +0,0 @@
-<?xml version='1.0' encoding='utf-8'?>
-<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
-  <Profiles>
-    <Profile Name="(Default)" />
-  </Profiles>
-  <Settings />
-</SettingsFile>

+ 321 - 4
SettingForm.Designer.cs

@@ -28,12 +28,329 @@
         /// </summary>
         private void InitializeComponent()
         {
-            this.components = new System.ComponentModel.Container();
-            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(800, 450);
-            this.Text = "SettingForm";
+            btnOK = new Button();
+            btnCancel = new Button();
+            groupBox1 = new GroupBox();
+            txtServer = new TextBox();
+            label1 = new Label();
+            groupBox2 = new GroupBox();
+            label6 = new Label();
+            nudInterval = new NumericUpDown();
+            cboPLCType = new ComboBox();
+            label4 = new Label();
+            label5 = new Label();
+            txtPLCPort = new TextBox();
+            label3 = new Label();
+            txtPLCIP = new TextBox();
+            label2 = new Label();
+            groupBox3 = new GroupBox();
+            label7 = new Label();
+            label8 = new Label();
+            txtPassword = new TextBox();
+            txtUserName = new TextBox();
+            txtCameraPort = new TextBox();
+            label10 = new Label();
+            txtCameraIP = new TextBox();
+            label11 = new Label();
+            groupBox1.SuspendLayout();
+            groupBox2.SuspendLayout();
+            ((System.ComponentModel.ISupportInitialize)nudInterval).BeginInit();
+            groupBox3.SuspendLayout();
+            SuspendLayout();
+            // 
+            // btnOK
+            // 
+            btnOK.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
+            btnOK.Location = new Point(276, 486);
+            btnOK.Name = "btnOK";
+            btnOK.Size = new Size(75, 23);
+            btnOK.TabIndex = 0;
+            btnOK.Text = "确定";
+            btnOK.UseVisualStyleBackColor = true;
+            btnOK.Click += btnOK_Click;
+            // 
+            // btnCancel
+            // 
+            btnCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
+            btnCancel.Location = new Point(357, 486);
+            btnCancel.Name = "btnCancel";
+            btnCancel.Size = new Size(75, 23);
+            btnCancel.TabIndex = 1;
+            btnCancel.Text = "取消";
+            btnCancel.UseVisualStyleBackColor = true;
+            btnCancel.Click += btnCancel_Click;
+            // 
+            // groupBox1
+            // 
+            groupBox1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+            groupBox1.Controls.Add(txtServer);
+            groupBox1.Controls.Add(label1);
+            groupBox1.Location = new Point(12, 12);
+            groupBox1.Name = "groupBox1";
+            groupBox1.Size = new Size(420, 64);
+            groupBox1.TabIndex = 2;
+            groupBox1.TabStop = false;
+            groupBox1.Text = "平台";
+            // 
+            // txtServer
+            // 
+            txtServer.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+            txtServer.Location = new Point(90, 22);
+            txtServer.Name = "txtServer";
+            txtServer.Size = new Size(303, 23);
+            txtServer.TabIndex = 1;
+            // 
+            // label1
+            // 
+            label1.AutoSize = true;
+            label1.Location = new Point(25, 25);
+            label1.Name = "label1";
+            label1.Size = new Size(59, 17);
+            label1.TabIndex = 0;
+            label1.Text = "服务地址:";
+            // 
+            // groupBox2
+            // 
+            groupBox2.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+            groupBox2.Controls.Add(label6);
+            groupBox2.Controls.Add(nudInterval);
+            groupBox2.Controls.Add(cboPLCType);
+            groupBox2.Controls.Add(label4);
+            groupBox2.Controls.Add(label5);
+            groupBox2.Controls.Add(txtPLCPort);
+            groupBox2.Controls.Add(label3);
+            groupBox2.Controls.Add(txtPLCIP);
+            groupBox2.Controls.Add(label2);
+            groupBox2.Location = new Point(12, 92);
+            groupBox2.Name = "groupBox2";
+            groupBox2.Size = new Size(420, 182);
+            groupBox2.TabIndex = 2;
+            groupBox2.TabStop = false;
+            groupBox2.Text = "PLC";
+            // 
+            // label6
+            // 
+            label6.AutoSize = true;
+            label6.Location = new Point(131, 148);
+            label6.Name = "label6";
+            label6.Size = new Size(20, 17);
+            label6.TabIndex = 4;
+            label6.Text = "秒";
+            // 
+            // nudInterval
+            // 
+            nudInterval.Location = new Point(90, 145);
+            nudInterval.Maximum = new decimal(new int[] { 10, 0, 0, 0 });
+            nudInterval.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
+            nudInterval.Name = "nudInterval";
+            nudInterval.Size = new Size(40, 23);
+            nudInterval.TabIndex = 3;
+            nudInterval.TextAlign = HorizontalAlignment.Right;
+            nudInterval.Value = new decimal(new int[] { 2, 0, 0, 0 });
+            // 
+            // cboPLCType
+            // 
+            cboPLCType.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+            cboPLCType.FormattingEnabled = true;
+            cboPLCType.Location = new Point(90, 104);
+            cboPLCType.Name = "cboPLCType";
+            cboPLCType.Size = new Size(303, 25);
+            cboPLCType.TabIndex = 2;
+            // 
+            // label4
+            // 
+            label4.AutoSize = true;
+            label4.Location = new Point(25, 107);
+            label4.Name = "label4";
+            label4.Size = new Size(35, 17);
+            label4.TabIndex = 0;
+            label4.Text = "类型:";
+            // 
+            // label5
+            // 
+            label5.AutoSize = true;
+            label5.Location = new Point(25, 148);
+            label5.Name = "label5";
+            label5.Size = new Size(59, 17);
+            label5.TabIndex = 0;
+            label5.Text = "接受频率:";
+            // 
+            // txtPLCPort
+            // 
+            txtPLCPort.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+            txtPLCPort.Location = new Point(90, 63);
+            txtPLCPort.Name = "txtPLCPort";
+            txtPLCPort.Size = new Size(303, 23);
+            txtPLCPort.TabIndex = 1;
+            // 
+            // label3
+            // 
+            label3.AutoSize = true;
+            label3.Location = new Point(25, 66);
+            label3.Name = "label3";
+            label3.Size = new Size(47, 17);
+            label3.TabIndex = 0;
+            label3.Text = "端口号:";
+            // 
+            // txtPLCIP
+            // 
+            txtPLCIP.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+            txtPLCIP.Location = new Point(90, 22);
+            txtPLCIP.Name = "txtPLCIP";
+            txtPLCIP.Size = new Size(303, 23);
+            txtPLCIP.TabIndex = 1;
+            // 
+            // label2
+            // 
+            label2.AutoSize = true;
+            label2.Location = new Point(25, 25);
+            label2.Name = "label2";
+            label2.Size = new Size(22, 17);
+            label2.TabIndex = 0;
+            label2.Text = "IP:";
+            // 
+            // groupBox3
+            // 
+            groupBox3.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+            groupBox3.Controls.Add(label7);
+            groupBox3.Controls.Add(label8);
+            groupBox3.Controls.Add(txtPassword);
+            groupBox3.Controls.Add(txtUserName);
+            groupBox3.Controls.Add(txtCameraPort);
+            groupBox3.Controls.Add(label10);
+            groupBox3.Controls.Add(txtCameraIP);
+            groupBox3.Controls.Add(label11);
+            groupBox3.Location = new Point(12, 291);
+            groupBox3.Name = "groupBox3";
+            groupBox3.Size = new Size(420, 182);
+            groupBox3.TabIndex = 2;
+            groupBox3.TabStop = false;
+            groupBox3.Text = "摄像头";
+            // 
+            // label7
+            // 
+            label7.AutoSize = true;
+            label7.Location = new Point(25, 145);
+            label7.Name = "label7";
+            label7.Size = new Size(35, 17);
+            label7.TabIndex = 0;
+            label7.Text = "密码:";
+            // 
+            // label8
+            // 
+            label8.AutoSize = true;
+            label8.Location = new Point(25, 104);
+            label8.Name = "label8";
+            label8.Size = new Size(47, 17);
+            label8.TabIndex = 0;
+            label8.Text = "用户名:";
+            // 
+            // txtPassword
+            // 
+            txtPassword.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+            txtPassword.Location = new Point(90, 142);
+            txtPassword.Name = "txtPassword";
+            txtPassword.Size = new Size(303, 23);
+            txtPassword.TabIndex = 1;
+            // 
+            // txtUserName
+            // 
+            txtUserName.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+            txtUserName.Location = new Point(90, 102);
+            txtUserName.Name = "txtUserName";
+            txtUserName.Size = new Size(303, 23);
+            txtUserName.TabIndex = 1;
+            // 
+            // txtCameraPort
+            // 
+            txtCameraPort.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+            txtCameraPort.Location = new Point(90, 62);
+            txtCameraPort.Name = "txtCameraPort";
+            txtCameraPort.Size = new Size(303, 23);
+            txtCameraPort.TabIndex = 1;
+            // 
+            // label10
+            // 
+            label10.AutoSize = true;
+            label10.Location = new Point(25, 65);
+            label10.Name = "label10";
+            label10.Size = new Size(47, 17);
+            label10.TabIndex = 0;
+            label10.Text = "端口号:";
+            // 
+            // txtCameraIP
+            // 
+            txtCameraIP.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
+            txtCameraIP.Location = new Point(90, 22);
+            txtCameraIP.Name = "txtCameraIP";
+            txtCameraIP.Size = new Size(303, 23);
+            txtCameraIP.TabIndex = 1;
+            // 
+            // label11
+            // 
+            label11.AutoSize = true;
+            label11.Location = new Point(25, 25);
+            label11.Name = "label11";
+            label11.Size = new Size(22, 17);
+            label11.TabIndex = 0;
+            label11.Text = "IP:";
+            // 
+            // SettingForm
+            // 
+            AutoScaleDimensions = new SizeF(7F, 17F);
+            AutoScaleMode = AutoScaleMode.Font;
+            ClientSize = new Size(444, 521);
+            Controls.Add(groupBox3);
+            Controls.Add(groupBox2);
+            Controls.Add(groupBox1);
+            Controls.Add(btnCancel);
+            Controls.Add(btnOK);
+            FormBorderStyle = FormBorderStyle.FixedSingle;
+            MaximizeBox = false;
+            MinimizeBox = false;
+            MinimumSize = new Size(460, 560);
+            Name = "SettingForm";
+            ShowIcon = false;
+            StartPosition = FormStartPosition.CenterParent;
+            Text = "配置";
+            Load += SettingForm_Load;
+            groupBox1.ResumeLayout(false);
+            groupBox1.PerformLayout();
+            groupBox2.ResumeLayout(false);
+            groupBox2.PerformLayout();
+            ((System.ComponentModel.ISupportInitialize)nudInterval).EndInit();
+            groupBox3.ResumeLayout(false);
+            groupBox3.PerformLayout();
+            ResumeLayout(false);
         }
 
         #endregion
+
+        private Button btnOK;
+        private Button btnCancel;
+        private GroupBox groupBox1;
+        private TextBox txtServer;
+        private Label label1;
+        private GroupBox groupBox2;
+        private TextBox txtPLCIP;
+        private Label label2;
+        private ComboBox cboPLCType;
+        private Label label4;
+        private TextBox txtPLCPort;
+        private Label label3;
+        private Label label6;
+        private NumericUpDown nudInterval;
+        private Label label5;
+        private GroupBox groupBox3;
+        private Label label8;
+        private Label label9;
+        private TextBox txtCameraIP;
+        private Label label10;
+        private TextBox txtCameraPort;
+        private Label label11;
+        private TextBox txtUserName;
+        private Label label7;
+        private TextBox txtPassword;
+        private TextBox textBox3;
     }
 }

+ 59 - 1
SettingForm.cs

@@ -1,4 +1,5 @@
-using System;
+using S7.Net;
+using System;
 using System.Collections.Generic;
 using System.ComponentModel;
 using System.Data;
@@ -16,5 +17,62 @@ namespace xicheji
         {
             InitializeComponent();
         }
+
+        private void SettingForm_Load(object sender, EventArgs e)
+        {
+            try
+            {
+                var names = Enum.GetNames<CpuType>();
+                cboPLCType.Items.Clear();
+                cboPLCType.Items.AddRange(names);
+
+
+                var config = ConfigHelper.GetConfig();
+
+                txtServer.Text = config.Server;
+                txtPLCIP.Text = config.PLCIP;
+                txtPLCPort.Text = config.PLCPort;
+                cboPLCType.SelectedItem = Enum.GetName<CpuType>(config.PLCType);
+                nudInterval.Value = config.PLCReceiveInterval;
+                txtCameraIP.Text = config.CameraIP;
+                txtCameraPort.Text = config.CameraPort;
+                txtUserName.Text = config.CameraUserName;
+                txtPassword.Text = config.CameraPassword;
+            }
+            catch (Exception ex)
+            {
+                MessageBox.Show(ex.Message + ex.StackTrace);
+            }
+        }
+
+        private void btnOK_Click(object sender, EventArgs e)
+        {
+            try
+            {
+                var config = ConfigHelper.GetConfig();
+
+                config.Server = txtServer.Text;
+                config.PLCIP = txtPLCIP.Text;
+                config.PLCPort = txtPLCPort.Text;
+                config.PLCType = Enum.Parse<CpuType>(cboPLCType.Text);
+                config.PLCReceiveInterval = int.Parse(nudInterval.Value.ToString());
+                config.CameraIP = txtCameraIP.Text;
+                config.CameraPort = txtCameraPort.Text;
+                config.CameraUserName = txtUserName.Text;
+                config.CameraPassword = txtPassword.Text;
+
+                ConfigHelper.SaveConfig(config);
+                this.DialogResult = DialogResult.OK;
+            }
+            catch (Exception ex)
+            {
+                MessageBox.Show(ex.Message + ex.StackTrace);
+            }
+        }
+
+        private void btnCancel_Click(object sender, EventArgs e)
+        {
+            this.DialogResult = DialogResult.Cancel;
+        }
     }
 }

+ 33 - 30
Properties/Resources.resx → SettingForm.resx

@@ -1,17 +1,17 @@
 <?xml version="1.0" encoding="utf-8"?>
 <root>
-  <!-- 
+  <!--
     Microsoft ResX Schema 
-    
+
     Version 2.0
-    
-    The primary goals of this format is to allow a simple XML format 
-    that is mostly human readable. The generation and parsing of the 
-    various data types are done through the TypeConverter classes 
+
+    The primary goals of this format is to allow a simple XML format
+    that is mostly human readable. The generation and parsing of the
+    various data types are done through the TypeConverter classes
     associated with the data types.
-    
+
     Example:
-    
+
     ... ado.net/XML headers & schema ...
     <resheader name="resmimetype">text/microsoft-resx</resheader>
     <resheader name="version">2.0</resheader>
@@ -26,40 +26,41 @@
         <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
         <comment>This is a comment</comment>
     </data>
-                
-    There are any number of "resheader" rows that contain simple 
+
+    There are any number of "resheader" rows that contain simple
     name/value pairs.
-    
-    Each data row contains a name, and value. The row also contains a 
-    type or mimetype. Type corresponds to a .NET class that support 
-    text/value conversion through the TypeConverter architecture. 
-    Classes that don't support this are serialized and stored with the 
+
+    Each data row contains a name, and value. The row also contains a
+    type or mimetype. Type corresponds to a .NET class that support
+    text/value conversion through the TypeConverter architecture.
+    Classes that don't support this are serialized and stored with the
     mimetype set.
-    
-    The mimetype is used for serialized objects, and tells the 
-    ResXResourceReader how to depersist the object. This is currently not 
+
+    The mimetype is used for serialized objects, and tells the
+    ResXResourceReader how to depersist the object. This is currently not
     extensible. For a given mimetype the value must be set accordingly:
-    
-    Note - application/x-microsoft.net.object.binary.base64 is the format 
-    that the ResXResourceWriter will generate, however the reader can 
+
+    Note - application/x-microsoft.net.object.binary.base64 is the format
+    that the ResXResourceWriter will generate, however the reader can
     read any of the formats listed below.
-    
+
     mimetype: application/x-microsoft.net.object.binary.base64
-    value   : The object must be serialized with 
-            : System.Serialization.Formatters.Binary.BinaryFormatter
+    value   : The object must be serialized with
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
             : and then encoded with base64 encoding.
     
     mimetype: application/x-microsoft.net.object.soap.base64
-    value   : The object must be serialized with 
+    value   : The object must be serialized with
             : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
             : and then encoded with base64 encoding.
 
     mimetype: application/x-microsoft.net.object.bytearray.base64
-    value   : The object must be serialized into a byte array 
+    value   : The object must be serialized into a byte array
             : using a System.ComponentModel.TypeConverter
             : and then encoded with base64 encoding.
     -->
   <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
     <xsd:element name="root" msdata:IsDataSet="true">
       <xsd:complexType>
         <xsd:choice maxOccurs="unbounded">
@@ -68,9 +69,10 @@
               <xsd:sequence>
                 <xsd:element name="value" type="xsd:string" minOccurs="0" />
               </xsd:sequence>
-              <xsd:attribute name="name" type="xsd:string" />
+              <xsd:attribute name="name" use="required" type="xsd:string" />
               <xsd:attribute name="type" type="xsd:string" />
               <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
             </xsd:complexType>
           </xsd:element>
           <xsd:element name="assembly">
@@ -85,9 +87,10 @@
                 <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
                 <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
               </xsd:sequence>
-              <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
               <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
               <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
             </xsd:complexType>
           </xsd:element>
           <xsd:element name="resheader">
@@ -109,9 +112,9 @@
     <value>2.0</value>
   </resheader>
   <resheader name="reader">
-    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
   <resheader name="writer">
-    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
 </root>

+ 2 - 1
config.xml

@@ -1,8 +1,9 @@
 <?xml version="1.0" encoding="utf-8" ?>
 <Config>
-	<Platform Server="IP+Port+BasePath"  UploadInterval="2"/>
+	<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="" />
+	<Camera IP="127.0.0.1" Port="1502" UserName="user" Password="Wayclouds2024" />
 	<Variables DBName="DB1">
 		<Variable Name="FF" Key="DBX0"/>
 		<Variable Name="数据长度" Key="DBX1"/>

+ 0 - 8
packages.config

@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<packages>
-  <package id="S7netplus" version="0.20.0" targetFramework="net472" />
-  <package id="System.Buffers" version="4.5.1" targetFramework="net472" />
-  <package id="System.Memory" version="4.5.5" targetFramework="net472" />
-  <package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
-  <package id="System.Runtime.CompilerServices.Unsafe" version="4.5.3" targetFramework="net472" />
-</packages>

+ 15 - 91
xicheji.csproj

@@ -1,100 +1,24 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+<Project Sdk="Microsoft.NET.Sdk">
+
   <PropertyGroup>
-    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
-    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProjectGuid>{28604952-3AFA-451D-891C-091B273FCB7A}</ProjectGuid>
     <OutputType>WinExe</OutputType>
-    <RootNamespace>xicheji</RootNamespace>
-    <AssemblyName>xicheji</AssemblyName>
-    <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
-    <FileAlignment>512</FileAlignment>
-    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
-    <Deterministic>true</Deterministic>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <PlatformTarget>AnyCPU</PlatformTarget>
-    <DebugSymbols>true</DebugSymbols>
-    <DebugType>full</DebugType>
-    <Optimize>false</Optimize>
-    <OutputPath>bin\Debug\</OutputPath>
-    <DefineConstants>DEBUG;TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
-    <PlatformTarget>AnyCPU</PlatformTarget>
-    <DebugType>pdbonly</DebugType>
-    <Optimize>true</Optimize>
-    <OutputPath>bin\Release\</OutputPath>
-    <DefineConstants>TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
+    <TargetFramework>net6.0-windows</TargetFramework>
+    <Nullable>enable</Nullable>
+    <UseWindowsForms>true</UseWindowsForms>
+    <ImplicitUsings>enable</ImplicitUsings>
   </PropertyGroup>
+
   <ItemGroup>
-    <Reference Include="S7.Net, Version=0.20.0.0, Culture=neutral, PublicKeyToken=d5812d469e84c693, processorArchitecture=MSIL">
-      <HintPath>packages\S7netplus.0.20.0\lib\net462\S7.Net.dll</HintPath>
-    </Reference>
-    <Reference Include="System" />
-    <Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
-      <HintPath>packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
-    </Reference>
-    <Reference Include="System.Core" />
-    <Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
-      <HintPath>packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
-    </Reference>
-    <Reference Include="System.Numerics" />
-    <Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
-      <HintPath>packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
-    </Reference>
-    <Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
-      <HintPath>packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
-    </Reference>
-    <Reference Include="System.Xml.Linq" />
-    <Reference Include="System.Data.DataSetExtensions" />
-    <Reference Include="Microsoft.CSharp" />
-    <Reference Include="System.Data" />
-    <Reference Include="System.Deployment" />
-    <Reference Include="System.Drawing" />
-    <Reference Include="System.Net.Http" />
-    <Reference Include="System.Windows.Forms" />
-    <Reference Include="System.Xml" />
+    <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="S7netplus" Version="0.20.0" />
   </ItemGroup>
+
   <ItemGroup>
-    <Compile Include="Form1.cs">
-      <SubType>Form</SubType>
-    </Compile>
-    <Compile Include="Form1.Designer.cs">
-      <DependentUpon>Form1.cs</DependentUpon>
-    </Compile>
-    <Compile Include="Program.cs" />
-    <Compile Include="Properties\AssemblyInfo.cs" />
-    <EmbeddedResource Include="Form1.resx">
-      <DependentUpon>Form1.cs</DependentUpon>
-    </EmbeddedResource>
-    <EmbeddedResource Include="Properties\Resources.resx">
-      <Generator>ResXFileCodeGenerator</Generator>
-      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
-      <SubType>Designer</SubType>
-    </EmbeddedResource>
-    <Compile Include="Properties\Resources.Designer.cs">
-      <AutoGen>True</AutoGen>
-      <DependentUpon>Resources.resx</DependentUpon>
-    </Compile>
-    <None Include="packages.config" />
-    <None Include="Properties\Settings.settings">
-      <Generator>SettingsSingleFileGenerator</Generator>
-      <LastGenOutput>Settings.Designer.cs</LastGenOutput>
+    <None Update="config.xml">
+      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>
-    <Compile Include="Properties\Settings.Designer.cs">
-      <AutoGen>True</AutoGen>
-      <DependentUpon>Settings.settings</DependentUpon>
-      <DesignTimeSharedInput>True</DesignTimeSharedInput>
-    </Compile>
-  </ItemGroup>
-  <ItemGroup>
-    <None Include="App.config" />
   </ItemGroup>
-  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+
 </Project>

+ 11 - 0
xicheji.csproj.user

@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <Compile Update="MainForm.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Update="SettingForm.cs">
+      <SubType>Form</SubType>
+    </Compile>
+  </ItemGroup>
+</Project>

+ 8 - 8
xicheji.sln

@@ -1,9 +1,9 @@
 
 Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 16
-VisualStudioVersion = 16.0.31129.286
+# Visual Studio Version 17
+VisualStudioVersion = 17.8.34316.72
 MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "xicheji", "xicheji.csproj", "{28604952-3AFA-451D-891C-091B273FCB7A}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "xicheji", "xicheji.csproj", "{6BAB5EB5-68FC-4C50-A36A-9BBD96FCD7FF}"
 EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -11,15 +11,15 @@ Global
 		Release|Any CPU = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(ProjectConfigurationPlatforms) = postSolution
-		{28604952-3AFA-451D-891C-091B273FCB7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{28604952-3AFA-451D-891C-091B273FCB7A}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{28604952-3AFA-451D-891C-091B273FCB7A}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{28604952-3AFA-451D-891C-091B273FCB7A}.Release|Any CPU.Build.0 = Release|Any CPU
+		{6BAB5EB5-68FC-4C50-A36A-9BBD96FCD7FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{6BAB5EB5-68FC-4C50-A36A-9BBD96FCD7FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{6BAB5EB5-68FC-4C50-A36A-9BBD96FCD7FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{6BAB5EB5-68FC-4C50-A36A-9BBD96FCD7FF}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
 	EndGlobalSection
 	GlobalSection(ExtensibilityGlobals) = postSolution
-		SolutionGuid = {08ED9C41-0F7A-4689-8719-F5DA51931BA7}
+		SolutionGuid = {5445C384-2C76-46BC-A3C0-A8BD34E4A2AA}
 	EndGlobalSection
 EndGlobal