Kaynağa Gözat

#IQRV #comment [DeviceControl] 验证适配器流程打通

gifur 4 yıl önce
ebeveyn
işleme
aa094a0b71

+ 54 - 2
Module/mod_DeviceControl/DeviceAdaptChecker.cpp

@@ -2,7 +2,7 @@
 #include <vector>
 #include <string>
 
-ErrorCodeEnum CAdapterLoader::loadConfig()
+ErrorCodeEnum CAdapterLoader::LoadConfigFromRootIni()
 {
     ErrorCodeEnum result(Error_Succeed);
     CSmartPointer<IConfigInfo> spRootConfig;
@@ -55,7 +55,7 @@ void CAdapterLoadChecker::Init(CEntityBase* pEntity)
             CAdapterLoader* item = new CAdapterLoader(adapterList[i], pEntity);
             mAdapterConfigList[i] = item;
         }
-        mAdapterConfigList[i]->loadConfig();
+        mAdapterConfigList[i]->LoadConfigFromRootIni();
     }
 }
 
@@ -98,3 +98,55 @@ CAutoArray<CSimpleStringA> CAdapterLoadChecker::GetConfigedAdapterFileName()
     return result;
 }
 
+bool VendorLibInfoEx::Load(CSimpleStringA& adapterFilename)
+{
+    bool result(false);
+    
+#ifdef RVC_OS_WIN
+    CSimpleStringA strPrefix("");
+    CSimpleStringA strSuffix(".dll");
+#else
+    CSimpleStringA strPrefix("lib");
+    CSimpleStringA strSuffix(".so");
+#endif //RVC_OS_WIN
+
+    if (adapterFilename.GetLength() < strPrefix.GetLength() + strSuffix.GetLength()) {
+        return result;
+    }
+    /*lib3.5.7.9.so*/
+    CSimpleStringA pureAdapterName = adapterFilename.SubString(
+        strPrefix.GetLength(), adapterFilename.GetLength() - strPrefix.GetLength() - strSuffix.GetLength());
+    
+    CAutoArray<CSimpleStringA> adapterElems = pureAdapterName.Split('.');
+    if (adapterElems.GetCount() != 4) {
+        return result;
+    }
+
+    for (int i = 0; i < array_size(adapterList); ++i) {
+        if (adapterElems[0].Compare(adapterList[i]) == 0) {
+            result = true;
+            break;
+        }
+    }
+    ///**TODO(Gifur@10/19/2021): 保守写法,需考虑到文件名异常的情况 */
+    for (int i = 0; result && i < adapterElems.GetCount(); ++i) {
+        switch (i) {
+        case 0:
+            strDevice = adapterElems[i];
+            break;
+        case 1:
+            strVendor = adapterElems[i];
+            break;
+        case 2:
+            strVersion = adapterElems[i];
+            break;
+        case 3:
+            strBatch = adapterElems[i];
+            break;
+        default:
+            break;
+        }
+    }
+
+    return result;
+}

+ 4 - 3
Module/mod_DeviceControl/DeviceAdaptChecker.h

@@ -18,6 +18,8 @@ struct VendorLibInfoEx : public VendorLibInfo
     DWORD dwParam2 = 0;
 
     CSimpleStringA strDepDirWithSlash;
+
+    bool Load(CSimpleStringA& adapterFilename);
 };
 
 class CAdapterLoader
@@ -29,7 +31,7 @@ public:
     }
     ~CAdapterLoader() {}
 
