Open Lighting Architecture: plugins/stageprofi/StageProfiDetector.h Source File

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
StageProfiDetector.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 * StageProfiDetector.h
17 * Detects StageProfi devices as they are attached.
18 * Copyright (C) 2014 Simon Newton
19 */
20
21#ifndef PLUGINS_STAGEPROFI_STAGEPROFIDETECTOR_H_
22#define PLUGINS_STAGEPROFI_STAGEPROFIDETECTOR_H_
23
24#include <map>
25#include <memory>
26#include <string>
27#include <vector>
28
29#include "ola/Callback.h"
30#include "ola/io/SelectServerInterface.h"
31#include "ola/io/Descriptor.h"
32#include "ola/network/AdvancedTCPConnector.h"
33#include "ola/util/Backoff.h"
34
35namespace ola {
36namespace plugin {
37namespace stageprofi {
38
39class StageProfiWidget;
40
41 class StageProfiDetector {
42 public:
43 typedef ola::Callback2<void, const std::string&, io::ConnectedDescriptor*>
44 WidgetCallback;
45
46 StageProfiDetector(ola::io::SelectServerInterface *ss,
47 const std::vector<std::string> &widget_paths,
48 WidgetCallback *callback);
49 ~StageProfiDetector();
50
51 void Start();
52 void Stop();
53
54 void ReleaseWidget(const std::string &widget_path);
55
56 private:
57 typedef std::map<std::string, ola::io::ConnectedDescriptor*> DescriptorMap;
58
59 ola::io::SelectServerInterface *m_ss;
60 std::auto_ptr<WidgetCallback> m_callback;
61 ola::thread::timeout_id m_timeout_id;
62 DescriptorMap m_usb_widgets;
63 DescriptorMap m_tcp_widgets;
64 ola::ExponentialBackoffPolicy m_backoff;
65
66 // TCP members
67 ola::network::TCPSocketFactory m_socket_factory;
68 ola::network::AdvancedTCPConnector m_tcp_connector;
69
70 bool RunDiscovery();
71 ola::io::ConnectedDescriptor* ConnectToUSB(const std::string &widget_path);
72
73 void SocketConnected(ola::network::TCPSocket *socket);
74};
75} // namespace stageprofi
76} // namespace plugin
77} // namespace ola
78#endif // PLUGINS_STAGEPROFI_STAGEPROFIDETECTOR_H_
Callback.h
ola::Callback2
A 2 argument callback which can be called multiple times.
Definition Callback.h:1895
ola::ExponentialBackoffPolicy
Definition Backoff.h:98
ola::io::ConnectedDescriptor
A BidirectionalFileDescriptor that also generates notifications when closed.
Definition Descriptor.h:283
ola::io::SelectServerInterface
The interface for the SelectServer.
Definition SelectServerInterface.h:42
ola::network::AdvancedTCPConnector
Attempts to open a TCP connection until a failure limit is reached.
Definition AdvancedTCPConnector.h:48
ola::network::TCPSocket
Definition TCPSocket.h:43
ola::plugin::stageprofi::StageProfiWidget
Definition StageProfiWidget.h:36
Descriptor.h
ola::plugin::stageprofi
Code for Stageprofi devices.
ola::plugin
Code for supported devices and protocols.
ola::thread::timeout_id
void * timeout_id
A timeout handle which can later be used to cancel a timeout.
Definition SchedulerInterface.h:34
ola
The namespace containing all OLA symbols.
Definition Credentials.cpp:44