1 |
/* |
---|
2 |
* Copyright (C) 2005-2008 by Pieter Palmers |
---|
3 |
* |
---|
4 |
* This file is part of FFADO |
---|
5 |
* FFADO = Free Firewire (pro-)audio drivers for linux |
---|
6 |
* |
---|
7 |
* FFADO is based upon FreeBoB |
---|
8 |
* |
---|
9 |
* This program is free software: you can redistribute it and/or modify |
---|
10 |
* it under the terms of the GNU General Public License as published by |
---|
11 |
* the Free Software Foundation, either version 2 of the License, or |
---|
12 |
* (at your option) version 3 of the License. |
---|
13 |
* |
---|
14 |
* This program is distributed in the hope that it will be useful, |
---|
15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 |
* GNU General Public License for more details. |
---|
18 |
* |
---|
19 |
* You should have received a copy of the GNU General Public License |
---|
20 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
21 |
* |
---|
22 |
*/ |
---|
23 |
|
---|
24 |
#include "controlserver.h" |
---|
25 |
#include "libcontrol/Element.h" |
---|
26 |
#include "libcontrol/BasicElements.h" |
---|
27 |
#include "libcontrol/MatrixMixer.h" |
---|
28 |
#include "libutil/Time.h" |
---|
29 |
#include "libutil/PosixMutex.h" |
---|
30 |
|
---|
31 |
namespace DBusControl { |
---|
32 |
|
---|
33 |
IMPL_DEBUG_MODULE( Element, Element, DEBUG_LEVEL_NORMAL ); |
---|
34 |
|
---|
35 |
// --- Element |
---|
36 |
Element::Element( DBus::Connection& connection, std::string p, Element* parent, Control::Element &slave) |
---|
37 |
: DBus::ObjectAdaptor(connection, p) |
---|
38 |
, m_Parent(parent) |
---|
39 |
, m_Slave(slave) |
---|
40 |
, m_UpdateLock( NULL ) |
---|
41 |
{ |
---|
42 |
debugOutput( DEBUG_LEVEL_VERBOSE, "Created Element on '%s'\n", |
---|
43 |
path().c_str() ); |
---|
44 |
// allocate a lock |
---|
45 |
if(parent == NULL) { |
---|
46 |
m_UpdateLock = new Util::PosixMutex("CTLSVEL"); |
---|
47 |
} else { |
---|
48 |
m_UpdateLock = NULL; |
---|
49 |
} |
---|
50 |
// set verbose level AFTER allocating the lock |
---|
51 |
setVerboseLevel(m_Slave.getVerboseLevel()); |
---|
52 |
} |
---|
53 |
|
---|
54 |
void Element::setVerboseLevel( const DBus::Int32 &i) |
---|
55 |
{ |
---|
56 |
setDebugLevel(i); |
---|
57 |
m_Slave.setVerboseLevel(i); |
---|
58 |
if(m_UpdateLock) m_UpdateLock->setVerboseLevel(i); |
---|
59 |
} |
---|
60 |
|
---|
61 |
DBus::Int32 Element::getVerboseLevel() |
---|
62 |
{ |
---|
63 |
return getDebugLevel(); |
---|
64 |
} |
---|
65 |
|
---|
66 |
void |
---|
67 |
Element::Lock() |
---|
68 |
{ |
---|
69 |
if(m_Parent) { |
---|
70 |
m_Parent->Lock(); |
---|
71 |
} else { |
---|
72 |
m_UpdateLock->Lock(); |
---|
73 |
} |
---|
74 |
} |
---|
75 |
|
---|
76 |
void |
---|
77 |
Element::Unlock() |
---|
78 |
{ |
---|
79 |
if(m_Parent) { |
---|
80 |
m_Parent->Unlock(); |
---|
81 |
} else { |
---|
82 |
m_UpdateLock->Unlock(); |
---|
83 |
} |
---|
84 |
} |
---|
85 |
|
---|
86 |
Util::Mutex* |
---|
87 |
Element::getLock() |
---|
88 |
{ |
---|
89 |
if(m_Parent) { |
---|
90 |
return m_Parent->getLock(); |
---|
91 |
} else { |
---|
92 |
return m_UpdateLock; |
---|
93 |
} |
---|
94 |
} |
---|
95 |
|
---|
96 |
DBus::UInt64 |
---|
97 |
Element::getId( ) |
---|
98 |
{ |
---|
99 |
return m_Slave.getId(); |
---|
100 |
} |
---|
101 |
|
---|
102 |
DBus::String |
---|
103 |
Element::getName( ) |
---|
104 |
{ |
---|
105 |
return DBus::String(m_Slave.getName()); |
---|
106 |
} |
---|
107 |
|
---|
108 |
DBus::String |
---|
109 |
Element::getLabel( ) |
---|
110 |
{ |
---|
111 |
return DBus::String(m_Slave.getLabel()); |
---|
112 |
} |
---|
113 |
|
---|
114 |
DBus::String |
---|
115 |
Element::getDescription( ) |
---|
116 |
{ |
---|
117 |
return DBus::String(m_Slave.getDescription()); |
---|
118 |
} |
---|
119 |
|
---|
120 |
// --- Container |
---|
121 |
Container::Container( DBus::Connection& connection, std::string p, Element* parent, Control::Container &slave) |
---|
122 |
: Element(connection, p, parent, slave) |
---|
123 |
, m_Slave(slave) |
---|
124 |
{ |
---|
125 |
debugOutput( DEBUG_LEVEL_VERBOSE, "Created Container on '%s'\n", |
---|
126 |
path().c_str() ); |
---|
127 |
|
---|
128 |
setDebugLevel(slave.getVerboseLevel()); |
---|
129 |
|
---|
130 |
// register an update signal handler |
---|
131 |
m_updateFunctor = new MemberSignalFunctor1< Container*, |
---|
132 |
void (Container::*)(int) > |
---|
133 |
( this, &Container::updated, (int)Control::Container::eS_Updated ); |
---|
134 |
if(m_updateFunctor) { |
---|
135 |
if(!slave.addSignalHandler(m_updateFunctor)) { |
---|
136 |
debugWarning("Could not add update signal functor\n"); |
---|
137 |
} |
---|
138 |
} else { |
---|
139 |
debugWarning("Could not create update signal functor\n"); |
---|
140 |
} |
---|
141 |
|
---|
142 |
// build the initial tree |
---|
143 |
m_Slave = slave; |
---|
144 |
updateTree(); |
---|
145 |
} |
---|
146 |
|
---|
147 |
Container::~Container() { |
---|
148 |
debugOutput( DEBUG_LEVEL_VERBOSE, "Deleting Container on '%s'\n", |
---|
149 |
path().c_str() ); |
---|
150 |
|
---|
151 |
Destroyed(); //send dbus signal |
---|
152 |
|
---|
153 |
if(m_updateFunctor) { |
---|
154 |
if(!m_Slave.remSignalHandler(m_updateFunctor)) { |
---|
155 |
debugWarning("Could not remove update signal functor\n"); |
---|
156 |
} |
---|
157 |
} |
---|
158 |
delete m_updateFunctor; |
---|
159 |
|
---|
160 |
for ( ElementVectorIterator it = m_Children.begin(); |
---|
161 |
it != m_Children.end(); |
---|
162 |
++it ) |
---|
163 |
{ |
---|
164 |
delete (*it); |
---|
165 |
} |
---|
166 |
} |
---|
167 |
|
---|
168 |
void |
---|
169 |
Container::setVerboseLevel( const DBus::Int32 & i) |
---|
170 |
{ |
---|
171 |
Element::setVerboseLevel(i); |
---|
172 |
for ( ElementVectorIterator it = m_Children.begin(); |
---|
173 |
it != m_Children.end(); |
---|
174 |
++it ) |
---|
175 |
{ |
---|
176 |
(*it)->setVerboseLevel(i); |
---|
177 |
} |
---|
178 |
} |
---|
179 |
|
---|
180 |
DBus::Int32 |
---|
181 |
Container::getNbElements( ) { |
---|
182 |
return m_Slave.countElements(); |
---|
183 |
} |
---|
184 |
|
---|
185 |
DBus::String |
---|
186 |
Container::getElementName( const DBus::Int32& i ) { |
---|
187 |
int nbElements=m_Slave.countElements(); |
---|
188 |
if (i<nbElements) { |
---|
189 |
m_Slave.lockControl(); |
---|
190 |
const Control::ElementVector elements = m_Slave.getElementVector(); |
---|
191 |
Control::Element *e = elements.at(i); |
---|
192 |
std::string name; |
---|
193 |
if(e) name = e->getName(); |
---|
194 |
m_Slave.unlockControl(); |
---|
195 |
return name; |
---|
196 |
} else return ""; |
---|
197 |
} |
---|
198 |
// Util::MutexLockHelper lock(*m_access_lock); |
---|
199 |
|
---|
200 |
// NOTE: call with tree locked |
---|
201 |
void |
---|
202 |
Container::updateTree() |
---|
203 |
{ |
---|
204 |
bool something_changed = false; |
---|
205 |
debugOutput( DEBUG_LEVEL_VERBOSE, "Updating tree...\n"); |
---|
206 |
// send a pre update signal |
---|
207 |
PreUpdate(); |
---|
208 |
debugOutput( DEBUG_LEVEL_VERBOSE, "Add handlers for elements...\n"); |
---|
209 |
// add handlers for the slaves that don't have one yet |
---|
210 |
const Control::ElementVector elements = m_Slave.getElementVector(); |
---|
211 |
for ( Control::ConstElementVectorIterator it = elements.begin(); |
---|
212 |
it != elements.end(); |
---|
213 |
++it ) |
---|
214 |
{ |
---|
215 |
Element *e = findElementForControl((*it)); |
---|
216 |
if(e == NULL) { // element not in tree |
---|
217 |
e = createHandler(this, *(*it)); |
---|
218 |
if (e) { |
---|
219 |
e->setVerboseLevel(getDebugLevel()); |
---|
220 |
m_Children.push_back(e); |
---|
221 |
debugOutput( DEBUG_LEVEL_VERBOSE, "Created handler %p for Control::Element %s...\n", |
---|
222 |
e, (*it)->getName().c_str()); |
---|
223 |
something_changed = true; |
---|
224 |
} else { |
---|
225 |
debugWarning("Failed to create handler for Control::Element %s\n", |
---|
226 |
(*it)->getName().c_str()); |
---|
227 |
} |
---|
228 |
} else { |
---|
229 |
// element already present |
---|
230 |
debugOutput( DEBUG_LEVEL_VERBOSE, "Already have handler (%p) for Control::Element %s...\n", |
---|
231 |
e, (*it)->getName().c_str()); |
---|
232 |
} |
---|
233 |
} |
---|
234 |
|
---|
235 |
debugOutput( DEBUG_LEVEL_VERBOSE, "Remove handlers without element...\n"); |
---|
236 |
std::vector<Element *> to_remove; |
---|
237 |
// remove handlers that don't have a slave anymore |
---|
238 |
for ( ElementVectorIterator it = m_Children.begin(); |
---|
239 |
it != m_Children.end(); |
---|
240 |
++it ) |
---|
241 |
{ |
---|
242 |
Element *e = *it; |
---|
243 |
bool found = false; |
---|
244 |
for ( Control::ConstElementVectorIterator it2 = elements.begin(); |
---|
245 |
it2 != elements.end(); |
---|
246 |
++it2 ) |
---|
247 |
{ |
---|
248 |
if(&(e)->m_Slave == *it2) { |
---|
249 |
found = true; |
---|
250 |
debugOutput( DEBUG_LEVEL_VERBOSE, "Slave for handler %p at %s is present: Control::Element %s...\n", |
---|
251 |
e, e->path().c_str(), (*it)->getName().c_str()); |
---|
252 |
break; |
---|
253 |
} |
---|
254 |
} |
---|
255 |
|
---|
256 |
if (!found) { |
---|
257 |
debugOutput(DEBUG_LEVEL_VERBOSE, |
---|
258 |
"going to remove handler %p on path %s since slave is gone\n", |
---|
259 |
e, e->path().c_str()); |
---|
260 |
// can't remove while iterating |
---|
261 |
to_remove.push_back(e); |
---|
262 |
something_changed = true; |
---|
263 |
} |
---|
264 |
} |
---|
265 |
// do the actual remove |
---|
266 |
while(to_remove.size()) { |
---|
267 |
Element * e = *(to_remove.begin()); |
---|
268 |
removeElement(e); |
---|
269 |
to_remove.erase(to_remove.begin()); |
---|
270 |
} |
---|
271 |
|
---|
272 |
if(something_changed) { |
---|
273 |
debugOutput(DEBUG_LEVEL_VERBOSE, |
---|
274 |
"send dbus signal for path %s since something changed\n", |
---|
275 |
path().c_str()); |
---|
276 |
// send a dbus signal |
---|
277 |
Updated(); |
---|
278 |
} |
---|
279 |
// send a post update signal |
---|
280 |
PostUpdate(); |
---|
281 |
} |
---|
282 |
|
---|
283 |
void |
---|
284 |
Container::removeElement(Element *e) |
---|
285 |
{ |
---|
286 |
debugOutput(DEBUG_LEVEL_VERBOSE, |
---|
287 |
"removing handler %p on path %s\n", |
---|
288 |
e, path().c_str()); |
---|
289 |
for ( ElementVectorIterator it = m_Children.begin(); |
---|
290 |
it != m_Children.end(); |
---|
291 |
++it ) |
---|
292 |
{ |
---|
293 |
if(*it == e) { |
---|
294 |
m_Children.erase(it); |
---|
295 |
delete e; |
---|
296 |
return; |
---|
297 |
} |
---|
298 |
} |
---|
299 |
debugError("BUG: Element %p not found!\n", e); |
---|
300 |
} |
---|
301 |
|
---|
302 |
// NOTE: call with access lock held! |
---|
303 |
Element * |
---|
304 |
Container::findElementForControl(Control::Element *e) |
---|
305 |
{ |
---|
306 |
for ( ElementVectorIterator it = m_Children.begin(); |
---|
307 |
it != m_Children.end(); |
---|
308 |
++it ) |
---|
309 |
{ |
---|
310 |
if(&(*it)->m_Slave == e) return (*it); |
---|
311 |
} |
---|
312 |
return NULL; |
---|
313 |
} |
---|
314 |
|
---|
315 |
void |
---|
316 |
Container::updated(int new_nb_elements) |
---|
317 |
{ |
---|
318 |
debugOutput( DEBUG_LEVEL_VERBOSE, "Got updated signal, new count='%d'\n", |
---|
319 |
new_nb_elements ); |
---|
320 |
// we lock the tree first |
---|
321 |
Lock(); |
---|
322 |
|
---|
323 |
// also lock the slave tree |
---|
324 |
m_Slave.lockControl(); |
---|
325 |
|
---|
326 |
// update our tree |
---|
327 |
updateTree(); |
---|
328 |
|
---|
329 |
// now unlock the slave tree |
---|
330 |
m_Slave.unlockControl(); |
---|
331 |
|
---|
332 |
// and unlock the access |
---|
333 |
Unlock(); |
---|
334 |
} |
---|
335 |
|
---|
336 |
/** |
---|
337 |
* \brief create a correct DBusControl counterpart for a given Control::Element |
---|
338 |
*/ |
---|
339 |
Element * |
---|
340 |
Container::createHandler(Element *parent, Control::Element& e) { |
---|
341 |
debugOutput( DEBUG_LEVEL_VERBOSE, "Creating handler for '%s'\n", |
---|
342 |
e.getName().c_str() ); |
---|
343 |
|
---|
344 |
if (dynamic_cast<Control::Container *>(&e) != NULL) { |
---|
345 |
debugOutput( DEBUG_LEVEL_VERBOSE, "Source is a Control::Container\n"); |
---|
346 |
|
---|
347 |
return new Container(conn(), std::string(path()+"/"+e.getName()), |
---|
348 |
parent, *dynamic_cast<Control::Container *>(&e)); |
---|
349 |
} |
---|
350 |
|
---|
351 |
if (dynamic_cast<Control::Continuous *>(&e) != NULL) { |
---|
352 |
debugOutput( DEBUG_LEVEL_VERBOSE, "Source is a Control::Continuous\n"); |
---|
353 |
|
---|
354 |
return new Continuous(conn(), std::string(path()+"/"+e.getName()), |
---|
355 |
parent, *dynamic_cast<Control::Continuous *>(&e)); |
---|
356 |
} |
---|
357 |
|
---|
358 |
if (dynamic_cast<Control::Discrete *>(&e) != NULL) { |
---|
359 |
debugOutput( DEBUG_LEVEL_VERBOSE, "Source is a Control::Discrete\n"); |
---|
360 |
|
---|
361 |
return new Discrete(conn(), std::string(path()+"/"+e.getName()), |
---|
362 |
parent, *dynamic_cast<Control::Discrete *>(&e)); |
---|
363 |
} |
---|
364 |
|
---|
365 |
if (dynamic_cast<Control::Text *>(&e) != NULL) { |
---|
366 |
debugOutput( DEBUG_LEVEL_VERBOSE, "Source is a Control::Text\n"); |
---|
367 |
|
---|
368 |
return new Text(conn(), std::string(path()+"/"+e.getName()), |
---|
369 |
parent, *dynamic_cast<Control::Text *>(&e)); |
---|
370 |
} |
---|
371 |
|
---|
372 |
if (dynamic_cast<Control::Register *>(&e) != NULL) { |
---|
373 |
debugOutput( DEBUG_LEVEL_VERBOSE, "Source is a Control::Register\n"); |
---|
374 |
|
---|
375 |
return new Register(conn(), std::string(path()+"/"+e.getName()), |
---|
376 |
parent, *dynamic_cast<Control::Register *>(&e)); |
---|
377 |
} |
---|
378 |
|
---|
379 |
// note that we have to check this before checking the Enum, |
---|
380 |
// since Enum is a base class |
---|
381 |
if (dynamic_cast<Control::AttributeEnum *>(&e) != NULL) { |
---|
382 |
debugOutput( DEBUG_LEVEL_VERBOSE, "Source is a Control::AttributeEnum\n"); |
---|
383 |
|
---|
384 |
return new AttributeEnum(conn(), std::string(path()+"/"+e.getName()), |
---|
385 |
parent, *dynamic_cast<Control::AttributeEnum *>(&e)); |
---|
386 |
} |
---|
387 |
|
---|
388 |
if (dynamic_cast<Control::Enum *>(&e) != NULL) { |
---|
389 |
debugOutput( DEBUG_LEVEL_VERBOSE, "Source is a Control::Enum\n"); |
---|
390 |
|
---|
391 |
return new Enum(conn(), std::string(path()+"/"+e.getName()), |
---|
392 |
parent, *dynamic_cast<Control::Enum *>(&e)); |
---|
393 |
} |
---|
394 |
|
---|
395 |
if (dynamic_cast<ConfigRom *>(&e) != NULL) { |
---|
396 |
debugOutput( DEBUG_LEVEL_VERBOSE, "Source is a ConfigRom\n"); |
---|
397 |
|
---|
398 |
return new ConfigRomX(conn(), std::string(path()+"/"+e.getName()), |
---|
399 |
parent, *dynamic_cast<ConfigRom *>(&e)); |
---|
400 |
} |
---|
401 |
|
---|
402 |
if (dynamic_cast<Control::MatrixMixer *>(&e) != NULL) { |
---|
403 |
debugOutput( DEBUG_LEVEL_VERBOSE, "Source is a Control::MatrixMixer\n"); |
---|
404 |
|
---|
405 |
return new MatrixMixer(conn(), std::string(path()+"/"+e.getName()), |
---|
406 |
parent, *dynamic_cast<Control::MatrixMixer *>(&e)); |
---|
407 |
} |
---|
408 |
|
---|
409 |
debugOutput( DEBUG_LEVEL_VERBOSE, "Source is a Control::Element\n"); |
---|
410 |
return new Element(conn(), std::string(path()+"/"+e.getName()), parent, e); |
---|
411 |
} |
---|
412 |
|
---|
413 |
// --- Continuous |
---|
414 |
|
---|
415 |
Continuous::Continuous( DBus::Connection& connection, std::string p, Element* parent, Control::Continuous &slave) |
---|
416 |
: Element(connection, p, parent, slave) |
---|
417 |
, m_Slave(slave) |
---|
418 |
{ |
---|
419 |
debugOutput( DEBUG_LEVEL_VERBOSE, "Created Continuous on '%s'\n", |
---|
420 |
path().c_str() ); |
---|
421 |
} |
---|
422 |
|
---|
423 |
DBus::Double |
---|
424 |
Continuous::setValue( const DBus::Double& value ) |
---|
425 |
{ |
---|
426 |
m_Slave.setValue(value); |
---|
427 |
/* |
---|
428 |
SleepRelativeUsec(1000*500); |
---|
429 |
|
---|
430 |
debugOutput( DEBUG_LEVEL_VERBOSE, "setValue(%lf) => %lf\n", value, m_Slave.getValue() ); |
---|
431 |
|
---|
432 |
return m_Slave.getValue();*/ |
---|
433 |
return value; |
---|
434 |
} |
---|
435 |
|
---|
436 |
DBus::Double |
---|
437 |
Continuous::getValue( ) |
---|
438 |
{ |
---|
439 |
double val = m_Slave.getValue(); |
---|
440 |
debugOutput( DEBUG_LEVEL_VERBOSE, "getValue() => %lf\n", val ); |
---|
441 |
return val; |
---|
442 |
} |
---|
443 |
|
---|
444 |
DBus::Double |
---|
445 |
Continuous::setValueIdx( const DBus::Int32 & idx, const DBus::Double& value ) |
---|
446 |
{ |
---|
447 |
m_Slave.setValue(idx, value); |
---|
448 |
/* |
---|
449 |
SleepRelativeUsec(1000*500); |
---|
450 |
|
---|
451 |
debugOutput( DEBUG_LEVEL_VERBOSE, "setValue(%lf) => %lf\n", value, m_Slave.getValue() ); |
---|
452 |
|
---|
453 |
return m_Slave.getValue();*/ |
---|
454 |
return value; |
---|
455 |
} |
---|
456 |
|
---|
457 |
DBus::Double |
---|
458 |
Continuous::getValueIdx( const DBus::Int32 & idx ) |
---|
459 |
{ |
---|
460 |
double val = m_Slave.getValue(idx); |
---|
461 |
debugOutput( DEBUG_LEVEL_VERBOSE, "getValue(%d) => %lf\n", idx, val ); |
---|
462 |
return val; |
---|
463 |
} |
---|
464 |
|
---|
465 |
DBus::Double |
---|
466 |
Continuous::getMinimum() |
---|
467 |
{ |
---|
468 |
double val = m_Slave.getMinimum(); |
---|
469 |
debugOutput( DEBUG_LEVEL_VERBOSE, "getMinimum() => %lf\n", val ); |
---|
470 |
return val; |
---|
471 |
} |
---|
472 |
|
---|
473 |
DBus::Double |
---|
474 |
Continuous::getMaximum() |
---|
475 |
{ |
---|
476 |
double val = m_Slave.getMaximum(); |
---|
477 |
debugOutput( DEBUG_LEVEL_VERBOSE, "getMaximum() => %lf\n", val ); |
---|
478 |
return val; |
---|
479 |
} |
---|
480 |
|
---|
481 |
// --- Discrete |
---|
482 |
|
---|
483 |
Discrete::Discrete( DBus::Connection& connection, std::string p, Element* parent, Control::Discrete &slave) |
---|
484 |
: Element(connection, p, parent, slave) |
---|
485 |
, m_Slave(slave) |
---|
486 |
{ |
---|
487 |
debugOutput( DEBUG_LEVEL_VERBOSE, "Created Discrete on '%s'\n", |
---|
488 |
path().c_str() ); |
---|
489 |
} |
---|
490 |
|
---|
491 |
DBus::Int32 |
---|
492 |
Discrete::setValue( const DBus::Int32& value ) |
---|
493 |
{ |
---|
494 |
m_Slave.setValue(value); |
---|
495 |
|
---|
496 |
/* SleepRelativeUsec(1000*500); |
---|
497 |
debugOutput( DEBUG_LEVEL_VERBOSE, "setValue(%d) => %d\n", value, m_Slave.getValue() ); |
---|
498 |
|
---|
499 |
return m_Slave.getValue();*/ |
---|
500 |
return value; |
---|
501 |
} |
---|
502 |
|
---|
503 |
DBus::Int32 |
---|
504 |
Discrete::getValue() |
---|
505 |
{ |
---|
506 |
int32_t val = m_Slave.getValue(); |
---|
507 |
debugOutput( DEBUG_LEVEL_VERBOSE, "getValue() => %d\n", val ); |
---|
508 |
return val; |
---|
509 |
} |
---|
510 |
|
---|
511 |
DBus::Int32 |
---|
512 |
Discrete::setValueIdx( const DBus::Int32& idx, const DBus::Int32& value ) |
---|
513 |
{ |
---|
514 |
m_Slave.setValue(idx, value); |
---|
515 |
|
---|
516 |
/* SleepRelativeUsec(1000*500); |
---|
517 |
debugOutput( DEBUG_LEVEL_VERBOSE, "setValue(%d) => %d\n", value, m_Slave.getValue() ); |
---|
518 |
|
---|
519 |
return m_Slave.getValue();*/ |
---|
520 |
return value; |
---|
521 |
} |
---|
522 |
|
---|
523 |
DBus::Int32 |
---|
524 |
Discrete::getValueIdx( const DBus::Int32& idx ) |
---|
525 |
{ |
---|
526 |
int32_t val = m_Slave.getValue(idx); |
---|
527 |
debugOutput( DEBUG_LEVEL_VERBOSE, "getValue(%d) => %d\n", idx, val ); |
---|
528 |
return val; |
---|
529 |
} |
---|
530 |
|
---|
531 |
// --- Text |
---|
532 |
|
---|
533 |
Text::Text( DBus::Connection& connection, std::string p, Element* parent, Control::Text &slave) |
---|
534 |
: Element(connection, p, parent, slave) |
---|
535 |
, m_Slave(slave) |
---|
536 |
{ |
---|
537 |
debugOutput( DEBUG_LEVEL_VERBOSE, "Created Text on '%s'\n", |
---|
538 |
path().c_str() ); |
---|
539 |
} |
---|
540 |
|
---|
541 |
DBus::String |
---|
542 |
Text::setValue( const DBus::String& value ) |
---|
543 |
{ |
---|
544 |
m_Slave.setValue(value); |
---|
545 |
|
---|
546 |
/* SleepRelativeUsec(1000*500); |
---|
547 |
debugOutput( DEBUG_LEVEL_VERBOSE, "setValue(%d) => %d\n", value, m_Slave.getValue() ); |
---|
548 |
|
---|
549 |
return m_Slave.getValue();*/ |
---|
550 |
return value; |
---|
551 |
} |
---|
552 |
|
---|
553 |
DBus::String |
---|
554 |
Text::getValue() |
---|
555 |
{ |
---|
556 |
std::string val = m_Slave.getValue(); |
---|
557 |
debugOutput( DEBUG_LEVEL_VERBOSE, "getValue() => %s\n", val.c_str() ); |
---|
558 |
return val; |
---|
559 |
} |
---|
560 |
|
---|
561 |
// --- Register |
---|
562 |
|
---|
563 |
Register::Register( DBus::Connection& connection, std::string p, Element* parent, Control::Register &slave) |
---|
564 |
: Element(connection, p, parent, slave) |
---|
565 |
, m_Slave(slave) |
---|
566 |
{ |
---|
567 |
debugOutput( DEBUG_LEVEL_VERBOSE, "Created Register on '%s'\n", |
---|
568 |
path().c_str() ); |
---|
569 |
} |
---|
570 |
|
---|
571 |
DBus::UInt64 |
---|
572 |
Register::setValue( const DBus::UInt64& addr, const DBus::UInt64& value ) |
---|
573 |
{ |
---|
574 |
m_Slave.setValue(addr, value); |
---|
575 |
|
---|
576 |
/* SleepRelativeUsec(1000*500); |
---|
577 |
debugOutput( DEBUG_LEVEL_VERBOSE, "setValue(%d) => %d\n", value, m_Slave.getValue() ); |
---|
578 |
|
---|
579 |
return m_Slave.getValue();*/ |
---|
580 |
return value; |
---|
581 |
} |
---|
582 |
|
---|
583 |
DBus::UInt64 |
---|
584 |
Register::getValue( const DBus::UInt64& addr ) |
---|
585 |
{ |
---|
586 |
DBus::UInt64 val = m_Slave.getValue(addr); |
---|
587 |
debugOutput( DEBUG_LEVEL_VERBOSE, "getValue(%lld) => %lld\n", addr, val ); |
---|
588 |
return val; |
---|
589 |
} |
---|
590 |
|
---|
591 |
// --- Enum |
---|
592 |
|
---|
593 |
Enum::Enum( DBus::Connection& connection, std::string p, Element* parent, Control::Enum &slave) |
---|
594 |
: Element(connection, p, parent, slave) |
---|
595 |
, m_Slave(slave) |
---|
596 |
{ |
---|
597 |
debugOutput( DEBUG_LEVEL_VERBOSE, "Created Enum on '%s'\n", |
---|
598 |
path().c_str() ); |
---|
599 |
} |
---|
600 |
|
---|
601 |
DBus::Int32 |
---|
602 |
Enum::select( const DBus::Int32& idx ) |
---|
603 |
{ |
---|
604 |
debugOutput( DEBUG_LEVEL_VERBOSE, "select(%d)\n", idx ); |
---|
605 |
return m_Slave.select(idx); |
---|
606 |
} |
---|
607 |
|
---|
608 |
DBus::Int32 |
---|
609 |
Enum::selected() |
---|
610 |
{ |
---|
611 |
int retval = m_Slave.selected(); |
---|
612 |
debugOutput( DEBUG_LEVEL_VERBOSE, "selected() => %d\n", retval ); |
---|
613 |
return retval; |
---|
614 |
} |
---|
615 |
|
---|
616 |
DBus::Int32 |
---|
617 |
Enum::count() |
---|
618 |
{ |
---|
619 |
int retval = m_Slave.count(); |
---|
620 |
debugOutput( DEBUG_LEVEL_VERBOSE, "count() => %d\n", retval ); |
---|
621 |
return retval; |
---|
622 |
} |
---|
623 |
|
---|
624 |
DBus::String |
---|
625 |
Enum::getEnumLabel( const DBus::Int32 & idx ) |
---|
626 |
{ |
---|
627 |
std::string retval = m_Slave.getEnumLabel(idx); |
---|
628 |
debugOutput( DEBUG_LEVEL_VERBOSE, "getEnumLabel(%d) => %s\n", idx, retval.c_str() ); |
---|
629 |
return retval; |
---|
630 |
} |
---|
631 |
|
---|
632 |
// --- AttributeEnum |
---|
633 |
AttributeEnum::AttributeEnum( DBus::Connection& connection, std::string p, Element* parent, Control::AttributeEnum &slave) |
---|
634 |
: Element(connection, p, parent, slave) |
---|
635 |
, m_Slave(slave) |
---|
636 |
{ |
---|
637 |
debugOutput( DEBUG_LEVEL_VERBOSE, "Created Enum on '%s'\n", |
---|
638 |
path().c_str() ); |
---|
639 |
} |
---|
640 |
|
---|
641 |
DBus::Int32 |
---|
642 |
AttributeEnum::select( const DBus::Int32& idx ) |
---|
643 |
{ |
---|
644 |
debugOutput( DEBUG_LEVEL_VERBOSE, "select(%d)\n", idx ); |
---|
645 |
return m_Slave.select(idx); |
---|
646 |
} |
---|
647 |
|
---|
648 |
DBus::Int32 |
---|
649 |
AttributeEnum::selected() |
---|
650 |
{ |
---|
651 |
int retval = m_Slave.selected(); |
---|
652 |
debugOutput( DEBUG_LEVEL_VERBOSE, "selected() => %d\n", retval ); |
---|
653 |
return retval; |
---|
654 |
} |
---|
655 |
|
---|
656 |
DBus::Int32 |
---|
657 |
AttributeEnum::count() |
---|
658 |
{ |
---|
659 |
int retval = m_Slave.count(); |
---|
660 |
debugOutput( DEBUG_LEVEL_VERBOSE, "count() => %d\n", retval ); |
---|
661 |
return retval; |
---|
662 |
} |
---|
663 |
|
---|
664 |
DBus::Int32 |
---|
665 |
AttributeEnum::attributeCount() |
---|
666 |
{ |
---|
667 |
int retval = m_Slave.attributeCount(); |
---|
668 |
debugOutput( DEBUG_LEVEL_VERBOSE, "attributeCount() => %d\n", retval ); |
---|
669 |
return retval; |
---|
670 |
} |
---|
671 |
|
---|
672 |
DBus::String |
---|
673 |
AttributeEnum::getEnumLabel( const DBus::Int32 & idx ) |
---|
674 |
{ |
---|
675 |
std::string retval = m_Slave.getEnumLabel(idx); |
---|
676 |
debugOutput( DEBUG_LEVEL_VERBOSE, "getEnumLabel(%d) => %s\n", idx, retval.c_str() ); |
---|
677 |
return retval; |
---|
678 |
} |
---|
679 |
|
---|
680 |
DBus::String |
---|
681 |
AttributeEnum::getAttributeValue( const DBus::Int32 & idx ) |
---|
682 |
{ |
---|
683 |
std::string retval = m_Slave.getAttributeValue(idx); |
---|
684 |
debugOutput( DEBUG_LEVEL_VERBOSE, "getAttributeValue(%d) => %s\n", idx, retval.c_str() ); |
---|
685 |
return retval; |
---|
686 |
} |
---|
687 |
|
---|
688 |
DBus::String |
---|
689 |
AttributeEnum::getAttributeName( const DBus::Int32 & idx ) |
---|
690 |
{ |
---|
691 |
std::string retval = m_Slave.getAttributeName(idx); |
---|
692 |
debugOutput( DEBUG_LEVEL_VERBOSE, "getAttributeName(%d) => %s\n", idx, retval.c_str() ); |
---|
693 |
return retval; |
---|
694 |
} |
---|
695 |
|
---|
696 |
// --- ConfigRom |
---|
697 |
|
---|
698 |
ConfigRomX::ConfigRomX( DBus::Connection& connection, std::string p, Element* parent, ConfigRom &slave) |
---|
699 |
: Element(connection, p, parent, slave) |
---|
700 |
, m_Slave(slave) |
---|
701 |
{ |
---|
702 |
debugOutput( DEBUG_LEVEL_VERBOSE, "Created ConfigRomX on '%s'\n", |
---|
703 |
path().c_str() ); |
---|
704 |
} |
---|
705 |
|
---|
706 |
DBus::String |
---|
707 |
ConfigRomX::getGUID( ) |
---|
708 |
{ |
---|
709 |
return m_Slave.getGuidString(); |
---|
710 |
} |
---|
711 |
|
---|
712 |
DBus::String |
---|
713 |
ConfigRomX::getVendorName( ) |
---|
714 |
{ |
---|
715 |
return m_Slave.getVendorName(); |
---|
716 |
} |
---|
717 |
|
---|
718 |
DBus::String |
---|
719 |
ConfigRomX::getModelName( ) |
---|
720 |
{ |
---|
721 |
return m_Slave.getModelName(); |
---|
722 |
} |
---|
723 |
|
---|
724 |
DBus::Int32 |
---|
725 |
ConfigRomX::getVendorId( ) |
---|
726 |
{ |
---|
727 |
return m_Slave.getNodeVendorId(); |
---|
728 |
} |
---|
729 |
|
---|
730 |
DBus::Int32 |
---|
731 |
ConfigRomX::getModelId( ) |
---|
732 |
{ |
---|
733 |
return m_Slave.getModelId(); |
---|
734 |
} |
---|
735 |
|
---|
736 |
DBus::Int32 |
---|
737 |
ConfigRomX::getUnitVersion( ) |
---|
738 |
{ |
---|
739 |
return m_Slave.getUnitVersion(); |
---|
740 |
} |
---|
741 |
|
---|
742 |
// --- MatrixMixer |
---|
743 |
|
---|
744 |
MatrixMixer::MatrixMixer( DBus::Connection& connection, std::string p, Element* parent, Control::MatrixMixer &slave) |
---|
745 |
: Element(connection, p, parent, slave) |
---|
746 |
, m_Slave(slave) |
---|
747 |
{ |
---|
748 |
debugOutput( DEBUG_LEVEL_VERBOSE, "Created MatrixMixer on '%s'\n", |
---|
749 |
path().c_str() ); |
---|
750 |
} |
---|
751 |
|
---|
752 |
DBus::String |
---|
753 |
MatrixMixer::getRowName( const DBus::Int32& row) { |
---|
754 |
return m_Slave.getRowName(row); |
---|
755 |
} |
---|
756 |
|
---|
757 |
DBus::String |
---|
758 |
MatrixMixer::getColName( const DBus::Int32& col) { |
---|
759 |
return m_Slave.getColName(col); |
---|
760 |
} |
---|
761 |
|
---|
762 |
DBus::Int32 |
---|
763 |
MatrixMixer::canWrite( const DBus::Int32& row, const DBus::Int32& col) { |
---|
764 |
return m_Slave.canWrite(row,col); |
---|
765 |
} |
---|
766 |
|
---|
767 |
DBus::Double |
---|
768 |
MatrixMixer::setValue( const DBus::Int32& row, const DBus::Int32& col, const DBus::Double& val ) { |
---|
769 |
return m_Slave.setValue(row,col,val); |
---|
770 |
} |
---|
771 |
|
---|
772 |
DBus::Double |
---|
773 |
MatrixMixer::getValue( const DBus::Int32& row, const DBus::Int32& col) { |
---|
774 |
return m_Slave.getValue(row,col); |
---|
775 |
} |
---|
776 |
|
---|
777 |
DBus::Int32 |
---|
778 |
MatrixMixer::getRowCount( ) { |
---|
779 |
return m_Slave.getRowCount(); |
---|
780 |
} |
---|
781 |
|
---|
782 |
DBus::Int32 |
---|
783 |
MatrixMixer::getColCount( ) { |
---|
784 |
return m_Slave.getColCount(); |
---|
785 |
} |
---|
786 |
|
---|
787 |
} // end of namespace Control |
---|