Version: 9.16.0
driver.cxx File Reference
#include "yacsconfig.h"
#include "RuntimeSALOME.hxx"
#include "Proc.hxx"
#include "Logger.hxx"
#include "Exception.hxx"
#include "Executor.hxx"
#include "parsers.hxx"
#include "VisitorSalomeSaveState.hxx"
#include "VisitorSaveSalomeSchema.hxx"
#include "LoadState.hxx"
#include "Dispatcher.hxx"
#include "LinkInfo.hxx"
#include "ObserverAsPlugin.hxx"
#include "PythonNode.hxx"
#include "KernelBasis.hxx"
#include "SALOME_Launcher.hxx"
#include "ServiceUnreachable.hxx"
#include "SALOME_NamingService_Wrapper.hxx"
#include "SALOME_NamingService.hxx"
#include "SALOME_ModuleCatalog.hh"
#include "SALOMESDS_DataServerManager.hxx"
#include "Basics_Utils.hxx"
#include <iostream>
#include <fstream>
#include <signal.h>
#include <list>
#include <argp.h>
Include dependency graph for driver.cxx:

Go to the source code of this file.

Classes

struct  arguments
 
struct  thread_st
 

Typedefs

typedef void(* sighandler_t) (int)
 

Functions

static error_t parse_opt (int key, char *arg, struct argp_state *state)
 
void timer (std::string msg)
 
void Handler (int theSigId)
 
void * dumpState (void *arg)
 
sighandler_t setsig (int sig, sighandler_t handler)
 
bool parse_init_port (const std::string &input, std::string &node, std::string &port, std::string &value)
 
void InitializeSSL ()
 
void shutdownServers ()
 
int main (int argc, char *argv[])
 

Variables

const char * argp_program_version ="driver V0.1"
 
const char * argp_program_bug_address ="<nepal@nepal.edf.fr>"
 
static char doc [] ="driver -- a SALOME YACS graph executor"
 
static char args_doc [] = "graph.xml"
 
static struct argp_option options []
 
static struct argp argp = { options, parse_opt, args_doc, doc }
 
Procp =0
 
static struct arguments myArgs
 

Typedef Documentation

◆ sighandler_t

typedef void(* sighandler_t) (int)

Definition at line 277 of file driver.cxx.

Function Documentation

◆ dumpState()

void * dumpState ( void *  arg)

Definition at line 252 of file driver.cxx.

253{
254 thread_st *st = (thread_st*)arg;
257#ifdef WIN32
258 Sleep(st->nbsec);
259#else
260 sleep(st->nbsec);
261#endif
262 string cmd = "touch " + st->lockFile;
263 system(cmd.c_str());
265 vst.openFileDump(st->dumpFile);
266 p->accept(&vst);
267 vst.closeFileDump();
268 cmd = "rm -f " + st->lockFile;
269 system(cmd.c_str());
271 }
272 delete st;
273 return NULL;
274}
virtual YACS::StatesForNode getEffectiveState() const
Return the node state in the context of its father.
Definition: Node.cxx:538
virtual void accept(Visitor *visitor)
Definition: Proc.cxx:199
Proc * p
Definition: driver.cxx:216
StatesForNode
Definition: define.hxx:34
@ FAILED
Definition: define.hxx:51
@ EXECFAILED
Definition: define.hxx:46
@ INTERNALERR
Definition: define.hxx:49
@ DONE
Definition: define.hxx:43
@ DISABLED
Definition: define.hxx:50
@ LOADFAILED
Definition: define.hxx:45
@ ERROR
Definition: define.hxx:52
int nbsec
Definition: driver.cxx:106
string lockFile
Definition: driver.cxx:108
string dumpFile
Definition: driver.cxx:107

References YACS::ENGINE::Proc::accept(), YACS::ENGINE::VisitorSaveState::closeFileDump(), YACS::DISABLED, YACS::DONE, thread_st::dumpFile, YACS::ERROR, YACS::EXECFAILED, YACS::FAILED, YACS::ENGINE::Node::getEffectiveState(), YACS::INTERNALERR, YACS::LOADFAILED, thread_st::lockFile, thread_st::nbsec, YACS::ENGINE::VisitorSaveState::openFileDump(), p, and yacsorb.CORBAEngineTest::state.

Referenced by main().

◆ Handler()

void Handler ( int  theSigId)

Definition at line 219 of file driver.cxx.

