""" Data models for laser control module. Provides dataclasses and enums for structured data representation throughout the laser control system. """ from dataclasses import dataclass from enum import IntEnum from typing import Optional, Dict, Any from datetime import datetime class VariationType(IntEnum): """Types of parameter variation modes.""" MANUAL = 0x00 CHANGE_CURRENT_LD1 = 0x01 CHANGE_CURRENT_LD2 = 0x02 CHANGE_TEMPERATURE_LD1 = 0x03 CHANGE_TEMPERATURE_LD2 = 0x04 @dataclass class Measurements: """Real-time measurements from the device.""" # Photodiode currents current1: float # Photodiode current for laser 1 (mA) current2: float # Photodiode current for laser 2 (mA) # Temperatures temp1: float # Temperature of laser 1 (°C) temp2: float # Temperature of laser 2 (°C) temp_ext1: Optional[float] = None # External thermistor 1 temperature (°C) temp_ext2: Optional[float] = None # External thermistor 2 temperature (°C) # Power supply voltages voltage_3v3: float = 0.0 # 3.3V rail voltage voltage_5v1: float = 0.0 # 5V rail 1 voltage voltage_5v2: float = 0.0 # 5V rail 2 voltage voltage_7v0: float = 0.0 # 7V rail voltage # Metadata timestamp: Optional[datetime] = None message_id: Optional[int] = None to6_counter_lsb: Optional[int] = None to6_counter_msb: Optional[int] = None def __post_init__(self): """Set timestamp if not provided.""" if self.timestamp is None: self.timestamp = datetime.now() def to_dict(self) -> Dict[str, Any]: """Convert to dictionary representation.""" return { 'current1': self.current1, 'current2': self.current2, 'temp1': self.temp1, 'temp2': self.temp2, 'temp_ext1': self.temp_ext1, 'temp_ext2': self.temp_ext2, 'voltage_3v3': self.voltage_3v3, 'voltage_5v1': self.voltage_5v1, 'voltage_5v2': self.voltage_5v2, 'voltage_7v0': self.voltage_7v0, 'timestamp': self.timestamp.isoformat() if self.timestamp else None, 'message_id': self.message_id }