From 8b22158d0a7483b7dc98281a6ebf13100aa0903e Mon Sep 17 00:00:00 2001 From: neo Date: Wed, 11 Sep 2024 15:52:01 +0200 Subject: [PATCH] ferrari label wip --- .../st-ten-1/ferrari_30x16_203.prn | 2 +- config/machine_settings/st-ten-1.ini | 2 +- src/components/archive_synchronizer.py | 4 +- src/scripts/print_labels.py | 39 +++++++++++++++++-- src/ui/archive/archive.py | 2 +- 5 files changed, 40 insertions(+), 9 deletions(-) diff --git a/config/label_templates/st-ten-1/ferrari_30x16_203.prn b/config/label_templates/st-ten-1/ferrari_30x16_203.prn index 8f6fbff..3ea7c0f 100644 --- a/config/label_templates/st-ten-1/ferrari_30x16_203.prn +++ b/config/label_templates/st-ten-1/ferrari_30x16_203.prn @@ -25,6 +25,6 @@ ^FH\^FDLA,{PART}{SN5}{MO}{YY}^FS ^FT237,104^A0I,23,23^FH\^CI28^FD{PART}^FS^CI27 ^FT237,46^A0I,23,23^FH\^CI28^FDN:{SN5}^FS^CI27 -^FT237,19^A0I,23,23^FH\^CI28^FD{DD}/{MM}/{YY}^FS^CI27 +^FT237,19^A0I,23,23^FH\^CI28^FD{DD}/{MO}/{YY}^FS^CI27 ^PQ1,0,1,Y ^XZ diff --git a/config/machine_settings/st-ten-1.ini b/config/machine_settings/st-ten-1.ini index 034f829..960980f 100644 --- a/config/machine_settings/st-ten-1.ini +++ b/config/machine_settings/st-ten-1.ini @@ -38,7 +38,7 @@ description_field: descrizione [label_printer] platform: windows -printer: zd420 +printer: Zebra_Technologies_ZTC_ZD421-203dpi_ZPL [recipes_defaults] tester_discharge_enable: yes diff --git a/src/components/archive_synchronizer.py b/src/components/archive_synchronizer.py index f68a693..b9ab049 100644 --- a/src/components/archive_synchronizer.py +++ b/src/components/archive_synchronizer.py @@ -108,7 +108,7 @@ class ArchiveSynchronizer(Component): "recipe": record.test_data.get("recipe", {}).get("name", None), "result": "OK" if record.result else "KO", "serial": record.id, - "time": record.time.isoformat(), + "time": record.timenow.isoformat(), "user": record.user.username, }, timeout=5, verify=False) if r.status_code != 200: @@ -132,7 +132,7 @@ class ArchiveSynchronizer(Component): if self.gcs_bucket is None: return False for path in record.test_data["vision"]["0"]["files"]: - dt = record.time + dt = record.timenow # path_in = f"{self.images_path}/{dt.strftime('%Y')}/{dt.strftime('%m')}/{os.path.basename(path)}" path_in = path path_out = f"{self.machine_id}/{dt.strftime('%Y')}/{dt.strftime('%m')}/{os.path.basename(path)}" diff --git a/src/scripts/print_labels.py b/src/scripts/print_labels.py index e7fc7af..3477fed 100644 --- a/src/scripts/print_labels.py +++ b/src/scripts/print_labels.py @@ -1,14 +1,45 @@ import time +from datetime import datetime + +from PyQt5.QtWidgets import QApplication +from fiona.model import Object from src.components.os_label_printer import * +from src.lib.helpers import ConfigReader -config={"printer":{"platform":"auto","printer":"zd421t"}} +system_id = "ST-TEN-1" -printer=Os_Label_Printer(config=config,name="printer") +config = ConfigReader(system_id=system_id) + +printer=Os_Label_Printer(config=config,name="label_printer") START_SN=1 -STOP_SN=5 - +STOP_SN=6 +timenow = datetime.now() +app = QApplication(sys.argv) for sn in range(START_SN,STOP_SN): print(f"PRINTING LABEL # {sn}") + context = { + # RECIPE DATA + "PART": "000825276", + # SERIAL DEFINITION + "SN": str(sn), + "SN4": f"{sn:0>4}", + "SN5": f"{sn:0>5}", + "SN6": f"{sn:0>6}", + # TIME DEFINITION + "DATETIME": timenow.strftime("%d/%m/%Y %H:%M:%S"), + "DATE": timenow.strftime("%d/%m/%Y"), + "TIME": timenow.strftime("%H:%M:%S"), + "YYYY": timenow.strftime("%Y"), + "YY": timenow.strftime("%y"), + "MO": timenow.strftime("%m"), + "DD": timenow.strftime("%d"), + "HH": timenow.strftime("%H"), + "MI": timenow.strftime("%M"), + "SS": timenow.strftime("%S"), + "JJJ": timenow.strftime("%j"), + } + printer.print_label("ferrari_30x16_203.prn",context) + time.sleep(1) \ No newline at end of file diff --git a/src/ui/archive/archive.py b/src/ui/archive/archive.py index cecd4d9..f0a1e6d 100755 --- a/src/ui/archive/archive.py +++ b/src/ui/archive/archive.py @@ -106,7 +106,7 @@ class Archive(Widget): for archived in list(ArchiveDbModel.select()): exportable = { # "id": archived.id, - "time": archived.time, + "time": archived.timenow, "user": archived.user, "result": archived.result, "overridden": archived.overridden,