Jelajahi Sumber

广告下载功能加入

yc_t 6 tahun lalu
induk
melakukan
82cf6b66fd
21 mengubah file dengan 1236 tambahan dan 53 penghapusan
  1. 8 5
      PLCLinker/centralController/App.config
  2. 40 31
      PLCLinker/centralController/FormCentralController.Designer.cs
  3. 11 0
      PLCLinker/centralController/FormCentralController.cs
  4. 15 3
      PLCLinker/centralController/FormCentralController.resx
  5. 451 0
      PLCLinker/centralController/FormPLCConf.Designer.cs
  6. 417 0
      PLCLinker/centralController/FormPLCConf.cs
  7. 120 0
      PLCLinker/centralController/FormPLCConf.resx
  8. 7 3
      PLCLinker/centralController/Monitor/Monitor.cs
  9. 29 6
      PLCLinker/centralController/Monitor/SystemInitializer.cs
  10. 119 0
      PLCLinker/centralController/advert/AdvertManager.cs
  11. TEMPAT SAMPAH
      PLCLinker/centralController/bin/Release/centralController.exe
  12. 7 4
      PLCLinker/centralController/bin/Release/centralController.exe.config
  13. TEMPAT SAMPAH
      PLCLinker/centralController/bin/Release/centralController.pdb
  14. 10 0
      PLCLinker/centralController/centralController.csproj
  15. 1 1
      PLCLinker/centralController/obj/Release/centralController.csproj.CoreCompileInputs.cache
  16. 1 0
      PLCLinker/centralController/obj/Release/centralController.csproj.FileListAbsolute.txt
  17. TEMPAT SAMPAH
      PLCLinker/centralController/obj/Release/centralController.csproj.GenerateResource.Cache
  18. TEMPAT SAMPAH
      PLCLinker/centralController/obj/Release/centralController.csprojResolveAssemblyReference.cache
  19. TEMPAT SAMPAH
      PLCLinker/centralController/obj/Release/centralController.exe
  20. TEMPAT SAMPAH
      PLCLinker/centralController/obj/Release/centralController.pdb
  21. TEMPAT SAMPAH
      PLCLinker/centralController/sdk/broadcast/broadcastDLL.dll

+ 8 - 5
PLCLinker/centralController/App.config

@@ -7,25 +7,26 @@
     <add key="retryCount" value="3"/>
     <!--数据库信息-->
     <!--<add key="remoteDBConnStr" value="Data Source=59.175.148.85;port=3306;uid=root;pooling=true;max pool size=1024;pwd=x5;database=zxpark;CharSet=utf8;Allow Zero Datetime=true;"/>-->
-    <add key="remoteDBConnStr" value="Data Source=192.168.111.61;port=3306;uid=remote;pooling=true;max pool size=1024;pwd=x5;database=zxpark_cloud_2;CharSet=utf8;Allow Zero Datetime=true;"/>
+    <!--<add key="remoteDBConnStr" value="Data Source=192.168.111.61;port=3306;uid=remote;pooling=true;max pool size=1024;pwd=x5;database=zxpark_cloud_2;CharSet=utf8;Allow Zero Datetime=true;"/>-->
+    <add key="remoteDBConnStr" value="Data Source=127.0.0.1;port=20000;uid=root;pooling=true;max pool size=1024;pwd=yct;database=zxpark_cloud_2;CharSet=utf8;Allow Zero Datetime=true;"/>
     <add key="localDBConnStr" value="Data Source=127.0.0.1;port=20000;uid=root;pooling=true;max pool size=1024;pwd=yct;database=zxpark_local;CharSet=utf8;Allow Zero Datetime=true;"/>
     <add key="DBtimeout" value="3"/>
     <!--号牌机信息-->
-    <add key="192.168.0.20" value="2"/>
+    <add key="192.168.10.62" value="2"/>
     <add key="192.168.0.21" value="1"/>
     <add key="filterRatio" value="0.7"/>
     <!--PLC基本配置-->
     <!--<add key="PLC_ip_address" value="192.168.0.10" />-->
-    <add key="plcIpAddress" value="192.168.0.141" />
+    <add key="plcIpAddress" value="192.168.10.60" />
     <add key="plcRack" value="0" />
     <add key="plcSlot" value="1" />
-    <!--分别对终端、中控、车位-->
+    <!--PLCdb块,分别对终端、中控、车位-->
     <add key="plcDatablockId" value="18,41,20" />
     <add key="plcTerminalCount" value="1" />
     <add key="plcParkingSpaceCount" value="200" />
     <add key="plcRefreshInterval" value="200"/>
     <!--显示屏信息-->
-    <add key="allInOneMachineIP" value="192.168.0.60"/>
+    <add key="allInOneMachineIP" value="192.168.10.99"/>
     <add key="allInOneMachinePort" value="8888"/>
     <!--中控webServer端口-->
     <add key="webPort" value="9000"/>
@@ -33,5 +34,7 @@
     <add key="garageID" value="1"/>
     <!--日志写入地址配置文件-->
     <add key="LogAddress" value="c:\\c#workspace\\LogDemo\\LoggerTest" />
+    <!--广告存放路径-->
+    <add key ="advertPath" value ="c:\\c#workspace\\LogDemo\\advert"/>
   </appSettings>
 </configuration>

+ 40 - 31
PLCLinker/centralController/FormCentralController.Designer.cs

@@ -29,14 +29,13 @@
         private void InitializeComponent()
         {
             this.components = new System.ComponentModel.Container();
-            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
+            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
             this.dotNetBarManager1 = new DevComponents.DotNetBar.DotNetBarManager(this.components);
             this.dockSite4 = new DevComponents.DotNetBar.DockSite();
             this.dockSite9 = new DevComponents.DotNetBar.DockSite();
             this.bar_mainWin = new DevComponents.DotNetBar.Bar();
             this.NumMachineMonitorPanel = new DevComponents.DotNetBar.PanelDockContainer();
             this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
-            this.ParkingSpaceMonitorPanel = new DevComponents.DotNetBar.PanelDockContainer();
             this.paymentPanel = new DevComponents.DotNetBar.PanelDockContainer();
             this.testPanel = new DevComponents.DotNetBar.PanelDockContainer();
             this.button1 = new System.Windows.Forms.Button();
@@ -45,6 +44,7 @@
             this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
             this.pictureBox1 = new System.Windows.Forms.PictureBox();
             this.labelX1 = new DevComponents.DotNetBar.LabelX();
+            this.ParkingSpaceMonitorPanel = new DevComponents.DotNetBar.PanelDockContainer();
             this.dci_ParkingSpace = new DevComponents.DotNetBar.DockContainerItem();
             this.dci_NumMachine = new DevComponents.DotNetBar.DockContainerItem();
             this.dci_payment = new DevComponents.DotNetBar.DockContainerItem();
@@ -90,6 +90,7 @@
             this.btn_openFile = new DevComponents.DotNetBar.ButtonItem();
             this.btn_refreshRecords = new DevComponents.DotNetBar.ButtonItem();
             this.btn_exportRecords = new DevComponents.DotNetBar.ButtonItem();
+            this.btn_setScheme = new DevComponents.DotNetBar.ButtonItem();
             this.btn_views = new DevComponents.DotNetBar.ButtonItem();
             this.btn_parkingSpace = new DevComponents.DotNetBar.ButtonItem();
             this.btn_numMachine = new DevComponents.DotNetBar.ButtonItem();
@@ -107,7 +108,7 @@
             this.panelDockContainer7 = new DevComponents.DotNetBar.PanelDockContainer();
             this.dockContainerItem1 = new DevComponents.DotNetBar.DockContainerItem();
             this.panelDockContainer8 = new DevComponents.DotNetBar.PanelDockContainer();
-            this.btn_setScheme = new DevComponents.DotNetBar.ButtonItem();
+            this.btn_PLCConf = new DevComponents.DotNetBar.ButtonItem();
             this.dockSite9.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.bar_mainWin)).BeginInit();
             this.bar_mainWin.SuspendLayout();
