Просмотр исходного кода

计费界面添加计费方式切换,读取PLC车位信息debug,心跳变为随机数,预约停取指令写入PLC中控db块,web检查是否可预约条件反置问题debug,根据PLC车位中时间结构调整

yc_t 6 лет назад
Родитель
Сommit
d2e36fd97f

BIN
PLCLinker/PLCConnector/PLC/PLCS7.dll


+ 4 - 2
PLCLinker/PLCS7/PLCS7.cs

@@ -30,7 +30,7 @@ namespace PLCS7
         protected const int mainBlockOffset = 52;
         protected const int parkingSpaceOffset = 18;
         protected const int terminalLength = 46;
-        protected const int parkingSpaceLength = 24;
+        protected const int parkingSpaceLength = 48;
         /// <summary>
         /// PLC 连接状态flag
         /// </summary>
@@ -391,11 +391,13 @@ namespace PLCS7
                 }
                 else if (abstractPLCMsg.GetType().Equals(typeof(MainBlockStru)) && whoami.Equals(PLCDataType.central))
                 {
-                    //只允许中控写入,且中控只允许写入号牌获取状态
+                    //只允许中控写入
                     MainBlockStru mbs = (MainBlockStru)abstractPLCMsg;
                     //byte[] temp = BitConverter.GetBytes(BytesRevert(mbs.licenseReceived));
                     if (mbs.centralHearbeat != (short)-1) { plc.WriteBytes(DataType.DataBlock, centralDB, mainBlockOffset + 8, BitConverter.GetBytes(BytesRevert(mbs.centralHearbeat))); }
                     if (mbs.licenseReceived != (short)-1) { plc.WriteBytes(DataType.DataBlock, centralDB, mainBlockOffset, BitConverter.GetBytes(BytesRevert(mbs.licenseReceived))); }
+                    if (mbs.bookParkCmd != (short)-1) { plc.WriteBytes(DataType.DataBlock, centralDB, mainBlockOffset, BitConverter.GetBytes(BytesRevert(mbs.bookParkCmd))); }
+                    if (mbs.bookFetchCmd != (short)-1) { plc.WriteBytes(DataType.DataBlock, centralDB, mainBlockOffset, BitConverter.GetBytes(BytesRevert(mbs.bookFetchCmd))); }
                     //ErrorCode ec = plc.WriteBytes(DataType.DataBlock, centralDB, mainBlockOffset, temp);
                     //if (!ec.Equals(ErrorCode.NoError)) { return false; }
                 }

BIN
PLCLinker/PLCS7/bin/Release/PLCS7.dll


BIN
PLCLinker/PLCS7/bin/Release/PLCS7.pdb


+ 6 - 7
PLCLinker/PLCS7/entity.cs

@@ -278,13 +278,12 @@ namespace PLCS7
         /// </summary>
         public short rearWheelbase;
 
