dispatch_communication.cpp 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741
  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 short).name(), t_index,sizeof(unsigned short), 1 });
  25. t_index += sizeof(unsigned short)*1;
  26. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_working_total_time", typeid(float).name(), t_index,sizeof(float), 1 });
  27. t_index += sizeof(float)*1;
  28. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_working_remaining_time", typeid(float).name(), t_index,sizeof(float), 1 });
  29. t_index += sizeof(float)*1;
  30. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved60_73", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 14 });
  31. t_index += sizeof(unsigned char)*14;
  32. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_dispatch_motion_direction", typeid(unsigned short).name(), t_index,sizeof(unsigned short), 1 });
  33. t_index += sizeof(unsigned short)*1;
  34. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved75_79", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 4 });
  35. t_index += sizeof(unsigned char)*4;
  36. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_passageway_id", typeid(unsigned int).name(), t_index,sizeof(unsigned int), 1 });
  37. t_index += sizeof(unsigned int)*1;
  38. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_passageway_direction", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  39. t_index += sizeof(unsigned char)*1;
  40. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved85", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  41. t_index += sizeof(unsigned char)*1;
  42. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_height_level", typeid(unsigned short).name(), t_index,sizeof(unsigned short), 1 });
  43. t_index += sizeof(unsigned short)*1;
  44. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved88_89", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 2 });
  45. t_index += sizeof(unsigned char)*2;
  46. 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 });
  47. t_index += sizeof(unsigned int)*1;
  48. 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 });
  49. t_index += sizeof(unsigned int)*1;
  50. 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 });
  51. t_index += sizeof(unsigned int)*1;
  52. 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 });
  53. t_index += sizeof(unsigned int)*1;
  54. 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 });
  55. t_index += sizeof(unsigned int)*1;
  56. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_parkingspace_direction", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  57. t_index += sizeof(unsigned char)*1;
  58. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved111", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  59. t_index += sizeof(unsigned char)*1;
  60. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_center_x", 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_center_y", 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_angle", 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_front_theta", 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_length", 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_width", typeid(float).name(), t_index,sizeof(float), 1 });
  71. t_index += sizeof(float)*1;
  72. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_height", typeid(float).name(), t_index,sizeof(float), 1 });
  73. t_index += sizeof(float)*1;
  74. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_wheel_base", typeid(float).name(), t_index,sizeof(float), 1 });
  75. t_index += sizeof(float)*1;
  76. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_wheel_width", typeid(float).name(), t_index,sizeof(float), 1 });
  77. t_index += sizeof(float)*1;
  78. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_license", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 20 });
  79. t_index += sizeof(unsigned char)*20;
  80. /* t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved168_187", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 20 });
  81. t_index += sizeof(unsigned char)*20;
  82. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_type", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  83. t_index += sizeof(unsigned char)*1;
  84. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved189_191", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 3 });
  85. t_index += sizeof(unsigned char)*3;
  86. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_uniformed_car_x", typeid(float).name(), t_index,sizeof(float), 1 });
  87. t_index += sizeof(float)*1;
  88. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_uniformed_car_y", 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_reserved200_209", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 10 });
  91. t_index += sizeof(unsigned char)*10;
  92. 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 });
  93. t_index += sizeof(unsigned char)*1;
  94. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved211_215", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 5 });
  95. t_index += sizeof(unsigned char)*5;
  96. 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 });
  97. t_index += sizeof(float)*1;
  98. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved217_231", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 25 });
  99. t_index += sizeof(unsigned char)*25;
  100. */
  101. // 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);
  102. 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);
  103. m_send_buf_map[0] = t_snap7_buf;
  104. t_index = 0;
  105. t_variable_information_vector.clear();
  106. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_key", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 50 });
  107. t_index += sizeof(unsigned char)*50;
  108. // 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);
  109. 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);
  110. m_send_buf_map[1] = t_snap7_buf;
  111. t_index = 0;
  112. t_variable_information_vector.clear();
  113. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_response_key", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 50 });
  114. t_index += sizeof(unsigned char)*50;
  115. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_response_status", typeid(unsigned short).name(), t_index,sizeof(unsigned short), 1 });
  116. t_index += sizeof(unsigned short)*1;
  117. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_working_total_time", typeid(float).name(), t_index,sizeof(float), 1 });
  118. t_index += sizeof(float)*1;
  119. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_working_remaining_time", typeid(float).name(), t_index,sizeof(float), 1 });
  120. t_index += sizeof(float)*1;
  121. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved60_73", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 14 });
  122. t_index += sizeof(unsigned char)*14;
  123. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_dispatch_motion_direction", typeid(unsigned short).name(), t_index,sizeof(unsigned short), 1 });
  124. t_index += sizeof(unsigned short)*1;
  125. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved75_79", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 4 });
  126. t_index += sizeof(unsigned char)*4;
  127. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_passageway_id", typeid(unsigned int).name(), t_index,sizeof(unsigned int), 1 });
  128. t_index += sizeof(unsigned int)*1;
  129. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_passageway_direction", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  130. t_index += sizeof(unsigned char)*1;
  131. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved85_89", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 5 });
  132. t_index += sizeof(unsigned char)*5;
  133. 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 });
  134. t_index += sizeof(unsigned int)*1;
  135. 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 });
  136. t_index += sizeof(unsigned int)*1;
  137. 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 });
  138. t_index += sizeof(unsigned int)*1;
  139. 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 });
  140. t_index += sizeof(unsigned int)*1;
  141. 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 });
  142. t_index += sizeof(unsigned int)*1;
  143. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_parkingspace_direction", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  144. t_index += sizeof(unsigned char)*1;
  145. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved111", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  146. t_index += sizeof(unsigned char)*1;
  147. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_center_x", typeid(float).name(), t_index,sizeof(float), 1 });
  148. t_index += sizeof(float)*1;
  149. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_center_y", typeid(float).name(), t_index,sizeof(float), 1 });
  150. t_index += sizeof(float)*1;
  151. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_angle", typeid(float).name(), t_index,sizeof(float), 1 });
  152. t_index += sizeof(float)*1;
  153. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_front_theta", typeid(float).name(), t_index,sizeof(float), 1 });
  154. t_index += sizeof(float)*1;
  155. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_length", typeid(float).name(), t_index,sizeof(float), 1 });
  156. t_index += sizeof(float)*1;
  157. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_width", typeid(float).name(), t_index,sizeof(float), 1 });
  158. t_index += sizeof(float)*1;
  159. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_height", typeid(float).name(), t_index,sizeof(float), 1 });
  160. t_index += sizeof(float)*1;
  161. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_wheel_base", typeid(float).name(), t_index,sizeof(float), 1 });
  162. t_index += sizeof(float)*1;
  163. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_wheel_width", typeid(float).name(), t_index,sizeof(float), 1 });
  164. t_index += sizeof(float)*1;
  165. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_license", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 20 });
  166. t_index += sizeof(unsigned char)*20;
  167. /* t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved168_187", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 20 });
  168. t_index += sizeof(unsigned char)*20;
  169. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_type", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  170. t_index += sizeof(unsigned char)*1;
  171. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved189_191", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 3 });
  172. t_index += sizeof(unsigned char)*3;
  173. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_uniformed_car_x", typeid(float).name(), t_index,sizeof(float), 1 });
  174. t_index += sizeof(float)*1;
  175. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_uniformed_car_y", typeid(float).name(), t_index,sizeof(float), 1 });
  176. t_index += sizeof(float)*1;
  177. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved200_209", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 10 });
  178. t_index += sizeof(unsigned char)*10;
  179. 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 });
  180. t_index += sizeof(unsigned char)*1;
  181. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved211_215", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 5 });
  182. t_index += sizeof(unsigned char)*5;
  183. 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 });
  184. t_index += sizeof(float)*1;
  185. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved217_231", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 25 });
  186. t_index += sizeof(unsigned char)*25;
  187. */
  188. // 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);
  189. 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);
  190. m_receive_buf_map[0] = t_snap7_buf;
  191. #ifdef CHUTIAN_PROJECT_PROJECT
  192. //调度状态
  193. t_index = 0;
  194. t_variable_information_vector.clear();
  195. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_dispatch_heartbeat", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  196. t_index += sizeof(unsigned char)*1;
  197. // 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);
  198. 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::NO_COMMUNICATION);
  199. m_send_buf_map[2] = t_snap7_buf;
  200. t_index = 0;
  201. t_variable_information_vector.clear();
  202. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_plc_heartbeat", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  203. t_index += sizeof(unsigned char)*1;
  204. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_plc_status_info", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  205. t_index += sizeof(unsigned char)*1;
  206. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved2_37", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 36 });
  207. t_index += sizeof(unsigned char)*36;
  208. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_turnplate_angle_min1", typeid(float).name(), t_index,sizeof(float), 1 });
  209. t_index += sizeof(float)*1;
  210. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_turnplate_angle_max1", typeid(float).name(), t_index,sizeof(float), 1 });
  211. t_index += sizeof(float)*1;
  212. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_turnplate_angle_min2", typeid(float).name(), t_index,sizeof(float), 1 });
  213. t_index += sizeof(float)*1;
  214. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_turnplate_angle_max2", typeid(float).name(), t_index,sizeof(float), 1 });
  215. t_index += sizeof(float)*1;
  216. // 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);
  217. 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);
  218. m_receive_buf_map[1] = t_snap7_buf;
  219. #endif //CHUTIAN_PROJECT_PROJECT
  220. #ifdef SHANGGUJIE_PROJECT_PROJECT
  221. //调度状态
  222. t_index = 0;
  223. t_variable_information_vector.clear();
  224. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_dispatch_heartbeat", typeid(unsigned short).name(), t_index,sizeof(unsigned short), 1 });
  225. t_index += sizeof(unsigned short)*1;
  226. // 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);
  227. 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);
  228. m_send_buf_map[2] = t_snap7_buf;
  229. t_index = 0;
  230. t_variable_information_vector.clear();
  231. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_plc_heartbeat", typeid(unsigned short).name(), t_index,sizeof(unsigned short), 1 });
  232. t_index += sizeof(unsigned short)*1;
  233. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_plc_status_info", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  234. t_index += sizeof(unsigned char)*1;
  235. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved3", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  236. t_index += sizeof(unsigned char)*1;
  237. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved3_9", typeid(unsigned short).name(), t_index,sizeof(unsigned short), 1 });
  238. t_index += sizeof(unsigned short)*1;
  239. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved6_9", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 4 });
  240. t_index += sizeof(unsigned char)*4;
  241. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_car_height", typeid(unsigned short).name(), t_index,sizeof(unsigned short), 1 });
  242. t_index += sizeof(unsigned short)*1;
  243. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_outside_door_status", typeid(unsigned short).name(), t_index,sizeof(unsigned short), 1 });
  244. t_index += sizeof(unsigned short)*1;
  245. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_inside_door_status", typeid(unsigned short).name(), t_index,sizeof(unsigned short), 1 });
  246. t_index += sizeof(unsigned short)*1;
  247. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_comb_body_status", typeid(unsigned short).name(), t_index,sizeof(unsigned short), 1 });
  248. t_index += sizeof(unsigned short)*1;
  249. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_turnplate_angle_min", typeid(float).name(), t_index,sizeof(float), 1 });
  250. t_index += sizeof(float)*1;
  251. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_turnplate_angle_max", typeid(float).name(), t_index,sizeof(float), 1 });
  252. t_index += sizeof(float)*1;
  253. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_sensor_1", 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_sensor_2", 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_reserved18_25", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 2 });
  258. t_index += sizeof(unsigned char)*2;
  259. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_car_height", typeid(unsigned short).name(), t_index,sizeof(unsigned short), 1 });
  260. t_index += sizeof(unsigned short)*1;
  261. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_outside_door_status", typeid(unsigned short).name(), t_index,sizeof(unsigned short), 1 });
  262. t_index += sizeof(unsigned short)*1;
  263. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_inside_door_status", typeid(unsigned short).name(), t_index,sizeof(unsigned short), 1 });
  264. t_index += sizeof(unsigned short)*1;
  265. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_comb_body_status", typeid(unsigned short).name(), t_index,sizeof(unsigned short), 1 });
  266. t_index += sizeof(unsigned short)*1;
  267. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_turnplate_angle_min", typeid(float).name(), t_index,sizeof(float), 1 });
  268. t_index += sizeof(float)*1;
  269. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_turnplate_angle_max", typeid(float).name(), t_index,sizeof(float), 1 });
  270. t_index += sizeof(float)*1;
  271. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_sensor_1", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  272. t_index += sizeof(unsigned char)*1;
  273. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_sensor_2", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  274. t_index += sizeof(unsigned char)*1;
  275. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved18_25", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 2 });
  276. t_index += sizeof(unsigned char)*2;
  277. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_car_height", typeid(unsigned short).name(), t_index,sizeof(unsigned short), 1 });
  278. t_index += sizeof(unsigned short)*1;
  279. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_outside_door_status", typeid(unsigned short).name(), t_index,sizeof(unsigned short), 1 });
  280. t_index += sizeof(unsigned short)*1;
  281. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_inside_door_status", typeid(unsigned short).name(), t_index,sizeof(unsigned short), 1 });
  282. t_index += sizeof(unsigned short)*1;
  283. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_comb_body_status", typeid(unsigned short).name(), t_index,sizeof(unsigned short), 1 });
  284. t_index += sizeof(unsigned short)*1;
  285. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_turnplate_angle_min", typeid(float).name(), t_index,sizeof(float), 1 });
  286. t_index += sizeof(float)*1;
  287. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_turnplate_angle_max", typeid(float).name(), t_index,sizeof(float), 1 });
  288. t_index += sizeof(float)*1;
  289. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_sensor_1", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  290. t_index += sizeof(unsigned char)*1;
  291. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_sensor_2", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  292. t_index += sizeof(unsigned char)*1;
  293. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved18_25", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 2 });
  294. t_index += sizeof(unsigned char)*2;
  295. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_car_height", typeid(unsigned short).name(), t_index,sizeof(unsigned short), 1 });
  296. t_index += sizeof(unsigned short)*1;
  297. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_outside_door_status", typeid(unsigned short).name(), t_index,sizeof(unsigned short), 1 });
  298. t_index += sizeof(unsigned short)*1;
  299. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_inside_door_status", typeid(unsigned short).name(), t_index,sizeof(unsigned short), 1 });
  300. t_index += sizeof(unsigned short)*1;
  301. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_comb_body_status", typeid(unsigned short).name(), t_index,sizeof(unsigned short), 1 });
  302. t_index += sizeof(unsigned short)*1;
  303. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_turnplate_angle_min", typeid(float).name(), t_index,sizeof(float), 1 });
  304. t_index += sizeof(float)*1;
  305. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_turnplate_angle_max", typeid(float).name(), t_index,sizeof(float), 1 });
  306. t_index += sizeof(float)*1;
  307. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_sensor_1", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  308. t_index += sizeof(unsigned char)*1;
  309. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_sensor_2", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  310. t_index += sizeof(unsigned char)*1;
  311. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved18_25", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 2 });
  312. t_index += sizeof(unsigned char)*2;
  313. // 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);
  314. 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::LOOP_COMMUNICATION);
  315. m_receive_buf_map[1] = t_snap7_buf;
  316. #endif //SHANGGUJIE_PROJECT_PROJECT
  317. //地面雷达指令
  318. t_index = 0;
  319. t_variable_information_vector.clear();
  320. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_center_x", typeid(float).name(), t_index,sizeof(float), 1 });
  321. t_index += sizeof(float)*1;
  322. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_center_y", typeid(float).name(), t_index,sizeof(float), 1 });
  323. t_index += sizeof(float)*1;
  324. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_angle", typeid(float).name(), t_index,sizeof(float), 1 });
  325. t_index += sizeof(float)*1;
  326. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_front_theta", typeid(float).name(), t_index,sizeof(float), 1 });
  327. t_index += sizeof(float)*1;
  328. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_length", typeid(float).name(), t_index,sizeof(float), 1 });
  329. t_index += sizeof(float)*1;
  330. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_width", typeid(float).name(), t_index,sizeof(float), 1 });
  331. t_index += sizeof(float)*1;
  332. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_height", typeid(float).name(), t_index,sizeof(float), 1 });
  333. t_index += sizeof(float)*1;
  334. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_wheel_base", typeid(float).name(), t_index,sizeof(float), 1 });
  335. t_index += sizeof(float)*1;
  336. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_car_wheel_width", typeid(float).name(), t_index,sizeof(float), 1 });
  337. t_index += sizeof(float)*1;
  338. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_uniformed_car_x", typeid(float).name(), t_index,sizeof(float), 1 });
  339. t_index += sizeof(float)*1;
  340. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_uniformed_car_y", typeid(float).name(), t_index,sizeof(float), 1 });
  341. t_index += sizeof(float)*1;
  342. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_response_locate_correct", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  343. t_index += sizeof(unsigned char)*1;
  344. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_response_ground_status", 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_reserved46_47", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 2 });
  347. t_index += sizeof(unsigned char)*2;
  348. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_heartbeat", 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_communication_mode", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  351. t_index += sizeof(unsigned char)*1;
  352. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_refresh_command", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  353. t_index += sizeof(unsigned char)*1;
  354. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_data_validity", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  355. t_index += sizeof(unsigned char)*1;
  356. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_response_data_validity", typeid(int).name(), t_index,sizeof(int), 1 });
  357. t_index += sizeof(int)*1;
  358. // 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);
  359. 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::NO_COMMUNICATION);
  360. m_send_buf_map[3] = t_snap7_buf;
  361. // 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);
  362. 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::NO_COMMUNICATION);
  363. m_send_buf_map[4] = 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(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);
  375. 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);
  376. m_send_buf_map[5] = t_snap7_buf;
  377. // 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);
  378. 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);
  379. m_send_buf_map[6] = t_snap7_buf;
  380. t_index = 0;
  381. t_variable_information_vector.clear();
  382. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_heartbeat", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  383. t_index += sizeof(unsigned char)*1;
  384. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_communication_mode", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  385. t_index += sizeof(unsigned char)*1;
  386. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_refresh_command", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  387. t_index += sizeof(unsigned char)*1;
  388. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_data_validity", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  389. t_index += sizeof(unsigned char)*1;
  390. // 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);
  391. 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);
  392. m_receive_buf_map[2] = t_snap7_buf;
  393. // 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);
  394. 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);
  395. m_receive_buf_map[3] = t_snap7_buf;
  396. //防撞雷达
  397. t_index = 0;
  398. t_variable_information_vector.clear();
  399. 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 });
  400. t_index += sizeof(unsigned char)*1;
  401. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved5_7", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 3 });
  402. t_index += sizeof(unsigned char)*3;
  403. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_response_offset_x", typeid(float).name(), t_index,sizeof(float), 1 });
  404. t_index += sizeof(float)*1;
  405. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_response_offset_angle", typeid(float).name(), t_index,sizeof(float), 1 });
  406. t_index += sizeof(float)*1;
  407. // 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);
  408. 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::NO_COMMUNICATION);
  409. m_send_buf_map[7] = t_snap7_buf;
  410. t_index = 0;
  411. t_variable_information_vector.clear();
  412. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_heartbeat", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  413. t_index += sizeof(unsigned char)*1;
  414. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_communication_mode", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  415. t_index += sizeof(unsigned char)*1;
  416. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_refresh_command", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  417. t_index += sizeof(unsigned char)*1;
  418. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_data_validity", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  419. t_index += sizeof(unsigned char)*1;
  420. // 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);
  421. 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::NO_COMMUNICATION);
  422. m_send_buf_map[8] = t_snap7_buf;
  423. t_index = 0;
  424. t_variable_information_vector.clear();
  425. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_heartbeat", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  426. t_index += sizeof(unsigned char)*1;
  427. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_communication_mode", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  428. t_index += sizeof(unsigned char)*1;
  429. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_refresh_command", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  430. t_index += sizeof(unsigned char)*1;
  431. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_data_validity", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  432. t_index += sizeof(unsigned char)*1;
  433. // 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);
  434. 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);
  435. m_receive_buf_map[4] = t_snap7_buf;
  436. //单片机指令
  437. t_index = 0;
  438. t_variable_information_vector.clear();
  439. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_process_status", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  440. t_index += sizeof(unsigned char)*1;
  441. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_process_control", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  442. t_index += sizeof(unsigned char)*1;
  443. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_over_border_status", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  444. t_index += sizeof(unsigned char)*1;
  445. 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 });
  446. t_index += sizeof(unsigned char)*1;
  447. 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 });
  448. t_index += sizeof(unsigned char)*1;
  449. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_outside_door_status", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  450. t_index += sizeof(unsigned char)*1;
  451. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_outside_door_control", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  452. t_index += sizeof(unsigned char)*1;
  453. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_dispatch_finish_flag", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  454. t_index += sizeof(unsigned char)*1;
  455. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_inside_existence_flag", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  456. t_index += sizeof(unsigned char)*1;
  457. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_outside_existence_flag", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  458. t_index += sizeof(unsigned char)*1;
  459. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reset_flag", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  460. t_index += sizeof(unsigned char)*1;
  461. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_stop_flag", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  462. t_index += sizeof(unsigned char)*1;
  463. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_error_code", typeid(unsigned int).name(), t_index,sizeof(unsigned int), 1 });
  464. t_index += sizeof(unsigned int)*1;
  465. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved16_35", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 20 });
  466. t_index += sizeof(unsigned char)*20;
  467. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_gpio_input", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 16 });
  468. t_index += sizeof(unsigned char)*16;
  469. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_gpio_output", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 8 });
  470. t_index += sizeof(unsigned char)*8;
  471. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved60_79", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 20 });
  472. t_index += sizeof(unsigned char)*20;
  473. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_heartbeat", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  474. t_index += sizeof(unsigned char)*1;
  475. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_communication_mode", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  476. t_index += sizeof(unsigned char)*1;
  477. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_refresh_command", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  478. t_index += sizeof(unsigned char)*1;
  479. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_data_validity", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  480. t_index += sizeof(unsigned char)*1;
  481. // 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);
  482. 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::NO_COMMUNICATION);
  483. m_send_buf_map[9] = t_snap7_buf;
  484. // 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);
  485. 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::NO_COMMUNICATION);
  486. m_send_buf_map[10] = t_snap7_buf;
  487. // 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);
  488. 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::NO_COMMUNICATION);
  489. m_send_buf_map[11] = t_snap7_buf;
  490. // 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);
  491. 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::NO_COMMUNICATION);
  492. m_send_buf_map[12] = t_snap7_buf;
  493. t_index = 0;
  494. t_variable_information_vector.clear();
  495. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_heartbeat", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  496. t_index += sizeof(unsigned char)*1;
  497. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_communication_mode", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  498. t_index += sizeof(unsigned char)*1;
  499. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_refresh_command", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  500. t_index += sizeof(unsigned char)*1;
  501. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_data_validity", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  502. t_index += sizeof(unsigned char)*1;
  503. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_insidedoor_status", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  504. t_index += sizeof(unsigned char)*1;
  505. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_outsidedoor_control", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
  506. t_index += sizeof(unsigned char)*1;
  507. // 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);
  508. 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);
  509. m_receive_buf_map[5] = t_snap7_buf;
  510. // 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);
  511. 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);
  512. m_receive_buf_map[6] = t_snap7_buf;
  513. // 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);
  514. 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);
  515. m_receive_buf_map[7] = t_snap7_buf;
  516. // 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);
  517. 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);
  518. m_receive_buf_map[8] = t_snap7_buf;
  519. //plc数据储存
  520. t_index = 0;
  521. t_variable_information_vector.clear();
  522. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_plc_data", typeid(float).name(), t_index,sizeof(float), DATA_STORAGE_PLC_DATA_LENGTH });
  523. t_index += sizeof(float)*DATA_STORAGE_PLC_DATA_LENGTH;
  524. t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_heartbeat", typeid(float).name(), t_index,sizeof(float), 1 });
  525. t_index += sizeof(float)*1;
  526. t_snap7_buf.init(DATA_STORAGE_FROM_PLC_TO_MANAGER_DBNUMBER_0 , 0, sizeof(Data_storage_from_plc_to_manager), t_variable_information_vector, Snap7_buf::NO_COMMUNICATION);
  527. m_receive_buf_map[9] = t_snap7_buf;
  528. switch ( m_plc_id )
  529. {
  530. case 0:
  531. {
  532. return Snap7_communication_base::communication_init_from_protobuf(SETTING_PATH SNAP7_COMMUNICATION_PARAMETER_PATH_A);
  533. break;
  534. }
  535. case 1:
  536. {
  537. return Snap7_communication_base::communication_init_from_protobuf(SETTING_PATH SNAP7_COMMUNICATION_PARAMETER_PATH_B);
  538. break;
  539. }
  540. case 2:
  541. {
  542. return Snap7_communication_base::communication_init_from_protobuf(SETTING_PATH SNAP7_COMMUNICATION_PARAMETER_PATH_C);
  543. break;
  544. }
  545. case 11:
  546. {
  547. return Snap7_communication_base::communication_init_from_protobuf(SETTING_PATH SNAP7_COMMUNICATION_PARAMETER_PATH_A1);
  548. break;
  549. }
  550. case 12:
  551. {
  552. return Snap7_communication_base::communication_init_from_protobuf(SETTING_PATH SNAP7_COMMUNICATION_PARAMETER_PATH_A2);
  553. break;
  554. }
  555. case 13:
  556. {
  557. return Snap7_communication_base::communication_init_from_protobuf(SETTING_PATH SNAP7_COMMUNICATION_PARAMETER_PATH_A3);
  558. break;
  559. }
  560. case 14:
  561. {
  562. return Snap7_communication_base::communication_init_from_protobuf(SETTING_PATH SNAP7_COMMUNICATION_PARAMETER_PATH_A4);
  563. break;
  564. }
  565. case 21:
  566. {
  567. return Snap7_communication_base::communication_init_from_protobuf(SETTING_PATH SNAP7_COMMUNICATION_PARAMETER_PATH_B1);
  568. break;
  569. }
  570. case 22:
  571. {
  572. return Snap7_communication_base::communication_init_from_protobuf(SETTING_PATH SNAP7_COMMUNICATION_PARAMETER_PATH_B2);
  573. break;
  574. }
  575. case 23:
  576. {
  577. return Snap7_communication_base::communication_init_from_protobuf(SETTING_PATH SNAP7_COMMUNICATION_PARAMETER_PATH_B3);
  578. break;
  579. }
  580. case 24:
  581. {
  582. return Snap7_communication_base::communication_init_from_protobuf(SETTING_PATH SNAP7_COMMUNICATION_PARAMETER_PATH_B4);
  583. break;
  584. }
  585. case 25:
  586. {
  587. return Snap7_communication_base::communication_init_from_protobuf(SETTING_PATH SNAP7_COMMUNICATION_PARAMETER_PATH_B5);
  588. break;
  589. }
  590. case 31:
  591. {
  592. return Snap7_communication_base::communication_init_from_protobuf(SETTING_PATH SNAP7_COMMUNICATION_PARAMETER_PATH_C1);
  593. break;
  594. }
  595. case 32:
  596. {
  597. return Snap7_communication_base::communication_init_from_protobuf(SETTING_PATH SNAP7_COMMUNICATION_PARAMETER_PATH_C2);
  598. break;
  599. }
  600. default:
  601. {
  602. return Error_manager(Error_code::SNAP7_READ_PROTOBUF_ERROR, Error_level::MINOR_ERROR,
  603. " Dispatch_communication::communication_init m_plc_id error ");
  604. break;
  605. }
  606. }
  607. }
  608. //反初始化 通信 模块。
  609. Error_manager Dispatch_communication::communication_uninit()
  610. {
  611. return Snap7_communication_base::communication_uninit();
  612. }
  613. //更新数据
  614. Error_manager Dispatch_communication::updata_receive_buf()
  615. {
  616. // return Error_code::SUCCESS;
  617. std::unique_lock<std::mutex> t_lock1(m_receive_buf_lock);
  618. std::unique_lock<std::mutex> t_lock2(m_data_lock);
  619. memcpy(&m_dispatch_response_from_plc_to_manager, m_receive_buf_map[0].mp_buf_obverse, m_receive_buf_map[0].m_size);
  620. memcpy(&m_dispatch_plc_status_from_plc_to_manager, m_receive_buf_map[1].mp_buf_obverse, m_receive_buf_map[1].m_size);
  621. 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);
  622. 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);
  623. memcpy(&m_anticollision_lidar_request_from_plc_to_manager, m_receive_buf_map[4].mp_buf_obverse, m_receive_buf_map[4].m_size);
  624. memcpy(&m_singlechip_request_from_plc_to_manager[0], m_receive_buf_map[5].mp_buf_obverse, m_receive_buf_map[5].m_size);
  625. memcpy(&m_singlechip_request_from_plc_to_manager[1], m_receive_buf_map[6].mp_buf_obverse, m_receive_buf_map[6].m_size);
  626. memcpy(&m_singlechip_request_from_plc_to_manager[3], m_receive_buf_map[7].mp_buf_obverse, m_receive_buf_map[7].m_size);
  627. memcpy(&m_singlechip_request_from_plc_to_manager[4], m_receive_buf_map[8].mp_buf_obverse, m_receive_buf_map[8].m_size);
  628. memcpy(&m_data_storage_from_plc_to_manager, m_receive_buf_map[9].mp_buf_obverse, m_receive_buf_map[9].m_size);
  629. return Error_code::SUCCESS;
  630. }
  631. Error_manager Dispatch_communication::updata_send_buf()
  632. {
  633. std::unique_lock<std::mutex> t_lock1(m_send_buf_lock);
  634. std::unique_lock<std::mutex> t_lock2(m_data_lock);
  635. 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);
  636. 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);
  637. memcpy(m_send_buf_map[2].mp_buf_obverse, &m_dispatch_plc_status_from_manager_to_plc, m_send_buf_map[2].m_size);
  638. 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);
  639. 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);
  640. 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);
  641. 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);
  642. 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);
  643. 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);
  644. memcpy(m_send_buf_map[9].mp_buf_obverse, &m_singlechip_response_from_manager_to_plc[0], m_send_buf_map[9].m_size);
  645. memcpy(m_send_buf_map[10].mp_buf_obverse, &m_singlechip_response_from_manager_to_plc[1], m_send_buf_map[10].m_size);
  646. memcpy(m_send_buf_map[11].mp_buf_obverse, &m_singlechip_response_from_manager_to_plc[2], m_send_buf_map[11].m_size);
  647. memcpy(m_send_buf_map[12].mp_buf_obverse, &m_singlechip_response_from_manager_to_plc[3], m_send_buf_map[12].m_size);
  648. // std::cout << " huli test :::: " << " m_dispatch_request_from_manager_to_plc_for_data = " << m_dispatch_request_from_manager_to_plc_for_data.m_request_car_center_x << std::endl;
  649. return Error_code::SUCCESS;
  650. }