123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- //
- // Created by zx on 2020/7/3.
- //
- #include <iostream>
- #include "../lidar_locate/Locate_communicator.h"
- #include <unistd.h>
- #include "../tool/thread_safe_list.h"
- int main(int argc,char* argv[])
- {
- int exe_id=rand()%1000000;
- Locate_communicator* pLocator=Locate_communicator::get_instance_pointer();
- pLocator->communication_connect("tcp://127.0.0.1:9006");
- pLocator->communication_run();
- int k=1;
- Thread_safe_list<std::string*> list;
- /*nnxx::socket socket{ nnxx::SP, nnxx::BUS };
- socket.bind("tcp://127.0.0.1:9005");
- socket.connect("tcp://127.0.0.1:9006");*/
- int n=0;
- while(1) {
- message::Measure_request_msg request;
- //message::Base_info base_msg;
- //request.mutable_base_info()->CopyFrom(base_msg);
- request.mutable_base_info()->set_msg_type(message::eLocate_request_msg);
- request.mutable_base_info()->set_sender(message::eMain);
- request.mutable_base_info()->set_receiver(message::eMeasurer);
- //request.mutable_base_info()->set_timeout_ms(1000);
- request.set_command_id(exe_id+n++);
- request.set_terminal_id(rand()%6);
- message::Measure_response_msg response;
- message::Measure_request_msg request_1;
- std::string str=request.SerializeAsString();
- Error_manager code=pLocator->locate_request(request,response);
- if(code!=SUCCESS)
- {
- std::cout<<code.to_string()<<std::endl;
- }
- else if(request.command_id()==response.command_id()){
- std::cout<<" Success request command :"<<response.DebugString()<<std::endl;
- std::cout<<" n == "<<n<<std::endl;
- }
- k++;
- usleep(1000*500);
- }
- return 0;
- }
|