From 47873fc9a211f0f74e7f3f312abdf6f21c7b2f91 Mon Sep 17 00:00:00 2001 From: Eddy Pedroni Date: Tue, 24 May 2022 13:17:04 +0200 Subject: Added gitignore, restructured repo, added initial tests --- .gitignore | 1 + lab_control/__init__.py | 3 +++ lab_control/function_generator.py | 23 +++++++++++++++++++++++ lab_control/oscilloscope.py | 17 +++++++++++++++++ lab_control/test/__init__.py | 0 lab_control/test/interfaces_test.py | 11 +++++++++++ src/lab-control/function_generator.py | 23 ----------------------- src/lab-control/oscilloscope.py | 17 ----------------- 8 files changed, 55 insertions(+), 40 deletions(-) create mode 100644 .gitignore create mode 100644 lab_control/__init__.py create mode 100644 lab_control/function_generator.py create mode 100644 lab_control/oscilloscope.py create mode 100644 lab_control/test/__init__.py create mode 100644 lab_control/test/interfaces_test.py delete mode 100644 src/lab-control/function_generator.py delete mode 100644 src/lab-control/oscilloscope.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..eeb8a6e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +**/__pycache__ diff --git a/lab_control/__init__.py b/lab_control/__init__.py new file mode 100644 index 0000000..b8c59c6 --- /dev/null +++ b/lab_control/__init__.py @@ -0,0 +1,3 @@ +#from os.path import dirname, abspath + +#ROOT_DIR = dirname(abspath(__file__)) diff --git a/lab_control/function_generator.py b/lab_control/function_generator.py new file mode 100644 index 0000000..b7b5266 --- /dev/null +++ b/lab_control/function_generator.py @@ -0,0 +1,23 @@ +class FunctionGenerator: + FUNCTION_SINE = 0 + FUNCTION_SQUARE = 1 + FUNCTION_SAWTOOTH = 2 + + def __init__(self): + raise Exception("This class should not be instantiated directly, please extend it instead") + + def setOn(self, channel: int) -> None: + pass + + def setOff(self, channel: int) -> None: + pass + + def setFrequency(self, channel: int, frequency: float) -> None: + pass + + def setAmplitude(self, channel: int, amplitude: float) -> None: + pass + + def setFunction(self, channel: int, function: int) -> None: + pass + diff --git a/lab_control/oscilloscope.py b/lab_control/oscilloscope.py new file mode 100644 index 0000000..a09f8a0 --- /dev/null +++ b/lab_control/oscilloscope.py @@ -0,0 +1,17 @@ +class Oscilloscope: + def __init__(self): + raise Exception("This class should not be instantiated directly, please extend it instead") + + def measureAmplitude(self, channel: int) -> float: + pass + + def measurePkToPk(self, channel: int) -> float: + pass + + def measureRMS(self, channel: int) -> float: + pass + + def measureFrequency(self, channel: int) -> float: + pass + + diff --git a/lab_control/test/__init__.py b/lab_control/test/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/lab_control/test/interfaces_test.py b/lab_control/test/interfaces_test.py new file mode 100644 index 0000000..bf9006b --- /dev/null +++ b/lab_control/test/interfaces_test.py @@ -0,0 +1,11 @@ +import pytest +from lab_control.oscilloscope import Oscilloscope +from lab_control.function_generator import FunctionGenerator + +def test_oscilloscopeInterface(): + with pytest.raises(Exception): + uut = Oscilloscope() + +def test_functionGeneratorInterface(): + with pytest.raises(Exception): + uut = FunctionGenerator() diff --git a/src/lab-control/function_generator.py b/src/lab-control/function_generator.py deleted file mode 100644 index b7b5266..0000000 --- a/src/lab-control/function_generator.py +++ /dev/null @@ -1,23 +0,0 @@ -class FunctionGenerator: - FUNCTION_SINE = 0 - FUNCTION_SQUARE = 1 - FUNCTION_SAWTOOTH = 2 - - def __init__(self): - raise Exception("This class should not be instantiated directly, please extend it instead") - - def setOn(self, channel: int) -> None: - pass - - def setOff(self, channel: int) -> None: - pass - - def setFrequency(self, channel: int, frequency: float) -> None: - pass - - def setAmplitude(self, channel: int, amplitude: float) -> None: - pass - - def setFunction(self, channel: int, function: int) -> None: - pass - diff --git a/src/lab-control/oscilloscope.py b/src/lab-control/oscilloscope.py deleted file mode 100644 index a09f8a0..0000000 --- a/src/lab-control/oscilloscope.py +++ /dev/null @@ -1,17 +0,0 @@ -class Oscilloscope: - def __init__(self): - raise Exception("This class should not be instantiated directly, please extend it instead") - - def measureAmplitude(self, channel: int) -> float: - pass - - def measurePkToPk(self, channel: int) -> float: - pass - - def measureRMS(self, channel: int) -> float: - pass - - def measureFrequency(self, channel: int) -> float: - pass - - -- cgit v1.2.3