Prechádzať zdrojové kódy

加入屏显功能。已测试通过。

yc_t 6 rokov pred
rodič
commit
0127dfffb2

+ 8 - 0
parkMonitor/entity/EntityForCore.cs

@@ -31,6 +31,9 @@ namespace parkMonitor.entity
         public int fetching_startRobot_address { get; set; }
         public int frontWheelbase_address { get; set; }
         public int rearWheelbase_address { get; set; }
+        public int centerXLimit { get; set; }
+        public int centerYLimit { get; set; }
+        public int angleALimit { get; set; }
         public static BlockingQueue remoteBQ;
         public static BlockingQueue localBQ;
         public static EntityForCore ins = new EntityForCore();
@@ -51,6 +54,11 @@ namespace parkMonitor.entity
                 wheelbase_status_address = Convert.ToInt32(ConfigurationManager.AppSettings["wheelbase_status_address"]);
                 //取车完成
                 fetch_completed_address = Convert.ToInt32(ConfigurationManager.AppSettings["fetch_completed_address"]);
+
+                centerXLimit = Convert.ToInt32(ConfigurationManager.AppSettings["centerX"]);
+                centerYLimit = Convert.ToInt32(ConfigurationManager.AppSettings["centerY"]);
+                angleALimit = Convert.ToInt32(ConfigurationManager.AppSettings["angleA"]);
+
             }
             catch
             {

+ 5 - 0
parkMonitor/parkMonitor.csproj

@@ -59,6 +59,10 @@
     <StartupObject />
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="broadcastDLL, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>sdk\broadcast\broadcastDLL.dll</HintPath>
+    </Reference>
     <Reference Include="HslCommunication, Version=4.3.2.0, Culture=neutral, processorArchitecture=MSIL">
       <SpecificVersion>False</SpecificVersion>
       <HintPath>sdk\HslCommunication\HslCommunication.dll</HintPath>
@@ -143,6 +147,7 @@
     <Compile Include="model\EquipmentsSection.cs" />
     <Compile Include="sdk\superscene\TimeTest.cs" />
     <Compile Include="server\AsyncCmdServer.cs" />
+    <Compile Include="server\broadcastModule\broadcastModule.cs" />
     <Compile Include="server\CoreThread\AbstractCmd.cs" />
     <Compile Include="server\CoreThread\SpaceManager.cs" />
     <Compile Include="server\CoreThread\AllotTest.cs" />

BIN
parkMonitor/sdk/broadcast/broadcastDLL.dll


+ 137 - 41
parkMonitor/server/CoreThread/AbstractCmd.cs

@@ -13,6 +13,7 @@ using parkMonitor.tools;
 using parkMonitor.Database2;
 using MySql.Data.MySqlClient;
 using parkMonitor.server.NumMachine;
+using parkMonitor.server.broadcastModule;
 
 namespace parkMonitor.server.CoreThread
 {
@@ -137,7 +138,7 @@ namespace parkMonitor.server.CoreThread
                         PLCMsg = (PLCMessage)PLC.GetMessage();
                     }
                     bool occupied = true;
-                    if (PLCMsg != null && PLCMsg.originalPlcList.Count!=0)
+                    if (PLCMsg != null && PLCMsg.originalPlcList.Count != 0)
                     {
                         if (robotID == 1)
                         {
@@ -201,9 +202,15 @@ namespace parkMonitor.server.CoreThread
         /// <param name="isParking"></param>
         public void Rollback(Command queueCmd, int parkingSpaceID, bool robotAllocated, bool isParking, LaserMessage lm)
         {
-            //命令回退
-            queueCmd.returnedCount += 1;
-            queuingThread.SetMessage(queueCmd);
+            if (queueCmd.id == 1)
+            {
+                BroadcastLinker.dispForAWhile(0, "流程中止", 8, false);
+            }
+            Console.WriteLine("回滚");
+            NumReset(queueCmd);
+            ////命令回退
+            //queueCmd.returnedCount += 1;
+            //queuingThread.SetMessage(queueCmd);
             //机械手释放
             if (robotAllocated)
             {
@@ -221,6 +228,7 @@ namespace parkMonitor.server.CoreThread
                         RobotID = 1
                     };
                     PLC.SetMessage(cMsg);
+                    oper.UpdateVehicleParkState(EntityForCore.remoteBQ, queueCmd.LicenseNum, 0);
                 }
                 else
                 {
@@ -231,6 +239,7 @@ namespace parkMonitor.server.CoreThread
                         RobotID = 1
                     };
                     PLC.SetMessage(cMsg);
+                    oper.UpdateVehicleParkState(EntityForCore.remoteBQ, queueCmd.LicenseNum, 1);
                 }
             }
             //释放激光
@@ -255,23 +264,6 @@ namespace parkMonitor.server.CoreThread
                         Log.WriteLog(LogType.NOT_DATABASE, LogFile.ERROR, "车位分配出现异常,需要重启");
                         return;
                     }
