yc_t 7 gadi atpakaļ
vecāks
revīzija
d4b4a1fc5f

+ 2 - 2
parkMonitor.sln

@@ -1,7 +1,7 @@
 
 Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 2013
-VisualStudioVersion = 12.0.40629.0
+# Visual Studio 15
+VisualStudioVersion = 15.0.27130.2026
 MinimumVisualStudioVersion = 10.0.40219.1
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "parkMonitor", "parkMonitor\parkMonitor.csproj", "{DD3DCAB1-41A7-4EED-ADEE-9E4BBCE6B4C0}"
 EndProject

+ 2 - 2
parkMonitor/App.config

@@ -50,9 +50,9 @@
     <add key="parkingSpaceX_address" value="17" />
     <add key="parkingSpaceY_address" value="18" />
     <add key="parkingSpaceZ_address" value="19" />
-<add key="parkingLaserCenterX_address" value="13" />
+    <add key="parkingLaserCenterX_address" value="13" />
     <add key="frontWheelbase_address" value="79" />
-<add key="rearWheelbase_address" value="80" />
+    <add key="rearWheelbase_address" value="80" />
     <!--激光设备配置-->
     <add key="park_command_address" value="10" />
     <add key="laser1_status_address" value="83" />

+ 106 - 0
parkMonitor/ClassDiagram1.cd

@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="utf-8"?>
+<ClassDiagram MajorVersion="1" MinorVersion="1">
+  <Class Name="parkMonitor.entity.AbstractMessage" Collapsed="true">
+    <Position X="7.25" Y="0.5" Width="1.5" />
+    <TypeIdentifier>
+      <HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
+      <FileName>entity\AbstractMessage.cs</FileName>
+    </TypeIdentifier>
+  </Class>
+  <Class Name="parkMonitor.entity.MessageUTF8">
+    <Position X="1" Y="1.75" Width="2.25" />
+    <TypeIdentifier>
+      <HashCode>AAgCAAACAAAAAAQAAAAAAAAAAAAAAAAABAAAAAAACBA=</HashCode>
+      <FileName>entity\AbstractMessage.cs</FileName>
+    </TypeIdentifier>
+    <Lollipop Position="0.2" />
+  </Class>
+  <Class Name="parkMonitor.entity.PLCNode">
+    <Position X="4.75" Y="1.75" Width="1.75" />
+    <TypeIdentifier>
+      <HashCode>AAAAAAAAAAAAAAAAgAAAAAAAAAAAAIACAAAgAAAAAAA=</HashCode>
+      <FileName>entity\AbstractMessage.cs</FileName>
+    </TypeIdentifier>
+  </Class>
+  <Class Name="parkMonitor.entity.PLCMessage">
+    <Position X="10.25" Y="1.75" Width="1.5" />
+    <TypeIdentifier>
+      <HashCode>AAAAAAAAAAABIQAAAAAAAAAAAAAAAAAAAAAAAAAAABA=</HashCode>
+      <FileName>entity\AbstractMessage.cs</FileName>
+    </TypeIdentifier>
+    <Lollipop Position="0.2" />
+  </Class>
+  <Class Name="parkMonitor.entity.NumberMachineNode" BaseTypeListCollapsed="true">
+    <Position X="6.5" Y="4.25" Width="2.25" />
+    <TypeIdentifier>
+      <HashCode>AAQAAAEAAAAAAAACgAAAAAAAAAAAAIAAAAAgAAABAhA=</HashCode>
+      <FileName>entity\AbstractMessage.cs</FileName>
+    </TypeIdentifier>
+    <ShowAsAssociation>
+      <Field Name="status" />
+    </ShowAsAssociation>
+    <Lollipop Position="0.2" />
+  </Class>
+  <Class Name="parkMonitor.entity.NumberMachineMessage">
+    <Position X="6.5" Y="1.75" Width="2.25" />
+    <AssociationLine Name="aNode" Type="parkMonitor.entity.NumberMachineNode">
+      <MemberNameLabel ManuallyPlaced="true">
+        <Position X="-0.797" Y="0.105" />
+      </MemberNameLabel>
+    </AssociationLine>
+    <TypeIdentifier>
+      <HashCode>AAAAAAAAAABAAAAAgAAAAAAAAAAAAIAAAAAQAAAAAAA=</HashCode>
+      <FileName>entity\AbstractMessage.cs</FileName>
+    </TypeIdentifier>
+    <ShowAsAssociation>
+      <Field Name="aNode" />
+    </ShowAsAssociation>
+  </Class>
+  <Class Name="parkMonitor.entity.LaserMessage">
+    <Position X="11.75" Y="1.75" Width="2.25" />
+    <AssociationLine Name="data" Type="parkMonitor.entity.Data">
+      <MemberNameLabel ManuallyPlaced="true">
+        <Position X="0.303" Y="0.071" />
+      </MemberNameLabel>
+    </AssociationLine>
+    <TypeIdentifier>
+      <HashCode>AAQgAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAQAAAAAhA=</HashCode>
+      <FileName>entity\AbstractMessage.cs</FileName>
+    </TypeIdentifier>
+    <ShowAsAssociation>
+      <Field Name="data" />
+    </ShowAsAssociation>
+    <Lollipop Position="0.2" />
+  </Class>
+  <Class Name="parkMonitor.entity.Data" BaseTypeListCollapsed="true">
+    <Position X="10.5" Y="4.75" Width="1.5" />
+    <TypeIdentifier>
+      <HashCode>AAAAAAAAAAAAAAQAQEAAABgAAAAAAAAAAAAAAABAABA=</HashCode>
+      <FileName>entity\AbstractMessage.cs</FileName>
+    </TypeIdentifier>
+    <Lollipop Position="0.2" />
+  </Class>
+  <Class Name="parkMonitor.entity.Command">
+    <Position X="3" Y="1.75" Width="1.75" />
+    <TypeIdentifier>
+      <HashCode>AAAAAAECAIAAAEAACAAAAAAAAAAAAAAAAAAgAAABChA=</HashCode>
+      <FileName>entity\AbstractMessage.cs</FileName>
+    </TypeIdentifier>
+    <Lollipop Position="0.2" />
+  </Class>
+  <Class Name="parkMonitor.entity.ParkingMessage">
+    <Position X="8.75" Y="1.75" Width="1.5" />
+    <TypeIdentifier>
+      <HashCode>AgQABAAAAAAAQAQAQEAAABgAQAAAAAAAAAAAAABADgA=</HashCode>
+      <FileName>entity\AbstractMessage.cs</FileName>
+    </TypeIdentifier>
+  </Class>
+  <Enum Name="parkMonitor.entity.EnumNumberMachineStatus">
+    <Position X="3.25" Y="5.75" Width="2.5" />
+    <TypeIdentifier>
+      <HashCode>AAAAAAAAAAAAAAAAAAgAAAAAAAAIAAAAAAAAAAAAAAA=</HashCode>
+      <FileName>entity\AbstractMessage.cs</FileName>
+    </TypeIdentifier>
+  </Enum>
+  <Font Name="微软雅黑" Size="9" />
+</ClassDiagram>

