dev to master #3
|
@ -2,7 +2,7 @@ arcId: 1
|
|||
port: 1234
|
||||
ip: 1.2.3.4
|
||||
env: dev
|
||||
interval: 1000
|
||||
interval: 3000
|
||||
reconnectInterval: 5000
|
||||
counterInterval: 1000
|
||||
db:
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"version": "1.0.0",
|
||||
"author": "Verdnatura Levante SL",
|
||||
"description": "rfid backend",
|
||||
"main": "index.js",
|
||||
"main": "server.js",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"start": "nodemon ./server.js"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import con from '../db/connect.js';
|
||||
|
||||
export default async(size, arcId) => {
|
||||
console.logger.info(`COUNTER: SIZE:${size} ARC_ID:${arcId}`);
|
||||
await con.query(`
|
||||
UPDATE vn.arcRead
|
||||
SET counter = ?
|
||||
|
|
|
@ -5,8 +5,8 @@ export default async(rfids, arcId) => {
|
|||
console.logger.info('PRINTING...');
|
||||
console.log([Array.from(rfids), arcId, null]);
|
||||
await con.query(`CALL vn.expeditionPallet_build(JSON_ARRAY(?), ?, ?, @palletId);`, [Array.from(rfids), arcId, null]);
|
||||
const palletId = await con.query(`SELECT @palletId;`);
|
||||
console.log(palletId);
|
||||
const [[{palletId}]] = await con.query(`SELECT @palletId as palletId;`);
|
||||
|
||||
await counter(null, arcId);
|
||||
if (!palletId)
|
||||
console.logger.error({error: 'ERROR_CREATING_PALLET', expeditions: rfids});
|
||||
|
|
|
@ -5,18 +5,19 @@ import debug from '../util/debugStream.js';
|
|||
import counter from './counter.js';
|
||||
|
||||
let interval;
|
||||
let counterInterval;
|
||||
|
||||
export default async(conf, cb) => {
|
||||
let rfidbuffer = new Set();
|
||||
let rfidbufferExtend = [];
|
||||
|
||||
const counterInterval = setInterval(counter, conf.counterInterval, rfidbuffer.size, conf.arcId);
|
||||
const stream = got.stream(`http://${conf.ip}/api/v1/data/stream`);
|
||||
|
||||
stream
|
||||
.on('data', async value => {
|
||||
const parsed = await rfidParser(value);
|
||||
console.log(parsed.codes);
|
||||
if (!parsed.codes.size) return;
|
||||
rfidbuffer = new Set([...rfidbuffer, ...parsed.codes]);
|
||||
rfidbufferExtend = rfidbufferExtend.concat(parsed.extended);
|
||||
|
||||
|
@ -26,6 +27,9 @@ export default async(conf, cb) => {
|
|||
clearTimeout(interval);
|
||||
interval = null;
|
||||
interval = setTimeout(createPallet, conf.interval);
|
||||
|
||||
if (!counterInterval)
|
||||
counterInterval = setTimeout(counterIntervalManager, conf.counterInterval);
|
||||
}
|
||||
})
|
||||
.on('error', e => {
|
||||
|
@ -34,11 +38,15 @@ export default async(conf, cb) => {
|
|||
|
||||
function createPallet() {
|
||||
clearTimeout(interval); // try remove
|
||||
clearInterval(counterInterval); // try remove
|
||||
|
||||
newPallet(rfidbuffer, conf.arcId);
|
||||
|
||||
rfidbuffer = new Set();
|
||||
rfidbufferExtend = [];
|
||||
}
|
||||
|
||||
function counterIntervalManager() {
|
||||
counterInterval = null;
|
||||
counter(rfidbuffer.size, conf.arcId);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -18,7 +18,7 @@ export default (parsed, conf) => {
|
|||
// 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.log('[WARNING_ANTENNA]: ', index + 1, ' ONLY ', set.size);
|
||||
console.logger.warn(`[ANTENNA]: ${index + 1} ONLY ${set.size}`);
|
||||
}
|
||||
|
||||
console.log('----------------------------------------------------------------');
|
||||
|
|
Loading…
Reference in New Issue