vn-rfid/util/debugStream.js

37 lines
1.6 KiB
JavaScript
Raw Normal View History

2024-03-04 10:42:48 +00:00
import debugMissing from './debugMissing.js';
2024-03-04 10:42:48 +00:00
export default async(parsed, conf) => {
2023-01-27 11:40:09 +00:00
if (conf.env != 'dev') return;
// 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);
2023-01-27 11:40:09 +00:00
console.log('UNIQUE READ ANTENNA:', uniqueRead[0].size, uniqueRead[1].size, uniqueRead[2].size, uniqueRead[3].size);
// 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);
// 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));
2024-03-04 10:42:48 +00:00
const uniqueReads = new Set([...uniqueRead[0], ...uniqueRead[1], ...uniqueRead[2], ...uniqueRead[3]]);
// console.log('UNIQUE READ TRI:', tri.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.logger.info('UNIQUE READ:', uniqueReads);
debugMissing(uniqueReads);
2023-01-27 11:40:09 +00:00
console.log('----------------------------------------------------------------');
};