Back to index

salome-kernel  6.5.0
Param_Double_Port_uses_i.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 //  File   : param_double_port_uses.cxx
00021 //  Author : André RIBES (EDF)
00022 //  Module : KERNEL
00023 //
00024 #include "Param_Double_Port_uses_i.hxx"
00025 
00026 Param_Double_Port_uses_i::Param_Double_Port_uses_i(Engines_ParallelDSC_i * par_compo, 
00027                                                    std::string port_name,
00028                                                    CORBA::ORB_ptr orb)
00029 {
00030   _orb = CORBA::ORB::_duplicate(orb);
00031   _fake_properties = new PortProperties_i();
00032   _fake_prop_ref = _fake_properties->_this();
00033   _fake_properties->_remove_ref();
00034 
00035   _par_compo = par_compo;
00036   _port_name = port_name;
00037   _provides_port = NULL;
00038 
00039   paco_fabrique_manager * pfm = paco_getFabriqueManager();
00040   pfm->register_comScheduling("Param_Double_Port_uses_i_direct", new paco_direct_fabrique());
00041   pfm->register_distribution("Param_Double_Port_uses_i_GaBro", new GaBro_fab());
00042   pfm->register_distribution("Param_Double_Port_uses_i_BasicBC", new BasicBC_fab());
00043 }
00044 
00045 Param_Double_Port_uses_i::~Param_Double_Port_uses_i()
00046 {
00047   if (_provides_port)
00048   {
00049     _provides_port->stop();
00050     delete _provides_port;
00051   }
00052 }
00053 
00054 void 
00055 Param_Double_Port_uses_i::add_port_to_component()
00056 {
00057     _par_compo->add_uses_port("IDL:Ports/Param_Double_Port:1.0", 
00058                               _port_name.c_str(),
00059                               _fake_prop_ref);
00060 }
00061 
00062 void
00063 Param_Double_Port_uses_i::start_port()
00064 {
00065   Engines::DSC::uses_port * uport = _par_compo->get_uses_port(_port_name.c_str());  
00066   _proxy_port =  Ports::Param_Double_Port::_narrow((*uport)[0]);
00067   _provides_port = Ports::PaCO_Param_Double_Port::PaCO_narrow(_proxy_port, _orb);
00068   _provides_port->copyClientGlobalContext(_par_compo);
00069   _provides_port->init(_par_compo->getMyRank(), _par_compo->getTotalNode());
00070   
00071   // Il faut maintenant configurer les bibliothèques
00072   // de redistributions de la fonction put
00073   ParallelMethodContext * method_ptr;
00074   method_ptr = _provides_port->getParallelMethodContext("put");
00075   method_ptr->setLibComScheduling("Param_Double_Port_uses_i_direct"); 
00076   method_ptr->setDistLibArg("param_data", "Param_Double_Port_uses_i_BasicBC", "in");
00077   BasicBC * dislib = (BasicBC *) method_ptr->getDistLibArg("param_data", "in");
00078   dislib->setEltSize(sizeof(CORBA::Double));
00079   dislib->setBlocSize(0); // BLOC
00080   dislib->setNodeRank(_par_compo->getMyRank());
00081 
00082   // Il faut maintenant configurer les bibliothèques
00083   // de redistributions de la fonction get_results
00084   method_ptr = _provides_port->getParallelMethodContext("get_results");
00085   method_ptr->setLibComScheduling("Param_Double_Port_uses_i_direct"); 
00086   method_ptr->setDistLibArg("param_results", "Param_Double_Port_uses_i_GaBro", "out");
00087   GaBro * dislib_gabro = (GaBro *) method_ptr->getDistLibArg("param_results", "out");
00088   dislib_gabro->setEltSize(sizeof(CORBA::Double));
00089 
00090   _provides_port->start();
00091   delete uport;
00092 }
00093 
00094 void 
00095 Param_Double_Port_uses_i::configure_port_method_put(int totalNbElt)
00096 {
00097   ParallelMethodContext * method_ptr;
00098   method_ptr = _provides_port->getParallelMethodContext("put");
00099   BasicBC * dislib = (BasicBC *) method_ptr->getDistLibArg("param_data", "in");
00100   dislib->setTotalNbElt(totalNbElt);
00101 }
00102 
00103 void 
00104 Param_Double_Port_uses_i::put(const Ports::Param_Double_Port::seq_double & param_data)
00105 {
00106   _provides_port->put(param_data);
00107 }
00108 
00109 void 
00110 Param_Double_Port_uses_i::get_results(Ports::Param_Double_Port::seq_double_out param_results)
00111 {
00112   _provides_port->get_results(param_results);
00113 }