test_locate_sample.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. //
  2. // Created by zx on 2020/7/3.
  3. //
  4. #include <iostream>
  5. #include "../lidar_locate/Locate_communicator.h";
  6. #include <unistd.h>
  7. #include "../tool/thread_safe_list.h"
  8. int main()
  9. {
  10. Locate_communicator* pLocator=Locate_communicator::get_instance_pointer();
  11. pLocator->communication_bind("tcp://127.0.0.1:9005");
  12. pLocator->communication_connect("tcp://127.0.0.1:9006");
  13. pLocator->communication_run();
  14. int k=1;
  15. Thread_safe_list<std::string*> list;
  16. /*nnxx::socket socket{ nnxx::SP, nnxx::BUS };
  17. socket.bind("tcp://127.0.0.1:9005");
  18. socket.connect("tcp://127.0.0.1:9006");*/
  19. while(1) {
  20. message::Measure_request_msg request;
  21. message::Base_info base_msg;
  22. request.mutable_base_info()->CopyFrom(base_msg);
  23. request.mutable_base_info()->set_msg_type(message::eLocate_request_msg);
  24. request.mutable_base_info()->set_sender(message::eMain);
  25. request.mutable_base_info()->set_receiver(message::eMeasurer);
  26. request.mutable_base_info()->set_timeout_ms(1000);
  27. request.set_command_id(222);
  28. request.set_terminal_id(0);
  29. message::Measure_response_msg response;
  30. message::Measure_request_msg request_1;
  31. std::string str=request.SerializeAsString();
  32. //socket.send(request_1.SerializeAsString());
  33. Error_manager code=pLocator->locate_request(request,response);
  34. if(code!=SUCCESS)
  35. {
  36. std::cout<<code.to_string()<<std::endl;
  37. }
  38. else if(request.command_id()==response.command_id()){
  39. std::cout<<" Success request command :"<<request.command_id()<<std::endl;
  40. }
  41. k++;
  42. usleep(1000*500);
  43. }
  44. return 0;
  45. }