Example #1
0
 def __init__(self, pipe):
     Interpreter.__init__(self, pipe=pipe)
     self.plot = None
     self.speed = 20.0
     self.scale = 1000.0  # g21 default.
     self.feed_convert = lambda s: s / (self.scale * 60.0)  # G94 default
     self.feed_invert = lambda s: s * (self.scale * 60.0)
     self.power_updated = True
     self.speed_updated = True
     self.group_modulation = False
Example #2
0
 def move(self, x, y):
     line = []
     if self.state == INTERPRETER_STATE_PROGRAM:
         line.append('G1')
     else:
         line.append('G0')
     line.append('X%f' % (x / self.scale))
     line.append('Y%f' % (y / self.scale))
     if self.power_updated:
         line.append('S%f' % self.power)
         self.power_updated = False
     if self.speed_updated:
         line.append('F%d' % int(self.feed_convert(self.speed)))
         self.speed_updated = False
     self.pipe.write(' '.join(line) + self.device.line_end)
     Interpreter.move(self, x, y)
Example #3
0
 def execute(self):
     if self.hold():
         return
     while self.plot is not None:
         if self.hold():
             return
         try:
             x, y, on = next(self.plot)
             if on == 0:
                 self.laser_on()
             else:
                 self.laser_off()
             self.move(x, y)
         except StopIteration:
             self.plot = None
             return
         except RuntimeError:
             self.plot = None
             return
     Interpreter.execute(self)
Example #4
0
 def ensure_program_mode(self, *values):
     self.pipe.write('M3' + self.device.line_end)
     Interpreter.ensure_program_mode(self, *values)
Example #5
0
 def set_speed(self, speed=None):
     Interpreter.set_speed(self, speed)
     self.speed_updated = True
Example #6
0
 def set_power(self, power=1000.0):
     Interpreter.set_power(self, power)
     self.power_updated = True
Example #7
0
 def ensure_finished_mode(self, *values):
     self.pipe.write('M5' + self.device.line_end)
     Interpreter.ensure_finished_mode(self, *values)