123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232 |
- using System;
- using System.Collections.Generic;
- namespace PLCLinker
- {
- /// <summary>
- /// 抽象消息类
- /// </summary>
- public abstract class AbstractMessage
- {
- }
- //********************************************* plc ************************************************
- /// <summary>
- /// plc节点类
- /// </summary>
- public class PLCNode : AbstractMessage
- {
- public string Address { get; set; }
- public string Value { get; set; }
- public PLCNode()
- {
- Address = "";
- Value = "";
- }
- public PLCNode(string addr, string v)
- {
- Address = addr;
- Value = v;
- }
- public override bool Equals(System.Object obj)
- {
- if (this == obj)
- return true;
- if (obj == null || obj.GetType() != this.GetType())
- return false;
- PLCNode p = obj as PLCNode;
- return (Address == p.Address) && (Value == p.Value);
- }
- public override int GetHashCode()
- {
- int hash = 7;
- return 31 * hash + Address.GetHashCode() + Value.GetHashCode();
- }
- }
- /// <summary>
- /// plc消息类
- /// </summary>
- public class PLCMessage : AbstractMessage, ICloneable
- {
- public List<PLCNode> extendedPlcList { get; set; }
- public List<PLCNode> originalPlcList { get; set; }
- public List<LaserMessage> laserMsgList { get; set; }
- public PLCMessage()
- {
- extendedPlcList = new List<PLCNode>();
- originalPlcList = new List<PLCNode>();
- laserMsgList = new List<LaserMessage>();
- }
- public object Clone()
- {
- PLCMessage plcClone = new PLCMessage();
- foreach (PLCNode pn in extendedPlcList)
- {
- plcClone.extendedPlcList.Add(pn);
- }
- foreach (PLCNode pn in originalPlcList)
- {
- plcClone.originalPlcList.Add(pn);
- }
- foreach (LaserMessage lm in laserMsgList)
- {
- plcClone.laserMsgList.Add(lm);
- }
- return plcClone;
- }
- }
- //********************************************** laser ************************************************
- /// <summary>
- /// 激光消息类
- /// </summary>
- public class LaserMessage : AbstractMessage, ICloneable
- {
- public int id { get; set; }
- public int status { get; set; }
- public bool recorded { get; set; }
- public bool abort_rescan { get; set; }
- public bool occupied { get; set; }
- public bool disconnected { get; set; }
- public string licenseNum { get; set; }
- public Data data;
- public LaserMessage()
- {
- data = new Data();
- licenseNum = "";
- }
- public LaserMessage(int id, int status)
- {
- this.id = id;
- this.status = status;
- abort_rescan = false;
- disconnected = false;
- data = new Data();
- }
- public object Clone()
- {
- LaserMessage lm = new LaserMessage();
- lm.id = id;
- lm.status = status;
- lm.data = (Data)data.Clone();
- lm.recorded = recorded;
- lm.abort_rescan = abort_rescan;
- lm.licenseNum = licenseNum;
- lm.disconnected = disconnected;
- return lm;
- }
- }
- /// <summary>
- /// 激光数据类
- /// </summary>
- public class Data : ICloneable
- {
- public int centerX { get; set; }
- public int centerY { get; set; }
- public int angleA { get; set; }
- public int length { get; set; }
- public int width { get; set; }
- public int height { get; set; }
- public Data() : this(0, 0, 0, 0, 0, 0) { }
- public Data(int cx, int cy, int aa, int l, int w, int h)
- {
- centerX = cx;
- centerY = cy;
- angleA = aa;
- length = l;
- width = w;
- height = h;
- }
- public object Clone()
- {
- Data d = new Data(centerX, centerY, angleA, length, width, height);
- return d;
- }
- }
- //********************************************** command **********************************************
- /// <summary>
- /// 命令类,由队列线程处理号牌与指令后产生
- /// </summary>
- public class Command : AbstractMessage, ICloneable
- {
- public char commandType { get; set; }
- public string LicenseNum { get; set; }
- public string userID { get; set; }
- public int garageID { get; set; }
- public int parkingRecordsID { get; set; }
- public string TimeRecord { get; set; }
- public string ip { get; set; }//新添加,用于定位号牌机
- public int returnedCount { get; set; }//标记被返回的命令
- public int id { get; set; }
- public bool manual { get; set; }//判断是否手动停取
- public Command()
- {
- LicenseNum = "";
- TimeRecord = "";
- userID = "";
- garageID = 0;
- parkingRecordsID = 0;
- ip = "";
- returnedCount = 0;
- id = 0;
- manual = false;
- }
- public object Clone()
- {
- Command cmdClone = new Command();
- cmdClone.commandType = commandType;
- cmdClone.LicenseNum = LicenseNum;
- cmdClone.userID = userID;
- cmdClone.garageID = garageID;
- cmdClone.parkingRecordsID = parkingRecordsID;
- cmdClone.TimeRecord = TimeRecord;
- cmdClone.ip = ip;
- cmdClone.id = id;
- cmdClone.returnedCount = returnedCount;
- cmdClone.manual = manual;
- return cmdClone;
- }
- }
- /// <summary>
- /// 控制信息类,核心在不同阶段发至plc
- /// 1: 停车startLaser--park_command_address
- /// 2: 停车激光的6个数据,startRobot,车位信息4个
- /// 3:停车完成,归零--park_completed_address
- /// 4:取车startRobot,车位信息4个
- /// 5: 取车完成,归零-fetch_completed_address
- /// </summary>
- public class ControlMessage : AbstractMessage
- {
- public int status { get; set; }
- public string LicenseNum { get; set; }
- public int laserID { get; set; }//激光地址
- public string parkingSpaceID { get; set; }
- public string parkingSpaceX { get; set; }
- public string parkingSpaceY { get; set; }
- public string parkingSpaceZ { get; set; }
- public string centerX { get; set; }
- public string centerY { get; set; }
- public string angleA { get; set; }
- public string length { get; set; }
- public string width { get; set; }
- public string height { get; set; }
- public int fetchPosition { get; set; }//取车放置位置(临时缓冲位)
- public int RobotID { get; set; }//机械手编号
- public int frontWheelbase { get; set; }
- public int rearWheelbase { get; set; }
- }
- }
|