@@ -201,9 +202,9 @@
             this.bar_mainWin.CanHide = true;
             this.bar_mainWin.CanUndock = false;
             this.bar_mainWin.Controls.Add(this.NumMachineMonitorPanel);
+            this.bar_mainWin.Controls.Add(this.ParkingSpaceMonitorPanel);
             this.bar_mainWin.Controls.Add(this.paymentPanel);
             this.bar_mainWin.Controls.Add(this.testPanel);
-            this.bar_mainWin.Controls.Add(this.ParkingSpaceMonitorPanel);
             this.bar_mainWin.DockTabAlignment = DevComponents.DotNetBar.eTabStripAlignment.Top;
             this.bar_mainWin.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.bar_mainWin.IsMaximized = false;
@@ -248,19 +249,6 @@
             this.flowLayoutPanel1.TabIndex = 1;
             this.flowLayoutPanel1.Resize += new System.EventHandler(this.flowLayoutPanel1_Resize);
             // 
-            // ParkingSpaceMonitorPanel
-            // 
-            this.ParkingSpaceMonitorPanel.DisabledBackColor = System.Drawing.Color.Empty;
-            this.ParkingSpaceMonitorPanel.Location = new System.Drawing.Point(3, 28);
-            this.ParkingSpaceMonitorPanel.Name = "ParkingSpaceMonitorPanel";
-            this.ParkingSpaceMonitorPanel.Size = new System.Drawing.Size(659, 377);
-            this.ParkingSpaceMonitorPanel.Style.Alignment = System.Drawing.StringAlignment.Center;
-            this.ParkingSpaceMonitorPanel.Style.BackColor1.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.BarBackground;
-            this.ParkingSpaceMonitorPanel.Style.BorderColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.BarDockedBorder;
-            this.ParkingSpaceMonitorPanel.Style.ForeColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.ItemText;
-            this.ParkingSpaceMonitorPanel.Style.GradientAngle = 90;
-            this.ParkingSpaceMonitorPanel.TabIndex = 9;
-            // 
             // paymentPanel
             // 
             this.paymentPanel.DisabledBackColor = System.Drawing.Color.Empty;
@@ -351,6 +339,19 @@
             this.labelX1.Text = "label1\r\nlable2";
             this.labelX1.TextAlignment = System.Drawing.StringAlignment.Center;
             // 
+            // ParkingSpaceMonitorPanel
+            // 
+            this.ParkingSpaceMonitorPanel.DisabledBackColor = System.Drawing.Color.Empty;
+            this.ParkingSpaceMonitorPanel.Location = new System.Drawing.Point(3, 28);
+            this.ParkingSpaceMonitorPanel.Name = "ParkingSpaceMonitorPanel";
+            this.ParkingSpaceMonitorPanel.Size = new System.Drawing.Size(659, 377);
+            this.ParkingSpaceMonitorPanel.Style.Alignment = System.Drawing.StringAlignment.Center;
+            this.ParkingSpaceMonitorPanel.Style.BackColor1.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.BarBackground;
+            this.ParkingSpaceMonitorPanel.Style.BorderColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.BarDockedBorder;
+            this.ParkingSpaceMonitorPanel.Style.ForeColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.ItemText;
+            this.ParkingSpaceMonitorPanel.Style.GradientAngle = 90;
+            this.ParkingSpaceMonitorPanel.TabIndex = 9;
+            // 
             // dci_ParkingSpace
             // 
             this.dci_ParkingSpace.Control = this.ParkingSpaceMonitorPanel;
@@ -430,14 +431,14 @@
             this.realGetTime,
             this.receiptNum,
             this.parkingPrice});
-            dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
-            dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Window;
-            dataGridViewCellStyle1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.ControlText;
-            dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
-            dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.ControlText;
-            dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
-            this.dataGridViewX1.DefaultCellStyle = dataGridViewCellStyle1;
+            dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
+            dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Window;
+            dataGridViewCellStyle2.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.ControlText;
+            dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight;
+            dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.ControlText;
+            dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
+            this.dataGridViewX1.DefaultCellStyle = dataGridViewCellStyle2;
             this.dataGridViewX1.Dock = System.Windows.Forms.DockStyle.Fill;
             this.dataGridViewX1.GridColor = System.Drawing.Color.FromArgb(((int)(((byte)(208)))), ((int)(((byte)(215)))), ((int)(((byte)(229)))));
             this.dataGridViewX1.Location = new System.Drawing.Point(0, 0);
@@ -882,6 +883,12 @@
             this.btn_exportRecords.Text = "导出最近记录";
             this.btn_exportRecords.Click += new System.EventHandler(this.btn_exportRecords_Click);
             // 
+            // btn_setScheme
+            // 
+            this.btn_setScheme.Name = "btn_setScheme";
+            this.btn_setScheme.Text = "收费策略";
+            this.btn_setScheme.Click += new System.EventHandler(this.btn_setScheme_Click);
+            // 
             // btn_views
             // 
             this.btn_views.Name = "btn_views";
@@ -934,8 +941,9 @@
             // 
             this.btn_devices.Name = "btn_devices";
             this.btn_devices.SubItems.AddRange(new DevComponents.DotNetBar.BaseItem[] {
-            this.btn_linkPLC});
-            this.btn_devices.Text = "设备";
+            this.btn_linkPLC,
+            this.btn_PLCConf});
+            this.btn_devices.Text = "工具";
             // 
             // btn_linkPLC
             // 
@@ -1048,11 +1056,11 @@
             this.panelDockContainer8.Style.GradientAngle = 90;
             this.panelDockContainer8.TabIndex = 37;
             // 
-            // btn_setScheme
+            // btn_PLCConf
             // 
-            this.btn_setScheme.Name = "btn_setScheme";
-            this.btn_setScheme.Text = "收费策略";
-            this.btn_setScheme.Click += new System.EventHandler(this.btn_setScheme_Click);
+            this.btn_PLCConf.Name = "btn_PLCConf";
+            this.btn_PLCConf.Text = "PLC数据调试";
+            this.btn_PLCConf.Click += new System.EventHandler(this.btn_PLCConf_Click);
             // 
             // centralController
             // 
@@ -1183,6 +1191,7 @@
         private DevComponents.DotNetBar.ButtonItem btn_terminals;
         private DevComponents.DotNetBar.ButtonItem btn_records;
         private DevComponents.DotNetBar.ButtonItem btn_setScheme;
+        private DevComponents.DotNetBar.ButtonItem btn_PLCConf;
     }
 }
 

+ 11 - 0
PLCLinker/centralController/FormCentralController.cs

@@ -1,4 +1,5 @@
 using DevComponents.DotNetBar.Controls;
+using PLCConnector;
 using System;
 using System.Collections.Generic;
 using System.IO;
@@ -234,6 +235,16 @@ namespace centralController
                 Monitor.Monitor.PLC.PLCConnect();
             }
         }
+        /// <summary>
+        /// PLC数据调试工具
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void btn_PLCConf_Click(object sender, EventArgs e)
+        {
+            FormPLCConf formPLCConf = new FormPLCConf();
+            formPLCConf.ShowDialog();
+        }
         #endregion
 
         /// <summary>

+ 15 - 3
PLCLinker/centralController/FormCentralController.resx

@@ -123,6 +123,21 @@
   <metadata name="bar_mainWin.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
+  <metadata name="bar_side.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>58</value>
+  </metadata>
+  <metadata name="bar_basicInfo.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="bar_notification.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="bar_mainWin.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
   <metadata name="parkingRecordsID.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
@@ -150,9 +165,6 @@
   <metadata name="bar_side.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
-  <metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>58</value>
-  </metadata>
   <metadata name="bar_basicInfo.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>

+ 451 - 0
PLCLinker/centralController/FormPLCConf.Designer.cs

