new kamil adc

This commit is contained in:
Ayzen
2026-06-11 13:02:02 +03:00
parent 21f76d7cd2
commit 9661504e51
46 changed files with 12097 additions and 1063 deletions
@@ -3,6 +3,7 @@
from __future__ import annotations
from dataclasses import dataclass, field
from typing import TYPE_CHECKING
from python_app.hardware_full.switch_drivers import (
H7992Driver,
@@ -11,6 +12,9 @@ from python_app.hardware_full.switch_drivers import (
SwitchDriverProtocol,
)
if TYPE_CHECKING:
from python_app.models.run_config_schema import SwitchModel
@dataclass(slots=True)
class SwitchService:
@@ -31,6 +35,25 @@ class SwitchService:
"""Create underlying driver based on configured mode and type."""
self._driver = self._build_driver()
@classmethod
def from_model(cls, model: SwitchModel) -> SwitchService:
"""Build a switch service from a ``SwitchModel`` config section.
The single construction path shared by every acquisition producer and
capture workflow, so all devices drive switches identically.
"""
return cls(
name=model.name,
positions=model.positions,
mode=model.driver_mode,
driver=model.driver,
gpio_chip=model.gpio_chip,
pin_a=model.pin_a,
pin_b=model.pin_b,
invert_logic=model.invert_logic,
default_position=model.default_position,
)
def open(self) -> None:
"""Open underlying switch driver resources."""
self._driver.open()