Open Lighting Architecture
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SensorResponder.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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15  *
16  * SensorResponder_h
17  * Copyright (C) 2013 Simon Newton
18  */
19 
28 #ifndef INCLUDE_OLA_RDM_SENSORRESPONDER_H_
29 #define INCLUDE_OLA_RDM_SENSORRESPONDER_H_
30 
31 #include <string>
32 #include <vector>
34 #include "ola/rdm/RDMEnums.h"
35 #include "ola/rdm/ResponderOps.h"
36 #include "ola/rdm/UID.h"
37 
38 namespace ola {
39 namespace rdm {
40 
45  public:
46  explicit SensorResponder(const UID &uid);
47  ~SensorResponder();
48 
49  void SendRDMRequest(const RDMRequest *request, RDMCallback *callback);
50 
51  private:
55  class RDMOps : public ResponderOps<SensorResponder> {
56  public:
57  static RDMOps *Instance() {
58  if (!instance)
59  instance = new RDMOps();
60  return instance;
61  }
62 
63  private:
64  RDMOps() : ResponderOps<SensorResponder>(PARAM_HANDLERS) {}
65 
66  static RDMOps *instance;
67  };
68 
69  struct sensor_value_s {
70  uint8_t sensor;
71  int16_t value;
72  int16_t lowest;
73  int16_t highest;
74  int16_t recorded;
75  } __attribute__((packed));
76 
77  typedef vector<class FakeSensor*> FakeSensors;
78 
79  const UID m_uid;
80  bool m_identify_mode;
81  FakeSensors m_sensors;
82 
83  const RDMResponse *GetDeviceInfo(const RDMRequest *request);
84  const RDMResponse *GetProductDetailList(const RDMRequest *request);
85  const RDMResponse *GetIdentify(const RDMRequest *request);
86  const RDMResponse *SetIdentify(const RDMRequest *request);
87  const RDMResponse *GetManufacturerLabel(const RDMRequest *request);
88  const RDMResponse *GetDeviceLabel(const RDMRequest *request);
89  const RDMResponse *GetDeviceModelDescription(const RDMRequest *request);
90  const RDMResponse *GetSoftwareVersionLabel(const RDMRequest *request);
91  const RDMResponse *GetSensorDefinition(const RDMRequest *request);
92  const RDMResponse *GetSensorValue(const RDMRequest *request);
93  const RDMResponse *SetSensorValue(const RDMRequest *request);
94  const RDMResponse *RecordSensor(const RDMRequest *request);
95 
96  static const ResponderOps<SensorResponder>::ParamHandler PARAM_HANDLERS[];
97 };
98 } // namespace rdm
99 } // namespace ola
100 #endif // INCLUDE_OLA_RDM_SENSORRESPONDER_H_