JGRDataModel.cs 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. using AmrControl.Dto;
  2. using Newtonsoft.Json;
  3. using NPOI.SS.Formula.Functions;
  4. using System.IO;
  5. using System.Runtime.InteropServices;
  6. using System.Security.Policy;
  7. namespace AmrControl.ADS
  8. {
  9. [Serializable]
  10. public class JGR_Tc_Model
  11. {
  12. // 0:仓储车 , 1:运输车, 2:仓储位充电器,3:轨道位充电器
  13. public byte jgrType;
  14. //出厂编号,30个长度带'\0',有效最多29个字节
  15. public string jgrSN;
  16. //车ID,取值范围0~63,不同类型的车/充电器的jgrID可以重复
  17. public byte jgrID;
  18. //无线模块的地址,长度2字节
  19. public ushort rcAddr;
  20. //无线模块的频率码,取值0~155,对应频率为 900+RC_FreqCode*0.2,单位MHz,默认频率码为0x32(50)
  21. public byte rcFreqCode;
  22. //在线/离线状态 是否在线(通讯是否正常)
  23. public byte isOnline;
  24. //健康状态 =0:正常; >=1:异常,异常编码看接口给
  25. public byte isHealthy;
  26. //充电标志,1:充电中,0:未在充电
  27. public byte isCharging;
  28. //充电电压,单位:V
  29. public float chargeVoltage;
  30. //充电电流,单位:mA
  31. public float chargeCurrent;
  32. //电池剩余电量,取值 0~100 , 100表示满电量
  33. public byte electricity;
  34. //驱动器通电/断电状态
  35. public byte isDriverPowerOn;
  36. //(*工作模式
  37. //1: 正常工作模式,即自动控制模式,只需给出运动的目标坐标,动作序列小车自己控制,正常工作时使用;
  38. //2:调试模式,即手动控制模式,用于调试,每一个动作都需要发送指令*)
  39. public byte workMode;
  40. //车轮位置(车身姿态) =1高姿态,=2中姿态,=3低姿态
  41. public byte wheelPosition;
  42. //行进/停止状态
  43. //(* 车体运动状态
  44. //0:静止状态
  45. //1:X负向移动
  46. //2:X正向移动
  47. //3:Y负向移动
  48. //4:Y正向移动*)
  49. public byte moveStatus;
  50. //移动速度,单位:m/s
  51. public float moveSpeed;
  52. //当前位置X
  53. public short currLocation_X;
  54. //当前位置Y
  55. public short currLocation_Y;
  56. //目标位置X
  57. public short destLocation_X;
  58. //目标位置Y
  59. public short destLocation_Y;
  60. /// <summary>
  61. /// 显示位置X,Y坐标
  62. /// </summary>
  63. public int displayX;
  64. public int displayY;
  65. //车轮是否在位置切换中
  66. public byte isWheelAltering;
  67. //4个碰撞传感器,true:碰撞,false:未碰撞
  68. public byte[] collideSensor;
  69. //X加速度,单位 m/s2
  70. public float acceleration_X;
  71. //Y加速度,单位 m/s2
  72. public float acceleration_Y;
  73. //Z加速度,单位 m/s2
  74. public float acceleration_Z;
  75. //XZ角度,单位:°
  76. public float angleXZ;
  77. //YZ角度,单位:°
  78. public float angleYZ;
  79. //吊篮限位标志,吊篮处于的位置 0:最高点; 1~7层
  80. public byte basketPosition;
  81. //吊篮抓夹状态 1:闭合状态; 2:张开状态
  82. public byte basketGripperStatus;
  83. //吊篮是否在移动,吊篮运动状态 吊篮运动状态 0:静止; 1:正在上提; 2:正在下放
  84. public byte basketMoveStatus;
  85. //RFID
  86. public string rfid;
  87. /// <summary>
  88. /// 需要移动的路径
  89. /// </summary>
  90. [JsonIgnore]
  91. public List<MovingPath> movingPaths;
  92. public JGR_Tc_Model()
  93. {
  94. collideSensor = new byte[4];
  95. movingPaths = new List<MovingPath>();
  96. }
  97. public int GetPathCounts()
  98. {
  99. int count = 0;
  100. lock(this)
  101. {
  102. count = movingPaths.Count;
  103. }
  104. return count;
  105. }
  106. public MovingPath GetFirstPath()
  107. {
  108. MovingPath path = null;
  109. lock (this)
  110. {
  111. if(movingPaths.Count > 0)
  112. {
  113. path = movingPaths[0];
  114. }
  115. }
  116. return path;
  117. }
  118. public MovingPath RemoveFirstPath()
  119. {
  120. MovingPath path = null;
  121. lock (this)
  122. {
  123. if (movingPaths.Count > 0)
  124. {
  125. path = movingPaths[0];
  126. movingPaths.RemoveAt(0);
  127. }
  128. }
  129. return path;
  130. }
  131. public void ClearPath()
  132. {
  133. lock (this)
  134. {
  135. movingPaths.Clear();
  136. }
  137. }
  138. /// <summary>
  139. /// 如果对象为空,可以加入,表示当前这辆车只能执行一组动作
  140. /// </summary>
  141. /// <param name="paths"></param>
  142. public void AddPath(List<MovingPath> paths)
  143. {
  144. lock (this)
  145. {
  146. if(movingPaths.Count == 0)
  147. {
  148. movingPaths.AddRange(paths);
  149. }
  150. }
  151. }
  152. }
  153. //用内存对齐方式并不对,可能是和TC程序接口是C#开发的有关 [StructLayout(LayoutKind.Sequential, Pack = 1)]
  154. /// <summary>
  155. /// TC程序中定义的JGR小车的数据结构
  156. /// </summary>
  157. [Serializable]
  158. public struct JGR_Ads_Struct
  159. {
  160. //出厂编号,30个长度带'\0',有效最多29个字节
  161. [JsonConverter(typeof(TcModelArrayConverter))]
  162. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 30)]
  163. public byte[] jgrSN;
  164. // 0:仓储车 , 1:运输车, 2:仓储位充电器,3:轨道位充电器
  165. public byte jgrType;
  166. //车ID,取值范围0~63,不同类型的车/充电器的jgrID可以重复
  167. public byte jgrID;
  168. //无线模块的地址,长度2字节
  169. public ushort rcAddr;
  170. //无线模块的频率码,取值0~155,对应频率为 900+RC_FreqCode*0.2,单位MHz,默认频率码为0x32(50)
  171. public byte rcFreqCode;
  172. //在线/离线状态 是否在线(通讯是否正常)
  173. public byte isOnline;
  174. //健康状态 true:正常; false:异常
  175. public byte isHealthy;
  176. //充电标志,1:充电中,0:未在充电
  177. public byte isCharging;
  178. //充电电压,单位:V
  179. public float chargeVoltage;
  180. //充电电流,单位:mA
  181. public float chargeCurrent;
  182. //电池剩余电量,取值 0~100 , 100表示满电量
  183. public byte electricity;
  184. //驱动器通电/断电状态
  185. public byte isDriverPowerOn;
  186. //(*工作模式
  187. //1: 正常工作模式,即自动控制模式,只需给出运动的目标坐标,动作序列小车自己控制,正常工作时使用;
  188. //2:调试模式,即手动控制模式,用于调试,每一个动作都需要发送指令*)
  189. public byte workMode;
  190. //车轮位置(车身姿态) =1高姿态,=2中姿态,=3低姿态
  191. public byte wheelPosition;
  192. //行进/停止状态
  193. //(* 车体运动状态
  194. //0:静止状态
  195. //1:X负向移动
  196. //2:X正向移动
  197. //3:Y负向移动
  198. //4:Y正向移动*)
  199. public byte moveStatus;
  200. //移动速度,单位:m/s
  201. public float moveSpeed;
  202. //当前位置X
  203. public short currLocation_X;
  204. //当前位置Y
  205. public short currLocation_Y;
  206. //目标位置X
  207. public short destLocation_X;
  208. //目标位置Y
  209. public short destLocation_Y;
  210. //车轮是否在位置切换中
  211. public byte isWheelAltering;
  212. //4个碰撞传感器,true:碰撞,false:未碰撞
  213. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
  214. public byte[] collideSensor;
  215. //X加速度,单位 m/s2
  216. public float acceleration_X;
  217. //Y加速度,单位 m/s2
  218. public float acceleration_Y;
  219. //Z加速度,单位 m/s2
  220. public float acceleration_Z;
  221. //XZ角度,单位:°
  222. public float angleXZ;
  223. //YZ角度,单位:°
  224. public float angleYZ;
  225. //吊篮限位标志,吊篮处于的位置 1:最高点; 2:最低点
  226. public byte basketPosition;
  227. //吊篮抓夹状态 1:闭合状态; 2:张开状态
  228. public byte basketGripperStatus;
  229. //吊篮是否在移动,吊篮运动状态 吊篮运动状态 0:静止; 1:正在上提; 2:正在下放
  230. public byte basketMoveStatus;
  231. //RFID
  232. [JsonConverter(typeof(TcModelArrayConverter))]
  233. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 50)]
  234. public byte[] rfid;
  235. }
  236. /// <summary>
  237. /// 车、充电桩的类型
  238. /// </summary>
  239. public enum JgrType : byte
  240. {
  241. /// <summary>
  242. /// 仓储车
  243. /// </summary>
  244. StorageCar = 0,
  245. /// <summary>
  246. /// 轨道车
  247. /// </summary>
  248. RailCar = 1,
  249. /// <summary>
  250. /// 仓储充电桩
  251. /// </summary>
  252. StorageCharging = 2,
  253. /// <summary>
  254. /// 轨道充电桩
  255. /// </summary>
  256. RailCharging = 3
  257. }
  258. }