yct %!s(int64=7) %!d(string=hai) anos
pai
achega
b151c7d9a7

+ 4 - 0
packages/repositories.config

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<repositories>
+  <repository path="..\parkMonitor\packages.config" />
+</repositories>

+ 1 - 1
parkMonitor/App.config

@@ -21,7 +21,7 @@
     <add key="SqlConnectionStr" value="Data Source=59.175.148.85;port=3306;uid=root;pooling=true;pwd=x5;database=zxpark;CharSet=utf8;Allow Zero Datetime=true;" />
     <add key="localGarageId" value="1"/>
     <!--日志写入地址配置文件-->
-    <add key="LogPath" value="E:\\c#workspace\\LogDemo\\LoggerTest" />
+    <add key="LogPath" value="c:\\c#workspace\\LogDemo\\LoggerTest" />
     <!--测量数据误差-->
     <add key="length" value="50" />
     <add key="width" value="50" />

+ 8 - 2
parkMonitor/DB/DBOperation.cs

@@ -171,7 +171,10 @@ namespace parkMonitor.DB
             {
                 con.Open();
                 cmd = oper.getComm(sql, con);
-                reader = oper.getResultSet(cmd);
+                while (reader == null)
+                {
+                    reader = oper.getResultSet(cmd);
+                }
                 while (reader.Read())
                 {
                     if (reader.HasRows)
@@ -593,7 +596,10 @@ namespace parkMonitor.DB
             {
                 con.Open();
                 cmd = oper.getComm(sql, con);
-                reader = oper.getResultSet(cmd);
+                while (reader == null)
+                {
+                    reader = oper.getResultSet(cmd);
+                }
                 while (reader.Read())
                 {
                     if (reader.HasRows)

+ 36 - 10
parkMonitor/server/CoreThread/AbstractCmd.cs

@@ -78,9 +78,9 @@ namespace parkMonitor.server.CoreThread
         public void WaitForRobotResource(int robotID)
         {
             PLCMessage PLCMsg = null;
-            while (true)
+            lock (robot)
             {
-                lock (robot)
+                while (true)
                 {
                     PLCMsg = (PLCMessage)PLC.GetMessage();
                     bool occupied = false;
@@ -93,7 +93,7 @@ namespace parkMonitor.server.CoreThread
                                 robot.parking_start_value = Convert.ToInt32(PLCMsg.originalPlcList[parking_startRobot_address].Value);
                                 robot.fetching_start_value = Convert.ToInt32(PLCMsg.originalPlcList[fetching_startRobot_address].Value);
                                 //刷新机械手资源状态值
-                                if (robot.parking_start_value == 0 && robot.fetching_start_value == 0)
+                                if (robot.parking_start_value == 0 && robot.fetching_start_value == 0 && !robot.occupied)
                                 {
                                     occupied = false;
                                 }
@@ -111,6 +111,7 @@ namespace parkMonitor.server.CoreThread
                     }
                     else
                     {
+                        robot.occupied = true;
                         break;
                     }
                 }
@@ -259,7 +260,7 @@ namespace parkMonitor.server.CoreThread
         /// <summary>
         /// 停车完成
         /// </summary>
-        private void WaitForStoreSignal(Command queueCmd, ref int parkingSpaceID, ref bool robotError)
+        private void WaitForStoreSignal(Command queueCmd, ref int parkingSpaceID, ref bool robotError, int status)
         {
             PLCMessage PLCMsg = null;
             while (true)
@@ -268,7 +269,7 @@ namespace parkMonitor.server.CoreThread
                 PLCMsg = (PLCMessage)PLC.GetMessage();
                 int storeStatus = Convert.ToInt32(PLCMsg.originalPlcList[park_completed_address].Value);
                 //停车完成信号
-                if (storeStatus == 1)
+                if (storeStatus == status)
                 {
                     break;
                 }
@@ -403,6 +404,9 @@ namespace parkMonitor.server.CoreThread
             UILogServer.ins.log("停止核对,准备启动机械手");
             int robotID = 0;
             robotID = queueCmd.id / 3 + 1;
+
+            int frontWheelbase = 0;
+            int rearWheelbase = 0;
             Task robotFree = Task.Factory.StartNew(() =>
             {
                 //需要先遍历robot数组,根据id找到对应机械手
@@ -429,16 +433,14 @@ namespace parkMonitor.server.CoreThread
             Log.WriteLog("停车,抓车:" + queueCmd.LicenseNum);
             UILogServer.ins.info("停车,抓车:" + queueCmd.LicenseNum);
 
-            int frontWheelbase = 0;
-            int rearWheelbase = 0;
             Task dataFromWheelbase = Task.Factory.StartNew(() =>
             {
-                WaitWheelbase(ref frontWheelbase,ref rearWheelbase);
+                WaitWheelbase(ref frontWheelbase, ref rearWheelbase);
             });
-            
+
             Task storeSignal = Task.Factory.StartNew(() =>
             {
-                WaitForStoreSignal(queueCmd, ref parkingSpaceID, ref robotError);
+                WaitForStoreSignal(queueCmd, ref parkingSpaceID, ref robotError, 1);
             });
             //storeSignal.Wait();
             Task.WaitAll(dataFromWheelbase, storeSignal);
@@ -446,6 +448,12 @@ namespace parkMonitor.server.CoreThread
             status = 3;
             cm.status = status;
             PLC.SetMessage(cm);
+            Task storeResetSignal = Task.Factory.StartNew(() =>
+            {
+                WaitForStoreSignal(queueCmd, ref parkingSpaceID, ref robotError, 0);
+            });
+            storeResetSignal.Wait();
+            robot.occupied = false;
             //机械手异常则跳出
             if (robotError)
             {
@@ -619,6 +627,24 @@ namespace parkMonitor.server.CoreThread
             //先手动赋值
             cm2.RobotID = 1;
             PLC.SetMessage(cm2);
+            Task signalResetFromPLC = Task.Factory.StartNew(() =>
+            {
+                while (true)
+                {
+                    Thread.Sleep(2000);
+                    PLCMsg = (PLCMessage)PLC.GetMessage();
+                    int fetchingStatus = Convert.ToInt32(PLCMsg.originalPlcList[fetch_completed_address].Value);
+                    //取车完成复位信号
+                    if (fetchingStatus == 0)
+                    {
+                        //取车完成后或可归零
+                        break;
+                    }
+                }
+            });
+            //Task.WaitAll(signalFromPLC);
+            signalResetFromPLC.Wait();
+            robot.occupied = false;
             Console.WriteLine("号牌:" + queueCmd.LicenseNum + "取车完成");
             Log.WriteLog("号牌:" + queueCmd.LicenseNum + "取车完成");
             UILogServer.ins.info("号牌:" + queueCmd.LicenseNum + "取车完成");

+ 5 - 0
parkMonitor/server/CoreThread/Robot.cs

@@ -13,5 +13,10 @@ namespace parkMonitor.server.CoreThread
         public int parking_start_value { get; set; }
         public int fetching_start_addr { get; set; }
         public int fetching_start_value { get; set; }
+        public bool occupied { get; set; }
+        public Robot()
+        {
+            occupied = false;
+        }
     }
 }

+ 13 - 13
parkMonitor/server/NumMachine/NumMachine.cs

@@ -493,7 +493,7 @@ namespace parkMonitor.server
                     do
                     {
                         //遍历,筛到号牌则入队
-                        if (enumer.Current.Value >= (int)(filterCount * 0.8) && enumer.Current.Key != null && !LicBuffer.Contains(enumer.Current.Key))
+                        if (enumer.Current.Value >= (int)(filterCount * 0.5) && enumer.Current.Key != null && !LicBuffer.Contains(enumer.Current.Key))
                         {
                             if (nmMsg.aNode == null || nmMsg.aNode.LicenseNum == null || nmMsg.aNode.LicenseNum != enumer.Current.Key.LicenseNum)
                             {
@@ -634,18 +634,18 @@ namespace parkMonitor.server
                 Run();
             });
 
-            //Task imgTest = Task.Factory.StartNew(() =>
-            //{
-            //    while (!isClosing)
-            //    {
-            //        Command cmd = new Command
-            //        {
-            //            id = 1
-            //        };
-            //        SetMessage(cmd);
-            //        Thread.Sleep(5000);
-            //    }
-            //});
+            Task imgTest = Task.Factory.StartNew(() =>
+            {
+                while (!isClosing)
+                {
+                    Command cmd = new Command
+                    {
+                        id = 1
+                    };
+                    SetMessage(cmd);
+                    Thread.Sleep(3000000);
+                }
+            });
 
         }
 

+ 24 - 17
parkMonitor/server/PLCLinker/PLCLinker.cs

@@ -97,7 +97,7 @@ namespace parkMonitor.server
                 parkingLaserCenterX_address = Int32.Parse(ConfigurationManager.AppSettings.Get("parkingLaserCenterX_address"));
                 parkingSpaceID_address = Int32.Parse(ConfigurationManager.AppSettings.Get("parkingSpaceID_address"));
                 park_completed_address = Int32.Parse(ConfigurationManager.AppSettings.Get("park_completed_address"));
-                park_completed_acknowledge_address = Int32.Parse(ConfigurationManager.AppSettings.Get("park_completed_acknowledge_address")); 
+                park_completed_acknowledge_address = Int32.Parse(ConfigurationManager.AppSettings.Get("park_completed_acknowledge_address"));
 
                 fetching_startRobot_address = Int32.Parse(ConfigurationManager.AppSettings.Get("fetching_startRobot_address"));
                 fetch_to_address = Int32.Parse(ConfigurationManager.AppSettings.Get("fetch_to_address"));
@@ -108,7 +108,7 @@ namespace parkMonitor.server
 
                 laser_start_address = Int32.Parse(ConfigurationManager.AppSettings.Get("park_command_address"));
 
-                rpu1 = new RobotProcessUnit(1, parking_startRobot_address, parkingLaserCenterX_address, parkingSpaceID_address, park_completed_address, park_completed_acknowledge_address, fetching_startRobot_address, fetch_to_address, fetch_completed_address,fetch_completed_acknowledge_address, frontWheelbase_address, rearWheelbase_address);
+                rpu1 = new RobotProcessUnit(1, parking_startRobot_address, parkingLaserCenterX_address, parkingSpaceID_address, park_completed_address, park_completed_acknowledge_address, fetching_startRobot_address, fetch_to_address, fetch_completed_address, fetch_completed_acknowledge_address, frontWheelbase_address, rearWheelbase_address);
 
                 //激光管理
                 for (int i = 1; i < 20; i++)
@@ -187,7 +187,7 @@ namespace parkMonitor.server
                 }
             }
             json = JsonHelper.SerializeObject(return_Value);//序列化     
-                                                            //List<PLCValue> prv = JsonHelper.DeserializeJsonToList<PLCValue>(json);
+            //List<PLCValue> prv = JsonHelper.DeserializeJsonToList<PLCValue>(json);
 
             //Console.WriteLine(json);
         }
@@ -466,8 +466,9 @@ namespace parkMonitor.server
                     foreach (PLCNode node in plcMsg.originalPlcList)
                     {
                         //判断激光空闲状态
-                        if (node.Address.Equals(lpuTemp.laser_status_address.ToString()) && (node.Value.Equals("254") || node.Value.Equals("255")))
+                        if (node.Address.Equals(lpuTemp.laser_status_address.ToString()) && (node.Value.Equals("254") || node.Value.Equals("255")) && !lpuTemp.occupied)
                         {
+                            lpuTemp.occupied = true;
                             jumpOut = true;
                             break;
                         }
@@ -534,21 +535,24 @@ namespace parkMonitor.server
                                 }
                                 if (laser_start_addr == "")
                                     return;
-
-                                WaitForLaserReady(lpuTemp);
-                                SendtoPLC(laser_start_addr, "0");
-                                foreach (LaserMessage lm in plcMsg.laserMsgList)
+                                lock (lpuTemp)
                                 {
-                                    if (lm.id == lpuTemp.id)
+                                    WaitForLaserReady(lpuTemp);
+                                    SendtoPLC(laser_start_addr, "0");
+
+                                    foreach (LaserMessage lm in plcMsg.laserMsgList)
                                     {
-                                        lm.status = 6;
-                                        break;
+                                        if (lm.id == lpuTemp.id)
+                                        {
+                                            lm.status = 6;
+                                            break;
+                                        }
                                     }
+                                    Thread.Sleep(300);
+                                    SendtoPLC(laser_start_addr, "1");
+                                    Thread.Sleep(100);
+                                    SendtoPLC("1", "1");//停车指令置1
                                 }
-                                Thread.Sleep(300);
-                                SendtoPLC(laser_start_addr, "1");
-                                Thread.Sleep(100);
-                                SendtoPLC("1", "1");//停车指令置1
                             });
                             //Console.WriteLine("扫摆激光启动");
                             break;
@@ -700,8 +704,9 @@ namespace parkMonitor.server
         public int laser_start_address { get; set; }
         public int laser_status_address { get; set; }
         public int id { get; set; }
+        public bool occupied { get; set; }
         private int LASER_RESCAN_COUNT, LASER_HEARTBEAT_PERIOD, laser_rescan_countdown, laser_heartbeat_countdown;
-        private bool laser_record, laser_heartbeat_test, enable_status_check = true,disconnected = false;
+        private bool laser_record, laser_heartbeat_test, enable_status_check = true, disconnected = false;
         private HashSet<int> laser_heartbeat = new HashSet<int>();
         private IEquipments plc = null;
         public LaserMessage laserMsg = new LaserMessage();
@@ -713,6 +718,7 @@ namespace parkMonitor.server
                 laserMsg.id = id;
                 this.id = id;
                 laserMsg.status = 6;
+                occupied = false;
                 this.laser_start_address = park_command_address;
                 this.laser_status_address = laser_status_address;
                 LASER_RESCAN_COUNT = laser_rescan_count;
@@ -895,6 +901,7 @@ namespace parkMonitor.server
                                 laserMsg.data.height = value;
                         }
                         laserMsg.recorded = true;
+                        occupied = false;
                         //Console.WriteLine("激光测量数据已记录");
                     }
                 }
