Пример #1
0
def end_state():
    try:
        scriptSys.GENERAL['mode']= "STOP"
        scriptSys.TIME_INIT = scriptSys.TIME
        print "STOP"
        # scriptSys.copy_report()
        return
    except Exception as e:
        scriptSys.error_report(e,"end_state()")
Пример #2
0
def measure_state() :
    try:
        if scriptSys.TIME < maxTimeMeasure:
            if scriptInc.measure() == 'FAIL':
                erase_state()
        else:
            analysis_state()
        # print "RUN"
        return
    except Exception as e:
        scriptSys.error_report(e,"zmeasure_state()")
Пример #3
0
def stress_test() :
    try:
        if scriptSys.GENERAL['mode'] != 'STRESS' : #si es llamado por 1
            scriptSys.GENERAL['mode'] = 'STRESS'
            scriptSys.TIME_INIT = scriptSys.TIME
            scriptSys.AUX['testnr'] = str(int(scriptSys.AUX['testnr'])+1)
            scriptSys.AUX['strike'] = 0
            scriptSys.AUX['strikeh'] = 0
            print "PAUSE"
            return
        #condiciones de Fallas:
        if scriptSys.VOLTAGE < lowVoltageLimit : #si actula la proteccion cargo la Batery
            scriptSys.AUX['Dropdown voltage T='+ str(scriptSys.TIME)] =scriptSys.VOLTAGE
            # scriptSys.send_msg('Dropdown voltage T='+ str(scriptSys.TIME))
            scriptSys.final_report("SoHfail",0)
            return
        # if scriptSys.VOLTAGE < vMargin : #si actula la proteccion cargo la Batery
        #     scriptSys.GENERAL['mode'] = 'CHARGE'
        #     scriptSys.TIME_INIT = scriptSys.TIME
        #     print "CHARGE,"+ vCharge1 +","+ iCharge1
        #     return
        if scriptSys.CURRENT > (-iMargin) and scriptSys.VOLTAGE < vMargin :
            scriptSys.AUX['F12'] =scriptSys.CURRENT
            scriptSys.final_report("F12",0)
            return
        if (scriptSys.TIME - scriptSys.TIME_INIT) >= maxTimeInit:
            slope1 = scriptSys.get_slope(range(scriptSys.TIME_INIT + 3,scriptSys.TIME))
            if slope1['VOLTAGE']  > 80 and slope1['CURRENT'] > 180 :
                scriptSys.AUX['F13 T='+ str(scriptSys.TIME)] =slope1
                # scriptSys.send_msg('F13 T='+ str(scriptSys.TIME))
                scriptSys.final_report("F13",0)
                return
        if (scriptSys.TIME - scriptSys.TIME_INIT) >= tMaxStress:
            scriptSys.AUX['F12'] =(scriptSys.TIME - scriptSys.TIME_INIT)
            scriptSys.final_report("F15",0)
            return
        ######################################

        actual_time = (scriptSys.TIME - scriptSys.TIME_INIT)
        scriptSys.AUX['actual_time'] = actual_time
        if  actual_time >= (tTestC3- tMargin)and actual_time <(tTestC3 + tMargin):
            msj = evaluate()
            return
        if  actual_time >=(tTestB3 - tMargin)and actual_time <(tTestB3 + tMargin):
            print "PAUSE"
            return
        if  actual_time >=(tTestA3 - tMargin)and actual_time <(tTestA3 + tMargin):
            print "DISCHARGE,"+ iDischargeTest2
            return

        print "RUN"
        return
    except Exception as e:
        scriptSys.error_report(e,"stress_test()")
Пример #4
0
def analysis():
    try:
        if scriptSys.SCRIPT[
                'mode'] != 'ANALYSIS':  #si es llamado por primera vez
            scriptSys.SCRIPT['mode'] = 'ANALYSIS'
            scriptSys.TIME_INIT = scriptSys.TIME

        if evaluate() == 'OK':
            scriptSys.ANALYSIS['analysisstate'] = 'OK'
        else:
            scriptSys.ANALYSIS['analysisstate'] = 'FAIL'

        return 'DONE'

    except Exception as e:
        scriptSys.error_report(e, "analysis()")