-                }
-                else
-                {
-                    ////复原已释放的车位
-                    //if (!ParkingSpaceManager.ins.SetParkingSpace(parkingSpaceID, 1))
-                    //{
-                    //    EntityForCore.ins.globalStatus = false;
-                    //    Log.WriteLog(LogType.NOT_DATABASE, LogFile.ERROR, "车位分配出现异常,需要重启");
-                    //    return;
-                    //}
-                }
-            }
-            else
-            {
-                if (isParking)
-                {
-                    oper.UpdateVehicleParkState(EntityForCore.remoteBQ, queueCmd.LicenseNum, 0);
                     if (robotAllocated)
                     {
                         oper.UpdateParkingSpaceState(EntityForCore.remoteBQ, parkingSpaceID, 0);
@@ -279,13 +271,50 @@ namespace parkMonitor.server.CoreThread
                 }
                 else
                 {
-                    oper.UpdateVehicleParkState(EntityForCore.remoteBQ, queueCmd.LicenseNum, 1);
+                    //复原已释放的车位
+                    if (!ParkingSpaceManager.ins.SetParkingSpace(parkingSpaceID, 1))
+                    {
+                        EntityForCore.ins.globalStatus = false;
+                        Log.WriteLog(LogType.NOT_DATABASE, LogFile.ERROR, "车位分配出现异常,需要重启");
+                        return;
+                    }
                     if (robotAllocated)
                     {
                         oper.UpdateParkingSpaceState(EntityForCore.remoteBQ, parkingSpaceID, 1);
                     }
                 }
             }
+            else
+            {
+                //if (isParking)
+                //{
+                //    oper.UpdateVehicleParkState(EntityForCore.remoteBQ, queueCmd.LicenseNum, 0);
+                //    if (robotAllocated)
+                //    {
+                //        oper.UpdateParkingSpaceState(EntityForCore.remoteBQ, parkingSpaceID, 0);
+                //    }
+                //}
+                //else
+                //{
+                //    oper.UpdateVehicleParkState(EntityForCore.remoteBQ, queueCmd.LicenseNum, 1);
+                //    if (robotAllocated)
+                //    {
+                //        oper.UpdateParkingSpaceState(EntityForCore.remoteBQ, parkingSpaceID, 1);
+                //    }
+                //}
+            }
+        }
+
+        /// <summary>
+        /// 号牌复位
+        /// </summary>
+        public void NumReset(Command queueCmd)
+        {
+            NumberMachineMessage numberMachineMessage = new NumberMachineMessage();
+            numberMachineMessage.aNode = new NumberMachineNode();
+            numberMachineMessage.aNode.ip = "";
+            numberMachineMessage.aNode.LicenseNum = queueCmd.LicenseNum;
+            queuingThread.SetMessage(numberMachineMessage);
         }
     }
 
