コード例 #1
0
def testscenario1():

    set_config('01', '11', '05')
    time.sleep(0.5)

    panel = getPanel()
    profile = switchCase(str(panel))
    if (profile == 'invalid configuration'):
        FILE = open('TC4_CEN_1.txt', 'a')
        print('Unexpected profile value. Panel read: {}'.format(panel),
              file=FILE)
        FILE.close()
        return False

    set_config('01', '12', '02')
    time.sleep(0.2)

    curve = getCurve(profile)

    for i in range(len(curve)):
        if (curve[i][1] == 0):
            if (i < 0 and i < len(curve) - 1):
                curve[i][1] = (curve[i - 1][1] + curve[i + 1][1]) / 2

    flag = []

    if (profile == 10):
        for c in curve:
            if (mask10(c[1], c[0])):
                flag.append(1)
            else:
                FILE = open('TC4_CEN_1.txt', 'a')
                print(c, '\t', profile, file=FILE)
                FILE.close()
                flag.append(0)
    elif (profile == 20):
        for c in curve:
            if (mask20(c[1], c[0])):
                flag.append(1)
            else:
                FILE = open('TC4_CEN_1.txt', 'a')
                print(c, '\t', profile, file=FILE)
                FILE.close()
                flag.append(0)
    elif (profile == 40):
        for c in curve:
            if (mask40(c[1], c[0])):
                flag.append(1)
            else:
                FILE = open('TC4_CEN_1.txt', 'a')
                print(c, '\t', profile, file=FILE)
                FILE.close()
                flag.append(0)
    else:
        for c in curve:
            if (mask60(c[1], c[0])):
                flag.append(1)
            else:
                FILE = open('TC4_CEN_1.txt', 'a')
                print(c, '\t', profile, file=FILE)
                FILE.close()
                flag.append(0)
    if (min(flag) == 1):
        return True
    else:
        return False
コード例 #2
0
def testscenario12():
    rtime = random.randint(1, 4)

    set_config('01', '12', '02')
    time.sleep(0.2)
    set_config('01', '12', '02')
    time.sleep(0.2)

    panel_before = getPanel()
    if (panel_before == 'invalid configuration'):
        FILE = open('TC1_ONOFF2_SUB_4.txt', 'a')
        print('invalid configuration for panel', file=FILE)
        FILE.close()
        return False

    profile = switchCase2(str(panel_before))
    if (profile == 'invalid configuration'):
        FILE = open('TC1_ONOFF2_SUB_4.txt', 'a')
        print('invalid configuration for profile', file=FILE)
        FILE.close()
        return False

    set_config('01', '12', '11')
    time.sleep(1.1)

    time.sleep(rtime)

    set_config('01', '12', '02')
    time.sleep(0.2)

    curve = getCurve(profile)

    flag = []

    if (profile == 10):
        for c in curve:
            if (mask10(c[1], c[0])):
                flag.append(1)
            else:
                FILE = open('TC1_ONOFF2_SUB_4.txt', 'a')
                print(
                    'Power error.\nElapsed time: {}\tLED power: {}\t Profile: {}'
                    .format(c[0], c[1], profile),
                    file=FILE)
                FILE.close()
                flag.append(0)
    elif (profile == 20):
        for c in curve:
            if (mask20(c[1], c[0])):
                flag.append(1)
            else:
                FILE = open('TC1_ONOFF2_SUB_4.txt', 'a')
                print(
                    'Power error.\nElapsed time: {}\tLED power: {}\t Profile: {}'
                    .format(c[0], c[1], profile),
                    file=FILE)
                FILE.close()
                flag.append(0)
    elif (profile == 40):
        for c in curve:
            if (mask40(c[1], c[0])):
                flag.append(1)
            else:
                FILE = open('TC1_ONOFF2_SUB_4.txt', 'a')
                print(
                    'Power error.\nElapsed time: {}\tLED power: {}\t Profile: {}'
                    .format(c[0], c[1], profile),
                    file=FILE)
                FILE.close()
                flag.append(0)
    else:
        for c in curve:
            if (mask60(c[1], c[0])):
                flag.append(1)
            else:
                FILE = open('TC1_ONOFF2_SUB_4.txt', 'a')
                print(
                    'Power error.\nElapsed time: {}\tLED power: {}\t Profile: {}'
                    .format(c[0], c[1], profile),
                    file=FILE)
                FILE.close()
                flag.append(0)
    if (min(flag) == 1):
        return True
    else:
        return False