220{
221 if(p)
222 {
223 p->cleanNodes();
224 //if requested save state
225 bool isFinalDump = !myArgs.finalDump.empty();
226 if (isFinalDump)
227 {
229 vst.openFileDump(myArgs.finalDump);
230 p->accept(&vst);
231 vst.closeFileDump();
232 }
233 //if requested shutdown schema
234 if(myArgs.shutdown < 999)
235 {
237 }
238 }
239 if (myArgs.killPort)
240 {
241 ostringstream command;
242 command << "killSalomeWithPort.py " << myArgs.killPort;
243 int status = system(command.str().c_str());
244 if (status == 0)
245 cerr << "Salome application on port " << myArgs.killPort << " is killed" << endl;
246 else
247 cerr << "Error: Can't kill Salome application on port " << myArgs.killPort << endl;
248 }
249 _exit(1);
250}
virtual void shutdown(int level)
Stop all pending activities of the composed node.
virtual void cleanNodes()
Clean the composed node in case of not clean exit.
static struct arguments myArgs
Definition: driver.cxx:217
std::string finalDump
Definition: driver.cxx:94
int killPort
Definition: driver.cxx:100
int shutdown
Definition: driver.cxx:98

References YACS::ENGINE::Proc::accept(), YACS::ENGINE::ComposedNode::cleanNodes(), YACS::ENGINE::VisitorSaveState::closeFileDump(), arguments::finalDump, arguments::killPort, myArgs, YACS::ENGINE::VisitorSaveState::openFileDump(), p, YACS::ENGINE::ComposedNode::shutdown(), and arguments::shutdown.

Referenced by main().

◆ InitializeSSL()

void InitializeSSL ( )

Definition at line 309 of file driver.cxx.

310{
311 setSSLMode(true);
312 KERNEL::getLauncherSA();
313}

Referenced by main().

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 342 of file driver.cxx.