@@ -294,12 +323,52 @@ namespace parkMonitor.server.CoreThread
     /// </summary>
     public class StopCmd : AbstractCmd
     {
-        /// <summary>
-        /// 停车数据库事务
-        /// </summary>
-        private void StopParkingSubmit()
+        private bool RangeValidation(Data data)
         {
-
+            int temp = 0;
+            Console.WriteLine(data.centerX + "," + data.centerY + "," + data.angleA);
+            lock (EntityForCore.ins)
+            {
+                if (data.centerX > EntityForCore.ins.centerXLimit)
+                {
+                    Console.WriteLine(EntityForCore.ins.centerXLimit);
+                    BroadcastLinker.dispForAWhile(1, "x轴超限", 6, false);
+                    //BroadcastLinker.ins.DispString(1, "x轴超限", 6);
+                    BroadcastLinker.ins.AudioPlay("请注意");
+                    temp += 1;
+                }
+                if (data.centerY > EntityForCore.ins.centerYLimit)
+                {
+                    Console.WriteLine(EntityForCore.ins.centerYLimit);
+                    BroadcastLinker.dispForAWhile(2, "y轴超限", 6, false);
+                    //BroadcastLinker.ins.DispString(2, "y轴超限", 6);
+                    BroadcastLinker.ins.AudioPlay("请注意");
+                    temp += 2;
+                }
+                if (data.angleA > EntityForCore.ins.angleALimit)
+                {
+                    Console.WriteLine(EntityForCore.ins.angleALimit);
+                    BroadcastLinker.dispForAWhile(3, "角度超限", 6, false);
+                    //BroadcastLinker.ins.DispString(3, "角度超限", 6);
+                    BroadcastLinker.ins.AudioPlay("请注意");
+                    temp += 4;
+                }
+            }
+            //Thread.Sleep(10000);
+            //for (int i = 0; i < 3; i++)
+            //{
+            //    if ((state & 0x01) == 1)
+            //    {
+            //        BroadcastLinker.ins.DispDownStr(i + 1, 0);
+            //        state = state >> 1;
+            //    }
+            //}
+            //BroadcastLinker.ins.DispDownStr(1, 0);
+            //BroadcastLinker.ins.DispDownStr(2, 0);
+            //BroadcastLinker.ins.DispDownStr(3, 0);
+            if (temp > 0) return false;
+            else return true;
+            //return temp > 0 ? false : true;
         }
         /// <summary>
         /// 命令中号牌与对应号牌机中当前号牌比对,确认车辆
@@ -334,17 +403,7 @@ namespace parkMonitor.server.CoreThread
             numberCheck.Wait();
             return result;
         }
-        /// <summary>
-        /// 号牌复位
-        /// </summary>
-        private void NumReset(Command queueCmd)
-        {
-            NumberMachineMessage numberMachineMessage = new NumberMachineMessage();
-            numberMachineMessage.aNode = new NumberMachineNode();
-            numberMachineMessage.aNode.ip = "";
-            numberMachineMessage.aNode.LicenseNum = queueCmd.LicenseNum;
-            queuingThread.SetMessage(numberMachineMessage);
-        }
+
         /// <summary>
         /// 车位资源
         /// </summary>
@@ -618,6 +677,10 @@ namespace parkMonitor.server.CoreThread
         public override void executeCmd(Command queueCmd)
         {
             //UILogServer.ins.info("停车流程:" + queueCmd.LicenseNum + "开始");
+            if (queueCmd.id == 1)
+            {
+                BroadcastLinker.dispForAWhile(0, "开始停车", 6, false);
+            }
             Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "停车流程:" + queueCmd.LicenseNum + "开始");
             string connectionStr = null;                                          //数据库连接字符串
             bool disappeared = false;                                             //车辆检测结果
@@ -646,7 +709,8 @@ namespace parkMonitor.server.CoreThread
             int freeSpaceCount = 0;                    //剩余空闲车位
             dataReal = WaitForLaserResource(queueCmd, disappeared, out lmToBeReleased);
             //判断激光资源有效性,无效代表超时且已点击回滚按钮
