Merge remote-tracking branch 'origin/master'

This commit is contained in:
edo-neo 2024-12-09 15:37:25 +01:00
commit bda17a5452
46 changed files with 181 additions and 30 deletions

Binary file not shown.

View File

@ -0,0 +1,45 @@
CT~~CD,~CC^~CT~
^XA
~TA000
~JSN
^LT0
^MNW
^MTT
^PON
^PMN
^LH0,0
^JMA
^PR2,2
~SD22
^JUS
^LRN
^CI27
^PA0,1,1,0
^XZ
^XA
^MMT
^PW320
^LL1119
^LS0
^FT57,105^A0N,39,38^FH\^CI28^FDERRECINQUE^FS^CI27
^FT58,148^A0N,20,20^FH\^CI28^FDVia Meucci 31/A^FS^CI27
^FT58,173^A0N,20,20^FH\^CI28^FD10079 Mappano(TO)^FS^CI27
^FT18,758^A0N,23,20^FH\^CI28^FD{DD}/{MO}/{YY}^FS^CI27
^FT183,758^A0N,23,20^FH\^CI28^FD{HH}:{MI}:{SS}^FS^CI27
^FT18,981^A0N,31,30^FH\^CI28^FDESITO:^FS^CI27
^FT144,981^A0N,31,30^FH\^CI28^FDCONFORME^FS^CI27
^FT24,471^A0N,25,25^FH\^CI28^FDPart number:^FS^CI27
^FT24,513^A0N,23,23^FH\^CI28^FD{PART}^FS^CI27
^FT24,555^A0N,25,25^FH\^CI28^FDSequential number:^FS^CI27
^FT24,598^A0N,23,23^FH\^CI28^FD{SN4}^FS^CI27
^FT18,833^A0N,23,23^FH\^CI28^FDOperatore:^FS^CI27
^FT157,674^A0N,23,23^FH\^CI28^FD{RESLEAK} mbar^FS^CI27
^FT18,674^A0N,23,23^FH\^CI28^FD{TTEST} s^FS^CI27
^FT18,724^A0N,23,23^FH\^CI28^FD{PTEST} mbar^FS^CI27
^BY1,3,64^FT58,384^BCN,,N,N
^FH\^FD>:{PART}^FS
^FT58,241^A0N,25,25^FH\^CI28^FD{DESCRIPTION}^FS^CI27
^FT58,292^A0N,45,46^FH\^CI28^FDLEAK TEST^FS^CI27
^FT165,833^A0N,23,23^FH\^CI28^FD{BADGE_NUM}^FS^CI27
^PQ1,0,1,Y
^XZ

View File

@ -0,0 +1,46 @@
CT~~CD,~CC^~CT~
^XA
~TA000
~JSN
^LT0
^MNW
^MTT
^PON
^PMN
^LH0,0
^JMA
^PR2,2
~SD26
^JUS
^LRN
^CI27
^PA0,1,1,0
^XZ
^XA
^MMT
^PW320
^LL1119
^LS0
^FT57,105^A0N,39,38^FH\^CI28^FDERRECINQUE^FS^CI27
^FT58,148^A0N,20,20^FH\^CI28^FDVia Meucci 31/A^FS^CI27
^FT58,173^A0N,20,20^FH\^CI28^FD10079 Mappano(TO)^FS^CI27
^FT18,758^A0N,23,20^FH\^CI28^FD{DD}/{MO}/{YY}^FS^CI27
^FT183,758^A0N,23,20^FH\^CI28^FD{HH}:{MI}:{SS}^FS^CI27
^FT18,981^A0N,31,30^FH\^CI28^FDESITO:^FS^CI27
^FT144,981^A0N,31,30^FH\^CI28^FDCONFORME^FS^CI27
^FT24,439^A0N,25,25^FH\^CI28^FDPart number:^FS^CI27
^FT24,481^A0N,23,23^FH\^CI28^FD{LABELTXT_2}^FS^CI27
^FT24,555^A0N,25,25^FH\^CI28^FDSequential number:^FS^CI27
^FT24,598^A0N,23,23^FH\^CI28^FD{SN4}^FS^CI27
^FT18,833^A0N,23,23^FH\^CI28^FDOperatore:^FS^CI27
^FT157,674^A0N,23,23^FH\^CI28^FD{RESLEAK} mbar^FS^CI27
^FT18,674^A0N,23,23^FH\^CI28^FD{TTEST} s^FS^CI27
^FT18,724^A0N,23,23^FH\^CI28^FD{PTEST} mbar^FS^CI27
^BY1,3,64^FT25,384^BCN,,N,N
^FH\^FD>:{PART}^FS
^FT58,241^A0N,25,25^FH\^CI28^FD{LABELTXT_1}^FS^CI27
^FT58,292^A0N,45,46^FH\^CI28^FDLEAK TEST^FS^CI27
^FT165,833^A0N,23,23^FH\^CI28^FD{BADGE_NUM}^FS^CI27
^FT24,512^A0N,23,23^FH\^CI28^FD{LABELTXT_3}^FS^CI27
^PQ1,0,1,Y
^XZ

