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( )
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()
def apply_logger(f): '''Applies a logger object to the 'wrapped' function.''' logger = get_logger(f.func_name) f.logger = logger return f
import serial import time from chiplotle.tools.logtools.get_logger import get_logger logger = get_logger(__name__) def what_plotter_in_port(port, wait_time=10): '''Check if there's a powered-on plotter in `port` port. - `port` : a string with port path or name. - `wait_time` : ``int`` maximum time in seconds to wait for plotter response. Returns the ID of the plotter found or None.''' assert isinstance(wait_time, int) if not isinstance(port, basestring): raise TypeError('`port` must be a string.') from chiplotle.tools.serialtools import instantiate_serial_from_config_file try: ser = instantiate_serial_from_config_file(port) except Exception as e: logger.info("Failed to instantiate serial device {} ({})".format(port, e)) return None try: ser.flushInput() ser.flushOutput() ser.write('IN;') ser.write('OI;')
def apply_logger(f): """Applies a logger object to the 'wrapped' function.""" logger = get_logger(f.__name__) f.logger = logger return f