-            if (dataReal == null)
+            //*****核对摆扫数据是否达标,未达标则将指令丢出,让用户重发指令
+            if (dataReal == null || !RangeValidation(dataReal))
             {
                 Rollback(queueCmd, 0, false, true, lmToBeReleased);
                 return;
@@ -778,7 +842,16 @@ namespace parkMonitor.server.CoreThread
             status = 2;
             cm.status = status;
             cm.RobotID = robotID;//启动对应机械手
-
+            if (queueCmd.id == 1)
+            {
+                //Task.Factory.StartNew(() =>
+                //{
+                BroadcastLinker.dispForAWhile(0, "抓车到" + ppp.parkingSpaceX, 60, false);
+                //BroadcastLinker.ins.DispString(0, "抓车到" + ppp.parkingSpaceX, 6);
+                //Thread.Sleep(5000);
+                //BroadcastLinker.ins.DispDownStr(0, 0);
+                //});
+            }
             //激光数据
             cm.centerX = Convert.ToString(dataReal.centerX);
             cm.centerY = Convert.ToString(dataReal.centerY);
@@ -837,7 +910,17 @@ namespace parkMonitor.server.CoreThread
             //int vehicleTypeID = oper.getVehicleTypeID(numberPlate);
             //判断测量数据是否准确
             //bool isDataRight = oper.IsDataRight(vehicleTypeLength, vehicleTypeWidth, vehicleTypeHeight, vehicleTypeWheelbase, vehicleTypeID);
-
+            if (queueCmd.id == 1)
+            {
+                //Task.Factory.StartNew(() =>
+                //{
+                BroadcastLinker.dispForAWhile(0, "停车完成", 10, true);
+                //BroadcastLinker.ins.DispString(0, "停车完成", 6);
+                BroadcastLinker.ins.AudioPlay("操作成功");
+                //    Thread.Sleep(5000);
+                //BroadcastLinker.OriginState();
+                //});
+            }
             //正常写入数据库
             if (userID != 0)
             {
@@ -1053,6 +1136,7 @@ namespace parkMonitor.server.CoreThread
         public override void executeCmd(Command queueCmd)
         {
             //UILogServer.ins.info("取车流程:" + queueCmd.LicenseNum + "开始");
+            BroadcastLinker.dispForAWhile(0, "取车开始", 10, false);
             Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "取车流程:" + queueCmd.LicenseNum + "开始");
             Vehicle vehiclelist = null;                 //待取车辆信息
             ControlMessage cm = null;
@@ -1140,6 +1224,12 @@ namespace parkMonitor.server.CoreThread
             cm.rearWheelbase = rearwheelbase;
             PLC.SetMessage(cm);
 
+
+            BroadcastLinker.dispForAWhile(0, "放车到" + ps.parkingSpaceX, 60, false);
+            //BroadcastLinker.ins.DispString(0, "放车到" + ps.parkingSpaceX, 6);
+            //Thread.Sleep(5000);
+            //BroadcastLinker.ins.DispDownStr(0, 0);
+
             Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "取车流程:" + queueCmd.LicenseNum + "取车");
             UILogServer.ins.info("取车流程:" + queueCmd.LicenseNum + "取车");
             //等待PLC取车完成信号
@@ -1180,6 +1270,12 @@ namespace parkMonitor.server.CoreThread
             //ManualParkingSimul.ins.Update(Int32.Parse(queueCmd.LicenseNum.Substring(2, 1)));
             //ParkingSimul.ins.Update(Int32.Parse(queueCmd.LicenseNum.Substring(2, 1)));
 
+            BroadcastLinker.dispForAWhile(0, "取车完成", 10, true);
+            //BroadcastLinker.ins.DispString(0, "停车完成", 6);
+            BroadcastLinker.ins.AudioPlay("谢谢惠顾,一路顺风");
+            //    Thread.Sleep(5000);
+            //BroadcastLinker.OriginState();
+
             int freeSpaceCount = ParkingSpaceManager.ins.GetFreeSpaceCount();
             //数据库更新
             lock (Parking_Space.RecordLock)

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

@@ -14,6 +14,7 @@ using parkMonitor.tools;
 using parkMonitor.Database2;
 using MySql.Data.MySqlClient;
 using parkMonitor.server.CoreThread;
+using parkMonitor.server.broadcastModule;
 
 namespace parkMonitor.server.CoreThread
 {
@@ -49,6 +50,7 @@ namespace parkMonitor.server.CoreThread
 
         public void Start()
         {
+            BroadcastLinker.Start();
             //创建所有实例
             for (int i = 0; i < equipNames.Length; ++i)
             {

+ 10 - 0
parkMonitor/server/NumMachine/NumMachine.cs

@@ -19,6 +19,7 @@ using parkMonitor.viewModel.objectTree;
 using parkMonitor.server.uiLogServer;
 using System.Configuration;
 using parkMonitor.LOG;
+using parkMonitor.server.broadcastModule;
 
 namespace parkMonitor.server
 {
@@ -497,6 +498,15 @@ namespace parkMonitor.server
                                 if (ipIdMap.TryGetValue(node.ip, out node.id))
                                 {
                                     LicBuffer.Enqueue((NumberMachineNode)node.Clone());
+                                    if (node.id == 1)
+                                    {
+                                        Task.Factory.StartNew(() => {
+                                            BroadcastLinker.ins.DispString(1, node.LicenseNum, 6);
+                                            BroadcastLinker.ins.AudioPlay(node.LicenseNum+",入场");
+                                            Thread.Sleep(5000);
+                                            BroadcastLinker.ins.DispDownStr(1, 0);
+                                        });
+                                    }
                                 }
                             }
                         }

+ 10 - 6
parkMonitor/server/PLCLinker/PLCLinker.cs

@@ -651,13 +651,17 @@ namespace parkMonitor.server
                             //判断激光空闲状态
                             lock (lpuTemp.laserMsg)
                             {
-                                if (node.Address.Equals(lpuTemp.laser_status_address.ToString()) && (node.Value.Equals("254") || node.Value.Equals("255")) && !lpuTemp.laserMsg.occupied)
+                                if (node.Address.Equals(lpuTemp.laser_status_address.ToString()))
                                 {
-                                    lpuTemp.laserMsg.occupied = true;
-                                    jumpOut = true;
-                                    //UILogServer.ins.log("获取摆扫激光空闲状态,准备启动激光");
-                                    Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "获取摆扫激光空闲状态,准备启动激光");
-                                    break;
+                                    Console.WriteLine(node.Value+", occupied:"+ lpuTemp.laserMsg.occupied+",id:"+lpuTemp.id);
+                                    if ((node.Value.Equals("254") || node.Value.Equals("255")) && !lpuTemp.laserMsg.occupied)
+                                    {
+                                        lpuTemp.laserMsg.occupied = true;
+                                        jumpOut = true;
+                                        //UILogServer.ins.log("获取摆扫激光空闲状态,准备启动激光");
+                                        Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "获取摆扫激光空闲状态,准备启动激光");
+                                        break;
+                                    }
                                 }
                             }
                         }

