62 lines
1.5 KiB
Python
62 lines
1.5 KiB
Python
from abc import ABC, abstractmethod
|
|
from typing import Callable
|
|
|
|
"""
|
|
Created on Tue Jan 21 16:19:01 2025
|
|
|
|
@author: Matthias Quintern
|
|
"""
|
|
|
|
class MeasurementDevice(ABC):
|
|
@abstractmethod
|
|
def test_connection(self) -> None:
|
|
"""
|
|
Verify that the device is still properly connected.
|
|
If not, raises ConnectionError
|
|
"""
|
|
pass
|
|
# RUN COMMANDS ON THE DEVICE
|
|
@abstractmethod
|
|
def run(self, code, verbose=False):
|
|
pass
|
|
|
|
@abstractmethod
|
|
def reset(self, verbose=False):
|
|
pass
|
|
|
|
@abstractmethod
|
|
def read_value(self) -> tuple[float, float]:
|
|
"""
|
|
Read a single value
|
|
|
|
Returns
|
|
-------
|
|
[timestamp, voltage]
|
|
"""
|
|
pass
|
|
|
|
# def measure(self, interval: int, update_func: Callable[None, [int, float, float]]|None=None, max_measurements:int|None=None):
|
|
@abstractmethod
|
|
def measureTODO():
|
|
"""
|
|
Take voltage readings after <interval> milliseconds.
|
|
|
|
Parameters
|
|
----------
|
|
interval : int
|
|
Number of milliseconds to wait between readings.
|
|
update_func : Callable[None, [int, float, float]] or None, optional
|
|
A function that is called after each reading with parameters <n_reading>, <time>, <voltage>. The default is None.
|
|
max_measurements : int or None, optional
|
|
Number of readings to perform. Set to None for infinite. The default is None.
|
|
|
|
Returns
|
|
-------
|
|
None.
|
|
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def __str__(self):
|
|
pass |