def instantiate_virtual_plotter(left_bottom = Coordinate(0,0),
                                right_top = Coordinate(10320, 7920),
                                type=None):
   '''
   Instantiates a virtual plotter with 8.5x11" (ANSI A) paper.
   If you have a default plotter defined in your config.py file
   we will use that plotter definition file (ignoring the serial
   port setting).
   '''

   which_plotter = type

   if type is None:
      map = get_config_value('serial_port_to_plotter_map')
      ## if user has set fixed port to plotter mapping...
      if map is not None:
         for k, v in map.items( ):
            which_plotter = v
      else:
         which_plotter = "Plotter"

   ser = VirtualSerialPort(left_bottom, right_top)
   plotter = instantiate_plotter_from_id(ser, which_plotter)
   print "\nInstantiated plotter %s:" % plotter
   coords = plotter.margins.soft.all_coordinates
   print "   Drawing limits: (left %s; bottom %s; right %s; top %s)" % coords
   print "   Buffer Size: %s" % plotter.buffer_size

   return plotter
def instantiate_virtual_plotter(
        left_bottom=Coordinate(0, 0),
        right_top=Coordinate(10320, 7920), type=None):
    '''
   Instantiates a virtual plotter with 8.5x11" (ANSI A) paper.
   If you have a default plotter defined in your config.py file
   we will use that plotter definition file (ignoring the serial
   port setting).
   '''

    which_plotter = type

    if type is None:
        map = get_config_value('serial_port_to_plotter_map')
        ## if user has set fixed port to plotter mapping...
        if map is not None:
            for k, v in map.items():
                which_plotter = v
        else:
            which_plotter = "Plotter"

    ser = VirtualSerialPort(left_bottom, right_top)
    plotter = instantiate_plotter_from_id(ser, which_plotter)
    print "\nInstantiated plotter %s:" % plotter
    coords = plotter.margins.soft.all_coordinates
    print "   Drawing limits: (left %s; bottom %s; right %s; top %s)" % coords
    print "   Buffer Size: %s" % plotter.buffer_size

    return plotter
Пример #3
0
   def __init__(self, serial_port):
      self.type = '_BasePlotter'
      self._logger = get_logger(self.__class__.__name__)
      self._serial_port = serial_port
      self._hpgl = commands
      self._margins = MarginsInterface(self)
      self.maximum_response_wait_time = get_config_value('maximum_response_wait_time')

      #this is so that we don't pause while preparing and sending
      #full buffers to the plotter. By sending 1/2 buffers we assure
      #that the plotter will still have some data to plot while
      #receiving the new data
      self.buffer_size = int(self._buffer_space / 2)
      self.initialize_plotter( )
Пример #4
0
    def __init__(self, serial_port):
        self.type = "_BasePlotter"
        self._logger = get_logger(self.__class__.__name__)
        self._serial_port = serial_port
        self._hpgl = commands
        self._margins = MarginsInterface(self)
        self.maximum_response_wait_time = get_config_value(
            "maximum_response_wait_time")

        # this is so that we don't pause while preparing and sending
        # full buffers to the plotter. By sending 1/2 buffers we assure
        # that the plotter will still have some data to plot while
        # receiving the new data
        self.buffer_size = int(self._buffer_space / 2)
        self.initialize_plotter()
Пример #5
0
def instantiate_plotters():
    """Instantiates all found and available plotters.
    The function sniffs all serial ports in search for pen plotters and
    instantiates all plotters found. If a plotter is not recognized,
    the function interactively queries user for plotter type."""

    from chiplotle.tools.plottertools import search_and_instantiate_plotters

    map = get_config_value("serial_port_to_plotter_map")
    ## if user has set fixed port to plotter mapping...
    if map is not None:
        result = []
        for k, v in list(map.items()):
            p = _instantiate_plotter(k, v)
            result.append(p)
    else:
        result = search_and_instantiate_plotters()
    return result
