Changeset 102 in pacpusframework for branches/2.0-beta1/include/Pacpus


Ignore:
Timestamp:
Jun 3, 2013, 6:13:21 PM (11 years ago)
Author:
morasjul
Message:

beta : correct reading mode

Location:
branches/2.0-beta1/include/Pacpus/kernel
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0-beta1/include/Pacpus/kernel/ConnectionBase.h

    r96 r102  
    22#define ConnectionBase_H
    33
     4#include <Pacpus/kernel/pacpus.h>
    45
    56namespace pacpus {
     
    78class AbstractInterface;
    89
    9 class ConnectionBase
     10class PACPUSLIB_API ConnectionBase
    1011{
    1112public:
  • branches/2.0-beta1/include/Pacpus/kernel/inputOutputBase.h

    r100 r102  
    4747    //InputInterfaceBase(QString name, ComponentBase * component,int a, QObject * parent = 0):AbstractInterface(name,component,parent) {} // TODO add ctor with function pointer
    4848
     49            enum ReadingMode {
     50        NeverSkip,
     51        TimeBounded,
     52        GetLast
     53    };
     54
    4955    virtual ~InputInterfaceBase(){}
    5056
     
    6066    }
    6167
     68    void setReadingMode(ReadingMode mode) { readingMode_ = mode;}
    6269    virtual PacpusEvent getEventTemplate() {return PacpusEvent(GENERIC_EVENT);} // TODO check ??
    63 
     70protected:
     71            ReadingMode readingMode_;
    6472};
    6573
     
    103111        in->addConnection(ConnectionBase(out,priority));
    104112        //LOG_INFO("connection : Output " << out->getSignature() << " => Input " << in->getSignature());
     113                in->setReadingMode(InputInterfaceBase::NeverSkip);
    105114        return true;
    106115    } else {
  • branches/2.0-beta1/include/Pacpus/kernel/inputOutputInterface.h

    r96 r102  
    2323    InputInterface(QString name, C * component, void (C::*m)(const T&)):InputInterfaceBase(name,component,component), method(m) {}
    2424    ~InputInterface() {}
    25 
    26     enum ReadingMode {
    27         NeverSkip,
    28         TimeBounded,
    29         GetLast
    30     };
    31 
    32     void setReadingMode(ReadingMode mode) { readingMode_ = mode;}
    3325    size_t getDataSize() {return sizeof(T);}
    3426    QString getDataType() {return QString(typeid(T).name());}
    3527
    3628    protected:
    37     ReadingMode readingMode_;
    3829    int boundingTime_;
    3930
     
    5748                switch (readingMode_){
    5849                    case TimeBounded:
     50                                                qDebug() << "Input " << this->getSignature() << " Time bournded "<< road_time()- typedEvent->t_ << " " << typedEvent->tr_;
    5951                    if(road_time() - typedEvent->t_> typedEvent->tr_)
    60                         break;
     52                                                { qDebug() << "Data skip " << this->getSignature();
     53                                        break;}
    6154                        (dynamic_cast<C*>(_component)->*method)(typedEvent->_data);
    6255                        break;
    6356                    case GetLast:
     57                                                qDebug() << "Input " << this->getSignature() << "GetLast "<< road_time() - typedEvent->t_ << " " << typedEvent->tr_;
    6458                        (dynamic_cast<C*>(_component)->*method)(typedEvent->_data);
    6559                        QCoreApplication::removePostedEvents(this,TYPED_EVENT); // delete all remining events
    6660                        break;
    6761                    case NeverSkip:
     62                                                qDebug() << "Input " << this->getSignature() << "NeverSkip "<< road_time() - typedEvent->t_ << " " << typedEvent->tr_;
    6863                    default:
    6964                        (dynamic_cast<C*>(_component)->*method)(typedEvent->_data);
     
    113108
    114109    // Used by Components to send data througth typed output
    115     void send(const T & data) {
     110    void send(const T & data, road_time_t t = road_time(), road_timerange_t tr = 0) {
    116111        for(QList<ConnectionBase>::iterator it = _connection.begin(); it!=_connection.end(); ++it){
    117112
    118113            //if(it->getInterface()->getDataType() != QString(typeid(QByteArray).name()))
    119                 QApplication::postEvent(it->getInterface(),new PacpusTypedEvent<T>(TYPED_EVENT,data),it->getPriority());
     114                QApplication::postEvent(it->getInterface(),new PacpusTypedEvent<T>(TYPED_EVENT,data,t,tr),it->getPriority());
    120115           /*else {
    121116                QByteArray buf;
Note: See TracChangeset for help on using the changeset viewer.