Merge pull request 'refs #5144 add minimum filter' (#4) from 5144-setMinimum into master
gitea/vn-rfid/pipeline/head This commit looks good Details

Reviewed-on: #4
This commit is contained in:
Alex Moreno 2023-05-18 11:30:42 +00:00
commit 27837412f6
4 changed files with 23 additions and 6 deletions

View File

@ -11,6 +11,10 @@ $ sudo npm install -g pino-pretty
Launch application in developer environment.
```
$ npm run start
or
$ npm run start | pino-pretty
```
For test.

6
db/querys/getArcs.js Normal file
View File

@ -0,0 +1,6 @@
import con from '../connect.js';
export default async() => {
const [arcs] = await con.query(`SELECT id as arcId, printerFk, ip, minimum FROM vn.arcRead;`);
return arcs;
};

View File

@ -1,15 +1,21 @@
import stream from './src/stream.js';
import getConfig from './util/getConfig.js';
import logger from 'pino';
import getArcs from './db/querys/getArcs.js';
console.logger = logger();
function main() {
async function main(arcId) {
const conf = getConfig();
stream(conf, e => {
for (let arc of await getArcs()) {
const config = Object.assign({}, conf, arc);
if (arcId && arcId != arc.arcId) continue;
stream(config, e => {
console.logger.error(e);
setTimeout(main, conf.reconnectInterval);
setTimeout(main, config.reconnectInterval, config.arcId);
});
}
}
main();

View File

@ -39,6 +39,7 @@ export default async(conf, cb) => {
function createPallet() {
clearTimeout(interval);
if (!conf.minimum || rfidbuffer.size > conf.minimum)
newPallet(rfidbuffer, conf.arcId);
rfidbuffer = new Set();