readerConfig.js 6.64 KB

/**
 * 读写器数据
 * readerIp: 读写器IP地址
 * rssi: 读写器RSSI限定值
 * frequency: 读写器定频设置
 * stay_time: 天线驻留时间
 * inventory_time: 盘点时间
 */
var readers = [
    {
        id: 1,
        readerId: 1,
        readerIp: '172.16.13.6',
        rssi: -60,
        frequency: 43, // 912.75
        stay_time: 200,
        inventory_time: 500
    },
    {
        id: 2,
        readerId: 2,
        readerIp: '172.16.13.7',
        rssi: -60,
        frequency: 1, // 915.25
        stay_time: 200,
        inventory_time: 500
    },
    {
        id: 3,
        readerId: 3,
        readerIp: '172.16.13.8',
        rssi: -60,
        frequency: 11, // 917.75
        stay_time: 200,
        inventory_time: 500
    },
    {
        id: 4,
        readerId: 4,
        readerIp: '172.16.13.10',
        rssi: -60,
        frequency: 47, // 922.75
        stay_time: 200,
        inventory_time: 500
    },
    {
        id: 5,
        readerId: 5,
        readerIp: '172.16.13.86',
        rssi: -65,
        frequency: 35, // 924.75
        stay_time: 100,
        inventory_time: 500
    },
    {
        id: 6,
        readerId: 6,
        readerIp: '172.16.13.87',
        rssi: -65,
        frequency: 42, // 925.75
        stay_time: 100,
        inventory_time: 500
    },
    {
        id: 7,
        readerId: 7,
        readerIp: '172.16.13.88',
        rssi: -65,
        frequency: 35, // 924.75
        stay_time: 100,
        inventory_time: 500
    },
    {
        id: 8,
        readerId: 8,
        readerIp: '172.16.13.89',
        rssi: -60,
        frequency: 47, // 922.75
        stay_time: 200,
        inventory_time: 500
    },
    {
        id: 9,
        readerId: 9,
        readerIp: '172.16.13.11',
        rssi: -60,
        frequency: 35, // 924.75
        stay_time: 100,
        inventory_time: 500
    },
    {
        id: 10,
        readerId: 10,
        readerIp: '172.16.13.12',
        rssi: -60,
        frequency: 49, // 923.25
        stay_time: 200,
        inventory_time: 500
    },
    {
        id: 11,
        readerId: 11,
        readerIp: '172.16.13.92',
        rssi: -60,
        frequency: 40, // 923.75
        stay_time: 100,
        inventory_time: 500
    },
    {
        id: 11,
        readerId: 12,
        readerIp: '172.16.13.13',
        rssi: -60,
        frequency: 8, // 919.25
        stay_time: 300,
        inventory_time: 400
    }
];
/**
 * 读写器天线数据
 * groupId: 组ID
 * readerId: 读写器ID
 * antId: 天线ID(0-3)
 * nPower: 天线功率
 */
var ants = [
    {
        id: 1,
        antId: 0,
        readerId: 1,
        groupId: 1,
        nPower: 17
    },
    {
        id: 2,
        antId: 3,
        readerId: 1,
        groupId: 1,
        nPower: 17
    },
    {
        id: 3,
        antId: 0,
        readerId: 2,
        groupId: 2,
        nPower: 17
    },
    {
        id: 4,
        antId: 3,
        readerId: 2,
        groupId: 2,
        nPower: 17
    },
    {
        id: 5,
        antId: 0,
        readerId: 3,
        groupId: 3,
        nPower: 18
    },
    {
        id: 6,
        antId: 3,
        readerId: 3,
        groupId: 3,
        nPower: 18
    },
    {
        id: 7,
        antId: 0,
        readerId: 4,
        groupId: 4,
        nPower: 17
    },
    {
        id: 8,
        antId: 3,
        readerId: 4,
        groupId: 4,
        nPower: 17
    },
    {
        id: 9,
        antId: 0,
        readerId: 5,
        groupId: 5,
        nPower: 14
    },
    {
        id: 10,
        antId: 1,
        readerId: 5,
        groupId: 5,
        nPower: 14
    },
    {
        id: 11,
        antId: 2,
        readerId: 5,
        groupId: 5,
        nPower: 14
    },
    {
        id: 12,
        antId: 3,
        readerId: 5,
        groupId: 5,
        nPower: 14
    },
    {
        id: 13,
        antId: 0,
        readerId: 6,
        groupId: 6,
        nPower: 14
    },
    {
        id: 14,
        antId: 1,
        readerId: 6,
        groupId: 6,
        nPower: 14
    },
    {
        id: 15,
        antId: 2,
        readerId: 6,
        groupId: 6,
        nPower: 14
    },
    {
        id: 16,
        antId: 3,
        readerId: 6,
        groupId: 6,
        nPower: 14
    },
    {
        id: 17,
        antId: 0,
        readerId: 7,
        groupId: 6,
        nPower: 14
    },
    {
        id: 18,
        antId: 3,
        readerId: 7,
        groupId: 6,
        nPower: 14
    },
    {
        id: 19,
        antId: 0,
        readerId: 8,
        groupId: 7,
        nPower: 15
    },
    {
        id: 20,
        antId: 1,
        readerId: 8,
        groupId: 7,
        nPower: 15
    },
    {
        id: 21,
        antId: 2,
        readerId: 8,
        groupId: 7,
        nPower: 15
    },
    {
        id: 22,
        antId: 3,
        readerId: 8,
        groupId: 7,
        nPower: 15
    },
    {
        id: 23,
        antId: 0,
        readerId: 9,
        groupId: 7,
        nPower: 15
    },
    {
        id: 24,
        antId: 3,
        readerId: 9,
        groupId: 7,
        nPower: 15
    },
    {
        id: 25,
        antId: 0,
        readerId: 10,
        groupId: 8,
        nPower: 15
    },
    {
        id: 26,
        antId: 3,
        readerId: 10,
        groupId: 8,
        nPower: 15
    },
    {
        id: 27,
        antId: 0,
        readerId: 11,
        groupId: 8,
        nPower: 15
    },
    {
        id: 28,
        antId: 1,
        readerId: 11,
        groupId: 8,
        nPower: 15
    },
    {
        id: 29,
        antId: 2,
        readerId: 11,
        groupId: 8,
        nPower: 15
    },
    {
        id: 30,
        antId: 3,
        readerId: 11,
        groupId: 8,
        nPower: 15
    },
    {
        id: 31,
        antId: 0,
        readerId: 12,
        groupId: 9,
        nPower: 25
    }
];

// 获取读写器配置
exports.getReaderConfig = function()
{
    var readersConfig = {};
    for (var i = 0; i < readers.length; i++)
    {
        var reader = readers[i];
        readersConfig[reader.readerIp] = {
            rssi: reader.rssi,
            frequency: reader.frequency,
            stay_time: reader.stay_time,
            inventory_time: reader.inventory_time,
            ants: [0, 0, 0, 0]
        };

        for (var j = 0; j < ants.length; j++)
        {
            var ant = ants[j];
            if(ant.readerId == reader.readerId)
            {
                readersConfig[reader.readerIp].ants[ant.antId] = ant.nPower;

                readersConfig[reader.readerIp].group = ant.groupId;
            }
        }
        if(!readersConfig[reader.readerIp].ants.length)
            delete readersConfig[reader.readerIp];
    }
    return readersConfig;
};