Exemplo n.º 1
0
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
Exemplo n.º 2
0
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
Exemplo n.º 3
0
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