コード例 #3
0
def testscenario5():
    if (getPotLum() != 0):
        FILE = open('TC1_ONOFF1_SUB_1.txt', 'a')
        FILE.write('Blue LED is not on yet;\nLED power: {}\n'.format(
            getPotLum()))
        FILE.close()
        return False
    else:
        rtime = random.randint(2, 9)
        rhex = hex(rtime)[2:]
        if (len(rhex) < 2):
            rhex = '0' + rhex

        set_config('01', '12', rhex)
        time.sleep(rtime / 10)
        panel = getPanel()
        panel = str(panel)
        profile = switchCase2(panel)
        if (profile == 'invalid configuration'):
            FILE = open('TC1_ONOFF1_SUB_1.txt', 'a')
            print(
                'Invalid configuration for panel.\nPanel: {}\tRandom time: {}\n'
                .format(panel, rtime),
                file=FILE)
            FILE.close()
            return False

        curve = getCurve(profile)

        for i in range(len(curve)):
            if (curve[i][1] == 0):
                if (i > 0 and i < len(curve) - 1):
                    curve[i][1] = (curve[i - 1][1] + curve[i + 1][1]) / 2

        set_config('01', '11', '02')
        time.sleep(0.2)
        flag = []

        if (profile == 10):
            for c in curve:
                if (mask10(c[1], c[0])):
                    flag.append(1)
                else:
                    FILE = open('TC1_ONOFF1_SUB_1.txt', 'a')
                    print(
                        'Power error.\nElapsed time: {}\tLED power: {}\t Profile: {}'
                        .format(c[0], c[1], profile),
                        file=FILE)
                    FILE.close()
                    flag.append(0)
        elif (profile == 20):
            for c in curve:
                if (mask20(c[1], c[0])):
                    flag.append(1)
                else:
                    FILE = open('TC1_ONOFF1_SUB_1.txt', 'a')
                    print(
                        'Power error.\nElapsed time: {}\tLED power: {}\t Profile: {}'
                        .format(c[0], c[1], profile),
                        file=FILE)
                    FILE.close()
                    flag.append(0)
        elif (profile == 40):
            for c in curve:
                if (mask40(c[1], c[0])):
                    flag.append(1)
                else:
                    FILE = open('TC1_ONOFF1_SUB_1.txt', 'a')
                    print(
                        'Power error.\nElapsed time: {}\tLED power: {}\t Profile: {}'
                        .format(c[0], c[1], profile),
                        file=FILE)
                    FILE.close()
                    flag.append(0)
        else:
            for c in curve:
                if (mask60(c[1], c[0])):
                    flag.append(1)
                else:
                    FILE = open('TC1_ONOFF1_SUB_1.txt', 'a')
                    print(
                        'Power error.\nElapsed time: {}\tLED power: {}\t Profile: {}'
                        .format(c[0], c[1], profile),
                        file=FILE)
                    FILE.close()
                    flag.append(0)
        if (min(flag) == 1):
            return True
        else:
            return False
コード例 #4
0
def testscenario1():
    rtime = random.randint(10, 30)
    rhex = hex(rtime)[2:]
    if (len(rhex) < 2):
        rhex = '0' + rhex
        FILE = open('randinfo.txt', 'w')
        FILE.write('{}\n'.format(rtime))
        FILE.close()

    set_config('01', '11', rhex)
    time.sleep(rtime / 10)
    panel_before = getPanel()

    set_config('01', '11', rhex)
    time.sleep((rtime / 10))
    panel_after = getPanel()

    if (panel_before == 'invalid configuration'
            or panel_after == 'invalid configuration'):
        FILE = open('TC1_SETA1_SUB_1.txt', 'a')
        print(
            'Invalid configuration for panel:\nRandom time:{}\t Panel before:{}\t Panel after:{}\n\n'
            .format(rtime, panel_before, panel_after),
            file=FILE)
        FILE.close()
        return False

    i, j = getIndex(panel_before, panel_after)

    if ((j - i) == 1 or (i - j) == 3):
        print("indices ok")
    else:
        FILE = open('TC1_SETA1_SUB_1.txt', 'a')
        print(
            'SETA activation do not provide valid transition.\nRandom time: {}\tPanel before: {}\tPanel after: {}'
            .format(rtime, panel_before, panel_after),
            file=FILE)
        FILE.close()
        return False

    profile = switchCase2(str(panel_after))

    set_config('01', '12', '02')
    time.sleep(0.2)

    curve = getCurve(profile)
    flag = []
    if (profile == 10):
        for c in curve:
            if (mask10(c[1], c[0])):
                flag.append(1)
            else:
                FILE = open('TC1_ONOFF1_SUB_1.txt', 'a')

                print(
                    'Power error.\nElapsed time: {}\tLED power: {}\t Profile: {}'
                    .format(c[0], c[1], profile),
                    file=FILE)
                FILE.close()
                flag.append(0)
    elif (profile == 20):
        for c in curve:
            if (mask20(c[1], c[0])):
                flag.append(1)
            else:
                FILE = open('TC1_ONOFF1_SUB_1.txt', 'a')

                print(
                    'Power error.\nElapsed time: {}\tLED power: {}\t Profile: {}'
                    .format(c[0], c[1], profile),
                    file=FILE)
                FILE.close()
                flag.append(0)
    elif (profile == 40):
        for c in curve:
            if (mask40(c[1], c[0])):
                flag.append(1)
            else:
                FILE = open('TC1_ONOFF1_SUB_1.txt', 'a')

                print(
                    'Power error.\nElapsed time: {}\tLED power: {}\t Profile: {}'
                    .format(c[0], c[1], profile),
                    file=FILE)
                FILE.close()
                flag.append(0)
    else:
        for c in curve:
            if (mask60(c[1], c[0])):
                flag.append(1)
            else:
                FILE = open('TC1_ONOFF1_SUB_1.txt', 'a')

                print(
                    'Power error.\nElapsed time: {}\tLED power: {}\t Profile: {}'
                    .format(c[0], c[1], profile),
                    file=FILE)
                FILE.close()
                flag.append(0)
    if (min(flag) == 1):
        return True
    else:
        return False
