From d9be69f8ffeb909b659ff94b649e46f2729fde5c Mon Sep 17 00:00:00 2001 From: caremoli Date: Thu, 5 Apr 2007 16:42:58 +0000 Subject: [PATCH] CCAR: quelques corrections dans les ports Calcium plus pas mal d'impressions pour debug --- src/DSC/DSC_Basic/DSC_i.cxx | 5 +++- src/DSC/DSC_Basic/DSC_interface.cxx | 4 ++++ .../DSC_User/Datastream/AdjacentFunctor.hxx | 24 ++++++++++++++++++- src/DSC/DSC_User/Datastream/Calcium/Calcium.c | 18 ++++++++++++-- .../Calcium/CalciumCouplingPolicy.cxx | 4 +++- .../Calcium/CalciumCouplingPolicy.hxx | 10 ++++++-- .../Datastream/Calcium/CalciumInterface.hxx | 9 ++++--- src/DSC/DSC_User/Datastream/GenericPort.hxx | 23 +++++++++++++++++- src/DSC/DSC_User/Superv_Component_i.cxx | 1 + src/DSC/DSC_User/Superv_Component_i.hxx | 8 ++++++- src/DSC/DSC_User/uses_port.hxx | 2 +- 11 files changed, 95 insertions(+), 13 deletions(-) diff --git a/src/DSC/DSC_Basic/DSC_i.cxx b/src/DSC/DSC_Basic/DSC_i.cxx index 7312f1bab..41b5adcea 100644 --- a/src/DSC/DSC_Basic/DSC_i.cxx +++ b/src/DSC/DSC_Basic/DSC_i.cxx @@ -35,7 +35,10 @@ Engines_DSC_i(CORBA::ORB_ptr orb, poa, contId, instanceName, - interfaceName) {} + interfaceName) +{ + std::cout << "--Engines_DSC_i: MARK 1 --" << instanceName << "----" << std::endl; +} Engines_DSC_i::~Engines_DSC_i() {} diff --git a/src/DSC/DSC_Basic/DSC_interface.cxx b/src/DSC/DSC_Basic/DSC_interface.cxx index faf266dbd..d96b2c545 100644 --- a/src/DSC/DSC_Basic/DSC_interface.cxx +++ b/src/DSC/DSC_Basic/DSC_interface.cxx @@ -147,6 +147,7 @@ Engines_DSC_interface::get_uses_port(const char* uses_port_name) Engines::DSC::BadPortType BPT; BPT.expected = CORBA::string_dup("Expected a uses port"); BPT.received = CORBA::string_dup((std::string("Received a provides/none port : ")+uses_port_name).c_str()); + std::cout << "---- DSC_Interface : MARK 1 ---- exception : " << uses_port_name << "----" << std::endl; throw BPT; } @@ -155,7 +156,10 @@ Engines_DSC_interface::get_uses_port(const char* uses_port_name) rtn_port = new Engines::DSC::uses_port(my_ports[uses_port_name]->uses_port_refs); } else + { + std::cout << "---- DSC_Interface : MARK 2 ---- exception : " << uses_port_name << "----" << std::endl; throw Engines::DSC::PortNotConnected(); + } return rtn_port; } diff --git a/src/DSC/DSC_User/Datastream/AdjacentFunctor.hxx b/src/DSC/DSC_User/Datastream/AdjacentFunctor.hxx index b59c92e6b..76888edad 100644 --- a/src/DSC/DSC_User/Datastream/AdjacentFunctor.hxx +++ b/src/DSC/DSC_User/Datastream/AdjacentFunctor.hxx @@ -51,6 +51,27 @@ template < typename T > struct AdjacentFunctor { // Suppose que les valeurs passées en paramètres sont triées par ordre croissant bool operator()(const T &v1) { + std::cout << "AdjacentFunctor: " << _minValue << _maxValue << std::endl; + std::cout << "AdjacentFunctor: " << _min << _max << std::endl; + if ( v1 <= _minValue && v1 >= _maxValue) + { + _equal= true; + std::cout << "AdjacentFunctor: _equal : " << v1 << std::endl; + return true; + } + if ( v1 < _minValue ) + { + _min=v1;_minFound=true; + std::cout << "AdjacentFunctor: _minFound : " <<_min << std::endl; + } + else if ( v1 > _maxValue ) + { + _max=v1;_maxFound=true; + std::cout << "AdjacentFunctor: _maxFound : " <<_max << std::endl; + } + + + /* if ( v1 < _minValue) { std::cout << "EE1: _min : " << _min << std::endl; _min=v1;_minFound=true; @@ -63,8 +84,9 @@ template < typename T > struct AdjacentFunctor { std::cout << "AdjacentFunctor: _equal : " << v1<< ", _minValue " << _minValue << ", _maxValue " << _maxValue << std::endl; return true; } // end if + */ - std::cout << "AdjacentFunctor: _minFound : " <<_min << ", _maxFound " << _max << std::endl; + //std::cout << "AdjacentFunctor: _minFound : " <<_min << ", _maxFound " << _max << std::endl; return ( _minFound && _maxFound ); } diff --git a/src/DSC/DSC_User/Datastream/Calcium/Calcium.c b/src/DSC/DSC_User/Datastream/Calcium/Calcium.c index 7560dff9a..a9732b254 100644 --- a/src/DSC/DSC_User/Datastream/Calcium/Calcium.c +++ b/src/DSC/DSC_User/Datastream/Calcium/Calcium.c @@ -58,7 +58,8 @@ typedef int bool; /* std::cout << "Ptr :" << *data << std::endl; */ \ /* */ \ /* std::cerr << "-------- CalciumInterface(C Part) MARK 2 ------------------" << std::endl; */ \ - *i = _i; \ + if(mode == CP_SEQUENTIEL) \ + *i = _i; \ *nRead=_nRead; \ /* std::cerr << "-------- CalciumInterface(C Part) MARK 3 ------------------" << std::endl; */ \ \ @@ -87,14 +88,21 @@ CALCIUM_EXT_LECT_INTERFACE_C_(lcp,float,float,cplx,); int * nRead, _type _qual * data ) { \ size_t _nRead; \ long _i=*i; \ + fflush(stdout); \ + fflush(stderr); \ + fprintf(stderr,"Beginning of CPLxx: %s %d %f\n",nomvar,*i,*ti); \ \ if ( (data == NULL) || (bufferLength < 1) ) return CPNTNULL; \ \ InfoType info = ecp_lecture_##_typeName (component, mode, ti, tf, &_i, \ nomvar, bufferLength, &_nRead, \ &data ); \ - *i = _i; \ + if(mode == CP_SEQUENTIEL) \ + *i = _i; \ *nRead=_nRead; \ + fprintf(stderr,"End of CPLxx: %s %d \n",nomvar,*i); \ + fflush(stdout); \ + fflush(stderr); \ \ return info; \ }; \ @@ -138,12 +146,18 @@ InfoType cp_fin (void * component, int code) { _type _qual * data ) { \ \ /*long _i=i;*/ \ + fflush(stdout); \ + fflush(stderr); \ + fprintf(stderr,"Beginning of CPExx: %s %d %f\n",nomvar,i,t); \ if ( (data == NULL) || (nbelem < 1) ) return CPNTNULL; \ printf("cp_name : Valeur de nomvar %s\n",nomvar); \ \ InfoType info = ecp_ecriture_##_typeName (component, mode, &t, i, \ nomvar, nbelem, \ data ); \ + fprintf(stderr,"End of CPExx: %s %d \n",nomvar,i); \ + fflush(stdout); \ + fflush(stderr); \ \ return info; \ }; \ diff --git a/src/DSC/DSC_User/Datastream/Calcium/CalciumCouplingPolicy.cxx b/src/DSC/DSC_User/Datastream/Calcium/CalciumCouplingPolicy.cxx index 616936534..1e3ae5d4a 100644 --- a/src/DSC/DSC_User/Datastream/Calcium/CalciumCouplingPolicy.cxx +++ b/src/DSC/DSC_User/Datastream/Calcium/CalciumCouplingPolicy.cxx @@ -106,7 +106,9 @@ void CalciumCouplingPolicy::disconnect(bool provideLastGivenValue) { std::cout << "-------- CalciumCouplingPolicy::disconnect CP_ARRET ------------------" << std::endl; _disconnectDirective = CalciumTypes::STOP; } - + //Wakeup get data if any + //wakeupWaiting(); + // if (waitingForAnyDataId || waitingForConvenientDataId); // cond_instance.signal(); diff --git a/src/DSC/DSC_User/Datastream/Calcium/CalciumCouplingPolicy.hxx b/src/DSC/DSC_User/Datastream/Calcium/CalciumCouplingPolicy.hxx index 5e2f20bfc..e08fcd0ae 100644 --- a/src/DSC/DSC_User/Datastream/Calcium/CalciumCouplingPolicy.hxx +++ b/src/DSC/DSC_User/Datastream/Calcium/CalciumCouplingPolicy.hxx @@ -124,6 +124,7 @@ public: TimeType getEffectiveTime(TimeType ti, TimeType tf); void disconnect(bool provideLastGivenValue); + virtual void wakeupWaiting(){}; }; //Fin de CalciumCouplingPolicy @@ -244,7 +245,11 @@ bool CalciumCouplingPolicy::isDataIdConveniant( AssocContainer & storedDatas, co typedef typename AssocContainer::key_type key_type; AdjacentFunctor< key_type > af(expectedDataId); if ( _dependencyType == CalciumTypes::TIME_DEPENDENCY ) + { + std::cout << "-------- time expected : " << expectedDataId.first << std::endl; + std::cout << "-------- time expected corrected : " << expectedDataId.first*(1.0-_deltaT) << std::endl; af.setMaxValue(key_type(expectedDataId.first*(1.0-_deltaT),0)); + } isBounded = false; // Rem 1 : @@ -264,8 +269,9 @@ bool CalciumCouplingPolicy::isDataIdConveniant( AssocContainer & storedDatas, co // Un codage en reverse serait plus efficace typename AssocContainer::iterator prev = storedDatas.begin(); typename AssocContainer::iterator current = prev; - while ( (current != storedDatas.end()) && - !af(current->first) ) { + while ( (current != storedDatas.end()) && !af(current->first) ) + { + std::cout << "------- stored time : " << current->first << std::endl; // if ( af(current->first) ) break; prev = current++; } diff --git a/src/DSC/DSC_User/Datastream/Calcium/CalciumInterface.hxx b/src/DSC/DSC_User/Datastream/Calcium/CalciumInterface.hxx index fa26c7d04..c7cf475ff 100644 --- a/src/DSC/DSC_User/Datastream/Calcium/CalciumInterface.hxx +++ b/src/DSC/DSC_User/Datastream/Calcium/CalciumInterface.hxx @@ -448,12 +448,14 @@ ecp_fin_ (void * component, int code) { double _tf=*tf; \ size_t _nRead=0; \ size_t _bufferLength=bufferLength; \ - \ + CalciumTypes::DependencyType _dependencyType= \ + static_cast(dependencyType); \ + \ if ( IsSameType< _name , cplx >::value ) _bufferLength*=2; \ std::cout << "-------- CalciumInterface(lecture Inter Part) MARK 1 ------------------" << std::endl; \ try { \ CalciumInterface::ecp_lecture< _type, _name >( *_component, \ - static_cast(dependencyType), \ + _dependencyType, \ _ti, _tf, *i, \ nomvar, \ _bufferLength, _nRead, *data); \ @@ -466,7 +468,8 @@ ecp_fin_ (void * component, int code) { std::cout << "-------- CalciumInterface(lecture Inter Part) _nRead : " << _nRead << std::endl; \ std::cout << "-------- CalciumInterface(lecture Inter Part) *nRead : " << *nRead << std::endl; \ } else *nRead = _nRead; \ - *ti=(CalTimeType< _type _qual >::TimeType)(_ti); \ + if (_dependencyType == CalciumTypes::CP_SEQUENTIEL ) \ + *ti=(CalTimeType< _type _qual >::TimeType)(_ti); \ std::cout << "-------- CalciumInterface(lecture Inter Part), Data Ptr :" << *data << std::endl; \ for (int i=0; i<_nRead;++i) \ printf("-------- CalciumInterface(lecture Inter Part), Valeur de data (typage entier) data[%d] : %d \n",i,(*data)[i]); \ diff --git a/src/DSC/DSC_User/Datastream/GenericPort.hxx b/src/DSC/DSC_User/Datastream/GenericPort.hxx index bed1d8c53..9c63ec5de 100644 --- a/src/DSC/DSC_User/Datastream/GenericPort.hxx +++ b/src/DSC/DSC_User/Datastream/GenericPort.hxx @@ -67,6 +67,7 @@ public: template DataType get(TimeType ti, TimeType tf, TagType tag = 0); template DataType next(TimeType &t, TagType &tag ); void close (PortableServer::POA_var poa, PortableServer::ObjectId_var id); + void wakeupWaiting(); private: @@ -116,6 +117,17 @@ GenericPort::close (PortableServer::POA_var po poa->deactivate_object (id); } +template < typename DataManipulator, typename COUPLING_POLICY> void +GenericPort::wakeupWaiting() +{ + std::cout << "-------- wakeupWaiting ------------------" << std::endl; + if (waitingForAnyDataId || waitingForConvenientDataId) + { + std::cout << "-------- wakeupWaiting:signal --------" << std::endl; + std::cout << std::flush; + cond_instance.signal(); + } +} /* Methode put_generique * @@ -127,7 +139,8 @@ template < typename TimeType,typename TagType> void GenericPort::put(CorbaInDataType dataParam, TimeType time, TagType tag) { - + fflush(stdout); + fflush(stderr); try { // Affichage des donnees pour DEBUGging cerr << "parametres emis: " << time << ", " << tag << endl; @@ -256,6 +269,8 @@ void GenericPort::put(CorbaInDataType dataPara // Pb2 : également si deux attentes de DataIds même différents car on n'en stocke qu'un ! // Conclusion : Pour l'instant on ne gère pas un service multithreadé qui effectue // des lectures simultanées sur le même port ! + std::cout << "-------- Put : new datas available ------------------" << std::endl; + fflush(stdout);fflush(stderr); cond_instance.signal(); } std::cout << "-------- Put : MARK 12 ------------------" << std::endl; @@ -264,6 +279,8 @@ void GenericPort::put(CorbaInDataType dataPara storedDatas_mutex.unlock(); std::cout << "-------- Put : MARK 13 ------------------" << std::endl; + fflush(stdout); + fflush(stderr); } // Catch les exceptions SALOME//C++ pour la transformer en une exception SALOME//CORBA catch ( const SALOME_Exception & ex ) { @@ -402,6 +419,8 @@ GenericPort::get(TimeType time, std::cout << "-------- Get : MARK 11 ------------------" << std::endl; // Ici on attend que la méthode put recoive la donnée + std::cout << "-------- Get : waiting datas ------------------" << std::endl; + fflush(stdout);fflush(stderr); cond_instance.wait(); std::cout << "-------- Get : MARK 12 ------------------" << std::endl; @@ -476,6 +495,8 @@ GenericPort::next(TimeType &t, waitingForAnyDataId = true; std::cout << "-------- Next : MARK 3 ------------------" << std::endl; // Ici on attend que la méthode put recoive la donnée + std::cout << "-------- Next : waiting datas ------------------" << std::endl; + fflush(stdout);fflush(stderr); cond_instance.wait(); if (lastDataIdSet) { diff --git a/src/DSC/DSC_User/Superv_Component_i.cxx b/src/DSC/DSC_User/Superv_Component_i.cxx index 9f238a1b6..2892ddabf 100644 --- a/src/DSC/DSC_User/Superv_Component_i.cxx +++ b/src/DSC/DSC_User/Superv_Component_i.cxx @@ -43,6 +43,7 @@ Superv_Component_i::Superv_Component_i(CORBA::ORB_ptr orb, bool notif) : Engines_DSC_i(orb, poa, contId, instanceName, interfaceName) { + std::cout << "--Superv_Component_i : MARK 1 ---- " << instanceName << "----" << std::endl; _my_basic_factory = new basic_port_factory(); _my_palm_factory = new palm_port_factory(); _my_calcium_factory = new calcium_port_factory(); diff --git a/src/DSC/DSC_User/Superv_Component_i.hxx b/src/DSC/DSC_User/Superv_Component_i.hxx index 37a34640e..1ee77c610 100644 --- a/src/DSC/DSC_User/Superv_Component_i.hxx +++ b/src/DSC/DSC_User/Superv_Component_i.hxx @@ -212,7 +212,7 @@ public: /*! * Gets a port already added in the component. * - * \param provides_port_name the name of the port. + * \param port_name the name of the port. * \return a port's pointer. */ template @@ -312,6 +312,12 @@ Superv_Component_i::get_port( const char * port_name) SpecificPortType * retPort; base_port * port; + my_superv_ports_it = my_superv_ports.find(port_name); + if (my_superv_ports_it == my_superv_ports.end()) + { + throw PortNotDefined( LOC(OSS()<< "Port " << port_name <<" does not exist")); + } + superv_port_t * superv_port = my_superv_ports[port_name]; try { if ( superv_port->p_ref != NULL ) { diff --git a/src/DSC/DSC_User/uses_port.hxx b/src/DSC/DSC_User/uses_port.hxx index 93307b3b1..940921989 100644 --- a/src/DSC/DSC_User/uses_port.hxx +++ b/src/DSC/DSC_User/uses_port.hxx @@ -30,7 +30,7 @@ #include "SALOME_Ports.hh" #include "DSC_Engines.hh" -/*! \class provides_port +/*! \class uses_port * \brief This class implements a DSC_User uses C++ port. * * This class is base class for all DSC_User uses port. -- 2.39.2