Open Lighting Architecture
 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 
35 
37  public:
39  m_enabled(false),
40  m_got_response(false),
41  m_socket(NULL),
42  m_ss(NULL) {}
43  virtual ~StageProfiWidget();
44 
45  // these methods are for communicating with the device
46  virtual bool Connect(const string &path) = 0;
47  int Disconnect();
48  string GetDevicePath() { return m_device_path; }
49  ConnectedDescriptor *GetSocket() { return m_socket; }
50  bool SendDmx(const DmxBuffer &buffer) const;
51  bool DetectDevice();
52  void SocketReady();
53  void Timeout();
54 
55  protected:
56  int Send255(unsigned int start, const uint8_t *buf, unsigned int len) const;
57  int SetChannel(unsigned int chan, uint8_t val) const;
58 
59  // instance variables
60  bool m_enabled;
61  bool m_got_response;
62  string m_device_path;
63  ConnectedDescriptor *m_socket;
64  SelectServer *m_ss;
65 
66  enum { DMX_MSG_LEN = 255 };
67  enum { DMX_HEADER_SIZE = 4};
68 
69  private:
70  int DoRecv();
71 };
72 } // namespace stageprofi
73 } // namespace plugin
74 } // namespace ola
75 #endif // PLUGINS_STAGEPROFI_STAGEPROFIWIDGET_H_