|
@@ -82,11 +82,39 @@ namespace parkMonitor.server.CoreThread
|
|
|
}
|
|
|
UILogServer.ins.info("收到web取车指令:" + cmd.LicenseNum);
|
|
|
}
|
|
|
+ //停车先遍历
|
|
|
else if (cmd.commandType.Equals('s'))
|
|
|
{
|
|
|
lock (StoreCmdQueue)
|
|
|
{
|
|
|
- StoreCmdQueue.Enqueue((Command)cmd.Clone());
|
|
|
+ NumberMachineNode num = null;
|
|
|
+ bool matched = false;
|
|
|
+ num = new NumberMachineNode();
|
|
|
+ lock (LicenseQueue)
|
|
|
+ {
|
|
|
+ for (int i = 0; i < LicenseQueue.Count; i++)
|
|
|
+ {
|
|
|
+ num = LicenseQueue.Dequeue();
|
|
|
+ //匹配成功
|
|
|
+ if (NumMachineNodeValidation(num) && cmd.LicenseNum.Equals(num.LicenseNum))
|
|
|
+ {
|
|
|
+ cmd.TimeRecord = num.TimeRecord;
|
|
|
+ cmd.ip = num.ip;
|
|
|
+ cmd.id = num.id;
|
|
|
+ ValidStoreCmdQueue.Enqueue((Command)cmd.Clone());
|
|
|
+ matched = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ LicenseQueue.Enqueue((NumberMachineNode)num.Clone());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!matched)
|
|
|
+ {
|
|
|
+ StoreCmdQueue.Enqueue((Command)cmd.Clone());
|
|
|
+ }
|
|
|
}
|
|
|
UILogServer.ins.info("收到web停车指令:" + cmd.LicenseNum);
|
|
|
}
|
|
@@ -106,21 +134,49 @@ namespace parkMonitor.server.CoreThread
|
|
|
private void Run()
|
|
|
{
|
|
|
NumberMachineNode temp = null;
|
|
|
+ Command cmd = null;
|
|
|
while (!isClosing)
|
|
|
{
|
|
|
lock (LicenseQueue)
|
|
|
{
|
|
|
+ bool matched = false;
|
|
|
//本地号牌已使用,则接收新的号牌消息
|
|
|
if (numMachineHandle != null && !NumMachineNodeValidation(license))
|
|
|
{
|
|
|
license = ((NumberMachineMessage)numMachineHandle.GetMessage()).aNode;
|
|
|
- //无重复则入号牌队列,并将号牌机线程获得的Node中ip标记为已使用
|
|
|
+ //无重复则匹配指令,匹配失败则入号牌队列,并将号牌机线程获得的Node中ip标记为已使用
|
|
|
if (NumMachineNodeValidation(license) && !LicenseQueue.Contains(license))
|
|
|
{
|
|
|
- LicenseQueue.Enqueue((NumberMachineNode)license.Clone());
|
|
|
+ UILogServer.ins.info("已扫描到号牌:" + license.LicenseNum + ",匹配中");
|
|
|
+ Console.WriteLine("已扫描到号牌:" + license.LicenseNum + ",匹配中");
|
|
|
+ //先匹配指令
|
|
|
+ cmd = new Command();
|
|
|
+ lock (StoreCmdQueue)
|
|
|
+ {
|
|
|
+ for (int i = 0; NumMachineNodeValidation(license) && i < StoreCmdQueue.Count; i++)
|
|
|
+ {
|
|
|
+ cmd = StoreCmdQueue.Dequeue();
|
|
|
+ //匹配成功
|
|
|
+ if (license.LicenseNum.Equals(cmd.LicenseNum))
|
|
|
+ {
|
|
|
+ cmd.TimeRecord = license.TimeRecord;
|
|
|
+ cmd.ip = license.ip;
|
|
|
+ cmd.id = license.id;
|
|
|
+ ValidStoreCmdQueue.Enqueue((Command)cmd.Clone());
|
|
|
+ matched = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ StoreCmdQueue.Enqueue((Command)cmd.Clone());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!matched)
|
|
|
+ {
|
|
|
+ LicenseQueue.Enqueue((NumberMachineNode)license.Clone());
|
|
|
+ }
|
|
|
license.ip = "used";
|
|
|
- UILogServer.ins.info("已扫描到号牌:" + license.LicenseNum + ",开始排队");
|
|
|
- Console.WriteLine("已扫描到号牌:" + license.LicenseNum + ",开始排队");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -136,7 +192,7 @@ namespace parkMonitor.server.CoreThread
|
|
|
}
|
|
|
|
|
|
//队列业务逻辑
|
|
|
- UserCmdMatch();
|
|
|
+ //UserCmdMatch();
|
|
|
Scheduling();
|
|
|
lock (StoreCmdQueue)
|
|
|
{
|
|
@@ -234,7 +290,8 @@ namespace parkMonitor.server.CoreThread
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
+ /*/// <summary>
|
|
|
+ /// 注:匹配已分别在获得号牌与指令时进行!!!
|
|
|
/// 停车匹配,一轮中从停车指令队列取一个,遍历号牌队列;之后反之,以号牌遍历停车指令队列
|
|
|
/// 匹配上则入合法指令队列,并标记号牌队列相应元素为已使用
|
|
|
/// </summary>
|
|
@@ -312,7 +369,7 @@ namespace parkMonitor.server.CoreThread
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
/// <summary>
|
|
|
/// 停取车调度,控制停取车比例,可多取一停,也可一取一停
|