Browse Source

超时指令提示调整,PLC重连机制调整

yc_t 6 years ago
parent
commit
58834017c9

+ 13 - 13
PLCLinker/PLCLinker.cs

@@ -856,19 +856,19 @@ namespace PLCLinker
                 }
             });
 
-            ////模拟plc与激光自动操作
-            //Task.Factory.StartNew(() =>
-            //{
-            //    laserAnim();
-            //});
-            //Task.Factory.StartNew(() =>
-            //{
-            //    wheelbaseAnim();
-            //});
-            //Task.Factory.StartNew(() =>
-            //{
-            //    autoCycling();
-            //});
+            //模拟plc与激光自动操作
+            Task.Factory.StartNew(() =>
+            {
+                laserAnim();
+            });
+            Task.Factory.StartNew(() =>
+            {
+                wheelbaseAnim();
+            });
+            Task.Factory.StartNew(() =>
+            {
+                autoCycling();
+            });
         }
 
         /// <summary>

+ 13 - 0
parkMonitor/controlPanel/ControlPanel.Designer.cs

@@ -36,6 +36,7 @@
             this.btn_reInit = new System.Windows.Forms.Button();
             this.btn_pause = new System.Windows.Forms.Button();
             this.btn_recover = new System.Windows.Forms.Button();
+            this.btn_PLC = new System.Windows.Forms.Button();
             this.SuspendLayout();
             // 
             // btn_refresh
@@ -115,11 +116,22 @@
             this.btn_recover.UseVisualStyleBackColor = true;
             this.btn_recover.Click += new System.EventHandler(this.btn_recover_Click);
             // 
+            // btn_PLC
+            // 
+            this.btn_PLC.Location = new System.Drawing.Point(151, 172);
+            this.btn_PLC.Name = "btn_PLC";
+            this.btn_PLC.Size = new System.Drawing.Size(75, 23);
+            this.btn_PLC.TabIndex = 11;
+            this.btn_PLC.Text = "重连PLC";
+            this.btn_PLC.UseVisualStyleBackColor = true;
+            this.btn_PLC.Click += new System.EventHandler(this.btn_PLC_Click);
+            // 
             // ControlPanel
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(369, 242);
+            this.Controls.Add(this.btn_PLC);
             this.Controls.Add(this.btn_recover);
             this.Controls.Add(this.btn_pause);
             this.Controls.Add(this.btn_reInit);
@@ -144,5 +156,6 @@
         private System.Windows.Forms.Button btn_reInit;
         private System.Windows.Forms.Button btn_pause;
         private System.Windows.Forms.Button btn_recover;
+        private System.Windows.Forms.Button btn_PLC;
     }
 }

+ 5 - 0
parkMonitor/controlPanel/ControlPanel.cs

@@ -136,5 +136,10 @@ namespace parkMonitor.controlPanel
             EntityForCore.ins.globalStatus = true;
             UILogServer.ins.warn("处理流程已恢复");
         }
+
+        private void btn_PLC_Click(object sender, EventArgs e)
+        {
+
+        }
     }
 }

+ 20 - 0
parkMonitor/server/CoreThread/CoreThreadTest2.cs

@@ -124,6 +124,26 @@ namespace parkMonitor.server.CoreThread
                         {
                             if (EntityForCore.ins.globalStatus)
                             {
+                                //UILogServer.ins.info("停车流程:鄂A11111未获取激光数据,继续等待");
+                                //UILogServer.ins.error("激光1计算异常,重新测量");
+                                //UILogServer.ins.error("激光1计算异常超过重测次数,请检查");
+                                //UILogServer.ins.error("鄂A11111缓冲位已满");
+                                //UILogServer.ins.info("无空闲机械手资源,继续等待");
+                                //UILogServer.ins.info("未获取轮距雷达完成状态,继续等待");
+                                //UILogServer.ins.info("停车流程:鄂A11111未获得停车完成信号1,继续等待");
+                                //UILogServer.ins.info("停车流程:鄂A11111未获得停车完成信号0,继续等待");
+
+                                //UILogServer.ins.error("无法获取车辆信息");
+                                //UILogServer.ins.error("车位分配出现异常!!!");
+                                //UILogServer.ins.info("取车流程:鄂A11111未获得取车完成信号1,继续等待");
+                                //UILogServer.ins.info("取车流程:鄂A11111未获得取车完成信号0,继续等待");
+
+                                //UILogServer.ins.warn("从web收到无法识别的用户指令,并非停取车");
+                                //UILogServer.ins.error("用户指令异常");
+
+                                //UILogServer.ins.log("用户1指令鄂A11111已存在超过10.1分钟 ,强制出队");
+                                //UILogServer.ins.log("号牌 鄂A11111 已扫描超过10.1分钟 ,强制出队");
+
                                 queueCmd = (Command)queuingThread.GetMessage();
                                 if (queueCmd != null)
                                 {

+ 14 - 2
parkMonitor/server/CoreThread/QueuingThread.cs

@@ -159,6 +159,10 @@ namespace parkMonitor.server.CoreThread
                                 BookParkingQueue.Enqueue(cmd);
                             }
                         }
+                    }else if (cmd.commandType.Equals('0'))
+                    {
+                        UILogServer.ins.info("收到web心跳");
+                        Log.WriteLog(LogType.NOT_DATABASE, LogFile.INFO, "收到web心跳");
                     }
                     else
                     {
@@ -446,8 +450,16 @@ namespace parkMonitor.server.CoreThread
                     }
                     else
                     {
-                        UILogServer.ins.info("任务:存入号牌为 " + cmd.LicenseNum + " 的车辆,开始排队");
-                        Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "停车命令:" + cmd.LicenseNum + "已进入可执行队列");
+                        if (cmd.commandType.Equals('s'))
+                        {
+                            UILogServer.ins.info("任务:存入号牌为 " + cmd.LicenseNum + " 的车辆,开始排队");
+                            Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "停车命令:" + cmd.LicenseNum + "已进入可执行队列");
+                        }
+                        else if(cmd.commandType.Equals('e'))
+                        {
+                            UILogServer.ins.info("任务:超时指令处理 " + cmd.LicenseNum + " ,开始排队");
+                            Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "停车指令超时:" + cmd.LicenseNum);
+                        }
                         ExecutableCmdQueue.Enqueue((Command)cmd.Clone());
                     }
                 }

