Merge pull request 'refs #5144 add minimum filter' (#4) from 5144-setMinimum into master
gitea/vn-rfid/pipeline/head This commit looks good
Details
gitea/vn-rfid/pipeline/head This commit looks good
Details
Reviewed-on: #4
This commit is contained in:
commit
27837412f6
|
@ -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.
|
||||
|
|
|
@ -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 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();
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue