Index: branches/2.0-beta1/include/Pacpus/kernel/inputOutputInterface.h
===================================================================
--- branches/2.0-beta1/include/Pacpus/kernel/inputOutputInterface.h	(revision 102)
+++ branches/2.0-beta1/include/Pacpus/kernel/inputOutputInterface.h	(revision 110)
@@ -4,8 +4,9 @@
 #include <Pacpus/kernel/Log.h>
 #include <Pacpus/kernel/inputOutputBase.h>
+#include <QApplication>
+#include <typeinfo>
 
-#include <typeinfo>
 #include <QDebug>
-#include <QApplication>
+#include <QThread>
 
 #include <QByteArray>
@@ -13,5 +14,7 @@
 #define ADD_INPUT(name,ComponentType, DataType, functionName)  input.insert(name,new InputInterface<DataType,ComponentType> (name,this,&ComponentType::functionName))
 #define ADD_OUTPUT(name,ComponentType, DataType)      output.insert(name,new OutputInterface<DataType,ComponentType> (name,this))
+
 #define GET_OUTPUT(name,ComponentType, DataType) dynamic_cast<OutputInterface<DataType,ComponentType> *> (output.value(name))
+#define GET_INPUT(name,ComponentType, DataType) dynamic_cast<InputInterface<DataType,ComponentType> *> (input.value(name))
 
 namespace pacpus {
@@ -26,10 +29,9 @@
     QString getDataType() {return QString(typeid(T).name());}
 
-    protected:
-    int boundingTime_;
+protected:
 
-    public:
+public:
 
-    PacpusEvent getEventTemplate() {return PacpusTypedEvent<T>(TYPED_EVENT); }
+    PacpusEvent* getEventTemplate() {return new PacpusTypedEvent<T>(TYPED_EVENT); }
 
     void customEvent(QEvent* event) {
@@ -37,39 +39,46 @@
         switch (event->type()) {
 
-                // from Component to Component (T->T)
-            case TYPED_EVENT: {
-                PacpusTypedEvent<T> * typedEvent = dynamic_cast<PacpusTypedEvent<T> *> (event);
-                //qDebug() << "E1 ";
-                //qDebug() << "recived 2 thread " << QThread::currentThread();
-                    if(typedEvent->tr_ == 0 && readingMode_ == TimeBounded) {
-                        //LOG_WARN("Incorrect TimeRange (0), switch to NeverSkip");
-                        readingMode_ = NeverSkip;}
+        // from Component to Component (T->T)
+        case TYPED_EVENT: {
+            PacpusTypedEvent<T> * typedEvent = dynamic_cast<PacpusTypedEvent<T> *> (event);
 
-                switch (readingMode_){
-                    case TimeBounded:
-						qDebug() << "Input " << this->getSignature() << " Time bournded "<< road_time()- typedEvent->t_ << " " << typedEvent->tr_;
-                    if(road_time() - typedEvent->t_> typedEvent->tr_)
-						{ qDebug() << "Data skip " << this->getSignature();
-					break;}
-                        (dynamic_cast<C*>(_component)->*method)(typedEvent->_data);
-                        break;
-                    case GetLast:
-						qDebug() << "Input " << this->getSignature() << "GetLast "<< road_time() - typedEvent->t_ << " " << typedEvent->tr_;
-                        (dynamic_cast<C*>(_component)->*method)(typedEvent->_data);
-                        QCoreApplication::removePostedEvents(this,TYPED_EVENT); // delete all remining events
-                        break;
-                    case NeverSkip:
-						qDebug() << "Input " << this->getSignature() << "NeverSkip "<< road_time() - typedEvent->t_ << " " << typedEvent->tr_;
-                    default:
-                        (dynamic_cast<C*>(_component)->*method)(typedEvent->_data);
-                }
+            qDebug() << "Revever " << getSignature() << " thread " << QThread::currentThread() << " Data & " << & typedEvent->data_;
+
+            if(typedEvent->tr_ < 500 && readingMode_ == TimeBounded) {
+                //LOG_WARN("Incorrect TimeRange (0), switch to NeverSkip");
+                qDebug() << "Incorrect TimeRange (0), switch to NeverSkip";
+                readingMode_ = NeverSkip;}
+
+            switch (readingMode_){
+            case TimeBounded:
+                qDebug() << "Input " << this->getSignature().leftJustified(20) << QString("Time bournded").leftJustified(15) << road_time()- typedEvent->t_ << "\t" << typedEvent->tr_;
+
+                if(road_time() - typedEvent->t_> typedEvent->tr_)
+                    {qDebug() << "Data skip " << this->getSignature();  break;}
+
+                (dynamic_cast<C*>(_component)->*method)(typedEvent->data_);
                 break;
+
+            case GetLast:
+                qDebug() << "Input " << this->getSignature().leftJustified(20) << QString("GetLast").leftJustified(15) << road_time() - typedEvent->t_ << "\t" << typedEvent->tr_;
+
+                (dynamic_cast<C*>(_component)->*method)(typedEvent->data_);
+                QCoreApplication::removePostedEvents(this,TYPED_EVENT); // delete all remining events
+                break;
+
+            case NeverSkip:
+                qDebug() << "Input " << this->getSignature().leftJustified(20) << QString("NeverSkip").leftJustified(15) << road_time() - typedEvent->t_ << "\t" << typedEvent->tr_;
+
+            default:
+                (dynamic_cast<C*>(_component)->*method)(typedEvent->data_);
             }
+            break;
+        }
 
-                // from Connection interface to Component (G->T)
-/*            case GENERIC_EVENT2: {
+            // from Connection interface to Component (G->T)
+            /*            case GENERIC_EVENT2: {
                 PacpusTypedEvent<QByteArray> * genericEvent = dynamic_cast<PacpusTypedEvent<QByteArray> *> (event);
                 T data;
-                QByteArray& buf = (QByteArray&) genericEvent->_data;
+                QByteArray& buf = (QByteArray&) genericEvent->data_;
                 QDataStream in(&buf,QIODevice::ReadOnly);
 
@@ -81,20 +90,33 @@
             case GENERIC_EVENT3: {
                 PacpusTypedEvent<T> * typedEvent = dynamic_cast<PacpusTypedEvent<T> *> (event);
-                (dynamic_cast<C*>(_component)->*method)(typedEvent->_data);     // copy 3 X
+                (dynamic_cast<C*>(_component)->*method)(typedEvent->data_);     // copy 3 X
 
                 break;
             }*/
 
-            default:
+        default:
 
             qDebug() << "Unknown event ID " << event->type();
-                break;
+            break;
         }
+    event->accept();
+    }
 
+    T& getData() {
+        T data;
+        // TODO ask output data;
 
+            //LOG4CXX_INFO(getLogger(), "Hello, World");
+
+        return data;
     }
 
 protected:
     void (C::*method)(const T&);
+
+ /*   log4cxx::LoggerPtr& getLogger() {
+        static log4cxx::LoggerPtr logger(log4cxx::Logger::getLogger(    LOG4CXX_LOCATION.getClassName()));
+        return logger;
+    }*/
 
 };
@@ -109,19 +131,30 @@
     // Used by Components to send data througth typed output
     void send(const T & data, road_time_t t = road_time(), road_timerange_t tr = 0) {
+
+        //QSharedPointer<T> sharedPointer = new T(data);
+
+        for(QList<ConnectionBase>::iterator it = _connection.begin(); it!=_connection.end(); ++it){
+            QApplication::postEvent(it->getInterface(),new PacpusTypedEvent<T>(TYPED_EVENT,data,t,tr),it->getPriority()); // Event is delete by the event loop handler
+            qDebug() << "sender " << it->getInterface()->getSignature() <<  " thread " << QThread::currentThread() << " Data & " << &data << " ";
+            // TODO DAta SHAred
+        }
+    }
+
+    /*    void send(const T & data, road_time_t t = road_time(), road_timerange_t tr = 0) {
         for(QList<ConnectionBase>::iterator it = _connection.begin(); it!=_connection.end(); ++it){
 
-            //if(it->getInterface()->getDataType() != QString(typeid(QByteArray).name()))
+            if(it->getInterface()->getDataType() != QString(typeid(QByteArray).name()))
                 QApplication::postEvent(it->getInterface(),new PacpusTypedEvent<T>(TYPED_EVENT,data,t,tr),it->getPriority());
-           /*else {
+           else {
                 QByteArray buf;
                 QDataStream out(&buf,QIODevice::ReadWrite);
                 PacpusTypedEvent<QByteArray> * ev =new PacpusTypedEvent<QByteArray>(GENERIC_EVENT3,buf);
                 QApplication::postEvent(it->getInterface(),ev,it->getPriority()); // Copy 2 (ctor)
-                }*/
+                }
         }
     }
 
     // Used by Connection Interfaces only to pose generic event
-/*    void sendGenericData(char * data, size_t size) {
+        void sendGenericData(char * data, size_t size) {
         QByteArray buf(data,size);  // copy 5
         for(QList<ConnectionBase>::iterator it = _connection.begin(); it!=_connection.end(); ++it)
