Newer
Older

Zoe Pfister
committed
//
// Created by cynthya on 10/6/22.
//
#ifndef CLIENT_MEASUREMENTDATA_HPP
#define CLIENT_MEASUREMENTDATA_HPP
#include "ArduinoJson.h"

Zoe Pfister
committed
#include "SensorInformation.hpp"
#include <list>
#include <optional>
#include <string>
#include <utility>

Zoe Michaela Dietmar Pfister
committed
#include <MeasurementTypes.h>

Zoe Michaela Dietmar Pfister
committed
#include <GlobalDefinitions.hpp>
Measurement(double value, int channel, int i2cAddress, MeasurementType measurementType,
ErrorType errorType)
: value(value), measurementType(measurementType), channel(channel),
i2cAddress(i2cAddress), errorType(errorType) {
}
Measurement(double value, MeasurementType measurementType)
: value(value), measurementType(measurementType) {
channel = NO_CHANNEL;
i2cAddress = NO_I2C_ADDRESS;
errorType = ErrorType::DATA_OK;

Zoe Michaela Dietmar Pfister
committed
}
Measurement() {
value = ERROR_VALUE;
measurementType = MeasurementType::NULL_MEASUREMENT;
channel = NO_CHANNEL;
i2cAddress = NO_I2C_ADDRESS;
errorType = ErrorType::NULL_MESSAGE;
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
}
[[nodiscard]] double getValue() const { return value; }
[[nodiscard]] const MeasurementType &
getMeasurementType() const { return measurementType; }
[[nodiscard]] std::string getMeasurementTypeString() const {
return MeasurementTypes::measurementTypeToString(measurementType);
}
[[nodiscard]] const int &getChannel() const { return channel; }
[[nodiscard]] const ErrorType &getErrorType() const { return errorType; }
[[nodiscard]] std::string getErrorTypeString() const {
return ErrorTypes::errorTypeToString(errorType);
}
void setErrorType(ErrorType type) {
errorType = type;
}
[[nodiscard]] const int &
getI2CAddress() const { return i2cAddress; }
private:
double value;
MeasurementType measurementType;
ErrorType errorType;
// TODO: is it possible for a sensor to have both a channel and an i2cAddress?
int channel = NO_CHANNEL;
int i2cAddress = NO_I2C_ADDRESS;

Zoe Pfister
committed
};

Zoe Pfister
committed
#endif // CLIENT_MEASUREMENTDATA_HPP