Selaa lähdekoodia

20210625, 调度流程 多车存取测试

huli 4 vuotta sitten
vanhempi
commit
11187b160e

+ 55 - 41
dispatch/carrier.cpp

@@ -236,15 +236,24 @@ Error_manager Carrier::update_device_communication()
 		m_last_heartbeat = tp_carrier_status_from_plc_to_dispatch->m_heartbeat;
 		m_status_updata_time = std::chrono::system_clock::now();
 
-//		std::cout << " 111111111111111111111111111 = " << 123 << std::endl;
-//		std::cout << " tp_carrier_request_from_dispatch_to_plc_for_key->m_request_key = " << tp_carrier_request_from_dispatch_to_plc_for_key->m_request_key << std::endl;
-//		std::cout << " tp_carrier_response_from_plc_to_dispatch->m_respons_key = " << tp_carrier_response_from_plc_to_dispatch->m_respons_key << std::endl;
-//		int a = tp_carrier_status_from_plc_to_dispatch->m_work_status;
-//		std::cout << " tp_carrier_status_from_plc_to_dispatch->m_work_status = " << a << std::endl;
-//		std::cout << " m_request_key = " << m_request_key << std::endl;
-//		std::cout << " m_respons_key = " << m_respons_key << std::endl;
-//		std::cout << " m_actual_device_status = " << m_actual_device_status << std::endl;
-//		std::cout << " 111111111111111111111111111 = " << 456 << std::endl;
+//		if ( get_device_id() == 0)
+//		{
+//			std::cout << " 111111111111111111111111111 = " << 123 << std::endl;
+//			std::cout << " tp_carrier_request_from_dispatch_to_plc_for_key->m_request_key = " << tp_carrier_request_from_dispatch_to_plc_for_key->m_request_key << std::endl;
+//			std::cout << " tp_carrier_response_from_plc_to_dispatch->m_respons_key = " << tp_carrier_response_from_plc_to_dispatch->m_respons_key << std::endl;
+//			int b = tp_carrier_status_from_plc_to_dispatch->m_safe_status;
+//			std::cout << " huli test :::: " << " tp_carrier_status_from_plc_to_dispatch->m_safe_status = " << b << std::endl;
+//			int a = tp_carrier_status_from_plc_to_dispatch->m_work_status;
+//			std::cout << " tp_carrier_status_from_plc_to_dispatch->m_work_status = " << a << std::endl;
+//			std::cout << " m_request_key = " << m_request_key << std::endl;
+//			std::cout << " m_respons_key = " << m_respons_key << std::endl;
+//			std::cout << " huli test :::: " << " m_request_x = " << m_request_x << std::endl;
+//			std::cout << " huli test :::: " << " m_respons_x = " << m_respons_x << std::endl;
+//			std::cout << " huli test :::: " << " m_actual_x = " << m_actual_x << std::endl;
+//			std::cout << " m_actual_device_status = " << m_actual_device_status << std::endl;
+//			std::cout << " 111111111111111111111111111 = " << 456 << std::endl;
+//		}
+
 		
 		//重连之后,搬运器状态   E_DISCONNECT  ->>  E_THREE_LEVEL_WORK
 		if ( m_dispatch_device_status == Dispatch_device_base::DISPATCH_DEVICE_DISCONNECT )
@@ -299,38 +308,43 @@ Error_manager Carrier::check_and_read_memory_to_task(std::shared_ptr<Task_Base>
 				Error_manager t_error(CARRIER_RESPONS_ERROR, MINOR_ERROR, "m_respons_status is error");
 				tp_carrier_task->set_task_error_manager(t_error);
 			}
