Lower number of lines to send per gcode part to 500, this should fix failure to convert to x3g code for Makerbots (which took about 8 seconds while ajax timeouts are 5 seconds).

Bump version to 0.9.1.
This commit is contained in:
Wouter R 2013-11-22 16:51:26 +01:00
parent fe9c2cc5ea
commit ea2d50fd60
4 changed files with 74 additions and 72 deletions

View File

@ -4,7 +4,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME := doodle3d-client PKG_NAME := doodle3d-client
PKG_VERSION := 0.9.0 PKG_VERSION := 0.9.1
PKG_RELEASE := 1 PKG_RELEASE := 1
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)

View File

@ -11,7 +11,7 @@ function setPrintprogress(val) {
//*/ //*/
function Printer() { function Printer() {
Printer.WIFIBOX_DISCONNECTED_STATE = "wifibox disconnected"; Printer.WIFIBOX_DISCONNECTED_STATE = "wifibox disconnected";
Printer.UNKNOWN_STATE = "unknown"; // happens when a printer is connection but there isn't communication yet Printer.UNKNOWN_STATE = "unknown"; // happens when a printer is connection but there isn't communication yet
Printer.DISCONNECTED_STATE = "disconnected"; // printer disconnected Printer.DISCONNECTED_STATE = "disconnected"; // printer disconnected
@ -21,40 +21,40 @@ function Printer() {
Printer.STOPPING_STATE = "stopping"; // when you stop (abort) a print it prints the endcode Printer.STOPPING_STATE = "stopping"; // when you stop (abort) a print it prints the endcode
Printer.ON_BEFORE_UNLOAD_MESSAGE = "You're doodle is still being send to the printer, leaving will result in a incomplete 3D print"; Printer.ON_BEFORE_UNLOAD_MESSAGE = "You're doodle is still being send to the printer, leaving will result in a incomplete 3D print";
this.temperature = 0; this.temperature = 0;
this.targetTemperature = 0; this.targetTemperature = 0;
this.currentLine = 0; this.currentLine = 0;
this.totalLines = 0; this.totalLines = 0;
this.bufferedLines = 0; this.bufferedLines = 0;
this.state = Printer.UNKNOWN_STATE; this.state = Printer.UNKNOWN_STATE;
this.hasControl = true; // whether this client has control access this.hasControl = true; // whether this client has control access
this.wifiboxURL; this.wifiboxURL;
this.checkStatusInterval = 3000; this.checkStatusInterval = 3000;
this.checkStatusDelay; this.checkStatusDelay;
this.timeoutTime = 3000; this.timeoutTime = 3000;
this.sendPrintPartTimeoutTime = 5000; this.sendPrintPartTimeoutTime = 5000;
this.gcode; // gcode to be printed this.gcode; // gcode to be printed
this.sendLength = 1500; // max amount of gcode lines per post (limited because WiFi box can't handle to much) this.sendLength = 500; // max amount of gcode lines per post (limited because WiFi box can't handle to much)
this.retryDelay = 2000; // retry setTimout delay this.retryDelay = 2000; // retry setTimout delay
this.retrySendPrintPartDelay; // retry setTimout instance this.retrySendPrintPartDelay; // retry setTimout instance
this.retryCheckStatusDelay; // retry setTimout instance this.retryCheckStatusDelay; // retry setTimout instance
this.retryStopDelay; // retry setTimout instance this.retryStopDelay; // retry setTimout instance
this.retryPreheatDelay; // retry setTimout instance this.retryPreheatDelay; // retry setTimout instance
Printer.MAX_GCODE_SIZE = 10; // max size of gcode in MB's (estimation) Printer.MAX_GCODE_SIZE = 10; // max size of gcode in MB's (estimation)
this.stateOverruled = false; this.stateOverruled = false;
// Events // Events
Printer.UPDATE = "update"; Printer.UPDATE = "update";
var self = this; var self = this;
this.init = function() { this.init = function() {
console.log("Printer:init"); console.log("Printer:init");
//this.wifiboxURL = "http://" + window.location.host + "/cgi-bin/d3dapi"; //this.wifiboxURL = "http://" + window.location.host + "/cgi-bin/d3dapi";
@ -62,21 +62,21 @@ function Printer() {
this.wifiboxURL = wifiboxURL; this.wifiboxURL = wifiboxURL;
//this.wifiboxURL = "proxy5.php"; //this.wifiboxURL = "proxy5.php";
console.log(" wifiboxURL: ",this.wifiboxURL); console.log(" wifiboxURL: ",this.wifiboxURL);
if(autoUpdate) { if(autoUpdate) {
this.startStatusCheckInterval(); this.startStatusCheckInterval();
} }
} }
this.preheat = function() { this.preheat = function() {
console.log("Printer:preheat"); console.log("Printer:preheat");
if( this.state == Printer.BUFFERING_STATE || if( this.state == Printer.BUFFERING_STATE ||
this.state == Printer.PRINTING_STATE || this.state == Printer.PRINTING_STATE ||
this.state == Printer.STOPPING_STATE) { this.state == Printer.STOPPING_STATE) {
return; return;
} }
var self = this; var self = this;
if (communicateWithWifibox) { if (communicateWithWifibox) {
$.ajax({ $.ajax({
@ -91,7 +91,7 @@ function Printer() {
self.retryPreheatDelay = setTimeout(function() { self.preheat() },self.retryDelay); // retry after delay self.retryPreheatDelay = setTimeout(function() { self.preheat() },self.retryDelay); // retry after delay
} }
} }
}).fail(function() { }).fail(function() {
console.log("Printer:preheat: failed"); console.log("Printer:preheat: failed");
clearTimeout(self.retryPreheatDelay); clearTimeout(self.retryPreheatDelay);
self.retryPreheatDelay = setTimeout(function() { self.preheat() },self.retryDelay); // retry after delay self.retryPreheatDelay = setTimeout(function() { self.preheat() },self.retryDelay); // retry after delay
@ -100,41 +100,41 @@ function Printer() {
console.log ("Printer >> f:preheat() >> communicateWithWifibox is false, so not executing this function"); console.log ("Printer >> f:preheat() >> communicateWithWifibox is false, so not executing this function");
} }
} }
this.print = function(gcode) { this.print = function(gcode) {
console.log("Printer:print"); console.log("Printer:print");
console.log(" gcode total # of lines: " + gcode.length); console.log(" gcode total # of lines: " + gcode.length);
message.set("Sending doodle to printer...",Message.NOTICE); message.set("Sending doodle to printer...",Message.NOTICE);
self.addLeaveWarning(); self.addLeaveWarning();
/*for (i = 0; i < gcode.length; i++) { /*for (i = 0; i < gcode.length; i++) {
gcode[i] += " (" + i + ")"; gcode[i] += " (" + i + ")";
}*/ }*/
this.sendIndex = 0; this.sendIndex = 0;
this.gcode = gcode; this.gcode = gcode;
//console.log(" gcode[20]: ",gcode[20]); //console.log(" gcode[20]: ",gcode[20]);
var gcodeLineSize = this.byteSize(gcode[20]); var gcodeLineSize = this.byteSize(gcode[20]);
//console.log(" gcodeLineSize: ",gcodeLineSize); //console.log(" gcodeLineSize: ",gcodeLineSize);
var gcodeSize = gcodeLineSize*gcode.length/1024/1024; // estimate gcode size in MB's var gcodeSize = gcodeLineSize*gcode.length/1024/1024; // estimate gcode size in MB's
console.log(" gcodeSize: ",gcodeSize); console.log(" gcodeSize: ",gcodeSize);
if(gcodeSize > Printer.MAX_GCODE_SIZE) { if(gcodeSize > Printer.MAX_GCODE_SIZE) {
alert("Error: Printer:print: gcode file is probably too big ("+gcodeSize+"MB) (max: "+Printer.MAX_GCODE_SIZE+"MB)"); alert("Error: Printer:print: gcode file is probably too big ("+gcodeSize+"MB) (max: "+Printer.MAX_GCODE_SIZE+"MB)");
console.log("Error: Printer:print: gcode file is probably too big ("+gcodeSize+"MB) (max: "+Printer.MAX_GCODE_SIZE+"MB)"); console.log("Error: Printer:print: gcode file is probably too big ("+gcodeSize+"MB) (max: "+Printer.MAX_GCODE_SIZE+"MB)");
this.overruleState(Printer.IDLE_STATE); this.overruleState(Printer.IDLE_STATE);
this.startStatusCheckInterval(); this.startStatusCheckInterval();
message.hide(); message.hide();
self.removeLeaveWarning(); self.removeLeaveWarning();
return; return;
} }
//this.targetTemperature = settings["printer.temperature"]; // slight hack //this.targetTemperature = settings["printer.temperature"]; // slight hack
this.sendPrintPart(this.sendIndex, this.sendLength); this.sendPrintPart(this.sendIndex, this.sendLength);
} }
this.byteSize = function(s){ this.byteSize = function(s){
@ -142,10 +142,10 @@ function Printer() {
} }
this.sendPrintPart = function(sendIndex,sendLength) { this.sendPrintPart = function(sendIndex,sendLength) {
console.log("Printer:sendPrintPart sendIndex: " + sendIndex + "/" + this.gcode.length + ", sendLength: " + sendLength); console.log("Printer:sendPrintPart sendIndex: " + sendIndex + "/" + this.gcode.length + ", sendLength: " + sendLength);
var firstOne = (sendIndex == 0)? true : false; var firstOne = (sendIndex == 0)? true : false;
var start = firstOne; // start printing right away var start = firstOne; // start printing right away
var completed = false; var completed = false;
if (this.gcode.length < (sendIndex + sendLength)) { if (this.gcode.length < (sendIndex + sendLength)) {
console.log(" sending less than max sendLength (and last)"); console.log(" sending less than max sendLength (and last)");
@ -154,7 +154,7 @@ function Printer() {
completed = true; completed = true;
} }
var gcodePart = this.gcode.slice(sendIndex, sendIndex+sendLength); var gcodePart = this.gcode.slice(sendIndex, sendIndex+sendLength);
var postData = { gcode: gcodePart.join("\n"), first: firstOne, start: start}; var postData = { gcode: gcodePart.join("\n"), first: firstOne, start: start};
var self = this; var self = this;
if (communicateWithWifibox) { if (communicateWithWifibox) {
@ -166,7 +166,7 @@ function Printer() {
timeout: this.sendPrintPartTimeoutTime, timeout: this.sendPrintPartTimeoutTime,
success: function(data){ success: function(data){
console.log("Printer:sendPrintPart response: ",data); console.log("Printer:sendPrintPart response: ",data);
if(data.status == "success") { if(data.status == "success") {
if (completed) { if (completed) {
console.log("Printer:sendPrintPart:gcode sending completed"); console.log("Printer:sendPrintPart:gcode sending completed");
@ -177,8 +177,8 @@ function Printer() {
//self.targetTemperature = settings["printer.temperature"]; // slight hack //self.targetTemperature = settings["printer.temperature"]; // slight hack
} else { } else {
// only if the state hasn't bin changed (by for example pressing stop) we send more gcode // only if the state hasn't bin changed (by for example pressing stop) we send more gcode
console.log("Printer:sendPrintPart:gcode part received (state: ",self.state,")"); console.log("Printer:sendPrintPart:gcode part received (state: ",self.state,")");
if(self.state == Printer.PRINTING_STATE || self.state == Printer.BUFFERING_STATE) { if(self.state == Printer.PRINTING_STATE || self.state == Printer.BUFFERING_STATE) {
console.log("Printer:sendPrintPart:sending next part"); console.log("Printer:sendPrintPart:sending next part");
self.sendPrintPart(sendIndex + sendLength, sendLength); self.sendPrintPart(sendIndex + sendLength, sendLength);
@ -186,22 +186,22 @@ function Printer() {
} }
} }
// after we know the first gcode packed has bin received or failed // after we know the first gcode packed has bin received or failed
// (and the driver had time to update the printer.state) // (and the driver had time to update the printer.state)
// we start checking the status again // we start checking the status again
if(sendIndex == 0) { if(sendIndex == 0) {
self.startStatusCheckInterval(); self.startStatusCheckInterval();
} }
} }
}).fail(function() { }).fail(function() {
console.log("Printer:sendPrintPart: failed"); console.log("Printer:sendPrintPart: failed");
clearTimeout(self.retrySendPrintPartDelay); clearTimeout(self.retrySendPrintPartDelay);
self.retrySendPrintPartDelay = setTimeout(function() { self.retrySendPrintPartDelay = setTimeout(function() {
console.log("request printer:sendPrintPart failed retry"); console.log("request printer:sendPrintPart failed retry");
self.sendPrintPart(sendIndex, sendLength) self.sendPrintPart(sendIndex, sendLength)
},self.retryDelay); // retry after delay },self.retryDelay); // retry after delay
// after we know the gcode packed has bin received or failed // after we know the gcode packed has bin received or failed
// (and the driver had time to update the printer.state) // (and the driver had time to update the printer.state)
// we start checking the status again // we start checking the status again
self.startStatusCheckInterval(); self.startStatusCheckInterval();
}); });
@ -209,7 +209,7 @@ function Printer() {
console.log ("Printer >> f:sendPrintPart() >> communicateWithWifibox is false, so not executing this function"); console.log ("Printer >> f:sendPrintPart() >> communicateWithWifibox is false, so not executing this function");
} }
} }
this.stop = function() { this.stop = function() {
console.log("Printer:stop"); console.log("Printer:stop");
endCode = generateEndCode(); endCode = generateEndCode();
@ -225,19 +225,19 @@ function Printer() {
timeout: this.timeoutTime, timeout: this.timeoutTime,
success: function(data){ success: function(data){
console.log("Printer:stop response: ", data); console.log("Printer:stop response: ", data);
// after we know the stop has bin received or failed // after we know the stop has bin received or failed
// (and the driver had time to update the printer.state) // (and the driver had time to update the printer.state)
// we start checking the status again // we start checking the status again
self.startStatusCheckInterval(); self.startStatusCheckInterval();
} }
}).fail(function() { }).fail(function() {
console.log("Printer:stop: failed"); console.log("Printer:stop: failed");
clearTimeout(self.retryStopDelay); clearTimeout(self.retryStopDelay);
self.retryStopDelay = setTimeout(function() { self.stop() },self.retryDelay); // retry after delay self.retryStopDelay = setTimeout(function() { self.stop() },self.retryDelay); // retry after delay
// after we know the stop has bin received or failed // after we know the stop has bin received or failed
// (and the driver had time to update the printer.state) // (and the driver had time to update the printer.state)
// we start checking the status again // we start checking the status again
self.startStatusCheckInterval(); self.startStatusCheckInterval();
}); });
@ -269,9 +269,9 @@ function Printer() {
timeout: this.timeoutTime, timeout: this.timeoutTime,
success: function(response){ success: function(response){
//console.log(" Printer:status: ",response.data.state); //," response: ",response); //console.log(" Printer:status: ",response.data.state); //," response: ",response);
self.handleStatusUpdate(response); self.handleStatusUpdate(response);
clearTimeout(self.checkStatusDelay); clearTimeout(self.checkStatusDelay);
clearTimeout(self.retryCheckStatusDelay); clearTimeout(self.retryCheckStatusDelay);
self.checkStatusDelay = setTimeout(function() { self.checkStatus() }, self.checkStatusInterval); self.checkStatusDelay = setTimeout(function() { self.checkStatus() }, self.checkStatusInterval);
@ -300,11 +300,11 @@ function Printer() {
self.state = data.state; self.state = data.state;
//console.log(" state > ",self.state); //console.log(" state > ",self.state);
} }
// temperature // temperature
self.temperature = data.hotend; self.temperature = data.hotend;
self.targetTemperature = data.hotend_target; self.targetTemperature = data.hotend_target;
// progress // progress
self.currentLine = data.current_line; self.currentLine = data.current_line;
self.totalLines = data.total_lines; self.totalLines = data.total_lines;
@ -312,7 +312,7 @@ function Printer() {
// access // access
self.hasControl = data.has_control; self.hasControl = data.has_control;
if(self.state == Printer.PRINTING_STATE || self.state == Printer.STOPPING_STATE) { if(self.state == Printer.PRINTING_STATE || self.state == Printer.STOPPING_STATE) {
console.log("progress: ",self.currentLine+"/"+self.totalLines+" ("+self.bufferedLines+") ("+self.state+")"); console.log("progress: ",self.currentLine+"/"+self.totalLines+" ("+self.bufferedLines+") ("+self.state+")");
} }
@ -322,14 +322,14 @@ function Printer() {
this.overruleState = function(newState) { this.overruleState = function(newState) {
this.stateOverruled = true; this.stateOverruled = true;
console.log(" stateOverruled: ",this.stateOverruled); console.log(" stateOverruled: ",this.stateOverruled);
self.state = newState; self.state = newState;
$(document).trigger(Printer.UPDATE); $(document).trigger(Printer.UPDATE);
this.stopStatusCheckInterval(); this.stopStatusCheckInterval();
} }
this.removeLeaveWarning = function() { this.removeLeaveWarning = function() {
window.onbeforeunload = null; window.onbeforeunload = null;
} }
@ -339,4 +339,4 @@ function Printer() {
return Printer.ON_BEFORE_UNLOAD_MESSAGE; return Printer.ON_BEFORE_UNLOAD_MESSAGE;
}; };
} }
} }

View File

@ -25,13 +25,13 @@ gcodeEnd.push("G90"); // absolute positioning
gcodeEnd.push("M117 Done "); // display message (20 characters to clear whole screen)*/ gcodeEnd.push("M117 Done "); // display message (20 characters to clear whole screen)*/
var MAX_POINTS_TO_PRINT = 200000; //400000; //80000; //40000; var MAX_POINTS_TO_PRINT = 200000; //400000; //80000; //40000;
var gcode = []; var gcode = [];
function generate_gcode() { function generate_gcode() {
console.log("f:generategcode()"); console.log("f:generategcode()");
gcode = []; gcode = [];
console.log("settings: ",settings); console.log("settings: ",settings);
@ -56,13 +56,13 @@ function generate_gcode() {
var preheatBedTemperature = settings["printer.heatup.bed.temperature"]; var preheatBedTemperature = settings["printer.heatup.bed.temperature"];
var printerBedWidth = settings["printer.bed.width"]; var printerBedWidth = settings["printer.bed.width"];
var printerBedHeight = settings["printer.bed.height"]; var printerBedHeight = settings["printer.bed.height"];
var gCodeOffsetX = printerBedWidth/2; //110; // mm var gCodeOffsetX = printerBedWidth/2; //110; // mm
var gCodeOffsetY = printerBedHeight/2; //110; // mm var gCodeOffsetY = printerBedHeight/2; //110; // mm
var startCode = generateStartCode(); var startCode = generateStartCode();
var endCode = generateEndCode(); var endCode = generateEndCode();
/* /*
console.log("f:generate_gcode >> EFFE CHECKEN:"); console.log("f:generate_gcode >> EFFE CHECKEN:");
console.log(" speed: " + speed); console.log(" speed: " + speed);
@ -104,13 +104,13 @@ function generate_gcode() {
// console.log("f:generategcode() >> paths: " + paths.toString()); // console.log("f:generategcode() >> paths: " + paths.toString());
// console.log("paths.toString(): " + paths.toString()); // console.log("paths.toString(): " + paths.toString());
// return; // return;
//gcode.push("M104 S" + temperature); // set target temperature and do not wait for the extruder to reach it //gcode.push("M104 S" + temperature); // set target temperature and do not wait for the extruder to reach it
//gcode.push("M109 S" + temperature); // set target temperature and wait for the extruder to reach it //gcode.push("M109 S" + temperature); // set target temperature and wait for the extruder to reach it
// add gcode begin commands // add gcode begin commands
gcode = gcode.concat(startCode); gcode = gcode.concat(startCode);
//gcode.push("M109 S" + temperature); // set target temperature and wait for the extruder to reach it //gcode.push("M109 S" + temperature); // set target temperature and wait for the extruder to reach it
var layers = maxObjectHeight / layerHeight; //maxObjectHeight instead of objectHeight var layers = maxObjectHeight / layerHeight; //maxObjectHeight instead of objectHeight
@ -134,15 +134,15 @@ function generate_gcode() {
//console.log(" numLayers: ",(layers*(objectHeight/maxObjectHeight))); //console.log(" numLayers: ",(layers*(objectHeight/maxObjectHeight)));
//console.log(" pointsToPrint: ",pointsToPrint); //console.log(" pointsToPrint: ",pointsToPrint);
//console.log(" MAX_POINTS_TO_PRINT: ",MAX_POINTS_TO_PRINT); //console.log(" MAX_POINTS_TO_PRINT: ",MAX_POINTS_TO_PRINT);
console.log("pointsToPrint: ",pointsToPrint); console.log("pointsToPrint: ",pointsToPrint);
if(pointsToPrint > MAX_POINTS_TO_PRINT) { if(pointsToPrint > MAX_POINTS_TO_PRINT) {
alert("Sorry, your doodle is too complex or too high. Please try to simplify it."); alert("Sorry, your doodle is too complex or too high. Please try to simplify it.");
console.log("ERROR: to many points too convert to gcode"); console.log("ERROR: to many points too convert to gcode");
return []; return [];
} }
for (var layer = 0; layer < layers; layer++) { for (var layer = 0; layer < layers; layer++) {
var p = JSON.parse(JSON.stringify(points)); // [].concat(points); var p = JSON.parse(JSON.stringify(points)); // [].concat(points);
@ -254,13 +254,13 @@ function generate_gcode() {
} }
// add gcode end commands // add gcode end commands
gcode = gcode.concat(endCode); gcode = gcode.concat(endCode);
return gcode; return gcode;
} }
function generateStartCode() { function generateStartCode() {
var printerType = settings["printer.type"]; var printerType = settings["printer.type"];
var startCode = ""; var startCode = "";
if(settingsWindow.isMarlinPrinter(printerType)) { if(settingsWindow.isMarlinPrinter(printerType)) {
startCode = settings["printer.startcode.marlin"]; startCode = settings["printer.startcode.marlin"];
@ -273,7 +273,7 @@ function generateStartCode() {
} }
function generateEndCode() { function generateEndCode() {
var printerType = settings["printer.type"]; var printerType = settings["printer.type"];
var endCode = ""; var endCode = "";
if(settingsWindow.isMarlinPrinter(printerType)) { if(settingsWindow.isMarlinPrinter(printerType)) {
endCode = settings["printer.endcode.marlin"]; endCode = settings["printer.endcode.marlin"];
@ -292,9 +292,9 @@ function subsituteVariables(gcode) {
var preheatTemperature = settings["printer.heatup.temperature"]; var preheatTemperature = settings["printer.heatup.temperature"];
var preheatBedTemperature = settings["printer.heatup.bed.temperature"]; var preheatBedTemperature = settings["printer.heatup.bed.temperature"];
var printerType = settings["printer.type"]; var printerType = settings["printer.type"];
switch (printerType) { switch (printerType) {
case "makerbot_replicator2": printerType = "r2x"; break; case "makerbot_replicator2": printerType = "r2x"; break; //FIXME: this should be r2, with a separate type for r2x
case "makerbot_thingomatic": printerType = "t6"; break; case "makerbot_thingomatic": printerType = "t6"; break;
} }

View File

@ -150,6 +150,8 @@
<script src="../js_src/Progressbar.js"></script> <script src="../js_src/Progressbar.js"></script>
<script src="../js_src/Thermometer.js"></script> <script src="../js_src/Thermometer.js"></script>
<script src="../js_src/utils.js"></script> <script src="../js_src/utils.js"></script>
<script src="../js_src/sketches.js"></script>
<script src="../js_src/Help.js"></script>
<script src="../js_src/sidebar.js"></script> <script src="../js_src/sidebar.js"></script>
<script src="../js_src/Message.js"></script> <script src="../js_src/Message.js"></script>
<script src="../js_src/main.js"></script> <script src="../js_src/main.js"></script>