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