Пример #6
0
def instantiate_plotters( ):
    '''Instantiates all found and available plotters.
    The function sniffs all serial ports in search for pen plotters and
    instantiates all plotters found. If a plotter is not recognized,
    the function interactively queries user for plotter type.'''

    from chiplotle.tools.plottertools import search_and_instantiate_plotters

    map = get_config_value('serial_port_to_plotter_map')
    ## if user has set fixed port to plotter mapping...
    if map is not None:
        result = [ ]
        for k, v in map.items( ):
            p = _instantiate_plotter(k, v)
            result.append(p)
    else:
        result = search_and_instantiate_plotters( )
    return result
Пример #7
0
def get_logger(name):
    logger = logging.getLogger(name)
    logger.setLevel(logging.DEBUG)
    string = "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
    formatter = logging.Formatter(string)
    fh = logging.FileHandler(LOG_FILE, "w")
    fh.setLevel(logging.DEBUG)
    fh.setFormatter(formatter)
    logger.addHandler(fh)

    if get_config_value("verbose") == True:
        string = "%(name)s - %(levelname)s - %(message)s"
        formatter = logging.Formatter(string)
        s = logging.StreamHandler()
        s.setLevel(logging.INFO)
        s.setFormatter(formatter)
        logger.addHandler(s)

    return logger
Пример #8
0
def get_logger(name):
    logger = logging.getLogger(name)
    logger.setLevel(logging.DEBUG)
    string = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
    formatter = logging.Formatter(string)
    fh = logging.FileHandler(LOG_FILE, 'w')
    fh.setLevel(logging.DEBUG)
    fh.setFormatter(formatter)
    logger.addHandler(fh)

    if get_config_value('verbose') == True:
        string = '%(name)s - %(levelname)s - %(message)s'
        formatter = logging.Formatter(string)
        s = logging.StreamHandler( )
        s.setLevel(logging.INFO)
        s.setFormatter(formatter)
        logger.addHandler(s)

    return logger
def instantiate_serial_from_config_file(port):
    '''Instantiates a Serial with port `port` and serial config
    parameters read from the configuration file.'''
    bytesize = get_config_value('bytesize')
    parity = get_config_value('parity')
    stopbits = get_config_value('stopbits')
    timeout = get_config_value('timeout')
    xonxoff = get_config_value('xonxoff')
    rtscts = get_config_value('rtscts')
    ser = serial.Serial(port = port,
        bytesize = bytesize,
        parity = parity,
        stopbits = stopbits,
        timeout = timeout,
        xonxoff = xonxoff,
        rtscts = rtscts)
    return ser
def instantiate_serial_from_config_file(port):
    '''Instantiates a Serial with port `port` and serial config
    parameters read from the configuration file.'''
    bytesize = get_config_value('bytesize')
    parity = get_config_value('parity')
    stopbits = get_config_value('stopbits')
    timeout = get_config_value('timeout')
    xonxoff = get_config_value('xonxoff')
    rtscts = get_config_value('rtscts')
    ser = serial.Serial(port=port,
                        bytesize=bytesize,
                        parity=parity,
                        stopbits=stopbits,
                        timeout=timeout,
                        xonxoff=xonxoff,
                        rtscts=rtscts)
    return ser
def instantiate_serial_from_config_file(port):
    """Instantiates a Serial with port `port` and serial config
    parameters read from the configuration file."""
    bytesize = get_config_value("bytesize")
    parity = get_config_value("parity")
    stopbits = get_config_value("stopbits")
    timeout = get_config_value("timeout")
    xonxoff = get_config_value("xonxoff")
    rtscts = get_config_value("rtscts")
    ser = serial.Serial(
        port=port,
        bytesize=bytesize,
        parity=parity,
        stopbits=stopbits,
        timeout=timeout,
        xonxoff=xonxoff,
        rtscts=rtscts,
    )
    return ser