@@ -0,0 +1,451 @@
+namespace PLCConnector
+{
+    partial class FormPLCConf
+    {
+        /// <summary>
+        /// 必需的设计器变量。
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary>
+        /// 清理所有正在使用的资源。
+        /// </summary>
+        /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #region Windows 窗体设计器生成的代码
+
+        /// <summary>
+        /// 设计器支持所需的方法 - 不要修改
+        /// 使用代码编辑器修改此方法的内容。
+        /// </summary>
+        private void InitializeComponent()
+        {
+            this.label1 = new System.Windows.Forms.Label();
+            this.label2 = new System.Windows.Forms.Label();
+            this.textBox2 = new System.Windows.Forms.TextBox();
+            this.groupBox1 = new System.Windows.Forms.GroupBox();
+            this.textBox4 = new System.Windows.Forms.TextBox();
+            this.button1 = new System.Windows.Forms.Button();
+            this.label3 = new System.Windows.Forms.Label();
+            this.textBox3 = new System.Windows.Forms.TextBox();
+            this.groupBox2 = new System.Windows.Forms.GroupBox();
+            this.textBox5 = new System.Windows.Forms.TextBox();
+            this.button2 = new System.Windows.Forms.Button();
+            this.textBox1 = new System.Windows.Forms.TextBox();
+            this.label4 = new System.Windows.Forms.Label();
+            this.groupBox3 = new System.Windows.Forms.GroupBox();
+            this.textBox6 = new System.Windows.Forms.TextBox();
+            this.button3 = new System.Windows.Forms.Button();
+            this.textBox7 = new System.Windows.Forms.TextBox();
+            this.label5 = new System.Windows.Forms.Label();
+            this.groupBox4 = new System.Windows.Forms.GroupBox();
+            this.textBox8 = new System.Windows.Forms.TextBox();
+            this.button4 = new System.Windows.Forms.Button();
+            this.textBox9 = new System.Windows.Forms.TextBox();
+            this.label6 = new System.Windows.Forms.Label();
+            this.btn_clear = new System.Windows.Forms.Button();
+            this.button6 = new System.Windows.Forms.Button();
+            this.button5 = new System.Windows.Forms.Button();
+            this.button7 = new System.Windows.Forms.Button();
+            this.button8 = new System.Windows.Forms.Button();
+            this.button9 = new System.Windows.Forms.Button();
+            this.button10 = new System.Windows.Forms.Button();
+            this.button11 = new System.Windows.Forms.Button();
+            this.btn_PLCLink = new System.Windows.Forms.Button();
+            this.groupBox1.SuspendLayout();
+            this.groupBox2.SuspendLayout();
+            this.groupBox3.SuspendLayout();
+            this.groupBox4.SuspendLayout();
+            this.SuspendLayout();
+            // 
+            // label1
+            // 
+            this.label1.AutoSize = true;
+            this.label1.Location = new System.Drawing.Point(6, 25);
+            this.label1.Name = "label1";
+            this.label1.Size = new System.Drawing.Size(41, 12);
+            this.label1.TabIndex = 1;
+            this.label1.Text = "数据块";
+            // 
+            // label2
+            // 
+            this.label2.AutoSize = true;
+            this.label2.Location = new System.Drawing.Point(6, 88);
+            this.label2.Name = "label2";
+            this.label2.Size = new System.Drawing.Size(41, 12);
+            this.label2.TabIndex = 3;
+            this.label2.Text = "偏移量";
+            // 
+            // textBox2
+            // 
+            this.textBox2.Location = new System.Drawing.Point(6, 103);
+            this.textBox2.Name = "textBox2";
+            this.textBox2.Size = new System.Drawing.Size(121, 21);
+            this.textBox2.TabIndex = 2;
+            this.textBox2.Text = "2";
+            // 
+            // groupBox1
+            // 
+            this.groupBox1.Controls.Add(this.textBox4);
+            this.groupBox1.Controls.Add(this.button1);
+            this.groupBox1.Controls.Add(this.label3);
+            this.groupBox1.Controls.Add(this.label2);
+            this.groupBox1.Controls.Add(this.textBox3);
+            this.groupBox1.Controls.Add(this.label1);
+            this.groupBox1.Controls.Add(this.textBox2);
+            this.groupBox1.Location = new System.Drawing.Point(12, 12);
+            this.groupBox1.Name = "groupBox1";
+            this.groupBox1.Size = new System.Drawing.Size(155, 250);
+            this.groupBox1.TabIndex = 4;
+            this.groupBox1.TabStop = false;
+            this.groupBox1.Text = "写入";
+            // 
+            // textBox4
+            // 
+            this.textBox4.Location = new System.Drawing.Point(8, 40);
+            this.textBox4.Name = "textBox4";
+            this.textBox4.Size = new System.Drawing.Size(121, 21);
+            this.textBox4.TabIndex = 7;
+            this.textBox4.Text = "中控";
+            // 
+            // button1
+            // 
+            this.button1.Location = new System.Drawing.Point(23, 209);
+            this.button1.Name = "button1";
+            this.button1.Size = new System.Drawing.Size(75, 23);
+            this.button1.TabIndex = 6;
+            this.button1.Text = "写入";
+            this.button1.UseVisualStyleBackColor = true;
+            this.button1.Click += new System.EventHandler(this.button1_Click);
+            // 
+            // label3
+            // 
+            this.label3.AutoSize = true;
+            this.label3.Location = new System.Drawing.Point(6, 158);
+            this.label3.Name = "label3";
+            this.label3.Size = new System.Drawing.Size(17, 12);
+            this.label3.TabIndex = 5;
+            this.label3.Text = "值";
+            // 
+            // textBox3
+            // 
+            this.textBox3.Location = new System.Drawing.Point(6, 173);
+            this.textBox3.Name = "textBox3";
+            this.textBox3.Size = new System.Drawing.Size(121, 21);
+            this.textBox3.TabIndex = 3;
+            this.textBox3.Text = "0";
+            // 
+            // groupBox2
+            // 
+            this.groupBox2.Controls.Add(this.textBox5);
+            this.groupBox2.Controls.Add(this.button2);
+            this.groupBox2.Controls.Add(this.textBox1);
+            this.groupBox2.Controls.Add(this.label4);
+            this.groupBox2.Location = new System.Drawing.Point(199, 12);
+            this.groupBox2.Name = "groupBox2";
+            this.groupBox2.Size = new System.Drawing.Size(171, 418);
+            this.groupBox2.TabIndex = 5;
+            this.groupBox2.TabStop = false;
+            this.groupBox2.Text = "读取";
+            // 
+            // textBox5
+            // 
+            this.textBox5.Location = new System.Drawing.Point(18, 40);
+            this.textBox5.Name = "textBox5";
+            this.textBox5.Size = new System.Drawing.Size(121, 21);
+            this.textBox5.TabIndex = 8;
+            this.textBox5.Text = "中控";
+            // 
+            // button2
+            // 
+            this.button2.Location = new System.Drawing.Point(46, 389);
+            this.button2.Name = "button2";
+            this.button2.Size = new System.Drawing.Size(75, 23);
+            this.button2.TabIndex = 7;
+            this.button2.Text = "读取";
+            this.button2.UseVisualStyleBackColor = true;
+            this.button2.Click += new System.EventHandler(this.button2_Click);
+            // 
+            // textBox1
+            // 
+            this.textBox1.Location = new System.Drawing.Point(18, 78);
+            this.textBox1.Multiline = true;
+            this.textBox1.Name = "textBox1";
+            this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
+            this.textBox1.Size = new System.Drawing.Size(133, 305);
+            this.textBox1.TabIndex = 8;
+            // 
+            // label4
+            // 
+            this.label4.AutoSize = true;
+            this.label4.Location = new System.Drawing.Point(18, 25);
+            this.label4.Name = "label4";
+            this.label4.Size = new System.Drawing.Size(41, 12);
+            this.label4.TabIndex = 6;
+            this.label4.Text = "数据块";
+            // 
+            // groupBox3
+            // 
+            this.groupBox3.Controls.Add(this.textBox6);
+            this.groupBox3.Controls.Add(this.button3);
+            this.groupBox3.Controls.Add(this.textBox7);
+            this.groupBox3.Controls.Add(this.label5);
+            this.groupBox3.Location = new System.Drawing.Point(397, 12);
+            this.groupBox3.Name = "groupBox3";
+            this.groupBox3.Size = new System.Drawing.Size(171, 418);
+            this.groupBox3.TabIndex = 6;
+            this.groupBox3.TabStop = false;
+            this.groupBox3.Text = "读取";
+            // 
+            // textBox6
+            // 
+            this.textBox6.Location = new System.Drawing.Point(18, 40);
+            this.textBox6.Name = "textBox6";
+            this.textBox6.Size = new System.Drawing.Size(121, 21);
+            this.textBox6.TabIndex = 8;
+            this.textBox6.Text = "终端1";
+            // 
+            // button3
+            // 
+            this.button3.Location = new System.Drawing.Point(46, 389);
+            this.button3.Name = "button3";
+            this.button3.Size = new System.Drawing.Size(75, 23);
+            this.button3.TabIndex = 7;
+            this.button3.Text = "读取";
+            this.button3.UseVisualStyleBackColor = true;
+            this.button3.Click += new System.EventHandler(this.button3_Click);
+            // 
+            // textBox7
+            // 
+            this.textBox7.Location = new System.Drawing.Point(18, 78);
+            this.textBox7.Multiline = true;
+            this.textBox7.Name = "textBox7";
+            this.textBox7.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
+            this.textBox7.Size = new System.Drawing.Size(133, 305);
+            this.textBox7.TabIndex = 8;
+            // 
+            // label5
+            // 
+            this.label5.AutoSize = true;
+            this.label5.Location = new System.Drawing.Point(18, 25);
+            this.label5.Name = "label5";
+            this.label5.Size = new System.Drawing.Size(41, 12);
+            this.label5.TabIndex = 6;
+            this.label5.Text = "数据块";
+            // 
+            // groupBox4
+            // 
+            this.groupBox4.Controls.Add(this.textBox8);
+            this.groupBox4.Controls.Add(this.button4);
+            this.groupBox4.Controls.Add(this.textBox9);
+            this.groupBox4.Controls.Add(this.label6);
+            this.groupBox4.Location = new System.Drawing.Point(587, 12);
+            this.groupBox4.Name = "groupBox4";
+            this.groupBox4.Size = new System.Drawing.Size(171, 418);
+            this.groupBox4.TabIndex = 9;
+            this.groupBox4.TabStop = false;
+            this.groupBox4.Text = "读取";
+            // 
+            // textBox8
+            // 
+            this.textBox8.Location = new System.Drawing.Point(18, 40);
+            this.textBox8.Name = "textBox8";
+            this.textBox8.Size = new System.Drawing.Size(121, 21);
+            this.textBox8.TabIndex = 8;
+            this.textBox8.Text = "车位1";
+            // 
+            // button4
+            // 
+            this.button4.Location = new System.Drawing.Point(46, 389);
+            this.button4.Name = "button4";
+            this.button4.Size = new System.Drawing.Size(75, 23);
+            this.button4.TabIndex = 7;
+            this.button4.Text = "读取";
+            this.button4.UseVisualStyleBackColor = true;
+            this.button4.Click += new System.EventHandler(this.button4_Click);
+            // 
+            // textBox9
+            // 
+            this.textBox9.Location = new System.Drawing.Point(18, 78);
+            this.textBox9.Multiline = true;
+            this.textBox9.Name = "textBox9";
+            this.textBox9.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
+            this.textBox9.Size = new System.Drawing.Size(133, 305);
+            this.textBox9.TabIndex = 8;
+            // 
+            // label6
+            // 
+            this.label6.AutoSize = true;
+            this.label6.Location = new System.Drawing.Point(18, 25);
+            this.label6.Name = "label6";
+            this.label6.Size = new System.Drawing.Size(41, 12);
+            this.label6.TabIndex = 6;
+            this.label6.Text = "数据块";
+            // 
+            // btn_clear
+            // 
+            this.btn_clear.Location = new System.Drawing.Point(443, 459);
+            this.btn_clear.Name = "btn_clear";
+            this.btn_clear.Size = new System.Drawing.Size(75, 23);
+            this.btn_clear.TabIndex = 10;
+            this.btn_clear.Text = "终端1清零";
+            this.btn_clear.UseVisualStyleBackColor = true;
+            this.btn_clear.Click += new System.EventHandler(this.btn_clear_Click);
+            // 
+            // button6
+            // 
+            this.button6.Location = new System.Drawing.Point(35, 268);
+            this.button6.Name = "button6";
+            this.button6.Size = new System.Drawing.Size(75, 23);
+            this.button6.TabIndex = 11;
+            this.button6.Text = "自动刷新";
+            this.button6.UseVisualStyleBackColor = true;
+            this.button6.Click += new System.EventHandler(this.btn_refresh_Click);
+            // 
+            // button5
+            // 
+            this.button5.Location = new System.Drawing.Point(622, 433);
+            this.button5.Name = "button5";
+            this.button5.Size = new System.Drawing.Size(93, 23);
+            this.button5.TabIndex = 12;
+            this.button5.Text = "凭证写入车位";
+            this.button5.UseVisualStyleBackColor = true;
+            this.button5.Click += new System.EventHandler(this.button5_Click);
+            // 
+            // button7
+            // 
+            this.button7.Location = new System.Drawing.Point(443, 430);
+            this.button7.Name = "button7";
+            this.button7.Size = new System.Drawing.Size(75, 23);
+            this.button7.TabIndex = 13;
+            this.button7.Text = "启动地感";
+            this.button7.UseVisualStyleBackColor = true;
+            this.button7.Click += new System.EventHandler(this.button7_Click);
+            // 
+            // button8
+            // 
+            this.button8.Location = new System.Drawing.Point(245, 430);
+            this.button8.Name = "button8";
+            this.button8.Size = new System.Drawing.Size(75, 23);
+            this.button8.TabIndex = 14;
+            this.button8.Text = "启动号牌机";
+            this.button8.UseVisualStyleBackColor = true;
+            this.button8.Click += new System.EventHandler(this.button8_Click);
+            // 
+            // button9
+            // 
+            this.button9.Location = new System.Drawing.Point(245, 459);
+            this.button9.Name = "button9";
+            this.button9.Size = new System.Drawing.Size(75, 23);
+            this.button9.TabIndex = 15;
+            this.button9.Text = "停车完成";
+            this.button9.UseVisualStyleBackColor = true;
+            this.button9.Click += new System.EventHandler(this.button9_Click);
+            // 
+            // button10
+            // 
+            this.button10.Location = new System.Drawing.Point(12, 297);
+            this.button10.Name = "button10";
+            this.button10.Size = new System.Drawing.Size(120, 23);
+            this.button10.TabIndex = 16;
+            this.button10.Text = "切换中控停取模式";
+            this.button10.UseVisualStyleBackColor = true;
+            this.button10.Click += new System.EventHandler(this.button10_Click);
+            // 
+            // button11
+            // 
+            this.button11.Location = new System.Drawing.Point(12, 326);
+            this.button11.Name = "button11";
+            this.button11.Size = new System.Drawing.Size(120, 23);
+            this.button11.TabIndex = 17;
+            this.button11.Text = "切换终端1停取模式";
+            this.button11.UseVisualStyleBackColor = true;
+            this.button11.Click += new System.EventHandler(this.button11_Click);
+            // 
+            // btn_PLCLink
+            // 
+            this.btn_PLCLink.Location = new System.Drawing.Point(20, 391);
+            this.btn_PLCLink.Name = "btn_PLCLink";
+            this.btn_PLCLink.Size = new System.Drawing.Size(104, 91);
+            this.btn_PLCLink.TabIndex = 18;
+            this.btn_PLCLink.Text = "连接PLC";
+            this.btn_PLCLink.UseVisualStyleBackColor = true;
+            this.btn_PLCLink.Click += new System.EventHandler(this.btn_PLCLink_Click);
+            // 
+            // FormPLCConf
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.ClientSize = new System.Drawing.Size(803, 527);
+            this.Controls.Add(this.btn_PLCLink);
+            this.Controls.Add(this.button11);
+            this.Controls.Add(this.button10);
+            this.Controls.Add(this.button9);
+            this.Controls.Add(this.button8);
+            this.Controls.Add(this.button7);
+            this.Controls.Add(this.button5);
+            this.Controls.Add(this.button6);
+            this.Controls.Add(this.btn_clear);
+            this.Controls.Add(this.groupBox4);
+            this.Controls.Add(this.groupBox3);
+            this.Controls.Add(this.groupBox2);
+            this.Controls.Add(this.groupBox1);
+            this.Name = "FormPLCConf";
+            this.Text = "Form1";
+            this.groupBox1.ResumeLayout(false);
+            this.groupBox1.PerformLayout();
+            this.groupBox2.ResumeLayout(false);
+            this.groupBox2.PerformLayout();
+            this.groupBox3.ResumeLayout(false);
+            this.groupBox3.PerformLayout();
+            this.groupBox4.ResumeLayout(false);
+            this.groupBox4.PerformLayout();
+            this.ResumeLayout(false);
+
+        }
+
+        #endregion
+
+        private System.Windows.Forms.Label label1;
+        private System.Windows.Forms.Label label2;
+        private System.Windows.Forms.TextBox textBox2;
+        private System.Windows.Forms.GroupBox groupBox1;
+        private System.Windows.Forms.Button button1;
+        private System.Windows.Forms.Label label3;
+        private System.Windows.Forms.TextBox textBox3;
+        private System.Windows.Forms.GroupBox groupBox2;
+        private System.Windows.Forms.TextBox textBox1;
+        private System.Windows.Forms.Label label4;
+        private System.Windows.Forms.Button button2;
+        private System.Windows.Forms.TextBox textBox4;
+        private System.Windows.Forms.TextBox textBox5;
+        private System.Windows.Forms.GroupBox groupBox3;
+        private System.Windows.Forms.TextBox textBox6;
+        private System.Windows.Forms.Button button3;
+        private System.Windows.Forms.TextBox textBox7;
+        private System.Windows.Forms.Label label5;
+        private System.Windows.Forms.GroupBox groupBox4;
+        private System.Windows.Forms.TextBox textBox8;
+        private System.Windows.Forms.Button button4;
+        private System.Windows.Forms.TextBox textBox9;
+        private System.Windows.Forms.Label label6;
+        private System.Windows.Forms.Button btn_clear;
+        private System.Windows.Forms.Button button6;
+        private System.Windows.Forms.Button button5;
+        private System.Windows.Forms.Button button7;
+        private System.Windows.Forms.Button button8;
+        private System.Windows.Forms.Button button9;
+        private System.Windows.Forms.Button button10;
+        private System.Windows.Forms.Button button11;
+        private System.Windows.Forms.Button btn_PLCLink;
+    }
+}
+

