Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
8635c7fd37
@ -9,9 +9,9 @@ exposure_time: 10000
|
||||
; vertical_crop_resolution: 2048
|
||||
; rotate_90_clockwise times: 0
|
||||
; auto_white_balance: off
|
||||
balance_red: 1.66
|
||||
balance_red: 1.85
|
||||
balance_green: 1.0
|
||||
balance_blue: 1.12
|
||||
balance_blue: 1.5
|
||||
|
||||
[vision_saver]
|
||||
time_format: %Y-%m-%d_%H-%M-%S
|
||||
@ -44,6 +44,6 @@ baudrate: 9600
|
||||
|
||||
[vision]
|
||||
detection_threshold: 0.5
|
||||
neural_network: hs3-20000
|
||||
neural_network: hs5-20000
|
||||
|
||||
; recipes_path: ./config/vision_test_recipes
|
||||
|
||||
@ -2,3 +2,4 @@
|
||||
this: this
|
||||
mino: mino
|
||||
DESKTOP-VOCOB38: vm
|
||||
ST-RES-1: stres1
|
||||
8
config/machine_settings/stres1.ini
Normal file
8
config/machine_settings/stres1.ini
Normal file
@ -0,0 +1,8 @@
|
||||
[tecna_t3]
|
||||
port: COM5
|
||||
|
||||
[neo_pixels]
|
||||
port: COM4
|
||||
baudrate: 9600
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
item {
|
||||
id: 1
|
||||
name: 'hs-ok'
|
||||
color: '0x000000'
|
||||
color: '0x55AA55'
|
||||
}
|
||||
item {
|
||||
id: 2
|
||||
|
||||
@ -22,7 +22,7 @@ instruction: CONTROLLARE PRESENZA TERMORESTRINGENTE
|
||||
[markers]
|
||||
|
||||
[zones]
|
||||
p1: 800,850 300,100 hs-ok # HEATSINK PRESENT
|
||||
p1: 1000,500 800,800 hs-ok # HEATSINK PRESENT
|
||||
|
||||
[labels]
|
||||
p1: 500,600 120 0xffffffff 0xff000000 4 TERMORESTRINGENTE
|
||||
p1: 660,1200 120 0xffffffff 0xff000000 4 TERMORESTRINGENTE
|
||||
|
||||
2
designer_win.sh
Normal file
2
designer_win.sh
Normal file
@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
venv/Lib/site-packages/qt5_applications/Qt/bin/designer
|
||||
@ -1,4 +0,0 @@
|
||||
#!/bin/bash -e
|
||||
cd "$(dirname "$0")"
|
||||
source "./venv/Scripts/activate" || source "./venv/bin/activate"
|
||||
python -O "./src/lib/charts/MultiAxisExample.py"
|
||||
@ -1,4 +0,0 @@
|
||||
#!/bin/bash -e
|
||||
cd "$(dirname "$0")"
|
||||
source "./venv/Scripts/activate" || source "./venv/bin/activate"
|
||||
python -O "./src/lifecycle.py"
|
||||
2
runme.sh
2
runme.sh
@ -1,4 +1,4 @@
|
||||
#!/bin/bash -e
|
||||
cd "$(dirname "$0")"
|
||||
source "./venv/bin/activate" || source "./venv/Scripts/activate" || :
|
||||
python -O "./src/main.py"
|
||||
python -O "./src/main.py" --no-edgetpu --no-tflite
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import sys
|
||||
import time
|
||||
import traceback
|
||||
|
||||
if "--sim-serial" in sys.argv:
|
||||
@ -16,6 +17,15 @@ C_UINT32_MAX = c_uint32(-1).value
|
||||
class NeoPixels(Component):
|
||||
def __init__(self, config=None, name=None):
|
||||
super().__init__(config=config, name=name, threaded=False)
|
||||
self.conn = serial.Serial(
|
||||
self.port,
|
||||
baudrate=self.baudrate,
|
||||
stopbits=self.stopbits,
|
||||
parity=self.parity,
|
||||
bytesize=self.bytesize,
|
||||
)
|
||||
time.sleep(5)
|
||||
self.set_all_pixel_color("#000000")
|
||||
|
||||
def config_changed(self):
|
||||
self.port = self.config[self.name]["port"]
|
||||
@ -30,18 +40,11 @@ class NeoPixels(Component):
|
||||
if not color.startswith("#") or len(color) != 7:
|
||||
raise ValueError("the color parameter must be in the html hex format: '#RRGGBB'")
|
||||
try:
|
||||
conn = serial.Serial(
|
||||
self.port,
|
||||
baudrate=self.baudrate,
|
||||
stopbits=self.stopbits,
|
||||
parity=self.parity,
|
||||
bytesize=self.bytesize,
|
||||
)
|
||||
conn.write(int.to_bytes(pixel, length=4, byteorder="big") + bytes.fromhex(color[1:7]) + b"\n")
|
||||
response = conn.readline()
|
||||
if response != "ok\n":
|
||||
self.conn.write(int.to_bytes(pixel, length=4, byteorder="big") + bytes.fromhex(color[1:7]) + b"\n")
|
||||
response = self.conn.readline()
|
||||
if response != b"ok\n":
|
||||
self.log.error(response.strip())
|
||||
conn.close()
|
||||
# conn.close()
|
||||
except serial.serialutil.SerialException:
|
||||
self.log.exception(traceback.format_exc())
|
||||
|
||||
|
||||
@ -180,7 +180,7 @@ class TecnaMarpossProvasetT3P(ModbusComponent):
|
||||
"Running test: test type",
|
||||
"Running test: sequence index",
|
||||
]}
|
||||
if info["Running test: active phase"] == "END TEST, WAITING THE START OF A NEW TEST":
|
||||
if info["Running test: active phase"] == "FINE TEST":
|
||||
info.update(self.get_test_results())
|
||||
self.log.debug(str(info))
|
||||
super()._get([info])
|
||||
|
||||
@ -7,7 +7,7 @@ registers = {
|
||||
"Life counter: TOTAL TESTS": [8 - 1, {"dt": "32bit_uint", }],
|
||||
"Real time test pressure output": [11 - 1, {"dt": "32bit_int", "f": 21, }],
|
||||
"Real time differential pressure output": [13 - 1, {"dt": "32bit_int", "f": 22, }],
|
||||
"Real time pressure line regulator": [15 - 1, {"dt": "16bit_int", "f": 23, }],
|
||||
"Real time pressure line regulator": [15 - 1, {"dt": "16bit_int", "f": 23,"g":0.1 }],
|
||||
"Active alarm flags": [16 - 1, {"dt": "16bit_uint", }],
|
||||
# | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|
||||
# | | | | A5 | A4 | A3 | A2 | A1 | | | | | | E3 | E2 | E1 |
|
||||
@ -28,9 +28,9 @@ registers = {
|
||||
"Running test: flow rate format": [27 - 1, {"dt": "16bit_uint", }], # white
|
||||
"Active test program number": [31 - 1, {"dt": "16bit_uint", }],
|
||||
"Running test: active phase": [32 - 1, {"dt": "16bit_uint", "decoding": {
|
||||
0: "WAITING START",
|
||||
10: "CHECK BARCODE",
|
||||
20: "WAITING BARCODE",
|
||||
0: "ATTESA START",
|
||||
10: "CONTROLLO BARCODE",
|
||||
20: "ATTESA BARCODE",
|
||||
30: "START TEST",
|
||||
40: "START CAGE",
|
||||
50: "START PLUG",
|
||||
@ -38,10 +38,10 @@ registers = {
|
||||
70: "WAIT DELAY ACKNOWLEDGE COMMAND",
|
||||
80: "WAIT DELAY",
|
||||
90: "WAIT ACKNOWLEDGE",
|
||||
100: "T0 PRE-FILL",
|
||||
110: "T1 FILLING",
|
||||
120: "T2 SETTLING",
|
||||
130: "T3 MEASURE",
|
||||
100: "T0 PRE-RIEMPIMENTO",
|
||||
110: "T1 RIEMPIMENTO",
|
||||
120: "T2 ASSESTAMENTO",
|
||||
130: "T3 MISURA",
|
||||
140: "WAITING OPERATOR RESULT ACKNOWLEDGE",
|
||||
150: "RESULT PRESENT",
|
||||
160: "MARKING",
|
||||
@ -49,7 +49,7 @@ registers = {
|
||||
180: "END SEQUENCE PROGRAM",
|
||||
190: "END PLUG",
|
||||
200: "END CAGE",
|
||||
210: "END TEST, WAITING THE START OF A NEW TEST",
|
||||
210: "FINE TEST",
|
||||
}, }],
|
||||
"Running test: phase backwards time": [33 - 1, {"dt": "16bit_uint", "f": 26, }],
|
||||
"Running test: filling pressure": [34 - 1, {"dt": "32bit_int", "f": 21, }],
|
||||
|
||||
@ -318,6 +318,7 @@ class Vision(Component):
|
||||
try:
|
||||
# create tensorflow model
|
||||
model = tf.saved_model.load(str(self.models_dir / model_name))
|
||||
model = model.signatures['serving_default']
|
||||
tf_mode = "normal"
|
||||
except Exception:
|
||||
self.log.exception(traceback.format_exc())
|
||||
@ -385,12 +386,15 @@ class Vision(Component):
|
||||
if lock:
|
||||
self.lock.unlock()
|
||||
detections = {
|
||||
"detection_scores": [scores],
|
||||
"detection_boxes": [boxes],
|
||||
"detection_classes": [map(lambda class_id: class_id + 1, class_ids)],
|
||||
"detection_scores": [scores][0:1],
|
||||
"detection_boxes": [boxes][0:1],
|
||||
"detection_classes": [map(lambda class_id: class_id + 1, class_ids)][0:1],
|
||||
}
|
||||
else:
|
||||
detections = self.model(tensor)
|
||||
input_tensor = tf.convert_to_tensor(np.asarray(tensor))
|
||||
#input_tensor = input_tensor[tf.newaxis, ...]
|
||||
|
||||
detections = self.model(input_tensor)
|
||||
if lock:
|
||||
self.lock.unlock()
|
||||
# WARNING: results other than the ones related to tensor[-1] will be discarded
|
||||
|
||||
@ -2,8 +2,11 @@ import time
|
||||
|
||||
import serial
|
||||
|
||||
#tester_port="/dev/ttyUSB0"
|
||||
tester_port="COM1"
|
||||
|
||||
conn = serial.Serial(
|
||||
"/dev/ttyUSB0",
|
||||
tester_port,
|
||||
baudrate=115200,
|
||||
stopbits=serial.STOPBITS_ONE,
|
||||
parity=serial.PARITY_NONE,
|
||||
|
||||
@ -1,17 +1,21 @@
|
||||
import time
|
||||
from ctypes import c_uint32
|
||||
|
||||
import serial
|
||||
|
||||
C_UINT32_MAX = c_uint32(-1).value
|
||||
conn = serial.Serial(
|
||||
"/dev/ttyACM1",
|
||||
"COM4",
|
||||
baudrate=9600,
|
||||
stopbits=serial.STOPBITS_ONE,
|
||||
parity=serial.PARITY_NONE,
|
||||
bytesize=serial.EIGHTBITS,
|
||||
rtscts=False,
|
||||
xonxoff=False
|
||||
)
|
||||
pixel = C_UINT32_MAX
|
||||
color = "#ff00ff"
|
||||
time.sleep(5)
|
||||
color = "#000000"
|
||||
conn.write(int.to_bytes(pixel, length=4, byteorder="big") + bytes.fromhex(color[1:7]) + b"\n")
|
||||
response = conn.readline()
|
||||
print(response)
|
||||
|
||||
@ -44,7 +44,7 @@ class Test(Widget):
|
||||
"done": Test_Assembly(self.select_step_img("success"), u"COLLAUDO COMPLETATO"),
|
||||
"emergency": Test_Assembly(self.select_step_img("reset_emergency"), u"EMERGENZA INTERVENUTA - RIPRISTINARE PULSANTE E SELEZIONARE \"RESET EMERGENZA\" DAL MEN\u00d9 \"STRUMENTI\""),
|
||||
"fail": Test_Assembly(self.select_step_img("fail"), u"CICLO INTERROTTO"),
|
||||
"leak": Test_Assembly(None, u"PREMERE START PER COMINCIARE LA PROVA TENUTA E ATTENDERE IL SUO COMPLETAMENTO", Test_Leak(components=self.components, recipe=self.recipe, step=self.step)),
|
||||
"leak": Test_Assembly(None, u"PREMERE START PER INIZIARE LA PROVA TENUTA", Test_Leak(components=self.components, recipe=self.recipe, step=self.step)),
|
||||
"print": Test_Assembly(self.select_step_img("print"), u"STAMPA ETICHETTA IN CORSO"),
|
||||
"select_recipe": Test_Assembly(None, u"SELEZIONARE IL CODICE DA COLLAUDARE", Recipe_Selection()),
|
||||
"vision": Test_Assembly(None, u"VERIFICARE CONTROLLO CON TELECAMERA", Test_Vision(components=self.components, recipe=self.recipe, step=self.step)),
|
||||
@ -270,6 +270,8 @@ class Test(Widget):
|
||||
|
||||
def done(self, ok=True):
|
||||
self.log.info("cycle done")
|
||||
self.data["vision"][0].pop("detections")
|
||||
self.data["vision"][0].pop("results")
|
||||
archived = Archive.archive(self.recipe, self.data, ok and self.data["ok"], overridden=self.data["overridden"])
|
||||
self.log.info(f"cycle archived locally: {archived!r}")
|
||||
# COUNT OK
|
||||
@ -279,17 +281,22 @@ class Test(Widget):
|
||||
def print(self, archived=None):
|
||||
self.log.info("cycle print")
|
||||
# LABEL PRINT
|
||||
datamatrix= archived.recipe.part_number+ archived.time.strftime("%m%y")+f"{archived.id:0>5}"
|
||||
dt_label=archived.time.strftime("%d/%m/%Y %H:%M:%S")
|
||||
pmax = self.data.get("leak", [{}, {}])[0].get("step", {}).get("spec", {}).get("test_pressure", "-")
|
||||
pmin=self.data.get("leak", [{}, {}])[0].get("results", {}).get("data", {}).get("Running test: pressure at the end of settling", "-")
|
||||
leak=self.data.get("leak", [{}, {}])[0].get("results", {}).get("data", {}).get("Running test: measured leak", "-")
|
||||
context = {
|
||||
"DATAMATRIX": str(self.data.get("barcodes", {}).get("serial", "")),
|
||||
"DATAMATRIX_TEXT": str(self.data.get("barcodes", {}).get("serial", "-")),
|
||||
"PIECE_NUM": str(self.data.get("barcodes", {}).get("serial", "-")),
|
||||
"DATETIME": str(archived.time.isoformat()),
|
||||
"DATAMATRIX": datamatrix,
|
||||
"DATAMATRIX_TEXT": datamatrix,
|
||||
"PIECE_NUM": str(archived.id),
|
||||
"DATETIME": dt_label,
|
||||
"SHIFT": str(get_shift(archived.time)),
|
||||
"STATION": str(self.machine_id),
|
||||
"OPERATOR": str(Users.get_session().user.username),
|
||||
"PMAX": str(self.data.get("leak", [{}, {}])[0].get("step", {}).get("spec", {}).get("test_pressure", "-")),
|
||||
"PMIN": str(self.data.get("leak", [{}, {}])[0].get("results", {}).get("data", {}).get("Running test: pressure at the end of settling", "-")),
|
||||
"LEAK": str(self.data.get("leak", [{}, {}])[0].get("results", {}).get("data", {}).get("Running test: measured leak", "-")),
|
||||
"PMAX": f"{pmax:.3f}",
|
||||
"PMIN": f"{pmin:.3f}",
|
||||
"LEAK": f"{leak:.3f}",
|
||||
"TFILL": str(self.data.get("leak", [{}, {}])[0].get("step", {}).get("spec", {}).get("filling_time", "-")),
|
||||
"TSTAB": str(self.data.get("leak", [{}, {}])[0].get("step", {}).get("spec", {}).get("settling_time", "-")),
|
||||
"TTEST": str(self.data.get("leak", [{}, {}])[0].get("step", {}).get("spec", {}).get("test_time", "-")),
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,9 +1,18 @@
|
||||
import os
|
||||
import sys
|
||||
from datetime import datetime
|
||||
|
||||
import cv2
|
||||
from PyQt5.QtCore import pyqtSignal
|
||||
from PyQt5.QtGui import QImage, QPixmap
|
||||
from ui.test_test import Test_Test
|
||||
|
||||
TMP_DIR = "tmp"
|
||||
ARCHIVE_DIR = "data/vision_saves"
|
||||
INFERENCE_INPUT_W = 256
|
||||
INFERENCE_INPUT_H = 256
|
||||
|
||||
|
||||
|
||||
class Test_Vision(Test_Test):
|
||||
request_frame = pyqtSignal()
|
||||
@ -27,6 +36,7 @@ class Test_Vision(Test_Test):
|
||||
self.components["vision"].resume()
|
||||
self.components["galaxy_camera"].resume()
|
||||
self.request_frame.emit() # request first frame
|
||||
self.save_b.clicked.connect(lambda: self.save_frame_all(position="tmp"))
|
||||
|
||||
def stop(self):
|
||||
# disable camera-vision loop
|
||||
@ -98,3 +108,26 @@ class Test_Vision(Test_Test):
|
||||
self.last.pop("render", None)
|
||||
super().emit_ko()
|
||||
self.components["neo_pixels"].set_all_pixel_color("#000000")
|
||||
|
||||
def save_frame_detection(self, position=None, date=None):
|
||||
if date is None:
|
||||
date = datetime.now()
|
||||
if position == "archive":
|
||||
save_dir = ARCHIVE_DIR
|
||||
elif position == "tmp":
|
||||
save_dir = TMP_DIR
|
||||
elif position is None:
|
||||
save_dir = self.config["image saver"]["location"]
|
||||
else:
|
||||
save_dir = position
|
||||
save_dir += "/img_archive"
|
||||
save_dir += f"/{date.strftime('%Y')}/{date.strftime('%m')}"
|
||||
self.remove_older_images_if_needed()
|
||||
if not os.path.exists(save_dir):
|
||||
os.makedirs(save_dir, exist_ok=True)
|
||||
filename = f"{save_dir}/{date.strftime('%Y-%m-%d_%H_%M_%S')}_{self.config['image saver']['suffix']}.png"
|
||||
print(f"saving {filename}")
|
||||
image_np_bgr = cv2.cvtColor(self.detection_image, cv2.COLOR_RGB2BGR)
|
||||
cv2.imwrite(filename, image_np_bgr)
|
||||
return filename
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user