浏览代码

激光重测调整,去除锁。号牌机筛选功能调整。

yct 7 年之前
父节点
当前提交
200d9690da
共有 2 个文件被更改,包括 67 次插入66 次删除
  1. 30 18
      parkMonitor/server/NumMachine/NumMachine.cs
  2. 37 48
      parkMonitor/server/PLCLinker/PLCLinker.cs

+ 30 - 18
parkMonitor/server/NumMachine/NumMachine.cs

@@ -535,15 +535,21 @@ namespace parkMonitor.server
             int count = 0;
             if (filter.ContainsKey(nmn) && filter.TryGetValue(nmn, out count))//存在则数量+1
             {
-                filter.Remove(nmn);
-                filter.Add(nmn, count + 1);
+                filter[nmn] = count + 1;
             }
             else//不存在则计数1
             {
                 filter.Add(nmn, 1);
             }
 
-            filterCount += 1;
+            //计算总数
+            filterCount =0;
+            Dictionary<NumberMachineNode, int>.Enumerator countEnumer = filter.GetEnumerator();
+            do
+            {
+                filterCount += countEnumer.Current.Value;
+            } while (countEnumer.MoveNext());
+            
             //达到计数限制,计算众数是否达标,达标则入队
             if (filterCount >= FILTERINGNUMBER)
             {
@@ -655,18 +661,24 @@ namespace parkMonitor.server
                 Run();
             });
 
-            //Task imgTest = Task.Factory.StartNew(() =>
-            //{
-            //    while (!isClosing)
-            //    {
-            //        Command cmd = new Command
-            //        {
-            //            id = 1
-            //        };
-            //        SetMessage(cmd);
-            //        Thread.Sleep(3000000);
-            //    }
-            //});
+            Task imgTest = Task.Factory.StartNew(() =>
+            {
+                while (!isClosing)
+                {
+                    Command cmd = new Command
+                    {
+                        id = 1
+                    };
+                    SetMessage(cmd);
+                    Thread.Sleep(30000);
+                    Command cmd2 = new Command
+                    {
+                        id = 2
+                    };
+                    SetMessage(cmd2);
+                    Thread.Sleep(30000);
+                }
+            });
 
         }
 
@@ -691,9 +703,9 @@ namespace parkMonitor.server
                 isClosing = true;
                 devPicMap.Clear();
             }
-            lock (namePicMap) { namePicMap.Clear();}
-            lock (ipIdMap) { ipIdMap.Clear();}
-            lock (ipHandleMap) { ipHandleMap.Clear();}
+            lock (namePicMap) { namePicMap.Clear(); }
+            lock (ipIdMap) { ipIdMap.Clear(); }
+            lock (ipHandleMap) { ipHandleMap.Clear(); }
             //this.Close();
         }
 

+ 37 - 48
parkMonitor/server/PLCLinker/PLCLinker.cs

@@ -899,18 +899,15 @@ namespace parkMonitor.server
         /// <param name="value"></param>
         public void UpdateLaserStatus(int addr, int value)
         {
-            if (enable_status_check)
+            int status_addr = laser_status_address;
+            if (addr == status_addr)
             {
-                int status_addr = laser_status_address;
-                if (addr == status_addr)
+                laserMsg.status = value;
+                //UILogServer.ins.log(value.ToString());
+                //系统异常状态复位
+                if (value != 5 && disordered)
                 {
-                    laserMsg.status = value;
-                    //UILogServer.ins.log(value.ToString());
-                    //系统异常状态复位
-                    if (value != 5 && disordered)
-                    {
-                        disordered = false;
-                    }
+                    disordered = false;
                 }
             }
         }
@@ -982,53 +979,45 @@ namespace parkMonitor.server
                                 }
                                 if (plc != null)
                                 {
-                                    lock (laserMsg)
+                                    laser_rescan_countdown--;
+                                    //停车指令置0
+                                    PLCNode pn = new PLCNode(laser_start_address.ToString(), "0");
+                                    plc.SetMessage(pn);
+                                    //未终止重测,车未开走,停车指令归零后置1
+                                    if (!laserMsg.abort_rescan)
                                     {
-                                        laser_rescan_countdown--;
-                                        //停车指令置0
-                                        PLCNode pn = new PLCNode(laser_start_address.ToString(), "0");
-                                        plc.SetMessage(pn);
-                                        //未终止重测,车未开走,停车指令归零后置1
-                                        if (!laserMsg.abort_rescan)
+                                        UILogServer.ins.error("激光" + laserMsg.id + "计算异常,重新测量");
+                                        //重测检测心跳
+                                        Task rescan_wait_heartbeat = Task.Factory.StartNew(() =>
                                         {
-                                            UILogServer.ins.error("激光" + laserMsg.id + "计算异常,重新测量");
-                                            //重测检测心跳
-                                            Task rescan_wait_heartbeat = Task.Factory.StartNew(() =>
+                                            MyTimer mt = new MyTimer();
+                                            mt.StartTiming();
+                                            while (laserMsg.status != 254 && laserMsg.status != 255)
                                             {
-                                                MyTimer mt = new MyTimer();
-                                                mt.StartTiming();
-                                                while (laserMsg.status != 254 && laserMsg.status != 255)
+                                                Thread.Sleep(1000);
+                                                mt.EndTiming();
+                                                int activationCount = 0;
+                                                if (mt.IsLonger(15, 1, false, out activationCount))
                                                 {
-                                                    Thread.Sleep(1000);
-                                                    mt.EndTiming();
-                                                    int activationCount = 0;
-                                                    if (mt.IsLonger(15, 1, false, out activationCount))
+                                                    if (activationCount == 1)
                                                     {
-                                                        if (activationCount == 1)
-                                                        {
-                                                            UILogServer.ins.info("重测前未获得心跳,继续等待");
-                                                        }
-                                                        if (MyTimer.restart && !mt.rolledBack)
-                                                        {
-                                                            mt.rolledBack = true;
-                                                            UILogServer.ins.error("发起重测前超时未能获取摆扫激光心跳,请检查设备");
-                                                        }
+                                                        UILogServer.ins.info("重测前未获得心跳,继续等待");
+                                                    }
+                                                    if (MyTimer.restart && !mt.rolledBack)
+                                                    {
+                                                        mt.rolledBack = true;
+                                                        UILogServer.ins.error("发起重测前超时未能获取摆扫激光心跳,请检查设备");
                                                     }
                                                 }
-                                            });
-                                            UILogServer.ins.log("获得心跳,准备发起重测");
-                                            rescan_wait_heartbeat.Wait();
-                                            pn = new PLCNode(laser_start_address.ToString(), "1");
-                                            plc.SetMessage(pn);
-                                            laserMsg.status = value;
-                                        }
-                                        else
-                                        {
-                                            laserMsg.status = 6;
-                                        }
+                                            }
+                                        });
+                                        UILogServer.ins.log("获得心跳,准备发起重测");
+                                        rescan_wait_heartbeat.Wait();
+                                        pn = new PLCNode(laser_start_address.ToString(), "1");
+                                        plc.SetMessage(pn);
                                     }
-                                    Thread.Sleep(500);
                                 }
+                                Thread.Sleep(500);
                                 enable_status_check = true;
                             });
                         }