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