Пример #1
0
def measure_z2() :
    if scriptSys.GENERAL['mode'] != 'Z_MEASURE2' : #si es llamado por primera vez
        scriptSys.GENERAL['mode'] = 'Z_MEASURE2'
        scriptSys.TIME_INIT = scriptSys.TIME
        print "DISCHARGE,1.0"
        return

    actual_time = (scriptSys.TIME - scriptSys.TIME_INIT)
    if  actual_time >= tTestD2 :
        # deja reposar y chequea q no caiga la tension
        # final_report()
        stress_test()
        return

    if  actual_time >= (tTestC2 - tMargin)  and  actual_time < (tTestC2 + tMargin) :
        # print "DISCHARGE,1.0"  Descarga fuerte
        scriptSys.import_data()
        t = scriptSys.TIME_INIT + tTestB2 + 2 #delay en el inicio de la descarga
        var = scriptSys.get_data('VOLTAGE', range( t - 5 , t - 5 + voltageAverage))
        V1 = sum(var) / float(len(var)) #promedio de las mediciones al principio
        var = scriptSys.get_data('VOLTAGE', range( scriptSys.TIME - voltageAverage, scriptSys.TIME ))
        V2 = sum(var) / float(len(var)) #promedio de las mediciones al final del test
        var = scriptSys.get_data('CURRENT', range(scriptSys.TIME - currentAverage,scriptSys.TIME))
        I1 = sum(var) / float(len(var)) #promedio de las mediciones al principio
        Z2 = int( ( (float(V2)-float(V1))/float(I1) ) *1000 )
        scriptSys.EVAL['int_z2'] = str(Z2)
        scriptSys.EVAL['int_z'] =   str(Z2) #str(round(Z1,0))
        # chequear rectas
        print "PAUSE"
        return

    if  actual_time >= (tTestB2 - tMargin)  and  actual_time < (tTestB2 + tMargin) :
        # deja reposar y chequea q no caiga la tension
        # stress_test()
        print "DISCHARGE,1.5"
        return

    if  actual_time >= (tTestA2 - tMargin)  and  actual_time < (tTestA2 + tMargin) :
        # print "DISCHARGE,0.2"  Descarga suave
        scriptSys.import_data()
        t = scriptSys.TIME_INIT + 2 #delay en el inicio de la descarga
        var = scriptSys.get_data('VOLTAGE', range( t - 5, t- 5 + voltageAverage))
        V1 = sum(var) / float(len(var)) #promedio de las mediciones al principio
        var = scriptSys.get_data('VOLTAGE', range( scriptSys.TIME - voltageAverage, scriptSys.TIME ))
        V2 = sum(var) / float(len(var)) #promedio de las mediciones al final del test
        var = scriptSys.get_data('CURRENT', range( scriptSys.TIME - currentAverage,scriptSys.TIME))
        I1 = sum(var) / float(len(var)) #promedio de las mediciones al principio
        Z1 = int( ( (float(V2)-float(V1))/float(I1) ) *1000 )

        scriptSys.EVAL['int_z1'] =  str(Z1) #str(round(Z1,3))
        # chequear rectas
        print "PAUSE"
        return
    print "RUN"
    return
Пример #2
0
def evaluate():
    try:
        scriptSys.import_data()
        scriptSys.data = scriptSys.data[10:-10]
        i = []
        for line in scriptSys.data:
            i.append(int(line['I0']))
        w = 20
        for x in range(w + 1, len(i)):
            iavew = sum(i[x - w:x - 1]) / float(len(i[x - w:x - 1]))
            if (iavew - i[x]) > 100:
                scriptSys.AUX['failcode'] = 1
                return 'FAIL'
        iave = sum(i) / float(len(i))
        if iave < 600 and iave > 400:
            scriptSys.AUX['failcode'] = 2
            return 'FAIL'
        if iave < 200:
            scriptSys.AUX['failcode'] = 3
            return 'FAIL'
        return 'OK'

    except Exception as e:
        scriptSys.error_report(e, "evaluate()")