-/*
-			std::cout << " huli test :::: " << "  {{{{{{{{{{{{{{{{{{{{{   33333333333333333333333333333333333333333 }}}}}}}}}}}}}}}}}}}}}}}}}}= " << 333 << std::endl;
-			std::cout << " huli test :::: " << " m_request_key = " << m_request_key << std::endl;
-			std::cout << " huli test :::: " << " m_request_x = " << m_request_x << std::endl;
-			std::cout << " huli test :::: " << " m_request_y = " << m_request_y << std::endl;
-			std::cout << " huli test :::: " << " m_request_z = " << m_request_z << std::endl;
-			std::cout << " huli test :::: " << " m_request_clamp_motion = " << m_request_clamp_motion << std::endl;
-			std::cout << " huli test :::: " << " m_request_wheelbase = " << m_request_wheelbase << std::endl;
-			std::cout << " huli test :::: " << " m_request_y1 = " << m_request_y1 << std::endl;
-			std::cout << " huli test :::: " << " m_request_y2 = " << m_request_y2 << std::endl;
-			std::cout << " m_request_joint_motion_x = " << m_request_joint_motion_x << std::endl;
-
-			std::cout << " huli test :::: " << " m_respons_key = " << m_respons_key << std::endl;
-			std::cout << " huli test :::: " << " m_respons_status = " << m_respons_status << std::endl;
-			std::cout << " huli test :::: " << " m_respons_x = " << m_respons_x << std::endl;
-			std::cout << " huli test :::: " << " m_respons_y = " << m_respons_y << std::endl;
-			std::cout << " huli test :::: " << " m_respons_z = " << m_respons_z << std::endl;
-			std::cout << " huli test :::: " << " m_respons_clamp_motion = " << m_respons_clamp_motion << std::endl;
-			std::cout << " huli test :::: " << " m_respons_wheelbase = " << m_respons_wheelbase << std::endl;
-			std::cout << " huli test :::: " << " m_respons_y1 = " << m_respons_y1 << std::endl;
-			std::cout << " huli test :::: " << " m_respons_y2 = " << m_respons_y2 << std::endl;
-			std::cout << " m_respons_joint_motion_x = " << m_respons_joint_motion_x << std::endl;
-
-			std::cout << " m_actual_device_status = " << m_actual_device_status << std::endl;
-			std::cout << " huli test :::: " << " m_actual_x = " << m_actual_x << std::endl;
-			std::cout << " huli test :::: " << " m_actual_y = " << m_actual_y << std::endl;
-			std::cout << " huli test :::: " << " m_actual_z = " << m_actual_z << std::endl;
-			std::cout << " huli test :::: " << " m_actual_y1 = " << m_actual_y1 << std::endl;
-			std::cout << " huli test :::: " << " m_actual_y2 = " << m_actual_y2 << std::endl;
-			std::cout << " huli test :::: " << " m_actual_clamp_motion1 = " << m_actual_clamp_motion1 << std::endl;
-			std::cout << " huli test :::: " << "  {{{{{{{{{{{{{{{{{{{{{{{{{{{{  44444444444444444444444444444444444444444 }}}}}}}}}}}}}}}}}}}}}}}}= " << 444 << std::endl;
-*/
+
+//			if ( get_device_id() == 0 )
+//			{
+//				std::cout << " huli test :::: " << "  {{{{{{{{{{{{{{{{{{{{{   33333333333333333333333333333333333333333 }}}}}}}}}}}}}}}}}}}}}}}}}}= " << 333 << std::endl;
+//				std::cout << " huli test :::: " << " m_request_key = " << m_request_key << std::endl;
+//				std::cout << " huli test :::: " << " m_request_x = " << m_request_x << std::endl;
+//				std::cout << " huli test :::: " << " m_request_y = " << m_request_y << std::endl;
+//				std::cout << " huli test :::: " << " m_request_z = " << m_request_z << std::endl;
+//				std::cout << " huli test :::: " << " m_request_clamp_motion = " << m_request_clamp_motion << std::endl;
+//				std::cout << " huli test :::: " << " m_request_wheelbase = " << m_request_wheelbase << std::endl;
+//				std::cout << " huli test :::: " << " m_request_y1 = " << m_request_y1 << std::endl;
+//				std::cout << " huli test :::: " << " m_request_y2 = " << m_request_y2 << std::endl;
+//				std::cout << " m_request_joint_motion_x = " << m_request_joint_motion_x << std::endl;
+//
+//				std::cout << " huli test :::: " << " m_respons_key = " << m_respons_key << std::endl;
+//				std::cout << " huli test :::: " << " m_respons_status = " << m_respons_status << std::endl;
+//				std::cout << " huli test :::: " << " m_respons_x = " << m_respons_x << std::endl;
+//				std::cout << " huli test :::: " << " m_respons_y = " << m_respons_y << std::endl;
+//				std::cout << " huli test :::: " << " m_respons_z = " << m_respons_z << std::endl;
+//				std::cout << " huli test :::: " << " m_respons_clamp_motion = " << m_respons_clamp_motion << std::endl;
+//				std::cout << " huli test :::: " << " m_respons_wheelbase = " << m_respons_wheelbase << std::endl;
+//				std::cout << " huli test :::: " << " m_respons_y1 = " << m_respons_y1 << std::endl;
+//				std::cout << " huli test :::: " << " m_respons_y2 = " << m_respons_y2 << std::endl;
+//				std::cout << " m_respons_joint_motion_x = " << m_respons_joint_motion_x << std::endl;
+//
+//				std::cout << " m_actual_device_status = " << m_actual_device_status << std::endl;
+//				std::cout << " huli test :::: " << " m_actual_load_status = " << m_actual_load_status << std::endl;
+//				std::cout << " huli test :::: " << " m_actual_x = " << m_actual_x << std::endl;
+//				std::cout << " huli test :::: " << " m_actual_y = " << m_actual_y << std::endl;
+//				std::cout << " huli test :::: " << " m_actual_z = " << m_actual_z << std::endl;
+//				std::cout << " huli test :::: " << " m_actual_y1 = " << m_actual_y1 << std::endl;
+//				std::cout << " huli test :::: " << " m_actual_y2 = " << m_actual_y2 << std::endl;
+//				std::cout << " huli test :::: " << " m_actual_clamp_motion1 = " << m_actual_clamp_motion1 << std::endl;
+//				std::cout << " huli test :::: " << "  {{{{{{{{{{{{{{{{{{{{{{{{{{{{  44444444444444444444444444444444444444444 }}}}}}}}}}}}}}}}}}}}}}}}= " << 444 << std::endl;
+//
+//			}
+
 			return Error_code::SUCCESS;
 		}
 			//返回没有收到数据

+ 2 - 3
dispatch/catcher.cpp

@@ -128,7 +128,6 @@ Error_manager Catcher::update_device_communication()
 	tp_catcher_request_from_dispatch_to_plc_for_data->m_request_d2 = m_request_d2;
 
 
