Compare commits
109
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
25dc81a5d2 | ||
|
|
9e27744a05 | ||
|
|
77df620237 | ||
|
|
8998be66eb | ||
|
|
1180cac147 | ||
|
|
270231a004 | ||
|
|
c2f0f6c7c4 | ||
|
|
c7afae38a8 | ||
|
|
873a825e57 | ||
|
|
dc2318f404 | ||
|
|
d8b95f845c | ||
|
|
014d39c11d | ||
|
|
a544a852f2 | ||
|
|
3311a48e3a | ||
|
|
5ac908afd4 | ||
|
|
12a3e659b1 | ||
|
|
b0780af7fa | ||
|
|
2ec31c7521 | ||
|
|
f2562500a3 | ||
|
|
85a567bdab | ||
|
|
11c415fd17 | ||
|
|
d67ea41032 | ||
|
|
66357ebe7e | ||
|
|
8dbde90a93 | ||
|
|
d2910de121 | ||
|
|
c5be9908c5 | ||
|
|
e844d42275 | ||
|
|
a0a6f958d9 | ||
|
|
16d156b530 | ||
|
|
420226b6c0 | ||
|
|
da8e72b0d6 | ||
|
|
ef13cbecfd | ||
|
|
5910bba30e | ||
|
|
19ba3b1f99 | ||
|
|
23bc6b8df7 | ||
|
|
69bea0f5b0 | ||
|
|
3c53394f4b | ||
|
|
8741053dfc | ||
|
|
8752f70ff3 | ||
|
|
2b66df39b6 | ||
|
|
17bb0e693d | ||
|
|
94e5b5fdaf | ||
|
|
497ec5c6b2 | ||
|
|
eaeae8d5ec | ||
|
|
3a05a2653b | ||
|
|
0ca63017c7 | ||
|
|
ea3416693c | ||
|
|
6dc56af3fa | ||
|
|
af297c2031 | ||
|
|
024cf81238 | ||
|
|
9d5a500b25 | ||
|
|
4bab1975c8 | ||
|
|
eae4153158 | ||
|
|
a92aa96623 | ||
|
|
ccf0ab3b51 | ||
|
|
7259c1c2ef | ||
|
|
d66675c672 | ||
|
|
38483b0c67 | ||
|
|
19de4053fe | ||
|
|
d0ff6d1579 | ||
|
|
105b68c807 | ||
|
|
97a6d8a15e | ||
|
|
26fa3df4aa | ||
|
|
9a336336d7 | ||
|
|
047d7f5046 | ||
|
|
4fc561dab5 | ||
|
|
785ac07de9 | ||
|
|
41c6978880 | ||
|
|
f7ebc4ec11 | ||
|
|
c06e8f47f0 | ||
|
|
dceb5dccd3 | ||
|
|
7a50138ae3 | ||
|
|
43cead8249 | ||
|
|
8492944fb5 | ||
|
|
f7433de2bf | ||
|
|
bbd46fd3a6 | ||
|
|
077486c838 | ||
|
|
baedab5931 | ||
|
|
36c8f25fd1 | ||
|
|
b3050f1058 | ||
|
|
a04a61f61b | ||
|
|
58204248bb | ||
|
|
a47740ae28 | ||
|
|
48d6a27fad | ||
|
|
5ffcd78f27 | ||
|
|
de9dd77b50 | ||
|
|
51c77be7a2 | ||
|
|
f98563cbe9 | ||
|
|
8c8059db30 | ||
|
|
fa586426fa | ||
|
|
60a1bf0d43 | ||
|
|
a48f194350 | ||
|
|
78f0ec94ea | ||
|
|
44f9e756da | ||
|
|
3d992d56cd | ||
|
|
72f7b4627f | ||
|
|
5c1f165079 | ||
|
|
95755ba515 | ||
|
|
791e4e26a9 | ||
|
|
4d61963894 | ||
|
|
5622a9c565 | ||
|
|
2e5069d5a1 | ||
|
|
4cd692e061 | ||
|
|
216a88c00c | ||
|
|
10f1917589 | ||
|
|
26f7d6e517 | ||
|
|
b7b2e99ab1 | ||
|
|
0966b231e8 | ||
|
|
00e1a1962b |
No files matched your search
@@ -51,6 +51,8 @@
|
||||
long as they are in use
|
||||
* Settings in UI get refreshed when opening settings dialog
|
||||
* New event "SettingsUpdated"
|
||||
* Print time estimation is now not displayed until it becomes somewhat stable. Display in web interface now also happens
|
||||
in a fuzzy way instead of the format hh:mm:ss, to not suggest a high accuracy anymore where the can't be one
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
@@ -73,6 +75,7 @@
|
||||
|
||||
* [#634](https://github.com/foosel/OctoPrint/pull/634) - Fixed missing `branch` fields in version dicts generated
|
||||
by versioneer
|
||||
* [IRC] Don't hiccup on slic3r filament_diameter comments generated for multi extruder setups
|
||||
|
||||
## 1.1.1 (2014-10-27)
|
||||
|
||||
|
||||
@@ -3,3 +3,4 @@ nose>=1.3.0
|
||||
sphinxcontrib-httpdomain
|
||||
sphinx_rtd_theme
|
||||
po2json
|
||||
ddt
|
||||
@@ -19,6 +19,7 @@ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||
DESC="Octoprint Daemon"
|
||||
NAME="Octoprint"
|
||||
DAEMON=/usr/local/bin/octoprint
|
||||
NICE=-10
|
||||
PIDFILE=/var/run/$NAME.pid
|
||||
PKGNAME=octoprint
|
||||
SCRIPTNAME=/etc/init.d/$PKGNAME
|
||||
@@ -72,7 +73,7 @@ do_start()
|
||||
RETVAL="$?"
|
||||
|
||||
if [ $RETVAL != 0 ]; then
|
||||
start-stop-daemon --start --background --quiet --pidfile $PIDFILE --make-pidfile \
|
||||
start-stop-daemon --start --background --quiet --pidfile $PIDFILE --make-pidfile --nicelevel $NICE\
|
||||
--exec $DAEMON --chuid $OCTOPRINT_USER --user $OCTOPRINT_USER --umask $UMASK -- $DAEMON_ARGS
|
||||
RETVAL="$?"
|
||||
fi
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
# coding=utf-8
|
||||
__author__ = "Gina Häußge <osd@foosel.net>"
|
||||
__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html"
|
||||
__copyright__ = "Copyright (C) 2014 Gina Häußge - Released under terms of the AGPLv3 License"
|
||||
|
||||
|
||||
@@ -0,0 +1,589 @@
|
||||
# coding=utf-8
|
||||
__author__ = "Gina Häußge <osd@foosel.net>"
|
||||
__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html"
|
||||
__copyright__ = "Copyright (C) 2014 Gina Häußge - Released under terms of the AGPLv3 License"
|
||||
|
||||
|
||||
import logging
|
||||
import os
|
||||
import time
|
||||
from octoprint.events import eventManager, Events
|
||||
from octoprint.comm.transport import MessageReceiver, StateReceiver, LogReceiver, State as TransportState
|
||||
from octoprint.filemanager.destinations import FileDestinations
|
||||
from octoprint.settings import settings
|
||||
|
||||
|
||||
class Protocol(MessageReceiver, StateReceiver, LogReceiver):
|
||||
|
||||
def __init__(self, transport_factory, protocol_listener=None):
|
||||
self._logger = logging.getLogger(__name__)
|
||||
|
||||
self._transport = transport_factory(self, self, self)
|
||||
self._transport_properties = self._transport.get_properties()
|
||||
|
||||
self._protocol_listener = protocol_listener
|
||||
self._state = State.OFFLINE
|
||||
|
||||
self._heatup_start_time = None
|
||||
self._heatup_time_lost = 0.0
|
||||
|
||||
self._pause_start_time = None
|
||||
self._pause_time_lost = 0.0
|
||||
|
||||
self._current_file = None
|
||||
|
||||
self._current_z = 0.0
|
||||
|
||||
self._sd_available = False
|
||||
self._sd_files = []
|
||||
|
||||
self._current_temperature = {}
|
||||
self._temperature_offsets = {}
|
||||
|
||||
self._error = None
|
||||
|
||||
def _reset(self):
|
||||
self._heatup_start_time = None
|
||||
self._heatup_time_lost = 0.0
|
||||
|
||||
self._current_file = None
|
||||
|
||||
self._current_z = 0.0
|
||||
|
||||
self._sd_available = False
|
||||
self._sd_files = []
|
||||
|
||||
self._current_temperature = {}
|
||||
self._temperature_offsets = {}
|
||||
|
||||
self._error = None
|
||||
|
||||
##~~ public
|
||||
|
||||
def connect(self, protocol_options, transport_options):
|
||||
self._transport.connect(transport_options)
|
||||
|
||||
def disconnect(self, on_error=False):
|
||||
if self.is_printing():
|
||||
payload = None
|
||||
if self._current_file is not None:
|
||||
payload = {
|
||||
"file": self._current_file.getFilename(),
|
||||
"filename": os.path.basename(self._current_file.getFilename()),
|
||||
"origin": self._current_file.getFileLocation()
|
||||
}
|
||||
eventManager().fire(Events.PRINT_FAILED, payload)
|
||||
self._transport.disconnect(on_error)
|
||||
|
||||
def send_manually(self, command, high_priority=False):
|
||||
pass
|
||||
|
||||
def select_file(self, filename, origin):
|
||||
pass
|
||||
|
||||
def deselect_file(self):
|
||||
pass
|
||||
|
||||
def start_print(self):
|
||||
if self._current_file is None:
|
||||
raise ValueError("No file selected for printing")
|
||||
|
||||
self._heatup_start_time = None
|
||||
self._heatup_time_lost = 0.0
|
||||
|
||||
self._current_file.start()
|
||||
self._changeState(State.PRINTING)
|
||||
eventManager().fire(Events.PRINT_STARTED, {
|
||||
"file": self._current_file.getFilename(),
|
||||
"filename": os.path.basename(self._current_file.getFilename()),
|
||||
"origin": self._current_file.getFileLocation()
|
||||
})
|
||||
|
||||
def pause_print(self, only_pause=None, only_resume=None):
|
||||
payload = {
|
||||
"file": self._current_file.getFilename(),
|
||||
"filename": os.path.basename(self._current_file.getFilename()),
|
||||
"origin": self._current_file.getFileLocation()
|
||||
}
|
||||
|
||||
if self._state == State.PRINTING and not only_resume:
|
||||
self._pause_start_time = time.time()
|
||||
|
||||
self._changeState(State.PAUSED)
|
||||
eventManager().fire(Events.PRINT_PAUSED, payload)
|
||||
|
||||
elif self._state == State.PAUSED and not only_pause:
|
||||
if self._pause_start_time:
|
||||
self._pause_time_lost += time.time() - self._pause_start_time
|
||||
self._pause_start_time = None
|
||||
|
||||
self._changeState(State.PRINTING)
|
||||
eventManager().fire(Events.PRINT_RESUMED, payload)
|
||||
|
||||
def cancel_print(self):
|
||||
eventManager().fire(Events.PRINT_CANCELLED, {
|
||||
"file": self._current_file.getFilename(),
|
||||
"filename": os.path.basename(self._current_file.getFilename()),
|
||||
"origin": self._current_file.getFileLocation()
|
||||
})
|
||||
self._changeState(State.OPERATIONAL)
|
||||
self._print_cancelled()
|
||||
if self._protocol_listener is not None:
|
||||
self._protocol_listener.onPrintjobCancelled(self)
|
||||
|
||||
def _print_cancelled(self):
|
||||
pass
|
||||
|
||||
def init_sd(self):
|
||||
pass
|
||||
|
||||
def release_sd(self):
|
||||
pass
|
||||
|
||||
def refresh_sd_files(self):
|
||||
pass
|
||||
|
||||
def add_sd_file(self, path, local, remote):
|
||||
pass
|
||||
|
||||
def remove_sd_file(self, filename):
|
||||
pass
|
||||
|
||||
def get_state(self):
|
||||
return self._state
|
||||
|
||||
def get_current_temperatures(self):
|
||||
return self._current_temperature
|
||||
|
||||
def get_temperature_offsets(self):
|
||||
result = {}
|
||||
result.update(self._temperature_offsets)
|
||||
return result
|
||||
|
||||
def set_temperature_offsets(self, new_temperature_offsets):
|
||||
offsets = {}
|
||||
offsets.update(new_temperature_offsets)
|
||||
self._temperature_offsets = offsets
|
||||
|
||||
def get_sd_files(self):
|
||||
return self._sd_files
|
||||
|
||||
def get_print_time(self):
|
||||
if self._current_file is None or self._current_file.getStartTime() is None:
|
||||
return None
|
||||
else:
|
||||
return max(int(time.time() - self._current_file.getStartTime() - self._heatup_time_lost - self._pause_time_lost), 0)
|
||||
|
||||
def get_connection_options(self):
|
||||
return self._transport.get_connection_options()
|
||||
|
||||
def get_current_connection(self):
|
||||
return self._transport.get_current_connection()
|
||||
|
||||
##~~ granular state detection for implementations
|
||||
|
||||
def is_heating_up(self):
|
||||
return self._heatup_start_time is not None
|
||||
|
||||
def is_printing(self):
|
||||
return self._state == State.PRINTING or self._state == State.PAUSED
|
||||
|
||||
def is_sd_printing(self):
|
||||
return isinstance(self._current_file, PrintingSdFileInformation) and self.is_busy()
|
||||
|
||||
def is_streaming(self):
|
||||
return self._state == State.STREAMING
|
||||
|
||||
def is_busy(self):
|
||||
return self.is_printing() or self.is_streaming()
|
||||
|
||||
def is_operational(self):
|
||||
return self._state == State.OPERATIONAL
|
||||
|
||||
def is_sd_ready(self):
|
||||
return self._sd_available
|
||||
|
||||
##~~ state tracking and reporting to protocol listener
|
||||
|
||||
def _changeState(self, newState):
|
||||
oldState = self._state
|
||||
self._state = newState
|
||||
self._stateChanged(newState)
|
||||
if self._protocol_listener is not None:
|
||||
self._protocol_listener.onStateChange(self, oldState, newState)
|
||||
|
||||
def _stateChanged(self, newState):
|
||||
pass
|
||||
|
||||
def _updateTemperature(self, temperatureData):
|
||||
self._current_temperature = temperatureData
|
||||
self._temperatureUpdated(temperatureData)
|
||||
if self._protocol_listener is not None:
|
||||
self._protocol_listener.onTemperatureUpdate(self, temperatureData)
|
||||
|
||||
def _temperatureUpdated(self, temperatureData):
|
||||
pass
|
||||
|
||||
def _reportProgress(self, completion=None, filepos=None):
|
||||
if completion is None:
|
||||
completion = self._getPrintCompletion()
|
||||
if filepos is None:
|
||||
filepos = self._getPrintFilepos()
|
||||
|
||||
progress = {
|
||||
"completion": completion,
|
||||
"filepos": filepos,
|
||||
"printTime": self.get_print_time()
|
||||
}
|
||||
|
||||
self._progressReported(progress)
|
||||
if self._protocol_listener is not None:
|
||||
self._protocol_listener.onProgress(self, progress)
|
||||
|
||||
def _progressReported(self, progress):
|
||||
pass
|
||||
|
||||
def _reportZChange(self, z):
|
||||
old_z = self._current_z
|
||||
self._current_z = z
|
||||
|
||||
self._zChangeReported(z)
|
||||
if self._protocol_listener is not None:
|
||||
self._protocol_listener.onZChange(self, old_z, z)
|
||||
|
||||
def _zChangeReported(self, newZ):
|
||||
pass
|
||||
|
||||
def _changeSdState(self, sdAvailable):
|
||||
self._sd_available = sdAvailable
|
||||
self._sdStateChanged(sdAvailable)
|
||||
if self._sd_available:
|
||||
self.refresh_sd_files()
|
||||
else:
|
||||
self._sd_files = []
|
||||
if self._protocol_listener is not None:
|
||||
self._protocol_listener.onSdStateChange(self, sdAvailable)
|
||||
|
||||
def _sdStateChanged(self, sdAvailable):
|
||||
pass
|
||||
|
||||
def _selectFile(self, currentFile):
|
||||
self._current_file = currentFile
|
||||
self._fileSelected(currentFile)
|
||||
if self._protocol_listener is not None:
|
||||
self._protocol_listener.onFileSelected(self, currentFile.getFilename(), currentFile.getFilesize(), currentFile.getFileLocation())
|
||||
eventManager().fire(Events.FILE_SELECTED, {
|
||||
"file": self._current_file.getFilename(),
|
||||
"origin": self._current_file.getFileLocation()
|
||||
})
|
||||
|
||||
def _fileSelected(self, currentFile):
|
||||
pass
|
||||
|
||||
def _sendSdFiles(self):
|
||||
self._sdFilesSent()
|
||||
if self._protocol_listener is not None:
|
||||
self._protocol_listener.onSdFiles(self, self._sd_files)
|
||||
|
||||
def _sdFilesSent(self):
|
||||
pass
|
||||
|
||||
def _finishPrintjob(self):
|
||||
self._reportProgress(completion=100, filepos=self._current_file.getFilesize())
|
||||
self._changeState(State.OPERATIONAL)
|
||||
if self._protocol_listener is not None:
|
||||
self._protocol_listener.onPrintjobDone(self)
|
||||
eventManager().fire(Events.PRINT_DONE, {
|
||||
"file": self._current_file.getFilename(),
|
||||
"filename": os.path.basename(self._current_file.getFilename()),
|
||||
"origin": self._current_file.getFileLocation(),
|
||||
"time": time.time() - self._current_file.getStartTime() if self._current_file.getStartTime() is not None else None
|
||||
})
|
||||
self._printJobFinished()
|
||||
|
||||
def _printJobFinished(self):
|
||||
pass
|
||||
|
||||
def _startFileTransfer(self, filename, filesize):
|
||||
self._fileTransferStarted(filename, filesize)
|
||||
if self._protocol_listener is not None:
|
||||
self._protocol_listener.onFileTransferStarted(self, filename, filesize)
|
||||
|
||||
def _fileTransferStarted(self, filename, filesize):
|
||||
pass
|
||||
|
||||
def _finishFileTransfer(self):
|
||||
self._changeState(State.OPERATIONAL)
|
||||
|
||||
current_file = self._current_file
|
||||
self._current_file = None
|
||||
|
||||
self._fileTransferFinished(current_file)
|
||||
|
||||
if self._protocol_listener is not None:
|
||||
self._protocol_listener.onFileTransferDone(self)
|
||||
|
||||
def _fileTransferFinished(self, current_file):
|
||||
pass
|
||||
|
||||
def _addSdFile(self, filename, filesize):
|
||||
"""
|
||||
Adds a file to the SD file list
|
||||
|
||||
:param filename: the filename to add to the list
|
||||
:param filesize: the filesize to add to the list, may be None
|
||||
"""
|
||||
self._sd_files.append((filename, filesize))
|
||||
self._sdFileAdded(filename, filesize)
|
||||
|
||||
def _sdFileAdded(self, filename, filesize):
|
||||
"""
|
||||
Called when a file has been added to the SD file list, can be used by the underyling protocol implementation
|
||||
to react to that.
|
||||
|
||||
:param filename: the filename to add to the list
|
||||
:param filesize: the filesize to add to the list, may be None
|
||||
"""
|
||||
pass
|
||||
|
||||
def _addSdFiles(self, files):
|
||||
"""
|
||||
Adds a list of files to the SD file list
|
||||
|
||||
:param files: the list of file tuples (name, size) to add to the list, size may be None
|
||||
"""
|
||||
for f in files:
|
||||
self._sd_files.append(f)
|
||||
self._sdFilesAdded(files)
|
||||
|
||||
def _sdFilesAdded(self, files):
|
||||
"""
|
||||
Called when a list of files has been added to the SD file list, can be used by the underlying protocol
|
||||
implementation to react to that.
|
||||
|
||||
:param files: the file tuples (name, size) added to the list, size may be None
|
||||
"""
|
||||
pass
|
||||
|
||||
def _resetSdFiles(self):
|
||||
"""
|
||||
Resets the SD file list
|
||||
"""
|
||||
self._sd_files = []
|
||||
self._sdFilesReset()
|
||||
|
||||
def _sdFilesReset(self):
|
||||
"""
|
||||
Called when the list of SD files has been reset, can be used in the underlying protocol implementation to
|
||||
react to that
|
||||
"""
|
||||
pass
|
||||
|
||||
def _heatupDetected(self):
|
||||
"""
|
||||
Called when the underlying protocol detects the beginning of a heat-up interval.
|
||||
"""
|
||||
self._heatup_start_time = time.time()
|
||||
|
||||
def _heatupDone(self):
|
||||
"""
|
||||
Called when the underlying protocol detects the end of a heat-up interval.
|
||||
"""
|
||||
if self._heatup_start_time is not None:
|
||||
self._heatup_time_lost += time.time() - self._heatup_start_time
|
||||
self._heatup_start_time = None
|
||||
|
||||
def _log_error(self, error):
|
||||
if self._protocol_listener is not None:
|
||||
self._protocol_listener.onLogError(self, error)
|
||||
|
||||
##~~ StateReceiver
|
||||
|
||||
def onStateChangeReceived(self, source, oldState, newState):
|
||||
if self._transport != source:
|
||||
return
|
||||
|
||||
if newState == TransportState.DETECTING_CONNECTION or newState == TransportState.OPENING_CONNECTION:
|
||||
self._changeState(State.CONNECTING)
|
||||
elif newState == TransportState.CONNECTED:
|
||||
self._changeState(State.CONNECTED)
|
||||
elif newState == TransportState.DISCONNECTED:
|
||||
self._changeState(State.OFFLINE)
|
||||
elif newState == TransportState.DISCONNECTED_WITH_ERROR or newState == TransportState.ERROR:
|
||||
self.onError(self._transport.getError())
|
||||
try:
|
||||
self._transport.disconnect()
|
||||
except:
|
||||
# TODO do we need to handle that?
|
||||
pass
|
||||
|
||||
##~~ MessageReceiver
|
||||
|
||||
def onError(self, error):
|
||||
self._changeState(State.ERROR)
|
||||
self._error = error
|
||||
eventManager().fire(Events.ERROR, {"error": error})
|
||||
|
||||
##~~ LogReceiver
|
||||
|
||||
def onLogRx(self, source, rx):
|
||||
if self._transport != source:
|
||||
return
|
||||
|
||||
if self._protocol_listener is not None:
|
||||
self._protocol_listener.onLogRx(self, rx)
|
||||
|
||||
def onLogTx(self, source, tx):
|
||||
if self._transport != source:
|
||||
return
|
||||
|
||||
if self._protocol_listener is not None:
|
||||
self._protocol_listener.onLogTx(self, tx)
|
||||
|
||||
def onLogError(self, source, error):
|
||||
if self._transport != source:
|
||||
return
|
||||
self._log_error(error)
|
||||
|
||||
##~~ helpers
|
||||
|
||||
def _getPrintCompletion(self):
|
||||
if self._current_file is None:
|
||||
return None
|
||||
return self._current_file.getProgress() * 100
|
||||
|
||||
def _getPrintFilepos(self):
|
||||
if self._current_file is None:
|
||||
return None
|
||||
return self._current_file.getFilepos()
|
||||
|
||||
|
||||
class ProtocolListener(object):
|
||||
def onStateChange(self, source, oldState, newState):
|
||||
pass
|
||||
|
||||
def onTemperatureUpdate(self, source, temperatureData):
|
||||
pass
|
||||
|
||||
def onProgress(self, source, progress):
|
||||
pass
|
||||
|
||||
def onZChange(self, source, oldZ, newZ):
|
||||
pass
|
||||
|
||||
def onFileSelected(self, source, filename, filesize, origin):
|
||||
pass
|
||||
|
||||
def onPrintjobStarted(self, source):
|
||||
pass
|
||||
|
||||
def onPrintjobDone(self, source):
|
||||
pass
|
||||
|
||||
def onPrintjobCancelled(self, source):
|
||||
pass
|
||||
|
||||
def onFileTransferStarted(self, source, filename, filesize):
|
||||
pass
|
||||
|
||||
def onFileTransferDone(self, source):
|
||||
pass
|
||||
|
||||
def onSdStateChange(self, source, sdAvailable):
|
||||
pass
|
||||
|
||||
def onSdFiles(self, source, files):
|
||||
pass
|
||||
|
||||
def onLogTx(self, source, tx):
|
||||
pass
|
||||
|
||||
def onLogRx(self, source, rx):
|
||||
pass
|
||||
|
||||
def onLogError(self, source, error):
|
||||
pass
|
||||
|
||||
|
||||
class State(object):
|
||||
|
||||
OFFLINE = "Offline"
|
||||
CONNECTING = "Connecting"
|
||||
CONNECTED = "Connected"
|
||||
OPERATIONAL = "Operational"
|
||||
PRINTING = "Printing"
|
||||
STREAMING = "Streaming"
|
||||
PAUSED = "Paused"
|
||||
ERROR = "Error"
|
||||
|
||||
|
||||
### Printing file information classes ##################################################################################
|
||||
|
||||
class PrintingFileInformation(object):
|
||||
"""
|
||||
Encapsulates information regarding the current file being printed: file name, current position, total size and
|
||||
time the print started.
|
||||
Allows to reset the current file position to 0 and to calculate the current progress as a floating point
|
||||
value between 0 and 1.
|
||||
"""
|
||||
|
||||
def __init__(self, filename):
|
||||
self._filename = filename
|
||||
self._filepos = 0
|
||||
self._filesize = None
|
||||
self._startTime = None
|
||||
|
||||
def getStartTime(self):
|
||||
return self._startTime
|
||||
|
||||
def getFilename(self):
|
||||
return self._filename
|
||||
|
||||
def getFilesize(self):
|
||||
return self._filesize
|
||||
|
||||
def getFilepos(self):
|
||||
return self._filepos
|
||||
|
||||
def getFileLocation(self):
|
||||
return FileDestinations.LOCAL
|
||||
|
||||
def getProgress(self):
|
||||
"""
|
||||
The current progress of the file, calculated as relation between file position and absolute size. Returns -1
|
||||
if file size is None or < 1.
|
||||
"""
|
||||
if self._filesize is None or not self._filesize > 0:
|
||||
return -1
|
||||
return float(self._filepos) / float(self._filesize)
|
||||
|
||||
def reset(self):
|
||||
"""
|
||||
Resets the current file position to 0.
|
||||
"""
|
||||
self._filepos = 0
|
||||
|
||||
def start(self):
|
||||
"""
|
||||
Marks the print job as started and remembers the start time.
|
||||
"""
|
||||
self._startTime = time.time()
|
||||
|
||||
|
||||
class PrintingSdFileInformation(PrintingFileInformation):
|
||||
"""
|
||||
Encapsulates information regarding an ongoing print from SD.
|
||||
"""
|
||||
|
||||
def __init__(self, filename, filesize):
|
||||
PrintingFileInformation.__init__(self, filename)
|
||||
self._filesize = filesize
|
||||
|
||||
def setFilepos(self, filepos):
|
||||
"""
|
||||
Sets the current file position.
|
||||
"""
|
||||
self._filepos = filepos
|
||||
|
||||
def getFileLocation(self):
|
||||
return FileDestinations.SDCARD
|
||||
@@ -0,0 +1,59 @@
|
||||
# coding=utf-8
|
||||
__author__ = "Gina Häußge <osd@foosel.net>"
|
||||
__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html"
|
||||
__copyright__ = "Copyright (C) 2014 Gina Häußge - Released under terms of the AGPLv3 License"
|
||||
|
||||
import re
|
||||
|
||||
from octoprint.comm.protocol.reprap import RepRapProtocol
|
||||
|
||||
|
||||
class RepetierTextualProtocol(RepRapProtocol):
|
||||
|
||||
__protocolinfo__ = ("repetier", "RepRap (Repetier Flavor)", False)
|
||||
|
||||
MESSAGE_TARGET_TEMPERATURE = staticmethod(lambda line: "TargetExtr" in line or "TargetBed" in line)
|
||||
MESSAGE_TEMPERATURE = staticmethod(lambda line: RepRapProtocol.MESSAGE_TEMPERATURE(line) or RepetierTextualProtocol.MESSAGE_TARGET_TEMPERATURE(line))
|
||||
|
||||
REGEX_POSITIVE_FLOAT = "[+]?[0-9]*\.?[0-9]+"
|
||||
REGEX_TARGET_EXTRUDER_TEMPERATURE = re.compile("TargetExtr([0-9]+):(%s)" % REGEX_POSITIVE_FLOAT)
|
||||
REGEX_TARGET_BED_TEMPERATURE = re.compile("TargetBed:(%s)" % REGEX_POSITIVE_FLOAT)
|
||||
|
||||
def __init__(self, transport_factory, protocol_listener=None):
|
||||
RepRapProtocol.__init__(self, transport_factory, protocol_listener)
|
||||
self._sd_available = True
|
||||
|
||||
def _reset(self, from_start=False):
|
||||
RepRapProtocol._reset(self, from_start=from_start)
|
||||
self._sd_available = True
|
||||
|
||||
def _process_temperatures(self, line):
|
||||
if RepetierTextualProtocol.MESSAGE_TARGET_TEMPERATURE(line):
|
||||
match_extr = RepetierTextualProtocol.REGEX_TARGET_EXTRUDER_TEMPERATURE.match(line)
|
||||
match_bed = RepetierTextualProtocol.REGEX_TARGET_BED_TEMPERATURE.match(line)
|
||||
|
||||
current_temperatures = self.get_current_temperatures()
|
||||
key = None
|
||||
target = None
|
||||
try:
|
||||
if match_extr is not None:
|
||||
tool_num = int(match_extr.group(1))
|
||||
key = "tool%d" % tool_num
|
||||
target = float(match_extr.group(2))
|
||||
elif match_bed is not None:
|
||||
key = "bed"
|
||||
target = float(match_bed.group(1))
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
if key is None:
|
||||
return False
|
||||
|
||||
if key in current_temperatures and current_temperatures[key] is not None and isinstance(current_temperatures[key], tuple):
|
||||
(actual, old_target) = current_temperatures[key]
|
||||
current_temperatures[key] = (actual, target)
|
||||
else:
|
||||
current_temperatures[key] = (None, target)
|
||||
self._updateTemperature(current_temperatures)
|
||||
else:
|
||||
RepRapProtocol._process_temperatures(self, line)
|
||||
@@ -0,0 +1,994 @@
|
||||
# coding=utf-8
|
||||
import Queue
|
||||
from collections import deque
|
||||
from octoprint.events import eventManager, Events
|
||||
from octoprint.util import filterNonAscii
|
||||
|
||||
__author__ = "Gina Häußge <osd@foosel.net>"
|
||||
__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html"
|
||||
__copyright__ = "Copyright (C) 2014 Gina Häußge - Released under terms of the AGPLv3 License"
|
||||
|
||||
import re
|
||||
import threading
|
||||
import time
|
||||
from octoprint.comm.protocol import State, Protocol, PrintingSdFileInformation
|
||||
from octoprint.comm.protocol.reprap.util import GcodeCommand, CommandQueue, CommandQueueEntry, PrintingGcodeFileInformation, \
|
||||
StreamingGcodeFileInformation, TypeAlreadyInQueue, SpecialCommandQueueEntry
|
||||
from octoprint.comm.transport import SendTimeout
|
||||
from octoprint.filemanager import valid_file_type
|
||||
from octoprint.filemanager.destinations import FileDestinations
|
||||
from octoprint.settings import settings
|
||||
from octoprint.util import CountedEvent
|
||||
import octoprint.plugin
|
||||
|
||||
|
||||
class RepRapProtocol(Protocol):
|
||||
|
||||
__protocolinfo__ = ("reprap", "RepRap", False)
|
||||
|
||||
## Firmware messages
|
||||
MESSAGE_OK = staticmethod(lambda line: line.startswith("ok"))
|
||||
MESSAGE_START = staticmethod(lambda line: line.startswith("start"))
|
||||
MESSAGE_WAIT = staticmethod(lambda line: line.startswith("wait"))
|
||||
MESSAGE_RESEND = staticmethod(lambda line: line.lower().startswith("resend") or line.lower().startswith("rs"))
|
||||
|
||||
MESSAGE_TEMPERATURE = staticmethod(lambda line: " T:" in line or line.startswith("T:") or " T0:" in line or line.startswith("T0:"))
|
||||
|
||||
MESSAGE_SD_INIT_OK = staticmethod(lambda line: line.lower() == "sd card ok")
|
||||
MESSAGE_SD_INIT_FAIL = staticmethod(lambda line: "sd init fail" in line.lower() or "volume.init failed" in line.lower() or "openroot failed" in line.lower())
|
||||
MESSAGE_SD_FILE_OPENED = staticmethod(lambda line: line.lower().startswith("file opened"))
|
||||
MESSAGE_SD_FILE_SELECTED = staticmethod(lambda line: line.lower().startswith("file selected"))
|
||||
MESSAGE_SD_BEGIN_FILE_LIST = staticmethod(lambda line: line.lower().startswith("begin file list"))
|
||||
MESSAGE_SD_END_FILE_LIST = staticmethod(lambda line: line.lower().startswith("end file list"))
|
||||
MESSAGE_SD_PRINTING_BYTE = staticmethod(lambda line: "sd printing byte" in line.lower())
|
||||
MESSAGE_SD_NOT_PRINTING = staticmethod(lambda line: "not sd printing" in line.lower())
|
||||
MESSAGE_SD_DONE_PRINTING = staticmethod(lambda line: "done printing file" in line.lower())
|
||||
MESSAGE_SD_BEGIN_WRITING = staticmethod(lambda line: "writing to file" in line.lower())
|
||||
MESSAGE_SD_END_WRITING = staticmethod(lambda line: "done saving file" in line.lower())
|
||||
|
||||
MESSAGE_ERROR = staticmethod(lambda line: line.startswith("Error:") or line.startswith("!!"))
|
||||
MESSAGE_ERROR_MULTILINE = staticmethod(lambda line: RepRapProtocol.REGEX_ERROR_MULTILINE.match(line))
|
||||
MESSAGE_ERROR_COMMUNICATION = staticmethod(lambda line: 'checksum mismatch' in line.lower()
|
||||
or 'wrong checksum' in line.lower()
|
||||
or 'line number is not last line number' in line.lower()
|
||||
or 'expected line' in line.lower()
|
||||
or 'no line number with checksum' in line.lower()
|
||||
or 'no checksum with line number' in line.lower()
|
||||
or 'missing checksum' in line.lower())
|
||||
MESSAGE_ERROR_COMMUNICATION_LINENUMBER = staticmethod(lambda line: 'line number is not line number' in line.lower()
|
||||
or 'expected line' in line.lower())
|
||||
|
||||
TRANSFORM_ERROR = staticmethod(lambda line: line[6:] if line.startswith("Error:") else line[2:])
|
||||
|
||||
## Commands
|
||||
COMMAND_GET_TEMP = staticmethod(lambda: GcodeCommand("M105"))
|
||||
COMMAND_SET_EXTRUDER_TEMP = staticmethod(lambda s, t, w: GcodeCommand("M109", s=s, t=t) if w else GcodeCommand("M104", s=s, t=t))
|
||||
COMMAND_SET_LINE = staticmethod(lambda n: GcodeCommand("M110 N%d" % n))
|
||||
COMMAND_SET_BED_TEMP = staticmethod(lambda s, w: GcodeCommand("M190", s=s) if w else GcodeCommand("M140", s=s))
|
||||
COMMAND_SET_RELATIVE_POSITIONING = staticmethod(lambda: GcodeCommand("G91"))
|
||||
COMMAND_SET_ABSOLUTE_POSITIONING = staticmethod(lambda: GcodeCommand("G90"))
|
||||
COMMAND_MOVE_AXIS = staticmethod(lambda axis, amount, speed: GcodeCommand("G1", x=amount if axis=='x' else None, y=amount if axis=='y' else None, z=amount if axis=='z' else None, f=speed))
|
||||
COMMAND_EXTRUDE = staticmethod(lambda amount, speed: GcodeCommand("G1", e=amount, f=speed))
|
||||
COMMAND_HOME_AXIS = staticmethod(lambda x, y, z: GcodeCommand("G28", x=0 if x else None, y=0 if y else None, z=0 if z else None))
|
||||
COMMAND_SET_TOOL = staticmethod(lambda t: GcodeCommand("T%d" % t))
|
||||
COMMAND_SD_REFRESH = staticmethod(lambda: GcodeCommand("M20"))
|
||||
COMMAND_SD_INIT = staticmethod(lambda: GcodeCommand("M21"))
|
||||
COMMAND_SD_RELEASE = staticmethod(lambda: GcodeCommand("M22"))
|
||||
COMMAND_SD_SELECT_FILE = staticmethod(lambda name: GcodeCommand("M23", param=name))
|
||||
COMMAND_SD_START = staticmethod(lambda: GcodeCommand("M24"))
|
||||
COMMAND_SD_PAUSE = staticmethod(lambda: GcodeCommand("M25"))
|
||||
COMMAND_SD_SET_POS = staticmethod(lambda pos: GcodeCommand("M26", s=pos))
|
||||
COMMAND_SD_STATUS = staticmethod(lambda: GcodeCommand("M27"))
|
||||
COMMAND_SD_BEGIN_WRITE = staticmethod(lambda name: GcodeCommand("M28", param=name))
|
||||
COMMAND_SD_END_WRITE = staticmethod(lambda name: GcodeCommand("M29", param=name))
|
||||
COMMAND_SD_DELETE = staticmethod(lambda name: GcodeCommand("M30", param=name))
|
||||
|
||||
## Command types
|
||||
COMMAND_TYPE_TEMPERATURE = "temperature"
|
||||
COMMAND_TYPE_SD_PROGRESS = "sd_progress"
|
||||
|
||||
# Regex matching temperature entries in line. Groups will be as follows:
|
||||
# - 1: whole tool designator incl. optional toolNumber ("T", "Tn", "B")
|
||||
# - 2: toolNumber, if given ("", "n", "")
|
||||
# - 3: actual temperature
|
||||
# - 4: whole target substring, if given (e.g. " / 22.0")
|
||||
# - 5: target temperature
|
||||
REGEX_TEMPERATURE = re.compile("(B|T(\d*)):\s*([-+]?\d*\.?\d+)(\s*\/?\s*([-+]?\d*\.?\d+))?")
|
||||
|
||||
# Regex matching "File opened" message. Groups will be as follows:
|
||||
# - 1: name of the file that got opened (e.g. "file.gco")
|
||||
# - 2: size of the file that got opened, in bytes, parseable to integer (e.g. "2392010")
|
||||
REGEX_FILE_OPENED = re.compile("File opened:\s*(.*?)\s+Size:\s*([0-9]*)")
|
||||
|
||||
# Regex matching printing byte message. Groups will be as follows:
|
||||
# - 1: current file position
|
||||
# - 2: file size
|
||||
REGEX_SD_PRINTING_BYTE = re.compile("([0-9]*)/([0-9]*)")
|
||||
|
||||
# Regex matching multi line errors
|
||||
#
|
||||
# Marlin reports MAXTEMP issues on extruders in the format
|
||||
#
|
||||
# Error:{int}
|
||||
# Extruder switched off. {MIN|MAX}TEMP triggered !
|
||||
#
|
||||
# This regex matches the line initiating those multiline errors. If it is encountered, the next line has
|
||||
# to be fetched from the transport layer in order to fully handle the error at hand.
|
||||
REGEX_ERROR_MULTILINE = re.compile("Error:[0-9]\n")
|
||||
|
||||
BLOCKING_COMMANDS = (
|
||||
"M109", "M190", # set and wait for temperature (hotend & bed)
|
||||
"G28", # home
|
||||
"G29", "G30", "G31", "G32" # bed probing
|
||||
)
|
||||
|
||||
def __init__(self, transport_factory, protocol_listener=None):
|
||||
Protocol.__init__(self, transport_factory, protocol_listener)
|
||||
|
||||
self._lastTemperatureUpdate = time.time()
|
||||
self._lastSdProgressUpdate = time.time()
|
||||
|
||||
self._startSeen = False
|
||||
self._receivingSdFileList = False
|
||||
|
||||
self._send_queue = CommandQueue()
|
||||
|
||||
self._clear_for_send = CountedEvent(max=10)
|
||||
|
||||
self._force_checksum = True
|
||||
self._wait_for_start = False
|
||||
self._sd_always_available = False
|
||||
self._rx_cache_size = 0
|
||||
|
||||
self._blocking_command_active = False
|
||||
|
||||
self._temperature_interval = 5.0
|
||||
self._sdstatus_interval = 5.0
|
||||
|
||||
self._sent_lines = deque([])
|
||||
self._send_lock = threading.RLock()
|
||||
|
||||
self._previous_resend = False
|
||||
self._last_comm_error = None
|
||||
self._last_resend_number = None
|
||||
self._current_resend_count = 0
|
||||
self._sent_before_resend = 0
|
||||
|
||||
self._send_queue_processing = True
|
||||
self._thread = threading.Thread(target=self._handle_send_queue, name="SendQueueHandler")
|
||||
self._thread.daemon = True
|
||||
self._thread.start()
|
||||
|
||||
self._fill_queue_semaphore = threading.BoundedSemaphore(10)
|
||||
self._fill_queue_state_signal = threading.Event()
|
||||
self._fill_queue_mutex = threading.Lock()
|
||||
self._fill_queue_processing = True
|
||||
self._fill_thread = threading.Thread(target=self._fill_send_queue, name="FillQueueHandler")
|
||||
self._fill_thread.daemon = True
|
||||
self._fill_thread.start()
|
||||
|
||||
self._current_line = 1
|
||||
self._current_extruder = 0
|
||||
self._state = State.OFFLINE
|
||||
|
||||
self._pluginManager = octoprint.plugin.plugin_manager()
|
||||
self._gcode_hooks = dict(
|
||||
queued=self._pluginManager.get_hooks("octoprint.comm.protocol.gcode.queued").values(),
|
||||
sending=self._pluginManager.get_hooks("octoprint.comm.protocol.gcode.sending").values(),
|
||||
sent=self._pluginManager.get_hooks("octoprint.comm.protocol.gcode.sent").values(),
|
||||
acknowledged=self._pluginManager.get_hooks("octoprint.comm.protocol.gcode.acknowledged").values()
|
||||
)
|
||||
|
||||
self._preprocessors = dict()
|
||||
self._setup_preprocessors()
|
||||
|
||||
self._reset()
|
||||
|
||||
def _setup_preprocessors(self):
|
||||
self._preprocessors.clear()
|
||||
|
||||
for attr in dir(self):
|
||||
if attr.startswith("_gcode") and (attr.endswith("_queued") or attr.endswith("_sending") or attr.endswith("_sent") or attr.endswith("_acknowledged")):
|
||||
split_attr = attr.split("_")
|
||||
if not len(split_attr) == 4:
|
||||
continue
|
||||
|
||||
prefix, code, postfix = split_attr[1:]
|
||||
if not postfix in self._preprocessors:
|
||||
self._preprocessors[postfix] = dict()
|
||||
self._preprocessors[postfix][code] = getattr(self, attr)
|
||||
|
||||
def _reset(self, from_start=False):
|
||||
with self._send_lock:
|
||||
self._lastTemperatureUpdate = time.time()
|
||||
self._lastSdProgressUpdate = time.time()
|
||||
|
||||
self._blocking_command_active = False
|
||||
|
||||
if self._wait_for_start:
|
||||
self._startSeen = from_start
|
||||
else:
|
||||
self._startSeen = True
|
||||
|
||||
if not self._startSeen:
|
||||
self._clear_for_send.clear(completely=True)
|
||||
else:
|
||||
if self._clear_for_send.blocked():
|
||||
self._clear_for_send.set()
|
||||
|
||||
self._receivingSdFileList = False
|
||||
|
||||
# clear the the send queue
|
||||
self._send_queue.clear()
|
||||
|
||||
self._sent_lines.clear()
|
||||
self._current_line = 1
|
||||
self._current_extruder = 0
|
||||
|
||||
self._previous_resend = False
|
||||
self._last_comm_error = None
|
||||
self._last_resend_number = None
|
||||
self._current_resend_count = 0
|
||||
self._sent_before_resend = 0
|
||||
|
||||
def connect(self, protocol_options, transport_options):
|
||||
self._wait_for_start = protocol_options["waitForStart"] if "waitForStart" in protocol_options else False
|
||||
self._force_checksum = protocol_options["checksum"] if "checksum" in protocol_options else True
|
||||
self._sd_always_available = protocol_options["sdAlwaysAvailable"] if "sdAlwaysAvailable" in protocol_options else False
|
||||
self._rx_cache_size = protocol_options["buffer"] if "buffer" in protocol_options else 0
|
||||
self._temperature_interval = protocol_options["timeout"]["temperature"] if "timeout" in protocol_options and "temperature" in protocol_options["timeout"] else 5.0
|
||||
self._sdstatus_interval = protocol_options["timeout"]["sdstatus"] if "timeout" in protocol_options and "sdstatus" in protocol_options["timeout"] else 5.0
|
||||
|
||||
self._reset()
|
||||
|
||||
# connect
|
||||
Protocol.connect(self, protocol_options, transport_options)
|
||||
|
||||
# we'll send an M110 first to reset line numbers to 0
|
||||
self._send(self.__class__.COMMAND_SET_LINE(0), high_priority=True)
|
||||
|
||||
# enqueue our first temperature query so it gets sent right on establishment of the connection
|
||||
self._send_temperature_query(with_type=True)
|
||||
|
||||
def disconnect(self, on_error=False):
|
||||
self._clear_for_send.clear(completely=True)
|
||||
# disconnect
|
||||
Protocol.disconnect(self, on_error=on_error)
|
||||
|
||||
def select_file(self, filename, origin):
|
||||
if origin == FileDestinations.SDCARD:
|
||||
if not self._sd_available:
|
||||
return
|
||||
self._send(self.__class__.COMMAND_SD_SELECT_FILE(filename), high_priority=True)
|
||||
else:
|
||||
self._selectFile(PrintingGcodeFileInformation(filename, self.get_temperature_offsets))
|
||||
|
||||
def start_print(self):
|
||||
wasPaused = self._state == State.PAUSED
|
||||
|
||||
Protocol.start_print(self)
|
||||
if isinstance(self._current_file, PrintingSdFileInformation):
|
||||
if wasPaused:
|
||||
self._send(self.__class__.COMMAND_SD_SET_POS(0))
|
||||
self._current_file.setFilepos(0)
|
||||
self._send(self.__class__.COMMAND_SD_START())
|
||||
|
||||
def cancel_print(self):
|
||||
if isinstance(self._current_file, PrintingSdFileInformation):
|
||||
self._send(self.__class__.COMMAND_SD_PAUSE)
|
||||
self._send(self.__class__.COMMAND_SD_SET_POS(0))
|
||||
|
||||
Protocol.cancel_print(self)
|
||||
|
||||
def _print_cancelled(self):
|
||||
with self._fill_queue_mutex:
|
||||
cleared = self._send_queue.clear(matcher=lambda entry: entry is not None and entry.command is not None and hasattr(entry.command, "progress") and entry.command.progress is not None and (not hasattr(entry, "prepared") or entry.prepared is None))
|
||||
self._logger.debug("Cleared %d job entries from the send queue: %r" % (len(cleared), cleared))
|
||||
|
||||
def init_sd(self):
|
||||
Protocol.init_sd(self)
|
||||
self._send(self.__class__.COMMAND_SD_INIT())
|
||||
if self._sd_always_available:
|
||||
self._changeSdState(True)
|
||||
|
||||
def release_sd(self):
|
||||
Protocol.release_sd(self)
|
||||
self._send(self.__class__.COMMAND_SD_RELEASE())
|
||||
if self._sd_always_available:
|
||||
self._changeSdState(False)
|
||||
|
||||
def refresh_sd_files(self):
|
||||
if not self._sd_available:
|
||||
return
|
||||
|
||||
Protocol.refresh_sd_files(self)
|
||||
self._send(self.__class__.COMMAND_SD_REFRESH())
|
||||
|
||||
def add_sd_file(self, path, local, remote):
|
||||
Protocol.add_sd_file(self, path, local, remote)
|
||||
if not self.is_operational() or self.is_busy():
|
||||
return
|
||||
|
||||
self.send_manually(self.__class__.COMMAND_SD_BEGIN_WRITE(remote))
|
||||
|
||||
self._current_file = StreamingGcodeFileInformation(path, local, remote)
|
||||
|
||||
self._current_file.start()
|
||||
|
||||
eventManager().fire(Events.TRANSFER_STARTED, {"local": local, "remote": remote})
|
||||
|
||||
self._startFileTransfer(remote, self._current_file.getFilesize())
|
||||
self._changeState(State.STREAMING)
|
||||
|
||||
def remove_sd_file(self, filename):
|
||||
Protocol.remove_sd_file(self, filename)
|
||||
if not self.is_operational() or \
|
||||
(self.is_busy() and isinstance(self._current_file, PrintingSdFileInformation) and
|
||||
self._current_file.getFilename() == filename):
|
||||
return
|
||||
|
||||
self.send_manually(self.__class__.COMMAND_SD_DELETE(filename))
|
||||
self.refresh_sd_files()
|
||||
|
||||
def set_temperature(self, type, value):
|
||||
if type.startswith("tool"):
|
||||
if settings().getInt(["printerParameters", "numExtruders"]) > 1:
|
||||
try:
|
||||
tool_num = int(type[len("tool"):])
|
||||
self.send_manually(self.__class__.COMMAND_SET_EXTRUDER_TEMP(value, tool_num, False))
|
||||
except ValueError:
|
||||
pass
|
||||
else:
|
||||
# set temperature without tool number
|
||||
self.send_manually(self.__class__.COMMAND_SET_EXTRUDER_TEMP(value, None, False))
|
||||
elif type == "bed":
|
||||
self.send_manually(self.__class__.COMMAND_SET_BED_TEMP(value, False))
|
||||
|
||||
def jog(self, axis, amount, speed):
|
||||
commands = (
|
||||
self.__class__.COMMAND_SET_RELATIVE_POSITIONING(),
|
||||
self.__class__.COMMAND_MOVE_AXIS(axis, amount, speed),
|
||||
self.__class__.COMMAND_SET_ABSOLUTE_POSITIONING()
|
||||
)
|
||||
self.send_manually(commands)
|
||||
|
||||
def home(self, axes):
|
||||
|
||||
commands = (
|
||||
self.__class__.COMMAND_SET_RELATIVE_POSITIONING(),
|
||||
self.__class__.COMMAND_HOME_AXIS('x' in axes, 'y' in axes, 'z' in axes),
|
||||
self.__class__.COMMAND_SET_ABSOLUTE_POSITIONING()
|
||||
)
|
||||
self.send_manually(commands)
|
||||
|
||||
def extrude(self, amount, speed):
|
||||
commands = (
|
||||
self.__class__.COMMAND_SET_RELATIVE_POSITIONING(),
|
||||
self.__class__.COMMAND_EXTRUDE(amount, speed),
|
||||
self.__class__.COMMAND_SET_ABSOLUTE_POSITIONING()
|
||||
)
|
||||
self.send_manually(commands)
|
||||
|
||||
def change_tool(self, tool):
|
||||
try:
|
||||
tool_num = int(tool[len("tool"):])
|
||||
self.send_manually(self.__class__.COMMAND_SET_TOOL(tool_num))
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
def send_manually(self, command, high_priority=False):
|
||||
if self.is_streaming():
|
||||
return
|
||||
if isinstance(command, (tuple, list)):
|
||||
for c in command:
|
||||
self._send(c, high_priority=high_priority)
|
||||
else:
|
||||
self._send(command, high_priority=high_priority)
|
||||
|
||||
def _fileTransferFinished(self, current_file):
|
||||
if isinstance(current_file, StreamingGcodeFileInformation):
|
||||
self.send_manually(self.__class__.COMMAND_SD_END_WRITE(current_file.getRemoteFilename()))
|
||||
eventManager().fire(Events.TRANSFER_DONE, {
|
||||
"local": current_file.getLocalFilename(),
|
||||
"remote": current_file.getRemoteFilename(),
|
||||
"time": self.get_print_time()
|
||||
})
|
||||
else:
|
||||
self._logger.warn("Finished file transfer to printer's SD card, but could not determine remote filename, assuming 'unknown.gco' for end-write-command")
|
||||
self.send_manually(self.__class__.COMMAND_SD_END_WRITE("unknown.gco"))
|
||||
self.refresh_sd_files()
|
||||
|
||||
##~~ callback methods
|
||||
|
||||
def onMessageReceived(self, source, message):
|
||||
if self._transport != source:
|
||||
return
|
||||
|
||||
message = self._handle_errors(message.strip())
|
||||
|
||||
##~~ Control message processing: ok, resend, start, wait
|
||||
|
||||
if self.__class__.MESSAGE_OK(message):
|
||||
if self._state == State.CONNECTED and self._startSeen:
|
||||
# if we are currently connected, have seen start and just gotten an "ok" we are now operational
|
||||
self._changeState(State.OPERATIONAL)
|
||||
if self.is_heating_up():
|
||||
self._heatupDone()
|
||||
|
||||
if not self._previous_resend:
|
||||
# our most left line from the sent_lines just got acknowledged
|
||||
self._process_acknowledgement()
|
||||
else:
|
||||
self._previous_resend = False
|
||||
self._clear_for_send.set()
|
||||
|
||||
elif self.__class__.MESSAGE_START(message):
|
||||
# initial handshake with the firmware
|
||||
if self._state != State.CONNECTED:
|
||||
# we received a "start" while running, this means the printer has unexpectedly reset
|
||||
self._changeState(State.CONNECTED)
|
||||
self._reset(from_start=True)
|
||||
return
|
||||
|
||||
elif self.__class__.MESSAGE_RESEND(message):
|
||||
self._previous_resend = True
|
||||
self._handle_resend_request(message)
|
||||
return
|
||||
|
||||
elif self.__class__.MESSAGE_WAIT(message):
|
||||
#self._clear_for_send.set()
|
||||
# TODO really?
|
||||
return
|
||||
|
||||
# SD file list
|
||||
if self._receivingSdFileList and not self.__class__.MESSAGE_SD_END_FILE_LIST(message):
|
||||
fileinfo = message.strip().split(None, 2)
|
||||
if len(fileinfo) > 1:
|
||||
filename, size = fileinfo
|
||||
filename = filename.lower()
|
||||
try:
|
||||
size = int(size)
|
||||
except ValueError:
|
||||
# whatever that was, it was not an integer, so we'll ignore it and set size to None
|
||||
size = None
|
||||
else:
|
||||
filename = fileinfo[0].lower()
|
||||
size = None
|
||||
|
||||
if valid_file_type(filename, "gcode"):
|
||||
if filterNonAscii(filename):
|
||||
self._logger.warn("Got a file from printer's SD that has a non-ascii filename (%s), that shouldn't happen according to the protocol" % filename)
|
||||
else:
|
||||
self._addSdFile(filename, size)
|
||||
return
|
||||
|
||||
##~~ regular message processing
|
||||
|
||||
# temperature updates
|
||||
if self.__class__.MESSAGE_TEMPERATURE(message):
|
||||
self._process_temperatures(message)
|
||||
if not self.__class__.MESSAGE_OK(message):
|
||||
self._heatupDetected()
|
||||
|
||||
# sd state
|
||||
elif self.__class__.MESSAGE_SD_INIT_OK(message):
|
||||
self._changeSdState(True)
|
||||
elif self.__class__.MESSAGE_SD_INIT_FAIL(message):
|
||||
self._changeSdState(False)
|
||||
|
||||
# sd progress
|
||||
elif self.__class__.MESSAGE_SD_PRINTING_BYTE(message):
|
||||
match = self.__class__.REGEX_SD_PRINTING_BYTE.search(message)
|
||||
if isinstance(self._current_file, PrintingSdFileInformation):
|
||||
self._current_file.setFilepos(int(match.group(1)))
|
||||
self._reportProgress()
|
||||
elif self.__class__.MESSAGE_SD_DONE_PRINTING(message):
|
||||
if isinstance(self._current_file, PrintingSdFileInformation):
|
||||
self._current_file.setFilepos(0)
|
||||
self._changeState(State.OPERATIONAL)
|
||||
self._finishPrintjob()
|
||||
|
||||
# sd file list
|
||||
elif self.__class__.MESSAGE_SD_BEGIN_FILE_LIST(message):
|
||||
self._resetSdFiles()
|
||||
self._receivingSdFileList = True
|
||||
elif self.__class__.MESSAGE_SD_END_FILE_LIST(message):
|
||||
self._receivingSdFileList = False
|
||||
self._sendSdFiles()
|
||||
|
||||
# sd file selection
|
||||
elif self.__class__.MESSAGE_SD_FILE_OPENED(message):
|
||||
match = self.__class__.REGEX_FILE_OPENED.search(message)
|
||||
self._selectFile(PrintingSdFileInformation(match.group(1), int(match.group(2))))
|
||||
|
||||
# sd file streaming
|
||||
elif self.__class__.MESSAGE_SD_BEGIN_WRITING(message):
|
||||
self._changeState(State.STREAMING)
|
||||
elif self.__class__.MESSAGE_SD_END_WRITING(message):
|
||||
self.refresh_sd_files()
|
||||
|
||||
# firmware specific messages
|
||||
if not self._evaluate_firmware_specific_messages(source, message):
|
||||
return
|
||||
|
||||
if not self.is_streaming():
|
||||
if time.time() > self._lastTemperatureUpdate + self._temperature_interval:
|
||||
self._send_temperature_query(with_type=True)
|
||||
elif self.is_sd_printing() and time.time() > self._lastSdProgressUpdate + self._sdstatus_interval:
|
||||
self._send_sd_progress_query(with_type=True)
|
||||
|
||||
def onTimeoutReceived(self, source):
|
||||
if self._transport != source:
|
||||
return
|
||||
# allow sending to restart communication
|
||||
if self._state != State.OFFLINE:
|
||||
if self._clear_for_send.blocked():
|
||||
self._clear_for_send.set()
|
||||
|
||||
def _stateChanged(self, newState):
|
||||
if ((self._state == State.PRINTING and not isinstance(self._current_file, PrintingSdFileInformation))
|
||||
or self._state == State.STREAMING):
|
||||
self._fill_queue_state_signal.set()
|
||||
else:
|
||||
self._fill_queue_state_signal.clear()
|
||||
|
||||
##~~ private
|
||||
|
||||
def _process_acknowledgement(self):
|
||||
with self._send_lock:
|
||||
if len(self._sent_lines) > 0:
|
||||
entry = self._sent_lines.popleft()
|
||||
|
||||
# process command as acknowledged
|
||||
self._process_command(entry.command, "acknowledged", with_line_number=entry.line_number)
|
||||
|
||||
if entry.command is not None:
|
||||
if entry.command.progress is not None:
|
||||
# if we got a progress, report it
|
||||
self._reportProgress(**entry.command.progress)
|
||||
|
||||
if entry.command.callback is not None:
|
||||
# if we got a callback, call it
|
||||
entry.command.callback(entry.command)
|
||||
|
||||
if len(self._sent_lines) > 0:
|
||||
# let's take a look at the next item in the nack queue, it might be a special entry demanding some action
|
||||
# from us now
|
||||
following_entry = self._sent_lines[0]
|
||||
if isinstance(following_entry, SpecialCommandQueueEntry):
|
||||
|
||||
if following_entry.type == SpecialCommandQueueEntry.TYPE_JOBDONE:
|
||||
# we got a special queue item that marks that we just acknowledged the last command of
|
||||
# an ongoing print job, so let's signal that now
|
||||
if self.is_streaming():
|
||||
self._finishFileTransfer()
|
||||
else:
|
||||
self._finishPrintjob()
|
||||
|
||||
# let's remove the special command, we should have processed it now...
|
||||
self._sent_lines.popleft()
|
||||
|
||||
else:
|
||||
self._logger.warn("Ooops, got an ok but had no unacknowledged command O.o")
|
||||
|
||||
# since we just got an acknowledgement, no more resends are pending
|
||||
self._last_resend_number = None
|
||||
self._current_resend_count = 0
|
||||
self._sent_before_resend = 0
|
||||
|
||||
def _evaluate_firmware_specific_messages(self, source, message):
|
||||
return True
|
||||
|
||||
def _send(self, command, high_priority=False, command_type=None, with_progress=None):
|
||||
if command is None:
|
||||
return
|
||||
|
||||
if isinstance(command, CommandQueueEntry):
|
||||
entry = command
|
||||
if entry.command is not None:
|
||||
entry.command.progress = with_progress
|
||||
else:
|
||||
if not isinstance(command, GcodeCommand):
|
||||
command = GcodeCommand.from_line(command)
|
||||
command.progress = with_progress
|
||||
|
||||
command, with_line_number = self._process_command(command, "queued")
|
||||
if command is None:
|
||||
return
|
||||
|
||||
entry = CommandQueueEntry(
|
||||
CommandQueueEntry.PRIORITY_HIGH if high_priority else CommandQueueEntry.PRIORITY_NORMAL,
|
||||
command,
|
||||
line_number=with_line_number,
|
||||
command_type=command_type
|
||||
)
|
||||
|
||||
try:
|
||||
self._send_queue.put(entry)
|
||||
except TypeAlreadyInQueue:
|
||||
pass
|
||||
|
||||
# Called only from worker thread, not thread safe
|
||||
def _send_next(self):
|
||||
try:
|
||||
command = self._current_file.getNext()
|
||||
except ValueError:
|
||||
# TODO _current_file might already be closed since the print ended asynchronously between our callee and here, causing a ValueError => find some nicer way to handle this
|
||||
return None
|
||||
|
||||
if command is None:
|
||||
command = SpecialCommandQueueEntry(SpecialCommandQueueEntry.TYPE_JOBDONE)
|
||||
|
||||
self._send(command, with_progress=dict(completion=self._getPrintCompletion(), filepos=self._getPrintFilepos()))
|
||||
|
||||
def _send_temperature_query(self, with_high_priority=False, with_type=False):
|
||||
self._send(self.__class__.COMMAND_GET_TEMP(), high_priority=with_high_priority, command_type=self.__class__.COMMAND_TYPE_TEMPERATURE if with_type else None)
|
||||
self._lastTemperatureUpdate = time.time()
|
||||
|
||||
def _send_sd_progress_query(self, with_high_priority=False, with_type=False):
|
||||
self._send(self.__class__.COMMAND_SD_STATUS(), high_priority=with_high_priority, command_type=self.__class__.COMMAND_TYPE_SD_PROGRESS if with_type else None)
|
||||
self._lastSdProgressUpdate = time.time()
|
||||
|
||||
def _handle_errors(self, line):
|
||||
if self.__class__.MESSAGE_ERROR(line):
|
||||
if self.__class__.MESSAGE_ERROR_MULTILINE(line):
|
||||
error = self._transport.receive()
|
||||
else:
|
||||
error = self.__class__.TRANSFORM_ERROR(line)
|
||||
|
||||
# skip the communication errors as those get corrected via resend requests
|
||||
if self.__class__.MESSAGE_ERROR_COMMUNICATION(error):
|
||||
self._last_comm_error = error
|
||||
pass
|
||||
# handle the error
|
||||
elif not self._state == State.ERROR:
|
||||
self.onError(error)
|
||||
return line
|
||||
|
||||
def _parse_temperatures(self, line):
|
||||
result = {}
|
||||
maxToolNum = 0
|
||||
for match in re.finditer(self.__class__.REGEX_TEMPERATURE, line):
|
||||
tool = match.group(1)
|
||||
toolNumber = int(match.group(2)) if match.group(2) and len(match.group(2)) > 0 else None
|
||||
if toolNumber > maxToolNum:
|
||||
maxToolNum = toolNumber
|
||||
|
||||
try:
|
||||
actual = float(match.group(3))
|
||||
target = None
|
||||
if match.group(4) and match.group(5):
|
||||
target = float(match.group(5))
|
||||
|
||||
result[tool] = (toolNumber, actual, target)
|
||||
except ValueError:
|
||||
# catch conversion issues, we'll rather just not get the temperature update instead of killing the connection
|
||||
pass
|
||||
|
||||
if "T0" in result.keys() and "T" in result.keys():
|
||||
del result["T"]
|
||||
|
||||
return maxToolNum, result
|
||||
|
||||
def _process_temperatures(self, line):
|
||||
maxToolNum, parsedTemps = self._parse_temperatures(line)
|
||||
|
||||
import copy
|
||||
result = copy.deepcopy(self._current_temperature)
|
||||
|
||||
# extruder temperatures
|
||||
if not "T0" in parsedTemps.keys() and not "T1" in parsedTemps.keys() and "T" in parsedTemps.keys():
|
||||
# no T1 so only single reporting, "T" is our one and only extruder temperature
|
||||
toolNum, actual, target = parsedTemps["T"]
|
||||
|
||||
if target is not None:
|
||||
result["tool0"] = (actual, target)
|
||||
elif "tool0" in result and result["tool0"] is not None and isinstance(result["tool0"], tuple):
|
||||
(oldActual, oldTarget) = result["tool0"]
|
||||
result["tool0"] = (actual, oldTarget)
|
||||
else:
|
||||
result["tool0"] = (actual, None)
|
||||
|
||||
elif not "T0" in parsedTemps.keys() and "T" in parsedTemps.keys():
|
||||
# Smoothieware sends multi extruder temperature data this way: "T:<first extruder> T1:<second extruder> ..." and therefore needs some special treatment...
|
||||
# TODO: Move to Smoothieware sub class?
|
||||
_, actual, target = parsedTemps["T"]
|
||||
del parsedTemps["T"]
|
||||
parsedTemps["T0"] = (0, actual, target)
|
||||
|
||||
if "T0" in parsedTemps.keys():
|
||||
for n in range(maxToolNum + 1):
|
||||
tool = "T%d" % n
|
||||
if not tool in parsedTemps.keys():
|
||||
continue
|
||||
|
||||
toolNum, actual, target = parsedTemps[tool]
|
||||
key = "tool%d" % toolNum
|
||||
if target is not None:
|
||||
result[key] = (actual, target)
|
||||
elif key in result and result[key] is not None and isinstance(result[key], tuple):
|
||||
(oldActual, oldTarget) = result[key]
|
||||
result[key] = (actual, oldTarget)
|
||||
else:
|
||||
result[key] = (actual, None)
|
||||
|
||||
# bed temperature
|
||||
if "B" in parsedTemps.keys():
|
||||
toolNum, actual, target = parsedTemps["B"]
|
||||
if target is not None:
|
||||
result["bed"] = (actual, target)
|
||||
elif "bed" in result and result["bed"] is not None and isinstance(result["bed"], tuple):
|
||||
(oldActual, oldTarget) = result["bed"]
|
||||
result["bed"] = (actual, oldTarget)
|
||||
else:
|
||||
result["bed"] = (actual, None)
|
||||
|
||||
self._updateTemperature(result)
|
||||
|
||||
def _handle_resend_request(self, message):
|
||||
line_to_resend = None
|
||||
try:
|
||||
line_to_resend = int(message.replace("N:", " ").replace("N", " ").replace(":", " ").split()[-1])
|
||||
except:
|
||||
if "rs" in message:
|
||||
line_to_resend = int(message.split()[1])
|
||||
|
||||
last_comm_error = self._last_comm_error
|
||||
self._last_comm_error = None
|
||||
|
||||
if line_to_resend is not None:
|
||||
with self._send_lock:
|
||||
if len(self._sent_lines) > 0:
|
||||
nack_entry = self._sent_lines[0]
|
||||
|
||||
if last_comm_error is not None and \
|
||||
self.__class__.MESSAGE_ERROR_COMMUNICATION_LINENUMBER(last_comm_error) \
|
||||
and line_to_resend == self._last_resend_number \
|
||||
and self._current_resend_count < self._sent_before_resend:
|
||||
# this resend is a complaint about the wrong line_number, we already resent the requested
|
||||
# one and didn't see more resend requests for those yet than we had additional lines in the sent
|
||||
# buffer back then, so this is probably caused by leftovers in the printer's receive buffer
|
||||
# (that got sent after the firmware cleared the receive buffer but before we'd fully processed
|
||||
# the old resend request), we'll therefore just increment our counter and ignore this
|
||||
self._current_resend_count += 1
|
||||
return
|
||||
else:
|
||||
# this is either a resend request for a new line_number, or a resend request not caused by a
|
||||
# line number mismatch, or we now saw more consecutive requests for that line number than there
|
||||
# were additional lines in the nack buffer when we saw the first one, so we'll have to handle it
|
||||
self._last_resend_number = line_to_resend
|
||||
self._current_resend_count = 0
|
||||
self._sent_before_resend = len(self._sent_lines) - 1
|
||||
|
||||
if nack_entry.line_number is not None and nack_entry.line_number == line_to_resend:
|
||||
try:
|
||||
while True:
|
||||
entry = self._sent_lines.popleft()
|
||||
entry.priority = CommandQueueEntry.PRIORITY_RESEND
|
||||
try:
|
||||
self._send_queue.put(entry)
|
||||
except TypeAlreadyInQueue:
|
||||
pass
|
||||
except IndexError:
|
||||
# that's ok, the nack lines are just empty
|
||||
pass
|
||||
|
||||
return
|
||||
|
||||
elif line_to_resend < nack_entry.line_number:
|
||||
# we'll ignore that resend request since that line was already acknowledged in the past
|
||||
return
|
||||
|
||||
# if we've reached this point, we could not resend the requested line
|
||||
error = "Printer requested line %d but no sufficient history is available, can't resend" % line_to_resend
|
||||
self._logger.warn(error)
|
||||
if self.is_printing():
|
||||
# abort the print, there's nothing we can do to rescue it now
|
||||
self.onError(error)
|
||||
|
||||
# reset line number local and remote
|
||||
self._current_line = 1
|
||||
self._sent_lines.clear()
|
||||
self._send(self.__class__.COMMAND_SET_LINE(0))
|
||||
|
||||
##~~ handle queue filling in this thread when printing or streaming
|
||||
|
||||
def _fill_send_queue(self):
|
||||
while self._fill_queue_processing:
|
||||
with self._fill_queue_mutex:
|
||||
self._fill_queue_state_signal.wait(0.1)
|
||||
|
||||
if not ((self._state == State.PRINTING and not isinstance(self._current_file, PrintingSdFileInformation))
|
||||
or self._state == State.STREAMING):
|
||||
continue
|
||||
|
||||
if self._fill_queue_semaphore.acquire(0.5):
|
||||
self._send_next()
|
||||
|
||||
|
||||
##~~ the actual send queue handling starts here
|
||||
|
||||
def _handle_send_queue(self):
|
||||
while self._send_queue_processing:
|
||||
if self._send_queue.qsize() == 0:
|
||||
# queue is empty, wait a bit before checking again
|
||||
if ((self._state == State.PRINTING and not isinstance(self._current_file, PrintingSdFileInformation))
|
||||
or self._state == State.STREAMING):
|
||||
self._logger.warn("Buffer under run while printing!")
|
||||
time.sleep(0.1)
|
||||
continue
|
||||
|
||||
if self._blocking_command_active:
|
||||
# blocking command is active, no use to send anything to the printer right now
|
||||
time.sleep(0.1)
|
||||
continue
|
||||
|
||||
try:
|
||||
with self._send_lock:
|
||||
with self._send_queue.clearlock:
|
||||
sent = self._send_from_queue()
|
||||
except SendTimeout:
|
||||
# we just got a send timeout, so we'll just try again on the next loop iteration
|
||||
continue
|
||||
|
||||
if not sent or self._rx_cache_size <= 0:
|
||||
# decrease the clear_for_send counter
|
||||
self._clear_for_send.clear()
|
||||
self._clear_for_send.wait()
|
||||
|
||||
def _send_from_queue(self):
|
||||
item, entry = self._send_queue.peek()
|
||||
if item is None:
|
||||
if ((self._state == State.PRINTING and not isinstance(self._current_file, PrintingSdFileInformation))
|
||||
or self._state == State.STREAMING):
|
||||
self._logger.warn("Buffer under run while printing!")
|
||||
return False
|
||||
|
||||
if not self._startSeen:
|
||||
return False
|
||||
|
||||
if isinstance(item, SpecialCommandQueueEntry):
|
||||
self._sent_lines.append(item)
|
||||
else:
|
||||
if item.prepared is None:
|
||||
prepared, line_number = self._prepare_for_sending(item.command, with_line_number=item.line_number)
|
||||
|
||||
item.prepared = prepared
|
||||
item.line_number = line_number
|
||||
|
||||
if item.prepared is not None:
|
||||
# only actually send the command if it wasn't filtered out by preprocessing
|
||||
|
||||
current_size = sum(self._sent_lines)
|
||||
new_size = current_size + item.size
|
||||
if new_size > self._rx_cache_size > 0 and not (current_size == 0):
|
||||
# Do not send if the left over space in the buffer is too small for this line. Exception: the buffer is empty
|
||||
# and the line still doesn't fit
|
||||
return False
|
||||
|
||||
# send the command - we might get a SendTimeout here which is supposed to bubble up since it's caught in the
|
||||
# actual send loop
|
||||
self._transport.send(item.prepared)
|
||||
|
||||
# add the queue item into the deque of commands not yet acknowledged
|
||||
self._sent_lines.append(item)
|
||||
|
||||
self._process_command(item.command, "sent", with_line_number=item.line_number)
|
||||
else:
|
||||
self._logger.debug("Dropping command which was disabled through preprocessing: %s" % item.command)
|
||||
|
||||
# remove from send queue
|
||||
try:
|
||||
self._fill_queue_semaphore.release()
|
||||
except ValueError:
|
||||
# that's ok, the bounded semaphore complains that we just released more often than we acquired, but
|
||||
# we do this explicitly an just use the bounded semaphore to guarantee an upper bound on the
|
||||
# items added to the send queue by the fill thread
|
||||
pass
|
||||
self._send_queue.remove(entry)
|
||||
|
||||
return True
|
||||
|
||||
##~~ preprocessing of command in the three phases "queued", "sent" and "acknowledged"
|
||||
|
||||
def _process_command(self, command, phase, with_line_number=None):
|
||||
if command is None:
|
||||
return None, None, None
|
||||
|
||||
if not phase in ("queued", "sending", "sent", "acknowledged"):
|
||||
return None
|
||||
|
||||
#handle our hooks, if any
|
||||
for hook in self._gcode_hooks[phase]:
|
||||
command, with_line_number = hook(self, command, with_line_number)
|
||||
|
||||
if phase in self._preprocessors and command is not None and command.command in self._preprocessors[phase]:
|
||||
command, with_line_number = self._preprocessors[phase][command.command](command, with_line_number)
|
||||
|
||||
# blocking command?
|
||||
if command is not None and command.command in self.__class__.BLOCKING_COMMANDS:
|
||||
if phase == "sent":
|
||||
self._logger.info("Waiting for a blocking command to finish: %s" % command.command)
|
||||
self._blocking_command_active = True
|
||||
elif phase == "acknowledged":
|
||||
self._logger.info("Blocking command finished: %s" % command.command)
|
||||
self._blocking_command_active = False
|
||||
|
||||
return command, with_line_number
|
||||
|
||||
def _prepare_for_sending(self, command, with_line_number=None):
|
||||
command, with_line_number = self._process_command(command, "sending", with_line_number=with_line_number)
|
||||
if command is None or command.unknown:
|
||||
return None, None
|
||||
|
||||
if self._force_checksum:
|
||||
if with_line_number is not None:
|
||||
line_number = with_line_number
|
||||
else:
|
||||
line_number = self._current_line
|
||||
command_to_send = "N%d %s" % (line_number, str(command))
|
||||
|
||||
checksum = reduce(lambda x, y: x ^ y, map(ord, command_to_send))
|
||||
|
||||
if with_line_number is None:
|
||||
self._current_line += 1
|
||||
|
||||
return "%s*%d" % (command_to_send, checksum), line_number
|
||||
else:
|
||||
return str(command), None
|
||||
|
||||
##~~ specific command actions
|
||||
|
||||
def _gcode_T_acknowledged(self, command, with_line_number):
|
||||
self._current_extruder = command.tool
|
||||
return command, with_line_number
|
||||
|
||||
def _gcode_G0_acknowledged(self, command, with_line_number):
|
||||
if command.z is not None:
|
||||
z = command.z
|
||||
self._reportZChange(z)
|
||||
return command, with_line_number
|
||||
_gcode_G1_acknowledged = _gcode_G0_acknowledged
|
||||
|
||||
def _gcode_M0_queued(self, command, with_line_number):
|
||||
self.pause_print()
|
||||
# Don't send the M0 or M1 to the machine, as M0 and M1 are handled as an LCD menu pause.
|
||||
return None, with_line_number
|
||||
_gcode_M1_queued = _gcode_M0_queued
|
||||
|
||||
def _gcode_M104_sent(self, command, with_line_number):
|
||||
key = "tool%d" % command.t if command.t is not None else self._current_extruder
|
||||
self._handle_temperature_code(command, key)
|
||||
return command, with_line_number
|
||||
_gcode_M109_sent = _gcode_M104_sent
|
||||
|
||||
def _gcode_M140_sent(self, command, with_line_number):
|
||||
key = "bed"
|
||||
self._handle_temperature_code(command, key)
|
||||
return command, with_line_number
|
||||
_gcode_M190_sent = _gcode_M140_sent
|
||||
|
||||
def _handle_temperature_code(self, command, key):
|
||||
if command.s is not None:
|
||||
target = command.s
|
||||
if key in self._current_temperature and self._current_temperature[key] is not None and isinstance(self._current_temperature[key], tuple):
|
||||
actual, old_target = self._current_temperature[key]
|
||||
self._current_temperature[key] = (actual, target)
|
||||
else:
|
||||
self._current_temperature[key] = (None, target)
|
||||
|
||||
def _gcode_M110_sending(self, command, with_line_number):
|
||||
if command.n is not None:
|
||||
new_line_number = command.n
|
||||
else:
|
||||
new_line_number = 0
|
||||
|
||||
self._current_line = new_line_number + 1
|
||||
|
||||
# send M110 command with new line number
|
||||
return command, new_line_number
|
||||
|
||||
def _gcode_M112_queued(self, command, with_line_number): # It's an emergency what todo? Canceling the print should be the minimum
|
||||
self.cancel_print()
|
||||
return command, with_line_number
|
||||
|
||||
@@ -0,0 +1,377 @@
|
||||
# coding=utf-8
|
||||
__author__ = "Gina Häußge <osd@foosel.net>"
|
||||
__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html"
|
||||
__copyright__ = "Copyright (C) 2014 Gina Häußge - Released under terms of the AGPLv3 License"
|
||||
|
||||
import Queue
|
||||
import re
|
||||
import heapq
|
||||
import os
|
||||
import time
|
||||
import itertools
|
||||
|
||||
from octoprint.comm.protocol import PrintingFileInformation
|
||||
|
||||
|
||||
class GcodeCommand(object):
|
||||
|
||||
KNOWN_FLOAT_ATTRIBUTES = ("x", "y", "z", "e", "s", "p", "r")
|
||||
KNOWN_INT_ATTRIBUTES = ("f", "t", "n")
|
||||
KNOWN_ATTRIBUTES = KNOWN_FLOAT_ATTRIBUTES + KNOWN_INT_ATTRIBUTES
|
||||
|
||||
COMMAND_REGEX = re.compile("^([GMT])(\d+)")
|
||||
ARGUMENT_REGEX = re.compile("\s+([%s][-+]?\d*\.?\d+|[%s][-+]?\d+)" % ("".join(map(lambda x: x.upper(), KNOWN_FLOAT_ATTRIBUTES)), "".join(map(lambda x: x.upper(), KNOWN_INT_ATTRIBUTES))))
|
||||
PARAM_REGEX = re.compile("^[GMT]\d+\s+(.*?)$")
|
||||
|
||||
@staticmethod
|
||||
def from_line(line):
|
||||
line = line.strip()
|
||||
command = ""
|
||||
args = {"original": line}
|
||||
match = GcodeCommand.COMMAND_REGEX.match(line)
|
||||
if match is None:
|
||||
args["unknown"] = True
|
||||
else:
|
||||
commandType = match.group(1)
|
||||
commandNumber = int(match.group(2))
|
||||
command = "%s%d" % (commandType, commandNumber)
|
||||
|
||||
|
||||
if commandType == "T":
|
||||
args["tool"] = commandNumber
|
||||
else:
|
||||
matchedArgs = GcodeCommand.ARGUMENT_REGEX.findall(line)
|
||||
if len(matchedArgs) == 0:
|
||||
paramMatch = GcodeCommand.PARAM_REGEX.match(line)
|
||||
if paramMatch is not None:
|
||||
args["param"] = paramMatch.group(1)
|
||||
else:
|
||||
for arg in matchedArgs:
|
||||
key = arg[0].lower()
|
||||
if key in GcodeCommand.KNOWN_INT_ATTRIBUTES:
|
||||
value = int(arg[1:])
|
||||
elif key in GcodeCommand.KNOWN_FLOAT_ATTRIBUTES:
|
||||
value = float(arg[1:])
|
||||
else:
|
||||
value = str(arg[1:])
|
||||
args[key] = value
|
||||
|
||||
return GcodeCommand(command, **args)
|
||||
|
||||
def __init__(self, command, **kwargs):
|
||||
self.command = command
|
||||
self.x = None
|
||||
self.y = None
|
||||
self.z = None
|
||||
self.e = None
|
||||
self.s = None
|
||||
self.p = None
|
||||
self.r = None
|
||||
self.f = None
|
||||
self.t = None
|
||||
self.n = None
|
||||
|
||||
self.tool = None
|
||||
self.original = None
|
||||
self.param = None
|
||||
|
||||
self.progress = None
|
||||
self.callback = None
|
||||
|
||||
self.unknown = False
|
||||
|
||||
for key, value in kwargs.iteritems():
|
||||
if key in GcodeCommand.KNOWN_ATTRIBUTES + ("tool", "original", "param", "progress", "callback", "unknown"):
|
||||
self.__setattr__(key, value)
|
||||
|
||||
def isGetTemperatureCommand(self):
|
||||
return self.command == "M105"
|
||||
|
||||
def isSetTemperatureCommand(self):
|
||||
return self.command in ("M104", "M140", "M109", "M190")
|
||||
|
||||
def isSelectToolCommand(self):
|
||||
return self.command.startswith("T")
|
||||
|
||||
def __repr__(self):
|
||||
return "GcodeCommand(\"{str}\",progress={progress})".format(str=str(self), progress=self.progress)
|
||||
|
||||
def __str__(self):
|
||||
if self.original is not None:
|
||||
return self.original
|
||||
else:
|
||||
attr = []
|
||||
for key in GcodeCommand.KNOWN_ATTRIBUTES:
|
||||
value = self.__getattribute__(key)
|
||||
if value is not None:
|
||||
if key in GcodeCommand.KNOWN_INT_ATTRIBUTES:
|
||||
attr.append("%s%d" % (key.upper(), value))
|
||||
elif key in GcodeCommand.KNOWN_FLOAT_ATTRIBUTES:
|
||||
attr.append("%s%f" % (key.upper(), value))
|
||||
else:
|
||||
attr.append("%s%r" % (key.upper(), value))
|
||||
attributeStr = " ".join(attr)
|
||||
return "%s%s%s" % (self.command.upper(), " " + attributeStr if attributeStr else "", " " + self.param if self.param else "")
|
||||
|
||||
|
||||
class CommandQueueEntry(object):
|
||||
PRIORITY_RESEND = 1
|
||||
PRIORITY_HIGH = 2
|
||||
PRIORITY_NORMAL = 3
|
||||
|
||||
def __init__(self, priority, command, line_number=None, command_type=None, prepared=None):
|
||||
self.priority = priority
|
||||
self.command = command
|
||||
self.line_number = line_number
|
||||
self.command_type = command_type
|
||||
self._prepared = prepared
|
||||
self._size = 0
|
||||
|
||||
@property
|
||||
def prepared(self):
|
||||
return self._prepared
|
||||
|
||||
@prepared.setter
|
||||
def prepared(self, prepared):
|
||||
self._prepared = prepared
|
||||
self._size = (len(prepared) + 1) if prepared is not None else 0
|
||||
|
||||
@property
|
||||
def size(self):
|
||||
return self._size
|
||||
|
||||
def __radd__(self, other):
|
||||
return other + self._size
|
||||
|
||||
def __repr__(self):
|
||||
return "CommandQueueEntry({command},prepared={prepared})".format(command=repr(self.command), prepared=self.prepared)
|
||||
|
||||
|
||||
class SpecialCommandQueueEntry(CommandQueueEntry):
|
||||
TYPE_JOBDONE = "JobDone"
|
||||
TYPE_JOBCANCELLED = "JobCancelled"
|
||||
|
||||
def __init__(self, type):
|
||||
CommandQueueEntry.__init__(self, CommandQueueEntry.PRIORITY_NORMAL, None)
|
||||
self.type = type
|
||||
|
||||
def __repr__(self):
|
||||
return "SpecialCommandQueueEntry(type={type})".format(type=self.type)
|
||||
|
||||
|
||||
class CommandQueue(Queue.Queue):
|
||||
'''Variant of Queue that retrieves open entries in priority order (lowest first, followed by addition order).
|
||||
|
||||
Entries need to be of the form (priority, command). An optional third argument commandType may be given:
|
||||
(priority, command, commandType), the queue will ensure that only one command of a given commandType will ever
|
||||
be in the queue.
|
||||
'''
|
||||
|
||||
def _init(self, maxsize):
|
||||
self.queue = []
|
||||
self.lookup = {}
|
||||
self.counter = itertools.count()
|
||||
|
||||
import threading
|
||||
self.clearlock = threading.RLock()
|
||||
|
||||
def _qsize(self, len=len):
|
||||
return len(self.queue)
|
||||
|
||||
def _put(self, item, heappush=heapq.heappush):
|
||||
if not isinstance(item, CommandQueueEntry):
|
||||
raise ValueError("queue can only take CommandQueueEntries, can't accept %r" % item)
|
||||
|
||||
command_type = item.command_type
|
||||
if command_type is not None:
|
||||
if command_type not in self.lookup:
|
||||
self.lookup[command_type] = item
|
||||
else:
|
||||
raise TypeAlreadyInQueue()
|
||||
|
||||
heappush(self.queue, (item.priority, next(self.counter), item))
|
||||
|
||||
def _get(self, heappop=heapq.heappop):
|
||||
priority, counter, item = heappop(self.queue)
|
||||
if item.command_type in self.lookup:
|
||||
del self.lookup[item.command_type]
|
||||
return item
|
||||
|
||||
def _entry_at(self, index):
|
||||
try:
|
||||
return self.queue[index]
|
||||
except IndexError:
|
||||
return None
|
||||
|
||||
def _del(self, entry, heapify=True):
|
||||
item = entry[2]
|
||||
try:
|
||||
self.queue.remove(entry)
|
||||
if heapify:
|
||||
heapq.heapify(self.queue)
|
||||
except ValueError:
|
||||
# that's ok, the entry probably just got removed already e.g. by print cancelling
|
||||
pass
|
||||
|
||||
if item.command_type in self.lookup:
|
||||
del self.lookup[item.command_type]
|
||||
|
||||
def peek(self):
|
||||
"""
|
||||
Returns the left most entry, result is either a tuple (priority, counter, CommandQueueEntry) or None (if queue
|
||||
was empty).
|
||||
"""
|
||||
|
||||
with self.mutex:
|
||||
entry = self._entry_at(0)
|
||||
return entry[2] if entry is not None else None, entry
|
||||
|
||||
def remove(self, entry):
|
||||
with self.mutex:
|
||||
self._del(entry)
|
||||
|
||||
def clear(self, matcher=None):
|
||||
if matcher is None:
|
||||
matcher = lambda x: True
|
||||
|
||||
cleared = []
|
||||
with self.clearlock:
|
||||
for entry in self.queue[:]:
|
||||
priority, counter, item = entry
|
||||
if matcher(item):
|
||||
self._del(entry, heapify=False)
|
||||
cleared.append(entry)
|
||||
heapq.heapify(self.queue)
|
||||
return cleared
|
||||
|
||||
def __repr__(self):
|
||||
return repr(self.queue)
|
||||
|
||||
class TypeAlreadyInQueue(Exception):
|
||||
pass
|
||||
|
||||
class PrintingGcodeFileInformation(PrintingFileInformation):
|
||||
"""
|
||||
Encapsulates information regarding an ongoing direct print. Takes care of the needed file handle and ensures
|
||||
that the file is closed in case of an error.
|
||||
"""
|
||||
|
||||
def __init__(self, filename, offsetCallback):
|
||||
PrintingFileInformation.__init__(self, filename)
|
||||
self._lineCount = None
|
||||
self._firstLine = None
|
||||
self._currentTool = 0
|
||||
|
||||
self._offsetCallback = offsetCallback
|
||||
|
||||
self._fileHandle = None
|
||||
if not os.path.exists(self._filename) or not os.path.isfile(self._filename):
|
||||
raise IOError("File %s does not exist" % self._filename)
|
||||
self._filesize = os.stat(self._filename).st_size
|
||||
|
||||
def start(self):
|
||||
"""
|
||||
Opens the file for reading and determines the file size. Start time won't be recorded until 100 lines in
|
||||
"""
|
||||
self._filehandle = open(self._filename, "r")
|
||||
self._lineCount = None
|
||||
self._startTime = None
|
||||
|
||||
def getNext(self):
|
||||
"""
|
||||
Retrieves the next line for printing.
|
||||
"""
|
||||
if self._filehandle is None:
|
||||
raise ValueError("File %s is not open for reading" % self._filename)
|
||||
|
||||
if self._lineCount is None:
|
||||
self._lineCount = 0
|
||||
self._startTime = time.time()
|
||||
return GcodeCommand.from_line("M110 N0")
|
||||
|
||||
try:
|
||||
command = None
|
||||
while command is None:
|
||||
if self._filehandle is None:
|
||||
# file got closed just now
|
||||
return None
|
||||
line = self._filehandle.readline()
|
||||
if not line:
|
||||
self._filehandle.close()
|
||||
self._filehandle = None
|
||||
command = self._process_command(line)
|
||||
self._lineCount += 1
|
||||
self._filepos = self._filehandle.tell()
|
||||
|
||||
return command
|
||||
except Exception as (e):
|
||||
if self._filehandle is not None:
|
||||
self._filehandle.close()
|
||||
self._filehandle = None
|
||||
raise e
|
||||
|
||||
def _process_command(self, line):
|
||||
# remove all comments and trim the line
|
||||
if ";" in line:
|
||||
line = line[0:line.find(";")]
|
||||
line = line.strip()
|
||||
|
||||
if len(line) > 0:
|
||||
# we still got something left => parse the command
|
||||
command = GcodeCommand.from_line(line)
|
||||
if command is None:
|
||||
return None
|
||||
|
||||
if command.isSelectToolCommand():
|
||||
# track tool changes
|
||||
self._currentTool = command.tool
|
||||
|
||||
elif command.isSetTemperatureCommand() and self._offsetCallback is not None:
|
||||
# if we have a temperature command and an offset callback, retrieve current offsets
|
||||
offsets = self._offsetCallback()
|
||||
|
||||
# extruder temperature, determine which one and retrieve corresponding offset
|
||||
if command.command == "M104" or command.command == "M109":
|
||||
tool_num = self._currentTool
|
||||
if command.t is not None:
|
||||
tool_num = command.t
|
||||
|
||||
key = "tool%d" % tool_num
|
||||
|
||||
# bed temperature
|
||||
elif command.command == "M140" or command.command == "M190":
|
||||
key = "bed"
|
||||
|
||||
# unknown, should never happen
|
||||
else:
|
||||
key = None
|
||||
|
||||
if key is not None and key in offsets:
|
||||
offset = offsets[key]
|
||||
command.s = command.s + offset
|
||||
if command.original is not None:
|
||||
command.original = None
|
||||
|
||||
# finally return the processed command
|
||||
return command
|
||||
else:
|
||||
# no command, return None
|
||||
return None
|
||||
|
||||
|
||||
class StreamingGcodeFileInformation(PrintingGcodeFileInformation):
|
||||
def __init__(self, path, localFilename, remoteFilename):
|
||||
PrintingGcodeFileInformation.__init__(self, path, None)
|
||||
self._localFilename = localFilename
|
||||
self._remoteFilename = remoteFilename
|
||||
|
||||
def start(self):
|
||||
PrintingGcodeFileInformation.start(self)
|
||||
self._startTime = time.time()
|
||||
|
||||
def getLocalFilename(self):
|
||||
return self._localFilename
|
||||
|
||||
def getRemoteFilename(self):
|
||||
return self._remoteFilename
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
# coding=utf-8
|
||||
__author__ = "Gina Häußge <osd@foosel.net>"
|
||||
__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html"
|
||||
__copyright__ = "Copyright (C) 2014 Gina Häußge - Released under terms of the AGPLv3 License"
|
||||
|
||||
import logging
|
||||
|
||||
from octoprint.events import eventManager, Events
|
||||
|
||||
class TransportError(Exception):
|
||||
pass
|
||||
|
||||
class SendTimeout(Exception):
|
||||
pass
|
||||
|
||||
class Transport(object):
|
||||
|
||||
def __init__(self, messageReceiver=None, stateReceiver=None, logReceiver=None):
|
||||
self._transport_logger = logging.getLogger("TRANSPORT")
|
||||
|
||||
self._messageReceiver = messageReceiver
|
||||
self._stateReceiver = stateReceiver
|
||||
self._logReceiver = logReceiver
|
||||
self._state = State.DISCONNECTED
|
||||
self._error = None
|
||||
self._opt = {}
|
||||
|
||||
def get_properties(self):
|
||||
raise NotImplemented()
|
||||
|
||||
def get_connection_options(self):
|
||||
return []
|
||||
|
||||
def get_current_connection(self):
|
||||
return self._opt
|
||||
|
||||
def connect(self, opt):
|
||||
self._opt = opt
|
||||
|
||||
def disconnect(self, onError=False):
|
||||
if onError:
|
||||
self.changeState(State.DISCONNECTED_WITH_ERROR)
|
||||
else:
|
||||
self.changeState(State.DISCONNECTED)
|
||||
eventManager().fire(Events.DISCONNECTED)
|
||||
def send(self, command):
|
||||
pass
|
||||
|
||||
def receive(self):
|
||||
pass
|
||||
|
||||
def changeState(self, newState):
|
||||
oldState = self._state
|
||||
self._state = newState
|
||||
if self._stateReceiver is not None:
|
||||
self._stateReceiver.onStateChangeReceived(self, oldState, newState)
|
||||
|
||||
def onError(self, error):
|
||||
self.changeState(State.ERROR)
|
||||
self._error = error
|
||||
|
||||
def onTimeout(self):
|
||||
if self._messageReceiver is not None:
|
||||
self._messageReceiver.onTimeoutReceived(self)
|
||||
|
||||
def getError(self):
|
||||
return self._error
|
||||
|
||||
def logTx(self, tx):
|
||||
if self._logReceiver is not None:
|
||||
self._logReceiver.onLogTx(self, tx)
|
||||
|
||||
def logRx(self, rx):
|
||||
if self._logReceiver is not None:
|
||||
self._logReceiver.onLogRx(self, rx)
|
||||
|
||||
def logError(self, error):
|
||||
if self._logReceiver is not None:
|
||||
self._logReceiver.onLogError(self, error)
|
||||
|
||||
def onMessageReceived(self, message):
|
||||
if self._messageReceiver is not None:
|
||||
self._messageReceiver.onMessageReceived(self, message)
|
||||
|
||||
|
||||
class TransportProperties(object):
|
||||
|
||||
FLOWCONTROL = "flowControl"
|
||||
|
||||
|
||||
class State(object):
|
||||
OPENING_CONNECTION = "Opening connection"
|
||||
DETECTING_CONNECTION = "Detecting connection"
|
||||
CONNECTED = "Connected"
|
||||
DISCONNECTED = "Disconnected"
|
||||
DISCONNECTED_WITH_ERROR = "Disconnected with error"
|
||||
ERROR = "Error"
|
||||
|
||||
|
||||
class MessageReceiver(object):
|
||||
def onMessageReceived(self, source, message):
|
||||
pass
|
||||
|
||||
def onTimeoutReceived(self, source):
|
||||
pass
|
||||
|
||||
|
||||
class StateReceiver(object):
|
||||
def onStateChangeReceived(self, source, oldState, newState):
|
||||
pass
|
||||
|
||||
|
||||
class LogReceiver(object):
|
||||
def onLogTx(self, source, tx):
|
||||
pass
|
||||
|
||||
def onLogRx(self, source, rx):
|
||||
pass
|
||||
|
||||
def onLogError(self, source, error):
|
||||
pass
|
||||
@@ -0,0 +1,192 @@
|
||||
# coding=utf-8
|
||||
__author__ = "Gina Häußge <osd@foosel.net>"
|
||||
__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html"
|
||||
__copyright__ = "Copyright (C) 2014 Gina Häußge - Released under terms of the AGPLv3 License"
|
||||
|
||||
import os
|
||||
import glob
|
||||
import threading
|
||||
import serial
|
||||
|
||||
try:
|
||||
import _winreg
|
||||
except:
|
||||
pass
|
||||
|
||||
from . import Transport, TransportProperties, State, SendTimeout, TransportError
|
||||
from octoprint.util import getExceptionString
|
||||
from octoprint.util.virtual import VirtualPrinter
|
||||
from octoprint.settings import settings
|
||||
from octoprint.events import eventManager, Events
|
||||
|
||||
class SerialTransport(Transport):
|
||||
|
||||
__transportinfo__ = ("serial", "Serial", False)
|
||||
|
||||
def __init__(self, messageReceiver, stateReceiver, logReceiver):
|
||||
Transport.__init__(self, messageReceiver, stateReceiver, logReceiver)
|
||||
|
||||
self._serial = None
|
||||
self._port = None
|
||||
self._baudrate = None
|
||||
self._connectionTimeout = None
|
||||
self._writeTimeout = None
|
||||
self._readTimeout = None
|
||||
|
||||
self._timeoutCounter = 0
|
||||
self._maxTimeouts = 20
|
||||
|
||||
self._thread = None
|
||||
|
||||
def get_properties(self):
|
||||
return {
|
||||
TransportProperties.FLOWCONTROL: False
|
||||
}
|
||||
|
||||
def get_connection_options(self):
|
||||
return {
|
||||
"port": self.__getSerialList(),
|
||||
"baudrate": self.__getBaudrateList()
|
||||
}
|
||||
|
||||
def connect(self, opt):
|
||||
Transport.connect(self, opt)
|
||||
|
||||
self._port = opt["port"] if "port" in opt else None
|
||||
self._baudrate = opt["baudrate"] if "baudrate" in opt else None
|
||||
|
||||
self._readTimeout = opt["timeout"]["read"] if "timeout" in opt and "read" in opt["timeout"] else 5.0
|
||||
self._writeTimeout = opt["timeout"]["write"] if "timeout" in opt and "write" in opt["timeout"] else 0.5
|
||||
|
||||
if self._connect():
|
||||
self._thread = threading.Thread(target=self._monitor, name="SerialTransportMonitor")
|
||||
self._thread.daemon = True
|
||||
self._thread.start()
|
||||
|
||||
def disconnect(self, onError=False):
|
||||
try:
|
||||
if self._serial is not None:
|
||||
self._serial.close()
|
||||
finally:
|
||||
self._serial = None
|
||||
self._thread = None
|
||||
Transport.disconnect(self, onError)
|
||||
|
||||
def send(self, command):
|
||||
commandToSend = command + "\n"
|
||||
try:
|
||||
self._serial.write(commandToSend)
|
||||
self._transport_logger.info("Send: %s" % command)
|
||||
self.logTx(command)
|
||||
except serial.SerialTimeoutException:
|
||||
self._transport_logger.warn("Timeout while sending: %s" % command)
|
||||
self.logError("Serial timeout while writing to serial port, try again later.")
|
||||
raise SendTimeout()
|
||||
except:
|
||||
exceptionString = getExceptionString()
|
||||
self.logError("Unexpected error while writing serial port: %s" % exceptionString)
|
||||
self.onError(exceptionString)
|
||||
self.disconnect(True)
|
||||
raise TransportError()
|
||||
|
||||
def receive(self):
|
||||
return self._readline()
|
||||
|
||||
def _monitor(self):
|
||||
error = None
|
||||
while True:
|
||||
line = self._readline()
|
||||
if line is None:
|
||||
error = "Serial connection closed unexpectedly"
|
||||
break
|
||||
if line == "":
|
||||
self._timeoutCounter += 1
|
||||
self.onTimeout()
|
||||
if self._maxTimeouts and self._timeoutCounter > self._maxTimeouts:
|
||||
error = "Printer did not respond at all over %d retries, considering it dead" % self._maxTimeouts
|
||||
break
|
||||
else:
|
||||
self._timeoutCounter = 0
|
||||
self.onMessageReceived(line.strip())
|
||||
|
||||
if error is not None:
|
||||
self._transport_logger.error(error)
|
||||
self.logError(error)
|
||||
self.onError(error)
|
||||
# TODO further error handling
|
||||
|
||||
def _connect(self):
|
||||
self.changeState(State.OPENING_CONNECTION)
|
||||
if self._port == "VIRTUAL":
|
||||
self._serial = VirtualPrinter(read_timeout=self._readTimeout, write_timeout=self._writeTimeout)
|
||||
self.changeState(State.CONNECTED)
|
||||
self._transport_logger.debug("Connected to %s" % self._serial)
|
||||
else:
|
||||
try:
|
||||
self._serial = serial.Serial(self._port, self._baudrate, timeout=self._readTimeout, writeTimeout=self._writeTimeout)
|
||||
self.changeState(State.CONNECTED)
|
||||
self._transport_logger.debug("Connected to %s" % self._serial)
|
||||
except:
|
||||
self.logError("Unexpected error while connecting to serial port: %s %s" % (self._port, getExceptionString()))
|
||||
self.onError("Failed to open serial port, permissions correct?")
|
||||
return False
|
||||
eventManager().fire(Events.CONNECTED, {"port": self._port, "baudrate": self._baudrate})
|
||||
return True
|
||||
|
||||
def _readline(self):
|
||||
if self._serial is None:
|
||||
return None
|
||||
|
||||
try:
|
||||
line = self._serial.readline()
|
||||
except:
|
||||
exceptionString = getExceptionString()
|
||||
self.logError("Unexpected error while reading serial port: %s" % exceptionString)
|
||||
self.onError(exceptionString)
|
||||
self.disconnect()
|
||||
return None
|
||||
|
||||
if line != "":
|
||||
loggable_line = unicode(line, "ascii", "replace").encode("ascii", "replace").rstrip()
|
||||
self._transport_logger.debug("Recv: %s" % loggable_line)
|
||||
self.logRx(loggable_line)
|
||||
return line
|
||||
|
||||
def __getSerialList(self):
|
||||
baselist=[]
|
||||
if os.name == "nt":
|
||||
try:
|
||||
key=_winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,"HARDWARE\\DEVICEMAP\\SERIALCOMM")
|
||||
i=0
|
||||
while(1):
|
||||
baselist+=[_winreg.EnumValue(key,i)[1]]
|
||||
i+=1
|
||||
except:
|
||||
pass
|
||||
baselist = baselist \
|
||||
+ glob.glob("/dev/ttyUSB*") \
|
||||
+ glob.glob("/dev/ttyACM*") \
|
||||
+ glob.glob("/dev/ttyAMA*") \
|
||||
+ glob.glob("/dev/tty.usb*") \
|
||||
+ glob.glob("/dev/cu.*") \
|
||||
+ glob.glob("/dev/rfcomm*")
|
||||
|
||||
additionalPorts = settings().get(["serial", "additionalPorts"])
|
||||
for additional in additionalPorts:
|
||||
baselist += glob.glob(additional)
|
||||
|
||||
prev = settings().get(["serial", "port"])
|
||||
if prev in baselist:
|
||||
baselist.remove(prev)
|
||||
baselist.insert(0, prev)
|
||||
if settings().getBoolean(["devel", "virtualPrinter", "enabled"]):
|
||||
baselist.append("VIRTUAL")
|
||||
return baselist
|
||||
|
||||
def __getBaudrateList(self):
|
||||
ret = [250000, 230400, 115200, 57600, 38400, 19200, 9600]
|
||||
prev = settings().getInt(["serial", "baudrate"])
|
||||
if prev in ret:
|
||||
ret.remove(prev)
|
||||
ret.insert(0, prev)
|
||||
return ret
|
||||
@@ -42,6 +42,7 @@ class Events(object):
|
||||
UPDATED_FILES = "UpdatedFiles"
|
||||
METADATA_ANALYSIS_STARTED = "MetadataAnalysisStarted"
|
||||
METADATA_ANALYSIS_FINISHED = "MetadataAnalysisFinished"
|
||||
METADATA_STATISTICS_UPDATED = "MetadataStatisticsUpdated"
|
||||
|
||||
# SD Upload
|
||||
TRANSFER_STARTED = "TransferStarted"
|
||||
@@ -62,6 +63,7 @@ class Events(object):
|
||||
HOME = "Home"
|
||||
Z_CHANGE = "ZChange"
|
||||
WAITING = "Waiting"
|
||||
DWELL = "Dwelling"
|
||||
COOLING = "Cooling"
|
||||
ALERT = "Alert"
|
||||
CONVEYOR = "Conveyor"
|
||||
@@ -306,7 +308,7 @@ class CommandTrigger(GenericEventListener):
|
||||
def _executeGcodeCommand(self, command):
|
||||
commands = [command]
|
||||
if isinstance(command, (list, tuple, set)):
|
||||
self.logger.debug("Executing GCode commands: %r" % command)
|
||||
self._logger.debug("Executing GCode commands: %r" % command)
|
||||
commands = list(command)
|
||||
else:
|
||||
self._logger.debug("Executing GCode command: %s" % command)
|
||||
|
||||
@@ -9,6 +9,7 @@ import logging
|
||||
import os
|
||||
|
||||
from octoprint.events import eventManager, Events
|
||||
from octoprint.plugin import plugin_manager, ProgressPlugin
|
||||
|
||||
from .destinations import FileDestinations
|
||||
from .analysis import QueueEntry, AnalysisQueue
|
||||
@@ -113,6 +114,8 @@ class FileManager(object):
|
||||
self._slicing_progress_callbacks = []
|
||||
self._last_slicing_progress = None
|
||||
|
||||
self._progress_plugins = plugin_manager().get_implementations(ProgressPlugin)
|
||||
|
||||
for storage_type, storage_manager in self._storage_managers.items():
|
||||
self._determine_analysis_backlog(storage_type, storage_manager)
|
||||
|
||||
@@ -156,7 +159,7 @@ class FileManager(object):
|
||||
position=None, profile=None, printer_profile_id=None, overrides=None, callback=None, callback_args=None):
|
||||
absolute_source_path = self.get_absolute_path(source_location, source_path)
|
||||
|
||||
def stlProcessed(source_location, source_path, tmp_path, dest_location, dest_path, start_time, printer_profile_id, callback, callback_args, _error=None, _cancelled=False):
|
||||
def stlProcessed(source_location, source_path, tmp_path, dest_location, dest_path, start_time, printer_profile_id, callback, callback_args, _error=None, _cancelled=False, _analysis=None):
|
||||
try:
|
||||
if _error:
|
||||
eventManager().fire(Events.SLICING_FAILED, {"stl": source_path, "gcode": dest_path, "reason": _error})
|
||||
@@ -184,7 +187,7 @@ class FileManager(object):
|
||||
file_obj = Wrapper(stl_name, temp_path, hash)
|
||||
|
||||
printer_profile = self._printer_profile_manager.get(printer_profile_id)
|
||||
self.add_file(dest_location, dest_path, file_obj, links=links, allow_overwrite=True, printer_profile=printer_profile)
|
||||
self.add_file(dest_location, dest_path, file_obj, links=links, allow_overwrite=True, printer_profile=printer_profile, analysis=_analysis)
|
||||
|
||||
end_time = time.time()
|
||||
eventManager().fire(Events.SLICING_DONE, {"stl": source_path, "gcode": dest_path, "time": end_time - start_time})
|
||||
@@ -246,14 +249,25 @@ class FileManager(object):
|
||||
return
|
||||
|
||||
progress_int = int(_progress * 100)
|
||||
if self._last_slicing_progress == progress_int:
|
||||
return
|
||||
else:
|
||||
if self._last_slicing_progress != progress_int:
|
||||
self._last_slicing_progress = progress_int
|
||||
for callback in self._slicing_progress_callbacks:
|
||||
try: callback.sendSlicingProgress(slicer, source_location, source_path, dest_location, dest_path, progress_int)
|
||||
except: self._logger.exception("Exception while pushing slicing progress")
|
||||
|
||||
if progress_int:
|
||||
def call_plugins(slicer, source_location, source_path, dest_location, dest_path, progress):
|
||||
for name, plugin in self._progress_plugins.items():
|
||||
try:
|
||||
plugin.on_slicing_progress(slicer, source_location, source_path, dest_location, dest_path, progress)
|
||||
except:
|
||||
self._logger.exception("Exception while sending slicing progress to plugin %s" % name)
|
||||
|
||||
import threading
|
||||
thread = threading.Thread(target=call_plugins, args=(slicer, source_location, source_path, dest_location, dest_path, progress_int))
|
||||
thread.daemon = False
|
||||
thread.start()
|
||||
|
||||
for callback in self._slicing_progress_callbacks:
|
||||
try: callback.sendSlicingProgress(slicer, source_location, source_path, dest_location, dest_path, progress_int)
|
||||
except: self._logger.exception("Exception while pushing slicing progress")
|
||||
|
||||
def get_busy_files(self):
|
||||
return self._slicing_jobs.keys()
|
||||
@@ -272,17 +286,20 @@ class FileManager(object):
|
||||
result[dst] = self._storage_managers[dst].list_files(path=path, filter=filter, recursive=recursive)
|
||||
return result
|
||||
|
||||
def add_file(self, destination, path, file_object, links=None, allow_overwrite=False, printer_profile=None):
|
||||
def add_file(self, destination, path, file_object, links=None, allow_overwrite=False, printer_profile=None, analysis=None):
|
||||
if printer_profile is None:
|
||||
printer_profile = self._printer_profile_manager.get_current_or_default()
|
||||
|
||||
file_path = self._storage(destination).add_file(path, file_object, links=links, printer_profile=printer_profile, allow_overwrite=allow_overwrite)
|
||||
absolute_path = self._storage(destination).get_absolute_path(file_path)
|
||||
|
||||
file_type = get_file_type(absolute_path)
|
||||
if file_type:
|
||||
queue_entry = QueueEntry(file_path, file_type[-1], destination, absolute_path, printer_profile)
|
||||
self._analysis_queue.enqueue(queue_entry, high_priority=True)
|
||||
if analysis is None:
|
||||
file_type = get_file_type(absolute_path)
|
||||
if file_type:
|
||||
queue_entry = QueueEntry(file_path, file_type[-1], destination, absolute_path, printer_profile)
|
||||
self._analysis_queue.enqueue(queue_entry, high_priority=True)
|
||||
else:
|
||||
self._add_analysis_result(destination, path, analysis)
|
||||
|
||||
eventManager().fire(Events.UPDATED_FILES, dict(type="printables"))
|
||||
return file_path
|
||||
@@ -309,9 +326,13 @@ class FileManager(object):
|
||||
def remove_link(self, destination, path, rel, data):
|
||||
self._storage(destination).remove_link(path, rel, data)
|
||||
|
||||
def log_print(self, destination, path, timestamp, print_time, success):
|
||||
def log_print(self, destination, path, timestamp, print_time, success, printer_profile):
|
||||
try:
|
||||
self._storage(destination).add_history(path, dict(timestamp=timestamp, printTime=print_time, success=success))
|
||||
if success:
|
||||
self._storage(destination).add_history(path, dict(timestamp=timestamp, printTime=print_time, success=success, printerProfile=printer_profile))
|
||||
else:
|
||||
self._storage(destination).add_history(path, dict(timestamp=timestamp, success=success, printerProfile=printer_profile))
|
||||
eventManager().fire(Events.METADATA_STATISTICS_UPDATED, dict(storage=destination, path=path))
|
||||
except NoSuchStorage:
|
||||
# if there's no storage configured where to log the print, we'll just not log it
|
||||
pass
|
||||
@@ -348,10 +369,13 @@ class FileManager(object):
|
||||
raise NoSuchStorage("No storage configured for destination {destination}".format(**locals()))
|
||||
return self._storage_managers[destination]
|
||||
|
||||
def _on_analysis_finished(self, entry, result):
|
||||
if not entry.location in self._storage_managers:
|
||||
def _add_analysis_result(self, destination, path, result):
|
||||
if not destination in self._storage_managers:
|
||||
return
|
||||
|
||||
storage_manager = self._storage_managers[entry.location]
|
||||
storage_manager.set_additional_metadata(entry.path, "analysis", result)
|
||||
storage_manager = self._storage_managers[destination]
|
||||
storage_manager.set_additional_metadata(path, "analysis", result)
|
||||
|
||||
def _on_analysis_finished(self, entry, result):
|
||||
self._add_analysis_result(entry.location, entry.path, result)
|
||||
|
||||
@@ -501,6 +501,7 @@ class LocalFileStorage(StorageInterface):
|
||||
metadata[name]["history"] = []
|
||||
|
||||
metadata[name]["history"].append(data)
|
||||
self._calculate_stats_from_history(name, path, metadata=metadata, save=False)
|
||||
self._save_metadata(path, metadata)
|
||||
|
||||
def _update_history(self, name, path, index, data):
|
||||
@@ -510,7 +511,8 @@ class LocalFileStorage(StorageInterface):
|
||||
return
|
||||
|
||||
try:
|
||||
metadata[name]["history"][index] = data
|
||||
metadata[name]["history"][index].update(data)
|
||||
self._calculate_stats_from_history(name, path, metadata=metadata, save=False)
|
||||
self._save_metadata(path, metadata)
|
||||
except IndexError:
|
||||
pass
|
||||
@@ -523,10 +525,55 @@ class LocalFileStorage(StorageInterface):
|
||||
|
||||
try:
|
||||
del metadata[name]["history"][index]
|
||||
self._calculate_stats_from_history(name, path, metadata=metadata, save=False)
|
||||
self._save_metadata(path, metadata)
|
||||
except IndexError:
|
||||
pass
|
||||
|
||||
def _calculate_stats_from_history(self, name, path, metadata=None, save=True):
|
||||
if metadata is None:
|
||||
metadata = self._get_metadata(path)
|
||||
|
||||
if not name in metadata or not "history" in metadata[name]:
|
||||
return
|
||||
|
||||
# collect data from history
|
||||
former_print_times = dict()
|
||||
last_print = dict()
|
||||
|
||||
|
||||
for history_entry in metadata[name]["history"]:
|
||||
if not "printTime" in history_entry or not "success" in history_entry or not history_entry["success"] or not "printerProfile" in history_entry:
|
||||
continue
|
||||
|
||||
printer_profile = history_entry["printerProfile"]
|
||||
print_time = history_entry["printTime"]
|
||||
|
||||
if not printer_profile in former_print_times:
|
||||
former_print_times[printer_profile] = []
|
||||
former_print_times[printer_profile].append(print_time)
|
||||
|
||||
if not printer_profile in last_print or last_print[printer_profile] is None or ("timestamp" in history_entry and history_entry["timestamp"] > last_print[printer_profile]["timestamp"]):
|
||||
last_print[printer_profile] = history_entry
|
||||
|
||||
# calculate stats
|
||||
statistics = dict(averagePrintTime=dict(), lastPrintTime=dict())
|
||||
|
||||
for printer_profile in former_print_times:
|
||||
if not former_print_times[printer_profile]:
|
||||
continue
|
||||
statistics["averagePrintTime"][printer_profile] = sum(former_print_times[printer_profile]) / float(len(former_print_times[printer_profile]))
|
||||
|
||||
for printer_profile in last_print:
|
||||
if not last_print[printer_profile]:
|
||||
continue
|
||||
statistics["lastPrintTime"][printer_profile] = last_print[printer_profile]["printTime"]
|
||||
|
||||
metadata[name]["statistics"] = statistics
|
||||
|
||||
if save:
|
||||
self._save_metadata(path, metadata)
|
||||
|
||||
def _get_links(self, name, path, searched_rel):
|
||||
metadata = self._get_metadata(path)
|
||||
result = []
|
||||
@@ -809,9 +856,12 @@ class LocalFileStorage(StorageInterface):
|
||||
with open(metadata_path) as f:
|
||||
try:
|
||||
import yaml
|
||||
return yaml.safe_load(f)
|
||||
metadata = yaml.safe_load(f)
|
||||
except:
|
||||
self._logger.exception("Error while reading .metadata.yaml from {path}".format(**locals()))
|
||||
else:
|
||||
self._metadata_cache[path] = metadata
|
||||
return metadata
|
||||
return dict()
|
||||
|
||||
def _save_metadata(self, path, metadata):
|
||||
|
||||
@@ -30,7 +30,8 @@ def plugin_manager(init=False, plugin_folders=None, plugin_types=None, plugin_en
|
||||
BlueprintPlugin,
|
||||
EventHandlerPlugin,
|
||||
SlicerPlugin,
|
||||
AppPlugin]
|
||||
AppPlugin,
|
||||
ProgressPlugin]
|
||||
if plugin_entry_points is None:
|
||||
plugin_entry_points = "octoprint.plugin"
|
||||
if plugin_disabled_list is None:
|
||||
|
||||
@@ -228,6 +228,36 @@ class SlicerPlugin(Plugin):
|
||||
pass
|
||||
|
||||
|
||||
class ProgressPlugin(Plugin):
|
||||
"""
|
||||
Via the ``ProgressPlugin`` mixing plugins can let themselves be called upon progress in print jobs or slicing jobs,
|
||||
limited to minimally 1% steps.
|
||||
"""
|
||||
|
||||
def on_print_progress(self, storage, path, progress):
|
||||
"""
|
||||
Called by OctoPrint on minimally 1% increments during a running print job.
|
||||
|
||||
:param location string: Location of the file
|
||||
:param path string: Path of the file
|
||||
:param progress int: Current progress as a value between 0 and 100
|
||||
"""
|
||||
pass
|
||||
|
||||
def on_slicing_progress(self, slicer, source_location, source_path, destination_location, destination_path, progress):
|
||||
"""
|
||||
Called by OctoPrint on minimally 1% increments during a running slicing job.
|
||||
|
||||
:param slicer string: Key of the slicer reporting the progress
|
||||
:param source_location string: Location of the source file
|
||||
:param source_path string: Path of the source file
|
||||
:param destination_location string: Location the destination file
|
||||
:param destination_path string: Path of the destination file
|
||||
:param progress int: Current progress as a value between 0 and 100
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class AppPlugin(Plugin):
|
||||
def get_additional_apps(self):
|
||||
return []
|
||||
|
||||
@@ -9,6 +9,7 @@ import logging
|
||||
import logging.handlers
|
||||
import os
|
||||
import flask
|
||||
import math
|
||||
|
||||
import octoprint.plugin
|
||||
import octoprint.util
|
||||
@@ -114,9 +115,8 @@ class CuraPlugin(octoprint.plugin.SlicerPlugin,
|
||||
# setup job tracking across threads
|
||||
import threading
|
||||
self._slicing_commands = dict()
|
||||
self._slicing_commands_mutex = threading.Lock()
|
||||
self._cancelled_jobs = []
|
||||
self._cancelled_jobs_mutex = threading.Lock()
|
||||
self._job_mutex = threading.Lock()
|
||||
|
||||
##~~ StartupPlugin API
|
||||
|
||||
@@ -230,54 +230,56 @@ class CuraPlugin(octoprint.plugin.SlicerPlugin,
|
||||
self._save_profile(path, new_profile, allow_overwrite=allow_overwrite)
|
||||
|
||||
def do_slice(self, model_path, printer_profile, machinecode_path=None, profile_path=None, position=None, on_progress=None, on_progress_args=None, on_progress_kwargs=None):
|
||||
if not profile_path:
|
||||
profile_path = s.get(["default_profile"])
|
||||
if not machinecode_path:
|
||||
path, _ = os.path.splitext(model_path)
|
||||
machinecode_path = path + ".gco"
|
||||
|
||||
if position and isinstance(position, dict) and "x" in position and "y" in position:
|
||||
posX = position["x"]
|
||||
posY = position["y"]
|
||||
else:
|
||||
posX = None
|
||||
posY = None
|
||||
|
||||
if on_progress:
|
||||
if not on_progress_args:
|
||||
on_progress_args = ()
|
||||
if not on_progress_kwargs:
|
||||
on_progress_kwargs = dict()
|
||||
|
||||
self._cura_logger.info("### Slicing %s to %s using profile stored at %s" % (model_path, machinecode_path, profile_path))
|
||||
|
||||
engine_settings = self._convert_to_engine(profile_path, printer_profile, posX, posY)
|
||||
|
||||
executable = s.get(["cura_engine"])
|
||||
if not executable:
|
||||
return False, "Path to CuraEngine is not configured "
|
||||
|
||||
working_dir, _ = os.path.split(executable)
|
||||
args = ['"%s"' % executable, '-v', '-p']
|
||||
for k, v in engine_settings.items():
|
||||
args += ["-s", '"%s=%s"' % (k, str(v))]
|
||||
args += ['-o', '"%s"' % machinecode_path, '"%s"' % model_path]
|
||||
|
||||
import sarge
|
||||
command = " ".join(args)
|
||||
self._logger.info("Running %r in %s" % (command, working_dir))
|
||||
try:
|
||||
p = sarge.run(command, cwd=working_dir, async=True, stdout=sarge.Capture(), stderr=sarge.Capture())
|
||||
try:
|
||||
with self._slicing_commands_mutex:
|
||||
self._slicing_commands[machinecode_path] = p.commands[0]
|
||||
with self._job_mutex:
|
||||
if not profile_path:
|
||||
profile_path = s.get(["default_profile"])
|
||||
if not machinecode_path:
|
||||
path, _ = os.path.splitext(model_path)
|
||||
machinecode_path = path + ".gco"
|
||||
|
||||
if position and isinstance(position, dict) and "x" in position and "y" in position:
|
||||
posX = position["x"]
|
||||
posY = position["y"]
|
||||
else:
|
||||
posX = None
|
||||
posY = None
|
||||
|
||||
if on_progress:
|
||||
if not on_progress_args:
|
||||
on_progress_args = ()
|
||||
if not on_progress_kwargs:
|
||||
on_progress_kwargs = dict()
|
||||
|
||||
self._cura_logger.info("### Slicing %s to %s using profile stored at %s" % (model_path, machinecode_path, profile_path))
|
||||
|
||||
engine_settings = self._convert_to_engine(profile_path, printer_profile, posX, posY)
|
||||
|
||||
executable = s.get(["cura_engine"])
|
||||
if not executable:
|
||||
return False, "Path to CuraEngine is not configured "
|
||||
|
||||
working_dir, _ = os.path.split(executable)
|
||||
args = ['"%s"' % executable, '-v', '-p']
|
||||
for k, v in engine_settings.items():
|
||||
args += ["-s", '"%s=%s"' % (k, str(v))]
|
||||
args += ['-o', '"%s"' % machinecode_path, '"%s"' % model_path]
|
||||
|
||||
import sarge
|
||||
command = " ".join(args)
|
||||
self._logger.info("Running %r in %s" % (command, working_dir))
|
||||
|
||||
p = sarge.run(command, cwd=working_dir, async=True, stdout=sarge.Capture(), stderr=sarge.Capture())
|
||||
self._slicing_commands[machinecode_path] = p.commands[0]
|
||||
|
||||
try:
|
||||
layer_count = None
|
||||
step_factor = dict(
|
||||
inset=0,
|
||||
skin=1,
|
||||
export=2
|
||||
)
|
||||
analysis = None
|
||||
while p.returncode is None:
|
||||
line = p.stderr.readline(timeout=0.5)
|
||||
if not line:
|
||||
@@ -331,17 +333,50 @@ class CuraPlugin(octoprint.plugin.SlicerPlugin,
|
||||
continue
|
||||
on_progress_kwargs["_progress"] = (step_factor[step] * layer_count + current_layer) / (layer_count * 3)
|
||||
on_progress(*on_progress_args, **on_progress_kwargs)
|
||||
|
||||
elif line.startswith("Print time:"):
|
||||
try:
|
||||
print_time = int(line[len("Print time:"):].strip())
|
||||
if analysis is None:
|
||||
analysis = dict()
|
||||
analysis["estimatedPrintTime"] = print_time
|
||||
except:
|
||||
pass
|
||||
|
||||
elif line.startswith("Filament:") or line.startswith("Filament2:"):
|
||||
if line.startswith("Filament:"):
|
||||
filament_str = line[len("Filament:"):].strip()
|
||||
tool_key = "tool0"
|
||||
else:
|
||||
filament_str = line[len("Filament2:"):].strip()
|
||||
tool_key = "tool1"
|
||||
|
||||
try:
|
||||
filament = int(filament_str)
|
||||
if analysis is None:
|
||||
analysis = dict()
|
||||
if not "filament" in analysis:
|
||||
analysis["filament"] = dict()
|
||||
if not tool_key in analysis["filament"]:
|
||||
analysis["filament"][tool_key] = dict()
|
||||
analysis["filament"][tool_key]["length"] = filament
|
||||
if "filamentDiameter" in engine_settings:
|
||||
radius_in_cm = float(int(engine_settings["filamentDiameter"]) / 10000.0) / 2.0
|
||||
filament_in_cm = filament / 10.0
|
||||
analysis["filament"][tool_key]["volume"] = filament_in_cm * math.pi * radius_in_cm * radius_in_cm
|
||||
except:
|
||||
pass
|
||||
finally:
|
||||
p.close()
|
||||
|
||||
with self._cancelled_jobs_mutex:
|
||||
with self._job_mutex:
|
||||
if machinecode_path in self._cancelled_jobs:
|
||||
self._cura_logger.info("### Cancelled")
|
||||
raise octoprint.slicing.SlicingCancelled()
|
||||
|
||||
self._cura_logger.info("### Finished, returncode %d" % p.returncode)
|
||||
if p.returncode == 0:
|
||||
return True, None
|
||||
return True, dict(analysis=analysis)
|
||||
else:
|
||||
self._logger.warn("Could not slice via Cura, got return code %r" % p.returncode)
|
||||
return False, "Got returncode %r" % p.returncode
|
||||
@@ -353,21 +388,21 @@ class CuraPlugin(octoprint.plugin.SlicerPlugin,
|
||||
return False, "Unknown error, please consult the log file"
|
||||
|
||||
finally:
|
||||
with self._cancelled_jobs_mutex:
|
||||
with self._job_mutex:
|
||||
if machinecode_path in self._cancelled_jobs:
|
||||
self._cancelled_jobs.remove(machinecode_path)
|
||||
with self._slicing_commands_mutex:
|
||||
if machinecode_path in self._slicing_commands:
|
||||
del self._slicing_commands[machinecode_path]
|
||||
|
||||
self._cura_logger.info("-" * 40)
|
||||
|
||||
def cancel_slicing(self, machinecode_path):
|
||||
with self._slicing_commands_mutex:
|
||||
with self._job_mutex:
|
||||
if machinecode_path in self._slicing_commands:
|
||||
with self._cancelled_jobs_mutex:
|
||||
self._cancelled_jobs.append(machinecode_path)
|
||||
self._slicing_commands[machinecode_path].terminate()
|
||||
self._cancelled_jobs.append(machinecode_path)
|
||||
command = self._slicing_commands[machinecode_path]
|
||||
if command is not None:
|
||||
command.terminate()
|
||||
self._logger.info("Cancelled slicing of %s" % machinecode_path)
|
||||
|
||||
def _load_profile(self, path):
|
||||
|
||||
+441
-261
@@ -1,12 +1,15 @@
|
||||
# coding=utf-8
|
||||
from octoprint.comm.protocol.repetier import RepetierTextualProtocol
|
||||
from octoprint.comm.transport import Transport
|
||||
|
||||
__author__ = "Gina Häußge <osd@foosel.net>"
|
||||
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||
|
||||
import time
|
||||
import datetime
|
||||
import threading
|
||||
import copy
|
||||
import os
|
||||
import re
|
||||
import logging
|
||||
|
||||
import octoprint.util.comm as comm
|
||||
@@ -17,6 +20,12 @@ from octoprint.events import eventManager, Events
|
||||
|
||||
from octoprint.filemanager.destinations import FileDestinations
|
||||
|
||||
from octoprint.comm.protocol import State as ProtocolState, Protocol
|
||||
from octoprint.comm.protocol.reprap import RepRapProtocol
|
||||
from octoprint.comm.transport.serialTransport import SerialTransport
|
||||
|
||||
from octoprint.plugin import plugin_manager, ProgressPlugin
|
||||
|
||||
def getConnectionOptions():
|
||||
"""
|
||||
Retrieves the available ports, baudrates, prefered port and baudrate for connecting to the printer.
|
||||
@@ -34,17 +43,14 @@ class Printer():
|
||||
from collections import deque
|
||||
|
||||
self._logger = logging.getLogger(__name__)
|
||||
#self._estimationLogger = logging.getLogger("ESTIMATIONS")
|
||||
#self._printTimeLogger = logging.getLogger("PRINT_TIME")
|
||||
|
||||
self._analysisQueue = analysisQueue
|
||||
self._fileManager = fileManager
|
||||
self._printerProfileManager = printerProfileManager
|
||||
|
||||
# state
|
||||
# TODO do we really need to hold the temperature here?
|
||||
self._temp = None
|
||||
self._bedTemp = None
|
||||
self._targetTemp = None
|
||||
self._targetBedTemp = None
|
||||
self._temps = deque([], 300)
|
||||
self._tempBacklog = []
|
||||
|
||||
@@ -73,13 +79,19 @@ class Printer():
|
||||
self._streamingFinishedCallback = None
|
||||
|
||||
self._selectedFile = None
|
||||
self._timeEstimationData = None
|
||||
|
||||
# comm
|
||||
self._comm = None
|
||||
|
||||
self._protocol = self._createProtocol()
|
||||
|
||||
# callbacks
|
||||
self._callbacks = []
|
||||
|
||||
# progress plugins
|
||||
self._lastProgressReport = None
|
||||
self._progressPlugins = plugin_manager().get_implementations(ProgressPlugin)
|
||||
|
||||
self._stateMonitor = StateMonitor(
|
||||
ratelimit=0.5,
|
||||
@@ -108,7 +120,51 @@ class Printer():
|
||||
currentZ=None
|
||||
)
|
||||
|
||||
eventManager().subscribe(Events.METADATA_ANALYSIS_FINISHED, self.onMetadataAnalysisFinished);
|
||||
eventManager().subscribe(Events.METADATA_ANALYSIS_FINISHED, self.onMetadataAnalysisFinished)
|
||||
eventManager().subscribe(Events.METADATA_STATISTICS_UPDATED, self.onMetadataStatisticsUpdated)
|
||||
|
||||
def _getTransportFactory(self):
|
||||
transports = self._getSubclassAttributes(Transport, "__transportinfo__", validator=lambda x: not x[2])
|
||||
|
||||
transportType = settings().get(["communication", "transport"])
|
||||
for t in transports:
|
||||
id, name, abstract, factory = t
|
||||
if transportType == id:
|
||||
return factory
|
||||
|
||||
return SerialTransport
|
||||
|
||||
def _createProtocol(self):
|
||||
transport = self._getTransportFactory()
|
||||
protocol_type = settings().get(["communication", "protocol"])
|
||||
|
||||
protocols = self._getSubclassAttributes(Protocol, "__protocolinfo__", validator=lambda x: not x[2])
|
||||
|
||||
protocol_factory = RepRapProtocol
|
||||
for p in protocols:
|
||||
id, name, abstract, factory = p
|
||||
if protocol_type == id:
|
||||
protocol_factory = factory
|
||||
break
|
||||
|
||||
return protocol_factory(transport, protocol_listener=self)
|
||||
|
||||
def _getSubclassAttributes(self, origin, attribute, converter=lambda o, v: v, validator=lambda x: True):
|
||||
result = []
|
||||
|
||||
if hasattr(origin, attribute):
|
||||
value = getattr(origin, attribute)
|
||||
if validator(value):
|
||||
converted = list(converter(origin, value))
|
||||
converted.append(origin)
|
||||
result.append(converted)
|
||||
|
||||
subclasses = origin.__subclasses__()
|
||||
if subclasses:
|
||||
for s in subclasses:
|
||||
result.extend(self._getSubclassAttributes(s, attribute, converter, validator))
|
||||
|
||||
return result
|
||||
|
||||
#~~ callback handling
|
||||
|
||||
@@ -150,6 +206,129 @@ class Printer():
|
||||
try: callback.sendFeedbackCommandOutput(name, output)
|
||||
except: self._logger.exception("Exception while pushing feedback command output")
|
||||
|
||||
#~~ callbacks from protocol
|
||||
|
||||
def onStateChange(self, source, oldState, newState):
|
||||
if not source == self._protocol:
|
||||
return
|
||||
|
||||
# forward relevant state changes to gcode manager
|
||||
if oldState == ProtocolState.PRINTING:
|
||||
self._analysisQueue.resume() # printing done, put those cpu cycles to good use
|
||||
if self._selectedFile is not None and newState == ProtocolState.OFFLINE or newState == ProtocolState.ERROR:
|
||||
self._fileManager.log_print(FileDestinations.SDCARD if self._selectedFile["sd"] else FileDestinations.LOCAL, self._selectedFile["filename"], time.time(), self._protocol.get_print_time(), False)
|
||||
elif newState == ProtocolState.PRINTING:
|
||||
self._analysisQueue.pause() # do not analyse files while printing
|
||||
|
||||
self._setState(newState)
|
||||
|
||||
def onTemperatureUpdate(self, source, temperatureData):
|
||||
if not source == self._protocol:
|
||||
return
|
||||
|
||||
self._addTemperatureData(temperatureData)
|
||||
|
||||
def onProgress(self, source, progress):
|
||||
if not source == self._protocol:
|
||||
return
|
||||
|
||||
self._setProgressData(progress["completion"], progress["filepos"], progress["printTime"])
|
||||
|
||||
def onZChange(self, source, oldZ, newZ):
|
||||
if not source == self._protocol:
|
||||
return
|
||||
|
||||
if newZ != oldZ:
|
||||
# we have to react to all z-changes, even those that might "go backward" due to a slicer's retraction or
|
||||
# anti-backlash-routines. Event subscribes should individually take care to filter out "wrong" z-changes
|
||||
eventManager().fire(Events.Z_CHANGE, {"new": newZ, "old": oldZ})
|
||||
|
||||
self._setCurrentZ(newZ)
|
||||
|
||||
def onFileSelected(self, source, filename, filesize, origin):
|
||||
if not source == self._protocol:
|
||||
return
|
||||
|
||||
self._setJobData(filename, filesize, origin)
|
||||
self._stateMonitor.setState({"text": self.getStateString(), "flags": self._getStateFlags()})
|
||||
|
||||
if self._printAfterSelect:
|
||||
self.startPrint()
|
||||
pass
|
||||
|
||||
def onPrintjobDone(self, source):
|
||||
if not source == self._protocol:
|
||||
return
|
||||
|
||||
self._setProgressData(100.0, self._selectedFile["filesize"], self._protocol.get_print_time())
|
||||
self._stateMonitor.setState({"text": self.getStateString(), "flags": self._getStateFlags()})
|
||||
|
||||
if self._selectedFile is not None:
|
||||
self._fileManager.log_print(FileDestinations.SDCARD if self._selectedFile["sd"] else FileDestinations.LOCAL, self._selectedFile["filename"], time.time(), self._protocol.get_print_time(), True, self._printerProfileManager.get_current_or_default()["id"])
|
||||
|
||||
def onPrintjobCancelled(self, source):
|
||||
if not source == self._protocol:
|
||||
return
|
||||
|
||||
if self._selectedFile is not None:
|
||||
self._fileManager.log_print(FileDestinations.SDCARD if self._selectedFile["sd"] else FileDestinations.LOCAL, self._selectedFile["filename"], time.time(), self._protocol.get_print_time(), False, self._printerProfileManager.get_current_or_default()["id"])
|
||||
|
||||
def onFileTransferStarted(self, source, filename, filesize):
|
||||
if not source == self._protocol:
|
||||
return
|
||||
|
||||
self._sdStreaming = True
|
||||
|
||||
self._setJobData(filename, filesize, FileDestinations.SDCARD)
|
||||
self._setProgressData(0.0, 0, 0)
|
||||
self._stateMonitor.setState({"text": self.getStateString(), "flags": self._getStateFlags()})
|
||||
|
||||
def onFileTransferDone(self, source):
|
||||
if not source == self._protocol:
|
||||
return
|
||||
|
||||
self._sdStreaming = False
|
||||
|
||||
if self._streamingFinishedCallback is not None:
|
||||
self._streamingFinishedCallback(self._sdRemoteName, FileDestinations.SDCARD)
|
||||
|
||||
self._sdRemoteName = None
|
||||
self._setCurrentZ(None)
|
||||
self._setJobData(None, None, None)
|
||||
self._setProgressData(None, None, None)
|
||||
self._stateMonitor.setState({"text": self.getStateString(), "flags": self._getStateFlags()})
|
||||
|
||||
def onSdStateChange(self, source, sdAvailable):
|
||||
if not source == self._protocol:
|
||||
return
|
||||
|
||||
self._stateMonitor.setState({"text": self.getStateString(), "flags": self._getStateFlags()})
|
||||
|
||||
def onSdFiles(self, source, files):
|
||||
if not source == self._protocol:
|
||||
return
|
||||
|
||||
eventManager().fire(Events.UPDATED_FILES, {"type": "gcode"})
|
||||
self._sdFilelistAvailable.set()
|
||||
|
||||
def onLogTx(self, source, tx):
|
||||
if not source == self._protocol:
|
||||
return
|
||||
|
||||
self._addLog("Send: %s" % tx)
|
||||
|
||||
def onLogRx(self, source, rx):
|
||||
if not source == self._protocol:
|
||||
return
|
||||
|
||||
self._addLog("Recv: %s" % rx)
|
||||
|
||||
def onLogError(self, source, error):
|
||||
if not source == self._protocol:
|
||||
return
|
||||
|
||||
self._addLog("ERROR: %s" % error)
|
||||
|
||||
#~~ callback from metadata analysis event
|
||||
|
||||
def onMetadataAnalysisFinished(self, event, data):
|
||||
@@ -158,119 +337,126 @@ class Printer():
|
||||
self._selectedFile["filesize"],
|
||||
self._selectedFile["sd"])
|
||||
|
||||
def onMetadataStatisticsUpdated(self, event, data):
|
||||
self._setJobData(self._selectedFile["filename"],
|
||||
self._selectedFile["filesize"],
|
||||
self._selectedFile["sd"])
|
||||
|
||||
#~~ progress plugin reporting
|
||||
|
||||
def _reportPrintProgressToPlugins(self, progress):
|
||||
if not progress or not self._selectedFile or not "sd" in self._selectedFile or not "filename" in self._selectedFile:
|
||||
return
|
||||
|
||||
storage = "sdcard" if self._selectedFile["sd"] else "local"
|
||||
filename = self._selectedFile["filename"]
|
||||
|
||||
def call_plugins(storage, filename, progress):
|
||||
for name, plugin in self._progressPlugins.items():
|
||||
try:
|
||||
plugin.on_print_progress(storage, filename, progress)
|
||||
except:
|
||||
self._logger.exception("Exception while sending print progress to plugin %s" % name)
|
||||
|
||||
thread = threading.Thread(target=call_plugins, args=(storage, filename, progress))
|
||||
thread.daemon = False
|
||||
thread.start()
|
||||
|
||||
#~~ printer commands
|
||||
|
||||
def connect(self, port=None, baudrate=None, profile=None):
|
||||
def connect(self, protocol_option_overrides=None, transport_option_overrides=None, profile=None):
|
||||
"""
|
||||
Connects to the printer. If port and/or baudrate is provided, uses these settings, otherwise autodetection
|
||||
will be attempted.
|
||||
"""
|
||||
if self._comm is not None:
|
||||
self._comm.close()
|
||||
self._comm = comm.MachineCom(port, baudrate, callbackObject=self)
|
||||
self._protocol.disconnect()
|
||||
|
||||
protocol_options = settings().get(["communication", "protocolOptions"], merged=True)
|
||||
if protocol_option_overrides is not None and isinstance(protocol_option_overrides, dict):
|
||||
protocol_options = util.dict_merge(protocol_options, protocol_option_overrides)
|
||||
|
||||
transport_options = settings().get(["communication", "transportOptions"], merged=True)
|
||||
if transport_option_overrides is not None and isinstance(transport_option_overrides, dict):
|
||||
transport_options = util.dict_merge(transport_options, transport_option_overrides)
|
||||
|
||||
self._protocol.connect(protocol_options, transport_options)
|
||||
self._printerProfileManager.select(profile)
|
||||
|
||||
def disconnect(self):
|
||||
"""
|
||||
Closes the connection to the printer.
|
||||
"""
|
||||
if self._comm is not None:
|
||||
self._comm.close()
|
||||
self._comm = None
|
||||
self._protocol.disconnect()
|
||||
self._printerProfileManager.deselect()
|
||||
eventManager().fire(Events.DISCONNECTED)
|
||||
|
||||
def getConnectionOptions(self):
|
||||
connection_options = self._protocol.get_connection_options()
|
||||
|
||||
return {
|
||||
"ports": connection_options["port"],
|
||||
"baudrates": connection_options["baudrate"],
|
||||
"portPreference": settings().get(["serial", "port"]),
|
||||
"baudratePreference": settings().getInt(["serial", "baudrate"]),
|
||||
"autoconnect": settings().getBoolean(["serial", "autoconnect"])
|
||||
}
|
||||
|
||||
def command(self, command):
|
||||
"""
|
||||
Sends a single gcode command to the printer.
|
||||
"""
|
||||
self.commands([command])
|
||||
self._protocol.send_manually(command)
|
||||
|
||||
def commands(self, commands):
|
||||
"""
|
||||
Sends multiple gcode commands (provided as a list) to the printer.
|
||||
"""
|
||||
if self._comm is None:
|
||||
return
|
||||
|
||||
for command in commands:
|
||||
self._comm.sendCommand(command)
|
||||
self.command(commands)
|
||||
|
||||
def jog(self, axis, amount):
|
||||
if not axis or not amount:
|
||||
return
|
||||
|
||||
printer_profile = self._printerProfileManager.get_current_or_default()
|
||||
movement_speed = printer_profile["axes"][axis]["speed"]
|
||||
self.commands(["G91", "G1 %s%.4f F%d" % (axis.upper(), amount, movement_speed), "G90"])
|
||||
axis = axis.lower()
|
||||
if axis in printer_profile["axes"]:
|
||||
speed = printer_profile["axes"][axis]["speed"]
|
||||
self._protocol.jog(axis, amount, speed)
|
||||
|
||||
def home(self, axes):
|
||||
self.commands(["G91", "G28 %s" % " ".join(map(lambda x: "%s0" % x.upper(), axes)), "G90"])
|
||||
self._protocol.home(axes)
|
||||
|
||||
def extrude(self, amount):
|
||||
if not amount:
|
||||
return
|
||||
|
||||
printer_profile = self._printerProfileManager.get_current_or_default()
|
||||
extrusion_speed = printer_profile["axes"]["e"]["speed"]
|
||||
self.commands(["G91", "G1 E%s F%d" % (amount, extrusion_speed), "G90"])
|
||||
if "e" in printer_profile["axes"]:
|
||||
speed = printer_profile["axes"]["e"]["speed"]
|
||||
self._protocol.extrude(amount, speed)
|
||||
|
||||
def changeTool(self, tool):
|
||||
try:
|
||||
toolNum = int(tool[len("tool"):])
|
||||
self.command("T%d" % toolNum)
|
||||
except ValueError:
|
||||
pass
|
||||
self._protocol.change_tool(tool)
|
||||
|
||||
def setTemperature(self, type, value):
|
||||
if type.startswith("tool"):
|
||||
printer_profile = self._printerProfileManager.get_current_or_default()
|
||||
extruder_count = printer_profile["extruder"]["count"]
|
||||
if extruder_count > 1:
|
||||
try:
|
||||
toolNum = int(type[len("tool"):])
|
||||
self.command("M104 T%d S%f" % (toolNum, value))
|
||||
except ValueError:
|
||||
pass
|
||||
else:
|
||||
self.command("M104 S%f" % value)
|
||||
elif type == "bed":
|
||||
self.command("M140 S%f" % value)
|
||||
self._protocol.set_temperature(type, value)
|
||||
|
||||
def setTemperatureOffset(self, offsets={}):
|
||||
if self._comm is None:
|
||||
return
|
||||
def setTemperatureOffset(self, offsets):
|
||||
current_offsets = self._protocol.get_temperature_offsets()
|
||||
|
||||
tool, bed = self._comm.getOffsets()
|
||||
|
||||
validatedOffsets = {}
|
||||
new_offsets = {}
|
||||
new_offsets.update(current_offsets)
|
||||
|
||||
for key in offsets:
|
||||
value = offsets[key]
|
||||
if key == "bed":
|
||||
bed = value
|
||||
validatedOffsets[key] = value
|
||||
elif key.startswith("tool"):
|
||||
try:
|
||||
toolNum = int(key[len("tool"):])
|
||||
tool[toolNum] = value
|
||||
validatedOffsets[key] = value
|
||||
except ValueError:
|
||||
pass
|
||||
if key == "bed" or re.match("tool\d+", key):
|
||||
new_offsets[key] = offsets[key]
|
||||
|
||||
self._comm.setTemperatureOffset(tool, bed)
|
||||
self._stateMonitor.setTempOffsets(validatedOffsets)
|
||||
|
||||
def selectFile(self, filename, sd, printAfterSelect=False):
|
||||
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
|
||||
self._protocol.set_temperature_offsets(new_offsets)
|
||||
self._stateMonitor.setTempOffsets(new_offsets)
|
||||
|
||||
def selectFile(self, filename, origin, printAfterSelect=False):
|
||||
self._printAfterSelect = printAfterSelect
|
||||
self._comm.selectFile(filename, sd)
|
||||
self._setProgressData(0, None, None, None)
|
||||
self._protocol.select_file(filename, origin)
|
||||
self._setProgressData(0, None, None)
|
||||
self._setCurrentZ(None)
|
||||
|
||||
def unselectFile(self):
|
||||
if self._comm is not None and (self._comm.isBusy() or self._comm.isStreaming()):
|
||||
return
|
||||
|
||||
self._comm.unselectFile()
|
||||
self._setProgressData(0, None, None, None)
|
||||
self._protocol.deselect_file()
|
||||
self._setProgressData(0, None, None)
|
||||
self._setCurrentZ(None)
|
||||
|
||||
def startPrint(self):
|
||||
@@ -278,31 +464,27 @@ class Printer():
|
||||
Starts the currently loaded print job.
|
||||
Only starts if the printer is connected and operational, not currently printing and a printjob is loaded
|
||||
"""
|
||||
if self._comm is None or not self._comm.isOperational() or self._comm.isPrinting():
|
||||
if not self._protocol.is_operational() or self._protocol.is_busy():
|
||||
return
|
||||
if self._selectedFile is None:
|
||||
return
|
||||
|
||||
self._timeEstimationData = TimeEstimationHelper()
|
||||
self._lastProgressReport = None
|
||||
self._setCurrentZ(None)
|
||||
self._comm.startPrint()
|
||||
self._protocol.start_print()
|
||||
|
||||
def togglePausePrint(self):
|
||||
"""
|
||||
Pause the current printjob.
|
||||
"""
|
||||
if self._comm is None:
|
||||
return
|
||||
|
||||
self._comm.setPause(not self._comm.isPaused())
|
||||
self._protocol.pause_print()
|
||||
|
||||
def cancelPrint(self, disableMotorsAndHeater=True):
|
||||
"""
|
||||
Cancel the current printjob.
|
||||
"""
|
||||
if self._comm is None:
|
||||
return
|
||||
|
||||
self._comm.cancelPrint()
|
||||
self._protocol.cancel_print()
|
||||
|
||||
if disableMotorsAndHeater:
|
||||
printer_profile = self._printerProfileManager.get_current_or_default()
|
||||
@@ -316,11 +498,11 @@ class Printer():
|
||||
|
||||
# reset progress, height, print time
|
||||
self._setCurrentZ(None)
|
||||
self._setProgressData(None, None, None, None)
|
||||
self._setProgressData(None, None, None)
|
||||
|
||||
# mark print as failure
|
||||
if self._selectedFile is not None:
|
||||
self._fileManager.log_print(FileDestinations.SDCARD if self._selectedFile["sd"] else FileDestinations.LOCAL, self._selectedFile["filename"], time.time(), self._comm.getPrintTime(), False)
|
||||
self._fileManager.log_print(FileDestinations.SDCARD if self._selectedFile["sd"] else FileDestinations.LOCAL, self._selectedFile["filename"], time.time(), self._protocol.get_print_time(), False, self._printerProfileManager.get_current_or_default()["id"])
|
||||
payload = {
|
||||
"file": self._selectedFile["filename"],
|
||||
"origin": FileDestinations.LOCAL
|
||||
@@ -347,48 +529,88 @@ class Printer():
|
||||
self._messages.append(message)
|
||||
self._stateMonitor.addMessage(message)
|
||||
|
||||
def _setProgressData(self, progress, filepos, printTime, printTimeLeft):
|
||||
def _estimateTotalPrintTime(self, progress, printTime):
|
||||
if not progress or not printTime:
|
||||
#self._estimationLogger.info("{progress};{printTime};;;;".format(**locals()))
|
||||
return None
|
||||
|
||||
else:
|
||||
newEstimate = printTime * 100 / progress
|
||||
self._timeEstimationData.update(newEstimate)
|
||||
|
||||
result = None
|
||||
if self._timeEstimationData.is_stable():
|
||||
result = self._timeEstimationData.average_total_rolling
|
||||
|
||||
#averageTotal = self._timeEstimationData.average_total
|
||||
#averageTotalRolling = self._timeEstimationData.average_total_rolling
|
||||
#averageDistance = self._timeEstimationData.average_distance
|
||||
|
||||
#self._estimationLogger.info("{progress};{printTime};{newEstimate};{averageTotal};{averageTotalRolling};{averageDistance}".format(**locals()))
|
||||
|
||||
return result
|
||||
|
||||
def _setProgressData(self, progress, filepos, printTime):
|
||||
estimatedTotalPrintTime = self._estimateTotalPrintTime(progress, printTime)
|
||||
statisticalTotalPrintTime = None
|
||||
totalPrintTime = estimatedTotalPrintTime
|
||||
|
||||
if self._selectedFile and "estimatedPrintTime" in self._selectedFile and self._selectedFile["estimatedPrintTime"]:
|
||||
statisticalTotalPrintTime = self._selectedFile["estimatedPrintTime"]
|
||||
if progress and printTime:
|
||||
if estimatedTotalPrintTime is None:
|
||||
totalPrintTime = statisticalTotalPrintTime
|
||||
else:
|
||||
if progress < 50:
|
||||
sub_progress = progress * 2 / 100
|
||||
else:
|
||||
sub_progress = 1.0
|
||||
totalPrintTime = (1 - sub_progress) * statisticalTotalPrintTime + sub_progress * estimatedTotalPrintTime
|
||||
|
||||
#self._printTimeLogger.info("{progress};{printTime};{estimatedTotalPrintTime};{statisticalTotalPrintTime};{totalPrintTime}".format(**locals()))
|
||||
|
||||
self._progress = progress
|
||||
self._printTime = printTime
|
||||
self._printTimeLeft = printTimeLeft
|
||||
self._printTimeLeft = totalPrintTime - printTime if (totalPrintTime is not None and printTime is not None) else None
|
||||
|
||||
self._stateMonitor.setProgress({
|
||||
"completion": self._progress * 100 if self._progress is not None else None,
|
||||
"completion": self._progress,
|
||||
"filepos": filepos,
|
||||
"printTime": int(self._printTime) if self._printTime is not None else None,
|
||||
"printTimeLeft": int(self._printTimeLeft * 60) if self._printTimeLeft is not None else None
|
||||
"printTimeLeft": int(self._printTimeLeft) if self._printTimeLeft is not None else None
|
||||
})
|
||||
|
||||
def _addTemperatureData(self, temp, bedTemp):
|
||||
if progress:
|
||||
progress_int = int(progress)
|
||||
if self._lastProgressReport != progress_int:
|
||||
self._lastProgressReport = progress_int
|
||||
self._reportPrintProgressToPlugins(progress_int)
|
||||
|
||||
|
||||
def _addTemperatureData(self, temperatureData):
|
||||
currentTimeUtc = int(time.time())
|
||||
|
||||
data = {
|
||||
"time": currentTimeUtc
|
||||
}
|
||||
for tool in temp.keys():
|
||||
data["tool%d" % tool] = {
|
||||
"actual": temp[tool][0],
|
||||
"target": temp[tool][1]
|
||||
}
|
||||
if bedTemp is not None and isinstance(bedTemp, tuple):
|
||||
data["bed"] = {
|
||||
"actual": bedTemp[0],
|
||||
"target": bedTemp[1]
|
||||
for tool in temperatureData.keys():
|
||||
data[tool] = {
|
||||
"actual": temperatureData[tool][0],
|
||||
"target": temperatureData[tool][1]
|
||||
}
|
||||
|
||||
self._temps.append(data)
|
||||
|
||||
self._temp = temp
|
||||
self._bedTemp = bedTemp
|
||||
|
||||
self._stateMonitor.addTemperature(data)
|
||||
|
||||
def _setJobData(self, filename, filesize, sd):
|
||||
def _setJobData(self, filename, filesize, origin):
|
||||
sd = origin == FileDestinations.SDCARD
|
||||
if filename is not None:
|
||||
self._selectedFile = {
|
||||
"filename": filename,
|
||||
"filesize": filesize,
|
||||
"sd": sd
|
||||
"sd": sd,
|
||||
"estimatedPrintTime": None
|
||||
}
|
||||
else:
|
||||
self._selectedFile = None
|
||||
@@ -400,12 +622,15 @@ class Printer():
|
||||
"date": None
|
||||
},
|
||||
"estimatedPrintTime": None,
|
||||
"averagePrintTime": None,
|
||||
"lastPrintTime": None,
|
||||
"filament": None,
|
||||
})
|
||||
return
|
||||
|
||||
estimatedPrintTime = None
|
||||
lastPrintTime = None
|
||||
averagePrintTime = None
|
||||
date = None
|
||||
filament = None
|
||||
if filename:
|
||||
@@ -424,17 +649,28 @@ class Printer():
|
||||
estimatedPrintTime = fileData["analysis"]["estimatedPrintTime"]
|
||||
if "filament" in fileData["analysis"].keys():
|
||||
filament = fileData["analysis"]["filament"]
|
||||
if "prints" in fileData and fileData["prints"] and "last" in fileData["prints"] and fileData["prints"]["last"] and "lastPrintTime" in fileData["prints"]["last"]:
|
||||
lastPrintTime = fileData["prints"]["last"]["lastPrintTime"]
|
||||
if "statistics" in fileData:
|
||||
printer_profile = self._printerProfileManager.get_current_or_default()["id"]
|
||||
if "averagePrintTime" in fileData["statistics"] and printer_profile in fileData["statistics"]["averagePrintTime"]:
|
||||
averagePrintTime = fileData["statistics"]["averagePrintTime"][printer_profile]
|
||||
if "lastPrintTime" in fileData["statistics"] and printer_profile in fileData["statistics"]["lastPrintTime"]:
|
||||
lastPrintTime = fileData["statistics"]["lastPrintTime"][printer_profile]
|
||||
|
||||
if averagePrintTime is not None:
|
||||
self._selectedFile["estimatedPrintTime"] = averagePrintTime
|
||||
elif estimatedPrintTime is not None:
|
||||
# TODO apply factor which first needs to be tracked!
|
||||
self._selectedFile["estimatedPrintTime"] = estimatedPrintTime
|
||||
|
||||
self._stateMonitor.setJobData({
|
||||
"file": {
|
||||
"name": os.path.basename(filename) if filename is not None else None,
|
||||
"origin": FileDestinations.SDCARD if sd else FileDestinations.LOCAL,
|
||||
"origin": origin,
|
||||
"size": filesize,
|
||||
"date": date
|
||||
},
|
||||
"estimatedPrintTime": estimatedPrintTime,
|
||||
"averagePrintTime": averagePrintTime,
|
||||
"lastPrintTime": lastPrintTime,
|
||||
"filament": filament,
|
||||
})
|
||||
@@ -466,149 +702,54 @@ class Printer():
|
||||
|
||||
#~~ callbacks triggered from self._comm
|
||||
|
||||
def mcLog(self, message):
|
||||
"""
|
||||
Callback method for the comm object, called upon log output.
|
||||
"""
|
||||
self._addLog(message)
|
||||
|
||||
def mcTempUpdate(self, temp, bedTemp):
|
||||
self._addTemperatureData(temp, bedTemp)
|
||||
|
||||
def mcStateChange(self, state):
|
||||
"""
|
||||
Callback method for the comm object, called if the connection state changes.
|
||||
"""
|
||||
oldState = self._state
|
||||
|
||||
# forward relevant state changes to gcode manager
|
||||
if self._comm is not None and oldState == self._comm.STATE_PRINTING:
|
||||
if self._selectedFile is not None:
|
||||
if state == self._comm.STATE_OPERATIONAL:
|
||||
self._fileManager.log_print(FileDestinations.SDCARD if self._selectedFile["sd"] else FileDestinations.LOCAL, self._selectedFile["filename"], time.time(), self._comm.getPrintTime(), True)
|
||||
elif state == self._comm.STATE_CLOSED or state == self._comm.STATE_ERROR or state == self._comm.STATE_CLOSED_WITH_ERROR:
|
||||
self._fileManager.log_print(FileDestinations.SDCARD if self._selectedFile["sd"] else FileDestinations.LOCAL, self._selectedFile["filename"], time.time(), self._comm.getPrintTime(), False)
|
||||
self._analysisQueue.resume() # printing done, put those cpu cycles to good use
|
||||
elif self._comm is not None and state == self._comm.STATE_PRINTING:
|
||||
self._analysisQueue.pause() # do not analyse files while printing
|
||||
|
||||
self._setState(state)
|
||||
|
||||
def mcMessage(self, message):
|
||||
"""
|
||||
Callback method for the comm object, called upon message exchanges via serial.
|
||||
Stores the message in the message buffer, truncates buffer to the last 300 lines.
|
||||
"""
|
||||
self._addMessage(message)
|
||||
|
||||
def mcProgress(self):
|
||||
"""
|
||||
Callback method for the comm object, called upon any change in progress of the printjob.
|
||||
Triggers storage of new values for printTime, printTimeLeft and the current progress.
|
||||
"""
|
||||
|
||||
self._setProgressData(self._comm.getPrintProgress(), self._comm.getPrintFilepos(), self._comm.getPrintTime(), self._comm.getPrintTimeRemainingEstimate())
|
||||
|
||||
def mcZChange(self, newZ):
|
||||
"""
|
||||
Callback method for the comm object, called upon change of the z-layer.
|
||||
"""
|
||||
oldZ = self._currentZ
|
||||
if newZ != oldZ:
|
||||
# we have to react to all z-changes, even those that might "go backward" due to a slicer's retraction or
|
||||
# anti-backlash-routines. Event subscribes should individually take care to filter out "wrong" z-changes
|
||||
eventManager().fire(Events.Z_CHANGE, {"new": newZ, "old": oldZ})
|
||||
|
||||
self._setCurrentZ(newZ)
|
||||
|
||||
def mcSdStateChange(self, sdReady):
|
||||
self._stateMonitor.setState({"text": self.getStateString(), "flags": self._getStateFlags()})
|
||||
|
||||
def mcSdFiles(self, files):
|
||||
eventManager().fire(Events.UPDATED_FILES, {"type": "gcode"})
|
||||
self._sdFilelistAvailable.set()
|
||||
|
||||
def mcFileSelected(self, filename, filesize, sd):
|
||||
self._setJobData(filename, filesize, sd)
|
||||
self._stateMonitor.setState({"text": self.getStateString(), "flags": self._getStateFlags()})
|
||||
|
||||
if self._printAfterSelect:
|
||||
self.startPrint()
|
||||
|
||||
def mcPrintjobDone(self):
|
||||
self._setProgressData(1.0, self._selectedFile["filesize"], self._comm.getPrintTime(), 0)
|
||||
self._stateMonitor.setState({"text": self.getStateString(), "flags": self._getStateFlags()})
|
||||
|
||||
def mcFileTransferStarted(self, filename, filesize):
|
||||
self._sdStreaming = True
|
||||
|
||||
self._setJobData(filename, filesize, True)
|
||||
self._setProgressData(0.0, 0, 0, None)
|
||||
self._stateMonitor.setState({"text": self.getStateString(), "flags": self._getStateFlags()})
|
||||
|
||||
def mcFileTransferDone(self, filename):
|
||||
self._sdStreaming = False
|
||||
|
||||
if self._streamingFinishedCallback is not None:
|
||||
# in case of SD files, both filename and absolutePath are the same, so we set the (remote) filename for
|
||||
# both parameters
|
||||
self._streamingFinishedCallback(filename, filename, FileDestinations.SDCARD)
|
||||
|
||||
self._setCurrentZ(None)
|
||||
self._setJobData(None, None, None)
|
||||
self._setProgressData(None, None, None, None)
|
||||
self._stateMonitor.setState({"text": self.getStateString(), "flags": self._getStateFlags()})
|
||||
|
||||
def mcReceivedRegisteredMessage(self, command, output):
|
||||
self._sendFeedbackCommandOutput(command, output)
|
||||
|
||||
#~~ sd file handling
|
||||
|
||||
def getSdFiles(self):
|
||||
if self._comm is None or not self._comm.isSdReady():
|
||||
if not self._protocol.is_sd_ready():
|
||||
return []
|
||||
return self._comm.getSdFiles()
|
||||
return self._protocol.get_sd_files()
|
||||
|
||||
def addSdFile(self, filename, absolutePath, streamingFinishedCallback):
|
||||
if not self._comm or self._comm.isBusy() or not self._comm.isSdReady():
|
||||
self._logger.error("No connection to printer or printer is busy")
|
||||
if self._protocol.is_busy() or not self._protocol.is_sd_ready():
|
||||
logging.error("No connection to printer or printer is busy")
|
||||
return
|
||||
|
||||
self._streamingFinishedCallback = streamingFinishedCallback
|
||||
|
||||
self.refreshSdFiles(blocking=True)
|
||||
existingSdFiles = map(lambda x: x[0], self._comm.getSdFiles())
|
||||
existingSdFiles = map(lambda x: x[0], self._protocol.get_sd_files())
|
||||
|
||||
remoteName = util.getDosFilename(filename, existingSdFiles)
|
||||
self._comm.startFileTransfer(absolutePath, filename, remoteName)
|
||||
self._sdRemoteName = util.getDosFilename(filename, existingSdFiles)
|
||||
self._protocol.add_sd_file(absolutePath, filename, self._sdRemoteName)
|
||||
|
||||
return remoteName
|
||||
return self._sdRemoteName
|
||||
|
||||
def deleteSdFile(self, filename):
|
||||
if not self._comm or not self._comm.isSdReady():
|
||||
if not self._protocol.is_sd_ready():
|
||||
return
|
||||
self._comm.deleteSdFile(filename)
|
||||
self._protocol.remove_sd_file(filename)
|
||||
|
||||
def initSdCard(self):
|
||||
if not self._comm or self._comm.isSdReady():
|
||||
return
|
||||
self._comm.initSdCard()
|
||||
self._protocol.init_sd()
|
||||
|
||||
def releaseSdCard(self):
|
||||
if not self._comm or not self._comm.isSdReady():
|
||||
if not self._protocol.is_sd_ready() or self._protocol.is_busy():
|
||||
return
|
||||
self._comm.releaseSdCard()
|
||||
self._protocol.release_sd()
|
||||
|
||||
def refreshSdFiles(self, blocking=False):
|
||||
"""
|
||||
Refreshs the list of file stored on the SD card attached to printer (if available and printer communication
|
||||
available). Optional blocking parameter allows making the method block (max 10s) until the file list has been
|
||||
received (and can be accessed via self._comm.getSdFiles()). Defaults to a asynchronous operation.
|
||||
received (and can be accessed via self._protocol.get_sd_files()). Defaults to a asynchronous operation.
|
||||
"""
|
||||
if not self._comm or not self._comm.isSdReady():
|
||||
if not self._protocol.is_sd_ready():
|
||||
return
|
||||
self._sdFilelistAvailable.clear()
|
||||
self._comm.refreshSdFiles()
|
||||
self._protocol.refresh_sd_files()
|
||||
if blocking:
|
||||
self._sdFilelistAvailable.wait(10000)
|
||||
|
||||
@@ -618,10 +759,7 @@ class Printer():
|
||||
"""
|
||||
Returns a human readable string corresponding to the current communication state.
|
||||
"""
|
||||
if self._comm is None:
|
||||
return "Offline"
|
||||
else:
|
||||
return self._comm.getStateString()
|
||||
return self._state
|
||||
|
||||
def getCurrentData(self):
|
||||
return self._stateMonitor.getCurrentData()
|
||||
@@ -631,26 +769,13 @@ class Printer():
|
||||
return currentData["job"]
|
||||
|
||||
def getCurrentTemperatures(self):
|
||||
if self._comm is not None:
|
||||
tempOffset, bedTempOffset = self._comm.getOffsets()
|
||||
else:
|
||||
tempOffset = {}
|
||||
bedTempOffset = None
|
||||
temperatures = self._protocol.get_current_temperatures()
|
||||
offsets = self._protocol.get_temperature_offsets()
|
||||
|
||||
result = {}
|
||||
if self._temp is not None:
|
||||
for tool in self._temp.keys():
|
||||
result["tool%d" % tool] = {
|
||||
"actual": self._temp[tool][0],
|
||||
"target": self._temp[tool][1],
|
||||
"offset": tempOffset[tool] if tool in tempOffset.keys() and tempOffset[tool] is not None else 0
|
||||
}
|
||||
if self._bedTemp is not None:
|
||||
result["bed"] = {
|
||||
"actual": self._bedTemp[0],
|
||||
"target": self._bedTemp[1],
|
||||
"offset": bedTempOffset
|
||||
}
|
||||
result.update(temperatures)
|
||||
for key, tool in result:
|
||||
tool["offset"] = offsets[key] if key in offsets and offsets[key] is not None else 0
|
||||
|
||||
return result
|
||||
|
||||
@@ -658,36 +783,34 @@ class Printer():
|
||||
return self._temps
|
||||
|
||||
def getCurrentConnection(self):
|
||||
if self._comm is None:
|
||||
return "Closed", None, None, None
|
||||
|
||||
port, baudrate = self._comm.getConnection()
|
||||
printer_profile = self._printerProfileManager.get_current_or_default()
|
||||
return self._comm.getStateString(), port, baudrate, printer_profile
|
||||
opt = self._protocol.get_current_connection()
|
||||
if "port" in opt.keys() and "baudrate" in opt.keys():
|
||||
return self._protocol.get_state(), opt["port"], opt["baudrate"], self._printerProfileManager.get_current_or_default()
|
||||
return self._protocol.get_state(), None, None, None
|
||||
|
||||
def isClosedOrError(self):
|
||||
return self._comm is None or self._comm.isClosedOrError()
|
||||
return self._protocol.get_state() == ProtocolState.OFFLINE or self._protocol == ProtocolState.ERROR
|
||||
|
||||
def isOperational(self):
|
||||
return self._comm is not None and self._comm.isOperational()
|
||||
return not self.isClosedOrError()
|
||||
|
||||
def isPrinting(self):
|
||||
return self._comm is not None and self._comm.isPrinting()
|
||||
return self._protocol.get_state() == ProtocolState.PRINTING
|
||||
|
||||
def isPaused(self):
|
||||
return self._comm is not None and self._comm.isPaused()
|
||||
return self._protocol.get_state() == ProtocolState.PAUSED
|
||||
|
||||
def isError(self):
|
||||
return self._comm is not None and self._comm.isError()
|
||||
return self._protocol.get_state() == ProtocolState.ERROR
|
||||
|
||||
def isReady(self):
|
||||
return self.isOperational() and not self._comm.isStreaming()
|
||||
return self.isOperational() and not self._protocol.is_streaming()
|
||||
|
||||
def isSdReady(self):
|
||||
if not settings().getBoolean(["feature", "sdSupport"]) or self._comm is None:
|
||||
if not settings().getBoolean(["feature", "sdSupport"]):
|
||||
return False
|
||||
else:
|
||||
return self._comm.isSdReady()
|
||||
return self._protocol.is_sd_ready()
|
||||
|
||||
class StateMonitor(object):
|
||||
def __init__(self, ratelimit, updateCallback, addTemperatureCallback, addLogCallback, addMessageCallback):
|
||||
@@ -778,3 +901,60 @@ class StateMonitor(object):
|
||||
"offsets": self._offsets
|
||||
}
|
||||
|
||||
|
||||
class TimeEstimationHelper(object):
|
||||
|
||||
STABLE_THRESHOLD = 0.1
|
||||
STABLE_COUNTDOWN = 250
|
||||
STABLE_ROLLING_WINDOW = 250
|
||||
|
||||
def __init__(self):
|
||||
import collections
|
||||
self._distances = collections.deque([], self.__class__.STABLE_ROLLING_WINDOW)
|
||||
self._totals = collections.deque([], self.__class__.STABLE_ROLLING_WINDOW)
|
||||
self._sum_total = 0
|
||||
self._count = 0
|
||||
self._stable_counter = None
|
||||
|
||||
def is_stable(self):
|
||||
return self._stable_counter is not None and self._stable_counter >= self.__class__.STABLE_COUNTDOWN
|
||||
|
||||
def update(self, newEstimate):
|
||||
old_average_total = self.average_total
|
||||
|
||||
self._sum_total += newEstimate
|
||||
self._totals.append(newEstimate)
|
||||
self._count += 1
|
||||
|
||||
if old_average_total:
|
||||
self._distances.append(abs(self.average_total - old_average_total))
|
||||
|
||||
if -1.0 * self.__class__.STABLE_THRESHOLD < self.average_distance < self.__class__.STABLE_THRESHOLD:
|
||||
if self._stable_counter is None:
|
||||
self._stable_counter = 0
|
||||
else:
|
||||
self._stable_counter += 1
|
||||
else:
|
||||
self._stable_counter = None
|
||||
|
||||
@property
|
||||
def average_total(self):
|
||||
if not self._count:
|
||||
return None
|
||||
else:
|
||||
return self._sum_total / self._count
|
||||
|
||||
@property
|
||||
def average_total_rolling(self):
|
||||
if not self._count or self._count < self.__class__.STABLE_ROLLING_WINDOW:
|
||||
return None
|
||||
else:
|
||||
return sum(self._totals) / len(self._totals)
|
||||
|
||||
@property
|
||||
def average_distance(self):
|
||||
if not self._count or self._count < self.__class__.STABLE_ROLLING_WINDOW + 1:
|
||||
return None
|
||||
else:
|
||||
return sum(self._distances) / len(self._distances)
|
||||
|
||||
@@ -348,7 +348,7 @@ class Server():
|
||||
printer_profile = printerProfileManager.get_default()
|
||||
connectionOptions = getConnectionOptions()
|
||||
if port in connectionOptions["ports"]:
|
||||
printer.connect(port=port, baudrate=baudrate, profile=printer_profile["id"] if "id" in printer_profile else "_default")
|
||||
printer.connect(transport_option_overrides=dict(port=port, baudrate=baudrate), profile=printer_profile["id"] if "id" in printer_profile else "_default")
|
||||
|
||||
# start up watchdogs
|
||||
observer = Observer()
|
||||
@@ -438,7 +438,7 @@ class Server():
|
||||
}
|
||||
},
|
||||
"loggers": {
|
||||
"SERIAL": {
|
||||
"TRANSPORT": {
|
||||
"level": "CRITICAL",
|
||||
"handlers": ["serialFile"],
|
||||
"propagate": False
|
||||
@@ -470,8 +470,8 @@ class Server():
|
||||
|
||||
if settings().getBoolean(["serial", "log"]):
|
||||
# enable debug logging to serial.log
|
||||
logging.getLogger("SERIAL").setLevel(logging.DEBUG)
|
||||
logging.getLogger("SERIAL").debug("Enabling serial logging")
|
||||
logging.getLogger("TRANSPORT").setLevel(logging.DEBUG)
|
||||
logging.getLogger("TRANSPORT").debug("Enabling transport logging")
|
||||
|
||||
if __name__ == "__main__":
|
||||
server = Server()
|
||||
|
||||
@@ -32,7 +32,7 @@ def connectionState():
|
||||
@restricted_access
|
||||
def connectionCommand():
|
||||
valid_commands = {
|
||||
"connect": ["autoconnect"],
|
||||
"connect": [],
|
||||
"disconnect": []
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ def connectionCommand():
|
||||
if "autoconnect" in data.keys():
|
||||
settings().setBoolean(["serial", "autoconnect"], data["autoconnect"])
|
||||
settings().save()
|
||||
printer.connect(port=port, baudrate=baudrate, profile=printerProfile)
|
||||
printer.connect(transport_option_overrides=dict(port=port, baudrate=baudrate), profile=printerProfile)
|
||||
elif command == "disconnect":
|
||||
printer.disconnect()
|
||||
|
||||
|
||||
@@ -89,9 +89,9 @@ def _getFileList(origin, filter=None):
|
||||
failure = 0
|
||||
last = None
|
||||
for entry in history:
|
||||
success += 1 if entry["success"] else 0
|
||||
failure += 1 if not entry["success"] else 0
|
||||
if not last or entry["timestamp"] > last["timestamp"]:
|
||||
success += 1 if "success" in entry and entry["success"] else 0
|
||||
failure += 1 if "success" in entry and not entry["success"] else 0
|
||||
if not last or ("timestamp" in entry and "timestamp" in last and entry["timestamp"] > last["timestamp"]):
|
||||
last = entry
|
||||
if last:
|
||||
prints = dict(
|
||||
@@ -99,10 +99,11 @@ def _getFileList(origin, filter=None):
|
||||
failure=failure,
|
||||
last=dict(
|
||||
success=last["success"],
|
||||
date=last["timestamp"],
|
||||
printTime=last["printTime"]
|
||||
date=last["timestamp"]
|
||||
)
|
||||
)
|
||||
if "printTime" in last:
|
||||
prints["last"]["printTime"] = last["printTime"]
|
||||
file["prints"] = prints
|
||||
|
||||
file.update({
|
||||
@@ -287,13 +288,11 @@ def gcodeFileCommand(filename, target):
|
||||
return make_response("Printer is not operational, cannot directly start printing", 409)
|
||||
printAfterLoading = True
|
||||
|
||||
sd = False
|
||||
if target == FileDestinations.SDCARD:
|
||||
filenameToSelect = filename
|
||||
sd = True
|
||||
else:
|
||||
filenameToSelect = fileManager.get_absolute_path(target, filename)
|
||||
printer.selectFile(filenameToSelect, sd, printAfterLoading)
|
||||
printer.selectFile(filenameToSelect, target, printAfterLoading)
|
||||
|
||||
elif command == "slice":
|
||||
if "slicer" in data.keys():
|
||||
|
||||
@@ -146,7 +146,7 @@ def _validate_profile(profile):
|
||||
converted_offsets = []
|
||||
for offset in profile["extruder"]["offsets"]:
|
||||
try:
|
||||
converted_offsets.append((float(offset[0]), float(offset[0])))
|
||||
converted_offsets.append((float(offset[0]), float(offset[1])))
|
||||
except:
|
||||
return False
|
||||
profile["extruder"]["offsets"] = converted_offsets
|
||||
|
||||
@@ -35,6 +35,10 @@ def getSettings():
|
||||
"key": s.get(["api", "key"]) if admin_permission.can() else "n/a",
|
||||
"allowCrossOrigin": s.get(["api", "allowCrossOrigin"])
|
||||
},
|
||||
"appearance": {
|
||||
"name": s.get(["appearance", "name"]),
|
||||
"color": s.get(["appearance", "color"])
|
||||
},
|
||||
"printer": {
|
||||
"defaultExtrusionLength": s.getInt(["printerParameters", "defaultExtrusionLength"])
|
||||
},
|
||||
@@ -120,6 +124,10 @@ def setSettings():
|
||||
if "key" in data["api"].keys(): s.set(["api", "key"], data["api"]["key"], True)
|
||||
if "allowCrossOrigin" in data["api"].keys(): s.setBoolean(["api", "allowCrossOrigin"], data["api"]["allowCrossOrigin"])
|
||||
|
||||
if "appearance" in data.keys():
|
||||
if "name" in data["appearance"].keys(): s.set(["appearance", "name"], data["appearance"]["name"])
|
||||
if "color" in data["appearance"].keys(): s.set(["appearance", "color"], data["appearance"]["color"])
|
||||
|
||||
if "printer" in data.keys():
|
||||
if "defaultExtrusionLength" in data["printer"]: s.setInt(["printerParameters", "defaultExtrusionLength"], data["printer"]["defaultExtrusionLength"])
|
||||
|
||||
@@ -156,12 +164,12 @@ def setSettings():
|
||||
if "log" in data["serial"].keys(): s.setBoolean(["serial", "log"], data["serial"]["log"])
|
||||
if oldLog and not s.getBoolean(["serial", "log"]):
|
||||
# disable debug logging to serial.log
|
||||
logging.getLogger("SERIAL").debug("Disabling serial logging")
|
||||
logging.getLogger("SERIAL").setLevel(logging.CRITICAL)
|
||||
logging.getLogger("TRANSPORT").debug("Disabling transport logging")
|
||||
logging.getLogger("TRANSPORT").setLevel(logging.CRITICAL)
|
||||
elif not oldLog and s.getBoolean(["serial", "log"]):
|
||||
# enable debug logging to serial.log
|
||||
logging.getLogger("SERIAL").setLevel(logging.DEBUG)
|
||||
logging.getLogger("SERIAL").debug("Enabling serial logging")
|
||||
logging.getLogger("TRANSPORT").setLevel(logging.DEBUG)
|
||||
logging.getLogger("TRANSPORT").debug("Enabling transport logging")
|
||||
|
||||
if "folder" in data.keys():
|
||||
if "uploads" in data["folder"].keys(): s.setBaseFolder("uploads", data["folder"]["uploads"])
|
||||
|
||||
@@ -194,7 +194,8 @@ class UploadStorageFallbackHandler(tornado.web.RequestHandler):
|
||||
end_of_header = None
|
||||
if delimiter_loc != -1:
|
||||
# found the delimiter in the currently available data
|
||||
data, self._buffer = data[0:delimiter_loc], data[delimiter_loc:]
|
||||
delimiter_data_end = 0 if delimiter_loc == 0 else delimiter_loc - 2
|
||||
data, self._buffer = data[0:delimiter_data_end], data[delimiter_loc:]
|
||||
end_of_header = self._buffer.find("\r\n\r\n")
|
||||
else:
|
||||
# make sure any boundary (with single or double ==) contained at the end of chunk does not get
|
||||
@@ -339,7 +340,7 @@ class UploadStorageFallbackHandler(tornado.web.RequestHandler):
|
||||
if "content_type" in part and part["content_type"] is not None:
|
||||
self._new_body += b"Content-Type: %s\r\n" % part["content_type"]
|
||||
self._new_body += b"\r\n"
|
||||
self._new_body += value
|
||||
self._new_body += value + b"\r\n"
|
||||
self._new_body += b"--%s--\r\n" % self._multipart_boundary
|
||||
|
||||
def _handle_method(self, *args, **kwargs):
|
||||
|
||||
+46
-16
@@ -23,6 +23,30 @@ def settings(init=False, configfile=None, basedir=None):
|
||||
return instance
|
||||
|
||||
default_settings = {
|
||||
"communication": {
|
||||
"protocol": "reprap",
|
||||
"protocolOptions": {
|
||||
"buffer": 63,
|
||||
"temperature": 5,
|
||||
"sdStatus": 1,
|
||||
"waitForStart": False,
|
||||
"forceChecksum": True,
|
||||
"sdAlwaysAvailable": False
|
||||
},
|
||||
"transport": "serial",
|
||||
"transportOptions": {
|
||||
"port": None,
|
||||
"baudrate": None,
|
||||
"timeout": {
|
||||
"read": 5,
|
||||
"write": 0.5
|
||||
},
|
||||
"additionalPorts": []
|
||||
},
|
||||
"autoconnect": False,
|
||||
"log": False
|
||||
},
|
||||
# TODO Remove, not used by the new communication layer but apparently still by the layers above it!
|
||||
"serial": {
|
||||
"port": None,
|
||||
"baudrate": None,
|
||||
@@ -79,12 +103,12 @@ default_settings = {
|
||||
},
|
||||
"feature": {
|
||||
"temperatureGraph": True,
|
||||
"waitForStartOnConnect": False,
|
||||
"alwaysSendChecksum": False,
|
||||
"sdSupport": True,
|
||||
"sdAlwaysAvailable": False,
|
||||
"swallowOkAfterResend": True,
|
||||
"repetierTargetTemp": False
|
||||
"waitForStartOnConnect": False, # TODO move to protocol options or reprap protocol
|
||||
"alwaysSendChecksum": True, # TODO move to protocol options
|
||||
"sdSupport": True, # TODO remove (can be always on)
|
||||
"sdAlwaysAvailable": False, # TODO move to protocol options
|
||||
"swallowOkAfterResend": True, # TODO remove (must always be done!)
|
||||
"repetierTargetTemp": False # TODO remove (built into repetier protocol implementation)
|
||||
},
|
||||
"folder": {
|
||||
"uploads": None,
|
||||
@@ -111,6 +135,10 @@ default_settings = {
|
||||
"pauseTriggers": [],
|
||||
"defaultExtrusionLength": 5
|
||||
},
|
||||
"appearance": {
|
||||
"name": "",
|
||||
"color": "default"
|
||||
},
|
||||
"controls": [],
|
||||
"system": {
|
||||
"actions": []
|
||||
@@ -158,10 +186,21 @@ default_settings = {
|
||||
"okWithLinenumber": False,
|
||||
"numExtruders": 1,
|
||||
"includeCurrentToolInTemps": True,
|
||||
"movementSpeed": {
|
||||
"x": 6000,
|
||||
"y": 6000,
|
||||
"z": 200,
|
||||
"e": 300
|
||||
},
|
||||
"hasBed": True,
|
||||
"repetierStyleTargetTemperature": False,
|
||||
"smoothieTemperatureReporting": False,
|
||||
"extendedSdFileList": False
|
||||
"extendedSdFileList": False,
|
||||
"throttle": 0.01,
|
||||
"waitOnLongMoves": False,
|
||||
"rxBuffer": 64,
|
||||
"txBuffer": 40,
|
||||
"commandBuffer": 4
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -281,15 +320,6 @@ class Settings(object):
|
||||
|
||||
dirty = True
|
||||
|
||||
if "appearance" in self._config:
|
||||
if "name" in self._config["appearance"]:
|
||||
default_profile["name"] = self._config["appearance"]["name"]
|
||||
if "color" in self._config["appearance"]:
|
||||
default_profile["color"] = self._config["appearance"]["color"]
|
||||
|
||||
del self._config["appearance"]
|
||||
dirty = True
|
||||
|
||||
if dirty:
|
||||
if not "printerProfiles" in self._config:
|
||||
self._config["printerProfiles"] = dict()
|
||||
|
||||
@@ -136,6 +136,8 @@ class SlicingManager(object):
|
||||
|
||||
if not ok:
|
||||
callback_kwargs.update(dict(_error=result))
|
||||
elif result is not None and isinstance(result, dict) and "analysis" in result:
|
||||
callback_kwargs.update(dict(_analysis=result["analysis"]))
|
||||
except SlicingCancelled:
|
||||
callback_kwargs.update(dict(_cancelled=True))
|
||||
finally:
|
||||
|
||||
@@ -1 +1 @@
|
||||
.btn{display:inline-block;*display:inline;*zoom:1;padding:4px 12px;margin-bottom:0;font-size:14px;line-height:20px;text-align:center;vertical-align:middle;cursor:pointer;color:#333;text-shadow:0 1px 1px rgba(255,255,255,.75);background-color:#f5f5f5;background-image:-moz-linear-gradient(top,#fff,#e6e6e6);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#e6e6e6));background-image:-webkit-linear-gradient(top,#fff,#e6e6e6);background-image:-o-linear-gradient(top,#fff,#e6e6e6);background-image:linear-gradient(to bottom,#fff,#e6e6e6);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffe6e6e6', GradientType=0);border-color:#e6e6e6 #e6e6e6 #bfbfbf;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#e6e6e6;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);border:1px solid #ccc;*border:0;border-bottom-color:#b3b3b3;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;*margin-left:.3em;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05)}.btn:hover,.btn:focus,.btn:active,.btn.active,.btn.disabled,.btn[disabled]{color:#333;background-color:#e6e6e6;*background-color:#d9d9d9}.btn:active,.btn.active{background-color:#ccc \9}.btn:first-child{*margin-left:0}.btn:hover,.btn:focus{color:#333;text-decoration:none;background-position:0 -15px;-webkit-transition:background-position .1s linear;-moz-transition:background-position .1s linear;-o-transition:background-position .1s linear;transition:background-position .1s linear}.btn:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}.btn.active,.btn:active{background-image:none;outline:0;-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05)}.btn.disabled,.btn[disabled]{cursor:default;background-image:none;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.btn-large{padding:11px 19px;font-size:17.5px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.btn-large [class^=icon-],.btn-large [class*=" icon-"]{margin-top:4px}.btn-small{padding:2px 10px;font-size:11.9px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-small [class^=icon-],.btn-small [class*=" icon-"]{margin-top:0}.btn-mini [class^=icon-],.btn-mini [class*=" icon-"]{margin-top:-1px}.btn-mini{padding:0 6px;font-size:10.5px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-block{display:block;width:100%;padding-left:0;padding-right:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.btn-block+.btn-block{margin-top:5px}input[type=submit].btn-block,input[type=reset].btn-block,input[type=button].btn-block{width:100%}.btn-primary.active,.btn-warning.active,.btn-danger.active,.btn-success.active,.btn-info.active,.btn-inverse.active{color:rgba(255,255,255,.75)}.btn-primary{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#006dcc;background-image:-moz-linear-gradient(top,#08c,#04c);background-image:-webkit-gradient(linear,0 0,0 100%,from(#08c),to(#04c));background-image:-webkit-linear-gradient(top,#08c,#04c);background-image:-o-linear-gradient(top,#08c,#04c);background-image:linear-gradient(to bottom,#08c,#04c);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc', endColorstr='#ff0044cc', GradientType=0);border-color:#04c #04c #002a80;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#04c;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-primary:hover,.btn-primary:focus,.btn-primary:active,.btn-primary.active,.btn-primary.disabled,.btn-primary[disabled]{color:#fff;background-color:#04c;*background-color:#003bb3}.btn-primary:active,.btn-primary.active{background-color:#039 \9}.btn-warning{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#faa732;background-image:-moz-linear-gradient(top,#fbb450,#f89406);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fbb450),to(#f89406));background-image:-webkit-linear-gradient(top,#fbb450,#f89406);background-image:-o-linear-gradient(top,#fbb450,#f89406);background-image:linear-gradient(to bottom,#fbb450,#f89406);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffbb450', endColorstr='#fff89406', GradientType=0);border-color:#f89406 #f89406 #ad6704;border-color:rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25);*background-color:#f89406;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-warning:hover,.btn-warning:focus,.btn-warning:active,.btn-warning.activeLine truncated
|
||||
.btn{display:inline-block;*display:inline;*zoom:1;padding:4px 12px;margin-bottom:0;font-size:14px;line-height:20px;text-align:center;vertical-align:middle;cursor:pointer;color:#333;text-shadow:0 1px 1px rgba(255,255,255,0.75);background-color:#f5f5f5;background-image:-moz-linear-gradient(top,#fff,#e6e6e6);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#e6e6e6));background-image:-webkit-linear-gradient(top,#fff,#e6e6e6);background-image:-o-linear-gradient(top,#fff,#e6e6e6);background-image:linear-gradient(to bottom,#fff,#e6e6e6);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff',endColorstr='#ffe6e6e6',GradientType=0);border-color:#e6e6e6 #e6e6e6 #bfbfbf;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);*background-color:#e6e6e6;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false);border:1px solid #ccc;*border:0;border-bottom-color:#b3b3b3;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;*margin-left:.3em;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05)}.btn:hover,.btn:focus,.btn:active,.btn.active,.btn.disabled,.btn[disabled]{color:#333;background-color:#e6e6e6;*background-color:#d9d9d9}.btn:active,.btn.active{background-color:#ccc \9}.btn:first-child{*margin-left:0}.btn:hover,.btn:focus{color:#333;text-decoration:none;background-position:0 -15px;-webkit-transition:background-position .1s linear;-moz-transition:background-position .1s linear;-o-transition:background-position .1s linear;transition:background-position .1s linear}.btn:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}.btn.active,.btn:active{background-image:none;outline:0;-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 2px 4px rgba(0,0,0,.15),0 1px 2px rgba(0,0,0,.05)}.btn.disabled,.btn[disabled]{cursor:default;background-image:none;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.btn-large{padding:11px 19px;font-size:17.5px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.btn-large [class^="icon-"],.btn-large [class*=" icon-"]{margin-top:4px}.btn-small{padding:2px 10px;font-size:11.9px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-small [class^="icon-"],.btn-small [class*=" icon-"]{margin-top:0}.btn-mini [class^="icon-"],.btn-mini [class*=" icon-"]{margin-top:-1px}.btn-mini{padding:0 6px;font-size:10.5px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-block{display:block;width:100%;padding-left:0;padding-right:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.btn-block+.btn-block{margin-top:5px}input[type="submit"].btn-block,input[type="reset"].btn-block,input[type="button"].btn-block{width:100%}.btn-primary.active,.btn-warning.active,.btn-danger.active,.btn-success.active,.btn-info.active,.btn-inverse.active{color:rgba(255,255,255,0.75)}.btn-primary{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#006dcc;background-image:-moz-linear-gradient(top,#08c,#04c);background-image:-webkit-gradient(linear,0 0,0 100%,from(#08c),to(#04c));background-image:-webkit-linear-gradient(top,#08c,#04c);background-image:-o-linear-gradient(top,#08c,#04c);background-image:linear-gradient(to bottom,#08c,#04c);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc',endColorstr='#ff0044cc',GradientType=0);border-color:#04c #04c #002a80;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);*background-color:#04c;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false)}.btn-primary:hover,.btn-primary:focus,.btn-primary:active,.btn-primary.active,.btn-primary.disabled,.btn-primary[disabled]{color:#fff;background-color:#04c;*background-color:#003bb3}.btn-primary:active,.btn-primary.active{background-color:#039 \9}.btn-warning{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#faa732;background-image:-moz-linear-gradient(top,#fbb450,#f89406);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fbb450),to(#f89406));background-image:-webkit-linear-gradient(top,#fbb450,#f89406);background-image:-o-linear-gradient(top,#fbb450,#f89406);background-image:linear-gradient(to bottom,#fbb450,#f89406);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffbb450',endColorstr='#fff89406',GradientType=0);border-color:#f89406 #f89406 #ad6704;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);*background-color:#f89406;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false)}.btn-warning:hover,.btn-warning:focus,.btn-warning:aLine truncated
|
||||
@@ -342,6 +342,21 @@ function formatDuration(seconds) {
|
||||
return _.sprintf(gettext(/* L10N: duration format */ "%(hour)02d:%(minute)02d:%(second)02d"), {hour: h, minute: m, second: s});
|
||||
}
|
||||
|
||||
function formatFuzzyEstimation(seconds, base) {
|
||||
if (!seconds) return "-";
|
||||
if (seconds < 0) return "-";
|
||||
|
||||
var m;
|
||||
if (base != undefined) {
|
||||
m = moment(base);
|
||||
} else {
|
||||
m = moment();
|
||||
}
|
||||
|
||||
m.add(seconds, "s");
|
||||
return m.fromNow(true);
|
||||
}
|
||||
|
||||
function formatDate(unixTimestamp) {
|
||||
if (!unixTimestamp) return "-";
|
||||
return moment.unix(unixTimestamp).format(gettext(/* L10N: Date format */ "YYYY-MM-DD HH:mm"));
|
||||
|
||||
@@ -1,33 +1,20 @@
|
||||
function AppearanceViewModel(settingsViewModel, printerStateViewModel) {
|
||||
var self = this;
|
||||
|
||||
self.settings = settingsViewModel;
|
||||
self.printerState = printerStateViewModel;
|
||||
|
||||
self.connected = ko.observable(false);
|
||||
|
||||
self.printerState.isErrorOrClosed.subscribe(function() {
|
||||
self.connected(!self.printerState.isErrorOrClosed());
|
||||
});
|
||||
self.name = settingsViewModel.appearance_name;
|
||||
self.color = settingsViewModel.appearance_color;
|
||||
|
||||
self.brand = ko.computed(function() {
|
||||
if (self.settings.printerProfiles.currentProfileData().name() && self.connected())
|
||||
return gettext("OctoPrint") + ": " + self.settings.printerProfiles.currentProfileData().name();
|
||||
if (self.name())
|
||||
return gettext("OctoPrint") + ": " + self.name();
|
||||
else
|
||||
return gettext("OctoPrint");
|
||||
});
|
||||
|
||||
self.title = ko.computed(function() {
|
||||
if (self.settings.printerProfiles.currentProfileData().name() && self.connected())
|
||||
return self.settings.printerProfiles.currentProfileData().name() + " [" + gettext("OctoPrint") + "]";
|
||||
if (self.name())
|
||||
return self.name() + " [" + gettext("OctoPrint") + "]";
|
||||
else
|
||||
return gettext("OctoPrint");
|
||||
});
|
||||
|
||||
self.color = ko.computed(function() {
|
||||
if (self.settings.printerProfiles.currentProfileData().color() && self.connected())
|
||||
return self.settings.printerProfiles.currentProfileData().color();
|
||||
else
|
||||
return "default";
|
||||
});
|
||||
}
|
||||
@@ -62,6 +62,7 @@ function ConnectionViewModel(loginStateViewModel, settingsViewModel, printerProf
|
||||
var portPreference = response.options.portPreference;
|
||||
var baudratePreference = response.options.baudratePreference;
|
||||
var printerPreference = response.options.printerProfilePreference;
|
||||
var printerProfiles = response.options.printerProfiles;
|
||||
|
||||
self.portOptions(ports);
|
||||
self.baudrateOptions(baudrates);
|
||||
|
||||
@@ -114,7 +114,7 @@ function ControlViewModel(loginStateViewModel, settingsViewModel) {
|
||||
self.sendJogCommand = function(axis, multiplier, distance) {
|
||||
if (typeof distance === "undefined")
|
||||
distance = $('#jog_distance button.active').data('distance');
|
||||
if (self.settings.getPrinterInvertAxis(axis)) {
|
||||
if (self.settings.printerProfiles.currentProfileData() && self.settings.printerProfiles.currentProfileData()["axes"] && self.settings.printerProfiles.currentProfileData()["axes"][axis] && self.settings.printerProfiles.currentProfileData()["axes"][axis]["inverted"]()) {
|
||||
multiplier *= -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -215,7 +215,7 @@ function PrinterProfilesViewModel() {
|
||||
self.editorVolumeHeight(data.volume.height);
|
||||
self.editorVolumeFormFactor(data.volume.formFactor);
|
||||
|
||||
self.editorHeatedBed(data.volume.heatedBed);
|
||||
self.editorHeatedBed(data.heatedBed);
|
||||
|
||||
self.editorNozzleDiameter(data.extruder.nozzleDiameter);
|
||||
self.editorExtruders(data.extruder.count);
|
||||
@@ -301,7 +301,7 @@ function PrinterProfilesViewModel() {
|
||||
for (var i = 1; i < self.editorExtruders(); i++) {
|
||||
var offset = [0.0, 0.0];
|
||||
if (i < self.editorExtruderOffsets().length) {
|
||||
offset = self.editorExtruderOffsets()[i];
|
||||
offset = [parseFloat(self.editorExtruderOffsets()[i]["x"]()), parseFloat(self.editorExtruderOffsets()[i]["y"]())];
|
||||
}
|
||||
profile.extruder.offsets.push(offset);
|
||||
}
|
||||
|
||||
@@ -62,9 +62,15 @@ function PrinterStateViewModel(loginStateViewModel) {
|
||||
return formatDuration(self.printTime());
|
||||
});
|
||||
self.printTimeLeftString = ko.computed(function() {
|
||||
if (!self.printTimeLeft())
|
||||
return "-";
|
||||
return formatDuration(self.printTimeLeft());
|
||||
if (self.printTimeLeft() == undefined) {
|
||||
if (!self.printTime() || !(self.isPrinting() || self.isPaused())) {
|
||||
return "-";
|
||||
} else {
|
||||
return gettext("Calculating...");
|
||||
}
|
||||
} else {
|
||||
return formatFuzzyEstimation(self.printTimeLeft());
|
||||
}
|
||||
});
|
||||
self.progressString = ko.computed(function() {
|
||||
if (!self.progress())
|
||||
|
||||
@@ -9,6 +9,43 @@ function SettingsViewModel(loginStateViewModel, usersViewModel, printerProfilesV
|
||||
self.api_key = ko.observable(undefined);
|
||||
self.api_allowCrossOrigin = ko.observable(undefined);
|
||||
|
||||
self.appearance_name = ko.observable(undefined);
|
||||
self.appearance_color = ko.observable(undefined);
|
||||
|
||||
self.appearance_available_colors = ko.observable([
|
||||
{key: "default", name: gettext("default")},
|
||||
{key: "red", name: gettext("red")},
|
||||
{key: "orange", name: gettext("orange")},
|
||||
{key: "yellow", name: gettext("yellow")},
|
||||
{key: "green", name: gettext("green")},
|
||||
{key: "blue", name: gettext("blue")},
|
||||
{key: "violet", name: gettext("violet")},
|
||||
{key: "black", name: gettext("black")}
|
||||
]);
|
||||
|
||||
self.appearance_colorName = function(color) {
|
||||
switch (color) {
|
||||
case "red":
|
||||
return gettext("red");
|
||||
case "orange":
|
||||
return gettext("orange");
|
||||
case "yellow":
|
||||
return gettext("yellow");
|
||||
case "green":
|
||||
return gettext("green");
|
||||
case "blue":
|
||||
return gettext("blue");
|
||||
case "violet":
|
||||
return gettext("violet");
|
||||
case "black":
|
||||
return gettext("black");
|
||||
case "default":
|
||||
return gettext("default");
|
||||
default:
|
||||
return color;
|
||||
}
|
||||
};
|
||||
|
||||
self.printer_defaultExtrusionLength = ko.observable(undefined);
|
||||
|
||||
self.webcam_streamUrl = ko.observable(undefined);
|
||||
@@ -23,6 +60,7 @@ function SettingsViewModel(loginStateViewModel, usersViewModel, printerProfilesV
|
||||
self.feature_temperatureGraph = ko.observable(undefined);
|
||||
self.feature_waitForStart = ko.observable(undefined);
|
||||
self.feature_alwaysSendChecksum = ko.observable(undefined);
|
||||
self.feature_pingPong = ko.observable(undefined);
|
||||
self.feature_sdSupport = ko.observable(undefined);
|
||||
self.feature_sdAlwaysAvailable = ko.observable(undefined);
|
||||
self.feature_swallowOkAfterResend = ko.observable(undefined);
|
||||
@@ -101,6 +139,9 @@ function SettingsViewModel(loginStateViewModel, usersViewModel, printerProfilesV
|
||||
self.api_key(response.api.key);
|
||||
self.api_allowCrossOrigin(response.api.allowCrossOrigin);
|
||||
|
||||
self.appearance_name(response.appearance.name);
|
||||
self.appearance_color(response.appearance.color);
|
||||
|
||||
self.printer_defaultExtrusionLength(response.printer.defaultExtrusionLength);
|
||||
|
||||
self.webcam_streamUrl(response.webcam.streamUrl);
|
||||
@@ -158,6 +199,10 @@ function SettingsViewModel(loginStateViewModel, usersViewModel, printerProfilesV
|
||||
"key": self.api_key(),
|
||||
"allowCrossOrigin": self.api_allowCrossOrigin()
|
||||
},
|
||||
"appearance" : {
|
||||
"name": self.appearance_name(),
|
||||
"color": self.appearance_color()
|
||||
},
|
||||
"printer": {
|
||||
"defaultExtrusionLength": self.printer_defaultExtrusionLength()
|
||||
},
|
||||
|
||||
@@ -1 +1 @@
|
||||
window.BABEL_TO_LOAD_de = {"locale": "de", "domain": "messages", "plural_expr": "(n != 1)", "messages": {"": "Project-Id-Version: OctoPrint\nReport-Msgid-Bugs-To: i18n@octoprint.org\nPOT-Creation-Date: 2014-10-20 09:44+0200\nPO-Revision-Date: 2014-10-20 09:48+0100\nLast-Translator: Gina H\u00e4u\u00dfge <osd@foosel.net>\nLanguage-Team: German (http://www.transifex.com/projects/p/octoprint/language/de/)\nPlural-Forms: nplurals=2; plural=(n != 1)\nMIME-Version: 1.0\nContent-Type: text/plain; charset=utf-8\nContent-Transfer-Encoding: 8bit\nGenerated-By: Babel 1.3\n", "Print Time Left": "Verbleibende Druckdauer", "Proceed": "Fortfahren", "Timelapse Temp Folder": "Tempor\u00e4res Zeitrafferverzeichnis", "Title": "Titel", "Only show files stored locally": "Nur lokal abgelegte Dateien anzeigen", "yellow": "Gelb", "Action": "Aktion", "Passwords do not match": "Passw\u00f6rter nicht identisch", "Sort by name": "Nach Name sortieren", "Save connection settings": "Verbindungseinstellungen speichern", "Rendering timelapse": "Zeitraffer wird gerendert", "Temperature": "Temperatur", "Files": "Dateien", "Bed Size": "Bettdimensionen", "Resume": "Weiter", "Always assume SD card is present": "Immer davon ausgehen, dass eine SD-Karte vorhanden ist", "Load and Print": "Laden und Drucken", "Sending file to SD": "Sende Datei zu SD", "Number of Extruders": "Anzahl Extruder", "black": "Schwarz", "Last Printed": "Zuletzt gedruckt", "Sourcecode": "Quellcode", "Estimated layer height": "Gesch\u00e4tzte Schichth\u00f6he", "You are now logged out": "Du bist jetzt ausgeloggt", "Uploaded": "Hochgeladen", "Opening serial port": "\u00d6ffnet Serialport", "New timelapse %(movie_basename)s is done rendering.": "Neue Zeitrafferaufnahme %(movie_basename)s wurde fertig gerendert", "Invert control": "Invertieren", "Webcam": "Webcam", "Remember me": "Login merken", "Enable GCode Visualizer": "GCode Viewer aktivieren", "The server appears to be offline, at least I'm not getting any response from it. I'll try to reconnect automatically <strong>over the next couple of minutes</strong>, however you are welcome to try a manual reconnect anytime using the button below.": "Der Server scheint offline zu sein, zumindest kann ich mich nicht mit ihm verbinden. Ich werde <strong>\u00fcber die n\u00e4chsten Minuten</strong> versuchen, zu reconnecten, aber Du kannst mittels des folgenden Buttons auch jederzeit einen manuellen Reconnect ansto\u00dfen.", "Rendering failed": "Rendering fehlgeschlagen", "Upload Folder": "Uploadverzeichnis", "descending": "absteigend", "Only show files stored on SD": "Nur auf SD abgelegte Dateien anzeigen", "X": "X", "Add user": "Nutzer hinzuf\u00fcgen", "GCODE commands in layer": "GCODE Kommandos in Schicht", "Estimated print time": "Gesch\u00e4tzte Druckdauer", "Serial Connection": "Serielle Verbindung", "Control": "Kontrolle", "Password": "Passwort", "Also show next layer": "Auch n\u00e4chste Schicht anzeigen", "Print Time": "Druckdauer", "Slicer": "Slicer", "Sort by file size": "Nach Gr\u00f6\u00dfe sortieren", "Machine State": "Druckerstatus", "Slicing Profile": "Slicingprofil", "Pauses the print job": "Pausiert den Druckjob", "API": "API", "Printing from SD": "Drucke von SD", "Stream URL": "Stream-URL", "Terminal filters": "Terminalfilter", "Change password for user \"%(user)s\"": "Passwort\u00e4nderung f\u00fcr Nutzer \"%(user)s\"", "mm": "mm", "Enable Temperature Graph": "Temperaturgraph aktivieren", "Delete user": "Nutzer l\u00f6schen", "Confirm Password": "Passwort best\u00e4tigen", "Disconnect": "Trennen", "Slicing done": "Slicing abgeschlossen", "Initialize SD card": "SD-Karte initialisieren", "System": "System", "Send": "Senden", "State": "Status", "Version": "Version", "YYYY-MM-DD HH:mm": "DD.MM.YYYY HH:mm", "Attempt to reconnect": "Erneut verbinden", "Streaming done": "Streaming abgeschlossen", "violet": "Violett", "Print": "Drucken", "Layer count": "Schichtanzahl", "OctoPrint Settings": "OctoPrint Einstellungen", "Are you sure?": "Bist Du sicher?", "blue": "Blau", "Printer": "Drucker", "Tool": "Werkzeug", "Settings": "Einstellungen", "Path to FFMPEG": "Pfad zu FFMPEG", "Upload to SD": "Upload (SD)", "The command \"%(command)s\" could not be executed.": "Das Kommando \"%(command)s\" konnte nicht ausgef\u00fchrt werden.", "Printed": "Gedruckt", "Wait for <code>start</code> on connect": "Bei der Verbindung auf <code>start</code> warten", "Layer number": "Schichtnummer", "Sync with job progress": "Job mit Fortschritt synchronisieren", "Circular": "Rund", "Total filament used": "Gesamtmenge genutzten Filaments", "red": "Rot", "Save as default": "Als Standard speichern", "Slicing ...": "Slice ...", "Last Print Time": "Letzte Druckdauer", "Target": "Soll", "Streaming ...": "Streame ...", "Default extrusion length": "Standard Extrusionsl\u00e4nge", "Logout successful": "Logout erfolgreich", "Now rendering timelapse %(movie_basename)s": "Rendere Zeitrafferaufnahme %(movie_basename)s", "Documentation": "Dokumentation", "%(hLine truncated
|
||||
window.BABEL_TO_LOAD_de = {"locale": "de", "domain": "messages", "plural_expr": "(n != 1)", "messages": {"": "Project-Id-Version: OctoPrint\nReport-Msgid-Bugs-To: i18n@octoprint.org\nPOT-Creation-Date: 2014-12-18 14:45+0100\nPO-Revision-Date: 2014-12-18 14:11+0000\nLast-Translator: Gina H\u00e4u\u00dfge <gina@foosel.net>\nLanguage-Team: German (http://www.transifex.com/projects/p/octoprint/language/de/)\nPlural-Forms: nplurals=2; plural=(n != 1)\nMIME-Version: 1.0\nContent-Type: text/plain; charset=utf-8\nContent-Transfer-Encoding: 8bit\nGenerated-By: Babel 1.3\n", "Print Time Left": "Verbleibende Druckdauer", "sec": "Sek", "Proceed": "Fortfahren", "Timelapse Temp Folder": "Tempor\u00e4res Zeitrafferverzeichnis", "Support <code>TargetExtr%%n</code>/<code>TargetBed</code> target temperature format": "<code>TargetExtr%%n</code>/<code>TargetBed</code> Zieltemperaturformat unterst\u00fctzen", "Upload Folder": "Uploadverzeichnis", "Only show files stored locally": "Nur lokal abgelegte Dateien anzeigen", "Add Printer Profile": "Druckerprofil hinzuf\u00fcgen", "yellow": "Gelb", "Save": "Speichern", "Action": "Aktion", "Passwords do not match": "Passw\u00f6rter nicht identisch", "Sort by name": "Nach Name sortieren", "Save connection settings": "Verbindungseinstellungen speichern", "Rendering timelapse": "Zeitraffer wird gerendert", "Color": "Farbe", "Temperature": "Temperatur", "Files": "Dateien", "Resume": "Weiter", "Always assume SD card is present": "Immer davon ausgehen, dass eine SD-Karte vorhanden ist", "Load and Print": "Laden und Drucken", "Sending file to SD": "Sende Datei zu SD", "Number of Extruders": "Anzahl Extruder", "black": "Schwarz", "Last Printed": "Zuletzt gedruckt", "Sourcecode": "Quellcode", "Estimated layer height": "Gesch\u00e4tzte Schichth\u00f6he", "You are now logged out": "Du bist jetzt ausgeloggt", "Uploaded": "Hochgeladen", "Form Factor": "Formfaktor", "Opening serial port": "\u00d6ffnet Serialport", "New timelapse %(movie_basename)s is done rendering.": "Neue Zeitrafferaufnahme %(movie_basename)s wurde fertig gerendert", "Invert control": "Invertieren", "Webcam": "Webcam", "Select for printing": "Zum Drucken ausw\u00e4hlen", "Allow <a href=\"%(url)s\">Cross Origin Resource Sharing (CORS)</a>": "<a href=\"%(url)s\">Cross Origin Resource Sharing (CORS)</a> erlauben", "Remember me": "Login merken", "Enable GCode Visualizer": "GCode Viewer aktivieren", "The server appears to be offline, at least I'm not getting any response from it. I'll try to reconnect automatically <strong>over the next couple of minutes</strong>, however you are welcome to try a manual reconnect anytime using the button below.": "Der Server scheint offline zu sein, zumindest kann ich mich nicht mit ihm verbinden. Ich werde <strong>\u00fcber die n\u00e4chsten Minuten</strong> versuchen, mich erneut zu verbinden, aber Du kannst mittels des folgenden Buttons auch jederzeit einen manuellen Reconnect ansto\u00dfen.", "Rendering failed": "Rendering fehlgeschlagen", "Motors off": "Motoren aus", "descending": "absteigend", "Only show files stored on SD": "Nur auf SD abgelegte Dateien anzeigen", "X": "X", "Add user": "Nutzer hinzuf\u00fcgen", "GCODE commands in layer": "GCODE Kommandos in Schicht", "Estimated print time": "Gesch\u00e4tzte Druckdauer", "Serial Connection": "Serielle Verbindung", "Control": "Kontrolle", "Password": "Passwort", "Also show next layer": "Auch n\u00e4chste Schicht anzeigen", "Print Time": "Druckdauer", "Slicer": "Slicer", "Nozzle Diameter": "D\u00fcsendurchmesser", "Sort by file size": "Nach Gr\u00f6\u00dfe sortieren", "Machine State": "Druckerstatus", "Slicing Profile": "Slicingprofil", "mm": "mm", "API": "API", "Printing from SD": "Drucke von SD", "Stream URL": "Stream-URL", "Terminal filters": "Terminalfilter", "Change password for user \"%(user)s\"": "Passwort\u00e4nderung f\u00fcr Nutzer \"%(user)s\"", "Enable Temperature Graph": "Temperaturgraph aktivieren", "Delete user": "Nutzer l\u00f6schen", "Timelapse bitrate": "Zeitrafferbitrate", "Confirm Password": "Passwort best\u00e4tigen", "Disconnect": "Trennen", "Slicing done": "Slicing abgeschlossen", "Initialize SD card": "SD-Karte initialisieren", "System": "System", "Send": "Senden", "State": "Status", "Version": "Version", "YYYY-MM-DD HH:mm": "DD.MM.YYYY HH:mm", "Attempt to reconnect": "Erneut verbinden", "Streaming done": "Streaming abgeschlossen", "violet": "Violett", "Print": "Drucken", "Layer count": "Schichtanzahl", "OctoPrint Settings": "OctoPrint Einstellungen", "Are you sure?": "Bist Du sicher?", "blue": "Blau", "Printer": "Drucker", "Delete Profile": "Profil entfernen", "Tool": "Werkzeug", "Settings": "Einstellungen", "Circular": "Rund", "Path to FFMPEG": "Pfad zu FFMPEG", "Upload to SD": "Upload (SD)", "The command \"%(command)s\" could not be executed.": "Das Kommando \"%(command)s\" konnte nicht ausgef\u00fchrt werden.", "Select a slicing profile...": "W\u00e4hle ein Slicingprofile...", "Wait for <code>start</code> on connect":Line truncated
|
||||
@@ -1 +1 @@
|
||||
window.BABEL_TO_LOAD_fr = {"locale": "fr", "domain": "messages", "plural_expr": "(n > 1)", "messages": {"": "Project-Id-Version: OctoPrint\nReport-Msgid-Bugs-To: i18n@octoprint.org\nPOT-Creation-Date: 2014-08-28 15:52+0200\nPO-Revision-Date: 2014-08-28 13:54+0000\nLast-Translator: Gina H\u00e4u\u00dfge <gina@foosel.net>\nLanguage-Team: French (http://www.transifex.com/projects/p/octoprint/language/fr/)\nPlural-Forms: nplurals=2; plural=(n > 1)\nMIME-Version: 1.0\nContent-Type: text/plain; charset=utf-8\nContent-Transfer-Encoding: 8bit\nGenerated-By: Babel 1.3\n", "Print Time Left": "Temps d'impression restant", "Proceed": "Continuer", "Timelapse Temp Folder": "R\u00e9pertoire temporaire des timelapses", "Title": "Titre", "Only show files stored locally": "Ne montre que les fichiers enregistr\u00e9s localement", "yellow": "jaune", "Path to Cura": "Chemin vers Cura", "Action": "Action", "Passwords do not match": "Les mots de passes ne sont pas semblables", "Sort by name": "Trier par nom", "Save connection settings": "Sauvegarder les param\u00e8tres de connection", "Rendering timelapse": "Rendu du timelapse en cours", "Cura": "Cura", "Files": "Fichiers", "Bed Size": "Taille du lit", "Always assume SD card is present": "Toujours supposer que la carte SD est pr\u00e9sente", "Load and Print": "Charger et imprimer", "Sending file to SD": "Envoi du fichier vers la carte SD en cours", "Number of Extruders": "Nombre d'extrudeurs", "black": "noir", "Last Printed": "Impression pr\u00e9c\u00e9dente", "Sourcecode": "Code source", "Estimated layer height": "Hauteur de couche estim\u00e9e", "You are now logged out": "Vous \u00eates maintenant d\u00e9connect\u00e9", "Uploaded": "Charg\u00e9", "Opening serial port": "Ouverture du port s\u00e9rie en cours", "New timelapse %(movie_basename)s is done rendering.": "Le rendu du nouveau timelapse %(movie_basename)s est termin\u00e9.", "Invert control": "Inverser le contr\u00f4le", "Webcam": "Webcam", "Remember me": "Se souvenir de moi", "Enable GCode Visualizer": "Activer le visualisateur de GCode", "The server appears to be offline, at least I'm not getting any response from it. I'll try to reconnect automatically <strong>over the next couple of minutes</strong>, however you are welcome to try a manual reconnect anytime using the button below.": "Le serveur semble \u00eatre hors ligne, du moins je ne re\u00e7ois aucunes r\u00e9ponses de celui-ci. Je vais tenter de me reconnecter automatiquement <strong>dans les minutes qui suivent</strong>. Quoiqu'il en soit vous pouvez tenter de vous reconnecter manuellement en utilisant le bouton ci-dessous.", "Rendering failed": "Echec du rendu", "Upload Folder": "R\u00e9pertoire des chargements", "descending": "descendant", "X": "X", "Add user": "Ajouter utilisateur", "GCODE commands in layer": "Commandes GCODE dans la couche", "Estimated print time": "Temps d'impression estim\u00e9", "Serial Connection": "Connection s\u00e9rie", "Control": "Contr\u00f4le", "Password": "Mot de passe", "Also show next layer": "Montrer \u00e9galement la couche suivante", "Print Time": "Temps d'impression", "Sort by file size": "Trier par taille des fichiers", "Machine State": "Etat de la machine", "default": "Par d\u00e9faut", "API": "API", "Printing from SD": "Impression depuis la carte SD en cours", "Terminal filters": "Filtres du terminal", "Change password for user \"%(user)s\"": "Changer le mot de passe pour l'utilisateur \"%(user)s\"", "Enable Temperature Graph": "Activer le graphique de temp\u00e9rature", "Delete user": "Supprimer utilisateur", "Confirm Password": "Confirmer le mot de passe", "Disconnect": "D\u00e9connecter", "Slicing done": "Tranchage termin\u00e9", "Initialize SD card": "Initialiser la carte SD", "System": "Syst\u00eame", "Send": "Envoyer", "State": "Etat", "Version": "Version", "YYYY-MM-DD HH:mm": "DD-MM-YYYY HH:mm", "Attempt to reconnect": "Tentative de reconnection", "Streaming done": "Diffusion en direct termin\u00e9", "violet": "violet", "Print": "Imprimer", "Layer count": "Nombre de couches", "OctoPrint Settings": "Param\u00e8tres d'OctoPrint", "Are you sure?": "Etes-vous s\u00fbre?", "blue": "bleu", "Printer": "Imprimante", "Tool": "Outil", "Settings": "Param\u00e8tres", "Path to FFMPEG": "Chemin vers FFMPEG", "Upload to SD": "Chargement vers la carte SD", "The command \"%(command)s\" could not be executed.": "La commande \"%(command)s\" n'a pas pu \u00eatre ex\u00e9cut\u00e9e", "Printed": "Imprim\u00e9", "Layer number": "Couche num\u00e9ro", "Sync with job progress": "Synchroniser avec le progr\u00e8s du job", "Circular": "Circulaire", "Total filament used": "Quantit\u00e9 de filament utilis\u00e9", "red": "rouge", "Save as default": "Sauver en tant que d\u00e9faut", "Slicing ...": "Tranchage en cours...", "Last Print Time": "Temps d'impression pr\u00e9c\u00e9dent", "Target": "Cible", "Streaming ...": "Diffusion en direct en cours...", "Logout successful": "Fermeture de session r\u00e9ussie", "Now rendering timelapse %(movieLine truncated
|
||||
window.BABEL_TO_LOAD_fr = {"locale": "fr", "domain": "messages", "plural_expr": "(n > 1)", "messages": {"": "Project-Id-Version: OctoPrint\nReport-Msgid-Bugs-To: i18n@octoprint.org\nPOT-Creation-Date: 2014-12-18 14:45+0100\nPO-Revision-Date: 2014-12-18 14:04+0000\nLast-Translator: Gina H\u00e4u\u00dfge <gina@foosel.net>\nLanguage-Team: French (http://www.transifex.com/projects/p/octoprint/language/fr/)\nPlural-Forms: nplurals=2; plural=(n > 1)\nMIME-Version: 1.0\nContent-Type: text/plain; charset=utf-8\nContent-Transfer-Encoding: 8bit\nGenerated-By: Babel 1.3\n", "Print Time Left": "Temps d'impression restant", "sec": "sec", "Proceed": "Continuer", "Timelapse Temp Folder": "R\u00e9pertoire temporaire des timelapses", "Support <code>TargetExtr%%n</code>/<code>TargetBed</code> target temperature format": "Support <code>TargetExtr%%n</code>/<code>TargetBed</code> format de temp\u00e9rature de la cible", "Upload Folder": "R\u00e9pertoire des chargements", "Only show files stored locally": "Ne montre que les fichiers enregistr\u00e9s localement", "Add Printer Profile": "", "yellow": "jaune", "Save": "Sauver", "Action": "Action", "Passwords do not match": "Les mots de passes ne sont pas semblables", "Sort by name": "Trier par nom", "Save connection settings": "Sauvegarder les param\u00e8tres de connection", "Rendering timelapse": "Rendu du timelapse en cours", "Color": "Couleur", "Temperature": "Temp\u00e9rature", "Files": "Fichiers", "Resume": "", "Always assume SD card is present": "Toujours supposer que la carte SD est pr\u00e9sente", "Load and Print": "Charger et imprimer", "Sending file to SD": "Envoi du fichier vers la carte SD en cours", "Number of Extruders": "Nombre d'extrudeurs", "black": "noir", "Last Printed": "Impression pr\u00e9c\u00e9dente", "Sourcecode": "Code source", "Estimated layer height": "Hauteur de couche estim\u00e9e", "You are now logged out": "Vous \u00eates maintenant d\u00e9connect\u00e9", "Uploaded": "Charg\u00e9", "Form Factor": "", "Opening serial port": "Ouverture du port s\u00e9rie en cours", "New timelapse %(movie_basename)s is done rendering.": "Le rendu du nouveau timelapse %(movie_basename)s est termin\u00e9.", "Invert control": "Inverser le contr\u00f4le", "Webcam": "Webcam", "Select for printing": "", "Allow <a href=\"%(url)s\">Cross Origin Resource Sharing (CORS)</a>": "Permettre <a href=\"%(url)s\">Cross Origin Resource Sharing (CORS)</a>", "Remember me": "Se souvenir de moi", "Enable GCode Visualizer": "Activer le visualisateur de GCode", "The server appears to be offline, at least I'm not getting any response from it. I'll try to reconnect automatically <strong>over the next couple of minutes</strong>, however you are welcome to try a manual reconnect anytime using the button below.": "Le serveur semble \u00eatre hors ligne, du moins je ne re\u00e7ois aucunes r\u00e9ponses de celui-ci. Je vais tenter de me reconnecter automatiquement <strong>dans les minutes qui suivent</strong>. Quoiqu'il en soit vous pouvez tenter de vous reconnecter manuellement en utilisant le bouton ci-dessous.", "Rendering failed": "Echec du rendu", "Motors off": "Eteindre les moteurs", "descending": "descendant", "Only show files stored on SD": "Ne montrer que les fichier enregistr\u00e9s sur la carte SD", "X": "X", "Add user": "Ajouter utilisateur", "GCODE commands in layer": "Commandes GCODE dans la couche", "Estimated print time": "Temps d'impression estim\u00e9", "Serial Connection": "Connection s\u00e9rie", "Control": "Contr\u00f4le", "Password": "Mot de passe", "Also show next layer": "Montrer \u00e9galement la couche suivante", "Print Time": "Temps d'impression", "Slicer": "", "Nozzle Diameter": "", "Sort by file size": "Trier par taille des fichiers", "Machine State": "Etat de la machine", "Slicing Profile": "", "mm": "mm", "API": "API", "Printing from SD": "Impression depuis la carte SD en cours", "Stream URL": "URL de diffusion en direct", "Terminal filters": "Filtres du terminal", "Change password for user \"%(user)s\"": "Changer le mot de passe pour l'utilisateur \"%(user)s\"", "Enable Temperature Graph": "Activer le graphique de temp\u00e9rature", "Delete user": "Supprimer utilisateur", "Timelapse bitrate": "Bitrate du timelapse", "Confirm Password": "Confirmer le mot de passe", "Disconnect": "D\u00e9connecter", "Slicing done": "Tranchage termin\u00e9", "Initialize SD card": "Initialiser la carte SD", "System": "Syst\u00eame", "Send": "Envoyer", "State": "Etat", "Version": "Version", "YYYY-MM-DD HH:mm": "DD-MM-YYYY HH:mm", "Attempt to reconnect": "Tentative de reconnection", "Streaming done": "Diffusion en direct termin\u00e9", "violet": "violet", "Print": "Imprimer", "Layer count": "Nombre de couches", "OctoPrint Settings": "Param\u00e8tres d'OctoPrint", "Are you sure?": "Etes-vous s\u00fbre?", "blue": "bleu", "Printer": "Imprimante", "Delete Profile": "", "Tool": "Outil", "Settings": "Param\u00e8tres", "Circular": "Circulaire", "Path to FFMPEG": "Chemin vers FFMPEG", "Upload to
Line truncated
|
||||
@@ -1 +1 @@
|
||||
window.BABEL_TO_LOAD_he = {"locale": "he", "domain": "messages", "plural_expr": "(n != 1)", "messages": {"": "Project-Id-Version: OctoPrint 1.2.0-dev-131-g854387b\nReport-Msgid-Bugs-To: i18n@octoprint.org\nPOT-Creation-Date: 2014-08-31 12:52+0300\nPO-Revision-Date: 2014-08-31 18:44+0200\nLast-Translator: Guy Sheffer <guysoft@gmail.com>\nLanguage-Team: he <guysoft@gmail.com>\nPlural-Forms: nplurals=2; plural=(n != 1)\nMIME-Version: 1.0\nContent-Type: text/plain; charset=utf-8\nContent-Transfer-Encoding: 8bit\nGenerated-By: Babel 1.3\n", "Print Time Left": "\u05d6\u05de\u05df \u05d4\u05d3\u05e4\u05e1\u05d4 \u05e0\u05d5\u05ea\u05e8", "Proceed": "\u05d4\u05de\u05e9\u05da", "Timelapse Temp Folder": "\u05ea\u05e7\u05d9\u05d9\u05d4 \u05d6\u05de\u05e0\u05d9\u05ea \u05dc-timelapse", "Title": "\u05db\u05d5\u05ea\u05e8\u05ea", "Only show files stored locally": "\u05d4\u05e6\u05d2 \u05e8\u05e7 \u05e7\u05d1\u05e6\u05d9\u05dd \u05d4\u05e9\u05de\u05d5\u05e8\u05d9\u05dd \u05de\u05e7\u05d5\u05de\u05d9\u05ea", "yellow": "\u05e6\u05d4\u05d5\u05d1", "Path to Cura": "\u05e0\u05ea\u05d9\u05d1 \u05dc-Cura", "Action": "\u05e4\u05e2\u05d5\u05dc\u05d4", "Passwords do not match": "\u05e1\u05d9\u05e1\u05de\u05d0\u05d5\u05ea \u05dc\u05d0 \u05ea\u05d5\u05d0\u05de\u05d5\u05ea", "Sort by name": "\u05de\u05d9\u05d9\u05df \u05dc\u05e4\u05d9 \u05e9\u05dd", "Save connection settings": "\u05e9\u05de\u05d5\u05e8 \u05d4\u05d2\u05d3\u05e8\u05d5\u05ea \u05d7\u05d9\u05d1\u05d5\u05e8", "Rendering timelapse": "\u05de\u05e8\u05e0\u05d3\u05e8 timelapse", "Cura": "Cura", "Files": "\u05e7\u05d1\u05e6\u05d9\u05dd", "Bed Size": "\u05d2\u05d5\u05d3\u05dc \u05de\u05d9\u05d8\u05d4", "Always assume SD card is present": "\u05ea\u05de\u05d9\u05d3 \u05ea\u05e0\u05d9\u05d7 \u05e9\u05db\u05e8\u05d8\u05d9\u05e1 SD \u05e0\u05de\u05e6\u05d0", "Load and Print": "\u05d8\u05e2\u05df \u05d5\u05d4\u05d3\u05e4\u05e1", "Sending file to SD": "\u05e9\u05d5\u05dc\u05d7 \u05e7\u05d5\u05d1\u05e5 \u05d0\u05dc SD", "Number of Extruders": "\u05de\u05e1\u05e4\u05e8 \u05d0\u05e7\u05e1\u05d8\u05e8\u05d5\u05d3\u05e8\u05d9\u05dd", "black": "\u05e9\u05d7\u05d5\u05e8", "Last Printed": "\u05d4\u05d5\u05d3\u05e4\u05e1 \u05dc\u05d0\u05d7\u05e8\u05d5\u05e0\u05d4", "Sourcecode": "\u05e7\u05d5\u05d3 \u05de\u05e7\u05d5\u05e8", "Estimated layer height": "\u05d2\u05d5\u05d1\u05d4 \u05e9\u05db\u05d1\u05d5\u05ea \u05de\u05e9\u05d5\u05e2\u05e8", "You are now logged out": "\u05d4\u05ea\u05e0\u05ea\u05e7\u05ea \u05de\u05d4\u05de\u05e2\u05e8\u05db\u05ea", "Uploaded": "\u05d4\u05d5\u05e2\u05dc\u05d4", "Opening serial port": "\u05e4\u05d5\u05ea\u05d7 \u05d9\u05e6\u05d9\u05e8\u05d4 \u05d8\u05d5\u05e8\u05d9\u05ea", "New timelapse %(movie_basename)s is done rendering.": "\u05e1\u05d9\u05d9\u05dd \u05dc\u05e8\u05e0\u05d3\u05e8 \u05d0\u05ea \u05d4-timelapse %(movie_basename)s", "Invert control": "\u05d4\u05e4\u05d5\u05da \u05e9\u05dc\u05d9\u05d8\u05d4", "Webcam": "\u05de\u05e6\u05dc\u05de\u05ea \u05e8\u05e9\u05ea", "Remember me": "\u05d6\u05db\u05d5\u05e8 \u05d0\u05d5\u05ea\u05d9", "Enable GCode Visualizer": "\u05d4\u05e4\u05e2\u05dc \u05d5\u05d9\u05d6\u05d5\u05d0\u05dc\u05d9\u05d6\u05e6\u05d9\u05d4 \u05e9\u05dc GCode", "The server appears to be offline, at least I'm not getting any response from it. I'll try to reconnect automatically <strong>over the next couple of minutes</strong>, however you are welcome to try a manual reconnect anytime using the button below.": "\u05e0\u05e8\u05d0\u05d4 \u05e9\u05d4\u05e9\u05e8\u05ea \u05dc\u05d0 \u05de\u05d7\u05d5\u05d1\u05e8, \u05d0\u05d5 \u05dc\u05e4\u05d7\u05d5\u05ea \u05d0\u05e0\u05d9 \u05dc\u05d0 \u05de\u05e6\u05dc\u05d9\u05d7 \u05dc\u05e7\u05d1\u05dc \u05db\u05dc \u05ea\u05d2\u05d5\u05d1\u05d4 \u05de\u05de\u05e0\u05d5. \u05d0\u05e0\u05e1\u05d4 \u05dc\u05d4\u05ea\u05d7\u05d1\u05e8 \u05de\u05d7\u05d3\u05e9 \u05d0\u05d5\u05d8\u05d5\u05de\u05d8\u05d9\u05ea <strong>\u05d1\u05e2\u05d5\u05d3 \u05de\u05e1\u05e4\u05e8 \u05d3\u05e7\u05d5\u05ea</strong>, \u05d0\u05d1\u05dc \u05e0\u05d9\u05ea\u05df \u05d2\u05dd \u05dc\u05e0\u05e1\u05d5\u05ea \u05dc\u05d4\u05ea\u05d7\u05d1\u05e8 \u05de\u05d7\u05d3\u05e9 \u05e2\u05dd \u05d4\u05db\u05e4\u05ea\u05d5\u05e8 \u05dc\u05d4\u05dc\u05df.", "Rendering failed": "\u05e8\u05d9\u05e0\u05d3\u05d5\u05e8 \u05e0\u05db\u05e9\u05dc", "Upload Folder": "\u05ea\u05e7\u05d9\u05d9\u05ea \u05d4\u05e2\u05dc\u05d0\u05d4", "descending": "\u05e1\u05d3\u05e8 \u05d9\u05d5\u05e8\u05d3", "X": "X", "Add user": "\u05d4\u05d5\u05e1\u05e3 \u05de\u05e9\u05ea\u05de\u05e9", "GCODE commands in layer": "\u05e4\u05e7\u05d5\u05d3\u05d5\u05ea GCODE \u05d1\u05e9\u05db\u05d1\u05d4", "Estimated print time": "\u05d6\u05de\u05df \u05d4\u05d3\u05e4\u05e1\u05d4 \u05de\u05e9\u05d5\u05e2\u05e8", "Serial Connection": "\u05d7\u05d9\u05d1\u05d5\u05e8 \u05d8\u05d5\u05e8\u05d9", "Control": "\u05e9\u05dc\u05d9\u05d8\u05d4", "Password": "\u05e1\u05d9\u05e1\u05de\u05d4", "Also show next layer": "\u05d0\u05e4\u05e9\u05e8 \u05d4\u05e6\u05d2\u05d4 \u05e9\u05dc \u05e9\u05db\u05d1\u05d4 \u05d4Line truncated
|
||||
window.BABEL_TO_LOAD_he = {"locale": "he", "domain": "messages", "plural_expr": "(n != 1)", "messages": {"": "Project-Id-Version: OctoPrint\nReport-Msgid-Bugs-To: i18n@octoprint.org\nPOT-Creation-Date: 2014-12-18 14:45+0100\nPO-Revision-Date: 2014-12-18 14:04+0000\nLast-Translator: Gina H\u00e4u\u00dfge <gina@foosel.net>\nLanguage-Team: Hebrew (http://www.transifex.com/projects/p/octoprint/language/he/)\nPlural-Forms: nplurals=2; plural=(n != 1)\nMIME-Version: 1.0\nContent-Type: text/plain; charset=utf-8\nContent-Transfer-Encoding: 8bit\nGenerated-By: Babel 1.3\n", "Print Time Left": "\u05d6\u05de\u05df \u05d4\u05d3\u05e4\u05e1\u05d4 \u05e0\u05d5\u05ea\u05e8", "sec": "\u05e9\u05e0'", "Proceed": "\u05d4\u05de\u05e9\u05da", "Timelapse Temp Folder": "\u05ea\u05e7\u05d9\u05d9\u05d4 \u05d6\u05de\u05e0\u05d9\u05ea \u05dc-timelapse", "Support <code>TargetExtr%%n</code>/<code>TargetBed</code> target temperature format": "\u05ea\u05de\u05d5\u05da \u05e2\u05d1\u05d5\u05e8 <code>TargetExtr%%n</code>/<code>TargetBed</code> \u05e4\u05d5\u05e8\u05de\u05d8 \u05d8\u05de\u05e4\u05e8\u05d8\u05d5\u05e8\u05ea \u05d9\u05d9\u05e2\u05d3", "Upload Folder": "\u05ea\u05e7\u05d9\u05d9\u05ea \u05d4\u05e2\u05dc\u05d0\u05d4", "Only show files stored locally": "\u05d4\u05e6\u05d2 \u05e8\u05e7 \u05e7\u05d1\u05e6\u05d9\u05dd \u05d4\u05e9\u05de\u05d5\u05e8\u05d9\u05dd \u05de\u05e7\u05d5\u05de\u05d9\u05ea", "Add Printer Profile": "", "yellow": "\u05e6\u05d4\u05d5\u05d1", "Save": "\u05e9\u05de\u05d5\u05e8", "Action": "\u05e4\u05e2\u05d5\u05dc\u05d4", "Passwords do not match": "\u05e1\u05d9\u05e1\u05de\u05d0\u05d5\u05ea \u05dc\u05d0 \u05ea\u05d5\u05d0\u05de\u05d5\u05ea", "Sort by name": "\u05de\u05d9\u05d9\u05df \u05dc\u05e4\u05d9 \u05e9\u05dd", "Save connection settings": "\u05e9\u05de\u05d5\u05e8 \u05d4\u05d2\u05d3\u05e8\u05d5\u05ea \u05d7\u05d9\u05d1\u05d5\u05e8", "Rendering timelapse": "\u05de\u05e8\u05e0\u05d3\u05e8 timelapse", "Color": "\u05e6\u05d1\u05e2", "Temperature": "\u05d8\u05de\u05e4\u05e8\u05d8\u05d5\u05e8\u05d4", "Files": "\u05e7\u05d1\u05e6\u05d9\u05dd", "Resume": "", "Always assume SD card is present": "\u05ea\u05de\u05d9\u05d3 \u05ea\u05e0\u05d9\u05d7 \u05e9\u05db\u05e8\u05d8\u05d9\u05e1 SD \u05e0\u05de\u05e6\u05d0", "Load and Print": "\u05d8\u05e2\u05df \u05d5\u05d4\u05d3\u05e4\u05e1", "Sending file to SD": "\u05e9\u05d5\u05dc\u05d7 \u05e7\u05d5\u05d1\u05e5 \u05d0\u05dc SD", "Number of Extruders": "\u05de\u05e1\u05e4\u05e8 \u05d0\u05e7\u05e1\u05d8\u05e8\u05d5\u05d3\u05e8\u05d9\u05dd", "black": "\u05e9\u05d7\u05d5\u05e8", "Last Printed": "\u05d4\u05d5\u05d3\u05e4\u05e1 \u05dc\u05d0\u05d7\u05e8\u05d5\u05e0\u05d4", "Sourcecode": "\u05e7\u05d5\u05d3 \u05de\u05e7\u05d5\u05e8", "Estimated layer height": "\u05d2\u05d5\u05d1\u05d4 \u05e9\u05db\u05d1\u05d5\u05ea \u05de\u05e9\u05d5\u05e2\u05e8", "You are now logged out": "\u05d4\u05ea\u05e0\u05ea\u05e7\u05ea \u05de\u05d4\u05de\u05e2\u05e8\u05db\u05ea", "Uploaded": "\u05d4\u05d5\u05e2\u05dc\u05d4", "Form Factor": "", "Opening serial port": "\u05e4\u05d5\u05ea\u05d7 \u05d9\u05e6\u05d9\u05e8\u05d4 \u05d8\u05d5\u05e8\u05d9\u05ea", "New timelapse %(movie_basename)s is done rendering.": "\u05e1\u05d9\u05d9\u05dd \u05dc\u05e8\u05e0\u05d3\u05e8 \u05d0\u05ea \u05d4-timelapse %(movie_basename)s", "Invert control": "\u05d4\u05e4\u05d5\u05da \u05e9\u05dc\u05d9\u05d8\u05d4", "Webcam": "\u05de\u05e6\u05dc\u05de\u05ea \u05e8\u05e9\u05ea", "Select for printing": "", "Allow <a href=\"%(url)s\">Cross Origin Resource Sharing (CORS)</a>": "\u05d0\u05e4\u05e9\u05e8 <a href=\"%(url)s\">Cross Origin Resource Sharing (CORS)</a>", "Remember me": "\u05d6\u05db\u05d5\u05e8 \u05d0\u05d5\u05ea\u05d9", "Enable GCode Visualizer": "\u05d4\u05e4\u05e2\u05dc \u05d5\u05d9\u05d6\u05d5\u05d0\u05dc\u05d9\u05d6\u05e6\u05d9\u05d4 \u05e9\u05dc GCode", "The server appears to be offline, at least I'm not getting any response from it. I'll try to reconnect automatically <strong>over the next couple of minutes</strong>, however you are welcome to try a manual reconnect anytime using the button below.": "\u05e0\u05e8\u05d0\u05d4 \u05e9\u05d4\u05e9\u05e8\u05ea \u05dc\u05d0 \u05de\u05d7\u05d5\u05d1\u05e8, \u05d0\u05d5 \u05dc\u05e4\u05d7\u05d5\u05ea \u05d0\u05e0\u05d9 \u05dc\u05d0 \u05de\u05e6\u05dc\u05d9\u05d7 \u05dc\u05e7\u05d1\u05dc \u05db\u05dc \u05ea\u05d2\u05d5\u05d1\u05d4 \u05de\u05de\u05e0\u05d5. \u05d0\u05e0\u05e1\u05d4 \u05dc\u05d4\u05ea\u05d7\u05d1\u05e8 \u05de\u05d7\u05d3\u05e9 \u05d0\u05d5\u05d8\u05d5\u05de\u05d8\u05d9\u05ea <strong>\u05d1\u05e2\u05d5\u05d3 \u05de\u05e1\u05e4\u05e8 \u05d3\u05e7\u05d5\u05ea</strong>, \u05d0\u05d1\u05dc \u05e0\u05d9\u05ea\u05df \u05d2\u05dd \u05dc\u05e0\u05e1\u05d5\u05ea \u05dc\u05d4\u05ea\u05d7\u05d1\u05e8 \u05de\u05d7\u05d3\u05e9 \u05e2\u05dd \u05d4\u05db\u05e4\u05ea\u05d5\u05e8 \u05dc\u05d4\u05dc\u05df.", "Rendering failed": "\u05e8\u05d9\u05e0\u05d3\u05d5\u05e8 \u05e0\u05db\u05e9\u05dc", "Motors off": "\u05db\u05d1\u05d4 \u05de\u05e0\u05d5\u05e2\u05d9\u05dd", "descending": "\u05eLine truncated
|
||||
@@ -1 +1 @@
|
||||
window.BABEL_TO_LOAD_nl = {"locale": "nl", "domain": "messages", "plural_expr": "(n != 1)", "messages": {"": "Project-Id-Version: OctoPrint\nReport-Msgid-Bugs-To: i18n@octoprint.org\nPOT-Creation-Date: 2014-08-28 15:52+0200\nPO-Revision-Date: 2014-09-01 20:11+0000\nLast-Translator: leon.bek <leon.bek@gmail.com>\nLanguage-Team: Dutch (http://www.transifex.com/projects/p/octoprint/language/nl/)\nPlural-Forms: nplurals=2; plural=(n != 1)\nMIME-Version: 1.0\nContent-Type: text/plain; charset=utf-8\nContent-Transfer-Encoding: 8bit\nGenerated-By: Babel 1.3\n", "Print Time Left": "Resterende print tijd", "Proceed": "Verder", "Timelapse Temp Folder": "Tijdelijke timelapse map", "Title": "Titel", "Only show files stored locally": "Laat alleen lokale bestanden zien", "yellow": "geel", "Path to Cura": "Lokatie van Cura", "Action": "Actie", "Passwords do not match": "Wachtwoorden komen niet overeen", "Sort by name": "Sorteer op naam", "Save connection settings": "Verbindings instellingen opslaan", "Rendering timelapse": "Renderen van timelapse", "Cura": "Cura", "Files": "Bestanden", "Bed Size": "Platform grootte", "Always assume SD card is present": "Neem aan dat SD kaart altijd aanwezig is", "Load and Print": "Laad en print", "Sending file to SD": "Verstuur bestand naar SD", "Number of Extruders": "Aantal Extruders", "black": "zwart", "Last Printed": "Laats geprint", "Sourcecode": "Broncode", "Estimated layer height": "Geschatte laag hooge", "You are now logged out": "Je bent nu uitgelogd", "Uploaded": "Geupload", "Opening serial port": "Openen van seri\u00eble poort", "New timelapse %(movie_basename)s is done rendering.": "Nieuwe timelapse %(movie_basename)s is gereed", "Invert control": "Bedieining spiegelen", "Webcam": "Webcam", "Remember me": "Onthoud me", "Enable GCode Visualizer": "Schakel GCode Visualizer in", "The server appears to be offline, at least I'm not getting any response from it. I'll try to reconnect automatically <strong>over the next couple of minutes</strong>, however you are welcome to try a manual reconnect anytime using the button below.": "De server lijkt offline te zijn, dat wil zeggen dat ik er geen reactie van krijg. Ik zal proberen om <strong>gedurende een paar minuten</strong> opnieuw te verbinden. Maar je bent op elk moment vrij om handmatig proberen te verbinden met onderstaande knop.", "Rendering failed": "Renderen mislukt", "Upload Folder": "Lokatie voor Uploads", "descending": "Aflopend", "X": "X", "Add user": "Gebruiker toevoegen", "GCODE commands in layer": "GCODE commando's in laag", "Estimated print time": "Geschatte print tijd", "Serial Connection": "Seri\u00eble verbinding", "Control": "Controle", "Password": "Wachtwoord", "Also show next layer": "Laat ook volgende laag zien", "Print Time": "Print tijd", "Sort by file size": "Sorteer op bestands grootte", "Machine State": "Machine status", "default": "Standaard", "API": "API", "Printing from SD": "Printen vanaf SD", "Terminal filters": "Terminal filters", "Change password for user \"%(user)s\"": "Verander wachtwoord voor gebruiker \"%(user)s\"", "Enable Temperature Graph": "Schakel temperatuur grafiek in", "Delete user": "Gebruiker verwijderen", "Confirm Password": "Bevestig wachtwoord", "Disconnect": "Verbreken", "Slicing done": "Slicing klaar", "Initialize SD card": "Formateer SD kaart", "System": "Systeem", "Send": "Verstuur", "State": "Status", "Version": "Versie", "YYYY-MM-DD HH:mm": "DD-MM-YYYY HH:mm", "Attempt to reconnect": "Probeer opnieuw te verbinden", "Streaming done": "Streaming klaar", "violet": "violet", "Print": "Print", "Layer count": "Aantal lagen", "OctoPrint Settings": "OctoPrint instellingen", "Are you sure?": "Weet je het zeker?", "blue": "blauw", "Printer": "Printer", "Tool": "Gereedschap", "Settings": "Instellingen", "Path to FFMPEG": "Lokatie van FFMPEG", "Upload to SD": "Uploaden naar SD", "The command \"%(command)s\" could not be executed.": "Het commando \"%(command)s\" kon niet uitgevoerd worden.", "Printed": "Geprint", "Layer number": "Laag nummer", "Sync with job progress": "Synchroniseer met taak voortgang", "Circular": "Cirkelvormig", "Total filament used": "Totaal gebruikte filament", "red": "rood", "Save as default": "Stel in als standaard", "Slicing ...": "Slicing ...", "Last Print Time": "Laatste print tijd", "Target": "Doel", "Streaming ...": "Streaming ...", "Logout successful": "Uitloggen succesvol", "Now rendering timelapse %(movie_basename)s": "Aan het renderen van timelapse %(movie_basename)s", "Documentation": "Documentatie", "%(hour)02d:%(minute)02d:%(second)02d": "%(hour)02d:%(minute)02d:%(second)02d", "Upload": "Upload", "ascending": "Oplopend", "Model size": "Model grootte", "Temperatures": "Temperaturen", "visited": "bezocht", "Timed": "Getimed", "Edit user \"%(user)s\"": "Bewerk gebruiker \"%(user)s\"", "Snapshot URL": "Snapshot URL", "Release SD card": "Geef SD kaart vrij", "Server is offline": "Server is offline", "Log communication to serial.log (might negatively impact
Line truncated
|
||||
window.BABEL_TO_LOAD_nl = {"locale": "nl", "domain": "messages", "plural_expr": "(n != 1)", "messages": {"": "Project-Id-Version: OctoPrint\nReport-Msgid-Bugs-To: i18n@octoprint.org\nPOT-Creation-Date: 2014-12-18 14:45+0100\nPO-Revision-Date: 2014-12-18 14:04+0000\nLast-Translator: Gina H\u00e4u\u00dfge <gina@foosel.net>\nLanguage-Team: Dutch (http://www.transifex.com/projects/p/octoprint/language/nl/)\nPlural-Forms: nplurals=2; plural=(n != 1)\nMIME-Version: 1.0\nContent-Type: text/plain; charset=utf-8\nContent-Transfer-Encoding: 8bit\nGenerated-By: Babel 1.3\n", "Print Time Left": "Resterende print tijd", "sec": "sec", "Proceed": "Doorgaan", "Timelapse Temp Folder": "Tijdelijke timelapse map", "Support <code>TargetExtr%%n</code>/<code>TargetBed</code> target temperature format": "Support <code>TargetExtr%%n</code>/<code>TargetBed</code> target temperature format", "Upload Folder": "Lokatie voor Uploads", "Only show files stored locally": "Laat alleen lokale bestanden zien", "Add Printer Profile": "", "yellow": "geel", "Save": "Opslaan", "Action": "Actie", "Passwords do not match": "De wachtwoorden komen niet overeen", "Sort by name": "Sorteer op naam", "Save connection settings": "Verbindings instellingen opslaan", "Rendering timelapse": "Renderen van timelapse", "Color": "Kleur", "Temperature": "Temperatuur", "Files": "Bestanden", "Resume": "Ga verder", "Always assume SD card is present": "Neem aan dat SD kaart altijd aanwezig is", "Load and Print": "Laad en print", "Sending file to SD": "Verstuur bestand naar SD kaartje", "Number of Extruders": "Aantal Extruders", "black": "zwart", "Last Printed": "Vorige print-job", "Sourcecode": "Broncode", "Estimated layer height": "Geschatte laag hooge", "You are now logged out": "Je bent nu uitgelogd", "Uploaded": "Geupload", "Form Factor": "", "Opening serial port": "Openen van seri\u00eble poort", "New timelapse %(movie_basename)s is done rendering.": "Nieuwe timelapse %(movie_basename)s is gerenderd", "Invert control": "Bedieining spiegelen", "Webcam": "Webcam", "Select for printing": "", "Allow <a href=\"%(url)s\">Cross Origin Resource Sharing (CORS)</a>": "Sta <a href=\"%(url)s\">Cross Origin Resource Sharing (CORS)</a> toe", "Remember me": "Onthoud me", "Enable GCode Visualizer": "Schakel GCode Visualizer in", "The server appears to be offline, at least I'm not getting any response from it. I'll try to reconnect automatically <strong>over the next couple of minutes</strong>, however you are welcome to try a manual reconnect anytime using the button below.": "De server lijkt offline te zijn, althans er komt geen enkele reactie. Ik zal over <strong>een paar minuten</strong> opnieuw pogen te verbinden. Je kunt op elk moment met onderstaande knop 'handmatig' proberen te verbinden", "Rendering failed": "Renderen mislukt", "Motors off": "Motoren uit", "descending": "Aflopend", "Only show files stored on SD": "Laat alleen bestanden op SD-kaart zien", "X": "X", "Add user": "Gebruiker toevoegen", "GCODE commands in layer": "GCODE commando's in laag", "Estimated print time": "Geschatte print tijd", "Serial Connection": "Seri\u00eble verbinding", "Control": "Controle", "Password": "Wachtwoord", "Also show next layer": "Laat ook volgende laag zien", "Print Time": "Print tijd", "Slicer": "'Slicer' of fileersoftware", "Nozzle Diameter": "", "Sort by file size": "Sorteer op bestands grootte", "Machine State": "Machine status", "Slicing Profile": "Fileer profiel", "mm": "mm", "API": "API", "Printing from SD": "Printen vanaf SD kaartje", "Stream URL": "Stream URL", "Terminal filters": "Terminal filters", "Change password for user \"%(user)s\"": "Verander wachtwoord voor gebruiker \"%(user)s\"", "Enable Temperature Graph": "Schakel temperatuur grafiek in", "Delete user": "Gebruiker verwijderen", "Timelapse bitrate": "Timelapse bitrate", "Confirm Password": "Bevestig wachtwoord", "Disconnect": "Verbreken", "Slicing done": "Fileren is klaar", "Initialize SD card": "Formateer SD kaart", "System": "Systeem", "Send": "Verstuur", "State": "Status", "Version": "Versie", "YYYY-MM-DD HH:mm": "DD-MM-YYYY HH:mm", "Attempt to reconnect": "Probeer opnieuw te verbinden", "Streaming done": "Het Streamen is klaar", "violet": "violet", "Print": "Print", "Layer count": "Aantal lagen", "OctoPrint Settings": "OctoPrint instellingen", "Are you sure?": "Weet je het zeker?", "blue": "blauw", "Printer": "Printer", "Delete Profile": "", "Tool": "Gereedschap", "Settings": "Instellingen", "Circular": "Cirkelvormig", "Path to FFMPEG": "Lokatie van FFMPEG", "Upload to SD": "opslaan op SD-kaart ", "The command \"%(command)s\" could not be executed.": "Het commando \"%(command)s\" kon niet uitgevoerd worden.", "Select a slicing profile...": "", "Wait for <code>start</code> on connect": "Wacht voor <code>start</code> bij het verbinden", "Sync with job progress": "Synchroniseer met taak voortgang", "Calculating...": "", "Total filament used": "Totaal gebruikte filament", "red": "rood", "Save as default":
Line truncated
|
||||
@@ -1 +1 @@
|
||||
window.BABEL_TO_LOAD_no = {"locale": "nb_NO", "domain": "messages", "plural_expr": "(n != 1)", "messages": {"": "Project-Id-Version: OctoPrint\nReport-Msgid-Bugs-To: i18n@octoprint.org\nPOT-Creation-Date: 2014-08-28 15:52+0200\nPO-Revision-Date: 2014-09-03 16:07+0000\nLast-Translator: lobster2b <ch.eikefjord@gmail.com>\nLanguage-Team: Norwegian (http://www.transifex.com/projects/p/octoprint/language/no/)\nPlural-Forms: nplurals=2; plural=(n != 1)\nMIME-Version: 1.0\nContent-Type: text/plain; charset=utf-8\nContent-Transfer-Encoding: 8bit\nGenerated-By: Babel 1.3\n", "Print Time Left": "Gjenst\u00e5ende utskriftstid", "Proceed": "Fortsett", "Timelapse Temp Folder": "Timelapse midlertidig mappe", "Title": "Tittel", "Only show files stored locally": "Bare vis filer lagret lokalt", "yellow": "gul", "Path to Cura": "Sti til Cura", "Action": "Handling", "Passwords do not match": "Passordet er ikke likt", "Sort by name": "Sorter ved navn", "Save connection settings": "Lagre tilkoblingsinnstillinger", "Rendering timelapse": "Sammensetter timelapse", "Cura": "Cura", "Files": "Filer", "Bed Size": "Plattformst\u00f8rrelse", "Always assume SD card is present": "Alltid anta at minnekort er p\u00e5 plass", "Load and Print": "Last og skriv ut", "Sending file to SD": "Sender fil til minnekort", "Number of Extruders": "Antall dyser", "black": "svart", "Last Printed": "Sist utskrevet", "Sourcecode": "Kildekode", "Estimated layer height": "Estimert lagh\u00f8yde", "You are now logged out": "Du er n\u00e5 logget ut", "Uploaded": "Opplastet", "Opening serial port": "\u00c5pner serialport", "New timelapse %(movie_basename)s is done rendering.": "Ny timelapse for %(movie_basename)s er ferdig sammensatt", "Invert control": "Inverter kontroller", "Webcam": "Nettkamera", "Remember me": "Husk meg", "Enable GCode Visualizer": "Aktiver GCode framviser", "The server appears to be offline, at least I'm not getting any response from it. I'll try to reconnect automatically <strong>over the next couple of minutes</strong>, however you are welcome to try a manual reconnect anytime using the button below.": "Serveren er tilsynelatende frakoblet, i det minste f\u00e5r jeg ikke noen respons fra den. Jeg pr\u00f8ver \u00e5 koble til automatisk <strong>over de neste minuttene</strong>, du kan pr\u00f8ve en manuell oppkobling n\u00e5r du \u00f8nsker det ved \u00e5 bruke knappen nedenfor.", "Rendering failed": "Sammensetting feilet", "Upload Folder": "Opplastningsmappe", "descending": "synkende", "X": "X", "Add user": "Legg til bruker", "GCODE commands in layer": "GCODE kommandoer i lag", "Estimated print time": "Beregnet printtid", "Serial Connection": "Seriell kontakt", "Control": "Kontroll", "Password": "Passord", "Also show next layer": "Ogs\u00e5 vis neste lag", "Print Time": "Utskriftstid", "Sort by file size": "Sorter filer etter st\u00f8rrelse", "Machine State": "Maskintilstand", "default": "standard", "API": "API", "Printing from SD": "Utskrift fra minnekort", "Terminal filters": "Terminal filtre", "Change password for user \"%(user)s\"": "Endre passord for bruker \"%(user)s\"", "Enable Temperature Graph": "Aktiver temperaturgraf", "Delete user": "Slett bruker", "Confirm Password": "Bekreft passord", "Disconnect": "Koble fra", "Slicing done": "Slicing ferdig", "Initialize SD card": "Start minnekortet", "System": "System", "Send": "Send", "State": "Tilstand", "Version": "Versjon", "YYYY-MM-DD HH:mm": "YYYY-MM-DD HH:mm", "Attempt to reconnect": "Fors\u00f8k \u00e5 koble til p\u00e5 nytt", "Streaming done": "Streaming ferdig", "violet": "fiolett", "Print": "Utskriv", "Layer count": "Antall lag", "OctoPrint Settings": "OctoPrint innstillinger", "Are you sure?": "Er du sikker?", "blue": "bl\u00e5", "Printer": "Printer", "Tool": "Verkt\u00f8y", "Settings": "Innstillinger", "Path to FFMPEG": "Sti til FFMPEG", "Upload to SD": "Last opp til minnekort", "The command \"%(command)s\" could not be executed.": "Kommando \"%(command)s\" mislykkes", "Printed": "Utskrevet", "Layer number": "Lag nummer", "Sync with job progress": "Synkroniser med jobbprogresjon", "Circular": "Sirkul\u00e6r", "Total filament used": "Totalt tr\u00e5dforbruk", "red": "r\u00f8d", "Save as default": "Lagre som standard", "Slicing ...": "Slicing ...", "Last Print Time": "Siste utskriftstid", "Target": "M\u00e5l", "Streaming ...": "Streaming ...", "Logout successful": "Logg ut vellykket", "Now rendering timelapse %(movie_basename)s": "Sammensetter timelapse %(movie_basename)s", "Documentation": "Dokumentasjon", "%(hour)02d:%(minute)02d:%(second)02d": "%(hour)02d:%(minute)02d:%(second)02d", "Upload": "Last opp", "ascending": "stigende", "Model size": "Modellst\u00f8rrelse", "Temperatures": "Temperaturer", "visited": "bes\u00f8kt", "Timed": "Tidtakes", "Edit user \"%(user)s\"": "Endre bruker \"%(user)s\"", "Snapshot URL": "Hurtigbilde URL", "Release SD card": "L\u00f8s ut minnekort", "Server is offline": "Server er frakoblet", "Log communication to serial.log (might negatively imLine truncated
|
||||
window.BABEL_TO_LOAD_no = {"locale": "nb_NO", "domain": "messages", "plural_expr": "(n != 1)", "messages": {"": "Project-Id-Version: OctoPrint\nReport-Msgid-Bugs-To: i18n@octoprint.org\nPOT-Creation-Date: 2014-12-18 14:45+0100\nPO-Revision-Date: 2014-12-18 14:04+0000\nLast-Translator: Gina H\u00e4u\u00dfge <gina@foosel.net>\nLanguage-Team: Norwegian (http://www.transifex.com/projects/p/octoprint/language/no/)\nPlural-Forms: nplurals=2; plural=(n != 1)\nMIME-Version: 1.0\nContent-Type: text/plain; charset=utf-8\nContent-Transfer-Encoding: 8bit\nGenerated-By: Babel 1.3\n", "Print Time Left": "Gjenst\u00e5ende utskriftstid", "sec": "sek", "Proceed": "Fortsett", "Timelapse Temp Folder": "Timelapse midlertidig mappe", "Support <code>TargetExtr%%n</code>/<code>TargetBed</code> target temperature format": "St\u00f8tte <code>TargetExtr%%n</code>/<code>TargetBed</code> m\u00e5l temperatur format", "Upload Folder": "Opplastningsmappe", "Only show files stored locally": "Bare vis filer lagret lokalt", "Add Printer Profile": "", "yellow": "gul", "Save": "Lagre", "Action": "Handling", "Passwords do not match": "Passordet er ikke likt", "Sort by name": "Sorter ved navn", "Save connection settings": "Lagre tilkoblingsinnstillinger", "Rendering timelapse": "Sammensetter timelapse", "Color": "Farge", "Temperature": "Temperatur", "Files": "Filer", "Resume": "Fortsett", "Always assume SD card is present": "Alltid anta at minnekort er p\u00e5 plass", "Load and Print": "Last og skriv ut", "Sending file to SD": "Sender fil til minnekort", "Number of Extruders": "Antall dyser", "black": "svart", "Last Printed": "Sist utskrevet", "Sourcecode": "Kildekode", "Estimated layer height": "Estimert lagh\u00f8yde", "You are now logged out": "Du er n\u00e5 logget ut", "Uploaded": "Opplastet", "Form Factor": "", "Opening serial port": "\u00c5pner serialport", "New timelapse %(movie_basename)s is done rendering.": "Ny timelapse for %(movie_basename)s er ferdig sammensatt", "Invert control": "Inverter kontroller", "Webcam": "Nettkamera", "Select for printing": "", "Allow <a href=\"%(url)s\">Cross Origin Resource Sharing (CORS)</a>": "Tillat <a href=\"%(url)s\">Cross Origin Resource Sharing (CORS)</a>", "Remember me": "Husk meg", "Enable GCode Visualizer": "Aktiver GCode framviser", "The server appears to be offline, at least I'm not getting any response from it. I'll try to reconnect automatically <strong>over the next couple of minutes</strong>, however you are welcome to try a manual reconnect anytime using the button below.": "Serveren er tilsynelatende frakoblet, i det minste f\u00e5r jeg ikke noen respons fra den. Jeg pr\u00f8ver \u00e5 koble til automatisk <strong>over de neste minuttene</strong>, du kan pr\u00f8ve en manuell oppkobling n\u00e5r du \u00f8nsker det ved \u00e5 bruke knappen nedenfor.", "Rendering failed": "Sammensetting feilet", "Motors off": "Motorer av", "descending": "synkende", "Only show files stored on SD": "Bare vis filer lagret p\u00e5 minnekortet", "X": "X", "Add user": "Legg til bruker", "GCODE commands in layer": "GCODE kommandoer i lag", "Estimated print time": "Beregnet printtid", "Serial Connection": "Seriell kontakt", "Control": "Kontroll", "Password": "Passord", "Also show next layer": "Ogs\u00e5 vis neste lag", "Print Time": "Utskriftstid", "Slicer": "Slicer", "Nozzle Diameter": "", "Sort by file size": "Sorter filer etter st\u00f8rrelse", "Machine State": "Maskintilstand", "Slicing Profile": "Slicer profil", "mm": "mm", "API": "API", "Printing from SD": "Utskrift fra minnekort", "Stream URL": "Str\u00f8m URL", "Terminal filters": "Terminal filtre", "Change password for user \"%(user)s\"": "Endre passord for bruker \"%(user)s\"", "Enable Temperature Graph": "Aktiver temperaturgraf", "Delete user": "Slett bruker", "Timelapse bitrate": "Timelapse bitrate", "Confirm Password": "Bekreft passord", "Disconnect": "Koble fra", "Slicing done": "Slicing ferdig", "Initialize SD card": "Start minnekortet", "System": "System", "Send": "Send", "State": "Tilstand", "Version": "Versjon", "YYYY-MM-DD HH:mm": "YYYY-MM-DD HH:mm", "Attempt to reconnect": "Fors\u00f8k \u00e5 koble til p\u00e5 nytt", "Streaming done": "Str\u00f8mming ferdig", "violet": "fiolett", "Print": "Utskriv", "Layer count": "Antall lag", "OctoPrint Settings": "OctoPrint innstillinger", "Are you sure?": "Er du sikker?", "blue": "bl\u00e5", "Printer": "Printer", "Delete Profile": "", "Tool": "Verkt\u00f8y", "Settings": "Innstillinger", "Circular": "Sirkul\u00e6r", "Path to FFMPEG": "Sti til FFMPEG", "Upload to SD": "Last opp til minnekort", "The command \"%(command)s\" could not be executed.": "Kommando \"%(command)s\" mislykkes", "Select a slicing profile...": "", "Wait for <code>start</code> on connect": "Vent for <code>start</code> p\u00e5 tilkobling", "Sync with job progress": "Synkroniser med jobbprogresjon", "Calculating...": "", "Total filament used": "Totalt tr\u00e5dforbruk", "red": "r\u00f8d", "Save as default": "Lagre som standard", "SlicingLine truncated
|
||||
@@ -1 +1 @@
|
||||
window.BABEL_TO_LOAD_ro = {"locale": "ro", "domain": "messages", "plural_expr": "(n==1?0:(((n%100>19)||((n%100==0)&&(n!=0)))?2:1))", "messages": {"": "Project-Id-Version: OctoPrint\nReport-Msgid-Bugs-To: i18n@octoprint.org\nPOT-Creation-Date: 2014-08-28 15:52+0200\nPO-Revision-Date: 2014-08-31 16:21+0000\nLast-Translator: 3Dmaker4U <3dmaker4u@gmail.com>\nLanguage-Team: Romanian (http://www.transifex.com/projects/p/octoprint/language/ro/)\nPlural-Forms: nplurals=3; plural=(n==1?0:(((n%100>19)||((n%100==0)&&(n!=0)))?2:1))\nMIME-Version: 1.0\nContent-Type: text/plain; charset=utf-8\nContent-Transfer-Encoding: 8bit\nGenerated-By: Babel 1.3\n", "Print Time Left": "Timp de imprimare r\u0103mas", "Proceed": "Continuare", "Timelapse Temp Folder": "Director temporar pentru \u00eenregistrarea rapid\u0103", "Title": "Titlu", "Only show files stored locally": "Arat\u0103 doar fi\u0219ierele stocate local", "yellow": "galben", "Path to Cura": "Cale c\u0103tre Cura", "Action": "Ac\u021biune", "Passwords do not match": "Parolele nu se potrivesc", "Sort by name": "Sortare dup\u0103 nume", "Save connection settings": "Salvare configura\u021bie conexiune", "Rendering timelapse": "Redare \u00eenregistrare rapid\u0103", "Cura": "Cura", "Files": "Fi\u0219iere", "Bed Size": "M\u0103rime mas\u0103", "Always assume SD card is present": "Consider\u0103 \u00eentotdeauna cardul SD prezent", "Load and Print": "\u00cenc\u0103rcare \u0219i imprimare", "Sending file to SD": "Se transmite fi\u0219ierul c\u0103tre SD", "Number of Extruders": "Num\u0103r de extrudere", "black": "negru", "Last Printed": "Ultima dat\u0103 imprimat", "Sourcecode": "Cod surs\u0103", "Estimated layer height": "\u00cen\u0103l\u021bimea stratului estimat\u0103", "You are now logged out": "Acum e\u0219ti deconectat", "Uploaded": "\u00cenc\u0103rcat", "Opening serial port": "Se deschide portul serial", "New timelapse %(movie_basename)s is done rendering.": "Redarea noii \u00eenregistr\u0103ri rapide %(movie_basename)s s-a terminat.", "Invert control": "Inversare comand\u0103", "Webcam": "Webcam", "Remember me": "\u021aine-m\u0103 minte", "Enable GCode Visualizer": "Activeaz\u0103 vizualizarea GCode", "The server appears to be offline, at least I'm not getting any response from it. I'll try to reconnect automatically <strong>over the next couple of minutes</strong>, however you are welcome to try a manual reconnect anytime using the button below.": "Se pare c\u0103 serverul nu este connectat sau, cel pu\u021bin, mie nu-mi r\u0103spunde. Voi \u00eencerca s\u0103 m\u0103 reconectez automat <strong>\u00een urm\u0103toarele dou\u0103 minute</strong>, dar po\u021bi \u00eencerca oric\u00e2nd s\u0103 te reconectezi manual utiliz\u00e2nd butonul de mai jos.", "Rendering failed": "Redarea a e\u0219uat", "Upload Folder": "\u00cencarc\u0103 director", "descending": "descresc\u0103tor", "X": "X", "Add user": "Ad\u0103ugare utilizator", "GCODE commands in layer": "comenzi GCODE \u00een strat", "Estimated print time": "Timp de imprimare estimat", "Serial Connection": "Conexiune serial\u0103", "Control": "Control", "Password": "Parol\u0103", "Also show next layer": "Vizualizare strat urm\u0103tor", "Print Time": "Timp de imprimare", "Sort by file size": "Sortare dup\u0103 m\u0103rimea fi\u0219ierului", "Machine State": "Starea ma\u0219inii", "default": "implicit", "API": "API", "Printing from SD": "Se imprim\u0103 de pe SD", "Terminal filters": "Filtre pentru terminal", "Change password for user \"%(user)s\"": "Modificare parol\u0103 pentru utilizatorul \"%(user)s\"", "Enable Temperature Graph": "Activeaz\u0103 graficul temperaturii", "Delete user": "\u0218tergere utilizator", "Confirm Password": "Confirmare parol\u0103", "Disconnect": "Deconectare", "Slicing done": "Feliere terminat\u0103", "Initialize SD card": "Ini\u021bializare card SD", "System": "Sistem", "Send": "Trimitere", "State": "Stare", "Version": "Versiune", "YYYY-MM-DD HH:mm": "DD.MM.YYYY HH.mm", "Attempt to reconnect": "\u00cencercare de reconectare", "Streaming done": "Transmiterea s-a terminat", "violet": "violet", "Print": "Imprimare", "Layer count": "Num\u0103r de straturi", "OctoPrint Settings": "Configurare OctoPrint", "Are you sure?": "E\u0219ti sigur?", "blue": "albastru", "Printer": "Imprimant\u0103", "Tool": "Unealt\u0103", "Settings": "Configura\u021bii", "Path to FFMPEG": "Cale c\u0103tre FFMPEG", "Upload to SD": "\u00cenc\u0103rcare pe SD", "The command \"%(command)s\" could not be executed.": "Comanda \"%(command)s\" nu a putut fi executat\u0103.", "Printed": "Imprimat", "Layer number": "Num\u0103rul stratului", "Sync with job progress": "Sincronizare cu stadiul lucr\u0103rii", "Circular": "Circular", "Total filament used": "Filament utilizat \u00een total", "red": "ro\u0219u", "Save as default": "Salvare ca valori implicite", "Slicing ...": "Se feliaz\u0103...", "Last Print Time": "Ultima imprimare a durat", "Target": "\u021aint\u0103", "Streaming ...": "Se transmite...", "Logout successful": "DecoLine truncated
|
||||
window.BABEL_TO_LOAD_ro = {"locale": "ro", "domain": "messages", "plural_expr": "(n==1?0:(((n%100>19)||((n%100==0)&&(n!=0)))?2:1))", "messages": {"": "Project-Id-Version: OctoPrint\nReport-Msgid-Bugs-To: i18n@octoprint.org\nPOT-Creation-Date: 2014-12-18 14:45+0100\nPO-Revision-Date: 2014-12-18 14:04+0000\nLast-Translator: Gina H\u00e4u\u00dfge <gina@foosel.net>\nLanguage-Team: Romanian (http://www.transifex.com/projects/p/octoprint/language/ro/)\nPlural-Forms: nplurals=3; plural=(n==1?0:(((n%100>19)||((n%100==0)&&(n!=0)))?2:1))\nMIME-Version: 1.0\nContent-Type: text/plain; charset=utf-8\nContent-Transfer-Encoding: 8bit\nGenerated-By: Babel 1.3\n", "Print Time Left": "Timp de imprimare r\u0103mas", "sec": "sec", "Proceed": "Continuare", "Timelapse Temp Folder": "Director temporar pentru \u00eenregistrarea rapid\u0103", "Support <code>TargetExtr%%n</code>/<code>TargetBed</code> target temperature format": "Sus\u021bine formatul <code>TargetExtr%%n</code>/<code>TargetBed</code> pentru temperatura \u021bint\u0103", "Upload Folder": "\u00cencarc\u0103 director", "Only show files stored locally": "Arat\u0103 doar fi\u0219ierele stocate local", "Add Printer Profile": "", "yellow": "galben", "Save": "Salvare", "Action": "Ac\u021biune", "Passwords do not match": "Parolele nu se potrivesc", "Sort by name": "Sortare dup\u0103 nume", "Save connection settings": "Salvare configura\u021bie conexiune", "Rendering timelapse": "Redare \u00eenregistrare rapid\u0103", "Color": "Culoare", "Temperature": "Temperatur\u0103", "Files": "Fi\u0219iere", "Resume": "", "Always assume SD card is present": "Consider\u0103 \u00eentotdeauna cardul SD prezent", "Load and Print": "\u00cenc\u0103rcare \u0219i imprimare", "Sending file to SD": "Se transmite fi\u0219ierul c\u0103tre SD", "Number of Extruders": "Num\u0103r de extrudere", "black": "negru", "Last Printed": "Ultima dat\u0103 imprimat", "Sourcecode": "Cod surs\u0103", "Estimated layer height": "\u00cen\u0103l\u021bimea stratului estimat\u0103", "You are now logged out": "Acum e\u0219ti deconectat", "Uploaded": "\u00cenc\u0103rcat", "Form Factor": "", "Opening serial port": "Se deschide portul serial", "New timelapse %(movie_basename)s is done rendering.": "Redarea noii \u00eenregistr\u0103ri rapide %(movie_basename)s s-a terminat.", "Invert control": "Inversare comand\u0103", "Webcam": "Webcam", "Select for printing": "", "Allow <a href=\"%(url)s\">Cross Origin Resource Sharing (CORS)</a>": "Permite <a href=\"%(url)s\">Cross Origin Resource Sharing (CORS)</a>", "Remember me": "\u021aine-m\u0103 minte", "Enable GCode Visualizer": "Activeaz\u0103 vizualizarea GCode", "The server appears to be offline, at least I'm not getting any response from it. I'll try to reconnect automatically <strong>over the next couple of minutes</strong>, however you are welcome to try a manual reconnect anytime using the button below.": "Se pare c\u0103 serverul nu este connectat sau, cel pu\u021bin, mie nu-mi r\u0103spunde. Voi \u00eencerca s\u0103 m\u0103 reconectez automat <strong>\u00een urm\u0103toarele dou\u0103 minute</strong>, dar po\u021bi \u00eencerca oric\u00e2nd s\u0103 te reconectezi manual utiliz\u00e2nd butonul de mai jos.", "Rendering failed": "Redarea a e\u0219uat", "Motors off": "Oprire motoare", "descending": "descresc\u0103tor", "Only show files stored on SD": "Arat\u0103 doar fi\u0219ierele stocate pe SD", "X": "X", "Add user": "Ad\u0103ugare utilizator", "GCODE commands in layer": "comenzi GCODE \u00een strat", "Estimated print time": "Timp de imprimare estimat", "Serial Connection": "Conexiune serial\u0103", "Control": "Control", "Password": "Parol\u0103", "Also show next layer": "Vizualizare strat urm\u0103tor", "Print Time": "Timp de imprimare", "Slicer": "", "Nozzle Diameter": "", "Sort by file size": "Sortare dup\u0103 m\u0103rimea fi\u0219ierului", "Machine State": "Starea ma\u0219inii", "Slicing Profile": "", "mm": "mm", "API": "API", "Printing from SD": "Se imprim\u0103 de pe SD", "Stream URL": "URL flux video", "Terminal filters": "Filtre pentru terminal", "Change password for user \"%(user)s\"": "Modificare parol\u0103 pentru utilizatorul \"%(user)s\"", "Enable Temperature Graph": "Activeaz\u0103 graficul temperaturii", "Delete user": "\u0218tergere utilizator", "Timelapse bitrate": "Vitez\u0103 \u00eenregistrare rapid\u0103", "Confirm Password": "Confirmare parol\u0103", "Disconnect": "Deconectare", "Slicing done": "Feliere terminat\u0103", "Initialize SD card": "Ini\u021bializare card SD", "System": "Sistem", "Send": "Trimitere", "State": "Stare", "Version": "Versiune", "YYYY-MM-DD HH:mm": "DD.MM.YYYY HH.mm", "Attempt to reconnect": "\u00cencercare de reconectare", "Streaming done": "Transmiterea s-a terminat", "violet": "violet", "Print": "Imprimare", "Layer count": "Num\u0103r de straturi", "OctoPrint Settings": "Configurare OctoPrint", "Are you sure?": "E\u0219ti sigur?", "blue": "albastru", "Printer": "Imprimant\u0103", "Delete Profile": "", "Tool": "Unealt\u0103",
Line truncated
|
||||
@@ -125,7 +125,7 @@
|
||||
<div class="accordion span4">
|
||||
<div class="accordion-group" data-bind="visible: loginState.isUser" id="connection_accordion">
|
||||
<div class="accordion-heading">
|
||||
<a class="accordion-toggle" data-toggle="collapse" href="#connection"><i class="icon-signal"></i> {{ _('Connection') }}</a>
|
||||
<a class="accordion-toggle" data-toggle="collapse" data-target="#connection"><i class="icon-signal"></i> {{ _('Connection') }}</a>
|
||||
</div>
|
||||
<div class="accordion-body collapse in" id="connection">
|
||||
<div class="accordion-inner">
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
<li><a href="#settings_api" data-toggle="tab">{{ _('API') }}</a></li>
|
||||
<li class="nav-header">OctoPrint</li>
|
||||
<li><a href="#settings_folder" data-toggle="tab">{{ _('Folders') }}</a></li>
|
||||
<li><a href="#settings_appearance" data-toggle="tab">{{ _('Appearance') }}</a></li>
|
||||
<li><a href="#settings_logs" data-toggle="tab">{{ _('Logs') }}</a></li>
|
||||
{% if settingsPlugins %}
|
||||
<li class="nav-header">Plugins</li>
|
||||
@@ -366,7 +367,7 @@
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: feature_alwaysSendChecksum" id="settings-featureAlwaysSendChecksum"> {{ _('Send a checksum with <strong>every</strong> command') }} <span class="label">{{ _('Repetier') }}</span>
|
||||
<input type="checkbox" data-bind="checked: feature_alwaysSendChecksum" id="settings-featureAlwaysSendChecksum"> {{ _('Send a checksum with <strong>every</strong> command (reconnect after changing)') }} <span class="label">{{ _('Repetier') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
@@ -477,6 +478,23 @@
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="tab-pane" id="settings_appearance">
|
||||
<form class="form-horizontal">
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="settings-appearanceName">{{ _('Title') }}</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="input-block-level" data-bind="value: appearance_name" id="settings-appearanceName">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="settings-appearanceColor">{{ _('Color') }}</label>
|
||||
<div class="controls">
|
||||
<select id="settings-appearanceColor" data-bind="value: appearance_color, options: appearance_available_colors, optionsText: 'name', optionsValue: 'key'">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="tab-pane" id="settings_api">
|
||||
<form class="form-horizontal" onsubmit="return false;">
|
||||
<div class="control-group">
|
||||
|
||||
Binary file not shown.
File diff suppressed because it is too large.
Load diff
Binary file not shown.
File diff suppressed because it is too large.
Load diff
Binary file not shown.
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
Binary file not shown.
File diff suppressed because it is too large.
Load diff
Binary file not shown.
File diff suppressed because it is too large.
Load diff
Binary file not shown.
File diff suppressed because it is too large.
Load diff
@@ -8,6 +8,7 @@ import sys
|
||||
import time
|
||||
import re
|
||||
import tempfile
|
||||
import threading
|
||||
import logging
|
||||
from flask import make_response
|
||||
|
||||
@@ -298,3 +299,42 @@ def address_for_client(host, port):
|
||||
pass
|
||||
|
||||
|
||||
class CountedEvent(object):
|
||||
|
||||
def __init__(self, value=0, max=None):
|
||||
self._counter = 0
|
||||
self._max = max
|
||||
self._mutex = threading.Lock()
|
||||
self._event = threading.Event()
|
||||
|
||||
self._internal_set(value)
|
||||
|
||||
def set(self):
|
||||
with self._mutex:
|
||||
self._internal_set(self._counter + 1)
|
||||
|
||||
def clear(self, completely=False):
|
||||
with self._mutex:
|
||||
if completely:
|
||||
self._internal_set(0)
|
||||
else:
|
||||
self._internal_set(self._counter - 1)
|
||||
|
||||
def wait(self, timeout=None):
|
||||
self._event.wait(timeout)
|
||||
|
||||
def blocked(self):
|
||||
with self._mutex:
|
||||
return self._counter == 0
|
||||
|
||||
def _internal_set(self, value):
|
||||
self._counter = value
|
||||
if self._counter <= 0:
|
||||
self._counter = 0
|
||||
self._event.clear()
|
||||
else:
|
||||
if self._max is not None and self._counter > self._max:
|
||||
self._counter = self._max
|
||||
self._event.set()
|
||||
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
import os, struct, sys, time
|
||||
|
||||
from serial import Serial
|
||||
|
||||
import chipDB
|
||||
|
||||
class IspBase():
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import os, struct, sys, time
|
||||
|
||||
from serial import Serial
|
||||
from serial import SerialException
|
||||
from serial import SerialException, SerialTimeoutException
|
||||
|
||||
import ispBase, intelHex
|
||||
|
||||
|
||||
+51
-44
@@ -77,6 +77,8 @@ gcodeToEvent = {
|
||||
"M226": Events.WAITING,
|
||||
"M0": Events.WAITING,
|
||||
"M1": Events.WAITING,
|
||||
# dwell command
|
||||
"G4": Events.DWELL,
|
||||
|
||||
# part cooler
|
||||
"M245": Events.COOLING,
|
||||
@@ -143,10 +145,14 @@ class MachineCom(object):
|
||||
self._bedTempOffset = 0
|
||||
self._commandQueue = queue.Queue()
|
||||
self._currentZ = None
|
||||
self._heatupWaitStartTime = 0
|
||||
self._heatupWaitStartTime = None
|
||||
self._heatupWaitTimeLost = 0.0
|
||||
self._pauseWaitStartTime = None
|
||||
self._pauseWaitTimeLost = 0.0
|
||||
self._currentExtruder = 0
|
||||
|
||||
self._timeout = None
|
||||
|
||||
self._alwaysSendChecksum = settings().getBoolean(["feature", "alwaysSendChecksum"])
|
||||
self._currentLine = 1
|
||||
self._resendDelta = None
|
||||
@@ -314,20 +320,17 @@ class MachineCom(object):
|
||||
if self._currentFile is None or self._currentFile.getStartTime() is None:
|
||||
return None
|
||||
else:
|
||||
return time.time() - self._currentFile.getStartTime()
|
||||
return time.time() - self._currentFile.getStartTime() - self._pauseWaitTimeLost
|
||||
|
||||
def getPrintTimeRemainingEstimate(self):
|
||||
def getCleanedPrintTime(self):
|
||||
printTime = self.getPrintTime()
|
||||
if printTime is None:
|
||||
return None
|
||||
|
||||
printTime /= 60
|
||||
progress = self._currentFile.getProgress()
|
||||
if progress:
|
||||
printTimeTotal = printTime / progress
|
||||
return printTimeTotal - printTime
|
||||
else:
|
||||
return None
|
||||
cleanedPrintTime = printTime - self._heatupWaitTimeLost
|
||||
if cleanedPrintTime < 0:
|
||||
cleanedPrintTime = 0.0
|
||||
return cleanedPrintTime
|
||||
|
||||
def getTemp(self):
|
||||
return self._temp
|
||||
@@ -388,6 +391,11 @@ class MachineCom(object):
|
||||
if self._currentFile is None:
|
||||
raise ValueError("No file selected for printing")
|
||||
|
||||
self._heatupWaitStartTime = 0
|
||||
self._heatupWaitTimeLost = 0.0
|
||||
self._pauseWaitStartTime = 0
|
||||
self._pauseWaitTimeLost = 0.0
|
||||
|
||||
try:
|
||||
self._currentFile.start()
|
||||
|
||||
@@ -470,6 +478,10 @@ class MachineCom(object):
|
||||
return
|
||||
|
||||
if not pause and self.isPaused():
|
||||
if self._pauseWaitStartTime:
|
||||
self._pauseWaitTimeLost = self._pauseWaitTimeLost + (time.time() - self._pauseWaitStartTime)
|
||||
self._pauseWaitStartTime = None
|
||||
|
||||
self._changeState(self.STATE_PRINTING)
|
||||
if self.isSdFileSelected():
|
||||
self.sendCommand("M24")
|
||||
@@ -482,6 +494,9 @@ class MachineCom(object):
|
||||
"origin": self._currentFile.getFileLocation()
|
||||
})
|
||||
elif pause and self.isPrinting():
|
||||
if not self._pauseWaitStartTime:
|
||||
self._pauseWaitStartTime = time.time()
|
||||
|
||||
self._changeState(self.STATE_PAUSED)
|
||||
if self.isSdFileSelected():
|
||||
self.sendCommand("M25") # pause print
|
||||
@@ -495,21 +510,6 @@ class MachineCom(object):
|
||||
def getSdFiles(self):
|
||||
return self._sdFiles
|
||||
|
||||
def startSdFileTransfer(self, filename):
|
||||
if not self.isOperational() or self.isBusy():
|
||||
return
|
||||
|
||||
self._changeState(self.STATE_TRANSFERING_FILE)
|
||||
self.sendCommand("M28 %s" % filename.lower())
|
||||
|
||||
def endSdFileTransfer(self, filename):
|
||||
if not self.isOperational() or self.isBusy():
|
||||
return
|
||||
|
||||
self.sendCommand("M29 %s" % filename.lower())
|
||||
self._changeState(self.STATE_OPERATIONAL)
|
||||
self.refreshSdFiles()
|
||||
|
||||
def deleteSdFile(self, filename):
|
||||
if not self.isOperational() or (self.isBusy() and
|
||||
isinstance(self._currentFile, PrintingSdFileInformation) and
|
||||
@@ -637,9 +637,11 @@ class MachineCom(object):
|
||||
self._changeState(self.STATE_CONNECTING)
|
||||
|
||||
#Start monitoring the serial port.
|
||||
timeout = getNewTimeout("communication")
|
||||
self._timeout = getNewTimeout("communication")
|
||||
|
||||
tempRequestTimeout = getNewTimeout("temperature")
|
||||
sdStatusRequestTimeout = getNewTimeout("sdStatus")
|
||||
|
||||
startSeen = not settings().getBoolean(["feature", "waitForStartOnConnect"])
|
||||
heatingUp = False
|
||||
swallowOk = False
|
||||
@@ -651,7 +653,7 @@ class MachineCom(object):
|
||||
if line is None:
|
||||
break
|
||||
if line.strip() is not "":
|
||||
timeout = getNewTimeout("communication")
|
||||
self._timeout = getNewTimeout("communication")
|
||||
|
||||
##~~ Error handling
|
||||
line = self._handleErrors(line)
|
||||
@@ -688,12 +690,9 @@ class MachineCom(object):
|
||||
self._callback.mcTempUpdate(self._temp, self._bedTemp)
|
||||
|
||||
#If we are waiting for an M109 or M190 then measure the time we lost during heatup, so we can remove that time from our printing time estimate.
|
||||
if not 'ok' in line:
|
||||
heatingUp = True
|
||||
if self._heatupWaitStartTime != 0:
|
||||
t = time.time()
|
||||
self._heatupWaitTimeLost = t - self._heatupWaitStartTime
|
||||
self._heatupWaitStartTime = t
|
||||
if 'ok' in line and self._heatupWaitStartTime:
|
||||
self._heatupWaitTimeLost = self._heatupWaitTimeLost + (time.time() - self._heatupWaitStartTime)
|
||||
self._heatupWaitStartTime = None
|
||||
elif supportRepetierTargetTemp and ('TargetExtr' in line or 'TargetBed' in line):
|
||||
matchExtr = self._regex_repetierTempExtr.match(line)
|
||||
matchBed = self._regex_repetierTempBed.match(line)
|
||||
@@ -823,7 +822,7 @@ class MachineCom(object):
|
||||
|
||||
### Baudrate detection
|
||||
if self._state == self.STATE_DETECT_BAUDRATE:
|
||||
if line == '' or time.time() > timeout:
|
||||
if line == '' or time.time() > self._timeout:
|
||||
if len(self._baudrateDetectList) < 1:
|
||||
self.close()
|
||||
self._errorValue = "No more baudrates to test, and no suitable baudrate found."
|
||||
@@ -843,7 +842,7 @@ class MachineCom(object):
|
||||
self._log("Trying baudrate: %d" % (baudrate))
|
||||
self._baudrateDetectRetry = 5
|
||||
self._baudrateDetectTestOk = 0
|
||||
timeout = getNewTimeout("communication")
|
||||
self._timeout = getNewTimeout("communication")
|
||||
self._serial.write('\n')
|
||||
self._sendCommand("M105")
|
||||
self._testingBaudrate = True
|
||||
@@ -879,7 +878,7 @@ class MachineCom(object):
|
||||
else:
|
||||
self.initSdCard()
|
||||
eventManager().fire(Events.CONNECTED, {"port": self._port, "baudrate": self._baudrate})
|
||||
elif time.time() > timeout:
|
||||
elif time.time() > self._timeout:
|
||||
self.close()
|
||||
|
||||
### Operational
|
||||
@@ -901,7 +900,7 @@ class MachineCom(object):
|
||||
|
||||
### Printing
|
||||
elif self._state == self.STATE_PRINTING:
|
||||
if line == "" and time.time() > timeout:
|
||||
if line == "" and time.time() > self._timeout:
|
||||
self._log("Communication timeout during printing, forcing a line")
|
||||
line = 'ok'
|
||||
|
||||
@@ -1238,14 +1237,25 @@ class MachineCom(object):
|
||||
self._resendDelta = None
|
||||
|
||||
return None
|
||||
def _gcode_M112(self, cmd): # It's an emergency what todo? Canceling the print should be the minimum
|
||||
self.cancelPrint()
|
||||
return cmd
|
||||
|
||||
def _gcode_M112(self, cmd): # It's an emergency what todo? Canceling the print should be the minimum
|
||||
self.cancelPrint()
|
||||
return cmd
|
||||
|
||||
def _gcode_G4(self, cmd):
|
||||
# we are intending to dwell for a period of time, increase the timeout to match
|
||||
cmd = cmd.upper()
|
||||
p_idx = cmd.find('P')
|
||||
s_idx = cmd.find('S')
|
||||
_timeout = 0
|
||||
if p_idx != -1:
|
||||
# dwell time is specified in milliseconds
|
||||
_timeout = int(cmd[p_idx+1:]) / 1000.0
|
||||
elif s_idx != -1:
|
||||
# dwell time is specified in seconds
|
||||
_timeout = int(cmd[s_idx+1:])
|
||||
self._timeout = getNewTimeout("communication") + _timeout
|
||||
return cmd
|
||||
|
||||
### MachineCom callback ################################################################################################
|
||||
|
||||
@@ -1386,9 +1396,9 @@ class PrintingGcodeFileInformation(PrintingFileInformation):
|
||||
"""
|
||||
Opens the file for reading and determines the file size. Start time won't be recorded until 100 lines in
|
||||
"""
|
||||
PrintingFileInformation.start(self)
|
||||
self._filehandle = open(self._filename, "r")
|
||||
self._lineCount = None
|
||||
self._startTime = None
|
||||
|
||||
def getNext(self):
|
||||
"""
|
||||
@@ -1415,9 +1425,6 @@ class PrintingGcodeFileInformation(PrintingFileInformation):
|
||||
self._lineCount += 1
|
||||
self._filepos = self._filehandle.tell()
|
||||
|
||||
if self._lineCount >= 100 and self._startTime is None:
|
||||
self._startTime = time.time()
|
||||
|
||||
return processedLine
|
||||
except Exception as (e):
|
||||
if self._filehandle is not None:
|
||||
|
||||
@@ -43,6 +43,7 @@ class gcode(object):
|
||||
|
||||
def _load(self, gcodeFile, printer_profile):
|
||||
filePos = 0
|
||||
readBytes = 0
|
||||
pos = [0.0, 0.0, 0.0]
|
||||
posOffset = [0.0, 0.0, 0.0]
|
||||
currentE = [0.0]
|
||||
@@ -53,29 +54,46 @@ class gcode(object):
|
||||
absoluteE = True
|
||||
scale = 1.0
|
||||
posAbs = True
|
||||
feedRateXY = min(printer_profile["axes"]["x"], printer_profile["axes"]["y"])
|
||||
feedRateXY = min(printer_profile["axes"]["x"]["speed"], printer_profile["axes"]["y"]["speed"])
|
||||
offsets = printer_profile["extruder"]["offsets"]
|
||||
|
||||
for line in gcodeFile:
|
||||
if self._abort:
|
||||
raise AnalysisAborted()
|
||||
filePos += 1
|
||||
readBytes += len(line)
|
||||
|
||||
if isinstance(gcodeFile, (file)):
|
||||
percentage = float(readBytes) / float(self._fileSize)
|
||||
elif isinstance(gcodeFile, (list)):
|
||||
percentage = float(filePos) / float(len(gcodeFile))
|
||||
else:
|
||||
percentage = None
|
||||
|
||||
try:
|
||||
if self.progressCallback is not None and (filePos % 1000 == 0):
|
||||
if isinstance(gcodeFile, (file)):
|
||||
self.progressCallback(float(gcodeFile.tell()) / float(self._fileSize))
|
||||
elif isinstance(gcodeFile, (list)):
|
||||
self.progressCallback(float(filePos) / float(len(gcodeFile)))
|
||||
if self.progressCallback is not None and (filePos % 1000 == 0) and percentage is not None:
|
||||
self.progressCallback(percentage)
|
||||
except:
|
||||
pass
|
||||
|
||||
if ';' in line:
|
||||
comment = line[line.find(';')+1:].strip()
|
||||
if comment.startswith("filament_diameter"):
|
||||
self._filamentDiameter = float(comment.split("=", 1)[1].strip())
|
||||
elif comment.startswith("CURA_PROFILE_STRING"):
|
||||
curaOptions = self._parseCuraProfileString(comment)
|
||||
filamentValue = comment.split("=", 1)[1].strip()
|
||||
try:
|
||||
self._filamentDiameter = float(filamentValue)
|
||||
except ValueError:
|
||||
try:
|
||||
self._filamentDiameter = float(filamentValue.split(",")[0].strip())
|
||||
except ValueError:
|
||||
self._filamentDiameter = 0.0
|
||||
elif comment.startswith("CURA_PROFILE_STRING") or comment.startswith("CURA_OCTO_PROFILE_STRING"):
|
||||
if comment.startswith("CURA_PROFILE_STRING"):
|
||||
prefix = "CURA_PROFILE_STRING:"
|
||||
else:
|
||||
prefix = "CURA_OCTO_PROFILE_STRING:"
|
||||
|
||||
curaOptions = self._parseCuraProfileString(comment, prefix)
|
||||
if "filament_diameter" in curaOptions:
|
||||
try:
|
||||
self._filamentDiameter = float(curaOptions["filament_diameter"])
|
||||
@@ -226,8 +244,8 @@ class gcode(object):
|
||||
self.extrusionVolume[i] = (self.extrusionAmount[i] * (math.pi * radius * radius)) / 1000
|
||||
self.totalMoveTimeMinute = totalMoveTimeMinute
|
||||
|
||||
def _parseCuraProfileString(self, comment):
|
||||
return {key: value for (key, value) in map(lambda x: x.split("=", 1), zlib.decompress(base64.b64decode(comment[len("CURA_PROFILE_STRING:"):])).split("\b"))}
|
||||
def _parseCuraProfileString(self, comment, prefix):
|
||||
return {key: value for (key, value) in map(lambda x: x.split("=", 1), zlib.decompress(base64.b64decode(comment[len(prefix):])).split("\b"))}
|
||||
|
||||
|
||||
def getCodeInt(line, code):
|
||||
|
||||
+400
-181
@@ -9,21 +9,42 @@ import os
|
||||
import re
|
||||
import threading
|
||||
import math
|
||||
import Queue
|
||||
|
||||
from serial import SerialTimeoutException
|
||||
|
||||
from octoprint.settings import settings
|
||||
|
||||
class VirtualPrinter():
|
||||
def __init__(self):
|
||||
self.readList = ['start\n', 'Marlin: Virtual Marlin!\n', '\x80\n', 'SD init fail\n'] # no sd card as default startup scenario
|
||||
def __init__(self, read_timeout=5.0, write_timeout=10.0):
|
||||
self._read_timeout = read_timeout
|
||||
self._write_timeout = write_timeout
|
||||
|
||||
self.incoming = CharCountingQueue(settings().getInt(["devel", "virtualPrinter", "rxBuffer"]), name="RxBuffer")
|
||||
self.outgoing = Queue.Queue()
|
||||
self.buffered = Queue.Queue(maxsize=settings().getInt(["devel", "virtualPrinter", "commandBuffer"]))
|
||||
|
||||
for item in ['start\n', 'Marlin: Virtual Marlin!\n', '\x80\n', 'SD card ok\n']: # no sd card as default startup scenario
|
||||
self.outgoing.put(item)
|
||||
|
||||
self.currentExtruder = 0
|
||||
self.temp = [0.0] * settings().getInt(["devel", "virtualPrinter", "numExtruders"])
|
||||
self.targetTemp = [0.0] * settings().getInt(["devel", "virtualPrinter", "numExtruders"])
|
||||
self.lastTempAt = time.time()
|
||||
self.bedTemp = 1.0
|
||||
self.bedTargetTemp = 1.0
|
||||
self.speeds = settings().get(["devel", "virtualPrinter", "movementSpeed"])
|
||||
|
||||
self._relative = True
|
||||
self._lastX = None
|
||||
self._lastY = None
|
||||
self._lastZ = None
|
||||
self._lastE = None
|
||||
|
||||
self._unitModifier = 1
|
||||
|
||||
self._virtualSd = settings().getBaseFolder("virtualSd")
|
||||
self._sdCardReady = False
|
||||
self._sdCardReady = True
|
||||
self._sdPrinter = None
|
||||
self._sdPrintingSemaphore = threading.Event()
|
||||
self._selectedSdFile = None
|
||||
@@ -36,151 +57,211 @@ class VirtualPrinter():
|
||||
self.currentLine = 0
|
||||
self.lastN = 0
|
||||
|
||||
self._incoming_lock = threading.RLock()
|
||||
|
||||
waitThread = threading.Thread(target=self._sendWaitAfterTimeout)
|
||||
waitThread.start()
|
||||
|
||||
def write(self, data):
|
||||
if self.readList is None:
|
||||
return
|
||||
readThread = threading.Thread(target=self._processIncoming)
|
||||
readThread.start()
|
||||
|
||||
data = data.strip()
|
||||
bufferThread = threading.Thread(target=self._processBuffer)
|
||||
bufferThread.start()
|
||||
|
||||
# strip checksum
|
||||
if "*" in data:
|
||||
data = data[:data.rfind("*")]
|
||||
self.currentLine += 1
|
||||
elif settings().getBoolean(["devel", "virtualPrinter", "forceChecksum"]):
|
||||
self.readList.append("Error: Missing checksum")
|
||||
return
|
||||
def __str__(self):
|
||||
return "VIRTUAL(read_timeout={read_timeout},write_timeout={write_timeout},options={options})"\
|
||||
.format(read_timeout=self._read_timeout, write_timeout=self._write_timeout, options=settings().get(["devel", "virtualPrinter"]))
|
||||
|
||||
# track N = N + 1
|
||||
if data.startswith("N") and "M110" in data:
|
||||
linenumber = int(re.search("N([0-9]+)", data).group(1))
|
||||
self.lastN = linenumber
|
||||
self.currentLine = linenumber
|
||||
self._sendOk()
|
||||
return
|
||||
elif data.startswith("N"):
|
||||
linenumber = int(re.search("N([0-9]+)", data).group(1))
|
||||
expected = self.lastN + 1
|
||||
if linenumber != expected:
|
||||
self.readList.append("Error: expected line %d got %d" % (expected, linenumber))
|
||||
self.readList.append("Resend:%d" % expected)
|
||||
if settings().getBoolean(["devel", "virtualPrinter", "okAfterResend"]):
|
||||
self.readList.append("ok")
|
||||
return
|
||||
elif self.currentLine == 100:
|
||||
# simulate a resend at line 100 of the last 5 lines
|
||||
self.lastN = 94
|
||||
self.readList.append("Error: Line Number is not Last Line Number\n")
|
||||
self.readList.append("rs %d\n" % (self.currentLine - 5))
|
||||
if settings().getBoolean(["devel", "virtualPrinter", "okAfterResend"]):
|
||||
self.readList.append("ok")
|
||||
return
|
||||
else:
|
||||
def _clearQueue(self, queue):
|
||||
try:
|
||||
while queue.get(block=False):
|
||||
continue
|
||||
except Queue.Empty:
|
||||
pass
|
||||
|
||||
def _processIncoming(self):
|
||||
while self.incoming is not None:
|
||||
self._simulateTemps()
|
||||
|
||||
try:
|
||||
data = self.incoming.get(timeout=0.01)
|
||||
except Queue.Empty:
|
||||
continue
|
||||
|
||||
if data is None:
|
||||
continue
|
||||
|
||||
data = data.strip()
|
||||
|
||||
# strip checksum
|
||||
if "*" in data:
|
||||
data = data[:data.rfind("*")]
|
||||
self.currentLine += 1
|
||||
elif settings().getBoolean(["devel", "virtualPrinter", "forceChecksum"]):
|
||||
self.outgoing.put("Error: Missing checksum")
|
||||
continue
|
||||
|
||||
# track N = N + 1
|
||||
if data.startswith("N") and "M110" in data:
|
||||
linenumber = int(re.search("N([0-9]+)", data).group(1))
|
||||
self.lastN = linenumber
|
||||
data = data.split(None, 1)[1].strip()
|
||||
self.currentLine = linenumber
|
||||
self._sendOk()
|
||||
continue
|
||||
elif data.startswith("N"):
|
||||
linenumber = int(re.search("N([0-9]+)", data).group(1))
|
||||
expected = self.lastN + 1
|
||||
if linenumber != expected:
|
||||
with self._incoming_lock:
|
||||
self._clearQueue(self.incoming)
|
||||
self.outgoing.put("Error: expected line %d got %d" % (expected, linenumber))
|
||||
self.outgoing.put("Resend:%d" % expected)
|
||||
self.outgoing.put("ok")
|
||||
continue
|
||||
elif self.currentLine == 100:
|
||||
# simulate a resend at line 100
|
||||
with self._incoming_lock:
|
||||
self.lastN = 99
|
||||
self._clearQueue(self.incoming)
|
||||
self.outgoing.put("Error: Line Number is not Last Line Number\n")
|
||||
self.outgoing.put("rs 100\n")
|
||||
self.outgoing.put("ok")
|
||||
continue
|
||||
else:
|
||||
self.lastN = linenumber
|
||||
data = data.split(None, 1)[1].strip()
|
||||
|
||||
data += "\n"
|
||||
data += "\n"
|
||||
|
||||
# shortcut for writing to SD
|
||||
if self._writingToSd and not self._selectedSdFile is None and not "M29" in data:
|
||||
with open(self._selectedSdFile, "a") as f:
|
||||
f.write(data)
|
||||
self._sendOk()
|
||||
return
|
||||
# shortcut for writing to SD
|
||||
if self._writingToSd and not self._selectedSdFile is None and not "M29" in data:
|
||||
with open(self._selectedSdFile, "a") as f:
|
||||
f.write(data)
|
||||
self._sendOk()
|
||||
continue
|
||||
|
||||
#print "Send: %s" % (data.rstrip())
|
||||
if 'M104' in data or 'M109' in data:
|
||||
self._parseHotendCommand(data)
|
||||
return
|
||||
#print "Send: %s" % (data.rstrip())
|
||||
if 'M104' in data or 'M109' in data:
|
||||
self._parseHotendCommand(data)
|
||||
continue
|
||||
|
||||
if 'M140' in data or 'M190' in data:
|
||||
self._parseBedCommand(data)
|
||||
return
|
||||
if 'M140' in data or 'M190' in data:
|
||||
self._parseBedCommand(data)
|
||||
continue
|
||||
|
||||
if 'M105' in data:
|
||||
self._processTemperatureQuery()
|
||||
elif 'M20' in data:
|
||||
if self._sdCardReady:
|
||||
self._listSd()
|
||||
elif 'M21' in data:
|
||||
self._sdCardReady = True
|
||||
self.readList.append("SD card ok")
|
||||
elif 'M22' in data:
|
||||
self._sdCardReady = False
|
||||
elif 'M23' in data:
|
||||
if self._sdCardReady:
|
||||
filename = data.split(None, 1)[1].strip()
|
||||
self._selectSdFile(filename)
|
||||
elif 'M24' in data:
|
||||
if self._sdCardReady:
|
||||
self._startSdPrint()
|
||||
elif 'M25' in data:
|
||||
if self._sdCardReady:
|
||||
self._pauseSdPrint()
|
||||
elif 'M26' in data:
|
||||
if self._sdCardReady:
|
||||
pos = int(re.search("S([0-9]+)", data).group(1))
|
||||
self._setSdPos(pos)
|
||||
elif 'M27' in data:
|
||||
if self._sdCardReady:
|
||||
self._reportSdStatus()
|
||||
elif 'M28' in data:
|
||||
if self._sdCardReady:
|
||||
filename = data.split(None, 1)[1].strip()
|
||||
self._writeSdFile(filename)
|
||||
elif 'M29' in data:
|
||||
if self._sdCardReady:
|
||||
self._finishSdFile()
|
||||
elif 'M30' in data:
|
||||
if self._sdCardReady:
|
||||
filename = data.split(None, 1)[1].strip()
|
||||
self._deleteSdFile(filename)
|
||||
elif "M114" in data:
|
||||
# send dummy position report
|
||||
self.readList.append("ok C: X:10.00 Y:3.20 Z:5.20 E:1.24")
|
||||
elif "M117" in data:
|
||||
# we'll just use this to echo a message, to allow playing around with pause triggers
|
||||
self.readList.append("ok %s" % re.search("M117\s+(.*)", data).group(1))
|
||||
elif "M999" in data:
|
||||
# mirror Marlin behaviour
|
||||
self.readList.append("Resend: 1")
|
||||
elif data.startswith("T"):
|
||||
self.currentExtruder = int(re.search("T(\d+)", data).group(1))
|
||||
self._sendOk()
|
||||
self.readList.append("Active Extruder: %d" % self.currentExtruder)
|
||||
elif len(data.strip()) > 0:
|
||||
self._sendOk()
|
||||
if 'M105' in data:
|
||||
self._processTemperatureQuery()
|
||||
continue
|
||||
elif 'M20' in data:
|
||||
if self._sdCardReady:
|
||||
self._listSd()
|
||||
elif 'M21' in data:
|
||||
self._sdCardReady = True
|
||||
self.outgoing.put("SD card ok")
|
||||
elif 'M22' in data:
|
||||
self._sdCardReady = False
|
||||
elif 'M23' in data:
|
||||
if self._sdCardReady:
|
||||
filename = data.split(None, 1)[1].strip()
|
||||
self._selectSdFile(filename)
|
||||
elif 'M24' in data:
|
||||
if self._sdCardReady:
|
||||
self._startSdPrint()
|
||||
elif 'M25' in data:
|
||||
if self._sdCardReady:
|
||||
self._pauseSdPrint()
|
||||
elif 'M26' in data:
|
||||
if self._sdCardReady:
|
||||
pos = int(re.search("S([0-9]+)", data).group(1))
|
||||
self._setSdPos(pos)
|
||||
elif 'M27' in data:
|
||||
if self._sdCardReady:
|
||||
self._reportSdStatus()
|
||||
elif 'M28' in data:
|
||||
if self._sdCardReady:
|
||||
filename = data.split(None, 1)[1].strip()
|
||||
self._writeSdFile(filename)
|
||||
elif 'M29' in data:
|
||||
if self._sdCardReady:
|
||||
self._finishSdFile()
|
||||
elif 'M30' in data:
|
||||
if self._sdCardReady:
|
||||
filename = data.split(None, 1)[1].strip()
|
||||
self._deleteSdFile(filename)
|
||||
elif "M114" in data:
|
||||
# send dummy position report
|
||||
self.outgoing.put("ok C: X:10.00 Y:3.20 Z:5.20 E:1.24")
|
||||
continue
|
||||
elif "M117" in data:
|
||||
# we'll just use this to echo a message, to allow playing around with pause triggers
|
||||
self.outgoing.put("echo:%s" % re.search("M117\s+(.*)", data).group(1))
|
||||
elif "M999" in data:
|
||||
# mirror Marlin behaviour
|
||||
self.outgoing.put("Resend: 1")
|
||||
elif data.startswith("T"):
|
||||
self.currentExtruder = int(re.search("T(\d+)", data).group(1))
|
||||
self.outgoing.put("Active Extruder: %d" % self.currentExtruder)
|
||||
elif "G20" in data:
|
||||
self._unitModifier = 1.0 / 2.54
|
||||
if self._lastX is not None:
|
||||
self._lastX *= 2.54
|
||||
if self._lastY is not None:
|
||||
self._lastY *= 2.54
|
||||
if self._lastZ is not None:
|
||||
self._lastZ *= 2.54
|
||||
if self._lastE is not None:
|
||||
self._lastE *= 2.54
|
||||
elif "G21" in data:
|
||||
self._unitModifier = 1.0
|
||||
if self._lastX is not None:
|
||||
self._lastX /= 2.54
|
||||
if self._lastY is not None:
|
||||
self._lastY /= 2.54
|
||||
if self._lastZ is not None:
|
||||
self._lastZ /= 2.54
|
||||
if self._lastE is not None:
|
||||
self._lastE /= 2.54
|
||||
elif "G90" in data:
|
||||
self._relative = False
|
||||
elif "G91" in data:
|
||||
self._relative = True
|
||||
elif "G92" in data:
|
||||
self._setPosition(data)
|
||||
|
||||
elif data.startswith("G0") or data.startswith("G1") or data.startswith("G2") or data.startswith("G3") \
|
||||
or data.startswith("G28") or data.startswith("G29") or data.startswith("G30") \
|
||||
or data.startswith("G31") or data.startswith("G32"):
|
||||
# simulate reprap buffered commands via a Queue with maxsize which internally simulates the moves
|
||||
self.buffered.put(data)
|
||||
|
||||
if len(data.strip()) > 0:
|
||||
self._sendOk()
|
||||
|
||||
def _listSd(self):
|
||||
self.readList.append("Begin file list")
|
||||
self.outgoing.put("Begin file list")
|
||||
if settings().getBoolean(["devel", "virtualPrinter", "extendedSdFileList"]):
|
||||
self.readList.extend(
|
||||
map(
|
||||
lambda x: "%s %d" % (x.upper(), os.stat(os.path.join(self._virtualSd, x)).st_size),
|
||||
os.listdir(self._virtualSd)
|
||||
)
|
||||
items = map(
|
||||
lambda x: "%s %d" % (x.upper(), os.stat(os.path.join(self._virtualSd, x)).st_size),
|
||||
os.listdir(self._virtualSd)
|
||||
)
|
||||
else:
|
||||
self.readList.extend(
|
||||
map(
|
||||
lambda x: x.upper(),
|
||||
os.listdir(self._virtualSd)
|
||||
)
|
||||
items = map(
|
||||
lambda x: x.upper(),
|
||||
os.listdir(self._virtualSd)
|
||||
)
|
||||
self.readList.append("End file list")
|
||||
self._sendOk()
|
||||
for item in items:
|
||||
self.outgoing.put(item)
|
||||
self.outgoing.put("End file list")
|
||||
|
||||
def _selectSdFile(self, filename):
|
||||
file = os.path.join(self._virtualSd, filename).lower()
|
||||
if not os.path.exists(file) or not os.path.isfile(file):
|
||||
self.readList.append("open failed, File: %s." % filename)
|
||||
self.outgoing.put("open failed, File: %s." % filename)
|
||||
else:
|
||||
self._selectedSdFile = file
|
||||
self._selectedSdFileSize = os.stat(file).st_size
|
||||
self.readList.append("File opened: %s Size: %d" % (filename, self._selectedSdFileSize))
|
||||
self.readList.append("File selected")
|
||||
self.outgoing.put("File opened: %s Size: %d" % (filename, self._selectedSdFileSize))
|
||||
self.outgoing.put("File selected")
|
||||
|
||||
def _startSdPrint(self):
|
||||
if self._selectedSdFile is not None:
|
||||
@@ -188,20 +269,18 @@ class VirtualPrinter():
|
||||
self._sdPrinter = threading.Thread(target=self._sdPrintingWorker)
|
||||
self._sdPrinter.start()
|
||||
self._sdPrintingSemaphore.set()
|
||||
self._sendOk()
|
||||
|
||||
def _pauseSdPrint(self):
|
||||
self._sdPrintingSemaphore.clear()
|
||||
self._sendOk()
|
||||
|
||||
def _setSdPos(self, pos):
|
||||
self._newSdFilePos = pos
|
||||
|
||||
def _reportSdStatus(self):
|
||||
if self._sdPrinter is not None and self._sdPrintingSemaphore.is_set:
|
||||
self.readList.append("SD printing byte %d/%d" % (self._selectedSdFilePos, self._selectedSdFileSize))
|
||||
self.outgoing.put("SD printing byte %d/%d" % (self._selectedSdFilePos, self._selectedSdFileSize))
|
||||
else:
|
||||
self.readList.append("Not SD printing")
|
||||
self.outgoing.put("Not SD printing")
|
||||
|
||||
def _processTemperatureQuery(self):
|
||||
includeTarget = not settings().getBoolean(["devel", "virtualPrinter", "repetierStyleTargetTemperature"])
|
||||
@@ -224,16 +303,16 @@ class VirtualPrinter():
|
||||
|
||||
if settings().getBoolean(["devel", "virtualPrinter", "includeCurrentToolInTemps"]):
|
||||
if includeTarget:
|
||||
self.readList.append("ok T:%.2f /%.2f %s @:64\n" % (self.temp[self.currentExtruder], self.targetTemp[self.currentExtruder] + 1, allTempsString))
|
||||
self.outgoing.put("ok T:%.2f /%.2f %s @:64\n" % (self.temp[self.currentExtruder], self.targetTemp[self.currentExtruder] + 1, allTempsString))
|
||||
else:
|
||||
self.readList.append("ok T:%.2f %s @:64\n" % (self.temp[self.currentExtruder], allTempsString))
|
||||
self.outgoing.put("ok T:%.2f %s @:64\n" % (self.temp[self.currentExtruder], allTempsString))
|
||||
else:
|
||||
self.readList.append("ok %s @:64\n" % allTempsString)
|
||||
self.outgoing.put("ok %s @:64\n" % allTempsString)
|
||||
else:
|
||||
if includeTarget:
|
||||
self.readList.append("ok T:%.2f /%.2f B:%.2f /%.2f @:64\n" % (self.temp[0], self.targetTemp[0], self.bedTemp, self.bedTargetTemp))
|
||||
self.outgoing.put("ok T:%.2f /%.2f B:%.2f /%.2f @:64\n" % (self.temp[0], self.targetTemp[0], self.bedTemp, self.bedTargetTemp))
|
||||
else:
|
||||
self.readList.append("ok T:%.2f B:%.2f @:64\n" % (self.temp[0], self.bedTemp))
|
||||
self.outgoing.put("ok T:%.2f B:%.2f @:64\n" % (self.temp[0], self.bedTemp))
|
||||
|
||||
def _parseHotendCommand(self, line):
|
||||
tool = 0
|
||||
@@ -254,14 +333,10 @@ class VirtualPrinter():
|
||||
pass
|
||||
|
||||
if "M109" in line:
|
||||
self._heatupThread = threading.Thread(target=self._waitForHeatup, args=["tool%d" % tool])
|
||||
self._heatupThread.start()
|
||||
return
|
||||
|
||||
self._sendOk()
|
||||
|
||||
self._waitForHeatup("tool%d" % tool)
|
||||
if settings().getBoolean(["devel", "virtualPrinter", "repetierStyleTargetTemperature"]):
|
||||
self.readList.append("TargetExtr%d:%d" % (tool, self.targetTemp[tool]))
|
||||
self.outgoing.put("TargetExtr%d:%d" % (tool, self.targetTemp[tool]))
|
||||
self._sendOk()
|
||||
|
||||
def _parseBedCommand(self, line):
|
||||
try:
|
||||
@@ -270,14 +345,98 @@ class VirtualPrinter():
|
||||
pass
|
||||
|
||||
if "M190" in line:
|
||||
self._heatupThread = threading.Thread(target=self._waitForHeatup, args=["bed"])
|
||||
self._heatupThread.start()
|
||||
return
|
||||
|
||||
self._waitForHeatup("bed")
|
||||
if settings().getBoolean(["devel", "virtualPrinter", "repetierStyleTargetTemperature"]):
|
||||
self.outgoing.put("TargetBed:%d" % self.bedTargetTemp)
|
||||
self._sendOk()
|
||||
|
||||
if settings().getBoolean(["devel", "virtualPrinter", "repetierStyleTargetTemperature"]):
|
||||
self.readList.append("TargetBed:%d" % self.bedTargetTemp)
|
||||
def _performMove(self, line):
|
||||
matchX = re.search("X([0-9.]+)", line)
|
||||
matchY = re.search("Y([0-9.]+)", line)
|
||||
matchZ = re.search("Z([0-9.]+)", line)
|
||||
matchE = re.search("E([0-9.]+)", line)
|
||||
|
||||
duration = 0
|
||||
if matchX is not None:
|
||||
try:
|
||||
x = float(matchX.group(1))
|
||||
if self._relative or self._lastX is None:
|
||||
duration = max(duration, x * self._unitModifier / float(self.speeds["x"]) * 60.0)
|
||||
else:
|
||||
duration = max(duration, (x - self._lastX) * self._unitModifier / float(self.speeds["x"]) * 60.0)
|
||||
self._lastX = x
|
||||
except:
|
||||
pass
|
||||
if matchY is not None:
|
||||
try:
|
||||
y = float(matchY.group(1))
|
||||
if self._relative or self._lastY is None:
|
||||
duration = max(duration, y * self._unitModifier / float(self.speeds["y"]) * 60.0)
|
||||
else:
|
||||
duration = max(duration, (y - self._lastY) * self._unitModifier / float(self.speeds["y"]) * 60.0)
|
||||
self._lastY = y
|
||||
except:
|
||||
pass
|
||||
if matchZ is not None:
|
||||
try:
|
||||
z = float(matchZ.group(1))
|
||||
if self._relative or self._lastZ is None:
|
||||
duration = max(duration, z * self._unitModifier / float(self.speeds["z"]) * 60.0)
|
||||
else:
|
||||
duration = max(duration, (z - self._lastZ) * self._unitModifier / float(self.speeds["z"]) * 60.0)
|
||||
self._lastZ = z
|
||||
except:
|
||||
pass
|
||||
if matchE is not None:
|
||||
try:
|
||||
e = float(matchE.group(1))
|
||||
if self._relative or self._lastE is None:
|
||||
duration = max(duration, e * self._unitModifier / float(self.speeds["e"]) * 60.0)
|
||||
else:
|
||||
duration = max(duration, (e - self._lastE) * self._unitModifier / float(self.speeds["e"]) * 60.0)
|
||||
self._lastE = e
|
||||
except:
|
||||
pass
|
||||
|
||||
if duration:
|
||||
if settings().getBoolean(["devel", "virtualPrinter", "waitOnLongMoves"]):
|
||||
slept = 0
|
||||
while duration - slept > self._read_timeout:
|
||||
time.sleep(self._read_timeout)
|
||||
self.outgoing.put("wait")
|
||||
slept += self._read_timeout
|
||||
else:
|
||||
time.sleep(duration)
|
||||
|
||||
def _setPosition(self, line):
|
||||
matchX = re.search("X([0-9.]+)", line)
|
||||
matchY = re.search("Y([0-9.]+)", line)
|
||||
matchZ = re.search("Z([0-9.]+)", line)
|
||||
matchE = re.search("E([0-9.]+)", line)
|
||||
|
||||
if matchX is None and matchY is None and matchZ is None and matchE is None:
|
||||
self._lastX = self._lastY = self._lastZ = self._lastE = 0
|
||||
else:
|
||||
if matchX is not None:
|
||||
try:
|
||||
self._lastX = float(matchX.group(1))
|
||||
except:
|
||||
pass
|
||||
if matchY is not None:
|
||||
try:
|
||||
self._lastY = float(matchY.group(1))
|
||||
except:
|
||||
pass
|
||||
if matchZ is not None:
|
||||
try:
|
||||
self._lastZ = float(matchZ.group(1))
|
||||
except:
|
||||
pass
|
||||
if matchE is not None:
|
||||
try:
|
||||
self._lastE = float(matchE.group(1))
|
||||
except:
|
||||
pass
|
||||
|
||||
def _writeSdFile(self, filename):
|
||||
file = os.path.join(self._virtualSd, filename).lower()
|
||||
@@ -285,17 +444,15 @@ class VirtualPrinter():
|
||||
if os.path.isfile(file):
|
||||
os.remove(file)
|
||||
else:
|
||||
self.readList.append("error writing to file")
|
||||
self.outgoing.put("error writing to file")
|
||||
|
||||
self._writingToSd = True
|
||||
self._selectedSdFile = file
|
||||
self.readList.append("Writing to file: %s" % filename)
|
||||
self._sendOk()
|
||||
self.outgoing.put("Writing to file: %s" % filename)
|
||||
|
||||
def _finishSdFile(self):
|
||||
self._writingToSd = False
|
||||
self._selectedSdFile = None
|
||||
self._sendOk()
|
||||
|
||||
def _sdPrintingWorker(self):
|
||||
self._selectedSdFilePos = 0
|
||||
@@ -318,47 +475,45 @@ class VirtualPrinter():
|
||||
if 'M140' in line or 'M190' in line:
|
||||
self._parseBedCommand(line)
|
||||
|
||||
time.sleep(0.01)
|
||||
time.sleep(settings().getFloat(["devel", "virtualPrinter", "throttle"]))
|
||||
|
||||
self._sdPrintingSemaphore.clear()
|
||||
self._selectedSdFilePos = 0
|
||||
self._sdPrinter = None
|
||||
self.readList.append("Done printing file")
|
||||
self.outgoing.put("Done printing file")
|
||||
|
||||
def _waitForHeatup(self, heater):
|
||||
delta = 0.5
|
||||
delta = 1
|
||||
delay = 1
|
||||
if heater.startswith("tool"):
|
||||
toolNum = int(heater[len("tool"):])
|
||||
while self.temp[toolNum] < self.targetTemp[toolNum] - delta or self.temp[toolNum] > self.targetTemp[toolNum] + delta:
|
||||
self._simulateTemps()
|
||||
self.readList.append("T:%0.2f /%0.2f" % (self.temp[toolNum], self.targetTemp[toolNum]))
|
||||
self._simulateTemps(delta=delta)
|
||||
self.outgoing.put("T:%0.2f" % self.temp[toolNum])
|
||||
time.sleep(delay)
|
||||
elif heater == "bed":
|
||||
while self.bedTemp < self.bedTargetTemp - delta or self.bedTemp > self.bedTargetTemp + delta:
|
||||
self._simulateTemps()
|
||||
self.readList.append("B:%0.2f /%0.2f" % (self.bedTemp, self.bedTargetTemp))
|
||||
self._simulateTemps(delta=delta)
|
||||
self.outgoing.put("B:%0.2f" % self.bedTemp)
|
||||
time.sleep(delay)
|
||||
self.readList.append("ok")
|
||||
|
||||
def _deleteSdFile(self, filename):
|
||||
f = os.path.join(self._virtualSd, filename)
|
||||
if os.path.exists(f) and os.path.isfile(f):
|
||||
os.remove(f)
|
||||
self._sendOk()
|
||||
|
||||
def _simulateTemps(self):
|
||||
def _simulateTemps(self, delta=1):
|
||||
timeDiff = self.lastTempAt - time.time()
|
||||
self.lastTempAt = time.time()
|
||||
for i in range(len(self.temp)):
|
||||
if abs(self.temp[i] - self.targetTemp[i]) > 1:
|
||||
if abs(self.temp[i] - self.targetTemp[i]) > delta:
|
||||
oldVal = self.temp[i]
|
||||
self.temp[i] += math.copysign(timeDiff * 10, self.targetTemp[i] - self.temp[i])
|
||||
if math.copysign(1, self.targetTemp[i] - oldVal) != math.copysign(1, self.targetTemp[i] - self.temp[i]):
|
||||
self.temp[i] = self.targetTemp[i]
|
||||
if self.temp[i] < 0:
|
||||
self.temp[i] = 0
|
||||
if abs(self.bedTemp - self.bedTargetTemp) > 1:
|
||||
if abs(self.bedTemp - self.bedTargetTemp) > delta:
|
||||
oldVal = self.bedTemp
|
||||
self.bedTemp += math.copysign(timeDiff * 10, self.bedTargetTemp - self.bedTemp)
|
||||
if math.copysign(1, self.bedTargetTemp - oldVal) != math.copysign(1, self.bedTargetTemp - self.bedTemp):
|
||||
@@ -366,34 +521,98 @@ class VirtualPrinter():
|
||||
if self.bedTemp < 0:
|
||||
self.bedTemp = 0
|
||||
|
||||
def _processBuffer(self):
|
||||
while self.buffered is not None:
|
||||
try:
|
||||
line = self.buffered.get(timeout=0.5)
|
||||
except Queue.Empty:
|
||||
continue
|
||||
|
||||
if line is None:
|
||||
continue
|
||||
|
||||
self._performMove(line)
|
||||
|
||||
def write(self, data):
|
||||
with self._incoming_lock:
|
||||
if self.incoming is None or self.outgoing is None:
|
||||
return
|
||||
try:
|
||||
self.incoming.put(data, timeout=self._write_timeout)
|
||||
except Queue.Full:
|
||||
raise SerialTimeoutException()
|
||||
|
||||
def readline(self):
|
||||
if self.readList is None:
|
||||
return ''
|
||||
n = 0
|
||||
|
||||
self._simulateTemps()
|
||||
|
||||
while len(self.readList) < 1:
|
||||
time.sleep(0.1)
|
||||
n += 1
|
||||
if n == 20:
|
||||
return ''
|
||||
if self.readList is None:
|
||||
return ''
|
||||
time.sleep(0.001)
|
||||
return self.readList.pop(0)
|
||||
try:
|
||||
line = self.outgoing.get(timeout=self._read_timeout)
|
||||
time.sleep(settings().getFloat(["devel", "virtualPrinter", "throttle"]))
|
||||
return line
|
||||
except Queue.Empty:
|
||||
return ""
|
||||
|
||||
def close(self):
|
||||
self.readList = None
|
||||
self.incoming = None
|
||||
self.outgoing = None
|
||||
self.buffered = None
|
||||
|
||||
def _sendOk(self):
|
||||
if settings().getBoolean(["devel", "virtualPrinter", "okWithLinenumber"]):
|
||||
self.readList.append("ok %d" % self.lastN)
|
||||
self.outgoing.put("ok %d" % self.lastN)
|
||||
else:
|
||||
self.readList.append("ok")
|
||||
self.outgoing.put("ok")
|
||||
|
||||
def _sendWaitAfterTimeout(self, timeout=5):
|
||||
time.sleep(timeout)
|
||||
if self.readList is not None:
|
||||
self.readList.append("wait")
|
||||
if self.outgoing is not None:
|
||||
self.outgoing.put("wait")
|
||||
|
||||
class CharCountingQueue(Queue.Queue):
|
||||
|
||||
def __init__(self, maxsize, name=None):
|
||||
Queue.Queue.__init__(self, maxsize=maxsize)
|
||||
self._size = 0
|
||||
self._name = name
|
||||
|
||||
def put(self, item, block=True, timeout=None):
|
||||
self.not_full.acquire()
|
||||
try:
|
||||
item_size = self._len(item)
|
||||
|
||||
if not block:
|
||||
if self._qsize() + item_size >= self.maxsize:
|
||||
raise Queue.Full
|
||||
elif timeout is None:
|
||||
while self._qsize() + item_size >= self.maxsize:
|
||||
self.not_full.wait()
|
||||
elif timeout < 0:
|
||||
raise ValueError("'timeout' must be a positive number")
|
||||
else:
|
||||
endtime = time.time() + timeout
|
||||
while self._qsize() + item_size >= self.maxsize:
|
||||
remaining = endtime - time.time()
|
||||
if remaining <= 0.0:
|
||||
raise Queue.Full
|
||||
self.not_full.wait(remaining)
|
||||
|
||||
self._put(item)
|
||||
self.unfinished_tasks += 1
|
||||
self.not_empty.notify()
|
||||
finally:
|
||||
self.not_full.release()
|
||||
|
||||
def _len(self, item):
|
||||
return len(item)
|
||||
|
||||
def _qsize(self, len=len):
|
||||
return self._size
|
||||
|
||||
# Put a new item in the queue
|
||||
def _put(self, item):
|
||||
self.queue.append(item)
|
||||
self._size += self._len(item)
|
||||
|
||||
# Get an item from the queue
|
||||
def _get(self):
|
||||
item = self.queue.popleft()
|
||||
self._size -= self._len(item)
|
||||
return item
|
||||
@@ -0,0 +1,74 @@
|
||||
# coding=utf-8
|
||||
from __future__ import absolute_import
|
||||
|
||||
__author__ = "Gina Häußge <osd@foosel.net>"
|
||||
__license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
|
||||
__copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||
|
||||
|
||||
import unittest
|
||||
from ddt import ddt, data, unpack
|
||||
|
||||
import octoprint.printer
|
||||
|
||||
@ddt
|
||||
class EstimationTestCase(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.estimation_helper = type(octoprint.printer.TimeEstimationHelper)(octoprint.printer.TimeEstimationHelper.__name__, (octoprint.printer.TimeEstimationHelper,), {
|
||||
'STABLE_THRESHOLD': 0.1,
|
||||
'STABLE_ROLLING_WINDOW': 3,
|
||||
'STABLE_COUNTDOWN': 1
|
||||
})()
|
||||
|
||||
@data(
|
||||
((1.0, 2.0, 3.0, 4.0, 5.0), 3.0),
|
||||
((1.0, 2.0, 0.0, 1.0, 2.0), 1.2),
|
||||
((1.0, -2.0, -1.0, -2.0, 3.0), -0.2)
|
||||
)
|
||||
@unpack
|
||||
def test_average_total(self, estimates, expected):
|
||||
for estimate in estimates:
|
||||
self.estimation_helper.update(estimate)
|
||||
|
||||
self.assertEquals(self.estimation_helper.average_total, expected)
|
||||
|
||||
@data(
|
||||
((1.0, 2.0), None), # not enough values, have 1, need 3
|
||||
((1.0, 2.0, 3.0), None), # not enough values, have 2, need 3
|
||||
((1.0, 2.0, 3.0, 4.0), 0.5), # average totals: 1.0, 1.5, 2.0, 2.5 => (3 * 0.5 / 3 = 0.5
|
||||
((1.0, 2.0, 3.0, 4.0, 5.0), 0.5), # average totals: 1.0, 1.5, 2.0, 2.5, 3.0 => (0.5 + 0.5 + 0.5) / 3 = 0.5
|
||||
((1.0, 2.0, 0.0, 1.0, 2.0), 0.7 / 3) # average totals: 1.0, 1.5, 1.0, 1.0, 1.2 => (0.5 + 0.0 + 0.2) / 3 = 0.7 / 3
|
||||
)
|
||||
@unpack
|
||||
def test_average_distance(self, estimates, expected):
|
||||
for estimate in estimates:
|
||||
self.estimation_helper.update(estimate)
|
||||
|
||||
self.assertEquals(self.estimation_helper.average_distance, expected)
|
||||
|
||||
@data(
|
||||
((1.0, 1.0), None),
|
||||
((1.0, 1.0, 1.0), 1.0),
|
||||
((1.0, 2.0, 3.0, 4.0, 5.0), 4.0),
|
||||
)
|
||||
@unpack
|
||||
def test_average_total_rolling(self, estimates, expected):
|
||||
for estimate in estimates:
|
||||
self.estimation_helper.update(estimate)
|
||||
|
||||
self.assertEquals(self.estimation_helper.average_total_rolling, expected)
|
||||
|
||||
@data(
|
||||
((1.0, 1.0, 1.0, 1.0), False), # average totals: 1.0, 1.0, 1.0, 1.0 => 3.0 / 3 = 1.0
|
||||
((1.0, 1.0, 1.0, 1.0, 1.0), True), # average totals: 1.0, 1.0, 1.0, 1.0, 1.0 => 0.0 / 3 = 0.0
|
||||
((1.0, 2.0, 3.0, 4.0, 5.0), False), # average totals: 1.0, 1.5, 2.0, 2.5, 3.0 => 1.5 / 3 = 0.5
|
||||
((0.0, 0.09, 0.18, 0.27, 0.36), True) # average totals: 0.0, 0.045, 0.09, 0.135, 0.18 => (0.045 + 0.045 + 0.045) / 3 = 0.045
|
||||
)
|
||||
@unpack
|
||||
def test_is_stable(self, estimates, expected):
|
||||
for estimate in estimates:
|
||||
self.estimation_helper.update(estimate)
|
||||
|
||||
self.assertEquals(self.estimation_helper.is_stable(), expected)
|
||||
|
||||
Reference in new issue
Block a user