dispatch_communication.h 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  1. //
  2. // Created by huli on 2020/9/25.
  3. //
  4. #ifndef NNXX_TESTS_DISPATCH_COMMUNICATION_H
  5. #define NNXX_TESTS_DISPATCH_COMMUNICATION_H
  6. #include "../tool/singleton.h"
  7. #include "../snap7_communication/snap7_communication_base.h"
  8. class Dispatch_communication:public Singleton<Dispatch_communication>, public Snap7_communication_base
  9. {
  10. public:
  11. //发送db快的标记位, 保证先发数据再发唯一码
  12. enum Send_database_flag
  13. {
  14. E_SEND_UNKNOW = 0,
  15. E_SEND_DATA_START = 1, //开始发送数据
  16. E_SEND_DATA_END = 2, //结束发送数据
  17. E_SEND_KEY_START = 3, //开始发送唯一码
  18. E_SEND_KEY_END = 4, //结束发送唯一码
  19. };
  20. #pragma pack(push, 1) //struct按照1个byte对齐
  21. //抓车模块给plc发送请求消息的DB编号
  22. #define CATCHER_REQUEST_FROM_DISPATCH_TO_PLC_DBNUMBER_1 110
  23. #define CATCHER_REQUEST_FROM_DISPATCH_TO_PLC_DBNUMBER_2 120
  24. //抓车模块给plc发送请求消息的指令结构体
  25. struct Catcher_request_from_dispatch_to_plc_for_data
  26. {
  27. //指令信息
  28. unsigned char m_reserved50 = 0; //预留
  29. unsigned char m_reserved51_69[19] = {0}; //预留
  30. // 请求的目标坐标和动作
  31. float m_request_x = 0; //机器人坐标x轴,
  32. float m_request_y = 0; //机器人坐标y轴,
  33. float m_request_b = 0; //机器人坐标b轴, 旋转范围80~280
  34. float m_request_z = 0; //机器人坐标z轴,
  35. unsigned char m_request_clamp_motion = 0; //机器人夹车杆. 0=无动作,1=夹紧,2=松开
  36. unsigned char m_reserved87_89[3] = {0}; //预留
  37. float m_request_wheelbase = 0; //机器人抓车杆前后轮距.
  38. float m_request_d1 = 0; //机器人坐标d1轴, 机器人抓车杆纵向移动(前轮抓杆)
  39. float m_request_d2 = 0; //机器人坐标d2轴, 机器人抓车杆纵向移动(后轮抓杆)
  40. };
  41. //抓车模块给plc发送请求消息的指令结构体
  42. struct Catcher_request_from_dispatch_to_plc_for_key
  43. {
  44. //指令信息
  45. unsigned char m_request_key[50] = {0}; //指令key(任务唯一码), 作为通信标志位
  46. };
  47. //plc给抓车模块发送答复消息的DB编号
  48. #define CATCHER_RESPONSE_FROM_PLC_TO_DISPATCH_DBNUMBER_1 111
  49. #define CATCHER_RESPONSE_FROM_PLC_TO_DISPATCH_DBNUMBER_2 121
  50. //plc给抓车模块发送答复消息的指令结构体
  51. struct Catcher_response_from_plc_to_dispatch
  52. {
  53. //指令信息
  54. unsigned char m_respons_key[50] = {0}; //指令key(任务唯一码), 作为通信标志位
  55. unsigned char m_respons_status = 0; //指令完成状态, 机器人答复指令, 返回任务完成的情况
  56. unsigned char m_reserved51_69[19] = {0}; //预留
  57. //请求的目标坐标和动作
  58. float m_respons_x = 0; //机器人坐标x轴,
  59. float m_respons_y = 0; //机器人坐标y轴,
  60. float m_respons_b = 0; //机器人坐标b轴, 旋转范围80~280
  61. float m_respons_z = 0; //机器人坐标z轴,
  62. unsigned char m_respons_clamp_motion = 0; //机器人夹车杆. 0=无动作,1=夹紧,2=松开
  63. unsigned char m_reserved87_89[3] = {0}; //预留
  64. float m_respons_wheelbase = 0; //机器人抓车杆前后轮距.
  65. float m_respons_d1 = 0; //机器人坐标d1轴, 机器人抓车杆纵向移动(前轮抓杆)
  66. float m_respons_d2 = 0; //机器人坐标d2轴, 机器人抓车杆纵向移动(后轮抓杆)
  67. };
  68. //plc给抓车模块发送状态消息的DB编号
  69. #define CATCHER_STATUS_FROM_PLC_TO_DISPATCH_DBNUMBER_1 113
  70. #define CATCHER_STATUS_FROM_PLC_TO_DISPATCH_DBNUMBER_2 123
  71. //plc给抓车模块发送状态消息的指令结构体
  72. struct Catcher_status_from_plc_to_dispatch
  73. {
  74. unsigned char m_heartbeat = 0; //心跳位, 0-255循环
  75. unsigned char m_safe_status = 0; //设备的安全状态
  76. unsigned char m_work_status = 0; //机器人的硬件设备状态
  77. unsigned char m_actual_load_status = 0; //机器人的负载状态, 机器人上面是否有车.
  78. unsigned char m_reserved4_37[34] = {0}; //预留
  79. float m_actual_x = 0; //机器人坐标x轴,
  80. float m_actual_y = 0; //机器人坐标y轴,
  81. float m_actual_b = 0; //机器人坐标b轴, 旋转范围80~280
  82. float m_actual_z = 0; //机器人坐标z轴,
  83. float m_actual_d1 = 0; //机器人坐标d1轴, 机器人抓车杆纵向移动(前轮抓杆)
  84. float m_actual_d2 = 0; //机器人坐标d2轴, 机器人抓车杆纵向移动(后轮抓杆)
  85. unsigned char m_actual_clamp_motion1 = 0; //机器人夹车杆. 0=无动作,1=夹紧,2=松开
  86. unsigned char m_actual_clamp_motion2 = 0; //机器人夹车杆. 0=无动作,1=夹紧,2=松开
  87. unsigned char m_actual_clamp_motion3 = 0; //机器人夹车杆. 0=无动作,1=夹紧,2=松开
  88. unsigned char m_actual_clamp_motion4 = 0; //机器人夹车杆. 0=无动作,1=夹紧,2=松开
  89. unsigned char m_reserved66_99[34] = {0}; //预留
  90. //故障信息
  91. unsigned char m_actual_error_code[50] = {0}; //搬运器错误码
  92. unsigned char m_actual_warning_code[50] = {0}; //升降机错误码
  93. unsigned char m_actual_error_description[256] = {0}; //升降机错误描述
  94. };
  95. //搬运器给plc发送请求消息的DB编号
  96. #define CARRIER_REQUEST_FROM_DISPATCH_TO_PLC_DBNUMBER_1 200
  97. #define CARRIER_REQUEST_FROM_DISPATCH_TO_PLC_DBNUMBER_2 270
  98. #define CARRIER_REQUEST_FROM_DISPATCH_TO_PLC_DBNUMBER_3 230
  99. //搬运器给plc发送请求消息的指令结构体
  100. struct Carrier_request_from_dispatch_to_plc_for_data
  101. {
  102. //指令信息
  103. unsigned char m_reserved50 = 0; //预留
  104. unsigned char m_reserved51_71[21] = {0}; //预留
  105. //请求的目标坐标和动作
  106. float m_request_x; //搬运器坐标x轴, 中跑车控制横向移动
  107. float m_request_y; //搬运器坐标y轴, 小跑车控制纵向移动
  108. float m_request_z; //搬运器坐标z轴, 电梯控制上下移动
  109. float m_request_y1; //搬运器坐标y1轴, 小跑车控制纵向移动(前轮抓杆)
  110. float m_request_y2; //搬运器坐标y2轴, 小跑车控制纵向移动(后轮抓杆)
  111. unsigned char m_request_clamp_motion; //小跑车夹车杆. 0=无动作,1=夹紧,2=松开
  112. unsigned char m_request_joint_motion_x; //电梯与X轴的横向轨道对接,0=无动作,1=进行对接, 2=松开对接
  113. unsigned char m_request_joint_motion_y; //小跑车与Y轴的横向轨道对接,0=无动作,1=进行对接, 2=松开对接
  114. unsigned char m_reserved95 = 0; //预留
  115. int m_request_space_id; //搬运器空间位置的id.
  116. int m_request_floor_id; //搬运器楼层位置的id.
  117. float m_request_wheelbase; //搬运器小跑车的抓车杆前后轮距.
  118. };
  119. //搬运器给plc发送请求消息的指令结构体
  120. struct Carrier_request_from_dispatch_to_plc_for_key
  121. {
  122. //指令信息
  123. unsigned char m_request_key[50] = {0}; //指令key(任务唯一码), 作为通信标志位
  124. };
  125. //plc给搬运器发送答复消息的DB编号
  126. #define CARRIER_RESPONSE_FROM_PLC_TO_DISPATCH_DBNUMBER_1 201
  127. #define CARRIER_RESPONSE_FROM_PLC_TO_DISPATCH_DBNUMBER_2 271
  128. #define CARRIER_RESPONSE_FROM_PLC_TO_DISPATCH_DBNUMBER_3 231
  129. //plc给搬运器发送答复消息的指令结构体
  130. struct Carrier_response_from_plc_to_dispatch
  131. {
  132. //指令信息
  133. unsigned char m_respons_key[50] = {0}; //指令key(任务唯一码), 作为通信标志位
  134. unsigned char m_respons_status = 0; //指令完成状态, 机器人答复指令, 返回任务完成的情况
  135. unsigned char m_reserved51_71[21] = {0}; //预留
  136. //请求的目标坐标和动作
  137. float m_respons_x; //搬运器坐标x轴, 中跑车控制横向移动
  138. float m_respons_y; //搬运器坐标y轴, 小跑车控制纵向移动
  139. float m_respons_z; //搬运器坐标z轴, 电梯控制上下移动
  140. float m_respons_y1; //搬运器坐标y1轴, 小跑车控制纵向移动(前轮抓杆)
  141. float m_respons_y2; //搬运器坐标y2轴, 小跑车控制纵向移动(后轮抓杆)
  142. unsigned char m_respons_clamp_motion; //小跑车夹车杆. 0=无动作,1=夹紧,2=松开
  143. unsigned char m_respons_joint_motion_x; //电梯与X轴的横向轨道对接,0=无动作,1=进行对接, 2=松开对接
  144. unsigned char m_respons_joint_motion_y; //小跑车与Y轴的横向轨道对接,0=无动作,1=进行对接, 2=松开对接
  145. unsigned char m_reserved95 = 0; //预留
  146. int m_respons_space_id; //搬运器空间位置的id.
  147. int m_respons_floor_id; //搬运器楼层位置的id.
  148. float m_respons_wheelbase; //搬运器小跑车的抓车杆前后轮距.
  149. };
  150. //plc给搬运器发送状态消息的DB编号
  151. #define CARRIER_STATUS_FROM_PLC_TO_DISPATCH_DBNUMBER_1 203
  152. #define CARRIER_STATUS_FROM_PLC_TO_DISPATCH_DBNUMBER_2 273
  153. #define CARRIER_STATUS_FROM_PLC_TO_DISPATCH_DBNUMBER_3 233
  154. //plc给搬运器发送状态消息的指令结构体
  155. struct Carrier_status_from_plc_to_dispatch
  156. {
  157. unsigned char m_heartbeat = 0; //心跳位, 0-255循环
  158. unsigned char m_safe_status = 0; //设备的安全状态
  159. unsigned char m_work_status = 0; //搬运器的硬件设备状态
  160. unsigned char m_actual_load_status = 0; //搬运器的负载状态, 小跑车上面是否有车.
  161. unsigned char m_reserved4_37[34] = {0}; //预留
  162. float m_actual_x = 0; //搬运器坐标x轴,
  163. float m_actual_y = 0; //搬运器坐标y轴,
  164. float m_actual_z = 0; //搬运器坐标z轴,
  165. float m_actual_y1 = 0; //搬运器坐标y1轴, 小跑车控制纵向移动(前轮抓杆)
  166. float m_actual_y2 = 0; //搬运器坐标y2轴, 小跑车控制纵向移动(前轮抓杆)
  167. unsigned char m_actual_clamp_motion1 = 0; //小跑车夹车杆. 0=无动作,1=夹紧,2=松开
  168. unsigned char m_actual_clamp_motion2 = 0; //小跑车夹车杆. 0=无动作,1=夹紧,2=松开
  169. unsigned char m_actual_small_sports_car_motion = 0; //小跑车的位置,是否在中跑车上面, 0=无动作,1=出发到位,2=返回到位
  170. unsigned char m_actual_joint_motion_x1 = 0; //电梯与X轴的横向轨道对接,0=无动作,1=伸出到位,2=收回到位
  171. unsigned char m_actual_joint_motion_x2 = 0; //电梯与X轴的横向轨道对接,0=无动作,1=伸出到位,2=收回到位
  172. unsigned char m_reserved63_101[39] = {0}; //预留
  173. //故障信息
  174. unsigned char m_actual_error_code[50] = {0}; //搬运器错误码
  175. unsigned char m_actual_warning_code[50] = {0}; //升降机错误码
  176. unsigned char m_actual_error_description[256] = {0}; //升降机错误描述
  177. };
  178. //通道口给plc发送请求消息的DB编号
  179. #define PASSAGEWAY_REQUEST_FROM_DISPATCH_TO_PLC_DBNUMBER_0 300
  180. #define PASSAGEWAY_REQUEST_FROM_DISPATCH_TO_PLC_DBNUMBER_1 310
  181. #define PASSAGEWAY_REQUEST_FROM_DISPATCH_TO_PLC_DBNUMBER_2 320
  182. #define PASSAGEWAY_REQUEST_FROM_DISPATCH_TO_PLC_DBNUMBER_3 330
  183. #define PASSAGEWAY_REQUEST_FROM_DISPATCH_TO_PLC_DBNUMBER_4 340
  184. #define PASSAGEWAY_REQUEST_FROM_DISPATCH_TO_PLC_DBNUMBER_5 350
  185. #define PASSAGEWAY_REQUEST_FROM_DISPATCH_TO_PLC_DBNUMBER_6 360
  186. #define PASSAGEWAY_REQUEST_FROM_DISPATCH_TO_PLC_DBNUMBER_7 370
  187. //通道口给plc发送请求消息的指令结构体
  188. struct Passageway_request_from_dispatch_to_plc_for_data
  189. {
  190. //指令信息
  191. unsigned char m_reserved50 = 0; //预留
  192. unsigned char m_reserved51_69[19] = {0}; //预留
  193. // 请求的目标坐标和动作
  194. unsigned char m_request_inside_door_motion = 0; //通道口 内门动作
  195. unsigned char m_request_outside_door_motion = 0; //通道口 外门动作
  196. unsigned char m_request_turntable_direction = 0; //通道口 转台方向
  197. };
  198. //通道口给plc发送请求消息的指令结构体
  199. struct Passageway_request_from_dispatch_to_plc_for_key
  200. {
  201. //指令信息
  202. unsigned char m_request_key[50] = {0}; //指令key(任务唯一码), 作为通信标志位
  203. };
  204. //plc给通道口发送答复消息的DB编号
  205. #define PASSAGEWAY_RESPONSE_FROM_PLC_TO_DISPATCH_DBNUMBER_0 301
  206. #define PASSAGEWAY_RESPONSE_FROM_PLC_TO_DISPATCH_DBNUMBER_1 311
  207. #define PASSAGEWAY_RESPONSE_FROM_PLC_TO_DISPATCH_DBNUMBER_2 321
  208. #define PASSAGEWAY_RESPONSE_FROM_PLC_TO_DISPATCH_DBNUMBER_3 331
  209. #define PASSAGEWAY_RESPONSE_FROM_PLC_TO_DISPATCH_DBNUMBER_4 341
  210. #define PASSAGEWAY_RESPONSE_FROM_PLC_TO_DISPATCH_DBNUMBER_5 351
  211. #define PASSAGEWAY_RESPONSE_FROM_PLC_TO_DISPATCH_DBNUMBER_6 361
  212. #define PASSAGEWAY_RESPONSE_FROM_PLC_TO_DISPATCH_DBNUMBER_7 371
  213. //plc给通道口发送答复消息的指令结构体
  214. struct Passageway_response_from_plc_to_dispatch
  215. {
  216. //指令信息
  217. unsigned char m_respons_key[50] = {0}; //指令key(任务唯一码), 作为通信标志位
  218. unsigned char m_respons_status = 0; //指令完成状态, 机器人答复指令, 返回任务完成的情况
  219. unsigned char m_reserved51_69[19] = {0}; //预留
  220. unsigned char m_respons_inside_door_motion = 0; //通道口 内门动作
  221. unsigned char m_respons_outside_door_motion = 0; //通道口 外门动作
  222. unsigned char m_respons_turntable_direction = 0; //通道口 转台方向
  223. };
  224. //plc给通道口发送状态消息的DB编号
  225. #define PASSAGEWAY_STATUS_FROM_PLC_TO_DISPATCH_DBNUMBER_0 303
  226. #define PASSAGEWAY_STATUS_FROM_PLC_TO_DISPATCH_DBNUMBER_1 313
  227. #define PASSAGEWAY_STATUS_FROM_PLC_TO_DISPATCH_DBNUMBER_2 323
  228. #define PASSAGEWAY_STATUS_FROM_PLC_TO_DISPATCH_DBNUMBER_3 333
  229. #define PASSAGEWAY_STATUS_FROM_PLC_TO_DISPATCH_DBNUMBER_4 343
  230. #define PASSAGEWAY_STATUS_FROM_PLC_TO_DISPATCH_DBNUMBER_5 353
  231. #define PASSAGEWAY_STATUS_FROM_PLC_TO_DISPATCH_DBNUMBER_6 363
  232. #define PASSAGEWAY_STATUS_FROM_PLC_TO_DISPATCH_DBNUMBER_7 373
  233. //plc给通道口发送状态消息的指令结构体
  234. struct Passageway_status_from_plc_to_dispatch
  235. {
  236. unsigned char m_heartbeat = 0; //心跳位, 0-255循环
  237. unsigned char m_safe_status = 0; //设备的安全状态
  238. unsigned char m_sensor_status1 = 0; //设备的传感器状态1
  239. unsigned char m_sensor_status2 = 0; //设备的传感器状态2
  240. unsigned char m_reserved4_35[32] = {0}; //预留
  241. unsigned char m_actual_turntable_direction; //通道口 转台方向
  242. unsigned char m_reserved37 = 0; //预留
  243. //故障信息
  244. unsigned char m_actual_error_code[50] = {0}; //通道口错误码
  245. unsigned char m_actual_warning_code[50] = {0}; //升降机错误码
  246. unsigned char m_actual_error_description[256] = {0}; //升降机错误描述
  247. };
  248. //snap7的通信参数路径
  249. #define SNAP7_COMMUNICATION_PARAMETER_PATH_A "../setting/snap7_communication_a.prototxt"
  250. #define SNAP7_COMMUNICATION_PARAMETER_PATH_B "../setting/snap7_communication_b.prototxt"
  251. #define SNAP7_COMMUNICATION_PARAMETER_PATH_C "../setting/snap7_communication_c.prototxt"
  252. //调度管理给plc发送调度指令 的DB编号
  253. #define DISPATCH_REQUEST_FROM_MANAGER_TO_PLC_DBNUMBER_0 9000
  254. //调度管理给plc发送调度指令 的结构体
  255. struct Dispatch_request_from_manager_to_plc_for_data
  256. {
  257. //指令信息
  258. unsigned char m_request_status = 0; //指令完成状态, 机器人答复指令, 返回任务完成的情况
  259. unsigned char m_reserved51_73[23] = {0}; //预留
  260. // 调度指令的起点,终点,方向
  261. unsigned char m_request_dispatch_motion_direction = 0; //调度方向 0=未知,1=存车,2=取车
  262. unsigned char m_reserved75_79[5] = {0}; //预留
  263. unsigned int m_request_passageway_id = 0; //出入口id 6个入口和6个出口
  264. unsigned char m_request_passageway_direction = 0; //出入口方向 0=未知,1=入口,2=出口
  265. unsigned char m_reserved85_89[5] = {0}; //预留
  266. unsigned int m_request_parkingspace_index_id = 0; //楼上车位索引id 1~180(3*6*13)
  267. unsigned int m_request_parkingspace_unit_id = 0; //楼上车位单元号 1~3
  268. unsigned int m_request_parkingspace_label_id = 0; //楼上车位标签号 1~78
  269. unsigned int m_request_parkingspace_floor_id = 0; //楼上车位楼层号 2~11
  270. unsigned int m_request_parkingspace_room_id = 0; //楼上车位房间号 1~6
  271. unsigned char m_request_parkingspace_direction = 0; //楼上车位方向 0=未知,1=朝南,2=朝北
  272. unsigned char m_reserved111 = 0; //预留
  273. //汽车的定位信息(地面雷达)
  274. float m_request_car_center_x = 0; //整车的中心点x值, 四轮的中心, 单位:米 m
  275. float m_request_car_center_y = 0; //整车的中心点y值, 四轮的中心, 单位:米 m
  276. float m_request_car_angle = 0; //整车的车身旋转角, 单位:度 (-90~90)
  277. float m_request_car_front_theta = 0; //整车的前轮的旋转角, 单位:度 (-90~90)
  278. float m_request_car_length = 0; //整车的长度, 用于规避碰撞, 单位:米 m
  279. float m_request_car_width = 0; //整车的宽度, 用于规避碰撞, 单位:米 m
  280. float m_request_car_height = 0; //整车的高度, 用于规避碰撞, 单位:米 m
  281. float m_request_car_wheel_base = 0; //整车的轮距, 前后轮的距离, 用于机器人或agv的抓车, 单位:米 m
  282. float m_request_car_wheel_width = 0; //整车的轮距, 左右轮的距离, 用于机器人或agv的抓车, 单位:米 m
  283. unsigned char m_request_car_license[20] = {0}; //车牌号(汽车唯一标示) 例如: 鄂A12345
  284. unsigned char m_reserved168_187[20] = {0}; //预留
  285. unsigned char m_request_car_type = 0; //0=未知,1=小车,2=中车,3=大车 ..188
  286. unsigned char m_reserved189_191[3] = {0}; //预留
  287. float m_request_uniformed_car_x = 0; //转角复位后,车辆中心点x
  288. float m_request_uniformed_car_y = 0; //转角复位后,车辆中心点y
  289. unsigned char m_reserved200_209[10] = {0}; //预留
  290. //防撞雷达 ..210
  291. unsigned char m_request_anticollision_lidar_flag = 0; //汽车是否停到正确的位置, 防撞雷达 预留, 楚天暂时不用,0=未知,1=位置正常,2=位置异常
  292. unsigned char m_reserved211_215[5] = {0}; //预留
  293. //轮距雷达 ..216
  294. float m_request_car_wheel_base_exact_value = 0; //汽车前后轮距,轮距雷达的精确值 预留, 楚天暂时不用,单位:米 m
  295. unsigned char m_reserved220_231[12] = {0}; //预留
  296. };
  297. //调度管理给plc发送调度指令 的结构体
  298. struct Dispatch_request_from_manager_to_plc_for_key
  299. {
  300. //指令信息
  301. unsigned char m_request_key[50] = {0}; //指令key(任务唯一码), 作为通信标志位
  302. };
  303. //plc给调度管理发送调度答复 的DB编号
  304. #define DISPATCH_RESPONSE_FROM_PLC_TO_MANAGER_DBNUMBER_0 9001
  305. //plc给调度管理发送调度答复 的结构体
  306. struct Dispatch_response_from_plc_to_manager
  307. {
  308. unsigned char m_response_key[50] = {0}; //指令key(任务唯一码), 作为通信标志位
  309. //指令信息
  310. unsigned char m_response_status = 0; //指令完成状态, 机器人答复指令, 返回任务完成的情况
  311. unsigned char m_reserved51_73[23] = {0}; //预留
  312. // 调度指令的起点,终点,方向
  313. unsigned char m_response_dispatch_motion_direction = 0; //调度方向 0=未知,1=存车,2=取车
  314. unsigned char m_reserved75_79[5] = {0}; //预留
  315. unsigned int m_response_passageway_id = 0; //出入口id 6个入口和6个出口
  316. unsigned char m_response_passageway_direction = 0; //出入口方向 0=未知,1=入口,2=出口
  317. unsigned char m_reserved85_89[5] = {0}; //预留
  318. unsigned int m_response_parkingspace_index_id = 0; //楼上车位索引id 1~180(3*6*13)
  319. unsigned int m_response_parkingspace_unit_id = 0; //楼上车位单元号 1~3
  320. unsigned int m_response_parkingspace_label_id = 0; //楼上车位标签号 1~78
  321. unsigned int m_response_parkingspace_floor_id = 0; //楼上车位楼层号 2~11
  322. unsigned int m_response_parkingspace_room_id = 0; //楼上车位房间号 1~6
  323. unsigned char m_response_parkingspace_direction = 0; //楼上车位方向 0=未知,1=朝南,2=朝北
  324. unsigned char m_reserved111 = 0; //预留
  325. //汽车的定位信息(地面雷达)
  326. float m_response_car_center_x = 0; //整车的中心点x值, 四轮的中心, 单位:米 m
  327. float m_response_car_center_y = 0; //整车的中心点y值, 四轮的中心, 单位:米 m
  328. float m_response_car_angle = 0; //整车的车身旋转角, 单位:度 (-90~90)
  329. float m_response_car_front_theta = 0; //整车的前轮的旋转角, 单位:度 (-90~90)
  330. float m_response_car_length = 0; //整车的长度, 用于规避碰撞, 单位:米 m
  331. float m_response_car_width = 0; //整车的宽度, 用于规避碰撞, 单位:米 m
  332. float m_response_car_height = 0; //整车的高度, 用于规避碰撞, 单位:米 m
  333. float m_response_car_wheel_base = 0; //整车的轮距, 前后轮的距离, 用于机器人或agv的抓车, 单位:米 m
  334. float m_response_car_wheel_width = 0; //整车的轮距, 左右轮的距离, 用于机器人或agv的抓车, 单位:米 m
  335. unsigned char m_response_car_license[20] = {0}; //车牌号(汽车唯一标示) 例如: 鄂A12345
  336. unsigned char m_reserved168_187[20] = {0}; //预留
  337. unsigned char m_response_car_type = 0; //0=未知,1=小车,2=中车,3=大车 ..188
  338. unsigned char m_reserved189_191[3] = {0}; //预留
  339. float m_response_uniformed_car_x = 0; //转角复位后,车辆中心点x
  340. float m_response_uniformed_car_y = 0; //转角复位后,车辆中心点y
  341. unsigned char m_reserved200_209[10] = {0}; //预留
  342. //防撞雷达 ..210
  343. unsigned char m_response_anticollision_lidar_flag = 0; //汽车是否停到正确的位置, 防撞雷达 预留, 楚天暂时不用,0=未知,1=位置正常,2=位置异常
  344. unsigned char m_reserved211_215[5] = {0}; //预留
  345. //轮距雷达 ..216
  346. float m_response_car_wheel_base_exact_value = 0; //汽车前后轮距,轮距雷达的精确值 预留, 楚天暂时不用,单位:米 m
  347. unsigned char m_reserved220_231[12] = {0}; //预留
  348. };
  349. //调度管理的的状态信息 的DB编号
  350. #define DISPATCH_PLC_STATUS_FROM_MANAGER_TO_PLC_DBNUMBER_0 9002
  351. //调度管理给plc发送状态消息的指令结构体
  352. struct Dispatch_plc_status_from_manager_to_plc
  353. {
  354. unsigned char m_heartbeat = 0; //心跳位, 0-255循环
  355. };
  356. //plc的状态信息 的DB编号
  357. #define DISPATCH_PLC_STATUS_FROM_PLC_TO_MANAGER_DBNUMBER_0 9003
  358. //plc给通道口发送状态消息的指令结构体
  359. struct Dispatch_plc_status_from_plc_to_manager
  360. {
  361. unsigned char m_heartbeat = 0; //心跳位, 0-255循环
  362. };
  363. //地面雷达给plc
  364. #define GROUND_LIDAR_RESPONSE_FROM_MANAGER_TO_PLC_DBNUMBER_0 9004
  365. #define GROUND_LIDAR_RESPONSE_FROM_MANAGER_TO_PLC_DBNUMBER_1 9014
  366. struct Ground_lidar_response_from_manager_to_plc_for_key
  367. {
  368. unsigned char m_response_heartbeat = 0; //心跳位, 0-255循环
  369. unsigned char m_response_communication_mode = 0; //通信模式 0 = 未知, 1=自动循环模式,2=手动刷新模式
  370. unsigned char m_response_refresh_command = 0; //刷新指令 0-255任意数字,与上一次不同即可
  371. unsigned char m_response_data_validity = 0; //数据有效性, 0 = 未知, 1 = 有效, 2 = 无效
  372. };
  373. struct Ground_lidar_response_from_manager_to_plc_for_data
  374. {
  375. //汽车的定位信息(地面雷达)
  376. float m_response_car_center_x = 0; //整车的中心点x值, 四轮的中心, 单位:米 m
  377. float m_response_car_center_y = 0; //整车的中心点y值, 四轮的中心, 单位:米 m
  378. float m_response_car_angle = 0; //整车的车身旋转角, 单位:度 (-90~90)
  379. float m_response_car_front_theta = 0; //整车的前轮的旋转角, 单位:度 (-90~90)
  380. float m_response_car_length = 0; //整车的长度, 用于规避碰撞, 单位:米 m
  381. float m_response_car_width = 0; //整车的宽度, 用于规避碰撞, 单位:米 m
  382. float m_response_car_height = 0; //整车的高度, 用于规避碰撞, 单位:米 m
  383. float m_response_car_wheel_base = 0; //整车的轮距, 前后轮的距离, 用于机器人或agv的抓车, 单位:米 m
  384. float m_response_car_wheel_width = 0; //整车的轮距, 左右轮的距离, 用于机器人或agv的抓车, 单位:米 m
  385. float m_response_uniformed_car_x = 0; //转角复位后,车辆中心点x
  386. float m_response_uniformed_car_y = 0; //转角复位后,车辆中心点y
  387. unsigned char m_response_locate_correct = 0; //数据是否有效, 0=无效, 1=有效
  388. unsigned char m_reserved45_48[3] = {0}; //预留
  389. unsigned char m_response_heartbeat = 0; //心跳位, 0-255循环
  390. unsigned char m_response_communication_mode = 0; //通信模式 0 = 未知, 1=自动循环模式,2=手动刷新模式
  391. unsigned char m_response_refresh_command = 0; //刷新指令 0-255任意数字,与上一次不同即可
  392. unsigned char m_response_data_validity = 0; //数据有效性, 0 = 未知, 1 = 有效, 2 = 无效
  393. };
  394. //plc给地面雷达
  395. #define GROUND_LIDAR_REQUEST_FROM_PLC_TO_MANAGER_DBNUMBER_0 9005
  396. #define GROUND_LIDAR_REQUEST_FROM_PLC_TO_MANAGER_DBNUMBER_1 9015
  397. struct Ground_lidar_request_from_plc_to_manager
  398. {
  399. unsigned char m_request_heartbeat = 0; //心跳位, 0-255循环
  400. unsigned char m_request_communication_mode = 0; //通信模式 0 = 未知, 1=自动循环模式,2=手动刷新模式
  401. unsigned char m_request_refresh_command = 0; //刷新指令 0-255任意数字,与上一次不同即可
  402. unsigned char m_request_data_validity = 0; //数据有效性, 0 = 未知, 1 = 有效, 2 = 无效
  403. };
  404. //防撞雷达给plc
  405. #define ANTICOLLISION_LIDAR_RESPONSE_FROM_MANAGER_TO_PLC_DBNUMBER_0 9006
  406. struct Anticollision_lidar_response_from_manager_to_plc_for_key
  407. {
  408. unsigned char m_response_heartbeat = 0; //心跳位, 0-255循环
  409. unsigned char m_response_communication_mode = 0; //通信模式 0 = 未知, 1=自动循环模式,2=手动刷新模式
  410. unsigned char m_response_refresh_command = 0; //刷新指令 0-255任意数字,与上一次不同即可
  411. unsigned char m_response_data_validity = 0; //数据有效性, 0 = 未知, 1 = 有效, 2 = 无效
  412. };
  413. struct Anticollision_lidar_response_from_manager_to_plc_for_data
  414. {
  415. unsigned char m_response_anticollision_lidar_flag = 0; //汽车是否停到正确的位置, 防撞雷达 预留, 楚天暂时不用,0=未知,1=位置正常,2=位置异常
  416. unsigned char m_reserved5_7[3] = {0}; //预留
  417. float m_response_offset_x = 0; //汽车x轴的偏移量, -1.0~+1.0, 单位米
  418. float m_response_offset_angle = 0; //汽车角度的偏移量, -7~+7, 单位度
  419. };
  420. //plc给防撞雷达
  421. #define ANTICOLLISION_LIDAR_REQUEST_FROM_PLC_TO_MANAGER_DBNUMBER_0 9007
  422. struct Anticollision_lidar_request_from_plc_to_manager
  423. {
  424. unsigned char m_request_heartbeat = 0; //心跳位, 0-255循环
  425. unsigned char m_request_communication_mode = 0; //通信模式 0 = 未知, 1=自动循环模式,2=手动刷新模式
  426. unsigned char m_request_refresh_command = 0; //刷新指令 0-255任意数字,与上一次不同即可
  427. unsigned char m_request_data_validity = 0; //数据有效性, 0 = 未知, 1 = 有效, 2 = 无效
  428. };
  429. //单片机给plc
  430. #define SINGLECHIP_RESPONSE_FROM_MANAGER_TO_PLC_DBNUMBER_0 9008
  431. #define SINGLECHIP_RESPONSE_FROM_MANAGER_TO_PLC_DBNUMBER_1 9018
  432. #define SINGLECHIP_RESPONSE_FROM_MANAGER_TO_PLC_DBNUMBER_2 9028
  433. #define SINGLECHIP_RESPONSE_FROM_MANAGER_TO_PLC_DBNUMBER_3 9038
  434. struct Singlechip_response_from_manager_to_plc
  435. {
  436. unsigned char m_process_status; //流程状态
  437. unsigned char m_process_control; //流程控制
  438. unsigned char m_over_border_status; //超界状态, 0:未知, 1:正常, 2:前超界, 3:后超界, 4:左超界, 5:右超界
  439. unsigned char m_car_height_status_current; //车高状态,当前持续的状态, 0:未知, 1:小车, 2:中车, 3:大车, 4:巨大车, 5:故障车
  440. unsigned char m_car_height_status_passing; //车高状态,经过外门口的状态, 0:未知, 1:小车, 2:中车, 3:大车, 4:巨大车, 5:故障车
  441. unsigned char m_outside_door_status; //外门的状态, 0:未知, 1:外门开到位, 2:外门关到位, 3:外门运行中, 4:外门故障
  442. unsigned char m_outside_door_control; //外门的控制, 0:未知, 1:外门开, 2:外门关,
  443. unsigned char m_dispatch_finish_flag; //调度完成标志位,true表示允许终端放下一辆车进入入口
  444. unsigned char m_inside_existence_flag; //门内是否存在汽车的标志位, true表示有车
  445. unsigned char m_outside_existence_flag; //门外是否存在汽车的标志位, 门外地感触发停车流程, true表示有车
  446. unsigned char m_reset_flag; //重启标志, true:控制看门狗重启
  447. unsigned char m_stop_flag; //急停标志,true:把控制口全部写0,并关闭流程。
  448. unsigned int m_error_code; //错误码
  449. unsigned char m_reserved16_35[20] = {0}; //预留
  450. unsigned char m_gpio_input[16] = {0}; //gpio输入口原始数据,
  451. unsigned char m_gpio_output[8] = {0}; //gpio输出口原始数据,
  452. unsigned char m_reserved60_79[20] = {0}; //预留
  453. unsigned char m_response_heartbeat = 0; //心跳位, 0-255循环
  454. unsigned char m_response_communication_mode = 0; //通信模式 0 = 未知, 1=自动循环模式,2=手动刷新模式
  455. unsigned char m_response_refresh_command = 0; //刷新指令 0-255任意数字,与上一次不同即可
  456. unsigned char m_response_data_validity = 0; //数据有效性, 0 = 未知, 1 = 有效, 2 = 无效
  457. };
  458. //plc给单片机
  459. #define SINGLECHIP_REQUEST_FROM_PLC_TO_MANAGER_DBNUMBER_0 9009
  460. #define SINGLECHIP_REQUEST_FROM_PLC_TO_MANAGER_DBNUMBER_1 9019
  461. #define SINGLECHIP_REQUEST_FROM_PLC_TO_MANAGER_DBNUMBER_2 9029
  462. #define SINGLECHIP_REQUEST_FROM_PLC_TO_MANAGER_DBNUMBER_3 9039
  463. struct Singlechip_request_from_plc_to_manager
  464. {
  465. unsigned char m_request_heartbeat = 0; //心跳位, 0-255循环
  466. unsigned char m_request_communication_mode = 0; //通信模式 0 = 未知, 1=自动循环模式,2=手动刷新模式
  467. unsigned char m_request_refresh_command = 0; //刷新指令 0-255任意数字,与上一次不同即可
  468. unsigned char m_request_data_validity = 0; //数据有效性, 0 = 未知, 1 = 有效, 2 = 无效
  469. };
  470. #pragma pack(pop) //取消对齐
  471. // 子类必须把父类设定为友元函数,这样父类才能使用子类的私有构造函数。
  472. friend class Singleton<Dispatch_communication>;
  473. private:
  474. // 父类的构造函数必须保护,子类的构造函数必须私有。
  475. Dispatch_communication();
  476. public:
  477. //必须关闭拷贝构造和赋值构造,只能通过 get_instance 函数来进行操作唯一的实例。
  478. Dispatch_communication(const Dispatch_communication& other) = delete;
  479. Dispatch_communication& operator =(const Dispatch_communication& other) = delete;
  480. ~Dispatch_communication();
  481. public://API functions
  482. //初始化 通信 模块。如下三选一
  483. virtual Error_manager communication_init(int plc_id);
  484. //反初始化 通信 模块。
  485. virtual Error_manager communication_uninit();
  486. public://get or set member variable
  487. // std::mutex * get_data_lock();
  488. // Request_from_dispatch_to_plc * get_request_from_dispatch_to_plc();
  489. // Response_from_plc_to_dispatch * get_response_from_plc_to_dispatch();
  490. // Status_from_dispatch_to_plc * get_status_from_dispatch_to_plc();
  491. // Status_from_plc_to_dispatch * get_status_from_plc_to_dispatch();
  492. protected://member functions
  493. //更新数据
  494. virtual Error_manager updata_receive_buf();
  495. virtual Error_manager updata_send_buf();
  496. protected://member variable
  497. public:
  498. int m_plc_id; //plc的id, 楚天车库的单元号
  499. std::mutex m_data_lock; //数据锁
  500. Catcher_request_from_dispatch_to_plc_for_data m_catcher_request_from_dispatch_to_plc_for_data[2]; //抓车模块给plc发送请求消息的指令结构体
  501. Catcher_request_from_dispatch_to_plc_for_key m_catcher_request_from_dispatch_to_plc_for_key[2]; //抓车模块给plc发送请求消息的指令结构体
  502. Catcher_response_from_plc_to_dispatch m_catcher_response_from_plc_to_dispatch[2]; //plc给抓车模块发送答复消息的指令结构体
  503. Catcher_status_from_plc_to_dispatch m_catcher_status_from_plc_to_dispatch[2]; //plc给抓车模块发送状态消息的指令结构体
  504. Carrier_request_from_dispatch_to_plc_for_data m_carrier_request_from_dispatch_to_plc_for_data[3]; //搬运器给plc发送请求消息的指令结构体
  505. Carrier_request_from_dispatch_to_plc_for_key m_carrier_request_from_dispatch_to_plc_for_key[3]; //搬运器给plc发送请求消息的指令结构体
  506. Carrier_response_from_plc_to_dispatch m_carrier_response_from_plc_to_dispatch[3]; //plc给搬运器发送答复消息的指令结构体
  507. Carrier_status_from_plc_to_dispatch m_carrier_status_from_plc_to_dispatch[3]; //plc给搬运器发送状态消息的指令结构体
  508. Passageway_request_from_dispatch_to_plc_for_data m_passageway_request_from_dispatch_to_plc_for_data[8]; //通道口给plc发送请求消息的指令结构体
  509. Passageway_request_from_dispatch_to_plc_for_key m_passageway_request_from_dispatch_to_plc_for_key[8]; //通道口给plc发送请求消息的指令结构体
  510. Passageway_response_from_plc_to_dispatch m_passageway_response_from_plc_to_dispatch[8]; //plc给通道口发送答复消息的指令结构体
  511. Passageway_status_from_plc_to_dispatch m_passageway_status_from_plc_to_dispatch[8]; //plc给通道口发送状态消息的指令结构体
  512. //调度指令
  513. Dispatch_request_from_manager_to_plc_for_data m_dispatch_request_from_manager_to_plc_for_data;
  514. Dispatch_request_from_manager_to_plc_for_key m_dispatch_request_from_manager_to_plc_for_key;
  515. Dispatch_response_from_plc_to_manager m_dispatch_response_from_plc_to_manager;
  516. //调度状态
  517. Dispatch_plc_status_from_manager_to_plc m_dispatch_plc_status_from_manager_to_plc;
  518. Dispatch_plc_status_from_plc_to_manager m_dispatch_plc_status_from_plc_to_manager;
  519. //地面雷达指令
  520. Ground_lidar_response_from_manager_to_plc_for_data m_ground_lidar_response_from_manager_to_plc_for_data[2];
  521. Ground_lidar_response_from_manager_to_plc_for_key m_ground_lidar_response_from_manager_to_plc_for_key[2];
  522. Ground_lidar_request_from_plc_to_manager m_ground_lidar_request_from_plc_to_manager[2];
  523. //防撞雷达指令
  524. Anticollision_lidar_response_from_manager_to_plc_for_data m_anticollision_lidar_response_from_manager_to_plc_for_data;
  525. Anticollision_lidar_response_from_manager_to_plc_for_key m_anticollision_lidar_response_from_manager_to_plc_for_key;
  526. Anticollision_lidar_request_from_plc_to_manager m_anticollision_lidar_request_from_plc_to_manager;
  527. //单片机
  528. Singlechip_response_from_manager_to_plc m_singlechip_response_from_manager_to_plc[4];
  529. Singlechip_request_from_plc_to_manager m_singlechip_request_from_plc_to_manager[4];
  530. private:
  531. };
  532. #endif //NNXX_TESTS_DISPATCH_COMMUNICATION_H