refactor: standardize codebase formatting, optimize import orders, and update GUI resolution to 1080p
This commit is contained in:
@@ -1,24 +1,25 @@
|
||||
"""Append live frames"""
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
from typing import Optional, TextIO
|
||||
|
||||
|
||||
from pygui.backend.models.frame import Frame
|
||||
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
|
||||
|
||||
|
||||
|
||||
|
||||
@property
|
||||
def is_recording(self) -> bool:
|
||||
return self._file_handle is not 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 ="")
|
||||
@@ -30,14 +31,14 @@ class CsvRecorder:
|
||||
file_handle.write("data\n")
|
||||
file_handle.flush()
|
||||
self._file_handle, self._path = file_handle, path
|
||||
|
||||
|
||||
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]
|
||||
self._file_handle.write(",".join(row) + "\n")
|
||||
self._file_handle.flush()
|
||||
|
||||
|
||||
def stop(self) -> Optional[str]:
|
||||
if self._file_handle is None:
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user