|
@@ -42,20 +42,74 @@ namespace parkMonitor.server.CoreThread
|
|
|
PLC = EquipmentSimpleFactory.ins.FindEquipment(EquipmentName.PLC);
|
|
|
//获取队列句柄
|
|
|
queuingThread = EquipmentSimpleFactory.ins.FindEquipment(EquipmentName.Queue);
|
|
|
+ //获取号牌机线程句柄
|
|
|
+ NumMachine = EquipmentSimpleFactory.ins.FindEquipment(EquipmentName.NumMachine);
|
|
|
//数据库
|
|
|
oper = new DBOperation();
|
|
|
//车位分配
|
|
|
c = new CEntrance();
|
|
|
aps = new AllotParkingSpace();
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public class StopCmd : AbstractCmd
|
|
|
{
|
|
|
+ /// <summary>
|
|
|
+ /// 命令中号牌与对应号牌机中当前号牌比对,确认车辆
|
|
|
+ /// </summary>
|
|
|
+ public bool NumValidation(Command queueCmd)
|
|
|
+ {
|
|
|
+ List<NumberMachineNode> numList = ((NumberMachineMessage)NumMachine.GetMessage()).data;
|
|
|
+ bool result = false;
|
|
|
+ Task numberCheck = Task.Factory.StartNew(() =>
|
|
|
+ {
|
|
|
+ int countdown = 8, count = 0;
|
|
|
+ while (countdown-- > 0)
|
|
|
+ {
|
|
|
+ foreach (NumberMachineNode node in numList)
|
|
|
+ {
|
|
|
+ if (queueCmd.ip.Equals(node.ip) && queueCmd.LicenseNum.Equals(node.LicenseNum))
|
|
|
+ {
|
|
|
+ count += 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Thread.Sleep(500);
|
|
|
+ }
|
|
|
+ if (count >= (int)(countdown * 0.8))
|
|
|
+ {
|
|
|
+ result = true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ result = false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ numberCheck.Wait();
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
public override void executeCmd(Command queueCmd)
|
|
|
{
|
|
|
+ int centerX = 0;
|
|
|
+ int centerY = 0;
|
|
|
+ int angleA = 0;
|
|
|
+ int length = 0;
|
|
|
+ int width = 0;
|
|
|
+ int height = 0;
|
|
|
PLCMessage PLCMsg = null;
|
|
|
int status = 1;//停车
|
|
|
+
|
|
|
+ //号牌验证,异常则退回队列
|
|
|
+ Func<Command, bool> numValidationResult = new Func<Command, bool>(NumValidation);
|
|
|
+ IAsyncResult result = numValidationResult.BeginInvoke(queueCmd, null, null);
|
|
|
+ bool checkResult = numValidationResult.EndInvoke(result);
|
|
|
+ if (!checkResult)
|
|
|
+ {
|
|
|
+ queuingThread.SetMessage(queueCmd);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
ParkingMessage pm = new ParkingMessage();
|
|
|
pm.status = status;
|
|
|
PLC.SetMessage(pm);
|
|
@@ -102,12 +156,6 @@ namespace parkMonitor.server.CoreThread
|
|
|
PLCMsg = (PLCMessage)PLC.GetMessage();
|
|
|
if (PLCMsg != null)
|
|
|
{
|
|
|
- int centerX = 0;
|
|
|
- int centerY = 0;
|
|
|
- int angleA = 0;
|
|
|
- int length = 0;
|
|
|
- int width = 0;
|
|
|
- int height = 0;
|
|
|
foreach (LaserMessage lm in PLCMsg.laserMsgList)
|
|
|
{
|
|
|
if(lm.id == 1 && lm.data!=null && lm.status == 3)
|
|
@@ -118,19 +166,6 @@ namespace parkMonitor.server.CoreThread
|
|
|
length = lm.data.length;
|
|
|
width = lm.data.width;
|
|
|
height = lm.data.height;
|
|
|
- status = 2;
|
|
|
- pm.status = status;
|
|
|
- pm.centerX = Convert.ToString(centerX);
|
|
|
- pm.centerY = Convert.ToString(centerY);
|
|
|
- pm.angleA = Convert.ToString(angleA);
|
|
|
- pm.length = Convert.ToString(length);
|
|
|
- pm.width = Convert.ToString(width);
|
|
|
- pm.height = Convert.ToString(height);
|
|
|
- pm.parkingSpaceID = Convert.ToString(parkingSpaceID);
|
|
|
- pm.parkingSpaceX = Convert.ToString(parkingSpaceX);
|
|
|
- pm.parkingSpaceY = Convert.ToString(parkingSpaceY);
|
|
|
- pm.parkingSpaceZ = Convert.ToString(parkingSpaceZ);
|
|
|
- PLC.SetMessage(pm);
|
|
|
jumpOut = true;
|
|
|
break;
|
|
|
}else if (lm.status == -1)
|
|
@@ -150,6 +185,30 @@ namespace parkMonitor.server.CoreThread
|
|
|
//Task.WaitAll(dataFromLaser,parkingSpace);
|
|
|
dataFromLaser.Wait();
|
|
|
|
|
|
+ //号牌验证,异常则退回队列
|
|
|
+ numValidationResult = new Func<Command, bool>(NumValidation);
|
|
|
+ result = numValidationResult.BeginInvoke(queueCmd, null, null);
|
|
|
+ checkResult = numValidationResult.EndInvoke(result);
|
|
|
+ if (!checkResult)
|
|
|
+ {
|
|
|
+ queuingThread.SetMessage(queueCmd);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ status = 2;
|
|
|
+ pm.status = status;
|
|
|
+ pm.centerX = Convert.ToString(centerX);
|
|
|
+ pm.centerY = Convert.ToString(centerY);
|
|
|
+ pm.angleA = Convert.ToString(angleA);
|
|
|
+ pm.length = Convert.ToString(length);
|
|
|
+ pm.width = Convert.ToString(width);
|
|
|
+ pm.height = Convert.ToString(height);
|
|
|
+ pm.parkingSpaceID = Convert.ToString(parkingSpaceID);
|
|
|
+ pm.parkingSpaceX = Convert.ToString(parkingSpaceX);
|
|
|
+ pm.parkingSpaceY = Convert.ToString(parkingSpaceY);
|
|
|
+ pm.parkingSpaceZ = Convert.ToString(parkingSpaceZ);
|
|
|
+ PLC.SetMessage(pm);
|
|
|
+
|
|
|
Console.WriteLine("停车,抓车:" + queueCmd.LicenseNum);
|
|
|
Log.WriteLog("停车,抓车:" + queueCmd.LicenseNum);
|
|
|
UILogServer.ins.info("停车,抓车:" + queueCmd.LicenseNum);
|
|
@@ -171,17 +230,19 @@ namespace parkMonitor.server.CoreThread
|
|
|
status = 3;
|
|
|
pm.status = status;
|
|
|
PLC.SetMessage(pm);
|
|
|
+
|
|
|
//停车完成,将相应车牌复位
|
|
|
NumberMachineMessage numberMachineMessage = new NumberMachineMessage();
|
|
|
numberMachineMessage.aNode = new NumberMachineNode();
|
|
|
numberMachineMessage.aNode.ip = "";
|
|
|
numberMachineMessage.aNode.LicenseNum = queueCmd.LicenseNum;
|
|
|
queuingThread.SetMessage(numberMachineMessage);
|
|
|
+
|
|
|
Console.WriteLine("停车完成,状态复位");
|
|
|
Log.WriteLog("停车完成,状态复位");
|
|
|
UILogServer.ins.info("停车完成,状态复位");
|
|
|
//根据号牌查找车型
|
|
|
- int vehicleTypeID = oper.getVehicleTypeID(numberPlate);
|
|
|
+ //int vehicleTypeID = oper.getVehicleTypeID(numberPlate);
|
|
|
//判断测量数据是否准确
|
|
|
//bool isDataRight = oper.IsDataRight(vehicleTypeLength, vehicleTypeWidth, vehicleTypeHeight, vehicleTypeWheelbase, vehicleTypeID);
|
|
|
|