Open Lighting Architecture
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SandNetDevice.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  * SandNetDevice.h
17  * Interface for the sandnet device
18  * Copyright (C) 2005-2009 Simon Newton
19  */
20 
21 #ifndef PLUGINS_SANDNET_SANDNETDEVICE_H_
22 #define PLUGINS_SANDNET_SANDNETDEVICE_H_
23 
24 #include <string>
25 #include "olad/Device.h"
26 #include "olad/Plugin.h"
27 #include "olad/PluginAdaptor.h"
28 #include "plugins/sandnet/SandNetCommon.h"
29 #include "plugins/sandnet/SandNetNode.h"
30 
31 namespace ola {
32 namespace plugin {
33 namespace sandnet {
34 
35 class SandNetDevice: public ola::Device {
36  public:
37  SandNetDevice(class SandNetPlugin *owner,
38  class Preferences *prefs,
39  class PluginAdaptor *plugin_adaptor);
40 
41  string DeviceId() const { return "1"; }
42  SandNetNode *GetNode() { return m_node; }
43 
44  bool SendAdvertisement();
45 
46  static const char IP_KEY[];
47  static const char NAME_KEY[];
48 
49  protected:
50  bool StartHook();
51  void PrePortStop();
52  void PostPortStop();
53 
54  private:
55  class Preferences *m_preferences;
56  class PluginAdaptor *m_plugin_adaptor;
57  SandNetNode *m_node;
58  ola::thread::timeout_id m_timeout_id;
59 
60  static const char SANDNET_DEVICE_NAME[];
61  // the number of input ports to create
62  static const unsigned int INPUT_PORTS = 8;
63  // send an advertistment every 2s.
64  static const int ADVERTISTMENT_PERIOD_MS = 2000;
65 };
66 } // namespace sandnet
67 } // namespace plugin
68 } // namespace ola
69 #endif // PLUGINS_SANDNET_SANDNETDEVICE_H_