]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
CCAR: add requests cp_effi and cp_efft to calcium api
authorcaremoli <caremoli>
Mon, 22 Mar 2010 08:31:09 +0000 (08:31 +0000)
committercaremoli <caremoli>
Mon, 22 Mar 2010 08:31:09 +0000 (08:31 +0000)
src/DSC/DSC_Python/calcium.i
src/DSC/DSC_User/Datastream/Calcium/Calcium.c
src/DSC/DSC_User/Datastream/Calcium/CalciumCInterface.cxx
src/DSC/DSC_User/Datastream/Calcium/CalciumCInterface.hxx
src/DSC/DSC_User/Datastream/Calcium/CalciumCouplingPolicy.hxx
src/DSC/DSC_User/Datastream/Calcium/CalciumCxxInterface.hxx
src/DSC/DSC_User/Datastream/Calcium/CalciumGenericProvidesPort.hxx
src/DSC/DSC_User/Datastream/Calcium/calcium_provides_port.hxx
src/DSC/DSC_User/Datastream/Calcium/calciumf.c
src/DSC/DSC_User/Datastream/CouplingPolicy.hxx
src/DSC/DSC_User/Datastream/GenericPort.hxx

index 28929edc4b60a3eaba77ae9af74ae611a29d7df5..0817e9abd5eb78ef88bd3b862cb9316ca3313758 100644 (file)
@@ -908,6 +908,8 @@ int cp_lln(Superv_Component_i *component,int dep,float  *ti,float  *tf,int *nite
 
 int cp_fini(Superv_Component_i *component,char *nom, int n);
 int cp_fint(Superv_Component_i *component,char *nom, float t);
+int cp_effi(Superv_Component_i *component,char *nom, int n);
+int cp_efft(Superv_Component_i *component,char *nom, float t);
 
 int cp_fin(Superv_Component_i *component,int cp_end);
 
index 52ef949e100f68bc5652f08b88d984aec4f29d8b..8ca73d83a2e9e96f1f83a194c80f2aa0d20e0e58 100644 (file)
@@ -39,6 +39,8 @@ typedef char bool;
 //TODO: ajouter les prototypes pour eviter les pbs de passage par valeur
 InfoType ecp_fint_ (void * component, char* nomVar, float t);
 InfoType ecp_fini_ (void * component, char* nomVar, int i);
+InfoType ecp_efft_ (void * component, char* nomVar, float t);
+InfoType ecp_effi_ (void * component, char* nomVar, int i);
 
 /************************************/
 /* INTERFACES DE LECTURE EN 0 COPIE */
@@ -340,3 +342,15 @@ InfoType cp_fint (void * component, char * nomvar, float t)
   InfoType info =  ecp_fint_(component,nomvar,t);
   return info;
 }
+
+InfoType cp_effi (void * component, char * nomvar, int i)
+{
+  InfoType info =  ecp_effi_(component,nomvar,i);
+  return info;
+}
+
+InfoType cp_efft (void * component, char * nomvar, float t)
+{
+  InfoType info =  ecp_efft_(component,nomvar,t);
+  return info;
+}
index 6aa687ffec9034bd95d7d031ded6ebda48a02d2d..48d7dff756e4b791440730ee6b2645c3c5f8d1df 100644 (file)
@@ -114,6 +114,39 @@ ecp_fint_ (void * component, char* nomvar, float t)
   return CalciumTypes::CPOK;
 }
 
