Open Lighting Architecture  0.9.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ArduinoRGBDevice.h
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 2 of the License, or
5  * (at your option) any later version.
6  *
7  * This program 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
10  * GNU Library General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
15  *
16  * ArduinoRGBDevice.h
17  * The Arduino RGB Mixer device.
18  * Copyright (C) 2010 Simon Newton
19  */
20 
21 #ifndef PLUGINS_USBPRO_ARDUINORGBDEVICE_H_
22 #define PLUGINS_USBPRO_ARDUINORGBDEVICE_H_
23 
24 #include <string>
25 #include "ola/DmxBuffer.h"
26 #include "olad/TokenBucket.h"
27 #include "plugins/usbpro/ArduinoWidget.h"
28 #include "plugins/usbpro/UsbSerialDevice.h"
29 
30 namespace ola {
31 namespace plugin {
32 namespace usbpro {
33 
34 
35 /*
36  * An Arduino RGB Mixer Device
37  */
39  public:
41  ola::AbstractPlugin *owner,
42  const std::string &name,
43  ArduinoWidget *widget,
44  uint16_t esta_id,
45  uint16_t device_id,
46  uint32_t serial);
47 
48  std::string DeviceId() const { return m_device_id; }
49 
50  private:
51  std::string m_device_id;
52 };
53 
54 
55 /*
56  * A single Output port per device
57  */
59  public:
61  ArduinoWidget *widget,
62  uint32_t serial,
63  const TimeStamp *wake_time,
64  unsigned int initial_count,
65  unsigned int rate);
66 
67  std::string Description() const { return m_description; }
68 
69  bool WriteDMX(const DmxBuffer &buffer, uint8_t) {
70  if (m_bucket.GetToken(*m_wake_time))
71  return m_widget->SendDMX(buffer);
72  else
73  OLA_INFO << "Port rated limited, dropping frame";
74  return true;
75  }
76 
77  void SendRDMRequest(const ola::rdm::RDMRequest *request,
78  ola::rdm::RDMCallback *callback) {
79  return m_widget->SendRDMRequest(request, callback);
80  }
81 
82  void RunFullDiscovery(ola::rdm::RDMDiscoveryCallback *callback) {
83  m_widget->RunFullDiscovery(callback);
84  }
85 
86  void RunIncrementalDiscovery(ola::rdm::RDMDiscoveryCallback *callback) {
87  m_widget->RunIncrementalDiscovery(callback);
88  }
89 
90  private:
91  ArduinoWidget *m_widget;
92  TokenBucket m_bucket;
93  const TimeStamp *m_wake_time;
94  std::string m_description;
95 };
96 } // namespace usbpro
97 } // namespace plugin
98 } // namespace ola
99 #endif // PLUGINS_USBPRO_ARDUINORGBDEVICE_H_