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;
|