huli 4 gadi atpakaļ
vecāks
revīzija
ad6c7bc675

+ 814 - 3
dispatch/carrier_base.cpp

@@ -3,10 +3,37 @@
 //
 
 #include "carrier_base.h"
+#include "dispatch_communication.h"
 
 Carrier_base::Carrier_base()
 {
-	m_carrier_status = E_CARRIER_UNKNOW;
+	m_carrier_status = E_UNKNOW;
+	m_carrier_id = 0;
+
+	m_parkspace_unit_id = 0;		//车位单元号(楚天项目为1~3)
+	m_parkspace_floor_id = 0;		//车位楼层号(楚天项目为1~14)
+	m_parkspace_room_id = 0;		//车位同层的房间号	(楚天项目一楼为1~4, 楼上为1~6)
+//	m_command_key = 0;				//任务唯一码
+	m_motion_direction = 0;			//调度方向, 根据停车取车选择出入口, 	1=入口,0=非入口
+	m_car_center_x = 0;				//汽车的中心坐标x
+	m_car_center_y = 0;				//汽车的中心坐标y
+	m_car_angle = 0;				//汽车的旋转角(角度-90~90)
+
+	m_carrier_coordinate_x = 0;				//搬运器坐标x轴, 中跑车控制横向移动
+	m_carrier_coordinate_y = 0;				//搬运器坐标y轴, (本模块默认为0, 由AGV模块去控制纵向移动)
+	m_carrier_coordinate_z = 0;				//搬运器坐标z轴, 电梯控制上下移动
+	m_respons_status = RESPONS_NORMAL;			//指令完成状态, 搬运器答复指令, 返回任务完成的情况
+
+	//硬件状态, 目前只做显示判断
+	m_carrier_device_status = E_UNKNOW;	//搬运器设备的状态, 楚天项目就是中跑车
+	memset(m_carrier_error_code, 0, 50);	//搬运器设备的报警信息位
+//	m_carrier_error_description = 0;//搬运器设备的报警状态描述
+	m_elevator_device_status = E_UNKNOW;	//升降机设备状态, 楚天项目就是电梯
+	memset(m_elevator_error_code, 0, 50);	//升降机设备的报警信息位
+//	m_elevator_error_description = 0;//升降机设备的报警状态描述
+
+	mp_execute_thread = NULL;
+
 }
 
 Carrier_base::~Carrier_base()
@@ -18,15 +45,372 @@ Carrier_base::~Carrier_base()
 //搬运器 初始化
 Error_manager Carrier_base::carrier_base_init()
 {
-	m_carrier_status = E_CARRIER_READY;
+//	线程默认开启
+	m_execute_condition.reset(false, true, false);
+	mp_execute_thread = new std::thread(&Carrier_base::execute_thread_fun, this);
+
+	m_carrier_status = E_READY;
+	return Error_code::SUCCESS;
 }
 //搬运器 反初始化
 Error_manager Carrier_base::carrier_base_uninit()
 {
-	m_carrier_status = E_CARRIER_UNKNOW;
+	if (mp_execute_thread)
+	{
+		m_execute_condition.kill_all();
+	}
+	if (mp_execute_thread)
+	{
+		mp_execute_thread->join();
+		delete mp_execute_thread;
+		mp_execute_thread = NULL;
+	}
+
+	m_carrier_status = E_UNKNOW;
+
+	return Error_code::SUCCESS;
+}
+
+
+
+
+//处理一级任务, 普通任务
+Error_manager Carrier_base::execute_one_level_task(std::shared_ptr<Carrier_task> p_carrier_task)
+{
+	Error_manager t_error;
+	Error_manager t_result;
+
+	//检查指针
+	if (p_carrier_task == NULL) {
+		return Error_manager(Error_code::POINTER_IS_NULL, Error_level::MINOR_ERROR,
+							 "Carrier_base::execute_one_level_task failed, POINTER_IS_NULL");
+	}
+	//检查任务类型,
+	if (p_carrier_task->get_task_type() != CARRIER_TASK)
+	{
+		return Error_manager(Error_code::CARRIER_TASK_TYPE_ERROR, Error_level::MINOR_ERROR,
+							 "Carrier_base::execute_one_level_task  get_task_type() != CARRIER_TASK ");
+	}
+
+	//检查接收方的状态
+	t_error = check_one_level_task();
+	if ( t_error != SUCCESS )
+	{
+		t_result.compare_and_cover_error(t_error);
+	}
+	else
+	{
+		//接受任务,并将任务的状态改为TASK_SIGNED已签收
+		mp_carrier_one_level_task = p_carrier_task;
+		mp_carrier_one_level_task->set_task_statu(TASK_SIGNED);
+
+		//这里不用检查任务内容, 直接下发给底层设备
+		//启动定位管理模块,的核心工作线程
+		m_carrier_status = E_ONE_LEVEL_WORK;
+		m_execute_condition.notify_all(true);
+		//通知 thread_work 子线程启动。
+
+		//将任务的状态改为 TASK_WORKING 处理中
+		mp_carrier_one_level_task->set_task_statu(TASK_WORKING);
+	}
+
+	if ( t_result != Error_code::SUCCESS )
+	{
+		return t_result;
+	}
+
+	return Error_code::SUCCESS;
+}
+//处理二级任务, 插队任务
+Error_manager Carrier_base::execute_two_level_task(std::shared_ptr<Carrier_task> p_carrier_task)
+{
+	Error_manager t_error;
+	Error_manager t_result;
+
+	//检查指针
+	if (p_carrier_task == NULL) {
+		return Error_manager(Error_code::POINTER_IS_NULL, Error_level::MINOR_ERROR,
+							 "Carrier_base::execute_two_level_task failed, POINTER_IS_NULL");
+	}
+	//检查任务类型,
+	if (p_carrier_task->get_task_type() != CARRIER_TASK)
+	{
+		return Error_manager(Error_code::CARRIER_TASK_TYPE_ERROR, Error_level::MINOR_ERROR,
+							 "Carrier_base::execute_two_level_task  get_task_type() != CARRIER_TASK ");
+	}
+
+
+	//检查接收方的状态
+	t_error = check_two_level_task();
+	if ( t_error != SUCCESS )
+	{
+		t_result.compare_and_cover_error(t_error);
+	}
+	else
+	{
+		//接受任务,并将任务的状态改为TASK_SIGNED已签收
+		mp_carrier_two_level_task = p_carrier_task;
+		mp_carrier_two_level_task->set_task_statu(TASK_SIGNED);
+
+		//这里不用检查任务内容, 直接下发给底层设备
+		//启动定位管理模块,的核心工作线程
+		m_carrier_status = E_TWO_LEVEL_WORK;
+		m_execute_condition.notify_all(true);
+		//通知 thread_work 子线程启动。
+
+		//将任务的状态改为 TASK_WORKING 处理中
+		mp_carrier_two_level_task->set_task_statu(TASK_WORKING);
+	}
+
+	if ( t_result != Error_code::SUCCESS )
+	{
+		return t_result;
+	}
+
+	return Error_code::SUCCESS;
+}
+//处理三级任务, 核心任务
+Error_manager Carrier_base::execute_three_level_task(std::shared_ptr<Carrier_task> p_carrier_task)
+{
+	Error_manager t_error;
+	Error_manager t_result;
+
+	//检查指针
+	if (p_carrier_task == NULL) {
+		return Error_manager(Error_code::POINTER_IS_NULL, Error_level::MINOR_ERROR,
+							 "Carrier_base::execute_three_level_task failed, POINTER_IS_NULL");
+	}
+	//检查任务类型,
+	if (p_carrier_task->get_task_type() != CARRIER_TASK)
+	{
+		return Error_manager(Error_code::CARRIER_TASK_TYPE_ERROR, Error_level::MINOR_ERROR,
+							 "Carrier_base::execute_three_level_task  get_task_type() != CARRIER_TASK ");
+	}
+
+
+	//检查接收方的状态
+	t_error = check_three_level_task();
+	if ( t_error != SUCCESS )
+	{
+		t_result.compare_and_cover_error(t_error);
+	}
+	else
+	{
+		//接受任务,并将任务的状态改为TASK_SIGNED已签收
+		mp_carrier_three_level_task = p_carrier_task;
+		mp_carrier_three_level_task->set_task_statu(TASK_SIGNED);
+
+		//这里不用检查任务内容, 直接下发给底层设备
+		//启动定位管理模块,的核心工作线程
+		m_carrier_status = E_THREE_LEVEL_WORK;
+		m_execute_condition.notify_all(true);
+		//通知 thread_work 子线程启动。
+
+		//将任务的状态改为 TASK_WORKING 处理中
+		mp_carrier_three_level_task->set_task_statu(TASK_WORKING);
+	}
+
+	if ( t_result != Error_code::SUCCESS )
+	{
+		return t_result;
+	}
+
+	return Error_code::SUCCESS;
+}
+
+//检查状态,是否正常运行
+Error_manager Carrier_base::check_status()
+{
+	if ( m_carrier_status == E_READY )
+	{
+		return Error_code::SUCCESS;
+	}
+	else if ( m_carrier_status >= E_BUSY && m_carrier_status <= E_THREE_LEVEL_OVER)
+	{
+		return Error_manager(Error_code::CARRIER_STATUS_BUSY, Error_level::NEGLIGIBLE_ERROR,
+							 " Carrier_base::check_status is busy ");
+	}
+	else
+	{
+		return Error_manager(Error_code::CARRIER_STATUS_ERROR, Error_level::MINOR_ERROR,
+							 " Carrier_base::check_status error ");
+	}
+	return Error_code::SUCCESS;
+}
+
+//判断能否执行一级任务
+Error_manager	Carrier_base::check_one_level_task()
+{
+	if ( m_carrier_status == E_READY )
+	{
+		return Error_code::SUCCESS;
+	}
+	else if ( m_carrier_status >= E_BUSY && m_carrier_status <= E_THREE_LEVEL_OVER)
+	{
+		return Error_manager(Error_code::CARRIER_STATUS_BUSY, Error_level::NEGLIGIBLE_ERROR,
+							 " Carrier_base::check_status is busy ");
+	}
+	else
+	{
+		return Error_manager(Error_code::CARRIER_STATUS_ERROR, Error_level::MINOR_ERROR,
+							 " Carrier_base::check_status error ");
+	}
+	return Error_code::SUCCESS;
+}
+//判断能否执行二级任务
+Error_manager	Carrier_base::check_two_level_task()
+{
+	if ( m_carrier_status == E_READY ||
+		 m_carrier_status == E_ONE_LEVEL_WORK ||
+		 m_carrier_status == E_ONE_LEVEL_OVER )
+	{
+		return Error_code::SUCCESS;
+	}
+	else if ( m_carrier_status >= E_TWO_LEVEL_WORK && m_carrier_status <= E_THREE_LEVEL_OVER)
+	{
+		return Error_manager(Error_code::CARRIER_STATUS_BUSY, Error_level::NEGLIGIBLE_ERROR,
+							 " Carrier_base::check_status is busy ");
+	}
+	else
+	{
+		return Error_manager(Error_code::CARRIER_STATUS_ERROR, Error_level::MINOR_ERROR,
+							 " Carrier_base::check_status error ");
+	}
+	return Error_code::SUCCESS;
+}
+//判断能否执行三级任务
+Error_manager	Carrier_base::check_three_level_task()
+{
+	if ( m_carrier_status == E_READY ||
+		 m_carrier_status == E_ONE_LEVEL_WORK ||
+		 m_carrier_status == E_ONE_LEVEL_OVER )
+	{
+		return Error_code::SUCCESS;
+	}
+	else if ( m_carrier_status >= E_TWO_LEVEL_WORK && m_carrier_status <= E_THREE_LEVEL_OVER)
+	{
+		return Error_manager(Error_code::CARRIER_STATUS_BUSY, Error_level::NEGLIGIBLE_ERROR,
+							 " Carrier_base::check_status is busy ");
+	}
+	else
+	{
+		return Error_manager(Error_code::CARRIER_STATUS_ERROR, Error_level::MINOR_ERROR,
+							 " Carrier_base::check_status error ");
+	}
+	return Error_code::SUCCESS;
+}
+
+//结束任务单,里面会根据任务的故障等级修正 任务单的状态
+Error_manager Carrier_base::end_task(std::shared_ptr<Carrier_task> carrier_task)
+{
+	LOG(INFO) << " ---Carrier_base::end_task run---"<< this;
+
+	carrier_task->m_respons_status = (Carrier_task::Respons_status)m_respons_status;
+
+	//注:这里只修改任务单的状态, 搬运器的状态不管
+	//在结束任务单时,将雷达任务状态改为 TASK_OVER 已结束
+	//判断任务单的错误等级,
+	if ( carrier_task->get_task_error_manager().get_error_level() < Error_level::MINOR_ERROR)
+	{
+		//强制改为TASK_OVER,不管它当前在做什么。
+		carrier_task->set_task_statu(TASK_OVER);
+	}
+	else
+	{
+		//强制改为 TASK_ERROR,不管它当前在做什么。
+		carrier_task->set_task_statu(TASK_ERROR);
+	}
+
+
+	return Error_code::SUCCESS;
+}
+
+//取消任务单,由发送方提前取消任务单
+Error_manager Carrier_base::cancel_task(std::shared_ptr<Carrier_task> carrier_task)
+{
+	//找到对应的任务单
+	if ( carrier_task->get_task_id() == mp_carrier_one_level_task->get_task_id() )
+	{
+		if ( m_carrier_status == E_ONE_LEVEL_WORK || m_carrier_status == E_ONE_LEVEL_OVER )
+		{
+			//如果正在执行一级任务, 那么取消当前指令, 然后降级
+			m_execute_condition.notify_all(false);
+			//确保内部线程已经停下
+			while (m_execute_condition.is_working())
+			{
+
+			}
+			cancel_command();
+			mp_carrier_one_level_task.reset();
+			m_carrier_status = E_READY;
+			m_execute_condition.notify_all(true);
+		}
+		else
+		{
+			//否则直接销毁任务单
+			mp_carrier_one_level_task.reset();
+		}
+	}
+	else if ( carrier_task->get_task_id() == mp_carrier_two_level_task->get_task_id() )
+	{
+		if ( m_carrier_status == E_TWO_LEVEL_WORK || m_carrier_status == E_TWO_LEVEL_OVER )
+		{
+			//如果正在执行二级任务, 那么取消当前指令, 然后降级
+			m_execute_condition.notify_all(false);
+			//确保内部线程已经停下
+			while (m_execute_condition.is_working())
+			{
+
+			}
+			cancel_command();
+			mp_carrier_two_level_task.reset();
+			m_carrier_status = E_ONE_LEVEL_WORK;
+			m_execute_condition.notify_all(true);
+		}
+		else
+		{
+			//否则直接销毁任务单
+			mp_carrier_two_level_task.reset();
+		}
+	}
+	else if ( carrier_task->get_task_id() == mp_carrier_three_level_task->get_task_id() )
+	{
+		if ( m_carrier_status == E_THREE_LEVEL_WORK || m_carrier_status == E_THREE_LEVEL_OVER )
+		{
+			//如果正在执行三级任务, 那么取消当前指令, 然后降级
+			m_execute_condition.notify_all(false);
+			//确保内部线程已经停下
+			while (m_execute_condition.is_working())
+			{
+
+			}
+			cancel_command();
+			mp_carrier_three_level_task.reset();
+			m_carrier_status = E_TWO_LEVEL_WORK;
+			m_execute_condition.notify_all(true);
+		}
+		else
+		{
+			//否则直接销毁任务单
+			mp_carrier_two_level_task.reset();
+		}
+	}
+	else
+	{
+		return Error_manager(Error_code::CARRIER_TASK_NOTHINGNESS, Error_level::MINOR_ERROR,
+							 " carrier_task->get_task_id() is nothingness ");
+	}
+
+	carrier_task->set_task_statu(TASK_DEAD);
+	return Error_code::SUCCESS;
 }
 
 
+//判断是否为待机,如果已经准备好,则可以执行任务。
+bool Carrier_base::is_ready()
+{
+	return (m_carrier_status == E_READY);
+}
 
 Carrier_base::Carrier_status Carrier_base::get_carrier_status()
 {
@@ -34,3 +418,430 @@ Carrier_base::Carrier_status Carrier_base::get_carrier_status()
 }
 
 