-
 	//答复消息, plc->调度
 	Dispatch_communication::Catcher_response_from_plc_to_dispatch * tp_catcher_response_from_plc_to_dispatch =
 	& Dispatch_communication::get_instance_references().m_catcher_response_from_plc_to_dispatch[m_device_id];
@@ -370,8 +369,8 @@ Error_manager Catcher::update_actual_coordinates_id()
 		m_actual_coordinates_rows = (m_actual_coordinates_id-1) / Dispatch_coordinates::get_instance_references().m_space_lock_columns;
 		m_actual_coordinates_columns = (m_actual_coordinates_id-1) % Dispatch_coordinates::get_instance_references().m_space_lock_columns;
 		Dispatch_coordinates::get_instance_references().set_space_lock_for_catcher(m_actual_coordinates_id, m_device_id);
-		//保留4楼的空间锁
-		Dispatch_coordinates::get_instance_references().catcher_4st_floor_space_lock(m_actual_coordinates_columns, m_device_id);
+		//保留3 4楼的空间锁
+		Dispatch_coordinates::get_instance_references().catcher_3rd_4st_floor_space_lock(m_actual_coordinates_columns, m_device_id);
 	}
 
 	return Error_code::SUCCESS;

+ 12 - 12
dispatch/dispatch_coordinates.cpp

@@ -413,7 +413,7 @@ Error_manager Dispatch_coordinates::carrier_try_space_lock(int row_min, int colu
 				try_flag = false;
 				break;
 			}
