🚨 Start to flesh out connection parameters
This commit is contained in:
1 parent
2d872baaec
commit
67047c006c
6 files changed
+47
-21
No files matched your search
@@ -23,7 +23,7 @@ from octoprint.comm.protocol.reprap.util.queues import ScriptQueue, JobQueue, Co
|
||||
|
||||
from octoprint.comm.scripts import InvalidScript, UnknownScript
|
||||
|
||||
from octoprint.comm.util.parameters import ChoiceType, Value, ParamGroup, BooleanType, SmallChoiceType
|
||||
from octoprint.comm.util.parameters import ChoiceType, Value, ParamGroup, BooleanType, FloatType, IntegerType, SmallChoiceType
|
||||
|
||||
from octoprint.comm.job import LocalGcodeFilePrintjob, SDFilePrintjob, \
|
||||
LocalGcodeStreamjob, CopyJobMixin
|
||||
@@ -138,6 +138,21 @@ class ReprapGcodeProtocol(Protocol, ThreeDPrinterProtocolMixin, MotorControlProt
|
||||
Value("never", title="Never")],
|
||||
default="detect")],
|
||||
help="Just a test",
|
||||
advanced=True),
|
||||
ParamGroup("timeouts_and_intervals",
|
||||
"Timeouts and Intervals",
|
||||
[FloatType("detection_timeout", "Detection", default=1),
|
||||
FloatType("connection_timeout", "Connection", default=10),
|
||||
FloatType("communication_timeout_normal", "Communication", default=30),
|
||||
FloatType("communication_timeout_busy", "Communication (busy)", default=3),
|
||||
FloatType("temperature_interval_idle", "Temperature (idle)", default=5),
|
||||
FloatType("temperature_interval_target", "Temperature (target set)", default=2),
|
||||
FloatType("temperature_interval_auto", "Temperature (autoreport)", default=2),
|
||||
FloatType("sdstatus_interval_normal", "SD Status", default=1),
|
||||
FloatType("sdstatus_interval_auto", "SD status (autoreport)", default=1),
|
||||
FloatType("resendok_timeout", "Resend OK", default=.5),
|
||||
FloatType("baudrate_detection_pause", "Baudrate Detection Pause", default=1.0),
|
||||
FloatType("position_log_wait", "Position Log Wait", default=10)],
|
||||
advanced=True)]
|
||||
|
||||
@staticmethod
|
||||
|
||||
@@ -5,7 +5,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"
|
||||
|
||||
from octoprint.comm.transport import Transport, LineAwareTransportWrapper, PushingTransportWrapper
|
||||
from octoprint.comm.util.parameters import TextType, IntegerType, SuggestionType, Value
|
||||
from octoprint.comm.util.parameters import TextType, IntegerType, ChoiceType, SuggestionType, BooleanType, Value
|
||||
|
||||
import serial
|
||||
import logging
|
||||
@@ -40,7 +40,14 @@ class SerialTransport(Transport):
|
||||
def get_connection_options(cls):
|
||||
return [
|
||||
SuggestionType("port", "Port", cls.get_available_serial_ports(), lambda value: Value(value)),
|
||||
SuggestionType("baudrate", "Baudrate", cls.get_available_baudrates(), lambda value: Value(value), default=0)
|
||||
SuggestionType("baudrate", "Baudrate", cls.get_available_baudrates(), lambda value: Value(value), default=0),
|
||||
IntegerType("write_timeout", "Write Timeout (sec)", min=1, default=10, advanced=True),
|
||||
BooleanType("exclusive", "Exclusive access", default=True, advanced=True),
|
||||
ChoiceType("parity", "Parity",
|
||||
[Value(serial.PARITY_NONE, "none"),
|
||||
Value(serial.PARITY_ODD, "odd"),
|
||||
Value(serial.PARITY_EVEN, "even")],
|
||||
default=serial.PARITY_NONE, advanced=True)
|
||||
]
|
||||
|
||||
@classmethod
|
||||
@@ -91,14 +98,14 @@ class SerialTransport(Transport):
|
||||
|
||||
self._closing = False
|
||||
|
||||
def create_connection(self, port="AUTO", baudrate=0):
|
||||
def create_connection(self, **kwargs):
|
||||
factory = self.serial_factory
|
||||
if self.serial_factory is None:
|
||||
factory = self._default_serial_factory
|
||||
|
||||
self._closing = False
|
||||
self._serial = factory(port=port, baudrate=baudrate)
|
||||
self.set_current_args(port=port, baudrate=baudrate)
|
||||
self._serial = factory(**kwargs)
|
||||
self.set_current_args(**kwargs)
|
||||
|
||||
return True
|
||||
|
||||
@@ -182,8 +189,12 @@ class SerialTransport(Transport):
|
||||
def in_waiting(self):
|
||||
return getattr(self._serial, "in_waiting", 0)
|
||||
|
||||
def _default_serial_factory(self, port=None, baudrate=None):
|
||||
return serial.Serial(port=port, baudrate=baudrate)
|
||||
def _default_serial_factory(self, **kwargs):
|
||||
return serial.Serial(port=kwargs.get("port"),
|
||||
baudrate=kwargs.get("baudrate"),
|
||||
exclusive=kwargs.get("exclusive"),
|
||||
parity=kwargs.get("parity"),
|
||||
write_timeout=kwargs.get("write_timeout", 10) * 1000)
|
||||
|
||||
def __str__(self):
|
||||
return "SerialTransport"
|
||||
|
||||
@@ -54,15 +54,17 @@ class TextType(ParamType):
|
||||
class IntegerType(ParamType):
|
||||
type = "integer"
|
||||
|
||||
def __init__(self, name, title, min=None, max=None, **kwargs):
|
||||
def __init__(self, name, title, min=None, max=None, unit=None, **kwargs):
|
||||
self.min = min
|
||||
self.max = max
|
||||
self.unit = unit
|
||||
ParamType.__init__(self, name, title, **kwargs)
|
||||
|
||||
def as_dict(self):
|
||||
result = ParamType.as_dict(self)
|
||||
result.update(dict(min=self.min,
|
||||
max=self.max))
|
||||
max=self.max,
|
||||
unit=self.unit))
|
||||
return result
|
||||
|
||||
def convert(self, value):
|
||||
@@ -81,15 +83,17 @@ class IntegerType(ParamType):
|
||||
class FloatType(ParamType):
|
||||
type = "float"
|
||||
|
||||
def __init__(self, name, title, min=None, max=None, **kwargs):
|
||||
def __init__(self, name, title, min=None, max=None, unit=None, **kwargs):
|
||||
self.min = min
|
||||
self.max = max
|
||||
self.unit = unit
|
||||
ParamType.__init__(self, name, title, **kwargs)
|
||||
|
||||
def as_dict(self):
|
||||
result = ParamType.as_dict(self)
|
||||
result.update(dict(min=self.min,
|
||||
max=self.max))
|
||||
max=self.max,
|
||||
unit=self.unit))
|
||||
return result
|
||||
|
||||
def convert(self, value):
|
||||
|
||||
@@ -31,6 +31,7 @@ from octoprint.settings import settings
|
||||
from octoprint.util import InvariantContainer
|
||||
from octoprint.util import to_unicode
|
||||
from octoprint.util import monotonic_time
|
||||
from octoprint.util import dict_merge
|
||||
|
||||
from octoprint.comm.protocol import ProtocolListener, FileAwareProtocolListener, PositionAwareProtocolListener, ProtocolState
|
||||
from octoprint.comm.job import StoragePrintjob, LocalGcodeFilePrintjob, LocalGcodeStreamjob, SDFilePrintjob, CopyJobMixin
|
||||
@@ -312,7 +313,7 @@ class Printer(PrinterInterface,
|
||||
|
||||
selected_transport = kwargs.get("transport", connection.transport)
|
||||
transport_connect_kwargs = connection.transport_parameters
|
||||
transport_connect_kwargs.update(kwargs.get("transport_options", dict()))
|
||||
transport_connect_kwargs = dict_merge(transport_connect_kwargs, kwargs.get("transport_options", dict()))
|
||||
|
||||
transport_kwargs = dict()
|
||||
transport_kwargs.update(dict(settings=settings(),
|
||||
@@ -323,9 +324,7 @@ class Printer(PrinterInterface,
|
||||
##~~ Protocol
|
||||
|
||||
selected_protocol = kwargs.get("protocol", connection.protocol)
|
||||
protocol_kwargs = connection.protocol_parameters
|
||||
protocol_kwargs.update(kwargs.get("protocol_options", dict()))
|
||||
|
||||
protocol_kwargs = dict_merge(connection.protocol_parameters, kwargs.get("protocol_options", dict()))
|
||||
protocol_kwargs.update(dict(settings=settings(),
|
||||
plugin_manager=plugin_manager(),
|
||||
event_bus=eventManager(),
|
||||
|
||||
@@ -107,7 +107,7 @@ $(function() {
|
||||
self.transportParameters = ko.observableArray();
|
||||
self.advancedTransportParameters = ko.observable();
|
||||
self.showAdvancedTransportOptions = function() {
|
||||
|
||||
$("#connection_transport_dialog").modal("show");
|
||||
};
|
||||
|
||||
self.selectedTransport.subscribe(function() {
|
||||
|
||||
@@ -33,14 +33,11 @@
|
||||
<!-- /ko -->
|
||||
<!-- /ko -->
|
||||
<!-- ko if: advancedTransportParameters -->
|
||||
<small class="text-block text-right"><a href="javascript:void(0)">{{ _('Advanced...') }}</a></small>
|
||||
<small class="text-block text-right"><a href="javascript:void(0)" data-bind="click: showAdvancedTransportOptions">{{ _('Advanced...') }}</a></small>
|
||||
<!-- /ko -->
|
||||
|
||||
<hr style="margin: 0">
|
||||
</div>
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" id="connection_save" data-bind="checked: saveSettings, css: {disabled: !isErrorOrClosed()}, enable: isErrorOrClosed()"> {{ _('Save connection settings') }}
|
||||
</label>
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" id="connection_autoconnect" data-bind="checked: settings.serial_autoconnect, css: {disabled: !isErrorOrClosed()}, enable: isErrorOrClosed()"> {{ _('Auto-connect on server startup') }}
|
||||
</label>
|
||||
|
||||
Reference in new issue
Block a user