|
@@ -1,5 +1,6 @@
|
|
|
using centralController;
|
|
|
using parkMonitor.entity;
|
|
|
+using parkMonitor.LOG;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Configuration;
|
|
@@ -23,7 +24,7 @@ namespace NumMachine
|
|
|
/// <summary>
|
|
|
/// 刷新时间间隔与个数
|
|
|
/// </summary>
|
|
|
- public const int REFRESHINGTIME = 500, FILTERINGNUMBER = 4;
|
|
|
+ public const int REFRESHINGTIME = 500, FILTERINGNUMBER = 5;
|
|
|
///<summary>通过设备句柄访问pic;链接时add,系统关闭时remove</summary>
|
|
|
private static Dictionary<int, IntPtr> devPicMap = new Dictionary<int, IntPtr>();
|
|
|
///<summary>通过名字获取pic对象;创建pic时add,系统关闭remove</summary>
|
|
@@ -391,6 +392,7 @@ namespace NumMachine
|
|
|
//号牌不为空
|
|
|
if (!(plateInformation.plate.Contains("_无_")))
|
|
|
{
|
|
|
+ Log.WriteLog(LogType.process, LogFile.INFO, nmn.id + "收到号牌回调信息: [" + plateInformation.plate + "]");
|
|
|
nmn.SetLic(strIP, nmn.id, plateInformation.plate, DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss"), GetStatus(strIP));
|
|
|
FilterLic(strIP, (NumberMachineNode)nmn.Clone());
|
|
|
}
|
|
@@ -427,7 +429,7 @@ namespace NumMachine
|
|
|
private void FilterLic(string ip, NumberMachineNode nmn)
|
|
|
{
|
|
|
int id = 0, activeCount = 0;
|
|
|
- if (ipIdMap.TryGetValue(ip, out id) && idCountMap.TryGetValue(id, out activeCount) && activeCount < FILTERINGNUMBER)
|
|
|
+ if (ipIdMap.TryGetValue(ip, out id) && idCountMap.TryGetValue(id, out activeCount))// && activeCount < FILTERINGNUMBER)
|
|
|
{
|
|
|
Dictionary<NumberMachineNode, int> filter;
|
|
|
//该filter不存在则创建
|
|
@@ -491,29 +493,34 @@ namespace NumMachine
|
|
|
while (enumer.MoveNext())
|
|
|
{
|
|
|
////遍历,计数达标且队列中无此号牌
|
|
|
+ Log.WriteLog(LogType.process, LogFile.INFO, "filter中号牌:" + enumer.Current.Key.LicenseNum + ", 个数:" + enumer.Current.Value);
|
|
|
//if (enumer.Current.Value >= (int)(filterCount * filterRatio) && enumer.Current.Key != null && !LicBuffer.Contains(enumer.Current.Key))
|
|
|
//找到最大计数及相应号牌信息
|
|
|
- if (enumer.Current.Value >= maxCount && enumer.Current.Key != null && !LicBuffer.Contains(enumer.Current.Key))
|
|
|
+ if (enumer.Current.Value >= maxCount && enumer.Current.Key != null)// && !LicBuffer.Contains(enumer.Current.Key))
|
|
|
{
|
|
|
- //输出节点为空或与该号牌不同
|
|
|
- if (nmMsg.aNode == null || nmMsg.aNode.LicenseNum == null || nmMsg.aNode.LicenseNum != enumer.Current.Key.LicenseNum)
|
|
|
- {
|
|
|
- maxCount = enumer.Current.Value;
|
|
|
- node = (NumberMachineNode)enumer.Current.Key.Clone();
|
|
|
- if (node != null && ipIdMap.TryGetValue(node.ip, out node.id))
|
|
|
- {
|
|
|
- LicBuffer.Enqueue((NumberMachineNode)node.Clone());
|
|
|
- if (Monitor.Monitor.allInOneMachine != null)
|
|
|
- {
|
|
|
- Monitor.Monitor.allInOneMachine.DispForAWhile(2, node.LicenseNum, 25, 1, node.LicenseNum + ",入场");
|
|
|
- Monitor.Monitor.allInOneMachine.DispForAWhile(3, "号牌机编号:" + node.id, 25, 1, "");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ ////输出节点为空或与该号牌不同
|
|
|
+ //if (nmMsg.aNode == null || nmMsg.aNode.LicenseNum == null || nmMsg.aNode.LicenseNum != enumer.Current.Key.LicenseNum)
|
|
|
+ //{
|
|
|
+ maxCount = enumer.Current.Value;
|
|
|
+ node = (NumberMachineNode)enumer.Current.Key.Clone();
|
|
|
+ Log.WriteLog(LogType.process, LogFile.INFO, "筛出号牌:" + node);
|
|
|
+ //}
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (node != null)
|
|
|
+ //if (node != null && ipIdMap.TryGetValue(node.ip, out node.id))
|
|
|
+ {
|
|
|
+ //LicBuffer.Enqueue((NumberMachineNode)node.Clone());
|
|
|
+ LicBuffer.Enqueue(node);
|
|
|
+ Log.WriteLog(LogType.process, LogFile.INFO, "号牌入队:" + node.LicenseNum);
|
|
|
+ if (Monitor.Monitor.allInOneMachine != null)
|
|
|
+ {
|
|
|
+ Monitor.Monitor.allInOneMachine.DispForAWhile(2, node.LicenseNum, 25, 1, node.LicenseNum + ",入场");
|
|
|
+ Monitor.Monitor.allInOneMachine.DispForAWhile(3, "号牌机编号:" + node.id, 25, 1, "");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- filterCount = 0;
|
|
|
+ //filterCount = 0;
|
|
|
filter.Clear();
|
|
|
}
|
|
|
}
|
|
@@ -919,7 +926,7 @@ namespace NumMachine
|
|
|
/// <returns></returns>
|
|
|
public string GetLicensePlate(int id)
|
|
|
{
|
|
|
- string license = "";
|
|
|
+ string license = "空";
|
|
|
NumberMachineNode node = null;
|
|
|
//Task.Factory.StartNew(() =>
|
|
|
//{
|
|
@@ -953,43 +960,50 @@ namespace NumMachine
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- while (idCountMap[id] < FILTERINGNUMBER)
|
|
|
+ idCountMap[id] = 0;
|
|
|
+ int count = 0;
|
|
|
+ while (count <= FILTERINGNUMBER)
|
|
|
{
|
|
|
- Console.WriteLine(handle);
|
|
|
+ //Console.WriteLine(handle);
|
|
|
ActivateSnap(handle);
|
|
|
- Thread.Sleep((int)(REFRESHINGTIME * 0.6));
|
|
|
+ count++;
|
|
|
+ Thread.Sleep((int)(REFRESHINGTIME));
|
|
|
}
|
|
|
- idCountMap[id] = 0;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- int timeLimit = FILTERINGNUMBER + 2;
|
|
|
+ int timeLimit = FILTERINGNUMBER * 2;
|
|
|
while (node == null && timeLimit-- > 0)
|
|
|
{
|
|
|
lock (LicBuffer)
|
|
|
{
|
|
|
+ Log.WriteLog(LogType.process, LogFile.INFO, "licBuffer 元素个数:" + LicBuffer.Count);
|
|
|
for (int i = 0; i < LicBuffer.Count; i++)
|
|
|
{
|
|
|
node = LicBuffer.Dequeue();
|
|
|
if (node != null)
|
|
|
{
|
|
|
- if (node.id == id)
|
|
|
+ if (node.id == id && node.LicenseNum != "")
|
|
|
{
|
|
|
license = node.LicenseNum;
|
|
|
+ Log.WriteLog(LogType.process, LogFile.INFO, "license: " + license + ", id: " + id);
|
|
|
break;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ Log.WriteLog(LogType.process, LogFile.INFO, "other license: " + node.LicenseNum + ", id: " + node.id);
|
|
|
LicBuffer.Enqueue(node);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
Thread.Sleep(REFRESHINGTIME);
|
|
|
- if (timeLimit == 0) { Console.WriteLine("本次未找到号牌"); }
|
|
|
}
|
|
|
+ if (timeLimit <= 0) { Console.WriteLine("本次未找到号牌"); Log.WriteLog(LogType.process, LogFile.INFO, id + "号号牌机未找到号牌"); }
|
|
|
+ else { Log.WriteLog(LogType.process, LogFile.INFO, id + "号号牌机本次号牌: [" + license + "]"); }
|
|
|
//}).Wait();
|
|
|
- return license;
|
|
|
+
|
|
|
+ return license == "空" ? "" : license;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|