def _get_printer_details(self):
     communicator = UsbPacketCommunicator(self.usb_queue_length)
     communicator.register_handler(IAmMessage, self._ident_call_back)
     communicator.start()
     communicator.send(IdentifyMessage())
     until = time.time() + 5.0
     while (not self.printer_details and time.time() < until):
         time.sleep(0.1)
     communicator.close()
     details = self.printer_details
     self.printer_details = None
     return details
 def _get_printer_details(self):
     communicator = UsbPacketCommunicator(self.usb_queue_length)
     communicator.register_handler(IAmMessage, self._ident_call_back)
     communicator.start()
     communicator.send(IdentifyMessage())
     until = time.time() + 5.0
     while (not self.printer_details and time.time() < until):
         time.sleep(0.1)
     communicator.close()
     details = self.printer_details
     self.printer_details = None
     return details
Example #3
0
 def _get_printer_details(self):
     communicator = UsbPacketCommunicator(self.usb_queue_length)
     communicator.register_handler(IAmMessage, self._ident_call_back)
     communicator.start()
     communicator.send(IdentifyMessage())
     until = time.time() + 5.0
     while (not self.printer_details and time.time() < until):
         time.sleep(0.1)
     communicator.close()
     if not self.printer_details:
         raise MissingPrinterException()
     details = self.printer_details
     self.printer_details = None
     logger.info("Loaded printer \n{}".format(str(details.sn)))
     return details
 def _get_printer_details(self):
     communicator = UsbPacketCommunicator(self.usb_queue_length)
     communicator.register_handler(IAmMessage, self._ident_call_back)
     communicator.start()
     communicator.send(IdentifyMessage())
     until = time.time() + 5.0
     while (not self.printer_details and time.time() < until):
         time.sleep(0.1)
     communicator.close()
     if not self.printer_details:
         raise MissingPrinterException()
     details = self.printer_details
     self.printer_details = None
     logger.info("Loaded printer \n{}".format(str(details.sn)))
     return details
Example #5
0
 def prepare(self):
     usb_communicator = UsbPacketCommunicator(50)
     usb_communicator.start()
     usb_communicator.send(EnterBootloaderMessage())
     time.sleep(0.1)  #need to wait for usb
     usb_communicator.close()