Пример #3
0
def measure_z1():
    if scriptSys.GENERAL['mode'] != 'Z_MEASURE':  #si es llamado por primera vez
        scriptSys.GENERAL['mode'] = 'Z_MEASURE'
        scriptSys.TIME_INIT = scriptSys.TIME
        print "DISCHARGE,0.2"

    if (scriptSys.TIME - scriptSys.TIME_INIT) >= (tTest3 + tTest2 + tTest1):
        # deja reposar y chequea q no caiga la tension
        scriptSys.import_data(
        )  #levanto todo el archivo solo cuando lo necesito
        t = scriptSys.TIME_INIT + tTest1 + tTest2
        var = scriptSys.get_data('VOLTAGE', range(t, t + voltageAverage))
        # chequear rectas
        stress_test()
    elif (scriptSys.TIME - scriptSys.TIME_INIT) >= (tTest2 + tTest1):
        # print "DISCHARGE,1.0"   Descarga fuerte
        scriptSys.import_data()
        t = scriptSys.TIME_INIT + tTest1
        var = scriptSys.get_data('VOLTAGE', range(t, t + voltageAverage))
        V1 = sum(var) / float(
            len(var))  #promedio de las mediciones al principio
        var = scriptSys.get_data(
            'VOLTAGE', range(t + tTest2, t + tTest2 + voltageAverage))
        V2 = sum(var) / float(
            len(var))  #promedio de las mediciones al final del test
        var = scriptSys.get_data('CURRENT', range(t, t + currentAverage))
        I1 = sum(var) / float(
            len(var))  #promedio de las mediciones al principio
        Z2 = int((float(V2 - V1) / float(I1)) * 1000)
        scriptSys.EVAL['int_z2'] = Z2
        # chequear rectas
    elif (scriptSys.TIME - scriptSys.TIME_INIT) >= tTest1:
        # print "DISCHARGE,0.2"  Descarga suave
        scriptSys.import_data()
        t = scriptSys.TIME_INIT
        var = scriptSys.get_data('VOLTAGE', range(t, t + voltageAverage))
        V1 = sum(var) / float(
            len(var))  #promedio de las mediciones al principio
        var = scriptSys.get_data(
            'VOLTAGE', range(t + tTest1, t + tTest1 + voltageAverage))
        V2 = sum(var) / float(
            len(var))  #promedio de las mediciones al final del test
        var = scriptSys.get_data('CURRENT', range(t, t + currentAverage))
        I1 = sum(var) / float(
            len(var))  #promedio de las mediciones al principio
        Z1 = int((float(V2 - V1) / float(I1)) * 1000)
        scriptSys.EVAL['int_z1'] = Z1
        # chequear rectas
        print "DISCHARGE,1.0"
    return
