A Node.js library to facilitate the use of bill validators.
Using yarn
$ yarn add bill-validator
Using npm
$ npm i --save bill-validator
import {createApex7000, createSerialInterface} from 'bill-validator'
const main = async () => {
// Create a IO Interface
const serialInterface = createSerialInterface({
port: '/dev/ttyUSB0'
, portOptions: {
autoOpen: false
, baudRate: 9600
, dataBits: 7
, parity: 'even'
, stopBits: 1
}
})
// Create the Bill validator
const apex7000 = createApex7000({
ioInterface: serialInterface
})
// Listen for events
apex7000.onAny((event, value) => {
console.log({[event]: value})
})
// Start
await apex7000.start()
// Accept
apex7000.accept()
}
main()
There are four methods, start, stop, accept and idle.
Method | Purpose |
---|---|
start | Open communication and initiate hardware. |
stop | Close communication. |
accept | Start accepting bills. Escrow and stacking is automatic |
idle | Don't accept bills but still listen for events. |
The bill validator will emit state changes and events.
Property | Type |
---|---|
accepting | Boolean |
billJammed | Boolean |
escrowed | Boolean |
failure | Boolean |
idling | Boolean |
returning | Boolean |
stackerFull | Boolean |
stackerPresent | Boolean |
stacking | Boolean |
Event | Type |
---|---|
billRejected | Boolean |
billStackedValue | Number |
cheated | Boolean |
powerUp | Boolean |
ready | Boolean |
returned | Boolean |
stacked | Boolean |
My coding style is a bit unorthodox and it's not what the cool kids are doing but you might like it. I use leading commas and tabs, oh the horror! Here's the eslint with all the details.
- Write tests
- Write code
- Submit PR
Copyright © 2019 Richard Ayotte