weblab-instrument
Version:
communication with instrument through usb
69 lines (61 loc) • 1.44 kB
JavaScript
const propMethod = require('../dev/propMethod.js');
const debug = require('debug');
const log = debug('afg_sys:log');
function SysCmd() {
this.sysLock = 'OFF';
this.display = 'ON';
this.lrn = [];
}
SysCmd.prototype.cmdHandler = {
IDN: {
getHandler() {
return true;
},
},
RST: {
setHelper() {
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;
},
},
SysErr: { //
getHandler(sysObj, res) {
log(res.toString());
if (res.toString() === '+0, \'No error.\'') {
sysObj.state.errCode.message = '';
} else {
log(`command error :${res.toString()}`);
sysObj.state.errCode.message = res.toString();
}
return true;
},
},
Disp: {
setHelper() {
return true;
},
},
CLS: {
setHelper() {
return true;
},
},
};
exports.initSysObj = function initSysObj(id) {
const sysCmd = new SysCmd();
sysCmd.prop = propMethod.CreatMethod.call(this, id);
return sysCmd;
};