def re_measure(cycle=1): Temp = Ud = Ud_m = Id = 0. if ag.temperature() >= 50.0: print "Hi, temperature! Cool!" ag.stop_output("all") ag.state_output() while ag.temperature() >= 40.0: print "Current Temperature: %.2f, Delay: %d sec" % ( ag.temperature(),60 * MEASURE_DELAY ) print "Delay" for sec in xrange( 12 * MEASURE_DELAY ): print "%d, " % (sec*5), time.sleep(5) ag.start_output("all") for i in xrange(cycle): time.sleep( MEASURE_DELAY ) Temp += ag.temperature() Ud += ag.source_value(1,"volt") Ud_m += ag.measure(1,"volt") Id += ag.measure(1,"cur") cycle = float(cycle) Measurements["Temp"] = Temp / cycle Measurements["Ud"] = Ud / cycle Measurements["Ud_m"] = Ud_m / cycle Measurements["Id"] = Id / cycle
def re_measure(cycle=1): Temp = Uc = Uc_m = Ic = Ue = Ue_m = Ib = 0.0 if ag.temperature() >= 50.0: print "High temperature! Cooler!!!!" ag.stop_output("all") ag.state_output() while ag.temperature() >= 40.0: print "Current Temperature: %.2f, Delay: %d sec" % (ag.temperature(), 60 * DELAY_MEASURE) print "Delay" for sec in xrange(12 * DELAY_MEASURE): print "%d, " % (sec * 5), time.sleep(5) ag.start_output("all") for i in xrange(cycle): time.sleep(DELAY_MEASURE) Temp += ag.temperature() Uc += ag.source_value(2, "volt") Uc_m += ag.measure(2, "volt") Ic += ag.measure(2, "cur") Ue += ag.source_value(1, "volt") Ue_m += ag.measure(1, "volt") Ib += ag.measure(1, "cur") cycle = float(cycle) Measurements["Temp"] = Temp / cycle Measurements["Uc"] = Uc / cycle Measurements["Uc_m"] = Uc_m / cycle Measurements["Ic"] = Ic / cycle Measurements["Ue"] = Ue / cycle Measurements["Ue_m"] = Ue_m / cycle Measurements["Ib"] = Ib / cycle
def re_measure(cycle=1): global Measurements if ag.temperature() >= 50.0: print "High temperature! Cooler!!!!" ag.stop_output("all") ag.state_output() while ag.temperature() >= 40.0: print "Current Temperature: %.2f, Delay: %d sec" % ( ag.temperature(),60 * MEASURE_DELAY ) print "Delay" for sec in xrange( 12 * MEASURE_DELAY ): print "%d, " % (sec*5), time.sleep(5) ag.start_output("all") Ids = Uds = Uds_m = Ugs = Ugs_m = Ubs = Ubs_m = Temp = 0.0 for i in xrange(cycle): # Impulse measure time.sleep( MEASURE_DELAY ) _measures = deepcopy(ag.measure_all()) Ids += _measures['ch1']['curr']['meas'] Uds += _measures['ch1']['volt']['sour'] Uds_m += _measures['ch1']['volt']['meas'] Ugs += _measures['ch2']['volt']['sour'] Ugs_m += _measures['ch2']['volt']['meas'] Ubs += _measures['ch3']['volt']['sour'] Ubs_m += _measures['ch3']['volt']['meas'] Temp += _measures['temp'] Measurements['Ids'] = Ids / float(cycle) Measurements['Uds'] = Uds / float(cycle) Measurements['Uds_m'] = Uds_m / float(cycle) Measurements['Ugs'] = Ugs / float(cycle) Measurements['Ugs_m'] = Ugs_m / float(cycle) Measurements['Ubs'] = Ubs / float(cycle) Measurements['Ubs_m'] = Ubs_m / float(cycle) Measurements['Temp'] = Temp / float(cycle)
def execute(): global IV_I,IV_V,Measurements,stop_measure,error_sat,GRAPH_2_X,GRAPH_2_Y # Задержка между измерениями # time.sleep( DELAY_MEASURE ) if error_sat >= 1: return False re_measure() no_inc = False try: good_rng = ag.get_good_range("v",Measurements["Ue_m"]) if ag.get_range(1,"v") != good_rng: ag.set_range( 1,"v",good_rng) print "@CH1 New range: %s , Ue = %.2f" % (good_rng, Measurements["Ue_m"] ) #Ue_check = round(Measurements["Ue_m"],2) # Выставляем оптимальный диапазон #print "@CH1 Good range: %s" % ( ag.get_good_range( "c", Measurements["Ib"] ) ) #if not(abs(Ue_check) < 0.02+abs(Measurements["Ue"]) and abs(Ue_check) > abs(Measurements["Ue"])-0.02): # next_range = ag.next_range(ag.get_range(1,"c"),"c") # ag.set_range( 1,"c",next_range) # time.sleep(DELAY_MEASURE*2) # re_measure() # # Ue_check = round(Measurements["Ue_m"],2) # if not(abs(Ue_check) < 0.02+abs(Measurements["Ue"]) and abs(Ue_check) > abs(Measurements["Ue"])-0.02): # print "F**K" # #print Ue_check # return True # # Uc_check = round(Measurements["Uc_m"],2) # Выставляем оптимальный диапазон #print "@CH1 Good range: %s" % ( ag.get_good_range( "c", Measurements["Ib"] ) ) if not(abs(Uc_check) < 0.03+abs(Measurements["Uc"]) and abs(Uc_check) > abs(Measurements["Uc"])-0.03): next_range = ag.next_range(ag.get_range(2,"c"),"c") ag.set_range( 2,"c",next_range) time.sleep(MEASURE_DELAY*2) re_measure() #Uc_check = round(Measurements["Uc_m"],2) #if not(abs(Uc_check) < 0.03+abs(Measurements["Uc"]) and abs(Uc_check) > abs(Measurements["Uc"])-0.03): # no_inc = True # print "F**K" #print Uc_check #return True #print "F**K" #prev_range = "" #while ag.get_good_range( "c", Measurements["Ib"] ) != ag.get_range(1,"c"): # if prev_range == "": # ag.set_range( 1,"c",ag.get_good_range( "c",Measurements["Ib"] ) ) # prev_range = ag.get_good_range( "c",Measurements["Ib"] ) # else: # rng_good = ag.get_good_range( "c",Measurements["Ib"] ) # if ag.get_range_num(rng_good,"c") < ag.get_range_num(prev_range,"c"): # break # else: # ag.set_range( 1,"c",rng_good ) # prev_range = rng_good # print "@CH1 New range: %s , Ib = %.2e" % (ag.get_good_range( "c", Measurements["Ib"] ), Measurements["Ib"] ) # re_measure() prev_range = "" while ag.get_good_range( "c", Measurements["Ic"] ) != ag.get_range(2,"c"): if prev_range == "": ag.set_range( 2,"c",ag.get_good_range( "c",Measurements["Ic"] ) ) prev_range = ag.get_good_range( "c",Measurements["Ic"] ) else: rng_good = ag.get_good_range( "c",Measurements["Ic"] ) if ag.get_range_num(rng_good,"c") < ag.get_range_num(prev_range,"c"): break else: ag.set_range( 2,"c",rng_good ) prev_range = rng_good print "@CH2 New range: %s , Ib = %.2e" % (ag.get_good_range( "c", Measurements["Ib"] ), Measurements["Ib"] ) re_measure() #while ag.get_good_range( "c", Measurements["Ib"] ) != ag.get_range(1,"c"): # ag.set_range( 1,"c",ag.get_good_range( "c",Measurements["Ib"] ) ) # print "@CH1 New range: %s , Ib = %.2e" % (ag.get_good_range( "c", Measurements["Ib"] ), Measurements["Ib"] ) # re_measure() #print "@CH2 Good range: %s" % ( ag.get_good_range( "c", Measurements["Ic"] ) ) #while ag.get_good_range( "c", Measurements["Ic"] ) != ag.get_range(2,"c"): # ag.set_range( 2,"c",ag.get_good_range( "c",Measurements["Ic"] ) ) #print "@CH2 New range: %s , Ib = %.2e" % (ag.get_good_range( "c", Measurements["Ic"] ), Measurements["Ic"] ) # re_measure() #if not(abs(Uc_check) < 0.02+abs(Measurements["Uc"]) and abs(Uc_check) > abs(Measurements["Uc"])-0.02): # next_range = ag.next_range(ag.get_range(2,"c"),"c") # ag.set_range( 2,"c",next_range) # re_measure() #Uc_check = round(Measurements["Uc_m"],2) #assert(abs(Uc_check) < 0.02+abs(Measurements["Uc"]) and abs(Uc_check) > abs(Measurements["Uc"])-0.02) if round(Measurements["Ic"],3) == 0.120: if error_sat >= 1: return False else: error_sat += 1 # Проводим измерения re_measure(MEASURE_COUNT) #if Measurements["Ib"] < 0.00: # raise ValueError #if Measurements["Ib"] < LastMeasurements["Ib"]: # raise ValueError Ue = Measurements["Ue_m"] Ue_meas = Measurements["Ue_m"] Ib = Measurements["Ib"] Ib_meas = Measurements["Ib_m"] Uc = Measurements["Uc"] Uc_meas = Measurements["Uc_m"] Ic = Measurements["Ic"] Temp = Measurements["Temp"] #Uc_check = round(Uc_meas,2) #if not(abs(Uc_check) < 0.03+abs(Uc) and abs(Uc_check) > abs(Uc)-0.03): # no_inc = True #Ue_check = round(Ue_meas,2) #if not(abs(Ue_check) < 0.03+abs(Ue) and abs(Ue_check) > abs(Ue)-0.03): # no_inc = True if Ib != 0.0: # B = Ic / Ib_meas B = Ic / Ib else: B = float("-inf") write2file(fdbg,"%.2f\t%.2e\t%.2e\t%.2f\t%.2f\t%.2e\t%.2f\t%.2f" % (Ue,Ib,Ib_meas,Uc,Uc_meas,Ic,B,Temp),True) write2file(fmeasure,"%.2f\t%.2e\t%.2f\t%.2e" % (Ue,Ib,Uc,Ic)) except AssertionError: pass #stop_measure = True #print "Stop measure" #print "Uc:%.2f" % ( round(Measurements["Uc_m"],2) ) #print "Current range CH2: %s" % ( ag.get_range(2,"c") ) #return False except ValueError: ag.stop_output(1) time.sleep( MEASURE_DELAY ) ag.start_output(1) print "Value Error" return False else: if Ib != 0.0: B = Ic/Ib else: B = float("-inf") if B >= 1.0 and no_inc == False: GRAPH_2_X += [Ib] GRAPH_2_Y += [B] # LastMeasurements = Measurements return True finally: pass #ag.debug() return True
print "Usage: ",sys.argv[0]," config_file.cfg" sys.exit(1) read_cfg = config.read(cfg_file) # Проверка считывания конфигурационного файла if len(read_cfg) != 1: print "Can't read config_file: %s" % (cfg_file) # Section: Agilent agilent_name = config.get('Agilent','name') # Initialize agilent if ag.agilent_init(agilent_name): print "Agilent initialized" ag.stop_output("all") else: print "exited...." sys.exit(1) # Set Ue_RANGES _Ib = config.get('Agilent','Ib') try: if len(_Ib.split(',')) != 1: # 1,2,3,4 __Ib = _Ib.split(',') for ___Ib in __Ib: Ib_RANGES += [ float(___Ib) ]
sys.exit(1) read_cfg = config.read(cfg_file) # Проверка считывания конфигурационного файла if len(read_cfg) != 1: print "Couldn't read config file: %s" % (cfg_file) sys.exit(1); # Section: Agilent agilent_name = config.get('Agilent','name') # Initialize agilent if ag.agilent_init(agilent_name): print "Agilent initialized" ag.stop_output("all") else: print "exited...." sys.exit(1) # Uds _Uds = config.get('Agilent','Uds') Uds_RANGES = ag.get_source_range(_Uds) # Ugs _Ugs = config.get('Agilent','Ugs') Ugs_RANGES = ag.get_source_range(_Ugs)
def execute(): global IV_I,IV_V,Measurements,stop_measure # Задержка между измерениями # time.sleep( MEASURE_DELAY ) re_measure() try: Uc_check = round(Measurements["Uc_m"],2) # Выставляем оптимальный диапазон #print "@CH1 Good range: %s" % ( ag.get_good_range( "c", Measurements["Ib"] ) ) if not(abs(Uc_check) < 0.02+abs(Measurements["Uc"]) and abs(Uc_check) > abs(Measurements["Uc"])-0.02): next_range = ag.next_range(ag.get_range(2,"c"),"c") ag.set_range( 2,"c",next_range) re_measure() #while ag.get_good_range( "c", Measurements["Ib"] ) != ag.get_range(1,"c"): # ag.set_range( 1,"c",ag.get_good_range( "c",Measurements["Ib"] ) ) #print "@CH1 New range: %s , Ib = %.2e" % (ag.get_good_range( "c", Measurements["Ib"] ), Measurements["Ib"] ) # re_measure() #print "@CH2 Good range: %s" % ( ag.get_good_range( "c", Measurements["Ic"] ) ) prev_range = "" while ag.get_good_range( "c", Measurements["Ic"] ) != ag.get_range(2,"c"): if prev_range == "": ag.set_range( 2,"c",ag.get_good_range( "c",Measurements["Ic"] ) ) prev_range = ag.get_good_range( "c",Measurements["Ic"] ) else: rng_good = ag.get_good_range( "c",Measurements["Ic"] ) if ag.get_range_num(rng_good,"c") < ag.get_range_num(prev_range,"c"): break; else: ag.set_range( 2,"c",rng_good ) prev_range = rng_good print "@CH2 New range: %s , Ic = %.2e" % (ag.get_good_range( "c", Measurements["Ic"] ), Measurements["Ic"] ) re_measure() Uc_check = round(Measurements["Uc_m"],2) assert(abs(Uc_check) < 0.02+abs(Measurements["Uc"]) and abs(Uc_check) > abs(Measurements["Uc"])-0.02) # Проводим измерения re_measure(MEASURE_COUNT) #if Measurements["Ib"] < 0.00: # raise ValueError #if Measurements["Ib"] < LastMeasurements["Ib"]: # raise ValueError Ue = Measurements["Ue"] Ib_meas = Measurements["Ib_m"] Ib = Measurements["Ib"] Uc = Measurements["Uc"] Uc_meas = Measurements["Uc_m"] Ic = Measurements["Ic"] Temp = Measurements["Temp"] write2file(fdbg,"%.2f\t%.2e\t%.2e\t%.2f\t%.2f\t%.2e\t%.2f" % (Ue,Ib,Ib_meas,Uc,Uc_meas,Ic,Temp),True) write2file(fmeasure,"%.2f\t%.2e\t%.2f\t%.2e" % (Ue,Ib,Uc,Ic)) except AssertionError: stop_measure = True print "Stop measure" print "Uc:%.2f" % ( round(Measurements["Uc_m"],2) ) return False except ValueError: ag.stop_output(1) time.sleep( MEASURE_DELAY ) ag.start_output(1) print "Value Error" return False else: IV_I += [Ic] IV_V += [Uc] #LastMeasurements = Measurements return True finally: pass #ag.debug() return True
def execute(): global IV_I,IV_V,Measurements,stop_measure,error_sat,GRAPH_2_X,GRAPH_2_Y,PrevMeasurements # Задержка между измерениями # time.sleep( DELAY_MEASURE ) if error_sat >= 1: return False re_measure() no_inc = False try: Ue_check = round(Measurements["Ue_m"],2) # Выставляем оптимальный диапазон #print "@CH1 Good range: %s" % ( ag.get_good_range( "c", Measurements["Ib"] ) ) if not(abs(Ue_check) < 0.04+abs(Measurements["Ue"]) and abs(Ue_check) > abs(Measurements["Ue"])-0.04): next_range = ag.next_range(ag.get_range(1,"c"),"c") ag.set_range( 1,"c",next_range) time.sleep(MEASURE_DELAY*2) re_measure() #Ue_check = round(Measurements["Ue_m"],2) Uc_check = round(Measurements["Uc_m"],2) # Выставляем оптимальный диапазон #print "@CH1 Good range: %s" % ( ag.get_good_range( "c", Measurements["Ib"] ) ) if not(abs(Uc_check) < 0.04+abs(Measurements["Uc"]) and abs(Uc_check) > abs(Measurements["Uc"])-0.04): next_range = ag.next_range(ag.get_range(2,"c"),"c") ag.set_range( 2,"c",next_range) time.sleep(MEASURE_DELAY*2) re_measure() #Uc_check = round(Measurements["Uc_m"],2) prev_range = "" while ag.get_good_range( "c", Measurements["Ib"] ) != ag.get_range(1,"c"): if prev_range == "": ag.set_range( 1,"c",ag.get_good_range( "c",Measurements["Ib"] ) ) prev_range = ag.get_good_range( "c",Measurements["Ib"] ) else: rng_good = ag.get_good_range( "c",Measurements["Ib"] ) if ag.get_range_num(rng_good,"c") < ag.get_range_num(prev_range,"c"): break else: ag.set_range( 1,"c",rng_good ) prev_range = rng_good print "@CH1 New range: %s , Ib = %.2e" % (ag.get_good_range( "c", Measurements["Ib"] ), Measurements["Ib"] ) re_measure() prev_range = "" while ag.get_good_range( "c", Measurements["Ic"] ) != ag.get_range(2,"c"): if prev_range == "": ag.set_range( 2,"c",ag.get_good_range( "c",Measurements["Ic"] ) ) prev_range = ag.get_good_range( "c",Measurements["Ic"] ) else: rng_good = ag.get_good_range( "c",Measurements["Ic"] ) if ag.get_range_num(rng_good,"c") < ag.get_range_num(prev_range,"c"): break else: ag.set_range( 2,"c",rng_good ) prev_range = rng_good print "@CH2 New range: %s , Ib = %.2e" % (ag.get_good_range( "c", Measurements["Ib"] ), Measurements["Ib"] ) re_measure() #while ag.get_good_range( "c", Measurements["Ib"] ) != ag.get_range(1,"c"): # ag.set_range( 1,"c",ag.get_good_range( "c",Measurements["Ib"] ) ) # print "@CH1 New range: %s , Ib = %.2e" % (ag.get_good_range( "c", Measurements["Ib"] ), Measurements["Ib"] ) # re_measure() #print "@CH2 Good range: %s" % ( ag.get_good_range( "c", Measurements["Ic"] ) ) #while ag.get_good_range( "c", Measurements["Ic"] ) != ag.get_range(2,"c"): # ag.set_range( 2,"c",ag.get_good_range( "c",Measurements["Ic"] ) ) #print "@CH2 New range: %s , Ib = %.2e" % (ag.get_good_range( "c", Measurements["Ic"] ), Measurements["Ic"] ) # re_measure() #if not(abs(Uc_check) < 0.02+abs(Measurements["Uc"]) and abs(Uc_check) > abs(Measurements["Uc"])-0.02): # next_range = ag.next_range(ag.get_range(2,"c"),"c") # ag.set_range( 2,"c",next_range) # re_measure() #Uc_check = round(Measurements["Uc_m"],2) #assert(abs(Uc_check) < 0.02+abs(Measurements["Uc"]) and abs(Uc_check) > abs(Measurements["Uc"])-0.02) if round(Measurements["Ic"],3) == 0.120: if error_sat >= 1: return False else: error_sat += 1 re_measure(MEASURE_COUNT) Ue = Measurements["Ue"] Ue_meas = Measurements["Ue_m"] Ib = Measurements["Ib"] Uc = Measurements["Uc"] Uc_meas = Measurements["Uc_m"] Ic = Measurements["Ic"] Temp = Measurements["Temp"] Uc_check = round(Uc_meas,2) if not(abs(Uc_check) < 0.04+abs(Uc) and abs(Uc_check) > abs(Uc)-0.04): no_inc = True Ue_check = round(Ue_meas,2) if not(abs(Ue_check) < 0.04+abs(Ue) and abs(Ue_check) > abs(Ue)-0.04): no_inc = True # if Ib < 0 or Ic < 0: #if Measurements["Ib"] < 0.00: # raise ValueError #if Measurements["Ib"] < LastMeasurements["Ib"]: if Ib != 0.0: B = Ic / Ib else: B = float("-inf") #if B > 0: write2file(fdbg,"%.2f\t%.2f\t%.2e\t%.2f\t%.2f\t%.2e\t%.2f\t%.2f" % (Ue,Ue_meas,Ib,Uc,Uc_meas,Ic,B,Temp),True) write2file(fmeasure,"%.2f\t%.2e\t%.2f\t%.2e" % (Ue,Ib,Uc,Ic)) except AssertionError: pass #stop_measure = True #print "Stop measure" #print "Uc:%.2f" % ( round(Measurements["Uc_m"],2) ) #print "Current range CH2: %s" % ( ag.get_range(2,"c") ) #return False except ValueError: ag.stop_output(1) time.sleep( MEASURE_DELAY ) ag.start_output(1) print "Value Error" return False else: if Ib != 0.0: B = Ic/Ib else: B = float("-inf") if B >= 1.0 and no_inc == False: if PrevMeasurements["Ib"] > Ib: #no_inc = True print "FUUU upper" else: IV_I += [B] IV_V += [Ue] GRAPH_2_X += [Ic] GRAPH_2_Y += [B] PrevMeasurements = deepcopy(Measurements) elif no_inc == True: ag.stop_output("all") time.sleep(2) ag.start_output("all") # LastMeasurements = Measurements return True finally: pass #ag.debug() return True