// // Created by zx on 2020/7/3. // #include #include #include #include #include #include "measure_message.pb.h" #include int main() { nnxx::socket socket{ nnxx::SP, nnxx::BUS }; socket.bind("tcp://127.0.0.1:4444"); int n=0; while(1) { std::string t_receive_string = socket.recv(0); if(t_receive_string.length()>0) { message::Base_info base_msg; message::Measure_response_msg response; message::Measure_request_msg request; message::Error_manager error_code; request.ParseFromString(t_receive_string); base_msg.set_msg_type(message::eLocate_response_msg); base_msg.set_sender(message::eMeasurer); base_msg.set_receiver(message::eMain); response.set_command_id(request.command_id()); response.set_terminal_id(request.terminal_id()); response.mutable_base_info()->CopyFrom(base_msg); int succ=int((rand()%1000)/999); if(succ==0) { message::Locate_information locate_info; locate_info.set_locate_x(0.9); locate_info.set_locate_y(2.25); locate_info.set_locate_height(1.5); locate_info.set_locate_width(1.7); locate_info.set_locate_length(4.5); locate_info.set_locate_wheel_base(2.7); locate_info.set_locate_angle(90.0); locate_info.set_locate_correct(true); response.mutable_locate_information()->CopyFrom(locate_info); } error_code.set_error_code(succ); response.mutable_error_manager()->CopyFrom(error_code); std::cout<