+//执行外界任务的执行函数
+void Carrier_base::execute_thread_fun()
+{
+	LOG(INFO) << " execute_thread_fun start "<< this;
+
+//	while (1);
+
+	Error_manager t_error;
+
+	while (m_execute_condition.is_alive())
+	{
+		m_execute_condition.wait();
+		if ( m_execute_condition.is_alive() )
+		{
+			std::this_thread::sleep_for(std::chrono::microseconds(1));
+			std::this_thread::yield();
+
+			switch ( (Carrier_status)m_carrier_status )
+			{
+				//核心任务, (三级任务)
+				case E_THREE_LEVEL_WORK:
+				{
+					if ( mp_carrier_three_level_task.get() != NULL )
+					{
+						//执行三级任务
+						std::unique_lock<std::mutex> t_lock(mp_carrier_three_level_task->m_lock);
+						m_parkspace_unit_id = mp_carrier_three_level_task->m_parkspace_unit_id;
+						m_parkspace_floor_id = mp_carrier_three_level_task->m_parkspace_floor_id;
+						m_parkspace_room_id = mp_carrier_three_level_task->m_parkspace_room_id;
+						m_command_key = mp_carrier_three_level_task->m_command_key;
+						m_motion_direction = mp_carrier_three_level_task->m_motion_direction;
+						m_car_center_x = mp_carrier_three_level_task->m_car_center_x;
+						m_car_center_y = mp_carrier_three_level_task->m_car_center_y;
+						m_car_angle = mp_carrier_three_level_task->m_car_angle;
+
+						//更新通信
+						update_device_communication();
+
+						//检查设备的答复
+						if ( m_respons_status == RESPONS_OVER )
+						{
+							mp_carrier_three_level_task->m_respons_status = (Carrier_task::Respons_status)m_respons_status;
+							end_task(mp_carrier_three_level_task);
+							m_carrier_status = E_THREE_LEVEL_OVER;
+						}
+						else if ( m_respons_status == RESPONS_MINOR_ERROR || m_respons_status == RESPONS_CRITICAL_ERROR )
+						{
+							mp_carrier_three_level_task->m_respons_status = (Carrier_task::Respons_status)m_respons_status;
+							//添加错误码
+							Error_manager t_error(CARRIER_RESPONS_ERROR, MINOR_ERROR, "m_respons_status is error");
+							mp_carrier_three_level_task->set_task_error_manager(t_error);
+							end_task(mp_carrier_three_level_task);
+							m_carrier_status = E_THREE_LEVEL_OVER;
+						}
+						else
+						{
+							//设备正常运行
+							//延时1ms, snap7的通信效率偏慢, 不需要高频率检查
+							std::this_thread::sleep_for(std::chrono::milliseconds(1));
+						}
+					}
+					else
+					{
+						//直接降级
+						m_carrier_status = E_TWO_LEVEL_WORK;
+					}
+					break;
+				}
+				case E_THREE_LEVEL_OVER:
+				{
+					if ( mp_carrier_three_level_task.get() != NULL )
+					{
+						//检查任务状态,
+						//在 E_THREE_LEVEL_WORK 里面, 已经 设为 TASK_OVER 了.
+						//等待发送方的新指令, (发送方会把状态改为回收, 表示这个任务结束)
+						if ( mp_carrier_three_level_task->get_task_statu() == TASK_WITHDRAW )
+						{
+							//这里会通知任务已经释放, 然后销毁任务单,  并降级
+							mp_carrier_three_level_task->set_task_statu(TASK_FREE);
+							mp_carrier_three_level_task.reset();
+							m_carrier_status = E_TWO_LEVEL_WORK;
+						}
+						//else //保持不动, 直到发送方给定新的任务,
+					}
+					else
+					{
+						//直接降级
+						m_carrier_status = E_TWO_LEVEL_WORK;
+					}
+					break;
+				}
+				case E_TWO_LEVEL_WORK:
+				{
+					if ( mp_carrier_two_level_task.get() != NULL )
+					{
+						//执行三级任务
+						std::unique_lock<std::mutex> t_lock(mp_carrier_two_level_task->m_lock);
+						m_parkspace_unit_id = mp_carrier_two_level_task->m_parkspace_unit_id;
+						m_parkspace_floor_id = mp_carrier_two_level_task->m_parkspace_floor_id;
+						m_parkspace_room_id = mp_carrier_two_level_task->m_parkspace_room_id;
+						m_command_key = mp_carrier_two_level_task->m_command_key;
+						m_motion_direction = mp_carrier_two_level_task->m_motion_direction;
+						m_car_center_x = mp_carrier_two_level_task->m_car_center_x;
+						m_car_center_y = mp_carrier_two_level_task->m_car_center_y;
+						m_car_angle = mp_carrier_two_level_task->m_car_angle;
+
+						//更新通信
+						update_device_communication();
+
+						//检查设备的答复
+						if ( m_respons_status == RESPONS_OVER )
+						{
+							mp_carrier_two_level_task->m_respons_status = (Carrier_task::Respons_status)m_respons_status;
+							end_task(mp_carrier_two_level_task);
+							m_carrier_status = E_TWO_LEVEL_OVER;
+						}
+						else if ( m_respons_status == RESPONS_MINOR_ERROR || m_respons_status == RESPONS_CRITICAL_ERROR )
+						{
+							mp_carrier_two_level_task->m_respons_status = (Carrier_task::Respons_status)m_respons_status;
+							//添加错误码
+							Error_manager t_error(CARRIER_RESPONS_ERROR, MINOR_ERROR, "m_respons_status is error");
+							mp_carrier_two_level_task->set_task_error_manager(t_error);
+							end_task(mp_carrier_two_level_task);
+							m_carrier_status = E_TWO_LEVEL_OVER;
+						}
+						else
+						{
+							//设备正常运行
+							//延时1ms, snap7的通信效率偏慢, 不需要高频率检查
+							std::this_thread::sleep_for(std::chrono::milliseconds(1));
+						}
+					}
+					else
+					{
+						//直接降级
+						m_carrier_status = E_ONE_LEVEL_WORK;
+					}
+					break;
+				}
+				case E_TWO_LEVEL_OVER:
+				{
+					if ( mp_carrier_two_level_task.get() != NULL )
+					{
+						//检查任务状态,
+						//在 E_TWO_LEVEL_WORK 里面, 已经 设为 TASK_OVER 了.
+						//等待发送方的新指令, (发送方会把状态改为回收, 表示这个任务结束)
+						if ( mp_carrier_two_level_task->get_task_statu() == TASK_WITHDRAW )
+						{
+							//这里会通知任务已经释放, 然后销毁任务单,  并降级
+							mp_carrier_two_level_task->set_task_statu(TASK_FREE);
+							mp_carrier_two_level_task.reset();
+							m_carrier_status = E_ONE_LEVEL_WORK;
+						}
+						//else //保持不动, 直到发送方给定新的任务,
+					}
+					else
+					{
+						//直接降级
+						m_carrier_status = E_ONE_LEVEL_WORK;
+					}
+					break;
+				}
+				case E_ONE_LEVEL_WORK:
+				{
+					if ( mp_carrier_one_level_task.get() != NULL )
+					{
+						//执行三级任务
+						std::unique_lock<std::mutex> t_lock(mp_carrier_one_level_task->m_lock);
+						m_parkspace_unit_id = mp_carrier_one_level_task->m_parkspace_unit_id;
+						m_parkspace_floor_id = mp_carrier_one_level_task->m_parkspace_floor_id;
+						m_parkspace_room_id = mp_carrier_one_level_task->m_parkspace_room_id;
+						m_command_key = mp_carrier_one_level_task->m_command_key;
+						m_motion_direction = mp_carrier_one_level_task->m_motion_direction;
+						m_car_center_x = mp_carrier_one_level_task->m_car_center_x;
+						m_car_center_y = mp_carrier_one_level_task->m_car_center_y;
+						m_car_angle = mp_carrier_one_level_task->m_car_angle;
+
+						//更新通信
+						update_device_communication();
+
+						//检查设备的答复
+						if ( m_respons_status == RESPONS_OVER )
+						{
+							mp_carrier_one_level_task->m_respons_status = (Carrier_task::Respons_status)m_respons_status;
+							end_task(mp_carrier_one_level_task);
+							m_carrier_status = E_ONE_LEVEL_OVER;
+						}
+						else if ( m_respons_status == RESPONS_MINOR_ERROR || m_respons_status == RESPONS_CRITICAL_ERROR )
+						{
+							mp_carrier_one_level_task->m_respons_status = (Carrier_task::Respons_status)m_respons_status;
+							//添加错误码
+							Error_manager t_error(CARRIER_RESPONS_ERROR, MINOR_ERROR, "m_respons_status is error");
+							mp_carrier_one_level_task->set_task_error_manager(t_error);
+							end_task(mp_carrier_one_level_task);
+							m_carrier_status = E_ONE_LEVEL_OVER;
+						}
+						else if(m_carrier_status == E_ONE_LEVEL_WORK)
+						{
+							//设备正常运行
+							//延时1ms, snap7的通信效率偏慢, 不需要高频率检查
+							std::this_thread::sleep_for(std::chrono::milliseconds(1));
+						}
+					}
+					else
+					{
+						//直接降级
+						m_carrier_status = E_READY;
+					}
+					break;
+				}
+				case E_ONE_LEVEL_OVER:
+				{
+					if ( mp_carrier_one_level_task.get() != NULL )
+					{
+						//检查任务状态,
+						//在 E_ONE_LEVEL_WORK 里面, 已经 设为 TASK_OVER 了.
+						//等待发送方的新指令, (发送方会把状态改为回收, 表示这个任务结束)
+						if ( mp_carrier_one_level_task->get_task_statu() == TASK_WITHDRAW )
+						{
+							//这里会通知任务已经释放, 然后销毁任务单,  并降级
+							mp_carrier_one_level_task->set_task_statu(TASK_FREE);
+							mp_carrier_one_level_task.reset();
+							m_carrier_status = E_READY;
+						}
+						//else //保持不动, 直到发送方给定新的任务,
+					}
+					else
+					{
+						//直接降级
+						m_carrier_status = E_READY;
+					}
+					break;
+				}
+				case E_FAULT:
+				{
+					//更新通信
+					update_device_communication();
+
+					//所有任务报错, 并销毁任务.
+					if ( mp_carrier_one_level_task.get() != NULL )
+					{
+						//添加错误码
+						Error_manager t_error(CARRIER_STATUS_ERROR, MINOR_ERROR, "m_respons_status is error");
+						mp_carrier_one_level_task->set_task_error_manager(t_error);
+						end_task(mp_carrier_one_level_task);
+						mp_carrier_one_level_task.reset();
+					}
+					if ( mp_carrier_two_level_task.get() != NULL )
+					{
+						//添加错误码
+						Error_manager t_error(CARRIER_STATUS_ERROR, MINOR_ERROR, "m_respons_status is error");
+						mp_carrier_two_level_task->set_task_error_manager(t_error);
+						end_task(mp_carrier_two_level_task);
+						mp_carrier_two_level_task.reset();
+					}
+					if ( mp_carrier_three_level_task.get() != NULL )
+					{
+						//添加错误码
+						Error_manager t_error(CARRIER_STATUS_ERROR, MINOR_ERROR, "m_respons_status is error");
+						mp_carrier_three_level_task->set_task_error_manager(t_error);
+						end_task(mp_carrier_three_level_task);
+						mp_carrier_three_level_task.reset();
+					}
+
+
+					break;
+				}
+				case E_DISCONNECT:
+				{
+					//更新通信
+					update_device_communication();
+					//所有任务报错, 并销毁任务.
+					if ( mp_carrier_one_level_task.get() != NULL )
+					{
+						//添加错误码
+						Error_manager t_error(CARRIER_STATUS_DISCONNECT, MINOR_ERROR, "m_respons_status is error");
+						mp_carrier_one_level_task->set_task_error_manager(t_error);
+						end_task(mp_carrier_one_level_task);
+						mp_carrier_one_level_task.reset();
+					}
+					if ( mp_carrier_two_level_task.get() != NULL )
+					{
+						//添加错误码
+						Error_manager t_error(CARRIER_STATUS_DISCONNECT, MINOR_ERROR, "m_respons_status is error");
+						mp_carrier_two_level_task->set_task_error_manager(t_error);
+						end_task(mp_carrier_two_level_task);
+						mp_carrier_two_level_task.reset();
+					}
+					if ( mp_carrier_three_level_task.get() != NULL )
+					{
+						//添加错误码
+						Error_manager t_error(CARRIER_STATUS_DISCONNECT, MINOR_ERROR, "m_respons_status is error");
+						mp_carrier_three_level_task->set_task_error_manager(t_error);
+						end_task(mp_carrier_three_level_task);
+						mp_carrier_three_level_task.reset();
+					}
+
+
+					break;
+				}
+				case E_READY:
+				{
+					//更新通信
+					update_device_communication();
+					break;
+				}
+				default:
+				{
+
+					break;
+				}
+			}
+
+
+
+		}
+	}
+	LOG(INFO) << " execute_thread_fun end "<< this;
+	return;
+}
+
+
+//更新设备底层通信数据
+Error_manager Carrier_base::update_device_communication()
+{
+	//加锁
+	std::mutex * tp_data_lock = 	Dispatch_communication::get_instance_references().get_data_lock();
+	std::unique_lock<std::mutex> t_lock(*tp_data_lock);
+
+	//请求消息, 调度->plc
+	Dispatch_communication::Request_from_dispatch_to_plc * tp_request_from_dispatch_to_plc =
+	Dispatch_communication::get_instance_references().get_request_from_dispatch_to_plc();
+	tp_request_from_dispatch_to_plc->m_block_id = m_parkspace_unit_id;
+	tp_request_from_dispatch_to_plc->m_floor_id = m_parkspace_floor_id;
+	tp_request_from_dispatch_to_plc->m_parkspace_id = m_parkspace_room_id;
+	memcpy(tp_request_from_dispatch_to_plc->m_command_key, m_command_key.c_str(), m_command_key.size());
+	tp_request_from_dispatch_to_plc->m_is_entrance_flag = m_motion_direction;
+	tp_request_from_dispatch_to_plc->m_center_x = m_car_center_x;
+	tp_request_from_dispatch_to_plc->m_center_y = m_car_center_y;
+	tp_request_from_dispatch_to_plc->m_car_angle = m_car_angle;
+
+
+	//答复消息, plc->调度
+	Dispatch_communication::Response_from_plc_to_dispatch * tp_response_from_plc_to_dispatch =
+	Dispatch_communication::get_instance_references().get_response_from_plc_to_dispatch();
+	m_respons_key = (char*)(tp_response_from_plc_to_dispatch->m_command_key);
+	if ( m_respons_key == m_command_key )
+	{
+		if ( tp_response_from_plc_to_dispatch->m_task_status == 0 )
+		{
+			if ( tp_response_from_plc_to_dispatch->m_command_flag == 0 )
+			{
+				m_respons_status = RESPONS_NORMAL;
+			}
+			else
+			{
+				m_respons_status = RESPONS_OVER;
+			}
+		}
+		else if ( tp_response_from_plc_to_dispatch->m_task_status == 1 )
+		{
+			m_respons_status = RESPONS_MINOR_ERROR;
+		}
+		else
+		{
+			m_respons_status = RESPONS_CRITICAL_ERROR;
+		}
+	}
+	else
+	{
+		m_respons_status = RESPONS_NORMAL;
+	}
+
+	//状态消息, 调度->plc
+	Dispatch_communication::Status_from_dispatch_to_plc * tp_status_from_dispatch_to_plc =
+	Dispatch_communication::get_instance_references().get_status_from_dispatch_to_plc();
+	tp_status_from_dispatch_to_plc->m_heartbeat++;
+
+	//状态消息, plc->调度
+	Dispatch_communication::Status_from_plc_to_dispatch * tp_status_from_plc_to_dispatch =
+	Dispatch_communication::get_instance_references().get_status_from_plc_to_dispatch();
+	//通过心跳帧来判断通信是否正常
+	if ( m_last_heartbeat != tp_status_from_plc_to_dispatch->m_heartbeat )
+	{
+		m_last_heartbeat = tp_status_from_plc_to_dispatch->m_heartbeat;
+		m_status_updata_time = std::chrono::system_clock::now();
+
+		m_carrier_coordinate_x = tp_status_from_plc_to_dispatch->m_carrier_coordinates;
+		m_carrier_coordinate_z = tp_status_from_plc_to_dispatch->m_elevator_coordinates;
+		m_carrier_angle = tp_status_from_plc_to_dispatch->m_carrier_angle;
+
+		m_elevator_device_status = tp_status_from_plc_to_dispatch->m_elevator_information;
+		memcpy(m_elevator_error_code, tp_status_from_plc_to_dispatch->m_elevator_error_code, 50);
+		m_elevator_error_description = (char*)(tp_status_from_plc_to_dispatch->m_carrier_error_string);
+
+		m_carrier_device_status = tp_status_from_plc_to_dispatch->m_carrier_information;
+		memcpy(m_carrier_error_code, tp_status_from_plc_to_dispatch->m_carrier_error_code, 50);
+		m_carrier_error_description = (char*)(tp_status_from_plc_to_dispatch->m_carrier_error_string);
+
+		if ( m_carrier_status == E_DISCONNECT )
+		{
+			m_carrier_status = E_THREE_LEVEL_WORK;
+		}
+	}
+	else if(std::chrono::system_clock::now() - m_status_updata_time > std::chrono::milliseconds(CARRIER_COMMUNICATION_OVER_TIME_MS))
+	{
+		m_carrier_status = E_DISCONNECT;
+	}
+
+
+	return Error_code::SUCCESS;
+}
+
+//取消下发的指令
+Error_manager Carrier_base::cancel_command()
+{
+	//以后再写 need programe
+	//目前调度和plc的通信指令做的很简单,没有暂停和急停 复位等操作.
+	//这里先空着,以后再写.
+	//调度模块单方面销毁任务, 不管底层plc的执行情况, 也不去告知plc任务取消.
+
+	return Error_code::SUCCESS;
+}
+
+
+
+

+ 113 - 11
dispatch/carrier_base.h

@@ -7,21 +7,43 @@
 
 #include "../error_code/error_code.h"
 #include <glog/logging.h>
+#include <thread>
+#include <mutex>
+#include "../tool/thread_condition.h"
+#include "../dispatch/carrier_task.h"
 
-
-//搬运器的基类, AGV和抓取机器人从他继承
+//搬运器的基类, 楚天项目就是电梯和中跑车的合并
 class Carrier_base
 {
 public:
-	//搬运器状态, 楚天项目就是AGV系统
+	//搬运器底层通信延时5000ms
+#define	CARRIER_COMMUNICATION_OVER_TIME_MS	5000
+
+	//搬运器状态,
 	enum Carrier_status
 	{
-		E_CARRIER_UNKNOW               = 0,     //未知
-		E_CARRIER_READY                = 1,     //准备,待机
-		E_CARRIER_STORE                = 2,	    //正在存车
-		E_CARRIER_PICKUP               = 3,	    //正在取车
+		E_UNKNOW               	= 0,    //未知
+		E_READY               	= 1,    //准备,待机
+		E_BUSY					= 2, 	//工作正忙
+
+		E_ONE_LEVEL_WORK		= 3,	//一级工作状态, 就是普通的移动任务
+		E_ONE_LEVEL_OVER		= 4, 	//一级工作完成,
+		E_TWO_LEVEL_WORK		= 5,	//二级工作状态, 就是紧急避让, 插队任务(会在执行一级任务的过程中, 插队并优先执行二级任务)
+		E_TWO_LEVEL_OVER		= 6, 	//一级工作完成,
+		E_THREE_LEVEL_WORK		= 7,	//三级工作任务, 就是锁定硬件资源, 不让插队, (除非急停或者取消任务)
+		E_THREE_LEVEL_OVER		= 8, 	//一级工作完成,
 
-		E_CARRIER_FAULT                = 10,     //故障
+		E_FAULT					= 100,	//故障
+		E_DISCONNECT			= 101, 	//通信故障
+	};
+
+	//指令完成状态, 搬运器答复指令, 返回任务完成的情况
+	enum Respons_status
+	{
+		RESPONS_NORMAL             	= 0,    //正常
+		RESPONS_OVER               	= 1,    //任务完成
+		RESPONS_MINOR_ERROR			= 100,	//一般故障, 可恢复
+		RESPONS_CRITICAL_ERROR		= 101,	//致命故障,不可恢复
 	};
 
 public:
@@ -34,14 +56,94 @@ public://API functions
 	virtual Error_manager carrier_base_init();
 	//搬运器 反初始化
 	virtual Error_manager carrier_base_uninit();
+
+	//处理一级任务, 普通任务
+	virtual Error_manager execute_one_level_task(std::shared_ptr<Carrier_task> p_carrier_task);
+	//处理二级任务, 插队任务
+	virtual Error_manager execute_two_level_task(std::shared_ptr<Carrier_task> p_carrier_task);
+	//处理三级任务, 核心任务
+	virtual Error_manager execute_three_level_task(std::shared_ptr<Carrier_task> p_carrier_task);
+	//检查状态,是否正常运行
+	Error_manager check_status();
+
+	//注意了, 调度任务允许同时接受多个任务
+	//判断能否执行一级任务
+	Error_manager	check_one_level_task();
+	//判断能否执行二级任务
+	Error_manager	check_two_level_task();
+	//判断能否执行三级任务
+	Error_manager	check_three_level_task();
+
+	//结束任务单,里面会根据任务的故障等级修正 任务单的状态
+	Error_manager end_task(std::shared_ptr<Carrier_task> carrier_task);
+	//取消任务单,由发送方提前取消任务单
+	Error_manager cancel_task(std::shared_ptr<Carrier_task> carrier_task);
+
+	//判断是否为待机,如果已经准备好,则可以执行任务。
+	bool is_ready();
 public://get or set member variable
 	Carrier_status get_carrier_status();
 
+protected://member functions
+	//执行外界任务的执行函数
+	void execute_thread_fun();
+
+	//更新设备底层通信数据
+	virtual Error_manager update_device_communication();
+
+	//取消下发的指令
+	virtual Error_manager cancel_command();
 protected://member variable
-	enum Carrier_status					m_carrier_status;	//搬运器状态,
+	std::atomic<Carrier_status>			m_carrier_status;			//搬运器总状态, 控制任务流程
+	int 								m_carrier_id;				//搬运器id, (楚天项目和单元号对应)
+	
+	//下发到硬件
+	//搬运器的目标车位
+	unsigned short 						m_parkspace_unit_id;		//车位单元号(楚天项目为1~3)
+	unsigned short 						m_parkspace_floor_id;		//车位楼层号(楚天项目为1~14)
+	unsigned short 						m_parkspace_room_id;		//车位同层的房间号	(楚天项目一楼为1~4, 楼上为1~6)
+	std::string							m_command_key;				//任务唯一码, 用作识别
+	unsigned char						m_motion_direction;			//调度方向, 根据停车取车选择出入口, 	1=入口,0=非入口
+	float 								m_car_center_x;				//汽车的中心坐标x
+	float 								m_car_center_y;				//汽车的中心坐标y
+	float 								m_car_angle;				//汽车的旋转角(角度-90~90)
+
+	//硬件反馈
+	//搬运器当前坐标
+	std::string							m_respons_key;				//应答的唯一码, 用作识别
+	Respons_status						m_respons_status;			//指令完成状态, 搬运器答复指令, 返回任务完成的情况
+
+
+
+	//硬件状态, 目前只做显示判断
+	std::chrono::system_clock::time_point	m_status_updata_time;	//状态更新时间点
+	unsigned char						m_last_heartbeat;			//上一次的心跳
+
+	//硬件坐标,
+	float 								m_carrier_coordinate_x;			//搬运器坐标x轴, 中跑车控制横向移动
+	float 								m_carrier_coordinate_y;			//搬运器坐标y轴, (本模块默认为0, 由AGV模块去控制纵向移动)
+	float 								m_carrier_coordinate_z;			//搬运器坐标z轴, 电梯控制上下移动
+	float 								m_carrier_angle;				//搬运器角度
+	//搬运器设备的状态(0bit为1:急停正常, 1bit为1:处于安全位置, 2bit为1:静止状态, 3bit为1:可执行新指令, 4bit为1:存在故障)
+	unsigned char						m_carrier_device_status;	//搬运器设备的状态, 楚天项目就是中跑车
+	unsigned char						m_carrier_error_code[50];	//搬运器设备的报警信息位
+	std::string							m_carrier_error_description;//搬运器设备的报警状态描述
+	//升降机设备的状态(0bit为1:急停正常, 1bit为1:处于安全位置, 2bit为1:静止状态, 3bit为1:可执行新指令, 4bit为1:存在故障)
+	unsigned char						m_elevator_device_status;	//升降机设备状态, 楚天项目就是电梯
+	unsigned char						m_elevator_error_code[50];	//升降机设备的报警信息位
+	std::string							m_elevator_error_description;//升降机设备的报警状态描述
+
+
+	//任务执行线程
+	std::thread*        				mp_execute_thread;   			//执行的线程指针,内存由本类管理
+	Thread_condition					m_execute_condition;			//执行的条件变量
+
+	std::shared_ptr<Carrier_task>		mp_carrier_one_level_task;		//搬运器的普通任务, (一般移动和等待指令, 允许被打断)
+	std::shared_ptr<Carrier_task>		mp_carrier_two_level_task;		//搬运器的优先任务, (紧急避让和插队指令, 允许打断普通任务)
+	std::shared_ptr<Carrier_task>		mp_carrier_three_level_task;	//搬运器的核心任务, (锁定位置进行抓车和放车, 最高任务, 不允许打断和被打断)
+
+
 
-	////搬运器
-	float 								m_coordinate_x;
 private:
 
 };