Пример #5
0
def init_state() :
    try:
        if int(scriptSys.TIME) >= maxTimeInit :
            #condiciones inciales:
            if scriptSys.CURRENT < (iMargin):
                scriptSys.AUX['failcode'] = 3
                scriptSys.final_report('FAIL_A',int(scriptSys.AUX['failcode']))
                return
            ##############################
            measure_state()
            return
            ##############################
        print "RUN"
        return
    except Exception as e:
        scriptSys.error_report(e,"init_state()")
Пример #6
0
def init_state():
    try:
        if int(scriptSys.TIME) >= maxTimeInit:
            if scriptSys.VOLTAGE > VALTA: scriptSys.GENERAL['vstate'] = "vALTA"
            if scriptSys.VOLTAGE < VBAJA: scriptSys.GENERAL['vstate'] = "vBAJA"
            else: scriptSys.GENERAL['vstate'] = "vMEDIA"

            if scriptSys.CURRENT > iMargin or scriptSys.CURRENT < (-iMargin):
                scriptSys.final_report("F01", 0)
                return
            if scriptSys.CURRENT < (2 * iMargin):
                charge_state(0)
                return
        print "RUN"
        return
    except Exception as e:
        scriptSys.error_report(e, "init_state()")
Пример #7
0
def inform():
    try:
        if scriptSys.SCRIPT['mode'] != 'INFORM':  #si es llamado por primera vez
            scriptSys.SCRIPT['mode'] = 'INFORM'
            scriptSys.TIME_INIT = scriptSys.TIME

            if scriptSys.DEV['datastate'] == 'OK':
                if scriptSys.ANALYSIS['erasestate'] == 'OK':
                    if scriptSys.ANALYSIS['analysisstate'] == 'OK':
                        scriptSys.final_report('SUCCESS_A', 0)
                    elif scriptSys.ANALYSIS['analysisstate'] == 'FAIL':
                        scriptSys.final_report('FAIL_A',
                                               int(scriptSys.AUX['failcode']))
                    else:
                        scriptSys.final_report('FAIL_Z',
                                               int(scriptSys.AUX['failcode']))
                elif scriptSys.ANALYSIS['erasestate'] == 'FAIL':
                    if scriptSys.ANALYSIS['analysisstate'] == 'OK':
                        scriptSys.final_report('FAIL_B', 0)
                    elif scriptSys.ANALYSIS['analysisstate'] == 'FAIL':
                        scriptSys.final_report('FAIL_C',
                                               int(scriptSys.AUX['failcode']))
                    else:
                        scriptSys.final_report('FAIL_Y',
                                               int(scriptSys.AUX['failcode']))
            elif scriptSys.DEV['datastate'] == 'FAIL':
                if scriptSys.ANALYSIS['analysisstate'] == 'OK':
                    scriptSys.final_report('FAIL_D', 0)
                elif scriptSys.ANALYSIS['analysisstate'] == 'FAIL':
                    scriptSys.final_report('FAIL_E',
                                           int(scriptSys.AUX['failcode']))
                else:
                    scriptSys.final_report('FAIL_X',
                                           int(scriptSys.AUX['failcode']))
            else:
                scriptSys.final_report('FAIL_W',
                                       int(scriptSys.AUX['failcode']))
        if (scriptSys.TIME - scriptSys.TIME_INIT) >= maxTimeInform:
            print "STOP"
            return
        print "RUN"
        return
    except Exception as e:
        scriptSys.error_report(e, "inform()")
Пример #8
0
def measure():
    try:
        if scriptSys.SCRIPT[
                'mode'] != 'MEASURE':  #si es llamado por primera vez
            scriptSys.SCRIPT['mode'] = 'MEASURE'
            scriptSys.TIME_INIT = scriptSys.TIME
            scriptSys.ANALYSIS['analysisstate'] = 'RUNNING'
            # return 'DONE'

        ######
        # condiciones de carga del telefono
        ######
        if evaluate_rt() == 'FAIL':
            scriptSys.AUX['failcode']
            return 'FAIL'
        print 'RUN'
        return 'DONE'
    except Exception as e:
        scriptSys.error_report(e, "measure()")
