import time

import numpy as np

from config.config import get_config
from .hdf5_fdi import HDF5_fdi as HDF5


cfg = get_config(validate_present=['data_folder'])
if cfg:
    log_folder=cfg['data_folder']
else:
    log_folder = "C:\\Users\mkemp\\Documents\\Python\\hdf5\\LOG_FILES\\"  # folder location

with HDF5(log_folder) as logger:

    # start a log
    logger.new_log()                # open a new file & datasets
    for n in range(50):             # data acquisition loop
        data = np.random.rand(4,1)  # read data
        logger.append_raw_motor_data(0, data)         # log it
    logger.stop()                   # close the file

    time.sleep(2)                   # some time passes ...

    # start a second log
    logger.new_log()
    for n in range(50):
        data = np.random.rand(4,1)
        logger.append_raw_motor_data(0, data)
    logger.stop()
