23 #define private public
24 #define protected public
25 #include <omniORB4/CORBA.h>
26 #include <omniORB4/internal/typecode.h>
42 #include "SALOME_LifeCycleCORBA.hxx"
43 #include "SALOME_Exception.hh"
46 #include <omniORB4/CORBA.h>
47 #include <omniORB4/minorCode.h>
80 YACSTRACE(1,
"+++++++++++++ CorbaNode::execute: " <<
getName() <<
" +++++++++++++++" );
90 CORBA::Request_var req = objComponent->_request(
_method.c_str());
91 CORBA::NVList_ptr
arguments = req->arguments() ;
93 DEBTRACE(
"+++++++++++++++++CorbaNode::inputs+++++++++++++++++" )
96 list<InputPort *>::iterator iter2;
101 DEBTRACE(
"port kind: " <<
p->edGetType()->kind() )
102 CORBA::Any* ob=
p->getAny();
104 CORBA::TypeCode_var typcod= ob->type();
105 switch(
p->edGetType()->kind())
124 if(*ob >>= CORBA::Any::to_boolean(
b))
142 DEBTRACE(
"+++++++++++++++++CorbaNode::outputs+++++++++++++++++" )
143 list<OutputPort *>::iterator iter;
148 DEBTRACE(
"port kind: " <<
p->edGetType()->kind() )
149 CORBA::Any* ob=
p->getAnyOut();
151 DEBTRACE(
"refcount CORBA : " << ((omni::TypeCode_base*)ob->pd_tc.in())->pd_ref_count);
156 DEBTRACE(
"refcount CORBA : " << ((omni::TypeCode_base*)ob->pd_tc.in())->pd_ref_count);
162 req->set_return_type(CORBA::_tc_void);
164 DEBTRACE(
"+++++++++++++++++CorbaNode::calculation+++++++++++++++++" <<
_method )
166 CORBA::Exception *exc =req->env()->exception();
169 DEBTRACE(
"An exception was thrown!" )
170 DEBTRACE(
"The raised exception is of Type:" << exc->_name() )
172 std::cerr <<
"The raised exception is of Type:" << exc->_name() << std::endl;
183 _errorDetails=
"Execution problem: the raised exception is of Type:";
188 DEBTRACE(
"++++++++++++CorbaNode::outputs++++++++++++" )
189 int out_param=in_param;
194 DEBTRACE(
"port kind: " <<
p->edGetType()->kind() )
195 DEBTRACE(
"port number: " << out_param )
196 CORBA::Any *ob=
arguments->item(out_param)->value();
198 DEBTRACE(
"refcount CORBA : " << ((omni::TypeCode_base*)ob->pd_tc.in())->pd_ref_count);
201 CORBA::TypeCode_var tc=ob->type();
202 switch(
p->edGetType()->kind())
230 out_param=out_param+1;
232 DEBTRACE(
"refcount CORBA : " << ((omni::TypeCode_base*)ob->pd_tc.in())->pd_ref_count);
235 DEBTRACE(
"++++++++++++++++++++++++++++++++++++++++++" )
241 list<OutputPort *>::const_iterator iter;
245 CORBA::Any *ob=
p->getAny();
246 DEBTRACE(
"refcount CORBA : " << ((omni::TypeCode_base*)ob->pd_tc.in())->pd_ref_count);
249 DEBTRACE(
"+++++++++++++++++ End CorbaNode::execute: " <<
getName() <<
" +++++++++++++++++" )
303 Engines::Superv_Component_var compo=Engines::Superv_Component::_narrow(objComponent);
304 if( CORBA::is_nil(compo) )
306 std::string msg=
"Can't get reference to DSC object (or it was nil).";
314 CORBA::Boolean ret=compo->init_service(
_method.c_str());
324 CORBA::Boolean ret=compo->init_service_with_multiple(
_method.c_str(), _param);
342 int index = _param.length();
343 _param.length(index + 1);
344 _param[index].name = CORBA::string_dup(port_name.c_str());
345 _param[index].number = number;
356 Engines::Superv_Component_var me=Engines::Superv_Component::_narrow(objComponent);
357 if( CORBA::is_nil(me) )
359 std::string msg=
"Can't get reference to Engines::Superv_Component: "+
getName();
363 std::list<OutputDataStreamPort *>::iterator iter;
364 Engines::ConnectionManager::connectionId id;
369 std::set<InPort *>::iterator iterout;
370 for(iterout=ports.begin();iterout != ports.end(); iterout++)
376 std::string msg=
"Can't connect : not a SalomeNode";
382 if( CORBA::is_nil(
comp))
384 std::string msg=
"Problem in connectService: " + snode->
getName();
385 msg=msg+
" Component is probably not launched. Modify your YACS file";
390 Engines::Superv_Component_var other=Engines::Superv_Component::_narrow(
comp);
391 if( CORBA::is_nil(other))
393 std::string msg=
"Can't connect to nil Engines::Superv_Component: " + snode->
getName();
399 id=manager.
connect(me,port->
getName().c_str(),other,(*iterout)->getName().c_str());
401 catch(Engines::DSC::PortNotDefined&
ex)
403 std::string msg=
"Problem in connectService. Unknown port: "+port->
getName()+
" or "+(*iterout)->getName();
407 catch(Engines::DSC::BadPortType&
ex)
409 std::string msg=
"Problem in connectService. Type of provides port is bad. Expected: ";
410 msg=msg +
ex.expected.in();
411 msg=msg +
"Received: "+
ex.received.in();
415 catch(Engines::DSC::NilPort&
ex)
417 std::string msg=
"Problem in connectService. Port is nil: "+port->
getName()+
" or "+(*iterout)->getName();
421 catch(
const SALOME::SALOME_Exception&
ex )
423 std::string msg=
"Problem in connectService. ";
424 msg +=
ex.details.text.in();
429 catch(CORBA::SystemException&
ex)
432 DEBTRACE(
"completion code: " <<
ex.completed() );
433 std::string msg=
"Problem in connectService. CORBA System exception ";
434 std::string excname=
ex._name();
435 msg=msg+excname +
" " +
getName()+
" " + port->
getName() +
" " + snode->
getName() +
" " + (*iterout)->getName();
441 std::string msg=
"Problem in connectService. Unknown exception";
454 (*iter)->initPortProperties();
456 std::list<InputDataStreamPort *>::iterator iterin;
459 (*iterin)->initPortProperties();
474 std::list<Engines::ConnectionManager::connectionId>::iterator iter;
475 for(iter = ids.begin(); iter != ids.end(); iter++)
477 DEBTRACE(
"Trying to disconnect: " << *iter );
480 manager.
disconnect(*iter,Engines::DSC::RemovingConnection);
482 catch(Engines::ConnectionManager::BadId&
ex)
484 DEBTRACE(
"Problem in disconnect: " << *iter );
486 catch(Engines::DSC::PortNotDefined&
ex)
488 DEBTRACE(
"Problem in disconnect: " << *iter );
490 catch(Engines::DSC::PortNotConnected&
ex)
492 DEBTRACE(
"Problem in disconnect: " << *iter );
494 catch(Engines::DSC::BadPortReference&
ex)
496 DEBTRACE(
"Problem in disconnect (Engines::DSC::BadPortReference): " << *iter );
498 catch(CORBA::SystemException&
ex)
500 DEBTRACE(
"Problem in disconnect (CORBA::SystemException): " << *iter );
504 DEBTRACE(
"Problem in disconnect: " << *iter );
520 YACSTRACE(1,
"+++++++++++++++++ SalomeNode::execute: " <<
getName() <<
" " <<
_method <<
" +++++++++++++++++" );
523 Engines::EngineComponent_var compo=Engines::EngineComponent::_narrow(objComponent);
529 Engines::FieldsDict_var
dico =
new Engines::FieldsDict;
530 dico->length(amap.size());
531 std::map<std::string,std::string>::const_iterator it;
533 for(it = amap.begin(); it != amap.end(); ++it)
535 dico[
i].key=CORBA::string_dup(it->first.c_str());
536 dico[
i].value <<=it->second.c_str();
539 compo->setProperties(
dico);
548 CORBA::Request_var req ;
551 req = objComponent->_request(
_method.c_str());
553 catch(CORBA::SystemException&
ex)
555 std::string msg=
"component '" +
_ref+
"' has no service '" +
_method+
"'";
559 CORBA::NVList_ptr
arguments = req->arguments() ;
561 DEBTRACE(
"+++++++++++++++++SalomeNode::inputs+++++++++++++++++" );
564 list<InputPort *>::iterator iter2;
571 DEBTRACE(
"port kind: " <<
p->edGetType()->kind() );
572 CORBA::Any* ob=
p->getAny();
574 CORBA::TypeCode_var tc=ob->type();
575 switch(
p->edGetType()->kind())
615 string::size_type debut =filename.find_first_of(
':',0);
616 while(debut != std::string::npos)
619 debut=filename.find_first_of(
':',debut);
621 DEBTRACE(
"inport with file: " << filename );
622 Engines::Salome_file_var isf=compo->setInputFileToService(
_method.c_str(),
p->
getName().c_str());
623 isf->setDistributedFile(filename.c_str());
624 Engines::Salome_file_ptr osf;
625 CORBA::Any* any=
p->getAny();
631 compo->checkInputFilesToService(
_method.c_str());
633 catch(
const SALOME::SALOME_Exception&
ex )
635 std::string text=
"Execution problem in checkInputFilesToService: ";
636 text += (
const char*)
ex.details.text;
640 catch(CORBA::SystemException&
ex)
642 std::string msg=
"Execution problem: component probably does not support files ??";
648 DEBTRACE(
"+++++++++++++++++SalomeNode::outputs+++++++++++++++++" )
649 list<OutputPort *>::iterator iter;
654 DEBTRACE(
"port kind: " <<
p->edGetType()->kind() )
657 CORBA::Any* ob=
p->getAnyOut();
667 req->set_return_type(CORBA::_tc_void);
669 req->exceptions()->add(SALOME::_tc_SALOME_Exception);
671 DEBTRACE(
"+++++++++++++++++SalomeNode::calculation+++++++++++++++++" <<
_method )
673 CORBA::Exception *exc =req->env()->exception();
676 DEBTRACE(
"An exception was thrown!" )
677 DEBTRACE(
"The raised exception is of Type:" << exc->_name() )
679 CORBA::SystemException* sysexc;
680 sysexc=CORBA::SystemException::_downcast(exc);
684 DEBTRACE(
"minor code: " << sysexc->minor() );
685 DEBTRACE(
"completion code: " << sysexc->completed() );
686 std::string text=
"Execution problem: ";
687 std::string excname=sysexc->_name();
688 if(excname ==
"BAD_OPERATION")
690 text=text+
"component '" +
_ref+
"' has no service '" +
_method+
"'";
692 else if(excname ==
"BAD_PARAM")
694 text=text+
"A parameter (input or output) passed to the call is out of range or otherwise considered illegal.\n";
695 text=text+
"Minor code: "+sysexc->NP_minorString();
697 else if(excname ==
"MARSHAL" && sysexc->minor() == omni::MARSHAL_PassEndOfMessage)
699 text=text+
"probably an error in arguments of service '" +
_method +
"' from component '" +
_ref+
"'";
701 else if(excname ==
"COMM_FAILURE" && sysexc->minor() == omni::COMM_FAILURE_UnMarshalResults)
703 text=text+
"probably an error in output arguments of service '" +
_method +
"' from component '" +
_ref+
"'";
705 else if(excname ==
"COMM_FAILURE" && sysexc->minor() == omni::COMM_FAILURE_UnMarshalArguments)
707 text=text+
"probably an error in input arguments of service '" +
_method +
"' from component '" +
_ref+
"'";
709 else if(excname ==
"COMM_FAILURE" && sysexc->minor() == omni::COMM_FAILURE_WaitingForReply)
711 text=text+
"probably an error in input arguments of service '" +
_method +
"' from component '" +
_ref+
"'";
715 DEBTRACE(sysexc->NP_minorString() );
716 text=text+
"System Exception "+ excname;
723 CORBA::UnknownUserException* userexc;
724 userexc=CORBA::UnknownUserException::_downcast(exc);
727 CORBA::Any anyExcept = userexc->exception();
729 const SALOME::SALOME_Exception* salexc;
730 if(anyExcept >>= salexc)
732 DEBTRACE(
"SALOME_Exception: "<< salexc->details.sourceFile);
733 DEBTRACE(
"SALOME_Exception: "<<salexc->details.lineNumber);
737 std::string msg=
"Execution problem: User Exception occurred";
741 std::string msg=
"Execution problem";
746 DEBTRACE(
"++++++++++++SalomeNode::outputs++++++++++++" )
747 int out_param=in_param;
752 DEBTRACE(
"port kind: " <<
p->edGetType()->kind() );
753 DEBTRACE(
"port number: " << out_param );
756 CORBA::Any *ob=
arguments->item(out_param)->value();
758 switch(
p->edGetType()->kind())
783 out_param=out_param+1;
799 string::size_type debut =filename.find_first_of(
':',0);
800 while(debut != std::string::npos)
803 debut=filename.find_first_of(
':',debut);
805 DEBTRACE(
"outport with file: " << filename );
806 Engines::Salome_file_var osf=compo->setOutputFileToService(
_method.c_str(),
p->
getName().c_str());
807 osf->setLocalFile(filename.c_str());
813 compo->checkOutputFilesToService(
_method.c_str());
815 catch(
const SALOME::SALOME_Exception&
ex )
817 std::string text=(
const char*)
ex.details.text;
819 throw Exception(
"Execution problem in checkOutputFilesToService: " + text);
821 catch(CORBA::SystemException&
ex)
823 std::string msg=
"Execution problem: component probably does not support files ?";
831 DEBTRACE(
"+++++++++++++++++ End SalomeNode::execute: " <<
getName() <<
" +++++++++++++++++" )
853 std::string msg=
"Component is not loaded";
857 Engines::EngineComponent_var compo=Engines::EngineComponent::_narrow(objComponent);
858 if( !CORBA::is_nil(compo) )
860 Engines::Container_var cont= compo->GetContainerRef();
861 CORBA::String_var logname = cont->logfilename();
864 std::string::size_type pos = msg.find(
":");
865 msg=msg.substr(pos+1);
868 catch(CORBA::COMM_FAILURE&
ex)
870 msg =
":Component no longer reachable: Caught system exception COMM_FAILURE";
871 msg +=
" -- unable to contact the object.";
873 catch(CORBA::SystemException&
ex)
875 msg =
":Component no longer reachable: Caught a CORBA::SystemException.\n";
878 CORBA::TypeCode_var tc = tmp.type();
879 const char *
p = tc->name();
885 catch(CORBA::Exception&
ex)
887 msg =
":Component no longer reachable: Caught CORBA::Exception.\n";
890 CORBA::TypeCode_var tc = tmp.type();
891 const char *
p = tc->name();
897 catch(omniORB::fatalException& fe)
899 msg =
":Component no longer reachable: Caught omniORB::fatalException.\n";
901 log <<
" file: " << fe.file() << endl;
902 log <<
" line: " << fe.line() << endl;
903 log <<
" mesg: " << fe.errmsg() << endl;
908 msg =
":Component no longer reachable: Caught unknown exception.";
915 DEBTRACE(
"SalomeNode::shutdown " << level);
#define YACSTRACE(level, msg)
YACSTRACE macro for dynamic trace: print only if YACS_TRACELEVEL environment variable is set and leve...
This class implements the interface Engines::ConnectionManager. It is used to make connections betwee...
ConnectionManager::connectionId connect(Engines::DSC_ptr uses_component, const char *uses_port_name, Engines::DSC_ptr provides_component, const char *provides_port_name)
void disconnect(ConnectionManager::connectionId id, Engines::DSC::Message message)
Class for CORBA component instance.
Class for CORBA Service Node.
static const char IMPL_NAME[]
virtual ServiceNode * createNode(const std::string &name)
Create a CORBANode with the same component object and no input or output port.
Node * simpleClone(ComposedNode *father, bool editionOnly) const
Clone the node : must also clone the component instance ?
virtual void execute()
Execute the service on the component associated to the node.
virtual std::string getKind() const
Return the service node kind.
CORBANode(const CORBANode &other, ComposedNode *father)
virtual void shutdown(int level)
Base class for all composed nodes.
std::string getName() const
std::string getName() const
std::list< InputPort * > _setOfInputPort
virtual std::string getErrorDetails()
Give a description of error when node status is ERROR.
std::list< OutputDataStreamPort * > _setOfOutputDataStreamPort
virtual void addDatastreamPortToInitMultiService(const std::string &port_name, int number)
std::list< InputDataStreamPort * > _setOfInputDataStreamPort
std::list< OutputPort * > _setOfOutputPort
virtual void initService()
virtual void disconnectService()
virtual void connectService()
Base class for all nodes.
virtual void cleanNodes()
Clean the node in case of not clean exit.
std::map< std::string, std::string > getProperties()
std::string _implementation
const std::string & getName() const
std::string _errorDetails
std::set< InPort * > edSetInPort() const
ConnectionManager & getConnectionManager()
static YACS::ENGINE::TypeCode * _tc_file
Class for Salome component instance.
Class for Salome component Service Node.
virtual ServiceNode * createNode(const std::string &name)
Create a SalomeNode with the same component object and no input or output port.
virtual std::string getContainerLog()
returns a string that contains the name of the container log file if it exists
SalomeNode(const SalomeNode &other, ComposedNode *father)
virtual void execute()
Execute the service on the component associated to the node.
YACS::BASES::Mutex _mutex
Node * simpleClone(ComposedNode *father, bool editionOnly) const
virtual void shutdown(int level)
Stop all pending activities of the node.
virtual std::string getKind() const
Return the service node kind.
Class for calculation node associated with a component service.
ComponentInstance * _component
virtual void setComponent(ComponentInstance *compo)
Associate an existing component instance to this service node AND check the consistency regarding the...
virtual ComponentInstance * getComponent()
Return the associated component instance.
YACSRUNTIMESALOME_EXPORT RuntimeSALOME * getSALOMERuntime()