geopm  3.1.0
GEOPM - Global Extensible Open Power Manager
All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros Pages
DerivativeSignal.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 - 2024 Intel Corporation
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 
6 #ifndef DERIVATIVESIGNAL_HPP_INCLUDE
7 #define DERIVATIVESIGNAL_HPP_INCLUDE
8 
9 #include <memory>
10 
11 #include "Signal.hpp"
12 #include "geopm/CircularBuffer.hpp"
13 
14 namespace geopm
15 {
16  class DerivativeSignal : public Signal
17  {
18  public:
19  DerivativeSignal(std::shared_ptr<Signal> time_sig,
20  std::shared_ptr<Signal> y_sig,
21  int read_loops, double sleep_time);
22  DerivativeSignal(const DerivativeSignal &other) = delete;
23  DerivativeSignal &operator=(const DerivativeSignal &other) = delete;
24  virtual ~DerivativeSignal() = default;
25  void setup_batch(void) override;
26  double sample(void) override;
27  double read(void) const override;
28  private:
29  struct m_sample_s {
30  double time;
31  double sample;
32  };
33 
36  static double compute_next(CircularBuffer<m_sample_s> &history,
37  int &num_fit,
38  double time, double signal);
39 
40  std::shared_ptr<Signal> m_time_sig;
41  std::shared_ptr<Signal> m_y_sig;
42 
43  const int M_NUM_SAMPLE_HISTORY;
45  int m_derivative_num_fit;
46  bool m_is_batch_ready;
47  double m_sleep_time;
48  double m_last_result;
49  };
50 }
51 
52 #endif
Definition: DerivativeSignal.hpp:17
double sample(void) override
Apply any conversions necessary to interpret the latest stored value as a double.
Definition: DerivativeSignal.cpp:82
double read(void) const override
Read directly the value of the signal without affecting any pushed batch signals.
Definition: DerivativeSignal.cpp:100
DerivativeSignal & operator=(const DerivativeSignal &other)=delete
virtual ~DerivativeSignal()=default
DerivativeSignal(const DerivativeSignal &other)=delete
DerivativeSignal(std::shared_ptr< Signal > time_sig, std::shared_ptr< Signal > y_sig, int read_loops, double sleep_time)
Definition: DerivativeSignal.cpp:17
void setup_batch(void) override
Prepare the signal for being updated through side effects by the owner's read_batch step....
Definition: DerivativeSignal.cpp:34
Definition: Signal.hpp:16
Definition: Agg.cpp:20