2015-04-24 16:12:48 +02:00
|
|
|
/******************************************************
|
|
|
|
*
|
|
|
|
* Printer
|
|
|
|
* Representation of the connected printer
|
|
|
|
*
|
|
|
|
******************************************************/
|
|
|
|
|
2015-06-05 09:56:58 +02:00
|
|
|
D3D.Printer = function () {
|
2015-04-24 16:12:48 +02:00
|
|
|
"use strict";
|
2015-04-28 14:11:41 +02:00
|
|
|
|
2015-04-30 18:26:34 +02:00
|
|
|
this.config = {};
|
2015-05-07 14:09:36 +02:00
|
|
|
};
|
|
|
|
D3D.Printer.prototype.updateConfig = function (config) {
|
|
|
|
"use strict";
|
|
|
|
|
2015-04-24 16:12:48 +02:00
|
|
|
for (var i in config) {
|
2015-04-24 21:32:39 +02:00
|
|
|
if (i.indexOf("printer") === 0) {
|
2015-04-30 18:26:34 +02:00
|
|
|
this.config[i] = config[i];
|
2015-04-24 21:32:39 +02:00
|
|
|
}
|
2015-04-24 16:12:48 +02:00
|
|
|
}
|
2015-05-07 14:09:36 +02:00
|
|
|
|
|
|
|
return this;
|
2015-04-24 16:12:48 +02:00
|
|
|
};
|
|
|
|
D3D.Printer.prototype.getStartCode = function () {
|
|
|
|
"use strict";
|
|
|
|
|
2015-04-30 18:26:34 +02:00
|
|
|
var gcode = this.config["printer.startcode"];
|
2015-04-24 16:12:48 +02:00
|
|
|
gcode = this.subsituteVariables(gcode);
|
|
|
|
|
2015-06-11 10:28:21 +02:00
|
|
|
return gcode;
|
2015-04-24 16:12:48 +02:00
|
|
|
};
|
|
|
|
D3D.Printer.prototype.getEndCode = function () {
|
|
|
|
"use strict";
|
|
|
|
|
2015-04-30 18:26:34 +02:00
|
|
|
var gcode = this.config["printer.endcode"];
|
2015-06-05 09:56:58 +02:00
|
|
|
|
2015-04-24 16:12:48 +02:00
|
|
|
gcode = this.subsituteVariables(gcode);
|
|
|
|
|
2015-06-11 10:28:21 +02:00
|
|
|
return gcode;
|
2015-04-24 16:12:48 +02:00
|
|
|
};
|
|
|
|
D3D.Printer.prototype.subsituteVariables = function (gcode) {
|
|
|
|
"use strict";
|
|
|
|
|
2015-04-30 18:26:34 +02:00
|
|
|
var temperature = this.config["printer.temperature"];
|
|
|
|
var bedTemperature = this.config["printer.bed.temperature"];
|
|
|
|
var preheatTemperature = this.config["printer.heatup.temperature"];
|
|
|
|
var preheatBedTemperature = this.config["printer.heatup.bed.temperature"];
|
|
|
|
var printerType = this.config["printer.type"];
|
|
|
|
var heatedbed = this.config["printer.heatedbed"];
|
2015-04-24 16:12:48 +02:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
var 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(/{printerType}/gi, printerType);
|
|
|
|
gcode = gcode.replace(/{if heatedBed}/gi, heatedBedReplacement);
|
|
|
|
|
|
|
|
return gcode;
|
|
|
|
};
|