コード例 #5
0
def testscenario2():
    rtime = random.randint(10, 30)
    rhex = hex(rtime)[2:]
    if (len(rhex) < 2):
        rhex = '0' + rhex

    set_config('01', '12', '02')
    time.sleep(0.3)
    set_config('01', '12', '02')
    time.sleep(0.2)

    panel_before = getPanel()
    set_config('01', '12', '02')
    time.sleep(0.2)

    time.sleep(5)

    set_config('01', '11', rhex)
    time.sleep(rtime / 10)

    panel_after = getPanel()

    if (panel_after == 'invalid configuration'
            or panel_before == 'invalid configuration'):
        FILE = open('TC1_SETA1_SUB_2.txt', 'a')
        print(
            'Invalid configuration for panel.\nRandom time: {}\tPanel before: {}\tPanel after: {}\n\n'
            .format(rtime, panel_before, panel_after),
            file=FILE)
        FILE.close()
        return False

    i, j = getIndex(panel_before, panel_after)
    profile = switchCase2(str(panel_after))

    curve = getCurve(profile)
    # zero = time.time()
    # future = zero + profile
    # time.sleep(3)
    # now = time.time()

    # while(now <= future - 1):
    #     p = getPotLum()
    #     now = time.time()
    #     if(p == 0):
    #         FILE = open('TC1_SETA1_SUB_2.txt', 'a')
    #         FILE.write('teste falhou. led azul nao parece estar ligado\n')
    #         FILE.write('{}\t'.format(p))
    #         FILE.write('{}\t'.format(profile))
    #         FILE.write('{}\t'.format(rtime))
    #         FILE.write('{}\t'.format(panel_before))
    #         FILE.write('{}\n\n'.format(panel_after))
    #         FILE.close()
    #         return False

    if ((j - i) == 1 or (i - j) == 3):
        print("teste ok")
        print(j, i)
        return True
    else:
        FILE = open('TC1_SETA1_SUB_2.txt', 'a')
        print(
            'SETA activation do not provide valid transition.\nRandom time: {}\tPanel before: {}\tPanel after: {}'
            .format(rtime, panel_before, panel_after),
            file=FILE)
        FILE.close()
        return False

    flag = []
    if (profile == 10):
        for c in curve:
            if (mask10(c[1], c[0])):
                flag.append(1)
            else:
                FILE = open('TC1_ONOFF1_SUB_2.txt', 'a')
                print(
                    'Power error.\nElapsed time: {}\tLED power: {}\t Profile: {}'
                    .format(c[0], c[1], profile),
                    file=FILE)
                FILE.close()
                flag.append(0)
    elif (profile == 20):
        for c in curve:
            if (mask20(c[1], c[0])):
                flag.append(1)
            else:
                FILE = open('TC1_ONOFF1_SUB_2.txt', 'a')
                print(
                    'Power error.\nElapsed time: {}\tLED power: {}\t Profile: {}'
                    .format(c[0], c[1], profile),
                    file=FILE)
                FILE.close()
                flag.append(0)
    elif (profile == 40):
        for c in curve:
            if (mask40(c[1], c[0])):
                flag.append(1)
            else:
                FILE = open('TC1_ONOFF1_SUB_2.txt', 'a')
                print(
                    'Power error.\nElapsed time: {}\tLED power: {}\t Profile: {}'
                    .format(c[0], c[1], profile),
                    file=FILE)
                FILE.close()
                flag.append(0)
    else:
        for c in curve:
            if (mask60(c[1], c[0])):
                flag.append(1)
            else:
                FILE = open('TC1_ONOFF1_SUB_2.txt', 'a')
                print(
                    'Power error.\nElapsed time: {}\tLED power: {}\t Profile: {}'
                    .format(c[0], c[1], profile),
                    file=FILE)
                FILE.close()
                flag.append(0)
    if (min(flag) == 1):
        return True
    else:
        return False