main.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //
  2. // Created by zx on 2020/6/18.
  3. //
  4. #include <iostream>
  5. #include <glog/logging.h>
  6. #include "setting.pb.h"
  7. #include "lidar_locate/Locate_communicator.h"
  8. #include <fcntl.h>
  9. #include <google/protobuf/io/zero_copy_stream_impl.h>
  10. #include <google/protobuf/text_format.h>
  11. using google::protobuf::io::FileInputStream;
  12. using google::protobuf::io::FileOutputStream;
  13. using google::protobuf::io::ZeroCopyInputStream;
  14. using google::protobuf::io::CodedInputStream;
  15. using google::protobuf::io::ZeroCopyOutputStream;
  16. using google::protobuf::io::CodedOutputStream;
  17. using google::protobuf::Message;
  18. bool read_proto_param(std::string file, ::google::protobuf::Message& parameter)
  19. {
  20. int fd = open(file.c_str(), O_RDONLY);
  21. if (fd == -1) return false;
  22. FileInputStream* input = new FileInputStream(fd);
  23. bool success = google::protobuf::TextFormat::Parse(input, &parameter);
  24. delete input;
  25. close(fd);
  26. return success;
  27. }
  28. int main(int argc,char* argv[])
  29. {
  30. //读取配置
  31. ///
  32. setting::global_setting parameter;
  33. if(false==read_proto_param("",parameter))
  34. {
  35. LOG(ERROR)<<"read setting file failed";
  36. return 0;
  37. }
  38. //创建各个模块的通讯对象
  39. setting::locate_setting locate_parameter=parameter.locate_parameter();
  40. Error_manager code=Locate_communicator::create_locate_communicator(locate_parameter.ip(),locate_parameter.port());
  41. if(code!=SUCCESS)
  42. {
  43. LOG(ERROR)<<code.to_string();
  44. }
  45. //测试各个模块
  46. // message::Command_message cmd_msg;
  47. // message::Locate_request_msg request;
  48. // message::Locate_response_msg result;
  49. //
  50. // code=Locate_communicator::get_instance()->locate_request(request,result);
  51. if(code!=SUCCESS)
  52. {
  53. LOG(ERROR)<<code.to_string();
  54. }
  55. return 0;
  56. }