-    ErrorCodeEnum loadConfig();
+    ErrorCodeEnum LoadConfigFromRootIni();
 
     bool IsNoAnyConfigure() const
     {
@@ -84,8 +86,7 @@ public:
 
     CAutoArray<CSimpleStringA> GetConfigedAdapterFileName();
 
-    static ErrorCodeEnum CheckDeviceAndAdapterAvailable(
-        const VendorLibInfoEx& vendorLibInfo, DWORD& dwErrorCode, CSimpleStringA& strErrMsg);
+    static ErrorCodeEnum CheckDeviceAndAdapterAvailable(const VendorLibInfoEx& vendorLibInfo, CSimpleStringA& strErrMsg);
 
 private:
     CAutoArray<CAdapterLoader*> mAdapterConfigList;

+ 40 - 30
Module/mod_DeviceControl/DeviceAdapterCheckerImpl.cpp

@@ -1,5 +1,5 @@
 #include "DeviceAdaptChecker.h"
-
+#include "fileutil.h"
 
 #include "PinPadClass.h"
 #include "CardIssuerClassPrivate.h"
@@ -11,10 +11,12 @@
 #include "GpioClass.h"
 #include "UpsClass.h"
 
-ErrorCodeEnum CAdapterLoadChecker::CheckDeviceAndAdapterAvailable(
-    const VendorLibInfoEx& libInfo, DWORD& dwErrorCode, CSimpleStringA& strErrMsg)
+ErrorCodeEnum CAdapterLoadChecker::CheckDeviceAndAdapterAvailable(const VendorLibInfoEx& libInfo, CSimpleStringA& strErrMsg)
 {
     ErrorCodeEnum result(Error_Succeed);
+
+
+
     int select = -1;
     for (int i = 0; libInfo.IsValid() && i < array_size(adapterList); ++i) {
         if (0 == strcmp(adapterList[i], libInfo.strDevice)) {
@@ -23,11 +25,19 @@ ErrorCodeEnum CAdapterLoadChecker::CheckDeviceAndAdapterAvailable(
         }
     }
 
+    CSimpleStringA strLibFullPath(libInfo.strDepDirWithSlash + libInfo.toLibNameString());
+    if (!ExistsFileA(strLibFullPath)) {
+        strErrMsg = CSimpleStringA::Format("%s 璺�緞涓嬫壘涓嶅埌 %s 鏂囦欢",
+                                           libInfo.strDepDirWithSlash.GetData(), libInfo.toLibNameString().GetData());
+        return Error_NotExist;
+    }
+
+
     switch (select) {
     case 0: //PinPad
     {
         DevAdptLibHelper<PinPadClass> devImpl;
-        result = devImpl.LoadUp(libInfo.strDepDirWithSlash + libInfo.toLibNameString());
+        result = devImpl.LoadUp(strLibFullPath);
         Dbg("Load returned: %s", SpStrError(result));
         if (Error_Succeed == result) {
             Dbg("%s: to open %p, %d, %d", __FUNCTION__, devImpl.GetDevPointer(), libInfo.dwPort, libInfo.dwBaudRate);
@@ -37,10 +47,10 @@ ErrorCodeEnum CAdapterLoadChecker::CheckDeviceAndAdapterAvailable(
                 DevErrorInfo devErrInfo;
                 memset(&devErrInfo, 0, sizeof(DevErrorInfo));
                 devImpl->GetLastErr(devErrInfo);
-                strErrMsg = CSimpleStringA::Format("打开设备失败:[%s] %s", SpStrError(result), devErrInfo.szErrMsg);
+                strErrMsg = CSimpleStringA::Format("鎵撳紑璁惧�澶辫触锛歔%s] %s", SpStrError(result), devErrInfo.szErrMsg);
             }
         } else {
-            strErrMsg = CSimpleStringA::Format("文件加载或获取对象失败:%s", SpStrError(result));
+            strErrMsg = CSimpleStringA::Format("鏂囦欢鍔犺浇鎴栬幏鍙栧�璞″け璐ワ細%s", SpStrError(result));
         }
         devImpl.TearDown();
     }
@@ -48,7 +58,7 @@ ErrorCodeEnum CAdapterLoadChecker::CheckDeviceAndAdapterAvailable(
     case 1: //CardIssuer
     {
         DevAdptLibHelper<CardIssuerClass> devImpl;
-        result = devImpl.LoadUp(libInfo.strDepDirWithSlash + libInfo.toLibNameString());
+        result = devImpl.LoadUp(strLibFullPath);
         Dbg("Load returned: %s", SpStrError(result));
         if (Error_Succeed == result) {
             Dbg("%s: to open %p, %d, %d", __FUNCTION__, devImpl.GetDevPointer(), libInfo.dwPort, libInfo.dwBaudRate);
@@ -59,10 +69,10 @@ ErrorCodeEnum CAdapterLoadChecker::CheckDeviceAndAdapterAvailable(
                 DevErrorInfo devErrInfo;
                 memset(&devErrInfo, 0, sizeof(DevErrorInfo));
                 devImpl->GetLastErr(devErrInfo);
-                strErrMsg = CSimpleStringA::Format("打开设备失败:[%s] %s", SpStrError(result), devErrInfo.szErrMsg);
+                strErrMsg = CSimpleStringA::Format("鎵撳紑璁惧�澶辫触锛歔%s] %s", SpStrError(result), devErrInfo.szErrMsg);
             }
         } else {
-            strErrMsg = CSimpleStringA::Format("文件加载或获取对象失败:%s", SpStrError(result));
+            strErrMsg = CSimpleStringA::Format("鏂囦欢鍔犺浇鎴栬幏鍙栧�璞″け璐ワ細%s", SpStrError(result));
         }
         devImpl.TearDown();
     }
@@ -70,7 +80,7 @@ ErrorCodeEnum CAdapterLoadChecker::CheckDeviceAndAdapterAvailable(
     case 2: //IDCertificate
     {
         DevAdptLibHelper<IDCerClass> devImpl;
-        result = devImpl.LoadUp(libInfo.strDepDirWithSlash + libInfo.toLibNameString());
+        result = devImpl.LoadUp(strLibFullPath);
         Dbg("Load returned: %s", SpStrError(result));
         if (Error_Succeed == result) {
             Dbg("%s: to open %p, %d", __FUNCTION__, devImpl.GetDevPointer(), libInfo.dwPort);
@@ -80,10 +90,10 @@ ErrorCodeEnum CAdapterLoadChecker::CheckDeviceAndAdapterAvailable(
                 DevErrorInfo devErrInfo;
                 memset(&devErrInfo, 0, sizeof(DevErrorInfo));
                 devImpl->GetLastErr(devErrInfo);
-                strErrMsg = CSimpleStringA::Format("打开设备失败:[%s] %s", SpStrError(result), devErrInfo.szErrMsg);
+                strErrMsg = CSimpleStringA::Format("鎵撳紑璁惧�澶辫触锛歔%s] %s", SpStrError(result), devErrInfo.szErrMsg);
             }
         } else {
-            strErrMsg = CSimpleStringA::Format("文件加载或获取对象失败:%s", SpStrError(result));
+            strErrMsg = CSimpleStringA::Format("鏂囦欢鍔犺浇鎴栬幏鍙栧�璞″け璐ワ細%s", SpStrError(result));
         }
         devImpl.TearDown();
     }
@@ -91,7 +101,7 @@ ErrorCodeEnum CAdapterLoadChecker::CheckDeviceAndAdapterAvailable(
     case 3: //ContactlessCard
     {
         DevAdptLibHelper<RFICClass> devImpl;
-        result = devImpl.LoadUp(libInfo.strDepDirWithSlash + libInfo.toLibNameString());
+        result = devImpl.LoadUp(strLibFullPath);
         Dbg("Load returned: %s", SpStrError(result));
         if (Error_Succeed == result) {
             Dbg("%s: to open %p, %d, %d", __FUNCTION__, devImpl.GetDevPointer(), libInfo.dwPort, libInfo.dwBaudRate);
@@ -101,10 +111,10 @@ ErrorCodeEnum CAdapterLoadChecker::CheckDeviceAndAdapterAvailable(
                 DevErrorInfo devErrInfo;
                 memset(&devErrInfo, 0, sizeof(DevErrorInfo));
                 devImpl->GetLastErr(devErrInfo);
-                strErrMsg = CSimpleStringA::Format("打开设备失败:[%s] %s", SpStrError(result), devErrInfo.szErrMsg);
+                strErrMsg = CSimpleStringA::Format("鎵撳紑璁惧�澶辫触锛歔%s] %s", SpStrError(result), devErrInfo.szErrMsg);
             }
         } else {
-            strErrMsg = CSimpleStringA::Format("文件加载或获取对象失败:%s", SpStrError(result));
+            strErrMsg = CSimpleStringA::Format("鏂囦欢鍔犺浇鎴栬幏鍙栧�璞″け璐ワ細%s", SpStrError(result));
         }
         devImpl.TearDown();
     }
@@ -112,7 +122,7 @@ ErrorCodeEnum CAdapterLoadChecker::CheckDeviceAndAdapterAvailable(
     case 4: //HSPScanner
     {
         DevAdptLibHelper<CHSPSClass> devImpl;
-        result = devImpl.LoadUp(libInfo.strDepDirWithSlash + libInfo.toLibNameString());
+        result = devImpl.LoadUp(strLibFullPath);
         Dbg("Load returned: %s", SpStrError(result));
         if (Error_Succeed == result) {
             Dbg("%s: to open %p", __FUNCTION__, devImpl.GetDevPointer());
@@ -122,10 +132,10 @@ ErrorCodeEnum CAdapterLoadChecker::CheckDeviceAndAdapterAvailable(
                 DevErrorInfo devErrInfo;
                 memset(&devErrInfo, 0, sizeof(DevErrorInfo));
                 devImpl->GetLastErr(devErrInfo);
-                strErrMsg = CSimpleStringA::Format("打开设备失败:[%s] %s", SpStrError(result), devErrInfo.szErrMsg);
+                strErrMsg = CSimpleStringA::Format("鎵撳紑璁惧�澶辫触锛歔%s] %s", SpStrError(result), devErrInfo.szErrMsg);
             }
         } else {
-            strErrMsg = CSimpleStringA::Format("文件加载或获取对象失败:%s", SpStrError(result));
+            strErrMsg = CSimpleStringA::Format("鏂囦欢鍔犺浇鎴栬幏鍙栧�璞″け璐ワ細%s", SpStrError(result));
         }
         devImpl.TearDown();
     }
@@ -133,7 +143,7 @@ ErrorCodeEnum CAdapterLoadChecker::CheckDeviceAndAdapterAvailable(
     case 5: //FingerPrint
     {
         DevAdptLibHelper<FingerPrintClass> devImpl;
-        result = devImpl.LoadUp(libInfo.strDepDirWithSlash + libInfo.toLibNameString());
+        result = devImpl.LoadUp(strLibFullPath);
         Dbg("Load returned: %s", SpStrError(result));
         if (Error_Succeed == result) {
             Dbg("%s: to open %p, %d, %d", __FUNCTION__, devImpl.GetDevPointer(), libInfo.dwPort, libInfo.dwBaudRate);
@@ -143,10 +153,10 @@ ErrorCodeEnum CAdapterLoadChecker::CheckDeviceAndAdapterAvailable(
                 DevErrorInfo devErrInfo;
                 memset(&devErrInfo, 0, sizeof(DevErrorInfo));
                 devImpl->GetLastErr(devErrInfo);
-                strErrMsg = CSimpleStringA::Format("打开设备失败:[%s] %s", SpStrError(result), devErrInfo.szErrMsg);
+                strErrMsg = CSimpleStringA::Format("鎵撳紑璁惧�澶辫触锛歔%s] %s", SpStrError(result), devErrInfo.szErrMsg);
             }
         } else {
-            strErrMsg = CSimpleStringA::Format("文件加载或获取对象失败:%s", SpStrError(result));
+            strErrMsg = CSimpleStringA::Format("鏂囦欢鍔犺浇鎴栬幏鍙栧�璞″け璐ワ細%s", SpStrError(result));
         }
         devImpl.TearDown();
     }
@@ -154,7 +164,7 @@ ErrorCodeEnum CAdapterLoadChecker::CheckDeviceAndAdapterAvailable(
     case 6: //WatchDog
     {
         DevAdptLibHelper<WatchDogClass> devImpl;
-        result = devImpl.LoadUp(libInfo.strDepDirWithSlash + libInfo.toLibNameString());
+        result = devImpl.LoadUp(strLibFullPath);
         Dbg("Load returned: %s", SpStrError(result));
         if (Error_Succeed == result) {
             Dbg("%s: to open %p", __FUNCTION__, devImpl.GetDevPointer());
@@ -164,10 +174,10 @@ ErrorCodeEnum CAdapterLoadChecker::CheckDeviceAndAdapterAvailable(
                 DevErrorInfo devErrInfo;
                 memset(&devErrInfo, 0, sizeof(DevErrorInfo));
                 devImpl->GetLastErr(devErrInfo);
-                strErrMsg = CSimpleStringA::Format("打开设备失败:[%s] %s", SpStrError(result), devErrInfo.szErrMsg);
+                strErrMsg = CSimpleStringA::Format("鎵撳紑璁惧�澶辫触锛歔%s] %s", SpStrError(result), devErrInfo.szErrMsg);
             }
         } else {
-            strErrMsg = CSimpleStringA::Format("文件加载或获取对象失败:%s", SpStrError(result));
+            strErrMsg = CSimpleStringA::Format("鏂囦欢鍔犺浇鎴栬幏鍙栧�璞″け璐ワ細%s", SpStrError(result));
         }
         devImpl.TearDown();
     }
@@ -175,7 +185,7 @@ ErrorCodeEnum CAdapterLoadChecker::CheckDeviceAndAdapterAvailable(
     case 7: //Gpio
     {
         DevAdptLibHelper<GpioClass> devImpl;
-        result = devImpl.LoadUp(libInfo.strDepDirWithSlash + libInfo.toLibNameString());
+        result = devImpl.LoadUp(strLibFullPath);
         Dbg("Load returned: %s", SpStrError(result));
         if (Error_Succeed == result) {
             GpioInitParam param = { libInfo.dwPort, libInfo.dwBaudRate, 4, {true, true, false, true} };
@@ -186,10 +196,10 @@ ErrorCodeEnum CAdapterLoadChecker::CheckDeviceAndAdapterAvailable(
                 DevErrorInfo devErrInfo;
                 memset(&devErrInfo, 0, sizeof(DevErrorInfo));
                 devImpl->GetLastErr(devErrInfo);
-                strErrMsg = CSimpleStringA::Format("打开设备失败:[%s] %s", SpStrError(result), devErrInfo.szErrMsg);
+                strErrMsg = CSimpleStringA::Format("鎵撳紑璁惧�澶辫触锛歔%s] %s", SpStrError(result), devErrInfo.szErrMsg);
             }
         } else {
-            strErrMsg = CSimpleStringA::Format("文件加载或获取对象失败:%s", SpStrError(result));
+            strErrMsg = CSimpleStringA::Format("鏂囦欢鍔犺浇鎴栬幏鍙栧�璞″け璐ワ細%s", SpStrError(result));
         }
         devImpl.TearDown();
     }
@@ -197,7 +207,7 @@ ErrorCodeEnum CAdapterLoadChecker::CheckDeviceAndAdapterAvailable(
     case 8: //Ups
     {
         DevAdptLibHelper<UpsClass> devImpl;
-        result = devImpl.LoadUp(libInfo.strDepDirWithSlash + libInfo.toLibNameString());
+        result = devImpl.LoadUp(strLibFullPath);
         Dbg("Load returned: %s", SpStrError(result));
         if (Error_Succeed == result) {
             Dbg("%s: to open %p, %d, %d", __FUNCTION__, devImpl.GetDevPointer(), libInfo.dwPort, libInfo.dwBaudRate);
@@ -207,10 +217,10 @@ ErrorCodeEnum CAdapterLoadChecker::CheckDeviceAndAdapterAvailable(
                 DevErrorInfo devErrInfo;
                 memset(&devErrInfo, 0, sizeof(DevErrorInfo));
                 devImpl->GetLastErr(devErrInfo);
-                strErrMsg = CSimpleStringA::Format("打开设备失败:[%s] %s", SpStrError(result), devErrInfo.szErrMsg);
+                strErrMsg = CSimpleStringA::Format("鎵撳紑璁惧�澶辫触锛歔%s] %s", SpStrError(result), devErrInfo.szErrMsg);
             }
         } else {
-            strErrMsg = CSimpleStringA::Format("文件加载或获取对象失败:%s", SpStrError(result));
+            strErrMsg = CSimpleStringA::Format("鏂囦欢鍔犺浇鎴栬幏鍙栧�璞″け璐ワ細%s", SpStrError(result));
         }
         devImpl.TearDown();
     }

+ 6 - 1
Module/mod_DeviceControl/DeviceControl.xml

@@ -158,6 +158,11 @@
         <param name="filenames" type="array_string"/>
         <!--0x1:exist; 0x2: root current config-->
         <param name="status" type="array_int"/>
+        <param name="port" type="array_int"/>
+        <param name="baudrate" type="array_int" />
+        <param name="param1" type="array_string"/>
+        <param name="param2" type="array_string"/>
+
       </res>
     </twoway>
     <twoway name="TestAdapterFileAvailable" overlap="true">
@@ -174,7 +179,7 @@
         <param name="param4" type="string" />
       </req>
       <res>
-        <!--0x1: exists; 0x2: load succ; 0x4: open succ.-->
+        <!--0x1: not exists; 0x2: load failed; 0x3: open failed-->
         <param name="status" type="uint" />
         <param name="msg" type="string" />
       </res>

+ 5 - 1
Module/mod_DeviceControl/DeviceControl_def_g.h

@@ -306,10 +306,14 @@ struct DeviceControlService_GetVendorFileList_Ans
 	CSimpleStringA msg;
 	CAutoArray<CSimpleStringA> filenames;
 	CAutoArray<int> status;
+	CAutoArray<int> port;
+	CAutoArray<int> baudrate;
+	CAutoArray<CSimpleStringA> param1;
+	CAutoArray<CSimpleStringA> param2;
 
 	void Serialize(SpBuffer &Buf)
 	{
-		auto & buf = Buf & result & msg & filenames & status;
+		auto & buf = Buf & result & msg & filenames & status & port & baudrate & param1 & param2;
 	}
 
 };

+ 30 - 5
Module/mod_DeviceControl/mod_DeviceControl.cpp

@@ -301,7 +301,8 @@ void CDeviceControlEntity::GetVendorFileList(SpReqAnsContext<DeviceControlServic
     return;
 }
 
-void CDeviceControlEntity::TestAdapterFileAvailable(SpReqAnsContext<DeviceControlService_TestAdapterFileAvailable_Req, DeviceControlService_TestAdapterFileAvailable_Ans>::Pointer ctx)
+void CDeviceControlEntity::TestAdapterFileAvailable(
+    SpReqAnsContext<DeviceControlService_TestAdapterFileAvailable_Req, DeviceControlService_TestAdapterFileAvailable_Ans>::Pointer ctx)
 {
     LOG_FUNCTION();
 
@@ -309,12 +310,36 @@ void CDeviceControlEntity::TestAdapterFileAvailable(SpReqAnsContext<DeviceContro
     int tmpResult = 0;
     CSimpleStringA tmpMsg(true);
 
-    CAdapterLoader loader(ctx->Req.filename, this);
-    tmpResult = loader.loadConfig();
+    if (ctx->Req.filename.IsNullOrEmpty()) {
+        ctx->Answer(Error_Param);
+        return;
+    }
+    
+    VendorLibInfoEx libInfo;
+    if (libInfo.Load(ctx->Req.filename)) {
+
+        libInfo.dwPort = ctx->Req.port;
+        libInfo.dwBaudRate = ctx->Req.baudrate;
+        libInfo.dwParam1 = ctx->Req.param1;
+        libInfo.dwParam2 = ctx->Req.param2;
+
+        GetFunction()->GetPath("Dep", libInfo.strDepDirWithSlash);
+        libInfo.strDepDirWithSlash += SPLIT_SLASH_STR;
+
+    } else if(ctx->Req.filename.IndexOf(".") == -1) { //pure adapter name
+
+        CAdapterLoader loader(ctx->Req.filename, this);
+        tmpResult = loader.LoadConfigFromRootIni();
+        libInfo = loader.vendorLibInfo;
+
+    } else {
+        Dbg("invalid adapter file name: %s", ctx->Req.filename.GetData());
+        ctx->Answer(Error_MisMatched);
+        return;
+    }
 
     if (tmpResult == 0) {
-        DWORD userCode(0);
-        ErrorCodeEnum ec = CAdapterLoadChecker::CheckDeviceAndAdapterAvailable(loader.vendorLibInfo, userCode, tmpMsg);
+        tmpResult = CAdapterLoadChecker::CheckDeviceAndAdapterAvailable(libInfo, tmpMsg);
     }
 
     ctx->Ans.status = tmpResult;

+ 58 - 22
addin/res/ManagerDesktop/guide.html

@@ -340,78 +340,114 @@
                                 </div>
                                 <div class="controls text-left">
                                     <div id="gui_adapter_config_device" class="select_on_normal device_selected_save_btn"
-                                        onclick="SelectItem(this)" value="*"></div>
+                                        onclick="SelectItem(this)" value=""></div>
                                     <div id="gui_adapter_config_device_list" class="select_list hide">
-                                        <div id="gui_adapter_config_device_list_item_0" option="PinPad" class="select_medium">
+                                        <div id="gui_adapter_config_device_list_item_0" option="PinPad" class="select_medium"
+                                         onclick="DeviceSelectChange('PinPad')">
                                             密码键盘
                                         </div>
-                                        <div id="gui_adapter_config_device_list_item_1" option="CardIssuer" class="select_medium">
+                                        <div id="gui_adapter_config_device_list_item_1" option="CardIssuer" class="select_medium"
+                                        onclick="DeviceSelectChange('CardIssuer')">
                                             发卡器
                                         </div>
-                                        <div id="gui_adapter_config_device_list_item_2" option="IDCertificate" class="select_medium">
+                                        <div id="gui_adapter_config_device_list_item_2" option="IDCertificate" class="select_medium"
+                                        onclick="DeviceSelectChange('IDCertificate')">
                                             身份证阅读器
                                         </div>
-                                        <div id="gui_adapter_config_device_list_item_3" option="ContactlessCard" class="select_medium">
+                                        <div id="gui_adapter_config_device_list_item_3" option="ContactlessCard" class="select_medium"
+                                        onclick="DeviceSelectChange('ContactlessCard')">
                                             非接读卡器
                                         </div>
-                                        <div id="gui_adapter_config_device_list_item_4" option="HSPScanner" class="select_medium">
+                                        <div id="gui_adapter_config_device_list_item_4" option="HSPScanner" class="select_medium"
+                                        onclick="DeviceSelectChange('HSPScanner')">
                                             高拍仪
                                         </div>
-                                        <div id="gui_adapter_config_device_list_item_5" option="FingerPrint" class="select_medium">
+                                        <div id="gui_adapter_config_device_list_item_5" option="FingerPrint" class="select_medium"
+                                        onclick="DeviceSelectChange('FingerPrint')">
                                             指纹仪
                                         </div>
-                                        <div id="gui_adapter_config_device_list_item_6" option="WatchDog" class="select_medium">
+                                        <div id="gui_adapter_config_device_list_item_6" option="WatchDog" class="select_medium"
+                                        onclick="DeviceSelectChange('WatchDog')">
                                             看门狗
                                         </div>
-                                        <div id="gui_adapter_config_device_list_item_7" option="Gpio" class="select_medium">
+                                        <div id="gui_adapter_config_device_list_item_7" option="Gpio" class="select_medium"
+                                        onclick="DeviceSelectChange('Gpio')">
                                             GPIO
                                         </div>
-                                        <div id="gui_adapter_config_device_list_item_8" option="Ups" class="select_medium">
+                                        <div id="gui_adapter_config_device_list_item_8" option="Ups" class="select_medium"
+                                        onclick="DeviceSelectChange('Ups')">
                                             UPS
                                         </div>
-                                        <div id="gui_adapter_config_device_list_item_9" option="*" class="select_medium">
+                                        <div id="gui_adapter_config_device_list_item_9" option="*" class="select_medium"
+                                        onclick="DeviceSelectChange('*')">
                                             全部
                                         </div>
                                     </div>
                                 </div>
                             </div>
-                            <div id="gui_adapter_config_vendor_div" class="clearboth" style="padding-top:30px;">
+                            <div id="gui_adapter_config_vendor_div" class="clearboth" style="padding-top:20px;">
                                 <div class="pull-left" style="width:330px;">
                                     <div class="text-right guide_input_label">设备厂商</div>
                                 </div>
                                 <div class="controls text-left">
                                     <div id="gui_adapter_config_vendor" class="select_on_normal btn_disabled"
-                                        onclick="SelectItem(this)" value="*"></div>
+                                        onclick="SelectItem(this)" value=""></div>
                                     <div id="gui_adapter_config_vendor_list" class="select_list hide">
-                                        <div id="gui_adapter_config_vendor_list_item_0" option="CW" class="select_medium">
+                                        <div id="gui_adapter_config_vendor_list_item_0" option="CW" class="select_medium"
+                                        onclick="VendorSelectChanged('CW')">
                                             恒银金融
                                         </div>
-                                        <div id="gui_adapter_config_vendor_list_item_1" option="KEBA" class="select_medium">
+                                        <div id="gui_adapter_config_vendor_list_item_1" option="KEBA" class="select_medium"
+                                        onclick="VendorSelectChanged('KEBA')">
                                             中钞科堡
                                         </div>
-                                        <div id="gui_adapter_config_vendor_list_item_2" option="GRG" class="select_medium">
+                                        <div id="gui_adapter_config_vendor_list_item_2" option="GRG" class="select_medium"
+                                        onclick="VendorSelectChanged('GRG')">
                                             广电运通
                                         </div>
-                                        <div id="gui_adapter_config_vendor_list_item_3" option="NANTIAN" class="select_medium">
+                                        <div id="gui_adapter_config_vendor_list_item_3" option="NANTIAN" class="select_medium"
+                                        onclick="VendorSelectChanged('NANTIAN')">
                                             云南南天
                                         </div>
-                                        <div id="gui_adapter_config_vendor_list_item_4" option="GWI" class="select_medium">
+                                        <div id="gui_adapter_config_vendor_list_item_4" option="GWI" class="select_medium"
+                                        onclick="VendorSelectChanged('GWI')">
                                             长城信息
                                         </div>
-                                        <div id="gui_adapter_config_vendor_list_item_5" option="*" class="select_medium">
+                                        <div id="gui_adapter_config_vendor_list_item_5" option="*" class="select_medium"
+                                        onclick="VendorSelectChanged('*')">
                                             全部
                                         </div>
                                     </div>
                                 </div>
                             </div>
-                            <div class="clearboth border_bottom" style="height:30px;width:480px; margin-left:100px; margin-right: 200px;"></div>
+                            <div id="interest_root_ini_div" class="clearboth" style="padding-top:20px;">
+                                <div class="pull-left" style="width:330px;">
+                                    <div class="text-right guide_input_label">&nbsp;</div>
+                                </div>
+                                <div class="pull-left margin-right-10">
+                                    <div style="margin-top:8px;">仅关注(root.ini)已配置内容</div>
+                                </div>
+                                <div class="pull-left">
+                                    <!-- <div id="gui_adapter_config_root_interest_switch" style="margin-top:8px;"
+                                        class="check_off margin_right_10"
+                                        onclick="EMUI.GuideController.captiveModifyPasswordSwitch(this)">
+                                    </div> -->
+                                    <div id="gui_adapter_config_root_interest_switch" style="margin-top:5px;"
+                                        class="switch_on margin_right_10"
+                                        onclick="Switch(this, InterestRootSwitch)">
+                                    </div>
+                                </div>
+                                
+                            </div>
+                            
+                            <div class="clearboth border_bottom" style="height:20px;width:480px; margin-left:100px; margin-right: 200px;"></div>
                             <div id="gui_adapter_config_adapter_div" class="clearboth" style="padding-top:30px;">
                                 <div class="pull-left" style="width:330px;">
                                     <div class="text-right guide_input_label">适配器列表</div>
                                 </div>
                                 <div class="controls text-left">
                                     <div id="gui_adapter_config_adapter" class="select_on_normal"
-                                        onclick="SelectItem(this)" value="*"></div>
+                                        onclick="SelectItem(this)" value=""></div>
                                     <div id="gui_adapter_config_adapter_list" class="select_list hide">
                                     </div>
                                 </div>
@@ -457,7 +493,7 @@
                             
                             <div class="clearboth" style="padding-top:30px">
                                 <div class="controls" style="margin-left: 140px;"><button class="btn_normal_short"
-                                        id="guide_adapter_config_check">测试</button></div>
+                                        id="guide_adapter_config_test">测试</button></div>
                                 <div class="controls"><button class="btn_normal_short"
                                     id="guide_adapter_config_next">保存</button></div>
                             </div>

+ 183 - 176
addin/res/ManagerDesktop/js/guide.js

@@ -39,173 +39,35 @@ var VENDOR = {
 };
 
 var globalFinishedFlag = false;
+var globalInterestRootFlag = false;
 
-$(function () {
-    
-    RVC.GuideController = RVC.Object.extend({
-        hideAllPage: function () {
-            $('#guide_start_page').hide();
-            $('#guide_init_param_page').hide();
-            $('#guide_sync_centersetting_page').hide();
-            $('#guide_access_authorize_page').hide();
-            $('#guide_media_config_page').hide();
-            $('#guide_finish_page').hide();
-            $('#guide_reboot_page').hide();
-        },
-        hideAllRebootTipElem: function() {
-            $('#reboot_operate').hide();
-            $('#guide_rebootinfo').hide();
-            $('#guide_rebootinfo_need_restart').hide();
-            $('#guide_rebootinfo_need_reboot').hide();
-            $('#guide_reboot_application_button').hide();
-            $('#guide_reboot_device_button').hide();
-
-            $('#guide_finished_button').hide();
-            $('#guide_finish_device_button').hide();
-            $('#guide_save_loading').hide();
-            $('#guide_reboot_loading').hide();
-            $('#guide_restart_loading').hide();
-        },
-        resizeWindow: function () {
-            var winHei = $(window).height();
-            var popHeight = 480;
-            var adjustHeight = 0;
-            var blueBackgroundHeight = 0;
-            if (winHei < 860) {
-                winHei = 860;
-            }
-            blueBackgroundHeight = winHei - $('.headcontainer').height() - $('#page_footer').height();
-            $('#guide_height').height(blueBackgroundHeight);
-            adjustHeight = (blueBackgroundHeight - popHeight) * 0.5;
-
-            $('#guide_start_page').css('padding-top', (adjustHeight + 100) + 'px');
-            var domWidth = $('body').width();
-            var winWidth = $('window').width();
-            if (domWidth > winWidth) {
-                setTimeout(function () {
-                    $('body').scrollTop($('.headcontainer').height() + adjustHeight);
-                    $('body').scrollLeft(($('body').width() - $(window).width()) / 2);
-                }, 1000)
-            }
-            $('#guide_init_param_page').css('padding-top', adjustHeight + 'px');
-        },
-        beginInstall: function() {
-            this.gotoPage(CONST.DeployStep_GetTerminalInfo);
-        },
-        getPage: function(step) {
-            var select_page = '';
-            switch(step) {
-                case CONST.DeployStep_Begin:
-                    select_page = 'guide_start_page';
-                    break;
-                case CONST.DeployStep_GetTerminalInfo :
-                    select_page = 'guide_init_param_page';
-                    break;
-                case CONST.DeployStep_FetchCenterSettings:
-                    select_page = 'guide_sync_centersetting_page';
-                break;
-                case CONST.DeployStep_AccessAuthorize :
-                    select_page = 'guide_access_authorize_page';
-                break;
-                case CONST.DeployStep_MediaConfig :
-                    select_page = 'guide_media_config_page';
-                break;
-                case CONST.DeployStep_AdapterConfig : 
-                    select_page = 'guide_adapter_config_page';
-                break;
-                case CONST.DeployStep_Finished  :
-                    select_page = 'guide_finish_page';
-                break; 
-                default:
-                break;
-            }
-            return select_page;
-        },
-        checkPageAvailable: function(step) {
-            const select_page = this.getPage(step);
-            if(select_page !== '') {
-                return true;
-            } else {
-                return false;
-            }
-        },
-        preLoadPage: function(step) {
-            this.hideAllPage();
-            switch(step) {
-                case CONST.DeployStep_MediaConfig:
-                    FulfillMediaDeviceList();
-                    break;
-                case CONST.DeployStep_AdapterConfig:
-                    FulfillDevAdapterFileList();
-                    break;
-                default:
-                    break;
-            }
-        },
-        postLoadPage: function(step) {
-            switch(step) {
-                case CONST.DeployStep_Finished:
-                    globalFinishedFlag = true;
-                    break;
-                default:
-                    break;
-            }
-        },
-        gotoPage: function(nextStep) {
-
-            var select_page = this.getPage(nextStep);
-
-            if(select_page !== '') {
-                this.preLoadPage(nextStep);
-                $('#' + select_page).show();
-                this.postLoadPage(nextStep);
-            } else {
-                utilShowToast('无法识别步骤标识:' + nextStep, 3000);
-            }
-        },
-        sectOverPass: function() {
-
-        },
-        sectNext: function() {
 
-        },
-        setNavigaBtnAble: function(enable) {
-
-        }
-    });
+function VendorSelectChanged(name)
+{
+    utilStartAlertDialog(name);
+}
 
+function DeviceSelectChange(name)
+{
+    utilStartAlertDialog(name);
+}
 
-    RVC.CameraConfigEntity = RVC.EntityController.extend({
-        entityName: 'CameraConfigManage',
-        className: 'CameraConfigManageService',
-        methodID: {
-            GetMediaAvailableList: 9,
-            SetMediaDevice: 10,
-            TestAvailableMedieDev: 11
-        },
-        methodSignature: {
-            GetMediaAvailableList: -1547834445,
-            SetMediaDevice: -865058557,
-            TestAvailableMedieDev: -2126935432
-        },
+function AdapterSelectChange(name)
+{
+    //utilStartAlertDialog(name);
+}
 
-        GetMediaAvailableList: function(req, callback) {
-            this.webSocketInvokeEx(req, 
-                ({id:this.methodID.GetMediaAvailableList, sig:this.methodSignature.GetMediaAvailableList}),
-                 callback);
-        },
-        SetMediaDevice: function(req, callback) {
-            this.webSocketInvokeEx(req, 
-                ({id:this.methodID.SetMediaDevice, sig:this.methodSignature.SetMediaDevice}),
-                 callback);
-        },
-        TestAvailableMedieDev: function(req, callback) {
-            this.webSocketInvokeEx(req, 
-                ({id:this.methodID.TestAvailableMedieDev, sig:this.methodSignature.TestAvailableMedieDev}),
-                 callback);
-        }
-    });
+function InterestRootSwitch() 
+{
+    if ($('#gui_adapter_config_root_interest_switch').hasClass('switch_on')) {
+        globalInterestRootFlag = true;
+    } else {
+        globalInterestRootFlag = false;
+    }
+}
 
+$(function () {
+    
     function ResetDeployConfig() {
         let req = new Request();
         req.preStep = CONST.DeployStep_Begin;
@@ -395,7 +257,7 @@ $(function () {
         PreDeployTerminalWithIPAndPort(ip, port, true);
     }
 
-    function generateDeviceSelect(devices, select_id) {
+    function generateMediaDeviceSelect(devices, select_id) {
         var deviceLength = 0;
         if ((devices) instanceof Array) {
             deviceLength = devices.length;
@@ -440,6 +302,8 @@ $(function () {
             pushHtml = '<div id="{{type}}_item_{{loop}}" option="{{deviceName}}" class="select_medium hide_with_ellipsis"'
             if(!(status[loop] & 0x1)) {
                 pushHtml += ' style="color:#C0C0C0;"'
+            } else {
+                pushHtml += ' onclick="AdapterSelectChange(\'{{deviceName}}\')"'
             }
             //root.ini 配置
             if((status[loop] & 0x2)) {
@@ -477,10 +341,10 @@ $(function () {
                         cameras.push(result.AvailableList[n]);
                     }
                 }
-                generateDeviceSelect(loundspeakers, 'gui_media_config_audio_output_outfree_list');
-                generateDeviceSelect(loundspeakers, 'gui_media_config_audio_output_infree_list');
-                generateDeviceSelect(microphones, 'gui_media_config_audio_input_outfree_list');
-                generateDeviceSelect(microphones, 'gui_media_config_audio_input_infree_list');
+                generateMediaDeviceSelect(loundspeakers, 'gui_media_config_audio_output_outfree_list');
+                generateMediaDeviceSelect(loundspeakers, 'gui_media_config_audio_output_infree_list');
+                generateMediaDeviceSelect(microphones, 'gui_media_config_audio_input_outfree_list');
+                generateMediaDeviceSelect(microphones, 'gui_media_config_audio_input_infree_list');
                 if(typeof flag !== 'undefined') {
                     $('#gui_media_config_audio_input_infree').empty();
                     $('#gui_media_config_audio_input_infree').attr('value', '');
@@ -530,7 +394,7 @@ $(function () {
                     utilStartAlertDialog("操作失败:[" + result.result + "] " + result.msg);
                 }
             } else if(typeof flag !== 'undefined'){
-                RVC.CameraConfigEntity.commErrorCallback(ret);
+                RVC.DeviceControlEntityCtrl.commErrorCallback(ret);
             }
         });
     }
@@ -619,14 +483,14 @@ $(function () {
 
     }
 
-    function CheckDevAdapterAvailable(adapterName)
+    function CheckDevAdapterAvailable(adapter, port, baudrate)
     {
         let req = new Request();
-        req.filename= adapterName;
+        req.filename= adapter;
         req.type = 0;
         req.options = 0;
-        req.port = 0;
-        req.baudrate = 0;
+        req.port = parseInt(port, 10);
+        req.baudrate = parseInt(baudrate, 10);
         req.param1 = 0;
         req.param2 = 0;
         req.param3 = "";
@@ -635,13 +499,150 @@ $(function () {
         RVC.DeviceControlEntityCtrl.TestAdapterFileAvailable(req, function(ret) {
             if(ret.errorCode === 0) {
                 let result = JSON.parse(ret[RVC.EntityController.sigResponseUUID])
-                utilStartAlertDialog("操作结果:[" + result.status + "] " + result.msg);
-            } else if(typeof flag !== 'undefined'){
-                RVC.CameraConfigEntity.commErrorCallback(ret);
+                if(result.status == 0) {
+                    utilStartAlertDialog("指定适配器文件成功加载,且尝试打开设备成功!");
+                } else {
+                    utilStartAlertDialog("验证失败:[" + result.status + "] " + result.msg);
+                }
+            } else {
+                RVC.DeviceControlEntityCtrl.commErrorCallback(ret);
             }
         });
     }
 
+    RVC.GuideController = RVC.Object.extend({
+        hideAllPage: function () {
+            $('#guide_start_page').hide();
+            $('#guide_init_param_page').hide();
+            $('#guide_sync_centersetting_page').hide();
+            $('#guide_access_authorize_page').hide();
+            $('#guide_media_config_page').hide();
+            $('#guide_finish_page').hide();
+            $('#guide_reboot_page').hide();
+        },
+        hideAllRebootTipElem: function() {
+            $('#reboot_operate').hide();
+            $('#guide_rebootinfo').hide();
+            $('#guide_rebootinfo_need_restart').hide();
+            $('#guide_rebootinfo_need_reboot').hide();
+            $('#guide_reboot_application_button').hide();
+            $('#guide_reboot_device_button').hide();
+    
+            $('#guide_finished_button').hide();
+            $('#guide_finish_device_button').hide();
+            $('#guide_save_loading').hide();
+            $('#guide_reboot_loading').hide();
+            $('#guide_restart_loading').hide();
+        },
+        resizeWindow: function () {
+            var winHei = $(window).height();
+            var popHeight = 480;
+            var adjustHeight = 0;
+            var blueBackgroundHeight = 0;
+            if (winHei < 860) {
+                winHei = 860;
+            }
+            blueBackgroundHeight = winHei - $('.headcontainer').height() - $('#page_footer').height();
+            $('#guide_height').height(blueBackgroundHeight);
+            adjustHeight = (blueBackgroundHeight - popHeight) * 0.5;
+    
+            $('#guide_start_page').css('padding-top', (adjustHeight + 100) + 'px');
+            var domWidth = $('body').width();
+            var winWidth = $('window').width();
+            if (domWidth > winWidth) {
+                setTimeout(function () {
+                    $('body').scrollTop($('.headcontainer').height() + adjustHeight);
+                    $('body').scrollLeft(($('body').width() - $(window).width()) / 2);
+                }, 1000)
+            }
+            $('#guide_init_param_page').css('padding-top', adjustHeight + 'px');
+        },
+        beginInstall: function() {
+            this.gotoPage(CONST.DeployStep_GetTerminalInfo);
+        },
+        getPage: function(step) {
+            var select_page = '';
+            switch(step) {
+                case CONST.DeployStep_Begin:
+                    select_page = 'guide_start_page';
+                    break;
+                case CONST.DeployStep_GetTerminalInfo :
+                    select_page = 'guide_init_param_page';
+                    break;
+                case CONST.DeployStep_FetchCenterSettings:
+                    select_page = 'guide_sync_centersetting_page';
+                break;
+                case CONST.DeployStep_AccessAuthorize :
+                    select_page = 'guide_access_authorize_page';
+                break;
+                case CONST.DeployStep_MediaConfig :
+                    select_page = 'guide_media_config_page';
+                break;
+                case CONST.DeployStep_AdapterConfig : 
+                    select_page = 'guide_adapter_config_page';
+                break;
+                case CONST.DeployStep_Finished  :
+                    select_page = 'guide_finish_page';
+                break; 
+                default:
+                break;
+            }
+            return select_page;
+        },
+        checkPageAvailable: function(step) {
+            const select_page = this.getPage(step);
+            if(select_page !== '') {
+                return true;
+            } else {
+                return false;
+            }
+        },
+        preLoadPage: function(step) {
+            this.hideAllPage();
+            switch(step) {
+                case CONST.DeployStep_MediaConfig:
+                    FulfillMediaDeviceList();
+                    break;
+                case CONST.DeployStep_AdapterConfig:
+                    InterestRootSwitch();
+                    FulfillDevAdapterFileList();
+                    break;
+                default:
+                    break;
+            }
+        },
+        postLoadPage: function(step) {
+            switch(step) {
+                case CONST.DeployStep_Finished:
+                    globalFinishedFlag = true;
+                    break;
+                default:
+                    break;
+            }
+        },
+        gotoPage: function(nextStep) {
+    
+            var select_page = this.getPage(nextStep);
+    
+            if(select_page !== '') {
+                this.preLoadPage(nextStep);
+                $('#' + select_page).show();
+                this.postLoadPage(nextStep);
+            } else {
+                utilShowToast('无法识别步骤标识:' + nextStep, 3000);
+            }
+        },
+        sectOverPass: function() {
+    
+        },
+        sectNext: function() {
+    
+        },
+        setNavigaBtnAble: function(enable) {
+    
+        }
+    });
+
     $(document).on('click', '#guide_init_param_ip_check #ip_connect_check', function(){
         var ip = $('#guide_server_ip').val();
         console.log('ip: ' + ip);
@@ -670,9 +671,15 @@ $(function () {
 
     });
 
-    $(document).on('click', '#guide_adapter_config_check', function() {
+    $(document).on('click', '#guide_adapter_config_test', function() {
         var deviceName = $('#gui_adapter_config_device').attr('value');
-        CheckDevAdapterAvailable(deviceName);
+        var vendorName = $('#gui_adapter_config_vendor').attr('value');
+
+        var adapterName = $('#gui_adapter_config_adapter').attr('value');
+        var paramPort = $('#guide_adapter_config_port_input').val();
+        var paramBaudrate = $('#guide_adapter_config_baudrate_input').val();
+
+        CheckDevAdapterAvailable(adapterName, paramPort, paramBaudrate);
     });
 
     $(document).on('click', '#guide_sync_centersetting_next', function() {

+ 31 - 0
addin/res/ManagerDesktop/js/public.js

@@ -1776,6 +1776,37 @@ $(function () {
 
     });
 
+    RVC.CameraConfigEntity = RVC.EntityController.extend({
+        entityName: 'CameraConfigManage',
+        className: 'CameraConfigManageService',
+        methodID: {
+            GetMediaAvailableList: 9,
+            SetMediaDevice: 10,
+            TestAvailableMedieDev: 11
+        },
+        methodSignature: {
+            GetMediaAvailableList: -1547834445,
+            SetMediaDevice: -865058557,
+            TestAvailableMedieDev: -2126935432
+        },
+    
+        GetMediaAvailableList: function(req, callback) {
+            this.webSocketInvokeEx(req, 
+                ({id:this.methodID.GetMediaAvailableList, sig:this.methodSignature.GetMediaAvailableList}),
+                 callback);
+        },
+        SetMediaDevice: function(req, callback) {
+            this.webSocketInvokeEx(req, 
+                ({id:this.methodID.SetMediaDevice, sig:this.methodSignature.SetMediaDevice}),
+                 callback);
+        },
+        TestAvailableMedieDev: function(req, callback) {
+            this.webSocketInvokeEx(req, 
+                ({id:this.methodID.TestAvailableMedieDev, sig:this.methodSignature.TestAvailableMedieDev}),
+                 callback);
+        }
+    });
+
     RVC.DeviceControlEntityCtrl.init();
     RVC.HealthmanagerEntityCtrl.init();