Browse Source

20211017, 通信test

huli 3 years ago
parent
commit
b5c0e2b94e

+ 21 - 10
dispatch/dispatch_communication.cpp

@@ -36,7 +36,7 @@ Error_manager Dispatch_communication::communication_init(int plc_id)
 //调度指令
 //调度指令
 	t_index = 0;
 	t_index = 0;
 	t_variable_information_vector.clear();
 	t_variable_information_vector.clear();
-	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved50", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
+	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_request_status", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
 	t_index += sizeof(unsigned char)*1;
 	t_index += sizeof(unsigned char)*1;
 	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved51_73", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 23 });
 	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved51_73", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 23 });
 	t_index += sizeof(unsigned char)*23;
 	t_index += sizeof(unsigned char)*23;
@@ -229,12 +229,25 @@ Error_manager Dispatch_communication::communication_init(int plc_id)
 	t_index += sizeof(float)*1;
 	t_index += sizeof(float)*1;
 	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_response_locate_correct", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
 	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_response_locate_correct", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
 	t_index += sizeof(unsigned char)*1;
 	t_index += sizeof(unsigned char)*1;
+	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved37_40", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 3 });
+	t_index += sizeof(unsigned char)*3;
+	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_heartbeat", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
+	t_index += sizeof(unsigned char)*1;
+	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_communication_mode", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
+	t_index += sizeof(unsigned char)*1;
+	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_refresh_command", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
+	t_index += sizeof(unsigned char)*1;
+	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_data_validity", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
+	t_index += sizeof(unsigned char)*1;
+	
+	
 
 
-	t_snap7_buf.init(GROUND_LIDAR_RESPONSE_FROM_MANAGER_TO_PLC_DBNUMBER_0 +m_plc_id*100, 4, sizeof(Ground_lidar_response_from_manager_to_plc_for_data), t_variable_information_vector, Snap7_buf::LOOP_COMMUNICATION);
+	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);
 	m_send_buf_map[3] = t_snap7_buf;
 	m_send_buf_map[3] = t_snap7_buf;
-	t_snap7_buf.init(GROUND_LIDAR_RESPONSE_FROM_MANAGER_TO_PLC_DBNUMBER_1 +m_plc_id*100, 4, sizeof(Ground_lidar_response_from_manager_to_plc_for_data), t_variable_information_vector, Snap7_buf::LOOP_COMMUNICATION);
+	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);
 	m_send_buf_map[4] = t_snap7_buf;
 	m_send_buf_map[4] = t_snap7_buf;
 
 
+
 	t_index = 0;
 	t_index = 0;
 	t_variable_information_vector.clear();
 	t_variable_information_vector.clear();
 	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_heartbeat", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
 	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_heartbeat", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
@@ -246,9 +259,9 @@ Error_manager Dispatch_communication::communication_init(int plc_id)
 	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_data_validity", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
 	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_data_validity", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
 	t_index += sizeof(unsigned char)*1;
 	t_index += sizeof(unsigned char)*1;
 
 
-	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::LOOP_COMMUNICATION);
+	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);
 	m_send_buf_map[5] = t_snap7_buf;
 	m_send_buf_map[5] = t_snap7_buf;
-	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::LOOP_COMMUNICATION);
+	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);
 	m_send_buf_map[6] = t_snap7_buf;
 	m_send_buf_map[6] = t_snap7_buf;
 
 
 	t_index = 0;
 	t_index = 0;
@@ -281,7 +294,7 @@ Error_manager Dispatch_communication::communication_init(int plc_id)
 	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_response_offset_angle", typeid(float).name(), t_index,sizeof(float), 1 });
 	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_response_offset_angle", typeid(float).name(), t_index,sizeof(float), 1 });
 	t_index += sizeof(float)*1;
 	t_index += sizeof(float)*1;
 
 
-	t_snap7_buf.init(GROUND_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);
+	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);
 	m_send_buf_map[7] = t_snap7_buf;
 	m_send_buf_map[7] = t_snap7_buf;
 
 
 	t_index = 0;
 	t_index = 0;
@@ -295,7 +308,7 @@ Error_manager Dispatch_communication::communication_init(int plc_id)
 	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_data_validity", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
 	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_data_validity", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
 	t_index += sizeof(unsigned char)*1;
 	t_index += sizeof(unsigned char)*1;
 
 
