Esempio n. 1
0
    def set_dac(self, devid, value):
        """ Set the DAC0 output"""
        tmpstr = "/DAC/run %d %x\n"
        if devid == 0:
            val = value / self.conf['DACCONST0']
        elif devid == 1:
            val = value / self.conf['DACCONST1']
        else:
            raise ElixysCBoxError("Unexpected DAC device id")

        val = int(math.ceil(val))
        dacmax = self.conf['DACMAX']
        if val > dacmax:
            log.warn("Attempt to set DAC %d to "
                     "%d, setting to MAX %d", devid, val, dacmax)
            val = dacmax

        dacmin = self.conf['DACMIN']
        if val < dacmin:
            log.warn("Attempt to set DAC %d to "
                     "%d, setting to MIN %d", devid, val, dacmin)

        tmpstr = tmpstr % (devid, val)
        log.debug("Set DAC: sent %s", tmpstr)
        self.write(tmpstr)
        self.read()
Esempio n. 2
0
 def all(self):
     self.state_ = self.status.DigitalInputs['state']               
     self.all_state_ = [not bool(self.state_ >> sensorbit & 1) 
         for sensorbit in range(self.sysconf['DigitalInputs']['count'])]
     log.debug("Get Digital input %d tripped -> %s"
               % (self.id_, self.tripped_))
     return self.all_state_
Esempio n. 3
0
 def get_analog_out(self):
     """ Return the analog Liquid Sensor value
     """
     self.analog_out_ = self.status.LiquidSensors[self.id_]['analog_in'] / 4095.0
     log.debug("Get Liquid Sensor Analog in %d on -> %s"
               % (self.id_, self.analog_out_))
     return self.analog_out_
Esempio n. 4
0
    def set_dac(self, devid, value):
        """ Set the DAC0 output"""
        tmpstr = "/DAC/run %d %x\n"
        if devid == 0:
            val = value / self.conf['DACCONST0']
        elif devid == 1:
            val = value / self.conf['DACCONST1']
        else:
            raise ElixysCBoxError("Unexpected DAC device id")

        val = int(math.ceil(val))
        dacmax = self.conf['DACMAX']
        if val > dacmax:
            log.warn("Attempt to set DAC %d to "
                    "%d, setting to MAX %d", devid, val, dacmax)
            val = dacmax

        dacmin = self.conf['DACMIN']
        if val < dacmin:
            log.warn("Attempt to set DAC %d to "
                    "%d, setting to MIN %d", devid, val, dacmin)
        
        tmpstr = tmpstr % (devid, val)
        log.debug("Set DAC: sent %s", tmpstr)
        self.write(tmpstr)
        self.read()
Esempio n. 5
0
 def turn_counter_clockwise(self):
     """ Turn the stopcock counter clockwise """
     log.debug("Turn stopcock %d counter-clockwise", self.id_)
     self.synth.valves[self._cw_valve_id].on = False
     time.sleep(0.2)
     self.synth.valves[self._ccw_valve_id].on = True
     time.sleep(0.2)
Esempio n. 6
0
 def turn_counter_clockwise(self):
     """ Turn the stopcock counter clockwise """
     log.debug("Turn stopcock %d counter-clockwise", self.id_)
     self.synth.valves[self._cw_valve_id].on = False
     time.sleep(0.2)
     self.synth.valves[self._ccw_valve_id].on = True
     time.sleep(0.2)
Esempio n. 7
0
 def set_on(self, value):
     log.debug("Set Mixer %d on -> %s" % (self.id_, value))
     self.on_ = value
     if value is True:
         self.set_duty_cycle(100.0)
     else:
         self.set_duty_cycle(0.0)
Esempio n. 8
0
 def lower_no_check(self):
     """ Move the actuator down but don't wait """
     log.debug("Actuator %s lower | Turn on valve:%d, Turn off valve:%d",
             repr(self), self._down_valve_id, self._up_valve_id)
     self.synth.valves[self._up_valve_id].on = False
     time.sleep(0.2)
     self.synth.valves[self._down_valve_id].on = True
