From 50f9659f8b8bd1b0a98185bfc2da9e6217b886ca Mon Sep 17 00:00:00 2001 From: Holger Frey Date: Fri, 28 Jun 2019 10:13:37 +0200 Subject: [PATCH] Added nozzel voltage and pulse to print info --- .gitignore | 1 + s3printlog/logparser.py | 16 ++++++++++++++++ s3printlog/main.py | 5 +++-- s3printlog/report.py | 14 +++++++------- test.py | 1 + 5 files changed, 28 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 6291ee1..9f917b4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # example data example 1/ example 2/ +example 3/ example fail 1/ example fail 2/ example fail 3/ diff --git a/s3printlog/logparser.py b/s3printlog/logparser.py index 69164c7..dd525c9 100644 --- a/s3printlog/logparser.py +++ b/s3printlog/logparser.py @@ -183,3 +183,19 @@ def parse_print_log(log_files): ) environment_df = tmp_df.drop(columns=["garbage 1", "garbage 2"]) return PrintLogResult(environment_df, print_info) + + +def augment_print_info(print_log_result, drop_log_list, encoding="iso-8859-1"): + """ gets voltage and pulse from a drop log file + + Since the voltage and pulse should not change during a print run, + we add this information to the print log info + """ + one_log_file = drop_log_list[0] + with open(one_log_file, "r", encoding=encoding) as file_handle: + for line in file_handle: + if line.startswith("Nozzle Voltage"): + print_log_result.info["voltage"] = parse_log_line(line, str) + elif line.startswith("Nozzle Pulse"): + print_log_result.info["pulse"] = parse_log_line(line, str) + return print_log_result diff --git a/s3printlog/main.py b/s3printlog/main.py index 24ad756..e665d42 100644 --- a/s3printlog/main.py +++ b/s3printlog/main.py @@ -12,7 +12,7 @@ from .analysis import ( generate_environment_graph, find_missing_drops, ) -from .logparser import parse_log_files, parse_print_log +from .logparser import parse_log_files, parse_print_log, augment_print_info from .report import generate_report DROP_CHECK_SUFFIX = ".cor" @@ -72,7 +72,8 @@ def process_print_log(log_files): image_path = log_files.folder / f"{log_files.folder.name}_environment.png" plt.savefig(image_path) - return PrintLogResult(ProcessResult(print_log.environment, image_path), print_log.info) + tmp_result = PrintLogResult(ProcessResult(print_log.environment, image_path), print_log.info) + return augment_print_info(tmp_result, log_files.drop_check) def process_log_files(log_files): drop_check_result = process_drop_checks(log_files) diff --git a/s3printlog/report.py b/s3printlog/report.py index 254153f..9f7e714 100644 --- a/s3printlog/report.py +++ b/s3printlog/report.py @@ -115,23 +115,23 @@ def failed_drops_flowable(drops, missing, what): def print_info_flowable(print_info): data = [ ("Source Plate:", print_info["source"]), - ("Print Solutions:", f"{print_info['solutions']} different solutions"), + ("Print Solutions:", f"{print_info['solutions']} solutions"), ("Target Substrate:", print_info["target"]), ("Number of Fields:", f"{print_info['fields']} fields printed"), ("Run Method:", print_info["run"]), + ("Voltage:", f"{print_info['voltage']} V"), + ("Pulse:", f"{print_info['pulse']} µs"), ( "Humidity Setting:", f"{print_info['humidity']} (humidifier might be turned off)", ), ] - # Table(data, colWidths=None, rowHeights=None, style=None, splitByRow=1, - # repeatRows=0, repeatCols=0, rowSplitRange=None, spaceBefore=None, - # spaceAfter=None) return Table(data, style=[ - ('TOPPADDING', (0, 0), (-1, -1), 1), + ('TOPPADDING', (0, 0), (-1, -1), 0), ('RIGHTPADDING', (0, 0), (-1, -1), 7), - ('BOTTOMPADDING', (0, 0), (-1, -1), 1), + ('BOTTOMPADDING', (0, 0), (-1, -1), 0), ('LEFTPADDING', (0, 0), (-1, -1), 0), + ('FONTSIZE', (0, 0), (-1, -1), 8), ],hAlign='LEFT' ) @@ -158,7 +158,7 @@ def generate_report(log_files, drops, missing, environment, print_info): if len(story) == 5: # no failed drop checks where reported - story.append(Spacer(width=17 * cm, height=1 * cm)) + story.append(Spacer(width=17 * cm, height=0.5 * cm)) story.append(Paragraph("No failed drop checks found.", style_n)) story.append(PageBreak()) diff --git a/test.py b/test.py index 795c948..7a8cb11 100644 --- a/test.py +++ b/test.py @@ -5,6 +5,7 @@ from s3printlog import main folder = 'C:/Users/Holgi/Developer/python-libraries/s3printlog/example 1' #folder = "example 2" +folder = "example 3" print("Generating report, PDF should be opened in a couple of seconds") report_file = main.process_log_folder(folder)