Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Krzysztof Grobelny | 8069771 | 2021-03-04 09:49:27 +0000 | [diff] [blame] | 3 | #include "interfaces/clock.hpp" |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame] | 4 | #include "interfaces/metric.hpp" |
Krzysztof Grobelny | 6ccfcbf | 2020-11-04 09:31:36 +0100 | [diff] [blame] | 5 | #include "interfaces/sensor.hpp" |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame] | 6 | #include "interfaces/sensor_listener.hpp" |
| 7 | |
Krzysztof Grobelny | 6ccfcbf | 2020-11-04 09:31:36 +0100 | [diff] [blame] | 8 | class Metric : |
| 9 | public interfaces::Metric, |
| 10 | public interfaces::SensorListener, |
| 11 | public std::enable_shared_from_this<Metric> |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame] | 12 | { |
| 13 | public: |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 14 | Metric(Sensors sensors, OperationType operationType, std::string id, |
Krzysztof Grobelny | 8069771 | 2021-03-04 09:49:27 +0000 | [diff] [blame] | 15 | std::string metadata, CollectionTimeScope, CollectionDuration, |
| 16 | std::unique_ptr<interfaces::Clock>); |
| 17 | ~Metric(); |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame] | 18 | |
Krzysztof Grobelny | 6ccfcbf | 2020-11-04 09:31:36 +0100 | [diff] [blame] | 19 | void initialize() override; |
Lukasz Kazmierczak | 7e098e9 | 2021-09-16 15:59:56 +0200 | [diff] [blame] | 20 | void deinitialize() override; |
Krzysztof Grobelny | 8069771 | 2021-03-04 09:49:27 +0000 | [diff] [blame] | 21 | std::vector<MetricValue> getReadings() const override; |
Krzysztof Grobelny | 6ccfcbf | 2020-11-04 09:31:36 +0100 | [diff] [blame] | 22 | void sensorUpdated(interfaces::Sensor&, uint64_t) override; |
| 23 | void sensorUpdated(interfaces::Sensor&, uint64_t, double value) override; |
Krzysztof Grobelny | d223819 | 2020-12-02 09:27:28 +0000 | [diff] [blame] | 24 | LabeledMetricParameters dumpConfiguration() const override; |
Szymon Dompke | 3eb5686 | 2021-09-20 15:32:04 +0200 | [diff] [blame^] | 25 | uint64_t sensorCount() const override; |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame] | 26 | |
| 27 | private: |
Krzysztof Grobelny | 8069771 | 2021-03-04 09:49:27 +0000 | [diff] [blame] | 28 | class CollectionData; |
| 29 | class DataPoint; |
| 30 | class DataInterval; |
| 31 | class DataStartup; |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 32 | |
Krzysztof Grobelny | 8069771 | 2021-03-04 09:49:27 +0000 | [diff] [blame] | 33 | static std::vector<std::unique_ptr<CollectionData>> |
| 34 | makeCollectionData(size_t size, OperationType, CollectionTimeScope, |
| 35 | CollectionDuration); |
| 36 | |
| 37 | void attemptUnpackJsonMetadata(); |
| 38 | CollectionData& findAssociatedData(const interfaces::Sensor& notifier); |
Krzysztof Grobelny | 6ccfcbf | 2020-11-04 09:31:36 +0100 | [diff] [blame] | 39 | |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 40 | std::string id; |
| 41 | std::string metadata; |
| 42 | std::vector<MetricValue> readings; |
| 43 | Sensors sensors; |
Krzysztof Grobelny | e8fc575 | 2021-02-05 14:30:45 +0000 | [diff] [blame] | 44 | OperationType operationType; |
Krzysztof Grobelny | 8069771 | 2021-03-04 09:49:27 +0000 | [diff] [blame] | 45 | CollectionTimeScope collectionTimeScope; |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 46 | CollectionDuration collectionDuration; |
Krzysztof Grobelny | 8069771 | 2021-03-04 09:49:27 +0000 | [diff] [blame] | 47 | std::vector<std::unique_ptr<CollectionData>> collectionAlgorithms; |
| 48 | std::unique_ptr<interfaces::Clock> clock; |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame] | 49 | }; |