-			else if ( mpp_space_lock[i][j].m_catcher_id != -1 )
+			if ( mpp_space_lock[i][j].m_catcher_id != -1 )
 			{
 				try_flag = false;
 				avoid_catcher_id = mpp_space_lock[i][j].m_catcher_id;
@@ -448,9 +448,8 @@ Error_manager Dispatch_coordinates::catcher_try_space_lock(int row_min, int colu
 	{
 		for (int j = column_min; j <= column_max ; ++j)
 		{
-			if ( mpp_space_lock[i][j].m_catcher_id != -1 &&
-				 mpp_space_lock[i][j].m_catcher_id != catcher_id &&
-				 mpp_space_lock[i][j].m_carrier_id != -1)
+			if ( (mpp_space_lock[i][j].m_catcher_id != -1 && mpp_space_lock[i][j].m_catcher_id != catcher_id)
+				 || mpp_space_lock[i][j].m_carrier_id != -1)
 			{
 				try_flag = false;
 				break;
@@ -472,7 +471,7 @@ Error_manager Dispatch_coordinates::catcher_try_space_lock(int row_min, int colu
 	else
 	{
 		return Error_manager(Error_code::DISPATCH_COORDINATES_CAN_NOT_LOCK, Error_level::MINOR_ERROR,
-							 " Dispatch_coordinates::carrier_try_space_lock error ");
+							 " Dispatch_coordinates::catcher_try_space_lock error ");
 	}
 }
 //搬运器强制空间加锁(不做判断了, 直接加锁)
@@ -537,14 +536,14 @@ Error_manager Dispatch_coordinates::catcher_space_unlock(int catcher_coordinates
 	if ( catcher_coordinates_id >= 34 && catcher_coordinates_id <= 42 )
 	{
 		int t_coordinates_columns = catcher_coordinates_id -30-1;
-		catcher_4st_floor_space_lock(t_coordinates_columns, catcher_id);
+		catcher_3rd_4st_floor_space_lock(t_coordinates_columns, catcher_id);
 	}
 	else if ( catcher_coordinates_id >= 1401 && catcher_coordinates_id <= 1406 )
 	{
 		int t_coordinates_columns = catcher_coordinates_id - 1400;
 		int temp = (t_coordinates_columns-1)%2;
 		t_coordinates_columns = 4 + ((t_coordinates_columns-1)/2)*3 + temp*2 -1;
-		catcher_4st_floor_space_lock(t_coordinates_columns, catcher_id);
+		catcher_3rd_4st_floor_space_lock(t_coordinates_columns, catcher_id);
 	}
 	else
 	{
@@ -553,15 +552,16 @@ Error_manager Dispatch_coordinates::catcher_space_unlock(int catcher_coordinates
 	}
 	return Error_code::SUCCESS;
 }
-//抓取器 加锁4楼的5个车位
-Error_manager Dispatch_coordinates::catcher_4st_floor_space_lock(int catcher_4st_floor_coordinates_columns, int catcher_id)
+//抓取器 加锁3楼和4楼的2*3个车位
+Error_manager Dispatch_coordinates::catcher_3rd_4st_floor_space_lock(int catcher_4st_floor_coordinates_columns, int catcher_id)
 {
-	//周围5个车位 加锁
-	mpp_space_lock[2][catcher_4st_floor_coordinates_columns-2].m_catcher_id = catcher_id;
+	//周围2*3个车位 加锁
+	mpp_space_lock[1][catcher_4st_floor_coordinates_columns-1].m_catcher_id = catcher_id;
+	mpp_space_lock[1][catcher_4st_floor_coordinates_columns].m_catcher_id = catcher_id;
+	mpp_space_lock[1][catcher_4st_floor_coordinates_columns+1].m_catcher_id = catcher_id;
 	mpp_space_lock[2][catcher_4st_floor_coordinates_columns-1].m_catcher_id = catcher_id;
 	mpp_space_lock[2][catcher_4st_floor_coordinates_columns].m_catcher_id = catcher_id;
 	mpp_space_lock[2][catcher_4st_floor_coordinates_columns+1].m_catcher_id = catcher_id;
-	mpp_space_lock[2][catcher_4st_floor_coordinates_columns+2].m_catcher_id = catcher_id;
 	return Error_code::SUCCESS;
 }
 

+ 2 - 2
dispatch/dispatch_coordinates.h

@@ -94,8 +94,8 @@ public://API functions
 	Error_manager carrier_space_unlock(int carrier_id);
 	//抓取器解锁, 上升到最上层, 全部解锁, 保留4楼的空间锁
 	Error_manager catcher_space_unlock(int catcher_coordinates_id, int catcher_id);
-	//抓取器 加锁4楼的5个车位
-	Error_manager catcher_4st_floor_space_lock(int catcher_4st_floor_coordinates_columns, int catcher_id);
+	//抓取器 加锁3楼和4楼的2*3个车位
+	Error_manager catcher_3rd_4st_floor_space_lock(int catcher_4st_floor_coordinates_columns, int catcher_id);
 public://get or set member variable
 
 	void set_space_lock(int space_rows, int space_columns, int catcher_id, int carrier_id);

+ 25 - 4
dispatch/dispatch_device_base.cpp

@@ -738,6 +738,27 @@ void Dispatch_device_base::set_break_flag(bool break_flag)
 	m_break_flag = break_flag;
 }
 
+std::string Dispatch_device_base::get_current_command_key()
+{
+	if ( m_dispatch_device_status == DISPATCH_DEVICE_THREE_LEVEL_WORK ||
+		 m_dispatch_device_status == DISPATCH_DEVICE_THREE_LEVEL_OVER)
+	{
+		return m_device_three_level_command_key;
+	}
+	if ( m_dispatch_device_status == DISPATCH_DEVICE_TWO_LEVEL_WORK ||
+		 m_dispatch_device_status == DISPATCH_DEVICE_TWO_LEVEL_OVER)
+	{
+		return m_device_two_level_command_key;
+	}
+	if ( m_dispatch_device_status == DISPATCH_DEVICE_ONE_LEVEL_WORK ||
+		 m_dispatch_device_status == DISPATCH_DEVICE_ONE_LEVEL_OVER)
+	{
+		return m_device_one_level_command_key;
+	}
+	std::string st;
+	return st;
+}
+
 
 //执行外界任务的执行函数
 void Dispatch_device_base::execute_thread_fun()
@@ -752,7 +773,7 @@ void Dispatch_device_base::execute_thread_fun()
 		{
 			std::this_thread::sleep_for(std::chrono::microseconds(1));
 			std::this_thread::sleep_for(std::chrono::milliseconds(1));
-//			std::this_thread::sleep_for(std::chrono::seconds(1));
+
 
 			std::this_thread::yield();
 			std::unique_lock<std::mutex> t_lock(m_lock);
@@ -989,7 +1010,7 @@ void Dispatch_device_base::execute_thread_fun()
 					if ( mp_device_one_level_task.get() != NULL )
 					{
 						//添加错误码
-						Error_manager t_error(DISPATCH_DEVICE_STATUS_ERROR, MINOR_ERROR, "m_respons_status is error");
+						Error_manager t_error(DISPATCH_DEVICE_STATUS_ERROR, MINOR_ERROR, "m_respons_status is error 123");
 						mp_device_one_level_task->set_task_error_manager(t_error);
 						end_task(mp_device_one_level_task);
 						mp_device_one_level_task.reset();
@@ -997,7 +1018,7 @@ void Dispatch_device_base::execute_thread_fun()
 					if ( mp_device_two_level_task.get() != NULL )
 					{
 						//添加错误码
-						Error_manager t_error(DISPATCH_DEVICE_STATUS_ERROR, MINOR_ERROR, "m_respons_status is error");
+						Error_manager t_error(DISPATCH_DEVICE_STATUS_ERROR, MINOR_ERROR, "m_respons_status is error 456");
 						mp_device_two_level_task->set_task_error_manager(t_error);
 						end_task(mp_device_two_level_task);
 						mp_device_two_level_task.reset();
@@ -1005,7 +1026,7 @@ void Dispatch_device_base::execute_thread_fun()
 					if ( mp_device_three_level_task.get() != NULL )
 					{
 						//添加错误码
-						Error_manager t_error(DISPATCH_DEVICE_STATUS_ERROR, MINOR_ERROR, "m_respons_status is error");
+						Error_manager t_error(DISPATCH_DEVICE_STATUS_ERROR, MINOR_ERROR, "m_respons_status is error 789");
 						mp_device_three_level_task->set_task_error_manager(t_error);
 						end_task(mp_device_three_level_task);
 						mp_device_three_level_task.reset();

+ 3 - 2
dispatch/dispatch_device_base.h

@@ -56,9 +56,9 @@ public:
 
 		DISPATCH_DEVICE_ONE_LEVEL_OVER		= 3, 	//一级工作完成,
 		DISPATCH_DEVICE_ONE_LEVEL_WORK		= 4,	//一级工作状态, 就是普通的移动任务
-		DISPATCH_DEVICE_TWO_LEVEL_OVER		= 5, 	//级工作完成,
+		DISPATCH_DEVICE_TWO_LEVEL_OVER		= 5, 	//级工作完成,
 		DISPATCH_DEVICE_TWO_LEVEL_WORK		= 6,	//二级工作状态, 就是紧急避让, 插队任务(会在执行一级任务的过程中, 插队并优先执行二级任务)
-		DISPATCH_DEVICE_THREE_LEVEL_OVER		= 7, 	//级工作完成,
+		DISPATCH_DEVICE_THREE_LEVEL_OVER		= 7, 	//级工作完成,
 		DISPATCH_DEVICE_THREE_LEVEL_WORK		= 8,	//三级工作任务, 就是锁定硬件资源, 不让插队, (除非急停或者取消任务)
 
 		DISPATCH_DEVICE_FAULT					= 100,	//故障
@@ -226,6 +226,7 @@ public://get or set member variable
 	bool get_break_flag();
 	void set_break_flag(bool break_flag);
 
+	std::string get_current_command_key();
 protected://member functions
 
 

+ 63 - 62
dispatch/dispatch_manager.cpp

@@ -732,7 +732,7 @@ void Dispatch_manager::resource_allocation()
 									break;
 								}
 							}
-							else if ( t_carrier_left_is_ready &&
+							if ( t_carrier_left_is_ready &&
 									  (t_parkspace_path == Dispatch_coordinates::Parkspace_path::LEFT_PATH || t_parkspace_path == Dispatch_coordinates::Parkspace_path::DOUBLE_PATH) )
 							{
 								m_carrier_map[0]->appoint_task((*iter)->m_command_key, (*iter)->m_dispatch_process_type, Dispatch_device_base::Dispatch_task_level::DISPATCH_TASK_ONE_LEVEL);
@@ -740,7 +740,7 @@ void Dispatch_manager::resource_allocation()
 								t_allocation_flag = true;
 								break;
 							}
-							else if ( t_carrier_right_is_ready &&
+							if ( t_carrier_right_is_ready &&
 									  (t_parkspace_path == Dispatch_coordinates::Parkspace_path::RIGHT_PATH || t_parkspace_path == Dispatch_coordinates::Parkspace_path::DOUBLE_PATH) )
 							{
 								m_carrier_map[1]->appoint_task((*iter)->m_command_key, (*iter)->m_dispatch_process_type, Dispatch_device_base::Dispatch_task_level::DISPATCH_TASK_ONE_LEVEL);
@@ -748,18 +748,13 @@ void Dispatch_manager::resource_allocation()
 								t_allocation_flag = true;
 								break;
 							}
-							else if ( t_carrier_3rd_is_ready && t_parkspace_path == Dispatch_coordinates::Parkspace_path::THIRD_FLOOR_PATH)
+							if ( t_carrier_3rd_is_ready && t_parkspace_path == Dispatch_coordinates::Parkspace_path::THIRD_FLOOR_PATH)
 							{
 								m_carrier_map[2]->appoint_task((*iter)->m_command_key, (*iter)->m_dispatch_process_type, Dispatch_device_base::Dispatch_task_level::DISPATCH_TASK_ONE_LEVEL);
 								(*iter)->set_main_carrier(m_carrier_map[2]);
 								t_allocation_flag = true;
 								break;
 							}
-							else
-							{
-								//流程和搬运器没有匹配上, 就直接找下一个流程
-								continue;
-							}
 						}
 					}
 				}
@@ -778,6 +773,16 @@ void Dispatch_manager::resource_allocation()
 							bool is_2nd_path = (*iter)->is_able_store_temporary_cache_path_2nd_floor();
 							bool is_3rd_path = (*iter)->is_able_store_temporary_cache_path_3rd_floor();
 
+//							std::cout << " huli test :::: " << " 1111111111111111 = " << 123 << std::endl;
+//							std::cout << " huli test :::: " << " is_left_path = " << is_left_path << std::endl;
+//							std::cout << " huli test :::: " << " is_right_path = " << is_right_path << std::endl;
+//							std::cout << " huli test :::: " << " is_temporary_path = " << is_temporary_path << std::endl;
+//							std::cout << " huli test :::: " << " is_2nd_path = " << is_2nd_path << std::endl;
+//							std::cout << " huli test :::: " << " is_3rd_path = " << is_3rd_path << std::endl;
+//							std::cout << " huli test :::: " << " 2222222222222222 = " << 567 << std::endl;
+
+
+
 							//如果只能存到缓存位, 那么也要执行, 修改标志位
 							if ( (!is_left_path) && (!is_right_path) && is_temporary_path)
 							{
@@ -817,7 +822,7 @@ void Dispatch_manager::resource_allocation()
 									}
 								}
 							}
-							else if ( t_carrier_left_is_ready )
+							if ( t_carrier_left_is_ready )
 							{
 								if ( is_left_path ||
 									 ( (!is_left_path) && (!is_right_path) && is_2nd_path) )//如果只能存到2楼, 那么也要执行
@@ -828,7 +833,7 @@ void Dispatch_manager::resource_allocation()
 									break;
 								}
 							}
-							else if ( t_carrier_right_is_ready )
+							if ( t_carrier_right_is_ready )
 							{
 								if ( is_right_path ||
 									 ( (!is_left_path) && (!is_right_path) && is_2nd_path) )//如果只能存到2楼, 那么也要执行
@@ -839,7 +844,7 @@ void Dispatch_manager::resource_allocation()
 									break;
 								}
 							}
-							else if ( t_carrier_3rd_is_ready)
+							if ( t_carrier_3rd_is_ready)
 							{
 								if ( (!is_left_path) && (!is_right_path) && is_3rd_path)
 								{
@@ -849,10 +854,6 @@ void Dispatch_manager::resource_allocation()
 									break;
 								}
 							}
-							else
-							{
-								continue;
-							}
 						}
 					}
 				}
