Changeset 153 in pacpusframework
- Timestamp:
- Aug 1, 2013, 11:42:22 AM (11 years ago)
- Location:
- branches/2.0-beta1
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.0-beta1/include/Pacpus/kernel/ConnectionBase.h
r102 r153 1 #ifndef C onnectionBase_H2 #define C onnectionBase_H1 #ifndef CONNECTIONBASE_H 2 #define CONNECTIONBASE_H 3 3 4 4 #include <Pacpus/kernel/pacpus.h> … … 11 11 { 12 12 public: 13 ConnectionBase(AbstractInterface * interface, int priority):_interface(interface),_priority(priority) {} 14 ~ConnectionBase() {} 13 ConnectionBase(AbstractInterface * interface, int priority) 14 : m_interface(interface) 15 , m_priority(priority) 16 {} 15 17 16 AbstractInterface * getInterface() const {return _interface;}17 int getPriority() const {return _priority;}18 ~ConnectionBase() 19 {} 18 20 19 bool operator== (ConnectionBase const &c) { 20 return _interface == c.getInterface() && _priority == c.getPriority();} 21 AbstractInterface * getInterface() const 22 { 23 return m_interface; 24 } 25 26 int getPriority() const 27 { 28 return m_priority; 29 } 30 31 bool operator==(ConnectionBase const &c) 32 { 33 return getInterface() == c.getInterface() 34 && getPriority() == c.getPriority() 35 ; 36 } 21 37 22 38 private: 23 AbstractInterface * _interface;24 int _priority;39 AbstractInterface * m_interface; 40 int m_priority; 25 41 }; 26 42 27 43 } // namespace pacpus 28 44 29 #endif // C onnectionBase_H45 #endif // CONNECTIONBASE_H -
branches/2.0-beta1/include/Pacpus/kernel/InputOutputBase.h
r152 r153 2 2 #define IN_OUT_BASE_H 3 3 4 #include <Pacpus/kernel/Log.h> 4 5 #include <Pacpus/kernel/pacpus.h> 5 6 #include <Pacpus/kernel/ConnectionBase.h> … … 26 27 , m_component(component) 27 28 , QObject(parent) 28 {} 29 { 30 LOG_DEBUG("constructing abstract connection '" << getName() << "'"); 31 } 29 32 30 33 ~AbstractInterface() -
branches/2.0-beta1/include/Pacpus/kernel/InputOutputInterface.h
r152 r153 5 5 #include <Pacpus/kernel/InputOutputBase.h> 6 6 #include <QApplication> 7 #include <QByteArray> 8 #include <QThread> 7 9 #include <typeinfo> 8 9 #include <QDebug>10 #include <QThread>11 12 #include <QByteArray>13 14 //#define ADD_INPUT(name, ComponentType, DataType, functionName) \15 // inputs().insert((name), new InputInterface<DataType, ComponentType> ((name), this, &ComponentType::functionName))16 //#define ADD_OUTPUT(name, ComponentType, DataType) \17 // outputs().insert((name), new OutputInterface<DataType, ComponentType> ((name), this))18 19 //#define GET_INPUT(name, ComponentType, DataType) \20 // dynamic_cast<InputInterface<DataType, ComponentType> *> (input.value(name))21 //#define GET_OUTPUT(name, ComponentType, DataType) \22 // dynamic_cast<OutputInterface<DataType, ComponentType> *> (output.value(name))23 10 24 11 namespace pacpus { … … 61 48 PacpusTypedEvent<T> * typedEvent = dynamic_cast<PacpusTypedEvent<T> *> (event); 62 49 63 //qDebug() << "Reciever " << getSignature() << " thread " << QThread::currentThread() << " Data & " << & typedEvent->data_;50 LOG_DEBUG("Receiver " << getSignature() << " thread " << QThread::currentThread() << " Data & " << & typedEvent->data_); 64 51 65 52 //if(_component) get state 66 53 67 54 if (typedEvent->timerange() < 500 && readingMode() == TimeBounded) { 68 //LOG_WARN("Incorrect TimeRange (0), switch to NeverSkip");69 qDebug() << "Incorrect TimeRange (0), switch to NeverSkip";70 readingMode() = NeverSkip;}55 LOG_WARN("Incorrect TimeRange (0), switch to NeverSkip"); 56 readingMode() = NeverSkip; 57 } 71 58 72 59 switch (readingMode()) { 73 60 case TimeBounded: 74 //qDebug() << "Input " << this->getSignature().leftJustified(20) << QString("Time bournded").leftJustified(15) << road_time()- typedEvent->t_ << "\t" << typedEvent->tr_;61 LOG_DEBUG("Input " << this->getSignature().leftJustified(20) << QString("Time bournded").leftJustified(15) << road_time()- typedEvent->t_ << "\t" << typedEvent->tr_); 75 62 76 63 if (road_time() - typedEvent->time() > typedEvent->timerange()) { 77 qDebug() << "Data skip " << this->getSignature();64 LOG_DEBUG("Data skip " << this->getSignature()); 78 65 break; 79 66 } … … 83 70 84 71 case GetLast: 85 //qDebug() << "Input " << this->getSignature().leftJustified(20) << QString("GetLast").leftJustified(15) << road_time() - typedEvent->t_ << "\t" << typedEvent->tr_;72 LOG_DEBUG("Input " << this->getSignature().leftJustified(20) << QString("GetLast").leftJustified(15) << road_time() - typedEvent->t_ << "\t" << typedEvent->tr_); 86 73 87 74 (dynamic_cast<C*>(component())->*method)(typedEvent->data()); 88 QCoreApplication::removePostedEvents(this,TYPED_EVENT); // delete all remining events 75 // delete all remaining events 76 QCoreApplication::removePostedEvents(this, TYPED_EVENT); 89 77 break; 90 78 91 79 case NeverSkip: 92 //qDebug() << "Input " << this->getSignature().leftJustified(20) << QString("NeverSkip").leftJustified(15) << road_time() - typedEvent->t_ << "\t" << typedEvent->tr_;80 LOG_DEBUG("Input " << this->getSignature().leftJustified(20) << QString("NeverSkip").leftJustified(15) << road_time() - typedEvent->t_ << "\t" << typedEvent->tr_); 93 81 94 82 default: … … 118 106 119 107 default: 120 121 qDebug() << "Unknown event ID " << event->type(); 108 LOG_WARN("Unknown event ID " << event->type()); 122 109 break; 123 110 } … … 152 139 153 140 // Used by Components to send data througth typed output 154 void send(const T & data, road_time_t t = road_time(), road_timerange_t tr = 0) {155 141 void send(const T & data, road_time_t t = road_time(), road_timerange_t tr = 0) 142 { 156 143 //QSharedPointer<T> sharedPointer = new T(data); 157 144 158 for (QList<ConnectionBase>::iterator it = connections().begin(); it != connections().end(); ++it){145 for (QList<ConnectionBase>::iterator it = connections().begin(); it != connections().end(); ++it) { 159 146 QApplication::postEvent(it->getInterface(),new PacpusTypedEvent<T>(TYPED_EVENT,data,t,tr),it->getPriority()); // Event is delete by the event loop handler 160 147 //qDebug() << "sender " << it->getInterface()->getSignature() << " thread " << QThread::currentThread() << " Data & " << &data << " "; -
branches/2.0-beta1/include/Pacpus/kernel/PacpusEvent.h
r150 r153 139 139 { 140 140 m_data = new char[m_dataSize]; 141 ::std::copy(data, data + m_dataSize, m_data); 141 ::std::copy(data, data + m_dataSize, // source 142 #ifdef _MSC_VER 143 ::stdext::checked_array_iterator<char *>(m_data, m_dataSize) // destination 144 #else 145 m_data // destination 146 #endif 147 ); 142 148 } 143 149 -
branches/2.0-beta1/src/PacpusLib/ComponentManager.cpp
r152 r153 338 338 339 339 ComponentBase* component = getComponent(componentName); 340 if (!component) 341 { 340 if (!component) { 342 341 LOG_WARN("cannot start component '" << componentName << "'. It does not exist!"); 343 342 return false; … … 348 347 LOG_WARN("cannot start component '" << componentName << "'. It can already be started"); 349 348 } 350 349 LOG_INFO("successfully started component '" << componentName << "'"); 351 350 return true; 352 351 }
Note:
See TracChangeset
for help on using the changeset viewer.