+ 18 - 18
parkMonitor/entity/AbstractMessage.cs

@@ -79,9 +79,9 @@ namespace parkMonitor.entity
     //plc list
     public class PLCMessage : AbstractMessage, ICloneable
     {
-        public List<PLCNode> extendedPlcList;
-        public List<PLCNode> originalPlcList;
-        public List<LaserMessage> laserMsgList;
+        public List<PLCNode> extendedPlcList { get; set; }
+        public List<PLCNode> originalPlcList { get; set; }
+        public List<LaserMessage> laserMsgList { get; set;}
 
         public PLCMessage()
         {
@@ -119,9 +119,9 @@ namespace parkMonitor.entity
     //NumMachine component
     public class NumberMachineNode : ICloneable
     {
-        public string ip;
-        public string LicenseNum;
-        public string TimeRecord;
+        public string ip { get; set; }
+        public string LicenseNum { get; set; }
+        public string TimeRecord { get; set; }
         public int id;
         public EnumNumberMachineStatus status;
         public NumberMachineNode() { }
@@ -166,7 +166,7 @@ namespace parkMonitor.entity
     //NumMachine list+aModel
     public class NumberMachineMessage : AbstractMessage
     {
-        public List<NumberMachineNode> data;
+        public List<NumberMachineNode> data { get; set; }
         public NumberMachineNode aNode;
 
         public NumberMachineMessage()
@@ -255,16 +255,16 @@ namespace parkMonitor.entity
     //********************************************** command **********************************************
     public class Command : AbstractMessage, ICloneable
     {
-        public char commandType;
-        public string LicenseNum;
-        public string userID;
-        public int garageID;
-        public int parkingRecordsID;
-        public string TimeRecord;
-        public string ip;//新添加,用于定位号牌机
-        public int returnedCount;//标记被返回的命令
-        public int id;
-        public bool manual;//判断是否手动停取
+        public char commandType { get; set; }
+        public string LicenseNum { get; set; }
+        public string userID { get; set; }
+        public int garageID { get; set; }
+        public int parkingRecordsID { get; set; }
+        public string TimeRecord { get; set; }
+        public string ip { get; set; }//新添加,用于定位号牌机
+        public int returnedCount { get; set; }//标记被返回的命令
+        public int id { get; set; }
+        public bool manual { get; set; }//判断是否手动停取
 
         public Command()
         {
@@ -299,7 +299,7 @@ namespace parkMonitor.entity
         }
     }
 
-    public class ParkingMessage : AbstractMessage
+    public class ControlMessage : AbstractMessage
     {
         //1: 停车startLaser--park_command_address
         //2: 停车激光的6个数据,startRobot,车位信息4个

+ 3 - 0
parkMonitor/parkMonitor.csproj

@@ -24,6 +24,7 @@
     <DefineConstants>DEBUG;TRACE</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
+    <DocumentationFile>bin\Debug\parkMonitor.xml</DocumentationFile>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
     <PlatformTarget>AnyCPU</PlatformTarget>
@@ -33,6 +34,7 @@
     <DefineConstants>TRACE</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
+    <DocumentationFile>bin\Release\parkMonitor.xml</DocumentationFile>
   </PropertyGroup>
   <PropertyGroup>
     <ApplicationIcon>resource\image\icon.ico</ApplicationIcon>
@@ -488,6 +490,7 @@
     <EmbeddedResource Include="view\FormModbus\VideoCfg_Form.resx">
       <DependentUpon>VideoCfg_Form.cs</DependentUpon>
     </EmbeddedResource>
+    <None Include="ClassDiagram1.cd" />
     <None Include="packages.config" />
     <None Include="Properties\Settings.settings">
       <Generator>SettingsSingleFileGenerator</Generator>

+ 3 - 3
parkMonitor/server/CoreThread/AbstractCmd.cs

@@ -297,7 +297,7 @@ namespace parkMonitor.server.CoreThread
         {        
             //第一步:
             int status = 1;//停车
-            ParkingMessage pm = new ParkingMessage();
+            ControlMessage pm = new ControlMessage();
             pm.status = status;
             pm.laserID = queueCmd.id;//启动对应激光
             PLC.SetMessage(pm);
@@ -537,7 +537,7 @@ namespace parkMonitor.server.CoreThread
             int parkingSpaceX = fslist.parkingSpaceX;
             int parkingSpaceY = fslist.parkingSpaceY;
             int parkingSpaceZ = fslist.parkingSpaceZ;
-            ParkingMessage pm = new ParkingMessage();
+            ControlMessage pm = new ControlMessage();
             
             int robotID = 0;
             robotID = parkingSpaceID / 15 + 1;
@@ -583,7 +583,7 @@ namespace parkMonitor.server.CoreThread
             signalFromPLC.Wait();
             //取车完成
             status = 5;
-            ParkingMessage pm2 = new ParkingMessage();
+            ControlMessage pm2 = new ControlMessage();
             pm2.status = status;
             //先手动赋值
             pm2.RobotID = 1;

+ 13 - 4
parkMonitor/server/CoreThread/QueuingThread.cs

@@ -28,7 +28,6 @@ namespace parkMonitor.server.CoreThread
         NumberMachineNode license;
         MessageUTF8 webMsg;
 
-
         public QueuingThread()
         {
             webHandle = EquipmentSimpleFactory.ins.FindEquipment(EquipmentName.Web);
@@ -357,11 +356,21 @@ namespace parkMonitor.server.CoreThread
                 {
                     if (command.returnedCount > 0)
                     {
-                        lock (ValidStoreCmdQueue)
+                        if (command.commandType.Equals('s'))
                         {
-                            ValidStoreCmdQueue.Enqueue((Command)command.Clone());
+                            lock (ValidStoreCmdQueue)
+                            {
+                                ValidStoreCmdQueue.Enqueue((Command)command.Clone());
+                            }
+                            UILogServer.ins.info("收到退回的停车指令:" + command.LicenseNum);
+                        }
+                        else if(command.commandType.Equals('f')){
+                            lock (FetchCmdQueue)
+                            {
+                                FetchCmdQueue.Enqueue((Command)command.Clone());
+                            }
+                            UILogServer.ins.info("收到退回的取车指令:" + command.LicenseNum);
                         }
-                        UILogServer.ins.info("收到退回的停车指令:" + command.LicenseNum);
                     }
                     else
                     {

+ 218 - 216
parkMonitor/server/NumMachine/NumMachine.cs

@@ -58,7 +58,7 @@ namespace parkMonitor.server
         ///<summary>通过设备句柄访问pic;链接时add,系统关闭时remove</summary>
         private Dictionary<int, PictureBox> devPicMap = new Dictionary<int, PictureBox>();
         ///<summary>通过名字获取pic对象;创建pic时add,系统关闭remove</summary>
-        private Dictionary<string, PictureBox> picNameMap = new Dictionary<string, PictureBox>();
+        private Dictionary<string, PictureBox> namePicMap = new Dictionary<string, PictureBox>();
         ///<summary>通过ip获取设备id;产生ip时创建</summary>
         private Dictionary<string, int> ipIdMap = new Dictionary<string, int>();
         ///<summary>通过ip获取设备句柄;产生句柄时创建</summary>
@@ -67,14 +67,14 @@ namespace parkMonitor.server
         private Queue<NumberMachineNode> LicBuffer = new Queue<NumberMachineNode>();
         ///<summary>计数Map</summary>
         private Dictionary<string, Dictionary<NumberMachineNode, int>> filterMap = new Dictionary<string, Dictionary<NumberMachineNode, int>>();
-        /// <summary>句柄到图像映射</summary>
-        private Dictionary<int, IntPtr> handleImgMap = new Dictionary<int, IntPtr>();
         /// <summary>筛选计数</summary>
         private int filterCount = 0;
         /// <summary>系统关闭</summary>
-        private bool closing = false;
+        private bool isClosing = false;
         /// <summary>开启拍照的设备</summary>
         private int snapshotDevHandle = -1;
+        /// <summary>允许无号牌时拍照</summary>
+        private bool enableEmptySnapshot = true;
 
         private NumberMachineMessage nmMsg = new NumberMachineMessage();
         VzClientSDK.VZLPRC_FIND_DEVICE_CALLBACK_EX find_DeviceCB = null;
@@ -146,7 +146,7 @@ namespace parkMonitor.server
 
         private void UpdateStatus(NumberMachineNode nmn)
         {
-            while (!closing)
+            while (!isClosing)
             {
                 if (GetStatus(nmn.ip) == 1)
                 {
@@ -169,7 +169,7 @@ namespace parkMonitor.server
         {
             try
             {
-                while (!closing)
+                while (!isClosing)
                 {
                     Thread.Sleep(REFRESHINGTIME);
                     //定时返回号牌
@@ -277,7 +277,7 @@ namespace parkMonitor.server
                     {
                         string str = "PictureBox" + Convert.ToString(i);
                         //该名称对应控件不存在,则创建并链接pic
-                        if (!picNameMap.ContainsKey(str))
+                        if (!namePicMap.ContainsKey(str))
                         {
                             PictureBox pic;
                             if (CreatePic(i, out pic))
@@ -317,29 +317,31 @@ namespace parkMonitor.server
 
                 VzClientSDK.VZ_LPR_MSG_PLATE_INFO plateInfo = new VzClientSDK.VZ_LPR_MSG_PLATE_INFO();
                 plateInfo.plate = strLicense;
-                
+
                 //根据setMessage中通过id信息找到的handle保存图片
-                if (!strLicense.Contains("_无_") && handle == snapshotDevHandle)
+                if (handle == snapshotDevHandle)
                 {
-                    string strFilePath = ConfigurationManager.AppSettings["LogPath"] + DateTime.Now.ToString("yyyyMMdd") + "\\";
-                    if (!Directory.Exists(strFilePath))
-                    {
-                        Directory.CreateDirectory(strFilePath);
-                    }
-                    string ip = Get_IP(handle);
-                    string path = strFilePath + ip +"-"+ DateTime.Now.ToString("hh_mm_ss") + ".jpg";
-                    int temp = VzClientSDK.VzLPRClient_ImageSaveToJpeg(pImgFull, path, 50);
-                    if (temp!=-1)
-                    {
-                        LogFile logFile = LogFile.LOG;
-                        Log.WriteLog(logFile, "号牌机" + ip + "已拍照,图片保存于 " + strFilePath);
-                        UILogServer.ins.info("号牌机" + ip + "已拍照,图片保存于 " + strFilePath);
-                    }
-                    else
+                    if (enableEmptySnapshot || !strLicense.Contains("_无_"))
                     {
-                        UILogServer.ins.info("图片保存失败");
+                        string strFilePath = ConfigurationManager.AppSettings["LogPath"] + DateTime.Now.ToString("yyyyMMdd") + "\\";
+                        if (!Directory.Exists(strFilePath))
+                        {
+                            Directory.CreateDirectory(strFilePath);
+                        }
+                        string ip = Get_IP(handle);
+                        string path = strFilePath + ip + "-" + DateTime.Now.ToString("hh_mm_ss") + ".jpg";
+                        int temp = VzClientSDK.VzLPRClient_ImageSaveToJpeg(pImgFull, path, 50);
+                        if (temp != -1)
+                        {
+                            LogFile logFile = LogFile.LOG;
+                            Log.WriteLog(logFile, "号牌机" + ip + "已拍照,图片保存于 " + strFilePath);
+                            UILogServer.ins.info("号牌机" + ip + "已拍照,图片保存于 " + strFilePath);
+                        }
+                        else
+                        {
+                            UILogServer.ins.info("图片保存失败");
+                        }
                     }
-                    
                     snapshotDevHandle = -1;
                 }
                 int size = Marshal.SizeOf(plateInfo);
@@ -557,10 +559,10 @@ namespace parkMonitor.server
                 AutoSize = false,
                 Name = "PictureBox" + Convert.ToString(index)
             };
-            if (!picNameMap.ContainsKey(pb.Name))
+            if (!namePicMap.ContainsKey(pb.Name))
             {
                 flowLayoutPanel1.Controls.Add(pb);
-                picNameMap.Add(pb.Name, pb);
+                namePicMap.Add(pb.Name, pb);
                 return true;
             }
             else
@@ -607,7 +609,7 @@ namespace parkMonitor.server
         {
             Task.Run(() =>
             {
-                closing = false;
+                isClosing = false;
 
                 try
                 {
@@ -628,229 +630,229 @@ namespace parkMonitor.server
                 Run();
             });
 
-            //Task imgTest = Task.Factory.StartNew(() =>
-            //{
-            //    while (!closing)
-            //    {
-            //        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(5000);
+                }
+            });
 
         }
 
-    /// <summary>
-    /// 系统关闭
-    /// </summary>
-    public void Stop()
-    {
-        VzClientSDK.VZLPRClient_StopFindDevice();
-        Dictionary<int, PictureBox>.Enumerator enumer = devPicMap.GetEnumerator();
-        do
+        /// <summary>
+        /// 系统关闭
+        /// </summary>
+        public void Stop()
         {
-            if (enumer.Current.Key != 0)
+            VzClientSDK.VZLPRClient_StopFindDevice();
+            Dictionary<int, PictureBox>.Enumerator enumer = devPicMap.GetEnumerator();
+            do
             {
-                StopPlay(enumer.Current.Key);
-                VzClientSDK.VzLPRClient_Close(enumer.Current.Key);
-                flowLayoutPanel1.Controls.Remove(enumer.Current.Value);
-            }
-        } while (enumer.MoveNext());
-        closing = true;
-        devPicMap.Clear();
-        picNameMap.Clear();
-        ipIdMap.Clear();
-        ipHandleMap.Clear();
-        //this.Close();
-    }
+                if (enumer.Current.Key != 0)
+                {
+                    StopPlay(enumer.Current.Key);
+                    VzClientSDK.VzLPRClient_Close(enumer.Current.Key);
+                    flowLayoutPanel1.Controls.Remove(enumer.Current.Value);
+                }
+            } while (enumer.MoveNext());
+            isClosing = true;
+            devPicMap.Clear();
+            namePicMap.Clear();
+            ipIdMap.Clear();
+            ipHandleMap.Clear();
+            //this.Close();
+        }
 
-    /// <summary>
-    /// 监控线程获取号牌机信息,核心线程获取号牌信息
-    /// </summary>
-    public AbstractMessage GetMessage()
-    {
-        lock (LicBuffer)
+        /// <summary>
+        /// 监控线程获取号牌机信息,核心线程获取号牌信息
+        /// </summary>
+        public AbstractMessage GetMessage()
         {
-            //准备输出的数据中存在非法Node,且LicBuffer可出队产生一个合法Node,则替换该非法Node,否则让Node=null
-            if (!NodeValidation(nmMsg.aNode))
+            lock (LicBuffer)
             {
-                for (int i = 0; i < LicBuffer.Count; i++)
+                //准备输出的数据中存在非法Node,且LicBuffer可出队产生一个合法Node,则替换该非法Node,否则让Node=null
+                if (!NodeValidation(nmMsg.aNode))
                 {
-                    NumberMachineNode n = LicBuffer.Dequeue();
-                    if (NodeValidation(n))
+                    for (int i = 0; i < LicBuffer.Count; i++)
                     {
-                        if (nmMsg.aNode != null && nmMsg.aNode.ip != null)
+                        NumberMachineNode n = LicBuffer.Dequeue();
+                        if (NodeValidation(n))
                         {
-                            LicBuffer.Enqueue((NumberMachineNode)nmMsg.aNode.Clone());
+                            if (nmMsg.aNode != null && nmMsg.aNode.ip != null)
+                            {
+                                LicBuffer.Enqueue((NumberMachineNode)nmMsg.aNode.Clone());
+                            }
+                            nmMsg.aNode = n;
+                            break;
+                        }
+                        else
+                        {
+                            LicBuffer.Enqueue(n);
                         }
-                        nmMsg.aNode = n;
-                        break;
-                    }
-                    else
-                    {
-                        LicBuffer.Enqueue(n);
                     }
                 }
             }
+            //if (NodeValidation(nmMsg.aNode) && ipIdMap.TryGetValue(nmMsg.aNode.ip, out int id))
+            //{
+            //    nmMsg.aNode.id = id;
+            //}
+            return nmMsg;
         }
-        //if (NodeValidation(nmMsg.aNode) && ipIdMap.TryGetValue(nmMsg.aNode.ip, out int id))
-        //{
-        //    nmMsg.aNode.id = id;
-        //}
-        return nmMsg;
-    }
 
-    /// <summary>
-    /// 一次停车流程完成时调用该方法,发送已完成车辆号牌信息
-    /// </summary>
-    /// <param name="message">已完成车辆的号牌相关信息存于message的aNode中,用于标记需清空的号牌</param>
-    public void SetMessage(AbstractMessage message)
-    {
-        if (message.GetType().Equals(typeof(NumberMachineMessage)))
+        /// <summary>
+        /// 一次停车流程完成时调用该方法,发送已完成车辆号牌信息
+        /// </summary>
+        /// <param name="message">已完成车辆的号牌相关信息存于message的aNode中,用于标记需清空的号牌</param>
+        public void SetMessage(AbstractMessage message)
         {
-            NumberMachineNode n = ((NumberMachineMessage)message).aNode;
-            lock (LicBuffer)
+            if (message.GetType().Equals(typeof(NumberMachineMessage)))
             {
-                //输入号牌格式无误
-                if (n != null && n.ip != null && n.ip == "")
+                NumberMachineNode n = ((NumberMachineMessage)message).aNode;
+                lock (LicBuffer)
                 {
-                    //与类成员变量中aNode号牌相同,将其ip复位表示已使用,重新入队等待清除
-                    if (nmMsg != null && nmMsg.aNode != null && nmMsg.aNode.LicenseNum.Equals(n.LicenseNum))
-                    {
-                        nmMsg.aNode.ip = "";
-                        LicBuffer.Enqueue((NumberMachineNode)nmMsg.aNode.Clone());
-                        nmMsg.aNode = null;
-                    }
-                    //搜索号牌队列,将相应号牌置空,准备清除
-                    else
+                    //输入号牌格式无误
+                    if (n != null && n.ip != null && n.ip == "")
                     {
-                        for (int i = 0; i < LicBuffer.Count; i++)
+                        //与类成员变量中aNode号牌相同,将其ip复位表示已使用,重新入队等待清除
+                        if (nmMsg != null && nmMsg.aNode != null && nmMsg.aNode.LicenseNum.Equals(n.LicenseNum))
                         {
-                            NumberMachineNode temp = LicBuffer.Dequeue();
-                            //已匹配上,ip置空
-                            if (temp.LicenseNum.Equals(n.LicenseNum))
+                            nmMsg.aNode.ip = "";
+                            LicBuffer.Enqueue((NumberMachineNode)nmMsg.aNode.Clone());
+                            nmMsg.aNode = null;
+                        }
+                        //搜索号牌队列,将相应号牌置空,准备清除
+                        else
+                        {
+                            for (int i = 0; i < LicBuffer.Count; i++)
                             {
-                                temp.ip = "";
+                                NumberMachineNode temp = LicBuffer.Dequeue();
+                                //已匹配上,ip置空
+                                if (temp.LicenseNum.Equals(n.LicenseNum))
+                                {
+                                    temp.ip = "";
+                                    LicBuffer.Enqueue(temp);
+                                    break;
+                                }
                                 LicBuffer.Enqueue(temp);
-                                break;
                             }
-                            LicBuffer.Enqueue(temp);
                         }
                     }
                 }
             }
-        }
-        //传入异常号牌,根据ip找到handle,改变snapshotDevHandle的值在回调函数中截图
-        if (message.GetType().Equals(typeof(Command)))
-        {
-            Command cmd = (Command)message;
-            if (cmd != null && cmd.id != 0)
+            //传入异常号牌,根据ip找到handle,改变snapshotDevHandle的值在回调函数中截图
+            if (message.GetType().Equals(typeof(Command)))
             {
-                Dictionary<string, int>.Enumerator enumerator = ipIdMap.GetEnumerator();
-                do
+                Command cmd = (Command)message;
+                if (cmd != null && cmd.id != 0)
                 {
-                   // 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))
+                    Dictionary<string, int>.Enumerator enumerator = ipIdMap.GetEnumerator();
+                    do
                     {
-                        snapshotDevHandle = handle;
-                        break;
-                    }
-                } while (enumerator.MoveNext());
-            }
-            else
-            {
-                UILogServer.ins.error("参数错误,图片未保存");
+                        // 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;
+                        }
+                    } while (enumerator.MoveNext());
+                }
+                else
+                {
+                    UILogServer.ins.error("参数错误,图片未保存");
+                }
             }
-        }
 
+        }
     }
-}
-public class Win32API
-{
-    [DllImport("User32.dll", EntryPoint = "FindWindow")]
-    public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
+    public class Win32API
+    {
+        [DllImport("User32.dll", EntryPoint = "FindWindow")]
+        public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
 
-    [DllImport("User32.dll", EntryPoint = "FindWindowEx")]
-    public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpClassName, string lpWindowName);
+        [DllImport("User32.dll", EntryPoint = "FindWindowEx")]
+        public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpClassName, string lpWindowName);
 
-    /// <summary>
-    /// 自定义的结构
-    /// </summary>
-    public struct My_lParam
-    {
-        public int i;
-        public string s;
-    }
-    /// <summary>
-    /// 使用COPYDATASTRUCT来传递字符串
-    /// </summary>
-    [StructLayout(LayoutKind.Sequential)]
-    public struct COPYDATASTRUCT
-    {
-        public IntPtr dwData;
-        public int cbData;
-        [MarshalAs(UnmanagedType.LPStr)]
-        public string lpData;
-    }
-    //消息发送API
-    [DllImport("User32.dll", EntryPoint = "SendMessage")]
-    public static extern int SendMessage(
-        IntPtr hWnd,        // 信息发往的窗口的句柄
-       int Msg,            // 消息ID
-        int wParam,         // 参数1
-        int lParam          //参数2
-    );
-
-
-    //消息发送API
-    [DllImport("User32.dll", EntryPoint = "SendMessage")]
-    public static extern int SendMessage(
-        IntPtr hWnd,        // 信息发往的窗口的句柄
-       int Msg,            // 消息ID
-        int wParam,         // 参数1
-        ref My_lParam lParam //参数2
-    );
-
-    //消息发送API
-    [DllImport("User32.dll", EntryPoint = "SendMessage")]
-    public static extern int SendMessage(
-        IntPtr hWnd,        // 信息发往的窗口的句柄
-       int Msg,            // 消息ID
-        int wParam,         // 参数1
-        ref COPYDATASTRUCT lParam  //参数2
-    );
-
-    //消息发送API
-    [DllImport("User32.dll", EntryPoint = "PostMessage")]
-    public static extern int PostMessage(
-        IntPtr hWnd,        // 信息发往的窗口的句柄
-       int Msg,            // 消息ID
-        int wParam,         // 参数1
-        int lParam            // 参数2
-    );
-
-
-    //消息发送API
-    [DllImport("User32.dll", EntryPoint = "PostMessage")]
-    public static extern int PostMessage(
-        IntPtr hWnd,        // 信息发往的窗口的句柄
-       int Msg,            // 消息ID
-        int wParam,         // 参数1
-        ref My_lParam lParam //参数2
-    );
-
-    //异步消息发送API
-    [DllImport("User32.dll", EntryPoint = "PostMessage")]
-    public static extern int PostMessage(
-        IntPtr hWnd,        // 信息发往的窗口的句柄
-       int Msg,            // 消息ID
-        int wParam,         // 参数1
-        ref COPYDATASTRUCT lParam  // 参数2
-    );
+        /// <summary>
+        /// 自定义的结构
+        /// </summary>
+        public struct My_lParam
+        {
+            public int i;
+            public string s;
+        }
+        /// <summary>
+        /// 使用COPYDATASTRUCT来传递字符串
+        /// </summary>
+        [StructLayout(LayoutKind.Sequential)]
+        public struct COPYDATASTRUCT
+        {
+            public IntPtr dwData;
+            public int cbData;
+            [MarshalAs(UnmanagedType.LPStr)]
+            public string lpData;
+        }
+        //消息发送API
+        [DllImport("User32.dll", EntryPoint = "SendMessage")]
+        public static extern int SendMessage(
+            IntPtr hWnd,        // 信息发往的窗口的句柄
+           int Msg,            // 消息ID
+            int wParam,         // 参数1
+            int lParam          //参数2
+        );
+
+
+        //消息发送API
+        [DllImport("User32.dll", EntryPoint = "SendMessage")]
+        public static extern int SendMessage(
+            IntPtr hWnd,        // 信息发往的窗口的句柄
+           int Msg,            // 消息ID
+            int wParam,         // 参数1
+            ref My_lParam lParam //参数2
+        );
+
+        //消息发送API
+        [DllImport("User32.dll", EntryPoint = "SendMessage")]
+        public static extern int SendMessage(
+            IntPtr hWnd,        // 信息发往的窗口的句柄
+           int Msg,            // 消息ID
+            int wParam,         // 参数1
+            ref COPYDATASTRUCT lParam  //参数2
+        );
+
+        //消息发送API
+        [DllImport("User32.dll", EntryPoint = "PostMessage")]
+        public static extern int PostMessage(
+            IntPtr hWnd,        // 信息发往的窗口的句柄
+           int Msg,            // 消息ID
+            int wParam,         // 参数1
+            int lParam            // 参数2
+        );
+
+
+        //消息发送API
+        [DllImport("User32.dll", EntryPoint = "PostMessage")]
+        public static extern int PostMessage(
+            IntPtr hWnd,        // 信息发往的窗口的句柄
+           int Msg,            // 消息ID
+            int wParam,         // 参数1
+            ref My_lParam lParam //参数2
+        );
+
+        //异步消息发送API
+        [DllImport("User32.dll", EntryPoint = "PostMessage")]
+        public static extern int PostMessage(
+            IntPtr hWnd,        // 信息发往的窗口的句柄
+           int Msg,            // 消息ID
+            int wParam,         // 参数1
+            ref COPYDATASTRUCT lParam  // 参数2
+        );
 
-}
+    }
 }

+ 3 - 15
parkMonitor/server/PLCLinker/PLCLinker.cs

@@ -62,9 +62,6 @@ namespace parkMonitor.server
         private int parking_startRobot_address;
         //addresses for laser data to be written to plc
         private int parkingSpaceID_address;
-        private int parkingSpaceX_address;
-        private int parkingSpaceY_address;
-        private int parkingSpaceZ_address;
         //addresses for space info to be written to plc
         private int parkingLaserCenterX_address;
         //parameters(addresses) for Laser monitoring
@@ -100,9 +97,6 @@ namespace parkMonitor.server
                 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")); 
-                //parkingSpaceX_address = Int32.Parse(ConfigurationManager.AppSettings.Get("parkingSpaceX_address"));
-                //parkingSpaceY_address = Int32.Parse(ConfigurationManager.AppSettings.Get("parkingSpaceY_address"));
-                //parkingSpaceZ_address = Int32.Parse(ConfigurationManager.AppSettings.Get("parkingSpaceZ_address"));
 
                 fetching_startRobot_address = Int32.Parse(ConfigurationManager.AppSettings.Get("fetching_startRobot_address"));
                 fetch_to_address = Int32.Parse(ConfigurationManager.AppSettings.Get("fetch_to_address"));
@@ -460,11 +454,6 @@ namespace parkMonitor.server
             }
         }
 
-        private void WheelbaseRadarMonitor()
-        {
-
-        }
-
         //***************公有方法****************
         public AbstractMessage GetMessage()
         {
@@ -499,9 +488,9 @@ namespace parkMonitor.server
                 PLCNode pv = (PLCNode)message;
                 SendtoPLC(pv.Address, pv.Value);
             }
-            else if (message.GetType().Equals(typeof(ParkingMessage)))
+            else if (message.GetType().Equals(typeof(ControlMessage)))
             {
-                ParkingMessage pm = (ParkingMessage)message;
+                ControlMessage pm = (ControlMessage)message;
                 if (pm != null && pm.status != 0)
                 {
                     switch (pm.status)
@@ -528,7 +517,7 @@ namespace parkMonitor.server
                                 bool jumpOut = false;
                                 while (!jumpOut)
                                 {
-                                    Thread.Sleep(1000 + (new Random()).Next(5, 10) * 200);
+                                    Thread.Sleep(1000);
                                     if (plcMsg != null && plcMsg.originalPlcList.Count > lpuTemp.laser_status_address)
                                     {
                                         foreach (PLCNode node in plcMsg.originalPlcList)
@@ -541,7 +530,6 @@ namespace parkMonitor.server
                                             }
                                         }
                                     }
-                                    Thread.Sleep(200);
                                 }
                                 SendtoPLC(laser_start_addr, "0");
                                 foreach (LaserMessage lm in plcMsg.laserMsgList)