-	t_snap7_buf.init(GROUND_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);
+	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);
 	m_send_buf_map[8] = t_snap7_buf;
 	m_send_buf_map[8] = t_snap7_buf;
 
 
 
 
@@ -310,7 +323,7 @@ Error_manager Dispatch_communication::communication_init(int plc_id)
 	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_data_validity", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
 	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_data_validity", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 1 });
 	t_index += sizeof(unsigned char)*1;
 	t_index += sizeof(unsigned char)*1;
 
 
-	t_snap7_buf.init(GROUND_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);
+	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);
 	m_receive_buf_map[4] = t_snap7_buf;
 	m_receive_buf_map[4] = t_snap7_buf;
 
 
 	return Snap7_communication_base::communication_init();
 	return Snap7_communication_base::communication_init();
@@ -347,8 +360,6 @@ Error_manager Dispatch_communication::updata_send_buf()
 	std::unique_lock<std::mutex> t_lock1(m_send_buf_lock);
 	std::unique_lock<std::mutex> t_lock1(m_send_buf_lock);
 	std::unique_lock<std::mutex> t_lock2(m_data_lock);
 	std::unique_lock<std::mutex> t_lock2(m_data_lock);
 
 
-	m_dispatch_request_from_manager_to_plc_for_data.m_reserved50 = 1;
-
 	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);
 	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);
 	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);
 	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);
 	memcpy(m_send_buf_map[2].mp_buf_obverse, &m_dispatch_plc_status_from_manager_to_plc, m_send_buf_map[2].m_size);
 	memcpy(m_send_buf_map[2].mp_buf_obverse, &m_dispatch_plc_status_from_manager_to_plc, m_send_buf_map[2].m_size);

+ 14 - 3
dispatch/dispatch_communication.h

@@ -288,13 +288,18 @@ public:
 
 
 
 
 
 
+
+
+
+
+
 //调度管理给plc发送调度指令 的DB编号
 //调度管理给plc发送调度指令 的DB编号
 #define DISPATCH_REQUEST_FROM_MANAGER_TO_PLC_DBNUMBER_0		9000
 #define DISPATCH_REQUEST_FROM_MANAGER_TO_PLC_DBNUMBER_0		9000
 //调度管理给plc发送调度指令 的结构体
 //调度管理给plc发送调度指令 的结构体
 	struct Dispatch_request_from_manager_to_plc_for_data
 	struct Dispatch_request_from_manager_to_plc_for_data
 	{
 	{
 		//指令信息
 		//指令信息
-		unsigned char			m_reserved50 = 0;					//预留
+		unsigned char			m_request_status = 0;			//指令完成状态, 机器人答复指令, 返回任务完成的情况
 		unsigned char			m_reserved51_73[23] = {0};			//预留
 		unsigned char			m_reserved51_73[23] = {0};			//预留
 		// 调度指令的起点,终点,方向
 		// 调度指令的起点,终点,方向
 		unsigned char			m_request_dispatch_motion_direction = 0;			//调度方向	0=未知,1=存车,2=取车
 		unsigned char			m_request_dispatch_motion_direction = 0;			//调度方向	0=未知,1=存车,2=取车
@@ -331,7 +336,7 @@ public:
 		unsigned char			m_reserved211_215[5] = {0};							//预留
 		unsigned char			m_reserved211_215[5] = {0};							//预留
 		//轮距雷达 ..216
 		//轮距雷达 ..216
 		float  					m_request_car_wheel_base_exact_value = 0;	//汽车前后轮距,轮距雷达的精确值	预留, 楚天暂时不用,单位:米 m
 		float  					m_request_car_wheel_base_exact_value = 0;	//汽车前后轮距,轮距雷达的精确值	预留, 楚天暂时不用,单位:米 m
-		unsigned char			m_reserved217_231[25] = {0};				//预留
+		unsigned char			m_reserved220_231[12] = {0};				//预留
 
 
 	};
 	};
 //调度管理给plc发送调度指令 的结构体
 //调度管理给plc发送调度指令 的结构体
