...
|
...
|
@@ -2,7 +2,7 @@ |
|
|
* @fileOverview 调用入口
|
|
|
* @author qiqi.zhou@yoho.cn
|
|
|
*/
|
|
|
//require("babel/register"); //es6 polyfill
|
|
|
require("babel/register"); //es6 polyfill
|
|
|
|
|
|
/**
|
|
|
* 连接器
|
...
|
...
|
@@ -102,11 +102,22 @@ exports.setFilter = function (connector, param) { |
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 设置天线驻留时长
|
|
|
* @method setAntStayTime
|
|
|
* @exports index/setAntStayTime
|
|
|
* @param {Connector} connect 连接器
|
|
|
* @param {Number} param 时长,单位毫秒 eg: 100
|
|
|
*/
|
|
|
exports.setAntStayTime = function (connector, param) {
|
|
|
config.send(connector, orders.setAntStayTime, param);
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 设置固定频率
|
|
|
* @method setFrequency
|
|
|
* @exports index/setFrequency
|
|
|
* @param {Connector} connector 连接器
|
|
|
* @param {Object} param 天线端口和定频的值 eg: {ant: 0, freq: 10 }
|
|
|
* @param {Object} param 天线端口和定频的值 eg: 10
|
|
|
*/
|
|
|
exports.setFrequency = function (connector, param) {
|
|
|
config.send(connector, orders.setFrequency, param);
|
...
|
...
|
@@ -157,20 +168,9 @@ exports.stopInventory = function (connector) { |
|
|
'on': '1',
|
|
|
rssi: -60
|
|
|
},
|
|
|
frequencys: [{//天线的定频
|
|
|
ant: 0,
|
|
|
freq: 10
|
|
|
}, {
|
|
|
ant: 1,
|
|
|
freq: 10
|
|
|
}, {
|
|
|
ant: 2,
|
|
|
freq: 10
|
|
|
}, {
|
|
|
ant: 3,
|
|
|
freq: 10
|
|
|
}],
|
|
|
frequencys: 10, //天线的定频
|
|
|
inventoryTime: 400,//设置盘点时长
|
|
|
antStayTime: 100,//设置天线驻留时长
|
|
|
power: [15, 0, 0, 0]//功率设置
|
|
|
}, function (data) {
|
|
|
//console.log(data);
|
...
|
...
|
@@ -188,10 +188,12 @@ exports.start = function (options, callback) { |
|
|
exports.setFilter(connector, options.filter);
|
|
|
}
|
|
|
|
|
|
if (options.frequencys) { //开启固定频率
|
|
|
_.forIn(options.frequencys, function (val, key) {
|
|
|
exports.setFrequency(connector, val);
|
|
|
});
|
|
|
if (options.antStayTime) { //设置天线驻留时长
|
|
|
exports.setAntStayTime(connector, options.antStayTime);
|
|
|
}
|
|
|
|
|
|
if (options.frequency) { //开启固定频率
|
|
|
exports.setFrequency(connector, options.frequency);
|
|
|
}
|
|
|
|
|
|
if (options.inventoryTime) { //设置盘点时长
|
...
|
...
|
@@ -210,13 +212,12 @@ exports.start = function (options, callback) { |
|
|
});
|
|
|
|
|
|
connector.on('sartInventory', function (data) {
|
|
|
//console.log(data.code);
|
|
|
if (data.code !== 2 && !isStop) {
|
|
|
exports.sartInventory(connector);
|
|
|
} else if (data.code === 2) {
|
|
|
rets = procTagInfo(countMap, rets, data.data);
|
|
|
}
|
|
|
callback(rets);
|
|
|
callback(connector.connected, rets);
|
|
|
});
|
|
|
|
|
|
checkInventoryFlag = setInterval(function () { //检查是否在架
|
...
|
...
|
@@ -264,21 +265,26 @@ function procTagInfo(countMap, rets, data) { |
|
|
var isExist = false,
|
|
|
now = 1 * new Date();
|
|
|
for (var i = 0; i < rets.length; i++) {
|
|
|
if (rets[i].epc === data.epc) {
|
|
|
rets[i].rssi = data.rssi;
|
|
|
rets[i].updateTime = now;
|
|
|
rets[i].state = 'on';
|
|
|
rets[i].ant = data.ant;
|
|
|
countMap[rets[i].epc] ++;
|
|
|
isExist = true;
|
|
|
for(var j = 0; j < data.length; j++) {
|
|
|
if (rets[i].epc === data[j].epc) {
|
|
|
rets[i].rssi = data[j].rssi;
|
|
|
rets[i].updateTime = now;
|
|
|
rets[i].state = 'on';
|
|
|
rets[i].ant = data[j].ant;
|
|
|
countMap[rets[i].epc] ++;
|
|
|
isExist = true;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (!isExist) {
|
|
|
data.updateTime = now;
|
|
|
data.state = 'on';
|
|
|
data.speed = 0;
|
|
|
countMap[data.epc] = 1;
|
|
|
rets.push(data);
|
|
|
_.map(data, function(item){
|
|
|
item.updateTime = now;
|
|
|
item.state = 'on';
|
|
|
item.speed = 0;
|
|
|
countMap[item.epc] = 1;
|
|
|
});
|
|
|
|
|
|
rets = rets.concat(data);
|
|
|
}
|
|
|
return rets;
|
|
|
}
|
...
|
...
|
@@ -313,4 +319,4 @@ function receive(client, data, err) { |
|
|
break;
|
|
|
}
|
|
|
return ret;
|
|
|
} |
|
|
\ No newline at end of file |
|
|
} |
...
|
...
|
|