343{
344 // Parse our arguments; every option seen by parse_opt will be reflected in arguments.
345#if defined WIN32 || defined __APPLE__
346#else
347 argp_parse (&argp, argc, argv, 0, 0, &myArgs);
348 std::cerr << "graph = " << myArgs.args[0];
349 std::cerr << " options: display=" << myArgs.display;
350 std::cerr << " verbose="<<myArgs.verbose;
351 std::cerr << " stop-on-error=" << myArgs.stop;
352 std::cerr << " shutdown=" << myArgs.shutdown;
353 std::cerr << " reset=" << myArgs.reset;
354 if (myArgs.killPort)
355 std::cerr << " kill-port=" << myArgs.killPort;
356 if (myArgs.stop)
357 std::cerr << " dumpErrorFile=" << myArgs.dumpErrorFile << std::endl;
358 else
359 std::cerr << std::endl;
360 std::list<std::string>::const_iterator it;
361 for(it=myArgs.init_ports.begin(); it != myArgs.init_ports.end(); it++)
362 {
363 std::cerr << (*it) << std::endl;
364 }
365#endif
366
367#ifndef WIN32
368 setsig(SIGINT,&Handler);
369 setsig(SIGTERM,&Handler);
370#endif
371
373
374 timer("Starting ");
375 long flags = RuntimeSALOME::UsePython + RuntimeSALOME::UseCorba + RuntimeSALOME::UseXml + \
376 RuntimeSALOME::UseCpp + RuntimeSALOME::UseSalome;
377 RuntimeSALOME::setRuntime(flags, argc, argv);
378
379 // Try to load the session catalog if it exists
380 try
381 {
383 runTime->loadModulCatalog();
384 CORBA::ORB_ptr orb = runTime->getOrb();
385 if (orb)
386 {
387 SALOME_NamingService_Wrapper namingService(orb);
388 CORBA::Object_var obj = namingService.Resolve("/Kernel/ModulCatalog");
389 SALOME_ModuleCatalog::ModuleCatalog_var aModuleCatalog = SALOME_ModuleCatalog::ModuleCatalog::_narrow(obj);
390 if (! CORBA::is_nil(aModuleCatalog))
391 {
392 CORBA::String_var anIOR = orb->object_to_string( aModuleCatalog );
393 YACS::ENGINE::Catalog* aCatalog = runTime->loadCatalog( "session", anIOR.in() );
394 runTime->addCatalog(aCatalog);
395 }
396 }
397 }
398 catch(ServiceUnreachable& e)
399 {
400 //Naming service unreachable don't add catalog
401 }
402
404 Executor executor;
405
406 try
407 {
408 timer("Elapsed time before load: ");
409 p=loader.load(myArgs.args[0]);
410 if(p==0)
411 {
412 std::cerr << "The imported file is probably not a YACS schema file" << std::endl;
413 return 1;
414 }
416 {
417 std::list<Node *> allNodes = p->getAllRecursiveNodes();
418 for(auto node : allNodes)
419 {
420 PythonNode *nodePy = dynamic_cast<PythonNode *>(node);
421 if( nodePy )
422 {
423 nodePy->setSqueezeStatus( true );
424 }
425 }
426 }
427 // Initialize the ports
428 for(std::list<std::string>::iterator it=myArgs.init_ports.begin(); it != myArgs.init_ports.end(); it++)
429 {
430 std::string node, port, value;
431 if(parse_init_port((*it), node, port, value))
432 {
433 std::cerr << "Initialization node=" << node
434 << " port=" << port
435 << " value=" << value << std::endl;
436
437 std::string init_state;
438 init_state = p->setInPortValue(node, port, value);
439 if(value.compare(init_state))
440 {
441 std::cerr << "Error on initialization:" << init_state << std::endl;
442 return 1;
443 }
444 }
445 else
446 {
447 std::cerr << "Error on parsing initialization string:" << (*it) << std::endl;
448 return 1;
449 }
450 }
451
452 //Get the parser logger
453 Logger* logger=p->getLogger("parser");
454 //Print errors logged if any
455 if(!logger->isEmpty())
456 {
457 std::cerr << "The imported file has errors" << std::endl;
458 std::cerr << logger->getStr() << std::endl;
459 }
460 //Don't execute if there are errors
461 if(logger->hasErrors())
462 {
463 if(!p->isValid())
464 {
465 std::string report=p->getErrorReport();
466 std::cerr << "The schema is not valid and can not be executed" << std::endl;
467 std::cerr << report << std::endl;
468 }
469 delete p;
471 Dispatcher* disp=Dispatcher::getDispatcher();
472 r->fini();
473 delete r;
474 delete disp;
475 return 1;
476 }
477 timer("Elapsed time after load: ");
478
479 if(!p->isValid())
480 {
481 std::string report=p->getErrorReport();
482 std::cerr << "The schema is not valid and can not be executed" << std::endl;
483 std::cerr << report << std::endl;
485 Dispatcher* disp=Dispatcher::getDispatcher();
486 r->fini();
487 delete r;
488 delete disp;
489 return 1;
490 }
491 timer("Elapsed time after validation: ");
492
493 // Check consistency
494 LinkInfo info(LinkInfo::ALL_DONT_STOP);
495 p->checkConsistency(info);
496 if(info.areWarningsOrErrors())
497 {
498 std::cerr << "The schema is not consistent and can not be executed" << std::endl;
499 std::cerr << info.getGlobalRepr() << std::endl;
501 Dispatcher* disp=Dispatcher::getDispatcher();
502 r->fini();
503 delete r;
504 delete disp;
505 return 1;
506 }
507 timer("Elapsed time after check consistency: ");
508
509 //execution
510 bool isXmlSchema = !myArgs.xmlSchema.empty() ;
511 if (isXmlSchema)
512 {
514 vss.openFileSchema(myArgs.xmlSchema);
515 p->accept(&vss);
516 vss.closeFileSchema();
517 }
518
519 bool fromScratch = myArgs.loadState.empty() ;
520 if (!fromScratch)
521 {
522 p->init();
523 p->exUpdateState();
524 stateParser* rootParser = new stateParser();
525 stateLoader myStateLoader(rootParser, p);
526 myStateLoader.parse(myArgs.loadState);
527 if(myArgs.reset>0)
528 {
530 p->exUpdateState();
531 }
532 }
533
534 if (myArgs.stop)
535 {
536 if ( !myArgs.dumpErrorFile.empty() )
537 executor.setStopOnError(true, myArgs.dumpErrorFile);
538 else
539 executor.setStopOnError(false, myArgs.dumpErrorFile);
540 }
541 if(myArgs.display>0)
542 {
543 std::ofstream f("toto");
544 p->writeDot(f);
545 f.close();
546 }
547
548 bool isDump = (myArgs.dump != 0);
549 pthread_t th;
550 if (isDump)
551 {
552 thread_st *st = new thread_st;
553 st->nbsec = myArgs.dump;
554 st->dumpFile = string("dumpState_") + myArgs.args[0];
555 string rootFile = st->dumpFile.substr(0,st->dumpFile.find("."));
556 st->lockFile = rootFile + ".lock";
557 pthread_create(&th,NULL,&dumpState,(void*)st);
558 }
560 cerr << "+++++++++++++++++++ start calculation +++++++++++++++++++" << endl;
561 executor.RunW(p,myArgs.display, fromScratch);
562 cerr << "+++++++++++++++++++ end calculation +++++++++++++++++++" << endl;
563 cerr << "Proc state : " << Node::getStateName(p->getEffectiveState()) << endl;
564 timer("Elapsed time after execution: ");
565
566 // Return 0 if SCHEMA OK
567 // Return 1 for YACS ERROR (EXCEPTION NOT CATCHED)
568 // Return 2 for YACS SCHEMA ERROR/FAILED
569 int return_value = 0;
570
572 {
573 std::string report=p->getErrorReport();
574 std::cerr << "Execution has ended in error" << std::endl;
575 std::cerr << report << std::endl;
576 return_value = 2;
577 }
578
579 if(myArgs.display>0)
580 {
581 std::ofstream g("titi");
582 p->writeDot(g);
583 g.close();
584 }
585
586 if (isDump)
587 {
588 pthread_join(th,NULL);
589 }
590
591 bool isFinalDump = !myArgs.finalDump.empty() ;
592 if (isFinalDump)
593 {
595 vst.openFileDump(myArgs.finalDump);
596 p->accept(&vst);
597 vst.closeFileDump();
598 }
599 if(myArgs.shutdown < 999)
600 {
603 }
604 delete p;
606 Dispatcher* disp=Dispatcher::getDispatcher();
607 r->fini();
608 delete r;
609 delete disp;
611 return return_value;
612 }
613 catch (YACS::Exception& e)
614 {
615 cerr << "Caught a YACS exception" << endl;
616 cerr << e.what() << endl;
618 Dispatcher* disp=Dispatcher::getDispatcher();
619 r->fini();
620 delete r;
621 delete disp;
622 return 1;
623 }
624 catch (const std::ios_base::failure&)
625 {
626 cerr << "Caught an io failure exception" << endl;
627 return 1;
628 }
629 catch(CORBA::SystemException& ex)
630 {
631 cerr << "Caught a CORBA::SystemException.:" << __FILE__ << ":" << __LINE__ << ":" ;
632 CORBA::Any tmp;
633 tmp <<= ex;
634 CORBA::TypeCode_var tc = tmp.type();
635 const char *p = tc->name();
636 if ( *p != '\0' )
637 cerr <<p;
638 else
639 cerr << tc->id();
640 cerr << endl;
641 return 1;
642 }
643 catch(omniORB::fatalException& fe)
644 {
645 cerr << "Caught omniORB::fatalException:" << endl;
646 cerr << " file: " << fe.file() << endl;
647 cerr << " line: " << fe.line() << endl;
648 cerr << " mesg: " << fe.errmsg() << endl;
649 return 1;
650 }
651 catch(...)
652 {
653 cerr << "Caught unknown exception." << endl;
654 return 1;
655 }
656}
void init(bool start=true)
Initialize the bloc.
Definition: Bloc.cxx:95
void exUpdateState()
Update the bloc state.
Definition: Bloc.cxx:153
class for YACS catalogs.
Definition: Catalog.hxx:42
std::list< Node * > getAllRecursiveNodes()
Get all children nodes elementary and composed including this node.
virtual std::string getErrorReport()
returns a string that contains an error report if the node is in error
virtual void resetState(int level)
Reset the state of the node and its children depending on the parameter level.
void checkConsistency(LinkInfo &info) const
Base class for dispatcher in observer pattern.
Definition: Dispatcher.hxx:74
Threaded Executor.
Definition: Executor.hxx:63
void setStopOnError(bool dumpRequested=false, std::string xmlFile="")
ask to stop execution on the first node found in error
Definition: Executor.cxx:399
void RunW(Scheduler *graph, int debug=0, bool fromScratch=true)
Definition: Executor.cxx:1833
Class that deal with list of semantics links for high level analysis.
Definition: LinkInfo.hxx:83
Class for logging error messages.
Definition: Logger.hxx:38
virtual bool hasErrors()
Definition: Logger.cxx:101
virtual bool isEmpty()
Definition: Logger.cxx:96
virtual std::string getStr()
Definition: Logger.cxx:85
virtual int isValid()
indicates if the node is valid (returns 1) or not (returns 0)
Definition: Node.cxx:730
std::string setInPortValue(std::string nodeName, std::string portName, std::string value)
Definition: Proc.cxx:288
virtual Logger * getLogger(const std::string &name)
Definition: Proc.cxx:431
virtual void writeDot(std::ostream &os) const
Dump to the input stream a dot representation of the node.
Definition: Proc.cxx:86
void setSqueezeStatus(bool sqStatus)
Definition: PythonNode.hxx:111
CORBA::ORB_ptr getOrb() const
virtual void addCatalog(Catalog *catalog)
Add a catalog of types and nodes to the runtime.
Definition: Runtime.cxx:323
virtual Catalog * loadCatalog(const std::string &sourceKind, const std::string &path)
Load a catalog of calculation to use as factory.
Definition: Runtime.cxx:285
class for parse an xml file, use a dedicated parser, to load a saved state of a SALOME execution.
Definition: LoadState.hxx:54
specialized parser to load SALOME execution saved states.
Definition: LoadState.hxx:81
const char * what(void) const noexcept
Definition: Exception.cxx:50
void shutdownServers()
Definition: driver.cxx:315
void * dumpState(void *arg)
Definition: driver.cxx:252
bool parse_init_port(const std::string &input, std::string &node, std::string &port, std::string &value)
Definition: driver.cxx:294
void Handler(int theSigId)
Definition: driver.cxx:219
sighandler_t setsig(int sig, sighandler_t handler)
Definition: driver.cxx:278
void InitializeSSL()
Definition: driver.cxx:309
static struct argp argp
Definition: driver.cxx:200
void timer(std::string msg)
Definition: driver.cxx:203
YACSRUNTIMESALOME_EXPORT RuntimeSALOME * getSALOMERuntime()
void YACSLIBENGINE_EXPORT UnLoadObserversPluginIfAny()
YACSLIBENGINE_EXPORT Runtime * getRuntime()
Definition: Runtime.cxx:61
void YACSLIBENGINE_EXPORT LoadObserversPluginIfAny(ComposedNode *rootNode, Executor *executor)
std::list< std::string > init_ports
Definition: driver.cxx:102
std::string xmlSchema
Definition: driver.cxx:96
int stop
Definition: driver.cxx:92
int display
Definition: driver.cxx:90
std::string dumpErrorFile
Definition: driver.cxx:93
int dump
Definition: driver.cxx:95
bool squeezeMemory
Definition: driver.cxx:101
int reset
Definition: driver.cxx:99
char * args[1]
Definition: driver.cxx:89
std::string loadState
Definition: driver.cxx:97
int verbose
Definition: driver.cxx:91
CORBA::ORB_ptr orb
Definition: yacsSrv.cxx:39
YACS::YACSLoader::YACSLoader * loader
Definition: yacs_clt.cxx:31

