import Interrupts from '../src/interrupts' const PINS = [process.env.PIN1 || 9 ,process.env.PIN2 || 10] const EDGE = process.env.EDGE || 'rising' // 'both' // outbound consumer const REMOTE_HOST = process.env.REMOTE_HOST || 'sbc' const REMOTE_PORT = process.env.REMOTE_PORT || 9001 const PATH = process.env.PATH || 'mcp' const LISTEN_TCP = process.env.LISTEN_TCP || '8020' const LISTEN_PATH = process.env.LISTEN_PATH || 'interrupt' let interrupts = new Interrupts(PINS, { id:'multi-interrupt', cmd:'interrupt.find', resetCmd:'interrupt.reset', resetInterval:0, edge:EDGE }) interrupts.amendConsumerCommands( {reply:() => {}} ) interrupts.on('log', ev => { if (ev.level !== 'debug' && ev.level !== 'trace') console.log(`LOG:'--${ev.level}-- ${ev.msg}`) // console.log(`LOG:'--${ev.level}-- ${ev.msg}`) }) interrupts.on('connection:socket', ev => { console.log(`remote socket connection event ${ev.socketName}: ${ev.state}`) }) ; (async () => { // interrupts.registerSocket('interrupt','c','t',{host:REMOTE_HOST, port:REMOTE_PORT, name:'interrupt', data:{pins:PINS, type:'interrupt'}}) interrupts.registerSocket('interrupt','c','n',{path:PATH, name:'interrupt', data:{name:'interrupt', pins:PINS, type:'interrupt'}}) // interrupts.registerSocket('listen','s','t',{port:1777}) await interrupts.init() await interrupts.socketsInit() })().catch(err => { console.error('FATAL: UNABLE TO START SYSTEM!\n',err) // process.kill(process.pid, 'SIGTERM') })