dispatch_communication.cpp 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  1. //
  2. // Created by huli on 2020/9/25.
  3. //
  4. #include "dispatch_communication.h"
  5. Dispatch_communication::Dispatch_communication()
  6. {
  7. }
  8. Dispatch_communication::~Dispatch_communication()
  9. {
  10. }
  11. //初始化 通信 模块。如下三选一
  12. Error_manager Dispatch_communication::communication_init(int plc_id)
  13. {
  14. m_plc_id = plc_id;
  15. int t_index = 0;
  16. std::vector<Snap7_buf::Variable_information> t_variable_information_vector;
  17. //往map通信缓存里面添加所需要的buf
  18. std::unique_lock<std::mutex> t_lock1(m_receive_buf_lock);
  19. std::unique_lock<std::mutex> t_lock2(m_send_buf_lock);
  20. Snap7_buf t_snap7_buf;
  21. //调度指令
  22. t_index = 0;
  23. t_variable_information_vector.clear();
  24. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_status", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  25. t_index += sizeof(unsigned char)*1;
  26. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved51_73", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 23 });
  27. t_index += sizeof(unsigned char)*23;
  28. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_dispatch_motion_direction", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  29. t_index += sizeof(unsigned char)*1;
  30. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved75_79", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 5 });
  31. t_index += sizeof(unsigned char)*5;
  32. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_passageway_id", typeid(unsigned int).name(), t_index,sizeof(unsigned int), 1 });
  33. t_index += sizeof(unsigned int)*1;
  34. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_passageway_direction", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  35. t_index += sizeof(unsigned char)*1;
  36. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved85_89", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 5 });
  37. t_index += sizeof(unsigned char)*5;
  38. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_parkingspace_index_id", typeid(unsigned int).name(), t_index,sizeof(unsigned int), 1 });
  39. t_index += sizeof(unsigned int)*1;
  40. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_parkingspace_unit_id", typeid(unsigned int).name(), t_index,sizeof(unsigned int), 1 });
  41. t_index += sizeof(unsigned int)*1;
  42. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_parkingspace_label_id", typeid(unsigned int).name(), t_index,sizeof(unsigned int), 1 });
  43. t_index += sizeof(unsigned int)*1;
  44. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_parkingspace_floor_id", typeid(unsigned int).name(), t_index,sizeof(unsigned int), 1 });
  45. t_index += sizeof(unsigned int)*1;
  46. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_parkingspace_room_id", typeid(unsigned int).name(), t_index,sizeof(unsigned int), 1 });
  47. t_index += sizeof(unsigned int)*1;
  48. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_parkingspace_direction", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  49. t_index += sizeof(unsigned char)*1;
  50. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved111", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  51. t_index += sizeof(unsigned char)*1;
  52. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_center_x", typeid(float).name(), t_index,sizeof(float), 1 });
  53. t_index += sizeof(float)*1;
  54. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_center_y", typeid(float).name(), t_index,sizeof(float), 1 });
  55. t_index += sizeof(float)*1;
  56. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_angle", typeid(float).name(), t_index,sizeof(float), 1 });
  57. t_index += sizeof(float)*1;
  58. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_front_theta", typeid(float).name(), t_index,sizeof(float), 1 });
  59. t_index += sizeof(float)*1;
  60. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_length", typeid(float).name(), t_index,sizeof(float), 1 });
  61. t_index += sizeof(float)*1;
  62. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_width", typeid(float).name(), t_index,sizeof(float), 1 });
  63. t_index += sizeof(float)*1;
  64. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_height", typeid(float).name(), t_index,sizeof(float), 1 });
  65. t_index += sizeof(float)*1;
  66. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_wheel_base", typeid(float).name(), t_index,sizeof(float), 1 });
  67. t_index += sizeof(float)*1;
  68. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_wheel_width", typeid(float).name(), t_index,sizeof(float), 1 });
  69. t_index += sizeof(float)*1;
  70. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_license", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 20 });
  71. t_index += sizeof(unsigned char)*20;
  72. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved168_187", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 20 });
  73. t_index += sizeof(unsigned char)*20;
  74. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_type", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  75. t_index += sizeof(unsigned char)*1;
  76. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved189_191", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 3 });
  77. t_index += sizeof(unsigned char)*3;
  78. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_uniformed_car_x", typeid(float).name(), t_index,sizeof(float), 1 });
  79. t_index += sizeof(float)*1;
  80. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_uniformed_car_y", typeid(float).name(), t_index,sizeof(float), 1 });
  81. t_index += sizeof(float)*1;
  82. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved200_209", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 10 });
  83. t_index += sizeof(unsigned char)*10;
  84. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_anticollision_lidar_flag", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  85. t_index += sizeof(unsigned char)*1;
  86. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved211_215", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 5 });
  87. t_index += sizeof(unsigned char)*5;
  88. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_wheel_base_exact_value", typeid(float).name(), t_index,sizeof(float), 1 });
  89. t_index += sizeof(float)*1;
  90. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved217_231", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 25 });
  91. t_index += sizeof(unsigned char)*25;
  92. // t_snap7_buf.init(DISPATCH_REQUEST_FROM_MANAGER_TO_PLC_DBNUMBER_0 +m_plc_id*100, 50, sizeof(Dispatch_request_from_manager_to_plc_for_data), t_variable_information_vector, Snap7_buf::LOOP_COMMUNICATION);
  93. t_snap7_buf.init(DISPATCH_REQUEST_FROM_MANAGER_TO_PLC_DBNUMBER_0 , 50, sizeof(Dispatch_request_from_manager_to_plc_for_data), t_variable_information_vector, Snap7_buf::LOOP_COMMUNICATION);
  94. m_send_buf_map[0] = t_snap7_buf;
  95. t_index = 0;
  96. t_variable_information_vector.clear();
  97. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_key", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 50 });
  98. t_index += sizeof(unsigned char)*50;
  99. // t_snap7_buf.init(DISPATCH_REQUEST_FROM_MANAGER_TO_PLC_DBNUMBER_0 +m_plc_id*100, 0, sizeof(Dispatch_request_from_manager_to_plc_for_key), t_variable_information_vector, Snap7_buf::LOOP_COMMUNICATION);
  100. t_snap7_buf.init(DISPATCH_REQUEST_FROM_MANAGER_TO_PLC_DBNUMBER_0 , 0, sizeof(Dispatch_request_from_manager_to_plc_for_key), t_variable_information_vector, Snap7_buf::LOOP_COMMUNICATION);
  101. m_send_buf_map[1] = t_snap7_buf;
  102. t_index = 0;
  103. t_variable_information_vector.clear();
  104. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_response_key", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 50 });
  105. t_index += sizeof(unsigned char)*50;
  106. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved50", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  107. t_index += sizeof(unsigned char)*1;
  108. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved51_73", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 23 });
  109. t_index += sizeof(unsigned char)*23;
  110. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_dispatch_motion_direction", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  111. t_index += sizeof(unsigned char)*1;
  112. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved75_79", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 5 });
  113. t_index += sizeof(unsigned char)*5;
  114. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_passageway_id", typeid(unsigned int).name(), t_index,sizeof(unsigned int), 1 });
  115. t_index += sizeof(unsigned int)*1;
  116. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_passageway_direction", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  117. t_index += sizeof(unsigned char)*1;
  118. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved85_89", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 5 });
  119. t_index += sizeof(unsigned char)*5;
  120. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_parkingspace_index_id", typeid(unsigned int).name(), t_index,sizeof(unsigned int), 1 });
  121. t_index += sizeof(unsigned int)*1;
  122. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_parkingspace_unit_id", typeid(unsigned int).name(), t_index,sizeof(unsigned int), 1 });
  123. t_index += sizeof(unsigned int)*1;
  124. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_parkingspace_label_id", typeid(unsigned int).name(), t_index,sizeof(unsigned int), 1 });
  125. t_index += sizeof(unsigned int)*1;
  126. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_parkingspace_floor_id", typeid(unsigned int).name(), t_index,sizeof(unsigned int), 1 });
  127. t_index += sizeof(unsigned int)*1;
  128. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_parkingspace_room_id", typeid(unsigned int).name(), t_index,sizeof(unsigned int), 1 });
  129. t_index += sizeof(unsigned int)*1;
  130. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_parkingspace_direction", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  131. t_index += sizeof(unsigned char)*1;
  132. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved111", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  133. t_index += sizeof(unsigned char)*1;
  134. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_center_x", typeid(float).name(), t_index,sizeof(float), 1 });
  135. t_index += sizeof(float)*1;
  136. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_center_y", typeid(float).name(), t_index,sizeof(float), 1 });
  137. t_index += sizeof(float)*1;
  138. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_angle", typeid(float).name(), t_index,sizeof(float), 1 });
  139. t_index += sizeof(float)*1;
  140. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_front_theta", typeid(float).name(), t_index,sizeof(float), 1 });
  141. t_index += sizeof(float)*1;
  142. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_length", typeid(float).name(), t_index,sizeof(float), 1 });
  143. t_index += sizeof(float)*1;
  144. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_width", typeid(float).name(), t_index,sizeof(float), 1 });
  145. t_index += sizeof(float)*1;
  146. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_height", typeid(float).name(), t_index,sizeof(float), 1 });
  147. t_index += sizeof(float)*1;
  148. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_wheel_base", typeid(float).name(), t_index,sizeof(float), 1 });
  149. t_index += sizeof(float)*1;
  150. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_wheel_width", typeid(float).name(), t_index,sizeof(float), 1 });
  151. t_index += sizeof(float)*1;
  152. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_license", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 20 });
  153. t_index += sizeof(unsigned char)*20;
  154. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved168_187", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 20 });
  155. t_index += sizeof(unsigned char)*20;
  156. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_type", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  157. t_index += sizeof(unsigned char)*1;
  158. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved189_191", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 3 });
  159. t_index += sizeof(unsigned char)*3;
  160. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_uniformed_car_x", typeid(float).name(), t_index,sizeof(float), 1 });
  161. t_index += sizeof(float)*1;
  162. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_uniformed_car_y", typeid(float).name(), t_index,sizeof(float), 1 });
  163. t_index += sizeof(float)*1;
  164. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved200_209", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 10 });
  165. t_index += sizeof(unsigned char)*10;
  166. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_anticollision_lidar_flag", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  167. t_index += sizeof(unsigned char)*1;
  168. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved211_215", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 5 });
  169. t_index += sizeof(unsigned char)*5;
  170. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_wheel_base_exact_value", typeid(float).name(), t_index,sizeof(float), 1 });
  171. t_index += sizeof(float)*1;
  172. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved217_231", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 25 });
  173. t_index += sizeof(unsigned char)*25;
  174. // t_snap7_buf.init(DISPATCH_RESPONSE_FROM_PLC_TO_MANAGER_DBNUMBER_0 +m_plc_id*100, 0, sizeof(Dispatch_response_from_plc_to_manager), t_variable_information_vector, Snap7_buf::LOOP_COMMUNICATION);
  175. t_snap7_buf.init(DISPATCH_RESPONSE_FROM_PLC_TO_MANAGER_DBNUMBER_0 , 0, sizeof(Dispatch_response_from_plc_to_manager), t_variable_information_vector, Snap7_buf::LOOP_COMMUNICATION);
  176. m_receive_buf_map[0] = t_snap7_buf;
  177. //调度状态
  178. t_index = 0;
  179. t_variable_information_vector.clear();
  180. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_heartbeat", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  181. t_index += sizeof(unsigned char)*1;
  182. // t_snap7_buf.init(DISPATCH_PLC_STATUS_FROM_MANAGER_TO_PLC_DBNUMBER_0 +m_plc_id*100, 0, sizeof(Dispatch_plc_status_from_manager_to_plc), t_variable_information_vector, Snap7_buf::LOOP_COMMUNICATION);
  183. t_snap7_buf.init(DISPATCH_PLC_STATUS_FROM_MANAGER_TO_PLC_DBNUMBER_0 , 0, sizeof(Dispatch_plc_status_from_manager_to_plc), t_variable_information_vector, Snap7_buf::LOOP_COMMUNICATION);
  184. m_send_buf_map[2] = t_snap7_buf;
  185. t_index = 0;
  186. t_variable_information_vector.clear();
  187. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_heartbeat", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  188. t_index += sizeof(unsigned char)*1;
  189. // t_snap7_buf.init(DISPATCH_PLC_STATUS_FROM_PLC_TO_MANAGER_DBNUMBER_0 +m_plc_id*100, 0, sizeof(Dispatch_plc_status_from_plc_to_manager), t_variable_information_vector, Snap7_buf::NO_COMMUNICATION);
  190. t_snap7_buf.init(DISPATCH_PLC_STATUS_FROM_PLC_TO_MANAGER_DBNUMBER_0 , 0, sizeof(Dispatch_plc_status_from_plc_to_manager), t_variable_information_vector, Snap7_buf::NO_COMMUNICATION);
  191. m_receive_buf_map[1] = t_snap7_buf;
  192. //地面雷达指令
  193. t_index = 0;
  194. t_variable_information_vector.clear();
  195. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_center_x", typeid(float).name(), t_index,sizeof(float), 1 });
  196. t_index += sizeof(float)*1;
  197. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_center_y", typeid(float).name(), t_index,sizeof(float), 1 });
  198. t_index += sizeof(float)*1;
  199. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_angle", typeid(float).name(), t_index,sizeof(float), 1 });
  200. t_index += sizeof(float)*1;
  201. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_front_theta", typeid(float).name(), t_index,sizeof(float), 1 });
  202. t_index += sizeof(float)*1;
  203. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_length", typeid(float).name(), t_index,sizeof(float), 1 });
  204. t_index += sizeof(float)*1;
  205. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_width", typeid(float).name(), t_index,sizeof(float), 1 });
  206. t_index += sizeof(float)*1;
  207. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_height", typeid(float).name(), t_index,sizeof(float), 1 });
  208. t_index += sizeof(float)*1;
  209. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_wheel_base", typeid(float).name(), t_index,sizeof(float), 1 });
  210. t_index += sizeof(float)*1;
  211. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_wheel_width", typeid(float).name(), t_index,sizeof(float), 1 });
  212. t_index += sizeof(float)*1;
  213. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_uniformed_car_x", typeid(float).name(), t_index,sizeof(float), 1 });
  214. t_index += sizeof(float)*1;
  215. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_uniformed_car_y", typeid(float).name(), t_index,sizeof(float), 1 });
  216. t_index += sizeof(float)*1;
  217. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_response_locate_correct", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  218. t_index += sizeof(unsigned char)*1;
  219. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved45_48", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 3 });
  220. t_index += sizeof(unsigned char)*3;
  221. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_heartbeat", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  222. t_index += sizeof(unsigned char)*1;
  223. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_communication_mode", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  224. t_index += sizeof(unsigned char)*1;
  225. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_refresh_command", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  226. t_index += sizeof(unsigned char)*1;
  227. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_data_validity", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  228. t_index += sizeof(unsigned char)*1;
  229. // t_snap7_buf.init(GROUND_LIDAR_RESPONSE_FROM_MANAGER_TO_PLC_DBNUMBER_0 +m_plc_id*100, 0, sizeof(Ground_lidar_response_from_manager_to_plc_for_data), t_variable_information_vector, Snap7_buf::LOOP_COMMUNICATION);
  230. t_snap7_buf.init(GROUND_LIDAR_RESPONSE_FROM_MANAGER_TO_PLC_DBNUMBER_0 , 0, sizeof(Ground_lidar_response_from_manager_to_plc_for_data), t_variable_information_vector, Snap7_buf::LOOP_COMMUNICATION);
  231. m_send_buf_map[3] = t_snap7_buf;
  232. // t_snap7_buf.init(GROUND_LIDAR_RESPONSE_FROM_MANAGER_TO_PLC_DBNUMBER_1 +m_plc_id*100, 0, sizeof(Ground_lidar_response_from_manager_to_plc_for_data), t_variable_information_vector, Snap7_buf::LOOP_COMMUNICATION);
  233. t_snap7_buf.init(GROUND_LIDAR_RESPONSE_FROM_MANAGER_TO_PLC_DBNUMBER_1 , 0, sizeof(Ground_lidar_response_from_manager_to_plc_for_data), t_variable_information_vector, Snap7_buf::LOOP_COMMUNICATION);
  234. m_send_buf_map[4] = t_snap7_buf;
  235. t_index = 0;
  236. t_variable_information_vector.clear();
  237. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_heartbeat", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  238. t_index += sizeof(unsigned char)*1;
  239. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_communication_mode", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  240. t_index += sizeof(unsigned char)*1;
  241. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_refresh_command", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  242. t_index += sizeof(unsigned char)*1;
  243. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_data_validity", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  244. t_index += sizeof(unsigned char)*1;
  245. // t_snap7_buf.init(GROUND_LIDAR_RESPONSE_FROM_MANAGER_TO_PLC_DBNUMBER_0 +m_plc_id*100, 0, sizeof(Ground_lidar_response_from_manager_to_plc_for_key), t_variable_information_vector, Snap7_buf::NO_COMMUNICATION);
  246. t_snap7_buf.init(GROUND_LIDAR_RESPONSE_FROM_MANAGER_TO_PLC_DBNUMBER_0 , 0, sizeof(Ground_lidar_response_from_manager_to_plc_for_key), t_variable_information_vector, Snap7_buf::NO_COMMUNICATION);
  247. m_send_buf_map[5] = t_snap7_buf;
  248. // t_snap7_buf.init(GROUND_LIDAR_RESPONSE_FROM_MANAGER_TO_PLC_DBNUMBER_1 +m_plc_id*100, 0, sizeof(Ground_lidar_response_from_manager_to_plc_for_key), t_variable_information_vector, Snap7_buf::NO_COMMUNICATION);
  249. t_snap7_buf.init(GROUND_LIDAR_RESPONSE_FROM_MANAGER_TO_PLC_DBNUMBER_1 , 0, sizeof(Ground_lidar_response_from_manager_to_plc_for_key), t_variable_information_vector, Snap7_buf::NO_COMMUNICATION);
  250. m_send_buf_map[6] = t_snap7_buf;
  251. t_index = 0;
  252. t_variable_information_vector.clear();
  253. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_heartbeat", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  254. t_index += sizeof(unsigned char)*1;
  255. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_communication_mode", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  256. t_index += sizeof(unsigned char)*1;
  257. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_refresh_command", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  258. t_index += sizeof(unsigned char)*1;
  259. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_data_validity", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  260. t_index += sizeof(unsigned char)*1;
  261. // t_snap7_buf.init(GROUND_LIDAR_REQUEST_FROM_PLC_TO_MANAGER_DBNUMBER_0 +m_plc_id*100, 0, sizeof(Ground_lidar_request_from_plc_to_manager), t_variable_information_vector, Snap7_buf::NO_COMMUNICATION);
  262. t_snap7_buf.init(GROUND_LIDAR_REQUEST_FROM_PLC_TO_MANAGER_DBNUMBER_0 , 0, sizeof(Ground_lidar_request_from_plc_to_manager), t_variable_information_vector, Snap7_buf::NO_COMMUNICATION);
  263. m_receive_buf_map[2] = t_snap7_buf;
  264. // t_snap7_buf.init(GROUND_LIDAR_REQUEST_FROM_PLC_TO_MANAGER_DBNUMBER_1 +m_plc_id*100, 0, sizeof(Ground_lidar_request_from_plc_to_manager), t_variable_information_vector, Snap7_buf::NO_COMMUNICATION);
  265. t_snap7_buf.init(GROUND_LIDAR_REQUEST_FROM_PLC_TO_MANAGER_DBNUMBER_1 , 0, sizeof(Ground_lidar_request_from_plc_to_manager), t_variable_information_vector, Snap7_buf::NO_COMMUNICATION);
  266. m_receive_buf_map[3] = t_snap7_buf;
  267. //防撞雷达
  268. t_index = 0;
  269. t_variable_information_vector.clear();
  270. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_response_anticollision_lidar_flag", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  271. t_index += sizeof(unsigned char)*1;
  272. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved5_7", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 3 });
  273. t_index += sizeof(unsigned char)*3;
  274. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_response_offset_x", typeid(float).name(), t_index,sizeof(float), 1 });
  275. t_index += sizeof(float)*1;
  276. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_response_offset_angle", typeid(float).name(), t_index,sizeof(float), 1 });
  277. t_index += sizeof(float)*1;
  278. // t_snap7_buf.init(ANTICOLLISION_LIDAR_RESPONSE_FROM_MANAGER_TO_PLC_DBNUMBER_0 +m_plc_id*100, 4, sizeof(Anticollision_lidar_response_from_manager_to_plc_for_data), t_variable_information_vector, Snap7_buf::LOOP_COMMUNICATION);
  279. t_snap7_buf.init(ANTICOLLISION_LIDAR_RESPONSE_FROM_MANAGER_TO_PLC_DBNUMBER_0 , 4, sizeof(Anticollision_lidar_response_from_manager_to_plc_for_data), t_variable_information_vector, Snap7_buf::LOOP_COMMUNICATION);
  280. m_send_buf_map[7] = t_snap7_buf;
  281. t_index = 0;
  282. t_variable_information_vector.clear();
  283. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_heartbeat", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  284. t_index += sizeof(unsigned char)*1;
  285. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_communication_mode", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  286. t_index += sizeof(unsigned char)*1;
  287. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_refresh_command", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  288. t_index += sizeof(unsigned char)*1;
  289. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_data_validity", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  290. t_index += sizeof(unsigned char)*1;
  291. // t_snap7_buf.init(ANTICOLLISION_LIDAR_RESPONSE_FROM_MANAGER_TO_PLC_DBNUMBER_0 +m_plc_id*100, 0, sizeof(Anticollision_lidar_response_from_manager_to_plc_for_key), t_variable_information_vector, Snap7_buf::LOOP_COMMUNICATION);
  292. t_snap7_buf.init(ANTICOLLISION_LIDAR_RESPONSE_FROM_MANAGER_TO_PLC_DBNUMBER_0 , 0, sizeof(Anticollision_lidar_response_from_manager_to_plc_for_key), t_variable_information_vector, Snap7_buf::LOOP_COMMUNICATION);
  293. m_send_buf_map[8] = t_snap7_buf;
  294. t_index = 0;
  295. t_variable_information_vector.clear();
  296. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_heartbeat", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  297. t_index += sizeof(unsigned char)*1;
  298. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_communication_mode", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  299. t_index += sizeof(unsigned char)*1;
  300. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_refresh_command", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  301. t_index += sizeof(unsigned char)*1;
  302. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_data_validity", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  303. t_index += sizeof(unsigned char)*1;
  304. // t_snap7_buf.init(ANTICOLLISION_LIDAR_REQUEST_FROM_PLC_TO_MANAGER_DBNUMBER_0 +m_plc_id*100, 0, sizeof(Anticollision_lidar_request_from_plc_to_manager), t_variable_information_vector, Snap7_buf::NO_COMMUNICATION);
  305. t_snap7_buf.init(ANTICOLLISION_LIDAR_REQUEST_FROM_PLC_TO_MANAGER_DBNUMBER_0 , 0, sizeof(Anticollision_lidar_request_from_plc_to_manager), t_variable_information_vector, Snap7_buf::NO_COMMUNICATION);
  306. m_receive_buf_map[4] = t_snap7_buf;
  307. //单片机指令
  308. t_index = 0;
  309. t_variable_information_vector.clear();
  310. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_process_status", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  311. t_index += sizeof(unsigned char)*1;
  312. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_process_control", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  313. t_index += sizeof(unsigned char)*1;
  314. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_over_border_status", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  315. t_index += sizeof(unsigned char)*1;
  316. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_car_height_status_current", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  317. t_index += sizeof(unsigned char)*1;
  318. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_car_height_status_passing", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  319. t_index += sizeof(unsigned char)*1;
  320. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_outside_door_status", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  321. t_index += sizeof(unsigned char)*1;
  322. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_outside_door_control", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  323. t_index += sizeof(unsigned char)*1;
  324. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_dispatch_finish_flag", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  325. t_index += sizeof(unsigned char)*1;
  326. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_inside_existence_flag", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  327. t_index += sizeof(unsigned char)*1;
  328. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_outside_existence_flag", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  329. t_index += sizeof(unsigned char)*1;
  330. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reset_flag", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  331. t_index += sizeof(unsigned char)*1;
  332. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_stop_flag", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  333. t_index += sizeof(unsigned char)*1;
  334. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_error_code", typeid(unsigned int).name(), t_index,sizeof(unsigned int), 1 });
  335. t_index += sizeof(unsigned int)*1;
  336. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved16_35", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 20 });
  337. t_index += sizeof(unsigned char)*20;
  338. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_gpio_input", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 16 });
  339. t_index += sizeof(unsigned char)*16;
  340. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_gpio_output", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 8 });
  341. t_index += sizeof(unsigned char)*8;
  342. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved60_79", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 20 });
  343. t_index += sizeof(unsigned char)*20;
  344. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_heartbeat", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  345. t_index += sizeof(unsigned char)*1;
  346. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_communication_mode", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  347. t_index += sizeof(unsigned char)*1;
  348. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_refresh_command", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  349. t_index += sizeof(unsigned char)*1;
  350. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_data_validity", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  351. t_index += sizeof(unsigned char)*1;
  352. // t_snap7_buf.init(SINGLECHIP_RESPONSE_FROM_MANAGER_TO_PLC_DBNUMBER_0 +m_plc_id*100, 0, sizeof(Singlechip_response_from_manager_to_plc), t_variable_information_vector, Snap7_buf::LOOP_COMMUNICATION);
  353. t_snap7_buf.init(SINGLECHIP_RESPONSE_FROM_MANAGER_TO_PLC_DBNUMBER_0 , 0, sizeof(Singlechip_response_from_manager_to_plc), t_variable_information_vector, Snap7_buf::LOOP_COMMUNICATION);
  354. m_send_buf_map[9] = t_snap7_buf;
  355. // t_snap7_buf.init(SINGLECHIP_RESPONSE_FROM_MANAGER_TO_PLC_DBNUMBER_1 +m_plc_id*100, 0, sizeof(Singlechip_response_from_manager_to_plc), t_variable_information_vector, Snap7_buf::LOOP_COMMUNICATION);
  356. t_snap7_buf.init(SINGLECHIP_RESPONSE_FROM_MANAGER_TO_PLC_DBNUMBER_1 , 0, sizeof(Singlechip_response_from_manager_to_plc), t_variable_information_vector, Snap7_buf::LOOP_COMMUNICATION);
  357. m_send_buf_map[10] = t_snap7_buf;
  358. // t_snap7_buf.init(SINGLECHIP_RESPONSE_FROM_MANAGER_TO_PLC_DBNUMBER_2 +m_plc_id*100, 0, sizeof(Singlechip_response_from_manager_to_plc), t_variable_information_vector, Snap7_buf::LOOP_COMMUNICATION);
  359. t_snap7_buf.init(SINGLECHIP_RESPONSE_FROM_MANAGER_TO_PLC_DBNUMBER_2 , 0, sizeof(Singlechip_response_from_manager_to_plc), t_variable_information_vector, Snap7_buf::LOOP_COMMUNICATION);
  360. m_send_buf_map[11] = t_snap7_buf;
  361. // t_snap7_buf.init(SINGLECHIP_RESPONSE_FROM_MANAGER_TO_PLC_DBNUMBER_3 +m_plc_id*100, 0, sizeof(Singlechip_response_from_manager_to_plc), t_variable_information_vector, Snap7_buf::LOOP_COMMUNICATION);
  362. t_snap7_buf.init(SINGLECHIP_RESPONSE_FROM_MANAGER_TO_PLC_DBNUMBER_3 , 0, sizeof(Singlechip_response_from_manager_to_plc), t_variable_information_vector, Snap7_buf::LOOP_COMMUNICATION);
  363. m_send_buf_map[12] = t_snap7_buf;
  364. t_index = 0;
  365. t_variable_information_vector.clear();
  366. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_heartbeat", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  367. t_index += sizeof(unsigned char)*1;
  368. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_communication_mode", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  369. t_index += sizeof(unsigned char)*1;
  370. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_refresh_command", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  371. t_index += sizeof(unsigned char)*1;
  372. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_data_validity", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  373. t_index += sizeof(unsigned char)*1;
  374. // t_snap7_buf.init(SINGLECHIP_REQUEST_FROM_PLC_TO_MANAGER_DBNUMBER_0 +m_plc_id*100, 0, sizeof(Singlechip_request_from_plc_to_manager), t_variable_information_vector, Snap7_buf::NO_COMMUNICATION);
  375. t_snap7_buf.init(SINGLECHIP_REQUEST_FROM_PLC_TO_MANAGER_DBNUMBER_0 , 0, sizeof(Singlechip_request_from_plc_to_manager), t_variable_information_vector, Snap7_buf::NO_COMMUNICATION);
  376. m_receive_buf_map[5] = t_snap7_buf;
  377. // t_snap7_buf.init(SINGLECHIP_REQUEST_FROM_PLC_TO_MANAGER_DBNUMBER_1 +m_plc_id*100, 0, sizeof(Singlechip_request_from_plc_to_manager), t_variable_information_vector, Snap7_buf::NO_COMMUNICATION);
  378. t_snap7_buf.init(SINGLECHIP_REQUEST_FROM_PLC_TO_MANAGER_DBNUMBER_1 , 0, sizeof(Singlechip_request_from_plc_to_manager), t_variable_information_vector, Snap7_buf::NO_COMMUNICATION);
  379. m_receive_buf_map[6] = t_snap7_buf;
  380. // t_snap7_buf.init(SINGLECHIP_REQUEST_FROM_PLC_TO_MANAGER_DBNUMBER_2 +m_plc_id*100, 0, sizeof(Singlechip_request_from_plc_to_manager), t_variable_information_vector, Snap7_buf::NO_COMMUNICATION);
  381. t_snap7_buf.init(SINGLECHIP_REQUEST_FROM_PLC_TO_MANAGER_DBNUMBER_2 , 0, sizeof(Singlechip_request_from_plc_to_manager), t_variable_information_vector, Snap7_buf::NO_COMMUNICATION);
  382. m_receive_buf_map[7] = t_snap7_buf;
  383. // t_snap7_buf.init(SINGLECHIP_REQUEST_FROM_PLC_TO_MANAGER_DBNUMBER_3 +m_plc_id*100, 0, sizeof(Singlechip_request_from_plc_to_manager), t_variable_information_vector, Snap7_buf::NO_COMMUNICATION);
  384. t_snap7_buf.init(SINGLECHIP_REQUEST_FROM_PLC_TO_MANAGER_DBNUMBER_3 , 0, sizeof(Singlechip_request_from_plc_to_manager), t_variable_information_vector, Snap7_buf::NO_COMMUNICATION);
  385. m_receive_buf_map[8] = t_snap7_buf;
  386. switch ( m_plc_id )
  387. {
  388. case 0:
  389. {
  390. return Snap7_communication_base::communication_init_from_protobuf(SNAP7_COMMUNICATION_PARAMETER_PATH_A);
  391. break;
  392. }
  393. case 1:
  394. {
  395. return Snap7_communication_base::communication_init_from_protobuf(SNAP7_COMMUNICATION_PARAMETER_PATH_B);
  396. break;
  397. }
  398. case 2:
  399. {
  400. return Snap7_communication_base::communication_init_from_protobuf(SNAP7_COMMUNICATION_PARAMETER_PATH_C);
  401. break;
  402. }
  403. default:
  404. {
  405. return Error_manager(Error_code::SNAP7_READ_PROTOBUF_ERROR, Error_level::MINOR_ERROR,
  406. " Dispatch_communication::communication_init m_plc_id error ");
  407. break;
  408. }
  409. }
  410. }
  411. //反初始化 通信 模块。
  412. Error_manager Dispatch_communication::communication_uninit()
  413. {
  414. return Snap7_communication_base::communication_uninit();
  415. }
  416. //更新数据
  417. Error_manager Dispatch_communication::updata_receive_buf()
  418. {
  419. // return Error_code::SUCCESS;
  420. std::unique_lock<std::mutex> t_lock1(m_receive_buf_lock);
  421. std::unique_lock<std::mutex> t_lock2(m_data_lock);
  422. memcpy(&m_dispatch_response_from_plc_to_manager, m_receive_buf_map[0].mp_buf_obverse, m_receive_buf_map[0].m_size);
  423. memcpy(&m_dispatch_plc_status_from_plc_to_manager, m_receive_buf_map[1].mp_buf_obverse, m_receive_buf_map[1].m_size);
  424. memcpy(&m_ground_lidar_request_from_plc_to_manager[0], m_receive_buf_map[2].mp_buf_obverse, m_receive_buf_map[2].m_size);
  425. memcpy(&m_ground_lidar_request_from_plc_to_manager[1], m_receive_buf_map[3].mp_buf_obverse, m_receive_buf_map[3].m_size);
  426. memcpy(&m_anticollision_lidar_request_from_plc_to_manager, m_receive_buf_map[4].mp_buf_obverse, m_receive_buf_map[4].m_size);
  427. memcpy(&m_singlechip_request_from_plc_to_manager[0], m_receive_buf_map[5].mp_buf_obverse, m_receive_buf_map[5].m_size);
  428. memcpy(&m_singlechip_request_from_plc_to_manager[1], m_receive_buf_map[6].mp_buf_obverse, m_receive_buf_map[6].m_size);
  429. memcpy(&m_singlechip_request_from_plc_to_manager[3], m_receive_buf_map[7].mp_buf_obverse, m_receive_buf_map[7].m_size);
  430. memcpy(&m_singlechip_request_from_plc_to_manager[4], m_receive_buf_map[8].mp_buf_obverse, m_receive_buf_map[8].m_size);
  431. return Error_code::SUCCESS;
  432. }
  433. Error_manager Dispatch_communication::updata_send_buf()
  434. {
  435. std::unique_lock<std::mutex> t_lock1(m_send_buf_lock);
  436. std::unique_lock<std::mutex> t_lock2(m_data_lock);
  437. memcpy(m_send_buf_map[0].mp_buf_obverse, &m_dispatch_request_from_manager_to_plc_for_data, m_send_buf_map[0].m_size);
  438. memcpy(m_send_buf_map[1].mp_buf_obverse, &m_dispatch_request_from_manager_to_plc_for_key, m_send_buf_map[1].m_size);
  439. memcpy(m_send_buf_map[2].mp_buf_obverse, &m_dispatch_plc_status_from_manager_to_plc, m_send_buf_map[2].m_size);
  440. memcpy(m_send_buf_map[3].mp_buf_obverse, &m_ground_lidar_response_from_manager_to_plc_for_data[0], m_send_buf_map[3].m_size);
  441. memcpy(m_send_buf_map[4].mp_buf_obverse, &m_ground_lidar_response_from_manager_to_plc_for_data[1], m_send_buf_map[4].m_size);
  442. memcpy(m_send_buf_map[5].mp_buf_obverse, &m_ground_lidar_response_from_manager_to_plc_for_key[0], m_send_buf_map[5].m_size);
  443. memcpy(m_send_buf_map[6].mp_buf_obverse, &m_ground_lidar_response_from_manager_to_plc_for_key[1], m_send_buf_map[6].m_size);
  444. memcpy(m_send_buf_map[7].mp_buf_obverse, &m_anticollision_lidar_response_from_manager_to_plc_for_data, m_send_buf_map[7].m_size);
  445. memcpy(m_send_buf_map[8].mp_buf_obverse, &m_anticollision_lidar_response_from_manager_to_plc_for_key, m_send_buf_map[8].m_size);
  446. memcpy(m_send_buf_map[9].mp_buf_obverse, &m_singlechip_response_from_manager_to_plc[0], m_send_buf_map[9].m_size);
  447. memcpy(m_send_buf_map[10].mp_buf_obverse, &m_singlechip_response_from_manager_to_plc[1], m_send_buf_map[10].m_size);
  448. memcpy(m_send_buf_map[11].mp_buf_obverse, &m_singlechip_response_from_manager_to_plc[2], m_send_buf_map[11].m_size);
  449. memcpy(m_send_buf_map[12].mp_buf_obverse, &m_singlechip_response_from_manager_to_plc[3], m_send_buf_map[12].m_size);
  450. return Error_code::SUCCESS;
  451. }