References YACS::ENGINE::Proc::accept(), YACS::ENGINE::Runtime::addCatalog(), YACS::ENGINE::LinkInfo::areWarningsOrErrors(), argp, arguments::args, YACS::ENGINE::ComposedNode::checkConsistency(), YACS::ENGINE::VisitorSaveState::closeFileDump(), YACS::ENGINE::VisitorSaveSchema::closeFileSchema(), arguments::display, YACS::DONE, arguments::dump, arguments::dumpErrorFile, thread_st::dumpFile, dumpState(), testCppPluginInvokation::ex, YACS::ENGINE::Bloc::exUpdateState(), gui.CONNECTOR::f(), arguments::finalDump, YACS::ENGINE::ComposedNode::getAllRecursiveNodes(), YACS::ENGINE::Node::getEffectiveState(), YACS::ENGINE::ComposedNode::getErrorReport(), YACS::ENGINE::LinkInfo::getGlobalRepr(), YACS::ENGINE::Proc::getLogger(), YACS::ENGINE::RuntimeSALOME::getOrb(), YACS::ENGINE::getRuntime(), YACS::ENGINE::getSALOMERuntime(), YACS::ENGINE::Logger::getStr(), Handler(), YACS::ENGINE::Logger::hasErrors(), YACS::ENGINE::Bloc::init(), arguments::init_ports, InitializeSSL(), YACS::ENGINE::Logger::isEmpty(), YACS::ENGINE::Node::isValid(), arguments::killPort, YACS::ENGINE::Runtime::loadCatalog(), loader, YACS::ENGINE::RuntimeSALOME::loadModulCatalog(), YACS::ENGINE::LoadObserversPluginIfAny(), arguments::loadState, thread_st::lockFile, myArgs, thread_st::nbsec, YACS::ENGINE::VisitorSaveState::openFileDump(), YACS::ENGINE::VisitorSaveSchema::openFileSchema(), orb, p, YACS::ENGINE::stateLoader::parse(), parse_init_port(), testCppPluginInvokation::r, arguments::reset, YACS::ENGINE::ComposedNode::resetState(), SALOME_NamingService_Wrapper::Resolve(), YACS::ENGINE::Executor::RunW(), YACS::ENGINE::Proc::setInPortValue(), setsig(), YACS::ENGINE::PythonNode::setSqueezeStatus(), YACS::ENGINE::Executor::setStopOnError(), YACS::ENGINE::ComposedNode::shutdown(), arguments::shutdown, shutdownServers(), arguments::squeezeMemory, arguments::stop, timer(), YACS::ENGINE::UnLoadObserversPluginIfAny(), arguments::verbose, YACS::ENGINE::Proc::writeDot(), and arguments::xmlSchema.

