瀏覽代碼

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

yc_t 7 年之前
父節點
當前提交
d87667c219

二進制
modbus_PLC_laser_test/新plc模拟.mbs


+ 2 - 2
parkMonitor/App.config

@@ -16,7 +16,7 @@
   </Equipments>
   <appSettings>
     <!--数据库连接配置文件-->
-    <add key="SqlConnectionLocation" value="Data Source=127.0.0.1;port=3306;uid=root;pooling=true;pwd=jingwang1995;database=zxpark;CharSet=utf8;Allow Zero Datetime=true;" />
+    <add key="SqlConnectionLocation" value="Data Source=127.0.0.1;port=20000;uid=root;pooling=true;pwd=jingwang1995;database=zxpark;CharSet=utf8;Allow Zero Datetime=true;" />
     <!--<add key="SqlConnectionStr" value="Data Source=52.77.33.102;port=3306;uid=Ubuntu1;pooling=true;pwd=12345678;database=zxpark;CharSet=utf8;Allow Zero Datetime=true;" />-->
 <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;" /> 
 <!--日志写入地址配置文件-->
@@ -64,7 +64,7 @@
     <add key="licenseTime" value="30" />
     <add key="userTime" value="30" />
     <!--上位机(Web线程)IP地址及配置serverScoket的端口-->
-    <add key="WebConfig" value="192.168.111.254:9000" />
+    <add key="WebConfig" value="192.168.111.84:9000" />
     <!--<add key ="WebConfig" value="127.0.0.1:9000"/>-->
 
     <!--车库入口-->

+ 26 - 17
parkMonitor/DB/DBOperation.cs

@@ -36,6 +36,7 @@ namespace parkMonitor.DB
                 }
                 if (reader != null)
                 {
+                    reader.Close();
                     reader.Dispose();
                 }
                 if (cmd != null)
@@ -44,7 +45,7 @@ namespace parkMonitor.DB
                 }
                 if (con != null)
                 {
-                    //con.Close();
+                    con.Close();
                     con.Dispose();
                 }
             }
@@ -84,6 +85,7 @@ namespace parkMonitor.DB
                 }
                 if (reader != null)
                 {
+                    reader.Close();
                     reader.Dispose();
                 }
                 if (cmd != null)
@@ -92,7 +94,7 @@ namespace parkMonitor.DB
                 }
                 if (con != null)
                 {
-                    //con.Close();
+                    con.Close();
                     con.Dispose();
                 }
             }
@@ -139,6 +141,7 @@ namespace parkMonitor.DB
                 }
                 if (reader != null)
                 {
+                    reader.Close();
                     reader.Dispose();
                 }
                 if (cmd != null)
@@ -147,7 +150,7 @@ namespace parkMonitor.DB
                 }
                 if (con != null)
                 {
-                    //con.Close();
+                    con.Close();
                     con.Dispose();
                 }
             }
@@ -194,6 +197,7 @@ namespace parkMonitor.DB
                 }
                 if (reader != null)
                 {
+                    reader.Close();
                     reader.Dispose();
                 }
                 if (cmd != null)
@@ -202,7 +206,7 @@ namespace parkMonitor.DB
                 }
                 if (con != null)
                 {
-                    //con.Close();
+                    con.Close();
                     con.Dispose();
                 }
             }
@@ -242,6 +246,7 @@ namespace parkMonitor.DB
                 }
                 if (reader != null)
                 {
+                    reader.Close();
                     reader.Dispose();
                 }
                 if (cmd != null)
@@ -250,7 +255,7 @@ namespace parkMonitor.DB
                 }
                 if (con != null)
                 {
-                    //con.Close();
+                    con.Close();
                     con.Dispose();
                 }
             }
@@ -274,12 +279,12 @@ namespace parkMonitor.DB
                 oper.getInsert(cmd);
                 parkingRecordsID = Convert.ToInt32(cmd.LastInsertedId);
                 if (cmd != null)
-                {
+                {                   
                     cmd.Dispose();
                 }
                 if (con != null)
                 {
-                    //con.Close();
+                    con.Close();
                     con.Dispose();
                 }
             }
@@ -306,7 +311,7 @@ namespace parkMonitor.DB
                 }
                 if (con != null)
                 {
-                    //con.Close();
+                    con.Close();
                     con.Dispose();
                 }
             }