@@ -913,7 +914,7 @@ void Dispatch_manager::resource_allocation()
 								}
 
 							}
-							else if ( t_carrier_left_is_pickup &&
+							if ( t_carrier_left_is_pickup &&
 									  (t_parkspace_path == Dispatch_coordinates::Parkspace_path::LEFT_PATH || t_parkspace_path == Dispatch_coordinates::Parkspace_path::DOUBLE_PATH) )
 							{
 								m_carrier_map[0]->appoint_task((*iter)->m_command_key, (*iter)->m_dispatch_process_type, Dispatch_device_base::Dispatch_task_level::DISPATCH_TASK_ONE_LEVEL);
@@ -921,7 +922,7 @@ void Dispatch_manager::resource_allocation()
 								t_allocation_flag = true;
 								break;
 							}
-							else if ( t_carrier_right_is_pickup &&
+							if ( t_carrier_right_is_pickup &&
 									  (t_parkspace_path == Dispatch_coordinates::Parkspace_path::RIGHT_PATH || t_parkspace_path == Dispatch_coordinates::Parkspace_path::DOUBLE_PATH) )
 							{
 								m_carrier_map[1]->appoint_task((*iter)->m_command_key, (*iter)->m_dispatch_process_type, Dispatch_device_base::Dispatch_task_level::DISPATCH_TASK_ONE_LEVEL);
@@ -929,18 +930,13 @@ void Dispatch_manager::resource_allocation()
 								t_allocation_flag = true;
 								break;
 							}
-							else if ( t_carrier_3rd_is_pickup && t_parkspace_path == Dispatch_coordinates::Parkspace_path::THIRD_FLOOR_PATH)
+							if ( t_carrier_3rd_is_pickup && t_parkspace_path == Dispatch_coordinates::Parkspace_path::THIRD_FLOOR_PATH)
 							{
 								m_carrier_map[2]->appoint_task((*iter)->m_command_key, (*iter)->m_dispatch_process_type, Dispatch_device_base::Dispatch_task_level::DISPATCH_TASK_ONE_LEVEL);
 								(*iter)->set_main_carrier(m_carrier_map[2]);
 								t_allocation_flag = true;
 								break;
 							}
-							else
-							{
-								//流程和搬运器没有匹配上, 就直接找下一个流程
-								continue;
-							}
 						}
 					}
 				}