-        public short year;
-        public byte month;
-        public byte day;
-        public byte hour;
-        public byte minute;
-        public byte second;
-        public int manosecond;
+        public int startTimeA;
+        public int startTimeB;
+        public int startTimeC;
+        public int endTimeA;
+        public int endTimeB;
+        public int endTimeC;
 
         public override string ToString()
         {

BIN
PLCLinker/PLCS7/obj/Release/PLCS7.dll


BIN
PLCLinker/PLCS7/obj/Release/PLCS7.pdb


+ 1 - 1
PLCLinker/centralController/App.config

@@ -9,7 +9,7 @@
     <!--<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=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="remoteDBConnStr" value="Data Source=192.168.10.125;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.10.121;port=3306;uid=remote;pooling=true;max pool size=1024;pwd=x5;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"/>
     <!--号牌机信息-->

+ 114 - 39
PLCLinker/centralController/FormPaymentScheme.Designer.cs

@@ -63,8 +63,12 @@ namespace centralController
             this.btnx_enableModify = new DevComponents.DotNetBar.ButtonX();
             this.btnx_confirmModification = new DevComponents.DotNetBar.ButtonX();
             this.btnx_cancelModify = new DevComponents.DotNetBar.ButtonX();
+            this.lb_schemeSwitch = new DevComponents.DotNetBar.LabelX();
+            this.gp_schemeSwitch = new DevComponents.DotNetBar.Controls.GroupPanel();
+            this.cb_schemeSwitch = new System.Windows.Forms.ComboBox();
             this.gp_paymentScheme.SuspendLayout();
             this.gp_VIPScheme.SuspendLayout();
+            this.gp_schemeSwitch.SuspendLayout();
             this.SuspendLayout();
             // 
             // gp_paymentScheme
@@ -95,7 +99,7 @@ namespace centralController
             this.gp_paymentScheme.DisabledBackColor = System.Drawing.Color.Empty;
             this.gp_paymentScheme.Location = new System.Drawing.Point(13, 12);
             this.gp_paymentScheme.Name = "gp_paymentScheme";
-            this.gp_paymentScheme.Size = new System.Drawing.Size(277, 308);
+            this.gp_paymentScheme.Size = new System.Drawing.Size(258, 327);
             // 
             // 
             // 
@@ -137,7 +141,7 @@ namespace centralController
             this.tbx_peakCharge.Border.CornerType = DevComponents.DotNetBar.eCornerType.Square;
             this.tbx_peakCharge.DisabledBackColor = System.Drawing.Color.White;
             this.tbx_peakCharge.ForeColor = System.Drawing.Color.Black;
-            this.tbx_peakCharge.Location = new System.Drawing.Point(144, 256);
+            this.tbx_peakCharge.Location = new System.Drawing.Point(143, 266);
             this.tbx_peakCharge.Name = "tbx_peakCharge";
             this.tbx_peakCharge.PreventEnterBeep = true;
             this.tbx_peakCharge.ReadOnly = true;
@@ -154,7 +158,7 @@ namespace centralController
             this.tbx_endChargeTime.Border.CornerType = DevComponents.DotNetBar.eCornerType.Square;
             this.tbx_endChargeTime.DisabledBackColor = System.Drawing.Color.White;
             this.tbx_endChargeTime.ForeColor = System.Drawing.Color.Black;
-            this.tbx_endChargeTime.Location = new System.Drawing.Point(144, 228);
+            this.tbx_endChargeTime.Location = new System.Drawing.Point(143, 238);
             this.tbx_endChargeTime.Name = "tbx_endChargeTime";
             this.tbx_endChargeTime.PreventEnterBeep = true;
             this.tbx_endChargeTime.ReadOnly = true;
@@ -171,7 +175,7 @@ namespace centralController
             this.tbx_startChargeTime.Border.CornerType = DevComponents.DotNetBar.eCornerType.Square;
             this.tbx_startChargeTime.DisabledBackColor = System.Drawing.Color.White;
             this.tbx_startChargeTime.ForeColor = System.Drawing.Color.Black;
-            this.tbx_startChargeTime.Location = new System.Drawing.Point(144, 200);
+            this.tbx_startChargeTime.Location = new System.Drawing.Point(143, 210);
             this.tbx_startChargeTime.Name = "tbx_startChargeTime";
             this.tbx_startChargeTime.PreventEnterBeep = true;
             this.tbx_startChargeTime.ReadOnly = true;
@@ -188,7 +192,7 @@ namespace centralController
             this.tbx_overnightCharge.Border.CornerType = DevComponents.DotNetBar.eCornerType.Square;
             this.tbx_overnightCharge.DisabledBackColor = System.Drawing.Color.White;
             this.tbx_overnightCharge.ForeColor = System.Drawing.Color.Black;
-            this.tbx_overnightCharge.Location = new System.Drawing.Point(144, 172);
+            this.tbx_overnightCharge.Location = new System.Drawing.Point(143, 182);
             this.tbx_overnightCharge.Name = "tbx_overnightCharge";
             this.tbx_overnightCharge.PreventEnterBeep = true;
             this.tbx_overnightCharge.ReadOnly = true;
@@ -205,7 +209,7 @@ namespace centralController
             this.tbx_eachCharge.Border.CornerType = DevComponents.DotNetBar.eCornerType.Square;
             this.tbx_eachCharge.DisabledBackColor = System.Drawing.Color.White;
             this.tbx_eachCharge.ForeColor = System.Drawing.Color.Black;
-            this.tbx_eachCharge.Location = new System.Drawing.Point(144, 144);
+            this.tbx_eachCharge.Location = new System.Drawing.Point(143, 154);
             this.tbx_eachCharge.Name = "tbx_eachCharge";
             this.tbx_eachCharge.PreventEnterBeep = true;
             this.tbx_eachCharge.ReadOnly = true;
@@ -222,7 +226,7 @@ namespace centralController
             this.tbx_upperBound.Border.CornerType = DevComponents.DotNetBar.eCornerType.Square;
             this.tbx_upperBound.DisabledBackColor = System.Drawing.Color.White;
             this.tbx_upperBound.ForeColor = System.Drawing.Color.Black;
-            this.tbx_upperBound.Location = new System.Drawing.Point(144, 115);
+            this.tbx_upperBound.Location = new System.Drawing.Point(143, 125);
             this.tbx_upperBound.Name = "tbx_upperBound";
             this.tbx_upperBound.PreventEnterBeep = true;
             this.tbx_upperBound.ReadOnly = true;
@@ -239,7 +243,7 @@ namespace centralController
             this.tbx_intervalCharge.Border.CornerType = DevComponents.DotNetBar.eCornerType.Square;
             this.tbx_intervalCharge.DisabledBackColor = System.Drawing.Color.White;
             this.tbx_intervalCharge.ForeColor = System.Drawing.Color.Black;
-            this.tbx_intervalCharge.Location = new System.Drawing.Point(144, 88);
+            this.tbx_intervalCharge.Location = new System.Drawing.Point(143, 98);
             this.tbx_intervalCharge.Name = "tbx_intervalCharge";
             this.tbx_intervalCharge.PreventEnterBeep = true;
             this.tbx_intervalCharge.ReadOnly = true;
@@ -256,7 +260,7 @@ namespace centralController
             this.tbx_firstCharge.Border.CornerType = DevComponents.DotNetBar.eCornerType.Square;
             this.tbx_firstCharge.DisabledBackColor = System.Drawing.Color.White;
             this.tbx_firstCharge.ForeColor = System.Drawing.Color.Black;
-            this.tbx_firstCharge.Location = new System.Drawing.Point(144, 60);
+            this.tbx_firstCharge.Location = new System.Drawing.Point(143, 70);
             this.tbx_firstCharge.Name = "tbx_firstCharge";
             this.tbx_firstCharge.PreventEnterBeep = true;
             this.tbx_firstCharge.ReadOnly = true;
@@ -273,7 +277,7 @@ namespace centralController
             this.tbx_firstChargeTime.Border.CornerType = DevComponents.DotNetBar.eCornerType.Square;
             this.tbx_firstChargeTime.DisabledBackColor = System.Drawing.Color.White;
             this.tbx_firstChargeTime.ForeColor = System.Drawing.Color.Black;
-            this.tbx_firstChargeTime.Location = new System.Drawing.Point(144, 32);
+            this.tbx_firstChargeTime.Location = new System.Drawing.Point(143, 42);
             this.tbx_firstChargeTime.Name = "tbx_firstChargeTime";
             this.tbx_firstChargeTime.PreventEnterBeep = true;
             this.tbx_firstChargeTime.ReadOnly = true;
@@ -290,7 +294,7 @@ namespace centralController
             this.tbx_freeTime.Border.CornerType = DevComponents.DotNetBar.eCornerType.Square;
             this.tbx_freeTime.DisabledBackColor = System.Drawing.Color.White;
             this.tbx_freeTime.ForeColor = System.Drawing.Color.Black;
-            this.tbx_freeTime.Location = new System.Drawing.Point(144, 4);
+            this.tbx_freeTime.Location = new System.Drawing.Point(143, 14);
             this.tbx_freeTime.Name = "tbx_freeTime";
             this.tbx_freeTime.PreventEnterBeep = true;
             this.tbx_freeTime.ReadOnly = true;
@@ -303,7 +307,7 @@ namespace centralController
             // 
             // 
             this.labelX10.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
-            this.labelX10.Location = new System.Drawing.Point(4, 256);
+            this.labelX10.Location = new System.Drawing.Point(3, 266);
             this.labelX10.Name = "labelX10";
             this.labelX10.Size = new System.Drawing.Size(122, 22);
             this.labelX10.TabIndex = 9;
@@ -315,7 +319,7 @@ namespace centralController
             // 
             // 
             this.labelX9.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
-            this.labelX9.Location = new System.Drawing.Point(4, 228);
+            this.labelX9.Location = new System.Drawing.Point(3, 238);
             this.labelX9.Name = "labelX9";
             this.labelX9.Size = new System.Drawing.Size(122, 22);
             this.labelX9.TabIndex = 8;
@@ -327,7 +331,7 @@ namespace centralController
             // 
             // 
             this.labelX8.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
-            this.labelX8.Location = new System.Drawing.Point(4, 200);
+            this.labelX8.Location = new System.Drawing.Point(3, 210);
             this.labelX8.Name = "labelX8";
             this.labelX8.Size = new System.Drawing.Size(122, 22);
             this.labelX8.TabIndex = 7;
@@ -339,7 +343,7 @@ namespace centralController
             // 
             // 
             this.labelX7.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
-            this.labelX7.Location = new System.Drawing.Point(4, 172);
+            this.labelX7.Location = new System.Drawing.Point(3, 182);
             this.labelX7.Name = "labelX7";
             this.labelX7.Size = new System.Drawing.Size(122, 22);
             this.labelX7.TabIndex = 6;
@@ -351,7 +355,7 @@ namespace centralController
             // 
             // 
             this.labelX6.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
-            this.labelX6.Location = new System.Drawing.Point(4, 144);
+            this.labelX6.Location = new System.Drawing.Point(3, 154);
             this.labelX6.Name = "labelX6";
             this.labelX6.Size = new System.Drawing.Size(122, 22);
             this.labelX6.TabIndex = 5;
@@ -363,7 +367,7 @@ namespace centralController
             // 
             // 
             this.labelX5.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
-            this.labelX5.Location = new System.Drawing.Point(4, 116);
+            this.labelX5.Location = new System.Drawing.Point(3, 126);
             this.labelX5.Name = "labelX5";
             this.labelX5.Size = new System.Drawing.Size(122, 22);
             this.labelX5.TabIndex = 4;
@@ -375,7 +379,7 @@ namespace centralController
             // 
             // 
             this.labelX4.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
-            this.labelX4.Location = new System.Drawing.Point(4, 88);
+            this.labelX4.Location = new System.Drawing.Point(3, 98);
             this.labelX4.Name = "labelX4";
             this.labelX4.Size = new System.Drawing.Size(122, 22);
             this.labelX4.TabIndex = 3;
@@ -387,7 +391,7 @@ namespace centralController
             // 
             // 
             this.labelX3.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
-            this.labelX3.Location = new System.Drawing.Point(4, 60);
+            this.labelX3.Location = new System.Drawing.Point(3, 70);
             this.labelX3.Name = "labelX3";
             this.labelX3.Size = new System.Drawing.Size(122, 22);
             this.labelX3.TabIndex = 2;
@@ -399,7 +403,7 @@ namespace centralController
             // 
             // 
             this.labelX2.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
-            this.labelX2.Location = new System.Drawing.Point(4, 32);
+            this.labelX2.Location = new System.Drawing.Point(3, 42);
             this.labelX2.Name = "labelX2";
             this.labelX2.Size = new System.Drawing.Size(122, 22);
             this.labelX2.TabIndex = 1;
@@ -411,7 +415,7 @@ namespace centralController
             // 
             // 
             this.labelX1.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
-            this.labelX1.Location = new System.Drawing.Point(4, 4);
+            this.labelX1.Location = new System.Drawing.Point(3, 14);
             this.labelX1.Name = "labelX1";
             this.labelX1.Size = new System.Drawing.Size(122, 22);
             this.labelX1.TabIndex = 0;
@@ -433,9 +437,9 @@ namespace centralController
             this.gp_VIPScheme.Controls.Add(this.labelX12);
             this.gp_VIPScheme.Controls.Add(this.labelX11);
             this.gp_VIPScheme.DisabledBackColor = System.Drawing.Color.Empty;
-            this.gp_VIPScheme.Location = new System.Drawing.Point(307, 12);
+            this.gp_VIPScheme.Location = new System.Drawing.Point(291, 12);
             this.gp_VIPScheme.Name = "gp_VIPScheme";
-            this.gp_VIPScheme.Size = new System.Drawing.Size(256, 242);
+            this.gp_VIPScheme.Size = new System.Drawing.Size(262, 197);
             // 
             // 
             // 
@@ -477,7 +481,7 @@ namespace centralController
             this.tbx_bookCharge.Border.CornerType = DevComponents.DotNetBar.eCornerType.Square;
             this.tbx_bookCharge.DisabledBackColor = System.Drawing.Color.White;
             this.tbx_bookCharge.ForeColor = System.Drawing.Color.Black;
-            this.tbx_bookCharge.Location = new System.Drawing.Point(143, 116);
+            this.tbx_bookCharge.Location = new System.Drawing.Point(143, 126);
             this.tbx_bookCharge.Name = "tbx_bookCharge";
             this.tbx_bookCharge.PreventEnterBeep = true;
             this.tbx_bookCharge.ReadOnly = true;
@@ -494,7 +498,7 @@ namespace centralController
             this.tbx_yearCard.Border.CornerType = DevComponents.DotNetBar.eCornerType.Square;
             this.tbx_yearCard.DisabledBackColor = System.Drawing.Color.White;
             this.tbx_yearCard.ForeColor = System.Drawing.Color.Black;
-            this.tbx_yearCard.Location = new System.Drawing.Point(143, 87);
+            this.tbx_yearCard.Location = new System.Drawing.Point(143, 97);
             this.tbx_yearCard.Name = "tbx_yearCard";
             this.tbx_yearCard.PreventEnterBeep = true;
             this.tbx_yearCard.ReadOnly = true;
@@ -511,7 +515,7 @@ namespace centralController
             this.tbx_halfYearCard.Border.CornerType = DevComponents.DotNetBar.eCornerType.Square;
             this.tbx_halfYearCard.DisabledBackColor = System.Drawing.Color.White;
             this.tbx_halfYearCard.ForeColor = System.Drawing.Color.Black;
-            this.tbx_halfYearCard.Location = new System.Drawing.Point(143, 60);
+            this.tbx_halfYearCard.Location = new System.Drawing.Point(143, 70);
             this.tbx_halfYearCard.Name = "tbx_halfYearCard";
             this.tbx_halfYearCard.PreventEnterBeep = true;
             this.tbx_halfYearCard.ReadOnly = true;
@@ -528,7 +532,7 @@ namespace centralController
             this.tbx_seasonCard.Border.CornerType = DevComponents.DotNetBar.eCornerType.Square;
             this.tbx_seasonCard.DisabledBackColor = System.Drawing.Color.White;
             this.tbx_seasonCard.ForeColor = System.Drawing.Color.Black;
-            this.tbx_seasonCard.Location = new System.Drawing.Point(143, 30);
+            this.tbx_seasonCard.Location = new System.Drawing.Point(143, 40);
             this.tbx_seasonCard.Name = "tbx_seasonCard";
             this.tbx_seasonCard.PreventEnterBeep = true;
             this.tbx_seasonCard.ReadOnly = true;
@@ -545,7 +549,7 @@ namespace centralController
             this.tbx_monthCard.Border.CornerType = DevComponents.DotNetBar.eCornerType.Square;
             this.tbx_monthCard.DisabledBackColor = System.Drawing.Color.White;
             this.tbx_monthCard.ForeColor = System.Drawing.Color.Black;
-            this.tbx_monthCard.Location = new System.Drawing.Point(143, 3);
+            this.tbx_monthCard.Location = new System.Drawing.Point(143, 13);
             this.tbx_monthCard.Name = "tbx_monthCard";
             this.tbx_monthCard.PreventEnterBeep = true;
             this.tbx_monthCard.ReadOnly = true;
@@ -558,7 +562,7 @@ namespace centralController
             // 
             // 
             this.labelX15.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
-            this.labelX15.Location = new System.Drawing.Point(3, 116);
+            this.labelX15.Location = new System.Drawing.Point(3, 126);
             this.labelX15.Name = "labelX15";
             this.labelX15.Size = new System.Drawing.Size(122, 22);
             this.labelX15.TabIndex = 14;
@@ -570,7 +574,7 @@ namespace centralController
             // 
             // 
             this.labelX14.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
-            this.labelX14.Location = new System.Drawing.Point(3, 88);
+            this.labelX14.Location = new System.Drawing.Point(3, 98);
             this.labelX14.Name = "labelX14";
             this.labelX14.Size = new System.Drawing.Size(122, 22);
             this.labelX14.TabIndex = 13;
@@ -582,7 +586,7 @@ namespace centralController
             // 
             // 
             this.labelX13.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
-            this.labelX13.Location = new System.Drawing.Point(3, 60);
+            this.labelX13.Location = new System.Drawing.Point(3, 70);
             this.labelX13.Name = "labelX13";
             this.labelX13.Size = new System.Drawing.Size(122, 22);
             this.labelX13.TabIndex = 12;
@@ -594,7 +598,7 @@ namespace centralController
             // 
             // 
             this.labelX12.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
-            this.labelX12.Location = new System.Drawing.Point(3, 32);
+            this.labelX12.Location = new System.Drawing.Point(3, 42);
             this.labelX12.Name = "labelX12";
             this.labelX12.Size = new System.Drawing.Size(122, 22);
             this.labelX12.TabIndex = 11;
@@ -606,7 +610,7 @@ namespace centralController
             // 
             // 
             this.labelX11.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
-            this.labelX11.Location = new System.Drawing.Point(3, 4);
+            this.labelX11.Location = new System.Drawing.Point(3, 14);
             this.labelX11.Name = "labelX11";
             this.labelX11.Size = new System.Drawing.Size(122, 22);
             this.labelX11.TabIndex = 10;
@@ -616,7 +620,7 @@ namespace centralController
             // 
             this.btnx_enableModify.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
             this.btnx_enableModify.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
-            this.btnx_enableModify.Location = new System.Drawing.Point(307, 286);
+            this.btnx_enableModify.Location = new System.Drawing.Point(297, 316);
             this.btnx_enableModify.Name = "btnx_enableModify";
             this.btnx_enableModify.Size = new System.Drawing.Size(75, 23);
             this.btnx_enableModify.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
@@ -628,7 +632,7 @@ namespace centralController
             // 
             this.btnx_confirmModification.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
             this.btnx_confirmModification.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
-            this.btnx_confirmModification.Location = new System.Drawing.Point(397, 286);
+            this.btnx_confirmModification.Location = new System.Drawing.Point(387, 316);
             this.btnx_confirmModification.Name = "btnx_confirmModification";
             this.btnx_confirmModification.Size = new System.Drawing.Size(75, 23);
             this.btnx_confirmModification.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
@@ -640,7 +644,7 @@ namespace centralController
             // 
             this.btnx_cancelModify.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
             this.btnx_cancelModify.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
-            this.btnx_cancelModify.Location = new System.Drawing.Point(488, 286);
+            this.btnx_cancelModify.Location = new System.Drawing.Point(478, 316);
             this.btnx_cancelModify.Name = "btnx_cancelModify";
             this.btnx_cancelModify.Size = new System.Drawing.Size(75, 23);
             this.btnx_cancelModify.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
@@ -648,21 +652,89 @@ namespace centralController
             this.btnx_cancelModify.Text = "取消修改";
             this.btnx_cancelModify.Click += new System.EventHandler(this.btnx_cancelModify_Click);
             // 
-            // Form_paymentScheme
+            // lb_schemeSwitch
+            // 
+            // 
+            // 
+            // 
+            this.lb_schemeSwitch.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
+            this.lb_schemeSwitch.Location = new System.Drawing.Point(52, 16);
+            this.lb_schemeSwitch.Name = "lb_schemeSwitch";
+            this.lb_schemeSwitch.Size = new System.Drawing.Size(156, 22);
+            this.lb_schemeSwitch.TabIndex = 20;
+            this.lb_schemeSwitch.Text = "计费策略切换";
+            // 
+            // gp_schemeSwitch
+            // 
+            this.gp_schemeSwitch.BackColor = System.Drawing.Color.White;
+            this.gp_schemeSwitch.CanvasColor = System.Drawing.SystemColors.Control;
+            this.gp_schemeSwitch.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2007;
+            this.gp_schemeSwitch.Controls.Add(this.cb_schemeSwitch);
+            this.gp_schemeSwitch.Controls.Add(this.lb_schemeSwitch);
+            this.gp_schemeSwitch.DisabledBackColor = System.Drawing.Color.Empty;
+            this.gp_schemeSwitch.Location = new System.Drawing.Point(292, 219);
+            this.gp_schemeSwitch.Name = "gp_schemeSwitch";
+            this.gp_schemeSwitch.Size = new System.Drawing.Size(261, 91);
+            // 
+            // 
+            // 
+            this.gp_schemeSwitch.Style.BackColor2SchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground2;
+            this.gp_schemeSwitch.Style.BackColorGradientAngle = 90;
+            this.gp_schemeSwitch.Style.BackColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground;
+            this.gp_schemeSwitch.Style.BorderBottom = DevComponents.DotNetBar.eStyleBorderType.Solid;
+            this.gp_schemeSwitch.Style.BorderBottomWidth = 1;
+            this.gp_schemeSwitch.Style.BorderColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder;
+            this.gp_schemeSwitch.Style.BorderLeft = DevComponents.DotNetBar.eStyleBorderType.Solid;
+            this.gp_schemeSwitch.Style.BorderLeftWidth = 1;
+            this.gp_schemeSwitch.Style.BorderRight = DevComponents.DotNetBar.eStyleBorderType.Solid;
+            this.gp_schemeSwitch.Style.BorderRightWidth = 1;
+            this.gp_schemeSwitch.Style.BorderTop = DevComponents.DotNetBar.eStyleBorderType.Solid;
+            this.gp_schemeSwitch.Style.BorderTopWidth = 1;
+            this.gp_schemeSwitch.Style.CornerDiameter = 4;
+            this.gp_schemeSwitch.Style.CornerType = DevComponents.DotNetBar.eCornerType.Rounded;
+            this.gp_schemeSwitch.Style.TextAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Center;
+            this.gp_schemeSwitch.Style.TextColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelText;
+            this.gp_schemeSwitch.Style.TextLineAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Near;
+            // 
+            // 
+            // 
+            this.gp_schemeSwitch.StyleMouseDown.CornerType = DevComponents.DotNetBar.eCornerType.Square;
+            // 
+            // 
+            // 
+            this.gp_schemeSwitch.StyleMouseOver.CornerType = DevComponents.DotNetBar.eCornerType.Square;
+            this.gp_schemeSwitch.TabIndex = 22;
+            this.gp_schemeSwitch.Text = "计费策略切换";
+            // 
+            // cb_schemeSwitch
+            // 
+            this.cb_schemeSwitch.FormattingEnabled = true;
+            this.cb_schemeSwitch.Items.AddRange(new object[] {
+            "按时收费",
+            "按次收费",
+            "按时段收费"});
+            this.cb_schemeSwitch.Location = new System.Drawing.Point(66, 44);
+            this.cb_schemeSwitch.Name = "cb_schemeSwitch";
+            this.cb_schemeSwitch.Size = new System.Drawing.Size(121, 20);
+            this.cb_schemeSwitch.TabIndex = 22;
+            // 
+            // FormPaymentScheme
             // 
             this.BackColor = System.Drawing.SystemColors.ButtonHighlight;
-            this.ClientSize = new System.Drawing.Size(575, 327);
+            this.ClientSize = new System.Drawing.Size(610, 355);
+            this.Controls.Add(this.gp_schemeSwitch);
             this.Controls.Add(this.btnx_cancelModify);
             this.Controls.Add(this.btnx_confirmModification);
             this.Controls.Add(this.btnx_enableModify);
             this.Controls.Add(this.gp_VIPScheme);
             this.Controls.Add(this.gp_paymentScheme);
             this.DoubleBuffered = true;
-            this.Name = "Form_paymentScheme";
+            this.Name = "FormPaymentScheme";
             this.Text = "收费策略";
             this.Load += new System.EventHandler(this.Form_paymentScheme_Load);
             this.gp_paymentScheme.ResumeLayout(false);
             this.gp_VIPScheme.ResumeLayout(false);
+            this.gp_schemeSwitch.ResumeLayout(false);
             this.ResumeLayout(false);
 
         }