◆ parse_init_port()

bool parse_init_port ( const std::string &  input,
std::string &  node,
std::string &  port,
std::string &  value 
)

Definition at line 294 of file driver.cxx.

295{
296 bool ok = true;
297 size_t pos_eq = input.find('=');
298 if(pos_eq == std::string::npos || pos_eq == input.size())
299 return false;
300 value = input.substr(pos_eq+1);
301 size_t pos_dot = input.rfind('.', pos_eq);
302 if(!pos_dot || pos_dot == std::string::npos || pos_dot >= pos_eq-1)
303 return false;
304 port = input.substr(pos_dot+1, pos_eq-pos_dot-1);
305 node = input.substr(0, pos_dot);
306 return true;
307}

Referenced by main(), and driver_internal::patchGraph().

◆ parse_opt()

static error_t parse_opt ( int  key,
char *  arg,
struct argp_state *  state 
)
static

Definition at line 116 of file driver.cxx.

117{
118#if defined WIN32 || defined __APPLE__
119#else
120 // Get the input argument from argp_parse, which we
121 // know is a pointer to our arguments structure.
122 struct arguments *myArgs = (arguments*)state->input;
123
124 switch (key)
125 {
126 case 'd':
127 myArgs->display = atoi(arg);
128 break;
129 case 't':
130 myArgs->shutdown = atoi(arg);
131 break;
132 case 'r':
133 myArgs->reset = atoi(arg);
134 break;
135 case 'v':
136 myArgs->verbose = 1;
137 break;
138 case 's':
139 myArgs->stop = 1;
140 break;
141 case 'e':
142 myArgs->stop = 1;
143 if (arg)
144 myArgs->dumpErrorFile = arg;
145 else
146 myArgs->dumpErrorFile = "dumpErrorState.xml";
147 break;
148 case 'f':
149 if (arg)
150 myArgs->finalDump = arg;
151 else
152 myArgs->finalDump = "finalDumpState.xml";
153 break;
154 case 'g':
155 if (arg)
156 myArgs->dump = atoi(arg);
157 else
158 myArgs->dump = 60;
159 break;
160 case 'l':
161 myArgs->loadState = arg;
162 break;
163 case 'x':
164 if (arg)
165 myArgs->xmlSchema = arg;
166 else
167 myArgs->xmlSchema = "saveSchema.xml";
168 break;
169 case 'k':
170 myArgs->killPort = atoi(arg);
171 break;
172 case 'i':
173 if (arg)
174 myArgs->init_ports.push_back(std::string(arg));
175 break;
176 case 'z':
177 myArgs->squeezeMemory = ! ( bool( atoi(arg) ) );
178 break;
179 case ARGP_KEY_ARG:
180 if (state->arg_num >=1) // Too many arguments.
181 argp_usage (state);
182 myArgs->args[state->arg_num] = arg;
183 break;
184
185 case ARGP_KEY_END:
186 if (state->arg_num < 1) // Not enough arguments.
187 argp_usage (state);
188 break;
189
190 default:
191 return ARGP_ERR_UNKNOWN;
192 }
193#endif
194 return 0;
195}

