110 lines
4.2 KiB
JavaScript
110 lines
4.2 KiB
JavaScript
import con from '../db/connect.js';
|
|
|
|
export default async(parsed, conf) => {
|
|
const palletFkFinding = 0;
|
|
const attempt = 0;
|
|
|
|
if (conf.env != 'dev') return;
|
|
// TOTAL
|
|
// console.log('TOTAL BUFFER: ', parsed.codes.size);
|
|
// console.log('BUFFER: ', parsed.codes);
|
|
// console.log('BUFFER_EXTEND: ', parsed);
|
|
|
|
// TOTAL READS BY ANTENNA
|
|
const totalRead = [0, 0, 0, 0];
|
|
for (let read of parsed.extended)
|
|
totalRead[read.antenna - 1]++;
|
|
console.log('TOTAL READ ANTENNA:', totalRead);
|
|
// UNIQUE READS BY ANTENNA
|
|
const uniqueRead = [new Set(), new Set(), new Set(), new Set()];
|
|
for (let read of parsed.extended)
|
|
uniqueRead[read.antenna - 1].add(read.code);
|
|
|
|
console.log('UNIQUE READ ANTENNA:', uniqueRead[0].size, uniqueRead[1].size, uniqueRead[2].size, uniqueRead[3].size);
|
|
|
|
// console.log(uniqueRead[0], uniqueRead[1]);
|
|
// console.log(uniqueRead[2], uniqueRead[3]);
|
|
|
|
// AL QUAD
|
|
let quad1 = [...uniqueRead[0]].filter(value => uniqueRead[1].has(value));
|
|
let quad2 = [...uniqueRead[2]].filter(value => uniqueRead[3].has(value));
|
|
const quad = quad1.filter(value => new Set(quad2).has(value));
|
|
console.log('UNIQUE READ QUAD:', quad.length);
|
|
// await con.query(`
|
|
// INSERT INTO vn.algorithm (palletFk, attempt, expeditionArray, expeditionCount, model, power)
|
|
// VALUES(?, ?, ?, ?, ?, ?);
|
|
// `, [
|
|
// palletFkFinding,
|
|
// attempt,
|
|
// quad.join(','),
|
|
// quad.length,
|
|
// 'QUAD',
|
|
// quad[0]?.transmitPowerCdbm
|
|
// ]);
|
|
|
|
// AL TRI
|
|
let tri1 = [...uniqueRead[1]];
|
|
let tri2 = [...uniqueRead[2]].filter(value => uniqueRead[3].has(value));
|
|
const tri = tri1.filter(value => new Set(tri2).has(value));
|
|
console.log('UNIQUE READ TRI:', tri.length);
|
|
// await con.query(`
|
|
// INSERT INTO vn.algorithm (palletFk, attempt, expeditionArray, expeditionCount, model, power)
|
|
// VALUES(?, ?, ?, ?, ?, ?);
|
|
// `, [
|
|
// palletFkFinding,
|
|
// attempt,
|
|
// tri.join(','),
|
|
// tri.length,
|
|
// 'TRI',
|
|
// tri[0]?.transmitPowerCdbm
|
|
// ]);
|
|
|
|
// AL BI
|
|
// const uniqueReadLeft = new Set([...uniqueRead[0], ...uniquaeRead[1]]);
|
|
// const uniqueReadRight = new Set([...uniqueRead[2], ...uniqueRead[3]]);
|
|
// const bi = [...uniqueReadLeft].filter(value => uniqueReadRight.has(value));
|
|
// console.log('UNIQUE READ BI:', bi.length);
|
|
// console.log('UNIQUE READ: 1', [...uniqueRead[0]].length);
|
|
console.log('UNIQUE READ:', new Set([...uniqueRead[0], ...uniqueRead[1], ...uniqueRead[2], ...uniqueRead[3]]));
|
|
console.log('UNIQUE READ:', new Set([...uniqueRead[0], ...uniqueRead[1], ...uniqueRead[2], ...uniqueRead[3]]).size);
|
|
// console.log('UNIQUE READ:', new Set([...uniqueRead[0], ...uniqueRead[1], ...uniqueRead[2], ...uniqueRead[3]]).size); //USE for test
|
|
console.logger.info('UNIQUE READ:', new Set([...uniqueRead[0], ...uniqueRead[1], ...uniqueRead[2], ...uniqueRead[3]]));
|
|
// await con.query(`
|
|
// INSERT INTO vn.algorithm (palletFk, attempt, expeditionArray, expeditionCount, model, power)
|
|
// VALUES(?, ?, ?, ?, ?, ?);
|
|
|
|
// `, [
|
|
// palletFkFinding,
|
|
// attempt,
|
|
// bi.join(','),
|
|
// bi.length,
|
|
// 'BI',
|
|
// bi[0]?.transmitPowerCdbm
|
|
// ]);
|
|
|
|
// // // AL BEST PEAK
|
|
// MIRAR SI DOS LA HAN LEIDO ENTONCES BUENA, O TAMBIEN SE PUEDE MIRAR QUE SI EL PEAK ES MEJOR A X COJERLA POR BUENA
|
|
// const allExpedition = [];
|
|
// for ()
|
|
// console.log('UNIQUE READ BI:', bi.length);
|
|
// await con.query(`
|
|
// INSERT INTO vn.algorithm (palletFk, attempt, expeditionArray, expeditionCount, model)
|
|
// VALUES(?, ?, ?, ?, ?, ?);
|
|
|
|
// `, [
|
|
// palletFkFinding,
|
|
// attempt,
|
|
// bi,
|
|
// bi.length,
|
|
// 'BI'
|
|
// ]);
|
|
|
|
// // WARNING IF AN ANTENNA READS LESS THAN IT SHOULD
|
|
// for (const [index, set] of uniqueRead.entries()) {
|
|
// if (((set.size * 100) / parsed.codes.size) < 25)
|
|
// console.logger.warn(`[ANTENNA]: ${index + 1} ONLY ${set.size}`);
|
|
// }
|
|
|
|
console.log('----------------------------------------------------------------');
|
|
};
|