Esempio n. 9
0
 def set_setpoint(self, value):
     """ Set the pressure regulator,
     setpoint is generally in psi, but really
     depends on the hw configuration """
     value = value * self.conf['PSICONV']
     log.debug("Set pressure regulator %d to %f", self.id_, value)
     self.synth.cbox.set_dac(self.id_, value) 
Esempio n. 10
0
 def set_on(self, value):
     """ Set the valve state """
     if not hasattr(self,'valve_state0') or not hasattr(self,'valve_state1') \
         or not hasattr(self,'valve_state2'):
         self.load_states()
     log.debug("Set Valve %d on -> %s" % (self.id_, value))
     self.on_ = value
     if self.id_ < 16:
         log.debug("Before Set Valve %d (state0) on -> %s" % (self.id_, bin(Valve.valve_state0)))
         if value is True:
             Valve.valve_state0 |= (1<<(self.id_%16))
         else:
             Valve.valve_state0 &= ~(1<<(self.id_%16))
         self.comproc.run_cmd(self.cmd_lookup['Valves']['set_state0'](Valve.valve_state0))
         log.debug("After Set Valve %d (state0) on -> %s" % (self.id_, bin(Valve.valve_state0)))
         self.on_ = True
     elif self.id_ < 32:
         if value is True:
             Valve.valve_state1 |= (1<< (self.id_%16))
         else:
             Valve.valve_state1 &= ~(1<<(self.id_%16))
         self.comproc.run_cmd(self.cmd_lookup['Valves']['set_state1'](Valve.valve_state1))
         log.debug("Set Valve %d (state1) on -> %s" % (self.id_, bin(Valve.valve_state1)))
         self.on_ = True
     elif self.id_ < 48:
         if value is True:
             Valve.valve_state2 |= (1<< (self.id_%16))
         else:
             Valve.valve_state2 &= ~(1<<(self.id_%16))
         self.comproc.run_cmd(self.cmd_lookup['Valves']['set_state2'](Valve.valve_state2))
         log.debug("Set Valve %d (state2) on -> %s" % (self.id_, bin(Valve.valve_state2)))
         self.on_ = True
Esempio n. 11
0
 def set_on(self, value):
     log.debug("Set Mixer %d on -> %s" % (self.id_, value))
     self.on_ = value
     if value is True:
         self.set_duty_cycle(100.0)
     else:
         self.set_duty_cycle(0.0)
Esempio n. 12
0
 def close_no_check(self):
     """ Close the gripper and don't check the sensors """
     log.debug("Gripper Close | Turn off valve:%d, Turn on valve:%d",
               self._open_valve_id, self._close_valve_id)
     self.synth.valves[self._open_valve_id].on = False
     time.sleep(0.2)
     self.synth.valves[self._close_valve_id].on = True
     time.sleep(0.2)
Esempio n. 13
0
 def close_no_check(self):
     """ Close the gripper and don't check the sensors """
     log.debug("Gripper Close | Turn off valve:%d, Turn on valve:%d",
             self._open_valve_id, self._close_valve_id)
     self.synth.valves[self._open_valve_id].on = False
     time.sleep(0.2)
     self.synth.valves[self._close_valve_id].on = True
     time.sleep(0.2)
Esempio n. 14
0
 def get_setpoint(self):
     """ Get the pressure regulator
     setpoint, i.e. the pressure it is suppose to get to
     """
     value = self.synth.cbox.get_dacs()[self.id_]
     value = value / self.conf['PSICONV']
     log.debug("Current setpoint on regulator %d = %f",
             self.id_, value)
     return value
Esempio n. 15
0
 def all(self):
     self.state_ = self.status.DigitalInputs['state']
     self.all_state_ = [
         not bool(self.state_ >> sensorbit & 1)
         for sensorbit in range(self.sysconf['DigitalInputs']['count'])
     ]
     log.debug("Get Digital input %d tripped -> %s" %
               (self.id_, self.tripped_))
     return self.all_state_
Esempio n. 16
0
 def get_pressure(self):
     """ Return the actual pressure in PSI,
     or something else depending on hwconf.ini
     """
     value = self.synth.cbox.get_adcs()[self.id_]
     value = value / self.conf['PSICONV']
     log.debug("Current pressure on regulator %d = %f",
             self.id_, value)
     return value