@@ -951,6 +947,16 @@ void Dispatch_manager::resource_allocation()
 			{
 				if ( !t_allocation_flag )
 				{
+					//没有分配的
+					int t_need_allocation_size = 0;
+					for (auto iter = m_process_store_list.begin(); iter != m_process_store_list.end(); ++iter)
+					{
+						if ( !(*iter)->is_ready() )
+						{
+							t_need_allocation_size++;
+						}
+					}
+
 					//然后做存车
 					for (auto iter = m_process_store_list.begin(); iter != m_process_store_list.end(); ++iter)
 					{
@@ -966,7 +972,7 @@ void Dispatch_manager::resource_allocation()
 
 							//如果只能存到缓存位, 或者存车流程数量超限, 修改标志位
 							if ( ( (!is_left_path) && (!is_right_path) && is_temporary_path) ||
-								 (m_process_store_list.size() >= DISPATCH_MANAHER_STORE_LIST_SIZE_LIMIT && is_temporary_path) )
+								 (t_need_allocation_size >= DISPATCH_MANAHER_STORE_LIST_SIZE_LIMIT && is_temporary_path) )
 							{
 								(*iter)->m_temporary_cache_flag = true;
 							}
@@ -977,38 +983,39 @@ void Dispatch_manager::resource_allocation()
 							//分配合理的版搬运器
 							if ( t_carrier_left_is_store && t_carrier_right_is_store)
 							{
-								if ( (is_left_path && is_right_path) ||
-									 ( (!is_left_path) && (!is_right_path) && is_2nd_path) || //如果只能存到2楼, 那么也要执行
-									 (m_process_store_list.size() >= DISPATCH_MANAHER_STORE_LIST_SIZE_LIMIT && is_2nd_path) )	//存车流程数量超限
+								if ( (   (*iter)->m_temporary_cache_flag && is_2nd_path) ||
+									 ( (!(*iter)->m_temporary_cache_flag) && is_left_path && is_right_path) )
 								{
-									//选最近的搬运器
-									if ( Dispatch_coordinates::get_instance_references().choice_nearest_carrier(
-									(*iter)->m_dispatch_source, tp_carrier_left->m_actual_coordinates_id,
-									tp_carrier_right->m_actual_coordinates_id) )
+									if ( is_2nd_path )
 									{
-										m_carrier_map[0]->appoint_task((*iter)->m_command_key,
-																	   (*iter)->m_dispatch_process_type,
-																	   Dispatch_device_base::Dispatch_task_level::DISPATCH_TASK_ONE_LEVEL);
-										(*iter)->set_main_carrier(m_carrier_map[0]);
-										t_allocation_flag = true;
-										break;
-									}
-									else
-									{
-										m_carrier_map[1]->appoint_task((*iter)->m_command_key,
-																	   (*iter)->m_dispatch_process_type,
-																	   Dispatch_device_base::Dispatch_task_level::DISPATCH_TASK_ONE_LEVEL);
-										(*iter)->set_main_carrier(m_carrier_map[1]);
-										t_allocation_flag = true;
-										break;
-									}
+										//选最近的搬运器
+										if ( Dispatch_coordinates::get_instance_references().choice_nearest_carrier(
+										(*iter)->m_dispatch_source, tp_carrier_left->m_actual_coordinates_id,
+										tp_carrier_right->m_actual_coordinates_id) )
+										{
+											m_carrier_map[0]->appoint_task((*iter)->m_command_key,
+																		   (*iter)->m_dispatch_process_type,
+																		   Dispatch_device_base::Dispatch_task_level::DISPATCH_TASK_ONE_LEVEL);
+											(*iter)->set_main_carrier(m_carrier_map[0]);
+											t_allocation_flag = true;
+											break;
+										}
+										else
+										{
+											m_carrier_map[1]->appoint_task((*iter)->m_command_key,
+																		   (*iter)->m_dispatch_process_type,
+																		   Dispatch_device_base::Dispatch_task_level::DISPATCH_TASK_ONE_LEVEL);
+											(*iter)->set_main_carrier(m_carrier_map[1]);
+											t_allocation_flag = true;
+											break;
+										}
+								    }
 								}
 							}
-							else if ( t_carrier_left_is_store )
+							if ( t_carrier_left_is_store )
 							{
-								if ( is_left_path ||
-									 ( (!is_left_path) && (!is_right_path) && is_2nd_path) || //如果只能存到2楼, 那么也要执行
-									 (m_process_store_list.size() >= DISPATCH_MANAHER_STORE_LIST_SIZE_LIMIT && is_2nd_path) )	//存车流程数量超限
+								if ( (   (*iter)->m_temporary_cache_flag && is_2nd_path) ||
+									 ( (!(*iter)->m_temporary_cache_flag) && is_left_path ) )
 								{
 									m_carrier_map[0]->appoint_task((*iter)->m_command_key, (*iter)->m_dispatch_process_type, Dispatch_device_base::Dispatch_task_level::DISPATCH_TASK_ONE_LEVEL);
 									(*iter)->set_main_carrier(m_carrier_map[0]);
@@ -1016,11 +1023,10 @@ void Dispatch_manager::resource_allocation()
 									break;
 								}
 							}
-							else if ( t_carrier_right_is_store )
+							if ( t_carrier_right_is_store )
 							{
-								if ( is_right_path ||
-									 ( (!is_left_path) && (!is_right_path) && is_2nd_path) || //如果只能存到2楼, 那么也要执行
-									 (m_process_store_list.size() >= DISPATCH_MANAHER_STORE_LIST_SIZE_LIMIT && is_2nd_path) )	//存车流程数量超限
+								if ( (   (*iter)->m_temporary_cache_flag && is_2nd_path) ||
+									 ( (!(*iter)->m_temporary_cache_flag) && is_right_path) )
 								{
 									m_carrier_map[1]->appoint_task((*iter)->m_command_key, (*iter)->m_dispatch_process_type, Dispatch_device_base::Dispatch_task_level::DISPATCH_TASK_ONE_LEVEL);
 									(*iter)->set_main_carrier(m_carrier_map[1]);
@@ -1028,10 +1034,9 @@ void Dispatch_manager::resource_allocation()
 									break;
 								}
 							}
-							else if ( t_carrier_3rd_is_store)
+							if ( t_carrier_3rd_is_store)
 							{
-								if ( ( (!is_left_path) && (!is_right_path) && is_3rd_path) || //如果只能存到3楼, 那么也要执行
-								(m_process_store_list.size() >= DISPATCH_MANAHER_STORE_LIST_SIZE_LIMIT && is_3rd_path) )	//存车流程数量超限
+								if ( (*iter)->m_temporary_cache_flag && is_3rd_path )
 								{
 									m_carrier_map[2]->appoint_task((*iter)->m_command_key, (*iter)->m_dispatch_process_type, Dispatch_device_base::Dispatch_task_level::DISPATCH_TASK_ONE_LEVEL);
 									(*iter)->set_main_carrier(m_carrier_map[2]);
@@ -1039,10 +1044,6 @@ void Dispatch_manager::resource_allocation()
 									break;
 								}
 							}
-							else
-							{
-								continue;
-							}
 						}
 					}
 				}

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 807 - 360
dispatch/dispatch_process.cpp