@@ -704,5 +776,8 @@ namespace centralController
         private DevComponents.DotNetBar.Controls.TextBoxX tbx_halfYearCard;
         private DevComponents.DotNetBar.Controls.TextBoxX tbx_seasonCard;
         private DevComponents.DotNetBar.Controls.TextBoxX tbx_monthCard;
+        private DevComponents.DotNetBar.LabelX lb_schemeSwitch;
+        private DevComponents.DotNetBar.Controls.GroupPanel gp_schemeSwitch;
+        private System.Windows.Forms.ComboBox cb_schemeSwitch;
     }
 }

+ 6 - 2
PLCLinker/centralController/FormPaymentScheme.cs

@@ -30,6 +30,7 @@ namespace centralController
             else
             {
                 displayScheme();
+                SetReadOnly(true);
             }
         }
         /// <summary>
@@ -37,6 +38,7 @@ namespace centralController
         /// </summary>
         private void displayScheme()
         {
+            cb_schemeSwitch.SelectedIndex = PaymentScheme.ins.schemeType - 1;
             tbx_freeTime.Text = PaymentScheme.ins.freeTime.ToString();
             tbx_firstChargeTime.Text = PaymentScheme.ins.firstChargeTime.ToString();
             tbx_firstCharge.Text = PaymentScheme.ins.firstCharge.ToString();
@@ -83,6 +85,7 @@ namespace centralController
                 }
             }
             catch (Exception ex) { Console.WriteLine("启动修改按钮异常,panel2"); }