+ 82 - 0
dispatch/carrier_task.cpp

@@ -0,0 +1,82 @@
+//
+// Created by huli on 2020/10/20.
+//
+
+#include "carrier_task.h"
+
+Carrier_task::Carrier_task()
+{
+	//构造函数锁定任务类型为 LOCATE_MANGER_TASK,后续不允许更改
+	m_task_type = CARRIER_TASK;
+	m_task_statu = TASK_CREATED;
+	m_task_statu_information.clear();
+	m_task_error_manager.error_manager_clear_all();
+
+	m_parkspace_unit_id = 0;
+	m_parkspace_floor_id = 0;
+	m_parkspace_room_id = 0;
+//	m_command_key = "";
+	m_motion_direction = 0;
+	m_car_center_x = 0;
+	m_car_center_y = 0;
+	m_car_angle = 0;
+
+
+
+	unsigned short 						m_parkspace_floor_id;		//车位楼层号(楚天项目为1~14)
+	unsigned short 						m_parkspace_room_id;		//车位同层的房间号	(楚天项目一楼为1~4, 楼上为1~6)
+	std::string							m_command_key;				//任务唯一码
+	unsigned char						m_motion_direction;			//调度方向, 根据停车取车选择出入口, 	1=入口,0=非入口
+	float 								m_car_center_x;				//汽车的中心坐标x
+	float 								m_car_center_y;				//汽车的中心坐标y
+	float 								m_car_angle;				//汽车的旋转角(角度-90~90)
+
+	//任务执行结果
+	Respons_status						m_respons_status;			//指令完成状态, 搬运器答复指令, 返回任务完成的情况
+}
+
+Carrier_task::~Carrier_task()
+{
+
+}
+
+
+//初始化任务单,必须初始化之后才可以使用,(可选参数)
+//    input:tast_receiver 接受对象
+//    input:task_over_time 超时时间
+Error_manager Carrier_task::task_init(void* p_tast_receiver,
+						std::chrono::milliseconds task_over_time,
+						unsigned short parkspace_unit_id,
+						unsigned shortparkspace_floor_id,
+						unsigned shortparkspace_room_id,
+						std::string command_key,
+						unsigned char motion_direction,
+						float car_center_x,
+						float car_center_y,
+						float car_angle
+)
+{
+	m_task_statu = TASK_CREATED;
+	m_task_statu_information.clear();
+	m_task_error_manager.error_manager_clear_all();
+
+	m_parkspace_unit_id = parkspace_unit_id;
+	m_parkspace_floor_id = shortparkspace_floor_id;
+	m_parkspace_room_id = shortparkspace_room_id;
+	m_command_key = command_key;
+	m_motion_direction = motion_direction;
+	m_car_center_x = car_center_x;
+	m_car_center_y = car_center_y;
+	m_car_angle = car_angle;
+
+	m_respons_status = RESPONS_NORMAL;
+}
+
+
+
+
+
+
+
+
+

+ 72 - 0
dispatch/carrier_task.h

@@ -0,0 +1,72 @@
+//
+// Created by huli on 2020/10/20.
+//
+
+#ifndef NNXX_TESTS_CARRIER_TASK_H
+#define NNXX_TESTS_CARRIER_TASK_H
+
+#include "../error_code/error_code.h"
+#include "../task/task_command_manager.h"
+#include "../task/task_base.h"
+#include <mutex>
+
+
+class Carrier_task :public Task_Base
+{
+public:
+	//指令完成状态, 搬运器答复指令, 返回任务完成的情况
+	enum Respons_status
+	{
+		RESPONS_NORMAL             	= 0,    //正常
+		RESPONS_OVER               	= 1,    //任务完成
+		RESPONS_MINOR_ERROR			= 100,	//一般故障, 可恢复
+		RESPONS_CRITICAL_ERROR		= 101,	//致命故障,不可恢复
+	};
+public:
+	Carrier_task();
+	Carrier_task(const Carrier_task& other)= default;
+	Carrier_task& operator =(const Carrier_task& other)= default;
+	~Carrier_task();
+public://API functions
+
+	//初始化任务单,必须初始化之后才可以使用,(可选参数)
+	//    input:tast_receiver 接受对象
+	//    input:task_over_time 超时时间
+	Error_manager task_init(void* p_tast_receiver,
+							std::chrono::milliseconds task_over_time,
+							unsigned short parkspace_unit_id,
+							unsigned shortparkspace_floor_id,
+							unsigned shortparkspace_room_id,
+							std::string command_key,
+							unsigned char motion_direction = 0,
+							float car_center_x = 0,
+							float car_center_y = 0,
+							float car_angle = 0
+	);
+public://get or set member variable
+
+protected://member functions
+
+public://member variable
+
+	std::mutex							m_lock;	//锁
+
+	//搬运器的目标车位
+	unsigned short 						m_parkspace_unit_id;		//车位单元号(楚天项目为1~3)
+	unsigned short 						m_parkspace_floor_id;		//车位楼层号(楚天项目为1~14)
+	unsigned short 						m_parkspace_room_id;		//车位同层的房间号	(楚天项目一楼为1~4, 楼上为1~6)
+	std::string							m_command_key;				//任务唯一码
+	unsigned char						m_motion_direction;			//调度方向, 根据停车取车选择出入口, 	1=入口,0=非入口
+	float 								m_car_center_x;				//汽车的中心坐标x
+	float 								m_car_center_y;				//汽车的中心坐标y
+	float 								m_car_angle;				//汽车的旋转角(角度-90~90)
+
+	//任务执行结果
+	Respons_status						m_respons_status;			//指令完成状态, 搬运器答复指令, 返回任务完成的情况
+
+private:
+
+};
+
+
+#endif //NNXX_TESTS_CARRIER_TASK_H

+ 154 - 28
dispatch/dispatch_communication.cpp

@@ -20,22 +20,131 @@ Dispatch_communication::~Dispatch_communication()
 //初始化 通信 模块。如下三选一
 Error_manager Dispatch_communication::communication_init()
 {
-	//往map通信缓存里面添加所需要的buf
-	{
-		std::unique_lock<std::mutex> t_lock(m_receive_buf_lock);
-		Snap7_buf t_response(RESPONSE_FROM_PLC_TO_DISPATCH_DBNUMBER, 0, sizeof(Response_from_plc_to_dispatch), Snap7_buf::LOOP_COMMUNICATION);
-		m_receive_buf_map[0] = t_response;
-		Snap7_buf t_plc_status(STATUS_FROM_PLC_TO_DISPATCH_DBNUMBER, 0, sizeof(Status_from_plc_to_dispatch), Snap7_buf::LOOP_COMMUNICATION);
-		m_receive_buf_map[1] = t_plc_status;
-	}
-	{
-		std::unique_lock<std::mutex> t_lock(m_send_buf_lock);
-		Snap7_buf t_request(REQUEST_FROM_DISPATCH_TO_PLC_DBNUMBER, 0, sizeof(Request_from_dispatch_to_plc), Snap7_buf::NO_COMMUNICATION);
-		m_send_buf_map[0] = t_request;
-		Snap7_buf t_dispatch_status(STATUS_FROM_DISPATCH_TO_PLC_DBNUMBER, 0, sizeof(Status_from_dispatch_to_plc), Snap7_buf::NO_COMMUNICATION);
-		m_send_buf_map[1] = t_dispatch_status;
-	}
+	int t_index = 0;
+	std::vector<Snap7_buf::Variable_information>		t_variable_information_vector;
 
+	//往map通信缓存里面添加所需要的buf
+	std::unique_lock<std::mutex> t_lock1(m_receive_buf_lock);
+	std::unique_lock<std::mutex> t_lock2(m_send_buf_lock);
+
+	t_index = 0;
+	t_variable_information_vector.clear();
+	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved0", 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_command_flag", 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_task_status", 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_reserved3_11", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 9 });
+	t_index += sizeof(unsigned char)*9;
+
+	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_block_id", typeid(unsigned short).name(), t_index,sizeof(unsigned short), 1 });
+	t_index += sizeof(unsigned short)*1;
+	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_floor_id", typeid(unsigned short).name(), t_index,sizeof(unsigned short), 1 });
+	t_index += sizeof(unsigned short)*1;
+	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_parkspace_id", typeid(unsigned short).name(), t_index,sizeof(unsigned short), 1 });
+	t_index += sizeof(unsigned short)*1;
+	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_command_key", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 256 });
+	t_index += sizeof(unsigned char)*256;
+	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_is_entrance_flag", 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_reserved275_289", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 15 });
+	t_index += sizeof(unsigned char)*15;
+
+	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_center_x", typeid(float).name(), t_index,sizeof(float), 1 });
+	t_index += sizeof(float)*1;
+	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_center_y", typeid(float).name(), t_index,sizeof(float), 1 });
+	t_index += sizeof(float)*1;
+	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_car_angle", typeid(float).name(), t_index,sizeof(float), 1 });
+	t_index += sizeof(float)*1;
+	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_car_length", typeid(float).name(), t_index,sizeof(float), 1 });
+	t_index += sizeof(float)*1;
+	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_car_width", typeid(float).name(), t_index,sizeof(float), 1 });
+	t_index += sizeof(float)*1;
+	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_car_height", typeid(float).name(), t_index,sizeof(float), 1 });
+	t_index += sizeof(float)*1;
+	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_wheel_base", typeid(float).name(), t_index,sizeof(float), 1 });
+	t_index += sizeof(float)*1;
+	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_wheel_width", typeid(float).name(), t_index,sizeof(float), 1 });
+	t_index += sizeof(float)*1;
+	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_voucher_number", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 256 });
+	t_index += sizeof(unsigned char)*256;
+	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_plate_number", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 512 });
+	t_index += sizeof(unsigned char)*512;
+	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_phone_number", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 256 });
+	t_index += sizeof(unsigned char)*256;
+	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved1346_1377", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 32 });
+	t_index += sizeof(unsigned char)*32;
+	Snap7_buf t_response(RESPONSE_FROM_PLC_TO_DISPATCH_DBNUMBER, 0, sizeof(Response_from_plc_to_dispatch), t_variable_information_vector, Snap7_buf::LOOP_COMMUNICATION);
+	m_receive_buf_map[0] = t_response;
+
+	Snap7_buf t_request(REQUEST_FROM_DISPATCH_TO_PLC_DBNUMBER, 0, sizeof(Request_from_dispatch_to_plc), t_variable_information_vector,Snap7_buf::NO_COMMUNICATION);
+	m_send_buf_map[0] = t_request;
+
+
+	t_index = 0;
+	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_index += sizeof(unsigned char)*1;
+	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_check_flag", 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_reserved2_9", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 8 });
+	t_index += sizeof(unsigned char)*8;
+
+	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_year", typeid(unsigned short).name(), t_index,sizeof(unsigned short), 1 });
+	t_index += sizeof(unsigned short)*1;
+	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_month", 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_day", 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_weekday", 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_hour", 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_minute", 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_second", 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_nanosecond", typeid(unsigned int).name(), t_index,sizeof(unsigned int), 1 });
+	t_index += sizeof(unsigned int)*1;
+	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved22_29", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 8 });
+	t_index += sizeof(unsigned char)*8;
+
+	Snap7_buf t_dispatch_status(STATUS_FROM_DISPATCH_TO_PLC_DBNUMBER, 0, sizeof(Status_from_dispatch_to_plc), t_variable_information_vector,Snap7_buf::NO_COMMUNICATION);
+	m_send_buf_map[1] = t_dispatch_status;
+
+
+	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_elevator_information", 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_reserved31", 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_elevator_coordinates", typeid(double).name(), t_index,sizeof(double), 1 });
+	t_index += sizeof(double)*1;
+	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved40_73", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 34 });
+	t_index += sizeof(unsigned char)*34;
+
+	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_carrier_information", 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_reserved75", 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_carrier_coordinates", typeid(double).name(), t_index,sizeof(double), 1 });
+	t_index += sizeof(double)*1;
+	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_carrier_angle", typeid(double).name(), t_index,sizeof(double), 1 });
+	t_index += sizeof(double)*1;
+	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_reserved92_125", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 34 });
+	t_index += sizeof(unsigned char)*34;
+
+	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_carrier_error_code", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 50 });
+	t_index += sizeof(unsigned char)*50;
+	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_carrier_error_string", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 512 });
+	t_index += sizeof(unsigned char)*512;
+	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_elevator_error_code", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 50 });
+	t_index += sizeof(unsigned char)*50;
+	t_variable_information_vector.push_back(Snap7_buf::Variable_information{"m_elevator_error_string", typeid(unsigned char).name(), t_index,sizeof(unsigned char), 512 });
+	t_index += sizeof(unsigned char)*512;
+
+	Snap7_buf t_plc_status(STATUS_FROM_PLC_TO_DISPATCH_DBNUMBER, 0, sizeof(Status_from_plc_to_dispatch), t_variable_information_vector,Snap7_buf::LOOP_COMMUNICATION);
+	m_receive_buf_map[1] = t_plc_status;
 
 	return Snap7_communication_base::communication_init();
 }
@@ -46,22 +155,41 @@ Error_manager Dispatch_communication::communication_uninit()
 	return Snap7_communication_base::communication_uninit();
 }
 
+std::mutex * Dispatch_communication::get_data_lock()
+{
+	return &m_data_lock;
+}
+Dispatch_communication::Request_from_dispatch_to_plc * Dispatch_communication::get_request_from_dispatch_to_plc()
+{
+	return &m_request_from_dispatch_to_plc;
+}
+Dispatch_communication::Response_from_plc_to_dispatch * Dispatch_communication::get_response_from_plc_to_dispatch()
+{
+	return &m_response_from_plc_to_dispatch;
+}
+Dispatch_communication::Status_from_dispatch_to_plc * Dispatch_communication::get_status_from_dispatch_to_plc()
+{
+	return &m_status_from_dispatch_to_plc;
+}
+Dispatch_communication::Status_from_plc_to_dispatch * Dispatch_communication::get_status_from_plc_to_dispatch()
+{
+	return &m_status_from_plc_to_dispatch;
+}
+
+
 //更新数据
 Error_manager Dispatch_communication::updata_receive_buf()
 {
 	std::unique_lock<std::mutex> t_lock1(m_receive_buf_lock);
 	std::unique_lock<std::mutex> t_lock2(m_data_lock);
 
-
-
-
 	memcpy(&m_response_from_plc_to_dispatch, m_receive_buf_map[0].mp_buf_obverse, m_receive_buf_map[0].m_size);
 	memcpy(&m_status_from_plc_to_dispatch, m_receive_buf_map[1].mp_buf_obverse, m_receive_buf_map[1].m_size);
 
-	std::cout << " huli test :::: " << " m_status_from_plc_to_dispatch.m_heartbeat = " << (int)m_status_from_plc_to_dispatch.m_heartbeat << std::endl;
-	std::cout << " huli test :::: " << " m_response_from_plc_to_dispatch.m_command_key = " << m_response_from_plc_to_dispatch.m_command_key << std::endl;
-	std::cout << " huli test :::: " << " m_status_from_plc_to_dispatch.m_elevator_coordinates = " << m_status_from_plc_to_dispatch.m_elevator_coordinates << std::endl;
-	std::cout << " huli test :::: " << " m_status_from_plc_to_dispatch.m_carrier_coordinates = " << m_status_from_plc_to_dispatch.m_carrier_coordinates << std::endl;
+//	std::cout << " huli test :::: " << " m_status_from_plc_to_dispatch.m_heartbeat = " << (int)m_status_from_plc_to_dispatch.m_heartbeat << std::endl;
+//	std::cout << " huli test :::: " << " m_response_from_plc_to_dispatch.m_command_key = " << m_response_from_plc_to_dispatch.m_command_key << std::endl;
+//	std::cout << " huli test :::: " << " m_status_from_plc_to_dispatch.m_elevator_coordinates = " << m_status_from_plc_to_dispatch.m_elevator_coordinates << std::endl;
+//	std::cout << " huli test :::: " << " m_status_from_plc_to_dispatch.m_carrier_coordinates = " << m_status_from_plc_to_dispatch.m_carrier_coordinates << std::endl;
 
 	return Error_code::SUCCESS;
 }
@@ -70,18 +198,16 @@ Error_manager Dispatch_communication::updata_send_buf()
 	std::unique_lock<std::mutex> t_lock1(m_send_buf_lock);
 	std::unique_lock<std::mutex> t_lock2(m_data_lock);
 
-	memcpy(m_request_from_dispatch_to_plc.m_command_key, "from_dispatch_to_plc_123", 20);
-	m_status_from_dispatch_to_plc.m_year = (unsigned short)20;
-	m_status_from_dispatch_to_plc.m_day = 20;
-	m_status_from_dispatch_to_plc.m_heartbeat = 20;
+//	memcpy(m_request_from_dispatch_to_plc.m_command_key, "from_dispatch_to_plc_123", 20);
+//	m_status_from_dispatch_to_plc.m_year = (unsigned short)20;
+//	m_status_from_dispatch_to_plc.m_day = 20;
+//	m_status_from_dispatch_to_plc.m_heartbeat = 20;
 
 	memcpy(m_send_buf_map[0].mp_buf_obverse, &m_request_from_dispatch_to_plc, m_send_buf_map[0].m_size);
 	m_send_buf_map[0].set_communication_mode(Snap7_buf::ONCE_COMMUNICATION);
 	memcpy(m_send_buf_map[1].mp_buf_obverse, &m_status_from_dispatch_to_plc, m_send_buf_map[1].m_size);
 	m_send_buf_map[1].set_communication_mode(Snap7_buf::ONCE_COMMUNICATION);
 
