Join connection dialog with new comm layer
This commit is contained in:
1 parent
5d0cb14f71
commit
3173783620
22 files changed
+464
-189
No files matched your search
@@ -7,31 +7,24 @@ __copyright__ = "Copyright (C) 2015 The OctoPrint Project - Released under terms
|
||||
|
||||
import octoprint.plugin
|
||||
|
||||
from octoprint.comm.transport.serialtransport import SerialTransport
|
||||
|
||||
class VirtualSerialTransport(SerialTransport):
|
||||
name = "Virtual Connection"
|
||||
key = "virtual"
|
||||
|
||||
@classmethod
|
||||
def get_connection_options(cls):
|
||||
return []
|
||||
|
||||
def create_connection(self, *args, **kwargs):
|
||||
from . import virtual
|
||||
self._serial = virtual.VirtualPrinter()
|
||||
|
||||
|
||||
class VirtualPrinterPlugin(octoprint.plugin.SettingsPlugin):
|
||||
def virtual_printer_factory(self, comm_instance, port, baudrate,
|
||||
read_timeout):
|
||||
if not port == "VIRTUAL":
|
||||
return None
|
||||
|
||||
if not self._settings.global_get_boolean(
|
||||
["devel", "virtualPrinter", "enabled"]):
|
||||
return None
|
||||
|
||||
import logging.handlers
|
||||
from octoprint.logging.handlers import CleaningTimedRotatingFileHandler
|
||||
|
||||
seriallog_handler = CleaningTimedRotatingFileHandler(self._settings.get_plugin_logfile_path(postfix="serial"),
|
||||
when="D",
|
||||
backupCount=3)
|
||||
seriallog_handler.setFormatter(logging.Formatter("%(asctime)s %(message)s"))
|
||||
seriallog_handler.setLevel(logging.DEBUG)
|
||||
|
||||
from . import virtual
|
||||
|
||||
serial_obj = virtual.VirtualPrinter(seriallog_handler=seriallog_handler,
|
||||
read_timeout=float(read_timeout))
|
||||
return serial_obj
|
||||
def register_transport_hook(self, *args, **kwargs):
|
||||
return [VirtualSerialTransport]
|
||||
|
||||
|
||||
__plugin_name__ = "Virtual Printer"
|
||||
@@ -49,5 +42,5 @@ def __plugin_load__():
|
||||
|
||||
global __plugin_hooks__
|
||||
__plugin_hooks__ = {
|
||||
"octoprint.comm.transport.serial.factory": plugin.virtual_printer_factory
|
||||
"octoprint.comm.transport.register": plugin.register_transport_hook
|
||||
}
|
||||
Reference in new issue
Block a user