+extern "C" CalciumTypes::InfoType 
+ecp_effi_ (void * component, char* nomvar, int i)
+{
+  Superv_Component_i * _component = static_cast<Superv_Component_i *>(component); 
+  try
+    {
+      CalciumInterface::ecp_effi( *_component,nomvar,i);
+    }
+  catch ( const CalciumException & ex)
+    {
+      DEBTRACE( ex.what() );
+      return ex.getInfo();
+    }
+  return CalciumTypes::CPOK;
+
+}
+
+extern "C" CalciumTypes::InfoType 
+ecp_efft_ (void * component, char* nomvar, float t)
+{
+  Superv_Component_i * _component = static_cast<Superv_Component_i *>(component); 
+  try
+    {
+      CalciumInterface::ecp_efft( *_component,nomvar,t);
+    }
+  catch ( const CalciumException & ex)
+    {
+      DEBTRACE( ex.what() );
+      return ex.getInfo();
+    }
+  return CalciumTypes::CPOK;
+}
+
 // INTERFACE C/CPP pour les chaines de caractères
 // Le paramètre supplémentaire strsize n'étant pas utilisé
 // j'utilise la génération par la macro CALCIUM_C2CPP_INTERFACE_(str,char*,);
index bebd3f030ccbf8da4025fd57e635bcf00d3b1ff3..c1d093869d9786a537ae778c6538b15bbb81e1af 100644 (file)
@@ -91,5 +91,7 @@ extern "C" CalciumTypes::InfoType ecp_fin_ (void * component, int code);
 extern "C" CalciumTypes::InfoType ecp_cd_ (void * component, char* instanceName);
 extern "C" CalciumTypes::InfoType ecp_fini_ (void * component, char* nomVar, int i);
 extern "C" CalciumTypes::InfoType ecp_fint_ (void * component, char* nomVar, float t);
+extern "C" CalciumTypes::InfoType ecp_effi_ (void * component, char* nomVar, int i);
+extern "C" CalciumTypes::InfoType ecp_efft_ (void * component, char* nomVar, float t);
 
 #endif
index a0e5bf26685f25e454cb936a72c25978b387da16..10d501856187351996a583e5a0288e727b7f95d9 100644 (file)
@@ -51,7 +51,7 @@ public:
   template <typename DataManipulator, 
     class EnableIf >                  friend class BoundedDataIdProcessor;
   template <typename DataManipulator >        friend class EraseDataIdProcessor;
-  template <typename DataManipulator >        friend class EraseDataIdBeforeTagProcessor;
+  template <typename DataManipulator >        friend class EraseDataIdBeforeOrAfterTagProcessor;
   template <typename DataManipulator >        friend class DisconnectProcessor;
 
   typedef CalciumTypes::DependencyType       DependencyType;
@@ -113,7 +113,7 @@ public:
             class EnableIf = void >    struct BoundedDataIdProcessor;
   //template <typename DataManipulator>  struct BoundedDataIdProcessor;
   template <typename DataManipulator>  struct EraseDataIdProcessor;
-  template <typename DataManipulator>  struct EraseDataIdBeforeTagProcessor;
+  template <typename DataManipulator>  struct EraseDataIdBeforeOrAfterTagProcessor;
   template <typename DataManipulator>  struct DisconnectProcessor;
 
   // Renvoie isEqual si le dataId attendu est trouvé dans storedDataIds :
@@ -349,38 +349,65 @@ bool CalciumCouplingPolicy::isDataIdConveniant( AssocContainer & storedDatas, co
   return isEqual || isBounded;
 }
 
-//Remove DataId before a given time or tag
+//Remove DataId before or after a given time or tag
 template < typename DataManipulator > 
