Browse Source

提交配置文件

weijw 5 months ago
parent
commit
ebbc5a9a97
7 changed files with 159 additions and 4 deletions
  1. 1 1
      MainForm.Designer.cs
  2. 22 2
      MainForm.cs
  3. 0 0
      MainForm.resx
  4. 1 1
      Program.cs
  5. 39 0
      SettingForm.Designer.cs
  6. 20 0
      SettingForm.cs
  7. 76 0
      config.xml

+ 1 - 1
Form1.Designer.cs → MainForm.Designer.cs

@@ -1,7 +1,7 @@
 
 namespace xicheji
 {
-    partial class Form1
+    partial class MainForm
     {
         /// <summary>
         /// 必需的设计器变量。

+ 22 - 2
Form1.cs → MainForm.cs

@@ -1,4 +1,5 @@
 using S7.Net;
+using S7.Net.Types;
 using System;
 using System.Collections.Generic;
 using System.ComponentModel;
@@ -11,11 +12,11 @@ using System.Windows.Forms;
 
 namespace xicheji
 {
-    public partial class Form1 : Form
+    public partial class MainForm : Form
     {
         private Plc plc;
 
-        public Form1()
+        public MainForm()
         {
             InitializeComponent();
         }
@@ -50,21 +51,40 @@ namespace xicheji
             //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
+
             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)
             {

+ 0 - 0
Form1.resx → MainForm.resx


+ 1 - 1
Program.cs

@@ -16,7 +16,7 @@ namespace xicheji
         {
             Application.EnableVisualStyles();
             Application.SetCompatibleTextRenderingDefault(false);
-            Application.Run(new Form1());
+            Application.Run(new MainForm());
         }
     }
 }

+ 39 - 0
SettingForm.Designer.cs

@@ -0,0 +1,39 @@
+namespace xicheji
+{
+    partial class SettingForm
+    {
+        /// <summary>
+        /// Required designer variable.
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary>
+        /// Clean up any resources being used.
+        /// </summary>
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #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.components = new System.ComponentModel.Container();
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.ClientSize = new System.Drawing.Size(800, 450);
+            this.Text = "SettingForm";
+        }
+
+        #endregion
+    }
+}

+ 20 - 0
SettingForm.cs

@@ -0,0 +1,20 @@
+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 System.Windows.Forms;
+
+namespace xicheji
+{
+    public partial class SettingForm : Form
+    {
+        public SettingForm()
+        {
+            InitializeComponent();
+        }
+    }
+}

+ 76 - 0
config.xml

@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<Config>
+	<Platform Server="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="" />
+	<Variables DBName="DB1">
+		<Variable Name="FF" Key="DBX0"/>
+		<Variable Name="数据长度" Key="DBX1"/>
+		<Variable Name="MAC1" Key="DBX2"/>
+		<Variable Name="MAC2" Key="DBX3"/>
+		<Variable Name="MAC3" Key="DBX4"/>
+		<Variable Name="MAC4" Key="DBX5"/>
+		<Variable Name="MAC5" Key="DBX6"/>
+		<Variable Name="MAC6" Key="DBX7"/>
+		<Variable Name="急停" Key="DBX10.0"/>
+		<Variable Name="冲洗泵故障" Key="DBX10.1"/>
+		<Variable Name="反洗泵故障" Key="DBX10.2"/>
+		<Variable Name="清淤泵故障" Key="DBX10.3"/>
+		<Variable Name="伴热故障" Key="DBX10.4"/>
+		<Variable Name="风刀故障" Key="DBX10.5"/>
+		<Variable Name="进车信号" Key="DBX12.0"/>
+		<Variable Name="防砸信号" Key="DBX12.1"/>
+		<Variable Name="1#冲洗泵" Key="DBX13.0"/>
+		<Variable Name="反洗泵" Key="DBX13.1"/>
+		<Variable Name="清淤泵" Key="DBX13.2"/>
+		<Variable Name="伴热" Key="DBX13.3"/>
+		<Variable Name="照明" Key="DBX13.4"/>
+		<Variable Name="抬杆" Key="DBX13.5"/>
+		<Variable Name="落杆" Key="DBX13.6"/>
+		<Variable Name="前红灯" Key="DBX14.0"/>
+		<Variable Name="前绿灯" Key="DBX14.1"/>
+		<Variable Name="后红灯" Key="DBX14.2"/>
+		<Variable Name="后绿灯" Key="DBX14.3"/>
+		<Variable Name="1#风刀" Key="DBX14.4"/>
+		<Variable Name="洗车中" Key="DBX15.0"/>
+		<Variable Name="清洗中" Key="DBX15.1"/>
+		<Variable Name="沥水中" Key="DBX15.2"/>
+		<Variable Name="出车中" Key="DBX15.3"/>
+		<Variable Name="风干中" Key="DBX15.4"/>
+		<Variable Name="手动" Key="DBX16.0"/>
+		<Variable Name="自动" Key="DBX16.1"/>
+		<Variable Name="洗车次数" Key="DBD20" Desc="次"/>
+		<Variable Name="累计用水量" Key="DBD24" Desc="t"/>
+		<Variable Name="累计用电量" Key="DBD28" Desc="kW·h"/>
+		<Variable Name="当前流量" Key="DBW32" Desc="m³/H*0.01"/>
+		<Variable Name="当前功率" Key="DBW34" Desc="kW*0.01"/>
+		<Variable Name="当前压力" Key="DBW36" Desc="MPa*0.01"/>
+		<Variable Name="IA" Key="DBW38" Desc="A*0.01"/>
+		<Variable Name="IB" Key="DBW40" Desc="A*0.01"/>
+		<Variable Name="IC" Key="DBW42" Desc="A*0.01"/>
+		<Variable Name="PF" Key="DBW44" Desc="0.001"/>
+		<Variable Name="当前月" Key="DBW46" Desc="月"/>
+		<Variable Name="当前日" Key="DBW48" Desc="日"/>
+		<Variable Name="当前时" Key="DBW50" Desc="时"/>
+		<Variable Name="当前分" Key="DBW52" Desc="分"/>
+		<Variable Name="当前秒" Key="DBW54" Desc="秒"/>
+		<Variable Name="车牌识别失败数" Key="DBD56"/>
+		<Variable Name="最后一次洗车开始月" Key="DBW60" Desc="月"/>
+		<Variable Name="最后一次洗车开始日" Key="DBW62" Desc="日"/>
+		<Variable Name="最后一次洗车开始时" Key="DBW64" Desc="时"/>
+		<Variable Name="最后一次洗车开始分" Key="DBW66" Desc="分"/>
+		<Variable Name="最后一次洗车开始秒" Key="DBW68" Desc="秒"/>
+		<Variable Name="最后一次洗车结束月" Key="DBW70" Desc="月"/>
+		<Variable Name="最后一次洗车结束日" Key="DBW72" Desc="日"/>
+		<Variable Name="最后一次洗车结束时" Key="DBW74" Desc="时"/>
+		<Variable Name="最后一次洗车结束分" Key="DBW76" Desc="分"/>
+		<Variable Name="最后一次洗车结束秒" Key="DBW78" Desc="秒"/>
+		<Variable Name="最后一次洗车总时长" Key="DBW80" Desc="S"/>
+		<Variable Name="最后一次洗车冲洗时长" Key="DBW82" Desc="S"/>
+		<Variable Name="最后一次洗车风干时长" Key="DBW84" Desc="S"/>
+		<Variable Name="最后一次洗车用水" Key="DBW86" Desc="t*0.01"/>
+		<Variable Name="最后一次洗车用电" Key="DBW88" Desc="kW·h*0.01"/>
+		<Variable Name="最后一次洗车水压" Key="DBW90" Desc="MPa*0.01"/>
+		<Variable Name="CRC" Key="DBW98" Desc="校验"/>
+	</Variables>
+</Config>