UNPKG

@nebulaglitch/shopbot

Version:
514 lines (471 loc) 13.8 kB
'use strict'; Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); const numeral = require('numeral'); function _define_property$4(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } class Code { toString() { return this.code; } constructor(code){ _define_property$4(this, "code", void 0); this.code = code; } } function _define_property$3(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } class Command { processArgs() { const processedArgs = this.args.map((current)=>{ let result = current; if (typeof current === 'number') { if (Number.isInteger(current)) { result = current; } else if (isNaN(current)) { result = ''; } else if (!isFinite(current)) { result = ''; } else { result = numeral(current).format('0.0000'); } } return result; }); return processedArgs; } toString() { let output = this.code; if (this.args.length > 0) { output += ', ' + this.processArgs().join(','); } return output; } constructor(code){ _define_property$3(this, "code", void 0); _define_property$3(this, "args", void 0); this.code = code; this.args = []; } } class Comment extends Command { toString() { return '\n' + this.code + ' ' + this.args.join(','); } constructor(name){ super('\''); this.args.push(name); } } function _define_property$2(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } class CmdGroup extends Array { get name() { return this.mName; } set name(name) { this.mName = name; } constructor(name, ...args){ super(...args), _define_property$2(this, "mName", void 0); this.mName = name; this.push(new Comment(name)); } } function _define_property$1(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } class Label { toString() { return this.name + ':'; } constructor(name){ _define_property$1(this, "name", void 0); this.name = name; } } function _define_property(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } class Variable { toString() { return '&' + this.name + ', ' + this.assignment; } constructor(name, assignment){ _define_property(this, "name", void 0); _define_property(this, "assignment", void 0); this.name = name; this.assignment = assignment; } } class ShopbotPrinter { static print(arr, sb = '') { arr.forEach((current)=>{ if (current instanceof Code) { sb += current.toString(); } else if (current instanceof Command) { sb += current.toString(); } else if (current instanceof Label) { sb += current.toString(); } else if (current instanceof Variable) { sb += current.toString(); } else if (current instanceof Array) { sb += '\n'; sb = ShopbotPrinter.print(current, sb); } sb += '\n'; }); return sb; } } class CutGCircle extends Command { constructor(diameter = null, xEndPoint = null, yEndPoint = null, xCenterOffset = null, yCenterOffset = null, outInTrue = null, direction = null, plunge = null, repetitions = null, proportionX = null, proportionY = null, tabPocketSpiral = null, pullUpEnd = null, doPlungeZ = null){ super("CG"); this.args.push(diameter); this.args.push(xEndPoint); this.args.push(yEndPoint); this.args.push(xCenterOffset); this.args.push(yCenterOffset); this.args.push(outInTrue); this.args.push(direction); this.args.push(plunge); this.args.push(repetitions); this.args.push(proportionX); this.args.push(proportionY); this.args.push(tabPocketSpiral); this.args.push(pullUpEnd); this.args.push(doPlungeZ); } } class CutCircleCenter extends Command { constructor(diameter = null, xCenterPoint = null, yCenterPoint = null, outInTrue = null, direction = null, startAngle = null, endAngle = null, plunge = null, repetitions = null, proportionX = null, proportionY = null, tabPocketSpiral = null, pullUpEnd = null, doPlungeZ = null){ super('CP'); this.args.push(diameter); this.args.push(xCenterPoint); this.args.push(yCenterPoint); this.args.push(outInTrue); this.args.push(direction); this.args.push(startAngle); this.args.push(endAngle); this.args.push(plunge); this.args.push(repetitions); this.args.push(proportionX); this.args.push(proportionY); this.args.push(tabPocketSpiral); this.args.push(pullUpEnd); this.args.push(doPlungeZ); } } class FileLoadPartFile extends Command { constructor(filename, proportionX, proportionY, proportionZ, repetitions, offset3d2d, plunge, tabFeature, doPlungeZ){ super('FP'); this.args.push(filename); this.args.push(proportionX); this.args.push(proportionY); this.args.push(proportionZ); this.args.push(repetitions); this.args.push(offset3d2d); this.args.push(plunge); this.args.push(tabFeature); this.args.push(doPlungeZ); } } class Input extends Command { toString() { return this.code + ' ' + this.args[0]; } constructor(text){ super('INPUT'); this.args.push(text); } } class Jog2 extends Command { constructor(distanceX, distanceY){ super("J2"); this.args.push(distanceX); this.args.push(distanceY); } } class Jog3 extends Command { constructor(distanceX = null, distanceY = null, distanceZ = null){ super("J3"); this.args.push(distanceX); this.args.push(distanceY); this.args.push(distanceZ); } } class Jog4 extends Command { constructor(distanceX = null, distanceY = null, distanceZ = null, distanceA = null){ super("J4"); this.args.push(distanceX); this.args.push(distanceY); this.args.push(distanceZ); this.args.push(distanceA); } } class JogA extends Command { constructor(distance){ super('JA'); this.args.push(distance); } } class JogB extends Command { constructor(distance){ super('JB'); this.args.push(distance); } } class JogSpeed extends Command { constructor(xjogspeed, yjogspeed){ super("JS"); this.args.push(xjogspeed); this.args.push(yjogspeed); } } class JogX extends Command { constructor(distance){ super('JX'); this.args.push(distance); } } class JogY extends Command { constructor(distance){ super('JY'); this.args.push(distance); } } class JogZ extends Command { constructor(distance){ super("JZ"); this.args.push(distance); } } class Move2 extends Command { constructor(distanceX, distanceY){ super("M2"); this.args.push(distanceX); this.args.push(distanceY); } } class Move3 extends Command { constructor(distanceX, distanceY, distanceZ){ super("M3"); this.args.push(distanceX); this.args.push(distanceY); this.args.push(distanceZ); } } class Move5 extends Command { constructor(distanceX, distanceY, distanceZ, distanceA, distanceB){ super('M5'); this.args.push(distanceX); this.args.push(distanceY); this.args.push(distanceZ); this.args.push(distanceA); this.args.push(distanceB); } } class MoveSetSpeed extends Command { constructor(xySpeed = null, zSpeed = null, aSpeed = null, bSpeed = null){ super('MS'); this.args.push(xySpeed); this.args.push(zSpeed); this.args.push(aSpeed); this.args.push(bSpeed); } } class MoveB extends Command { constructor(distance){ super('MB'); this.args.push(distance); } } class MoveX extends Command { constructor(distance){ super("MX"); this.args.push(distance); } } class MoveY extends Command { constructor(distance){ super("MY"); this.args.push(distance); } } class MoveZ extends Command { constructor(distance){ super("MZ"); this.args.push(distance); } } class Pause extends Command { constructor(seconds){ super("PAUSE"); this.args.push(seconds); } } class SetAbsolute extends Command { constructor(){ super("SA"); } } class SetContinuousMovement extends Command { constructor(switchNum){ super("SC"); this.args.push(switchNum); } } class SetOutputSwitch extends Command { constructor(switchNum, state){ super("SO"); this.args.push(switchNum); this.args.push(state); } } class ValAxis extends Command { constructor(cxLocation = null, yLocation = null, zLocation = null, aLocation = null, bLocation = null, tableBaseXLocation = null, tableBaseYlocation = null, tableBaseZLocation = null, tableBaseALocation = null, tableBaseBLocation = null){ super('VA'); this.args.push(cxLocation); this.args.push(yLocation); this.args.push(zLocation); this.args.push(aLocation); this.args.push(bLocation); this.args.push(tableBaseXLocation); this.args.push(tableBaseYlocation); this.args.push(tableBaseZLocation); this.args.push(tableBaseALocation); this.args.push(tableBaseBLocation); } } class ValComm extends Command { constructor(commPortNum = null, obsolete2 = null, obsolete3 = null, driverChan1 = null, driverChan2 = null, driverChan3 = null, driverChan4 = null, speed = null){ super('VI'); this.args.push(commPortNum); this.args.push(obsolete2); this.args.push(obsolete3); this.args.push(driverChan1); this.args.push(driverChan2); this.args.push(driverChan3); this.args.push(driverChan4); this.args.push(speed); } } class ValuesCutterParameters extends Command { constructor(diameter, obsolete1 = null, obsolete2 = null, safeZPullUp = null, plungeDirection = null, pocketOverlap = null, safeAPullUp = null, triggeredOutputSwitch = null, triggerONThreshold = null, triggerOFFThreshold = null, verticalAxisMonitored = null, triggeredOutputSwitchNum = null){ super('VC'); this.args.push(diameter); } } class ValuesDisplaySettings extends Command { constructor(obsolete1, numAxes, linearUnits, unitsTypeA, unitsTypeB, obsolete2, displayFileComments, keypadFixedDistance, keypadRemote, writePartFileLog, writeSystemLog, messageScreenLocX, messageScreenLocY, messageScreenSizeX, messageScreenSizeY, showFileProgress1, keypadSwitchesAutoOff, showFileProgress2, mainDisplayType){ super('VD'); this.args.push(obsolete1); } } class ZeroA extends Command { constructor(distance){ super('ZA'); } } class ZeroB extends Command { constructor(distance){ super('ZB'); } } const name = 'Shopbot', version = '0.0.1'; const myObject = { name, version }; exports.CmdGroup = CmdGroup; exports.Code = Code; exports.Command = Command; exports.Comment = Comment; exports.CutCircleCenter = CutCircleCenter; exports.CutGCircle = CutGCircle; exports.FileLoadPartFile = FileLoadPartFile; exports.Input = Input; exports.Jog2 = Jog2; exports.Jog3 = Jog3; exports.Jog4 = Jog4; exports.JogA = JogA; exports.JogB = JogB; exports.JogSpeed = JogSpeed; exports.JogX = JogX; exports.JogY = JogY; exports.JogZ = JogZ; exports.Label = Label; exports.Move2 = Move2; exports.Move3 = Move3; exports.Move5 = Move5; exports.MoveB = MoveB; exports.MoveSetSpeed = MoveSetSpeed; exports.MoveX = MoveX; exports.MoveY = MoveY; exports.MoveZ = MoveZ; exports.Pause = Pause; exports.SetAbsolute = SetAbsolute; exports.SetContinuousMovement = SetContinuousMovement; exports.SetOutputSwitch = SetOutputSwitch; exports.ShopbotPrinter = ShopbotPrinter; exports.ValAxis = ValAxis; exports.ValComm = ValComm; exports.ValuesCutterParameters = ValuesCutterParameters; exports.ValuesDisplaySettings = ValuesDisplaySettings; exports.Variable = Variable; exports.ZeroA = ZeroA; exports.ZeroB = ZeroB; exports.myObject = myObject; //# sourceMappingURL=index.cjs.map