Esempio n. 17
0
 def get_setpoint(self):
     """ Get the pressure regulator
     setpoint, i.e. the pressure it is suppose to get to
     """
     value = self.synth.cbox.get_dacs()[self.id_]
     value = value / self.conf['PSICONV']
     log.debug("Current setpoint on regulator %d = %f",
             self.id_, value)
     return value
Esempio n. 18
0
 def get_pressure(self):
     """ Return the actual pressure in PSI,
     or something else depending on hwconf.ini
     """
     value = self.synth.cbox.get_adcs()[self.id_]
     value = value / self.conf['PSICONV']
     log.debug("Current pressure on regulator %d = %f",
             self.id_, value)
     return value
Esempio n. 19
0
 def set_duty_cycle(self, value):
     log.debug("Set Mixer %d duty cycle -> %f" % (self.id_, value))        
     if value >= 0.0 and value <= 100.0:
         self.duty_ = value
         cmd = self.cmd_lookup['Mixers']['set_duty_cycle'][self.id_](value)
         self.comproc.run_cmd(cmd)
     else:
         # Raise Exception, value out of range!
         log.error("Mixer %d duty cycle -> %f out of range" % (self.id_, value))                
Esempio n. 20
0
 def get_on(self):
     log.debug("Get Temperature Controller %d on -> %s" %
               (self.id_, self.on_))
     errcode = self.status.TemperatureControllers[0]['error_code']
     if errcode == '\x01':
         self.on_ = True
     else:
         self.on_ = False
     return self.on_
Esempio n. 21
0
 def set_on(self, value):
     log.debug("Set Temperature Controller %d on -> %s"
               % (self.id_, value))
     self.on_ = value
     if self.on_ is True:
         cmd = self.cmd_lookup['TemperatureControllers']['turn_on'][self.id_]()
     else:
         cmd = self.cmd_lookup['TemperatureControllers']['turn_off'][self.id_]()
     self.comproc.run_cmd(cmd)
Esempio n. 22
0
 def get_on(self):
     log.debug("Get Temperature Controller %d on -> %s"
               % (self.id_, self.on_))
     errcode = self.status.TemperatureControllers[0]['error_code']
     if errcode == '\x01':
         self.on_ = True
     else:
         self.on_ = False
     return self.on_
Esempio n. 23
0
 def get_on(self):
     """ Determine if we are on or not.
     Heaters can ONLY be queried for their state
     temperature controller are used to turn them on or off
     """
     self.state_ = self.status['Heaters']['state']
     self.on_ = bool(self.state_ >> self.id_ & 1)
     log.debug("Get Heater %d on -> %s" % (self.id_, self.on_))
     return self.on_
Esempio n. 24
0
    def move_coord(self, x, y):
        """ Move to x, y coordinates """

        log.debug("Move Reagent Robot to %d, %d", x, y)
        self.prepare_move()
        self.xactuator.move(x)
        self.yactuator.move(y)
        self.yactuator.wait()
        self.xactuator.wait()
Esempio n. 25
0
    def set_analog_out(self, value):
        if not (value >= 0.0 and value <= 10.0):
            # Should raise exception in future!!!!
            log.error("SMC Analog setpoint (%f) out of range" % value)
            return
        self.comproc.run_cmd(self.cmd_lookup['SMCInterfaces']['set_analog_out']
                             [self.id_](value))
        log.debug("Set SMC Analog out %d on -> %s" % (self.id_, value))

        self.analog_out_ = value
Esempio n. 26
0
 def set_on(self, value):
     log.debug("Set Temperature Controller %d on -> %s" % (self.id_, value))
     self.on_ = value
     if self.on_ is True:
         cmd = self.cmd_lookup['TemperatureControllers']['turn_on'][
             self.id_]()
     else:
         cmd = self.cmd_lookup['TemperatureControllers']['turn_off'][
             self.id_]()
     self.comproc.run_cmd(cmd)