+            cb_schemeSwitch.Enabled = !isReadOnly;
         }
         /// <summary>
         /// 允许修改计费策略参数
@@ -104,6 +107,7 @@ namespace centralController
             {
                 PaymentScheme ps = new PaymentScheme()
                 {
+                    schemeType = cb_schemeSwitch.SelectedIndex + 1,
                     freeTime = int.Parse(tbx_freeTime.Text),
                     firstChargeTime = int.Parse(tbx_firstChargeTime.Text),
                     firstCharge = int.Parse(tbx_firstCharge.Text),
@@ -126,14 +130,14 @@ namespace centralController
                     PaymentScheme.ins = PaymentScheme.GetCurrentPaymentScheme(1);
                     displayScheme();
                     SetReadOnly(true);
-                    MessageBox.Show("成功更新收费策略","提示");
+                    MessageBox.Show("成功更新收费策略", "提示");
                 }
                 else
                 {
                     MessageBox.Show("收费策略修改失败,请检查后重试", "提示");
                 }
             }
-            catch (Exception ex){ MessageBox.Show("收费策略修改失败,请检查后重试", "提示"); }
+            catch (Exception ex) { MessageBox.Show("收费策略修改失败,请检查后重试", "提示"); }
         }
         /// <summary>
         /// 取消修改,显示原参数并将参数设为只读

