dev
This commit is contained in:
parent
b547b70760
commit
ea904533ae
|
|
@ -1,32 +1,54 @@
|
|||
import time
|
||||
from datetime import datetime
|
||||
import sys
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from PyQt5.QtWidgets import QApplication
|
||||
|
||||
from src.components.os_label_printer import *
|
||||
from src.lib.helpers import ConfigReader
|
||||
|
||||
SYSTEM_ID = "test-linux"
|
||||
# Machine/config to use
|
||||
SYSTEM_ID = "st-ten-14"
|
||||
|
||||
# Serial interval and range
|
||||
START_SN = 1
|
||||
STOP_SN = 6
|
||||
TEMPLATE = "Texa30x16.prn"
|
||||
PRINTER_NAME = "zd421"
|
||||
PN = "3918423"
|
||||
STOP_SN = 295 # print 295 labels
|
||||
|
||||
# Label template and part number
|
||||
TEMPLATE = "EtichettaR5_Montaggio_1prova.prn"
|
||||
PN = "19901487000000"
|
||||
|
||||
# Fixed fields requested by user
|
||||
OPERATOR = "UTENTE 1"
|
||||
STATION = "ST-TEN-6"
|
||||
CADUTA_AMMESSA = 30 # PMIN (mbar)
|
||||
P_RILEVATA_BASE = 1819.2 # RESPSET base (mbar)
|
||||
P_RILEVATA_STEP = 10.1 # add variability of 10.1 for each label
|
||||
|
||||
config = ConfigReader(system_id=SYSTEM_ID)
|
||||
printer = Os_Label_Printer(config=config, name="label_printer")
|
||||
barcode_format = "F{SUPPLY}C{PART}D{YY}{WW}S{SN7}"
|
||||
|
||||
# Use a base time and add 1 minute for each subsequent serial
|
||||
base_time = datetime.now()
|
||||
|
||||
app = QApplication(sys.argv)
|
||||
for sn in range(START_SN, STOP_SN + 1):
|
||||
timenow = datetime.now()
|
||||
# time increases by 1 minute for each serial
|
||||
timenow = base_time + timedelta(minutes=(sn - START_SN))
|
||||
|
||||
# compute requested pressure values
|
||||
respset_val = P_RILEVATA_BASE + (sn - START_SN) * P_RILEVATA_STEP
|
||||
# caduta rilevata alternating between -0.1 and -0.2 as requested ("-01 to -02")
|
||||
resleak_val = -0.1 if (sn % 2 == 1) else -0.2
|
||||
|
||||
print(f"PRINTING LABEL # {sn}")
|
||||
context = {
|
||||
"PART": PN,
|
||||
# serials
|
||||
"SN": str(sn),
|
||||
"SN4": f"{sn:0>4}",
|
||||
"SN5": f"{sn:0>5}",
|
||||
"SN6": f"{sn:0>6}",
|
||||
"SN7": f"{sn:0>7}",
|
||||
# date/time
|
||||
"DATETIME": timenow.strftime("%d/%m/%Y %H:%M:%S"),
|
||||
"DATE": timenow.strftime("%d/%m/%Y"),
|
||||
"TIME": timenow.strftime("%H:%M:%S"),
|
||||
|
|
@ -39,11 +61,14 @@ for sn in range(START_SN, STOP_SN + 1):
|
|||
"SS": timenow.strftime("%S"),
|
||||
"JJJ": timenow.strftime("%j"),
|
||||
"WW": timenow.strftime("%W"),
|
||||
"SUPPLY": "10231",
|
||||
# fields used by the template
|
||||
"PART": PN,
|
||||
"RECIPE": "R5", # generic recipe code for barcode prefix
|
||||
"OPERATOR": OPERATOR,
|
||||
"STATION": STATION,
|
||||
"RESPSET": f"{respset_val:.1f}", # P. rilevata
|
||||
"PMIN": f"{CADUTA_AMMESSA}", # Caduta ammessa
|
||||
"RESLEAK": f"{resleak_val:.1f}", # Caduta rilevata
|
||||
}
|
||||
formatted_barcode = barcode_format.format(**context)
|
||||
context['BCODE'] = formatted_barcode
|
||||
|
||||
printer.print_label(TEMPLATE, context)
|
||||
|
||||
time.sleep(1)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user