diff --git a/.gitignore b/.gitignore index 7f56f29f9788213d9279670fa2c77e0a3406952b..7bfd7fbfd74af6aa9fd8f86e6d41b13d9026db05 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ # ignore any virtual environment *venv + +# ignore pycache +*__pycache__ \ No newline at end of file diff --git a/README.md b/README.md index 5f1c9c641e0500be5d15165164a17281366dca56..306a155be088ef759858bf9c1bf125d557b87b36 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # README -# First create a python virtual environment +## First create a python virtual environment ```bash python3 -m venv demo_venv @@ -17,4 +17,11 @@ which pip $ ~/tiqi-js-tutorial/demo_venv/bin/pip which python $ ~/tiqi-js-tutorial/demo_venv/bin/python +``` + +## Create mock device class + +```bash +mkdir device +touch device/__init__.py ``` \ No newline at end of file diff --git a/device/__init__.py b/device/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..3f39f413f584813e10bc695ce16fb26d66385e13 --- /dev/null +++ b/device/__init__.py @@ -0,0 +1 @@ +from .device import Device diff --git a/device/device.py b/device/device.py new file mode 100644 index 0000000000000000000000000000000000000000..ec557c420779257d3164392a3962dcd2cba476a6 --- /dev/null +++ b/device/device.py @@ -0,0 +1,32 @@ +class Device: + __voltage = 0.0 + __current = 0.0 + + def __init__(self): + # code to connect to device + self.__voltage = 1.0 + self.__current = 0.0 + + def _get_voltage(self): + # read voltage from device + voltage = self.__voltage + return voltage + + def _set_voltage(self, new_voltage): + # write voltage to device + self.__voltage = new_voltage + + def _get_current(self): + # read current from device + current = self.__curent + return current + + def _set_current(self, new_current): + # write current to device + self.__curent = new_current + + def _calculate_resistance(self): + current = self._get_current() + voltage = self._get_voltage() + resistance = voltage / current + return resistance