+ 0 - 3
PLCLinker/centralController/FormPaymentScheme.resx

@@ -117,7 +117,4 @@
   <resheader name="writer">
     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
-  <metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
 </root>

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

@@ -131,7 +131,10 @@ namespace Monitor
                                 for (int i = 0; i < plcTerminalCount; i++)
                                 {
                                     Terminal.Terminal.terminalInfo.Add((TerminalStru)received[i]);
-                                    Terminal.Terminal.termUsedMap.Add(((TerminalStru)received[i]).terminalID, false);
+                                    if (!Terminal.Terminal.termUsedMap.ContainsKey(((TerminalStru)received[i]).terminalID))
+                                        Terminal.Terminal.termUsedMap.Add(((TerminalStru)received[i]).terminalID, false);
+                                    else
+                                        Terminal.Terminal.termUsedMap[((TerminalStru)received[i]).terminalID] = false;
                                 }
                             }
                         }
@@ -494,18 +497,22 @@ namespace Monitor
             {
                 return mainBlockInfo.reserveTotalSpace;
             }
-            if (parkingSpaceInfo != null)
+            try
             {
-                foreach (ParkingSpaceStru psStru in parkingSpaceInfo)
+                if (parkingSpaceInfo != null)
                 {
-                    if (psStru.spaceStatus != 1 && psStru.spaceStatus != 3)
+                    foreach (ParkingSpaceStru psStru in parkingSpaceInfo)
                     {
-                        freeSpaceCount++;
-                        if (psStru.spaceStatus == 2)
-                            reservedSpaceCount++;
+                        if (psStru.spaceStatus != 1 && psStru.spaceStatus != 3)
+                        {
+                            freeSpaceCount++;
+                            if (psStru.spaceStatus == 2)
+                                reservedSpaceCount++;
+                        }
                     }
                 }
             }
