瀏覽代碼

#IQRV #comment [DeviceControl] 打通过滤条件切换

gifur 4 年之前
父節點
當前提交
3386341fc2

+ 9 - 2
Module/mod_DeviceControl/DeviceAdaptChecker.cpp

@@ -76,15 +76,22 @@ bool CAdapterLoadChecker::IsThisFileConfigure(LPCTSTR fileName)
     return result;
 }
 
-CAutoArray<CSimpleStringA> CAdapterLoadChecker::GetConfigedAdapterFileName()
+CAutoArray<CSimpleStringA> CAdapterLoadChecker::GetConfigedAdapterFileName(LPCTSTR device, LPCTSTR vendor)
 {
     CAutoArray<CSimpleStringA> result;
     std::vector<std::string> tmp;
+
+    const  bool deviceFilterFlag = (device != NULL && strlen(device) > 0);
+    const  bool vendorFilterFlag = (vendor != NULL && strlen(vendor) > 0);
+
+
     for (int i = 0; i < mAdapterConfigList.GetCount(); ++i) {
         if (mAdapterConfigList[i] == nullptr)
             continue;
         CAdapterLoader*& item = mAdapterConfigList[i];
-        if (item->IsFullConfig()) {
+        if (item->IsFullConfig() 
+            && (!deviceFilterFlag || item->vendorLibInfo.strDevice.Compare(device) == 0)
+            && (!vendorFilterFlag || item->vendorLibInfo.strVendor.Compare(vendor) == 0)) {
             tmp.push_back(std::string(item->GetAdaperFileName().GetData()));
         }
     }

+ 1 - 1
Module/mod_DeviceControl/DeviceAdaptChecker.h

@@ -84,7 +84,7 @@ public:
 
     bool IsThisFileConfigure(LPCTSTR fileName);
 
-    CAutoArray<CSimpleStringA> GetConfigedAdapterFileName();
+    CAutoArray<CSimpleStringA> GetConfigedAdapterFileName(LPCTSTR device = "", LPCTSTR vendor = "");
 
     static ErrorCodeEnum CheckDeviceAndAdapterAvailable(const VendorLibInfoEx& vendorLibInfo, CSimpleStringA& strErrMsg);
 

+ 5 - 1
Module/mod_DeviceControl/mod_DeviceControl.cpp

@@ -234,7 +234,11 @@ void CDeviceControlEntity::GetVendorFileList(SpReqAnsContext<DeviceControlServic
     if (ctx->Req.root) {
         CAdapterLoadChecker* checker = new CAdapterLoadChecker();
         checker->Init(this);
-        ctx->Ans.filenames = checker->GetConfigedAdapterFileName();
+        if (ctx->Req.adapter.IsNullOrEmpty() || ctx->Req.adapter.Compare("*") == 0) {
+            ctx->Ans.filenames = checker->GetConfigedAdapterFileName();
+        } else {
+            ctx->Ans.filenames = checker->GetConfigedAdapterFileName(ctx->Req.adapter);
+        }
         ctx->Ans.status.Init(ctx->Ans.filenames.GetCount());
         CSimpleStringA strDepDirPath2 = strDepDirPath + SPLIT_SLASH_STR;
         for (int i = 0; i < ctx->Ans.filenames.GetCount(); ++i) {

+ 2 - 2
addin/res/ManagerDesktop/guide.html

@@ -340,7 +340,7 @@
                                 </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"
                                          onclick="DeviceSelectChange('PinPad')">
@@ -391,7 +391,7 @@
                                 </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"
                                         onclick="VendorSelectChanged('CW')">

二進制
addin/res/ManagerDesktop/images/switch_off-.png


二進制
addin/res/ManagerDesktop/images/switch_off.png


+ 91 - 72
addin/res/ManagerDesktop/js/guide.js

@@ -42,28 +42,114 @@ var globalFinishedFlag = false;
 var globalInterestRootFlag = false;
 
 
+function generateAdapterSelect(devices, status, select_id) {
+    var deviceLength = 0;
+    if ((devices) instanceof Array) {
+        deviceLength = devices.length;
+    } else {
+        deviceLength = 1
+    }
+    var devicesHtml = '';
+    var selectid = select_id;
+    $('#' + selectid).empty();
+    for (var loop = 0; loop < deviceLength; loop++) {
+        var cur = devices[loop];
+        var deviceTemplateData = {
+            loop: loop,
+            deviceName : cur,
+            type: selectid
+        };
+        var pushHtml = '';
+        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)) {
+            pushHtml += '>{{deviceName}}&nbsp;(当前配置)</div>'
+        } else {
+            pushHtml += '>{{deviceName}}</div>'
+        }
+        $('#' +  selectid).secureAppend(pushHtml, deviceTemplateData);
+    }
+}
+
+function FulfillDevAdapterFileList(device, vendor, root_or_not, flag)
+{
+    let req = new Request();
+    req.root = root_or_not;
+    req.adapter=device;
+    req.vendor=vendor;
+    req.version="";
+    req.batch="";
+
+    RVC.DeviceControlEntityCtrl.GetVendorFileList(req, function(ret) {
+        if(ret.errorCode === 0) {
+            let result = JSON.parse(ret[RVC.EntityController.sigResponseUUID])
+            if(result.result == 0) {
+                var libs = [];
+                var status = [];
+                for (var n = 0; n < result.filenames.length; n++) {
+                    console.log(result.filenames[n] + ' ' + result.status[n]);
+                    libs.push(result.filenames[n]);
+                    status.push(result.status[n]);
+                }
+                generateAdapterSelect(libs, status, 'gui_adapter_config_adapter_list');
+                if(typeof flag !== 'undefined') {
+                    utilShowToast("已刷新");
+                }
+
+            } else if(typeof flag !== 'undefined') {
+                utilStartAlertDialog("操作失败:[" + result.result + "] " + result.msg);
+            } else {
+                console.error("操作失败:[" + result.result + "] " + result.msg);
+            }
+        } else if(typeof flag !== 'undefined'){
+            RVC.DeviceControlEntityCtrl.commErrorCallback(ret);
+        } else {
+            console.error("操作失败! ErrorCode: " + ErrorCodeStringfy(ret.errorCode));
+        }
+    });
+}
+
+function LoadDeviceAdaptersWithEvent(flag)
+{
+    var deviceName = $('#gui_adapter_config_device').attr('value');
+    var vendorName = $('#gui_adapter_config_vendor').attr('value').toLowerCase();
+    FulfillDevAdapterFileList(deviceName, vendorName, globalInterestRootFlag, flag);
+}
+
 function VendorSelectChanged(name)
 {
-    utilStartAlertDialog(name);
+    var deviceName = $('#gui_adapter_config_device').attr('value');
+    var vendorName = name.toLowerCase();
+    FulfillDevAdapterFileList(deviceName, vendorName, globalInterestRootFlag, true);
 }
 
 function DeviceSelectChange(name)
 {
-    utilStartAlertDialog(name);
+    var vendorName = $('#gui_adapter_config_vendor').attr('value').toLowerCase();
+    FulfillDevAdapterFileList(name, vendorName, globalInterestRootFlag, true);
 }
 
 function AdapterSelectChange(name)
 {
-    //utilStartAlertDialog(name);
+    //LoadDeviceAdaptersWithEvent(true);
 }
 
-function InterestRootSwitch() 
+function InterestRootSwitch(flag) 
 {
     if ($('#gui_adapter_config_root_interest_switch').hasClass('switch_on')) {
         globalInterestRootFlag = true;
     } else {
         globalInterestRootFlag = false;
     }
+    if(typeof flag == 'undefined')
+        LoadDeviceAdaptersWithEvent(true);
+    else 
+        LoadDeviceAdaptersWithEvent();
 }
 
 $(function () {
@@ -281,39 +367,6 @@ $(function () {
         }
     }
 
-    function generateAdapterSelect(devices, status, select_id) {
-        var deviceLength = 0;
-        if ((devices) instanceof Array) {
-            deviceLength = devices.length;
-        } else {
-            deviceLength = 1
-        }
-        var devicesHtml = '';
-        var selectid = select_id;
-        $('#' + selectid).empty();
-        for (var loop = 0; loop < deviceLength; loop++) {
-            var cur = devices[loop];
-            var deviceTemplateData = {
-                loop: loop,
-                deviceName : cur,
-                type: selectid
-            };
-            var pushHtml = '';
-            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)) {
-                pushHtml += '>{{deviceName}}&nbsp;(当前配置)</div>'
-            } else {
-                pushHtml += '>{{deviceName}}</div>'
-            }
-            $('#' +  selectid).secureAppend(pushHtml, deviceTemplateData);
-        }
-    }
 
     function FulfillMediaDeviceList(flag)
     {
@@ -368,37 +421,6 @@ $(function () {
         });
     }
 
-    function FulfillDevAdapterFileList(flag)
-    {
-        let req = new Request();
-        req.root = false;
-        req.adapter="";
-        req.vendor="";
-        req.version="";
-        req.batch="";
-
-        RVC.DeviceControlEntityCtrl.GetVendorFileList(req, function(ret) {
-            if(ret.errorCode === 0) {
-                let result = JSON.parse(ret[RVC.EntityController.sigResponseUUID])
-                if(result.result == 0) {
-                    var libs = [];
-                    var status = [];
-                    for (var n = 0; n < result.filenames.length; n++) {
-                        console.log(result.filenames[n] + ' ' + result.status[n]);
-                        libs.push(result.filenames[n]);
-                        status.push(result.status[n]);
-                    }
-                    generateAdapterSelect(libs, status, 'gui_adapter_config_adapter_list');
-
-                } else if(typeof flag !== 'undefined') {
-                    utilStartAlertDialog("操作失败:[" + result.result + "] " + result.msg);
-                }
-            } else if(typeof flag !== 'undefined'){
-                RVC.DeviceControlEntityCtrl.commErrorCallback(ret);
-            }
-        });
-    }
-
     function SaveMediaDeviceConfig()
     {
         //话筒扬声器
@@ -604,8 +626,7 @@ $(function () {
                     FulfillMediaDeviceList();
                     break;
                 case CONST.DeployStep_AdapterConfig:
-                    InterestRootSwitch();
-                    FulfillDevAdapterFileList();
+                    InterestRootSwitch(true);
                     break;
                 default:
                     break;
@@ -672,8 +693,6 @@ $(function () {
     });
 
     $(document).on('click', '#guide_adapter_config_test', function() {
-        var deviceName = $('#gui_adapter_config_device').attr('value');
-        var vendorName = $('#gui_adapter_config_vendor').attr('value');
 
         var adapterName = $('#gui_adapter_config_adapter').attr('value');
         var paramPort = $('#guide_adapter_config_port_input').val();