Version: 8.3.0
yacs_clt.cxx File Reference
#include <Python.h>
#include <yacs.hh>
#include "RuntimeSALOME.hxx"
#include "Proc.hxx"
#include "parsers.hxx"
#include <vector>
#include <string>
#include <iostream>
#include <pthread.h>
Include dependency graph for yacs_clt.cxx:

Go to the source code of this file.

Classes

class  Obs_i
 

Functions

void * run (void *obj)
 
int main (int argc, char **argv)
 

Variables

YACS::YACSLoader::YACSLoaderloader
 
YACS_ORB::YACS_Gen_var yacsref
 
YACS_ORB::Proc_ptr server_proc
 

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 59 of file yacs_clt.cxx.

References CORBAEngineTest::i, loader, orb, server_proc, YACS::ENGINE::RuntimeSALOME::setRuntime(), YACS::YACSLoader::YACSLoader(), and yacsref.

60 {
63 
64  try
65  {
66  CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
67  CORBA::Object_var obj = orb->string_to_object("corbaname:rir:#test.my_context/Yacs.Object");
68  yacsref = YACS_ORB::YACS_Gen::_narrow(obj);
69  if( CORBA::is_nil(yacsref) )
70  {
71  std::cerr << "Can't narrow reference to type yacs (or it was nil)." << std::endl;
72  return 1;
73  }
74 
75  //Activate POA
76  CORBA::Object_var poa = orb->resolve_initial_references("RootPOA");
77  PortableServer::POA_var root_poa = PortableServer::POA::_narrow(poa);
78  PortableServer::POAManager_var poa_man = root_poa->the_POAManager();
79  poa_man->activate();
80 
81  char* xmlFile="/local/chris/SALOME2/SUPERV/YACS/BR_CC/YACS_SRC/src/yacsloader/samples/aschema.xml";
82  //Load XML file in client
83  YACS::ENGINE::Proc* local_proc=loader->load(xmlFile);
84  //Load xml file in server
85  server_proc = yacsref->Load(xmlFile);
86  //Create an observer for server_proc
87  Obs_i* obs=new Obs_i(server_proc);
88  YACS_ORB::Observer_ptr obs_ptr = obs->_this();
89  //Get ids and names
90  YACS_ORB::stringArray_var names;
91  YACS_ORB::longArray_var ids;
92  server_proc->getIds(ids.out(),names.out());
93  //Register it
94  int len=ids->length();
95  int numid;
96  for(int i=0;i<len;i++)
97  {
98  numid=ids[i];
99  yacsref->addObserver(obs_ptr,numid,"status");
100  }
101  //Execute Proc in thread ??
102  pthread_t th;
103  //pthread_create(&th,NULL,run,0);
104  yacsref->Run(server_proc);
105 
106  //orb->run();
107  orb->destroy();
108  }
109  catch(CORBA::COMM_FAILURE& ex) {
110  std::cerr << "Caught system exception COMM_FAILURE -- unable to contact the "
111  << "object." << std::endl;
112  }
113  catch(CORBA::SystemException&) {
114  std::cerr << "Caught a CORBA::SystemException." << std::endl;
115  }
116  catch(CORBA::Exception&) {
117  std::cerr << "Caught CORBA::Exception." << std::endl;
118  }
119  catch(omniORB::fatalException& fe) {
120  std::cerr << "Caught omniORB::fatalException:" << std::endl;
121  std::cerr << " file: " << fe.file() << std::endl;
122  std::cerr << " line: " << fe.line() << std::endl;
123  std::cerr << " mesg: " << fe.errmsg() << std::endl;
124  }
125  catch(...) {
126  std::cerr << "Caught unknown exception." << std::endl;
127  }
128  return 0;
129 }
void* run ( void *  obj)

Definition at line 54 of file yacs_clt.cxx.

References server_proc, and yacsref.

Referenced by YACS::ENGINE::XmlNode::execute().

55 {
56  yacsref->Run(server_proc);
57 }

Variable Documentation

YACS_ORB::Proc_ptr server_proc

Definition at line 52 of file yacs_clt.cxx.

Referenced by main(), and run().

YACS_ORB::YACS_Gen_var yacsref

Definition at line 51 of file yacs_clt.cxx.

Referenced by main(), and run().