Пример #4
0
def evaluate():
    try:
        scriptSys.import_data()
        flag1 = True
        flag2 = False
        flag3 = False
        flag4 = False
        var = []
        cur = []

        for line in scriptSys.data:
            i = int(line['CURRENT'])
            t = int(line['TIME'])
            s = int(line['STATUS'])
            if s == 3 and flag1 and (t > scriptSys.TIME_INIT):
                flag1 = False
                ind = scriptSys.data.index(line) - 1
                Vi0 = int(scriptSys.data[ind - 1]['VOLTAGE'])
                Vi0 += int(scriptSys.data[ind - 2]['VOLTAGE'])
                Vi0 += int(scriptSys.data[ind - 3]['VOLTAGE'])
                Vi0 += int(scriptSys.data[ind - 4]['VOLTAGE'])
                Vi0 += int(scriptSys.data[ind - 5]['VOLTAGE'])
                Vi0 /= 5  #promedio de las ultimas 5 muestas antes de la descarga
                t0 = int(line['TIME'])  #tiempo de inicio de la descarga
                flag2 = True
            if s == 4 and flag2 and (t > scriptSys.TIME_INIT):
                flag2 = False
                ind = scriptSys.data.index(line) + 1
                Vf0 = int(scriptSys.data[ind + 1]['VOLTAGE'])
                Vf0 += int(scriptSys.data[ind + 2]['VOLTAGE'])
                Vf0 += int(scriptSys.data[ind + 3]['VOLTAGE'])
                Vf0 += int(scriptSys.data[ind + 4]['VOLTAGE'])
                Vf0 += int(scriptSys.data[ind + 5]['VOLTAGE'])
                Vf0 /= 5  #promedio de las ultimas 5 muestas antes de la descarga

                Vd1 = Vi0 - int(scriptSys.data[ind + 0]['VOLTAGE'])
                Vd2 = Vi0 - int(scriptSys.data[ind + 16]['VOLTAGE'])
                flag3 = True
            if s == 3 and (t > scriptSys.TIME_INIT
                           ):  #tomo las tensiones durante la descarga
                var.append(int(line['VOLTAGE']))
                cur.append(int(line['CURRENT']))

        #regresion lineal
        testnr = int(scriptSys.AUX['testnr'])
        if testnr == 1:
            origin = org
        if testnr == 2:
            origin = org - 9000
        if testnr == 3:
            origin = org - 10000
        if testnr == 4:
            origin = org - 10000
        if testnr == 5:
            origin = org - 11000
        result = factor1 * Vd1 + factor2 * Vd2
        SoH = int((result * slopeP + origin) / 1000)

        current = sum(cur) / len(cur)
        Zint = int((float(float(Vf0 - Vi0)) / float(current)) * 1000)

        scriptSys.AUX['current' + str(testnr)] = current
        scriptSys.AUX['Vf0' + str(testnr)] = Vf0
        scriptSys.AUX['Vi0' + str(testnr)] = Vi0
        scriptSys.AUX['Zint' + str(testnr)] = Zint
        # scriptSys.send_msg('SoH'+str(testnr)+":"+str(SoH))

        ######################################################
        #evaluacion de repetir el test
        # t0 -= len(var)
        ######################################################
        Va = 20  #pico negativo maximo en la descarga
        Vam = 250
        #caso A
        ave = sum(var[5:20]) / len(var[5:20])
        t = 0
        for v in var[0:5]:
            t += 1
            if (ave - v) > Va:
                scriptSys.AUX['casoA_t' + str(t0 + t - 1)] = (ave - v)
                if int(scriptSys.AUX['strike']) >= 1:
                    if (t0 + t - 1) - int(scriptSys.AUX['striket']) >= 30:
                        scriptSys.AUX['strike'] = str(
                            int(scriptSys.AUX['strike']) + 1)
                        scriptSys.AUX['striket'] = str(t0 + t - 1)
                else:
                    scriptSys.AUX['strike'] = str(
                        int(scriptSys.AUX['strike']) + 1)
                    scriptSys.AUX['striket'] = str(t0 + t - 1)
                # scriptSys.send_msg('casoA  tiempo:  '+ str(t0 + t -1))
            if (ave - v) > Vam:
                scriptSys.AUX['casoAm_t' + str(t0 + t - 1)] = (ave - v)
                scriptSys.AUX['strike'] = str(int(scriptSys.AUX['strike']) + 1)
                # scriptSys.send_msg('casoA  tiempo:  '+ str(t0 + t -1))
                scriptSys.final_report("SoHfail", SoH)
                return
        ######################################################
        Vb = 50  #caida promedio maxima en la descarga
        Vbm = 300
        #caso B
        w = 10
        t = 5
        for x in range(5 + w, len(var) - 5 - w):
            t += 1
            ave = sum(var[x - w:x]) / len(var[x - w:x])
            if (ave - var[x]) > Vb:
                scriptSys.AUX['casoB_t' + str(t0 + t + w)] = (ave - var[x])
                # scriptSys.send_msg('casoB  tiempo:  '+ str(t0 + t +w))
                if int(scriptSys.AUX['strike']) >= 1:
                    if (t0 + t - 1) - int(scriptSys.AUX['striket']) >= 30:
                        scriptSys.AUX['strike'] = str(
                            int(scriptSys.AUX['strike']) + 1)
                        scriptSys.AUX['striket'] = str(t0 + t - 1)
                else:
                    scriptSys.AUX['strike'] = str(
                        int(scriptSys.AUX['strike']) + 1)
                    scriptSys.AUX['striket'] = str(t0 + t - 1)
            if (ave - var[x]) > Vbm:
                scriptSys.AUX['casoBm_t' + str(t0 + t + w)] = (ave - var[x])
                scriptSys.AUX['strike'] = str(int(scriptSys.AUX['strike']) + 1)
                # scriptSys.send_msg('casoB  tiempo:  '+ str(t0 + t +w))
                scriptSys.final_report("SoHfail", SoH)
                return

        ######################################################
        Vc = 20
        Vcm = 200
        #caso C
        ave = sum(var[-25:-5]) / len(var[-25:-5])
        t = len(var[:-25])
        for v in var[-5:]:
            t += 1
            if (ave - v) > Vc:
                scriptSys.AUX['casoC_t' + str(t0 + t - 1)] = (ave - v)
                # scriptSys.send_msg('casoC  tiempo:  '+ str(t0 + t -1))
                if int(scriptSys.AUX['strike']) >= 1:
                    if (t0 + t - 1) - int(scriptSys.AUX['striket']) >= 30:
                        scriptSys.AUX['strike'] = str(
                            int(scriptSys.AUX['strike']) + 1)
                        scriptSys.AUX['striket'] = str(t0 + t - 1)
                else:
                    scriptSys.AUX['strike'] = str(
                        int(scriptSys.AUX['strike']) + 1)
                    scriptSys.AUX['striket'] = str(t0 + t - 1)
            if (ave - v) > Vcm:
                scriptSys.AUX['casoCm_t' + str(t0 + t + w)] = (ave - v)
                # scriptSys.send_msg('casoC  tiempo:  '+ str(t0 + t -1))
                scriptSys.AUX['strike'] = str(int(scriptSys.AUX['strike']) + 1)
                scriptSys.final_report("SoHfail", SoH)
                return
        ######################################################
        Vdm = 2800  #tension de caida maxima
        #caso D
        t = 0
        for v in var:
            t += 1
            if v < Vdm:
                scriptSys.AUX['casoDm_t' + str(t0 + t - 1)] = v
                # scriptSys.send_msg('casoD  tiempo:  '+ str(t0 + t -1))
                scriptSys.final_report("SoHfail", SoH)
                return

        ######################################################
        #caso E
        p = 0  #evaluacion de pendiente positiva
        t = 0
        for x in range(20, len(var) - 10):
            p += var[x + 1] - var[x]
            t += 1
        if p > 16:
            # scriptSys.send_msg('casoE  pendiente:  '+ str(p))
            scriptSys.AUX['casoE_t' + str(t0 + t - 1)] = p
            if int(scriptSys.AUX['strike']) >= 1:
                if (t0 + t - 1) - int(scriptSys.AUX['striket']) >= 30:
                    scriptSys.AUX['strike'] = str(
                        int(scriptSys.AUX['strike']) + 1)
                    scriptSys.AUX['striket'] = str(t0 + t - 1)
            else:
                scriptSys.AUX['strike'] = str(int(scriptSys.AUX['strike']) + 1)
                scriptSys.AUX['striket'] = str(t0 + t - 1)
        ######################################################
        #casoF
        w = 30  #evaluacion de caida de promedio
        t = 15
        for x in range(5 + w, len(var) - 5 - w):
            t += 1
            p = 0
            for y in range(w):
                p += var[x + y] - var[x + y + 1]
                # print var[x]
            if p > 132:
                # scriptSys.send_msg('casoF pendiente:  '+ str(p)+ ' tiempo:  '+ str(t0 + t +w))
                scriptSys.AUX['casoF_t' + str(t0 + t - 1)] = p
                if int(scriptSys.AUX['strike']) >= 1:
                    if (t0 + t - 1) - int(scriptSys.AUX['striket']) >= 30:
                        scriptSys.AUX['strike'] = str(
                            int(scriptSys.AUX['strike']) + 1)
                        scriptSys.AUX['striket'] = str(t0 + t - 1)
                else:
                    scriptSys.AUX['strike'] = str(
                        int(scriptSys.AUX['strike']) + 1)
                    scriptSys.AUX['striket'] = str(t0 + t - 1)
        ######################################################

        #evaluacion de strikes
        strike = int(scriptSys.AUX['strike'])
        scriptSys.AUX['strikeh'] = int(scriptSys.AUX['strikeh']) + strike
        # if strike >= 3 or strikeh >= 3:
        strikeh = int(scriptSys.AUX['strikeh'])
        #     scriptSys.final_report("SoHfail",SoH)
        if strikeh >= 3:
            scriptSys.final_report("SoHfail", SoH)
            return
        #evaluacion de repetir el test
        # if testnr >= 2:
        #     soh1 = int(scriptSys.AUX['soh'+str(testnr-1)])
        #     # if abs(soh1-int(SoH)) < 20 and strike == 0:
        #     if abs(int(soh1)-int(SoH)) < 10:
        #         if  (soh1+int(SoH))/2  > (Boundary + Bmargin):
        #             scriptSys.final_report("SoHok",SoH)
        #             return
        #         if (soh1+int(SoH))/2  < (Boundary - Bmargin):
        #             scriptSys.final_report("SoHfail",SoH)
        #             return
        #     if testnr >= 5:
        #         if  (soh1+int(SoH))/2  >= (Boundary):
        #             scriptSys.final_report("SoHok",SoH)
        #             return
        #         if (soh1+int(SoH))/2  < (Boundary):
        #             scriptSys.final_report("SoHfail",SoH)
        #             return

        if Zint > Z_BOUNDARY:
            scriptSys.final_report("SoHok", Zint)
        else:
            scriptSys.final_report("SoHok", Zint)

        scriptSys.AUX['strike'] = 0
        scriptSys.TIME_INIT = scriptSys.TIME
        scriptSys.AUX['testnr'] = str(int(scriptSys.AUX['testnr']) + 1)
        print "RUN"
        return

    except Exception as e:
        scriptSys.error_report(e, "evaluate()")