Esempio n. 27
0
 def set_duty_cycle(self, value):
     log.debug("Set Mixer %d duty cycle -> %f" % (self.id_, value))
     if value >= 0.0 and value <= 100.0:
         self.duty_ = value
         cmd = self.cmd_lookup['Mixers']['set_duty_cycle'][self.id_](value)
         self.comproc.run_cmd(cmd)
     else:
         # Raise Exception, value out of range!
         log.error("Mixer %d duty cycle -> %f out of range" %
                   (self.id_, value))
Esempio n. 28
0
    def set_analog_out(self, value):
        if not(value >= 0.0 and value <= 10.0):
            # Should raise exception in future!!!!
            log.error("SMC Analog setpoint (%f) out of range" % value)
            return
        self.comproc.run_cmd(self.cmd_lookup['SMCInterfaces']['set_analog_out'][self.id_](value))
        log.debug("Set SMC Analog out %d on -> %s"
                  % (self.id_, value))

        self.analog_out_ = value
Esempio n. 29
0
 def set_setpoint(self, value):
     if value > 180.0:
         #Raise exception
         log.debug("Error Temperature Controller %d setpoint -> %f,"
                   "TOO HOT, should be less than 180"
                   % (self.id_, self.setpoint_))
         return
     self.setpoint_ = value
     log.debug("Set Temperature Controller %d setpoint -> %f"
               % (self.id_, self.setpoint_))
     cmd = self.cmd_lookup['TemperatureControllers']['set_setpoint'][self.id_](value)
     self.comproc.run_cmd(cmd)
Esempio n. 30
0
 def set_setpoint(self, value):
     if value > 180.0:
         #Raise exception
         log.debug("Error Temperature Controller %d setpoint -> %f,"
                   "TOO HOT, should be less than 180" %
                   (self.id_, self.setpoint_))
         return
     self.setpoint_ = value
     log.debug("Set Temperature Controller %d setpoint -> %f" %
               (self.id_, self.setpoint_))
     cmd = self.cmd_lookup['TemperatureControllers']['set_setpoint'][
         self.id_](value)
     self.comproc.run_cmd(cmd)
Esempio n. 31
0
 def lower(self):
     """ Lower actuator and unsure it gets there """
     for i in xrange(self.conf['retry_count']):
         begintime = datetime.now()
         self.lower_no_check()
         while self.timeout > datetime.now() - begintime:
             time.sleep(0.1)
             if self.is_down:
                 log.debug("Lower actuator %s success", repr(self))
                 return
         log.info("Failed to raise actuator %s before timeout, retry %d",
                     repr(self), i)
     log.error("Failed to lower actuator %s after retrys", repr(self))
Esempio n. 32
0
 def close(self):
     """ Close the gripper and make sure it closes """
     for i in xrange(self.conf['retry_count']):
         begintime = datetime.now()
         self.close_no_check()
         while self.timeout > datetime.now() - begintime:
             time.sleep(0.1)
             if self.is_closed:
                 log.debug("Close actuator %s success", repr(self))
                 return
         log.info("Failed to close actuator %s before timeout, retry %d",
                  repr(self), i)
     log.error("Failed to close actuator %s after retrys", repr(self))
Esempio n. 33
0
 def close(self):
     """ Close the gripper and make sure it closes """
     for i in xrange(self.conf['retry_count']):
         begintime = datetime.now()
         self.close_no_check()
         while self.timeout > datetime.now() - begintime:
             time.sleep(0.1)
             if self.is_closed:
                 log.debug("Close actuator %s success", repr(self))
                 return
         log.info("Failed to close actuator %s before timeout, retry %d",
                     repr(self), i)
     log.error("Failed to close actuator %s after retrys", repr(self))
