source: pacpusframework/branches/2.0-beta1/src/DBITEPlayerLib/DbtPlyTrigger.cpp@ 105

Last change on this file since 105 was 89, checked in by morasjul, 11 years ago

PACPUS 2.0 Beta deployed in new branch

Major changes:
-Add communication interface between components
-Add examples for communications interface (TestComponents)
-Move to Qt5 support

  • Property svn:executable set to *
File size: 1.8 KB
Line 
1// %pacpus:license{
2// This file is part of the PACPUS framework distributed under the
3// CECILL-C License, Version 1.0.
4// %pacpus:license}
5/// @version $Id: DbtPlyTrigger.cpp 76 2013-01-10 17:05:10Z kurdejma $
6
7#include <Pacpus/DbitePlayer/DbtPlyTrigger.h>
8
9#include <Pacpus/kernel/ComponentManager.h>
10#include <Pacpus/kernel/Log.h>
11
12namespace pacpus {
13
14DECLARE_STATIC_LOGGER("pacpus.core.DbtPlyTrigger");
15
16// Construction de la fabrique de composant DbtPlyTrigger
17//static ComponentFactory<DbtPlyTrigger> factory("DbtPlyTrigger");
18
19DbtPlyTrigger::DbtPlyTrigger(QString name)
20 : ComponentBase(name)
21 , mEngine(NULL)
22{
23 THREAD_ALIVE = false;
24}
25
26DbtPlyTrigger::~DbtPlyTrigger()
27{
28}
29
30ComponentBase::COMPONENT_CONFIGURATION DbtPlyTrigger::configureComponent(XmlComponentConfig /*config*/)
31{
32 ComponentManager * mgr = ComponentManager::getInstance();
33 // we get a pointer to the engine component
34 mEngine = dynamic_cast<DbtPlyEngine *>(mgr->getComponent("dbiteEngine"));
35 if (NULL == mEngine) {
36 LOG_FATAL("cannot get a pointer of the 'dbiteEngine' component");
37 return CONFIGURED_FAILED;
38 }
39 connect(this, SIGNAL(triggerSig()),
40 mEngine,SLOT(engReceiver()),
41 Qt::DirectConnection);
42
43 return CONFIGURED_OK;
44}
45
46void DbtPlyTrigger::startActivity()
47{
48 THREAD_ALIVE = true;
49 start();
50}
51
52void DbtPlyTrigger::stopActivity()
53{
54 THREAD_ALIVE = false;
55}
56
57// The thread is started when the user press the play button
58void DbtPlyTrigger::run()
59{
60#ifdef WIN32
61 timeBeginPeriod(1);
62#endif
63
64 while(THREAD_ALIVE) {
65 if (mEngine->isPlaying()) {
66 Q_EMIT triggerSig();
67 }
68 msleep(1);
69 }
70
71#ifdef WIN32
72 timeEndPeriod(1);
73#endif
74}
75
76} // namespace pacpus
Note: See TracBrowser for help on using the repository browser.