|
@@ -21,6 +21,7 @@ System_communication::~System_communication()
|
|
|
//检查消息是否有效, 主要检查消息类型和接受者, 判断这条消息是不是给我的.
|
|
|
Error_manager System_communication::check_msg(Communication_message* p_msg)
|
|
|
{
|
|
|
+
|
|
|
//通过 p_msg->get_message_type() 和 p_msg->get_receiver() 判断这条消息是不是给我的.
|
|
|
if ( p_msg->get_message_type() == Communication_message::Message_type::eLocate_request_msg
|
|
|
&& p_msg->get_receiver() == Communication_message::Communicator::eMeasurer )
|
|
@@ -29,6 +30,7 @@ Error_manager System_communication::check_msg(Communication_message* p_msg)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+// std::cout << "System_communication::check_msg INVALID_MESSAGE" << std::endl;
|
|
|
//无效的消息,
|
|
|
return Error_code::INVALID_MESSAGE;
|
|
|
}
|
|
@@ -40,8 +42,8 @@ Error_manager System_communication::check_executer(Communication_message* p_msg
|
|
|
//检查对应模块的状态, 判断是否可以处理这条消息
|
|
|
//同时也要判断是否超时, 超时返回 COMMUNICATION_ANALYSIS_TIME_OUT
|
|
|
//如果处理器正在忙别的, 那么返回 COMMUNICATION_EXCUTER_IS_BUSY
|
|
|
- std::cout << "Communication_socket_base::check_msg p_buf = " << p_msg->get_message_buf() << std::endl;
|
|
|
- std::cout << "Communication_socket_base::check_msg size = " << p_msg->get_message_buf().size() << std::endl;
|
|
|
+// std::cout << "Communication_socket_base::check_msg p_buf = " << p_msg->get_message_buf() << std::endl;
|
|
|
+// std::cout << "Communication_socket_base::check_msg size = " << p_msg->get_message_buf().size() << std::endl;
|
|
|
|
|
|
Error_manager t_error;
|
|
|
if ( p_msg->is_over_time() )
|
|
@@ -52,6 +54,7 @@ Error_manager System_communication::check_executer(Communication_message* p_msg
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+
|
|
|
return System_executor::get_instance_references().check_executer(p_msg);
|
|
|
}
|
|
|
return Error_code::SUCCESS;
|
|
@@ -68,7 +71,17 @@ Error_manager System_communication::encapsulate_send_data()
|
|
|
{
|
|
|
Error_manager t_error;
|
|
|
|
|
|
-//创建一条答复消息
|
|
|
+ message::Measure_request_msg t_measure_request_msg;
|
|
|
+ t_measure_request_msg.mutable_base_info()->set_msg_type(message::Message_type::eLocate_request_msg);
|
|
|
+ t_measure_request_msg.mutable_base_info()->set_timeout_ms(5000);
|
|
|
+ t_measure_request_msg.mutable_base_info()->set_sender(message::Communicator::eMain);
|
|
|
+ t_measure_request_msg.mutable_base_info()->set_receiver(message::Communicator::eMeasurer);
|
|
|
+ t_measure_request_msg.set_command_id(123);
|
|
|
+ t_measure_request_msg.set_terminal_id(1);
|
|
|
+ string t_msg = t_measure_request_msg.SerializeAsString();
|
|
|
+ System_communication::get_instance_references().encapsulate_msg(t_msg);
|
|
|
+ /*
|
|
|
+ //创建一条状态消息
|
|
|
message::Measure_status_msg t_measure_status_msg;
|
|
|
t_measure_status_msg.mutable_base_info()->set_msg_type(message::Message_type::eLocate_status_msg);
|
|
|
t_measure_status_msg.mutable_base_info()->set_timeout_ms(5000);
|
|
@@ -104,7 +117,7 @@ Error_manager System_communication::encapsulate_send_data()
|
|
|
|
|
|
string t_msg = t_measure_status_msg.SerializeAsString();
|
|
|
System_communication::get_instance_references().encapsulate_msg(t_msg);
|
|
|
-
|
|
|
+*/
|
|
|
return Error_code::SUCCESS;
|
|
|
}
|
|
|
|