|
@@ -212,10 +212,12 @@ Error_manager Dispatch_manager::execute_for_dispatch_request_msg(message::Dispat
|
|
|
if ( dispatch_request_msg.dispatch_motion_direction() == message::Dispatch_motion_direction::E_STORE_CAR )
|
|
|
{
|
|
|
m_dispatch_request_store_list.push_back(dispatch_request_msg);
|
|
|
+ m_store_updata_time = std::chrono::system_clock::now();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
m_dispatch_request_pickup_list.push_back(dispatch_request_msg);
|
|
|
+ m_pickup_updata_time = std::chrono::system_clock::now();
|
|
|
}
|
|
|
|
|
|
|
|
@@ -283,30 +285,130 @@ Error_manager Dispatch_manager::encapsulate_send_dispatch_manager_status()
|
|
|
t_dispatch_terminal_status_msg.mutable_base_info()->set_receiver(message::Communicator::eEmpty);
|
|
|
|
|
|
t_dispatch_terminal_status_msg.mutable_id_struct()->set_unit_id(t_dispatch_manager_id);
|
|
|
- t_dispatch_terminal_status_msg.set_terminal_status(message::Terminal_status::E_TERMINAL_READY);
|
|
|
+ t_dispatch_terminal_status_msg.set_terminal_status(message::Terminal_status(m_dispatch_manager_status));
|
|
|
t_dispatch_terminal_status_msg.set_passageway_direction(message::Passageway_direction::E_BILATERAL);
|
|
|
|
|
|
+
|
|
|
+ //E_DISPATCH_POCESS_OVER
|
|
|
+ {
|
|
|
+ std::unique_lock<std::mutex> t_lock(m_lock);
|
|
|
+ for (auto iter = m_dispatch_response_store_map.begin(); iter != m_dispatch_response_store_map.end(); ++iter)
|
|
|
+ {
|
|
|
+ message::Dispatch_process_information * tp_dispatch_process_information =
|
|
|
+ t_dispatch_terminal_status_msg.mutable_dispatch_store_process_information_vector()->Add();
|
|
|
+ tp_dispatch_process_information->set_car_numberplate(iter->second.parkspace_info_ex(0).car_info().car_numberplate());
|
|
|
+ tp_dispatch_process_information->set_command_key(iter->second.command_key());
|
|
|
+ tp_dispatch_process_information->set_dispatch_motion_direction(iter->second.dispatch_motion_direction());
|
|
|
+ tp_dispatch_process_information->mutable_id_struct()->CopyFrom(iter->second.id_struct());
|
|
|
+ tp_dispatch_process_information->mutable_locate_information()->CopyFrom(iter->second.locate_information());
|
|
|
+ tp_dispatch_process_information->mutable_parkspace_info_ex()->CopyFrom(iter->second.parkspace_info_ex());
|
|
|
+ tp_dispatch_process_information->set_car_type(iter->second.car_type());
|
|
|
+
|
|
|
+ tp_dispatch_process_information->set_dispatch_process_status(message::Dispatch_process_status::E_DISPATCH_POCESS_OVER);
|
|
|
+ }
|
|
|
+ for (auto iter = m_dispatch_response_pickup_map.begin(); iter != m_dispatch_response_pickup_map.end(); ++iter)
|
|
|
+ {
|
|
|
+ message::Dispatch_process_information * tp_dispatch_process_information =
|
|
|
+ t_dispatch_terminal_status_msg.mutable_dispatch_pickup_process_information_vector()->Add();
|
|
|
+ tp_dispatch_process_information->set_car_numberplate(iter->second.parkspace_info_ex(0).car_info().car_numberplate());
|
|
|
+ tp_dispatch_process_information->set_command_key(iter->second.command_key());
|
|
|
+ tp_dispatch_process_information->set_dispatch_motion_direction(iter->second.dispatch_motion_direction());
|
|
|
+ tp_dispatch_process_information->mutable_id_struct()->CopyFrom(iter->second.id_struct());
|
|
|
+ tp_dispatch_process_information->mutable_locate_information()->CopyFrom(iter->second.locate_information());
|
|
|
+ tp_dispatch_process_information->mutable_parkspace_info_ex()->CopyFrom(iter->second.parkspace_info_ex());
|
|
|
+ tp_dispatch_process_information->set_car_type(iter->second.car_type());
|
|
|
+
|
|
|
+ tp_dispatch_process_information->set_dispatch_process_status(message::Dispatch_process_status::E_DISPATCH_POCESS_OVER);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //E_DISPATCH_POCESS_WORKING
|
|
|
+ {
|
|
|
+ if ( m_dispatch_plc.get_dispatch_plc_status() == Dispatch_plc::Dispatch_plc_status::DISPATCH_PLC_REQUEST ||
|
|
|
+ m_dispatch_plc.get_dispatch_plc_status() == Dispatch_plc::Dispatch_plc_status::DISPATCH_PLC_WORKING||
|
|
|
+ m_dispatch_plc.get_dispatch_plc_status() == Dispatch_plc::Dispatch_plc_status::DISPATCH_PLC_BUSY)
|
|
|
+ {
|
|
|
+ message::Dispatch_request_msg t_dispatch_request_msg = m_dispatch_plc.get_dispatch_request_msg();
|
|
|
+ if ( t_dispatch_request_msg.dispatch_motion_direction() == message::Dispatch_motion_direction::E_STORE_CAR )
|
|
|
+ {
|
|
|
+ message::Dispatch_process_information * tp_dispatch_process_information =
|
|
|
+ t_dispatch_terminal_status_msg.mutable_dispatch_store_process_information_vector()->Add();
|
|
|
+ tp_dispatch_process_information->set_car_numberplate(t_dispatch_request_msg.parkspace_info_ex(0).car_info().car_numberplate());
|
|
|
+ tp_dispatch_process_information->set_command_key(t_dispatch_request_msg.command_key());
|
|
|
+ tp_dispatch_process_information->set_dispatch_motion_direction(t_dispatch_request_msg.dispatch_motion_direction());
|
|
|
+ tp_dispatch_process_information->mutable_id_struct()->CopyFrom(t_dispatch_request_msg.id_struct());
|
|
|
+ tp_dispatch_process_information->mutable_locate_information()->CopyFrom(t_dispatch_request_msg.locate_information());
|
|
|
+ tp_dispatch_process_information->mutable_parkspace_info_ex()->CopyFrom(t_dispatch_request_msg.parkspace_info_ex());
|
|
|
+ tp_dispatch_process_information->set_car_type(t_dispatch_request_msg.car_type());
|
|
|
+
|
|
|
+ tp_dispatch_process_information->set_dispatch_process_status(message::Dispatch_process_status::E_DISPATCH_POCESS_WORKING);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ message::Dispatch_process_information * tp_dispatch_process_information =
|
|
|
+ t_dispatch_terminal_status_msg.mutable_dispatch_pickup_process_information_vector()->Add();
|
|
|
+ tp_dispatch_process_information->set_car_numberplate(t_dispatch_request_msg.parkspace_info_ex(0).car_info().car_numberplate());
|
|
|
+ tp_dispatch_process_information->set_command_key(t_dispatch_request_msg.command_key());
|
|
|
+ tp_dispatch_process_information->set_dispatch_motion_direction(t_dispatch_request_msg.dispatch_motion_direction());
|
|
|
+ tp_dispatch_process_information->mutable_id_struct()->CopyFrom(t_dispatch_request_msg.id_struct());
|
|
|
+ tp_dispatch_process_information->mutable_locate_information()->CopyFrom(t_dispatch_request_msg.locate_information());
|
|
|
+ tp_dispatch_process_information->mutable_parkspace_info_ex()->CopyFrom(t_dispatch_request_msg.parkspace_info_ex());
|
|
|
+ tp_dispatch_process_information->set_car_type(t_dispatch_request_msg.car_type());
|
|
|
+
|
|
|
+ tp_dispatch_process_information->set_dispatch_process_status(message::Dispatch_process_status::E_DISPATCH_POCESS_WORKING);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //E_DISPATCH_POCESS_WAIT
|
|
|
+ {
|
|
|
+ std::unique_lock<std::mutex> t_lock(m_lock);
|
|
|
+ int t_store_wait_number = 1;
|
|
|
+ for (auto iter = m_dispatch_request_store_list.begin(); iter != m_dispatch_request_store_list.end(); ++iter)
|
|
|
+ {
|
|
|
+ message::Dispatch_process_information * tp_dispatch_process_information =
|
|
|
+ t_dispatch_terminal_status_msg.mutable_dispatch_store_process_information_vector()->Add();
|
|
|
+ tp_dispatch_process_information->set_car_numberplate(iter->parkspace_info_ex(0).car_info().car_numberplate());
|
|
|
+ tp_dispatch_process_information->set_command_key(iter->command_key());
|
|
|
+ tp_dispatch_process_information->set_dispatch_motion_direction(iter->dispatch_motion_direction());
|
|
|
+ tp_dispatch_process_information->mutable_id_struct()->CopyFrom(iter->id_struct());
|
|
|
+ tp_dispatch_process_information->mutable_locate_information()->CopyFrom(iter->locate_information());
|
|
|
+ tp_dispatch_process_information->mutable_parkspace_info_ex()->CopyFrom(iter->parkspace_info_ex());
|
|
|
+ tp_dispatch_process_information->set_car_type(iter->car_type());
|
|
|
+
|
|
|
+ tp_dispatch_process_information->set_dispatch_process_status(message::Dispatch_process_status::E_DISPATCH_POCESS_WAIT);
|
|
|
+ tp_dispatch_process_information->set_m_wait_number(t_store_wait_number);
|
|
|
+ t_store_wait_number++;
|
|
|
+ }
|
|
|
+ int t_pickup_wait_number = 1;
|
|
|
+ for (auto iter = m_dispatch_request_pickup_list.begin(); iter != m_dispatch_request_pickup_list.end(); ++iter)
|
|
|
+ {
|
|
|
+ message::Dispatch_process_information * tp_dispatch_process_information =
|
|
|
+ t_dispatch_terminal_status_msg.mutable_dispatch_pickup_process_information_vector()->Add();
|
|
|
+ tp_dispatch_process_information->set_car_numberplate(iter->parkspace_info_ex(0).car_info().car_numberplate());
|
|
|
+ tp_dispatch_process_information->set_command_key(iter->command_key());
|
|
|
+ tp_dispatch_process_information->set_dispatch_motion_direction(iter->dispatch_motion_direction());
|
|
|
+ tp_dispatch_process_information->mutable_id_struct()->CopyFrom(iter->id_struct());
|
|
|
+ tp_dispatch_process_information->mutable_locate_information()->CopyFrom(iter->locate_information());
|
|
|
+ tp_dispatch_process_information->mutable_parkspace_info_ex()->CopyFrom(iter->parkspace_info_ex());
|
|
|
+ tp_dispatch_process_information->set_car_type(iter->car_type());
|
|
|
+
|
|
|
+ tp_dispatch_process_information->set_dispatch_process_status(message::Dispatch_process_status::E_DISPATCH_POCESS_WAIT);
|
|
|
+ tp_dispatch_process_information->set_m_wait_number(t_pickup_wait_number);
|
|
|
+ t_pickup_wait_number++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ std::string t_store_updata_time = Time_tool::get_instance_references().get_time_string_millisecond(m_store_updata_time);
|
|
|
+ std::string t_pickup_updata_time = Time_tool::get_instance_references().get_time_string_millisecond(m_pickup_updata_time);
|
|
|
+
|
|
|
+ t_dispatch_terminal_status_msg.set_dispatch_store_process_information_updata_time(t_store_updata_time);
|
|
|
+ t_dispatch_terminal_status_msg.set_dispatch_pickup_process_information_updata_time(t_pickup_updata_time);
|
|
|
+
|
|
|
+
|
|
|
t_msg1 = t_dispatch_terminal_status_msg.SerializeAsString();
|
|
|
System_communication::get_instance_references().encapsulate_msg(t_msg1);
|
|
|
-/*
|
|
|
- std::string t_msg2;
|
|
|
- //创建一条 调度管理总管理的状态 新版
|
|
|
- message::Dispatch_manager_status_msg t_dispatch_manager_status_msg;
|
|
|
- t_dispatch_manager_status_msg.mutable_base_info()->set_msg_type(message::Message_type::eDispatch_manager_status_msg);
|
|
|
- t_dispatch_manager_status_msg.mutable_base_info()->set_timeout_ms(5000);
|
|
|
- t_dispatch_manager_status_msg.mutable_base_info()->set_sender(message::Communicator::eDispatch_manager);
|
|
|
- t_dispatch_manager_status_msg.mutable_base_info()->set_receiver(message::Communicator::eEmpty);
|
|
|
-
|
|
|
- t_dispatch_manager_status_msg.set_dispatch_id(t_dispatch_manager_id*2);
|
|
|
- Dispatch_manager::Dispatch_manager_status t_dispatch_manager_status = get_dispatch_manager_status();
|
|
|
- t_dispatch_manager_status_msg.set_dispatch_manager_status((message::Dispatch_manager_status)t_dispatch_manager_status);
|
|
|
-
|
|
|
- t_msg2 = t_dispatch_manager_status_msg.SerializeAsString();
|
|
|
- System_communication::get_instance_references().encapsulate_msg(t_msg2);
|
|
|
- t_dispatch_manager_status_msg.set_dispatch_id(t_dispatch_manager_id*2+1);
|
|
|
- t_msg2 = t_dispatch_manager_status_msg.SerializeAsString();
|
|
|
- System_communication::get_instance_references().encapsulate_msg(t_msg2);
|
|
|
-*/
|
|
|
+
|
|
|
|
|
|
return Error_code::SUCCESS;
|
|
|
}
|
|
@@ -382,7 +484,7 @@ void Dispatch_manager::resource_allocation()
|
|
|
std::this_thread::yield();
|
|
|
std::unique_lock<std::mutex> t_lock(m_lock);
|
|
|
|
|
|
-
|
|
|
+ //sort resource_allocation
|
|
|
if ( m_dispatch_plc.get_dispatch_plc_status() == Dispatch_plc::Dispatch_plc_status::DISPATCH_PLC_READY )
|
|
|
{
|
|
|
if ( m_dispatch_motion_direction_next == Common_data::Dispatch_motion_direction::DISPATCH_MOTION_DIRECTION_PICKUP)
|
|
@@ -392,6 +494,7 @@ void Dispatch_manager::resource_allocation()
|
|
|
{
|
|
|
m_dispatch_plc.execute_for_dispatch_request_msg(*iter);
|
|
|
m_dispatch_request_pickup_list.erase(iter);
|
|
|
+ m_store_updata_time = std::chrono::system_clock::now();
|
|
|
}
|
|
|
m_dispatch_motion_direction_next = Common_data::Dispatch_motion_direction::DISPATCH_MOTION_DIRECTION_STORE;
|
|
|
}
|
|
@@ -402,6 +505,7 @@ void Dispatch_manager::resource_allocation()
|
|
|
{
|
|
|
m_dispatch_plc.execute_for_dispatch_request_msg(*iter);
|
|
|
m_dispatch_request_store_list.erase(iter);
|
|
|
+ m_pickup_updata_time = std::chrono::system_clock::now();
|
|
|
}
|
|
|
m_dispatch_motion_direction_next = Common_data::Dispatch_motion_direction::DISPATCH_MOTION_DIRECTION_PICKUP;
|
|
|
}
|
|
@@ -409,8 +513,41 @@ void Dispatch_manager::resource_allocation()
|
|
|
{
|
|
|
///////
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
+
|
|
|
+ //store finish check and erese
|
|
|
+ for (auto iter = m_dispatch_response_store_map.begin(); iter != m_dispatch_response_store_map.end();)
|
|
|
+ {
|
|
|
+ if ( std::chrono::system_clock::now() - iter->first > std::chrono::seconds(10) )
|
|
|
+ {
|
|
|
+ iter = m_dispatch_response_store_map.erase(iter);
|
|
|
+ m_store_updata_time = std::chrono::system_clock::now();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ++iter;
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ //pickup finish check and erese //判断2个出口是否空闲
|
|
|
+ if ( Dispatch_manager::get_instance_references().m_dispatch_singlechip[2].is_outlet_ready() )
|
|
|
+ {
|
|
|
+ if ( m_dispatch_response_pickup_map.find(0) != m_dispatch_response_pickup_map.end() )
|
|
|
+ {
|
|
|
+ m_dispatch_response_pickup_map.erase(0);
|
|
|
+ m_pickup_updata_time = std::chrono::system_clock::now();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if ( Dispatch_manager::get_instance_references().m_dispatch_singlechip[3].is_outlet_ready() )
|
|
|
+ {
|
|
|
+ if ( m_dispatch_response_pickup_map.find(1) != m_dispatch_response_pickup_map.end() )
|
|
|
+ {
|
|
|
+ m_dispatch_response_pickup_map.erase(1);
|
|
|
+ m_pickup_updata_time = std::chrono::system_clock::now();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|