-
-
 	return Error_code::SUCCESS;
 }
 

+ 7 - 4
dispatch/dispatch_communication.h

@@ -19,7 +19,7 @@ public:
 	{
 	    unsigned char 			m_reserved0 = 0;				//预留
 	    unsigned char			m_command_flag = 0;				//指令标志位, 0bit==1:流程开始, 1bit==1:校验无误
-		unsigned char			m_reserved2 = 0;				//预留
+		unsigned char			m_task_status = 0;				//流程状态, 0=正常,1=可恢复型故障,2=不可恢复故障
 		unsigned char			m_reserved3_11[9] = {0};		//预留
 
 	    //指令信息
@@ -132,7 +132,7 @@ public:
 		unsigned char			m_carrier_information = 0;		//搬运器信息,
 		unsigned char			m_reserved75 = 0;				//预留
 		double 					m_carrier_coordinates = 0;		//搬运器坐标
-		double 					m_carrier_angle = 0;			//搬运器坐标
+		double 					m_carrier_angle = 0;			//搬运器角度
 		unsigned char			m_reserved92_125[34] = {0};		//预留
 
 		//故障信息
@@ -159,8 +159,11 @@ public://API functions
 	//反初始化 通信 模块。
 	virtual Error_manager communication_uninit();
 public://get or set member variable
-
-
+	std::mutex * get_data_lock();
+	Request_from_dispatch_to_plc * get_request_from_dispatch_to_plc();
+	Response_from_plc_to_dispatch * get_response_from_plc_to_dispatch();
+	Status_from_dispatch_to_plc * get_status_from_dispatch_to_plc();
+	Status_from_plc_to_dispatch * get_status_from_plc_to_dispatch();
 protected://member functions
 	//更新数据
 	virtual Error_manager updata_receive_buf();

+ 5 - 3
dispatch/dispatch_manager.h

@@ -83,10 +83,12 @@ protected://member variable
 
 	Dispatch_manager_status						m_dispatch_manager_status;			//调度管理 的状态
 
-	int 										m_dispatch_id;						//
+	int 										m_dispatch_id;						//调度模块的id, (楚天项目就是单元号, 0~2)
+
+	int 										m_carrier_number;					//搬运器的数量, 默认3个
+	std::vector<Carrier_base*>					m_carrier_vector;					//搬运器的对象实例,内存由本类管理
+
 
-//	int 										m_carrier_number;					//搬运器的数量, 默认3个
-//	std::vector<Carrier_base*>					m_carrier_vector;					//搬运器的对象实例,内存由本类管理
 
 
 private:

+ 76 - 56
error_code/error_code.h

@@ -95,7 +95,6 @@ enum Error_code
 	LASER_TASK_OVER_TIME,							//雷达基类模块, 任务超时
 	LASER_QUEUE_ERROR,								//雷达基类模块, 数据缓存错误
 
-
 //    laser_livox.cpp的错误码
     LIVOX_ERROR_BASE                = 0x01020000,
     LIVOX_START_FAILE,								//livox模块,开始扫描失败
@@ -127,21 +126,20 @@ enum Error_code
 
 
      //PLC error code  ...
-    PLC_ERROR_BASE                  = 0x02010000,
-    PLC_UNKNOWN_ERROR,
-    PLC_EMPTY_TASK,
-    PLC_IP_PORT_ERROR,
-    PLC_SLAVE_ID_ERROR,
-    PLC_CONNECTION_FAILED,
-    PLC_READ_FAILED,
-    PLC_WRITE_FAILED,
-    PLC_NOT_ENOUGH_DATA_ERROR,
+    PLC_ERROR_BASE                  				= 0x02010000,
+    PLC_UNKNOWN_ERROR,								//plc未知错误
+    PLC_EMPTY_TASK,									//plc任务为空
+    PLC_IP_PORT_ERROR,								//plc的ip端口错误
+    PLC_SLAVE_ID_ERROR,								//plc的身份id错误
+    PLC_CONNECTION_FAILED,							//PLC连接失败
+    PLC_READ_FAILED,								//plc读取失败
+    PLC_WRITE_FAILED,								//plc写入失败
+    PLC_NOT_ENOUGH_DATA_ERROR,						//PLC没有足够的数据错误
 
 
 
     //locate 定位模块,
 	LOCATER_ERROR_BASE                				= 0x03000000,
-
 	//LASER_MANAGER 定位管理模块
 	LOCATER_MANAGER_ERROR_BASE                		= 0x03010000,
 	LOCATER_MANAGER_READ_PROTOBUF_ERROR,				//定位管理模块,读取参数错误
@@ -150,61 +148,65 @@ enum Error_code
 	LOCATER_MANAGER_TASK_TYPE_ERROR,					//定位管理模块,任务类型错误
 	LOCATER_MANAGER_IS_NOT_READY,						//定位管理模块,不在准备状态
 	LOCATER_MANAGER_CLOUD_MAP_ERROR,					//定位管理模块,任务输入点云map的error
-	LOCATE_MANAGER_TASK_OVER_TIME,						//定位管理模块,任务超时
+	LOCATER_MANAGER_TASK_OVER_TIME,						//定位管理模块,任务超时
 
 
-	//Locater.cpp error from 0x0301000-0x030100FF
-	LOCATER_TASK_INIT_CLOUD_EMPTY ,
-    LOCATER_TASK_ERROR,
-    LOCATER_TASK_INPUT_CLOUD_UNINIT,
-    LOCATER_INPUT_CLOUD_EMPTY,
-    LOCATER_YOLO_UNINIT,
-    LOCATER_POINTSIFT_UNINIT,
-    LOCATER_3DCNN_UNINIT,
-    LOCATER_INPUT_YOLO_CLOUD_EMPTY,
-    LOCATER_Y_OUT_RANGE_BY_PLC,
-    LOCATER_MEASURE_HEIGHT_CLOUD_UNINIT,
-    LOCATER_MEASURE_HEIGHT_CLOUD_EMPTY,
-    LOCATER_INPUT_CLOUD_UNINIT,
+	//Locater.cpp error 
+	LOCATER_ALGORITHM_ERROR_BASE                	= 0x03020000,
+	LOCATER_TASK_INIT_CLOUD_EMPTY ,						//定位任务初始化点云为空
+    LOCATER_TASK_ERROR,									//定位任务错误
+    LOCATER_TASK_INPUT_CLOUD_UNINIT,					//定位任务输入点云为空
+    LOCATER_INPUT_CLOUD_EMPTY,							//定位输入点云为空
+    LOCATER_YOLO_UNINIT,								//定位yolo未初始化
+    LOCATER_POINTSIFT_UNINIT,							//定位POINTSIFT未初始化
+    LOCATER_3DCNN_UNINIT,								//定位3DCNN未初始化
+    LOCATER_INPUT_YOLO_CLOUD_EMPTY,						//定位输入yolo点云为空
+    LOCATER_Y_OUT_RANGE_BY_PLC,							//定位超出plc的限制范围
+    LOCATER_MEASURE_HEIGHT_CLOUD_UNINIT,				//定位测量高点云未初始化
+    LOCATER_MEASURE_HEIGHT_CLOUD_EMPTY,					//定位测量高点云为空
+    LOCATER_INPUT_CLOUD_UNINIT,							//定位输入点云未初始化
 
 
     //point sift from 0x03010100-0x030101FF
-    LOCATER_SIFT_INIT_FAILED=0x03010100,
-    LOCATER_SIFT_INPUT_CLOUD_UNINIT,
-	LOCATER_SIFT_INPUT_CLOUD_EMPTY,
-	LOCATER_SIFT_GRID_ERROR,
-	LOCATER_SIFT_SELECT_ERROR,
-	LOCATER_SIFT_CLOUD_VERY_LITTLE,
-	LOCATER_SIFT_CREATE_INPUT_DATA_FAILED,
-	LOCATER_SIFT_PREDICT_FAILED,
-	LOCATER_SIFT_PREDICT_TIMEOUT,
-	LOCATER_SIFT_PREDICT_NO_WHEEL_POINT,
-	LOCATER_SIFT_PREDICT_NO_CAR_POINT,
-
-    LOCATER_SIFT_FILTE_OBS_FAILED,
-    LOCATER_SIFT_INPUT_BOX_PARAMETER_FAILED,
-
-//    //yolo from 0x03010200-0x030102FF
-//        LOCATER_YOLO_DETECT_FAILED=0x03010200,
+	LOCATER_SIFT_ERROR_BASE							=0x03020100,
+   	LOCATER_SIFT_INIT_FAILED,							//定位过滤模块,初始化失败
+    LOCATER_SIFT_INPUT_CLOUD_UNINIT,					//定位过滤模块,输入点云未初始化
+	LOCATER_SIFT_INPUT_CLOUD_EMPTY,						//定位过滤模块,输入点云为空
+	LOCATER_SIFT_GRID_ERROR,							//定位过滤模块,筛选网格错误
+	LOCATER_SIFT_SELECT_ERROR,							//定位过滤模块,筛选选择错误
+	LOCATER_SIFT_CLOUD_VERY_LITTLE,						//定位过滤模块,筛选点云很少
+	LOCATER_SIFT_CREATE_INPUT_DATA_FAILED,				//定位过滤模块,筛选创建输入数据失败
+	LOCATER_SIFT_PREDICT_FAILED,						//定位过滤模块,预测失败
+	LOCATER_SIFT_PREDICT_TIMEOUT,						//定位过滤模块,预测超时
+	LOCATER_SIFT_PREDICT_NO_WHEEL_POINT,				//定位过滤模块,预测结果没有车轮点云
+	LOCATER_SIFT_PREDICT_NO_CAR_POINT,					//定位过滤模块,预测结果没有车身点云
+
+    LOCATER_SIFT_FILTE_OBS_FAILED,						//定位过滤模块,过滤OBS失败
+    LOCATER_SIFT_INPUT_BOX_PARAMETER_FAILED,			//定位过滤模块,输入范围参数错误
+
+//    //yolo 
+//    LOCATER_YOLO_ERROR_BASE						=0x03020200,
+//    LOCATER_YOLO_DETECT_FAILED,
 //    LOCATER_YOLO_DETECT_NO_TARGET,
 //    LOCATER_YOLO_PARAMETER_INVALID,
 //    LOCATER_YOLO_INPUT_CLOUD_UNINIT,
 
     //3dcnn from 0x03010300-0x030103FF
-    LOCATER_3DCNN_INIT_FAILED=0x03010300,
-    LOCATER_3DCNN_INPUT_CLOUD_UNINIT,
-	LOCATER_3DCNN_INPUT_CLOUD_EMPTY,
-	LOCATER_3DCNN_INPUT_CLOUD_MAP_ERROR,
-	LOCATER_3DCNN_PCA_OUT_ERROR,
-	LOCATER_3DCNN_EXTRACT_RECT_ERROR,
-	LOCATER_3DCNN_RECT_SIZE_ERROR,
-
-    LOCATER_3DCNN_PREDICT_FAILED,
-    LOCATER_3DCNN_VERIFY_RECT_FAILED_3,
-    LOCATER_3DCNN_VERIFY_RECT_FAILED_4,
-    LOCATER_3DCNN_KMEANS_FAILED,
-    LOCATER_3DCNN_IIU_FAILED,
-    LOCATER_3DCNN_PCA_OUT_CLOUD_EMPTY,
+    LOCATER_3DCNN_ERROR_BASE						=0x03020300,
+    LOCATER_3DCNN_INIT_FAILED,							//定位3DCNN模块,初始化失败
+    LOCATER_3DCNN_INPUT_CLOUD_UNINIT,					//定位3DCNN模块,输入点云未初始化
+	LOCATER_3DCNN_INPUT_CLOUD_EMPTY,					//定位3DCNN模块,输入点云为空
+	LOCATER_3DCNN_INPUT_CLOUD_MAP_ERROR,				//定位3DCNN模块,输入点云的map错误
+	LOCATER_3DCNN_PCA_OUT_ERROR,						//定位3DCNN模块,pca错误
+	LOCATER_3DCNN_EXTRACT_RECT_ERROR,					//定位3DCNN模块,提取矩形错误
+	LOCATER_3DCNN_RECT_SIZE_ERROR,						//定位3DCNN模块,矩形范围错误
+
+    LOCATER_3DCNN_PREDICT_FAILED,						//定位3DCNN模块,预测失败
+    LOCATER_3DCNN_VERIFY_RECT_FAILED_3,					//定位3DCNN模块,验证矩形失败3
+    LOCATER_3DCNN_VERIFY_RECT_FAILED_4,					//定位3DCNN模块,验证矩形失败4
+    LOCATER_3DCNN_KMEANS_FAILED,						//定位3DCNN模块,k均值失败
+    LOCATER_3DCNN_IIU_FAILED,							//定位3DCNN模块,IIU失败
+    LOCATER_3DCNN_PCA_OUT_CLOUD_EMPTY,					//定位3DCNN模块,pca输出点云为空
 
     //System_manager error from 0x04010000-0x0401FFFF
     SYSTEM_READ_PARAMETER_ERROR=0x04010100,
@@ -329,6 +331,10 @@ enum Error_code
     LOCATER_MSG_REQUEST_INVALID,
     LOCATER_MSG_RESPONSE_HAS_NO_REQUEST,
 
+
+	//Dispatch 调度 模块 错误码
+	DISPATCH_ERROR_BASE								= 0x13000000,
+
 	//Dispatch_manager 调度管理模块 错误码
 	DISPATCH_MANAGER_ERROR_BASE						= 0x13010000,
 	DISPATCH_MANAGER_READ_PROTOBUF_ERROR,				//调度管理模块,读取参数错误
@@ -337,6 +343,20 @@ enum Error_code
 	DISPATCH_MANAGER_TASK_TYPE_ERROR,					//调度管理模块,任务类型错误
 	DISPATCH_MANAGER_IS_NOT_READY,						//调度管理模块,不在准备状态
 
+	CARRIER_ERROR_BASE								= 0x13020000,
+	CARRIER_READ_PROTOBUF_ERROR,				//搬运器模块,读取参数错误
+	CARRIER_STATUS_BUSY,						//搬运器模块,状态正忙
+	CARRIER_STATUS_ERROR,						//搬运器模块,状态错误
+	CARRIER_STATUS_DISCONNECT,					//搬运器模块,状态断连
+	CARRIER_TASK_TYPE_ERROR,					//搬运器模块,任务类型错误
+	CARRIER_TASK_OVER_TIME,						//搬运器模块,任务超时
+	CARRIER_IS_NOT_READY,						//搬运器模块,不在准备状态
+	CARRIER_RESPONS_ERROR,						//搬运器模块,指令的执行失败
+	CARRIER_TASK_NOTHINGNESS,					//搬运器模块,任务不存在
+
+
+
+
 	//snap7 通信模块 错误码
 	SNAP7_ERROR_BASE								= 0x1401000,
 	SNAP7_READ_PROTOBUF_ERROR,							//snap7通信模块,读取参数错误

+ 35 - 61
main.cpp

@@ -50,70 +50,10 @@ void myfunction (int i) {  // function:
 	std::cout << ' ' << i;
 }
 
+
 int main(int argc,char* argv[])
 {
 
-	TSnap7Client 					t_snap7_client;			//通信的客户端
-
-	int result=t_snap7_client.ConnectTo("192.168.2.110",0,1);
-	std::cout << " huli test :::: " << " result = " << result << std::endl;
-
-//	std::this_thread::sleep_for(std::chrono::seconds(1));
-
-	unsigned char t_read[20] = {0};
-	memset(t_read, 0, 20);
-	result = t_snap7_client.AsDBRead(120, 0, 1, t_read);
-	if ( result == 0 )
-	{
-		t_snap7_client.WaitAsCompletion(100);
-	}
-	std::cout << " huli test :::: " << " t_read = " << (int)t_read[0] << std::endl;
-	std::cout << " huli test :::: " << " AsDBRead result = " <<  result << std::endl;
-
-//	std::this_thread::sleep_for(std::chrono::seconds(1));
-
-	short f = -4;
-	unsigned char * p_asd = (unsigned char *)&f;
-
-//	unsigned char t_write[20] = {0};
-//	memset(t_write, 20, 20);
-//	t_write[0] = p_asd[3];
-//	t_write[1] = p_asd[2];
-//	t_write[2] = p_asd[1];
-//	t_write[3] = p_asd[0];
-
-//	t_write[0] = p_asd[1];
-//	t_write[1] = p_asd[0];
-
-	unsigned char t_write[20] = "鄂A123456";
-//	t_write[19] = 's';
-
-
-
-	result = t_snap7_client.AsDBWrite(120, 72, 20, t_write);
-	if ( result == 0 )
-	{
-		t_snap7_client.WaitAsCompletion(100);
-	}
-	std::cout << " huli test :::: " << " t_read = " << (int)t_write[0] << std::endl;
-	std::cout << " huli test :::: " << " AsDBRead result = " <<  result << std::endl;
-
-//	return 0;
-
-
-
-	char a=1;
-	typeof(a) b=2;
-
-	typeid(a).name();
-	std::cout << " huli test :::: " << " a = " << a << std::endl;
-	std::cout << " huli test :::: " << " typeid(a).name() = " << typeid(a).name() << std::endl;
-	std::cout << " huli test :::: " << " b = " << b << std::endl;
-	std::cout << " huli test :::: " << " typeid(b).name() = " << typeid(b).name() << std::endl;
-	std::cout << " huli test :::: " << " typeid(int).name() = " << typeid(int).name() << std::endl;
-
-
-	return 0;
 
 
 	const char* logPath = "./";
@@ -141,9 +81,43 @@ int main(int argc,char* argv[])
 	std::cout << " huli test :::: " << " t_error = " << t_error << std::endl;
 	std::cout << "Dispatch_communication = " << Dispatch_communication::get_instance_references().get_status() << std::endl;
 
+	Carrier_base t_carrier_base;
+	t_carrier_base.carrier_base_init();
+
+	std::shared_ptr<Carrier_task> tp_carrier_task(new Carrier_task);
+	tp_carrier_task->task_init(NULL,std::chrono::milliseconds(15000),
+	1,2,3,"asd",
+	0,10,20,30);
+
+
+	std::cout << " huli test :::: " << " tp_carrier_task->get_task_statu = " << tp_carrier_task->get_task_statu() << std::endl;
+	std::cout << " huli test :::: " << " tp_carrier_task->m_respons_status = " << tp_carrier_task->m_respons_status << std::endl;
+
+	std::cout << " huli test :::: " << " tp_carrier_task->m_respons_status = " << t_carrier_base.get_carrier_status() << std::endl;
+
+
+	std::cout << " ---------------------------------------------------" << std::endl;
+
+	t_error = t_carrier_base.execute_one_level_task(tp_carrier_task);
+	std::cout << " huli test :::: " << " t_error = " << t_error << std::endl;
+
+	while ( 1 )
+	{
+		std::cout << " huli test :::: " << " tp_carrier_task->get_task_statu = " << tp_carrier_task->get_task_statu() << std::endl;
+		std::cout << " huli test :::: " << " tp_carrier_task->m_respons_status = " << tp_carrier_task->m_respons_status << std::endl;
+
+		std::cout << " huli test :::: " << " t_carrier_base.get_carrier_status() = " << t_carrier_base.get_carrier_status() << std::endl;
+
+
+		std::cout << " ---------------------------------------------------" << std::endl;
+		std::this_thread::sleep_for(std::chrono::milliseconds(100));
+
+	}
+
 	char ch123 ;
 	std::cin >> ch123 ;
 
+
 	Dispatch_communication::get_instance_references().communication_uninit();
 	return 0;
 

+ 99 - 80
message/dispatch_message.pb.cc

@@ -121,6 +121,7 @@ void InitDefaultsDispatch_request_msgImpl() {
   ::google::protobuf::internal::InitProtobufDefaults();
 #endif  // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
   protobuf_message_5fbase_2eproto::InitDefaultsBase_info();
+  protobuf_message_5fbase_2eproto::InitDefaultsParkspace_info();
   protobuf_message_5fbase_2eproto::InitDefaultsLocate_information();
   {
     void* ptr = &::message::_Dispatch_request_msg_default_instance_;
@@ -214,14 +215,14 @@ const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_PROTOBUF_ATTRIBUT
   GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::message::Dispatch_request_msg, command_key_),
   GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::message::Dispatch_request_msg, dispatch_motion_direction_),
   GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::message::Dispatch_request_msg, terminal_id_),
-  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::message::Dispatch_request_msg, parkspace_id_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::message::Dispatch_request_msg, parkspace_info_),
   GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::message::Dispatch_request_msg, locate_information_),
   1,
   0,