Пример #9
0
def already_charged(option):
    try:
        if scriptSys.GENERAL['mode'] != 'END':  #si es llamado por primera vez
            scriptSys.GENERAL['mode'] = 'END'
            scriptSys.TIME_INIT = scriptSys.TIME
            print "STOP,NTF,100,0"

        scriptSys.GUI['line1'] = "Analysis Finished"
        if option == 1:
            scriptSys.GUI['line2'] = "Batery low voltage :" \
                + str(scriptSys.VOLTAGE) + 'V'
        if option == 2:
            scriptSys.GUI['line2'] = "Batery already DISCHARGED :" \
                + str(scriptSys.VOLTAGE) + 'V'
        scriptSys.GUI['bgcolor'] = '"120,244,183"'
        scriptSys.GUI['extra_info'] = " Z1="+scriptSys.EVAL['int_z1'] \
            +" Z2="+scriptSys.EVAL['int_z2']
        scriptSys.copy_report()
        return
    except Exception as e:
        scriptSys.error_report(e, "already_charged()")
Пример #10
0
def erase():
    try:
        if scriptSys.SCRIPT['mode'] != 'ERASE':  #si es llamado por primera vez
            scriptSys.SCRIPT['mode'] = 'ERASE'
            scriptSys.TIME_INIT = scriptSys.TIME
            print "ERASE"
            return 'NO'
        if scriptSys.ANALYSIS['erasestate'] == 'OK':
            return 'DONE'
        if scriptSys.ANALYSIS['erasestate'] == 'FAIL':
            return 'DONE'
        # scriptSys.send_msg(str((scriptSys.TIME - scriptSys.TIME_INIT)))
        if scriptSys.ANALYSIS['erasestate'] == 'RUNNING' or scriptSys.ANALYSIS[
                'erasestate'] == 'NO':
            if (scriptSys.TIME - scriptSys.TIME_INIT) >= maxTimeErase:
                scriptSys.ANALYSIS['erasestate'] = 'FAIL'
                return 'DONE'
        print "RUN"
        return
    except Exception as e:
        scriptSys.error_report(e, "erase()")
Пример #11
0
def discharge_state(number) :
    try:
        if not scriptSys.GENERAL['mode'] == 'DISCHARGE' : #si es llamado por 1
            scriptSys.GENERAL['mode'] = 'DISCHARGE'
            scriptSys.TIME_INIT = scriptSys.TIME
            if number == 1 : print "DISCHARGE,"+ iDischarge1
            if number == 2 : print "DISCHARGE,"+ iDischarge2
            if number == 3 : print "DISCHARGE,"+ iDischarge3
            return

        if scriptSys.VOLTAGE < (umbralVoltTarget - umbralVolt) \
            and (scriptSys.TIME - scriptSys.TIME_INIT) >= minTimeDischarge:
            cond_state()
            return

        if (int(scriptSys.TIME) - int(scriptSys.TIME_INIT)) >= maxTimeDischarge:
            scriptSys.final_report("maxTimeDischarge")
            return
        print "RUN"
        return
    except:
        scriptSys.error_report("discharge_state()")
Пример #12
0
def get_line(dType, tLapse):
    try:
        n = len(tLapse)
        if len(tLapse)%2 == 1:
            tLapse.pop()
            n = len(tLapse)
        var = scriptSys.get_data(dType, tLapse)
        VAR = sum(var) / float(len(var)) #promedio
        m = []
        m_aux = []
        for x in range(0 , n , 2):
            m_aux.append((var[x]+var[x+1])/2)
        for x in range((n/2)-1):
            m.append((m_aux[x+1]-m_aux[x])/2)
        M = sum(m) / float(len(m)) #promedio
        VAR1 = VAR + M *(n/2)
        if scriptSys.DEBUG_MODE : scriptDebug.plot_line(dType,M,VAR1,tLapse[-1])
        scriptSys.GENERAL['line_m'] = str(M)
        scriptSys.GENERAL['line_m'] = str(VAR1)
        return
    except:
        scriptSys.error_report("get_line()")
