UNPKG

weblab-instrument

Version:
110 lines (106 loc) 3.02 kB
const propMethod = require('../dev/propMethod.js'); function HorObj() { this.temp = 0; this.position = '0'; this.zposition = '0'; this.scale = '2E-6'; this.zscale = '1E-6'; this.mode = 'MAIN'; this.expand = 'CENTER'; } HorObj.prototype.cmdHandler = { HorPosition: { getHandler(horObj, res) { res = res.slice(0, -1); horObj.position = res.toString(); return true; }, setHelper(horObj, arg, cb) { horObj.position = arg.toString(); if (horObj.temp != parseFloat(arg)) { if (typeof cb === 'function') { cb(['-500', `${horObj.temp.toExponential()} argument does not accept, set to near one ${arg}`]); } return false; } return true; }, }, HorZoomPosition: { getHandler(horObj, res) { res = res.slice(0, -1); horObj.zposition = res.toString(); return true; }, setHelper(horObj, arg, cb) { horObj.zposition = arg.toString(); if (horObj.temp != parseFloat(arg)) { if (typeof cb === 'function') { cb(['-500', `${horObj.temp.toExponential()} argument does not accept, set to near one ${arg}`]); } return false; } return true; }, }, HorZoomScale: { getHandler(horObj, res) { res = res.slice(0, -1); horObj.zscale = res.toString(); return true; }, setHelper(horObj, arg) { // console.log(HorObj); horObj.zscale = arg; return true; }, }, HorScale: { getHandler(horObj, res) { res = res.slice(0, -1); horObj.scale = res.toString(); return true; }, setHelper(horObj, arg) { horObj.scale = arg; return true; }, }, HorMode: { getHandler(horObj, res) { res = res.slice(0, -1); horObj.mode = res.toString(); return true; }, setHelper(horObj, arg) { horObj.mode = arg; return true; }, }, HorExpand: { getHandler(horObj, res) { res = res.slice(0, -1); horObj.expand = res.toString(); return true; }, setHelper(horObj, arg) { horObj.expand = arg; return true; }, }, }; HorObj.prototype.setToDefault = function setToDefault(horObj) { horObj.temp = 0; horObj.position = '0'; horObj.zposition = '0'; horObj.scale = '2E-6'; horObj.zscale = '1E-6'; horObj.mode = 'MAIN'; horObj.expand = 'CENTER'; }; exports.initHorObj = function initHorObj(id) { const horCmd = new HorObj(); // horCmd.cmdHandler=cmdHandler; horCmd.prop = propMethod.CreatMethod.call(this, id); return horCmd; };