weblab-instrument
Version:
communication with instrument through usb
63 lines (56 loc) • 1.51 kB
JavaScript
const propMethod = require('../dev/propMethod.js');
// const debug = require('debug');
// const log = debug('pwr_channel:log');
function Channel() {
this.iout = '0';
this.vout = '0';
this.iset = '0';
this.vset = '0';
}
Channel.prototype.cmdHandler = {
ISET: {
setHelper(chObj, arg) {
chObj.iset = arg;
},
getHandler(chObj, res) {
// console.log(`ISet return: ${res}`);
res = res.slice(0, -1);
chObj.iset = res.toString();
return true;
},
},
VSET: {
setHelper(chObj, arg) {
chObj.vset = arg;
return true;
},
getHandler(chObj, res) {
// console.log(`VSet return: ${res}`);
res = res.slice(0, -1);
chObj.vset = res.toString();
return true;
},
},
IOUT: {
getHandler(chObj, res) {
// console.log(`VSet return: ${res}`);
res = res.slice(0, -1);
chObj.iout = res.toString();
return true;
},
},
VOUT: {
getHandler(chObj, res) {
// console.log(`VSet return: ${res}`);
res = res.slice(0, -1);
chObj.vout = res.toString();
return true;
},
},
};
exports.initPwrChanObj = function initPwrChanObj(id) {
const chanCmd = new Channel();
chanCmd.id = id;
chanCmd.prop = propMethod.CreatMethod.call(this, id);
return chanCmd;
};