示例#1
0
def witch_qc_append(aveliable_qc=[]):
    voltage_start = voltage_measure.main()
    voltage_change.up()
    voltage_difrence = voltage_measure.main() - voltage_start
    if (voltage_difrence > values_to_rules.qc_3_change_minimal) and (voltage_difrence < values_to_rules.qc_3_change_max):
        aveliable_qc.append(3)
    elif (voltage_difrence > values_to_rules.qc_2_change_minimal) and (voltage_difrence < values_to_rules.qc_2_change_max):
        aveliable_qc.append(2)
    return aveliable_qc
示例#2
0
def main():
    parser = create_parser()
    args = parser.parse_args()
    print("Waiting for voltage...")
    lcd_screen.message("Waiting for", "voltage...")
    while 1:
        if voltage_measure.main() > start_voltage_value:
            print(f"Detected voltage bigger then {start_voltage_value}V, measure start:")
            lcd_screen.message("Detected voltage", "measure start")
            break
        time.sleep(start_sleep_perioud)
    count = 0
    start_time = time.time()
    perioud_time = time.time()
    while 1:
        time.sleep(perioud)
        count+=1
        ram = technical_recorder.ram_measure()
        a = (a_measure.main())/1000
        v = voltage_measure.main()
        p = a*v
        one_measure_time = time.time() - perioud_time
        print(one_measure_time)
        perioud_time = time.time()
        w_temp = p * one_measure_time
        if count == 1:
            w_all = w_temp
        else:
            w_all = w_temp + result[count-1]["all_energy"]
        all_measure_time = time.time() - start_time
        result[count]={"current": a, "voltage": v, "power": p, "energy_in_perioud": w_temp, "all_energy": w_all, "all_measure_time": all_measure_time, "RAM using %": ram,
                        "single_measure_time": one_measure_time}
        print(result[count])
        lcd_screen.measure_show(result[count]["voltage"], result[count]["current"], result[count]["all_measure_time"], result[count]["all_energy"]/18)
        if (result[count]["current"] < stop_current_value) or (result[count]["voltage"] < stop_voltage_value):
            output_name = create_result_name(args.name)
            script_localization = os.path.dirname(os.path.realpath(__file__))
            result_path = os.path.join(script_localization, result_folder_name, output_name)
            os.mkdir(result_path)
            with open(os.path.join(result_path, "measure_data.json"), "w") as outfile:
                json.dump(result, outfile)
            final_report = create_report(result)
            print(final_report)
            lcd_screen.final_info(final_report["all_measurment_time"], final_report["all_energy_mAh_5V"])
            with open(os.path.join(result_path, "final_report.json"), "w") as outfile:
                json.dump(final_report, outfile)
            break
示例#3
0
def max_current_test(minimal_voltage=None):
    start_time = datetime.datetime.now()
    measure = []
    resistor_change.set_max()
    while voltage_measure.main() > minimal_voltage:
        actual_current = current_measure.main()
        actual_voltage = voltage_measure.main()
        actual_power = actual_voltage * actual_current
        finish_time = datetime.datetime.now()
        measure.append([
            actual_current, actual_voltage, actual_power,
            -actual_power * (start_time - finish_time).total_seconds()
        ])
        start_time = datetime.datetime.now()
        resistor_change.down()

    return measure
def check_voltage(desired_voltage, accepted_delta=0.2):
    actual_voltage = voltage_measure.main()
    actual_delta = actual_voltage - desired_voltage
    if abs(actual_delta) <= accepted_delta:
        result = True
    else:
        result = False

    return (result, actual_delta)
示例#5
0
def measure_energy(minimal_voltage):
    measure = []
    start_time = datetime.datetime.now()
    actual_voltage = voltage_measure.main()
    while actual_voltage > minimal_voltage:
        actual_voltage = voltage_measure.main()
        actual_current = current_measure.main()
        actual_power = actual_voltage * actual_current
        finish_time = datetime.datetime.now()
        measure.append([
            actual_current, actual_voltage, actual_power,
            -actual_power * (start_time - finish_time).total_seconds()
        ])

        start_time = datetime.datetime.now()
        time.sleep(config.time_beetwen_measure)
        print(measure)
    return measure
示例#6
0
def main():
    i = 0
    result = []
    with open('test_data/power_supply.json') as json_file:
        data = json.load(json_file)
    while i < 1000:
        i += 1
        result.append(random.uniform(data["base_voltage"] * 0.95, data["base_voltage"] * 1.05))
    return {voltage_measure.main(): result}
示例#7
0
def set_qc_3():
    voltage_change.set_voltage(5.0)
    resistor_change.set_max()

    voltage_change.up()

    if voltage_measure.main() > 5.5:
        QC_type_change.main()

    voltage_change.set_voltage(5.0)
示例#8
0
def main(type):
    measure_stability = {}
    measure_v_a = {}
    resistor_change.set_max()
    lcd_screen.main("Waiting for", "voltage...")
    while 1:
        if voltage_measure.main() > config.start_voltage_value:
            lcd_screen.main("Detected voltage", "measure start")
            break
        time.sleep(config.start_sleep_perioud)
    voltage_change.set_voltage(5.0)
    measure_v_a[5.0] = max_current_test(minimal_voltage=4.45)
    measure_stability.update(stability_measure.main())
    aveliable_qc = qc_detector()
    if len(aveliable_qc) >= 2:
        set_qc_3()

    while True:
        resistor_change.set_max()
        old_voltage = voltage_measure.main()
        voltage_change.up()
        actual_voltage = voltage_measure.main()
        print(actual_voltage)
        voltage_diffrent = actual_voltage - old_voltage
        if voltage_diffrent < 0.1:
            break
        measure_stability.update(stability_measure.main())
        measure_v_a[actual_voltage] = max_current_test(actual_voltage - 0.19)

    for i in measure_v_a:
        print(measure_v_a[i])
    print(aveliable_qc)
    print(measure_stability)
    print(type)

    if type == "powerbank":
        test_resistance, max_voltage = rules_module.parametre_to_energy_test(
            measure_v_a)
        voltage_change.set_voltage(max_voltage)
        resistor_change.set_value(test_resistance)

        measure_energy(4.0)
    print(detect_max_power(measure_v_a))
示例#9
0
def check_voltage_corretly(desired_voltage, accepted_delta=values_to_rules.voltage_correctly_delta):
    actual_voltage = voltage_measure.main()
    actual_delta = actual_voltage - desired_voltage
    if abs(actual_delta) <= accepted_delta:
        return "voltage_correct"
    else:
        if actual_delta < 0:
            result = "up"
        if actual_delta > 0:
            result = "down"

    return result