update settings

This commit is contained in:
casperlamboo 2016-05-07 22:59:20 +02:00 committed by Simon Voordouw
parent 41de708903
commit 66cfe4d883

View File

@ -12,46 +12,47 @@ export default class {
} }
startCode () { startCode () {
var gcode = this.config["startCode"]; const { startCode } = this.config;
const gcode = this._subsituteVariables(startCode);
gcode = this._subsituteVariables(gcode);
return gcode; return gcode;
} }
endCode () { endCode () {
var gcode = this.config["endCode"]; const { endCode } = this.config;
const gcode = this._subsituteVariables(endCode);
gcode = this._subsituteVariables(gcode);
return gcode; return gcode;
} }
_subsituteVariables (gcode) { _subsituteVariables (gcode) {
var temperature = this.config["temperature"]; let {
var bedTemperature = this.config["bedTemperature"]; temperature,
var preheatTemperature = this.config["heatupTemperature"]; bedTemperature,
var preheatBedTemperature = this.config["heatupBedTemperature"]; heatTemperature,
var travelSpeed = this.config["travelSpeed"] * 60; heatBedTemperature,
var printerType = this.config["type"]; travelSpeed,
var heatedbed = this.config["heatedbed"]; printerType,
heatedbed
} = this.config;
travelSpeed *= 60;
switch (printerType) { switch (printerType) {
case "makerbot_replicator2": printerType = "r2"; break; case 'makerbot_replicator2': printerType = 'r2'; break;
case "makerbot_replicator2x": printerType = "r2x"; break; case 'makerbot_replicator2x': printerType = 'r2x'; break;
case "makerbot_thingomatic": printerType = "t6"; break; case 'makerbot_thingomatic': printerType = 't6'; break;
case "makerbot_generic": printerType = "r2"; break; case 'makerbot_generic': printerType = 'r2'; break;
case "_3Dison_plus": printerType = "r2"; break; case '_3Dison_plus': printerType = 'r2'; break;
} }
var heatedBedReplacement = heatedbed ? "" : ";";
gcode = gcode.replace(/{printingTemp}/gi, temperature); const heatedBedReplacement = heatedbed ? '' : ';';
gcode = gcode.replace(/{printingBedTemp}/gi, bedTemperature);
gcode = gcode.replace(/{preheatTemp}/gi, preheatTemperature); gcode = gcode.replace(/{ printingTemp }/gi, temperature);
gcode = gcode.replace(/{preheatBedTemp}/gi, preheatBedTemperature); gcode = gcode.replace(/{ printingBedTemp }/gi, bedTemperature);
gcode = gcode.replace(/{printerType}/gi, printerType); gcode = gcode.replace(/{ preheatTemp }/gi, heatTemperature);
gcode = gcode.replace(/{travelSpeed}/gi, travelSpeed); gcode = gcode.replace(/{ preheatBedTemp }/gi, heatBedTemperature);
gcode = gcode.replace(/{if heatedBed}/gi, heatedBedReplacement); gcode = gcode.replace(/{ printerType }/gi, printerType);
gcode = gcode.replace(/{ travelSpeed }/gi, travelSpeed);
gcode = gcode.replace(/{ if heatedBed }/gi, heatedBedReplacement);
return gcode; return gcode;
} }