Пример #13
0
def evaluate() :
    try:
        capacityVectoAmps   = 0
        capacityVectorAh    = 0
        capacityVectoWatt   = 0
        for line in scriptSys.data:
            i = int(line['CURRENT'])
            t = int(line['TIME'])
            if i >= (iDischTest1 - iMar) and i <=(iDischTest1 + iMar) \
                and (t > scriptSys.TIME_INIT):
                capacityVectoAmps += int(line['CURRENT'])
                capacityVectoWatt += int(line['CURRENT']) * int(line['VOLTAGE'])
        capacityAh = int(capacityVectoAmps / (1000*3600)) #/1000x mAmp y 3600xHr
        capacityWh = int(capacityVectoAmps / (1000000*3600))
        # scriptSys.import_data()
        result = (scriptSys.TIME - scriptSys.TIME_INIT)
        #regresion lineal
        SoH = int((result * slope + origin)/1000)
        scriptSys.final_report("sohAW",SoH,capacityAh,capacityWh)
        return
    except:
        scriptSys.error_report("evaluate()")
Пример #14
0
def init_state() :
    try:
        if scriptSys.TIME >= maxTimeInit and scriptSys.VOLTAGE > vMargin:
            scriptInc.measure_z1()
            return
        if scriptSys.TIME >= maxTimeInitFail and scriptSys.VOLTAGE <= vMargin:
            scriptSys.final_report("F01",0)
            return
            # if scriptSys.VOLTAGE <= umbralVoltLow:
            #     charge_state(1)
            #     return
            # if scriptSys.VOLTAGE > umbralVoltLow:
            #     stress_state()
            #     return
            #
            # if scriptSys.VOLTAGE < umbralVoltHigh and \
            #     scriptSys.VOLTAGE > umbralVoltLow:
            #     stress_state()
            #     return
        print "RUN"
        return
    except:
        scriptSys.error_report("init_state()")
Пример #15
0
def stress_test() :
    try:
        if scriptSys.GENERAL['mode'] != 'STRESS' : #si es llamado por 1
            scriptSys.GENERAL['mode'] = 'STRESS'
            scriptSys.TIME_INIT = scriptSys.TIME
            print "DISCHARGE,"+ iDischargeTest1
            return
        if  scriptSys.VOLTAGE <= vMargin:
            scriptSys.final_report("maxTimeInitFail",0)
            return
        if scriptSys.VOLTAGE <= lowVoltageLimit: #si actula la proteccion cargo la Batery
            evaluate()
            return

        actual_time = (scriptSys.TIME - scriptSys.TIME_INIT)
        if  actual_time >= tMaxStress :
            scriptSys.final_report("tMaxStress",0)
            return

        print "RUN"
        return
    except:
        scriptSys.error_report("stress_test()")
Пример #16
0
def charge_state(number) :
    try:
        if not scriptSys.GENERAL['mode'] == 'CHARGE' : #si es llamado por 1 vez
            scriptSys.GENERAL['mode'] = 'CHARGE'
            scriptSys.TIME_INIT = scriptSys.TIME
            # if (umbralVoltTarget - scriptSys.VOLTAGE) <(0.1*umbralVoltTarget):
            #     number = 4
            # elif (umbralVoltTarget -scriptSys.VOLTAGE)<(0.2*umbralVoltTarget):
            #     number = 3
            # elif (umbralVoltTarget -scriptSys.VOLTAGE)<(0.4*umbralVoltTarget):
            #     number = 2
            # else:
            #     number = 1
            # if number == 4 : print "CHARGE,"+ vCharge4 +","+ iCharge4
            # if number == 3 : print "CHARGE,"+ vCharge3 +","+ iCharge3
            # if number == 1 :
            print "CHARGE,"+ vCharge1 +","+ iCharge1
            return
        if  scriptSys.VOLTAGE < (int(1000*float(vCharge2)) + vMargin) and \
            scriptSys.VOLTAGE > (int(1000*float(vCharge2)) - vMargin) and \
            scriptSys.CURRENT < vMargin:
            scriptSys.final_report(0)

        if  scriptSys.CURRENT <= (umbralCurrentTarget) and \
            (scriptSys.TIME - scriptSys.TIME_INIT) >= minTimeCharge:
            cond_state()
            return

        if (int(scriptSys.TIME) - int(scriptSys.TIME_INIT)) >= maxTimeCharge :
            scriptSys.final_report("maxTimeCharge")
            return
        # print "RUN"
        print "CHARGE,"+ vCharge2 +","+ iCharge2
        return
    except:
        scriptSys.error_report("charge_state()")