-  3,
   4,
   5,
   2,
+  3,
   GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::message::Dispatch_response_msg, _has_bits_),
   GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::message::Dispatch_response_msg, _internal_metadata_),
   ~0u,  // no _extensions_
@@ -288,44 +289,45 @@ void AddDescriptorsImpl() {
       "2\022.message.Base_info\022\023\n\013terminal_id\030\002 \002("
       "\005\0221\n\017terminal_status\030\003 \002(\0162\030.message.Ter"
       "minal_status\022;\n\024passageway_direction\030\004 \002"
-      "(\0162\035.message.Passageway_direction\"\375\001\n\024Di"
+      "(\0162\035.message.Passageway_direction\"\230\002\n\024Di"
       "spatch_request_msg\022%\n\tbase_info\030\001 \002(\0132\022."
       "message.Base_info\022\023\n\013command_key\030\002 \002(\t\022E"
       "\n\031dispatch_motion_direction\030\003 \002(\0162\".mess"
       "age.Dispatch_motion_direction\022\023\n\013termina"
-      "l_id\030\004 \002(\005\022\024\n\014parkspace_id\030\005 \002(\005\0227\n\022loca"
-      "te_information\030\006 \001(\0132\033.message.Locate_in"
-      "formation\"\202\001\n\025Dispatch_response_msg\022%\n\tb"
-      "ase_info\030\001 \002(\0132\022.message.Base_info\022\023\n\013co"
-      "mmand_key\030\002 \002(\t\022-\n\rerror_manager\030\003 \002(\0132\026"
-      ".message.Error_manager*\261\001\n\027Dispatch_mana"
-      "ger_status\022\035\n\031E_DISPATCH_MANAGER_UNKNOW\020"
-      "\000\022\034\n\030E_DISPATCH_MANAGER_READY\020\001\022\034\n\030E_DIS"
-      "PATCH_MANAGER_STORE\020\002\022\035\n\031E_DISPATCH_MANA"
-      "GER_PICKUP\020\003\022\034\n\030E_DISPATCH_MANAGER_FAULT"
-      "\020\n*{\n\016Catcher_status\022\024\n\020E_CATCHER_UNKNOW"
-      "\020\000\022\023\n\017E_CATCHER_READY\020\001\022\023\n\017E_CATCHER_STO"
-      "RE\020\002\022\024\n\020E_CATCHER_PICKUP\020\003\022\023\n\017E_CATCHER_"
-      "FAULT\020\n*{\n\016Carrier_status\022\024\n\020E_CARRIER_U"
-      "NKNOW\020\000\022\023\n\017E_CARRIER_READY\020\001\022\023\n\017E_CARRIE"
-      "R_STORE\020\002\022\024\n\020E_CARRIER_PICKUP\020\003\022\023\n\017E_CAR"
-      "RIER_FAULT\020\n*\201\001\n\017Elevator_status\022\025\n\021E_EL"
-      "EVATOR_UNKNOW\020\000\022\024\n\020E_ELEVATOR_READY\020\001\022\024\n"
-      "\020E_ELEVATOR_STORE\020\002\022\025\n\021E_ELEVATOR_PICKUP"
-      "\020\003\022\024\n\020E_ELEVATOR_FAULT\020\n*\215\001\n\021Passageway_"
-      "status\022\027\n\023E_PASSAGEWAY_UNKNOW\020\000\022\026\n\022E_PAS"
-      "SAGEWAY_READY\020\001\022\026\n\022E_PASSAGEWAY_STORE\020\002\022"
-      "\027\n\023E_PASSAGEWAY_PICKUP\020\003\022\026\n\022E_PASSAGEWAY"
-      "_FAULT\020\n*\201\001\n\017Terminal_status\022\025\n\021E_TERMIN"
-      "AL_UNKNOW\020\000\022\024\n\020E_TERMINAL_READY\020\001\022\024\n\020E_T"
-      "ERMINAL_STORE\020\002\022\025\n\021E_TERMINAL_PICKUP\020\003\022\024"
-      "\n\020E_TERMINAL_FAULT\020\n*B\n\024Passageway_direc"
-      "tion\022\013\n\007E_INLET\020\000\022\014\n\010E_OUTLET\020\001\022\017\n\013E_BIL"
-      "ATERAL\020\002*>\n\031Dispatch_motion_direction\022\017\n"
-      "\013E_STORE_CAR\020\000\022\020\n\014E_PICKUP_CAR\020\001"
+      "l_id\030\004 \002(\005\022/\n\016parkspace_info\030\005 \002(\0132\027.mes"
+      "sage.Parkspace_info\0227\n\022locate_informatio"
+      "n\030\006 \001(\0132\033.message.Locate_information\"\202\001\n"
+      "\025Dispatch_response_msg\022%\n\tbase_info\030\001 \002("
+      "\0132\022.message.Base_info\022\023\n\013command_key\030\002 \002"
+      "(\t\022-\n\rerror_manager\030\003 \002(\0132\026.message.Erro"
+      "r_manager*\261\001\n\027Dispatch_manager_status\022\035\n"
+      "\031E_DISPATCH_MANAGER_UNKNOW\020\000\022\034\n\030E_DISPAT"
+      "CH_MANAGER_READY\020\001\022\034\n\030E_DISPATCH_MANAGER"
+      "_STORE\020\002\022\035\n\031E_DISPATCH_MANAGER_PICKUP\020\003\022"
+      "\034\n\030E_DISPATCH_MANAGER_FAULT\020\n*{\n\016Catcher"
+      "_status\022\024\n\020E_CATCHER_UNKNOW\020\000\022\023\n\017E_CATCH"
+      "ER_READY\020\001\022\023\n\017E_CATCHER_STORE\020\002\022\024\n\020E_CAT"
+      "CHER_PICKUP\020\003\022\023\n\017E_CATCHER_FAULT\020\n*{\n\016Ca"
+      "rrier_status\022\024\n\020E_CARRIER_UNKNOW\020\000\022\023\n\017E_"
+      "CARRIER_READY\020\001\022\023\n\017E_CARRIER_STORE\020\002\022\024\n\020"
+      "E_CARRIER_PICKUP\020\003\022\023\n\017E_CARRIER_FAULT\020\n*"
+      "\201\001\n\017Elevator_status\022\025\n\021E_ELEVATOR_UNKNOW"
+      "\020\000\022\024\n\020E_ELEVATOR_READY\020\001\022\024\n\020E_ELEVATOR_S"
+      "TORE\020\002\022\025\n\021E_ELEVATOR_PICKUP\020\003\022\024\n\020E_ELEVA"
+      "TOR_FAULT\020\n*\215\001\n\021Passageway_status\022\027\n\023E_P"
+      "ASSAGEWAY_UNKNOW\020\000\022\026\n\022E_PASSAGEWAY_READY"
+      "\020\001\022\026\n\022E_PASSAGEWAY_STORE\020\002\022\027\n\023E_PASSAGEW"
+      "AY_PICKUP\020\003\022\026\n\022E_PASSAGEWAY_FAULT\020\n*\201\001\n\017"
+      "Terminal_status\022\025\n\021E_TERMINAL_UNKNOW\020\000\022\024"
+      "\n\020E_TERMINAL_READY\020\001\022\024\n\020E_TERMINAL_STORE"
+      "\020\002\022\025\n\021E_TERMINAL_PICKUP\020\003\022\024\n\020E_TERMINAL_"
+      "FAULT\020\n*B\n\024Passageway_direction\022\013\n\007E_INL"
+      "ET\020\000\022\014\n\010E_OUTLET\020\001\022\017\n\013E_BILATERAL\020\002*>\n\031D"
+      "ispatch_motion_direction\022\017\n\013E_STORE_CAR\020"
+      "\000\022\020\n\014E_PICKUP_CAR\020\001"
   };
   ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
-      descriptor, 2032);
+      descriptor, 2059);
   ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
     "dispatch_message.proto", &protobuf_RegisterTypes);
   ::protobuf_message_5fbase_2eproto::AddDescriptors();
@@ -1845,6 +1847,8 @@ void Dispatch_terminal_status_msg::InternalSwap(Dispatch_terminal_status_msg* ot
 void Dispatch_request_msg::InitAsDefaultInstance() {
   ::message::_Dispatch_request_msg_default_instance_._instance.get_mutable()->base_info_ = const_cast< ::message::Base_info*>(
       ::message::Base_info::internal_default_instance());
+  ::message::_Dispatch_request_msg_default_instance_._instance.get_mutable()->parkspace_info_ = const_cast< ::message::Parkspace_info*>(
+      ::message::Parkspace_info::internal_default_instance());
   ::message::_Dispatch_request_msg_default_instance_._instance.get_mutable()->locate_information_ = const_cast< ::message::Locate_information*>(
       ::message::Locate_information::internal_default_instance());
 }
@@ -1852,6 +1856,10 @@ void Dispatch_request_msg::clear_base_info() {
   if (base_info_ != NULL) base_info_->Clear();
   clear_has_base_info();
 }
+void Dispatch_request_msg::clear_parkspace_info() {
+  if (parkspace_info_ != NULL) parkspace_info_->Clear();
+  clear_has_parkspace_info();
+}
 void Dispatch_request_msg::clear_locate_information() {
   if (locate_information_ != NULL) locate_information_->Clear();
   clear_has_locate_information();
@@ -1861,7 +1869,7 @@ const int Dispatch_request_msg::kBaseInfoFieldNumber;
 const int Dispatch_request_msg::kCommandKeyFieldNumber;
 const int Dispatch_request_msg::kDispatchMotionDirectionFieldNumber;
 const int Dispatch_request_msg::kTerminalIdFieldNumber;
-const int Dispatch_request_msg::kParkspaceIdFieldNumber;
+const int Dispatch_request_msg::kParkspaceInfoFieldNumber;
 const int Dispatch_request_msg::kLocateInformationFieldNumber;
 #endif  // !defined(_MSC_VER) || _MSC_VER >= 1900
 
@@ -1888,14 +1896,19 @@ Dispatch_request_msg::Dispatch_request_msg(const Dispatch_request_msg& from)
   } else {
     base_info_ = NULL;
   }
+  if (from.has_parkspace_info()) {
+    parkspace_info_ = new ::message::Parkspace_info(*from.parkspace_info_);
+  } else {
+    parkspace_info_ = NULL;
+  }
   if (from.has_locate_information()) {
     locate_information_ = new ::message::Locate_information(*from.locate_information_);
   } else {
     locate_information_ = NULL;
   }
   ::memcpy(&dispatch_motion_direction_, &from.dispatch_motion_direction_,
-    static_cast<size_t>(reinterpret_cast<char*>(&parkspace_id_) -
-    reinterpret_cast<char*>(&dispatch_motion_direction_)) + sizeof(parkspace_id_));
+    static_cast<size_t>(reinterpret_cast<char*>(&terminal_id_) -
+    reinterpret_cast<char*>(&dispatch_motion_direction_)) + sizeof(terminal_id_));
   // @@protoc_insertion_point(copy_constructor:message.Dispatch_request_msg)
 }
 