+ 7 - 1
dispatch/dispatch_process.h

@@ -231,7 +231,7 @@ public:
 		DISPATCH_CATCHER_PICKUP_37				= 337,
 		DISPATCH_CATCHER_PICKUP_38				= 338,
 		DISPATCH_CATCHER_PICKUP_39				= 339,
-
+		DISPATCH_CATCHER_PICKUP_40				= 340,
 		DISPATCH_CATCHER_PICKUP_END				= 399,
 
 
@@ -340,6 +340,7 @@ public:
 		DISPATCH_CATCHER_STORE_37				= 537,
 		DISPATCH_CATCHER_STORE_38				= 538,
 		DISPATCH_CATCHER_STORE_39				= 539,
+		DISPATCH_CATCHER_STORE_40				= 540,
 		DISPATCH_CATCHER_STORE_END				= 599,
 
 		DISPATCH_CONTROL_DISCONNECT_DEVICE		= 7, 	//流程 解除设备
@@ -399,6 +400,9 @@ public:
 		//给机器人发送避让指令, 2号机器人(可选)
 		std::shared_ptr<Dispatch_device_base>		mp_avoid_catcher;						//调度设备指针, 内存由Dispatch_manager来管理
 		std::shared_ptr<Task_Base>					mp_avoid_catcher_task;					//调度任务指针, 内存由本模块管理