Пример #17
0
def cond_state():
    try:
        if not scriptSys.GENERAL['mode'] == 'CONDITIONING' : #es llamado por 1
            scriptSys.GENERAL['mode'] = 'CONDITIONING'
            scriptSys.TIME_INIT = scriptSys.TIME
            print "PAUSE"
            return

        if  ((scriptSys.TIME) - (scriptSys.TIME_INIT)) >= (maxTimeCond-tMargin):
            stress_state()
            return
        if  scriptSys.VOLTAGE < (int(1000*float(vCharge2)) + vMargin) and \
            scriptSys.VOLTAGE > (int(1000*float(vCharge2)) - vMargin) and \
            scriptSys.CURRENT < vMargin:
            scriptSys.final_report(0)
            # if scriptSys.VOLTAGE < umbralVoltLow:
            #     charge_state(2)
            #     scriptSys.ini_Update()
            #     sys.exit()
            #     return
            #
            # scriptInc.already_charged()

            # if scriptSys.VOLTAGE > umbralVoltHigh:
            #     discharge_state(2)
            #     scriptSys.ini_Update()
            #     sys.exit()
            # if scriptSys.VOLTAGE < umbralVoltHigh and \
            #     scriptSys.VOLTAGE > umbralVoltLow:
            #     scriptInc.measure_z1()
            #     scriptSys.ini_Update()
            #     sys.exit()
        print "RUN"
        return
    except:
        scriptSys.error_report("cond_state()")
Пример #18
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()")
Пример #19
0
            print "CHARGE,4.2,1.8"
            return
        if  actual_time >= 90:
            print "PAUSE"
            return
        if  actual_time >= 60:
            print "DISCHARGE,1.5"
            return
        if  actual_time >= 30:
>>>>>>> Bat Activate
            print "PAUSE"
            return
        print "RUN"
        return
    except:
        scriptSys.error_report("measure_z1()")
################################################################
##########                  measure_z2                ##########
################################################################
#Setup
tTest12  =   30  #tiempo de descarga suave
tTest22  =   60  #tiempo de descarga fuerte
tTest32  =   60  #tiempo de recuperacion
tTest42  =   20  #tiempo de chequeo e incio de sig etapa
tTest52  =   20
# tMargin =   5   #margen de tiempo por no ser 10s exactos
voltageAverage = 3
currentAverage = 5
Z1 = 0
Z2 = 0
tTestA2  =   tTest12
Пример #20
0
def pause_state():
    try:
        print "RUN"
        return
    except Exception as e:
        scriptSys.error_report(e, "pause_state()")
Пример #21
0
def stress_state():
    try:
        scriptInc.stress_test()
        return
    except Exception as e:
        scriptSys.error_report(e, "stress_state()")
Пример #22
0
def zmeasure2_state():
    try:
        scriptInc.measure_z2()
        return
    except Exception as e:
        scriptSys.error_report(e, "zmeasure2_state()")
Пример #23
0
def stress_state():
    try:
        scriptInc.stress_test()
        return
    except:
        scriptSys.error_report("stress_state()")
Пример #24
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()")
Пример #25
0
def evaluate_rt():
    try:
        return 'OK'
    except Exception as e:
        scriptSys.error_report(e, "evaluatert()")
