roo_transceivers
API Documentation for roo_transceivers
Loading...
Searching...
No Matches
measurement.h
Go to the documentation of this file.
1#pragma once
2
3#include <cmath>
4
5#include "roo_time.h"
7
8namespace roo_transceivers {
9
10/// Measurement of a quantity at a specific time.
12 public:
17
18 /// Returns true if this is the initial/empty measurement.
19 bool isInitial() const { return (isnanf(value_) && time_micros_ == 0); }
20
21 /// Returns true if quantity and value are defined.
22 bool isDefined() const {
24 !isnanf(value_));
25 }
26
28 float value = nanf(""))
30 time_micros_(time.inMicros() < (1LL << 52) ? time.inMicros()
31 : ((1LL << 52) - 1)),
32 value_(value) {}
33
34 /// Returns the quantity type.
36
37 /// Returns the measurement timestamp.
38 roo_time::Uptime time() const {
39 return roo_time::Uptime::Start() + roo_time::Micros(time_micros_);
40 }
41
42 /// Returns the measurement value.
43 float value() const { return value_; }
44
45 /// Returns true if value is unknown (NaN).
46 bool isUnknown() const { return isnanf(value_); }
47
48 private:
49 struct {
51 uint64_t time_micros_ : 52;
52 };
53 float value_;
54};
55
56} // namespace roo_transceivers
Measurement of a quantity at a specific time.
Definition measurement.h:11
bool isDefined() const
Returns true if quantity and value are defined.
Definition measurement.h:22
float value() const
Returns the measurement value.
Definition measurement.h:43
bool isInitial() const
Returns true if this is the initial/empty measurement.
Definition measurement.h:19
bool isUnknown() const
Returns true if value is unknown (NaN).
Definition measurement.h:46
roo_time::Uptime time() const
Returns the measurement timestamp.
Definition measurement.h:38
roo_transceivers_Quantity quantity() const
Returns the quantity type.
Definition measurement.h:35
Measurement(roo_transceivers_Quantity quantity, roo_time::Uptime time, float value=nanf(""))
Definition measurement.h:27
roo_transceivers_Quantity quantity_
Definition measurement.h:50
@ roo_transceivers_Quantity_kUnspecifiedQuantity
enum _roo_transceivers_Quantity roo_transceivers_Quantity