-struct CalciumCouplingPolicy::EraseDataIdBeforeTagProcessor
+struct CalciumCouplingPolicy::EraseDataIdBeforeOrAfterTagProcessor
 {
   CalciumCouplingPolicy &_couplingPolicy;
     
-  EraseDataIdBeforeTagProcessor(CalciumCouplingPolicy &couplingPolicy):
+  EraseDataIdBeforeOrAfterTagProcessor(CalciumCouplingPolicy &couplingPolicy):
     _couplingPolicy(couplingPolicy) {};
 
   template < typename Container,typename TimeType,typename TagType >
-  void apply(Container & storedDatas, TimeType time, TagType tag) const 
+  void apply(Container & storedDatas, TimeType time, TagType tag, bool before) const 
     {
       typedef typename Container::iterator   iterator;
+      typedef typename Container::reverse_iterator   riterator;
 
       if(_couplingPolicy._dependencyType == CalciumTypes::TIME_DEPENDENCY)
         {
-          iterator it=storedDatas.begin();
-          while(it != storedDatas.end() && it->first.first <= time)
+          if(before)
             {
-              DataManipulator::delete_data(it->second);
-              storedDatas.erase(it);
-              it=storedDatas.begin();
+              iterator it=storedDatas.begin();
+              while(it != storedDatas.end() && it->first.first <= time)
+                {
+                  DataManipulator::delete_data(it->second);
+                  storedDatas.erase(it);
+                  it=storedDatas.begin();
+                }
+            }
+          else
+            {
+              riterator it=storedDatas.rbegin();
+              while(it != storedDatas.rend() && it->first.first >= time)
+                {
+                  DataManipulator::delete_data(it->second);
+                  storedDatas.erase(it->first);
+                  it=storedDatas.rbegin();
+                }
             }
         }
       else
         {
-          iterator it=storedDatas.begin();
-          while(it != storedDatas.end() && it->first.second <= tag)
+          if(before)
+            {
+              iterator it=storedDatas.begin();
+              while(it != storedDatas.end() && it->first.second <= tag)
+                {
+                  DataManipulator::delete_data(it->second);
+                  storedDatas.erase(it);
+                  it=storedDatas.begin();
+                }
+            }
+          else
             {
-              DataManipulator::delete_data(it->second);
-              storedDatas.erase(it);
-              it=storedDatas.begin();
+              riterator it=storedDatas.rbegin();
+              while(it != storedDatas.rend() && it->first.second >= tag)
+                {
+                  DataManipulator::delete_data(it->second);
+                  storedDatas.erase(it->first);
+                  it=storedDatas.rbegin();
+                }
             }
         }
     }
index 677b30e0fbb6a19f3c1a0fe0239c69c827e3ec26..3fdf8ec2812b3aa7db055e0f5a7ce03f6206acbf 100644 (file)
@@ -669,7 +669,7 @@ namespace CalciumInterface {
                                 << portDependencyType << " must be iteration mode."));
       }
 
-    port->calcium_erase(0., i);
+    port->calcium_erase(0., i,true);
 
     std::stringstream msg;
     msg << "i<=" << i ;
@@ -728,13 +728,132 @@ namespace CalciumInterface {
                                 << portDependencyType << " must be time mode."));
       }
 
-    port->calcium_erase(t, 0);
+    port->calcium_erase(t, 0,true);
 
     std::stringstream msg;
     msg << "t<=" << t ;
     Engines_DSC_interface::writeEvent("CP_FINT",containerName,componentName,nomVar.c_str(),"",msg.str().c_str());
 
   };