Example #6
0
class UsbTestTerminal(object):
    VREF_CAL_POS = 0
    TEMP30_CAL_POS = 1
    TEMP110_CAL_POS = 2
    ADC_KEY_POS = 3
    ADC_PA3_POS = 4
    ADC_TEMP_POS = 5
    ADC_VREF_POS = 6

    def __init__(self, verbose=False):
        self._verbose = verbose

        self._drips = 0
        self._serial = None
        self._swrev = None
        self._hwrev = None
        self._adcNum = []
        self._adcVal = []
        self._dataRate = None
        self._adcCals = []
        self._move = [0, 0, 0]

        self._usb = UsbPacketCommunicator(10)
        self._usb.register_handler(IAmMessage, self.iAmHandler)
        self._usb.register_handler(DripRecordedMessage, self.dripHandler)
        self._usb.register_handler(ReturnAdcValMessage, self.adcHandler)
        self._usb.start()
        if verbose:
            print "Started usb terminal"
        time.sleep(0.1)

    def usbClose(self):
        self._usb.close()

    def laserOff(self):
        move = self._move
        self._usb.send(MoveMessage(move[0], move[1], 0))

    def laserOn(self):
        move = self._move
        self._usb.send(MoveMessage(move[0], move[1], 255))

    def move(self, x, y, laserPower=0):
        self._move = [x, y, laserPower]
        self._usb.send(MoveMessage(x, y, laserPower))

    def setDrips(self, dripCount=0):
        self._usb.send(SetDripCountMessage(dripCount))

    def identify(self):
        self._usb.send(IdentifyMessage())

    def enterBootloader(self, i_am_sure=None):
        if i_am_sure == (0xDEADBEEF):
            self._usb.send(EnterBootloaderMessage())
            if (self._verbose):
                print "Bootloadereded"
        elif (self._verbose):
            print "i_am_sure not loaded with the correct value"
            print "Note: This may lock your peachy into the bootloader"
            print "      if you have old firmware on your board"

    #A non-ideal push/pop queue interface.
    #Doesn't account for mis-matching - May be worth clearing on each request?
    def popAdc(self, timeout=0.1):
        start = time.time()
        timeout = start + timeout  #in seconds
        while (time.time() < timeout):  #wait for data being available or
            if (len(self._adcVal) != 0):
                tmp = [self._adcNum[0], self._adcVal[0]]
                del self._adcNum[0]
                del self._adcVal[0]
                return tmp
            else:
                time.sleep(0.01)

    def clearAdcQueues(self):
        self._adcNum = []
        self._adcVal = []

    def getAdcCalibrations(self):
        if len(self._adcCals) != 3:
            [adcNum, adcVrefCal] = self.getAdcVal(self.VREF_CAL_POS)
            [adcNum, adcTemp30] = self.getAdcVal(self.TEMP30_CAL_POS)
            [adcNum, adcTemp110] = self.getAdcVal(self.TEMP110_CAL_POS)
            self._adcCals = [adcVrefCal, adcTemp30, adcTemp110]

    def getTemperature(self):

        self.getAdcCalibrations()

        #Return actual Temperature in C
        #Formulas taken from STM32F0 datasheet page 252
        adcVrefCal = self._adcCals[self.VREF_CAL_POS]
        adcTemp30 = self._adcCals[self.TEMP30_CAL_POS]
        adcTemp110 = self._adcCals[self.TEMP110_CAL_POS]

        #Get the current Vref and Temperature each time
        [adcNum, adcTemperature] = self.getAdcVal(self.ADC_TEMP_POS)
        [adcNum, adcVref] = self.getAdcVal(self.ADC_VREF_POS)

        vrefCompensation = 1.0 * adcVrefCal / adcVref
        temperature = adcTemperature * vrefCompensation - adcTemp30
        temperature = temperature * (110 - 30) / (adcTemp110 - adcTemp30)
        temperature = temperature + 30

        if (self._verbose):
            print('Temperatures Value={0} Celcius={1}'.format(
                adcTemperature, temperature))

        return temperature

    def getSupplyVoltage(self):

        self.getAdcCalibrations()
        adcVrefCal = self._adcCals[self.VREF_CAL_POS]
        [adcNum, adcVref] = self.getAdcVal(self.ADC_VREF_POS)

        vrefCompensation = 1.0 * adcVrefCal / adcVref

        #calibrated at 3.3V always
        supplyVoltage = 3.3 * vrefCompensation

        if (self._verbose):
            print('Voltage {0}, Value {1}'.format(supplyVoltage, adcVref))

        return supplyVoltage

    def getAdcKeyVal(self):
        return self.getAdcVal(self.ADC_KEY_POS)

    def getAdcVal(self, adcNum):
        '''ADC NUMBERS:
        0 - Vref Calibration Factor
        1 - 30C temperature calibration
        2 - 110C temperature calibration
        3 - ADC key (PA2)
        4 - Pin (PA3)
        5 - Temperature
        6 - Vref (3.3V volts)
        '''

        self._adcNum.append(adcNum)
        self._usb.send(GetAdcValMessage(adcNum))
        if self._verbose:
            print('adcNum: {0}'.format(adcNum))
        return self.popAdc()

    def adcHandler(self, message):
        if (len(self._adcNum) > len(self._adcVal)):
            self._adcVal.append(message.adcVal)
            if self._verbose:
                print('adcNum: {0} adcVal: {1}'.format(self._adcNum[-1],
                                                       self._adcVal[-1]))
        else:
            self.clearAdcQueues()

    def dripHandler(self, message):
        self._drips = message.drips
        if self._verbose:
            print('Recieved drip: {0}'.format(message.drips))

    def iAmHandler(self, message):
        self._serial = message.sn
        self._swrev = message.swrev
        self._hwrev = message.hwrev
        self._dataRate = message.dataRate
        if self._verbose:
            print('Serial number: {0}'.format(message.sn))
            print('SW rev number: {0}'.format(message.swrev))
            print('HW rev number: {0}'.format(message.hwrev))
            print('Data Rate:     {0}'.format(message.dataRate))
