Merge remote-tracking branch 'daprice/load-and-print' into devel

This commit is contained in:
Gina Häußge committed 2013-03-30 17:30:25 +01:00
commit 52bd2bee49
5 files changed
+46 -2

No files matched your search

+27
View File
@@ -172,6 +172,22 @@ class Printer():
self._gcodeLoader.start()
self._stateMonitor.setState({"state": self._state, "stateString": self.getStateString(), "flags": self._getStateFlags()})
def loadAndPrintGcode(self, file):
"""
Loads the gcode from the given file as the new print job and starts the print.
Aborts if the printer is currently printing or another gcode file is currently being loaded, or if loading the gcode file fails.
"""
if (self._comm is not None and self._comm.isPrinting()) or (self._gcodeLoader is not None):
return
self._setJobData(None, None)
self._gcodeLoader = GcodeLoader(file, self._onGcodeLoadingProgress, self._onGcodeLoadedToPrint)
self._gcodeLoader.start()
self._stateMonitor.setState({"state": self._state, "stateString": self.getStateString(), "flags": self._getStateFlags()})
def startPrint(self):
"""
@@ -416,6 +432,17 @@ class Printer():
self._stateMonitor.setGcodeData({"filename": None, "progress": None})
self._stateMonitor.setState({"state": self._state, "stateString": self.getStateString(), "flags": self._getStateFlags()})
def _onGcodeLoadedToPrint(self, filename, gcodeList):
self._setJobData(filename, gcodeList)
self._setCurrentZ(None)
self._setProgressData(None, None, None)
self._gcodeLoader = None
self._stateMonitor.setGcodeData({"filename": None, "progress": None})
self._stateMonitor.setState({"state": self._state, "stateString": self.getStateString(), "flags": self._getStateFlags()})
self.startPrint();
#~~ state reports
def feedrateState(self):
+8
View File
@@ -266,6 +266,14 @@ def loadGcodeFile():
printer.loadGcode(filename)
return jsonify(SUCCESS)
@app.route(BASEURL + "gcodefiles/loadandprint", methods=["POST"])
def loadAndPrintGcodeFile():
if "filename" in request.values.keys():
filename = gcodeManager.getAbsolutePath(request.values["filename"])
if filename is not None:
printer.loadAndPrintGcode(filename)
return jsonify(SUCCESS)
@app.route(BASEURL + "gcodefiles/delete", methods=["POST"])
def deleteGcodeFile():
if "filename" in request.values.keys():
+1 -1
View File
@@ -145,7 +145,7 @@ table {
&.gcode_files_action {
text-align: center;
width: 45px;
width: 70px;
}
// timelapse files
+9
View File
@@ -719,6 +719,15 @@ function GcodeFilesViewModel() {
})
}
self.loadAndPrintFile = function(filename) {
$.ajax({
url: AJAX_BASEURL + "gcodefiles/loadandprint",
type: "POST",
dataType: "json",
data: {filename: filename}
})
}
self.removeFile = function(filename) {
$.ajax({
url: AJAX_BASEURL + "gcodefiles/delete",
+1 -1
View File
@@ -127,7 +127,7 @@
<tr data-bind="css: $root.getSuccessClass($data), popover: { title: name, animation: true, html: true, placement: 'right', trigger: 'hover', delay: 0, content: $root.getPopoverContent($data), html: true }">
<td class="gcode_files_name" data-bind="text: name"></td>
<td class="gcode_files_size" data-bind="text: size"></td>
<td class="gcode_files_action"><a href="#" class="icon-trash" data-bind="click: function() { $root.removeFile($data.name); }"></a>&nbsp;|&nbsp;<a href="#" class="icon-folder-open" data-bind="click: function() { $root.loadFile($data.name); }"></a></td>
<td class="gcode_files_action"><a href="#" class="icon-trash" title="Remove" data-bind="click: function() { $root.removeFile($data.name); }"></a>&nbsp;|&nbsp;<a href="#" class="icon-folder-open" title="Load" data-bind="click: function() { $root.loadFile($data.name); }"></a>&nbsp;|&nbsp;<a href="#" class="icon-print" title="Load and Print" data-bind="click: function() { $root.loadAndPrintFile($data.name); }"></a></td>
</tr>
</tbody>
</table>