|
@@ -10,6 +10,7 @@ using parkMonitor.entity;
|
|
|
using parkMonitor.LOG;
|
|
|
using parkMonitor.server.uiLogServer;
|
|
|
using parkMonitor.controlPanel;
|
|
|
+using parkMonitor.model;
|
|
|
|
|
|
namespace parkMonitor.server.CoreThread
|
|
|
{
|
|
@@ -99,13 +100,16 @@ namespace parkMonitor.server.CoreThread
|
|
|
Parking_Space temp = null;
|
|
|
while (enumer.MoveNext())
|
|
|
{
|
|
|
- if (enumer.Current.Value.parkingSpaceState == 0)
|
|
|
+ if (enumer.Current.Value != null)
|
|
|
{
|
|
|
- lps.Add(enumer.Current.Key, enumer.Current.Value);
|
|
|
- }
|
|
|
- else if (enumer.Current.Value.parkingSpaceState == 2 && enumer.Current.Value.licence == queueCmd.LicenseNum)
|
|
|
- {
|
|
|
- temp = (Parking_Space)(enumer.Current.Value.Clone());
|
|
|
+ if (enumer.Current.Value.parkingSpaceState == 0)
|
|
|
+ {
|
|
|
+ lps.Add(enumer.Current.Key, enumer.Current.Value);
|
|
|
+ }
|
|
|
+ else if (enumer.Current.Value.parkingSpaceState == 2 && enumer.Current.Value.licence == queueCmd.LicenseNum)
|
|
|
+ {
|
|
|
+ temp = (Parking_Space)(enumer.Current.Value.Clone());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
if (temp != null && !booking)
|
|
@@ -125,14 +129,17 @@ namespace parkMonitor.server.CoreThread
|
|
|
Dictionary<int, Parking_Space>.Enumerator enumer2 = lps.GetEnumerator();
|
|
|
while (enumer2.MoveNext())
|
|
|
{
|
|
|
- float deltaX = (enumer2.Current.Value.parkingSpaceX - pt_Ent.parkingEntX) * (float)xWeight;
|
|
|
- float deltaY = (enumer2.Current.Value.parkingSpaceY - pt_Ent.parkingEntY) * (float)yWeight;
|
|
|
- float deltaZ = (enumer2.Current.Value.parkingSpaceZ - pt_Ent.parkingEntZ) * (float)zWeight;
|
|
|
- float dist_sq = deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ;
|
|
|
- if (dist_sq < min_dis_sq)
|
|
|
+ if (enumer2.Current.Value != null)
|
|
|
{
|
|
|
- min_dis_sq = dist_sq;
|
|
|
- rps = enumer2.Current.Value;
|
|
|
+ float deltaX = (enumer2.Current.Value.parkingSpaceX - pt_Ent.parkingEntX) * (float)xWeight;
|
|
|
+ float deltaY = (enumer2.Current.Value.parkingSpaceY - pt_Ent.parkingEntY) * (float)yWeight;
|
|
|
+ float deltaZ = (enumer2.Current.Value.parkingSpaceZ - pt_Ent.parkingEntZ) * (float)zWeight;
|
|
|
+ float dist_sq = deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ;
|
|
|
+ if (dist_sq < min_dis_sq)
|
|
|
+ {
|
|
|
+ min_dis_sq = dist_sq;
|
|
|
+ rps = enumer2.Current.Value;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
count = lps.Count - 1;
|
|
@@ -205,7 +212,7 @@ namespace parkMonitor.server.CoreThread
|
|
|
Dictionary<int, Parking_Space>.Enumerator enumer = parkingSpaceStatusMap.GetEnumerator();
|
|
|
while (enumer.MoveNext())
|
|
|
{
|
|
|
- if (enumer.Current.Value.parkingSpaceState == 0) { count += 1; }
|
|
|
+ if (enumer.Current.Value!=null && enumer.Current.Value.parkingSpaceState == 0) { count += 1; }
|
|
|
}
|
|
|
}
|
|
|
return count;
|
|
@@ -221,7 +228,7 @@ namespace parkMonitor.server.CoreThread
|
|
|
Parking_Space temp = null;
|
|
|
while (enumer.MoveNext())
|
|
|
{
|
|
|
- if (enumer.Current.Value.parkingSpaceState == 2 && enumer.Current.Value.licence == license)
|
|
|
+ if (enumer.Current.Value!=null && enumer.Current.Value.parkingSpaceState == 2 && enumer.Current.Value.licence == license)
|
|
|
{
|
|
|
temp = (Parking_Space)(enumer.Current.Value.Clone());
|
|
|
}
|
|
@@ -247,7 +254,7 @@ namespace parkMonitor.server.CoreThread
|
|
|
parkingEntY = entY;
|
|
|
parkingEntZ = entZ;
|
|
|
}
|
|
|
- public CEntrance() : this(0,0,0)
|
|
|
+ public CEntrance() : this(0, 0, 0)
|
|
|
{
|
|
|
|
|
|
}
|
|
@@ -291,28 +298,60 @@ namespace parkMonitor.server.CoreThread
|
|
|
{
|
|
|
public static ParkingBufferManager ins { get; set; }
|
|
|
public int bufferCount { get; set; }
|
|
|
- public bool checkedManually { get; set; }
|
|
|
- public List<ParkingBuffer> bufferList = new List<ParkingBuffer>();
|
|
|
+ private int bufferAddress = 0, completeStatusAddress = 0;
|
|
|
+ public bool checkedAuto { get; set; }
|
|
|
+ public List<ParkingBuffer> bufferList = null;
|
|
|
public bool InitParkingBuffers()
|
|
|
{
|
|
|
- checkedManually = false;
|
|
|
+ checkedAuto = false;
|
|
|
+ bufferList = new List<ParkingBuffer>();
|
|
|
try
|
|
|
{
|
|
|
bufferCount = Int32.Parse(ConfigurationManager.AppSettings["bufferCount"]);
|
|
|
- for (int i = 1; i <= bufferCount; i++)
|
|
|
+ bufferAddress = Int32.Parse(ConfigurationManager.AppSettings["bufferAddress"]);
|
|
|
+ completeStatusAddress = Int32.Parse(ConfigurationManager.AppSettings["completeStatusAddress"]);
|
|
|
+ IEquipments plc = null;
|
|
|
+ List<PLCNode> pList = null;
|
|
|
+ while (plc == null)
|
|
|
+ {
|
|
|
+ plc = EquipmentSimpleFactory.ins.FindEquipment(EquipmentName.PLC);
|
|
|
+ }
|
|
|
+ pList = ((PLCMessage)plc.GetMessage()).originalPlcList;
|
|
|
+ //根据plc中数据初始化缓冲位
|
|
|
+ for (int i = 0; i < bufferCount; i++)
|
|
|
{
|
|
|
- //初始完全占用
|
|
|
- bufferList.Add(new ParkingBuffer(i));
|
|
|
+ for (int j = 0; j < pList.Count; j++)
|
|
|
+ {
|
|
|
+ if (pList[j].Address == (bufferAddress + i).ToString())
|
|
|
+ {
|
|
|
+ if (pList[j].Value == "1")
|
|
|
+ {
|
|
|
+ bufferList.Add(new ParkingBuffer(i + 1, true));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ else if (pList[j].Value == "0")
|
|
|
+ {
|
|
|
+ bufferList.Add(new ParkingBuffer(i + 1, false));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ UILogServer.ins.error("缓冲位数据异常,请检查plc相关数据");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- UILogServer.ins.warn("请手动确认缓冲位状态");
|
|
|
+ //UILogServer.ins.warn("请手动确认缓冲位状态");
|
|
|
Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "初始化缓冲位成功");
|
|
|
+ checkedAuto = true;
|
|
|
return true;
|
|
|
}
|
|
|
- catch { return false; }
|
|
|
+ catch { Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "初始化缓冲位失败"); return false; }
|
|
|
}
|
|
|
public ParkingBuffer MallocParkingBuffer(int numMachineID)
|
|
|
{
|
|
|
- if (!checkedManually)
|
|
|
+ if (!checkedAuto)
|
|
|
return null;
|
|
|
int min_dis_sq = 2500; //初始默认缓冲位距号牌ID 50 个单位
|
|
|
ParkingBuffer allocatedPB = null;
|