UNPKG

weblab-instrument

Version:
79 lines (71 loc) 1.77 kB
const propMethod = require('../dev/propMethod.js'); // const debug = require('debug'); // const log = debug('am_channel:log'); function AM() { this.temp = ''; this.type = 'SIN'; this.source = 'INTernal'; this.freq = '1E+6'; this.state = 'OFF'; this.depth = '1E+1'; } AM.prototype.cmdHandler = { AMInteFunc: { setHelper(amObj, arg) { amObj.type = arg; }, getHandler(amObj, res) { res = res.slice(0, -1); amObj.type = res.toString(); return true; }, }, AMInteFreq: { setHelper(amObj, arg) { amObj.freq = arg; return true; }, getHandler(amObj, res) { res = res.slice(0, -1); amObj.freq = res.toString(); return true; }, }, AMSource: { setHelper(amObj, arg) { amObj.source = arg; }, getHandler(amObj, res) { res = res.slice(0, -1); amObj.source = res.toString(); return true; }, }, AMState: { setHelper(amObj, arg) { amObj.state = arg; }, getHandler(amObj, res) { res = res.slice(0, -1); amObj.state = res.toString(); return true; }, }, AMDepth: { setHelper(amObj, arg) { amObj.depth = arg; return true; }, getHandler(amObj, res) { res = res.slice(0, -1); amObj.depth = res.toString(); return true; }, }, }; exports.initAMObj = function initAMObj(id) { const amCmd = new AM(); amCmd.id = id; amCmd.prop = propMethod.CreatMethod.call(this, id); return amCmd; };