@@ -1903,8 +1916,8 @@ void Dispatch_request_msg::SharedCtor() {
   _cached_size_ = 0;
   command_key_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
   ::memset(&base_info_, 0, static_cast<size_t>(
-      reinterpret_cast<char*>(&parkspace_id_) -
-      reinterpret_cast<char*>(&base_info_)) + sizeof(parkspace_id_));
+      reinterpret_cast<char*>(&terminal_id_) -
+      reinterpret_cast<char*>(&base_info_)) + sizeof(terminal_id_));
 }
 
 Dispatch_request_msg::~Dispatch_request_msg() {
@@ -1915,6 +1928,7 @@ Dispatch_request_msg::~Dispatch_request_msg() {
 void Dispatch_request_msg::SharedDtor() {
   command_key_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
   if (this != internal_default_instance()) delete base_info_;
+  if (this != internal_default_instance()) delete parkspace_info_;
   if (this != internal_default_instance()) delete locate_information_;
 }
 
@@ -1948,7 +1962,7 @@ void Dispatch_request_msg::Clear() {
   (void) cached_has_bits;
 
   cached_has_bits = _has_bits_[0];
-  if (cached_has_bits & 7u) {
+  if (cached_has_bits & 15u) {
     if (cached_has_bits & 0x00000001u) {
       GOOGLE_DCHECK(!command_key_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
       (*command_key_.UnsafeRawStringPointer())->clear();
@@ -1958,14 +1972,18 @@ void Dispatch_request_msg::Clear() {
       base_info_->Clear();
     }
     if (cached_has_bits & 0x00000004u) {
+      GOOGLE_DCHECK(parkspace_info_ != NULL);
+      parkspace_info_->Clear();
+    }
+    if (cached_has_bits & 0x00000008u) {
       GOOGLE_DCHECK(locate_information_ != NULL);
       locate_information_->Clear();
     }
   }
-  if (cached_has_bits & 56u) {
+  if (cached_has_bits & 48u) {
     ::memset(&dispatch_motion_direction_, 0, static_cast<size_t>(
-        reinterpret_cast<char*>(&parkspace_id_) -
-        reinterpret_cast<char*>(&dispatch_motion_direction_)) + sizeof(parkspace_id_));
+        reinterpret_cast<char*>(&terminal_id_) -
+        reinterpret_cast<char*>(&dispatch_motion_direction_)) + sizeof(terminal_id_));
   }
   _has_bits_.Clear();
   _internal_metadata_.Clear();
@@ -2043,14 +2061,12 @@ bool Dispatch_request_msg::MergePartialFromCodedStream(
         break;
       }
 
-      // required int32 parkspace_id = 5;
+      // required .message.Parkspace_info parkspace_info = 5;
       case 5: {
         if (static_cast< ::google::protobuf::uint8>(tag) ==
-            static_cast< ::google::protobuf::uint8>(40u /* 40 & 0xFF */)) {
-          set_has_parkspace_id();
-          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
-                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
-                 input, &parkspace_id_)));
+            static_cast< ::google::protobuf::uint8>(42u /* 42 & 0xFF */)) {
+          DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
+               input, mutable_parkspace_info()));
         } else {
           goto handle_unusual;
         }
@@ -2113,23 +2129,24 @@ void Dispatch_request_msg::SerializeWithCachedSizes(
   }
 
   // required .message.Dispatch_motion_direction dispatch_motion_direction = 3;
-  if (cached_has_bits & 0x00000008u) {
+  if (cached_has_bits & 0x00000010u) {
     ::google::protobuf::internal::WireFormatLite::WriteEnum(
       3, this->dispatch_motion_direction(), output);
   }
 
   // required int32 terminal_id = 4;
-  if (cached_has_bits & 0x00000010u) {
+  if (cached_has_bits & 0x00000020u) {
     ::google::protobuf::internal::WireFormatLite::WriteInt32(4, this->terminal_id(), output);
   }
 
-  // required int32 parkspace_id = 5;
-  if (cached_has_bits & 0x00000020u) {
-    ::google::protobuf::internal::WireFormatLite::WriteInt32(5, this->parkspace_id(), output);
+  // required .message.Parkspace_info parkspace_info = 5;
+  if (cached_has_bits & 0x00000004u) {
+    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+      5, *this->parkspace_info_, output);
   }
 
   // optional .message.Locate_information locate_information = 6;
-  if (cached_has_bits & 0x00000004u) {
+  if (cached_has_bits & 0x00000008u) {
     ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
       6, *this->locate_information_, output);
   }
@@ -2168,23 +2185,25 @@ void Dispatch_request_msg::SerializeWithCachedSizes(
   }
 
   // required .message.Dispatch_motion_direction dispatch_motion_direction = 3;
-  if (cached_has_bits & 0x00000008u) {
+  if (cached_has_bits & 0x00000010u) {
     target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
       3, this->dispatch_motion_direction(), target);
   }
 
   // required int32 terminal_id = 4;
-  if (cached_has_bits & 0x00000010u) {
+  if (cached_has_bits & 0x00000020u) {
     target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(4, this->terminal_id(), target);
   }
 
-  // required int32 parkspace_id = 5;
-  if (cached_has_bits & 0x00000020u) {
-    target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(5, this->parkspace_id(), target);
+  // required .message.Parkspace_info parkspace_info = 5;
+  if (cached_has_bits & 0x00000004u) {
+    target = ::google::protobuf::internal::WireFormatLite::
+      InternalWriteMessageToArray(
+        5, *this->parkspace_info_, deterministic, target);
   }
 
   // optional .message.Locate_information locate_information = 6;
-  if (cached_has_bits & 0x00000004u) {
+  if (cached_has_bits & 0x00000008u) {
     target = ::google::protobuf::internal::WireFormatLite::
       InternalWriteMessageToArray(
         6, *this->locate_information_, deterministic, target);
@@ -2216,6 +2235,13 @@ size_t Dispatch_request_msg::RequiredFieldsByteSizeFallback() const {
         *this->base_info_);
   }
 
+  if (has_parkspace_info()) {
+    // required .message.Parkspace_info parkspace_info = 5;
+    total_size += 1 +
+      ::google::protobuf::internal::WireFormatLite::MessageSize(
+        *this->parkspace_info_);
+  }
+
   if (has_dispatch_motion_direction()) {
     // required .message.Dispatch_motion_direction dispatch_motion_direction = 3;
     total_size += 1 +
@@ -2229,13 +2255,6 @@ size_t Dispatch_request_msg::RequiredFieldsByteSizeFallback() const {
         this->terminal_id());
   }
 
-  if (has_parkspace_id()) {
-    // required int32 parkspace_id = 5;
-    total_size += 1 +
-      ::google::protobuf::internal::WireFormatLite::Int32Size(
-        this->parkspace_id());
-  }
-
   return total_size;
 }
 size_t Dispatch_request_msg::ByteSizeLong() const {
@@ -2247,7 +2266,7 @@ size_t Dispatch_request_msg::ByteSizeLong() const {
       ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
         _internal_metadata_.unknown_fields());
   }
-  if (((_has_bits_[0] & 0x0000003b) ^ 0x0000003b) == 0) {  // All required fields are present.
+  if (((_has_bits_[0] & 0x00000037) ^ 0x00000037) == 0) {  // All required fields are present.
     // required string command_key = 2;
     total_size += 1 +
       ::google::protobuf::internal::WireFormatLite::StringSize(
@@ -2258,6 +2277,11 @@ size_t Dispatch_request_msg::ByteSizeLong() const {
       ::google::protobuf::internal::WireFormatLite::MessageSize(
         *this->base_info_);
 
+    // required .message.Parkspace_info parkspace_info = 5;
+    total_size += 1 +
+      ::google::protobuf::internal::WireFormatLite::MessageSize(
+        *this->parkspace_info_);
+
     // required .message.Dispatch_motion_direction dispatch_motion_direction = 3;
     total_size += 1 +
       ::google::protobuf::internal::WireFormatLite::EnumSize(this->dispatch_motion_direction());
@@ -2267,11 +2291,6 @@ size_t Dispatch_request_msg::ByteSizeLong() const {
       ::google::protobuf::internal::WireFormatLite::Int32Size(
         this->terminal_id());
 
-    // required int32 parkspace_id = 5;
-    total_size += 1 +
-      ::google::protobuf::internal::WireFormatLite::Int32Size(
-        this->parkspace_id());
-
   } else {
     total_size += RequiredFieldsByteSizeFallback();
   }
@@ -2321,16 +2340,16 @@ void Dispatch_request_msg::MergeFrom(const Dispatch_request_msg& from) {
       mutable_base_info()->::message::Base_info::MergeFrom(from.base_info());
     }
     if (cached_has_bits & 0x00000004u) {
-      mutable_locate_information()->::message::Locate_information::MergeFrom(from.locate_information());
+      mutable_parkspace_info()->::message::Parkspace_info::MergeFrom(from.parkspace_info());
     }
     if (cached_has_bits & 0x00000008u) {
-      dispatch_motion_direction_ = from.dispatch_motion_direction_;
+      mutable_locate_information()->::message::Locate_information::MergeFrom(from.locate_information());
     }
     if (cached_has_bits & 0x00000010u) {
-      terminal_id_ = from.terminal_id_;
+      dispatch_motion_direction_ = from.dispatch_motion_direction_;
     }
     if (cached_has_bits & 0x00000020u) {
-      parkspace_id_ = from.parkspace_id_;
+      terminal_id_ = from.terminal_id_;
     }
     _has_bits_[0] |= cached_has_bits;
   }
@@ -2351,7 +2370,7 @@ void Dispatch_request_msg::CopyFrom(const Dispatch_request_msg& from) {
 }
 
 bool Dispatch_request_msg::IsInitialized() const {
-  if ((_has_bits_[0] & 0x0000003b) != 0x0000003b) return false;
+  if ((_has_bits_[0] & 0x00000037) != 0x00000037) return false;
   if (has_base_info()) {
     if (!this->base_info_->IsInitialized()) return false;
   }
@@ -2366,10 +2385,10 @@ void Dispatch_request_msg::InternalSwap(Dispatch_request_msg* other) {
   using std::swap;
   command_key_.Swap(&other->command_key_);
   swap(base_info_, other->base_info_);
+  swap(parkspace_info_, other->parkspace_info_);
   swap(locate_information_, other->locate_information_);
   swap(dispatch_motion_direction_, other->dispatch_motion_direction_);
   swap(terminal_id_, other->terminal_id_);
-  swap(parkspace_id_, other->parkspace_id_);
   swap(_has_bits_[0], other->_has_bits_[0]);
   _internal_metadata_.Swap(&other->_internal_metadata_);
   swap(_cached_size_, other->_cached_size_);

+ 64 - 36
message/dispatch_message.pb.h

@@ -824,6 +824,15 @@ class Dispatch_request_msg : public ::google::protobuf::Message /* @@protoc_inse
   ::message::Base_info* mutable_base_info();
   void set_allocated_base_info(::message::Base_info* base_info);
 
+  // required .message.Parkspace_info parkspace_info = 5;
+  bool has_parkspace_info() const;
+  void clear_parkspace_info();
+  static const int kParkspaceInfoFieldNumber = 5;
+  const ::message::Parkspace_info& parkspace_info() const;
+  ::message::Parkspace_info* release_parkspace_info();
+  ::message::Parkspace_info* mutable_parkspace_info();
+  void set_allocated_parkspace_info(::message::Parkspace_info* parkspace_info);
+
   // optional .message.Locate_information locate_information = 6;
   bool has_locate_information() const;
   void clear_locate_information();
@@ -847,13 +856,6 @@ class Dispatch_request_msg : public ::google::protobuf::Message /* @@protoc_inse
   ::google::protobuf::int32 terminal_id() const;
   void set_terminal_id(::google::protobuf::int32 value);
 
-  // required int32 parkspace_id = 5;
-  bool has_parkspace_id() const;
-  void clear_parkspace_id();
-  static const int kParkspaceIdFieldNumber = 5;
-  ::google::protobuf::int32 parkspace_id() const;
-  void set_parkspace_id(::google::protobuf::int32 value);
-
   // @@protoc_insertion_point(class_scope:message.Dispatch_request_msg)
  private:
   void set_has_base_info();
@@ -864,8 +866,8 @@ class Dispatch_request_msg : public ::google::protobuf::Message /* @@protoc_inse
   void clear_has_dispatch_motion_direction();
   void set_has_terminal_id();
   void clear_has_terminal_id();
-  void set_has_parkspace_id();
-  void clear_has_parkspace_id();
+  void set_has_parkspace_info();
+  void clear_has_parkspace_info();
   void set_has_locate_information();
   void clear_has_locate_information();
 
@@ -877,10 +879,10 @@ class Dispatch_request_msg : public ::google::protobuf::Message /* @@protoc_inse
   mutable int _cached_size_;
   ::google::protobuf::internal::ArenaStringPtr command_key_;
   ::message::Base_info* base_info_;
+  ::message::Parkspace_info* parkspace_info_;
   ::message::Locate_information* locate_information_;
   int dispatch_motion_direction_;
   ::google::protobuf::int32 terminal_id_;
-  ::google::protobuf::int32 parkspace_id_;
   friend struct ::protobuf_dispatch_5fmessage_2eproto::TableStruct;
   friend void ::protobuf_dispatch_5fmessage_2eproto::InitDefaultsDispatch_request_msgImpl();
 };
@@ -1590,13 +1592,13 @@ inline void Dispatch_request_msg::set_allocated_command_key(::std::string* comma
 
 // required .message.Dispatch_motion_direction dispatch_motion_direction = 3;
 inline bool Dispatch_request_msg::has_dispatch_motion_direction() const {
-  return (_has_bits_[0] & 0x00000008u) != 0;
+  return (_has_bits_[0] & 0x00000010u) != 0;
 }
 inline void Dispatch_request_msg::set_has_dispatch_motion_direction() {
-  _has_bits_[0] |= 0x00000008u;
+  _has_bits_[0] |= 0x00000010u;
 }
 inline void Dispatch_request_msg::clear_has_dispatch_motion_direction() {
-  _has_bits_[0] &= ~0x00000008u;
+  _has_bits_[0] &= ~0x00000010u;
 }
 inline void Dispatch_request_msg::clear_dispatch_motion_direction() {
   dispatch_motion_direction_ = 0;
@@ -1615,13 +1617,13 @@ inline void Dispatch_request_msg::set_dispatch_motion_direction(::message::Dispa
 
 // required int32 terminal_id = 4;
 inline bool Dispatch_request_msg::has_terminal_id() const {
-  return (_has_bits_[0] & 0x00000010u) != 0;
+  return (_has_bits_[0] & 0x00000020u) != 0;
 }
 inline void Dispatch_request_msg::set_has_terminal_id() {
-  _has_bits_[0] |= 0x00000010u;
+  _has_bits_[0] |= 0x00000020u;
 }
 inline void Dispatch_request_msg::clear_has_terminal_id() {
-  _has_bits_[0] &= ~0x00000010u;
+  _has_bits_[0] &= ~0x00000020u;
 }
 inline void Dispatch_request_msg::clear_terminal_id() {
   terminal_id_ = 0;
@@ -1637,39 +1639,65 @@ inline void Dispatch_request_msg::set_terminal_id(::google::protobuf::int32 valu
   // @@protoc_insertion_point(field_set:message.Dispatch_request_msg.terminal_id)
 }
 
-// required int32 parkspace_id = 5;
-inline bool Dispatch_request_msg::has_parkspace_id() const {
-  return (_has_bits_[0] & 0x00000020u) != 0;
+// required .message.Parkspace_info parkspace_info = 5;
+inline bool Dispatch_request_msg::has_parkspace_info() const {
+  return (_has_bits_[0] & 0x00000004u) != 0;
 }
-inline void Dispatch_request_msg::set_has_parkspace_id() {
-  _has_bits_[0] |= 0x00000020u;
+inline void Dispatch_request_msg::set_has_parkspace_info() {
+  _has_bits_[0] |= 0x00000004u;
 }
-inline void Dispatch_request_msg::clear_has_parkspace_id() {
-  _has_bits_[0] &= ~0x00000020u;
+inline void Dispatch_request_msg::clear_has_parkspace_info() {
+  _has_bits_[0] &= ~0x00000004u;
 }
-inline void Dispatch_request_msg::clear_parkspace_id() {
-  parkspace_id_ = 0;
-  clear_has_parkspace_id();
+inline const ::message::Parkspace_info& Dispatch_request_msg::parkspace_info() const {
+  const ::message::Parkspace_info* p = parkspace_info_;
+  // @@protoc_insertion_point(field_get:message.Dispatch_request_msg.parkspace_info)
+  return p != NULL ? *p : *reinterpret_cast<const ::message::Parkspace_info*>(
+      &::message::_Parkspace_info_default_instance_);
+}
+inline ::message::Parkspace_info* Dispatch_request_msg::release_parkspace_info() {
+  // @@protoc_insertion_point(field_release:message.Dispatch_request_msg.parkspace_info)
+  clear_has_parkspace_info();
+  ::message::Parkspace_info* temp = parkspace_info_;
+  parkspace_info_ = NULL;
+  return temp;
 }
-inline ::google::protobuf::int32 Dispatch_request_msg::parkspace_id() const {
-  // @@protoc_insertion_point(field_get:message.Dispatch_request_msg.parkspace_id)
-  return parkspace_id_;
+inline ::message::Parkspace_info* Dispatch_request_msg::mutable_parkspace_info() {
+  set_has_parkspace_info();
+  if (parkspace_info_ == NULL) {
+    parkspace_info_ = new ::message::Parkspace_info;
+  }
+  // @@protoc_insertion_point(field_mutable:message.Dispatch_request_msg.parkspace_info)
+  return parkspace_info_;
 }
-inline void Dispatch_request_msg::set_parkspace_id(::google::protobuf::int32 value) {
-  set_has_parkspace_id();
-  parkspace_id_ = value;
-  // @@protoc_insertion_point(field_set:message.Dispatch_request_msg.parkspace_id)
+inline void Dispatch_request_msg::set_allocated_parkspace_info(::message::Parkspace_info* parkspace_info) {
+  ::google::protobuf::Arena* message_arena = GetArenaNoVirtual();
+  if (message_arena == NULL) {
+    delete reinterpret_cast< ::google::protobuf::MessageLite*>(parkspace_info_);
+  }
+  if (parkspace_info) {
+    ::google::protobuf::Arena* submessage_arena = NULL;
+    if (message_arena != submessage_arena) {
+      parkspace_info = ::google::protobuf::internal::GetOwnedMessage(
+          message_arena, parkspace_info, submessage_arena);
+    }
+    set_has_parkspace_info();
+  } else {
+    clear_has_parkspace_info();
+  }
+  parkspace_info_ = parkspace_info;
+  // @@protoc_insertion_point(field_set_allocated:message.Dispatch_request_msg.parkspace_info)
 }
 
 // optional .message.Locate_information locate_information = 6;
 inline bool Dispatch_request_msg::has_locate_information() const {
-  return (_has_bits_[0] & 0x00000004u) != 0;
+  return (_has_bits_[0] & 0x00000008u) != 0;
 }
 inline void Dispatch_request_msg::set_has_locate_information() {
-  _has_bits_[0] |= 0x00000004u;
+  _has_bits_[0] |= 0x00000008u;
 }
 inline void Dispatch_request_msg::clear_has_locate_information() {
-  _has_bits_[0] &= ~0x00000004u;
+  _has_bits_[0] &= ~0x00000008u;
 }
 inline const ::message::Locate_information& Dispatch_request_msg::locate_information() const {
   const ::message::Locate_information* p = locate_information_;

+ 1 - 1
message/dispatch_message.proto

@@ -122,7 +122,7 @@ message Dispatch_request_msg
 
     required Dispatch_motion_direction  dispatch_motion_direction=3;            //调度方向, 停车取车
     required int32                      terminal_id=4;                          //终端id, 出入口
-    required int32                      parkspace_id=5;                         //车位编号, 停车位
+    required Parkspace_info             parkspace_info=5;                         //车位编号, 停车位
     optional Locate_information         locate_information=6;                   //汽车测量信息, 只有停车时有数据, 取车时没有数据.
 }
 

+ 99 - 60
message/message_base.pb.cc

@@ -269,9 +269,10 @@ const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_PROTOBUF_ATTRIBUT
   GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::message::Parkspace_info, car_info_),
   GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::message::Parkspace_info, entry_time_),
   GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::message::Parkspace_info, leave_time_),
+  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::message::Parkspace_info, block_id_),
   3,
   4,
-  10,
+  11,
   5,
   6,
   7,
@@ -280,6 +281,7 @@ const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_PROTOBUF_ATTRIBUT
   2,
   0,
   1,
+  10,
 };
 static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
   { 0, 9, sizeof(::message::Base_info)},
@@ -287,7 +289,7 @@ static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROT
   { 20, 28, sizeof(::message::Error_manager)},
   { 31, 46, sizeof(::message::Locate_information)},
   { 56, 65, sizeof(::message::Car_info)},
-  { 69, 85, sizeof(::message::Parkspace_info)},
+  { 69, 86, sizeof(::message::Parkspace_info)},
 };
 
 static ::google::protobuf::Message const * const file_default_instances[] = {
@@ -338,63 +340,64 @@ void AddDescriptorsImpl() {
       "rect\030\t \001(\010\022\032\n\022locate_front_theta\030\n \001(\002\"V"
       "\n\010Car_info\022\022\n\ncar_length\030\001 \001(\002\022\021\n\tcar_wi"
       "dth\030\002 \001(\002\022\022\n\ncar_height\030\003 \001(\002\022\017\n\007license"
-      "\030\004 \001(\t\"\234\002\n\016Parkspace_info\022\024\n\014parkspace_i"
+      "\030\004 \001(\t\"\256\002\n\016Parkspace_info\022\024\n\014parkspace_i"
       "d\030\001 \001(\005\022\r\n\005index\030\002 \001(\005\022%\n\tdirection\030\003 \001("
       "\0162\022.message.Direction\022\r\n\005floor\030\004 \001(\005\022\016\n\006"
       "length\030\005 \001(\002\022\r\n\005width\030\006 \001(\002\022\016\n\006height\030\007 "
       "\001(\002\0223\n\020parkspace_status\030\010 \001(\0162\031.message."
       "Parkspace_status\022#\n\010car_info\030\t \001(\0132\021.mes"
       "sage.Car_info\022\022\n\nentry_time\030\n \001(\t\022\022\n\nlea"
-      "ve_time\030\013 \001(\t*\350\007\n\014Message_type\022\r\n\teBase_"
-      "msg\020\000\022\020\n\014eCommand_msg\020\001\022\026\n\022eLocate_statu"
-      "s_msg\020\021\022\027\n\023eLocate_request_msg\020\022\022\030\n\024eLoc"
-      "ate_response_msg\020\023\022\034\n\030eLocate_sift_reque"
-      "st_msg\020\024\022\035\n\031eLocate_sift_response_msg\020\025\022"
-      "\030\n\024eDispatch_status_msg\020!\022\031\n\025eDispatch_r"
-      "equest_msg\020\"\022\032\n\026eDispatch_response_msg\020#"
-      "\022$\n eParkspace_allocation_status_msg\0201\022%"
-      "\n!eParkspace_allocation_request_msg\0202\022&\n"
-      "\"eParkspace_allocation_response_msg\0203\022!\n"
-      "\035eParkspace_search_request_msg\0204\022\"\n\036ePar"
-      "kspace_search_response_msg\0205\022\"\n\036eParkspa"
-      "ce_release_request_msg\0206\022#\n\037eParkspace_r"
-      "elease_response_msg\0207\022\'\n#eParkspace_forc"
-      "e_update_request_msg\0208\022(\n$eParkspace_for"
-      "ce_update_response_msg\0209\022(\n$eParkspace_c"
-      "onfirm_alloc_request_msg\020:\022)\n%eParkspace"
-      "_confirm_alloc_response_msg\020;\022\036\n\032eStore_"
-      "command_request_msg\020A\022\037\n\033eStore_command_"
-      "response_msg\020B\022\037\n\033ePickup_command_reques"
-      "t_msg\020C\022 \n\034ePickup_command_response_msg\020"
-      "D\022\037\n\032eStoring_process_statu_msg\020\220\001\022\037\n\032eP"
-      "icking_process_statu_msg\020\221\001\022\"\n\035eCentral_"
-      "controller_statu_msg\020\240\001\022#\n\036eEntrance_man"
-      "ual_operation_msg\020\260\001\022\"\n\035eProcess_manual_"
-      "operation_msg\020\261\001*\202\001\n\014Communicator\022\n\n\006eEm"
-      "pty\020\000\022\t\n\005eMain\020\001\022\016\n\teTerminor\020\200\002\022\017\n\nePar"
-      "kspace\020\200\004\022\016\n\teMeasurer\020\200\006\022\032\n\025eMeasurer_s"
-      "ift_server\020\201\006\022\016\n\teDispatch\020\200\010**\n\014Process"
-      "_type\022\014\n\010eStoring\020\001\022\014\n\010ePicking\020\002*e\n\013Err"
-      "or_level\022\n\n\006NORMAL\020\000\022\024\n\020NEGLIGIBLE_ERROR"
-      "\020\001\022\017\n\013MINOR_ERROR\020\002\022\017\n\013MAJOR_ERROR\020\003\022\022\n\016"
-      "CRITICAL_ERROR\020\004*q\n\020Parkspace_status\022\024\n\020"
-      "eParkspace_empty\020\000\022\027\n\023eParkspace_occupie"
-      "d\020\001\022\030\n\024eParkspace_reserverd\020\002\022\024\n\020eParksp"
-      "ace_error\020\003*(\n\tDirection\022\014\n\010eForward\020\001\022\r"
-      "\n\teBackward\020\002*\335\002\n\tStep_type\022\017\n\013eAlloc_st"
-      "ep\020\000\022\021\n\reMeasure_step\020\001\022\021\n\reCompare_step"
-      "\020\002\022\022\n\016eDispatch_step\020\003\022\021\n\reConfirm_step\020"
-      "\004\022\020\n\014eSearch_step\020\005\022\016\n\neWait_step\020\006\022\021\n\re"
-      "Release_step\020\007\022\r\n\teComplete\020\010\022\025\n\021eBackCo"
-      "nfirm_step\020\t\022\026\n\022eBack_compare_step\020\n\022\025\n\021"
-      "eBackMeasure_step\020\013\022\023\n\017eBackAlloc_step\020\014"
-      "\022\022\n\016eBackWait_step\020\r\022\026\n\022eBackDispatch_st"
-      "ep\020\016\022\024\n\020eBackSearch_step\020\017\022\021\n\reBackCompl"
-      "ete\020\020*C\n\nStep_statu\022\014\n\010eWaiting\020\000\022\014\n\010eWo"
-      "rking\020\001\022\n\n\006eError\020\002\022\r\n\teFinished\020\003"
+      "ve_time\030\013 \001(\t\022\020\n\010block_id\030\014 \001(\005*\350\007\n\014Mess"
+      "age_type\022\r\n\teBase_msg\020\000\022\020\n\014eCommand_msg\020"
+      "\001\022\026\n\022eLocate_status_msg\020\021\022\027\n\023eLocate_req"
+      "uest_msg\020\022\022\030\n\024eLocate_response_msg\020\023\022\034\n\030"
+      "eLocate_sift_request_msg\020\024\022\035\n\031eLocate_si"
+      "ft_response_msg\020\025\022\030\n\024eDispatch_status_ms"
+      "g\020!\022\031\n\025eDispatch_request_msg\020\"\022\032\n\026eDispa"
+      "tch_response_msg\020#\022$\n eParkspace_allocat"
+      "ion_status_msg\0201\022%\n!eParkspace_allocatio"
+      "n_request_msg\0202\022&\n\"eParkspace_allocation"
+      "_response_msg\0203\022!\n\035eParkspace_search_req"
+      "uest_msg\0204\022\"\n\036eParkspace_search_response"
+      "_msg\0205\022\"\n\036eParkspace_release_request_msg"
+      "\0206\022#\n\037eParkspace_release_response_msg\0207\022"
+      "\'\n#eParkspace_force_update_request_msg\0208"
+      "\022(\n$eParkspace_force_update_response_msg"
+      "\0209\022(\n$eParkspace_confirm_alloc_request_m"
+      "sg\020:\022)\n%eParkspace_confirm_alloc_respons"
+      "e_msg\020;\022\036\n\032eStore_command_request_msg\020A\022"
+      "\037\n\033eStore_command_response_msg\020B\022\037\n\033ePic"
+      "kup_command_request_msg\020C\022 \n\034ePickup_com"
+      "mand_response_msg\020D\022\037\n\032eStoring_process_"
+      "statu_msg\020\220\001\022\037\n\032ePicking_process_statu_m"
+      "sg\020\221\001\022\"\n\035eCentral_controller_statu_msg\020\240"
+      "\001\022#\n\036eEntrance_manual_operation_msg\020\260\001\022\""
+      "\n\035eProcess_manual_operation_msg\020\261\001*\202\001\n\014C"
+      "ommunicator\022\n\n\006eEmpty\020\000\022\t\n\005eMain\020\001\022\016\n\teT"
+      "erminor\020\200\002\022\017\n\neParkspace\020\200\004\022\016\n\teMeasurer"
+      "\020\200\006\022\032\n\025eMeasurer_sift_server\020\201\006\022\016\n\teDisp"
+      "atch\020\200\010**\n\014Process_type\022\014\n\010eStoring\020\001\022\014\n"
+      "\010ePicking\020\002*e\n\013Error_level\022\n\n\006NORMAL\020\000\022\024"
+      "\n\020NEGLIGIBLE_ERROR\020\001\022\017\n\013MINOR_ERROR\020\002\022\017\n"
+      "\013MAJOR_ERROR\020\003\022\022\n\016CRITICAL_ERROR\020\004*q\n\020Pa"
+      "rkspace_status\022\024\n\020eParkspace_empty\020\000\022\027\n\023"
+      "eParkspace_occupied\020\001\022\030\n\024eParkspace_rese"
+      "rverd\020\002\022\024\n\020eParkspace_error\020\003*(\n\tDirecti"
+      "on\022\014\n\010eForward\020\001\022\r\n\teBackward\020\002*\335\002\n\tStep"
+      "_type\022\017\n\013eAlloc_step\020\000\022\021\n\reMeasure_step\020"
+      "\001\022\021\n\reCompare_step\020\002\022\022\n\016eDispatch_step\020\003"
+      "\022\021\n\reConfirm_step\020\004\022\020\n\014eSearch_step\020\005\022\016\n"
+      "\neWait_step\020\006\022\021\n\reRelease_step\020\007\022\r\n\teCom"
+      "plete\020\010\022\025\n\021eBackConfirm_step\020\t\022\026\n\022eBack_"
+      "compare_step\020\n\022\025\n\021eBackMeasure_step\020\013\022\023\n"
+      "\017eBackAlloc_step\020\014\022\022\n\016eBackWait_step\020\r\022\026"
+      "\n\022eBackDispatch_step\020\016\022\024\n\020eBackSearch_st"
+      "ep\020\017\022\021\n\reBackComplete\020\020*C\n\nStep_statu\022\014\n"
+      "\010eWaiting\020\000\022\014\n\010eWorking\020\001\022\n\n\006eError\020\002\022\r\n"
+      "\teFinished\020\003"
   };
   ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
-      descriptor, 2834);
+      descriptor, 2852);
   ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
     "message_base.proto", &protobuf_RegisterTypes);
 }
@@ -2578,6 +2581,7 @@ const int Parkspace_info::kParkspaceStatusFieldNumber;
 const int Parkspace_info::kCarInfoFieldNumber;
 const int Parkspace_info::kEntryTimeFieldNumber;
 const int Parkspace_info::kLeaveTimeFieldNumber;
+const int Parkspace_info::kBlockIdFieldNumber;
 #endif  // !defined(_MSC_VER) || _MSC_VER >= 1900
 
 Parkspace_info::Parkspace_info()
@@ -2618,8 +2622,8 @@ void Parkspace_info::SharedCtor() {
   entry_time_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
   leave_time_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
   ::memset(&car_info_, 0, static_cast<size_t>(
-      reinterpret_cast<char*>(&parkspace_status_) -
-      reinterpret_cast<char*>(&car_info_)) + sizeof(parkspace_status_));
+      reinterpret_cast<char*>(&block_id_) -
+      reinterpret_cast<char*>(&car_info_)) + sizeof(block_id_));
   direction_ = 1;
 }
 
@@ -2683,10 +2687,10 @@ void Parkspace_info::Clear() {
         reinterpret_cast<char*>(&width_) -
         reinterpret_cast<char*>(&parkspace_id_)) + sizeof(width_));
   }
-  if (cached_has_bits & 1792u) {
+  if (cached_has_bits & 3840u) {
     ::memset(&height_, 0, static_cast<size_t>(
-        reinterpret_cast<char*>(&parkspace_status_) -
-        reinterpret_cast<char*>(&height_)) + sizeof(parkspace_status_));
+        reinterpret_cast<char*>(&block_id_) -
+        reinterpret_cast<char*>(&height_)) + sizeof(block_id_));
     direction_ = 1;
   }
   _has_bits_.Clear();
@@ -2871,6 +2875,20 @@ bool Parkspace_info::MergePartialFromCodedStream(
         break;
       }
 
+      // optional int32 block_id = 12;
+      case 12: {
+        if (static_cast< ::google::protobuf::uint8>(tag) ==
+            static_cast< ::google::protobuf::uint8>(96u /* 96 & 0xFF */)) {
+          set_has_block_id();
+          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+                 input, &block_id_)));
+        } else {
+          goto handle_unusual;
+        }
+        break;
+      }
+
       default: {
       handle_unusual:
         if (tag == 0) {
@@ -2909,7 +2927,7 @@ void Parkspace_info::SerializeWithCachedSizes(
   }
 
   // optional .message.Direction direction = 3;
-  if (cached_has_bits & 0x00000400u) {
+  if (cached_has_bits & 0x00000800u) {
     ::google::protobuf::internal::WireFormatLite::WriteEnum(
       3, this->direction(), output);
   }
@@ -2966,6 +2984,11 @@ void Parkspace_info::SerializeWithCachedSizes(
       11, this->leave_time(), output);
   }
 
+  // optional int32 block_id = 12;
+  if (cached_has_bits & 0x00000400u) {
+    ::google::protobuf::internal::WireFormatLite::WriteInt32(12, this->block_id(), output);
+  }
+
   if (_internal_metadata_.have_unknown_fields()) {
     ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
         _internal_metadata_.unknown_fields(), output);
@@ -2992,7 +3015,7 @@ void Parkspace_info::SerializeWithCachedSizes(
   }
 
   // optional .message.Direction direction = 3;
-  if (cached_has_bits & 0x00000400u) {
+  if (cached_has_bits & 0x00000800u) {
     target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
       3, this->direction(), target);
   }
@@ -3052,6 +3075,11 @@ void Parkspace_info::SerializeWithCachedSizes(
         11, this->leave_time(), target);
   }
 
+  // optional int32 block_id = 12;
+  if (cached_has_bits & 0x00000400u) {
+    target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(12, this->block_id(), target);
+  }
+
   if (_internal_metadata_.have_unknown_fields()) {
     target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
         _internal_metadata_.unknown_fields(), target);
@@ -3123,7 +3151,7 @@ size_t Parkspace_info::ByteSizeLong() const {
     }
 
   }
-  if (_has_bits_[8 / 32] & 1792u) {
+  if (_has_bits_[8 / 32] & 3840u) {
     // optional float height = 7;
     if (has_height()) {
       total_size += 1 + 4;
@@ -3135,6 +3163,13 @@ size_t Parkspace_info::ByteSizeLong() const {
         ::google::protobuf::internal::WireFormatLite::EnumSize(this->parkspace_status());
     }
 
+    // optional int32 block_id = 12;
+    if (has_block_id()) {
+      total_size += 1 +
+        ::google::protobuf::internal::WireFormatLite::Int32Size(
+          this->block_id());
+    }
+
     // optional .message.Direction direction = 3;
     if (has_direction()) {
       total_size += 1 +
@@ -3201,7 +3236,7 @@ void Parkspace_info::MergeFrom(const Parkspace_info& from) {
     }
     _has_bits_[0] |= cached_has_bits;
   }
-  if (cached_has_bits & 1792u) {
+  if (cached_has_bits & 3840u) {
     if (cached_has_bits & 0x00000100u) {
       height_ = from.height_;
     }
@@ -3209,6 +3244,9 @@ void Parkspace_info::MergeFrom(const Parkspace_info& from) {
       parkspace_status_ = from.parkspace_status_;
     }
     if (cached_has_bits & 0x00000400u) {
+      block_id_ = from.block_id_;
+    }
+    if (cached_has_bits & 0x00000800u) {
       direction_ = from.direction_;
     }
     _has_bits_[0] |= cached_has_bits;
@@ -3249,6 +3287,7 @@ void Parkspace_info::InternalSwap(Parkspace_info* other) {
   swap(width_, other->width_);
   swap(height_, other->height_);
   swap(parkspace_status_, other->parkspace_status_);
+  swap(block_id_, other->block_id_);
   swap(direction_, other->direction_);
   swap(_has_bits_[0], other->_has_bits_[0]);
   _internal_metadata_.Swap(&other->_internal_metadata_);

+ 37 - 3
message/message_base.pb.h

@@ -1213,6 +1213,13 @@ class Parkspace_info : public ::google::protobuf::Message /* @@protoc_insertion_
   ::message::Parkspace_status parkspace_status() const;
   void set_parkspace_status(::message::Parkspace_status value);
 
+  // optional int32 block_id = 12;
+  bool has_block_id() const;
+  void clear_block_id();
+  static const int kBlockIdFieldNumber = 12;
+  ::google::protobuf::int32 block_id() const;
+  void set_block_id(::google::protobuf::int32 value);
+
   // optional .message.Direction direction = 3;
   bool has_direction() const;
   void clear_direction();
@@ -1244,6 +1251,8 @@ class Parkspace_info : public ::google::protobuf::Message /* @@protoc_insertion_
   void clear_has_entry_time();
   void set_has_leave_time();
   void clear_has_leave_time();
+  void set_has_block_id();
+  void clear_has_block_id();
 
   ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
   ::google::protobuf::internal::HasBits<1> _has_bits_;
@@ -1258,6 +1267,7 @@ class Parkspace_info : public ::google::protobuf::Message /* @@protoc_insertion_
   float width_;
   float height_;
   int parkspace_status_;
+  ::google::protobuf::int32 block_id_;
   int direction_;
   friend struct ::protobuf_message_5fbase_2eproto::TableStruct;
   friend void ::protobuf_message_5fbase_2eproto::InitDefaultsParkspace_infoImpl();
@@ -1983,13 +1993,13 @@ inline void Parkspace_info::set_index(::google::protobuf::int32 value) {
 
 // optional .message.Direction direction = 3;
 inline bool Parkspace_info::has_direction() const {
-  return (_has_bits_[0] & 0x00000400u) != 0;
+  return (_has_bits_[0] & 0x00000800u) != 0;
 }
 inline void Parkspace_info::set_has_direction() {
-  _has_bits_[0] |= 0x00000400u;
+  _has_bits_[0] |= 0x00000800u;
 }
 inline void Parkspace_info::clear_has_direction() {
-  _has_bits_[0] &= ~0x00000400u;
+  _has_bits_[0] &= ~0x00000800u;
 }
 inline void Parkspace_info::clear_direction() {
   direction_ = 1;
@@ -2307,6 +2317,30 @@ inline void Parkspace_info::set_allocated_leave_time(::std::string* leave_time)
   // @@protoc_insertion_point(field_set_allocated:message.Parkspace_info.leave_time)
 }
 
+// optional int32 block_id = 12;
+inline bool Parkspace_info::has_block_id() const {
+  return (_has_bits_[0] & 0x00000400u) != 0;
+}
+inline void Parkspace_info::set_has_block_id() {
+  _has_bits_[0] |= 0x00000400u;
+}
+inline void Parkspace_info::clear_has_block_id() {
+  _has_bits_[0] &= ~0x00000400u;
+}
+inline void Parkspace_info::clear_block_id() {
+  block_id_ = 0;
+  clear_has_block_id();
+}
+inline ::google::protobuf::int32 Parkspace_info::block_id() const {
+  // @@protoc_insertion_point(field_get:message.Parkspace_info.block_id)
+  return block_id_;
+}
+inline void Parkspace_info::set_block_id(::google::protobuf::int32 value) {
+  set_has_block_id();
+  block_id_ = value;
+  // @@protoc_insertion_point(field_set:message.Parkspace_info.block_id)
+}
+
 #ifdef __GNUC__
   #pragma GCC diagnostic pop
 #endif  // __GNUC__

+ 1 - 0
message/message_base.proto

@@ -169,6 +169,7 @@ message Parkspace_info
     optional Car_info           car_info=9;              //当前车位存入车辆的凭证号
     optional string             entry_time=10;          //入场时间
     optional string             leave_time=11;          //离场时间
+    optional int32              block_id=12;            //区块编号
 }
 
 /*

+ 5 - 1
setting/communication.prototxt

@@ -19,10 +19,14 @@ communication_parameters
 
 
   # connect_string_vector:"tcp://192.168.2.183:30002"
-   connect_string_vector:"tcp://192.168.2.125:7001"
+
 
 
 #   connect_string_vector:"tcp://192.168.2.233:2333"
 
+#connect_string_vector:"tcp://192.168.2.125:7001"
+
+#connect_string_vector:"tcp://192.168.2.179:30000"
+connect_string_vector:"tcp://192.168.2.183:30000"
 }
 

+ 42 - 2
snap7_communication/snap7_buf.cpp

@@ -59,7 +59,8 @@ Snap7_buf::~Snap7_buf()
 	}
 }
 
-Snap7_buf::Snap7_buf(int id, int start_index, int size, Communication_mode communication_mode)
+Snap7_buf::Snap7_buf(int id, int start_index, int size,
+					 std::vector<Snap7_buf::Variable_information>& variable_information_vector,Communication_mode communication_mode)
 {
 	m_id = id;
 	m_start_index = start_index;
@@ -72,9 +73,11 @@ Snap7_buf::Snap7_buf(int id, int start_index, int size, Communication_mode commu
 		mp_buf_reverse = (void*)malloc(size);
 		memset(mp_buf_reverse, 0, size);
 		m_size = size;
+		m_variable_information_vector=variable_information_vector;
 	}
 }
-Snap7_buf::Snap7_buf(int id, int start_index, int size, void* p_buf_obverse, void* p_buf_reverse, Communication_mode communication_mode)
+Snap7_buf::Snap7_buf(int id, int start_index, int size, void* p_buf_obverse, void* p_buf_reverse,
+					 std::vector<Snap7_buf::Variable_information>& variable_information_vector, Communication_mode communication_mode)
 {
 	m_id = id;
 	m_start_index = start_index;
@@ -87,6 +90,43 @@ Snap7_buf::Snap7_buf(int id, int start_index, int size, void* p_buf_obverse, voi
 		mp_buf_reverse = (void*)malloc(size);
 		memcpy(mp_buf_reverse, p_buf_reverse, size);
 		m_size = size;
+		m_variable_information_vector=variable_information_vector;
+	}
+}
+
+//正序数据 转为 倒序数据
+void Snap7_buf::obverse_to_reverse()
+{
+	char *p_in=(char*)mp_buf_obverse;
+	char *p_out=(char*)mp_buf_reverse;
+
+	for ( auto &iter:m_variable_information_vector)
+	{
+		for (int i = 0; i < iter.m_variable_count; ++i)
+		{
+			for (int j = iter.m_variable_index*i; j < iter.m_variable_index*i+iter.m_variable_size ; ++j)
+			{
+				p_out[j] = p_in[iter.m_variable_index*i+iter.m_variable_size - j -1];
+			}
+		}
+	}
+}
+
+//倒序数据 转为 正序数据
+void Snap7_buf::reverse_to_obverse()
+{
+	char *p_in=(char*)mp_buf_reverse;
+	char *p_out=(char*)mp_buf_obverse;
+
+	for ( auto &iter:m_variable_information_vector)
+	{
+		for (int i = 0; i < iter.m_variable_count; ++i)
+		{
+			for (int j = iter.m_variable_index*i; j < iter.m_variable_index*i+iter.m_variable_size ; ++j)
+			{
+				p_out[j] = p_in[iter.m_variable_index*i+iter.m_variable_size - j -1];
+			}
+		}
 	}
 }
 

+ 8 - 3
snap7_communication/snap7_buf.h

@@ -7,6 +7,7 @@
 #include <string>
 #include <map>
 #include <vector>
+#include <iostream>
 
 //Snap7协议的数据结构
 class Snap7_buf
@@ -24,7 +25,7 @@ public:
 	struct Variable_information
 	{
 	    std::string		m_variable_name;		//变量名称
-	    char 			m_variable_type;		//变量类型, 使用 typeid(a).name() 获取
+	    std::string		m_variable_type;		//变量类型, 使用 typeid(a).name() 获取
 	    int 			m_variable_index;		//变量下标, 偏移量
 	    int 			m_variable_size;		//变量类型大小
 		int				m_variable_count;		//变量个数
@@ -35,10 +36,14 @@ public:
 	Snap7_buf& operator =(const Snap7_buf& other);
 	~Snap7_buf();
 public://API functions
-	Snap7_buf(int id, int start_index, int size, Communication_mode communication_mode = NO_COMMUNICATION);
-	Snap7_buf(int id, int start_index, int size, void* p_buf_obverse, void* p_buf_reverse, Communication_mode communication_mode = NO_COMMUNICATION);
+	Snap7_buf(int id, int start_index, int size,
+			  std::vector<Snap7_buf::Variable_information>& variable_information_vector,Communication_mode communication_mode = NO_COMMUNICATION);
+	Snap7_buf(int id, int start_index, int size, void* p_buf_obverse, void* p_buf_reverse,
+			  std::vector<Snap7_buf::Variable_information>& variable_information_vector, Communication_mode communication_mode = NO_COMMUNICATION);
 
+	//正序数据 转为 倒序数据
 	void obverse_to_reverse();
+	//倒序数据 转为 正序数据
 	void reverse_to_obverse();
 public://get or set member variable
 	int get_id();

+ 23 - 18
snap7_communication/snap7_communication.pb.cc

@@ -40,6 +40,10 @@ void InitDefaultsSnap7_communication_parameterImpl() {
 #else
   ::google::protobuf::internal::InitProtobufDefaults();
 #endif  // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
+  ::Snap7_communication_proto::Snap7_communication_parameter::_default_ip_string_.DefaultConstruct();
+  *::Snap7_communication_proto::Snap7_communication_parameter::_default_ip_string_.get_mutable() = ::std::string("192.168.0.1", 11);
+  ::google::protobuf::internal::OnShutdownDestroyString(
+      ::Snap7_communication_proto::Snap7_communication_parameter::_default_ip_string_.get_mutable());
   {
     void* ptr = &::Snap7_communication_proto::_Snap7_communication_parameter_default_instance_;
     new (ptr) ::Snap7_communication_proto::Snap7_communication_parameter();
@@ -126,15 +130,15 @@ void AddDescriptorsImpl() {
   InitDefaults();
   static const char descriptor[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
       "\n\031snap7_communication.proto\022\031Snap7_commu"
-      "nication_proto\"2\n\035Snap7_communication_pa"
-      "rameter\022\021\n\tip_string\030\001 \002(\t\"\205\001\n!Snap7_com"
-      "munication_parameter_all\022`\n\036snap7_commun"
-      "ication_parameters\030\001 \002(\01328.Snap7_communi"
-      "cation_proto.Snap7_communication_paramet"
-      "er"
+      "nication_proto\"\?\n\035Snap7_communication_pa"
+      "rameter\022\036\n\tip_string\030\001 \002(\t:\013192.168.0.1\""
+      "\205\001\n!Snap7_communication_parameter_all\022`\n"
+      "\036snap7_communication_parameters\030\001 \002(\01328."
+      "Snap7_communication_proto.Snap7_communic"
+      "ation_parameter"
   };
   ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
-      descriptor, 242);
+      descriptor, 255);
   ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
     "snap7_communication.proto", &protobuf_RegisterTypes);
 }
@@ -156,6 +160,7 @@ namespace Snap7_communication_proto {
 
 void Snap7_communication_parameter::InitAsDefaultInstance() {
 }
+::google::protobuf::internal::ExplicitlyConstructed< ::std::string> Snap7_communication_parameter::_default_ip_string_;
 #if !defined(_MSC_VER) || _MSC_VER >= 1900
 const int Snap7_communication_parameter::kIpStringFieldNumber;
 #endif  // !defined(_MSC_VER) || _MSC_VER >= 1900
@@ -174,16 +179,16 @@ Snap7_communication_parameter::Snap7_communication_parameter(const Snap7_communi
       _has_bits_(from._has_bits_),
       _cached_size_(0) {
   _internal_metadata_.MergeFrom(from._internal_metadata_);
-  ip_string_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+  ip_string_.UnsafeSetDefault(&::Snap7_communication_proto::Snap7_communication_parameter::_default_ip_string_.get());
   if (from.has_ip_string()) {
-    ip_string_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.ip_string_);
+    ip_string_.AssignWithDefault(&::Snap7_communication_proto::Snap7_communication_parameter::_default_ip_string_.get(), from.ip_string_);
   }
   // @@protoc_insertion_point(copy_constructor:Snap7_communication_proto.Snap7_communication_parameter)
 }
 
 void Snap7_communication_parameter::SharedCtor() {
   _cached_size_ = 0;
-  ip_string_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+  ip_string_.UnsafeSetDefault(&::Snap7_communication_proto::Snap7_communication_parameter::_default_ip_string_.get());
 }
 
 Snap7_communication_parameter::~Snap7_communication_parameter() {
@@ -192,7 +197,7 @@ Snap7_communication_parameter::~Snap7_communication_parameter() {
 }
 
 void Snap7_communication_parameter::SharedDtor() {
-  ip_string_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+  ip_string_.DestroyNoArena(&::Snap7_communication_proto::Snap7_communication_parameter::_default_ip_string_.get());
 }
 
 void Snap7_communication_parameter::SetCachedSize(int size) const {
@@ -226,8 +231,8 @@ void Snap7_communication_parameter::Clear() {
 
   cached_has_bits = _has_bits_[0];
   if (cached_has_bits & 0x00000001u) {
-    GOOGLE_DCHECK(!ip_string_.IsDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited()));
-    (*ip_string_.UnsafeRawStringPointer())->clear();
+    GOOGLE_DCHECK(!ip_string_.IsDefault(&::Snap7_communication_proto::Snap7_communication_parameter::_default_ip_string_.get()));
+    (*ip_string_.UnsafeRawStringPointer())->assign(*&::Snap7_communication_proto::Snap7_communication_parameter::_default_ip_string_.get());
   }
   _has_bits_.Clear();
   _internal_metadata_.Clear();
@@ -243,7 +248,7 @@ bool Snap7_communication_parameter::MergePartialFromCodedStream(
     tag = p.first;
     if (!p.second) goto handle_unusual;
     switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
-      // required string ip_string = 1;
+      // required string ip_string = 1 [default = "192.168.0.1"];
       case 1: {
         if (static_cast< ::google::protobuf::uint8>(tag) ==
             static_cast< ::google::protobuf::uint8>(10u /* 10 & 0xFF */)) {
@@ -286,7 +291,7 @@ void Snap7_communication_parameter::SerializeWithCachedSizes(
   (void) cached_has_bits;
 
   cached_has_bits = _has_bits_[0];
-  // required string ip_string = 1;
+  // required string ip_string = 1 [default = "192.168.0.1"];
   if (cached_has_bits & 0x00000001u) {
     ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
       this->ip_string().data(), static_cast<int>(this->ip_string().length()),
@@ -311,7 +316,7 @@ void Snap7_communication_parameter::SerializeWithCachedSizes(
   (void) cached_has_bits;
 
   cached_has_bits = _has_bits_[0];
-  // required string ip_string = 1;
+  // required string ip_string = 1 [default = "192.168.0.1"];
   if (cached_has_bits & 0x00000001u) {
     ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(
       this->ip_string().data(), static_cast<int>(this->ip_string().length()),
@@ -339,7 +344,7 @@ size_t Snap7_communication_parameter::ByteSizeLong() const {
       ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
         _internal_metadata_.unknown_fields());
   }
-  // required string ip_string = 1;
+  // required string ip_string = 1 [default = "192.168.0.1"];
   if (has_ip_string()) {
     total_size += 1 +
       ::google::protobuf::internal::WireFormatLite::StringSize(
@@ -376,7 +381,7 @@ void Snap7_communication_parameter::MergeFrom(const Snap7_communication_paramete
 
   if (from.has_ip_string()) {
     set_has_ip_string();
-    ip_string_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.ip_string_);
+    ip_string_.AssignWithDefault(&::Snap7_communication_proto::Snap7_communication_parameter::_default_ip_string_.get(), from.ip_string_);
   }
 }
 

+ 11 - 10
snap7_communication/snap7_communication.pb.h

@@ -152,7 +152,7 @@ class Snap7_communication_parameter : public ::google::protobuf::Message /* @@pr
 
   // accessors -------------------------------------------------------
 
-  // required string ip_string = 1;
+  // required string ip_string = 1 [default = "192.168.0.1"];
   bool has_ip_string() const;
   void clear_ip_string();
   static const int kIpStringFieldNumber = 1;
@@ -175,6 +175,7 @@ class Snap7_communication_parameter : public ::google::protobuf::Message /* @@pr
   ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
   ::google::protobuf::internal::HasBits<1> _has_bits_;
   mutable int _cached_size_;
+  static ::google::protobuf::internal::ExplicitlyConstructed< ::std::string> _default_ip_string_;
   ::google::protobuf::internal::ArenaStringPtr ip_string_;
   friend struct ::protobuf_snap7_5fcommunication_2eproto::TableStruct;
   friend void ::protobuf_snap7_5fcommunication_2eproto::InitDefaultsSnap7_communication_parameterImpl();
@@ -302,7 +303,7 @@ class Snap7_communication_parameter_all : public ::google::protobuf::Message /*
 #endif  // __GNUC__
 // Snap7_communication_parameter
 
-// required string ip_string = 1;
+// required string ip_string = 1 [default = "192.168.0.1"];
 inline bool Snap7_communication_parameter::has_ip_string() const {
   return (_has_bits_[0] & 0x00000001u) != 0;
 }
@@ -313,7 +314,7 @@ inline void Snap7_communication_parameter::clear_has_ip_string() {
   _has_bits_[0] &= ~0x00000001u;
 }
 inline void Snap7_communication_parameter::clear_ip_string() {
-  ip_string_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+  ip_string_.ClearToDefaultNoArena(&::Snap7_communication_proto::Snap7_communication_parameter::_default_ip_string_.get());
   clear_has_ip_string();
 }
 inline const ::std::string& Snap7_communication_parameter::ip_string() const {
@@ -322,38 +323,38 @@ inline const ::std::string& Snap7_communication_parameter::ip_string() const {
 }
 inline void Snap7_communication_parameter::set_ip_string(const ::std::string& value) {
   set_has_ip_string();
-  ip_string_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+  ip_string_.SetNoArena(&::Snap7_communication_proto::Snap7_communication_parameter::_default_ip_string_.get(), value);
   // @@protoc_insertion_point(field_set:Snap7_communication_proto.Snap7_communication_parameter.ip_string)
 }
 #if LANG_CXX11
 inline void Snap7_communication_parameter::set_ip_string(::std::string&& value) {
   set_has_ip_string();
   ip_string_.SetNoArena(
-    &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+    &::Snap7_communication_proto::Snap7_communication_parameter::_default_ip_string_.get(), ::std::move(value));
   // @@protoc_insertion_point(field_set_rvalue:Snap7_communication_proto.Snap7_communication_parameter.ip_string)
 }
 #endif
 inline void Snap7_communication_parameter::set_ip_string(const char* value) {
   GOOGLE_DCHECK(value != NULL);
   set_has_ip_string();
-  ip_string_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+  ip_string_.SetNoArena(&::Snap7_communication_proto::Snap7_communication_parameter::_default_ip_string_.get(), ::std::string(value));
   // @@protoc_insertion_point(field_set_char:Snap7_communication_proto.Snap7_communication_parameter.ip_string)
 }
 inline void Snap7_communication_parameter::set_ip_string(const char* value, size_t size) {
   set_has_ip_string();
-  ip_string_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+  ip_string_.SetNoArena(&::Snap7_communication_proto::Snap7_communication_parameter::_default_ip_string_.get(),
       ::std::string(reinterpret_cast<const char*>(value), size));
   // @@protoc_insertion_point(field_set_pointer:Snap7_communication_proto.Snap7_communication_parameter.ip_string)
 }
 inline ::std::string* Snap7_communication_parameter::mutable_ip_string() {
   set_has_ip_string();
   // @@protoc_insertion_point(field_mutable:Snap7_communication_proto.Snap7_communication_parameter.ip_string)
-  return ip_string_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+  return ip_string_.MutableNoArena(&::Snap7_communication_proto::Snap7_communication_parameter::_default_ip_string_.get());
 }
 inline ::std::string* Snap7_communication_parameter::release_ip_string() {
   // @@protoc_insertion_point(field_release:Snap7_communication_proto.Snap7_communication_parameter.ip_string)
   clear_has_ip_string();
-  return ip_string_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+  return ip_string_.ReleaseNoArena(&::Snap7_communication_proto::Snap7_communication_parameter::_default_ip_string_.get());
 }
 inline void Snap7_communication_parameter::set_allocated_ip_string(::std::string* ip_string) {
   if (ip_string != NULL) {
@@ -361,7 +362,7 @@ inline void Snap7_communication_parameter::set_allocated_ip_string(::std::string
   } else {
     clear_has_ip_string();
   }
-  ip_string_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ip_string);
+  ip_string_.SetAllocatedNoArena(&::Snap7_communication_proto::Snap7_communication_parameter::_default_ip_string_.get(), ip_string);
   // @@protoc_insertion_point(field_set_allocated:Snap7_communication_proto.Snap7_communication_parameter.ip_string)
 }
 

+ 15 - 42
snap7_communication/snap7_communication_base.cpp

@@ -38,7 +38,8 @@ Error_manager Snap7_communication_base::communication_init_from_protobuf(Snap7_c
 {
 	LOG(INFO) << " ---Communication_socket_base::communication_init() --- "<< this;
 	Error_manager t_error;
-	snap7_communication_parameter_all.DebugString();
+//	snap7_communication_parameter_all.DebugString();
+
 	if ( snap7_communication_parameter_all.snap7_communication_parameters().has_ip_string() )
 	{
 		m_ip_string = snap7_communication_parameter_all.snap7_communication_parameters().ip_string();
@@ -147,7 +148,7 @@ void Snap7_communication_base::communication_thread()
 Error_manager t_error;
 	while (m_communication_condition.is_alive())
 	{
-		m_communication_condition.wait_for_ex(std::chrono::microseconds(1));
+		m_communication_condition.wait_for_ex(std::chrono::milliseconds(m_communication_delay_time_ms));
 
 		//s7的通信时间较长, 所以将发送和接受分开
 		//发送多个时, 必须加锁后一起发送, 不允许分段写入, 防止数据错误
@@ -238,37 +239,18 @@ Error_manager Snap7_communication_base::read_data_buf(Snap7_buf& snap7_buf)
 	Error_manager t_error;
 	if ( snap7_buf.m_communication_mode != Snap7_buf::NO_COMMUNICATION)
 	{
-		std::unique_lock<std::mutex> lck(m_communication_lock);
-		int result = m_snap7_client.AsDBRead(snap7_buf.m_id, snap7_buf.m_start_index, snap7_buf.m_size, snap7_buf.mp_buf_reverse);
-		if ( result == 0 )
-		{
-			m_snap7_client.WaitAsCompletion(100);
-		}
-
 		if ( snap7_buf.m_communication_mode == Snap7_buf::ONCE_COMMUNICATION )
 		{
 			snap7_buf.m_communication_mode = Snap7_buf::NO_COMMUNICATION;
 		}
-		std::this_thread::sleep_for(std::chrono::milliseconds(m_communication_delay_time_ms));
-		if (result==0)
-		{
-			t_error = reverse_byte(snap7_buf.mp_buf_reverse, snap7_buf.mp_buf_obverse, snap7_buf.m_size);
-
-//			unsigned int ccccc = *((unsigned int*)snap7_buf.mp_buf_reverse);
-//
-//			std::cout << " huli test :::: " << " snap7_buf.m_id = " << snap7_buf.m_id << std::endl;
-//			std::cout << " huli test :::: " << " snap7_buf.m_start_index = " << snap7_buf.m_start_index << std::endl;
-//			std::cout << " huli test :::: " << " snap7_buf.m_size = " << snap7_buf.m_size << std::endl;
-//			std::cout << " huli test :::: " << " ccccc = " << (unsigned int)ccccc << std::endl;
-
 
-
-			if ( t_error != Error_code::SUCCESS )
-			{
-				return t_error;
-			}
-			std::this_thread::sleep_for(std::chrono::milliseconds(m_communication_delay_time_ms));
-			return Error_code::SUCCESS;
+		std::unique_lock<std::mutex> lck(m_communication_lock);
+		int result = m_snap7_client.AsDBRead(snap7_buf.m_id, snap7_buf.m_start_index, snap7_buf.m_size, snap7_buf.mp_buf_reverse);
+		if ( result == 0 )
+		{
+			m_snap7_client.WaitAsCompletion(100);
+			//倒序数据 转为 正序数据
+			snap7_buf.reverse_to_obverse();
 		}
 		else
 		{
@@ -285,12 +267,14 @@ Error_manager Snap7_communication_base::write_data_buf(Snap7_buf& snap7_buf)
 	Error_manager t_error;
 	if ( snap7_buf.m_communication_mode != Snap7_buf::NO_COMMUNICATION)
 	{
-		t_error = reverse_byte(snap7_buf.mp_buf_obverse, snap7_buf.mp_buf_reverse, snap7_buf.m_size);
-		if (t_error != Error_code::SUCCESS)
+		if ( snap7_buf.m_communication_mode != Snap7_buf::ONCE_COMMUNICATION )
 		{
-			return t_error;
+			snap7_buf.m_communication_mode = Snap7_buf::NO_COMMUNICATION;
 		}
 
+		//正序数据 转为 倒序数据
+		snap7_buf.obverse_to_reverse();
+
 		std::unique_lock<std::mutex> lck(m_communication_lock);
 		int result = m_snap7_client.AsDBWrite(snap7_buf.m_id, snap7_buf.m_start_index, snap7_buf.m_size,
 											  snap7_buf.mp_buf_reverse);
@@ -298,17 +282,6 @@ Error_manager Snap7_communication_base::write_data_buf(Snap7_buf& snap7_buf)
 		{
 			m_snap7_client.WaitAsCompletion(100);
 		}
-		std::cout << " huli test :::: " << " AsDBWrite result = " <<  result << std::endl;
-		if ( snap7_buf.m_communication_mode != Snap7_buf::ONCE_COMMUNICATION )
-		{
-			snap7_buf.m_communication_mode = Snap7_buf::NO_COMMUNICATION;
-		}
-		std::this_thread::sleep_for(std::chrono::milliseconds(m_communication_delay_time_ms));
-		if (result == 0)
-		{
-			std::this_thread::sleep_for(std::chrono::milliseconds(m_communication_delay_time_ms));
-			return Error_code::SUCCESS;
-		}
 		else
 		{
 			return Error_manager(Error_code::SNAP7_WRITE_ERROR, Error_level::MINOR_ERROR,

+ 1 - 1
system/system_executor.cpp

@@ -207,7 +207,7 @@ Error_manager System_executor::execute_msg(Communication_message* p_msg)
 									  t_dispatch_request_msg.command_key(),
 									  (Dispatch_manager::Dispatch_motion_direction)t_dispatch_request_msg.dispatch_motion_direction(),
 									  t_dispatch_request_msg.terminal_id(),
-									  t_dispatch_request_msg.parkspace_id(),
+									  t_dispatch_request_msg.parkspace_info().parkspace_id(),
 									  &t_locate_information		);
 			}
 			else

+ 19 - 15
test.txt

@@ -2,32 +2,36 @@
 
 
 
+cd deepin-wine-for-ubuntu/
 
+chmod +x install_2.8.22.sh
 
-
-//搬运器状态
-message Carrier_status
-{
-    E_CARRIER_
-    
-    E_CARRIER_UNKNOW               = 0;    //未知
-        E_CARRIER_READY                = 1;    //准备,待机
-        E_CARRIER_STORE                = 2;	//正在存车
-        E_CARRIER_PICKUP               = 3;	//正在取车
-        E_CARRIER__FAULT               = 4;    //故障
-}
-
-
-
+./install_2.8.22.sh
 
 
+3. 下载 Deepin-QQ、Deepin-WeChat
+wget https://mirrors.aliyun.com/deepin/pool/non-free/d/deepin.com.qq.im/deepin.com.qq.im_9.1.8deepin0_i386.deb
 
+wget https://mirrors.aliyun.com/deepin/pool/non-free/d/deepin.com.wechat/deepin.com.wechat_2.6.8.65deepin0_i386.deb
 
+4. 安装 Deepin-QQ、Deepin-WeChat
+sudo dpkg -i deepin.com.qq.im_9.1.8deepin0_i386.deb
 
+sudo dpkg -i deepin.com.wechat_2.6.8.65deepin0_i386.deb
 
+sudo apt-get install -f
 
+5. 增加系统托盘
+如果是 GNOME 桌面,可以在 https://extensions.gnome.org/extension/1031/topicons/ 安装 TopIcons Plus 插件。
 
+6. 如果是 hdpi 的屏幕,还需执行以下操作来缩放界面
+天知道我当时为什么脑子一抽买了15寸的 4k 屏幕笔记本……
 
+WINEPREFIX=~/.deepinwine/Deepin-QQ deepin-wine winecfg
 
+WINEPREFIX=~/.deepinwine/Deepin-WeChat deepin-wine winecfg
+作者:秋色楓
+https://www.bilibili.com/read/cv6031375?from=search
+出处: bilibili