From 225cca34e158c41ee2875d046c3a51b23bb55a5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 14 Feb 2019 17:29:42 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A5=20Remove=20old=20test=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../comm/protocol/reprap/__init__.py | 82 ------------------- 1 file changed, 82 deletions(-) diff --git a/src/octoprint/comm/protocol/reprap/__init__.py b/src/octoprint/comm/protocol/reprap/__init__.py index 5ad40c14e..e7dccba83 100644 --- a/src/octoprint/comm/protocol/reprap/__init__.py +++ b/src/octoprint/comm/protocol/reprap/__init__.py @@ -2156,85 +2156,3 @@ class ReprapGcodeProtocol(Protocol, ThreeDPrinterProtocolMixin, MotorControlProt self._registered_messages = flavor_comm_attrs + flavor_message_attrs self._current_registered_messages = self._registered_messages self._error_messages = flavor_error_attrs - - -if __name__ == "__main__": - from octoprint.comm.transport.serialtransport import VirtualSerialTransport - from octoprint.comm.protocol.reprap.virtual import VirtualPrinter - from octoprint.comm.protocol import ProtocolListener, FileAwareProtocolListener - from octoprint.comm.job import PrintjobListener - - import os - - virtual_sd = "C:/Users/gina/AppData/Roaming/OctoPrint/virtualSd" - filename = "20mm_c~1.gco" - - def virtual_serial_factory(): - return VirtualPrinter(virtual_sd=virtual_sd) - - class CustomProtocolListener(ProtocolListener, FileAwareProtocolListener, PrintjobListener): - - def __init__(self, protocol): - super(CustomProtocolListener, self).__init__() - self._job = None - self._queue = [] - self._protocol = protocol - - def add_job(self, job): - self._queue.append(job) - - def get_next_job(self): - return self._queue.pop(0) if self._queue else None - - def start_next_job(self): - job = self.get_next_job() - if job is None: - return - - self._job = job - self._job.register_listener(self) - self._protocol.process(self._job) - - def on_protocol_state(self, protocol, old_state, new_state, *args, **kwargs): - if protocol != self._protocol: - return - print("State changed from {} to {}".format(old_state, new_state)) - - def on_protocol_temperature(self, protocol, temperatures, *args, **kwargs): - if protocol != self._protocol: - return - print("Temperature update: {!r}".format(temperatures)) - - def on_protocol_sd_file_list(self, protocol, files): - if protocol != self._protocol: - return - print("Received files from printer:") - for f in files: - print("\t{} (Size {} bytes)".format(*f)) - - self.start_next_job() - - def on_protocol_log(self, protocol, data, *args, **kwargs): - if protocol != self._protocol: - return - print(data) - - def on_job_progress(self, job): - if job != self._job: - return - print("Job progress: {}% (Time: {} min)".format(int(job.progress * 100) if job.progress is not None else "0", - "{}:{}".format(int(job.elapsed / 60), int(job.elapsed % 60)) if job.elapsed is not None else "?")) - - def on_job_done(self, job, *args, **kwargs): - self.start_next_job() - - transport = VirtualSerialTransport(virtual_serial_factory=virtual_serial_factory) - protocol = ReprapGcodeProtocol() - - protocol_listener = CustomProtocolListener(protocol) - protocol_listener.add_job(LocalGcodeFilePrintjob(os.path.join(virtual_sd, filename), "local", "foo.gcode")) - protocol_listener.add_job(SDFilePrintjob(filename)) - protocol.register_listener(protocol_listener) - - transport.connect() - protocol.connect(transport)