+
+  static void
+  ecp_effi(Superv_Component_i & component,const std::string  & nomVar,long const  & i)
+  {
+    CORBA::String_var componentName=component.instanceName();
+    std::string containerName=component.getContainerName();
+
+    if (nomVar.empty())
+      {
+        Engines_DSC_interface::writeEvent("CP_EFFI",containerName,componentName,"",CPMESSAGE[CalciumTypes::CPNMVR],"");
+        throw CalciumException(CalciumTypes::CPNMVR, LOC("Empty variable name"));
+      }
+
+    calcium_provides_port* port;
+
+    try
+      {
+        port = component.Superv_Component_i::get_port< calcium_provides_port >(nomVar.c_str());
+      }
+    catch ( const Superv_Component_i::PortNotDefined & ex)
+      {
+        Engines_DSC_interface::writeEvent("CP_EFFI",containerName,componentName,nomVar.c_str(),CPMESSAGE[CalciumTypes::CPNMVR],ex.what());
+        throw (CalciumException(CalciumTypes::CPNMVR,ex));
+      }
+    catch ( const Superv_Component_i::PortNotConnected & ex)
+      {
+        Engines_DSC_interface::writeEvent("CP_EFFI",containerName,componentName,nomVar.c_str(),CPMESSAGE[CalciumTypes::CPLIEN],ex.what());
+        throw (CalciumException(CalciumTypes::CPLIEN,ex));
+      }
+    catch ( const Superv_Component_i::BadCast & ex)
+      {
+        Engines_DSC_interface::writeEvent("CP_EFFI",containerName,componentName,nomVar.c_str(),CPMESSAGE[CalciumTypes::CPTPVR],ex.what());
+        throw (CalciumException(CalciumTypes::CPTPVR,ex));
+      }
+
+    // get dependency mode
+    CalciumTypes::DependencyType portDependencyType = port->getDependencyType();
+
+    if ( portDependencyType == CalciumTypes::UNDEFINED_DEPENDENCY )
+      {
+        Engines_DSC_interface::writeEvent("CP_EFFI",containerName,componentName,nomVar.c_str(),CPMESSAGE[CalciumTypes::CPIT],"Dependency mode is undefined");
+        throw CalciumException(CalciumTypes::CPIT, LOC(OSS()<<"Dependency mode of variable " << nomVar << " is undefined."));
+      }
+
+    if ( portDependencyType != CalciumTypes::ITERATION_DEPENDENCY )
+      {
+        Engines_DSC_interface::writeEvent("CP_EFFI",containerName,componentName,nomVar.c_str(),CPMESSAGE[CalciumTypes::CPIT],
+                   "Dependency mode must be iteration mode");
+        throw CalciumException(CalciumTypes::CPITVR, LOC(OSS()<<"Dependency mode of variable " << nomVar << ": "
+                                << portDependencyType << " must be iteration mode."));
+      }
+
+    port->calcium_erase(0., i,false);
+
+    std::stringstream msg;
+    msg << "i>=" << i ;
+    Engines_DSC_interface::writeEvent("CP_EFFI",containerName,componentName,nomVar.c_str(),"",msg.str().c_str());
+
+  };
+
+  static void
+  ecp_efft(Superv_Component_i & component,const std::string  & nomVar,double const  & t)
+  {
+    CORBA::String_var componentName=component.instanceName();
+    std::string containerName=component.getContainerName();
+
+    if (nomVar.empty())
+      {
+        Engines_DSC_interface::writeEvent("CP_EFFT",containerName,componentName,"",CPMESSAGE[CalciumTypes::CPNMVR],"");
+        throw CalciumException(CalciumTypes::CPNMVR, LOC("Empty variable name"));
+      }
+
+    calcium_provides_port* port;
+
+    try
+      {
+        port = component.Superv_Component_i::get_port< calcium_provides_port >(nomVar.c_str());
+      }
+    catch ( const Superv_Component_i::PortNotDefined & ex)
+      {
+        Engines_DSC_interface::writeEvent("CP_EFFT",containerName,componentName,nomVar.c_str(),CPMESSAGE[CalciumTypes::CPNMVR],ex.what());
+        throw (CalciumException(CalciumTypes::CPNMVR,ex));
+      }
+    catch ( const Superv_Component_i::PortNotConnected & ex)
+      {
+        Engines_DSC_interface::writeEvent("CP_EFFT",containerName,componentName,nomVar.c_str(),CPMESSAGE[CalciumTypes::CPLIEN],ex.what());
+        throw (CalciumException(CalciumTypes::CPLIEN,ex));
+      }
+    catch ( const Superv_Component_i::BadCast & ex)
+      {
+        Engines_DSC_interface::writeEvent("CP_EFFT",containerName,componentName,nomVar.c_str(),CPMESSAGE[CalciumTypes::CPTPVR],ex.what());
+        throw (CalciumException(CalciumTypes::CPTPVR,ex));
+      }
+
+    // get dependency mode
+    CalciumTypes::DependencyType portDependencyType = port->getDependencyType();
+
+    if ( portDependencyType == CalciumTypes::UNDEFINED_DEPENDENCY )
+      {
+        Engines_DSC_interface::writeEvent("CP_EFFT",containerName,componentName,nomVar.c_str(),CPMESSAGE[CalciumTypes::CPIT],"Dependency mode is undefined");
+        throw CalciumException(CalciumTypes::CPIT, LOC(OSS()<<"Dependency mode of variable " << nomVar << " is undefined."));
+      }
+
+    if ( portDependencyType != CalciumTypes::TIME_DEPENDENCY )
+      {
+        Engines_DSC_interface::writeEvent("CP_EFFT",containerName,componentName,nomVar.c_str(),CPMESSAGE[CalciumTypes::CPIT],
+                   "Dependency mode must be time mode");
+        throw CalciumException(CalciumTypes::CPITVR, LOC(OSS()<<"Dependency mode of variable " << nomVar << ": "
+                                << portDependencyType << " must be time mode."));
+      }
+
+    port->calcium_erase(t, 0,false);
+
+    std::stringstream msg;
+    msg << "t>=" << t ;
+    Engines_DSC_interface::writeEvent("CP_EFFT",containerName,componentName,nomVar.c_str(),"",msg.str().c_str());
+
+  };
+
 };
 
 #endif
