Define basic sensor interface
This commit is contained in:
parent
0a7ff9ef71
commit
a848ed4894
@ -15,6 +15,19 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
SensorDriver sensorDriver;
|
SensorDriver sensorDriver;
|
||||||
|
|
||||||
|
const auto sensors = sensorDriver.enumerateSensors();
|
||||||
|
|
||||||
|
for(const auto& sensor: sensors) {
|
||||||
|
const auto sensorRange = sensor.readRange();
|
||||||
|
const auto sensorValues = sensor.readValues();
|
||||||
|
|
||||||
|
qInfo("Sensor range: [%d,%d]", sensorRange.first, sensorRange.second);
|
||||||
|
|
||||||
|
for(size_t i = 0; i < sensorValues.size(); ++i) {
|
||||||
|
qInfo("Sensor value %d: %d", i, sensorValues[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QApplication application(argc, argv);
|
QApplication application(argc, argv);
|
||||||
MainWindow mainWindow;
|
MainWindow mainWindow;
|
||||||
mainWindow.show();
|
mainWindow.show();
|
||||||
|
@ -4,6 +4,26 @@
|
|||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
|
||||||
|
SensorDriver::Sensor::Sensor()
|
||||||
|
{
|
||||||
|
qDebug("Creating sensor");
|
||||||
|
}
|
||||||
|
|
||||||
|
SensorDriver::Sensor::~Sensor()
|
||||||
|
{
|
||||||
|
qDebug("Destroying sensor");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::pair<int, int> SensorDriver::Sensor::readRange() const
|
||||||
|
{
|
||||||
|
return {0, 4 * 1024 - 1};
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<int> SensorDriver::Sensor::readValues() const
|
||||||
|
{
|
||||||
|
return {520, 1233, 4233};
|
||||||
|
}
|
||||||
|
|
||||||
SensorDriver::SensorDriver()
|
SensorDriver::SensorDriver()
|
||||||
{
|
{
|
||||||
qDebug("Initializing sensor driver");
|
qDebug("Initializing sensor driver");
|
||||||
@ -36,3 +56,8 @@ SensorDriver::~SensorDriver()
|
|||||||
{
|
{
|
||||||
qDebug("Destroying sensor driver");
|
qDebug("Destroying sensor driver");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<SensorDriver::Sensor> SensorDriver::enumerateSensors() const
|
||||||
|
{
|
||||||
|
return {Sensor()};
|
||||||
|
}
|
||||||
|
@ -1,9 +1,25 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
class SensorDriver {
|
class SensorDriver {
|
||||||
|
class Sensor {
|
||||||
|
public:
|
||||||
|
Sensor();
|
||||||
|
~Sensor();
|
||||||
|
|
||||||
|
std::pair<int, int> readRange() const;
|
||||||
|
std::vector<int> readValues() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SensorDriver();
|
SensorDriver();
|
||||||
~SensorDriver();
|
~SensorDriver();
|
||||||
|
|
||||||
|
std::vector<Sensor> enumerateSensors() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user