refs #5144 add minimum filter #4
|
@ -11,6 +11,10 @@ $ sudo npm install -g pino-pretty
|
||||||
Launch application in developer environment.
|
Launch application in developer environment.
|
||||||
```
|
```
|
||||||
$ npm run start
|
$ npm run start
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
$ npm run start | pino-pretty
|
||||||
```
|
```
|
||||||
|
|
||||||
For test.
|
For test.
|
||||||
|
|
|
@ -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;
|
||||||
|
};
|
12
server.js
12
server.js
|
@ -1,15 +1,21 @@
|
||||||
import stream from './src/stream.js';
|
import stream from './src/stream.js';
|
||||||
import getConfig from './util/getConfig.js';
|
import getConfig from './util/getConfig.js';
|
||||||
import logger from 'pino';
|
import logger from 'pino';
|
||||||
|
import getArcs from './db/querys/getArcs.js';
|
||||||
|
|
||||||
console.logger = logger();
|
console.logger = logger();
|
||||||
|
|
||||||
function main() {
|
async function main(arcId) {
|
||||||
const conf = getConfig();
|
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);
|
console.logger.error(e);
|
||||||
setTimeout(main, conf.reconnectInterval);
|
setTimeout(main, config.reconnectInterval, config.arcId);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
main();
|
main();
|
||||||
|
|
|
@ -39,6 +39,7 @@ export default async(conf, cb) => {
|
||||||
function createPallet() {
|
function createPallet() {
|
||||||
clearTimeout(interval);
|
clearTimeout(interval);
|
||||||
|
|
||||||
|
if (!conf.minimum || rfidbuffer.size > conf.minimum)
|
||||||
newPallet(rfidbuffer, conf.arcId);
|
newPallet(rfidbuffer, conf.arcId);
|
||||||
|
|
||||||
rfidbuffer = new Set();
|
rfidbuffer = new Set();
|
||||||
|
|
Loading…
Reference in New Issue