Exemplo n.º 1
0
def loop_get_data(t0, serNums, tester, date, tstart):
    try:
        fname = 'data_{:d}_{:d}_{:d}_{:d}.csv'.format(*serNums)
        print('data logging started under file name: ' + fname)
        with open(fname, 'w+') as f:
            f.write(
                ("Burn in test for boards {:d}, {:d}, {:d}, {:d}. Tested by " +
                 tester + " beginning on " + date + " at " + tstart +
                 "\n\n").format(*serNums))
            f.write(
                "PASSED power cycle test\nPASSED channel enable/disable test.\n"
            )
            for slot in range(1, 5):
                for ch in range(1, 9):
                    tmp = lzamp.get_channel_offset(slot, ch)**2
                    if tmp > 1:
                        print('ERROR: bad offset')
                        error.set()
            f.write("PASSED pre-burn in offset test test\n")

            f.write(
                "time (s), air flow (mm/s), af temp, SC temp, B1T1, B1T2, B1T3, "
                +
                "B1T4, B2T1, B2T2, B2T3, B2T4, B3T1, B3T2, B3T3, B3T4, B4T1, B4T2, B4T3, B4T4, I+ (A), I- (A), V+, V-,\n"
            )

        write_str = '{:.4g}, '
        nn = 0
        while ((time() - t0) < (3600 * 24)) & (not event.is_set()):
            with open(fname, 'a+') as f:
                f.write(write_str.format(time() - t0))
                af = lzamp.get_airflow()
                if (af < 300):
                    nn += 1
                else:
                    nn = 0
                if nn > 5:
                    error.set()
                    print('Low Airflow')

                f.write(write_str.format(af))

                f.write(write_str.format(lzamp.get_airflow_temp()))

                t = lzamp.get_temp()
                if t > 40:
                    error.set()
                    print('SC Overheated')

                f.write(write_str.format(t))
                for ii in range(4):
                    for jj in range(4):
                        t = lzamp.get_AMP_temp(ii + 1, jj + 1)
                        if t > 50:
                            error.set()
                            print('AMP Overheated')
                        f.write(write_str.format(t))

                val = lzamp.get_current_pos()
                if (val < 2.0) | (val > 3.0):
                    error.set()
                    print("+ Current out of range")
                f.write(write_str.format(val))

                val = lzamp.get_current_neg()
                if (val < 2.0) | (val > 3.0):
                    error.set()
                    print("- Current out of range")
                f.write(write_str.format(val))

                val = lzamp.get_voltage_pos()
                if (val < 6) | (val > 10):
                    error.set()
                    print("+ Voltage out of range")
                f.write(write_str.format(val))

                val = lzamp.get_voltage_neg()
                if (val < 6) | (val > 10):
                    error.set()
                    print("- Voltage out of range")
                f.write(write_str.format(val))

                f.write('\n')

            if error.is_set():
                break
            sleep(60)

        for slot in range(1, 5):
            for ch in range(1, 9):
                tmp = lzamp.get_channel_offset(slot, ch)**2
                if tmp > 1:
                    print('ERROR: bad offset')
                    error.set()
        with open(fname, 'r') as f:
            contents = f.readlines()
        contents.insert(5, "PASSED Burn in test\n\n")
        contents.insert(5, "PASSED post-burn in offset test test\n")
        contents = "".join(contents)
        with open(fname, 'w') as f:
            f.write(contents)

        complete.set()

        print('\ndata logging stopped')
    except:
        print('data logging failed')
        error.set()
Exemplo n.º 2
0
def loop_data_logging(serNums):
    global c_pos_voltage, c_neg_voltage, c_pos_current, c_neg_current, c_air_flow, c_af_temp, c_SC_temp

    global c_AMP_temps
    c_AMP_temps = zeros((4, 4))

    global c_DC_offsets
    c_DC_offsets = zeros((4, 8))

    log_dir = '/home/debian/LZAMP/daily_logs/'
    try:
        write_str = '{:.4g}, '
        while (not end_log.is_set()):
            sleep(20)

            fname = 'data_{:d}_{:d}_{:d}_{:d}_' + c_date + '.csv'
            fname = fname.format(*serNums)
            if not isfile(log_dir + fname):
                print('\ncreating data log file\n')
                with open(log_dir + fname, 'w+') as f:
                    f.write(
                        "time (s), air flow (mm/s), af temp, SC temp, B1T1, B1T2, B1T3, "
                        +
                        "B1T4, B2T1, B2T2, B2T3, B2T4, B3T1, B3T2, B3T3, B3T4, B4T1, B4T2, B4T3, B4T4, "
                        +
                        "B1DC1, B1DC2, B1DC3, B1DC4, B1DC5, B1DC6, B1DC7, B1DC8, "
                        +
                        "B2DC1, B2DC2, B2DC3, B2DC4, B2DC5, B2DC6, B2DC7, B2DC8, "
                        +
                        "B3DC1, B3DC2, B3DC3, B3DC4, B3DC5, B3DC6, B3DC7, B3DC8, "
                        +
                        "B4DC1, B4DC2, B4DC3, B4DC4, B4DC5, B4DC6, B4DC7, B4DC8, "
                        + "I+ (A), I- (A), V+, V-, NumChEnabled,\n")
                    print('\ndata currently logging to: ' + log_dir + fname +
                          '\n')

            with open(log_dir + fname, 'a+') as f:

                c_time = localtime()
                seconds_since_midnight = int(c_time.tm_hour * 3600 +
                                             c_time.tm_min * 60 +
                                             c_time.tm_sec)
                f.write(write_str.format(seconds_since_midnight))
                sleep(0.1)

                c_air_flow = lzamp.get_airflow()
                c_af_temp = lzamp.get_airflow_temp()
                f.write(write_str.format(c_air_flow))
                f.write(write_str.format(c_af_temp))
                sleep(0.1)

                c_SC_temp = lzamp.get_temp()
                f.write(write_str.format(c_SC_temp))
                sleep(0.1)

                for ii in range(4):
                    for jj in range(4):
                        c_AMP_temps[ii][jj] = lzamp.get_AMP_temp(
                            ii + 1, jj + 1)
                        f.write(write_str.format(c_AMP_temps[ii][jj]))
                sleep(0.1)

                for ii in range(4):
                    for jj in range(8):
                        c_DC_offsets[ii][jj] = lzamp.get_channel_offset(
                            ii + 1, jj + 1)
                        f.write(write_str.format(c_DC_offsets[ii][jj]))
                sleep(0.1)

                c_pos_current = lzamp.get_current_pos()
                c_neg_current = lzamp.get_current_neg()
                f.write(write_str.format(c_pos_current))
                f.write(write_str.format(c_neg_current))
                sleep(0.1)

                c_pos_voltage = lzamp.get_voltage_pos()
                c_neg_voltage = lzamp.get_voltage_neg()
                f.write(write_str.format(c_pos_voltage))
                f.write(write_str.format(c_neg_voltage))
                sleep(0.1)

                f.write(write_str.format(c_channels_enabled))

                f.write('\n')

        print('\ndata logging ended\n')

    except (KeyboardInterrupt, SystemExit):
        raise
    except Exception:
        exception_traceback_log.exception('The following error occurred:')
        pass