class DripperSetupMixIn(object):
    '''This is a Mixin for the ConfigurationAPI and exists only for organizational purposes'''

    def get_dripper_drips_per_mm(self):
        '''Returns Drips Per mm'''

        return self._current_config.dripper.drips_per_mm

    def get_dripper_type(self):
        '''Returns the configured Dripper Type'''

        return self._current_config.dripper.dripper_type

    def get_dripper_emulated_drips_per_second(self):
        '''Gets the drips per second to be emulated'''

        return self._current_config.dripper.emulated_drips_per_second

    def get_dripper_photo_zaxis_delay(self):
        '''Gets the photo delay in seconds'''

        return self._current_config.dripper.photo_zaxis_delay

    def set_dripper_drips_per_mm(self, drips):
        '''Sets Drips Per mm'''

        self._current_config.dripper.drips_per_mm = drips
        if self._drip_detector:
            self._drip_detector.set_drips_per_mm(drips)
        self.save()

    def set_dripper_type(self, value):
        '''Sets the configured Dripper Type'''

        self._current_config.dripper.dripper_type = value
        self.save()

    def set_dripper_emulated_drips_per_second(self, value):
        '''Sets the drips per second to be emulated'''

        self._current_config.dripper.emulated_drips_per_second = value
        self.save()

    def set_dripper_photo_zaxis_delay(self, value):
        '''Sets the photo delay in seconds'''

        self._current_config.dripper.photo_zaxis_delay = value
        self.save()

    def reset_drips(self):
        '''Sets the drip count back to 0'''

        self._drip_detector.reset()

    def start_counting_drips(self, drip_call_back=None):
        '''Turns on the counting of drips. Stop must be called to end this.'''

        self.drip_call_back = drip_call_back
        if self._current_config.serial.on:
            self._commander = SerialCommander(self._current_config.serial.port)
        self._change_dripper()

    def _change_dripper(self):
        self._stop_current_dripper()
        if self._current_config.dripper.dripper_type == 'emulated':
            pass
        elif self._current_config.dripper.dripper_type == 'photo':
            pass
        elif self._current_config.dripper.dripper_type == 'microcontroller':
            self._communicator = UsbPacketCommunicator(self._current_config.circut.calibration_queue_length)
            self._communicator.start()
            self._drip_detector = SerialDripZAxis(self._communicator, 1, 0.0, drip_call_back=self.drip_call_back)

    def _stop_current_dripper(self):
        if self._communicator:
            self._communicator.close()
        if self._drip_detector:
            self._drip_detector.close()
            self._drip_detector = None

    def stop_counting_drips(self):
        '''Turns off the counting of drips if counting'''

        if self._commander:
            self._commander.close()
        self._stop_current_dripper()

    def send_dripper_on_command(self):
        '''If serial commuinication is enabled this send the turn on drips command'''

        if self._commander:
            self._commander.send_command(self._current_config.serial.on_command)
        else:
            raise Exception("Serial not Started")

    def send_dripper_off_command(self):
        '''If serial commuinication is enabled this send the turn off drips command'''

        if self._commander:
            self._commander.send_command(self._current_config.serial.off_command)
        else:
            raise Exception("Serial not Started")
