- Timestamp:
- Oct 28, 2013, 3:24:14 PM (11 years ago)
- Location:
- trunk/src/PacpusLib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/PacpusLib/ComponentBase.cpp
r182 r201 9 9 #include <Pacpus/kernel/ComponentManager.h> 10 10 #include <Pacpus/kernel/Log.h> 11 #include <Pacpus/kernel/PacpusException.h> 11 12 12 13 #include <boost/program_options/parsers.hpp> … … 210 211 vector<string> xargs = convertAttributesToArgumentVector(cfg.getProperties()); 211 212 212 boost::program_options::variables_map vm;213 po::variables_map vm; 213 214 try { 214 215 po::store( … … 220 221 po::notify(vm); 221 222 } catch (po::error & e) { 222 LOG_ ERROR(e.what());223 throw ;223 LOG_WARN(e.what()); 224 throw PacpusException(e.what()); 224 225 } 225 226 -
trunk/src/PacpusLib/ComponentManager.cpp
r199 r201 13 13 #include <Pacpus/kernel/InputOutputBase.h> 14 14 #include <Pacpus/kernel/Log.h> 15 #include <Pacpus/kernel/PacpusException.h> 15 16 16 17 #include <QDomNodeList> … … 290 291 if (NULL == component) { 291 292 LOG_WARN("component '" << componentName << "' does not exist"); 292 } else { 293 component->param.localCopy(cfg.qDomElement()); 293 continue; 294 } 295 296 component->param.localCopy(cfg.qDomElement()); 297 try { 294 298 component->parseParameters(cfg); 295 299 component->setConfigurationState(component->configureComponent(cfg)); 300 } catch (PacpusException & e) { 301 LOG_ERROR("component '" << componentName << "' has thrown an exception"); 302 LOG_ERROR(e.what()); 303 component->setConfigurationState(ComponentBase::CONFIGURED_FAILED); 296 304 } 297 305 } // for 298 306 299 307 // Third, if some components requested a delayed configuration, retry 300 for (int i = 0 ; i < componentsNodeList.size(); ++i) {308 for (int i = 0, iend = componentsNodeList.size(); i < iend; ++i) { 301 309 cfg.localCopy(componentsNodeList.item(i).toElement()); 302 310 QString componentName = cfg.getComponentName(); … … 305 313 if (NULL == component) { 306 314 LOG_WARN("component '" << componentName << "' does not exist"); 315 continue; 316 } 317 318 // Pacpus 2.0 : add inputs and outputs 319 component->addInputs(); 320 component->addOutputs(); 321 322 if (ComponentBase::CONFIGURATION_DELAYED == component->configurationState()) { 323 LOG_DEBUG("try to configure component '" << componentName << "'"); 324 325 // copy locally the config parameters of the component 326 component->param.localCopy(cfg.qDomElement()); 327 component->setConfigurationState(component->configureComponent(cfg)); 328 } 329 330 if (ComponentBase::CONFIGURED_OK == component->configurationState()) { 331 --componentsToConfigureCount; 307 332 } else { 308 // Pacpus 2.0 : add inputs and outputs 309 component->addInputs(); 310 component->addOutputs(); 311 312 if (ComponentBase::CONFIGURATION_DELAYED == component->configurationState()) { 313 LOG_DEBUG("try to configure component '" << componentName << "'"); 314 315 // copy locally the config parameters of the component 316 component->param.localCopy(cfg.qDomElement()); 317 component->setConfigurationState(component->configureComponent(cfg)); 318 } 319 320 if (ComponentBase::CONFIGURED_OK == component->configurationState()) { 321 --componentsToConfigureCount; 322 } else { 323 LOG_ERROR("cannot configure component '" << componentName << "'" 324 << ". Dependencies with other components are too complex" 325 << ". It was not configured, please review your configuration and/or your component" 326 ); 327 component->setConfigurationState(ComponentBase::CONFIGURED_FAILED); 328 } 333 LOG_ERROR("cannot configure component '" << componentName << "'" 334 << ". Dependencies with other components are too complex" 335 << ". It was not configured, please review your configuration and/or your component" 336 ); 337 component->setConfigurationState(ComponentBase::CONFIGURED_FAILED); 329 338 } 330 339 } // for … … 338 347 QDomNodeList connectionsNodeList = xmlTree_->getAllConnections(); 339 348 340 for (int i = 0 ; i < connectionsNodeList.size(); ++i) {349 for (int i = 0, iend = connectionsNodeList.size(); i < iend; ++i) { 341 350 cfg.localCopy(connectionsNodeList.item(i).toElement()); 342 351 QString connectionInput = cfg.getConnectionInput(); … … 372 381 } 373 382 374 bool ComponentManager::start(const QString & componentName)383 bool ComponentManager::start(const QString & componentName) 375 384 { 376 385 LOG_TRACE("start(component=" << componentName << ")"); … … 382 391 } 383 392 393 if (ComponentBase::CONFIGURED_OK != component->configurationState()) { 394 LOG_WARN("cannot start component '" << componentName << "'. It has not been configured properly!"); 395 return false; 396 } 397 384 398 LOG_INFO("starting component '" << componentName << "'..."); 385 399 if (!component->startComponent()) { … … 402 416 } 403 417 404 bool ComponentManager::stop(ComponentBase * component) const418 bool ComponentManager::stop(ComponentBase * component) const 405 419 { 406 420 if (!component) { … … 414 428 } 415 429 416 bool ComponentManager::stop(const QString & componentName)430 bool ComponentManager::stop(const QString & componentName) 417 431 { 418 432 LOG_TRACE("stop(component=" << componentName << ")"); … … 432 446 } 433 447 434 ComponentBase * ComponentManager::getComponent(const QString& name)448 ComponentBase * ComponentManager::getComponent(const QString & name) 435 449 { 436 450 LOG_TRACE("getComponent(name=" << name << ")");
Note:
See TracChangeset
for help on using the changeset viewer.