grbl state alarm treatment

This commit is contained in:
Teja 2015-01-09 21:47:57 +01:00
parent a87131ac1f
commit 59368ca240
9 changed files with 32 additions and 5 deletions

View file

@ -154,7 +154,7 @@ var UI_API_KEY = "{{ uiApiKey }}";
</div>
<div>
<button class="btn box pull-left" data-bind="enable: isOperational() && !isPrinting() && loginState.isUser(), click: function() { $root.sendJogCommand('x',-1) }"><i class="icon-arrow-left"></i></button>
<button class="btn box pull-left" data-bind="enable: isOperational() && !isPrinting() && loginState.isUser(), click: function() { $root.sendHomeCommand(['x', 'y']) }"><i class="icon-home"></i></button>
<button class="btn box pull-left" data-bind="enable: (isOperational() || isLocked()) && !isPrinting() && loginState.isUser(), click: function() { $root.sendHomeCommand(['x', 'y']) }"><i class="icon-home"></i></button>
<button class="btn box pull-left" data-bind="enable: isOperational() && !isPrinting() && loginState.isUser(), click: function() { $root.sendJogCommand('x',1) }"><i class="icon-arrow-right"></i></button>
</div>
<div>
@ -282,7 +282,7 @@ var UI_API_KEY = "{{ uiApiKey }}";
<div class="size">{{ _('Size') }}: <span data-bind="text: formatSize(size)"></span></div>
<div class="btn-group action-buttons">
<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() { $root.convertSVG($data); }, css: {disabled: !$root.enableSVGConversion($data)}"><i class="icon-fire" title="{{ _('Convert to Laserpath') }}"></i></div>
<div class="btn btn-mini" data-bind="click: function() { $root.convertSVG($data); }, css: {disabled: !$root.enableSVGConversion($data)}"><i class="icon-play" title="{{ _('Convert to Laserpath') }}"></i></div>
</div>
</div>
</script>

View file

@ -464,6 +464,7 @@ class Printer():
def _getStateFlags(self):
return {
"operational": self.isOperational(),
"locked": self.isLocked(),
"printing": self.isPrinting(),
"closedOrError": self.isClosedOrError(),
"error": self.isError(),
@ -681,6 +682,9 @@ class Printer():
def isOperational(self):
return self._comm is not None and self._comm.isOperational()
def isLocked(self):
return self._comm is not None and self._comm.isLocked()
def isPrinting(self):
return self._comm is not None and self._comm.isPrinting()

View file

@ -19,7 +19,7 @@ import octoprint.util as util
@api.route("/printer", methods=["GET"])
def printerState():
if not printer.isOperational():
if not (printer.isOperational() or printer.isLocked()):
return make_response("Printer is not operational", 409)
# process excludes

View file

@ -1568,7 +1568,7 @@ input.search-query,
}
/* TODO ... don't use :hover ... tablets! */
/* TODO ... don't use :hover ... tablets!
.file_list_entry .action-buttons,
.file_list_entry .uploaded,
.file_list_entry .size {
@ -1580,6 +1580,7 @@ input.search-query,
.file_list_entry:hover .size {
display: block;
}
*/
#area_preview {
background-image: url(../img/crosshair.png);

View file

@ -13,6 +13,7 @@ function ConnectionViewModel(loginStateViewModel, settingsViewModel) {
self.isErrorOrClosed = ko.observable(undefined);
self.isOperational = ko.observable(undefined);
self.isLocked = ko.observable(undefined);
self.isPrinting = ko.observable(undefined);
self.isPaused = ko.observable(undefined);
self.isError = ko.observable(undefined);
@ -69,6 +70,7 @@ function ConnectionViewModel(loginStateViewModel, settingsViewModel) {
self.isErrorOrClosed(data.flags.closedOrError);
self.isOperational(data.flags.operational);
self.isOperational(data.flags.locked);
self.isPaused(data.flags.paused);
self.isPrinting(data.flags.printing);
self.isError(data.flags.error);

View file

@ -14,6 +14,7 @@ function ControlViewModel(loginStateViewModel, settingsViewModel, printerStateVi
self.isErrorOrClosed = ko.observable(undefined);
self.isOperational = ko.observable(undefined);
self.isLocked = ko.observable(undefined);
self.isPrinting = ko.observable(undefined);
self.isPaused = ko.observable(undefined);
self.isError = ko.observable(undefined);
@ -60,6 +61,7 @@ function ControlViewModel(loginStateViewModel, settingsViewModel, printerStateVi
self._processStateData = function(data) {
self.isErrorOrClosed(data.flags.closedOrError);
self.isOperational(data.flags.operational);
self.isLocked(data.flags.locked);
self.isPaused(data.flags.paused);
self.isPrinting(data.flags.printing);
self.isError(data.flags.error);

View file

@ -220,6 +220,7 @@ function GcodeFilesViewModel(printerStateViewModel, loginStateViewModel, slicing
self.downloadLink = function(data) {
if (data["refs"] && data["refs"]["download"]) {
console.log(data["refs"])
return data["refs"]["download"];
} else {
return false;

View file

@ -6,6 +6,7 @@ function PrinterStateViewModel(loginStateViewModel) {
self.stateString = ko.observable(undefined);
self.isErrorOrClosed = ko.observable(undefined);
self.isOperational = ko.observable(undefined);
self.isLocked = ko.observable(undefined);
self.isPrinting = ko.observable(undefined);
self.isPaused = ko.observable(undefined);
self.isError = ko.observable(undefined);
@ -133,6 +134,7 @@ function PrinterStateViewModel(loginStateViewModel) {
self.stateString(gettext(data.text));
self.isErrorOrClosed(data.flags.closedOrError);
self.isOperational(data.flags.operational);
self.isLocked(data.flags.locked);
self.isPaused(data.flags.paused);
self.isPrinting(data.flags.printing);
self.isError(data.flags.error);

View file

@ -114,6 +114,7 @@ class MachineCom(object):
STATE_ERROR = 9
STATE_CLOSED_WITH_ERROR = 10
STATE_TRANSFERING_FILE = 11
STATE_LOCKED = 12
def __init__(self, port = None, baudrate = None, callbackObject = None):
self._logger = logging.getLogger(__name__)
@ -263,6 +264,8 @@ class MachineCom(object):
return "Error: %s" % (self.getShortErrorString())
if self._state == self.STATE_TRANSFERING_FILE:
return "Transfering file to SD"
if self._state == self.STATE_LOCKED:
return "Locked"
return "?%d?" % (self._state)
def getShortErrorString(self):
@ -281,6 +284,9 @@ class MachineCom(object):
def isOperational(self):
return self._state == self.STATE_OPERATIONAL or self._state == self.STATE_PRINTING or self._state == self.STATE_PAUSED or self._state == self.STATE_TRANSFERING_FILE
def isLocked(self):
return self._state == self.STATE_LOCKED
def isPrinting(self):
return self._state == self.STATE_PRINTING
@ -736,7 +742,15 @@ class MachineCom(object):
grblMoving = True
grblLastStatus = line
if("Alarm" in line):
self._changeState(self.STATE_LOCKED)
else:
if(grblMoving):
self._changeState(self.STATE_PRINTING)
else:
self._changeState(self.STATE_OPERATIONAL)
parts = line.strip("\r\n").split(":")
pos = parts[1].split(",")
@ -745,6 +759,7 @@ class MachineCom(object):
pos = parts[2].split(",")
WPos = (float(pos[0]), float(pos[1]), float( pos[2].strip(">") ))
self._callback.mcPosUpdate(MPos, WPos)