References arguments::args, arguments::display, arguments::dump, arguments::dumpErrorFile, arguments::finalDump, arguments::init_ports, arguments::killPort, arguments::loadState, myArgs, arguments::reset, arguments::shutdown, arguments::squeezeMemory, yacsorb.CORBAEngineTest::state, arguments::stop, arguments::verbose, and arguments::xmlSchema.

◆ setsig()

sighandler_t setsig ( int  sig,
sighandler_t  handler 
)

Definition at line 278 of file driver.cxx.

279{
280 sigset_t sigmask;
281 sigemptyset (&sigmask);
282 sigaddset(&sigmask, sig);
283 sigprocmask(SIG_UNBLOCK, &sigmask, NULL);
284 struct sigaction context, ocontext;
285 context.sa_handler = handler;
286 sigemptyset(&context.sa_mask);
287 context.sa_flags = 0;
288 if (sigaction(sig, &context, &ocontext) == -1)
289 return SIG_ERR;
290 return ocontext.sa_handler;
291}

Referenced by main().

◆ shutdownServers()

void shutdownServers ( )

Definition at line 315 of file driver.cxx.

316{
317 // shutdown data server scopes
318 try
319 {
321 runTime->loadModulCatalog();
322 CORBA::ORB_ptr orb = runTime->getOrb();
323 if (orb)
324 {
325 SALOME_NamingService_Wrapper namingService(orb);
326 CORBA::Object_var objDSM(namingService.Resolve(SALOMESDS::DataServerManager::NAME_IN_NS));
327 SALOME::DataServerManager_var dsm(SALOME::DataServerManager::_narrow(objDSM));
328 if ( !CORBA::is_nil(dsm) )
329 dsm->shutdownScopes();
330 }
331 }
332 catch(const CORBA::Exception& )
333 {
334 // ignore and continue
335 }
336 catch(ServiceUnreachable& e)
337 {
338 // ignore and continue
339 }
340}

