Changeset 288 in pacpusframework for trunk/src/DBITEPlayerLib
- Timestamp:
- Mar 26, 2014, 9:27:30 PM (11 years ago)
- Location:
- trunk/src/DBITEPlayerLib
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/DBITEPlayerLib/DbtPlyEngine.cpp
r277 r288 10 10 #include <Pacpus/kernel/Log.h> 11 11 12 #include < cassert>12 #include <boost/assert.hpp> 13 13 #include <limits> 14 14 #include <QDir> … … 226 226 void DbtPlyEngine::playEvent() 227 227 { 228 using boost::dynamic_pointer_cast; 229 228 230 LOG_DEBUG("Clicked: play"); 229 231 230 232 // get user interface 231 233 ComponentManager * mgr = ComponentManager::getInstance(); 232 DbtPlyUserInterface * ui = dynamic_cast<DbtPlyUserInterface *>(mgr->getComponent("dbiteUserInterface"));233 assert(ui);234 boost::shared_ptr<DbtPlyUserInterface> ui = dynamic_pointer_cast<DbtPlyUserInterface>(mgr->getComponent("dbiteUserInterface")); 235 BOOST_ASSERT(ui); 234 236 // get time value from slider 235 237 lastTDbt_ = ui->getTime() + tDbtMin_; … … 268 270 void DbtPlyEngine::setState(DbtPlyEngineState * newState) 269 271 { 270 assert(newState);272 BOOST_ASSERT(newState); 271 273 LOG_DEBUG(mCurrentState->toString() << " => " << newState->toString()); 272 274 mCurrentState = newState; … … 284 286 mSpeed = kMaxSpeed; 285 287 } 286 assert(kMinSpeed <= mSpeed);287 assert(mSpeed <= kMaxSpeed);288 BOOST_ASSERT(kMinSpeed <= mSpeed); 289 BOOST_ASSERT(mSpeed <= kMaxSpeed); 288 290 LOG_INFO("event: Speed Up, speed = " << mSpeed); 289 291 Q_EMIT displayStateSig(mCurrentState, mSpeed); … … 296 298 mSpeed = kMinSpeed; 297 299 } 298 assert(kMinSpeed <= mSpeed);299 assert(mSpeed <= kMaxSpeed);300 BOOST_ASSERT(kMinSpeed <= mSpeed); 301 BOOST_ASSERT(mSpeed <= kMaxSpeed); 300 302 LOG_INFO("event: Speed Up, speed = " << mSpeed); 301 303 Q_EMIT displayStateSig(mCurrentState, mSpeed); … … 304 306 void DbtPlyEngine::reset() 305 307 { 308 using boost::dynamic_pointer_cast; 309 306 310 lastTNow_ = road_time(); 307 311 lastTDbt_ = tDbtMin_; … … 311 315 // get user interface 312 316 ComponentManager * mgr = ComponentManager::getInstance(); 313 DbtPlyUserInterface * ui = dynamic_cast<DbtPlyUserInterface *>(mgr->getComponent("dbiteUserInterface"));314 assert(ui);317 boost::shared_ptr<DbtPlyUserInterface> ui = dynamic_pointer_cast<DbtPlyUserInterface>(mgr->getComponent("dbiteUserInterface")); 318 BOOST_ASSERT(ui); 315 319 // reset time value of the slider 316 320 ui->resetTime(); -
trunk/src/DBITEPlayerLib/DbtPlyFileManager.cpp
r181 r288 67 67 ComponentBase::COMPONENT_CONFIGURATION DbtPlyFileManager::configureComponent(XmlComponentConfig config) 68 68 { 69 using boost::dynamic_pointer_cast; 70 69 71 ComponentManager * mgr = ComponentManager::getInstance(); 70 mEngine = static_cast<DbtPlyEngine *>(mgr->getComponent("dbiteEngine"));71 if ( NULL == mEngine) {72 mEngine = dynamic_pointer_cast<DbtPlyEngine>(mgr->getComponent("dbiteEngine")); 73 if (!mEngine) { 72 74 LOG_FATAL("cannot get a pointer of the 'dbiteEngine' component"); 73 75 return CONFIGURED_FAILED; … … 81 83 // register the road_time_t type for the connection 82 84 qRegisterMetaType<road_time_t>("road_time_t"); 83 connect(mEngine , SIGNAL(play(road_time_t,road_time_t, bool)),85 connect(mEngine.get(), SIGNAL(play(road_time_t,road_time_t, bool)), 84 86 this, SLOT(playData(road_time_t,road_time_t, bool)), 85 87 Qt::DirectConnection); 86 88 connect(this, SIGNAL(tMinMaxIs(road_time_t,road_time_t )), 87 mEngine , SLOT(tMinMax(road_time_t, road_time_t)));88 connect(mEngine , SIGNAL(stopfile()),89 mEngine.get(), SLOT(tMinMax(road_time_t, road_time_t))); 90 connect(mEngine.get(), SIGNAL(stopfile()), 89 91 this, SLOT (beginfile())); 90 92 -
trunk/src/DBITEPlayerLib/DbtPlyTrigger.cpp
r152 r288 39 39 ComponentBase::COMPONENT_CONFIGURATION DbtPlyTrigger::configureComponent(XmlComponentConfig /*config*/) 40 40 { 41 using boost::dynamic_pointer_cast; 42 41 43 ComponentManager * mgr = ComponentManager::getInstance(); 42 44 // we get a pointer to the engine component 43 mEngine = dynamic_ cast<DbtPlyEngine *>(mgr->getComponent("dbiteEngine"));44 if ( NULL ==mEngine) {45 mEngine = dynamic_pointer_cast<DbtPlyEngine>(mgr->getComponent("dbiteEngine")); 46 if (!mEngine) { 45 47 LOG_FATAL("cannot get a pointer of the 'dbiteEngine' component"); 46 48 return CONFIGURED_FAILED; 47 49 } 48 50 connect(this, SIGNAL(triggerSig()), 49 mEngine ,SLOT(engReceiver()),51 mEngine.get(), SLOT(engReceiver()), 50 52 Qt::DirectConnection); 51 53 -
trunk/src/DBITEPlayerLib/DbtPlyUserInterface.cpp
r152 r288 61 61 ComponentBase::COMPONENT_CONFIGURATION DbtPlyUserInterface::configureComponent(XmlComponentConfig /*config*/) 62 62 { 63 using boost::dynamic_pointer_cast; 64 63 65 ComponentManager * mgr = ComponentManager::getInstance(); 64 mEngine = dynamic_ cast<DbtPlyEngine *>(mgr->getComponent("dbiteEngine"));65 if ( NULL ==mEngine) {66 mEngine = dynamic_pointer_cast<DbtPlyEngine>(mgr->getComponent("dbiteEngine")); 67 if (!mEngine) { 66 68 LOG_FATAL("cannot get a pointer of the 'dbiteEngine' component"); 67 69 return CONFIGURED_FAILED; … … 275 277 componentTableWidget->setItem(idx, 0, new QTableWidgetItem(componentName)); 276 278 277 ComponentBase * component = mgr->getComponent(componentName); 278 if (component) { 279 COMPONENT_STATE state = component->getState(); 280 281 QString stateString; 282 switch (state) { 283 case STOPPED: 284 stateString = tr("Stopped"); 285 break; 286 case NOT_MONITORED: 287 stateString = tr("Not monitored"); 288 break; 289 case MONITOR_OK: 290 stateString = tr("Monitor OK"); 291 break; 292 case MONITOR_NOK: 293 stateString = tr("Monitor wrong"); 294 break; 295 296 default: 297 stateString = tr("UNKNOWN"); 298 break; 299 } 300 componentTableWidget->setItem(idx, 1, new QTableWidgetItem(stateString)); 301 302 // TODO: ADD component type and some detailed information (e.g. parameters) 303 //QString componentInfo = component->getDetails(); 304 //componentTableWidget->setItem(idx, 2, new QTableWidgetItem(componentInfo)); 279 ComponentSharedPointer component = mgr->getComponent(componentName); 280 if (!component) { 281 continue; 305 282 } 283 284 COMPONENT_STATE state = component->getState(); 285 286 QString stateString; 287 switch (state) { 288 case STOPPED: 289 stateString = tr("Stopped"); 290 break; 291 case NOT_MONITORED: 292 stateString = tr("Not monitored"); 293 break; 294 case MONITOR_OK: 295 stateString = tr("Monitor OK"); 296 break; 297 case MONITOR_NOK: 298 stateString = tr("Monitor wrong"); 299 break; 300 301 default: 302 stateString = tr("UNKNOWN"); 303 break; 304 } 305 componentTableWidget->setItem(idx, 1, new QTableWidgetItem(stateString)); 306 307 // TODO: ADD component type and some detailed information (e.g. parameters) 308 //QString componentInfo = component->getDetails(); 309 //componentTableWidget->setItem(idx, 2, new QTableWidgetItem(componentInfo)); 306 310 } 307 311 } … … 309 313 void DbtPlyUserInterface::connectButtons() 310 314 { 315 // FIXME: use Qt5 connect style 311 316 connect(playBut, SIGNAL(clicked()), 312 mEngine , SLOT(playEvent()));317 mEngine.get(), SLOT(playEvent())); 313 318 connect(pauseBut, SIGNAL(clicked()), 314 mEngine , SLOT(pauseEvent()));319 mEngine.get(), SLOT(pauseEvent())); 315 320 connect(stopBut, SIGNAL(clicked()), 316 mEngine , SLOT(stopEvent()));321 mEngine.get(), SLOT(stopEvent())); 317 322 connect(speedUpBut, SIGNAL(clicked()), 318 mEngine , SLOT(speedUpEvent()));323 mEngine.get(), SLOT(speedUpEvent())); 319 324 connect(speedDownBut, SIGNAL(clicked()), 320 mEngine , SLOT(speedDownEvent()));325 mEngine.get(), SLOT(speedDownEvent())); 321 326 } 322 327 323 328 void DbtPlyUserInterface::connectDisplay() 324 329 { 325 connect(mEngine , SIGNAL(displayStateSig(DbtPlyEngineState *, float)),330 connect(mEngine.get(), SIGNAL(displayStateSig(DbtPlyEngineState *, float)), 326 331 this, SLOT(displayStateSlot(DbtPlyEngineState *, float))); 327 332 328 connect (mEngine , SIGNAL(timeMinMax(road_time_t, road_time_t)),333 connect (mEngine.get(), SIGNAL(timeMinMax(road_time_t, road_time_t)), 329 334 this, SLOT(displayMinMaxTime(road_time_t , road_time_t))); 330 connect (mEngine , SIGNAL(curReplayTime(road_time_t)),335 connect (mEngine.get(), SIGNAL(curReplayTime(road_time_t)), 331 336 this, SLOT(displayTime(road_time_t))); 332 337 connect (rev, SIGNAL(toggled(bool)), 333 mEngine , SLOT(changeDirection(bool)));338 mEngine.get(), SLOT(changeDirection(bool))); 334 339 } 335 340 … … 337 342 { 338 343 connect (timeSlider, SIGNAL(sliderPressed()), 339 mEngine , SLOT(pauseEvent()));344 mEngine.get(), SLOT(pauseEvent())); 340 345 connect (timeSlider, SIGNAL(sliderReleased()), 341 mEngine , SLOT(playEvent()));346 mEngine.get(), SLOT(playEvent())); 342 347 } 343 348
Note:
See TracChangeset
for help on using the changeset viewer.