|
1 | | -# Example device module |
| 1 | +# SimpleDeviceModule |
2 | 2 |
|
3 | | -Simple example that builds an openDAQ module giving access to an example device. Said device contains 2 channels, each with a value and time signal. The value signal outputs a counter signal, increasing at a rate of 1 per second. |
| 3 | +**SimpleDeviceModule** is an example module demonstrating how to build and test a simple device module using the **openDAQ framework**. |
| 4 | +This repository can serve as a template for building other modules integrated with openDAQ. |
4 | 5 |
|
5 | | -## Testing the module |
| 6 | +--- |
6 | 7 |
|
7 | | -To test the module, enable the `OPENDAQ_DEVICE_EXAMPLE_ENABLE_SERVER_APP` cmake flag. Doing so will add an openDAQ native server module to your build targets, and add an additional "server_application" executable. Running the executable will create a device, add an openDAQ server, and enable discovery. |
| 8 | +## Prerequisites |
8 | 9 |
|
9 | | -To connect to the device, the openDAQ Python GUI application can be used (Latest Python version is recommended): |
| 10 | +- **CMake** (>= 3.25) |
| 11 | +- **Git** |
| 12 | +- **C++ compiler** (Visual Studio on Windows, GCC/Clang on Linux/macOS) |
| 13 | +- Optional: **openDAQ framework** installed locally or available via versioned checkout |
10 | 14 |
|
| 15 | +--- |
| 16 | + |
| 17 | +## Building the Project |
| 18 | + |
| 19 | +There are two main ways to provide the openDAQ framework: |
| 20 | + |
| 21 | +1. **Using a local openDAQ installation** |
| 22 | + - Install the openDAQ package on your machine. |
| 23 | + - Set the environment variable `OPENDAQ_ROOT` to the path containing the binaries. |
| 24 | + - Then CMake will automatically detect the binaries during configuration. |
| 25 | + |
| 26 | +```bash |
| 27 | +export OPENDAQ_ROOT=/path/to/opendaq |
| 28 | + |
| 29 | +cmake -S . -B build/output \ |
| 30 | + -G "Ninja" \ |
| 31 | + -DEXAMPLE_MODULE_ENABLE_TESTS=ON \ |
| 32 | + -DSIMPLE_DEVICE_MODULE_OPENDAQ_SDK_VER=3.20.4 |
| 33 | +``` |
| 34 | + |
| 35 | +2. **Using a specific openDAQ version via CMake** |
| 36 | + - Pass the desired version using the `SIMPLE_DEVICE_MODULE_OPENDAQ_SDK_VER`. |
| 37 | + - CMake will perform a checkout of the openDAQ repository at the specified tag and build the minimal set of binaries needed to build the module and run tests. |
| 38 | + |
| 39 | +```bash |
| 40 | +cmake -S . -B build/output \ |
| 41 | + -G "Ninja" \ |
| 42 | + -DEXAMPLE_MODULE_ENABLE_TESTS=ON \ |
| 43 | + -DSIMPLE_DEVICE_MODULE_OPENDAQ_SDK_VER=3.20.4 |
| 44 | +``` |
| 45 | + |
| 46 | +--- |
| 47 | + |
| 48 | +### Example: Build Module |
| 49 | + |
| 50 | +```bash |
| 51 | +cmake --build build/output --config Release |
| 52 | +``` |
| 53 | + |
| 54 | +#### Note: |
| 55 | +- The flag `EXAMPLE_MODULE_ENABLE_TESTS=ON` is required if you want to build the module tests for subsequent execution. |
| 56 | +- Building the module without `EXAMPLE_MODULE_ENABLE_TESTS=ON` will skip test compilation. |
| 57 | +- Providing either `OPENDAQ_ROOT` or `SIMPLE_DEVICE_MODULE_OPENDAQ_SDK_VER` is mandatory for the module to find the required binaries. |
| 58 | + |
| 59 | +### Running Tests |
| 60 | +Once the build is complete: |
| 61 | +```bash |
| 62 | +ctest --test-dir build/output --output-on-failure -C Release -V |
11 | 63 | ``` |
12 | | -py -m pip install openDAQ |
13 | | -py -m openDAQ |
14 | | -``` |
|
0 commit comments