🚧 Further work on various things
This commit is contained in:
1 parent
98860ece7f
commit
37c439ca8c
19 files changed
+760
-364
No files matched your search
@@ -0,0 +1,11 @@
|
||||
# General TODOs
|
||||
|
||||
* firmware info propagation & FirmwareCheck
|
||||
* SerialTransport:
|
||||
* additional ports & baudrates for SerialTransport
|
||||
* port & baudrate blacklist for SerialTransport
|
||||
* RepRapProtocol:
|
||||
* M112 on disconnect
|
||||
* tool command sanity check & "unknown tool" eval
|
||||
* notification on suppressed commands
|
||||
* ok buffer size
|
||||
@@ -7,12 +7,7 @@ import os
|
||||
import time
|
||||
from abc import ABCMeta
|
||||
|
||||
from octoprint.comm.protocol import (
|
||||
FileAwareProtocolListener,
|
||||
FileManagementProtocolMixin,
|
||||
ProtocolListener,
|
||||
ProtocolState,
|
||||
)
|
||||
from octoprint.comm.protocol import ProtocolListener, ProtocolState
|
||||
from octoprint.util.listener import ListenerAware
|
||||
|
||||
|
||||
@@ -362,221 +357,10 @@ class LocalFilePrintjob(StoragePrintjob):
|
||||
)
|
||||
|
||||
|
||||
class LocalGcodeFilePrintjob(LocalFilePrintjob):
|
||||
def can_process(self, protocol):
|
||||
return LocalGcodeFilePrintjob in protocol.supported_jobs
|
||||
|
||||
def process_line(self, line):
|
||||
# TODO no dependency on protocol module
|
||||
from octoprint.comm.protocol.reprap.util import strip_comment
|
||||
|
||||
# strip line
|
||||
processed = line.strip()
|
||||
|
||||
# strip comments
|
||||
processed = strip_comment(processed)
|
||||
if not len(processed):
|
||||
return None
|
||||
|
||||
# TODO apply offsets
|
||||
|
||||
# return result
|
||||
return processed
|
||||
|
||||
|
||||
class CopyJobMixin:
|
||||
pass
|
||||
|
||||
|
||||
class LocalGcodeStreamjob(LocalGcodeFilePrintjob, CopyJobMixin):
|
||||
|
||||
exclusive = True
|
||||
|
||||
@classmethod
|
||||
def from_job(cls, job, remote):
|
||||
if not isinstance(job, LocalGcodeFilePrintjob):
|
||||
raise ValueError("job must be a LocalGcodeFilePrintjob")
|
||||
|
||||
path = job._path
|
||||
storage = job._storage
|
||||
path_in_storage = job._path_in_storage
|
||||
name = job._name
|
||||
user = job._user
|
||||
encoding = job._encoding
|
||||
event_data = job._event_data
|
||||
|
||||
return cls(
|
||||
remote,
|
||||
path,
|
||||
storage,
|
||||
path_in_storage,
|
||||
name=name,
|
||||
user=user,
|
||||
encoding=encoding,
|
||||
event_data=event_data,
|
||||
)
|
||||
|
||||
def __init__(self, remote, *args, **kwargs):
|
||||
super(LocalGcodeStreamjob, self).__init__(*args, **kwargs)
|
||||
self._remote = remote
|
||||
|
||||
@property
|
||||
def remote(self):
|
||||
return self._remote
|
||||
|
||||
def process(self, protocol, position=0, user=None, tags=None, **kwargs):
|
||||
super(LocalGcodeStreamjob, self).process(
|
||||
protocol, position=position, user=user, tags=tags, **kwargs
|
||||
)
|
||||
self._protocol.record_file(self._remote)
|
||||
|
||||
def process_job_done(self, user=None, tags=None, **kwargs):
|
||||
self._protocol.stop_recording_file()
|
||||
super(LocalGcodeStreamjob, self).process_job_done(user=user, tags=tags, **kwargs)
|
||||
|
||||
def process_job_failed(self, **kwargs):
|
||||
self._protocol.stop_recording_file()
|
||||
super(LocalGcodeStreamjob, self).process_job_failed(**kwargs)
|
||||
|
||||
def process_job_cancelled(self, user=None, tags=None, **kwargs):
|
||||
self._protocol.stop_recording_file()
|
||||
self._protocol.delete_file(self.remote)
|
||||
super(LocalGcodeStreamjob, self).process_job_cancelled(
|
||||
user=user, tags=tags, **kwargs
|
||||
)
|
||||
|
||||
def can_process(self, protocol):
|
||||
from octoprint.comm.protocol import FileStreamingProtocolMixin
|
||||
|
||||
return (
|
||||
LocalGcodeStreamjob in protocol.supported_jobs
|
||||
and isinstance(protocol, FileStreamingProtocolMixin)
|
||||
and isinstance(protocol, FileManagementProtocolMixin)
|
||||
)
|
||||
|
||||
def report_stats(self):
|
||||
elapsed = self.elapsed
|
||||
lines = self._read_lines
|
||||
|
||||
if elapsed and lines:
|
||||
self._logger.info(
|
||||
"Job processed in {:.3f}s ({} lines). Approx. {:.3f} lines/s, {:.3f} ms/line".format(
|
||||
elapsed,
|
||||
lines,
|
||||
float(lines) / float(elapsed),
|
||||
float(elapsed) * 1000.0 / float(lines),
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
class SDFilePrintjob(StoragePrintjob, FileAwareProtocolListener):
|
||||
|
||||
parallel = True
|
||||
|
||||
def __init__(self, path, status_interval=2.0, *args, **kwargs):
|
||||
name = path
|
||||
if name.startswith("/"):
|
||||
name = name[1:]
|
||||
|
||||
StoragePrintjob.__init__(
|
||||
self,
|
||||
"sdcard",
|
||||
name,
|
||||
name=name,
|
||||
event_data={"name": name, "path": path, "origin": "sdcard"},
|
||||
)
|
||||
self._filename = path
|
||||
self._status_interval = status_interval
|
||||
|
||||
self._status_timer = None
|
||||
self._active = False
|
||||
|
||||
self._size = None
|
||||
self._last_pos = None
|
||||
|
||||
@property
|
||||
def size(self):
|
||||
return self._size
|
||||
|
||||
@property
|
||||
def pos(self):
|
||||
return self._last_pos
|
||||
|
||||
@property
|
||||
def active(self):
|
||||
return self._start is not None and self._active
|
||||
|
||||
@property
|
||||
def status_interval(self):
|
||||
return self._status_interval
|
||||
|
||||
def can_process(self, protocol):
|
||||
from octoprint.comm.protocol import FileAwareProtocolMixin
|
||||
|
||||
return SDFilePrintjob in protocol.supported_jobs and isinstance(
|
||||
protocol, FileAwareProtocolMixin
|
||||
)
|
||||
|
||||
def process(self, protocol, position=0, user=None, tags=None, **kwargs):
|
||||
Printjob.process(
|
||||
self, protocol, position=position, user=user, tags=tags, **kwargs
|
||||
)
|
||||
|
||||
self._protocol.register_listener(self)
|
||||
self._active = True
|
||||
self._last_pos = position
|
||||
|
||||
self._protocol.start_file_print(
|
||||
self._filename,
|
||||
position=position,
|
||||
user=user,
|
||||
tags=tags,
|
||||
part_of_job=True,
|
||||
**kwargs
|
||||
)
|
||||
self._protocol.start_file_print_status_monitor()
|
||||
|
||||
def pause(self, user=None, tags=None, **kwargs):
|
||||
super(SDFilePrintjob, self).pause(user=user, tags=tags, **kwargs)
|
||||
self._protocol.pause_file_print(user=user, tags=tags, part_of_job=True, **kwargs)
|
||||
|
||||
def resume(self, user=None, tags=None, **kwargs):
|
||||
super(SDFilePrintjob, self).resume(user=user, tags=tags, **kwargs)
|
||||
self._protocol.resume_file_print(user=user, tags=tags, part_of_job=True, **kwargs)
|
||||
|
||||
def on_protocol_sd_status(self, protocol, pos, total):
|
||||
self._last_pos = pos
|
||||
self._size = total
|
||||
self.process_job_progress()
|
||||
|
||||
def on_protocol_file_print_started(
|
||||
self, protocol, name, long_name, size, *args, **kwargs
|
||||
):
|
||||
self._size = size
|
||||
self.process_job_started(**kwargs)
|
||||
|
||||
def on_protocol_file_print_done(self, protocol, *args, **kwargs):
|
||||
self._protocol.stop_file_print_status_monitor(**kwargs)
|
||||
self.process_job_done(**kwargs)
|
||||
|
||||
def on_protocol_file_print_paused(self, protocol, *args, **kwargs):
|
||||
self._protocol.pause_file_print(**kwargs)
|
||||
|
||||
def on_protocol_file_print_resumed(self, protocol, *args, **kwargs):
|
||||
self._protocol.resume_file_print(**kwargs)
|
||||
|
||||
def reset_job(self, success=True):
|
||||
super(SDFilePrintjob, self).reset_job(success=success)
|
||||
self._active = False
|
||||
self._last_pos = None
|
||||
self._size = None
|
||||
|
||||
def event_payload(self, incl_last=False):
|
||||
payload = Printjob.event_payload(self, incl_last=incl_last)
|
||||
payload["size"] = self.size
|
||||
return payload
|
||||
|
||||
|
||||
class PrintjobListener:
|
||||
def on_job_started(self, job, suppress_script=False, *args, **kwargs):
|
||||
pass
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html"
|
||||
__copyright__ = "Copyright (C) 2021 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||
|
||||
from . import CopyJobMixin, LocalFilePrintjob
|
||||
|
||||
|
||||
class LocalGcodeFilePrintjob(LocalFilePrintjob):
|
||||
def can_process(self, protocol):
|
||||
return LocalGcodeFilePrintjob in protocol.supported_jobs
|
||||
|
||||
def process_line(self, line):
|
||||
from octoprint.comm.protocol.reprap.util import strip_comment
|
||||
|
||||
# strip line
|
||||
processed = line.strip()
|
||||
|
||||
# strip comments
|
||||
processed = strip_comment(processed)
|
||||
if not len(processed):
|
||||
return None
|
||||
|
||||
# TODO apply offsets
|
||||
|
||||
# return result
|
||||
return processed
|
||||
|
||||
|
||||
class LocalGcodeStreamjob(LocalGcodeFilePrintjob, CopyJobMixin):
|
||||
|
||||
exclusive = True
|
||||
|
||||
@classmethod
|
||||
def from_job(cls, job, remote):
|
||||
if not isinstance(job, LocalGcodeFilePrintjob):
|
||||
raise ValueError("job must be a LocalGcodeFilePrintjob")
|
||||
|
||||
path = job._path
|
||||
storage = job._storage
|
||||
path_in_storage = job._path_in_storage
|
||||
name = job._name
|
||||
user = job._user
|
||||
encoding = job._encoding
|
||||
event_data = job._event_data
|
||||
|
||||
return cls(
|
||||
remote,
|
||||
path,
|
||||
storage,
|
||||
path_in_storage,
|
||||
name=name,
|
||||
user=user,
|
||||
encoding=encoding,
|
||||
event_data=event_data,
|
||||
)
|
||||
|
||||
def __init__(self, remote, *args, **kwargs):
|
||||
super(LocalGcodeStreamjob, self).__init__(*args, **kwargs)
|
||||
self._remote = remote
|
||||
|
||||
@property
|
||||
def remote(self):
|
||||
return self._remote
|
||||
|
||||
def process(self, protocol, position=0, user=None, tags=None, **kwargs):
|
||||
super(LocalGcodeStreamjob, self).process(
|
||||
protocol, position=position, user=user, tags=tags, **kwargs
|
||||
)
|
||||
self._protocol.record_file(self._remote)
|
||||
|
||||
def process_job_done(self, user=None, tags=None, **kwargs):
|
||||
self._protocol.stop_recording_file()
|
||||
super(LocalGcodeStreamjob, self).process_job_done(user=user, tags=tags, **kwargs)
|
||||
|
||||
def process_job_failed(self, **kwargs):
|
||||
self._protocol.stop_recording_file()
|
||||
super(LocalGcodeStreamjob, self).process_job_failed(**kwargs)
|
||||
|
||||
def process_job_cancelled(self, user=None, tags=None, **kwargs):
|
||||
self._protocol.stop_recording_file()
|
||||
self._protocol.delete_file(self.remote)
|
||||
super(LocalGcodeStreamjob, self).process_job_cancelled(
|
||||
user=user, tags=tags, **kwargs
|
||||
)
|
||||
|
||||
def can_process(self, protocol):
|
||||
from octoprint.comm.protocol import (
|
||||
FileManagementProtocolMixin,
|
||||
FileStreamingProtocolMixin,
|
||||
)
|
||||
|
||||
return (
|
||||
LocalGcodeStreamjob in protocol.supported_jobs
|
||||
and isinstance(protocol, FileStreamingProtocolMixin)
|
||||
and isinstance(protocol, FileManagementProtocolMixin)
|
||||
)
|
||||
|
||||
def report_stats(self):
|
||||
elapsed = self.elapsed
|
||||
lines = self._read_lines
|
||||
|
||||
if elapsed and lines:
|
||||
self._logger.info(
|
||||
"Job processed in {:.3f}s ({} lines). Approx. {:.3f} lines/s, {:.3f} ms/line".format(
|
||||
elapsed,
|
||||
lines,
|
||||
float(lines) / float(elapsed),
|
||||
float(elapsed) * 1000.0 / float(lines),
|
||||
)
|
||||
)
|
||||
@@ -0,0 +1,114 @@
|
||||
__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html"
|
||||
__copyright__ = "Copyright (C) 2021 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||
|
||||
from octoprint.comm.protocol import FileAwareProtocolListener
|
||||
|
||||
from . import Printjob, StoragePrintjob
|
||||
|
||||
|
||||
class SDFilePrintjob(StoragePrintjob, FileAwareProtocolListener):
|
||||
|
||||
parallel = True
|
||||
|
||||
def __init__(self, path, status_interval=2.0, *args, **kwargs):
|
||||
name = path
|
||||
if name.startswith("/"):
|
||||
name = name[1:]
|
||||
|
||||
StoragePrintjob.__init__(
|
||||
self,
|
||||
"sdcard",
|
||||
name,
|
||||
name=name,
|
||||
event_data={"name": name, "path": path, "origin": "sdcard"},
|
||||
)
|
||||
self._filename = path
|
||||
self._status_interval = status_interval
|
||||
|
||||
self._status_timer = None
|
||||
self._active = False
|
||||
|
||||
self._size = None
|
||||
self._last_pos = None
|
||||
|
||||
@property
|
||||
def size(self):
|
||||
return self._size
|
||||
|
||||
@property
|
||||
def pos(self):
|
||||
return self._last_pos
|
||||
|
||||
@property
|
||||
def active(self):
|
||||
return self._start is not None and self._active
|
||||
|
||||
@property
|
||||
def status_interval(self):
|
||||
return self._status_interval
|
||||
|
||||
def can_process(self, protocol):
|
||||
from octoprint.comm.protocol import FileAwareProtocolMixin
|
||||
|
||||
return SDFilePrintjob in protocol.supported_jobs and isinstance(
|
||||
protocol, FileAwareProtocolMixin
|
||||
)
|
||||
|
||||
def process(self, protocol, position=0, user=None, tags=None, **kwargs):
|
||||
Printjob.process(
|
||||
self, protocol, position=position, user=user, tags=tags, **kwargs
|
||||
)
|
||||
|
||||
self._protocol.register_listener(self)
|
||||
self._active = True
|
||||
self._last_pos = position
|
||||
|
||||
self._protocol.start_file_print(
|
||||
self._filename,
|
||||
position=position,
|
||||
user=user,
|
||||
tags=tags,
|
||||
part_of_job=True,
|
||||
**kwargs
|
||||
)
|
||||
self._protocol.start_file_print_status_monitor()
|
||||
|
||||
def pause(self, user=None, tags=None, **kwargs):
|
||||
super(SDFilePrintjob, self).pause(user=user, tags=tags, **kwargs)
|
||||
self._protocol.pause_file_print(user=user, tags=tags, part_of_job=True, **kwargs)
|
||||
|
||||
def resume(self, user=None, tags=None, **kwargs):
|
||||
super(SDFilePrintjob, self).resume(user=user, tags=tags, **kwargs)
|
||||
self._protocol.resume_file_print(user=user, tags=tags, part_of_job=True, **kwargs)
|
||||
|
||||
def on_protocol_sd_status(self, protocol, pos, total):
|
||||
self._last_pos = pos
|
||||
self._size = total
|
||||
self.process_job_progress()
|
||||
|
||||
def on_protocol_file_print_started(
|
||||
self, protocol, name, long_name, size, *args, **kwargs
|
||||
):
|
||||
self._size = size
|
||||
self.process_job_started(**kwargs)
|
||||
|
||||
def on_protocol_file_print_done(self, protocol, *args, **kwargs):
|
||||
self._protocol.stop_file_print_status_monitor(**kwargs)
|
||||
self.process_job_done(**kwargs)
|
||||
|
||||
def on_protocol_file_print_paused(self, protocol, *args, **kwargs):
|
||||
self._protocol.pause_file_print(**kwargs)
|
||||
|
||||
def on_protocol_file_print_resumed(self, protocol, *args, **kwargs):
|
||||
self._protocol.resume_file_print(**kwargs)
|
||||
|
||||
def reset_job(self, success=True):
|
||||
super(SDFilePrintjob, self).reset_job(success=success)
|
||||
self._active = False
|
||||
self._last_pos = None
|
||||
self._size = None
|
||||
|
||||
def event_payload(self, incl_last=False):
|
||||
payload = Printjob.event_payload(self, incl_last=incl_last)
|
||||
payload["size"] = self.size
|
||||
return payload
|
||||
@@ -58,7 +58,123 @@ def all_protocols():
|
||||
return _registry.values()
|
||||
|
||||
|
||||
class Protocol(ListenerAware, TransportListener):
|
||||
class ProtocolErrorStats(ListenerAware):
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__()
|
||||
|
||||
self._rx = 0
|
||||
self._rx_errors = 0
|
||||
self._rx_error_rate = 0
|
||||
self._rx_arm = -1
|
||||
self._rx_threshold = 0
|
||||
self._rx_triggered = False
|
||||
|
||||
self._tx = 0
|
||||
self._tx_errors = 0
|
||||
self._tx_error_rate = 0
|
||||
self._tx_arm = -1
|
||||
self._tx_threshold = 0
|
||||
self._tx_triggered = False
|
||||
|
||||
self.reset(**kwargs)
|
||||
|
||||
def reset(
|
||||
self, rx_arm=None, rx_threshold=None, tx_arm=None, tx_threshold=None, **kwargs
|
||||
):
|
||||
self._rx = self._rx_errors = self._rx_error_rate = 0
|
||||
self._rx_triggered = False
|
||||
if rx_arm is not None:
|
||||
self._rx_arm = rx_arm
|
||||
if rx_threshold is not None:
|
||||
self._rx_threshold = rx_threshold
|
||||
|
||||
self._tx = self._tx_errors = self._tx_error_rate = 0
|
||||
self._tx_triggered = False
|
||||
if tx_arm is not None:
|
||||
self._tx_arm = tx_arm
|
||||
if tx_threshold is not None:
|
||||
self._tx_threshold = tx_threshold
|
||||
|
||||
@property
|
||||
def rx(self):
|
||||
return self._rx
|
||||
|
||||
@property
|
||||
def rx_errors(self):
|
||||
return self._rx_errors
|
||||
|
||||
@property
|
||||
def rx_error_rate(self):
|
||||
return self._rx_error_rate
|
||||
|
||||
@property
|
||||
def rx_error_threshold(self):
|
||||
return self._rx_threshold
|
||||
|
||||
@property
|
||||
def tx(self):
|
||||
return self._tx
|
||||
|
||||
@property
|
||||
def tx_errors(self):
|
||||
return self._tx_errors
|
||||
|
||||
@property
|
||||
def tx_error_rate(self):
|
||||
return self._tx_error_rate
|
||||
|
||||
@property
|
||||
def tx_error_threshold(self):
|
||||
return self._tx_threshold
|
||||
|
||||
def inc_rx(self):
|
||||
self._rx += 1
|
||||
if self._rx > self._rx_arm:
|
||||
self.notify_listeners("on_protocol_stats_rx_armed", self)
|
||||
|
||||
def inc_rx_errors(self):
|
||||
self._rx_errors += 1
|
||||
self._rx_error_rate = (self._rx_errors / self._rx) if self._rx > 0 else 0
|
||||
if (
|
||||
self._rx > self._rx_arm
|
||||
and self._rx_error_rate > self._rx_threshold
|
||||
and not self._rx_triggered
|
||||
):
|
||||
self._rx_triggered = True
|
||||
self.notify_listeners("on_protocol_stats_rx_triggered", self)
|
||||
|
||||
def inc_tx(self):
|
||||
self._tx += 1
|
||||
if self._tx > self._tx_arm:
|
||||
self.notify_listeners("on_protocol_stats_tx_armed", self)
|
||||
|
||||
def inc_tx_errors(self):
|
||||
self._tx_errors += 1
|
||||
self._tx_error_rate = (self._tx_errors / self._tx) if self._tx > 0 else 0
|
||||
if (
|
||||
self._tx > self._tx_arm
|
||||
and self._tx_error_rate > self._tx_threshold
|
||||
and not self._tx_triggered
|
||||
):
|
||||
self._tx_triggered = True
|
||||
self.notify_listeners("on_protocol_stats_tx_triggered", self)
|
||||
|
||||
|
||||
class ProtocolErrorStatsListener:
|
||||
def on_protocol_stats_tx_armed(self, stats):
|
||||
pass
|
||||
|
||||
def on_protocol_stats_tx_triggered(self, stats):
|
||||
pass
|
||||
|
||||
def on_protocol_stats_rx_armed(self, stats):
|
||||
pass
|
||||
|
||||
def on_protocol_stats_rx_triggered(self, stats):
|
||||
pass
|
||||
|
||||
|
||||
class Protocol(ListenerAware, TransportListener, ProtocolErrorStatsListener):
|
||||
|
||||
name = None
|
||||
key = None
|
||||
@@ -80,6 +196,7 @@ class Protocol(ListenerAware, TransportListener):
|
||||
self._connection_logger = logging.getLogger("CONNECTION")
|
||||
self._state = ProtocolState.DISCONNECTED
|
||||
self._error = None
|
||||
self._stats = ProtocolErrorStats()
|
||||
|
||||
self._printer_profile = kwargs.get("printer_profile")
|
||||
self._plugin_manager = kwargs.get("plugin_manager")
|
||||
@@ -174,6 +291,10 @@ class Protocol(ListenerAware, TransportListener):
|
||||
def error(self, new_error):
|
||||
self._error = new_error
|
||||
|
||||
@property
|
||||
def stats(self):
|
||||
return self._stats
|
||||
|
||||
def connect(self, transport, transport_args=None, transport_kwargs=None):
|
||||
if self.state not in (
|
||||
ProtocolState.DISCONNECTED,
|
||||
|
||||
@@ -8,18 +8,16 @@ import queue
|
||||
import threading
|
||||
import time
|
||||
|
||||
from octoprint.comm.job import (
|
||||
CopyJobMixin,
|
||||
LocalGcodeFilePrintjob,
|
||||
LocalGcodeStreamjob,
|
||||
SDFilePrintjob,
|
||||
)
|
||||
from octoprint.comm.job import CopyJobMixin
|
||||
from octoprint.comm.job.gcode import LocalGcodeFilePrintjob, LocalGcodeStreamjob
|
||||
from octoprint.comm.job.sdcard import SDFilePrintjob
|
||||
from octoprint.comm.protocol import (
|
||||
FanControlProtocolMixin,
|
||||
Fdm3dPrinterProtocolMixin,
|
||||
FileStreamingProtocolMixin,
|
||||
MotorControlProtocolMixin,
|
||||
Protocol,
|
||||
ProtocolErrorStatsListener,
|
||||
ProtocolState,
|
||||
)
|
||||
from octoprint.comm.protocol.reprap.commands import Command, to_command
|
||||
@@ -137,6 +135,7 @@ class ReprapGcodeProtocol(
|
||||
FileStreamingProtocolMixin,
|
||||
PushingTransportWrapperListener,
|
||||
TransportListener,
|
||||
ProtocolErrorStatsListener,
|
||||
):
|
||||
name = "Reprap GCODE Protocol"
|
||||
key = "reprap"
|
||||
@@ -178,7 +177,10 @@ class ReprapGcodeProtocol(
|
||||
],
|
||||
expert=True,
|
||||
help=gettext(
|
||||
'Some Marlin forks lack an acknowledging `ok` with their resend requests. Set this to "Always" or "If detected as necessary" if you run into communication stalls on resend requests.'
|
||||
"Some firmwares lack an acknowledging `ok` with their "
|
||||
'resend requests. Set this to "Always" or "If detected '
|
||||
'as necessary" if you run into communication stalls on '
|
||||
"resend requests."
|
||||
),
|
||||
),
|
||||
BooleanType(
|
||||
@@ -198,7 +200,8 @@ class ReprapGcodeProtocol(
|
||||
BooleanType(
|
||||
"block_while_dwelling",
|
||||
gettext(
|
||||
"Block all communication while a dwell command (`G4`) is active"
|
||||
"Block all communication while a dwell command (`G4`) "
|
||||
"is active"
|
||||
),
|
||||
),
|
||||
BooleanType(
|
||||
@@ -212,47 +215,80 @@ class ReprapGcodeProtocol(
|
||||
BooleanType(
|
||||
"heatup_abortable",
|
||||
gettext(
|
||||
"Allow cancelling blocking heatups if the firmware supports it"
|
||||
"Allow cancelling blocking heatups if the firmware "
|
||||
"supports it"
|
||||
),
|
||||
),
|
||||
SmallListType(
|
||||
"blocked_commands",
|
||||
gettext("Blocked commands"),
|
||||
help=gettext(
|
||||
"Use this to specify commands that should never be sent to the printer. Just the G or M code, comma separated. Defaults to `M0` and `M1` since most firmware will block until a button on the controller has been pressed if it receives either of those two commands."
|
||||
"Use this to specify commands that should never be sent "
|
||||
"to the printer. Just the G or M code, comma separated."
|
||||
),
|
||||
),
|
||||
SmallListType(
|
||||
"checksum_requiring_commands",
|
||||
gettext("Checksum requiring commands"),
|
||||
help=gettext(""),
|
||||
help=gettext(
|
||||
"Use this to specify which commands **always** need to "
|
||||
"be sent with a checksum. Just the G or M code, comma "
|
||||
"separated."
|
||||
),
|
||||
),
|
||||
SmallListType(
|
||||
"long_running_commands",
|
||||
gettext("Long running commands"),
|
||||
help=gettext(""),
|
||||
help=gettext(
|
||||
"Use this to specify the commands known to take a long "
|
||||
"time to complete without output from your printer and "
|
||||
"hence might cause timeout issues. Just the G or M code, "
|
||||
"comma separated."
|
||||
),
|
||||
),
|
||||
SmallListType(
|
||||
"asynchronous_commands",
|
||||
gettext("Asynchronous commands"),
|
||||
help=gettext(""),
|
||||
help=gettext(
|
||||
"Use this to specify commands that should never be sent "
|
||||
"to the printer. Just the G or M code, comma separated. "
|
||||
"Defaults to M0 and M1 since most firmware will block "
|
||||
"until a button on the controller has been pressed if "
|
||||
"it receives either of those two commands."
|
||||
),
|
||||
expert=True,
|
||||
),
|
||||
SmallListType(
|
||||
"pausing_commands",
|
||||
gettext("Pausing commands"),
|
||||
help=gettext(""),
|
||||
help=gettext(
|
||||
"Use this to specify commands on which OctoPrint should "
|
||||
"pause the print job. Just the G or M code, comma "
|
||||
"separated."
|
||||
),
|
||||
expert=True,
|
||||
),
|
||||
SmallListType(
|
||||
"emergency_commands",
|
||||
gettext("Emergency commands"),
|
||||
help=gettext(""),
|
||||
help=gettext(
|
||||
"Use this to specify emergency commands which should "
|
||||
"jump any queues and - if supported by the firmware - "
|
||||
"be force sent. Just the G or M code, comma separated."
|
||||
),
|
||||
expert=True,
|
||||
),
|
||||
IntegerType(
|
||||
"ok_buffer_size",
|
||||
gettext("`ok` buffer size"),
|
||||
min=1,
|
||||
help=gettext("Only modifiy if told to do so"),
|
||||
),
|
||||
],
|
||||
help=gettext(
|
||||
"You can override the firmware flavor default settings here. You usually should *not* need to do that. Only change anything if the defaults don't work for your printer."
|
||||
"You can override the firmware flavor default settings here. You "
|
||||
"usually should *not* need to do that. Only change anything if "
|
||||
"the defaults don't work for your printer."
|
||||
),
|
||||
advanced=True,
|
||||
),
|
||||
@@ -273,10 +309,14 @@ class ReprapGcodeProtocol(
|
||||
Value(
|
||||
"cancel",
|
||||
title=gettext(
|
||||
"Cancel any ongoing prints but stay connected to the printer"
|
||||
"Cancel any ongoing prints but stay connected to the "
|
||||
"printer"
|
||||
),
|
||||
help=gettext(
|
||||
"Please note that if you choose this, OctoPrint will still disconnect from the printer in case of *fatal* errors reported by your firmware (e.g. `kill() called`, `fatal:`)"
|
||||
"Please note that if you choose this, OctoPrint will "
|
||||
"still disconnect from the printer in case of "
|
||||
"*fatal* errors reported by your firmware (e.g. "
|
||||
"`kill() called`, `fatal:`)"
|
||||
),
|
||||
),
|
||||
Value(
|
||||
@@ -284,20 +324,23 @@ class ReprapGcodeProtocol(
|
||||
title=gettext("Ignore"),
|
||||
warning=True,
|
||||
help=gettext(
|
||||
"Only choose this if your firmware sends error messages that are not actual errors. Might mask printer issues (even fatal errors!), be careful!"
|
||||
"Only choose this if your firmware sends error "
|
||||
"messages that are not actual errors. Might mask "
|
||||
"printer issues (even fatal errors!), be careful!"
|
||||
),
|
||||
),
|
||||
],
|
||||
default="disconnect",
|
||||
),
|
||||
# TODO: implement send_m112 flag
|
||||
BooleanType(
|
||||
"send_m112",
|
||||
gettext("Send `M112` on disconnect due to error"),
|
||||
"send_emergency_stop",
|
||||
gettext("Send emergency stop on disconnect due to error"),
|
||||
default=True,
|
||||
warning=False,
|
||||
help=gettext(
|
||||
"If this is checked, OctoPrint will try to send an `M112` prior to a disconnect due to a (fatal) error in order to disable heaters and motors."
|
||||
"If this is checked, OctoPrint will try to send an emergency "
|
||||
"stop command prior to a disconnect due to a (fatal) error "
|
||||
"in order to disable heaters and motors."
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -331,7 +374,74 @@ class ReprapGcodeProtocol(
|
||||
help=gettext(
|
||||
"If you disable this, the `cancel_position` placeholders in your cancel GCODE script and the corresponding data in the print recovery data will stay unpopulated! However, cancelling speed might improve slightly."
|
||||
),
|
||||
)
|
||||
),
|
||||
],
|
||||
advanced=True,
|
||||
),
|
||||
ParamGroup(
|
||||
"sanity_checking",
|
||||
gettext("Sanity Checking"),
|
||||
[
|
||||
BooleanType(
|
||||
"sanity_check_tools",
|
||||
gettext("Sanity check tool commands"),
|
||||
default=True,
|
||||
warning=True,
|
||||
help=gettext(
|
||||
"If enabled, OctoPrint will not send tool commands to your "
|
||||
"printer that exceed the number of extruders configured in "
|
||||
"the active printer profile, or for which the firmware has "
|
||||
'reported an "invalid extruder" error. Only uncheck this if '
|
||||
"OctoPrint or your firmware mistakingly mark valid tools as "
|
||||
"invalid and be sure to investigate the reason for that, it "
|
||||
"might be a misconfiguration you need to correct for proper "
|
||||
"operation."
|
||||
),
|
||||
),
|
||||
SmallChoiceType(
|
||||
"notify_suppressed_commands",
|
||||
gettext(
|
||||
"Display notifications for suppressed commands",
|
||||
),
|
||||
[
|
||||
Value(
|
||||
"info",
|
||||
title=gettext(
|
||||
'Show notifications of severity "info" and "warning"'
|
||||
),
|
||||
),
|
||||
Value(
|
||||
"warn",
|
||||
title=gettext('Show notifications of severity "warning"'),
|
||||
),
|
||||
Value("never", title=gettext("Never show notifications")),
|
||||
],
|
||||
default="warn",
|
||||
),
|
||||
],
|
||||
advanced=True,
|
||||
),
|
||||
ParamGroup(
|
||||
"resend_tracking",
|
||||
gettext("Resend Tracking"),
|
||||
[
|
||||
IntegerType(
|
||||
"resend_ratio_threshold",
|
||||
gettext("Critical resend ratio"),
|
||||
min=1,
|
||||
max=100,
|
||||
unit="%",
|
||||
default=10,
|
||||
warning=False,
|
||||
),
|
||||
IntegerType(
|
||||
"resend_ratio_start",
|
||||
gettext("Tracking start"),
|
||||
min=0,
|
||||
unit="lines",
|
||||
default=100,
|
||||
warning=False,
|
||||
),
|
||||
],
|
||||
advanced=True,
|
||||
),
|
||||
@@ -421,7 +531,10 @@ class ReprapGcodeProtocol(
|
||||
default=1.0,
|
||||
unit="sec",
|
||||
help=gettext(
|
||||
"Some controllers need a bit of a breather before baudrate detection after initial connect. If baudrate detection fails due to a hanging controller, try increasing this value."
|
||||
"Some controllers need a bit of a breather before baudrate "
|
||||
"detection after initial connect. If baudrate detection "
|
||||
"fails due to a hanging controller, try increasing this "
|
||||
"value."
|
||||
),
|
||||
),
|
||||
FloatType(
|
||||
@@ -431,7 +544,10 @@ class ReprapGcodeProtocol(
|
||||
default=0.5,
|
||||
unit="sec",
|
||||
help=gettext(
|
||||
"Some firmwares do not send an `ok` after a resend request. This timeout configures how long OctoPrint will wait for one until it assumes this particular bug to be present and generate its own."
|
||||
"Some firmwares do not send an `ok` after a resend request. "
|
||||
"This timeout configures how long OctoPrint will wait for "
|
||||
"one until it assumes this particular bug to be present and "
|
||||
"generate its own."
|
||||
),
|
||||
),
|
||||
IntegerType(
|
||||
@@ -440,7 +556,8 @@ class ReprapGcodeProtocol(
|
||||
expert=True,
|
||||
default=2,
|
||||
help=gettext(
|
||||
"Set to 0 to disable consecutive timeout detection and handling."
|
||||
"Set to 0 to disable consecutive timeout detection and "
|
||||
"handling."
|
||||
),
|
||||
),
|
||||
IntegerType(
|
||||
@@ -449,7 +566,8 @@ class ReprapGcodeProtocol(
|
||||
expert=True,
|
||||
default=5,
|
||||
help=gettext(
|
||||
"Set to 0 to disable consecutive timeout detection and handling."
|
||||
"Set to 0 to disable consecutive timeout detection and "
|
||||
"handling."
|
||||
),
|
||||
),
|
||||
IntegerType(
|
||||
@@ -458,7 +576,8 @@ class ReprapGcodeProtocol(
|
||||
expert=True,
|
||||
default=5,
|
||||
help=gettext(
|
||||
"Set to 0 to disable consecutive timeout detection and handling."
|
||||
"Set to 0 to disable consecutive timeout detection and "
|
||||
"handling."
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -522,7 +641,7 @@ class ReprapGcodeProtocol(
|
||||
return dict((x, getattr(cls, x)) for x in dir(cls) if x.startswith(prefix))
|
||||
|
||||
def __init__(self, flavor=None, *args, **kwargs):
|
||||
super(ReprapGcodeProtocol, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
self.flavor = lookup_flavor(flavor)
|
||||
if self.flavor is None:
|
||||
@@ -535,6 +654,12 @@ class ReprapGcodeProtocol(
|
||||
flavor=self.flavor.key, flavor_overrides=self.flavor_overrides
|
||||
)
|
||||
|
||||
self._stats.reset(
|
||||
tx_arm=kwargs.get("resend_ratio_start", 100),
|
||||
tx_threshold=(kwargs.get("resend_ratio_threshold", 10) / 100.0),
|
||||
)
|
||||
self._stats.register_listener(self)
|
||||
|
||||
self._logger = logging.getLogger(__name__)
|
||||
self._commdebug_logger = logging.getLogger("COMMDEBUG")
|
||||
self._phase_logger = logging.getLogger(__name__ + ".command_phases")
|
||||
@@ -576,6 +701,9 @@ class ReprapGcodeProtocol(
|
||||
self.firmware_errors = kwargs.get("error_handling", {}).get(
|
||||
"firmware_errors", "disconnect"
|
||||
)
|
||||
self.send_emergency_stop = kwargs.get("error_handling", {}).get(
|
||||
"send_emergency_stop", True
|
||||
)
|
||||
|
||||
flavor_comm_attrs = self.get_flavor_attributes_starting_with(self.flavor, "comm_")
|
||||
flavor_message_attrs = self.get_flavor_attributes_starting_with(
|
||||
@@ -596,22 +724,23 @@ class ReprapGcodeProtocol(
|
||||
"_command_phase_"
|
||||
)
|
||||
|
||||
self._capability_support = {}
|
||||
self._capability_support[CAPABILITY_AUTOREPORT_TEMP] = kwargs.get(
|
||||
"capabilities", {}
|
||||
).get("autoreport_temp", True)
|
||||
self._capability_support[CAPABILITY_AUTOREPORT_SD_STATUS] = kwargs.get(
|
||||
"capabilities", {}
|
||||
).get("autoreport_sd_status", True)
|
||||
self._capability_support[CAPABILITY_EMERGENCY_PARSER] = kwargs.get(
|
||||
"capabilities", {}
|
||||
).get("emergency_parser", True)
|
||||
self._capability_support[CAPABILITY_BUSY_PROTOCOL] = kwargs.get(
|
||||
"capabilities", {}
|
||||
).get("busy_protocol", True)
|
||||
self._capability_support[CAPABILITY_CHAMBER_TEMP] = kwargs.get(
|
||||
"capabilities", {}
|
||||
).get("chamber_temp", True)
|
||||
self._capability_support = {
|
||||
CAPABILITY_AUTOREPORT_TEMP: kwargs.get("capabilities", {}).get(
|
||||
"autoreport_temp", True
|
||||
),
|
||||
CAPABILITY_AUTOREPORT_SD_STATUS: kwargs.get("capabilities", {}).get(
|
||||
"autoreport_sd_status", True
|
||||
),
|
||||
CAPABILITY_EMERGENCY_PARSER: kwargs.get("capabilities", {}).get(
|
||||
"emergency_parser", True
|
||||
),
|
||||
CAPABILITY_BUSY_PROTOCOL: kwargs.get("capabilities", {}).get(
|
||||
"busy_protocol", True
|
||||
),
|
||||
CAPABILITY_CHAMBER_TEMP: kwargs.get("capabilities", {}).get(
|
||||
"chamber_temp", True
|
||||
),
|
||||
}
|
||||
|
||||
self._transport = None
|
||||
|
||||
@@ -1175,6 +1304,22 @@ class ReprapGcodeProtocol(
|
||||
self._sd_status_poller.cancel()
|
||||
self._sd_status_poller = None
|
||||
|
||||
##~~ ProtocolErrorStatsListener
|
||||
|
||||
def on_protocol_stats_tx_triggered(self, stats):
|
||||
if stats != self._stats:
|
||||
return
|
||||
|
||||
message = (
|
||||
"Over {:.0f}% of transmitted lines have triggered resend requests "
|
||||
"({:.2f}%). The communication with the printer is unreliable. "
|
||||
"Please see https://faq.octoprint.org/communication-errors.".format(
|
||||
stats.tx_error_threshold * 100, stats.tx_error_rate * 100
|
||||
)
|
||||
)
|
||||
self.process_protocol_log(message)
|
||||
self._logger.warning(message)
|
||||
|
||||
##~~
|
||||
|
||||
def can_send(self):
|
||||
@@ -1866,6 +2011,7 @@ class ReprapGcodeProtocol(
|
||||
self._on_comm_ok(wait=True)
|
||||
|
||||
def _on_comm_resend(self, linenumber):
|
||||
self._stats.inc_tx_errors()
|
||||
try:
|
||||
if linenumber is None:
|
||||
return False
|
||||
@@ -3036,6 +3182,7 @@ class ReprapGcodeProtocol(
|
||||
data (bytes): the data to send
|
||||
"""
|
||||
self._transport.write(data + b"\n")
|
||||
self._stats.inc_tx()
|
||||
|
||||
def _add_to_last_lines(self, command, line_number=None):
|
||||
# type: (str, int) -> None
|
||||
@@ -3043,6 +3190,10 @@ class ReprapGcodeProtocol(
|
||||
|
||||
##~~ gcode command handlers
|
||||
|
||||
def _gcode_T_queuing(self, command):
|
||||
# TODO evaluate "sanity_check_tools", block and trigger notification if needed
|
||||
pass
|
||||
|
||||
def _gcode_T_sent(self, command):
|
||||
if command.tool:
|
||||
self._internal_flags["current_tool"] = int(command.tool)
|
||||
@@ -3230,51 +3381,6 @@ class ReprapGcodeProtocol(
|
||||
self._last_lines.clear()
|
||||
self._internal_flags["resend_linenumber"] = None
|
||||
|
||||
def _gcode_M112_queuing(self, command):
|
||||
# emergency stop, jump the queue with the M112
|
||||
emergency_stop = self.flavor.command_emergency_stop().bytes
|
||||
self._do_send_without_checksum(emergency_stop)
|
||||
self._do_increment_and_send_with_checksum(emergency_stop)
|
||||
|
||||
# No idea if the printer is still listening or if M112 won. Just in case
|
||||
# we'll now try to also manually make sure all heaters are shut off - better
|
||||
# safe than sorry. We do this ignoring the queue since at this point it
|
||||
# is irrelevant whether the printer has sent enough ack's or not, we
|
||||
# are going to shutdown the connection in a second anyhow.
|
||||
extruder_count = self._printer_profile["extruder"]["count"]
|
||||
shared_nozzle = self._printer_profile["extruder"]["sharedNozzle"]
|
||||
if extruder_count > 1 and not shared_nozzle:
|
||||
for tool in range(extruder_count):
|
||||
self._do_increment_and_send_with_checksum(
|
||||
self.flavor.command_set_extruder_temp(0, tool=tool).bytes
|
||||
)
|
||||
else:
|
||||
self._do_increment_and_send_with_checksum(
|
||||
self.flavor.command_set_extruder_temp(0).bytes
|
||||
)
|
||||
|
||||
if self._printer_profile["heatedBed"]:
|
||||
self._do_increment_and_send_with_checksum(
|
||||
self.flavor.command_set_bed_temp(0).bytes
|
||||
)
|
||||
|
||||
# close to reset host state
|
||||
# TODO needs error handling
|
||||
"""
|
||||
self._errorValue = "Closing serial port due to emergency stop M112."
|
||||
self._log(self._errorValue)
|
||||
self.close(is_error=True)
|
||||
"""
|
||||
|
||||
# fire the M112 event since we sent it and we're going to prevent the caller from seeing it
|
||||
event = GCODE_TO_EVENT.get("M112")
|
||||
if event is not None:
|
||||
self._event_bus.fire(event)
|
||||
|
||||
# return None 1-tuple to eat the one that is queuing because we don't want to send it twice
|
||||
# I hope it got it the first time because as far as I can tell, there is no way to know
|
||||
return (None,)
|
||||
|
||||
# TODO
|
||||
# def _gcode_M114_queued(self, *args, **kwargs):
|
||||
# self._reset_position_timers()
|
||||
@@ -3332,13 +3438,14 @@ class ReprapGcodeProtocol(
|
||||
|
||||
def _command_phase_queuing(self, command):
|
||||
if isinstance(command, GcodeCommand):
|
||||
if (
|
||||
command.code in self.flavor.emergency_commands
|
||||
and command.code != self.flavor.command_emergency_stop().code
|
||||
):
|
||||
message = "Force-sending {} to the printer".format(command)
|
||||
self._logger.info(message)
|
||||
return self._emergency_force_send(command, message)
|
||||
if command.code in self.flavor.emergency_commands:
|
||||
if command.code == self.flavor.command_emergency_stop().code:
|
||||
self._trigger_emergency_stop()
|
||||
return (None,)
|
||||
else:
|
||||
message = "Force-sending {} to the printer".format(command)
|
||||
self._logger.info(message)
|
||||
return self._emergency_force_send(command, message)
|
||||
|
||||
if (
|
||||
self.state in ProtocolState.PROCESSING_STATES
|
||||
@@ -3348,6 +3455,7 @@ class ReprapGcodeProtocol(
|
||||
self.pause_processing(tags=command.tags)
|
||||
|
||||
if command.code in self.flavor.blocked_commands:
|
||||
# TODO evaluate "notify_suppressed_commands" and trigger notification if needed
|
||||
self._logger.info(
|
||||
"Not sending {} to printer, it's configured as a blocked command".format(
|
||||
command
|
||||
@@ -3437,4 +3545,60 @@ class ReprapGcodeProtocol(
|
||||
self.state = ProtocolState.ERROR
|
||||
self._event_bus.fire(Events.ERROR, {"error": text, "reason": reason})
|
||||
if disconnect:
|
||||
if (
|
||||
self.send_emergency_stop
|
||||
and not self._is_streaming()
|
||||
and reason not in ("connection", "autodetect")
|
||||
):
|
||||
self._trigger_emergency_stop(close=False)
|
||||
self.disconnect(error=True)
|
||||
|
||||
def _trigger_emergency_stop(self, close=True):
|
||||
emergency_command = self.flavor.command_emergency_stop()
|
||||
self._logger.info(
|
||||
"Force-sending {} to the printer".format(emergency_command.code)
|
||||
)
|
||||
|
||||
# emergency stop, jump the queue with the M112, regardless of whether the EMERGENCY_PARSER capability is
|
||||
# available or not
|
||||
#
|
||||
# send the M112 once without and with checksum
|
||||
self._do_send_without_checksum(emergency_command.bytes)
|
||||
self._do_increment_and_send_with_checksum(emergency_command.bytes)
|
||||
|
||||
# No idea if the printer is still listening or if M112 won. Just in case
|
||||
# we'll now try to also manually make sure all heaters are shut off - better
|
||||
# safe than sorry. We do this ignoring the queue since at this point it
|
||||
# is irrelevant whether the printer has sent enough ack's or not, we
|
||||
# are going to shutdown the connection in a second anyhow.
|
||||
if self._printer_profile["extruder"]["count"] > 1:
|
||||
for tool in range(self._printer_profile["extruder"]["count"]):
|
||||
self._do_increment_and_send_with_checksum(
|
||||
self.flavor.command_set_extruder_temp(0, tool=tool).bytes
|
||||
)
|
||||
else:
|
||||
self._do_increment_and_send_with_checksum(
|
||||
self.flavor.command_set_extruder_temp(0).bytes
|
||||
)
|
||||
|
||||
if self._printer_profile["heatedBed"]:
|
||||
self._do_increment_and_send_with_checksum(
|
||||
self.flavor.command_set_bed_temp(0).bytes
|
||||
)
|
||||
|
||||
if self._printer_profile["heatedChamber"]:
|
||||
self._do_increment_and_send_with_checksum(
|
||||
self.flavor.command_set_chamber_temp(0).bytes
|
||||
)
|
||||
|
||||
if close:
|
||||
# close to reset host state
|
||||
self.error = "Closing serial port due to emergency stop."
|
||||
self.process_protocol_log("!!! " + self.error)
|
||||
self._logger.warning(self.error)
|
||||
self.disconnect(error=True)
|
||||
|
||||
# fire the M112 event since we sent it and we're going to prevent the caller from seeing it
|
||||
gcode = emergency_command.code
|
||||
if gcode in GCODE_TO_EVENT:
|
||||
self._event_bus.fire(GCODE_TO_EVENT[gcode])
|
||||
@@ -76,6 +76,8 @@ class GenericFlavor(metaclass=FlavorMeta):
|
||||
|
||||
heatup_abortable = False
|
||||
|
||||
ok_buffer_size = 1
|
||||
|
||||
regex_min_max_error = re.compile(r"Error:[0-9]\n")
|
||||
"""Regex matching first line of min/max errors from legacy firmware."""
|
||||
|
||||
@@ -150,6 +152,7 @@ class GenericFlavor(metaclass=FlavorMeta):
|
||||
"pausing_commands": cls.pausing_commands,
|
||||
"emergency_commands": cls.emergency_commands,
|
||||
"heatup_abortable": cls.heatup_abortable,
|
||||
"ok_buffer_size": cls.ok_buffer_size,
|
||||
}
|
||||
|
||||
##~~ Identifier
|
||||
|
||||
@@ -5,6 +5,7 @@ import copy
|
||||
import threading
|
||||
|
||||
from octoprint.comm.protocol.reprap.commands import Command, to_command
|
||||
from octoprint.comm.util.gcode import strip_comment
|
||||
from octoprint.util import CountedEvent
|
||||
|
||||
regex_float_pattern = r"[-+]?[0-9]*\.?[0-9]+"
|
||||
@@ -12,26 +13,12 @@ regex_positive_float_pattern = r"[+]?[0-9]*\.?[0-9]+"
|
||||
regex_int_pattern = r"\d+"
|
||||
|
||||
|
||||
def strip_comment(line):
|
||||
if ";" not in line:
|
||||
# shortcut
|
||||
return line
|
||||
|
||||
escaped = False
|
||||
result = []
|
||||
for c in line:
|
||||
if c == ";" and not escaped:
|
||||
break
|
||||
result += c
|
||||
escaped = (c == "\\") and not escaped
|
||||
return "".join(result).strip()
|
||||
|
||||
|
||||
def process_gcode_line(line, offsets=None, current_tool=None):
|
||||
line = strip_comment(line).strip()
|
||||
if not len(line):
|
||||
return None
|
||||
|
||||
# TODO: apply offsets
|
||||
# if offsets is not None:
|
||||
# line = apply_temperature_offsets(line, offsets, current_tool=current_tool)
|
||||
|
||||
|
||||
@@ -14,13 +14,14 @@ _registry = {}
|
||||
|
||||
|
||||
def register_transports():
|
||||
from .serialtransport import SerialTransport
|
||||
from .serialtransport import SerialTransport, SerialUrlTransport
|
||||
from .sockettransport import SerialOverTcpTransport, TcpTransport
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# stock transports
|
||||
register_transport(SerialTransport)
|
||||
register_transport(SerialUrlTransport)
|
||||
register_transport(TcpTransport)
|
||||
register_transport(SerialOverTcpTransport)
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ __license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agp
|
||||
__copyright__ = "Copyright (C) 2018 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||
|
||||
import logging
|
||||
import os
|
||||
|
||||
import serial
|
||||
|
||||
@@ -12,9 +13,11 @@ from octoprint.comm.util.parameters import (
|
||||
IntegerType,
|
||||
SmallChoiceType,
|
||||
SuggestionType,
|
||||
UrlType,
|
||||
Value,
|
||||
)
|
||||
from octoprint.util import dummy_gettext as gettext
|
||||
from octoprint.util.platform import get_os, set_close_exec
|
||||
|
||||
|
||||
class SerialTransport(Transport):
|
||||
@@ -45,9 +48,9 @@ class SerialTransport(Transport):
|
||||
baudrates += additional_baudrates
|
||||
|
||||
return type(
|
||||
cls.__name__ + b"WithAdditionalPorts",
|
||||
cls.__name__ + "WithAdditionalPorts",
|
||||
(cls,),
|
||||
{b"unix_port_patterns": patterns, b"suggested_baudrates": baudrates},
|
||||
{"unix_port_patterns": patterns, "suggested_baudrates": baudrates},
|
||||
)
|
||||
|
||||
@classmethod
|
||||
@@ -66,6 +69,11 @@ class SerialTransport(Transport):
|
||||
lambda value: Value(value),
|
||||
default=0,
|
||||
),
|
||||
] + cls._get_common_options()
|
||||
|
||||
@classmethod
|
||||
def _get_common_options(cls):
|
||||
return [
|
||||
IntegerType(
|
||||
"write_timeout",
|
||||
gettext("Write Timeout"),
|
||||
@@ -95,7 +103,6 @@ class SerialTransport(Transport):
|
||||
advanced=True,
|
||||
expert=True,
|
||||
),
|
||||
# TODO: implement parity workaround flag
|
||||
SmallChoiceType(
|
||||
"parity_workaround",
|
||||
gettext("Apply parity double open workaround"),
|
||||
@@ -285,18 +292,80 @@ class SerialTransport(Transport):
|
||||
return getattr(self._serial, "in_waiting", 0)
|
||||
|
||||
def _default_serial_factory(self, **kwargs):
|
||||
return serial.Serial(
|
||||
port=kwargs.get("port"),
|
||||
serial_obj = self._create_serial(**kwargs)
|
||||
self._apply_parity_workaround(serial_obj, **kwargs)
|
||||
serial_obj.open()
|
||||
self._set_close_exec(serial_obj, **kwargs)
|
||||
|
||||
return serial_obj
|
||||
|
||||
@classmethod
|
||||
def _create_serial(cls, **kwargs):
|
||||
serial_obj = serial.Serial(
|
||||
baudrate=kwargs.get("baudrate"),
|
||||
exclusive=kwargs.get("exclusive"),
|
||||
parity=kwargs.get("parity"),
|
||||
write_timeout=kwargs.get("write_timeout", 10) * 1000,
|
||||
)
|
||||
serial_obj.port = kwargs.get("port") # set port only now to prevent auto open
|
||||
return serial_obj
|
||||
|
||||
@classmethod
|
||||
def _apply_parity_workaround(cls, serial_obj, **kwargs):
|
||||
use_parity_workaround = kwargs.get("parity_workaround")
|
||||
needs_parity_workaround = get_os() == "linux" and os.path.exists(
|
||||
"/etc/debian_version"
|
||||
) # See #673
|
||||
|
||||
if use_parity_workaround == "always" or (
|
||||
needs_parity_workaround and use_parity_workaround == "detect"
|
||||
):
|
||||
serial_obj.parity = serial.PARITY_ODD
|
||||
serial_obj.open()
|
||||
serial_obj.close()
|
||||
serial_obj.parity = kwargs.get("parity")
|
||||
|
||||
return serial_obj
|
||||
|
||||
@classmethod
|
||||
def _set_close_exec(cls, serial_obj, **kwargs):
|
||||
if hasattr(serial_obj, "fd"):
|
||||
# posix
|
||||
set_close_exec(serial_obj.fd)
|
||||
elif hasattr(serial_obj, "_port_handle"):
|
||||
# win32
|
||||
# noinspection PyProtectedMember
|
||||
set_close_exec(serial_obj._port_handle)
|
||||
|
||||
return serial_obj
|
||||
|
||||
def __str__(self):
|
||||
return "SerialTransport"
|
||||
|
||||
|
||||
class SerialUrlTransport(SerialTransport):
|
||||
name = "Serial URL Connection"
|
||||
key = "serialurl"
|
||||
message_integrity = False
|
||||
|
||||
@classmethod
|
||||
def get_connection_options(cls):
|
||||
return [
|
||||
UrlType(
|
||||
"url",
|
||||
"URL",
|
||||
help=gettext(
|
||||
"See [here](https://pythonhosted.org/pyserial/url_handlers.html#urls) for supported URL schemes"
|
||||
),
|
||||
)
|
||||
] + cls._get_common_options()
|
||||
|
||||
@classmethod
|
||||
def _create_serial(cls, **kwargs):
|
||||
serial_obj = serial.serial_for_url(kwargs.get("url"), do_not_open=True)
|
||||
return serial_obj
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# list ports
|
||||
ports = SerialTransport.get_available_serial_ports()
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html"
|
||||
__copyright__ = "Copyright (C) 2021 The OctoPrint Project - Released under terms of the AGPLv3 License"
|
||||
|
||||
|
||||
def strip_comment(line):
|
||||
if ";" not in line:
|
||||
# shortcut
|
||||
return line
|
||||
|
||||
escaped = False
|
||||
result = []
|
||||
for c in line:
|
||||
if c == ";" and not escaped:
|
||||
break
|
||||
result += c
|
||||
escaped = (c == "\\") and not escaped
|
||||
return "".join(result).strip()
|
||||
@@ -79,6 +79,10 @@ class TextType(ParamType):
|
||||
return value
|
||||
|
||||
|
||||
class UrlType(TextType):
|
||||
type = "url"
|
||||
|
||||
|
||||
class IntegerType(ParamType):
|
||||
type = "integer"
|
||||
|
||||
|
||||
@@ -591,7 +591,7 @@ class LocalFileStorage(Storage):
|
||||
return "analysis" in metadata
|
||||
|
||||
def create_print_job(self, path, user=None):
|
||||
from octoprint.comm.job import LocalGcodeFilePrintjob
|
||||
from octoprint.comm.job.gcode import LocalGcodeFilePrintjob
|
||||
|
||||
return LocalGcodeFilePrintjob(
|
||||
self.path_on_disk(path),
|
||||
|
||||
@@ -18,13 +18,9 @@ from frozendict import frozendict
|
||||
|
||||
import octoprint.util.json
|
||||
from octoprint import util as util
|
||||
from octoprint.comm.job import (
|
||||
CopyJobMixin,
|
||||
LocalGcodeFilePrintjob,
|
||||
LocalGcodeStreamjob,
|
||||
SDFilePrintjob,
|
||||
StoragePrintjob,
|
||||
)
|
||||
from octoprint.comm.job import CopyJobMixin, StoragePrintjob
|
||||
from octoprint.comm.job.gcode import LocalGcodeFilePrintjob, LocalGcodeStreamjob
|
||||
from octoprint.comm.job.sdcard import SDFilePrintjob
|
||||
from octoprint.comm.protocol import (
|
||||
FileAwareProtocolListener,
|
||||
PositionAwareProtocolListener,
|
||||
@@ -1423,15 +1419,12 @@ class Printer(
|
||||
)
|
||||
|
||||
def _update_resend_data_callback(self):
|
||||
# if not self._comm:
|
||||
# return self._dict(count=0, transmitted=0, ratio=0)
|
||||
# return self._dict(
|
||||
# count=self._comm.received_resends,
|
||||
# transmitted=self._comm.transmitted_lines,
|
||||
# ratio=int(self._comm.resend_ratio * 100),
|
||||
# )
|
||||
# TODO implement me
|
||||
return self._dict(count=0, transmitted=0, ratio=0)
|
||||
if not self._protocol:
|
||||
return self._dict(count=0, transmitted=0, ratio=0)
|
||||
stats = self._protocol.stats
|
||||
return self._dict(
|
||||
count=stats.tx_errors, transmitted=stats.tx, ratio=stats.tx_error_rate * 100
|
||||
)
|
||||
|
||||
def _add_temperature_data(self, temperatures=None):
|
||||
if temperatures is None:
|
||||
|
||||
@@ -110,13 +110,13 @@ def connectionProfileSet(identifier):
|
||||
@Permissions.SETTINGS.require(403)
|
||||
def connectionProfilesDelete(identifier):
|
||||
current_profile = connectionProfileManager.get_current()
|
||||
if current_profile and current_profile["id"] == identifier:
|
||||
if current_profile and current_profile.id == identifier:
|
||||
return make_response(
|
||||
"Cannot delete currently selected profile: {}".format(identifier), 409
|
||||
)
|
||||
|
||||
default_profile = connectionProfileManager.get_default()
|
||||
if default_profile and default_profile["id"] == identifier:
|
||||
if default_profile and default_profile.id == identifier:
|
||||
return make_response("Cannot delete default profile: {}".format(identifier), 409)
|
||||
|
||||
connectionProfileManager.remove(identifier)
|
||||
|
||||
@@ -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;*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.active,.btn.disabled,.btn:active,.btn:focus,.btn:hover,.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:focus,.btn:hover{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:#333 dotted thin;outline:-webkit-focus-ring-color auto 5px;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{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;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.active,.btn-primary.disabled,.btn-primary:active,.btn-primary:focus,.btn-primary:hover,.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;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.active,.btn-warning.disabled,.btn-warning:active,.btn-warning:focus,.btn-warning:hover,.btn-warning[disabled]{color:#fff;background-color:#f89406;*background-color:#df8505}.btn-warning.active,.btn-warning:active{background-color:#c67605 \9}.btn-danger{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#da4f49;background-image:-moz-linear-gradient(top,#ee5f5b,#bd362f);background-image:-webkit-gradient(linear,0 0,0 100%,from(#ee5f5b),to(#bd362f));background-image:-webkit-linear-gradient(top,#ee5f5b,#bd362f);background-image:-o-linear-gradient(top,#ee5f5b,#bd362f);background-image:linear-gradient(to bottom,#ee5f5b,#bd362f);background-repeaLine 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,.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;*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.active,.btn.disabled,.btn:active,.btn:focus,.btn:hover,.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:focus,.btn:hover{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:#333 dotted thin;outline:-webkit-focus-ring-color auto 5px;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{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;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.active,.btn-primary.disabled,.btn-primary:active,.btn-primary:focus,.btn-primary:hover,.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;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.active,.btn-warning.disabled,.btn-warning:active,.btn-warning:focus,.btn-warning:hover,.btn-warning[disabled]{color:#fff;background-color:#f89406;*background-color:#df8505}.btn-warning.active,.btn-warning:active{background-color:#c67605 \9}.btn-danger{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25);background-color:#da4f49;background-image:-moz-linear-gradient(top,#ee5f5b,#bd362f);background-image:-webkit-gradient(linear,0 0,0 100%,from(#ee5f5b),to(#bd362f));background-image:-webkit-linear-gradient(top,#ee5f5b,#bd362f);background-image:-o-linear-gradient(top,#ee5f5b,#bd362f);background-image:linear-gradient(to bottom,#ee5f5b,#bd362f);background-repeaLine truncated
|
||||
@@ -12,7 +12,7 @@
|
||||
<!-- /ko -->
|
||||
|
||||
<div class="advanced_options" data-bind="visible: expertProtocolParameters">
|
||||
<div><small><a class="muted" href="#" data-bind="toggleContent: { class: 'fa-caret-right fa-caret-down', parent: '.advanced_options', container: '.hide' }"><i class="fa fa-caret-right"></i> {{ _('Expert options') }}</a></small></div>
|
||||
<div><small><a class="muted" href="javascript:void(0)" data-bind="toggleContent: { class: 'fa-caret-right fa-caret-down', parent: '.advanced_options', container: '.hide' }"><i class="fa fa-caret-right"></i> {{ _('Expert options') }}</a></small></div>
|
||||
<div class="hide">
|
||||
<!-- ko foreach: protocolParameters -->
|
||||
<!-- ko if: expert -->
|
||||
@@ -42,7 +42,7 @@
|
||||
<!-- /ko -->
|
||||
|
||||
<div class="advanced_options" data-bind="visible: expertTransportParameters">
|
||||
<div><small><a class="muted" href="#" data-bind="toggleContent: { class: 'fa-caret-right fa-caret-down', parent: '.advanced_options', container: '.hide' }"><i class="fa fa-caret-right"></i> {{ _('Expert options') }}</a></small></div>
|
||||
<div><small><a class="muted" href="javascript:void(0)" data-bind="toggleContent: { class: 'fa-caret-right fa-caret-down', parent: '.advanced_options', container: '.hide' }"><i class="fa fa-caret-right"></i> {{ _('Expert options') }}</a></small></div>
|
||||
<div class="hide">
|
||||
<!-- ko foreach: transportParameters -->
|
||||
<!-- ko if: expert -->
|
||||
@@ -79,7 +79,7 @@
|
||||
<span class="add-on" data-bind="text: $data.unit"></span>
|
||||
</div>
|
||||
<!-- /ko -->
|
||||
<!-- ko unless: $data.unit -->
|
||||
<!-- ko ifnot: $data.unit -->
|
||||
<input class="input-small" type="number" step="1" data-bind="value: $data.value, attr: {placeholder: $data.default, min: $data.min, max: $data.max}, css: {disabled: !$root.isErrorOrClosed()}, enable: $root.isErrorOrClosed()">
|
||||
<!-- /ko -->
|
||||
<span class="help-block" data-bind="visible: $data.help, markdownInline: $data.help"></span>
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
<hr style="margin: 0">
|
||||
|
||||
<label data-bind="css: {disabled: !isErrorOrClosed()}, enable: isErrorOrClosed()">{{ _('Printer Profile') }}</label>
|
||||
<select class="input-block-level" data-test-id="connection-baudrates" data-bind="options: availablePrinterProfiles, optionsText: 'name', value: selectedPrinter, css: {disabled: !isErrorOrClosed()}, enable: isErrorOrClosed()"></select>
|
||||
<select class="input-block-level" data-test-id="connection-printer-profiles" data-bind="options: availablePrinterProfiles, optionsText: 'name', value: selectedPrinter, css: {disabled: !isErrorOrClosed()}, enable: isErrorOrClosed()"></select>
|
||||
|
||||
<hr style="margin: 0">
|
||||
|
||||
<label data-bind="css: {disabled: !isErrorOrClosed()}, enable: isErrorOrClosed()">{{ _('Protocol') }}</label>
|
||||
<select class="input-block-level" data-test-id="connection-printer-profiles" data-bind="options: availableProtocols, optionsText: 'name', value: selectedProtocol, css: {disabled: !isErrorOrClosed()}, enable: isErrorOrClosed()"></select>
|
||||
<select class="input-block-level" data-test-id="connection-protocols" data-bind="options: availableProtocols, optionsText: 'name', value: selectedProtocol, css: {disabled: !isErrorOrClosed()}, enable: isErrorOrClosed()"></select>
|
||||
<!-- ko foreach: protocolParameters -->
|
||||
<!-- ko if: !advanced -->
|
||||
<!-- ko template: { name: 'connection_template_' + $data.type, data: $data } --><!-- /ko -->
|
||||
@@ -26,7 +26,7 @@
|
||||
<hr style="margin: 0">
|
||||
|
||||
<label data-bind="css: {disabled: !isErrorOrClosed()}, enable: isErrorOrClosed()">{{ _('Transport') }}</label>
|
||||
<select class="input-block-level" data-bind="options: availableTransports, optionsText: 'name', value: selectedTransport, css: {disabled: !isErrorOrClosed()}, enable: isErrorOrClosed()"></select>
|
||||
<select class="input-block-level" data-test-id="connection-transports" data-bind="options: availableTransports, optionsText: 'name', value: selectedTransport, css: {disabled: !isErrorOrClosed()}, enable: isErrorOrClosed()"></select>
|
||||
<!-- ko foreach: transportParameters -->
|
||||
<!-- ko if: !advanced -->
|
||||
<!-- ko template: { name: 'connection_template_' + $data.type, data: $data } --><!-- /ko -->
|
||||
@@ -46,46 +46,65 @@
|
||||
<button class="btn btn-block" id="printer_connect_and_save" data-bind="click: function() { connect(true) }, visible: isErrorOrClosed() && adjustConnectionParameters()">{{ _('Save & Connect') }}</button>
|
||||
<button class="btn btn-primary btn-block" id="printer_connect" data-test-id="connection-connect" data-bind="click: function() { connect() }, text: buttonText">{{ _('Connect') }}</button>
|
||||
|
||||
<script type="text/html" id="connection_template_description">
|
||||
<p data-bind="markdownInline: $data.value"></p>
|
||||
</script>
|
||||
<script type="text/html" id="connection_template_text">
|
||||
<label data-bind="text: $data.title, css: {disabled: !$root.isErrorOrClosed()}, enable: $root.isErrorOrClosed()"></label>
|
||||
<input class="input-block-level" type="text" data-bind="value: $data.value, attr: {placeholder: $data.default}, css: {disabled: !$root.isErrorOrClosed()}, enable: $root.isErrorOrClosed()">
|
||||
<small class="help-block" data-bind="visible: $data.help, markdownInline: $data.help"></small>
|
||||
</script>
|
||||
<script type="text/html" id="connection_template_url">
|
||||
<label data-bind="text: $data.title, css: {disabled: !$root.isErrorOrClosed()}, enable: $root.isErrorOrClosed()"></label>
|
||||
<input class="input-block-level" type="text" data-bind="value: $data.value, attr: {placeholder: $data.default}, css: {disabled: !$root.isErrorOrClosed()}, enable: $root.isErrorOrClosed()">
|
||||
<small class="help-block" data-bind="visible: $data.help, markdownInline: $data.help"></small>
|
||||
</script>
|
||||
<script type="text/html" id="connection_template_integer">
|
||||
<label data-bind="text: $data.title, css: {disabled: !$root.isErrorOrClosed()}, enable: $root.isErrorOrClosed()"></label>
|
||||
<input class="input-block-level" type="number" step="1" data-bind="value: $data.value, attr: {placeholder: $data.default, min: $data.min, max: $data.max}, css: {disabled: !$root.isErrorOrClosed()}, enable: $root.isErrorOrClosed()">
|
||||
<small class="help-block" data-bind="visible: $data.help, markdownInline: $data.help"></small>
|
||||
</script>
|
||||
<script type="text/html" id="connection_template_float">
|
||||
<label data-bind="text: $data.title, css: {disabled: !$root.isErrorOrClosed()}, enable: $root.isErrorOrClosed()"></label>
|
||||
<input class="input-block-level" type="number" data-bind="value: $data.value, attr: {placeholder: $data.default, min: $data.min, max: $data.max}, css: {disabled: !$root.isErrorOrClosed()}, enable: $root.isErrorOrClosed()">
|
||||
<small class="help-block" data-bind="visible: $data.help, markdownInline: $data.help"></small>
|
||||
</script>
|
||||
<script type="text/html" id="connection_template_choice">
|
||||
<label data-bind="text: $data.title, css: {disabled: !$root.isErrorOrClosed()}, enable: $root.isErrorOrClosed()"></label>
|
||||
<select class="input-block-level" data-bind="options: $data.choices, optionsText: 'title', optionsValue: 'value', value: $data.value, css: {disabled: !$root.isErrorOrClosed()}, enable: $root.isErrorOrClosed()"></select>
|
||||
<small class="help-block" data-bind="visible: $data.help, markdownInline: $data.help"></small>
|
||||
</script>
|
||||
<script type="text/html" id="connection_template_smallchoice">
|
||||
<label data-bind="text: $data.title, css: {disabled: !$root.isErrorOrClosed()}, enable: $root.isErrorOrClosed()"></label>
|
||||
<!-- ko foreach: choices -->
|
||||
<label class="radio">
|
||||
<input type="radio" data-bind="attr: { name: 'connection_dialog_' + $parent.name + '_group' }, value: $data.value, checked: $parent.value"> <span data-bind="text: $data.title"></span>
|
||||
<small class="help-block" data-bind="visible: $data.help, markdownInline: $data.help"></small>
|
||||
</label>
|
||||
<!-- /ko -->
|
||||
<small class="help-block" data-bind="visible: $data.help, markdownInline: $data.help"></small>
|
||||
</script>
|
||||
<script type="text/html" id="connection_template_boolean">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: $data.value, css: {disabled: !$root.isErrorOrClosed()}, enable: $root.isErrorOrClosed()"> <span data-bind="text: $data.title"></span>
|
||||
<span class="help-block" data-bind="visible: $data.help, markdownInline: $data.help"></span>
|
||||
</label>
|
||||
<small class="help-block" data-bind="visible: $data.help, markdownInline: $data.help"></small>
|
||||
</script>
|
||||
<script type="text/html" id="connection_template_suggestion">
|
||||
<label data-bind="text: $data.title, css: {disabled: !$root.isErrorOrClosed()}, enable: $root.isErrorOrClosed()"></label>
|
||||
<select class="input-block-level" data-bind="options: $data.suggestions, optionsText: 'title', optionsValue: 'value', value: $data.value, css: {disabled: !$root.isErrorOrClosed()}, enable: $root.isErrorOrClosed()"></select>
|
||||
<small class="help-block" data-bind="visible: $data.help, markdownInline: $data.help"></small>
|
||||
</script>
|
||||
<script type="text/html" id="connection_template_list">
|
||||
<label data-bind="text: $data.title, css: {disabled: !$root.isErrorOrClosed()}, enable: $root.isErrorOrClosed()"></label>
|
||||
<textarea data-bind="value: $data.value, css: {disabled: !$root.isErrorOrClosed()}, enable: $root.isErrorOrClosed()"></textarea>
|
||||
<small class="help-block" data-bind="visible: $data.help, markdownInline: $data.help"></small>
|
||||
</script>
|
||||
<script type="text/html" id="connection_template_smalllist">
|
||||
<label data-bind="text: $data.title, css: {disabled: !$root.isErrorOrClosed()}, enable: $root.isErrorOrClosed()"></label>
|
||||
<input type="text" class="input-block-level" data-bind="value: $data.value, css: {disabled: !$root.isErrorOrClosed()}, enable: $root.isErrorOrClosed()">
|
||||
<small class="help-block" data-bind="visible: $data.help, markdownInline: $data.help"></small>
|
||||
</script>
|
||||
<script type="text/html" id="connection_template_group">
|
||||
<label data-bind="text: $data.title"></label>
|
||||
|
||||
@@ -30,7 +30,7 @@ class ListenerAware:
|
||||
method(*args, **kwargs)
|
||||
except Exception:
|
||||
logger.exception(
|
||||
"Exception while calling {}(...) on protocol listener {}".format(
|
||||
"Exception while calling {}(...) on listener {}".format(
|
||||
name, listener
|
||||
)
|
||||
)
|
||||
Reference in new issue
Block a user