Open Lighting Architecture  0.9.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
StageProfiWidget.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  * stageprofidevice.h
17  * Interface for the stageprofi device
18  * Copyright (C) 2006 Simon Newton
19  */
20 
21 #ifndef PLUGINS_STAGEPROFI_STAGEPROFIWIDGET_H_
22 #define PLUGINS_STAGEPROFI_STAGEPROFIWIDGET_H_
23 
24 #include <memory>
25 #include <string>
26 #include "ola/DmxBuffer.h"
27 #include "ola/Callback.h"
28 #include "ola/io/Descriptor.h"
29 #include "ola/io/SelectServerInterface.h"
30 
31 namespace ola {
32 namespace plugin {
33 namespace stageprofi {
34 
35 
37  public:
39 
49  ola::io::ConnectedDescriptor *descriptor,
50  const std::string &widget_path,
51  DisconnectCallback *disconnect_cb);
52 
57 
62  std::string GetPath() const { return m_widget_path; }
63 
64  bool SendDmx(const DmxBuffer &buffer);
65 
66  private:
67  enum { DMX_MSG_LEN = 255 };
68  enum { DMX_HEADER_SIZE = 4};
69 
71  std::auto_ptr<ola::io::ConnectedDescriptor> m_descriptor;
72  const std::string m_widget_path;
73  DisconnectCallback *m_disconnect_cb;
74  ola::thread::timeout_id m_timeout_id;
75  bool m_got_response;
76 
77  void SocketReady();
78  void DiscoveryTimeout();
79  bool Send255(uint16_t start, const uint8_t *buf, unsigned int len) const;
80  void SendQueryPacket();
81  void RunDisconnectHandler();
82 };
83 } // namespace stageprofi
84 } // namespace plugin
85 } // namespace ola
86 #endif // PLUGINS_STAGEPROFI_STAGEPROFIWIDGET_H_