UNPKG

weblab-instrument

Version:
84 lines (76 loc) 1.76 kB
const propMethod = require('../dev/propMethod.js'); const debug = require('debug'); const log = debug('dmm_sys:log'); function SysCmd() { this.sysLock = 'OFF'; this.display = 'ON'; this.func = 'VOLT'; this.val = '0'; this.autorange = 'ON'; } SysCmd.prototype.cmdHandler = { IDN: { getHandler(sysObj, res) { log(res); return true; }, }, RST: { setHelper() { log('sent RST command'); return true; }, }, CLS: { setHelper() { log('sent CLS command'); return true; }, }, VAL: { getHandler(sysObj, res) { sysObj.val = res; return true; }, }, SysLocal: { setHelper(sysObj) { log('sent SysLocal command'); sysObj.sysLock = 'OFF'; return true; }, }, SysRemote: { setHelper(sysObj) { log('sent SysRemote command'); sysObj.sysLock = 'ON'; return true; }, }, Function: { getHandler(sysObj, res) { sysObj.func = res; return true; }, setHelper(sysObj, arg) { sysObj.func = arg; return true; }, }, AutoRange: { getHandler(sysObj, res) { sysObj.autorange = res; return true; }, setHelper(sysObj, arg) { log('sent RangeAuto command'); sysObj.autorange = arg; return true; }, }, }; exports.initDmmSysObj = function initDmmSysObj(id) { const sysCmd = new SysCmd(); sysCmd.prop = propMethod.CreatMethod.call(this, id); return sysCmd; };