Browse Source

1.Change tool/map_lanetoxodr. Add License.

yuchuli 3 years ago
parent
commit
4576fba809

+ 71 - 0
src/tool/map_lanetoxodr/adclicenseserv.cpp

@@ -0,0 +1,71 @@
+#include "adclicenseserv.h"
+
+#include <QProcess>
+#include "modulecomm.h"
+#include <thread>
+#include <iostream>
+
+namespace iv {
+struct ivlicensekey
+{
+    bool linshikey;
+    bool yongjiukey;
+};
+}
+
+
+iv::ivlicensekey gkey;
+void * gpa;
+bool gbHaveRecvKey = false;
+
+
+
+ADCLicenseServ::ADCLicenseServ()
+{
+
+}
+
+void ListenKey(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
+{
+
+    std::cout<<"key len is "<<nSize<<std::endl;
+    if(nSize >= sizeof (iv::ivlicensekey))
+    {
+        memcpy(&gkey,strdata,sizeof(iv::ivlicensekey));
+        std::cout<<" key 1:"<<gkey.linshikey<<"key 2:"<<gkey.yongjiukey<<std::endl;
+        gbHaveRecvKey = true;
+    }
+
+}
+
+
+int ADCLicenseServ::CheckLincese()
+{
+    gpa = iv::modulecomm::RegisterRecv("keyfeedback",ListenKey);
+    std::this_thread::sleep_for(std::chrono::milliseconds(100));
+    QProcess * pProc = new QProcess();
+//    pProc->start("adc_key_win_exe.exe");
+    QTime xTime;
+    xTime.start();
+    while(gbHaveRecvKey == false)
+    {
+        std::this_thread::sleep_for(std::chrono::milliseconds(1));
+        if(xTime.elapsed()>10000)
+        {
+            break;
+        }
+    }
+    if(gbHaveRecvKey)
+    {
+        if((gkey.yongjiukey == true)||(gkey.linshikey == true))
+        {
+            return  0;
+        }
+        else
+        {
+            return  -1;
+        }
+    }
+    return -2;
+
+}

+ 14 - 0
src/tool/map_lanetoxodr/adclicenseserv.h

@@ -0,0 +1,14 @@
+#ifndef ADCLICENSESERV_H
+#define ADCLICENSESERV_H
+
+
+class ADCLicenseServ
+{
+public:
+    ADCLicenseServ();
+
+public:
+    static int CheckLincese();
+};
+
+#endif // ADCLICENSESERV_H

+ 17 - 0
src/tool/map_lanetoxodr/main.cpp

@@ -12,6 +12,9 @@
 #endif
 
 #include <QApplication>
+#include <QMessageBox>
+
+#include "adclicenseserv.h"
 
 
 #ifdef ANDROID
@@ -75,6 +78,20 @@ int main(int argc, char *argv[])
 #ifdef XODRViewer
     XVMainWindow w;
 #else
+    int nRtn = ADCLicenseServ::CheckLincese();
+    if(nRtn == -1)
+    {
+        QMessageBox::warning(NULL,"Warning","License 错误,请申请Lincense",QMessageBox::YesAll);
+        return 0;
+    }
+    else
+    {
+        if(nRtn == -2)
+        {
+            QMessageBox::warning(NULL,"Warning","License服务启动失败",QMessageBox::YesAll);
+            return 0;
+        }
+    }
     MainWindow w;
 #endif
     w.show();

+ 3 - 1
src/tool/map_lanetoxodr/map_lanetoxodr.pro

@@ -28,6 +28,7 @@ QMAKE_LFLAGS += -no-pie
 
 
 SOURCES += \
+    adclicenseserv.cpp \
     autoconnect.cpp \
     autoroadcontact.cpp \
     dialogaddroadfromrtk.cpp \
@@ -76,6 +77,7 @@ SOURCES += \
     xodrscenfunc.cpp
 
 HEADERS += \
+    adclicenseserv.h \
     autoconnect.h \
     autoroadcontact.h \
     dialogaddroadfromrtk.h \
@@ -164,7 +166,7 @@ INCLUDEPATH += $$PWD/../../include/msgtype
 INCLUDEPATH += $$PWD/../../common/common/xodr
 
 
-#DEFINES += OPENDRIVE_EDITONLY
+DEFINES += OPENDRIVE_EDITONLY
 
 
 DISTFILES += \