refactor(backend): clean up package re-exports, settings model properties, and unused signals
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
"""Append live frames"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
@@ -12,17 +13,15 @@ from pygui.backend.wafer.zwafer_models import Sensor
|
||||
class CsvRecorder:
|
||||
def __init__(self) -> None:
|
||||
self._file_handle: Optional[TextIO] = None
|
||||
self._oath: Optional[str] = None
|
||||
|
||||
self._path: Optional[str] = None
|
||||
|
||||
@property
|
||||
def is_recording(self) -> bool:
|
||||
return self._file_handle is not None
|
||||
return self._file_handle is not None
|
||||
|
||||
|
||||
def start(self, path: str, sensors:list[Sensor], serial: str = "") -> None:
|
||||
def start(self, path: str, sensors: list[Sensor], serial: str = "") -> None:
|
||||
Path(path).parent.mkdir(parents=True, exist_ok=True)
|
||||
file_handle = open(path, "w", encoding="utf-8", newline ="")
|
||||
file_handle = open(path, "w", encoding="utf-8", newline="")
|
||||
file_handle.write(f"Wafer ID={serial}\n")
|
||||
file_handle.write(f"Acquisition Date={datetime.now():%m/%d/%Y}\n")
|
||||
file_handle.write("Label," + ",".join(s.label for s in sensors) + "\n")
|
||||
@@ -32,7 +31,7 @@ class CsvRecorder:
|
||||
file_handle.flush()
|
||||
self._file_handle, self._path = file_handle, path
|
||||
|
||||
def write(self, frame: Frame) -> None:
|
||||
def write(self, frame: Frame) -> None:
|
||||
if self._file_handle is None:
|
||||
return
|
||||
row = [f"{frame.time:.3f}"] + [f"{v:.3f}" for v in frame.values]
|
||||
@@ -65,21 +64,11 @@ class CsvRecorder:
|
||||
Returns:
|
||||
True on success (at least one frame written).
|
||||
"""
|
||||
from pygui.backend.data.data_records import is_official_csv
|
||||
from pygui.backend.data.data_records import is_data_row, is_official_csv
|
||||
|
||||
if start_frame < 0 or end_frame < start_frame:
|
||||
return False
|
||||
|
||||
def _is_data_row(stripped: str) -> bool:
|
||||
cols = [c.strip() for c in stripped.split(",") if c.strip()]
|
||||
if not cols:
|
||||
return False
|
||||
try:
|
||||
[float(c) for c in cols]
|
||||
except ValueError:
|
||||
return False
|
||||
return True
|
||||
|
||||
with open(source_path, "r", encoding="utf-8") as f:
|
||||
lines = f.readlines()
|
||||
|
||||
@@ -99,7 +88,7 @@ class CsvRecorder:
|
||||
# official format: row 0 is the sensor-name header
|
||||
out.append(line)
|
||||
continue
|
||||
if not stripped or not _is_data_row(stripped):
|
||||
if not stripped or not is_data_row(stripped):
|
||||
continue
|
||||
frame_idx += 1
|
||||
if start_frame <= frame_idx <= end_frame:
|
||||
@@ -112,4 +101,3 @@ class CsvRecorder:
|
||||
with open(file_path, "w", encoding="utf-8", newline="") as f:
|
||||
f.writelines(out)
|
||||
return True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user