AbstractMessage.cs 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. using System;
  2. using System.Collections.Generic;
  3. namespace PLCLinker
  4. {
  5. /// <summary>
  6. /// 抽象消息类
  7. /// </summary>
  8. public abstract class AbstractMessage
  9. {
  10. }
  11. //********************************************* plc ************************************************
  12. /// <summary>
  13. /// plc节点类
  14. /// </summary>
  15. public class PLCNode : AbstractMessage
  16. {
  17. public string Address { get; set; }
  18. public string Value { get; set; }
  19. public PLCNode()
  20. {
  21. Address = "";
  22. Value = "";
  23. }
  24. public PLCNode(string addr, string v)
  25. {
  26. Address = addr;
  27. Value = v;
  28. }
  29. public override bool Equals(System.Object obj)
  30. {
  31. if (this == obj)
  32. return true;
  33. if (obj == null || obj.GetType() != this.GetType())
  34. return false;
  35. PLCNode p = obj as PLCNode;
  36. return (Address == p.Address) && (Value == p.Value);
  37. }
  38. public override int GetHashCode()
  39. {
  40. int hash = 7;
  41. return 31 * hash + Address.GetHashCode() + Value.GetHashCode();
  42. }
  43. }
  44. /// <summary>
  45. /// plc消息类
  46. /// </summary>
  47. public class PLCMessage : AbstractMessage, ICloneable
  48. {
  49. public List<PLCNode> extendedPlcList { get; set; }
  50. public List<PLCNode> originalPlcList { get; set; }
  51. public List<LaserMessage> laserMsgList { get; set; }
  52. public PLCMessage()
  53. {
  54. extendedPlcList = new List<PLCNode>();
  55. originalPlcList = new List<PLCNode>();
  56. laserMsgList = new List<LaserMessage>();
  57. }
  58. public object Clone()
  59. {
  60. PLCMessage plcClone = new PLCMessage();
  61. foreach (PLCNode pn in extendedPlcList)
  62. {
  63. plcClone.extendedPlcList.Add(pn);
  64. }
  65. foreach (PLCNode pn in originalPlcList)
  66. {
  67. plcClone.originalPlcList.Add(pn);
  68. }
  69. foreach (LaserMessage lm in laserMsgList)
  70. {
  71. plcClone.laserMsgList.Add(lm);
  72. }
  73. return plcClone;
  74. }
  75. }
  76. //********************************************** laser ************************************************
  77. /// <summary>
  78. /// 激光消息类
  79. /// </summary>
  80. public class LaserMessage : AbstractMessage, ICloneable
  81. {
  82. public int id { get; set; }
  83. public int status { get; set; }
  84. public bool recorded { get; set; }
  85. public bool abort_rescan { get; set; }
  86. public bool occupied { get; set; }
  87. public bool disconnected { get; set; }
  88. public string licenseNum { get; set; }
  89. public Data data;
  90. public LaserMessage()
  91. {
  92. data = new Data();
  93. licenseNum = "";
  94. }
  95. public LaserMessage(int id, int status)
  96. {
  97. this.id = id;
  98. this.status = status;
  99. abort_rescan = false;
  100. disconnected = false;
  101. data = new Data();
  102. }
  103. public object Clone()
  104. {
  105. LaserMessage lm = new LaserMessage();
  106. lm.id = id;
  107. lm.status = status;
  108. lm.data = (Data)data.Clone();
  109. lm.recorded = recorded;
  110. lm.abort_rescan = abort_rescan;
  111. lm.licenseNum = licenseNum;
  112. lm.disconnected = disconnected;
  113. return lm;
  114. }
  115. }
  116. /// <summary>
  117. /// 激光数据类
  118. /// </summary>
  119. public class Data : ICloneable
  120. {
  121. public int centerX { get; set; }
  122. public int centerY { get; set; }
  123. public int angleA { get; set; }
  124. public int length { get; set; }
  125. public int width { get; set; }
  126. public int height { get; set; }
  127. public Data() : this(0, 0, 0, 0, 0, 0) { }
  128. public Data(int cx, int cy, int aa, int l, int w, int h)
  129. {
  130. centerX = cx;
  131. centerY = cy;
  132. angleA = aa;
  133. length = l;
  134. width = w;
  135. height = h;
  136. }
  137. public object Clone()
  138. {
  139. Data d = new Data(centerX, centerY, angleA, length, width, height);
  140. return d;
  141. }
  142. }
  143. //********************************************** command **********************************************
  144. /// <summary>
  145. /// 命令类,由队列线程处理号牌与指令后产生
  146. /// </summary>
  147. public class Command : AbstractMessage, ICloneable
  148. {
  149. public char commandType { get; set; }
  150. public string LicenseNum { get; set; }
  151. public string userID { get; set; }
  152. public int garageID { get; set; }
  153. public int parkingRecordsID { get; set; }
  154. public string TimeRecord { get; set; }
  155. public string ip { get; set; }//新添加,用于定位号牌机
  156. public int returnedCount { get; set; }//标记被返回的命令
  157. public int id { get; set; }
  158. public bool manual { get; set; }//判断是否手动停取
  159. public Command()
  160. {
  161. LicenseNum = "";
  162. TimeRecord = "";
  163. userID = "";
  164. garageID = 0;
  165. parkingRecordsID = 0;
  166. ip = "";
  167. returnedCount = 0;
  168. id = 0;
  169. manual = false;
  170. }
  171. public object Clone()
  172. {
  173. Command cmdClone = new Command();
  174. cmdClone.commandType = commandType;
  175. cmdClone.LicenseNum = LicenseNum;
  176. cmdClone.userID = userID;
  177. cmdClone.garageID = garageID;
  178. cmdClone.parkingRecordsID = parkingRecordsID;
  179. cmdClone.TimeRecord = TimeRecord;
  180. cmdClone.ip = ip;
  181. cmdClone.id = id;
  182. cmdClone.returnedCount = returnedCount;
  183. cmdClone.manual = manual;
  184. return cmdClone;
  185. }
  186. }
  187. /// <summary>
  188. /// 控制信息类,核心在不同阶段发至plc
  189. /// 1: 停车startLaser--park_command_address
  190. /// 2: 停车激光的6个数据,startRobot,车位信息4个
  191. /// 3:停车完成,归零--park_completed_address
  192. /// 4:取车startRobot,车位信息4个
  193. /// 5: 取车完成,归零-fetch_completed_address
  194. /// </summary>
  195. public class ControlMessage : AbstractMessage
  196. {
  197. public int status { get; set; }
  198. public string LicenseNum { get; set; }
  199. public int laserID { get; set; }//激光地址
  200. public string parkingSpaceID { get; set; }
  201. public string parkingSpaceX { get; set; }
  202. public string parkingSpaceY { get; set; }
  203. public string parkingSpaceZ { get; set; }
  204. public string centerX { get; set; }
  205. public string centerY { get; set; }
  206. public string angleA { get; set; }
  207. public string length { get; set; }
  208. public string width { get; set; }
  209. public string height { get; set; }
  210. public int fetchPosition { get; set; }//取车放置位置(临时缓冲位)
  211. public int RobotID { get; set; }//机械手编号
  212. public int frontWheelbase { get; set; }
  213. public int rearWheelbase { get; set; }
  214. }
  215. }