Changeset 159 in pacpusframework for branches/2.0-beta1/include/Pacpus/kernel
- Timestamp:
- Aug 1, 2013, 2:19:48 PM (11 years ago)
- Location:
- branches/2.0-beta1/include/Pacpus/kernel
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.0-beta1/include/Pacpus/kernel/InputOutputBase.h
r153 r159 117 117 {} 118 118 119 // TODO for serealization prupose (not yet implemented !!!) 119 120 virtual void customEvent(QEvent* e) 120 121 { … … 179 180 } 180 181 182 // TODO for serealization prupose (not yet implemented !!!) 181 183 void send(/*const*/ QByteArray & data) 182 184 { -
branches/2.0-beta1/include/Pacpus/kernel/InputOutputInterface.h
r153 r159 42 42 { 43 43 // TODO check component state started 44 //if(_component) get state 44 45 switch (event->type()) { 45 46 case TYPED_EVENT: 46 47 { 47 // cast from Component to Component (T->T) 48 48 49 PacpusTypedEvent<T> * typedEvent = dynamic_cast<PacpusTypedEvent<T> *> (event); 49 50 50 LOG_DEBUG("Receiver " << getSignature() << " thread " << QThread::currentThread() << " Data & " << & typedEvent->data_);51 LOG_DEBUG("Receiver " << getSignature() << " thread " << QThread::currentThread()); 51 52 52 //if(_component) get state 53 53 54 54 55 if (typedEvent->timerange() < 500 && readingMode() == TimeBounded) { … … 59 60 switch (readingMode()) { 60 61 case TimeBounded: 61 LOG_DEBUG("Input " << this->getSignature().leftJustified(20) << QString("Time bournded").leftJustified(15) << road_time()- typedEvent->t_ << "\t" << typedEvent->tr_);62 62 63 63 if (road_time() - typedEvent->time() > typedEvent->timerange()) { … … 70 70 71 71 case GetLast: 72 LOG_DEBUG("Input " << this->getSignature().leftJustified(20) << QString("GetLast").leftJustified(15) << road_time() - typedEvent->t_ << "\t" << typedEvent->tr_);73 72 74 73 (dynamic_cast<C*>(component())->*method)(typedEvent->data()); … … 78 77 79 78 case NeverSkip: 80 LOG_DEBUG("Input " << this->getSignature().leftJustified(20) << QString("NeverSkip").leftJustified(15) << road_time() - typedEvent->t_ << "\t" << typedEvent->tr_); 79 (dynamic_cast<C*>(component())->*method)(typedEvent->data()); 80 break; 81 81 82 82 default: 83 (dynamic_cast<C*>(component())->*method)(typedEvent->data());83 LOG_WARN("Unknown reading mode " << readingMode()); 84 84 } 85 85 break; 86 86 } 87 87 88 // from Connection interface to Component (G->T) 89 /* case GENERIC_EVENT2: { 90 PacpusTypedEvent<QByteArray> * genericEvent = dynamic_cast<PacpusTypedEvent<QByteArray> *> (event); 91 T data; 92 QByteArray& buf = (QByteArray&) genericEvent->data_; 93 QDataStream in(&buf,QIODevice::ReadOnly); 94 95 (dynamic_cast<C*>(_component)->*method)(data); // copy 8 X 96 break; 97 } 98 99 // from Component to Connection interface (T->G) (Typed in QByteArray) 100 case GENERIC_EVENT3: { 101 PacpusTypedEvent<T> * typedEvent = dynamic_cast<PacpusTypedEvent<T> *> (event); 102 (dynamic_cast<C*>(_component)->*method)(typedEvent->data_); // copy 3 X 103 104 break; 105 }*/ 88 // Add here new event type if needed 106 89 107 90 default: … … 112 95 } 113 96 97 // TODO for Pulling mode (not yet implemented !!!) 114 98 T& getData() { 115 99 T data; 116 100 // TODO ask output data; 117 118 //LOG4CXX_INFO(getLogger(), "Hello, World");119 101 120 102 return data; … … 123 105 protected: 124 106 void (C::*method)(const T&); 125 126 /* log4cxx::LoggerPtr& getLogger() {127 static log4cxx::LoggerPtr logger(log4cxx::Logger::getLogger( LOG4CXX_LOCATION.getClassName()));128 return logger;129 }*/130 107 131 108 }; … … 141 118 void send(const T & data, road_time_t t = road_time(), road_timerange_t tr = 0) 142 119 { 120 // FIXME Data Shared 143 121 //QSharedPointer<T> sharedPointer = new T(data); 144 122 … … 146 124 QApplication::postEvent(it->getInterface(),new PacpusTypedEvent<T>(TYPED_EVENT,data,t,tr),it->getPriority()); // Event is delete by the event loop handler 147 125 //qDebug() << "sender " << it->getInterface()->getSignature() << " thread " << QThread::currentThread() << " Data & " << &data << " "; 148 // TODO Data Shared149 126 } 150 127 } 151 128 152 /* void send(const T & data, road_time_t t = road_time(), road_timerange_t tr = 0) {153 for(QList<ConnectionBase>::iterator it = _connection.begin(); it!=_connection.end(); ++it){154 155 if(it->getInterface()->getDataType() != QString(typeid(QByteArray).name()))156 QApplication::postEvent(it->getInterface(),new PacpusTypedEvent<T>(TYPED_EVENT,data,t,tr),it->getPriority());157 else {158 QByteArray buf;159 QDataStream out(&buf,QIODevice::ReadWrite);160 PacpusTypedEvent<QByteArray> * ev =new PacpusTypedEvent<QByteArray>(GENERIC_EVENT3,buf);161 QApplication::postEvent(it->getInterface(),ev,it->getPriority()); // Copy 2 (ctor)162 }163 }164 }165 166 // Used by Connection Interfaces only to pose generic event167 void sendGenericData(char * data, size_t size) {168 QByteArray buf(data,size); // copy 5169 for(QList<ConnectionBase>::iterator it = _connection.begin(); it!=_connection.end(); ++it)170 QApplication::postEvent(it->getInterface(),new PacpusTypedEvent<QByteArray>(GENERIC_EVENT2,buf),it->getPriority()); // Copy 6(ctor)171 172 173 }174 */175 129 size_t getDataSize() 176 130 {
Note:
See TracChangeset
for help on using the changeset viewer.