zhaochongyi
2024-08-30 7f164af532f66aff71419682c5b3f531b606983a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
const {Controller} = require("ee-core");
const Services = require('ee-core/services')
const {params} = require("debug");
 
class IcrfController extends Controller {
    constructor(ctx) {
        super(ctx);
    }
    /**
     * 连接串口读写器
     * @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();
    };
 
    /**
     * 鸣响
     * @param number 次数
     */
    connectBeep(number = 1){
        Services.get('icrf').beep();
    }
    /**
     * 开启定时寻卡任务
     */
    doJobByPool(){
        return Services.get('icrf').doJobByPool();
    }
 
    /**
     * 关闭定时寻卡任务
     * @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;