Changeset 13813 for fact


Ignore:
Timestamp:
05/22/12 12:27:42 (12 years ago)
Author:
neise
Message:
evolving
File:
1 edited

Legend:

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

    r13812 r13813  
    213213
    214214#============ BIAS VOLTAGE ====================================================
    215 def VoltageOn( mode = None, Watchdog = None, verbose = True):
     215time_of_last_overcurrent = -1. * float('inf')
     216number_of_overcurrent_occurences = 0
     217
     218def VoltageOn( mode = None, Watchdog = None, timeout = 30, verbose = True):
    216219    """ High Level Method for switching on the bias Voltage
    217220        can be called, in whatever state the bias and the feedback might be.
     
    228231        raise ValueError("mode must be 'temperature', 'current' or 'feedback'")
    229232
    230    
    231    
    232     bias.set_global_dac(1)
    233     if not bias.wait(9, 10):
    234         msg.warn("bias not in Voltage ON after 10sec")
    235         return False
    236     if not bias.wait(5, 10):
    237         msg.warn("bias not Ramping after 10sec")
    238         return False
    239     if not bias.wait(9, 30):
    240         msg.warn("bias not fully ramped up after 30sec")
    241         return False
     233    if mode == 'temperature':
     234        fb_target = 10 #TempControl
     235    elif mode == 'feedback':
     236        fb_target = 11 # FeedbackControl
     237    elif mode == 'current':
     238        fb_target = 12 #CurrentControl
     239   
     240    bias_target = 9 # VoltageOn
     241   
     242    starttime = time.time()
     243   
     244    while not ((bias.stn == bias_target) and (fb.stn == fb_target)):
     245        if time.time() - starttime > timeout:
     246            msg.fail("VoltageOn did not succeed after "+str(timeout)+' seconds')
     247            return False
     248           
     249        elif fb.stn == fb_target-3: # everything fine, but output disabled
     250            fb.enable_output(1)
     251            bias.set_global_dac(1)
     252       
     253        elif fb.stn == fb_target and bias.stn == 5: # feedback ok, but we are Ramping
     254            # lets try to wait
     255            time.sleep(0.5)
     256       
     257        elif bias.stn == 1: #Disconnected
     258            bias.reconnect()
     259           
     260        elif bias.stn == 6: # Overcurrent
     261            if number_of_overcurrent_occurences < 3:
     262                bias.set_zero_voltage()
     263                bias.reset_over_current_status()
     264            elif time.time() - time_of_last_overcurrent > 60:
     265                number_of_overcurrent_occurences = 0
     266           
     267            number_of_overcurrent_occurences += 1
     268            time_of_last_overcurrent = time.time()
     269       
     270        elif bias.stn == 7: # VoltageOff
     271            bias.set_global_dac(1)
     272           
     273        elif bias.stn == 8: # NotReferenced
     274            bias.set_zero_voltage()
     275            bias.set_global_dac(1)
     276       
     277       
     278        else:
     279            # if nothing was done. sleep a while
     280            time.sleep(0.5)
     281   
     282   
     283 
    242284
    243285    msg("waiting 45sec...")   
     
    245287    return True
    246288
     289
     290
     291def VoltageOff
     292def std_bias_watchdog( state, verbose=True ):
     293    msg = MSG(verbose)
     294    if state == 1: #Disconnected
     295        msg.warn("BIAS just DISCONNECTED .. trying to reconnect")
     296        msg.warn("current runnumber:"+fad_control.runnumber() )
     297        bias.reconnect()
     298        time.sleep(1)
     299        bias.set_zero_voltage()
     300        # TODO: This should work, but it is stupid.
     301        bias.reset_over_current_status()
     302        bias.reset_over_current_status()
     303        bias.set_zero_voltage()
     304        bias.reset_over_current_status()
     305        bias.set_global_dac(1)
    247306
    248307
Note: See TracChangeset for help on using the changeset viewer.