gcode: Eliminate the process_batch() method
Allow the callers of process_batch() to directly inspect the gcode mutex. Those callers can then directly invoke run_script(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
@@ -42,12 +42,10 @@ class IdleTimeout:
|
||||
self.state = "Printing"
|
||||
try:
|
||||
script = self.idle_gcode.render()
|
||||
res = self.gcode.process_batch(script.split('\n'))
|
||||
res = self.gcode.run_script(script)
|
||||
except:
|
||||
logging.exception("idle timeout gcode execution")
|
||||
return eventtime + 1.
|
||||
if not res:
|
||||
# Raced with incoming g-code commands
|
||||
self.state = "Ready"
|
||||
return eventtime + 1.
|
||||
print_time = self.toolhead.get_last_move_time()
|
||||
self.state = "Idle"
|
||||
@@ -64,7 +62,7 @@ class IdleTimeout:
|
||||
if idle_time < self.idle_timeout:
|
||||
# Wait for idle timeout
|
||||
return eventtime + self.idle_timeout - idle_time
|
||||
if not self.gcode.process_batch([]):
|
||||
if self.gcode.get_mutex().test():
|
||||
# Gcode class busy
|
||||
return eventtime + 1.
|
||||
# Idle timeout has elapsed
|
||||
@@ -82,7 +80,7 @@ class IdleTimeout:
|
||||
if buffer_time > -READY_TIMEOUT:
|
||||
# Wait for ready timeout
|
||||
return eventtime + READY_TIMEOUT + buffer_time
|
||||
if not self.gcode.process_batch([]):
|
||||
if self.gcode.get_mutex().test():
|
||||
# Gcode class busy
|
||||
return eventtime + READY_TIMEOUT
|
||||
# Transition to "ready" state
|
||||
|
||||
@@ -146,6 +146,7 @@ class VirtualSD:
|
||||
self.gcode.respond_error("Unable to seek file")
|
||||
self.work_timer = None
|
||||
return self.reactor.NEVER
|
||||
gcode_mutex = self.gcode.get_mutex()
|
||||
partial_input = ""
|
||||
lines = []
|
||||
while not self.must_pause_work:
|
||||
@@ -170,12 +171,13 @@ class VirtualSD:
|
||||
lines.reverse()
|
||||
self.reactor.pause(self.reactor.NOW)
|
||||
continue
|
||||
# Pause if any other request is pending in the gcode class
|
||||
if gcode_mutex.test():
|
||||
self.reactor.pause(self.reactor.monotonic() + 0.100)
|
||||
continue
|
||||
# Dispatch command
|
||||
try:
|
||||
res = self.gcode.process_batch([lines[-1]])
|
||||
if not res:
|
||||
self.reactor.pause(self.reactor.monotonic() + 0.100)
|
||||
continue
|
||||
self.gcode.run_script(lines[-1])
|
||||
except self.gcode.error as e:
|
||||
break
|
||||
except:
|
||||
|
||||
Reference in New Issue
Block a user