+            catch { Console.WriteLine("空闲车位数,计数异常");return 0; }
             switch (state)
             {
                 case 0:

+ 4 - 1
PLCLinker/centralController/Monitor/SystemInitializer.cs

@@ -190,6 +190,7 @@ namespace Monitor
                 }
                 else if (Monitor.PLC.isConnected)
                 {
+                    Random rnd = new Random();
                     //启动心跳进程
                     Task.Factory.StartNew(() =>
                     {
@@ -202,8 +203,10 @@ namespace Monitor
                                 if (list.Count != 0)
                                 {
                                     mbs = (MainBlockStru)list[0];
-                                    mbs.centralHearbeat = (mbs.centralHearbeat == (short)254) ? (short)255 : (short)254;
+                                    mbs.centralHearbeat = (short)rnd.Next(100,999);
                                     mbs.licenseReceived = (short)-1;
+                                    mbs.bookParkCmd = (short)-1;
+                                    mbs.bookFetchCmd = (short)-1;
                                     Monitor.PLC.WriteToPLC(mbs, PLCDataType.central);
                                 }
                             }

+ 47 - 20
PLCLinker/centralController/Terminal/Terminal.cs

@@ -409,9 +409,6 @@ namespace Terminal
         /// </summary>
         private static void ParkNumSubProcess()
         {
-            //int numMachineLaunch = Monitor.Monitor.mainBlockInfo.numMachineLaunch;
-            //if (numMachineLaunch != 0)
-            //{
             for (int i = 0; i < terminalInfo.Count; i++)
             {
                 //启动指令与终端id匹配
@@ -438,6 +435,9 @@ namespace Terminal
                         {
                             MainBlockStru mb = new MainBlockStru
                             {
+                                centralHearbeat = (short)-1,
+                                bookParkCmd = -1,
+                                bookFetchCmd = -1,
                                 licenseReceived = (short)2
                             };
                             Monitor.Monitor.PLC.WriteToPLC(mb, PLCDataType.central);
@@ -457,14 +457,19 @@ namespace Terminal
                             //记录或更新当前号牌
                             lock (idLicMap)
                             {
-                                if (idLicMap.ContainsKey(terminalInfo[i].terminalID) && idLicMap[terminalInfo[i].terminalID] != license)
+                                try
                                 {
-                                    idLicMap[terminalInfo[i].terminalID] = license;
-                                }
-                                else
-                                {
-                                    idLicMap.Add(terminalInfo[i].terminalID, license);
+                                    if (idLicMap.ContainsKey(terminalInfo[i].terminalID))
+                                    {
+                                        if (!idLicMap[terminalInfo[i].terminalID].Equals(license))
+                                            idLicMap[terminalInfo[i].terminalID] = license;
+                                    }
+                                    else
+                                    {
+                                        idLicMap.Add(terminalInfo[i].terminalID, license);
+                                    }
                                 }
+                                catch(Exception e) { Log.WriteLog(LogType.process, LogFile.ERROR, "号牌" + license + "记录号牌异常\n"+e.StackTrace); }
                             }
                             Log.WriteLog(LogType.process, LogFile.ERROR, "号牌" + license + "已记录");
 
@@ -497,17 +502,26 @@ namespace Terminal
                             //无论是否注册,皆告知PLC,已获取号牌或比对异常、终止流程
                             MainBlockStru mb = new MainBlockStru
                             {
+                                centralHearbeat = -1,
+                                bookFetchCmd = -1,
+                                bookParkCmd = -1,
                                 licenseReceived = (short)numReceivedStatus
                             };
                             Monitor.Monitor.PLC.WriteToPLC(mb, PLCDataType.central);
                             //号牌获取结果被清零才跳出
                             Monitor.Monitor.SetNotification("已写入号牌获取结果,等待号牌机启动指令清零");
                         }
-                        while (term.numMachineLaunch != 0)
+                        int countdown = 5;
+                        while (countdown-- > 0)
                         {
-                            Thread.Sleep(1000);
+                            if (term.numMachineLaunch == 0)
+                            {
+                                Monitor.Monitor.SetNotification("号牌机启动指令已被清零"); break;
+                            }
+                            else
+                                Thread.Sleep(1000);
                         }
-                        Monitor.Monitor.SetNotification("号牌机启动指令已被清零");
+
                     }
                 }
             }
@@ -636,6 +650,7 @@ namespace Terminal
                 //Console.WriteLine(i);
                 if (terminalInfo[i].terminalStatus == 1 && terminalInfo[i].groundStatus == 1 && terminalInfo[i].btnStatus == 0 && !lockList[i])
                 {
+                    lockList[i] = true;
                     Action<int> reserveAction = new Action<int>(ReservedOper);
                     reserveAction(i);
                 }
@@ -645,7 +660,6 @@ namespace Terminal
         {
             Task.Factory.StartNew(() =>
             {
-                lockList[index] = true;
                 string license = "";
                 int countdown = 2;
                 short registered = 4;
@@ -653,6 +667,7 @@ namespace Terminal
                 {
                     license = Monitor.Monitor.numMachineLinker.GetLicensePlate(terminalInfo[index].terminalID);
                 }
+                Monitor.Monitor.SetNotification(terminalInfo[index].terminalID + "号车位收到地感,拍到" + license);
                 if (license != "")
                 {
                     //map中加入或更新号牌,供完成时写入数据库用
@@ -712,7 +727,7 @@ namespace Terminal
                 }
                 else
                 {
-                    Thread.Sleep(500);
+                    Thread.Sleep(200);
                 }
                 lockList[index] = false;
             });
@@ -951,11 +966,18 @@ namespace Terminal
                 {
                     //按时计费
                     case 1:
-                        if (hours > scheme.firstChargeTime)
+                        if (hours > scheme.firstChargeTime + scheme.freeTime)
                         {
-                            parkFee = Math.Min(scheme.firstCharge + scheme.intervalCharge * hours / scheme.chargeInterval, scheme.upperBound);
+                            if (hours > 24)
+                            {
+                                parkFee = hours/24 * scheme.upperBound + Math.Min(scheme.intervalCharge * (hours%24) / scheme.chargeInterval, scheme.upperBound);
+                            }
+                            else
+                            {
+                                parkFee = Math.Min(scheme.firstCharge + scheme.intervalCharge * hours / scheme.chargeInterval, scheme.upperBound);
+                            }
                         }
-                        else if (hours > scheme.firstChargeTime - scheme.freeTime)
+                        else if (hours > scheme.freeTime)
                         {
                             parkFee = scheme.firstCharge;
                         }
@@ -966,7 +988,8 @@ namespace Terminal
                         break;
                     //按次计费
                     case 2:
-                        int overnightCount = hours / 24;
+                        //Console.WriteLine(DateTime.Now.Date.ToString()+","+ parkTime.Date.ToString());
+                        int overnightCount = (DateTime.Now.Date - parkTime.Date).Days;
                         parkFee = scheme.eachCharge + overnightCount * scheme.overnightCharge;
                         break;
                     //按时间段计费
@@ -1038,11 +1061,12 @@ namespace Terminal
                     {
                         FindVipInfo(license, ref orderRecordsID, ref monthCardType, ref monthCardTimeLength, ref orderTimeLength);
                     }
+                    if (monthCardType == -1) monthCardType = 0;
                     //3.获取停车时刻,根据用户类型计费发送给PLC,暂认为无预约
                     DateTime parkTime = DateTime.Parse(realParkTime);
                     DateTime currentTime = DateTime.Now;
                     int fee = 32767;
-                    if (failed) { monthCardType = -1; }
+                    if (failed) { monthCardType = -2; }
                     if (PaymentScheme.ins != null)
                     {
                         if (monthCardTimeLength.TotalHours > 0)
@@ -1074,7 +1098,7 @@ namespace Terminal
                         }
                         catch { Console.WriteLine("error"); }
                     }
-                    Monitor.Monitor.SetNotification("用户类型:" + monthCardType + ",费用:" + fee + ",等待凭证号被清除且流程结束后更新车辆状态");
+                    Monitor.Monitor.SetNotification("用户类型:" + (monthCardType+1) + ",费用:" + fee + ",等待凭证号被清除且流程结束后更新车辆状态");
                     FetchInfo fetchInfo = new FetchInfo(license, parkingRecordsID, remoteParkingRecordsID, fee, receiptNum);
                     if (!fetchMap.ContainsKey(termIndex))
                         fetchMap.Add(termIndex, fetchInfo);
@@ -1112,6 +1136,9 @@ namespace Terminal
                             count++;
                             if (count == 1)
                                 Monitor.Monitor.SetNotification("等待凭证号清除");
+                            if (count > 10000)//避免int型数据溢出
+                                count = 2;
+                            Thread.Sleep(200);
                         }
                         int paymentStatus = 0;
                         for (int i = 0; i < terminalInfo.Count; i++)

+ 72 - 22
PLCLinker/centralController/WebServer/WebServer.cs

@@ -1,5 +1,6 @@
 using centralController.model;
 using nettyCommunication;
+using PLCS7;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -135,7 +136,7 @@ namespace centralController.WebServer
         /// <param name="license"></param>
         /// <param name="latestIndex">最近第几条记录,1表示最新一条</param>
         /// <returns></returns>
-        private int FindCurrentOrderRecordID(bool localDB, string license,int latestIndex = 1)
+        private int FindCurrentOrderRecordID(bool localDB, string license, int latestIndex = 1)
         {
             int currentID = 0;
             List<object[]> orderRecords = Monitor.Monitor.GetOrderRecords(localDB, license, DateTime.Now.ToString("yyyy-MM-dd"), DateTime.Now.AddDays(1).ToString("yyyy-MM-dd"));
@@ -143,7 +144,7 @@ namespace centralController.WebServer
             {
                 try
                 {
-                    currentID = (int)(UInt32)orderRecords[latestIndex-1][0];
+                    currentID = (int)(UInt32)orderRecords[latestIndex - 1][0];
                 }
                 catch { }
             }
@@ -165,7 +166,7 @@ namespace centralController.WebServer
             InsertOrderRecord(localDB, userID, parking, license, orderTime, orderLength);
             //查询预约记录id号
             int currentID = FindCurrentOrderRecordID(localDB, license);
-            if(currentID == 0){ /*反馈web,预约失败*/ return false; }
+            if (currentID == 0) { /*反馈web,预约失败*/ return false; }
             //更新车辆状态
             UpdateVehicleState(localDB, parking ? 4 : 5, currentID, license);
             return true;
@@ -203,9 +204,9 @@ namespace centralController.WebServer
                 }
             }
             if (allBookableSpace >= count)
