|
@@ -20,39 +20,16 @@ using parkMonitor.server.uiLogServer;
|
|
|
using System.Configuration;
|
|
|
using parkMonitor.LOG;
|
|
|
|
|
|
-/*
|
|
|
- * try {
|
|
|
- FormModbus form = new FormModbus();
|
|
|
- form.Start();
|
|
|
- //form.Show();
|
|
|
- Thread run = new Thread(form.Run);
|
|
|
- run.Start();
|
|
|
- }catch(Exception ex)
|
|
|
- {
|
|
|
-
|
|
|
- Debug.WriteLine("error");
|
|
|
- }
|
|
|
- */
|
|
|
-
|
|
|
namespace parkMonitor.server
|
|
|
{
|
|
|
- /*
|
|
|
- * 号牌机通信类
|
|
|
- *
|
|
|
- * 初始化
|
|
|
- * NumMachineLinker nml = new NumMachineLinker();
|
|
|
- * nml.Start();
|
|
|
- *
|
|
|
- * 读号牌
|
|
|
- * nml.getMessage();
|
|
|
- * nml.aModel.ip="";
|
|
|
- *
|
|
|
- * 结束
|
|
|
- * nml.Stop();
|
|
|
- *
|
|
|
- * */
|
|
|
+ /// <summary>
|
|
|
+ /// 号牌机通信类
|
|
|
+ /// </summary>
|
|
|
public partial class NumMachineLinker : Form, IEquipments
|
|
|
{
|
|
|
+ /// <summary>
|
|
|
+ /// 刷新时间间隔与个数
|
|
|
+ /// </summary>
|
|
|
public const int REFRESHINGTIME = 500, FILTERINGNUMBER = 8;
|
|
|
|
|
|
///<summary>通过设备句柄访问pic;链接时add,系统关闭时remove</summary>
|
|
@@ -83,9 +60,14 @@ namespace parkMonitor.server
|
|
|
VzClientSDK.VZLPRC_PLATE_INFO_CALLBACK m_PlateResultCB = null;
|
|
|
private const int MSG_PLATE_INFO = 0x901;
|
|
|
private const int MSG_DEVICE_INFO = 0x902;
|
|
|
- //private string m_sAppPath;
|
|
|
+ /// <summary>
|
|
|
+ /// 用于消息传递机制
|
|
|
+ /// </summary>
|
|
|
public IntPtr hwndMain;
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 号牌机类构造函数
|
|
|
+ /// </summary>
|
|
|
public NumMachineLinker()
|
|
|
{
|
|
|
Control.CheckForIllegalCrossThreadCalls = false;
|
|
@@ -100,9 +82,14 @@ namespace parkMonitor.server
|
|
|
hwndMain = this.Handle;
|
|
|
//m_sAppPath = System.IO.Directory.GetCurrentDirectory();
|
|
|
}
|
|
|
-
|
|
|
- public delegate void SetDateTime();////定义时钟委托
|
|
|
- public delegate void Begin_Read();//实时采集
|
|
|
+ /// <summary>
|
|
|
+ /// 定义时钟委托
|
|
|
+ /// </summary>
|
|
|
+ public delegate void SetDateTime();
|
|
|
+ /// <summary>
|
|
|
+ /// 实时采集
|
|
|
+ /// </summary>
|
|
|
+ public delegate void Begin_Read();
|
|
|
|
|
|
private void FormSiemens_Load(object sender, EventArgs e)
|
|
|
{
|
|
@@ -253,6 +240,92 @@ namespace parkMonitor.server
|
|
|
|
|
|
}
|
|
|
|
|
|
+ ///<summary>信息自动处理</summary>
|
|
|
+ protected override void DefWndProc(ref Message m)
|
|
|
+ {
|
|
|
+ IntPtr intptr;
|
|
|
+ VzClientSDK.VZ_LPR_MSG_PLATE_INFO plateInfo;
|
|
|
+ VzClientSDK.VZ_LPR_DEVICE_INFO deviceInfo;
|
|
|
+
|
|
|
+ int handle = 0;
|
|
|
+
|
|
|
+ switch (m.Msg)
|
|
|
+ {
|
|
|
+ case MSG_PLATE_INFO:
|
|
|
+
|
|
|
+ intptr = (IntPtr)m.WParam.ToInt32();
|
|
|
+ handle = m.LParam.ToInt32();
|
|
|
+ if (intptr != null)
|
|
|
+ {
|
|
|
+ //根据句柄获取设备IP
|
|
|
+ string strIP = Get_IP(handle);
|
|
|
+ plateInfo = (VzClientSDK.VZ_LPR_MSG_PLATE_INFO)Marshal.PtrToStructure(intptr, typeof(VzClientSDK.VZ_LPR_MSG_PLATE_INFO));
|
|
|
+ SetDetail(plateInfo, strIP);
|
|
|
+
|
|
|
+ Marshal.FreeHGlobal(intptr);
|
|
|
+ }
|
|
|
+
|
|
|
+ break;
|
|
|
+
|
|
|
+ case MSG_DEVICE_INFO:
|
|
|
+ intptr = (IntPtr)m.WParam.ToInt32();
|
|
|
+ if (intptr != null)
|
|
|
+ {
|
|
|
+ deviceInfo = (VzClientSDK.VZ_LPR_DEVICE_INFO)Marshal.PtrToStructure(intptr, typeof(VzClientSDK.VZ_LPR_DEVICE_INFO));
|
|
|
+ DeviceLink(deviceInfo.device_ip, deviceInfo.serial_no);
|
|
|
+ Marshal.FreeHGlobal(intptr);
|
|
|
+
|
|
|
+ }
|
|
|
+ break;
|
|
|
+
|
|
|
+ default:
|
|
|
+ base.DefWndProc(ref m);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ///<summary>ip+port字符串转ipe</summary>
|
|
|
+ private void GetIpEndPoint(string ipp, out IPEndPoint ipe)
|
|
|
+ {
|
|
|
+ IPAddress myIP = IPAddress.Parse(ipp.Remove(ipp.LastIndexOf(':')) + "");
|
|
|
+ string myPort = ipp.Substring(ipp.IndexOf(':') + 1);
|
|
|
+ ipe = new IPEndPoint(myIP, int.Parse(myPort));
|
|
|
+ }
|
|
|
+
|
|
|
+ ///<summary>与设备连接,启动更新设备状态线程,输出视频</summary>
|
|
|
+ private void DeviceLink(string pStrDev, string serialNO)
|
|
|
+ {
|
|
|
+ IPEndPoint ipe;
|
|
|
+ GetIpEndPoint(pStrDev, out ipe);
|
|
|
+ string ip = ipe.Address.ToString();
|
|
|
+ if (ipHandleMap.ContainsKey(ip))
|
|
|
+ {
|
|
|
+ //MessageBox.Show("设备已分配句柄");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ int handle = 0;
|
|
|
+ //找到设备,加入list
|
|
|
+ NumberMachineNode node = new NumberMachineNode(ip, 0, "", "", 1);
|
|
|
+ nmMsg.data.Add(node);
|
|
|
+ handle = VzClientSDK.VzLPRClient_Open(ip, (ushort)80, "admin", "admin");
|
|
|
+ Task.Factory.StartNew(() =>
|
|
|
+ {
|
|
|
+ UpdateStatus(node);
|
|
|
+ });
|
|
|
+ if (handle == 0)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ VzClientSDK.VzLPRClient_SetVideoEncodeType(handle, 0);
|
|
|
+ //将句柄加入
|
|
|
+ ipHandleMap.Add(ip, handle);
|
|
|
+ //MessageBox.Show("摄像头打开成功");
|
|
|
+ handleCallbackMap.Add(handle, null);
|
|
|
+ //链接句柄到新PictureBox
|
|
|
+ VideoOutput(handle);
|
|
|
+ }
|
|
|
+
|
|
|
///<summary>视频输出</summary>
|
|
|
private void VideoOutput(int handle)
|
|
|
{
|
|
@@ -359,49 +432,6 @@ namespace parkMonitor.server
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
- ///<summary>信息自动处理</summary>
|
|
|
- protected override void DefWndProc(ref Message m)
|
|
|
- {
|
|
|
- IntPtr intptr;
|
|
|
- VzClientSDK.VZ_LPR_MSG_PLATE_INFO plateInfo;
|
|
|
- VzClientSDK.VZ_LPR_DEVICE_INFO deviceInfo;
|
|
|
-
|
|
|
- int handle = 0;
|
|
|
-
|
|
|
- switch (m.Msg)
|
|
|
- {
|
|
|
- case MSG_PLATE_INFO:
|
|
|
-
|
|
|
- intptr = (IntPtr)m.WParam.ToInt32();
|
|
|
- handle = m.LParam.ToInt32();
|
|
|
- if (intptr != null)
|
|
|
- {
|
|
|
- //根据句柄获取设备IP
|
|
|
- string strIP = Get_IP(handle);
|
|
|
- plateInfo = (VzClientSDK.VZ_LPR_MSG_PLATE_INFO)Marshal.PtrToStructure(intptr, typeof(VzClientSDK.VZ_LPR_MSG_PLATE_INFO));
|
|
|
- SetDetail(plateInfo, strIP);
|
|
|
-
|
|
|
- Marshal.FreeHGlobal(intptr);
|
|
|
- }
|
|
|
-
|
|
|
- break;
|
|
|
-
|
|
|
- case MSG_DEVICE_INFO:
|
|
|
- intptr = (IntPtr)m.WParam.ToInt32();
|
|
|
- if (intptr != null)
|
|
|
- {
|
|
|
- deviceInfo = (VzClientSDK.VZ_LPR_DEVICE_INFO)Marshal.PtrToStructure(intptr, typeof(VzClientSDK.VZ_LPR_DEVICE_INFO));
|
|
|
- DeviceLink(deviceInfo.device_ip, deviceInfo.serial_no);
|
|
|
- Marshal.FreeHGlobal(intptr);
|
|
|
-
|
|
|
- }
|
|
|
- break;
|
|
|
-
|
|
|
- default:
|
|
|
- base.DefWndProc(ref m);
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
///<summary>记录车牌,时间,状态信息;刷新本地entity,并且入buffer</summary>
|
|
|
private void SetDetail(VzClientSDK.VZ_LPR_MSG_PLATE_INFO plateInformation, string strIP)
|
|
@@ -511,48 +541,6 @@ namespace parkMonitor.server
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- ///<summary>ip+port字符串转ipe</summary>
|
|
|
- private void GetIpEndPoint(string ipp, out IPEndPoint ipe)
|
|
|
- {
|
|
|
- IPAddress myIP = IPAddress.Parse(ipp.Remove(ipp.LastIndexOf(':')) + "");
|
|
|
- string myPort = ipp.Substring(ipp.IndexOf(':') + 1);
|
|
|
- ipe = new IPEndPoint(myIP, int.Parse(myPort));
|
|
|
- }
|
|
|
-
|
|
|
- ///<summary>与设备连接,启动更新设备状态线程,输出视频</summary>
|
|
|
- private void DeviceLink(string pStrDev, string serialNO)
|
|
|
- {
|
|
|
- IPEndPoint ipe;
|
|
|
- GetIpEndPoint(pStrDev, out ipe);
|
|
|
- string ip = ipe.Address.ToString();
|
|
|
- if (ipHandleMap.ContainsKey(ip))
|
|
|
- {
|
|
|
- //MessageBox.Show("设备已分配句柄");
|
|
|
- return;
|
|
|
- }
|
|
|
- int handle = 0;
|
|
|
- //找到设备,加入list
|
|
|
- NumberMachineNode node = new NumberMachineNode(ip, 0, "", "", 1);
|
|
|
- nmMsg.data.Add(node);
|
|
|
- handle = VzClientSDK.VzLPRClient_Open(ip, (ushort)80, "admin", "admin");
|
|
|
- Task.Factory.StartNew(() =>
|
|
|
- {
|
|
|
- UpdateStatus(node);
|
|
|
- });
|
|
|
- if (handle == 0)
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- VzClientSDK.VzLPRClient_SetVideoEncodeType(handle, 0);
|
|
|
- //将句柄加入
|
|
|
- ipHandleMap.Add(ip, handle);
|
|
|
- //MessageBox.Show("摄像头打开成功");
|
|
|
- handleCallbackMap.Add(handle,null);
|
|
|
- //链接句柄到新PictureBox
|
|
|
- VideoOutput(handle);
|
|
|
- }
|
|
|
-
|
|
|
///<summary>创建新pic并记录在picNameMap</summary>
|
|
|
private bool CreatePic(int index, out PictureBox pb)
|
|
|
{
|
|
@@ -775,6 +763,9 @@ namespace parkMonitor.server
|
|
|
|
|
|
}
|
|
|
}
|
|
|
+ /// <summary>
|
|
|
+ /// 消息发送api
|
|
|
+ /// </summary>
|
|
|
public class Win32API
|
|
|
{
|
|
|
[DllImport("User32.dll", EntryPoint = "FindWindow")]
|