[89] | 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 |
|
---|
| 12 | namespace pacpus {
|
---|
| 13 |
|
---|
| 14 | DECLARE_STATIC_LOGGER("pacpus.core.DbtPlyTrigger");
|
---|
| 15 |
|
---|
| 16 | // Construction de la fabrique de composant DbtPlyTrigger
|
---|
| 17 | //static ComponentFactory<DbtPlyTrigger> factory("DbtPlyTrigger");
|
---|
| 18 |
|
---|
| 19 | DbtPlyTrigger::DbtPlyTrigger(QString name)
|
---|
| 20 | : ComponentBase(name)
|
---|
| 21 | , mEngine(NULL)
|
---|
| 22 | {
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 | DbtPlyTrigger::~DbtPlyTrigger()
|
---|
| 26 | {
|
---|
| 27 | }
|
---|
| 28 |
|
---|
[152] | 29 | void DbtPlyTrigger::addInputs()
|
---|
| 30 | {
|
---|
| 31 | // empty: no inputs
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | void DbtPlyTrigger::addOutputs()
|
---|
| 35 | {
|
---|
| 36 | // empty: no outputs
|
---|
| 37 | }
|
---|
| 38 |
|
---|
[89] | 39 | ComponentBase::COMPONENT_CONFIGURATION DbtPlyTrigger::configureComponent(XmlComponentConfig /*config*/)
|
---|
| 40 | {
|
---|
| 41 | ComponentManager * mgr = ComponentManager::getInstance();
|
---|
| 42 | // we get a pointer to the engine component
|
---|
| 43 | mEngine = dynamic_cast<DbtPlyEngine *>(mgr->getComponent("dbiteEngine"));
|
---|
| 44 | if (NULL == mEngine) {
|
---|
| 45 | LOG_FATAL("cannot get a pointer of the 'dbiteEngine' component");
|
---|
| 46 | return CONFIGURED_FAILED;
|
---|
| 47 | }
|
---|
| 48 | connect(this, SIGNAL(triggerSig()),
|
---|
| 49 | mEngine,SLOT(engReceiver()),
|
---|
| 50 | Qt::DirectConnection);
|
---|
| 51 |
|
---|
| 52 | return CONFIGURED_OK;
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 | void DbtPlyTrigger::startActivity()
|
---|
| 56 | {
|
---|
| 57 | start();
|
---|
| 58 | }
|
---|
| 59 |
|
---|
| 60 | void DbtPlyTrigger::stopActivity()
|
---|
| 61 | {
|
---|
| 62 | }
|
---|
| 63 |
|
---|
| 64 | // The thread is started when the user press the play button
|
---|
| 65 | void DbtPlyTrigger::run()
|
---|
| 66 | {
|
---|
| 67 | #ifdef WIN32
|
---|
| 68 | timeBeginPeriod(1);
|
---|
| 69 | #endif
|
---|
| 70 |
|
---|
[152] | 71 | while(isActive()) {
|
---|
[89] | 72 | if (mEngine->isPlaying()) {
|
---|
| 73 | Q_EMIT triggerSig();
|
---|
| 74 | }
|
---|
| 75 | msleep(1);
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | #ifdef WIN32
|
---|
| 79 | timeEndPeriod(1);
|
---|
| 80 | #endif
|
---|
| 81 | }
|
---|
| 82 |
|
---|
| 83 | } // namespace pacpus
|
---|