index 176f2a231817a974aff6300da05b612ecee1410b..34e35aaa9d4b0c95ecece61c9ddd883d7d640b30 100644 (file)
                                        const Engines::DSC::Message message) { \
       if ( message == Engines::DSC::AddingConnection)                   \
         {                                                               \
-          _disconnect_mutex.lock();                              \
+          _disconnect_mutex.lock();                                     \
           _mustnotdisconnect++;                                         \
-          _disconnect_mutex.unlock();                            \
+          _disconnect_mutex.unlock();                                   \
         }                                                               \
       else if ( message == Engines::DSC::RemovingConnection )           \
         {                                                               \
         }                                                               \
     }                                                                   \
                                                                         \
-    inline void calcium_erase(float t,long i)                           \
+    inline void calcium_erase(float t,long i, bool before)              \
     {                                                                   \
-      erase(t,i);                                                       \
+      erase(t,i,before);                                                \
     }                                                                   \
   };                                                                    \
 
index 8f1780d51face5ade1da357e01b3008d2764b98b..73a3ae7ea751757355041fc6a9a7b00037d77624 100644 (file)
@@ -62,7 +62,7 @@ public :
   virtual  InterpolationSchem getInterpolationSchem () const  =0;
   virtual  ExtrapolationSchem getExtrapolationSchem () const  =0;
 
-  virtual void calcium_erase (float t,long i) {};
+  virtual void calcium_erase (float t,long i, bool before) {};
 };
 
 #endif
index 61a6058b5152a8ff1b9f28eba96d124e9c719d3e..97aad485900fa6e09a431ba5af353c71918de432 100644 (file)
@@ -85,8 +85,13 @@ void F_FUNC(cpfin,CPFIN)(long *compo,cal_int *dep,cal_int *err)
   *err=cp_fin((void *)*compo,(int)*dep);
 }
 
+/**************************************/
+/* ERASE INTERFACE                    */
+/**************************************/
 void F_FUNC(cpfini,CPFINI)(long *compo,STR_PSTR(nom),cal_int *i, cal_int *err STR_PLEN(nom));
 void F_FUNC(cpfint,CPFINT)(long *compo,STR_PSTR(nom),float *t, cal_int *err STR_PLEN(nom));