-                return false;
-            else
                 return true;
+            else
+                return false;
         }
         /// <summary>
         /// 根据消息类型分别处理
@@ -219,24 +220,27 @@ namespace centralController.WebServer
                 {
                     //预约停
                     case "RESERVE":
-                        if (!ReservationValidate(msg))
+                        if (msg.sender != "" && msg.bookTime != "" && msg.bookLength != 0)
                         {
-                            //回复预约失败给web
-                            msg.cmd = "FAILED";
-                            comm.SendMessage(msg);
-                        }
-                        else
-                        {
-                            lock (waitToReserveLock)
+                            if (!ReservationValidate(msg))
                             {
-                                waitToReserveQueue.Enqueue(msg);
+                                //回复预约失败给web
+                                msg.cmd = "FAILED";
+                                comm.SendMessage(msg);
+                            }
+                            else
+                            {
+                                lock (waitToReserveLock)
+                                {
+                                    waitToReserveQueue.Enqueue(msg);
+                                }
+                                //预约记录与车辆状态写入数据库
+                                ReserveDBOperation(true, msg.sender, true, msg.context, msg.bookTime, msg.bookLength);
+                                ReserveDBOperation(false, msg.sender, true, msg.context, msg.bookTime, msg.bookLength);
+                                //回复成功给web
+                                msg.cmd = "0";
+                                comm.SendMessage(msg);
                             }
-                            //预约记录与车辆状态写入数据库
-                            ReserveDBOperation(true, msg.sender, true, msg.context, msg.bookTime, msg.bookLength);
-                            ReserveDBOperation(false, msg.sender, true, msg.context, msg.bookTime, msg.bookLength);
-                            //回复成功给web
-                            msg.cmd = "0";
-                            comm.SendMessage(msg);
                         }
                         break;
                     //预约取
@@ -244,6 +248,9 @@ namespace centralController.WebServer
                         break;
                     //停车
                     case "PARK":
+                        //根据号牌寻找对应号牌机编号,找不到则返回失败信息
+                        //判断号牌机编号对应PLC数据块是否空闲,空闲则判断按钮状态并发送停车指令到PLC,否则返回失败信息
+
                         break;
                     //取车
                     case "FETCH":
@@ -272,6 +279,41 @@ namespace centralController.WebServer
             }
             catch (Exception ex) { Console.WriteLine("收消息," + ex.Message + "\n" + ex.StackTrace); }
         }
