def move_motors(imagetype="", obs_mode="", iodine_cell=3): ### Check which obs mode the OR defines and move motors... # Check if motors are moving: output = get_db_values.db_connection().get_fields_site01("coude_unit", fields=["calib_mirror_pos", "iodine_pos", "filter_pos", "mirror_slide", "spectrograph_foc", "slit_pos"]) timeout = time.time() + 20 for motor in output: if float(output[motor]) == 0.0: time.sleep(1) output_motor = get_db_values.db_connection().get_fields_site01("coude_unit", fields=[motor]) while float(output_motor[motor]) == 0.0: time.sleep(1) output_motor = get_db_values.db_connection().get_fields_site01("coude_unit", fields=[motor]) if time.time() > timeout: break try: if imagetype.lower() == 'thar': try: lamp.Lamp(lamp='thar').set_on() # Might change Lamp to LAMP at some point lamp.Lamp(lamp='halo').set_off() # Might change Lamp to LAMP at some point except Exception,e: print clock.timename(), "One of the lamps was not switched correctly" pst.PST().move(3,2) # Move IODINE cell out of path pst.PST().move(4,3) # Move Calibration mirror to ThAr position elif imagetype.lower() == 'sun': try: lamp.Lamp(lamp='thar').set_off() # Might change Lamp to LAMP at some point lamp.Lamp(lamp='halo').set_off() # Might change Lamp to LAMP at some point except Exception,e: print clock.timename(), "One of the lamps was not switched correctly"
def main(): testLamp = lamp.Lamp(60, 90) testLamp.setBrightness(50) testLamp.showCurrentPower() print(alg(1, 2, 10))
print clock.timename(), "One of the lamps was not switched correctly" pst.PST().move(3,2) # Move IODINE cell out of path pst.PST().move(4,3) # Move Calibration mirror to ThAr position elif imagetype.lower() == 'sun': try: lamp.Lamp(lamp='thar').set_off() # Might change Lamp to LAMP at some point lamp.Lamp(lamp='halo').set_off() # Might change Lamp to LAMP at some point except Exception,e: print clock.timename(), "One of the lamps was not switched correctly" pst.PST().move(3,2) # Move IODINE cell out of path pst.PST().move(4,4) # Move Calibration slide to Sun Fibre position elif imagetype.lower() == 'suni2': try: lamp.Lamp(lamp='thar').set_off() # Might change Lamp to LAMP at some point lamp.Lamp(lamp='halo').set_off() # Might change Lamp to LAMP at some point except Exception,e: print clock.timename(), "One of the lamps was not switched correctly" pst.PST().move(3,iodine_cell) # Move IODINE cell into light path pst.PST().move(4,4) # Move Calibration mirror to Sun Fiber position ### These are the same for all types of observations... pst.PST().move(1,4) # Move Filter wheel to position 4 (Free) pst.PST().move(6,8) # Move slit to right position Set_M8.set_m8_pos() except Exception, e: print clock.timename(), "An error occured when trying to move the motors: ", e
''' Un módulo permite agrupar funcionalidad y ocultar la complejidad. Para poder incluir un módulo podemos utilizar import ''' from lamp import Lamp lamp = Lamp(is_turned_on=True) lamp._display_image() import lamp lamp = lamp.Lamp(is_turned_on=False) lamp._display_image() ''' En Python la comunidad comparte su código usando PyPi (python package index), Pip es un repositorio utilizado para instalar módulos de la comunidad. Con pip install [package_name] se puede instalar el paquete que se desea e importarlo a nuestro código con el keyword import. '''