class UsbTestTerminal(object):
    VREF_CAL_POS = 0
    TEMP30_CAL_POS = 1
    TEMP110_CAL_POS = 2
    ADC_KEY_POS = 3
    ADC_PA3_POS = 4
    ADC_TEMP_POS = 5
    ADC_VREF_POS = 6

    def __init__(self,verbose=False):
        self._verbose=verbose

        self._drips=0
        self._serial=None
        self._swrev=None
        self._hwrev=None
        self._adcNum=[]
        self._adcVal=[]
        self._dataRate=None
        self._adcCals=[]
        self._move=[0,0,0]

        self._usb = UsbPacketCommunicator(10)
        self._usb.register_handler(IAmMessage, self.iAmHandler)
        self._usb.register_handler(DripRecordedMessage, self.dripHandler)
        self._usb.register_handler(ReturnAdcValMessage, self.adcHandler)
        self._usb.start()
        if verbose:
            print "Started usb terminal"
        time.sleep(0.1)

    def usbClose(self):
        self._usb.close()

    def laserOff(self):
        move=self._move
        self._usb.send(MoveMessage(move[0],move[1],0))

    def laserOn(self):
        move=self._move
        self._usb.send(MoveMessage(move[0],move[1],255))

    def move(self,x,y,laserPower=0):
        self._move=[x,y,laserPower]
        self._usb.send(MoveMessage(x,y,laserPower))

    def setDrips(self,dripCount=0):
        self._usb.send(SetDripCountMessage(dripCount))

    def identify(self):
        self._usb.send(IdentifyMessage())

    def enterBootloader(self,i_am_sure=None):
        if i_am_sure==(0xDEADBEEF):
            self._usb.send(EnterBootloaderMessage())
            if (self._verbose):
                print "Bootloadereded"
        elif (self._verbose):
            print "i_am_sure not loaded with the correct value"
            print "Note: This may lock your peachy into the bootloader"
            print "      if you have old firmware on your board"

    #A non-ideal push/pop queue interface.
    #Doesn't account for mis-matching - May be worth clearing on each request?
    def popAdc(self,timeout=0.1):
        start=time.time()
        timeout=start+timeout #in seconds
        while(time.time()<timeout): #wait for data being available or 
            if (len(self._adcVal) != 0):
                tmp=[self._adcNum[0],self._adcVal[0]]
                del self._adcNum[0]
                del self._adcVal[0]
                return tmp
            else:
                time.sleep(0.01)

    def clearAdcQueues(self):
        self._adcNum=[]
        self._adcVal=[]

    def getAdcCalibrations(self):
        if len(self._adcCals)!=3:
            [adcNum,adcVrefCal] = self.getAdcVal(self.VREF_CAL_POS)
            [adcNum,adcTemp30] = self.getAdcVal(self.TEMP30_CAL_POS)
            [adcNum,adcTemp110] = self.getAdcVal(self.TEMP110_CAL_POS)
            self._adcCals = [adcVrefCal,adcTemp30,adcTemp110]

    def getTemperature(self):

        self.getAdcCalibrations()

        #Return actual Temperature in C
        #Formulas taken from STM32F0 datasheet page 252
        adcVrefCal = self._adcCals[self.VREF_CAL_POS]
        adcTemp30 = self._adcCals[self.TEMP30_CAL_POS]
        adcTemp110 = self._adcCals[self.TEMP110_CAL_POS]

        #Get the current Vref and Temperature each time
        [adcNum,adcTemperature]=self.getAdcVal(self.ADC_TEMP_POS)
        [adcNum,adcVref]=self.getAdcVal(self.ADC_VREF_POS)

        vrefCompensation = 1.0*adcVrefCal/adcVref
        temperature = adcTemperature*vrefCompensation-adcTemp30
        temperature = temperature*(110-30)/(adcTemp110-adcTemp30)
        temperature = temperature + 30

        if (self._verbose):
            print ('Temperatures Value={0} Celcius={1}'.format(adcTemperature,temperature))

        return temperature

    def getSupplyVoltage(self):

        self.getAdcCalibrations()
        adcVrefCal=self._adcCals[self.VREF_CAL_POS]
        [adcNum,adcVref]=self.getAdcVal(self.ADC_VREF_POS)

        vrefCompensation = 1.0*adcVrefCal/adcVref
        
        #calibrated at 3.3V always
        supplyVoltage = 3.3*vrefCompensation

        if (self._verbose):
            print ('Voltage {0}, Value {1}'.format(supplyVoltage,adcVref))

        return supplyVoltage

    def getAdcKeyVal(self):
        return self.getAdcVal(self.ADC_KEY_POS)

    def getAdcVal(self,adcNum):
        '''ADC NUMBERS:
        0 - Vref Calibration Factor
        1 - 30C temperature calibration
        2 - 110C temperature calibration
        3 - ADC key (PA2)
        4 - Pin (PA3)
        5 - Temperature
        6 - Vref (3.3V volts)
        '''

        self._adcNum.append(adcNum)
        self._usb.send(GetAdcValMessage(adcNum))
        if self._verbose:
            print('adcNum: {0}'.format(adcNum))
        return self.popAdc()

    def adcHandler(self,message):
        if (len(self._adcNum) > len(self._adcVal)):
            self._adcVal.append(message.adcVal)
            if self._verbose:
                print('adcNum: {0} adcVal: {1}'.format(self._adcNum[-1], self._adcVal[-1]))
        else:
            self.clearAdcQueues()

    def dripHandler(self, message):
        self._drips=message.drips
        if self._verbose:
            print('Recieved drip: {0}'.format(message.drips))

    def iAmHandler(self, message):
        self._serial=message.sn
        self._swrev=message.swrev
        self._hwrev=message.hwrev
        self._dataRate=message.dataRate
        if self._verbose:
            print('Serial number: {0}'.format(message.sn))
            print('SW rev number: {0}'.format(message.swrev))
            print('HW rev number: {0}'.format(message.hwrev))
            print('Data Rate:     {0}'.format(message.dataRate))