@@ -337,6 +342,7 @@ namespace parkMonitor.DB
                 }
                 if (reader != null)
                 {
+                    reader.Close();
                     reader.Dispose();
                 }
                 if (cmd != null)
@@ -345,7 +351,7 @@ namespace parkMonitor.DB
                 }
                 if (con != null)
                 {
-                    //con.Close();
+                    con.Close();
                     con.Dispose();
                 }
             }
@@ -372,7 +378,7 @@ namespace parkMonitor.DB
                 }
                 if (con != null)
                 {
-                    //con.Close();
+                    con.Close();
                     con.Dispose();
                 }
             }
@@ -398,7 +404,7 @@ namespace parkMonitor.DB
                 }
                 if (con != null)
                 {
-                    //con.Close();
+                    con.Close();
                     con.Dispose();
                 }
             }
@@ -424,7 +430,7 @@ namespace parkMonitor.DB
                 }
                 if (con != null)
                 {
-                    //con.Close();
+                    con.Close();
                     con.Dispose();
                 }
             }
@@ -450,7 +456,7 @@ namespace parkMonitor.DB
                 }
                 if (con != null)
                 {
-                    //con.Close();
+                    con.Close();
                     con.Dispose();
                 }
             }
@@ -476,7 +482,7 @@ namespace parkMonitor.DB
                 }
                 if (con != null)
                 {
-                    //con.Close();
+                    con.Close();
                     con.Dispose();
                 }
             }
@@ -507,6 +513,7 @@ namespace parkMonitor.DB
                 }
                 if (reader != null)
                 {
+                    reader.Close();
                     reader.Dispose();
                 }
                 if (cmd != null)
@@ -515,7 +522,7 @@ namespace parkMonitor.DB
                 }
                 if (con != null)
                 {
-                    //con.Close();
+                    con.Close();
                     con.Dispose();
                 }
             }
@@ -555,6 +562,7 @@ namespace parkMonitor.DB
                 }
                 if (reader != null)
                 {
+                    reader.Close();
                     reader.Dispose();
                 }
                 if (cmd != null)
@@ -563,7 +571,7 @@ namespace parkMonitor.DB
                 }
                 if (con != null)
                 {
-                    //con.Close();
+                    con.Close();
                     con.Dispose();
                 }
             }
@@ -600,6 +608,7 @@ namespace parkMonitor.DB
                 }
                 if (reader != null)
                 {
+                    reader.Close();
                     reader.Dispose();
                 }
                 if (cmd != null)
@@ -608,7 +617,7 @@ namespace parkMonitor.DB
                 }
                 if (con != null)
                 {
-                    //con.Close();
+                    con.Close();
                     con.Dispose();
                 }
             }

+ 19 - 16
parkMonitor/DBLocation/DBLocation.cs

@@ -34,7 +34,7 @@ namespace parkMonitor.DBLocation
                 }
                 if (con != null)
                 {
-                    //con.Close();
+                    con.Close();
                     con.Dispose();
                 }
             }
@@ -63,7 +63,7 @@ namespace parkMonitor.DBLocation
                 }
                 if (con != null)
                 {
-                    //con.Close();
+                    con.Close();
                     con.Dispose();
                 }
             }
@@ -95,6 +95,7 @@ namespace parkMonitor.DBLocation
                 }
                 if (reader != null)
                 {
+                    reader.Close();
                     reader.Dispose();
                 }
                 if (cmd != null)
@@ -103,7 +104,7 @@ namespace parkMonitor.DBLocation
                 }
                 if (con != null)
                 {
-                    //con.Close();
+                    con.Close();
                     con.Dispose();
                 }
             }
@@ -135,6 +136,7 @@ namespace parkMonitor.DBLocation
                 }
                 if (reader != null)
                 {
+                    reader.Close();
                     reader.Dispose();
                 }
                 if (cmd != null)
@@ -143,7 +145,7 @@ namespace parkMonitor.DBLocation
                 }
                 if (con != null)
                 {
-                    //con.Close();
+                    con.Close();
                     con.Dispose();
                 }
             }