Esempio n. 34
0
    def __init__(self):

        super(SynthesizerHAL, self).__init__()

        log.debug("Initializing SynthesizerHAL")
        self.mixer_motors = [
            Mixer(i) for i in range(self.sysconf['Mixers']['count'])
        ]
        self.valves = [
            Valve(i) for i in range(self.sysconf['Valves']['count'])
        ]
        self.thermocouples = [
            Thermocouple(i)
            for i in range(self.sysconf['Thermocouples']['count'])
        ]
        self.aux_thermocouples = [
            AuxThermocouple(i)
            for i in range(self.sysconf['AuxThermocouples']['count'])
        ]

        self.heaters = [
            Heater(i) for i in range(self.sysconf['Heaters']['count'])
        ]

        self.temperature_controllers = [
            TemperatureController(i)
            for i in range(self.sysconf['TemperatureControllers']['count'])
        ]

        self.smc_interfaces = [
            SMCInterface(i)
            for i in range(self.sysconf['SMCInterfaces']['count'])
        ]

        self.fans = [Fan(i) for i in range(self.sysconf['Fans']['count'])]

        self.linear_axis = [
            LinearActuator(i)
            for i in range(self.sysconf['LinearActuators']['count'])
        ]

        self.digital_inputs = [
            DigitalInput(i)
            for i in range(self.sysconf['DigitalInputs']['count'])
        ]

        self.liquid_sensors = [
            LiquidSensor(i)
            for i in range(self.sysconf['LiquidSensors']['count'])
        ]
        self.start_com_proc()
Esempio n. 35
0
    def open(self):
        """ Open the gripper and make sure it opens """
        for i in xrange(self.conf['retry_count']):
            begintime = datetime.now()
            self.open_no_check()
            while self.timeout > datetime.now() - begintime:
                time.sleep(0.1)
                if self.is_open:
                    log.debug("Open actuator %s success", repr(self))
                    return

            log.info("Failed to open actautor %s before timeout, retry %d",
                     repr(self), i)
        log.error("Failed to open actuator %s after retrys", repr(self))
Esempio n. 36
0
    def lift(self):
        """ Move the actuator up and ensure it gets there """
        for i in xrange(self.conf['retry_count']):
            begintime = datetime.now()
            self.lift_no_check()
            while self.timeout > datetime.now() - begintime:
                time.sleep(0.1)
                if self.is_up:
                    log.debug("Lift actuator %s success", repr(self))
                    return

            log.info("Failed to raise actautor %s before timeout, retry %d",
                        repr(self), i)
        log.error("Failed to raise actuator %s after retrys", repr(self))
Esempio n. 37
0
    def open(self):
        """ Open the gripper and make sure it opens """
        for i in xrange(self.conf['retry_count']):
            begintime = datetime.now()
            self.open_no_check()
            while self.timeout > datetime.now() - begintime:
                time.sleep(0.1)
                if self.is_open:
                    log.debug("Open actuator %s success", repr(self))
                    return

            log.info("Failed to open actautor %s before timeout, retry %d",
                        repr(self), i)
        log.error("Failed to open actuator %s after retrys", repr(self))
Esempio n. 38
0
 def lower(self):
     """ Lower actuator and ensure it gets there """
     self.prepare_air()
     for i in xrange(self.conf['retry_count']):
         begintime = datetime.now()
         self.lower_no_check()
         while self.timeout > datetime.now() - begintime:
             time.sleep(0.1)
             if self.is_down:
                 log.debug("Lower actuator %s success", repr(self))
                 return
         log.info("Failed to raise actuator %s before timeout, retry %d",
                     repr(self), i)
     log.error("Failed to lower actuator %s after retrys", repr(self))
     raise ElixysPneumaticError("Failed to lower %s"
             " check digital sensors and pressure source"% repr(self))
Esempio n. 39
0
    def __init__(self):
        """ The is the Synthesizer object giving
        access to all the sub systems.
        Here we construct all the subsystems, and
        attach them to our "system"
        """

        super(SynthesizerHAL, self).__init__()

        log.debug("Initializing SynthesizerHAL")
        self.mixer_motors = [Mixer(i) for i in
                             range(self.sysconf['Mixers']['count'])]
        self.valves = [Valve(i) for i in
                       range(self.sysconf['Valves']['count'])]
        self.thermocouples = [Thermocouple(i) for i in
                              range(self.sysconf['Thermocouples']['count'])]
        self.aux_thermocouples = [
            AuxThermocouple(i) for i in
            range(self.sysconf['AuxThermocouples']['count'])]

        self.heaters = [Heater(i) for i in
                        range(self.sysconf['Heaters']['count'])]

        self.temperature_controllers = [
            TemperatureController(i) for i in
            range(self.sysconf['TemperatureControllers']['count'])]

        self.smc_interfaces = [SMCInterface(i) for i in
                               range(self.sysconf['SMCInterfaces']['count'])]

        self.fans = [Fan(i) for i in
                     range(self.sysconf['Fans']['count'])]

        self.linear_axis = [LinearActuator(i) for i in
                            range(self.sysconf['LinearActuators']['count'])]

        self.digital_inputs = [DigitalInput(i) for i in
                               range(self.sysconf['DigitalInputs']['count'])]

        self.liquid_sensors = [LiquidSensor(i) for i in
                               range(self.sysconf['LiquidSensors']['count'])]

        self.start_com_proc()