Пример #5
0
def measure_z2():
    try:
        if scriptSys.SCRIPT['mode'] != 'Z_MEASURE2':  #si es llamado por 1
            scriptSys.SCRIPT['mode'] = 'Z_MEASURE2'
            scriptSys.TIME_INIT = scriptSys.TIME
            print "DISCHARGE,1.0"
            return

        actual_time = (scriptSys.TIME - scriptSys.TIME_INIT)
        if actual_time >= tTestD2:
            # deja reposar y chequea q no caiga la tension
            # final_report(0,0)
            # stress_test()
            scriptSys.SCRIPT['mode'] = 'CHARGE'
            scriptSys.TIME_INIT = scriptSys.TIME
            print "CHARGE,4.2,1.2"
            # scriptTest.charge_state(1)
            return

        if  actual_time >=(tTestC2 - tMargin) \
            and actual_time <(tTestC2 + tMargin):
            # print "DISCHARGE,1.0"  Descarga fuerte
            scriptSys.import_data()
            #delay en el inicio de la descarga
            t = scriptSys.TIME_INIT + tTestB2 + 2
            var = scriptSys.get_data('VOLTAGE', \
                range( t - 5 , t - 5 + voltageAverage))
            #promedio de las mediciones al principio
            V1 = sum(var) / float(len(var))
            var = scriptSys.get_data('VOLTAGE', \
                range( scriptSys.TIME - voltageAverage, scriptSys.TIME ))
            #promedio de las mediciones al final del test
            V2 = sum(var) / float(len(var))
            var = scriptSys.get_data(
                'CURRENT',
                range(scriptSys.TIME - currentAverage, scriptSys.TIME))
            #promedio de las mediciones al principio
            I1 = sum(var) / float(len(var))
            Z2 = int(((float(V2) - float(V1)) / float(I1)) * 1000)
            scriptSys.EVAL['int_z2'] = str(Z2)
            scriptSys.EVAL['int_z'] = str(Z2)  #str(round(Z1,0))
            # chequear rectas
            print "PAUSE"
            return

        if  actual_time >=(tTestB2 - tMargin) \
            and actual_time <(tTestB2 + tMargin):
            # deja reposar y chequea q no caiga la tension
            # stress_test()
            print "DISCHARGE,1.5"
            return

        if  actual_time >= (tTestA2 - tMargin) \
            and  actual_time < (tTestA2 + tMargin) :
            # print "DISCHARGE,0.2"  Descarga suave
            scriptSys.import_data()
            t = scriptSys.TIME_INIT + 2  #delay en el inicio de la descarga
            var = scriptSys.get_data('VOLTAGE', \
                range( t - 5, t- 5 + voltageAverage))
            #promedio de las mediciones al principio
            V1 = sum(var) / float(len(var))
            var = scriptSys.get_data('VOLTAGE', \
                range( scriptSys.TIME - voltageAverage, scriptSys.TIME ))
            #promedio de las mediciones al final del test
            V2 = sum(var) / float(len(var))
            var = scriptSys.get_data('CURRENT', \
                range( scriptSys.TIME - currentAverage,scriptSys.TIME))
            #promedio de las mediciones al principio
            I1 = sum(var) / float(len(var))
            Z1 = int(((float(V2) - float(V1)) / float(I1)) * 1000)

            scriptSys.EVAL['int_z1'] = str(Z1)  #str(round(Z1,3))
            # chequear rectas
            print "PAUSE"
            return
        print "RUN"
        return
    except Exception as e:
        scriptSys.error_report(e, "measure_z2()")
Пример #6
0
            import scriptDebug
        except:
            print "ERROR file scriptDebug Not found!!"
            sys.exit()

#Setup
umbralVoltHigh = 3800
umbralVoltMin = 3600
umbralVoltLow = 3200
maxTimeInit = 20  # 20 seg
maxTimeDischarge = 30 * 60  # 30 min
maxTimeCharge = 1 * 60 * 60  # 1 hr
maxTimeCondit = 20  # 20 seg

if scriptSys.DEBUG_MODE: scriptInc.get_line('VOLTAGE', range(40, 60))
scriptSys.import_data()


################################################################
##########                  INIT                      ##########
################################################################
def init_state():
    if int(scriptSys.TIME) > maxTimeInit:
        if scriptSys.VOLTAGE < umbralVoltLow:
            scriptSys.TIME_INIT = scriptSys.TIME
            scriptSys.GENERAL['mode'] = "CHARGE"
            print "CHARGE,4.5,1.0"
            scriptSys.ini_Update()
            sys.exit()
        if scriptSys.VOLTAGE > umbralVoltHigh:
            scriptSys.TIME_INIT = scriptSys.TIME