class DripperSetupMixIn(object):

    '''Depricated use get_dripper_drips_per_mm'''
    def get_drips_per_mm(self):
        logging.warning("Depricated use get_dripper_drips_per_mm")
        return self.get_dripper_drips_per_mm()

    '''Returns Drips Per mm'''
    def get_dripper_drips_per_mm(self):
        return self._current_config.dripper.drips_per_mm

    '''Returns the configured Dripper Type'''
    def get_dripper_type(self):
        return self._current_config.dripper.dripper_type

    '''Depricated use get_dripper_emulated_drips_per_second'''
    def get_emulated_drips_per_second(self):
        logging.warning("Depricated use get_dripper_emulated_drips_per_second")
        return self.get_dripper_emulated_drips_per_second()

    '''Gets the drips per second to be emulated'''
    def get_dripper_emulated_drips_per_second(self):
        return self._current_config.dripper.emulated_drips_per_second

    '''Depricated use get_dripper_photo_zaxis_delay'''
    def get_photo_zaxis_delay(self):
        logging.warning("Depricated use get_dripper_photo_zaxis_delay")
        return self.get_dripper_photo_zaxis_delay()

    '''Gets the photo delay in seconds'''
    def get_dripper_photo_zaxis_delay(self):
        return self._current_config.dripper.photo_zaxis_delay

    '''Depricated use set_dripper_drips_per_mm'''
    def set_drips_per_mm(self, drips):
        logging.warning("Depricated use set_dripper_drips_per_mm")
        self.set_dripper_drips_per_mm(drips)

    '''Sets Drips Per mm'''
    def set_dripper_drips_per_mm(self, drips):
        self._current_config.dripper.drips_per_mm = drips
        if self._drip_detector:
            self._drip_detector.set_drips_per_mm(drips)
        self.save()

    '''Sets the configured Dripper Type'''
    def set_dripper_type(self, value):
        self._current_config.dripper.dripper_type = value
        self.save()

    '''Depricated use set_dripper_emulated_drips_per_second'''
    def set_emulated_drips_per_second(self, value):
        logging.warning("Depricated use set_dripper_emulated_drips_per_second")
        self.set_dripper_emulated_drips_per_second(value)

    '''Sets the drips per second to be emulated'''
    def set_dripper_emulated_drips_per_second(self, value):
        self._current_config.dripper.emulated_drips_per_second = value
        self.save()

    '''Depricated use set_dripper_photo_zaxis_delay'''
    def set_photo_zaxis_delay(self, value):
        logging.warning("Depricated use set_dripper_photo_zaxis_delay")
        self.set_dripper_photo_zaxis_delay(value)

    '''Sets the photo delay in seconds'''
    def set_dripper_photo_zaxis_delay(self, value):
        self._current_config.dripper.photo_zaxis_delay = value
        self.save()

    '''Sets the drip count back to 0'''
    def reset_drips(self):
        self._drip_detector.reset()

    '''Turns on the counting of drips. Stop must be called to end this.'''
    def start_counting_drips(self, drip_call_back=None):
        self.drip_call_back = drip_call_back
        if self._current_config.serial.on:
            self._commander = SerialCommander(self._current_config.serial.port)
        self._change_dripper()

    def _change_dripper(self):
        self._stop_current_dripper()
        if self._current_config.dripper.dripper_type == 'emulated':
            pass
        elif self._current_config.dripper.dripper_type == 'photo':
            pass
        elif self._current_config.dripper.dripper_type == 'microcontroller':
            self._communicator = UsbPacketCommunicator(self._current_config.circut.calibration_queue_length)
            self._communicator.start()
            self._drip_detector = SerialDripZAxis(self._communicator, 1, 0.0, drip_call_back=self.drip_call_back)

    def _stop_current_dripper(self):
        if self._communicator:
            self._communicator.close()
        if self._drip_detector:
            self._drip_detector.close()
            self._drip_detector = None

    '''Turns off the counting of drips if counting'''
    def stop_counting_drips(self):
        if self._commander:
            self._commander.close()
        self._stop_current_dripper()

    def send_dripper_on_command(self):
        if self._commander:
            self._commander.send_command(self._current_config.serial.on_command)
        else:
            raise Exception("Serial not Started")

    def send_dripper_off_command(self):
        if self._commander:
            self._commander.send_command(self._current_config.serial.off_command)
        else:
            raise Exception("Serial not Started")
