|
|
@ -91,6 +91,16 @@ def no_progress_bar(iterator): |
|
|
|
"""" as stub function for not displaying a progress bar """ |
|
|
|
"""" as stub function for not displaying a progress bar """ |
|
|
|
return iterator |
|
|
|
return iterator |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def gui_progress_factory(settings): |
|
|
|
|
|
|
|
"""" as stub function for not displaying a progress bar """ |
|
|
|
|
|
|
|
total = settings.measurements |
|
|
|
|
|
|
|
print(f"measuring every {settings.interval.value}{settings.interval.unit} for {settings.duration.value}{settings.duration.unit}") |
|
|
|
|
|
|
|
def gui_progress(iterator): |
|
|
|
|
|
|
|
for i in iterator: |
|
|
|
|
|
|
|
print(f"measurement {i} of {total}") |
|
|
|
|
|
|
|
yield i |
|
|
|
|
|
|
|
print(f"measurement {total} of {total}") |
|
|
|
|
|
|
|
return gui_progress |
|
|
|
|
|
|
|
|
|
|
|
def _get_log_file_path(settings): |
|
|
|
def _get_log_file_path(settings): |
|
|
|
""" constructs the path to the log file """ |
|
|
|
""" constructs the path to the log file """ |
|
|
@ -102,11 +112,8 @@ def _get_log_file_path(settings): |
|
|
|
|
|
|
|
|
|
|
|
def _log_measurement_info(logger, settings): |
|
|
|
def _log_measurement_info(logger, settings): |
|
|
|
""" logs all measurement info """ |
|
|
|
""" logs all measurement info """ |
|
|
|
nr_of_measurements = 1 + ( |
|
|
|
|
|
|
|
settings.duration.seconds // settings.interval.seconds |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
measurement_info = { |
|
|
|
measurement_info = { |
|
|
|
"Measurements": nr_of_measurements, |
|
|
|
"Measurements": settings.measurements, |
|
|
|
"Duration": f"{settings.duration.value}{settings.duration.unit}", |
|
|
|
"Duration": f"{settings.duration.value}{settings.duration.unit}", |
|
|
|
"Interval": f"{settings.interval.value}{settings.interval.unit}", |
|
|
|
"Interval": f"{settings.interval.value}{settings.interval.unit}", |
|
|
|
"Com-Port": settings.port, |
|
|
|
"Com-Port": settings.port, |
|
|
@ -148,13 +155,12 @@ def measure_series(settings, progress_bar=no_progress_bar, data_logger=None): |
|
|
|
"Measured Data", [headers], append_empty_line=False |
|
|
|
"Measured Data", [headers], append_empty_line=False |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
nr_of_measurements = measurement_info["Measurements"] |
|
|
|
for i in progress_bar(range(1, settings.measurements)): |
|
|
|
for i in progress_bar(range(1, nr_of_measurements)): |
|
|
|
|
|
|
|
data = _measure_and_log(i, conn, logger) |
|
|
|
data = _measure_and_log(i, conn, logger) |
|
|
|
data_collection.append(data) |
|
|
|
data_collection.append(data) |
|
|
|
time.sleep(settings.interval.seconds) |
|
|
|
time.sleep(settings.interval.seconds) |
|
|
|
|
|
|
|
|
|
|
|
data = _measure_and_log(nr_of_measurements, conn, logger) |
|
|
|
data = _measure_and_log(settings.measurements, conn, logger) |
|
|
|
data_collection.append(data) |
|
|
|
data_collection.append(data) |
|
|
|
|
|
|
|
|
|
|
|
data_df = pandas.DataFrame(data_collection).set_index("time") |
|
|
|
data_df = pandas.DataFrame(data_collection).set_index("time") |
|
|
@ -181,11 +187,16 @@ def cli(): |
|
|
|
) |
|
|
|
) |
|
|
|
export_as_excel(result) |
|
|
|
export_as_excel(result) |
|
|
|
|
|
|
|
|
|
|
|
@Gooey(program_name="SartoriusLogger") |
|
|
|
@Gooey(program_name="SartoriusLogger", |
|
|
|
|
|
|
|
progress_regex="^measurement (?P<current>\d+) of (?P<total>\d+)", |
|
|
|
|
|
|
|
progress_expr="current / total * 100" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
) |
|
|
|
def gui(): |
|
|
|
def gui(): |
|
|
|
settings = parse_gui_arguments() |
|
|
|
settings = parse_gui_arguments() |
|
|
|
log_file_path = _get_log_file_path(settings) |
|
|
|
log_file_path = _get_log_file_path(settings) |
|
|
|
|
|
|
|
gpb = gui_progress_factory(settings) |
|
|
|
result = measure_series( |
|
|
|
result = measure_series( |
|
|
|
settings, progress_bar=tqdm, data_logger=DataLogger(log_file_path) |
|
|
|
settings, progress_bar=gpb, data_logger=DataLogger(log_file_path) |
|
|
|
) |
|
|
|
) |
|
|
|
export_as_excel(result) |
|
|
|
export_as_excel(result) |
|
|
|