123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- //
- // Created by zx on 2020/6/18.
- //
- #include <iostream>
- #include <glog/logging.h>
- #include "setting.pb.h"
- #include "lidar_locate/Locate_communicator.h"
- #include <fcntl.h>
- #include <google/protobuf/io/zero_copy_stream_impl.h>
- #include <google/protobuf/text_format.h>
- using google::protobuf::io::FileInputStream;
- using google::protobuf::io::FileOutputStream;
- using google::protobuf::io::ZeroCopyInputStream;
- using google::protobuf::io::CodedInputStream;
- using google::protobuf::io::ZeroCopyOutputStream;
- using google::protobuf::io::CodedOutputStream;
- using google::protobuf::Message;
- bool read_proto_param(std::string file, ::google::protobuf::Message& parameter)
- {
- int fd = open(file.c_str(), O_RDONLY);
- if (fd == -1) return false;
- FileInputStream* input = new FileInputStream(fd);
- bool success = google::protobuf::TextFormat::Parse(input, ¶meter);
- delete input;
- close(fd);
- return success;
- }
- int main(int argc,char* argv[])
- {
- //读取配置
- ///
- setting::global_setting parameter;
- if(false==read_proto_param("",parameter))
- {
- LOG(ERROR)<<"read setting file failed";
- return 0;
- }
- //创建各个模块的通讯对象
- setting::locate_setting locate_parameter=parameter.locate_parameter();
- Error_manager code=Locate_communicator::create_locate_communicator(locate_parameter.ip(),locate_parameter.port());
- if(code!=SUCCESS)
- {
- LOG(ERROR)<<code.to_string();
- }
- //测试各个模块
- // message::Command_message cmd_msg;
- // message::Locate_request_msg request;
- // message::Locate_response_msg result;
- //
- // code=Locate_communicator::get_instance()->locate_request(request,result);
- if(code!=SUCCESS)
- {
- LOG(ERROR)<<code.to_string();
- }
- return 0;
- }
|