Open Lighting Architecture  0.9.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PathportDevice.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  * PathportDevice.h
17  * Interface for the pathport device
18  * Copyright (C) 2005 Simon Newton
19  */
20 
21 #ifndef PLUGINS_PATHPORT_PATHPORTDEVICE_H_
22 #define PLUGINS_PATHPORT_PATHPORTDEVICE_H_
23 
24 #include <string>
25 #include "olad/Device.h"
26 #include "ola/io/SelectServer.h"
27 #include "plugins/pathport/PathportNode.h"
28 
29 namespace ola {
30 namespace plugin {
31 namespace pathport {
32 
33 class PathportDevice: public ola::Device {
34  public:
35  PathportDevice(class PathportPlugin *owner,
36  class Preferences *preferences,
37  class PluginAdaptor *plugin_adaptor);
38 
39  std::string DeviceId() const { return "1"; }
40  PathportNode *GetNode() const { return m_node; }
41  bool SendArpReply();
42 
43  static const char K_DEFAULT_NODE_NAME[];
44  static const char K_DSCP_KEY[];
45  static const char K_NODE_ID_KEY[];
46  static const char K_NODE_IP_KEY[];
47  static const char K_NODE_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  PathportNode *m_node;
58  ola::thread::timeout_id m_timeout_id;
59 
60  static const char PATHPORT_DEVICE_NAME[];
61  static const uint32_t PORTS_PER_DEVICE = 8;
62  static const int ADVERTISTMENT_PERIOD_MS = 6000;
63 };
64 } // namespace pathport
65 } // namespace plugin
66 } // namespace ola
67 #endif // PLUGINS_PATHPORT_PATHPORTDEVICE_H_