Open Lighting Architecture  0.9.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ResponderLoadSensor.h
Go to the documentation of this file.
1 /*
2  * This library is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU Lesser General Public
4  * License as published by the Free Software Foundation; either
5  * version 2.1 of the License, or (at your option) any later version.
6  *
7  * This library is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10  * Lesser General Public License for more details.
11  *
12  * You should have received a copy of the GNU Lesser General Public
13  * License along with this library; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15  *
16  * ResponderLoadSensor.h
17  * Copyright (C) 2013 Peter Newman
18  */
19 
28 #ifndef INCLUDE_OLA_RDM_RESPONDERLOADSENSOR_H_
29 #define INCLUDE_OLA_RDM_RESPONDERLOADSENSOR_H_
30 
32 #include <ola/system/SystemUtils.h>
33 
34 #include <string>
35 
36 namespace ola {
37 namespace rdm {
41 class LoadSensor: public Sensor {
42  public:
43  LoadSensor(const ola::system::load_averages load_average,
44  const std::string &description)
45  : Sensor(SENSOR_OTHER,
46  UNITS_NONE,
47  PREFIX_CENTI,
48  description,
49  SensorOptions(true,
50  true,
51  0,
52  SENSOR_DEFINITION_RANGE_MAX_UNDEFINED,
53  0,
54  SENSOR_DEFINITION_NORMAL_MAX_UNDEFINED)),
55  m_load_average(load_average) {
56  // set high / low to something
57  Reset();
58  // Force recorded back to zero
59  m_recorded = 0;
60  }
61 
62  static const int16_t LOAD_SENSOR_ERROR_VALUE = 0;
63 
64  protected:
65  int16_t PollSensor();
66 
67  private:
68  ola::system::load_averages m_load_average;
69 };
70 } // namespace rdm
71 } // namespace ola
72 #endif // INCLUDE_OLA_RDM_RESPONDERLOADSENSOR_H_