+ 417 - 0
PLCLinker/centralController/FormPLCConf.cs

@@ -0,0 +1,417 @@
+using PLCS7;
+using S7.Net;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Configuration;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace PLCConnector
+{
+    public partial class FormPLCConf : Form
+    {
+        PLCLinker pl;
+        public FormPLCConf()
+        {
+            InitializeComponent();
+            string ip = "";
+            short rack = 0;
+            short slot = 0;
+            string[] blockIds = new string[3];
+            try
+            {
+                ip = ConfigurationManager.AppSettings.Get("plcIpAddress");
+                rack = Int16.Parse(ConfigurationManager.AppSettings.Get("plcRack"));
+                slot = Int16.Parse(ConfigurationManager.AppSettings.Get("plcSlot"));
+                blockIds = (ConfigurationManager.AppSettings.Get("plcDatablockId")).Split(',');
+                pl = new PLCLinker(CpuType.S71500, ip, rack, slot, int.Parse(blockIds[0]), int.Parse(blockIds[1]), int.Parse(blockIds[2]), 6, 200);
+            }
+            catch (Exception e) { MessageBox.Show("配置文件异常"); }
+        }
+
+        public static void parkingSpaceDBTest(AbstractPLCLinker pl, Random rnd)
+        {
+            if (!pl.isConnected) { pl.PLCConnect(); }
+            else
+            {
+                //读车位表信息
+                List<object> psList = pl.ReadFromPLC(PLCDataType.parkingSpace, 1);
+                psList.AddRange(pl.ReadFromPLC(PLCDataType.parkingSpace, 2));
+                foreach (var ps in psList)
+                {
+                    Console.WriteLine(((ParkingSpaceStru)ps).ToString());
+                }
+                //写入车位状态信息
+                ParkingSpaceStru pss = new ParkingSpaceStru
+                {
+                    parkingSpace = (short)rnd.Next(1, 3),
+                    spaceStatus = (short)rnd.Next(0, 3)
+                };
+                pl.WriteToPLC(pss, PLCDataType.central);
+                Console.WriteLine("写入状态值");
+            }
+        }
+
+        public static void terminalDBTest(AbstractPLCLinker pl, Random rnd)
+        {
+            if (!pl.isConnected) { pl.PLCConnect(); }
+            else
+            {
+                //读终端块数据
+                List<object> tList = pl.ReadFromPLC(PLCDataType.terminal, 1);
+                foreach (var term in tList)
+                {
+                    Console.WriteLine(((TerminalStru)term).ToString());
+                }
+                //模拟中控写数据
+                TerminalStru tsCentral = new TerminalStru
+                {
+                    terminalID = 1,
+                    paymentStatus = (short)rnd.Next(100, 999),
+                    licVerification = -1,
+                    parkingFee = (short)rnd.Next(100, 999),
+                    userType = (short)rnd.Next(100, 999)
+                };
+                //模拟终端写数据
+                TerminalStru tsTerminal = new TerminalStru
+                {
+                    terminalID = 1,
+                    terminalStatus = (short)rnd.Next(100, 999),
+                    btnStatus = (short)rnd.Next(100, 999),
+                    licenseCodeA = (short)rnd.Next(100, 999),
+                    licenseCodeB = -1,
+                    licenseCodeC = (short)rnd.Next(100, 999),
+                    receiptNum = (short)rnd.Next(100, 999)
+                };
+                //pl.WriteToPLC(tsCentral, PLCDataType.central);
+                pl.WriteToPLC(tsTerminal, PLCDataType.terminal);
+            }
+        }
+
+        private void button1_Click(object sender, EventArgs e)
+        {
+            PLCDataType type = PLCDataType.parkingSpace;
+            int offset = 0;
+            int value = 0;
+            try
+            {
+                offset = Int32.Parse(textBox2.Text);
+                value = Int32.Parse(textBox3.Text);
+            }
+            catch { MessageBox.Show("异常"); return; }
+            switch (textBox4.Text)
+            {
+                case "中控":
+                    type = PLCDataType.central;
+                    break;
+                case "终端1":
+                    type = PLCDataType.terminal;
+                    break;
+                case "终端2":
+                    type = PLCDataType.terminal;
+                    offset += 42;
+                    break;
+                case "终端3":
+                    type = PLCDataType.terminal;
+                    offset += 42*2;
+                    break;
+                case "车位1":
+                    type = PLCDataType.parkingSpace;
+                    break;
+            }
+            if (value < 32768)
+            {
+                pl.WriteAccordingToOffset(type, offset, (short)value);
+            }
+            else
+            {
+                pl.WriteAccordingToOffset(type, offset, value);
+            }
+        }
+
+        private void button2_Click(object sender, EventArgs e)
+        {
+            PLCDataType type = PLCDataType.parkingSpace;
+            int id = -1;
+            switch ((string)textBox5.Text)
+            {
+                case "中控":
+                    type = PLCDataType.central;id = 0;
+                    break;
+                case "终端1":
+                    type = PLCDataType.terminal; id = 1;
+                    break;
+                case "终端2":
+                    type = PLCDataType.terminal; id = 2;
+                    break;
+                case "终端3":
+                    type = PLCDataType.terminal; id = 3;
+                    break;
+                case "车位1":
+                    type = PLCDataType.parkingSpace; id = 4;
+                    break;
+            }
+            string result = "";
+            try
+            {
+                if (id == 4)
+                {
+                    List<object> list = pl.ReadFromPLC(type, 1);
+                    result = ((ParkingSpaceStru)list[0]).ToString();
+                }
+                else if (id > 0)
+                {
+                    List<object> list = pl.ReadFromPLC(type, id);
+                    result = ((TerminalStru)list[0]).ToString();
+                }
+                else if (id == 0)
+                {
+                    List<object> list = pl.ReadFromPLC(type, id);
+                    result = ((MainBlockStru)list[0]).ToString();
+                }
+            }
+            catch { Console.WriteLine("异常"); return; }
+            textBox1.Text = result.Replace(",","\r\n");
+        }
+
+        private void button3_Click(object sender, EventArgs e)
+        {
+            PLCDataType type = PLCDataType.parkingSpace;
+            int id = -1;
+            switch ((string)textBox6.Text)
+            {
+                case "中控":
+                    type = PLCDataType.central; id = 0;
+                    break;
+                case "终端1":
+                    type = PLCDataType.terminal; id = 1;
+                    break;
+                case "终端2":
+                    type = PLCDataType.terminal; id = 2;
+                    break;
+                case "终端3":
+                    type = PLCDataType.terminal; id = 3;
+                    break;
+                case "车位1":
+                    type = PLCDataType.parkingSpace; id = 4;
+                    break;
+            }
+            string result = "";
+            try
+            {
+                if (id == 4)
+                {
+                    List<object> list = pl.ReadFromPLC(type, 1);
+                    result = ((ParkingSpaceStru)list[0]).ToString();
+                }
+                else if (id > 0)
+                {
+                    List<object> list = pl.ReadFromPLC(type, id);
+                    result = ((TerminalStru)list[0]).ToString();
+                }
+                else if (id == 0)
+                {
+                    List<object> list = pl.ReadFromPLC(type, id);
+                    result = ((MainBlockStru)list[0]).ToString();
+                }
+            }
+            catch { Console.WriteLine("异常"); return; }
+            textBox7.Text = result.Replace(",", "\r\n");
+        }
+
+        private void button4_Click(object sender, EventArgs e)
+        {
+            PLCDataType type = PLCDataType.parkingSpace;
+            int id = -1;
+            switch ((string)textBox8.Text)
+            {
+                case "中控":
+                    type = PLCDataType.central; id = 0;
+                    break;
+                case "终端1":
+                    type = PLCDataType.terminal; id = 1;
+                    break;
+                case "终端2":
+                    type = PLCDataType.terminal; id = 2;
+                    break;
+                case "终端3":
+                    type = PLCDataType.terminal; id = 3;
+                    break;
+                case "车位1":
+                    type = PLCDataType.parkingSpace; id = 4;
+                    break;
+            }
+            string result = "";
+            try
+            {
+                if (id == 4)
+                {
+                    List<object> list = pl.ReadFromPLC(type, 1);
+                    result = ((ParkingSpaceStru)list[0]).ToString();
+                }
+                else if (id > 0)
+                {
+                    List<object> list = pl.ReadFromPLC(type, id);
+                    result = ((TerminalStru)list[0]).ToString();
+                }
+                else if (id == 0)
+                {
+                    List<object> list = pl.ReadFromPLC(type, id);
+                    result = ((MainBlockStru)list[0]).ToString();
+                }
+            }
+            catch { Console.WriteLine("异常"); return; }
+            textBox9.Text = result.Replace(",", "\r\n");
+        }
+
+        private void btn_refresh_Click(object sender, EventArgs e)
+        {
+            Timer timer1 = new Timer();
+            timer1.Interval = 1000;
+            timer1.Tick += new EventHandler(button2_Click);
+            timer1.Start();
+            Timer timer2 = new Timer();
+            timer2.Interval = 1000;
+            timer2.Tick += new EventHandler(button3_Click);
+            timer2.Start();
+            Timer timer3 = new Timer();
+            timer3.Interval = 1000;
+            timer3.Tick += new EventHandler(button4_Click);
+            timer3.Start();
+        }
+
+        private void btn_clear_Click(object sender, EventArgs e)
+        {
+            TerminalStru tsFromCentral = new TerminalStru
+            {
+                terminalID = 1,
+                parkingFee = (short)32767,
+                paymentStatus = (short)0,
+                licVerification =(short)0,
+                userType = (short)0,
+            };
+            TerminalStru tsFromTerminal = new TerminalStru
+            {
+                terminalID = 1,
+                btnStatus = -1,
+                cmd = (short)0,
+                receiptNum = (short)0,
+            };
+            pl.WriteToPLC(tsFromCentral, PLCDataType.central);
+            pl.WriteToPLC(tsFromTerminal, PLCDataType.terminal);
+        }
+        /// <summary>
+        /// 凭证号写入车位
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void button5_Click(object sender, EventArgs e)
+        {
+            List<object> list = pl.ReadFromPLC(PLCDataType.terminal, 1);
+            int receipt = ((TerminalStru)list[0]).receiptNum;
+            pl.WriteAccordingToOffset(PLCDataType.parkingSpace, 14, receipt);
+        }
+        /// <summary>
+        /// 启动地感
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void button7_Click(object sender, EventArgs e)
+        {
+            List<object> list = pl.ReadFromPLC(PLCDataType.terminal, 1);
+            short ground = ((TerminalStru)list[0]).groundStatus;
+            if (ground == (short)1)
+            {
+                pl.WriteAccordingToOffset(PLCDataType.terminal, 36, (short)0);
+            }
+            else
+            {
+                pl.WriteAccordingToOffset(PLCDataType.terminal, 36, (short)1);
+            }
+        }
+        /// <summary>
+        /// 启动号牌机
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void button8_Click(object sender, EventArgs e)
+        {
+            pl.WriteAccordingToOffset(PLCDataType.central, 2, (short)1);
+        }
+        /// <summary>
+        /// 清空中控db
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void button9_Click(object sender, EventArgs e)
+        {
+            List<object> list = pl.ReadFromPLC(PLCDataType.central, 0);
+            short complete = ((MainBlockStru)list[0]).processCompleted;
+            if (complete == (short)0)
+            {
+                pl.WriteAccordingToOffset(PLCDataType.central, 2, (short)0);
+                pl.WriteAccordingToOffset(PLCDataType.central, 16, (short)1);
+                pl.WriteAccordingToOffset(PLCDataType.central, 52, (short)0);
+                
+            }
+            else
+            {
+                pl.WriteAccordingToOffset(PLCDataType.central, 2, (short)0);
+                pl.WriteAccordingToOffset(PLCDataType.central, 16, (short)0);
+                pl.WriteAccordingToOffset(PLCDataType.central, 52, (short)0);
+                
+            }
+        }
+        /// <summary>
+        /// 切换中控停取模式
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void button10_Click(object sender, EventArgs e)
+        {
+            List<object> list = pl.ReadFromPLC(PLCDataType.central, 0);
+            short park = ((MainBlockStru)list[0]).parkingRunning;
+            if(park == (short)0)
+            {
+                pl.WriteAccordingToOffset(PLCDataType.central, 12, (short)1);
+                pl.WriteAccordingToOffset(PLCDataType.central, 14, (short)0);
+            }
+            else
+            {
+                pl.WriteAccordingToOffset(PLCDataType.central, 12, (short)0);
+                pl.WriteAccordingToOffset(PLCDataType.central, 14, (short)1);
+            }
+        }
+        /// <summary>
+        /// 切换终端停取模式
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void button11_Click(object sender, EventArgs e)
+        {
+            List<object> list = pl.ReadFromPLC(PLCDataType.terminal, 1);
+            short termStatus = ((TerminalStru)list[0]).terminalStatus;
+            if (termStatus == (short)1)
+            {
+                pl.WriteAccordingToOffset(PLCDataType.terminal, 2, (short)2);
+            }
+            else
+            {
+                pl.WriteAccordingToOffset(PLCDataType.terminal, 2, (short)1);
+            }
+        }
+
+        private void btn_PLCLink_Click(object sender, EventArgs e)
+        {
+            if (!Monitor.Monitor.PLC.isConnected)
+            {
+                Monitor.Monitor.PLC.PLCConnect();
+            }
+        }
+    }
+}