Example #10
0
class DripperSetupMixIn(object):
    '''This is a Mixin for the ConfigurationAPI and exists only for organizational purposes'''
    def get_dripper_drips_per_mm(self):
        '''Returns Drips Per mm'''

        return self._current_config.dripper.drips_per_mm

    def get_dripper_type(self):
        '''Returns the configured Dripper Type'''

        return self._current_config.dripper.dripper_type

    def get_dripper_emulated_drips_per_second(self):
        '''Gets the drips per second to be emulated'''

        return self._current_config.dripper.emulated_drips_per_second

    def get_dripper_photo_zaxis_delay(self):
        '''Gets the photo delay in seconds'''

        return self._current_config.dripper.photo_zaxis_delay

    def set_dripper_drips_per_mm(self, drips):
        '''Sets Drips Per mm'''

        self._current_config.dripper.drips_per_mm = drips
        if self._drip_detector:
            self._drip_detector.set_drips_per_mm(drips)
        self.save()

    def set_dripper_type(self, value):
        '''Sets the configured Dripper Type'''

        self._current_config.dripper.dripper_type = value
        self.save()

    def set_dripper_emulated_drips_per_second(self, value):
        '''Sets the drips per second to be emulated'''

        self._current_config.dripper.emulated_drips_per_second = value
        self.save()

    def set_dripper_photo_zaxis_delay(self, value):
        '''Sets the photo delay in seconds'''

        self._current_config.dripper.photo_zaxis_delay = value
        self.save()

    def reset_drips(self):
        '''Sets the drip count back to 0'''

        self._drip_detector.reset()

    def start_counting_drips(self, drip_call_back=None):
        '''Turns on the counting of drips. Stop must be called to end this.'''

        self.drip_call_back = drip_call_back
        if self._current_config.serial.on:
            self._commander = SerialCommander(self._current_config.serial.port)
        self._change_dripper()

    def _change_dripper(self):
        self._stop_current_dripper()
        if self._current_config.dripper.dripper_type == 'emulated':
            pass
        elif self._current_config.dripper.dripper_type == 'photo':
            pass
        elif self._current_config.dripper.dripper_type == 'microcontroller':
            self._communicator = UsbPacketCommunicator(
                self._current_config.circut.calibration_queue_length)
            self._communicator.start()
            self._drip_detector = SerialDripZAxis(
                self._communicator, 1, 0.0, drip_call_back=self.drip_call_back)

    def _stop_current_dripper(self):
        if self._communicator:
            self._communicator.close()
        if self._drip_detector:
            self._drip_detector.close()
            self._drip_detector = None

    def stop_counting_drips(self):
        '''Turns off the counting of drips if counting'''

        if self._commander:
            self._commander.close()
        self._stop_current_dripper()

    def send_dripper_on_command(self):
        '''If serial commuinication is enabled this send the turn on drips command'''

        if self._commander:
            self._commander.send_command(
                self._current_config.serial.on_command)
        else:
            raise Exception("Serial not Started")

    def send_dripper_off_command(self):
        '''If serial commuinication is enabled this send the turn off drips command'''

        if self._commander:
            self._commander.send_command(
                self._current_config.serial.off_command)
        else:
            raise Exception("Serial not Started")