Пример #26
0
def charge_state(number) :
    try:
        if not scriptSys.GENERAL['mode'] == 'CHARGE' : #si es llamado por 1 vez
            scriptSys.GENERAL['mode'] = 'CHARGE'
            scriptSys.TIME_INIT = scriptSys.TIME
            print "CHARGE,"+ vCharge1 +","+ iCharge1
            return
        if scriptSys.CURRENT < iMargin and \
            scriptSys.VOLTAGE > (int(1000*float(vCharge2))-100) :
            scriptSys.AUX['F03t'] =scriptSys.VOLTAGE
            scriptSys.AUX['F03'] =scriptSys.TIME
            scriptSys.final_report("F03",0)
            return
        if (scriptSys.TIME - scriptSys.TIME_INIT) <= maxTimeInit:
            print "CHARGE,"+ vCharge2 +","+ iCharge2
            return
        if  scriptSys.CURRENT < (umbralCurrentTarget) and \
            (scriptSys.TIME - scriptSys.TIME_INIT) >= minTimeCharge:
            cond_state()
            return

        #condiciones de Fallas:

        if scriptSys.CURRENT < iMargin :
            scriptSys.AUX['F02t'] =scriptSys.CURRENT
            scriptSys.AUX['F02'] =scriptSys.TIME
            scriptSys.final_report("F02",0)
            return
        if (scriptSys.TIME - scriptSys.TIME_INIT) >= maxTimeInit:
            slope = scriptSys.get_slope(range(scriptSys.TIME_INIT + 10,scriptSys.TIME))
            if scriptSys.GENERAL['vstate'] == "vBAJA" and not slope['VOLTAGE'] > -80 \
                and scriptSys.CURRENT > (int(1000*float(iCharge2))-200):
                scriptSys.AUX['F04t'] =scriptSys.CURRENT
                scriptSys.AUX['F04'] =scriptSys.TIME
                scriptSys.final_report("F04",0)
                return
            if scriptSys.GENERAL['vstate'] == "vMEDIA" and not slope['VOLTAGE'] > -80\
                and scriptSys.CURRENT > (int(1000*float(iCharge2))-200):
                scriptSys.AUX['F05t'] =slope['VOLTAGE']
                scriptSys.AUX['F05'] =scriptSys.TIME
                scriptSys.final_report("F05",0)
                return
            if scriptSys.GENERAL['vstate'] == "vALTA" and not slope['CURRENT'] < 80\
                and scriptSys.VOLTAGE > (int(1000*float(vCharge2))-200):
                scriptSys.AUX['F06t'] =slope['CURRENT']
                scriptSys.AUX['F06'] =scriptSys.TIME
                scriptSys.final_report("F06",0)
                return
            # if slope['VOLTAGE'] > 0 and slope['CURRENT'] < 0 :
            #     scriptSys.AUX['F07'] =slope['CURRENT']
            #     scriptSys.AUX['F07t'] =scriptSys.TIME
            #     scriptSys.final_report("F07",0)
            #     return
            if slope['VOLTAGE'] < 0 :
                scriptSys.AUX['F08t'] =slope['VOLTAGE']
                scriptSys.AUX['F04'] =scriptSys.TIME
                scriptSys.final_report("F08",0)
                return
        if (scriptSys.TIME - scriptSys.TIME_INIT) >= maxTimeChargeLow and \
            scriptSys.GENERAL['vstate'] == "vBAJA" :
            scriptSys.AUX['F09t'] =(scriptSys.TIME - scriptSys.TIME_INIT)
            scriptSys.AUX['F04'] =scriptSys.TIME
            scriptSys.final_report("F09",0)
            return
        if (scriptSys.TIME - scriptSys.TIME_INIT) >= maxTimeChargeMed and \
            scriptSys.GENERAL['vstate'] == "vMEDIA" :
            scriptSys.AUX['F10t'] =(scriptSys.TIME - scriptSys.TIME_INIT)
            scriptSys.AUX['F04'] =scriptSys.TIME
            scriptSys.final_report("F10",0)
            return
        if (scriptSys.TIME - scriptSys.TIME_INIT) >= maxTimeChargeHig and \
            scriptSys.GENERAL['vstate'] == "vALTA" :
            scriptSys.AUX['F11t'] =(scriptSys.TIME - scriptSys.TIME_INIT)
            scriptSys.AUX['F04'] =scriptSys.TIME
            scriptSys.final_report("F11",0)
            return
        print "RUN"
        return
    except Exception as e:
        scriptSys.error_report(e,"charge_state()")