+ 120 - 0
PLCLinker/centralController/FormPLCConf.resx

@@ -0,0 +1,120 @@
+<?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 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <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 
+    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 
+    mimetype set.
+    
+    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 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    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 
+            : 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 
+            : 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">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <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">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <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" 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">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>

+ 7 - 3
PLCLinker/centralController/Monitor/Monitor.cs

@@ -1,4 +1,5 @@
 using BroadcastModule;
+using centralController.advert;
 using db;
 using Monitor;
 using MySql.Data.MySqlClient;
@@ -71,6 +72,11 @@ namespace Monitor
         public static IWebServer webServer;
         public static int webPort { get; set; }
         /// <summary>
+        /// 广告路径
+        /// </summary>
+        public static string advertPath { get; set; }
+        public static AdvertManager advertMgr;
+        /// <summary>
         /// 系统初始化器句柄
         /// </summary>
         internal static SystemInitializer sysInitializer;
@@ -86,7 +92,7 @@ namespace Monitor
         /// 将显示在界面的提示字符串
         /// </summary>
         private static Queue<string> notificationQueue = new Queue<string>();
-        private const int MAXLINES = 10;
+        private const int MAXLINES = 50;
 
         private void PLCUpdate()
         {
@@ -264,8 +270,6 @@ namespace Monitor
             return ((double)capacity / gb).ToString("0.0") + "GB";
         }
 
