new kamil adc
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user