Browse Source

change xodr2rd5_grpc. add grpc server set.

yuchuli 2 years ago
parent
commit
c6ba1aa755
2 changed files with 27 additions and 2 deletions
  1. 13 1
      src/test/xodr2rd5_grpc/main.cpp
  2. 14 1
      src/test/xodr2rd5_grpc/rd5route.cpp

+ 13 - 1
src/test/xodr2rd5_grpc/main.cpp

@@ -11,11 +11,13 @@
 
 static char gstr_inputpath[256];
 static char gstr_outputpath[256];
+static char gstr_grpcserver[256];
 
 void print_useage()
 {
     std::cout<<" -i --input $xodrfile : set  input file path. eq.  -i d:/lk.xodr"<<std::endl;
     std::cout<<" -o --output $outputfile : set output file. eq.  -o d:/test.rd5"<<std::endl;
+    std::cout<<" -s --grpcserver  set server grpc ip & port. eq.  -s 111.33.136.149:50091"<<std::endl;
     std::cout<<" -h --help print help"<<std::endl;
 }
 
@@ -29,7 +31,7 @@ int  GetOptLong(int argc, char *argv[]) {
     // 第几个元素的描述,即是long_opts的下标值
     int option_index = 0;
     // 设置短参数类型及是否需要参数
-    const char *optstring = "i:o:h";
+    const char *optstring = "i:o:s:h";
 
     // 设置长参数类型及其简写,比如 --reqarg <==>-r
     /*
@@ -48,6 +50,7 @@ int  GetOptLong(int argc, char *argv[]) {
     static struct option long_options[] = {
         {"input", required_argument, NULL, 'i'},
         {"output", required_argument, NULL, 'o'},
+        {"grpcserver", required_argument, NULL, 's'},
         {"help",  no_argument,       NULL, 'h'},
  //       {"optarg", optional_argument, NULL, 'o'},
         {0, 0, 0, 0}  // 添加 {0, 0, 0, 0} 是为了防止输入空值
@@ -72,6 +75,9 @@ int  GetOptLong(int argc, char *argv[]) {
         case 'o':
             strncpy(gstr_outputpath,optarg,255);
             break;
+        case 's':
+            strncpy(gstr_grpcserver,optarg,255);
+            break;
         case 'h':
             print_useage();
             nRtn = 1; //because use -h
@@ -138,6 +144,7 @@ int main(int argc, char *argv[])
 
     snprintf(gstr_inputpath,256," ");
     snprintf(gstr_outputpath,256," ");
+    snprintf(gstr_grpcserver,256," ");
 
     int nRtn = GetOptLong(argc,argv);
     if(nRtn == 1)  //show help,so exit.
@@ -213,6 +220,11 @@ int main(int argc, char *argv[])
     int nres;
 
     std::string strserverstr = GetServerstr();
+    if(strncmp(gstr_grpcserver , " ",255) != 0)
+    {
+        strserverstr = gstr_grpcserver;
+    }
+    std::cout<<" grpcserver: "<<strserverstr<<std::endl;
     carmakercvt * pcvt = new carmakercvt(strserverstr);
     nres = pcvt->GetRes(strinputname,stroutputname,strcmd,pstr_ptr,ninputsize,pout_ptr,noutputsize);
 

+ 14 - 1
src/test/xodr2rd5_grpc/rd5route.cpp

@@ -18,6 +18,8 @@ static char gstr_fromlane[256];
 static char gstr_toroad[256];
 static char gstr_tolane[256];
 
+static char gstr_grpcserver[256];
+
 void print_useage()
 {
     std::cout<<" -i --input $xodrfile : set  input file path. eq.  -i d:/lk.rd5"<<std::endl;
@@ -26,6 +28,7 @@ void print_useage()
     std::cout<<" -b --from lane . eq. -b -1"<<std::endl;
     std::cout<<" -c --to road.  eq. -c 3"<<std::endl;
     std::cout<<" -d --to lane . eq. -d -1"<<std::endl;
+    std::cout<<" -s --grpcserver  set server grpc ip & port. eq.  -s 111.33.136.149:50091"<<std::endl;
     std::cout<<" -h --help print help"<<std::endl;
 }
 
@@ -39,7 +42,7 @@ int  GetOptLong(int argc, char *argv[]) {
     // 第几个元素的描述,即是long_opts的下标值
     int option_index = 0;
     // 设置短参数类型及是否需要参数
-    const char *optstring = "i:o:a:b:c:d:h";
+    const char *optstring = "i:o:a:b:c:d:s:h";
 
     // 设置长参数类型及其简写,比如 --reqarg <==>-r
     /*
@@ -62,6 +65,7 @@ int  GetOptLong(int argc, char *argv[]) {
         {"fromlane", required_argument, NULL, 'b'},
         {"toroad", required_argument, NULL, 'c'},
         {"tolane", required_argument, NULL, 'd'},
+        {"grpcserver", required_argument, NULL, 's'},
         {"help",  no_argument,       NULL, 'h'},
  //       {"optarg", optional_argument, NULL, 'o'},
         {0, 0, 0, 0}  // 添加 {0, 0, 0, 0} 是为了防止输入空值
@@ -98,6 +102,9 @@ int  GetOptLong(int argc, char *argv[]) {
         case 'd':
             strncpy(gstr_tolane,optarg,255);
             break;
+        case 's':
+            strncpy(gstr_grpcserver,optarg,255);
+            break;
         case 'h':
             print_useage();
             nRtn = 1; //because use -h
@@ -163,6 +170,7 @@ int main(int argc, char *argv[])
 
     snprintf(gstr_inputpath,256," ");
     snprintf(gstr_outputpath,256," ");
+    snprintf(gstr_grpcserver,256," ");
 
     snprintf(gstr_fromroad,256,"1");
     snprintf(gstr_toroad,256,"3");
@@ -249,6 +257,11 @@ int main(int argc, char *argv[])
     int nres;
 
     std::string strserverstr = GetServerstr();
+    if(strncmp(gstr_grpcserver , " ",255) != 0)
+    {
+        strserverstr = gstr_grpcserver;
+    }
+    std::cout<<" grpcserver: "<<strserverstr<<std::endl;
     carmakercvt * pcvt = new carmakercvt(strserverstr);
     nres = pcvt->GetRes(strinputname,stroutputname,strcmd,pstr_ptr,ninputsize,pout_ptr,noutputsize);