-
-
         //************************************ 公有方法 **********************************
         public Monitor(IntPtr flpHandle)
         {

+ 29 - 6
PLCLinker/centralController/Monitor/SystemInitializer.cs

@@ -5,6 +5,7 @@ using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 using BroadcastModule;
+using centralController.advert;
 using db;
 using MySql.Data.MySqlClient;
 using NumMachine;
@@ -53,8 +54,10 @@ namespace Monitor
                 Monitor.allInOneMachinePort = Convert.ToInt32(ConfigurationManager.AppSettings.Get("allInOneMachinePort"));
                 //webServer端口
                 Monitor.webPort = Convert.ToInt32(ConfigurationManager.AppSettings.Get("webPort"));
-
+                //车库ID
                 Monitor.garageID = Convert.ToInt32(ConfigurationManager.AppSettings.Get("garageID"));
+                //广告路径
+                Monitor.advertPath = ConfigurationManager.AppSettings.Get("advertPath");
                 //配置文件读取结束,进入状态1
                 Monitor.initializeState = 1;
                 initStatus = true;
@@ -62,10 +65,10 @@ namespace Monitor
             catch (Exception e) { Console.WriteLine("初始化," + e.Message); return; }
 
             Monitor.AddNotification("初始化PLC连接...");
-            //initStatus = initStatus && PLCInit(retryCount);
-            ////PLC初始化结束,进入状态2
-            //if (!initStatus) { return; }
-            //else { Monitor.initializeState = 2; }
+            initStatus = initStatus && PLCInit(retryCount);
+            //PLC初始化结束,进入状态2
+            if (!initStatus) { return; }
+            else { Monitor.initializeState = 2; }
 
             //初始化数据库对象
             Monitor.AddNotification("初始化数据库...");
@@ -128,7 +131,9 @@ namespace Monitor
             //Monitor.allInOneMachine.Play(2, BroadcastBoard.PlayMode.download, "date");
             //Monitor.allInOneMachine.Play(3, BroadcastBoard.PlayMode.download, "time");
             //Monitor.allInOneMachine.Refresh();
-
+            //初始化广告实例
+            Monitor.advertMgr = new AdvertManager();
+            initStatus = initStatus && AdvertMgrInit(3);
             //Monitor.AddNotification("test");
             Terminal.Terminal.Start();
             //系统初始化结束,进入状态5
@@ -192,6 +197,24 @@ namespace Monitor
             return false;
         }
         /// <summary>