+ 3 - 2
parkMonitor/server/NumMachine/ParkingSimul.cs

@@ -17,7 +17,7 @@ namespace parkMonitor.server.NumMachine
     class ParkingSimul
     {
         public static ParkingSimul ins;
-        private const string hostname = "192.168.0.197";
+        private const string hostname = "192.168.0.198";
         private const int port = 9000;
         private const string userId = "18202736439";
         private const string garageId = "1";
@@ -117,7 +117,8 @@ namespace parkMonitor.server.NumMachine
         public void Run()
         {
             int cycleCount = 2;
-            while (cycleCount-->0)
+            //while (cycleCount-->0)
+            while(true)
             {
                 rnd = new Random(DateTime.Now.Millisecond);
                 if (numStatusMap.Count > 0)

+ 50 - 41
parkMonitor/server/PLCLinker/PLCLinker.cs

@@ -339,35 +339,9 @@ namespace parkMonitor.server
                 }
                 else
                 {
-                    //plc掉线则将系统暂停
-                    EntityForCore.ins.globalStatus = false;
-                    if (linkCount-- >= 0)
+                    if (EntityForCore.ins.globalStatus)
                     {
-                        Task.Factory.StartNew(() =>
-                        {
-                            MyTimer mt = new MyTimer();
-                            mt.StartTiming();
-                            while (!isClosing)
-                            {
-                                mt.EndTiming();
-                                int count;
-                                if (mt.IsLonger(1, 1, true, out count))
-                                {
-                                    //断线后只显示一次
-                                    UILogServer.ins.warn("尝试重连PLC");
-                                    Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "PLC重连中,请稍候。。。。。。");
-                                }
-                                LinkStart();
-                                Thread.Sleep(10000);
-                                if (isConnection)
-                                {
-                                    EntityForCore.ins.globalStatus = true;
-                                    linkCount = 0;
-                                    break;
-                                }
-                            }
-                        });
-                        linkCount = -1;
+                        Reconnect();
                     }
                 }
             }
@@ -377,6 +351,41 @@ namespace parkMonitor.server
             }
         }
 
+        private void Reconnect()
+        {
+            //plc掉线则将系统暂停
+            EntityForCore.ins.globalStatus = false;
+            //if (linkCount-- >= 0)
+            //{
+            linkCount = 10;
+            Task.Factory.StartNew(() =>
+            {
+                MyTimer mt = new MyTimer();
+                mt.StartTiming();
+                while (linkCount-- > 0)
+                {
+                    mt.EndTiming();
+                    int count;
+                    if (mt.IsLonger(1, 1, true, out count))
+                    {
+                        //断线后只显示一次
+                        UILogServer.ins.warn("暂停系统,尝试重连PLC");
+                        Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "PLC重连中,请稍候。。。。。。");
+                    }
+                    LinkStart();
+                    Thread.Sleep(10000);
+                    if (isConnection)
+                    {
+                        EntityForCore.ins.globalStatus = true;
+                        linkCount = 10;
+                        break;
+                    }
+                }
+            }).Wait();
+            //linkCount = -1;
+            //}
+        }
+
         /// <summary>
         /// 从PLC读取数据
         /// </summary>
@@ -854,19 +863,19 @@ namespace parkMonitor.server
                 }
             });
 
-            ////模拟plc与激光自动操作
-            //Task.Factory.StartNew(() =>
-            //{
-            //    laserAnim();
-            //});
-            //Task.Factory.StartNew(() =>
-            //{
-            //    wheelbaseAnim();
-            //});
-            //Task.Factory.StartNew(() =>
-            //{
-            //    autoCycling();
-            //});
+            //模拟plc与激光自动操作
+            Task.Factory.StartNew(() =>
+            {
+                laserAnim();
+            });
+            Task.Factory.StartNew(() =>
+            {
+                wheelbaseAnim();
+            });
+            Task.Factory.StartNew(() =>
+            {
+                autoCycling();
+            });
         }
 
         /// <summary>