+void F_FUNC(cpeffi,CPEFFI)(long *compo,STR_PSTR(nom),cal_int *i, cal_int *err STR_PLEN(nom));
+void F_FUNC(cpefft,CPEFFT)(long *compo,STR_PSTR(nom),float *t, cal_int *err STR_PLEN(nom));
 
 void F_FUNC(cpfini,CPFINI)(long *compo,STR_PSTR(nom),cal_int *i, cal_int *err STR_PLEN(nom))
 {
@@ -102,6 +107,20 @@ void F_FUNC(cpfint,CPFINT)(long *compo,STR_PSTR(nom),float *t, cal_int *err STR_
   free_str1(cnom);
 }
 
+void F_FUNC(cpeffi,CPEFFI)(long *compo,STR_PSTR(nom),cal_int *i, cal_int *err STR_PLEN(nom))
+{
+  char* cnom=fstr1(STR_PTR(nom),STR_LEN(nom));
+  *err=cp_effi((void *)*compo,cnom,*i);
+  free_str1(cnom);
+}
+
+void F_FUNC(cpefft,CPEFFT)(long *compo,STR_PSTR(nom),float *t, cal_int *err STR_PLEN(nom))
+{
+  char* cnom=fstr1(STR_PTR(nom),STR_LEN(nom));
+  *err=cp_efft((void *)*compo,cnom,*t);
+  free_str1(cnom);
+}
+
 /**************************************/
 /* INTERFACES DE LECTURE              */
 /**************************************/
index 521fd438d66b21713edeb977da80022898f5e897..8f8d7cc463985dd6e97689eedb665ff916077677 100644 (file)
@@ -152,12 +152,12 @@ public:
 
   // Remove all DataId from a container before a given time or tag
   template <typename DataManipulator>
-  struct EraseDataIdBeforeTagProcessor {
+  struct EraseDataIdBeforeOrAfterTagProcessor {
 
-    EraseDataIdBeforeTagProcessor(CouplingPolicy couplingPolicy) {};
+    EraseDataIdBeforeOrAfterTagProcessor(CouplingPolicy couplingPolicy) {};
 
     template < typename Container , typename TimeType , typename TagType >
-    void apply(Container & storedDatas, TimeType time, TagType tag ) const {
+    void apply(Container & storedDatas, TimeType time, TagType tag, bool before ) const {
       typedef typename Container::key_type   key_type;
       typedef typename Container::value_type value_type;
       typedef typename Container::iterator iterator;
index 52eb345acb0918b2f550e42e9bd7843d313a8529..bf3eee07b67fd2afaf5d0c03dbbf3fca29700036 100644 (file)
@@ -73,7 +73,7 @@ public:
   template <typename TimeType,typename TagType> DataType next(TimeType &t, TagType  &tag );
   void      close (PortableServer::POA_var poa, PortableServer::ObjectId_var id);
   void wakeupWaiting();
-  template <typename TimeType,typename TagType> void erase(TimeType time, TagType tag );
+  template <typename TimeType,typename TagType> void erase(TimeType time, TagType tag, bool before );
 
 private:
 
@@ -343,10 +343,10 @@ void GenericPort<DataManipulator, COUPLING_POLICY>::put(CorbaInDataType dataPara
 template < typename DataManipulator, typename COUPLING_POLICY >
 template <typename TimeType,typename TagType>
 void
-GenericPort<DataManipulator, COUPLING_POLICY>::erase(TimeType time, TagType  tag)
+GenericPort<DataManipulator, COUPLING_POLICY>::erase(TimeType time, TagType  tag, bool before)
 {
-  typename COUPLING_POLICY::template EraseDataIdBeforeTagProcessor<DataManipulator> processEraseDataId(*this);
-  processEraseDataId.apply(storedDatas,time,tag);
+  typename COUPLING_POLICY::template EraseDataIdBeforeOrAfterTagProcessor<DataManipulator> processEraseDataId(*this);
+  processEraseDataId.apply(storedDatas,time,tag,before);
 }
 
 // Version du Get en 0 copy