import Interrupts from '../src/interrupts' import Base from '@uci/base' const PINS = [9,10,24] const HOST = 'trantor' const PORT = 9000 const PATH = 'interrupt' let hook = (packet) => { packet.cmd = 'pin.interrupt.find' console.dir(packet) return packet } let interrupts = new Interrupts(PINS,{host:HOST, hook:true, 10:{wait:200}}) // let listener = new Base({sockets:'inter#s>t', inter:{port:9000}, id:'listener'}) interrupts.setHook(hook) // let interrupts = new Interrupts(PINS,{host:HOST, port:9000, hook:true, path:PATH}) // let listener = new Base({sockets:'intert#s>t,intern#s>n', intern:{path:PATH}, intert:{host:HOST, port:PORT}, id:'listener'}) // listener.interrupt = async function (packet) { // return new Promise((resolve) => { // console.log('interrupt received at listener') // console.dir(packet) // resolve({status: 'processed'}) // }) // } ; (async () => { // console.log(await listener.init()) await interrupts.init() interrupts.fire() })().catch(err => { console.error('FATAL: UNABLE TO START SYSTEM!\n',err) // process.kill(process.pid, 'SIGTERM') })