|
|
var net = require('net'),
|
|
|
_ = require('lodash'),
|
|
|
tagService = require('./tagService.js'),
|
|
|
readerConfig = require('./readerConfig.js').getReaderConfig(),
|
|
|
async = require('async'),
|
|
|
WebSocketServer = require('ws').Server;
|
|
|
|
|
|
var r = require('./rfidRedis.js');
|
...
|
...
|
@@ -62,6 +64,26 @@ function main() |
|
|
|
|
|
ws.send(JSON.stringify(infos));
|
|
|
}
|
|
|
else if(params.commandType === 'restart') // 重启读写器
|
|
|
{
|
|
|
var reader = readerConfig[params.reader];
|
|
|
console.log(reader);
|
|
|
var filter = {
|
|
|
'on': '1',
|
|
|
rssi: reader.rssi
|
|
|
};
|
|
|
// 尝试重连5次
|
|
|
async.retry(5, function(cb, results){
|
|
|
setTimeout(function(){
|
|
|
tagService.connectReader(params.reader, 9761, filter, reader.frequency, reader.inventory_time, reader.stay_time, reader.ants, reader.group, cb);
|
|
|
}, 3000);
|
|
|
|
|
|
}, function(err, results){
|
|
|
if(err){
|
|
|
console.error(err);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
terminals.push({
|
...
|
...
|
@@ -130,7 +152,7 @@ function getMillTimeDiffNow(val) |
|
|
|
|
|
/**
|
|
|
* 读取命令结果
|
|
|
* @param String data 传入的数据
|
|
|
* @param {String} data 传入的数据
|
|
|
* @returns {Object} 解析出来的数据对象
|
|
|
*/
|
|
|
function getCommand(data)
|
...
|
...
|
@@ -152,13 +174,13 @@ function getCommand(data) |
|
|
}
|
|
|
|
|
|
params.commandType = data.CommandType;
|
|
|
if(params.commandType !== 'daemon')
|
|
|
if('GroupID' in data)
|
|
|
{
|
|
|
if('GroupID' in data)
|
|
|
{
|
|
|
params.groupId = data.GroupID;
|
|
|
}
|
|
|
params.groupId = data.GroupID;
|
|
|
}
|
|
|
|
|
|
if('state' in data)
|
|
|
{
|
|
|
var state = data.State;
|
|
|
if(state == 'ShelfOn' || state == 'ShelfOnAndNear')
|
|
|
{
|
...
|
...
|
@@ -170,6 +192,10 @@ function getCommand(data) |
|
|
}
|
|
|
params.state = state;
|
|
|
}
|
|
|
if('reader' in data)
|
|
|
{
|
|
|
params.reader = data.reader;
|
|
|
}
|
|
|
|
|
|
return params;
|
|
|
}
|
...
|
...
|
|