Open Lighting Architecture
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MilInstWidget.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  * MilInstWidget.h
17  * Interface for the milinst widget
18  * Copyright (C) 2013 Peter Newman
19  */
20 
21 #ifndef PLUGINS_MILINST_MILINSTWIDGET_H_
22 #define PLUGINS_MILINST_MILINSTWIDGET_H_
23 
24 #include <fcntl.h>
25 #include <termios.h>
26 #include <string>
27 
28 #include "ola/io/SelectServer.h"
29 #include "ola/DmxBuffer.h"
30 
31 namespace ola {
32 namespace plugin {
33 namespace milinst {
34 
37 
39  public:
40  static int ConnectToWidget(const std::string &path, speed_t speed = B9600);
41 
42  explicit MilInstWidget(const std::string &path):
43  m_enabled(false),
44  m_path(path),
45  m_socket(NULL),
46  m_ss(NULL) {}
47  virtual ~MilInstWidget();
48 
49  // these methods are for communicating with the device
50  virtual bool Connect() = 0;
51  int Disconnect();
52  ConnectedDescriptor *GetSocket() { return m_socket; }
53  string GetPath() { return m_path; }
54  virtual bool SendDmx(const DmxBuffer &buffer) const = 0;
55  virtual bool DetectDevice() = 0;
56 
57  protected:
58  virtual int SetChannel(unsigned int chan, uint8_t val) const = 0;
59 
60  // instance variables
61  bool m_enabled;
62  const string m_path;
63  ConnectedDescriptor *m_socket;
64  SelectServer *m_ss;
65 };
66 } // namespace milinst
67 } // namespace plugin
68 } // namespace ola
69 #endif // PLUGINS_MILINST_MILINSTWIDGET_H_