21 #ifndef INCLUDE_OLAD_UNIVERSE_H_
22 #define INCLUDE_OLAD_UNIVERSE_H_
24 #include <ola/Clock.h>
31 #include <olad/DmxSource.h>
63 string Name()
const {
return m_universe_name; }
64 unsigned int UniverseId()
const {
return m_universe_id; }
65 merge_mode MergeMode()
const {
return m_merge_mode; }
66 bool IsActive()
const;
67 uint8_t ActivePriority()
const {
return m_active_priority; }
75 return m_rdm_discovery_interval;
82 return m_last_discovery_time;
86 void SetName(
const string &name);
87 void SetMergeMode(merge_mode merge_mode);
93 m_rdm_discovery_interval = discovery_interval;
98 const DmxBuffer &GetDMX()
const {
return m_buffer; }
101 bool AddPort(InputPort *port);
102 bool AddPort(OutputPort *port);
103 bool RemovePort(InputPort *port);
104 bool RemovePort(OutputPort *port);
105 bool ContainsPort(InputPort *port)
const;
106 bool ContainsPort(OutputPort *port)
const;
107 unsigned int InputPortCount()
const {
return m_input_ports.size(); }
108 unsigned int OutputPortCount()
const {
return m_output_ports.size(); }
109 void InputPorts(vector<InputPort*> *ports);
110 void OutputPorts(vector<OutputPort*> *ports);
113 bool AddSourceClient(Client *client);
114 bool RemoveSourceClient(Client *client);
115 bool ContainsSourceClient(Client *client)
const;
116 unsigned int SourceClientCount()
const {
return m_source_clients.size(); }
119 bool AddSinkClient(Client *client);
120 bool RemoveSinkClient(Client *client);
121 bool ContainsSinkClient(Client *client)
const;
122 unsigned int SinkClientCount()
const {
return m_sink_clients.size(); }
125 bool PortDataChanged(InputPort *port);
126 bool SourceClientDataChanged(Client *client);
141 bool operator==(
const Universe &other) {
142 return m_universe_id == other.UniverseId();
145 static const char K_FPS_VAR[];
146 static const char K_MERGE_HTP_STR[];
147 static const char K_MERGE_LTP_STR[];
148 static const char K_UNIVERSE_INPUT_PORT_VAR[];
149 static const char K_UNIVERSE_MODE_VAR[];
150 static const char K_UNIVERSE_NAME_VAR[];
151 static const char K_UNIVERSE_OUTPUT_PORT_VAR[];
152 static const char K_UNIVERSE_RDM_REQUESTS[];
153 static const char K_UNIVERSE_SINK_CLIENTS_VAR[];
154 static const char K_UNIVERSE_SOURCE_CLIENTS_VAR[];
155 static const char K_UNIVERSE_UID_COUNT_VAR[];
159 unsigned int expected_count;
160 unsigned int current_count;
161 ola::rdm::rdm_response_code response_code;
163 vector<string> packets;
164 } broadcast_request_tracker;
166 typedef map<Client*, bool> SourceClientMap;
168 string m_universe_name;
169 unsigned int m_universe_id;
170 string m_universe_id_str;
171 uint8_t m_active_priority;
172 enum merge_mode m_merge_mode;
173 vector<InputPort*> m_input_ports;
174 vector<OutputPort*> m_output_ports;
175 set<Client*> m_sink_clients;
180 SourceClientMap m_source_clients;
181 class UniverseStore *m_universe_store;
183 ExportMap *m_export_map;
184 map<UID, OutputPort*> m_output_uids;
186 TimeInterval m_rdm_discovery_interval;
187 TimeStamp m_last_discovery_time;
189 Universe(
const Universe&);
190 Universe& operator=(
const Universe&);
191 void HandleBroadcastAck(broadcast_request_tracker *tracker,
192 ola::rdm::rdm_response_code code,
194 const std::vector<std::string> &packets);
195 void HandleBroadcastDiscovery(broadcast_request_tracker *tracker,
196 ola::rdm::rdm_response_code code,
198 const std::vector<std::string> &packets);
199 bool UpdateDependants();
202 void HTPMergeSources(
const vector<DmxSource> &sources);
203 bool MergeAll(
const InputPort *port,
const Client *client);
204 void PortDiscoveryComplete(BaseCallback0<void> *on_complete,
205 OutputPort *output_port,
209 void SafeIncrement(
const string &name);
210 void SafeDecrement(
const string &name);
212 template<
class PortClass>
213 bool GenericAddPort(PortClass *port,
214 vector<PortClass*> *ports);
216 template<
class PortClass>
217 bool GenericRemovePort(PortClass *port,
218 vector<PortClass*> *ports,
219 map<UID, PortClass*> *uid_map = NULL);
221 template<
class PortClass>
222 bool GenericContainsPort(PortClass *port,
223 const vector<PortClass*> &ports)
const;
226 #endif // INCLUDE_OLAD_UNIVERSE_H_