Esempio n. 40
0
    def get_adcs(self):
        """ Query the CBox board for the ADC values
        convert them to integers, then multiple by the
        conversion factors in the hwconf.
        """
        self.clear_in_serial_buffer()
        tmpstr = "/ADC/run\n"
        self.write(tmpstr)
        resp = self.read()
        log.debug("Get ADCS: %s" , resp)
        regex = re.compile("(?:[ADC])+ "
                       "(?P<adc0>[0-9A-Fa-f]*), "
                       "(?P<adc1>[0-9A-Fa-f]*)")
        mtch = regex.match(resp)
        adcval0 = (int(mtch.group('adc0'), 16) - self.conf['ADCOFFSET0']) * \
			self.conf['ADCCONST0']
        adcval1 = (int(mtch.group('adc1'), 16) - self.conf['ADCOFFSET1']) * \
			self.conf['ADCCONST1']
        log.debug("ADC0 = %s", adcval0)
        return adcval0, adcval1
Esempio n. 41
0
 def set_on(self, value):
     if not hasattr(self,'valve_state0') or not hasattr(self,'valve_state1') \
         or not hasattr(self,'valve_state2'):
         self.load_states()
     log.debug("Set Valve %d on -> %s" % (self.id_, value))
     self.on_ = value
     if self.id_ < 16:
         log.debug("Before Set Valve %d (state0) on -> %s" %
                   (self.id_, bin(Valve.valve_state0)))
         if value is True:
             Valve.valve_state0 |= (1 << (self.id_ % 16))
         else:
             Valve.valve_state0 &= ~(1 << (self.id_ % 16))
         self.comproc.run_cmd(self.cmd_lookup['Valves']['set_state0'](
             Valve.valve_state0))
         log.debug("After Set Valve %d (state0) on -> %s" %
                   (self.id_, bin(Valve.valve_state0)))
         self.on_ = True
     elif self.id_ < 32:
         if value is True:
             Valve.valve_state1 |= (1 << (self.id_ % 16))
         else:
             Valve.valve_state1 &= ~(1 << (self.id_ % 16))
         self.comproc.run_cmd(self.cmd_lookup['Valves']['set_state1'](
             Valve.valve_state1))
         log.debug("Set Valve %d (state1) on -> %s" %
                   (self.id_, bin(Valve.valve_state1)))
         self.on_ = True
     elif self.id_ < 48:
         if value is True:
             Valve.valve_state2 |= (1 << (self.id_ % 16))
         else:
             Valve.valve_state2 &= ~(1 << (self.id_ % 16))
         self.comproc.run_cmd(self.cmd_lookup['Valves']['set_state2'](
             Valve.valve_state2))
         log.debug("Set Valve %d (state2) on -> %s" %
                   (self.id_, bin(Valve.valve_state2)))
         self.on_ = True
Esempio n. 42
0
 def get_on(self):        
     if not hasattr(self,'valve_state0') or not hasattr(self,'valve_state1') \
         or not hasattr(self,'valve_state2'):
         self.load_states()
     val = False
     if self.id_ < 16:
         valve_state = self.status.Valves['state0']
         val = bool((valve_state >> self.id_) & 1)
         self.on_ = False
         
     elif self.id_ < 32:
         valve_state = self.status.Valves['state1']
         val = bool((valve_state >> (self.id_ - 16)) & 1)
         self.on_ = False
         
     elif self.id_ < 48:
         valve_state = self.status.Valves['state2']
         val = bool((valve_state >> (self.id_ - 32)) & 1)            
         self.on_ = False
     
     log.debug("Get Valve %d on -> %s" % (self.id_, val))
     
     return val
