From 16c179b122eb8c69d31b0fab66c5e29b9c332b8d Mon Sep 17 00:00:00 2001
From: 15815213711 <a13118667520@163.com>
Date: 星期四, 24 四月 2025 10:17:07 +0800
Subject: [PATCH] 变更

---
 electron/controller/icrf.js |  116 ++++++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 93 insertions(+), 23 deletions(-)

diff --git a/electron/controller/icrf.js b/electron/controller/icrf.js
index 9e79d44..57f435f 100644
--- a/electron/controller/icrf.js
+++ b/electron/controller/icrf.js
@@ -1,33 +1,103 @@
 const {Controller} = require("ee-core");
-const Ps = require("ee-core/ps");
-const koffi = require('koffi');
-const path = require("path");
-class IcrfController extends Controller{
-    hcicrf =null;
+const Services = require('ee-core/services')
+const {params} = require("debug");
+
+class IcrfController extends Controller {
     constructor(ctx) {
         super(ctx);
-        const dllPath = path.join(Ps.getExtraResourcesDir(),'dll','hc_icrf32.dll');
-        this.hcicrf =koffi.load(dllPath);
     }
-    async hc_init(params){
-        const hc_init = this.hcicrf.func('int __stdcall hc_init(short port, uint32_t baud)');
-        let hcInit = hc_init(2, 115200);
-        console.log(hcInit);
-        if (hcInit <=0){
-            // let errMsg = this.getErrMsg(hcInit);
-            //console.log(errMsg)
-        }
-        return hcInit;
+    /**
+     * 杩炴帴涓插彛璇诲啓鍣�
+     * @param {params.number} params.port 绔彛鍙�, 鍙栧�� 0 ~ 19, 瀵瑰簲绔彛 COM1 ~ COM20
+     * @param {params.number} params.baud 娉㈢壒鐜�, 鍙栧�� 9600 ~ 115200
+     * @returns {number} 璇诲啓鍣ㄥ彞鏌�
+     */
+    connectSerialPort(params) {
+       return Services.get('icrf').connectSerialPort(params.port,params.baud);
+    };
+
+    /**
+     * 杩炴帴USB璇诲啓鍣�
+     * @param params
+     * @returns {*}
+     */
+    connectUsb(params) {
+       return Services.get('icrf').connectUsb(params.number);
+    };
+
+    /**
+     * 鏂紑璇诲啓鍣�
+     * @returns {(function(*, *, ...[*]): {msg: string, code: *})|*}
+     */
+    connectExit(){
+        return Services.get('icrf').connectExit();
+    };
+
+    /**
+     * 楦e搷
+     * @param number 娆℃暟
+     */
+    connectBeep(number = 1){
+        Services.get('icrf').beep();
+    }
+    /**
+     * 寮�鍚畾鏃跺鍗′换鍔�
+     */
+    doJobByPool(){
+        return Services.get('icrf').doJobByPool();
     }
 
-    getErrMsg(st){
-        let getErrMsg = this.hcicrf.func("int getErrMsg(short st,short lg, char errMsg)");
-        let errMsg = getErrMsg(st, 0, 1024);
-        console.log(errMsg)
-        return errMsg;
+    /**
+     * 鍏抽棴瀹氭椂瀵诲崱浠诲姟
+     * @returns {*}
+     */
+    unJobByPool(){
+        return Services.get('icrf').unJobByPool();
+    }
+    /**
+     * 瀵诲崱
+     */
+    connectRfCard(){
+        return Services.get('icrf').connectRfCard();
+    }
+
+    /**
+     * 鏍¢獙瀵嗙爜
+     */
+    connectRfAuthenticationKey(){
+        return Services.get('icrf').connectRfAuthenticationKey();
+
+    }
+
+    /**
+     * 璇绘暟鎹�
+     */
+    connectRfRead(params){
+        let connectRfAuthenticationKey1 = Services.get('icrf').connectRfAuthenticationKey(params.addr);
+        return Services.get('icrf').connectRfRead(params.addr);
+
+    }
+
+    /**
+     * 鍐欐暟鎹�
+     * @param params.data 鍐欏叆鐨勬暟鎹�
+     * @param params.addr 鍐欏叆鐨勫尯鍩� 3,7,11,15,19瀵嗙爜鐗囧尯涓ョ浣跨敤
+     */
+    connectRfWrite(params){
+        let connectRfAuthenticationKey1 = Services.get('icrf').connectRfAuthenticationKey(params.addr);
+        console.log(connectRfAuthenticationKey1)
+        return Services.get('icrf').connectRfWrite(params.data,params.addr);
+    }
+
+    /**
+     * 缁堟鍗★紙瀹屾垚鎵�鏈夋搷浣滐級
+     */
+
+    connectRfHalt(){
+        return Services.get('icrf').connectRfHalt();
     }
 
 }
 
-IcrfController.toString = ()=> '[class IcrfController]';
-module.exports =IcrfController;
\ No newline at end of file
+IcrfController.toString = () => '[class IcrfController]';
+module.exports = IcrfController;
\ No newline at end of file

--
Gitblit v1.8.0