|
|
/**
|
|
|
* UHF 读写器的指令操作上
|
|
|
*/
|
|
|
import Base from './base';
|
|
|
import _ from 'lodash';
|
|
|
import util from '../util';
|
|
|
import info from '../interface';
|
|
|
|
|
|
let log = util.log;
|
|
|
|
|
|
class Uhf extends Base {
|
|
|
constructor() {
|
|
|
super(null);
|
|
|
this.proc = {
|
|
|
openUhf: this.procFunc,
|
|
|
closeUhf: this.procFunc,
|
|
|
getConfig: this.getConfig,
|
|
|
getVersion: this.getVersion
|
|
|
};
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取读写器信息返回处理
|
|
|
*/
|
|
|
getConfig(data, client) {
|
|
|
let region = ['FCC', 'CCC', 'NCC', 'JPN'],
|
|
|
power = [],
|
|
|
retData = {},
|
|
|
retKey = null,
|
|
|
returnVal = null;
|
|
|
|
|
|
for (let val of _.slice(data, 2, 4)) {
|
|
|
power.push(parseInt(val, 16));
|
|
|
}
|
|
|
//处理返回结果
|
|
|
if (data[1] === '16') {
|
|
|
retData = {
|
|
|
power: power,
|
|
|
region: region[Number(data[6])],
|
|
|
speedMode: Number(data[7]),
|
|
|
invTime: parseInt(_.slice(data, 8, 12).join(''), 16),
|
|
|
invCount: data[12]
|
|
|
}
|
|
|
retKey = _.slice(data, 0, 2);
|
|
|
} else {
|
|
|
retKey = data;
|
|
|
}
|
|
|
|
|
|
returnVal = util.returnProc(retKey, client.remoteAddress, info.getConfig.output);
|
|
|
returnVal.data = retData;
|
|
|
return returnVal;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
*获取版本返回处理
|
|
|
*/
|
|
|
getVersion(data, client) {
|
|
|
let retData = null;
|
|
|
let retKey = _.slice(data, 0, 4);
|
|
|
let returnVal = util.returnProc(retKey, client.remoteAddress, info.getVersion.output);
|
|
|
if (data[2] === '0' && data[3] === '0') {
|
|
|
returnVal.data = {
|
|
|
majorVersion: parseInt(data[4], 16),
|
|
|
minorVersion: parseInt(data[5], 16)
|
|
|
};
|
|
|
}
|
|
|
|
|
|
return returnVal;
|
|
|
}
|
|
|
}
|
|
|
export default Uhf; |
|
|
\ No newline at end of file |
...
|
...
|
|