소스 검색

Merge remote-tracking branch 'anonymous/dev' into dev

# Conflicts:
#	parkMonitor/server/CoreThread/AbstractCmd.cs
#	parkMonitor/server/PLCLinker/PLCLinker.cs
yc_t 7 년 전
부모
커밋
0e5c7a4399

+ 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)

+ 29 - 4
parkMonitor/server/CoreThread/AbstractCmd.cs

@@ -99,7 +99,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;
                                 }
@@ -333,7 +333,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)
                 {
                     UILogServer.ins.log("已获得停车完成信号");
                     break;
@@ -522,6 +522,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找到对应机械手
@@ -548,8 +551,6 @@ 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);
@@ -565,6 +566,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)
             {
@@ -767,6 +774,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

@@ -523,7 +523,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)
                             {
@@ -622,18 +622,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 - 16
parkMonitor/server/PLCLinker/PLCLinker.cs

@@ -85,7 +85,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"));
@@ -96,7 +96,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++)
@@ -175,7 +175,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);
         }
@@ -457,8 +457,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;
                             UILogServer.ins.log("获取摆扫激光空闲状态,准备启动激光");
                             break;
@@ -539,20 +540,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;
@@ -707,8 +712,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();
@@ -720,6 +726,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;
@@ -908,6 +915,7 @@ namespace parkMonitor.server
                                 laserMsg.data.height = value;
                         }
                         laserMsg.recorded = true;
+                        occupied = false;
                         UILogServer.ins.info("摆扫激光测量数据已记录");
                     }
                 }
@@ -938,7 +946,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;   //选中项的详细信息