Changeset 13818 for fact


Ignore:
Timestamp:
05/23/12 02:59:43 (12 years ago)
Author:
neise
Message:
evolving
File:
1 edited

Legend:

Unmodified
Added
Removed
  • fact/tools/PyDimCtrl/pyfactctrl.py

    r13814 r13818  
    11#!/usr/bin/python -tti
    22from factdimserver import *
     3
     4
    35
    46# List of Wobble Positions
     
    3335
    3436            VoltageOn( mode='current' )
    35             for i in range(4):
    36                 msg("Taking Data Run "+str(i+1)+" of 4")
    37                 TakeDataRun()
     37            TakeData() #Ped | ExtLP | 4x Data
    3838            VoltageOff()
    3939
     
    223223        In all other cases, the method will perform the needed steps to switch
    224224        on the bias voltage, the way the user requested
     225       
     226        raises NotImplementedError in case of 'feedback'
    225227    """
    226228    msg = MSG( verbose )
     
    234236        fb_target = 10 #TempControl
    235237    elif mode == 'feedback':
    236         fb_target = 11 # FeedbackControl
     238        #fb_target = 11 # FeedbackControl
     239        raise NotImplementedError('The author of this script did not know how to start this mode')
    237240    elif mode == 'current':
    238241        fb_target = 12 #CurrentControl
     
    242245    starttime = time.time()
    243246   
    244     while not ((bias.stn == bias_target) and (fb.stn == fb_target)):
     247    long_enough = (time.time() - bias.last_st_change > 2) and (time.time() - fb.last_st_change > 2)
     248    while not ((bias.stn == bias_target) and (fb.stn == fb_target) and long_enough):
     249       
    245250        if time.time() - starttime > timeout:
    246251            msg.fail("VoltageOn did not succeed after "+str(timeout)+' seconds')
    247252            return False
    248            
     253       
    249254        elif fb.stn == fb_target-3: # everything fine, but output disabled
    250255            fb.enable_output(1)
    251             bias.set_global_dac(1)
     256       
    252257       
    253258        elif fb.stn == fb_target and bias.stn == 5: # feedback ok, but we are Ramping
    254259            # lets try to wait
    255260            time.sleep(0.5)
     261           
     262        elif fb.stn == 6: #Connected
     263            if mode == 'temperature':
     264                fb.start_temp_control(0.0)
     265            elif mode == 'current':
     266                fb.start_current_control(0.0)
     267            elif mode == 'feedback':
     268                raise NotImplementedError('The author of this script did not know how to start this mode')
    256269       
    257270        elif bias.stn == 1: #Disconnected
    258271            bias.reconnect()
     272            # makes no sense to be quick in this case
     273            time.sleep(2)
    259274           
    260275        elif bias.stn == 6: # Overcurrent
     
    279294            # if nothing was done. sleep a while
    280295            time.sleep(0.5)
    281    
    282    
     296       
     297        long_enough = (time.time() - bias.last_st_change > 2) and (time.time() - fb.last_st_change > 2)
    283298 
    284 
    285     msg("waiting 45sec...")   
    286     time.sleep(45)
    287     return True
    288 
     299   
     300    msg.ok("Voltage is On")
     301    if mode == 'current':
     302        msg("Waiting 45sec, so we get at least 3 current readings")
     303        time.sleep(45)
     304   
     305    return True
     306
     307def VoltageOff( timeout = 10, verbose = True):
     308    """ High Level Method for switching off the bias Voltage
     309    """
     310    msg = MSG( verbose )
     311    bias = bias_control
     312   
     313    bias.set_zero_voltage()
     314   
     315    starttime = time.time()
     316    while not bias.stn == 7: # VoltageOff
     317        if time.time() - starttime > timeout:
     318            msg.fail("VoltageOff did not succeed after "+str(timeout)+' seconds')
     319            return False
     320        time.sleep(1)
     321
     322    msg.ok("Voltage is Off")   
     323    return True
    289324
    290325
     
    305340
    306341
    307 def IsReadyForDataTaking( verbose = True ):
     342#==============================================================================
     343def IsReadyForDataTaking( TrackingNeeded = True, verbose = True ):
    308344    drive = drive_control
    309345    bias = bias_control
     
    315351
    316352    ok = True
    317     if not drive.stn == 7:
    318         msg.warn(drive.name + ':' + drive.sts + "  NOT ok")
    319         ok = False
    320     else:
    321         msg.ok(drive.name + ':' + drive.sts + "      OK")
     353    if TrackingNeeded:
     354        if not drive.stn == 7:
     355            msg.warn(drive.name + ':' + drive.sts + "  NOT ok")
     356            ok = False
     357        else:
     358            msg.ok(drive.name + ':' + drive.sts + "      OK")
    322359
    323360    if not feedback.stn == 12:
     
    347384def TakeDataRun( verbose = True ):
    348385    fad = fad_control   
    349     msg = MSG()
    350     msg.output = verbose
     386    msg = MSG(verbose)
     387
    351388    if not IsReadyForDataTaking( verbose=False ):
    352389        msg.fail("System not Ready for DataTaking")
     
    364401
    365402def TakePedestalOnRun( verbose = True ):
    366     msg = MSG()
    367     msg.output = verbose
    368     if not IsReadyForDataTaking( verbose=False ):
     403    msg = MSG(verbose)
     404
     405    if not IsReadyForDataTaking( TrackingNeeded=False, verbose=False ):
    369406        msg.fail("System not Ready for DataTaking")
    370407        IsReadyForDataTaking( verbose=True )
     
    381418   
    382419def TakeExtLpRun( verbose = True ):
    383     msg = MSG()
    384     msg.output = verbose
    385     if not IsReadyForDataTaking( verbose=False ):
     420    msg = MSG(verbose)
     421    if not IsReadyForDataTaking( TrackingNeeded=False, verbose=False ):
    386422        msg.fail("System not Ready for DataTaking")
    387423        IsReadyForDataTaking( verbose=True )
     
    398434
    399435def TakeData( verbose = True):
    400     msg = MSG()
    401     msg.output = verbose
     436    msg = MSG(verbose)
    402437    TakePedestalOnRun()
    403438    TakeExtLpRun()
     
    696731
    697732#==============================================================================
    698 # standard watchdog:
    699 def std_bias_watchdog( state, verbose=True ):
    700     msg = MSG(verbose)
    701     if state == 1: #Disconnected
    702         msg.warn("BIAS just DISCONNECTED .. trying to reconnect")
    703         msg.warn("current runnumber:"+fad_control.runnumber() )
    704         bias.reconnect()
    705         time.sleep(1)
    706         bias.set_zero_voltage()
    707         # TODO: This should work, but it is stupid.
    708         bias.reset_over_current_status()
    709         bias.reset_over_current_status()
    710         bias.set_zero_voltage()
    711         bias.reset_over_current_status()
    712         bias.set_global_dac(1)
    713 
    714733# create introduction:
    715734class INTRO(object):
     
    721740        print "welcome to PyDimCtrl V0.1:"
    722741        print "--------------------------"
    723         print "If the hardware is ON but not all the software is connected try:"
    724         print "      Connect()"
    725742        print "If all the programs are already up and running, you might want to"
    726743        print "     TakeDrsAmplitudeCalibration(roi=1024) or "
     
    736753        print "Switch off with:"
    737754        print "     VoltageOff()"
     755        print "In case you would like to simply take Data of a certain source try:"
     756        print "     TakeFullSet(source = 'Crab')"
    738757        print ""
    739         print "In case you would like a Watchdog to check, if the Voltage is up"
    740         print "and the BiasCrate is not disconnected, then try:"
    741         print "     VoltageOn( mode='--see above--', Watchdog=True )"
    742         print "PLEASE NOTE: The Watchdog will monitor the State of BIAS_CONTROL"
    743         print "and in case of a connection loss, it will: "
    744         print "     * print a warning"
    745         print "     * issue a the RECONNECT command"
    746         print "     * issue SET_ZERO_VOLTAGE - since this is the only way to get referenced"
    747         print "     * Ramp up again, using the same settings as before"
    748         print "     * possible OverCurrent situation will be treated as usual"
    749         print "The Watchdog will not react on any other state change, like OverCurrent or VoltageOff"
     758        print "look at the 'source_list' to get an overview, of the "
     759        print "current sources available:"
     760        print "     pprint(source_list)"
     761        print ""
     762        print ""
    750763        print ""
    751764        print ""
Note: See TracChangeset for help on using the changeset viewer.