Open Lighting Architecture  0.9.0
 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15  *
16  * stageprofidevice.h
17  * Interface for the stageprofi device
18  * Copyright (C) 2006-2007 Simon Newton
19  */
20 
21 #ifndef PLUGINS_STAGEPROFI_STAGEPROFIWIDGET_H_
22 #define PLUGINS_STAGEPROFI_STAGEPROFIWIDGET_H_
23 
24 #include <string>
25 #include "ola/io/SelectServer.h"
26 #include "ola/network/Socket.h"
27 #include "ola/DmxBuffer.h"
28 
29 namespace ola {
30 namespace plugin {
31 namespace stageprofi {
32 
33 
35  public:
37  m_enabled(false),
38  m_got_response(false),
39  m_socket(NULL),
40  m_ss(NULL) {}
41  virtual ~StageProfiWidget();
42 
43  // these methods are for communicating with the device
44  virtual bool Connect(const std::string &path) = 0;
45  int Disconnect();
46  std::string GetDevicePath() { return m_device_path; }
47  ola::io::ConnectedDescriptor *GetSocket() { return m_socket; }
48  bool SendDmx(const DmxBuffer &buffer) const;
49  bool DetectDevice();
50  void SocketReady();
51  void Timeout();
52 
53  protected:
54  int Send255(uint16_t start, const uint8_t *buf, unsigned int len) const;
55  int SetChannel(uint16_t chan, uint8_t val) const;
56 
57  // instance variables
58  bool m_enabled;
59  bool m_got_response;
60  std::string m_device_path;
63 
64  enum { DMX_MSG_LEN = 255 };
65  enum { DMX_HEADER_SIZE = 4};
66 
67  private:
68  int DoRecv();
69 };
70 } // namespace stageprofi
71 } // namespace plugin
72 } // namespace ola
73 #endif // PLUGINS_STAGEPROFI_STAGEPROFIWIDGET_H_