Esempio n. 43
0
    def get_on(self):
        if not hasattr(self,'valve_state0') or not hasattr(self,'valve_state1') \
            or not hasattr(self,'valve_state2'):
            self.load_states()
        val = False
        if self.id_ < 16:
            valve_state = self.status.Valves['state0']
            val = bool((valve_state >> self.id_) & 1)
            self.on_ = False

        elif self.id_ < 32:
            valve_state = self.status.Valves['state1']
            val = bool((valve_state >> (self.id_ - 16)) & 1)
            self.on_ = False

        elif self.id_ < 48:
            valve_state = self.status.Valves['state2']
            val = bool((valve_state >> (self.id_ - 32)) & 1)
            self.on_ = False

        log.debug("Get Valve %d on -> %s" % (self.id_, val))

        return val
Esempio n. 44
0
    def __init__(self):
        super(ControlBoxSystem, self).__init__()
        self.conf = self.sysconf['ControlBox']
        if os.name == 'nt':
            self._port = self.conf['win_port']
        elif os.name == 'posix':
            self._port = self.conf['posix_port']
        else:
            raise ElixysComportError("Could not "
                                     "determine platform for port")
        self._baud = self.conf['baud']

        if self.sysconf['Simulator']['controlbox']:
            log.debug("Loading the control box simulator")
            from pyelixys.hal.tests.testcontrolbox import CBoxSim
            self.serial = CBoxSim()
            return

        try:
            self.serial = serial.Serial(port=self._port,
                                        baudrate=self._baud,
                                        timeout=0.2)
            if os.name == 'posix':
                self.serial.close()
                self.serial.baudrate = 115200
                self.serial.baudrate = self._baud
                self.serial.open()
                self.serial.baudrate = 115200
                self.serial.baudrate = self._baud
        except SerialException:
            log.error("Failed to open comport %s", self._port)
            raise ElixysComportError("Serial COM port not available at %s."
                                     "Ensure CBox Board is connected and "
                                     "user has permission to"
                                     "access device" % self._port)

        self._leds = 0
Esempio n. 45
0
    def __init__(self):
        super(ControlBoxSystem, self).__init__()
        self.conf = self.sysconf['ControlBox']
        if os.name == 'nt':
            self._port = self.conf['win_port']
        elif os.name == 'posix':
            self._port = self.conf['posix_port']
        else:
            raise ElixysComportError("Could not "
                    "determine platform for port")
        self._baud = self.conf['baud']

        if self.sysconf['Simulator']['controlbox']:
            log.debug("Loading the control box simulator")
            from pyelixys.hal.tests.testcontrolbox import CBoxSim
            self.serial = CBoxSim()
            return

        try:
            self.serial = serial.Serial(port=self._port,
                                    baudrate=self._baud,
                                    timeout=0.2)
	    if os.name == 'posix':
		self.serial.close()
		self.serial.baudrate = 115200
                self.serial.baudrate = self._baud
		self.serial.open()
		self.serial.baudrate = 115200
		self.serial.baudrate = self._baud
        except SerialException:
            log.error("Failed to open comport %s", self._port)
            raise ElixysComportError("Serial COM port not available at %s."
                                    "Ensure CBox Board is connected and "
                                    "user has permission to"
                                    "access device" % self._port)

        self._leds = 0
Esempio n. 46
0
    def __init__(self):
        
        super(SynthesizerHAL, self).__init__()        
        
        log.debug("Initializing SynthesizerHAL")
        self.mixer_motors = [Mixer(i) for i in
                             range(self.sysconf['Mixers']['count'])]
        self.valves = [Valve(i) for i in
                       range(self.sysconf['Valves']['count'])]
        self.thermocouples = [Thermocouple(i) for i in
                              range(self.sysconf['Thermocouples']['count'])]
        self.aux_thermocouples = [
            AuxThermocouple(i) for i in
            range(self.sysconf['AuxThermocouples']['count'])]

        self.heaters = [Heater(i) for i in
                        range(self.sysconf['Heaters']['count'])]

        self.temperature_controllers = [
            TemperatureController(i) for i in
            range(self.sysconf['TemperatureControllers']['count'])]

        self.smc_interfaces = [SMCInterface(i) for i in
                               range(self.sysconf['SMCInterfaces']['count'])]

        self.fans = [Fan(i) for i in
                     range(self.sysconf['Fans']['count'])]

        self.linear_axis = [LinearActuator(i) for i in
                            range(self.sysconf['LinearActuators']['count'])]

        self.digital_inputs = [DigitalInput(i) for i in
                               range(self.sysconf['DigitalInputs']['count'])]

        self.liquid_sensors = [LiquidSensor(i) for i in
                               range(self.sysconf['LiquidSensors']['count'])]
        self.start_com_proc()