@@ -925,7 +932,7 @@ namespace parkMonitor.server
         public int frontWheelbase { get; set; }
         public int rearWheelbase { get; set; }
 
-        public RobotProcessUnit(int id, int parking_startRobot_address, int parking_laserCenterX_address, int parkingSpaceID_address, int park_completed_address,int park_completed_acknowledge_address, int fetching_startRobot_address, int fetch_to_address, int fetch_completed_address,int fetch_completed_acknowledge_address, int frontWheelbase, int rearWheelbase)
+        public RobotProcessUnit(int id, int parking_startRobot_address, int parking_laserCenterX_address, int parkingSpaceID_address, int park_completed_address, int park_completed_acknowledge_address, int fetching_startRobot_address, int fetch_to_address, int fetch_completed_address, int fetch_completed_acknowledge_address, int frontWheelbase, int rearWheelbase)
         {
             this.id = id;
             this.parking_startRobot_address = parking_startRobot_address;

+ 2 - 2
parkMonitor/server/monitorServer/MonitorServer.cs

@@ -36,9 +36,9 @@ namespace parkMonitor.server {
 
 	/// <summary>监控线程服务</summary>
 	public class MonitorServer : IEquipments {
-		public int maxShowItemCount = 3;    //最大可显示的项数量
+		public int maxShowItemCount = 4;    //最大可显示的项数量
 		public int minTimeGap = 200;        //最小更新频率
-		public int timeGap = 2000;          //更新频率
+		public int timeGap = 200;          //更新频率
 		public ObjectItemVM selectTreeVM = null;//选中项
 		public ObservableCollection<DevDetailItemVM> lastDetailVM = null;   //选中项的详细信息
 

+ 1 - 0
parkMonitor/view/mainWin/MainWindow.xaml.cs

@@ -191,6 +191,7 @@ namespace parkMonitor
             if (win.isOk)
             {
                 Close();
+                System.Environment.Exit(0);
             }
         }
 

+ 1 - 0
parkMonitor/view/menuBox/MenuBox.xaml.cs

@@ -73,6 +73,7 @@ namespace parkMonitor.view.util {
 
 			if(win.isOk) {
 				mainWin.Close();
+                System.Environment.Exit(0);
 			}
 		}