+ 62 - 0
parkMonitor/server/broadcastModule/broadcastModule.cs

@@ -0,0 +1,62 @@
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using BroadcastModule;
+
+namespace parkMonitor.server.broadcastModule
+{
+    public class BroadcastLinker
+    {
+        public static BroadcastBoard ins;
+        static string ip;
+        static int port;
+
+        /// <summary>
+        /// 初始化单例
+        /// </summary>
+        public static void Start()
+        {
+            try
+            {
+                ip = ConfigurationManager.AppSettings["broadcastIP"];
+                port = Int32.Parse(ConfigurationManager.AppSettings["broadcastPort"]);
+                ins = new BroadcastBoard(ip, port);
+                ins.Refresh();
+                ins.AudioPlay("欢迎光临");
+                ins.DownloadString(0, "欢迎光临", 0);
+                ins.DownloadString(1, "智象停车", 0);
+                ins.DownloadString(2, "date", 0);
+                ins.DownloadString(3, "time", 0);
+                ins.DispDownStr(0, 0);
+                ins.DispDownStr(1, 0);
+                ins.DispDownStr(2, 0);
+                ins.DispDownStr(3, 0);
+            }
+            catch (Exception e) { Console.WriteLine(e.Message); ins = null; }
+        }
+
+        public static void dispForAWhile(int winID, string str, int delay, bool switchToOrigin)
+        {
+            ins.DispString(winID, str, 10);
+            Task.Factory.StartNew(() =>
+            {
+                if (switchToOrigin)
+                {
+                    Thread.Sleep(delay * 1000);
+                    OriginState();
+                }
+            });
+        }
+        public static void OriginState()
+        {
+            ins.DispDownStr(0, 0);
+            ins.DispDownStr(1, 0);
+            ins.DispDownStr(2, 0);
+            ins.DispDownStr(3, 0);
+        }
+    }
+}

+ 2 - 2
parkMonitor/view/FormModbus/FormModbus.cs

@@ -1035,7 +1035,7 @@ namespace PLC_Communication
                             // 显示图片
                             if (plateInfo.img_path != "")
                             {
-                                pictureBox2.Image = Image.FromFile(plateInfo.img_path);
+                                //pictureBox2.Image = Image.FromFile(plateInfo.img_path);
                             }
 
                         }
@@ -1050,7 +1050,7 @@ namespace PLC_Communication
                             // 显示图片
                             if (plateInfo.img_path != "")
                             {
-                                pictureBox4.Image = Image.FromFile(plateInfo.img_path);
+                                //pictureBox4.Image = Image.FromFile(plateInfo.img_path);
                             }
                         }