@@ -175,15 +177,16 @@ namespace parkMonitor.DBLocation
                 }
                 if (reader != null)
                 {
+                    reader.Close();
                     reader.Dispose();
                 }
                 if (cmd != null)
-                {
+                {                    
                     cmd.Dispose();
                 }
                 if (con != null)
                 {
-                    //con.Close();
+                    con.Close();
                     con.Dispose();
                 }
             }
@@ -215,7 +218,7 @@ namespace parkMonitor.DBLocation
                 }
                 if (con != null)
                 {
-                    //con.Close();
+                    con.Close();
                     con.Dispose();
                 }
             }
@@ -244,7 +247,7 @@ namespace parkMonitor.DBLocation
                 }
                 if (con != null)
                 {
-                    //con.Close();
+                    con.Close();
                     con.Dispose();
                 }
             }
@@ -271,7 +274,7 @@ namespace parkMonitor.DBLocation
                 }
                 if (con != null)
                 {
-                    //con.Close();
+                    con.Close();
                     con.Dispose();
                 }
             }
@@ -297,7 +300,7 @@ namespace parkMonitor.DBLocation
                 }
                 if (con != null)
                 {
-                    //con.Close();
+                    con.Close();
                     con.Dispose();
                 }
             }
@@ -323,7 +326,7 @@ namespace parkMonitor.DBLocation
                 }
                 if (con != null)
                 {
-                    //con.Close();
+                    con.Close();
                     con.Dispose();
                 }
             }
@@ -349,7 +352,7 @@ namespace parkMonitor.DBLocation
                 }
                 if (con != null)
                 {
-                    //con.Close();
+                    con.Close();
                     con.Dispose();
                 }
             }
@@ -375,7 +378,7 @@ namespace parkMonitor.DBLocation
                 }
                 if (con != null)
                 {
-                    //con.Close();
+                    con.Close();
                     con.Dispose();
                 }
             }
@@ -406,7 +409,7 @@ namespace parkMonitor.DBLocation
                 }
                 if (con != null)
                 {
-                    //con.Close();
+                    con.Close();
                     con.Dispose();
                 }
             }
@@ -433,7 +436,7 @@ namespace parkMonitor.DBLocation
                 }
                 if (con != null)
                 {
-                    //con.Close();
+                    con.Close();
                     con.Dispose();
                 }
             }
@@ -473,7 +476,7 @@ namespace parkMonitor.DBLocation
                 }
                 if (con != null)
                 {
-                    //con.Close();
+                    con.Close();
                     con.Dispose();
                 }
             }

+ 171 - 115
parkMonitor/server/CoreThread/AbstractCmd.cs

@@ -27,9 +27,9 @@ namespace parkMonitor.server.CoreThread
         public IEquipments queuingThread { set; get; }
         public DBOperation oper { set; get; }
         public IEquipments NumMachine { set; get; }
-        public CEntrance c { set; get; }
+        public CEntrance cEntrance { set; get; }
         public AllotParkingSpace aps { set; get; }
-        public abstract void executeCmd(Command queueCmd);
+
         public int parking_startRobot_address { get; set; }
         public int fetching_startRobot_address { get; set; }
         public DBLocationOperator locationOper { get; set; }
@@ -62,7 +62,7 @@ namespace parkMonitor.server.CoreThread
             //数据库
             oper = new DBOperation();
             //车位分配
-            c = new CEntrance();
+            cEntrance = new CEntrance();
             aps = new AllotParkingSpace();
             robot = new Robot()
             {
@@ -72,9 +72,10 @@ namespace parkMonitor.server.CoreThread
             };
             locationOper = new DBLocationOperator();
         }