View File

@ -56,18 +56,20 @@ status_root:api/device-info-update/
download_root:media/uploads/
images_path: data/images
poll_time: 60
hold_time: 30
poll_time: 10
hold_time: 10
service_account_json: config/machine_settings/gcloud_default.json
bucket_id: st_ten_img
[archive_synchronizer_extra]
archive_endpoint: https://r5portal.it/api/st-ten-save/
portal_address: https://r5portal.it/
archive_root:api/st-ten-save/
status_root:api/device-info-update/
download_root:media/uploads/
archive_endpoint: http://172.20.3.13/api/st-ten-save/
images_path: data/images
poll_time: 60
hold_time: 30
service_account_json: config/machine_settings/gcloud_default.json
bucket_id: st_ten_img
poll_time: 10
hold_time: 10
[label_printer]
platform: windows

View File

@ -5,6 +5,7 @@ image_for_warning= st-ten-1
[hardware_config]
archive_synchronizer: present
archive_synchronizer_extra: present
galaxy_camera: absent
uvc_camera: absent
label_printer: present
@ -18,6 +19,12 @@ screwdriver: absent
digital_io: present
external_flush_blow: absent
# VERO PROJECT LOCAL SERVER
[archive_synchronizer_extra]
portal_address: http://172.20.3.13:45006/
poll_time: 10
hold_time: 10
[tecna_t3]
port: COM4
model: t3l

View File

@ -5,6 +5,7 @@ image_for_warning= st-ten-14
[hardware_config]
archive_synchronizer: present
archive_synchronizer_extra: present
uvc_camera: absent
label_printer: present
neo_pixels: absent
@ -19,13 +20,19 @@ fixture_id: absent
discard_box: absent
enforce_piece_removal: no
# VERO PROJECT LOCAL SERVER
[archive_synchronizer_extra]
portal_address: http://172.20.3.13:45007/
poll_time: 10
hold_time: 10
[tecna_t3]
port: /dev/ttyUSB0
model: t3l
[label_printer]
platform: linux
printer: ZTC-ZD421-203dpi-ZPL
printer: Zebra_Technologies_ZTC_ZD421-203dpi_ZPL
[digital_io]
# OUTPUT MAP FOR FIXTURE CONNECTOR

View File

@ -2,8 +2,10 @@
description = ST-TEN-4 - REPARTO PREFORMATURA - MAPPANO
instruction_folder = st-ten-4
image_for_warning= st-ten-4
[hardware_config]
archive_synchronizer: present
archive_synchronizer_extra: present
uvc_camera: absent
label_printer: present
neo_pixels: absent
@ -13,6 +15,12 @@ vision_saver: absent
vision: absent
screwdriver: absent
# VERO PROJECT LOCAL SERVER
[archive_synchronizer_extra]
portal_address: http://172.20.3.13:45008/
poll_time: 10
hold_time: 10
[tecna_t3]
port: COM4
model: t3p

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View File

