|
@@ -4,6 +4,7 @@
|
|
|
|
|
|
#include "dispatch_plc.h"
|
|
#include "dispatch_plc.h"
|
|
#include "../system/system_communication.h"
|
|
#include "../system/system_communication.h"
|
|
|
|
+#include "dispatch_manager.h"
|
|
|
|
|
|
Dispatch_plc::Dispatch_plc()
|
|
Dispatch_plc::Dispatch_plc()
|
|
{
|
|
{
|
|
@@ -149,20 +150,60 @@ void Dispatch_plc::execute_thread_fun()
|
|
if ( std::chrono::system_clock::now() - m_start_time > std::chrono::milliseconds(m_timeout_ms) )
|
|
if ( std::chrono::system_clock::now() - m_start_time > std::chrono::milliseconds(m_timeout_ms) )
|
|
{
|
|
{
|
|
//超时直接报错
|
|
//超时直接报错
|
|
- m_result = Error_manager(Error_code::DISPATCH_PLC_TIME_OUT, Error_level::MINOR_ERROR,
|
|
|
|
- " DISPATCH_PLC_TIME_OUT fun error ");
|
|
|
|
|
|
+ m_result = Error_manager(Error_code::DISPATCH_PLC_TIME_OUT, Error_level::MINOR_ERROR,
|
|
|
|
+ " DISPATCH_PLC_TIME_OUT fun error ");
|
|
m_dispatch_plc_status = DISPATCH_PLC_RESPONSE;
|
|
m_dispatch_plc_status = DISPATCH_PLC_RESPONSE;
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- //封装 给plc的调度请求
|
|
|
|
- m_result = encapsulate_dispatch_request_to_plc();
|
|
|
|
- if ( m_result == Error_code::SUCCESS )
|
|
|
|
|
|
+ if ( m_dispatch_request_msg.dispatch_motion_direction() == message::Dispatch_motion_direction::E_STORE_CAR )
|
|
{
|
|
{
|
|
- m_dispatch_plc_status = DISPATCH_PLC_WORKING;
|
|
|
|
|
|
+ //封装 给plc的调度请求
|
|
|
|
+ m_result = encapsulate_dispatch_request_to_plc();
|
|
|
|
+ if ( m_result == Error_code::SUCCESS )
|
|
|
|
+ {
|
|
|
|
+ m_dispatch_plc_status = DISPATCH_PLC_WORKING;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ m_dispatch_plc_status = DISPATCH_PLC_RESPONSE;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else if( m_dispatch_request_msg.dispatch_motion_direction() == message::Dispatch_motion_direction::E_PICKUP_CAR )
|
|
|
|
+ {
|
|
|
|
+ //判断2个出口是否空闲
|
|
|
|
+ if ( Dispatch_manager::get_instance_references().m_dispatch_singlechip[2].is_outlet_ready() )
|
|
|
|
+ {
|
|
|
|
+ //封装 给plc的调度请求
|
|
|
|
+ m_result = encapsulate_dispatch_request_to_plc(0);
|
|
|
|
+ if ( m_result == Error_code::SUCCESS )
|
|
|
|
+ {
|
|
|
|
+ m_dispatch_plc_status = DISPATCH_PLC_WORKING;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ m_dispatch_plc_status = DISPATCH_PLC_RESPONSE;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else if ( Dispatch_manager::get_instance_references().m_dispatch_singlechip[3].is_outlet_ready() )
|
|
|
|
+ {
|
|
|
|
+ //封装 给plc的调度请求
|
|
|
|
+ m_result = encapsulate_dispatch_request_to_plc(1);
|
|
|
|
+ if ( m_result == Error_code::SUCCESS )
|
|
|
|
+ {
|
|
|
|
+ m_dispatch_plc_status = DISPATCH_PLC_WORKING;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ m_dispatch_plc_status = DISPATCH_PLC_RESPONSE;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //else无限等待
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
|
|
+ m_result = Error_manager(Error_code::DISPATCH_PLC_DIRECTION_ERROR, Error_level::MINOR_ERROR,
|
|
|
|
+ " DISPATCH_PLC_DIRECTION_ERROR fun error ");
|
|
m_dispatch_plc_status = DISPATCH_PLC_RESPONSE;
|
|
m_dispatch_plc_status = DISPATCH_PLC_RESPONSE;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -228,7 +269,7 @@ void Dispatch_plc::execute_thread_fun()
|
|
|
|
|
|
|
|
|
|
//封装 给plc的调度请求
|
|
//封装 给plc的调度请求
|
|
-Error_manager Dispatch_plc::encapsulate_dispatch_request_to_plc()
|
|
|
|
|
|
+Error_manager Dispatch_plc::encapsulate_dispatch_request_to_plc(int outlet_id)
|
|
{
|
|
{
|
|
//把m_dispatch_request_msg的信息传给本地的数据缓存.
|
|
//把m_dispatch_request_msg的信息传给本地的数据缓存.
|
|
std::unique_lock<std::mutex> t_lock(m_lock);
|
|
std::unique_lock<std::mutex> t_lock(m_lock);
|
|
@@ -237,18 +278,21 @@ Error_manager Dispatch_plc::encapsulate_dispatch_request_to_plc()
|
|
{
|
|
{
|
|
m_request_dispatch_motion_direction = Common_data::Dispatch_motion_direction::DISPATCH_MOTION_DIRECTION_STORE;
|
|
m_request_dispatch_motion_direction = Common_data::Dispatch_motion_direction::DISPATCH_MOTION_DIRECTION_STORE;
|
|
m_request_passageway_direction = Common_data::Passageway_direction::PASSAGEWAY_DIRECTION_INLET;
|
|
m_request_passageway_direction = Common_data::Passageway_direction::PASSAGEWAY_DIRECTION_INLET;
|
|
|
|
+ m_request_passageway_id = m_dispatch_request_msg.terminal_id()+1;//0~5入口终端号改为1~6
|
|
}
|
|
}
|
|
else if( m_dispatch_request_msg.dispatch_motion_direction() == message::Dispatch_motion_direction::E_PICKUP_CAR )
|
|
else if( m_dispatch_request_msg.dispatch_motion_direction() == message::Dispatch_motion_direction::E_PICKUP_CAR )
|
|
{
|
|
{
|
|
m_request_dispatch_motion_direction = Common_data::Dispatch_motion_direction::DISPATCH_MOTION_DIRECTION_PICKUP;
|
|
m_request_dispatch_motion_direction = Common_data::Dispatch_motion_direction::DISPATCH_MOTION_DIRECTION_PICKUP;
|
|
m_request_passageway_direction = Common_data::Passageway_direction::PASSAGEWAY_DIRECTION_OUTLET;
|
|
m_request_passageway_direction = Common_data::Passageway_direction::PASSAGEWAY_DIRECTION_OUTLET;
|
|
|
|
+ m_request_passageway_id = m_dispatch_request_msg.terminal_id()*2+outlet_id+1;//0~2出口单元号改为1~6
|
|
|
|
+
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
m_request_dispatch_motion_direction = Common_data::Dispatch_motion_direction::DISPATCH_MOTION_DIRECTION_UNKNOWN;
|
|
m_request_dispatch_motion_direction = Common_data::Dispatch_motion_direction::DISPATCH_MOTION_DIRECTION_UNKNOWN;
|
|
m_request_passageway_direction = Common_data::Passageway_direction::PASSAGEWAY_DIRECTION_UNKNOWN;
|
|
m_request_passageway_direction = Common_data::Passageway_direction::PASSAGEWAY_DIRECTION_UNKNOWN;
|
|
|
|
+ m_request_passageway_id = -1;
|
|
}
|
|
}
|
|
- m_request_passageway_id = m_dispatch_request_msg.terminal_id()+1;//0~5改为1~6
|
|
|
|
|
|
|
|
if ( m_dispatch_request_msg.locate_information().locate_correct() )
|
|
if ( m_dispatch_request_msg.locate_information().locate_correct() )
|
|
{
|
|
{
|