+		//给3楼搬运器发送避让指令,
+		std::shared_ptr<Dispatch_device_base>		mp_avoid_carrier;					//调度设备指针, 内存由Dispatch_manager来管理
+		std::shared_ptr<Task_Base>					mp_avoid_carrier_task;				//调度任务指针, 内存由本模块管理
 
 		Error_manager								m_error;							//错误码
 	};
@@ -644,6 +648,8 @@ public://member variable
 
 //	std::chrono::system_clock::time_point  m_time_to_send_control_response;		//发送 控制的任务答复 的时间
 
+	Dispatch_control_status						mcarrier;
+	Dispatch_control_status						mcatcher;
 private:
 
 };

+ 5 - 3
error_code/error_code.h

@@ -1,13 +1,15 @@
 
+#define MAIN_TEST 1
+//#define PROCESS_TEST 1
+#define TIME_TEST 1
+
 //Error_code是错误码的底层通用模块,
 //功能:用作故障分析和处理。
 
 //用法:所有的功能接口函数return错误管理类,
 //然后上层判断分析错误码,并进行故障处理。
 
-#define MAIN_TEST 1
-//#define PROCESS_TEST 1
-#define TIME_TEST 1
+
 
 #ifndef TEST_ERROR_ERROR_CODE_H
 #define TEST_ERROR_ERROR_CODE_H

+ 4 - 20
main.cpp

@@ -102,24 +102,6 @@ int main(int argc,char* argv[])
 	System_communication::get_instance_references().communication_init();
 	System_communication::get_instance_references().set_encapsulate_cycle_time(1000);
 
-	std::this_thread::sleep_for(std::chrono::seconds(1));
-	Dispatch_coordinates::get_instance_references().cout_space_lock();
-
-	Dispatch_coordinates * tp_dispatch_coordinates = Dispatch_coordinates::get_instance_pointer();
-	int t_avoid_catcher_id=-1;
-	t_error = Dispatch_coordinates::get_instance_references().carrier_try_space_lock(0, 7-1,
-																					  0, tp_dispatch_coordinates->m_space_lock_columns-1,
-																					  1, t_avoid_catcher_id);
-	t_error = Dispatch_coordinates::get_instance_references().carrier_try_space_lock(3, 0,
-																					 3, 7-1,
-																					 0, t_avoid_catcher_id);
-
-	Dispatch_coordinates::get_instance_references().cout_space_lock();
-	tp_dispatch_coordinates->carrier_space_unlock(0);
-	Dispatch_coordinates::get_instance_references().cout_space_lock();
-	tp_dispatch_coordinates->carrier_space_unlock(1);
-	Dispatch_coordinates::get_instance_references().cout_space_lock();
-
 
 	while (1)
 	{
@@ -167,7 +149,7 @@ int main(int argc,char* argv[])
 	Catcher_task * tp_catcher_task1 = (Catcher_task *)tp_task_Base1.get();
 	tp_catcher_task1->task_init(NULL,std::chrono::milliseconds(15000));
 	tp_catcher_task1->m_request_key = "x23456789012345678901234567890r1";
-	tp_catcher_task1->m_request_x = 7755;
+	tp_catcher_task1->m_request_x = 17955;
 	tp_catcher_task1->m_request_y = 3000;
 	tp_catcher_task1->m_request_b = 90;
 	tp_catcher_task1->m_request_z = 5410;
@@ -191,9 +173,11 @@ int main(int argc,char* argv[])
 	tp_carrier_task20->task_init(NULL,std::chrono::milliseconds(15000));
 	tp_carrier_task20->m_request_key = "x23456789012345678901234567890c0";
 	tp_carrier_task20->m_request_x = 1;
+//	tp_carrier_task20->m_request_x = 25400;
 //	tp_carrier_task20->m_request_x = 32600;
 	tp_carrier_task20->m_request_y = 3000;
 	tp_carrier_task20->m_request_z = 2525;
+	tp_carrier_task20->m_request_z = 10325;
 	tp_carrier_task20->m_request_y1 = 4500;
 	tp_carrier_task20->m_request_y2 = 1700;
 	tp_carrier_task20->m_request_clamp_motion = Carrier_task::E_CLAMP_LOOSE;
@@ -247,7 +231,7 @@ int main(int argc,char* argv[])
 	Carrier_task * tp_carrier_task22 = (Carrier_task *)tp_task_Base22.get();
 	tp_carrier_task22->task_init(NULL,std::chrono::milliseconds(15000));
 	tp_carrier_task22->m_request_key = "x23456789012345678901234567890c2";
-	tp_carrier_task22->m_request_x = 7755;
+	tp_carrier_task22->m_request_x = 17955;
 //	tp_carrier_task22->m_request_x = 4700;
 	tp_carrier_task22->m_request_y = 3000;
 	tp_carrier_task22->m_request_z = 5125;