@ -46,10 +46,11 @@ class ArchiveSynchronizer(Component):
self._do_set_period({"period": float(self.config[self.name]["poll_time"])})
self.hold_time = round(float(self.config[self.name]["hold_time"]) * 1000)
self.gcs_client = storage.Client.from_service_account_json(self.config[self.name]["service_account_json"])
self.gcs_client._http.mount("", HTTPAdapter(max_retries=Retry(total=0))) # this seems to be useless
self.gcs_client._http.adapters.move_to_end("", last=False) # this seems to be useless
self.bucket_id = self.config[self.name]["bucket_id"]
if self.name == "archive_synchronizer":
self.gcs_client = storage.Client.from_service_account_json(self.config[self.name]["service_account_json"])
self.gcs_client._http.mount("", HTTPAdapter(max_retries=Retry(total=0))) # this seems to be useless
self.gcs_client._http.adapters.move_to_end("", last=False) # this seems to be useless
self.bucket_id = self.config[self.name]["bucket_id"]
self.gcs_bucket = None
@db.connection_context()
@ -57,16 +58,36 @@ class ArchiveSynchronizer(Component):
if self.main_window is None:
self.main_window = get_main_window()
for record in list(Archive.select().where((Archive.archived != True) | (Archive.uploaded != True))): # using "is not True" breaks the query.. # list() forces the complete execution of the query unlocking the db unlike __enter__()
if self.name != "archive_synchronizer_extra":
# MAIN SERVER
bit_pos = 0
unsaved_records = Archive.select().where((Archive.archived == 0) |
(Archive.archived == 2) |
(Archive.uploaded == 0))
else:
# EXTRA SERVER (VERO PROJECT SPA)
bit_pos = 1
unsaved_records = Archive.select().where((Archive.archived == 0) |
(Archive.archived == 1))
for record in unsaved_records:
if not self.simulate:
if record.archived is not True:
record.archived = self.remote_archive(record) is True
s = time.time()
save_ok = self.remote_archive(record) is True
e = time.time()
else:
save_ok=True
if record.uploaded is not True:
record.uploaded = self.remote_store(record) is True
else:
self.log.info("simulated archive synchronizer cycle")
#record.save()
save_ok=True
if save_ok:
record.archived |= (1 << bit_pos)
self.log.info(f"({self.name}) id {record.id}: archived remotely")
else:
self.log.info(f"({self.name}) id {record.id}: failed to archive remotely")
self.main_window.run_request.emit(record.save, [], {})
if self.hold_time > 0:
@ -77,7 +98,9 @@ class ArchiveSynchronizer(Component):
self.machine_status="working"
super()._get()
self.update_machine_status()
if self.name == "archive_synchronizer":
self.update_machine_status()
def update_machine_status(self):
status_call = f"{self.status_endpoint}?machine-id={self.machine_id.upper()}&status={self.machine_status}"
@ -141,16 +164,28 @@ class ArchiveSynchronizer(Component):
if not self.simulate:
with requests.Session() as s:
s.mount("", HTTPAdapter(max_retries=Retry(total=0))) # this disables retries
r = requests.post(self.archive_endpoint, params={
"data": json.dumps(record.test_data),
"machine_id": self.machine_id,
"overridden": record.overridden,
"recipe": record.test_data.get("recipe", {}).get("name", None),
"result": "OK" if record.result else "KO",
"serial": record.id,
"time": record.time.isoformat(),
"user": record.user.username,
}, timeout=5, verify=False)
if self.name == "archive_synchronizer":
r = requests.post(self.archive_endpoint, params={
"data": json.dumps(record.test_data),
"machine_id": self.machine_id,
"overridden": record.overridden,
"recipe": record.test_data.get("recipe", {}).get("name", None),
"result": "OK" if record.result else "KO",
"serial": record.id,
"time": record.time.isoformat(),
"user": record.user.username,
}, timeout=5, verify=False)
else:
r = requests.get(self.archive_endpoint, params={
"machine_id": self.machine_id,
"overridden": record.overridden,
"recipe": record.test_data.get("recipe", {}).get("name", None),
"result": "OK" if record.result else "KO",
"serial": record.id,
"time": record.time.isoformat(),
"user": record.user.username,
}, timeout=5, verify=False)
if r.status_code != 200:
raise AssertionError("bad status response")
except AssertionError as e:

View File

@ -1,7 +1,7 @@
from datetime import datetime
from peewee import (AutoField, BooleanField, DateTimeField, ForeignKeyField,
TextField)
TextField, IntegerField)
from playhouse.sqlite_ext import JSONField
from .base_model import BaseModel, db
@ -16,7 +16,7 @@ class Archive(BaseModel):
overridden = BooleanField(null=False)
test_data = JSONField(null=False)
label = TextField(null=True)
archived = BooleanField(null=False, default=False)
archived = IntegerField(null=False, default=False)
uploaded = BooleanField(null=False, default=False)
@classmethod

View File

@ -101,6 +101,7 @@ try:
# INIT COMPONENT
self.components_specs = {
"archive_synchronizer": {"c": ArchiveSynchronizer},
"archive_synchronizer_extra": {"c": ArchiveSynchronizer},
"label_printer": {"c": Os_Label_Printer, "t": False},
"extra_label_printer": {"c": Os_Label_Printer, "t": False},
"label_printer_2": {"c": BrotherLabelPrinter, "t": False},

View File

@ -370,7 +370,7 @@ class Test(Widget):
self.archived.label = compiled_label
self.log.info(f"Label printed. Saving...")
#self.archived.save()
self.main_window.run_request.emit(self.archived.save, [], {})
self.main_window.main_window.run_request.emit(self.archived.save, [], {})
self.next_timer.start(500)
elif self.step.step_type == "wait":
self.next_timer.start(500)