References YACS::ENGINE::RuntimeSALOME::getOrb(), YACS::ENGINE::getSALOMERuntime(), YACS::ENGINE::RuntimeSALOME::loadModulCatalog(), orb, and SALOME_NamingService_Wrapper::Resolve().

Referenced by main().

◆ timer()

void timer ( std::string  msg)

Definition at line 203 of file driver.cxx.

204{
205#if defined WIN32 || defined __APPLE__
206#else
207 struct timeval tv;
208 gettimeofday(&tv,NULL);
209 long t=tv.tv_sec*1000+tv.tv_usec/1000;
210 static long t0=t;
211 gettimeofday(&tv,NULL);
212 std::cerr << msg << tv.tv_sec*1000+tv.tv_usec/1000-t0 << " ms" << std::endl;
213#endif
214}
static timeval tv
Definition: chrono.hxx:71

References gui.Appli::t, and tv.

Referenced by main().

Variable Documentation

◆ argp

struct argp argp = { options, parse_opt, args_doc, doc }
static

Definition at line 200 of file driver.cxx.

Referenced by main().

◆ argp_program_bug_address

const char* argp_program_bug_address ="<nepal@nepal.edf.fr>"

Definition at line 62 of file driver.cxx.

◆ argp_program_version

const char* argp_program_version ="driver V0.1"

Definition at line 61 of file driver.cxx.

◆ args_doc

char args_doc[] = "graph.xml"
static

Definition at line 64 of file driver.cxx.

◆ doc

◆ myArgs

struct arguments myArgs
static

Definition at line 217 of file driver.cxx.

Referenced by Handler(), main(), and parse_opt().

◆ options

struct argp_option options[]
static
Initial value:
=
{
{"display", 'd', "level", 0, "Display dot files: 0=never to 3=very often (default 0)"},
{"verbose", 'v', 0, 0, "Produce verbose output" },
{"stop-on-error", 's', 0, 0, "Stop on first error" },
{"dump-on-error", 'e', "file", OPTION_ARG_OPTIONAL, "Stop on first error and dump state"},
{"dump-final", 'f', "file", OPTION_ARG_OPTIONAL, "dump final state"},
{"dump", 'g', "nbsec", OPTION_ARG_OPTIONAL, "dump state"},
{"load-state", 'l', "file", 0, "Load State from a previous partial execution"},
{"save-xml-schema", 'x', "file", OPTION_ARG_OPTIONAL, "dump xml schema"},
{"shutdown", 't', "level", 0, "Shutdown the schema: 0=no shutdown to 3=full shutdown (default 1)"},
{"reset", 'r', "level", 0, "Reset the schema before execution: 0=nothing, 1=reset error nodes to ready state (default 0)"},
{"kill-port", 'k', "port", 0, "Kill Salome application running on the specified port if the driver process is killed (with SIGINT or SIGTERM)"},
{"init_port", 'i', "value", OPTION_ARG_OPTIONAL, "Initialisation value of a port, specified as bloc.node.port=value."},
{"donotsqueeze", 'z', "value", 0, "Desactivate squeeze memory optimization."},
{ nullptr }
}

Definition at line 68 of file driver.cxx.

Referenced by YACS::HMI::EditionScript::onEdit().

◆ p

Proc* p =0

Definition at line 216 of file driver.cxx.