+        /// 初始化更新广告
+        /// </summary>
+        /// <param name="retryCount"></param>
+        /// <returns></returns>
+        internal bool AdvertMgrInit(int retryCount)
+        {
+            int temp = retryCount;
+            while (temp-- > 0)
+            {
+                if (Monitor.advertMgr != null)
+                {
+                    if (Monitor.advertMgr.UpdateAdvert())
+                        return true;
+                }
+            }
+            return false;
+        }
+        /// <summary>
         /// 系统关闭
         /// </summary>
         internal void Stop()

+ 119 - 0
PLCLinker/centralController/advert/AdvertManager.cs

@@ -0,0 +1,119 @@
+using MySql.Data.MySqlClient;
+using parkMonitor.LOG;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace centralController.advert
+{
+    public class AdvertManager
+    {
+        /// <summary>
+        /// 从数据库获取URL,更新本地广告文件
+        /// </summary>
+        /// <returns></returns>
+        public bool UpdateAdvert()
+        {
+            bool result = true;
+            List<string> urls = new List<string>();
+            if (Monitor.Monitor.remoteDBOper != null)
+            {
+                //获取URLs
+                string getAdvertUrlSql = "select advertUrl from advert;";
+                MySqlDataReader reader = Monitor.Monitor.remoteDBOper.Query(getAdvertUrlSql);
+                if (reader != null)
+                {
+                    try
+                    {
+                        while (reader.Read() && reader.HasRows)
+                        {
+                            urls.Add(reader.GetString("advertUrl"));
+                        }
+                    }
+                    catch { result = false; }
+                    try
+                    {
+                        reader.Close();
+                        reader.Dispose();
+                    }
+                    catch { result = false; }
+                }
+                //删除本地文件,下载url中文件到本地
+                try
+                {
+                    if (!Directory.Exists(Monitor.Monitor.advertPath))
+                    {
+                        Directory.CreateDirectory(Monitor.Monitor.advertPath);
+                    }
+                    string[] fileList = Directory.GetFiles(Monitor.Monitor.advertPath);
+                    for (int i = 0; i < fileList.Length; i++)
+                    {
+                        File.Delete(fileList[i]);
+                    }
+                    if (Directory.Exists(Monitor.Monitor.advertPath + @"\temp"))
+                        Directory.Delete(Monitor.Monitor.advertPath + @"\temp");
+                }
+                catch { Log.WriteLog(LogType.process, LogFile.ERROR, "本地文件删除异常"); result = false; }
+                if (urls.Count() > 0)
+                {
+                    List<string>.Enumerator enumer = urls.GetEnumerator();
+                    while (enumer.MoveNext())
+                    {
+                        string fileName = Path.GetFileName(enumer.Current);
+                        result = result && HttpDownload(enumer.Current, Monitor.Monitor.advertPath + @"\" + fileName);
+                    }
+                }
+            }
+            return result;
+        }
+        /// <summary>
+        /// http下载文件
+        /// </summary>
+        /// <param name="url">下载文件地址</param>
+        /// <param name="path">文件存放地址,包含文件名</param>
+        /// <returns></returns>
+        private bool HttpDownload(string url, string path)
+        {
+            string tempPath = System.IO.Path.GetDirectoryName(path) + @"\temp";
+            System.IO.Directory.CreateDirectory(tempPath);  //创建临时文件目录
+            string tempFile = tempPath + @"\" + System.IO.Path.GetFileName(path) + ".temp"; //临时文件
+            if (System.IO.File.Exists(tempFile))
+            {
+                System.IO.File.Delete(tempFile);    //存在则删除
+            }
+            try
+            {
+                FileStream fs = new FileStream(tempFile, FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
+                // 设置参数
+                HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
+                //发送请求并获取相应回应数据
+                HttpWebResponse response = request.GetResponse() as HttpWebResponse;
+                //直到request.GetResponse()程序才开始向目标网页发送Post请求
+                Stream responseStream = response.GetResponseStream();
+                //创建本地文件写入流
+                //Stream stream = new FileStream(tempFile, FileMode.Create);
+                byte[] bArr = new byte[1024];
+                int size = responseStream.Read(bArr, 0, (int)bArr.Length);
+                while (size > 0)
+                {
+                    //stream.Write(bArr, 0, size);
+                    fs.Write(bArr, 0, size);
+                    size = responseStream.Read(bArr, 0, (int)bArr.Length);
+                }
+                //stream.Close();
+                fs.Close();
+                responseStream.Close();
+                System.IO.File.Move(tempFile, path);
+                return true;
+            }
+            catch (Exception ex)
+            {
+                return false;
+            }
+        }
+    }
+}

TEMPAT SAMPAH
PLCLinker/centralController/bin/Release/centralController.exe


+ 7 - 4
PLCLinker/centralController/bin/Release/centralController.exe.config

@@ -7,16 +7,17 @@
     <add key="retryCount" value="3"/>
     <!--数据库信息-->
     <!--<add key="remoteDBConnStr" value="Data Source=59.175.148.85;port=3306;uid=root;pooling=true;max pool size=1024;pwd=x5;database=zxpark;CharSet=utf8;Allow Zero Datetime=true;"/>-->
-    <add key="remoteDBConnStr" value="Data Source=192.168.111.61;port=3306;uid=remote;pooling=true;max pool size=1024;pwd=x5;database=zxpark_cloud_2;CharSet=utf8;Allow Zero Datetime=true;"/>
+    <!--<add key="remoteDBConnStr" value="Data Source=192.168.111.61;port=3306;uid=remote;pooling=true;max pool size=1024;pwd=x5;database=zxpark_cloud_2;CharSet=utf8;Allow Zero Datetime=true;"/>-->
+    <add key="remoteDBConnStr" value="Data Source=127.0.0.1;port=20000;uid=root;pooling=true;max pool size=1024;pwd=yct;database=zxpark_cloud_2;CharSet=utf8;Allow Zero Datetime=true;"/>
     <add key="localDBConnStr" value="Data Source=127.0.0.1;port=20000;uid=root;pooling=true;max pool size=1024;pwd=yct;database=zxpark_local;CharSet=utf8;Allow Zero Datetime=true;"/>
     <add key="DBtimeout" value="3"/>
     <!--号牌机信息-->
-    <add key="192.168.0.20" value="2"/>
+    <add key="192.168.10.62" value="2"/>
     <add key="192.168.0.21" value="1"/>
     <add key="filterRatio" value="0.7"/>
     <!--PLC基本配置-->
     <!--<add key="PLC_ip_address" value="192.168.0.10" />-->
-    <add key="plcIpAddress" value="192.168.0.141" />
+    <add key="plcIpAddress" value="192.168.10.60" />
     <add key="plcRack" value="0" />
     <add key="plcSlot" value="1" />
     <!--分别对终端、中控、车位-->
@@ -25,7 +26,7 @@
     <add key="plcParkingSpaceCount" value="200" />
     <add key="plcRefreshInterval" value="200"/>
     <!--显示屏信息-->
-    <add key="allInOneMachineIP" value="192.168.0.60"/>
+    <add key="allInOneMachineIP" value="192.168.10.99"/>
     <add key="allInOneMachinePort" value="8888"/>
     <!--中控webServer端口-->
     <add key="webPort" value="9000"/>
@@ -33,5 +34,7 @@
     <add key="garageID" value="1"/>
     <!--日志写入地址配置文件-->
     <add key="LogAddress" value="c:\\c#workspace\\LogDemo\\LoggerTest" />
+    <!--广告存放路径-->
+    <add key ="advertPath" value ="c:\\c#workspace\\LogDemo\\advert"/>
   </appSettings>
 </configuration>

TEMPAT SAMPAH
PLCLinker/centralController/bin/Release/centralController.pdb


+ 10 - 0
PLCLinker/centralController/centralController.csproj

@@ -89,6 +89,7 @@
     <Reference Include="System.Xml" />
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="advert\AdvertManager.cs" />
     <Compile Include="entity\AbstractMessage.cs" />
     <Compile Include="entity\Jsonhelper.cs" />
     <Compile Include="Form_paymentScheme.cs">
@@ -103,6 +104,12 @@
     <Compile Include="LOG\LogTest.cs" />
     <Compile Include="model\MainModel.cs" />
     <Compile Include="model\SysConst.cs" />
+    <Compile Include="FormPLCConf.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="FormPLCConf.Designer.cs">
+      <DependentUpon>FormPLCConf.cs</DependentUpon>
+    </Compile>
     <Compile Include="Monitor\SystemInitializer.cs" />
     <Compile Include="FormCentralController.cs">
       <SubType>Form</SubType>
@@ -135,6 +142,9 @@
       <DependentUpon>FormCentralController.cs</DependentUpon>
       <SubType>Designer</SubType>
     </EmbeddedResource>
+    <EmbeddedResource Include="FormPLCConf.resx">
+      <DependentUpon>FormPLCConf.cs</DependentUpon>
+    </EmbeddedResource>
     <EmbeddedResource Include="Properties\Resources.resx">
       <Generator>ResXFileCodeGenerator</Generator>
       <LastGenOutput>Resources.Designer.cs</LastGenOutput>

+ 1 - 1
PLCLinker/centralController/obj/Release/centralController.csproj.CoreCompileInputs.cache

@@ -1 +1 @@
-9fe48c294a8181f28841f7dc443bba75d30deab0
+5c8ea47b81e72bf94bef32daba8a67279fe7abf2

+ 1 - 0
PLCLinker/centralController/obj/Release/centralController.csproj.FileListAbsolute.txt

@@ -22,3 +22,4 @@ E:\superScene\智能停车项目\智能停车项目v2.0\PLCLinker\centralControl
 E:\superScene\智能停车项目\智能停车项目v2.0\PLCLinker\centralController\bin\Release\PLCS7.xml
 E:\superScene\智能停车项目\智能停车项目v2.0\PLCLinker\centralController\obj\Release\centralController.csprojResolveAssemblyReference.cache
 E:\superScene\智能停车项目\智能停车项目v2.0\PLCLinker\centralController\obj\Release\centralController.Form_paymentScheme.resources
+E:\superScene\智能停车项目\智能停车项目v2.0\PLCLinker\centralController\obj\Release\PLCConnector.FormPLCConf.resources

TEMPAT SAMPAH
PLCLinker/centralController/obj/Release/centralController.csproj.GenerateResource.Cache


TEMPAT SAMPAH
PLCLinker/centralController/obj/Release/centralController.csprojResolveAssemblyReference.cache


TEMPAT SAMPAH
PLCLinker/centralController/obj/Release/centralController.exe


TEMPAT SAMPAH
PLCLinker/centralController/obj/Release/centralController.pdb


TEMPAT SAMPAH
PLCLinker/centralController/sdk/broadcast/broadcastDLL.dll