Changeset 152 in pacpusframework for branches/2.0-beta1/src/DBITEPlayerLib


Ignore:
Timestamp:
Aug 1, 2013, 10:45:50 AM (11 years ago)
Author:
Marek Kurdej
Message:

Major update.
Renamed: addInput -> addInputs, addOutput -> addOutputs and made pure virtual (=0).
Transformed macro definitions into template methods: ADD_INPUT -> ComponentBase::addInput, ADD_OUTPUT -> ComponentBase::addOutput, GET_INPUT -> ComponentBase::getTypedInput, GET_OUTPUT -> ComponentBase::getTypedOutput.
Fixed: added public/protected set/get methods in ComponentBase, made member fields private.

Location:
branches/2.0-beta1/src/DBITEPlayerLib
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0-beta1/src/DBITEPlayerLib/DbtPlyEngine.cpp

    r89 r152  
    2323DECLARE_STATIC_LOGGER("pacpus.core.DbtPlyEngine");
    2424
    25 static const string kPropertyDataDirectory = "datadir";
    26 
    27 static const string kPropertyLoggerConfiguration = "log-config-file";
    28 
    29 static const string kPropertyReplayMode = "replay_mode";
    30 static const string kPropertyReplayModeLastData = "1";
    31 static const string kPropertyReplayModeAllData = "2";
     25static const char * kPropertyDataDirectory = "datadir";
     26
     27static const char * kPropertyLoggerConfiguration = "log-config-file";
     28
     29static const char * kPropertyReplayMode = "replay_mode";
     30static const char * kPropertyReplayModeLastData = "1";
     31static const char * kPropertyReplayModeAllData = "2";
    3232
    3333typedef float SpeedType;
     
    6363}
    6464
     65void DbtPlyEngine::addInputs()
     66{
     67    // empty: no inputs
     68}
     69
     70void DbtPlyEngine::addOutputs()
     71{
     72    // empty: no outputs
     73}
     74
    6575////////////////////////////////////////////////////////////////////////////////
    6676/// Returns the directory where the data are stored.
     
    103113    int i = 0;
    104114
    105     while (THREAD_ALIVE) {
     115    while (isActive()) {
    106116        tNow_ = road_time();
    107117        float elapsedTime = tNow_ - lastTNow_;
     
    145155/// Configuration method of the engine
    146156/// called automatically by the component manager
    147 ComponentBase::COMPONENT_CONFIGURATION DbtPlyEngine::configureComponent(XmlComponentConfig /*config*/)
     157ComponentBase::COMPONENT_CONFIGURATION DbtPlyEngine::configureComponent(XmlComponentConfig config)
    148158{
    149159    // datadir
    150     dataDir_ = param.getProperty(kPropertyDataDirectory.c_str());
    151     LOG_INFO("property " << kPropertyDataDirectory.c_str() << "=\""
     160    dataDir_ = config.getProperty(kPropertyDataDirectory);
     161    LOG_INFO("property " << kPropertyDataDirectory << "=\""
    152162             << dataDir_ << "\"");
    153163    if (dataDir_.isNull()) {
    154         LOG_FATAL("The data directory '" << componentName << "' is invalid or unavailable!");
     164        LOG_FATAL("The data directory '" << name() << "' is invalid or unavailable!");
    155165    }
    156166
     
    162172    ////////////////////////////////////////////////////////////////////////////////
    163173    // logger configuration
    164     QString loggerConfig = param.getProperty(kPropertyLoggerConfiguration.c_str());
    165     LOG_INFO("property " << kPropertyLoggerConfiguration.c_str() << "=\""
     174    QString loggerConfig = config.getProperty(kPropertyLoggerConfiguration);
     175    LOG_INFO("property " << kPropertyLoggerConfiguration << "=\""
    166176             << loggerConfig << "\"");
    167177    if (!loggerConfig.isNull()) {
     
    172182    ////////////////////////////////////////////////////////////////////////////////
    173183    // Replay Mode
    174     QString replayModeValue = param.getProperty(kPropertyReplayMode.c_str());
    175     LOG_INFO("property " << kPropertyReplayMode.c_str() << "=\""
     184    QString replayModeValue = config.getProperty(kPropertyReplayMode);
     185    LOG_INFO("property " << kPropertyReplayMode << "=\""
    176186             << replayModeValue << "\"");
    177187    if (replayModeValue.isNull()) {
    178         LOG_INFO("property " << kPropertyReplayMode.c_str() << " unset."
     188        LOG_INFO("property " << kPropertyReplayMode << " unset."
    179189                 << " Set to default = 1.");
    180190        replayMode_ = PlayModeLastData;
     
    185195            replayMode_ = PlayModeAllData;
    186196        } else {
    187             LOG_WARN("unknown " << kPropertyReplayMode.c_str() << " '" << replayModeValue << "'."
     197            LOG_WARN("unknown " << kPropertyReplayMode << " '" << replayModeValue << "'."
    188198                     << " Set to default = 1.");
    189199            replayMode_ = PlayModeLastData;
     
    200210    LOG_INFO("Starting...");
    201211
    202     THREAD_ALIVE = true;
     212    setActive(true);
    203213    start();
    204214}
     
    210220    LOG_TRACE("stopping activity...");
    211221
    212     THREAD_ALIVE = false;
     222    setActive(false);
    213223}
    214224
  • branches/2.0-beta1/src/DBITEPlayerLib/DbtPlyFileManager.cpp

    r141 r152  
    2121DECLARE_STATIC_LOGGER("pacpus.core.DbtPlyFileManager");
    2222
    23 const string kPropertyVerbose = "verbose";
     23const char * kPropertyVerbose = "verbose";
    2424const int kPropertyVerboseDefaultValue = 1;
    2525
    26 const string kPropertyDbiteFileName = "dbt";
     26const char * kPropertyDbiteFileName = "dbt";
    2727
    2828// It is the maximum time elapsed between the computation of the tDbt and the data replay in microseconds
     
    3131////////////////////////////////////////////////////////////////////////////////
    3232/// Constructor.
    33 DbtPlyFileManager::DbtPlyFileManager(QString name):ComponentBase(name)
     33DbtPlyFileManager::DbtPlyFileManager(QString name)
     34    : ComponentBase(name)
    3435{
    3536    LOG_TRACE("constructor");
     
    8586    /////////////////////////////////////////
    8687    {
    87         QString verbose = param.getProperty(kPropertyVerbose.c_str());
     88        QString verbose = config.getProperty(kPropertyVerbose);
    8889        if (verbose.isNull()) {
    8990            LOG_INFO("property " << kPropertyVerbose << " not set."
     
    103104
    104105    /////////////////////////////////////////
    105     dbtProperty_ = param.getProperty(kPropertyDbiteFileName.c_str());
    106     mShowGui = param.getProperty("ui").toInt();
     106    dbtProperty_ = config.getProperty(kPropertyDbiteFileName);
     107    mShowGui = config.getProperty("ui").toInt();
    107108    mDbtDataPath = mEngine->getDataDir();
    108109
     
    180181void DbtPlyFileManager::displayUI()
    181182{
    182     LOG_WARN("component '" << componentName << "' has no user interface. Please set ui property to 0 in your XML configuration");
     183    LOG_WARN("component '" << name() << "' has no user interface. Please set ui property to 0 in your XML configuration");
    183184}
    184185
     
    300301    deltaTDbtTab_[(deltaTDbtTabLoop_++)%1000] = deltaT;
    301302    if (deltaT > kMaxPendingTimeFromEngineMicrosecs) {
    302         LOG_WARN(componentName << ": data not replayed: elapsed time since engine notification too big:" << deltaT << "us");
     303        LOG_WARN(name() << ": data not replayed: elapsed time since engine notification too big:" << deltaT << "us");
    303304        return;
    304305    }
  • branches/2.0-beta1/src/DBITEPlayerLib/DbtPlyTrigger.cpp

    r89 r152  
    2121    , mEngine(NULL)
    2222{
    23     THREAD_ALIVE = false;
    2423}
    2524
    2625DbtPlyTrigger::~DbtPlyTrigger()
    2726{
     27}
     28
     29void DbtPlyTrigger::addInputs()
     30{
     31    // empty: no inputs
     32}
     33
     34void DbtPlyTrigger::addOutputs()
     35{
     36    // empty: no outputs
    2837}
    2938
     
    4655void DbtPlyTrigger::startActivity()
    4756{   
    48     THREAD_ALIVE = true;
    4957    start();
    5058}
     
    5260void DbtPlyTrigger::stopActivity()
    5361{
    54     THREAD_ALIVE = false;
    5562}
    5663
     
    6269#endif
    6370
    64     while(THREAD_ALIVE) {
     71    while(isActive()) {
    6572        if (mEngine->isPlaying()) {
    6673            Q_EMIT triggerSig();
  • branches/2.0-beta1/src/DBITEPlayerLib/DbtPlyUserInterface.cpp

    r89 r152  
    4848}
    4949
     50void DbtPlyUserInterface::addInputs()
     51{
     52    // empty: no inputs
     53}
     54
     55void DbtPlyUserInterface::addOutputs()
     56{
     57    // empty: no outputs
     58}
     59
    5060////////////////////////////////////////////////////////////////////////////////
    5161ComponentBase::COMPONENT_CONFIGURATION DbtPlyUserInterface::configureComponent(XmlComponentConfig /*config*/)
Note: See TracChangeset for help on using the changeset viewer.