Download raw (1023 bytes)
#!/usr/bin/env python2 # -*- coding: utf-8 -*- import chiplotle from settings import db import time from plottertools.memory import enlargeMemory # PLOTTER_SIGNATURE = '7550' # PLOTTER_PORT= '/dev/ttyUSB0' VIRTUAL = False if VIRTUAL: plotter = chiplotle.tools.plottertools.instantiate_virtual_plotter() else: plotter = chiplotle.tools.plottertools.instantiate_plotters()[0] enlargeMemory(plotter) while True: plotcursor = db.plots.find({'plotted': False}).sort('timestamp', 1).limit(1) if plotcursor.count() > 0: plot = plotcursor[0] if plot: try: plotter.write('IN;{};PG;'.format(str(plot['hpgl'].decode('utf-8')))) plotter._serial_port.flush() db.plots.update({'_id': plot['_id']}, {'$set': {'plotted': True}}) if VIRTUAL: chiplotle.tools.io.view(plotter) plotter = chiplotle.tools.plottertools.instantiate_virtual_plotter() except: print 'Something went wrong while plotting' pass time.sleep(4)