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
42 public:
45
47 const std::vector<std::string> &widget_paths,
48 WidgetCallback *callback);
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
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;
65
66 // TCP members
67 ola::network::TCPSocketFactory m_socket_factory;
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_
A 2 argument callback which can be called multiple times.
Definition Callback.h:1895
Definition Backoff.h:98
A BidirectionalFileDescriptor that also generates notifications when closed.
Definition Descriptor.h:283
The interface for the SelectServer.
Definition SelectServerInterface.h:42
Attempts to open a TCP connection until a failure limit is reached.
Definition AdvancedTCPConnector.h:48
Definition TCPSocketFactory.h:46
Definition TCPSocket.h:43
Definition StageProfiDetector.h:41
void * timeout_id
A timeout handle which can later be used to cancel a timeout.
Definition SchedulerInterface.h:34
The namespace containing all OLA symbols.
Definition Credentials.cpp:44