Open Lighting Architecture  Latest Git
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
15  *
16  * SandNetDevice.h
17  * Interface for the sandnet device
18  * Copyright (C) 2005 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  std::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 advertisement every 2s.
64  static const int ADVERTISEMENT_PERIOD_MS = 2000;
65 };
66 } // namespace sandnet
67 } // namespace plugin
68 } // namespace ola
69 #endif // PLUGINS_SANDNET_SANDNETDEVICE_H_
bool StartHook()
Called during Start().
Definition: SandNetDevice.cpp:63
Provides a wrapper for the DeviceManager and SelectServer objects so that the plugins can register de...
Definition: Device.h:95
void * timeout_id
A timeout handle which can later be used to cancel a timeout.
Definition: SchedulerInterface.h:34
Definition: SandNetDevice.h:35
Definition: PluginAdaptor.h:41
std::string DeviceId() const
The device ID.
Definition: SandNetDevice.h:41
Definition: Preferences.h:147
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
Definition: SandNetNode.h:41
Definition: SandNetPlugin.h:33