mirror of
https://github.com/Doodle3D/doodle3d-client.git
synced 2024-12-22 05:03:48 +01:00
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:
parent
fe9c2cc5ea
commit
ea2d50fd60
2
Makefile
2
Makefile
@ -4,7 +4,7 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME := doodle3d-client
|
||||
PKG_VERSION := 0.9.0
|
||||
PKG_VERSION := 0.9.1
|
||||
PKG_RELEASE := 1
|
||||
|
||||
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
|
||||
|
@ -11,7 +11,7 @@ function setPrintprogress(val) {
|
||||
//*/
|
||||
|
||||
function Printer() {
|
||||
|
||||
|
||||
Printer.WIFIBOX_DISCONNECTED_STATE = "wifibox disconnected";
|
||||
Printer.UNKNOWN_STATE = "unknown"; // happens when a printer is connection but there isn't communication yet
|
||||
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.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.targetTemperature = 0;
|
||||
this.currentLine = 0;
|
||||
this.totalLines = 0;
|
||||
this.bufferedLines = 0;
|
||||
this.state = Printer.UNKNOWN_STATE;
|
||||
this.hasControl = true; // whether this client has control access
|
||||
|
||||
this.wifiboxURL;
|
||||
|
||||
this.hasControl = true; // whether this client has control access
|
||||
|
||||
this.wifiboxURL;
|
||||
|
||||
this.checkStatusInterval = 3000;
|
||||
this.checkStatusDelay;
|
||||
this.timeoutTime = 3000;
|
||||
this.sendPrintPartTimeoutTime = 5000;
|
||||
|
||||
|
||||
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.retrySendPrintPartDelay; // retry setTimout instance
|
||||
this.retryCheckStatusDelay; // retry setTimout instance
|
||||
this.retryStopDelay; // retry setTimout instance
|
||||
this.retryPreheatDelay; // retry setTimout instance
|
||||
|
||||
|
||||
Printer.MAX_GCODE_SIZE = 10; // max size of gcode in MB's (estimation)
|
||||
|
||||
|
||||
this.stateOverruled = false;
|
||||
|
||||
|
||||
// Events
|
||||
Printer.UPDATE = "update";
|
||||
|
||||
|
||||
var self = this;
|
||||
|
||||
|
||||
this.init = function() {
|
||||
console.log("Printer:init");
|
||||
//this.wifiboxURL = "http://" + window.location.host + "/cgi-bin/d3dapi";
|
||||
@ -62,21 +62,21 @@ function Printer() {
|
||||
this.wifiboxURL = wifiboxURL;
|
||||
//this.wifiboxURL = "proxy5.php";
|
||||
console.log(" wifiboxURL: ",this.wifiboxURL);
|
||||
|
||||
|
||||
if(autoUpdate) {
|
||||
this.startStatusCheckInterval();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.preheat = function() {
|
||||
console.log("Printer:preheat");
|
||||
|
||||
|
||||
if( this.state == Printer.BUFFERING_STATE ||
|
||||
this.state == Printer.PRINTING_STATE ||
|
||||
this.state == Printer.STOPPING_STATE) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var self = this;
|
||||
if (communicateWithWifibox) {
|
||||
$.ajax({
|
||||
@ -91,7 +91,7 @@ function Printer() {
|
||||
self.retryPreheatDelay = setTimeout(function() { self.preheat() },self.retryDelay); // retry after delay
|
||||
}
|
||||
}
|
||||
}).fail(function() {
|
||||
}).fail(function() {
|
||||
console.log("Printer:preheat: failed");
|
||||
clearTimeout(self.retryPreheatDelay);
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.print = function(gcode) {
|
||||
console.log("Printer:print");
|
||||
console.log(" gcode total # of lines: " + gcode.length);
|
||||
|
||||
|
||||
message.set("Sending doodle to printer...",Message.NOTICE);
|
||||
self.addLeaveWarning();
|
||||
|
||||
|
||||
/*for (i = 0; i < gcode.length; i++) {
|
||||
gcode[i] += " (" + i + ")";
|
||||
}*/
|
||||
|
||||
|
||||
this.sendIndex = 0;
|
||||
this.gcode = gcode;
|
||||
|
||||
|
||||
//console.log(" gcode[20]: ",gcode[20]);
|
||||
var gcodeLineSize = this.byteSize(gcode[20]);
|
||||
//console.log(" gcodeLineSize: ",gcodeLineSize);
|
||||
var gcodeSize = gcodeLineSize*gcode.length/1024/1024; // estimate gcode size in MB's
|
||||
console.log(" gcodeSize: ",gcodeSize);
|
||||
|
||||
|
||||
if(gcodeSize > Printer.MAX_GCODE_SIZE) {
|
||||
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)");
|
||||
|
||||
|
||||
this.overruleState(Printer.IDLE_STATE);
|
||||
this.startStatusCheckInterval();
|
||||
message.hide();
|
||||
self.removeLeaveWarning();
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//this.targetTemperature = settings["printer.temperature"]; // slight hack
|
||||
|
||||
|
||||
this.sendPrintPart(this.sendIndex, this.sendLength);
|
||||
}
|
||||
this.byteSize = function(s){
|
||||
@ -142,10 +142,10 @@ function Printer() {
|
||||
}
|
||||
this.sendPrintPart = function(sendIndex,sendLength) {
|
||||
console.log("Printer:sendPrintPart sendIndex: " + sendIndex + "/" + this.gcode.length + ", sendLength: " + sendLength);
|
||||
|
||||
|
||||
var firstOne = (sendIndex == 0)? true : false;
|
||||
var start = firstOne; // start printing right away
|
||||
|
||||
|
||||
var completed = false;
|
||||
if (this.gcode.length < (sendIndex + sendLength)) {
|
||||
console.log(" sending less than max sendLength (and last)");
|
||||
@ -154,7 +154,7 @@ function Printer() {
|
||||
completed = true;
|
||||
}
|
||||
var gcodePart = this.gcode.slice(sendIndex, sendIndex+sendLength);
|
||||
|
||||
|
||||
var postData = { gcode: gcodePart.join("\n"), first: firstOne, start: start};
|
||||
var self = this;
|
||||
if (communicateWithWifibox) {
|
||||
@ -166,7 +166,7 @@ function Printer() {
|
||||
timeout: this.sendPrintPartTimeoutTime,
|
||||
success: function(data){
|
||||
console.log("Printer:sendPrintPart response: ",data);
|
||||
|
||||
|
||||
if(data.status == "success") {
|
||||
if (completed) {
|
||||
console.log("Printer:sendPrintPart:gcode sending completed");
|
||||
@ -177,8 +177,8 @@ function Printer() {
|
||||
//self.targetTemperature = settings["printer.temperature"]; // slight hack
|
||||
} else {
|
||||
// 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) {
|
||||
console.log("Printer:sendPrintPart:sending next part");
|
||||
self.sendPrintPart(sendIndex + sendLength, sendLength);
|
||||
@ -186,22 +186,22 @@ function Printer() {
|
||||
}
|
||||
}
|
||||
// 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
|
||||
if(sendIndex == 0) {
|
||||
self.startStatusCheckInterval();
|
||||
}
|
||||
}
|
||||
}).fail(function() {
|
||||
}).fail(function() {
|
||||
console.log("Printer:sendPrintPart: failed");
|
||||
clearTimeout(self.retrySendPrintPartDelay);
|
||||
self.retrySendPrintPartDelay = setTimeout(function() {
|
||||
console.log("request printer:sendPrintPart failed retry");
|
||||
self.sendPrintPart(sendIndex, sendLength)
|
||||
self.sendPrintPart(sendIndex, sendLength)
|
||||
},self.retryDelay); // retry after delay
|
||||
|
||||
|
||||
// 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
|
||||
self.startStatusCheckInterval();
|
||||
});
|
||||
@ -209,7 +209,7 @@ function Printer() {
|
||||
console.log ("Printer >> f:sendPrintPart() >> communicateWithWifibox is false, so not executing this function");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.stop = function() {
|
||||
console.log("Printer:stop");
|
||||
endCode = generateEndCode();
|
||||
@ -225,19 +225,19 @@ function Printer() {
|
||||
timeout: this.timeoutTime,
|
||||
success: function(data){
|
||||
console.log("Printer:stop response: ", data);
|
||||
|
||||
|
||||
// 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
|
||||
self.startStatusCheckInterval();
|
||||
}
|
||||
}).fail(function() {
|
||||
}).fail(function() {
|
||||
console.log("Printer:stop: failed");
|
||||
clearTimeout(self.retryStopDelay);
|
||||
self.retryStopDelay = setTimeout(function() { self.stop() },self.retryDelay); // retry after delay
|
||||
|
||||
|
||||
// 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
|
||||
self.startStatusCheckInterval();
|
||||
});
|
||||
@ -269,9 +269,9 @@ function Printer() {
|
||||
timeout: this.timeoutTime,
|
||||
success: function(response){
|
||||
//console.log(" Printer:status: ",response.data.state); //," response: ",response);
|
||||
|
||||
|
||||
self.handleStatusUpdate(response);
|
||||
|
||||
|
||||
clearTimeout(self.checkStatusDelay);
|
||||
clearTimeout(self.retryCheckStatusDelay);
|
||||
self.checkStatusDelay = setTimeout(function() { self.checkStatus() }, self.checkStatusInterval);
|
||||
@ -300,11 +300,11 @@ function Printer() {
|
||||
self.state = data.state;
|
||||
//console.log(" state > ",self.state);
|
||||
}
|
||||
|
||||
|
||||
// temperature
|
||||
self.temperature = data.hotend;
|
||||
self.targetTemperature = data.hotend_target;
|
||||
|
||||
|
||||
// progress
|
||||
self.currentLine = data.current_line;
|
||||
self.totalLines = data.total_lines;
|
||||
@ -312,7 +312,7 @@ function Printer() {
|
||||
|
||||
// access
|
||||
self.hasControl = data.has_control;
|
||||
|
||||
|
||||
if(self.state == Printer.PRINTING_STATE || self.state == Printer.STOPPING_STATE) {
|
||||
console.log("progress: ",self.currentLine+"/"+self.totalLines+" ("+self.bufferedLines+") ("+self.state+")");
|
||||
}
|
||||
@ -322,14 +322,14 @@ function Printer() {
|
||||
this.overruleState = function(newState) {
|
||||
this.stateOverruled = true;
|
||||
console.log(" stateOverruled: ",this.stateOverruled);
|
||||
|
||||
|
||||
self.state = newState;
|
||||
|
||||
|
||||
$(document).trigger(Printer.UPDATE);
|
||||
|
||||
|
||||
this.stopStatusCheckInterval();
|
||||
}
|
||||
|
||||
|
||||
this.removeLeaveWarning = function() {
|
||||
window.onbeforeunload = null;
|
||||
}
|
||||
@ -339,4 +339,4 @@ function Printer() {
|
||||
return Printer.ON_BEFORE_UNLOAD_MESSAGE;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,13 +25,13 @@ gcodeEnd.push("G90"); // absolute positioning
|
||||
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 = [];
|
||||
|
||||
function generate_gcode() {
|
||||
console.log("f:generategcode()");
|
||||
|
||||
|
||||
|
||||
gcode = [];
|
||||
|
||||
console.log("settings: ",settings);
|
||||
@ -56,13 +56,13 @@ function generate_gcode() {
|
||||
var preheatBedTemperature = settings["printer.heatup.bed.temperature"];
|
||||
var printerBedWidth = settings["printer.bed.width"];
|
||||
var printerBedHeight = settings["printer.bed.height"];
|
||||
|
||||
|
||||
var gCodeOffsetX = printerBedWidth/2; //110; // mm
|
||||
var gCodeOffsetY = printerBedHeight/2; //110; // mm
|
||||
|
||||
|
||||
var startCode = generateStartCode();
|
||||
var endCode = generateEndCode();
|
||||
|
||||
|
||||
/*
|
||||
console.log("f:generate_gcode >> EFFE CHECKEN:");
|
||||
console.log(" speed: " + speed);
|
||||
@ -104,13 +104,13 @@ function generate_gcode() {
|
||||
// console.log("f:generategcode() >> paths: " + paths.toString());
|
||||
// console.log("paths.toString(): " + paths.toString());
|
||||
// return;
|
||||
|
||||
|
||||
//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
|
||||
|
||||
|
||||
// add gcode begin commands
|
||||
gcode = gcode.concat(startCode);
|
||||
|
||||
|
||||
//gcode.push("M109 S" + temperature); // set target temperature and wait for the extruder to reach it
|
||||
|
||||
var layers = maxObjectHeight / layerHeight; //maxObjectHeight instead of objectHeight
|
||||
@ -134,15 +134,15 @@ function generate_gcode() {
|
||||
//console.log(" numLayers: ",(layers*(objectHeight/maxObjectHeight)));
|
||||
//console.log(" pointsToPrint: ",pointsToPrint);
|
||||
//console.log(" MAX_POINTS_TO_PRINT: ",MAX_POINTS_TO_PRINT);
|
||||
|
||||
|
||||
console.log("pointsToPrint: ",pointsToPrint);
|
||||
|
||||
|
||||
if(pointsToPrint > MAX_POINTS_TO_PRINT) {
|
||||
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");
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
for (var layer = 0; layer < layers; layer++) {
|
||||
|
||||
var p = JSON.parse(JSON.stringify(points)); // [].concat(points);
|
||||
@ -254,13 +254,13 @@ function generate_gcode() {
|
||||
}
|
||||
// add gcode end commands
|
||||
gcode = gcode.concat(endCode);
|
||||
|
||||
|
||||
return gcode;
|
||||
}
|
||||
|
||||
function generateStartCode() {
|
||||
var printerType = settings["printer.type"];
|
||||
|
||||
|
||||
var startCode = "";
|
||||
if(settingsWindow.isMarlinPrinter(printerType)) {
|
||||
startCode = settings["printer.startcode.marlin"];
|
||||
@ -273,7 +273,7 @@ function generateStartCode() {
|
||||
}
|
||||
function generateEndCode() {
|
||||
var printerType = settings["printer.type"];
|
||||
|
||||
|
||||
var endCode = "";
|
||||
if(settingsWindow.isMarlinPrinter(printerType)) {
|
||||
endCode = settings["printer.endcode.marlin"];
|
||||
@ -292,9 +292,9 @@ function subsituteVariables(gcode) {
|
||||
var preheatTemperature = settings["printer.heatup.temperature"];
|
||||
var preheatBedTemperature = settings["printer.heatup.bed.temperature"];
|
||||
var printerType = settings["printer.type"];
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -150,6 +150,8 @@
|
||||
<script src="../js_src/Progressbar.js"></script>
|
||||
<script src="../js_src/Thermometer.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/Message.js"></script>
|
||||
<script src="../js_src/main.js"></script>
|
||||
|
Loading…
Reference in New Issue
Block a user