-
-        public void WaitForRobotResource(PLCMessage PLCMsg, int robotID)
+        public abstract void executeCmd(Command queueCmd);
+        public void WaitForRobotResource( int robotID)
         {
+            PLCMessage PLCMsg = null;
             while (true)
             {
                 lock (robot)
@@ -162,17 +163,139 @@ namespace parkMonitor.server.CoreThread
             numberMachineMessage.aNode.LicenseNum = queueCmd.LicenseNum;
             queuingThread.SetMessage(numberMachineMessage);
         }
-
-        public override void executeCmd(Command queueCmd)
+        /// <summary>
+        /// 车位资源
+        /// </summary>
+        /// <param name="queueCmd"></param>
+        /// <returns></returns>
+        private Parking_Space WaitForParkingSpaceResource(Command queueCmd)
+        {
+            //中心点
+            cEntrance.parkingEntX = parkingEntX;
+            cEntrance.parkingEntY = parkingEntY;
+            cEntrance.parkingEntZ = parkingEntZ;
+            Parking_Space ppp = new Parking_Space();
+            while (true)
+            {
+                if (!queueCmd.manual)
+                {
+                    ppp = aps.MallocParkingSpace(cEntrance, oper);//自动
+                }
+                else
+                {
+                    ppp = aps.MallocParkingSpace(cEntrance, locationOper);//手动
+                }
+                if (ppp != null)
+                {
+                    break;
+                }
+                if (isClosing)
+                {
+                    break;
+                }
+                Thread.Sleep(200);
+            }
+            return ppp;
+        }
+        private Data WaitForLaserResource(Command queueCmd, bool disappeared)
         {
             //激光数据
-            int centerX = 0;
-            int centerY = 0;
-            int angleA = 0;
-            int length = 0;
-            int width = 0;
-            int height = 0;
+            Data data = new Data();      
+            bool jumpOut = false;
+            PLCMessage PLCMsg = null;
+            jumpOut = false;
+            while (true)
+            {
+                PLCMsg = (PLCMessage)PLC.GetMessage();
+                if (PLCMsg != null)
+                {
+                    foreach (LaserMessage lm in PLCMsg.laserMsgList)
+                    {
+                        if (lm.id == queueCmd.id && lm.data != null)
+                        {
+                            lock (lm)
+                            {
+                                //判断车辆检测结果,
+                                if (disappeared)
+                                {
+                                    lm.abort_rescan = true;
+                                    jumpOut = true;
+                                    break;
+                                }
+                                //存储相应激光数据
+                                if (lm.recorded)
+                                {
+                                    data.angleA = lm.data.angleA; 
+                                    data.centerX = lm.data.centerX;
+                                    data.centerY = lm.data.centerY;
+                                    data.length = lm.data.length;
+                                    data.width = lm.data.width;
+                                    data.height = lm.data.height;
+                                    jumpOut = true;
+                                    lm.recorded = false;
+                                    break;
+                                }
+                                else if (lm.status == -1)
+                                {
+                                    LogFile logFile = LogFile.ERROR;
+                                    UILogServer.ins.error("激光" + lm.id + "连接异常");
+                                    Log.WriteLog(logFile, "激光异常");
+                                    Thread.Sleep(5000);
+                                }
+                            }
+                        }
+                    }
+                    if (jumpOut)
+                    {
+                        break;
+                    }
+                }
+                Thread.Sleep(1000);
+            }
+            return data;
+        }
+        /// <summary>
+        /// 停车完成
+        /// </summary>
+        private void WaitForStoreSignal(Command queueCmd, ref int parkingSpaceID, ref int frontWheelbase, ref int rearWheelbase, ref bool robotError)
+        {
             PLCMessage PLCMsg = null;
+            while (true)
+            {
+                Thread.Sleep(1000);
+                PLCMsg = (PLCMessage)PLC.GetMessage();
+                int storeStatus = Convert.ToInt32(PLCMsg.originalPlcList[park_completed_address].Value);
+                //停车完成信号
+                if (storeStatus == 1)
+                {
+                    frontWheelbase = Convert.ToInt32(PLCMsg.originalPlcList[frontWheelbase_address].Value);
+                    rearWheelbase = Convert.ToInt32(PLCMsg.originalPlcList[rearWheelbase_address].Value);
+                    break;
+                }
+                else if (1 == 2)//机械手异常,则退指令,写数据库归位
+                {
+                    robotError = true;
+                    queueCmd.returnedCount += 1;
+                    queuingThread.SetMessage(queueCmd);
+                    if (!queueCmd.manual)
+                    {
+                        oper.UpdateParkingSpaceState(parkingSpaceID, 0);
+                    }
+                    else
+                    {
+                        locationOper.UpdateParkingSpaceState(parkingSpaceID, 0);
+                    }
+                    break;
+                }
+            }
+        }
+        /// <summary>
+        /// 停车流程
+        /// </summary>
+        /// <param name="queueCmd"></param>
+        public override void executeCmd(Command queueCmd)
+        {        
+            //第一步:
             int status = 1;//停车
             ParkingMessage pm = new ParkingMessage();
             pm.status = status;
@@ -180,26 +303,13 @@ namespace parkMonitor.server.CoreThread
             PLC.SetMessage(pm);
             Console.WriteLine("停车,开激光:" + queueCmd.LicenseNum);
             Log.WriteLog("停车,开激光:" + queueCmd.LicenseNum);
-            UILogServer.ins.info("停车,开激光:" + queueCmd.LicenseNum);
-            c.parkingEntX = parkingEntX;
-            c.parkingEntY = parkingEntY;
-            c.parkingEntZ = parkingEntZ;
+            UILogServer.ins.info("停车,开激光:" + queueCmd.LicenseNum);   
+        
             Parking_Space ppp = new Parking_Space();
             Task parkingSpace = Task.Factory.StartNew(() =>
             {
-                while (true)
-                {
-                    ppp = aps.MallocParkingSpace(c);//得到车位
-                    if (ppp != null)
-                    {
-                        break;
-                    }
-                    if (isClosing) { return; }
-                    Thread.Sleep(200);
-                }
+                ppp = WaitForParkingSpaceResource(queueCmd);
             });
-            //parkingSpace.Wait();
-            
             //int garageID = ppp.garageID;
             string numberPlate = queueCmd.LicenseNum;
             int userID = 0;
@@ -210,8 +320,6 @@ namespace parkMonitor.server.CoreThread
             }
             int garageID = queueCmd.garageID;
             string realParkTime = queueCmd.TimeRecord;
-
-            bool jumpOut = false;
             bool disappeared = false;
             bool stopChecking = false;
             bool robotError = false;
@@ -242,71 +350,36 @@ namespace parkMonitor.server.CoreThread
             //        t = startTime - endTime;
             //    }
             //});
-
+            Data dataReal = new Data();
             Task dataFromLaser = Task.Factory.StartNew(() =>
             {
-                while (true)
-                {
-                    jumpOut = false;
-                    PLCMsg = (PLCMessage)PLC.GetMessage();
-                    if (PLCMsg != null)
-                    {
-                        foreach (LaserMessage lm in PLCMsg.laserMsgList)
-                        {
-                            if (lm.id == queueCmd.id && lm.data != null)
-                            {
-                                lock (lm)
-                                {
-                                    //判断车辆检测结果,
-                                    if (disappeared)
-                                    {
-                                        lm.abort_rescan = true;
-                                        jumpOut = true;
-                                        break;
-                                    }
-                                    //存储相应激光数据
-                                    if (lm.recorded)
-                                    {
-                                        centerX = lm.data.centerX;
-                                        centerY = lm.data.centerY;
-                                        angleA = lm.data.angleA;
-                                        length = lm.data.length;
-                                        width = lm.data.width;
-                                        height = lm.data.height;
-                                        jumpOut = true;
-                                        lm.recorded = false;
-                                        break;
-                                    }
-                                    else if (lm.status == -1)
-                                    {
-                                        LogFile logFile = LogFile.ERROR;
-                                        UILogServer.ins.error("激光" + lm.id + "连接异常");
-                                        Log.WriteLog(logFile, "激光异常");
-                                        Thread.Sleep(5000);
-                                    }
-                                }
-                            }
-                        }
-                        if (jumpOut)
-                        {
-                            break;
-                        }
-                    }
-                    Thread.Sleep(1000);
-                }
+                dataReal = WaitForLaserResource(queueCmd, disappeared);
             });
-
-            //dataFromLaser.Wait();
-            Task.WaitAll(parkingSpace,dataFromLaser);
+            Task.WaitAll(parkingSpace, dataFromLaser);
+            //车位
             int parkingSpaceID = ppp.parkingSpaceID;
             int parkingSpaceX = ppp.parkingSpaceX;
             int parkingSpaceY = ppp.parkingSpaceY;
             int parkingSpaceZ = ppp.parkingSpaceZ;
-
+            //激光数据
+            int centerX = dataReal.centerX;
+            int centerY = dataReal.centerY;
+            int angleA = dataReal.angleA;
+            int length = dataReal.length;
+            int width = dataReal.width;
+            int height = dataReal.height;
+            //号牌失效,数据库回滚
             if (disappeared)
             {
                 NumReset(queueCmd);
-                oper.UpdateVehicleParkState(queueCmd.LicenseNum, 0);
+                if (!queueCmd.manual)
+                {
+                    oper.UpdateVehicleParkState(queueCmd.LicenseNum, 0);
+                }
+                else
+                {
+                    locationOper.UpdateVehicleParkState(queueCmd.LicenseNum, 0);
+                }
                 return;
             }
             stopChecking = true;//开始启动机械手,停止检测号牌
@@ -316,9 +389,10 @@ namespace parkMonitor.server.CoreThread
             Task robotFree = Task.Factory.StartNew(() =>
             {
                 //需要先遍历robot数组,根据id找到对应机械手
-                WaitForRobotResource(PLCMsg, robotID);
+                WaitForRobotResource(robotID);
             });
             robotFree.Wait();
+            //第二步:
             status = 2;
             pm.status = status;
             pm.RobotID = robotID;//启动对应机械手
@@ -342,29 +416,10 @@ namespace parkMonitor.server.CoreThread
             int rearWheelbase = 0;
             Task storeSignal = Task.Factory.StartNew(() =>
             {
-                while (true)
-                {
-                    Thread.Sleep(1000);
-                    PLCMsg = (PLCMessage)PLC.GetMessage();
-                    int storeStatus = Convert.ToInt32(PLCMsg.originalPlcList[park_completed_address].Value);
-                    //停车完成信号
-                    if (storeStatus == 1)
-                    {
-                        frontWheelbase = Convert.ToInt32(PLCMsg.originalPlcList[frontWheelbase_address].Value);
-                        rearWheelbase = Convert.ToInt32(PLCMsg.originalPlcList[rearWheelbase_address].Value);
-                        break;
-                    }
-                    else if (1 == 2)//机械手异常,则退指令,写数据库归位
-                    {
-                        robotError = true;
-                        queueCmd.returnedCount += 1;
-                        queuingThread.SetMessage(queueCmd);
-                        oper.UpdateParkingSpaceState(parkingSpaceID, 0);
-                        break;
-                    }
-                }
+                WaitForStoreSignal(queueCmd, ref parkingSpaceID, ref frontWheelbase, ref rearWheelbase, ref robotError);
             });
             storeSignal.Wait();
+            //第三步:
             status = 3;
             pm.status = status;
             PLC.SetMessage(pm);
@@ -403,7 +458,7 @@ namespace parkMonitor.server.CoreThread
                     //插入停车记录表
                     int parkingRecordsID = oper.InsertToParkingRecords(userID, numberPlate, parkingSpaceID, garageID, 3, realParkTime);
                     //车辆表更新车辆信息
-                    oper.UpdateVehicle(numberPlate, 1, realParkTime, parkingRecordsID, parkingSpaceID, 1,frontWheelbase,rearWheelbase);
+                    oper.UpdateVehicle(numberPlate, 1, realParkTime, parkingRecordsID, parkingSpaceID, 1, frontWheelbase, rearWheelbase);
                     //更新车库表剩余车位数
                     int freeSpaceCount = oper.getGarageFreeSpace(garageID);
                     freeSpaceCount = freeSpaceCount - 1;
@@ -425,7 +480,7 @@ namespace parkMonitor.server.CoreThread
                 else
                 {
                     //插入停车记录表
-                    int parkingRecordsID = locationOper.InsertToParkingRecords(1,userID, numberPlate, parkingSpaceID, garageID, 3, realParkTime);
+                    int parkingRecordsID = locationOper.InsertToParkingRecords(1, userID, numberPlate, parkingSpaceID, garageID, 3, realParkTime);
                     //判断车辆表是否存在车辆
                     bool isNumberPlateFromVehicle = locationOper.IsNumberPlateFromVehicle(numberPlate);
                     if (isNumberPlateFromVehicle == false)
@@ -474,17 +529,17 @@ namespace parkMonitor.server.CoreThread
             int parkingSpaceX = fslist.parkingSpaceX;
             int parkingSpaceY = fslist.parkingSpaceY;
             int parkingSpaceZ = fslist.parkingSpaceZ;
-            int status = 4;//取车
-
             ParkingMessage pm = new ParkingMessage();
+            
             int robotID = 0;
             robotID = parkingSpaceID / 15 + 1;
             Task robotFree = Task.Factory.StartNew(() =>
             {
-                WaitForRobotResource(PLCMsg, robotID);
+                WaitForRobotResource(robotID);
             });
             robotFree.Wait();
-
+            //取车
+            int status = 4;
             pm.status = status;
             //先手动赋值
             pm.RobotID = 1;
@@ -518,6 +573,7 @@ namespace parkMonitor.server.CoreThread
             });
             //Task.WaitAll(signalFromPLC);
             signalFromPLC.Wait();