Esempio n. 47
0
 def get_analog_in(self):
     vref = self.sysconf['SMCInterfaces']['analog_in_vref'] # Depends on gain set on board!
     self.analog_in_ = self.status.SMCInterfaces[self.id_]['analog_in']
     log.debug("Get SMC RAW Analog in %d on -> %s"
               % (self.id_, self.analog_in_))
     log.debug("VREF: %f" % vref)
     self.analog_in_ = self.analog_in_ / 4096.0 * vref
     log.debug("Get SMC Analog in %d on -> %s"
               % (self.id_, self.analog_in_))
     return self.analog_in_
Esempio n. 48
0
 def get_analog_in(self):
     vref = self.sysconf['SMCInterfaces'][
         'analog_in_vref']  # Depends on gain set on board!
     self.analog_in_ = self.status.SMCInterfaces[self.id_]['analog_in']
     log.debug("Get SMC RAW Analog in %d on -> %s" %
               (self.id_, self.analog_in_))
     log.debug("VREF: %f" % vref)
     self.analog_in_ = self.analog_in_ / 4096.0 * vref
     log.debug("Get SMC Analog in %d on -> %s" %
               (self.id_, self.analog_in_))
     return self.analog_in_
Esempio n. 49
0
    def set_on(self, value):
        log.debug("Set Fan %d on -> %s" % (self.id_, value))
        self.on_ = value
        if value is True:
            cmd = self.cmd_lookup['Fans']['turn_on'][self.id_]()
            log.debug("Turn On")
        else:
            log.debug("Turn Off")
            cmd = self.cmd_lookup['Fans']['turn_off'][self.id_]()

        self.comproc.run_cmd(cmd)
Esempio n. 50
0
    def set_on(self, value):
        log.debug("Set Fan %d on -> %s"
                  % (self.id_, value))
        self.on_ = value
        if value is True:
            cmd = self.cmd_lookup['Fans']['turn_on'][self.id_]()
            log.debug("Turn On")
        else:
            log.debug("Turn Off")
            cmd = self.cmd_lookup['Fans']['turn_off'][self.id_]()

        self.comproc.run_cmd(cmd)
Esempio n. 51
0
 def get_tripped(self):
     self.state_ = self.status.DigitalInputs['state']
     self.tripped_ = not bool(self.state_ >> self.id_ & 1)
     log.debug("Get Digital input %d tripped -> %s" %
               (self.id_, self.tripped_))
     return self.tripped_
Esempio n. 52
0
 def get_home(self):
     log.debug("Get Actuator %d Home -> %s" % (self.id_, self.home_))
     return self.home_
Esempio n. 53
0
 def get_analog_out(self):
     self.analog_out_ = self.status.LiquidSensors[
         self.id_]['analog_in'] / 4095.0
     log.debug("Get Liquid Sensor Analog in %d on -> %s" %
               (self.id_, self.analog_out_))
     return self.analog_out_
Esempio n. 54
0
 def get_on_off(self):
     """ Get the state of the pump ssr """
     value = self.synth.cbox.get_ssr()[self.id_]
     log.debug("Coolant pump is on = %s", value)
     return value
Esempio n. 55
0
 def turn_on_off(self, value):
     """ Set the state of the SSR """
     log.debug("Set coolant pump on = %s", value)
     self.synth.cbox.set_ssr(self.id_, value)
Esempio n. 56
0
 def set_home(self, value):
     log.debug("Set Actuator %d Home -> %s" % (self.id_, value))
     self.home_ = value