Open Lighting Architecture  0.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AckTimerResponder.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  * AckTimerResponder_h
17  * Copyright (C) 2013 Simon Newton
18  */
19 
28 #ifndef INCLUDE_OLA_RDM_ACKTIMERRESPONDER_H_
29 #define INCLUDE_OLA_RDM_ACKTIMERRESPONDER_H_
30 
31 #include <ola/Clock.h>
33 #include <ola/rdm/RDMEnums.h>
34 #include <ola/rdm/ResponderOps.h>
35 #include <ola/rdm/ResponderPersonality.h>
36 #include <ola/rdm/UID.h>
37 
38 #include <queue>
39 #include <string>
40 #include <vector>
41 
42 namespace ola {
43 namespace rdm {
44 
49  public:
50  explicit AckTimerResponder(const UID &uid);
52 
53  void SendRDMRequest(const RDMRequest *request, RDMCallback *callback);
54 
55  private:
59  class RDMOps : public ResponderOps<AckTimerResponder> {
60  public:
61  static RDMOps *Instance() {
62  if (!instance)
63  instance = new RDMOps();
64  return instance;
65  }
66 
67  private:
68  RDMOps() : ResponderOps<AckTimerResponder>(PARAM_HANDLERS) {}
69 
70  static RDMOps *instance;
71  };
72 
76  class Personalities : public PersonalityCollection {
77  public:
78  static const Personalities *Instance();
79 
80  private:
81  explicit Personalities(const PersonalityList &personalities) :
82  PersonalityCollection(personalities) {
83  }
84 
85  static Personalities *instance;
86  };
87 
88  // The actual queue of messages to be collected.
89  typedef std::queue<class QueuedResponse*> ResponseQueue;
90 
91  // The list of responses which aren't available yet. When they become
92  // valid they are moved to the ResponseQueue,
93  typedef std::vector<class QueuedResponse*> PendingResponses;
94 
95  const UID m_uid;
96  uint16_t m_start_address;
97  bool m_identify_mode;
98  PersonalityManager m_personality_manager;
99 
100  ResponseQueue m_queued_messages;
101  PendingResponses m_upcoming_queued_messages;
102  std::auto_ptr<class QueuedResponse> m_last_queued_message;
103  ola::Clock m_clock;
104 
105  uint16_t Footprint() const {
106  return m_personality_manager.ActivePersonalityFootprint();
107  }
108 
109  uint8_t QueuedMessageCount() const;
110  void QueueAnyNewMessages();
111  const RDMResponse *ResponseFromQueuedMessage(
112  const RDMRequest *request,
113  const class QueuedResponse *queued_response);
114  const RDMResponse *EmptyStatusMessage(const RDMRequest *request);
115  const RDMResponse *GetQueuedMessage(const RDMRequest *request);
116  const RDMResponse *GetDeviceInfo(const RDMRequest *request);
117  const RDMResponse *GetPersonality(const RDMRequest *request);
118  const RDMResponse *SetPersonality(const RDMRequest *request);
119  const RDMResponse *GetPersonalityDescription(const RDMRequest *request);
120  const RDMResponse *GetDmxStartAddress(const RDMRequest *request);
121  const RDMResponse *SetDmxStartAddress(const RDMRequest *request);
122  const RDMResponse *GetIdentify(const RDMRequest *request);
123  const RDMResponse *SetIdentify(const RDMRequest *request);
124  const RDMResponse *GetManufacturerLabel(const RDMRequest *request);
125  const RDMResponse *GetDeviceLabel(const RDMRequest *request);
126  const RDMResponse *GetDeviceModelDescription(const RDMRequest *request);
127  const RDMResponse *GetSoftwareVersionLabel(const RDMRequest *request);
128 
129  static const ResponderOps<AckTimerResponder>::ParamHandler PARAM_HANDLERS[];
130  static const uint16_t ACK_TIMER_MS;
131 };
132 } // namespace rdm
133 } // namespace ola
134 #endif // INCLUDE_OLA_RDM_ACKTIMERRESPONDER_H_