+            //取车完成
             status = 5;
             ParkingMessage pm2 = new ParkingMessage();
             pm2.status = status;
@@ -562,7 +618,7 @@ namespace parkMonitor.server.CoreThread
                 //更新车辆表车辆停车状态
                 locationOper.UpdateVehicleParkState(queueCmd.LicenseNum, 0);
                 //更新停车记录表
-                locationOper.UpdateParkingRecords(0,6, queueCmd.TimeRecord, queueCmd.parkingRecordsID);
+                locationOper.UpdateParkingRecords(0, 6, queueCmd.TimeRecord, queueCmd.parkingRecordsID);
             }
         }
     }

+ 1 - 1
parkMonitor/server/CoreThread/AllotParkingSpace.cs

@@ -11,7 +11,7 @@ namespace parkMonitor.server.CoreThread
     public class AllotParkingSpace
     {
         //根据车位位置及状态分配目标车位,返回Parking Space的ID
-        public Parking_Space MallocParkingSpace(CEntrance pt_Ent)
+        public Parking_Space MallocParkingSpace(CEntrance pt_Ent,object c)
         {
             DBOperation o = new DBOperation();
             List<Parking_Space> lps = o.GetParkingSpace();

+ 23 - 23
parkMonitor/server/CoreThread/AllotTest.cs

@@ -1,24 +1,24 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using parkMonitor.DB;
+//using System;
+//using System.Collections.Generic;
+//using System.Linq;
+//using System.Text;
+//using System.Threading.Tasks;
+//using parkMonitor.DB;
 
-namespace parkMonitor.server.CoreThread
-{
-    class AllotTest
-    {
-        public void AllotMethod()
-        {
-            AllotParkingSpace aps = new AllotParkingSpace();
-            CEntrance c = new CEntrance();
-            c.parkingEntX = 0;
-            c.parkingEntY = 0;
-            c.parkingEntZ = 0;
-            Parking_Space ppp = new Parking_Space();
-            ppp = aps.MallocParkingSpace(c);
-            Console.WriteLine(ppp);
-        }
-    }
-}
+//namespace parkMonitor.server.CoreThread
+//{
+//    class AllotTest
+//    {
+//        public void AllotMethod()
+//        {
+//            AllotParkingSpace aps = new AllotParkingSpace();
+//            CEntrance c = new CEntrance();
+//            c.parkingEntX = 0;
+//            c.parkingEntY = 0;
+//            c.parkingEntZ = 0;
+//            Parking_Space ppp = new Parking_Space();
+//            ppp = aps.MallocParkingSpace(c);
+//            Console.WriteLine(ppp);
+//        }
+//    }
+//}

+ 3 - 1
parkMonitor/server/NumMachine/NumMachine.cs

@@ -752,7 +752,9 @@ namespace parkMonitor.server
                 Dictionary<string, int>.Enumerator enumerator = ipIdMap.GetEnumerator();
                 do
                 {
-                    if (enumerator.Current.Value == cmd.id && ipHandleMap.TryGetValue(enumerator.Current.Key, out int handle))
+                   // if (enumerator.Current.Value == cmd.id && ipHandleMap.TryGetValue(enumerator.Current.Key, out int handle))
+                    int handle = 0;
+                     if(enumerator.Current.Value == cmd.id && ipHandleMap.TryGetValue(enumerator.Current.Key, out handle))
                     {
                         snapshotDevHandle = handle;
                         break;