@@ -386,7 +391,7 @@ public:
 		unsigned char			m_reserved211_215[5] = {0};							//预留
 		unsigned char			m_reserved211_215[5] = {0};							//预留
 		//轮距雷达 ..216
 		//轮距雷达 ..216
 		float  					m_response_car_wheel_base_exact_value = 0;	//汽车前后轮距,轮距雷达的精确值	预留, 楚天暂时不用,单位:米 m
 		float  					m_response_car_wheel_base_exact_value = 0;	//汽车前后轮距,轮距雷达的精确值	预留, 楚天暂时不用,单位:米 m
-		unsigned char			m_reserved217_231[25] = {0};				//预留
+		unsigned char			m_reserved220_231[12] = {0};				//预留
 
 
 	};
 	};
 
 
@@ -439,6 +444,12 @@ public:
 		float  					m_response_car_wheel_base = 0;				//整车的轮距, 前后轮的距离, 用于机器人或agv的抓车, 单位:米 m
 		float  					m_response_car_wheel_base = 0;				//整车的轮距, 前后轮的距离, 用于机器人或agv的抓车, 单位:米 m
 		float  					m_response_car_wheel_width = 0;				//整车的轮距, 左右轮的距离, 用于机器人或agv的抓车, 单位:米 m
 		float  					m_response_car_wheel_width = 0;				//整车的轮距, 左右轮的距离, 用于机器人或agv的抓车, 单位:米 m
 		unsigned char			m_response_locate_correct = 0;				//数据是否有效, 0=无效, 1=有效
 		unsigned char			m_response_locate_correct = 0;				//数据是否有效, 0=无效, 1=有效
+			
+		unsigned char			m_reserved37_40[3] = {0};							//预留
+		unsigned char			m_response_heartbeat = 0;							//心跳位, 0-255循环
+		unsigned char			m_response_communication_mode = 0;					//通信模式	0 = 未知, 1=自动循环模式,2=手动刷新模式
+		unsigned char			m_response_refresh_command = 0;						//刷新指令 0-255任意数字,与上一次不同即可
+		unsigned char			m_response_data_validity = 0;						//数据有效性, 0 = 未知, 1 = 有效, 2 = 无效
 	};
 	};
 
 
 	//plc给地面雷达
 	//plc给地面雷达

+ 18 - 16
dispatch/dispatch_ground_lidar.cpp

@@ -62,8 +62,8 @@ Error_manager Dispatch_ground_lidar::execute_for_ground_status_msg(message::Grou
 	m_ground_status_msg_updata_time = std::chrono::system_clock::now();
 	m_ground_status_msg_updata_time = std::chrono::system_clock::now();
 	m_ground_status_msg_updata_flag = true;
 	m_ground_status_msg_updata_flag = true;
 
 
-	std::cout << " huli test :::: " << " ---------------------------------------------------- = " << std::endl;
-	std::cout << " huli test :::: " << " m_ground_status_msg = " << m_ground_status_msg.DebugString() << std::endl;
+//	std::cout << " huli test :::: " << " ---------------------------------------------------- = " << std::endl;
+//	std::cout << " huli test :::: " << " m_ground_status_msg = " << m_ground_status_msg.DebugString() << std::endl;
 
 
 	return Error_code::SUCCESS;
 	return Error_code::SUCCESS;
 }
 }
@@ -93,9 +93,10 @@ void Dispatch_ground_lidar::execute_thread_fun()
 
 
 			std::this_thread::yield();
 			std::this_thread::yield();
 
 
