Add new PyQt UI

This commit is contained in:
Ayzen
2026-04-26 18:39:55 +03:00
parent c92745d2bc
commit 0ec504ffa9
33 changed files with 3284 additions and 3789 deletions

View File

@ -1,15 +1,8 @@
"""
Example: how to embed laser_control into any Python application.
Run:
python3 laser_control/example_usage.py
"""
"""Minimal examples for embedding laser_control into another Python app."""
import sys
import time
from laser_control import (
LaserController,
VariationType,
ValidationError,
CommunicationError,
)
@ -42,47 +35,6 @@ def example_manual_mode(port: str = None):
except CommunicationError as e:
print(f"Communication error: {e}")
def example_variation_mode(port: str = None):
"""Variation mode: sweep current of laser 1."""
collected = []
def on_measurement(m):
collected.append(m)
print(f" t={m.timestamp.isoformat(timespec='milliseconds')} "
f"I1={m.current1:.3f} mA T1={m.temp1:.2f} °C")
with LaserController(port=port, on_data=on_measurement) as ctrl:
try:
ctrl.start_variation(
variation_type=VariationType.CHANGE_CURRENT_LD1,
params={
'min_value': 33.0, # mA (matches firmware initial current)
'max_value': 60.0, # mA
'step': 0.05, # mA
'time_step': 50, # µs (20-100), Word 6 = time_step × 100
'delay_time': 10, # ms (3-10), Word 10 = Tau
'static_temp1': 28.0,
'static_temp2': 28.9,
'static_current1': 33.0,
'static_current2': 35.0,
}
)
print("Variation task started. Collecting data for 2 s...")
deadline = time.monotonic() + 2.0
while time.monotonic() < deadline:
ctrl.get_measurements()
time.sleep(0.15)
ctrl.stop_task()
print(f"Done. Collected {len(collected)} measurements.")
except ValidationError as e:
print(f"Parameter validation error: {e}")
except CommunicationError as e:
print(f"Communication error: {e}")
def example_embed_in_app():
"""
Minimal embedding pattern for use inside another application.
@ -105,6 +57,3 @@ if __name__ == '__main__':
print("=== Manual mode example ===")
example_manual_mode(port)
print("\n=== Variation mode example ===")
example_variation_mode(port)