Referenced by YACS::ENGINE::PythonNode::applyDPLScope(), YACS::switchtypeParser::case_(), YACS::ENGINE::CppNode::cloneNode(), YACS::ENGINE::PythonNode::cloneNode(), YACS::ENGINE::PyFuncNode::cloneNode(), YACS::ENGINE::SalomePythonNode::cloneNode(), YACS::ENGINE::SalomeContainerToolsBase::CreateComponentInstance(), YACS::ENGINE::LocalContainer::createInternalInstance(), YACS::switchtypeParser::default_(), driverTest(), dumpState(), YACS::ENGINE::InPort::edNotifyDereferencedBy(), YACS::ENGINE::InPort::edNotifyReferencedBy(), YACS::ENGINE::ElementaryNode::edRemovePort(), YACS::ENGINE::CORBANode::execute(), YACS::ENGINE::SalomeNode::execute(), YACS::ENGINE::CppNode::execute(), YACS::ENGINE::DistributedPythonNode::execute(), YACS::ENGINE::SalomePythonNode::execute(), YACS::ENGINE::XmlNode::execute(), YACS::ENGINE::PythonNode::executeLocal(), YACS::ENGINE::PyFuncNode::executeLocal(), YACS::ENGINE::PythonNode::executeRemote(), YACS::ENGINE::PyFuncNode::executeRemote(), xmlParserBase::getAttributes(), YACS::ENGINE::SalomeNode::getContainerLog(), YACS::ENGINE::Node::getDPLScopeInfo(), YACS::HMI::SceneLinkItem::getFromNode(), YACS::HMI::SceneLinkItem::getToNode(), Handler(), outputParser::init(), YACS::ENGINE::graphParser::init(), YACS::ENGINE::nodeParser::init(), YACS::ENGINE::attrParser::init(), YACS::ENGINE::portParser::init(), YACS::ENGINE::valueParser::init(), YACS::ENGINE::arrayParser::init(), YACS::ENGINE::dataParser::init(), YACS::ENGINE::simpleTypeParser::init(), YACS::ENGINE::loopPortParser::init(), YACS::ENGINE::sampleParser::init(), YACS::inlinetypeParser< T >::inport(), YACS::servertypeParser< T >::instream(), YACS::servicetypeParser< T >::instream(), YACS::ENGINE::SalomePythonNode::load(), Yacs_i::Load(), YACS::ENGINE::CORBAComponent::load(), YACS::ENGINE::ProcCataLoader::loadCata(), YACS::ENGINE::PyFuncNode::loadLocal(), YACS::ENGINE::loadState(), main(), outputParser::onStart(), YACS::ENGINE::stateParser::onStart(), YACS::ENGINE::graphParser::onStart(), YACS::ENGINE::nodeParser::onStart(), YACS::ENGINE::portParser::onStart(), YACS::ENGINE::valueParser::onStart(), YACS::ENGINE::arrayParser::onStart(), YACS::ENGINE::dataParser::onStart(), YACS::ENGINE::loopPortParser::onStart(), YACS::ENGINE::sampleParser::onStart(), operator<<(), YACS::ENGINE::operator<<(), YACS::inlinetypeParser< T >::outport(), YACS::servertypeParser< T >::outstream(), YACS::servicetypeParser< T >::outstream(), YACS::outnodetypeParser< T >::parameter(), YACS::presettypeParser< T >::parameter(), Proc_i::Proc_i(), YACS::ENGINE::ProxyPort::ProxyPort(), YACS::ENGINE::OutputXmlPort::put(), YACS::ENGINE::OutputCorbaPort::put(), YACS::ENGINE::OutputCppPort::put(), YACS::ENGINE::ForEachLoopGen::releaseDelegateOf(), Yacs_i::Run(), YACS::switchtypeParser::select(), YACS::HMI::SceneLinkItem::setPath(), YACS::ENGINE::stateParser::setProc(), YACS::ENGINE::PythonNode::squeezeMemory(), YACS::ENGINE::PythonNode::squeezeMemoryRemote(), YACS::parser::start_element(), xmlParserBase::start_element(), YACS::ENGINE::stateLoader::stateLoader(), YACSPMMLBasicsTest1::testYACSdriver_LRANN(), YACSPMMLBasicsTest1::testYACSdriver_PmmlDoesNotExist(), YACSPMMLBasicsTest1::testYACSdriverLinearRegression(), YACSPMMLBasicsTest1::testYACSdriverNeuralNetwork(), and YACS::ENGINE::Bloc::writeDot().