Example #11
0
class DripperSetupMixIn(object):
    '''Depricated use get_dripper_drips_per_mm'''
    def get_drips_per_mm(self):
        logging.warning("Depricated use get_dripper_drips_per_mm")
        return self.get_dripper_drips_per_mm()

    '''Returns Drips Per mm'''

    def get_dripper_drips_per_mm(self):
        return self._current_config.dripper.drips_per_mm

    '''Returns the configured Dripper Type'''

    def get_dripper_type(self):
        return self._current_config.dripper.dripper_type

    '''Depricated use get_dripper_emulated_drips_per_second'''

    def get_emulated_drips_per_second(self):
        logging.warning("Depricated use get_dripper_emulated_drips_per_second")
        return self.get_dripper_emulated_drips_per_second()

    '''Gets the drips per second to be emulated'''

    def get_dripper_emulated_drips_per_second(self):
        return self._current_config.dripper.emulated_drips_per_second

    '''Depricated use get_dripper_photo_zaxis_delay'''

    def get_photo_zaxis_delay(self):
        logging.warning("Depricated use get_dripper_photo_zaxis_delay")
        return self.get_dripper_photo_zaxis_delay()

    '''Gets the photo delay in seconds'''

    def get_dripper_photo_zaxis_delay(self):
        return self._current_config.dripper.photo_zaxis_delay

    '''Depricated use set_dripper_drips_per_mm'''

    def set_drips_per_mm(self, drips):
        logging.warning("Depricated use set_dripper_drips_per_mm")
        self.set_dripper_drips_per_mm(drips)

    '''Sets Drips Per mm'''

    def set_dripper_drips_per_mm(self, drips):
        self._current_config.dripper.drips_per_mm = drips
        if self._drip_detector:
            self._drip_detector.set_drips_per_mm(drips)
        self.save()

    '''Sets the configured Dripper Type'''

    def set_dripper_type(self, value):
        self._current_config.dripper.dripper_type = value
        self.save()

    '''Depricated use set_dripper_emulated_drips_per_second'''

    def set_emulated_drips_per_second(self, value):
        logging.warning("Depricated use set_dripper_emulated_drips_per_second")
        self.set_dripper_emulated_drips_per_second(value)

    '''Sets the drips per second to be emulated'''

    def set_dripper_emulated_drips_per_second(self, value):
        self._current_config.dripper.emulated_drips_per_second = value
        self.save()

    '''Depricated use set_dripper_photo_zaxis_delay'''

    def set_photo_zaxis_delay(self, value):
        logging.warning("Depricated use set_dripper_photo_zaxis_delay")
        self.set_dripper_photo_zaxis_delay(value)

    '''Sets the photo delay in seconds'''

    def set_dripper_photo_zaxis_delay(self, value):
        self._current_config.dripper.photo_zaxis_delay = value
        self.save()

    '''Sets the drip count back to 0'''

    def reset_drips(self):
        self._drip_detector.reset()

    '''Turns on the counting of drips. Stop must be called to end this.'''

    def start_counting_drips(self, drip_call_back=None):
        self.drip_call_back = drip_call_back
        if self._current_config.serial.on:
            self._commander = SerialCommander(self._current_config.serial.port)
        self._change_dripper()

    def _change_dripper(self):
        self._stop_current_dripper()
        if self._current_config.dripper.dripper_type == 'emulated':
            pass
        elif self._current_config.dripper.dripper_type == 'photo':
            pass
        elif self._current_config.dripper.dripper_type == 'microcontroller':
            self._communicator = UsbPacketCommunicator(
                self._current_config.circut.calibration_queue_length)
            self._communicator.start()
            self._drip_detector = SerialDripZAxis(
                self._communicator, 1, 0.0, drip_call_back=self.drip_call_back)

    def _stop_current_dripper(self):
        if self._communicator:
            self._communicator.close()
        if self._drip_detector:
            self._drip_detector.close()
            self._drip_detector = None

    '''Turns off the counting of drips if counting'''

    def stop_counting_drips(self):
        if self._commander:
            self._commander.close()
        self._stop_current_dripper()

    def send_dripper_on_command(self):
        if self._commander:
            self._commander.send_command(
                self._current_config.serial.on_command)
        else:
            raise Exception("Serial not Started")

    def send_dripper_off_command(self):
        if self._commander:
            self._commander.send_command(
                self._current_config.serial.off_command)
        else:
            raise Exception("Serial not Started")