fixed some problems with communication

updated communication shell see
http://www.doodle3d.com/help/api-documentation
This commit is contained in:
casperlamboo 2015-05-07 10:48:24 +02:00
parent 33576ad45b
commit 69e5534d0d
5 changed files with 197 additions and 145 deletions

156
build/d3d.js vendored
View File

@ -1,7 +1,7 @@
/******************************************************
*
* Utils
* requires jQuery, Three.js
* requires jQuery, Three.js, Clipper.js
*
******************************************************/
@ -147,6 +147,8 @@ var requestAnimFrame = (function () {
* Box
* Representation of de Doodle3DBox
* Handles all communication with the doodle box
* JavaScript shell for api communication
* Check http://www.doodle3d.com/help/api-documentation
*
******************************************************/
@ -237,12 +239,12 @@ D3D.Box.prototype.printBatch = function () {
var gcode = this.printBatches.shift();
sendAPI(this.api + "printer/print", {
"start": ((this.currentBatch === 0) ? "true" : "false"),
"first": ((this.currentBatch === 0) ? "true" : "false"),
"start": ((this.currentBatch === 0) ? true : false),
"first": ((this.currentBatch === 0) ? true : false),
"gcode": gcode.join("\n")
}, function (data) {
console.log("batch sent: " + self.currentBatch, data);
if (self.printBatches.length > 0) {
//sent new batch
self.currentBatch ++;
@ -254,7 +256,7 @@ D3D.Box.prototype.printBatch = function () {
self.updateState();
});
};
D3D.Box.prototype.stop = function () {
D3D.Box.prototype.stopPrint = function () {
"use strict";
this.printBatches = [];
@ -275,140 +277,160 @@ D3D.Box.prototype.stop = function () {
sendAPI(this.api + "printer/stop", {
"gcode": finishMove.join("\n")
//"gcode": {}
}, function (data) {
console.log("Printer stop command sent");
});
return this;
};
D3D.Box.prototype.setConfig = function (data) {
D3D.Box.prototype.setConfig = function (data, callback) {
//works
"use strict";
sendAPI(this.api + "config", data);
sendAPI(this.api + "config", data, callback);
return this;
};
D3D.Box.prototype.getInfoLog = function (callback) {
D3D.Box.prototype.getInfo = function (callback) {
//works
"use strict";
getAPI(self.api + "info/logfiles", function (data) {
if (callback !== undefined) {
callback(data);
}
});
getAPI(this.api + "info", callback);
};
D3D.Box.prototype.downloadInfoLog = function (callback) {
//works in google chrome... not tested in other browsers
//some browsers may redirect using this code
"use strict";
return this;
window.location = this.api + "info/logfiles";
};
D3D.Box.prototype.getInfoAcces = function (callback) {
//works
"use strict";
getAPI(self.api + "info/acces", function (data) {
if (callback !== undefined) {
callback(data);
}
});
getAPI(this.api + "info/access", callback);
return this;
};
D3D.Box.prototype.getNetwerkScan = function (callback) {
D3D.Box.prototype.getNetworkScan = function (callback) {
//works
"use strict";
getAPI(self.api + "network/scan", function (data) {
if (callback !== undefined) {
callback(data);
}
});
getAPI(this.api + "network/scan", callback);
return this;
};
D3D.Box.prototype.getNetworkKnown = function (callback) {
//works
"use strict";
getAPI(self.api + "network/known", function (data) {
if (callback !== undefined) {
callback(data);
}
});
getAPI(this.api + "network/known", callback);
return this;
};
D3D.Box.prototype.getNetworkStatus = function (callback) {
//works
"use strict";
getAPI(self.api + "network/status", function (data) {
if (callback !== undefined) {
callback(data);
}
});
getAPI(this.api + "network/status", callback);
return this;
};
D3D.Box.prototype.setNetworkAssosiate = function (data) {
D3D.Box.prototype.setNetworkAssosiate = function (data, callback) {
//works
"use strict";
sendAPI(self.api + "network/assosiate", data);
sendAPI(this.api + "network/associate", data, callback);
return this;
};
D3D.Box.prototype.setNetworkDisassosiate = function (data) {
D3D.Box.prototype.setNetworkDisassosiate = function (callback) {
//not tested
"use strict";
sendAPI(self.api + "network/displayassosiate", data);
sendAPI(this.api + "network/disassociate", {}, callback);
return this;
};
D3D.Box.prototype.setNetworkOpenap = function (data) {
D3D.Box.prototype.setNetworkOpenAP = function (callback) {
//not tested
"use strict";
sendAPI(self.api + "network/openap", data);
sendAPI(this.api + "network/openap", {}, callback);
return this;
};
D3D.Box.prototype.setNetworkRemove = function (ssid) {
D3D.Box.prototype.setNetworkRemove = function (ssid, callback) {
//works
"use strict";
sendAPI(self.api + "network/displayassosiate", {ssid: ssid});
sendAPI(this.api + "network/remove", {
ssid: ssid
}, callback);
return this;
};
D3D.Box.prototype.getNetworkAlive = function (callback) {
//works but returns empty array
"use strict";
getAPI(self.api + "network/alive", function (data) {
if (callback !== undefined) {
callback(data);
}
});
getAPI(this.api + "network/alive", callback);
return this;
};
D3D.Box.prototype.getPrinterListAll = function (callback) {
//works
"use strict";
getAPI(self.api + "printer/listall", function (data) {
if (callback !== undefined) {
callback(data);
}
});
getAPI(this.api + "printer/listall", callback);
return this;
};
D3D.Box.prototype.setPrinterHeatup = function (data) {
D3D.Box.prototype.setPrinterHeatup = function (callback) {
//works
"use strict";
sendAPI(self.api + "printer/heatup", data);
sendAPI(this.api + "printer/heatup", {}, callback);
return this;
};
D3D.Box.prototype.getVersion = function (data) {
D3D.Box.prototype.getSystemVersions = function (callback) {
//works
"use strict";
getAPI(self.api + "system/fwversion", function (data) {
if (callback !== undefined) {
callback(data);
}
});
getAPI(this.api + "system/fwversions", callback);
return this;
};
D3D.Box.prototype.getUpdateStatus = function (callback) {
//not tested
"use strict";
getAPI(this.api + "update/status", callback);
return this;
};
D3D.Box.prototype.setUpdateDownload = function (callback) {
//not tested
"use strict";
sendAPI(this.api + "update/download", {}, callback);
return this;
};
D3D.Box.prototype.setUpdateInstall = function (callback) {
//not tested
"use strict";
sendAPI(this.api + "update/install", {}, callback);
return this;
};
D3D.Box.prototype.setUpdateClear = function (callback) {
//not tested
"use strict";
sendAPI(this.api + "update/clear", {}, callback);
return this;
};
@ -499,7 +521,11 @@ D3D.Slicer = function () {
D3D.Slicer.prototype.setGeometry = function (geometry) {
"use strict";
this.geometry = geometry;
if (geometry instanceof THREE.BufferGeometry) {
geometry = new THREE.Geometry().fromBufferGeometry(geometry);
}
this.geometry = geometry.clone();
this.geometry.mergeVertices();
this.createLines();
@ -909,11 +935,11 @@ D3D.Slicer.prototype.drawPaths = function (printer, min, max) {
for (var i = 0; i < paths.length; i ++) {
var path = paths[i];
context.moveTo((path[0].X- 100) * 6.0 + 200, (path[0].Y- 100) * 6.0 + 200);
context.moveTo((path[0].X * 2), (path[0].Y * 2));
for (var j = 0; j < path.length; j ++) {
var point = path[j];
context.lineTo((point.X- 100) * 6.0 + 200, (point.Y- 100) * 6.0 + 200);
context.lineTo((point.X * 2), (point.Y * 2));
}
//context.closePath();
}

2
build/d3d.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -23,19 +23,23 @@ $(document).ready(function () {
listDoodle.append("<li><a href='doodle.html#192.168.5.1'>Wired Printer</a></li>");
listSliceTest.append("<li><a href='slice_test.html#192.168.5.1'>Wired Printer</a></li>");
/*printers.push({
/*
printers.push({
name: "wired box",
d3dbox: new D3D.Box("192.168.5.1")
});*/
});
*/
getAPI(api + "list.php", function (boxes) {
for (var i = 0; i < boxes.length; i ++) {
var box = boxes[i];
/*printers.push({
/*
printers.push({
name: box.wifiboxid,
d3dbox: new D3D.Box(box.localip)
});*/
});
*/
listDoodle.append("<li><a href='doodle.html#" + box.localip + "'>" + box.wifiboxid + "</a></li>");
listSliceTest.append("<li><a href='slice_test.html#" + box.localip + "'>" + box.wifiboxid + "</a></li>");
@ -49,7 +53,8 @@ $(document).ready(function () {
<p>Slice Test</p>
<ul id="printers-slicetest"></ul>
<!--<table>
<!--
<table>
<tr>
<th>localip</th>
<th>wifiboxid</th>
@ -60,7 +65,7 @@ $(document).ready(function () {
<td>wifiboxid</td>
<td>date</td>
</tr>
</table>-->
</table>
-->
</body>
</html>

View File

@ -87,7 +87,7 @@ var geometry = (function () {
var hole = new THREE.Path();
hole.absarc(0, 0, 5, 0, Math.PI*2, true );
//circle.holes.push(hole);
circle.holes.push(hole);
var matrix = new THREE.Matrix4();
matrix.makeRotationX(Math.PI*1.5);
@ -123,7 +123,8 @@ var layer = 149;
var img = slicer.drawPaths(printer, layer, layer + 1);
context.drawImage(img, 0, 0);
/*var loader = new THREE.STLLoader();
/*
var loader = new THREE.STLLoader();
loader.load('stl/overhang_test.stl', function (geometry) {
var matrix = new THREE.Matrix4();
@ -140,8 +141,14 @@ loader.load('stl/overhang_test.stl', function (geometry) {
var slicer = new D3D.Slicer().setGeometry(geometry);
//gcode = slicer.getGcode(printer);
});*/
var layer = 149;
var img = slicer.drawPaths(printer, layer, layer + 1);
context.drawImage(img, 0, 0);
var gcode = slicer.getGcode(printer);
console.log(gcode);
});
*/
(function animate () {
"use strict";

View File

@ -3,6 +3,8 @@
* Box
* Representation of de Doodle3DBox
* Handles all communication with the doodle box
* JavaScript shell for api communication
* Check http://www.doodle3d.com/help/api-documentation
*
******************************************************/
@ -93,12 +95,12 @@ D3D.Box.prototype.printBatch = function () {
var gcode = this.printBatches.shift();
sendAPI(this.api + "printer/print", {
"start": ((this.currentBatch === 0) ? "true" : "false"),
"first": ((this.currentBatch === 0) ? "true" : "false"),
"start": ((this.currentBatch === 0) ? true : false),
"first": ((this.currentBatch === 0) ? true : false),
"gcode": gcode.join("\n")
}, function (data) {
console.log("batch sent: " + self.currentBatch, data);
if (self.printBatches.length > 0) {
//sent new batch
self.currentBatch ++;
@ -110,7 +112,7 @@ D3D.Box.prototype.printBatch = function () {
self.updateState();
});
};
D3D.Box.prototype.stop = function () {
D3D.Box.prototype.stopPrint = function () {
"use strict";
this.printBatches = [];
@ -131,148 +133,160 @@ D3D.Box.prototype.stop = function () {
sendAPI(this.api + "printer/stop", {
"gcode": finishMove.join("\n")
//"gcode": {}
}, function (data) {
console.log("Printer stop command sent");
});
return this;
};
D3D.Box.prototype.setConfig = function (data) {
D3D.Box.prototype.setConfig = function (data, callback) {
//works
"use strict";
sendAPI(this.api + "config", data);
sendAPI(this.api + "config", data, callback);
return this;
};
D3D.Box.prototype.getInfoLog = function (callback) {
D3D.Box.prototype.getInfo = function (callback) {
//works
"use strict";
getAPI(this.api + "info/logfiles", function (data) {
if (callback !== undefined) {
callback(data);
}
});
getAPI(this.api + "info", callback);
};
D3D.Box.prototype.downloadInfoLog = function (callback) {
//works in google chrome... not tested in other browsers
//some browsers may redirect using this code
"use strict";
return this;
window.location = this.api + "info/logfiles";
};
D3D.Box.prototype.getInfoAcces = function (callback) {
//works
"use strict";
//error
//cannot call function or module 'info/acces' ('module/function 'info/acces' does not exist')
getAPI(this.api + "info/acces", function (data) {
if (callback !== undefined) {
callback(data);
}
});
getAPI(this.api + "info/access", callback);
return this;
};
D3D.Box.prototype.getNetwerkScan = function (callback) {
D3D.Box.prototype.getNetworkScan = function (callback) {
//works
"use strict";
getAPI(this.api + "network/scan", function (data) {
if (callback !== undefined) {
callback(data);
}
});
getAPI(this.api + "network/scan", callback);
return this;
};
D3D.Box.prototype.getNetworkKnown = function (callback) {
//works
"use strict";
getAPI(this.api + "network/known", function (data) {
if (callback !== undefined) {
callback(data);
}
});
getAPI(this.api + "network/known", callback);
return this;
};
D3D.Box.prototype.getNetworkStatus = function (callback) {
//works
"use strict";
getAPI(this.api + "network/status", function (data) {
if (callback !== undefined) {
callback(data);
}
});
getAPI(this.api + "network/status", callback);
return this;
};
D3D.Box.prototype.setNetworkAssosiate = function (data) {
D3D.Box.prototype.setNetworkAssosiate = function (data, callback) {
//works
"use strict";
sendAPI(this.api + "network/assosiate", data);
sendAPI(this.api + "network/associate", data, callback);
return this;
};
D3D.Box.prototype.setNetworkDisassosiate = function (data) {
D3D.Box.prototype.setNetworkDisassosiate = function (callback) {
//not tested
"use strict";
sendAPI(this.api + "network/displayassosiate", data);
sendAPI(this.api + "network/disassociate", {}, callback);
return this;
};
D3D.Box.prototype.setNetworkOpenap = function (data) {
D3D.Box.prototype.setNetworkOpenAP = function (callback) {
//not tested
"use strict";
sendAPI(this.api + "network/openap", data);
sendAPI(this.api + "network/openap", {}, callback);
return this;
};
D3D.Box.prototype.setNetworkRemove = function (ssid) {
D3D.Box.prototype.setNetworkRemove = function (ssid, callback) {
//works
"use strict";
sendAPI(this.api + "network/displayassosiate", {ssid: ssid});
sendAPI(this.api + "network/remove", {
ssid: ssid
}, callback);
return this;
};
D3D.Box.prototype.getNetworkAlive = function (callback) {
//works but returns empty array
"use strict";
//emty?
getAPI(this.api + "network/alive", function (data) {
if (callback !== undefined) {
callback(data);
}
});
getAPI(this.api + "network/alive", callback);
return this;
};
D3D.Box.prototype.getPrinterListAll = function (callback) {
//works
"use strict";
getAPI(this.api + "printer/listall", function (data) {
if (callback !== undefined) {
callback(data);
}
});
getAPI(this.api + "printer/listall", callback);
return this;
};
D3D.Box.prototype.setPrinterHeatup = function (data) {
D3D.Box.prototype.setPrinterHeatup = function (callback) {
//works
"use strict";
sendAPI(this.api + "printer/heatup", data);
sendAPI(this.api + "printer/heatup", {}, callback);
return this;
};
D3D.Box.prototype.getVersion = function (data) {
D3D.Box.prototype.getSystemVersions = function (callback) {
//works
"use strict";
//error
//cannot call function or module 'system/fwversion' ('module/function 'system/fwversion' does not exist')
getAPI(this.api + "system/fwversions", callback);
return this;
};
D3D.Box.prototype.getUpdateStatus = function (callback) {
//not tested
"use strict";
getAPI(this.api + "system/fwversion", function (data) {
if (callback !== undefined) {
callback(data);
}
});
getAPI(this.api + "update/status", callback);
return this;
};
D3D.Box.prototype.setUpdateDownload = function (callback) {
//not tested
"use strict";
sendAPI(this.api + "update/download", {}, callback);
return this;
};
D3D.Box.prototype.setUpdateInstall = function (callback) {
//not tested
"use strict";
sendAPI(this.api + "update/install", {}, callback);
return this;
};
D3D.Box.prototype.setUpdateClear = function (callback) {
//not tested
"use strict";
sendAPI(this.api + "update/clear", {}, callback);
return this;
};