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