Пример #27
0
def measure_z2():
    try:
        if scriptSys.GENERAL['mode'] != 'Z_MEASURE2':  #si es llamado por 1
            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(0,0)
            # stress_test()
            scriptSys.GENERAL['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()")
Пример #28
0
def charge_state(number):
    try:
        if not scriptSys.GENERAL['mode'] == 'CHARGE':  #si es llamado por 1 vez
            scriptSys.GENERAL['mode'] = 'CHARGE'
            scriptSys.TIME_INIT = scriptSys.TIME
            print "CHARGE," + vCharge1 + "," + iCharge1
            return
        # if scriptSys.CURRENT < iMargin and \
        #     scriptSys.VOLTAGE > (int(1000*float(vCharge2))-100) :
        #     scriptSys.final_report("F03",0)
        #     return
        if (scriptSys.TIME - scriptSys.TIME_INIT) <= maxTimeInit:
            print "CHARGE," + vCharge2 + "," + iCharge2
            return
        if  scriptSys.CURRENT < (umbralCurrentTarget) and \
            (scriptSys.TIME - scriptSys.TIME_INIT) >= minTimeCharge:

            if not scriptSys.GENERAL[
                    'mode'] == 'INIT':  #si es llamado por 1 vez
                scriptSys.GENERAL['mode'] = 'INIT'
                scriptSys.GENERAL['entradas'] = '0'

            testA()

            # cond_state()
            return

        #condiciones de Fallas:

        # if scriptSys.CURRENT < iMargin :
        #     scriptSys.final_report("F02",0)
        #     return
        # if (scriptSys.TIME - scriptSys.TIME_INIT) >= maxTimeInit:
        #     slope = scriptSys.get_slope(range(scriptSys.TIME_INIT + 3,scriptSys.TIME))
        #     if scriptSys.GENERAL['vstate'] == "vBAJA" and not slope['VOLTAGE'] > -80 \
        #         and scriptSys.CURRENT > (int(1000*float(iCharge2))-200):
        #         scriptSys.final_report("F04",0)
        #         return
        #     if scriptSys.GENERAL['vstate'] == "vMEDIA" and not slope['VOLTAGE'] > -80\
        #         and scriptSys.CURRENT > (int(1000*float(iCharge2))-200):
        #         scriptSys.final_report("F05",0)
        #         return
        #     if scriptSys.GENERAL['vstate'] == "vALTA" and not slope['CURRENT'] < 80\
        #         and scriptSys.VOLTAGE > (int(1000*float(vCharge2))-200):
        #         scriptSys.final_report("F06",0)
        #         return
        #     if slope['VOLTAGE'] > 0 and slope['CURRENT'] < 80 :
        #         scriptSys.final_report("F07",0)
        #         return
        #     if slope['VOLTAGE'] < 100 :
        #         scriptSys.final_report("F08",0)
        #         return
        # if (scriptSys.TIME - scriptSys.TIME_INIT) >= maxTimeChargeLow and \
        #     scriptSys.GENERAL['vstate'] == "vBAJA" :
        #     scriptSys.final_report("F09",0)
        #     return
        # if (scriptSys.TIME - scriptSys.TIME_INIT) >= maxTimeChargeMed and \
        #     scriptSys.GENERAL['vstate'] == "vMEDIA" :
        #     scriptSys.final_report("F10",0)
        #     return
        # if (scriptSys.TIME - scriptSys.TIME_INIT) >= maxTimeChargeHig and \
        #     scriptSys.GENERAL['vstate'] == "vALTA" :
        #     scriptSys.final_report("F11",0)
        #     return
        print "RUN"
        return
    except Exception as e:
        scriptSys.error_report(e, "charge_state()")
Пример #29
0
def pause_state():
    try:
        print "RUN"
        return
    except:
        scriptSys.error_report("pause_state()")
Пример #30
0
def inform_state():
    try:
        scriptInc.inform()
        return
    except Exception as e:
        scriptSys.error_report(e,"pause_state()")