bugfixes! state model works again. feature: printing of placed svg files & direct gcode.
This commit is contained in:
parent
5ef6600ab6
commit
3184b0251f
8 changed files with 85 additions and 45 deletions
|
|
@ -184,6 +184,10 @@ class FileManager(object):
|
|||
end_time = time.time()
|
||||
eventManager().fire(Events.SLICING_DONE, {"stl": source_path, "gcode": dest_path, "gcode_location": dest_location, "time": end_time - start_time})
|
||||
|
||||
#absolute_path = self._storage(dest_location).get_absolute_path(dest_path)
|
||||
#with open (absolute_path, "r") as myfile:
|
||||
# print("sliced gcode\n", myfile.readlines())
|
||||
|
||||
if callback is not None:
|
||||
if callback_args is None:
|
||||
callback_args = ()
|
||||
|
|
|
|||
|
|
@ -246,7 +246,6 @@ class SvgToGcodePlugin(octoprint.plugin.SlicerPlugin,
|
|||
on_progress_kwargs = dict()
|
||||
|
||||
self._svgtogcode_logger.info("### Slicing %s to %s using profile stored at %s" % (model_path, machinecode_path, profile_path))
|
||||
print("### Slicing %s to %s using profile stored at %s" % (model_path, machinecode_path, profile_path))
|
||||
|
||||
engine_settings = self._convert_to_engine(profile_path)
|
||||
|
||||
|
|
@ -311,13 +310,13 @@ class SvgToGcodePlugin(octoprint.plugin.SlicerPlugin,
|
|||
if p.returncode == 0:
|
||||
return True, None
|
||||
else:
|
||||
self._logger.warn("Could not slice via Cura, got return code %r" % p.returncode)
|
||||
self._logger.warn("Could not slice, got return code %r" % p.returncode)
|
||||
return False, "Got returncode %r" % p.returncode
|
||||
|
||||
except octoprint.slicing.SlicingCancelled as e:
|
||||
raise e
|
||||
except:
|
||||
self._logger.exception("Could not slice via Cura, got an unknown error")
|
||||
self._logger.exception("Could not slice, got an unknown error")
|
||||
return False, "Unknown error, please consult the log file"
|
||||
|
||||
finally:
|
||||
|
|
|
|||
|
|
@ -293,8 +293,8 @@ var UI_API_KEY = "{{ uiApiKey }}";
|
|||
<!--<div class="btn btn-mini toggleAdditionalData" data-bind="click: function() { if ($root.enableAdditionalData($data)) { $root.toggleAdditionalData($data); } else { return; } }, css: { disabled: !$root.enableAdditionalData($data) }"><i class="icon-chevron-down"></i></div>-->
|
||||
<a class="btn btn-mini" data-bind="attr: {href: $root.downloadLink($data), css: {disabled: !$root.downloadLink($data)}}"><i class="icon-download-alt" title="{{ _('Download') }}"></i></a>
|
||||
<div class="btn btn-mini" data-bind="click: function() { if ($root.enableRemove($data)) { $root.removeFile($data); } else { return; } }, css: {disabled: !$root.enableRemove($data)}"><i class="icon-trash" title="{{ _('Remove') }}"></i></div>
|
||||
<div class="btn btn-mini" data-bind="click: function() { if ($root.enableSelect($data)) { $root.loadFile($data, false); } else { return; } }, css: {disabled: !$root.enableSelect($data)}"><i class="icon-folder-open" title="{{ _('Load') }}"></i></div>
|
||||
<div class="btn btn-mini" data-bind="click: function() { if ($root.enableSelect($data)) { $root.loadFile($data, true); } else { return; } }, css: {disabled: !$root.enableSelect($data)}"><i class="icon-fire" title="{{ _('Load and Laser') }}"></i></div>
|
||||
<!--<div class="btn btn-mini" data-bind="click: function() { if ($root.enableSelect($data)) { $root.loadFile($data, false); } else { return; } }, css: {disabled: !$root.enableSelect($data)}"><i class="icon-folder-open" title="{{ _('Load') }}"></i></div>-->
|
||||
<div class="btn btn-mini" data-bind="click: function() { if ($root.enableSelect($data)) { $root.startGcodeWithSafetyWarning($data); } else { return; } }, css: {disabled: !$root.enableSelect($data)}"><i class="icon-fire" title="{{ _('Load and Laser') }}"></i></div>
|
||||
<!--<div class="btn btn-mini" data-bind="click: function() { $root.showFile($data); }"><i class="icon-arrow-right" title="{{ _('Preview') }}"></i></div>-->
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -258,6 +258,7 @@ class Printer():
|
|||
if self._comm is None or (self._comm.isBusy() or self._comm.isStreaming()):
|
||||
self._logger.info("Cannot load file: printer not connected or currently busy")
|
||||
return
|
||||
print("printe.py", "selectFile", filename, sd, printAfterSelect);
|
||||
|
||||
self._printAfterSelect = printAfterSelect
|
||||
self._comm.selectFile(filename, sd)
|
||||
|
|
@ -281,7 +282,7 @@ class Printer():
|
|||
return
|
||||
if self._selectedFile is None:
|
||||
return
|
||||
|
||||
|
||||
self._addPositionData(None, None)
|
||||
self._setCurrentZ(None)
|
||||
self._comm.startPrint()
|
||||
|
|
|
|||
|
|
@ -381,7 +381,6 @@ def gcodeConvertCommand():
|
|||
|
||||
|
||||
if command == "convert":
|
||||
print("files.py convert", data)
|
||||
|
||||
import os
|
||||
name, _ = os.path.splitext(data['gcode'])
|
||||
|
|
|
|||
|
|
@ -117,7 +117,6 @@ function GcodeFilesViewModel(printerStateViewModel, loginStateViewModel, slicing
|
|||
|
||||
self._otherRequestInProgress = false;
|
||||
self.requestData = function(filenameToFocus, locationToFocus) {
|
||||
console.log("requestData", filenameToFocus, locationToFocus);
|
||||
if (self._otherRequestInProgress) return;
|
||||
|
||||
self._otherRequestInProgress = true;
|
||||
|
|
@ -126,7 +125,6 @@ function GcodeFilesViewModel(printerStateViewModel, loginStateViewModel, slicing
|
|||
method: "GET",
|
||||
dataType: "json",
|
||||
success: function(response) {
|
||||
console.log("requestData api/files/response", response);
|
||||
self.fromResponse(response, filenameToFocus, locationToFocus);
|
||||
self._otherRequestInProgress = false;
|
||||
},
|
||||
|
|
@ -174,6 +172,12 @@ function GcodeFilesViewModel(printerStateViewModel, loginStateViewModel, slicing
|
|||
data: JSON.stringify({command: "select", print: printAfterLoad})
|
||||
});
|
||||
};
|
||||
|
||||
self.startGcodeWithSafetyWarning = function(gcodeFile){
|
||||
self.printerState.show_safety_glasses_warning(function(){
|
||||
self.loadFile(gcodeFile, true);
|
||||
});
|
||||
};
|
||||
|
||||
self.removeFile = function(file) {
|
||||
if (!file || !file.refs || !file.refs.hasOwnProperty("resource")) return;
|
||||
|
|
@ -202,7 +206,6 @@ function GcodeFilesViewModel(printerStateViewModel, loginStateViewModel, slicing
|
|||
self.placeSVG = function(file) {
|
||||
if (file && file["refs"] && file["refs"]["download"]) {
|
||||
var url = file.refs.download.replace("downloads", "serve");
|
||||
console.log("placeSVG", url);
|
||||
self.workingArea.placeSVG(url);
|
||||
}
|
||||
};
|
||||
|
|
@ -352,37 +355,49 @@ function GcodeFilesViewModel(printerStateViewModel, loginStateViewModel, slicing
|
|||
};
|
||||
|
||||
self.onUpdatedFiles = function(payload) {
|
||||
console.log("onUpdatedFiles", payload)
|
||||
if (payload.type == "gcode") {
|
||||
self.requestData();
|
||||
}
|
||||
};
|
||||
|
||||
self.onSlicingDone = function(payload) {
|
||||
//self.requestData();
|
||||
jQuery('<div/>', {
|
||||
class: "safety_glasses_heads_up"
|
||||
}).appendTo("#confirmation_dialog .confirmation_dialog_message");
|
||||
jQuery('<div/>', {
|
||||
class: "safety_glasses_warning",
|
||||
text: gettext("The laser will now start. Protect yourself and everybody in the room appropriately before proceeding!")
|
||||
}).appendTo("#confirmation_dialog .confirmation_dialog_message");
|
||||
//$("#confirmation_dialog .confirmation_dialog_message").text(gettext("The laser will now start. Protect yourself and everybody in the room appropriately before proceeding!"));
|
||||
$("#confirmation_dialog .confirmation_dialog_acknowledge").unbind("click");
|
||||
$("#confirmation_dialog .confirmation_dialog_acknowledge").click(
|
||||
function(e) {
|
||||
e.preventDefault();
|
||||
$("#confirmation_dialog").modal("hide");
|
||||
var url = API_BASEURL + "files/" + payload.gcode_location + "/" + payload.gcode;
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
contentType: "application/json; charset=UTF-8",
|
||||
data: JSON.stringify({command: "select", print: true})
|
||||
});
|
||||
var callback = function(e) {
|
||||
e.preventDefault();
|
||||
var url = API_BASEURL + "files/" + payload.gcode_location + "/" + payload.gcode;
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
contentType: "application/json; charset=UTF-8",
|
||||
data: JSON.stringify({command: "select", print: true})
|
||||
});
|
||||
$("#confirmation_dialog").modal("show");
|
||||
};
|
||||
self.printerState.show_safety_glasses_warning(callback);
|
||||
|
||||
//self.requestData();
|
||||
// jQuery('<div/>', {
|
||||
// class: "safety_glasses_heads_up"
|
||||
// }).appendTo("#confirmation_dialog .confirmation_dialog_message");
|
||||
// jQuery('<div/>', {
|
||||
// class: "safety_glasses_warning",
|
||||
// text: gettext("The laser will now start. Protect yourself and everybody in the room appropriately before proceeding!")
|
||||
// }).appendTo("#confirmation_dialog .confirmation_dialog_message");
|
||||
// //$("#confirmation_dialog .confirmation_dialog_message").text(gettext("The laser will now start. Protect yourself and everybody in the room appropriately before proceeding!"));
|
||||
// $("#confirmation_dialog .confirmation_dialog_acknowledge").unbind("click");
|
||||
// $("#confirmation_dialog .confirmation_dialog_acknowledge").click(
|
||||
// function(e) {
|
||||
// e.preventDefault();
|
||||
// $("#confirmation_dialog").modal("hide");
|
||||
// var url = API_BASEURL + "files/" + payload.gcode_location + "/" + payload.gcode;
|
||||
// $.ajax({
|
||||
// url: url,
|
||||
// type: "POST",
|
||||
// dataType: "json",
|
||||
// contentType: "application/json; charset=UTF-8",
|
||||
// data: JSON.stringify({command: "select", print: true})
|
||||
// });
|
||||
// });
|
||||
// $("#confirmation_dialog").modal("show");
|
||||
};
|
||||
|
||||
self.onMetadataAnalysisFinished = function(payload) {
|
||||
|
|
|
|||
|
|
@ -206,16 +206,35 @@ function PrinterStateViewModel(loginStateViewModel, vectorConversionViewModel) {
|
|||
self.busyFiles(busyFiles);
|
||||
};
|
||||
|
||||
self.show_safety_glasses_warning = function(callback){
|
||||
|
||||
jQuery('<div/>', {
|
||||
class: "safety_glasses_heads_up"
|
||||
}).appendTo("#confirmation_dialog .confirmation_dialog_message");
|
||||
jQuery('<div/>', {
|
||||
class: "safety_glasses_warning",
|
||||
text: gettext("The laser will now start. Protect yourself and everybody in the room appropriately before proceeding!")
|
||||
}).appendTo("#confirmation_dialog .confirmation_dialog_message");
|
||||
//$("#confirmation_dialog .confirmation_dialog_message").text(gettext("The laser will now start. Protect yourself and everybody in the room appropriately before proceeding!"));
|
||||
$("#confirmation_dialog .confirmation_dialog_acknowledge").unbind("click");
|
||||
$("#confirmation_dialog .confirmation_dialog_acknowledge").click(
|
||||
function(e){
|
||||
if(typeof callback === 'function'){
|
||||
callback(e);
|
||||
$("#confirmation_dialog").modal("hide");
|
||||
$("#confirmation_dialog .confirmation_dialog_message").html('');
|
||||
}
|
||||
});
|
||||
$("#confirmation_dialog").modal("show");
|
||||
|
||||
};
|
||||
|
||||
self.print_with_safety_glasses_warning = function(){
|
||||
$("#confirmation_dialog .confirmation_dialog_message").text(gettext("The laser will now start. Protect yourself and everybody in the room appropriately before proceeding!"));
|
||||
$("#confirmation_dialog .confirmation_dialog_acknowledge").unbind("click");
|
||||
$("#confirmation_dialog .confirmation_dialog_acknowledge").click(
|
||||
function(e) {
|
||||
e.preventDefault();
|
||||
$("#confirmation_dialog").modal("hide");
|
||||
self.print();
|
||||
});
|
||||
$("#confirmation_dialog").modal("show");
|
||||
var callback = function(e) {
|
||||
e.preventDefault();
|
||||
self.print();
|
||||
};
|
||||
self.show_safety_glasses_warning(callback);
|
||||
};
|
||||
|
||||
self.print = function() {
|
||||
|
|
|
|||
|
|
@ -218,6 +218,7 @@ class MachineCom(object):
|
|||
|
||||
oldState = self.getStateString()
|
||||
self._state = newState
|
||||
print('Changing monitoring state from \'%s\' to \'%s\'' % (oldState, self.getStateString()))
|
||||
self._log('Changing monitoring state from \'%s\' to \'%s\'' % (oldState, self.getStateString()))
|
||||
self._callback.mcStateChange(newState)
|
||||
|
||||
|
|
@ -448,6 +449,7 @@ class MachineCom(object):
|
|||
"file": self._currentFile.getFilename(),
|
||||
"origin": self._currentFile.getFileLocation()
|
||||
})
|
||||
print("comm.py selectFile", filename, self._currentFile)
|
||||
self._callback.mcFileSelected(filename, self._currentFile.getFilesize(), False)
|
||||
|
||||
def unselectFile(self):
|
||||
|
|
@ -745,7 +747,8 @@ class MachineCom(object):
|
|||
|
||||
if("Alarm" in line):
|
||||
self._changeState(self.STATE_LOCKED)
|
||||
if("Idle" in line):
|
||||
if("Idle" in line and self._state == self.STATE_LOCKED):
|
||||
print("### comm.py GRBL pos update", line)
|
||||
self._changeState(self.STATE_OPERATIONAL)
|
||||
|
||||
|
||||
|
|
@ -938,7 +941,7 @@ class MachineCom(object):
|
|||
self.close()
|
||||
|
||||
### Operational
|
||||
elif self._state == self.STATE_OPERATIONAL or self._state == self.STATE_PAUSED or self.STATE_LOCKED:
|
||||
elif self._state == self.STATE_OPERATIONAL or self._state == self.STATE_PAUSED or self._state == self.STATE_LOCKED:
|
||||
#Request the temperature on comm timeout (every 5 seconds) when we are not printing.
|
||||
if line == "" or "wait" in line:
|
||||
if self._resendDelta is not None:
|
||||
|
|
|
|||
Loading…
Reference in a new issue