vn-rfid/util/streamDebug.js

22 lines
919 B
JavaScript
Raw Normal View History

export default (rfidbuffer, rfidbufferSet) => {
if (conf.env != 'dev') return;
let totalBuffer = rfidbuffer.map(rfid => rfid.code);
let totalBufferSet = new Set(totalBuffer);
console.log('TOTAL BUFFER: ', totalBufferSet.size);
const totalRead = [0, 0, 0, 0];
for (let buffer of rfidbuffer)
totalRead[buffer.antenna - 1]++;
console.log('TOTAL READ ANTENNA:', totalRead);
for (let buffer of parsed)
rfidbufferSet[buffer.antenna - 1].add(buffer.code);
console.log('UNIQUE READ ANTENNA:', rfidbufferSet[0].size, rfidbufferSet[1].size, rfidbufferSet[2].size, rfidbufferSet[3].size);
for (const [index, set] of rfidbufferSet.entries()) {
if (((set.size * 100) / totalBufferSet.size) < 25)
console.log('[WARNING_ANTENNA]: ', index, ' ONLY ', set.size);
}
console.log('----------------------------------------------------------------');
};