🔥 Remove old test code
This commit is contained in:
1 parent
9a4149164b
commit
225cca34e1
1 file changed
-82
@@ -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)
|
||||
Reference in new issue
Block a user