+
+        private void SendBookCmd(bool parking, int state)
+        {
+            int countdown = 5;
+            while (countdown-- > 0)
+            {
+                if (Monitor.Monitor.mainBlockInfo.bookParkCmd != 0)
+                    Thread.Sleep(300);
+                else
+                {
+                    MainBlockStru mb = new MainBlockStru
+                    {
+                        centralHearbeat = -1,
+                        bookParkCmd = parking ? (short)state : (short)-1,
+                        bookFetchCmd = !parking ? (short)state : (short)-1,
+                        licenseReceived = -1
+                    };
+                    Monitor.Monitor.PLC.WriteToPLC(mb, PLCDataType.central);
+                    break;
+                }
+                if (countdown == 2)
+                {
+                    Monitor.Monitor.SetNotification("未能获取预约指令位0状态,尝试手动清除");
+                    MainBlockStru mb = new MainBlockStru
+                    {
+                        centralHearbeat = -1,
+                        bookParkCmd = parking ? (short)0 : (short)-1,
+                        bookFetchCmd = !parking ? (short)0 : (short)-1,
+                        licenseReceived = -1
+                    };
+                    Monitor.Monitor.PLC.WriteToPLC(mb, PLCDataType.central);
+                    Thread.Sleep(500);
+                }
+            }
+        }
         /// <summary>
         /// 根据时间段处理所有准备预约及已预约指令
         /// </summary>
@@ -292,7 +334,11 @@ namespace centralController.WebServer
                             //达到预约启动时间,放入已预约队列
                             if (ts.TotalMinutes >= 0)
                             {
-                                //通知PLC减少一个可预约车位数
+                                //如果是预约停车,通知PLC减少一个可预约车位数
+                                if (msg.cmd == "RESERVE")
+                                {
+                                    SendBookCmd(true, 1);
+                                }
                                 lock (reservedLock)
                                 {
                                     reservedQueue.Enqueue(msg);
@@ -320,6 +366,7 @@ namespace centralController.WebServer
                             if (ts.TotalMinutes > msg.bookLength * 60)
                             {
                                 //通知PLC将可预约车位数恢复一个
+                                SendBookCmd(true, 2);
                                 //恢复车辆状态
                                 UpdateVehicleState(true, 0, 0, msg.context);
                                 UpdateVehicleState(false, 0, 0, msg.context);
@@ -422,7 +469,10 @@ namespace centralController.WebServer
                         if (connected && comm != null)
                         {
                             MessageUTF8 msg = ((MessageUTF8)comm.ReceiveMessage());
-                            MsgHandling(msg);
+                            if (msg != null)
+                            {
+                                MsgHandling(msg);
+                            }
                             Monitor.Monitor.SetNotification(msg.context);
                         }
                     }

Разница между файлами не показана из-за своего большого размера
+ 1 - 1
PLCLinker/centralController/model/PaymentScheme.cs


BIN
PLCLinker/centralController/obj/Release/centralController.csproj.GenerateResource.Cache


BIN
PLCLinker/centralController/sdk/PLC/PLCS7.dll


+ 1 - 1
PLCLinker/centralController/serversettings.json

@@ -1,7 +1,7 @@
 {
 
   "ssl": "false",
-  "host": "192.168.10.125",
+  "host": "192.168.10.121",
   "garageID":"2",
   "port": "9000",
   "size": "1024"