-
+			
 			if (m_ground_status_msg_updata_flag)
 			if (m_ground_status_msg_updata_flag)
 			{
 			{
+			
 				std::unique_lock<std::mutex> t_lock(Dispatch_communication::get_instance_references().m_data_lock);
 				std::unique_lock<std::mutex> t_lock(Dispatch_communication::get_instance_references().m_data_lock);
 				std::unique_lock<std::mutex> t_lock2(m_lock);
 				std::unique_lock<std::mutex> t_lock2(m_lock);
 
 
@@ -105,15 +106,16 @@ void Dispatch_ground_lidar::execute_thread_fun()
 				Dispatch_communication::Ground_lidar_response_from_manager_to_plc_for_key *p_response_key = &Dispatch_communication::get_instance_references().m_ground_lidar_response_from_manager_to_plc_for_key[t_inlet_id];
 				Dispatch_communication::Ground_lidar_response_from_manager_to_plc_for_key *p_response_key = &Dispatch_communication::get_instance_references().m_ground_lidar_response_from_manager_to_plc_for_key[t_inlet_id];
 				Dispatch_communication::Ground_lidar_request_from_plc_to_manager *p_request = &Dispatch_communication::get_instance_references().m_ground_lidar_request_from_plc_to_manager[t_inlet_id];
 				Dispatch_communication::Ground_lidar_request_from_plc_to_manager *p_request = &Dispatch_communication::get_instance_references().m_ground_lidar_request_from_plc_to_manager[t_inlet_id];
 
 
-				if (p_request->m_request_communication_mode == 0)
+
+				if (p_request->m_request_communication_mode != 2)
 				{
 				{
-					p_response_key->m_response_heartbeat++;
-					p_response_key->m_response_communication_mode = p_request->m_request_communication_mode;
-					p_response_key->m_response_refresh_command = p_request->m_request_refresh_command;
+					p_response_data->m_response_heartbeat = 1-p_response_data->m_response_heartbeat;
+					p_response_data->m_response_communication_mode = p_request->m_request_communication_mode;
+					p_response_data->m_response_refresh_command = p_request->m_request_refresh_command;
 
 
 					p_response_data->m_response_car_center_x = m_ground_status_msg.locate_information_realtime().locate_x();
 					p_response_data->m_response_car_center_x = m_ground_status_msg.locate_information_realtime().locate_x();
 					p_response_data->m_response_car_center_y = m_ground_status_msg.locate_information_realtime().locate_y();
 					p_response_data->m_response_car_center_y = m_ground_status_msg.locate_information_realtime().locate_y();
-					p_response_data->m_response_car_angle = m_ground_status_msg.locate_information_realtime().locate_angle();
+					p_response_data->m_response_car_angle = m_ground_status_msg.locate_information_realtime().locate_angle()-90;
 					p_response_data->m_response_car_front_theta = m_ground_status_msg.locate_information_realtime().locate_front_theta();
 					p_response_data->m_response_car_front_theta = m_ground_status_msg.locate_information_realtime().locate_front_theta();
 					p_response_data->m_response_car_length = m_ground_status_msg.locate_information_realtime().locate_length();
 					p_response_data->m_response_car_length = m_ground_status_msg.locate_information_realtime().locate_length();
 					p_response_data->m_response_car_width = m_ground_status_msg.locate_information_realtime().locate_width();
 					p_response_data->m_response_car_width = m_ground_status_msg.locate_information_realtime().locate_width();
@@ -122,21 +124,21 @@ void Dispatch_ground_lidar::execute_thread_fun()
 					p_response_data->m_response_car_wheel_width = m_ground_status_msg.locate_information_realtime().locate_wheel_width();
 					p_response_data->m_response_car_wheel_width = m_ground_status_msg.locate_information_realtime().locate_wheel_width();
 					p_response_data->m_response_locate_correct = m_ground_status_msg.locate_information_realtime().locate_correct();
 					p_response_data->m_response_locate_correct = m_ground_status_msg.locate_information_realtime().locate_correct();
 				}
 				}
-				else if (p_response_key->m_response_refresh_command == p_request->m_request_refresh_command)
+				else if (p_response_data->m_response_refresh_command == p_request->m_request_refresh_command)
 				{
 				{
-					p_response_key->m_response_heartbeat++;
-					p_response_key->m_response_communication_mode = p_request->m_request_communication_mode;
-					p_response_key->m_response_refresh_command = p_request->m_request_refresh_command;
+					p_response_data->m_response_heartbeat = 1-p_response_data->m_response_heartbeat;
+					p_response_data->m_response_communication_mode = p_request->m_request_communication_mode;
+					p_response_data->m_response_refresh_command = p_request->m_request_refresh_command;
 				}
 				}
 				else
 				else
 				{
 				{
-					p_response_key->m_response_heartbeat++;
-					p_response_key->m_response_communication_mode = p_request->m_request_communication_mode;
-					p_response_key->m_response_refresh_command = p_request->m_request_refresh_command;
+					p_response_data->m_response_heartbeat = 1-p_response_data->m_response_heartbeat;
+					p_response_data->m_response_communication_mode = p_request->m_request_communication_mode;
+					p_response_data->m_response_refresh_command = p_request->m_request_refresh_command;
 
 
 					p_response_data->m_response_car_center_x = m_ground_status_msg.locate_information_realtime().locate_x();
 					p_response_data->m_response_car_center_x = m_ground_status_msg.locate_information_realtime().locate_x();
 					p_response_data->m_response_car_center_y = m_ground_status_msg.locate_information_realtime().locate_y();
 					p_response_data->m_response_car_center_y = m_ground_status_msg.locate_information_realtime().locate_y();
-					p_response_data->m_response_car_angle = m_ground_status_msg.locate_information_realtime().locate_angle();
+					p_response_data->m_response_car_angle = m_ground_status_msg.locate_information_realtime().locate_angle()-90;
 					p_response_data->m_response_car_front_theta = m_ground_status_msg.locate_information_realtime().locate_front_theta();
 					p_response_data->m_response_car_front_theta = m_ground_status_msg.locate_information_realtime().locate_front_theta();
 					p_response_data->m_response_car_length = m_ground_status_msg.locate_information_realtime().locate_length();
 					p_response_data->m_response_car_length = m_ground_status_msg.locate_information_realtime().locate_length();
 					p_response_data->m_response_car_width = m_ground_status_msg.locate_information_realtime().locate_width();
 					p_response_data->m_response_car_width = m_ground_status_msg.locate_information_realtime().locate_width();

+ 19 - 6
dispatch/dispatch_plc.cpp

@@ -248,13 +248,25 @@ Error_manager Dispatch_plc::encapsulate_dispatch_request_to_plc()
 		m_request_dispatch_motion_direction = Common_data::Dispatch_motion_direction::DISPATCH_MOTION_DIRECTION_UNKNOWN;
 		m_request_dispatch_motion_direction = Common_data::Dispatch_motion_direction::DISPATCH_MOTION_DIRECTION_UNKNOWN;
 		m_request_passageway_direction = Common_data::Passageway_direction::PASSAGEWAY_DIRECTION_UNKNOWN;
 		m_request_passageway_direction = Common_data::Passageway_direction::PASSAGEWAY_DIRECTION_UNKNOWN;
 	}
 	}
-	m_request_passageway_id = m_dispatch_request_msg.terminal_id();
+	m_request_passageway_id = m_dispatch_request_msg.terminal_id()+1;//0~5改为1~6
 
 
 	if ( m_dispatch_request_msg.locate_information().locate_correct() )
 	if ( m_dispatch_request_msg.locate_information().locate_correct() )
 	{
 	{
 		m_request_car_center_x = m_dispatch_request_msg.locate_information().locate_x();
 		m_request_car_center_x = m_dispatch_request_msg.locate_information().locate_x();
 		m_request_car_center_y = m_dispatch_request_msg.locate_information().locate_y();
 		m_request_car_center_y = m_dispatch_request_msg.locate_information().locate_y();
-		m_request_car_angle = m_dispatch_request_msg.locate_information().locate_angle();
+		m_request_car_angle = m_dispatch_request_msg.locate_information().locate_angle()-90;//80~100改为-10~+10
+		m_request_car_front_theta = m_dispatch_request_msg.locate_information().locate_front_theta();
+		m_request_car_length = m_dispatch_request_msg.locate_information().locate_length();
+		m_request_car_width = m_dispatch_request_msg.locate_information().locate_width();
+		m_request_car_height = m_dispatch_request_msg.locate_information().locate_height();
+		m_request_car_wheel_base = m_dispatch_request_msg.locate_information().locate_wheel_base();
+		m_request_car_wheel_width = m_dispatch_request_msg.locate_information().locate_wheel_width();
+	}
+	else
+	{
+		m_request_car_center_x = m_dispatch_request_msg.locate_information().locate_x();
+		m_request_car_center_y = m_dispatch_request_msg.locate_information().locate_y();
+		m_request_car_angle = m_dispatch_request_msg.locate_information().locate_angle()-90;//80~100改为-10~+10
 		m_request_car_front_theta = m_dispatch_request_msg.locate_information().locate_front_theta();
 		m_request_car_front_theta = m_dispatch_request_msg.locate_information().locate_front_theta();
 		m_request_car_length = m_dispatch_request_msg.locate_information().locate_length();
 		m_request_car_length = m_dispatch_request_msg.locate_information().locate_length();
 		m_request_car_width = m_dispatch_request_msg.locate_information().locate_width();
 		m_request_car_width = m_dispatch_request_msg.locate_information().locate_width();
@@ -338,6 +350,7 @@ Error_manager Dispatch_plc::update_dispatch_plc_communication()
 	memset(m_dispatch_request_from_manager_to_plc_for_key->m_request_key, 0, 50);
 	memset(m_dispatch_request_from_manager_to_plc_for_key->m_request_key, 0, 50);
 	int t_size1 = m_request_key.size()<=50 ? m_request_key.size() : 50 ;
 	int t_size1 = m_request_key.size()<=50 ? m_request_key.size() : 50 ;
 	memcpy(m_dispatch_request_from_manager_to_plc_for_key->m_request_key, m_request_key.c_str(), t_size1);
 	memcpy(m_dispatch_request_from_manager_to_plc_for_key->m_request_key, m_request_key.c_str(), t_size1);
+	tp_dispatch_request_from_manager_to_plc_for_data->m_request_status = 1;
 	tp_dispatch_request_from_manager_to_plc_for_data->m_request_dispatch_motion_direction = m_request_dispatch_motion_direction;
 	tp_dispatch_request_from_manager_to_plc_for_data->m_request_dispatch_motion_direction = m_request_dispatch_motion_direction;
 	tp_dispatch_request_from_manager_to_plc_for_data->m_request_passageway_id = m_request_passageway_id;
 	tp_dispatch_request_from_manager_to_plc_for_data->m_request_passageway_id = m_request_passageway_id;
 	tp_dispatch_request_from_manager_to_plc_for_data->m_request_passageway_direction = m_request_passageway_direction;
 	tp_dispatch_request_from_manager_to_plc_for_data->m_request_passageway_direction = m_request_passageway_direction;
@@ -442,7 +455,7 @@ Error_manager Dispatch_plc::check_response_from_plc()
 	std::unique_lock<std::mutex> t_lock(m_lock);
 	std::unique_lock<std::mutex> t_lock(m_lock);
 
 
 
 
-
+#ifndef WAIT_PLC_RESPONSE
 	//need, 调试代码, 延时10s, 直接返回成功
 	//need, 调试代码, 延时10s, 直接返回成功
 	if ( std::chrono::system_clock::now() - m_start_time > std::chrono::seconds(10) )
 	if ( std::chrono::system_clock::now() - m_start_time > std::chrono::seconds(10) )
 	{
 	{
@@ -453,10 +466,10 @@ Error_manager Dispatch_plc::check_response_from_plc()
 	{
 	{
 		return Error_code::NODATA;
 		return Error_code::NODATA;
 	}
 	}
+#endif
 
 
 
 
-
-
+#ifdef WAIT_PLC_RESPONSE
 	//检查唯一码
 	//检查唯一码
 	if ( m_response_key == m_request_key  )
 	if ( m_response_key == m_request_key  )
 	{
 	{
@@ -475,7 +488,7 @@ Error_manager Dispatch_plc::check_response_from_plc()
 	{
 	{
 		return Error_code::NODATA;
 		return Error_code::NODATA;
 	}
 	}
-
+#endif
 	return Error_code::SUCCESS;
 	return Error_code::SUCCESS;
 }
 }
 
 

+ 2 - 2
error_code/error_code.h

@@ -3,8 +3,8 @@
 //#define PROCESS_TEST 1
 //#define PROCESS_TEST 1
 //#define TIME_TEST 1
 //#define TIME_TEST 1
 
 
-#define S7_TEST 1
-
+#define PLC_S7_COMMUNICATION 1	//是否开启plc的通信
+#define WAIT_PLC_RESPONSE 1		//是否等待plc的答复
 
 
 //Error_code是错误码的底层通用模块,
 //Error_code是错误码的底层通用模块,
 //功能:用作故障分析和处理。
 //功能:用作故障分析和处理。

+ 49 - 8
main.cpp

@@ -53,17 +53,9 @@ GOOGLE_GLOG_DLL_DECL void shut_down_logging(const char* data, int size)
 #include <chrono>
 #include <chrono>
 using namespace std;
 using namespace std;
 
 
-
-
-
 int main(int argc,char* argv[])
 int main(int argc,char* argv[])
 {
 {
 
 
-
-
-
-
-
 	int t_id = 2;
 	int t_id = 2;
 	if ( argc == 2 )
 	if ( argc == 2 )
 	{
 	{
@@ -122,6 +114,55 @@ int main(int argc,char* argv[])
 //20210922
 //20210922
 	while (1)
 	while (1)
 	{
 	{
+		std::string test_string;
+		std::cin >> test_string ;
+
+		if ( test_string == "9" )
+		{
+
+			message::Dispatch_request_msg dispatch_request_msg;
+			dispatch_request_msg.mutable_base_info()->set_msg_type(message::Message_type::eDispatch_request_msg);
+			dispatch_request_msg.mutable_base_info()->set_timeout_ms(5000000);
+			dispatch_request_msg.mutable_base_info()->set_sender(message::Communicator::eMain);
+			dispatch_request_msg.mutable_base_info()->set_receiver(message::Communicator::eDispatch_manager);
+			dispatch_request_msg.set_command_key("12345678901234567890123456789012");
+
+			dispatch_request_msg.set_dispatch_motion_direction(message::Dispatch_motion_direction::E_STORE_CAR);
+			dispatch_request_msg.set_terminal_id(4);
+			message::Locate_information t_locate_information;
+			t_locate_information.set_locate_x(-1.901);
+			t_locate_information.set_locate_y(-5.829);
+			t_locate_information.set_locate_angle(2);
+			t_locate_information.set_locate_length(4.78);
+			t_locate_information.set_locate_width(1.88);
+			t_locate_information.set_locate_height(1.65);
+			t_locate_information.set_locate_wheel_base(2.78);
+			t_locate_information.set_locate_wheel_width(1.88);
+			t_locate_information.set_locate_front_theta(0);
+
+			t_locate_information.set_uniformed_car_x(0);
+			t_locate_information.set_uniformed_car_y(0);
+			t_locate_information.set_locate_correct(true);
+			dispatch_request_msg.mutable_locate_information()->CopyFrom(t_locate_information);
+
+			message::Parkspace_info *tp_parkspace_info = dispatch_request_msg.mutable_parkspace_info_ex()->Add();
+			tp_parkspace_info->set_parkingspace_index_id(167);
+			tp_parkspace_info->set_parkingspace_type(message::Parkspace_type::MID_PARKINGSPACE);
+			tp_parkspace_info->set_parkingspace_unit_id(3);
+			tp_parkspace_info->set_parkingspace_label_id(11);
+			tp_parkspace_info->set_parkingspace_room_id(5);
+			tp_parkspace_info->set_parkingspace_direction(message::Direction::eBackward);
+			tp_parkspace_info->set_parkingspace_floor_id(3);
+			tp_parkspace_info->set_parkingspace_width(0);
+			tp_parkspace_info->set_parkingspace_height(0);
+			tp_parkspace_info->set_parkingspace_status(message::Parkspace_status::eParkspace_empty);
+			tp_parkspace_info->set_car_type(message::Car_type::MID_CAR);
+			dispatch_request_msg.set_car_type(message::Car_type::MID_CAR);
+
+			Dispatch_manager::get_instance_references().execute_for_dispatch_request_msg(dispatch_request_msg);
+
+		}
+
 		std::this_thread::sleep_for(std::chrono::seconds(1));
 		std::this_thread::sleep_for(std::chrono::seconds(1));
 	}
 	}
 	return 0;
 	return 0;

+ 2 - 1
setting/communication.prototxt

@@ -32,7 +32,8 @@ communication_parameters
 #    connect_string_vector:"tcp://192.168.2.174:30002"
 #    connect_string_vector:"tcp://192.168.2.174:30002"
 
 
     connect_string_vector:"tcp://192.168.1.233:30000"
     connect_string_vector:"tcp://192.168.1.233:30000"
-    connect_string_vector:"tcp://192.168.1.240:30010"
+    connect_string_vector:"tcp://192.168.1.233:30010"
+
 
 
 }
 }
 
 

+ 1 - 1
snap7_communication/snap7_communication_base.cpp

@@ -55,7 +55,7 @@ Error_manager Snap7_communication_base::communication_init_from_protobuf(Snap7_c
 		}
 		}
 	}
 	}
 
 
-#ifdef S7_TEST
+#ifdef PLC_S7_COMMUNICATION
 	//启动通信, run thread
 	//启动通信, run thread
 	communication_run();
 	communication_run();
 #endif
 #endif