From: Ovidiu Mircescu Date: Wed, 23 Jul 2014 09:37:14 +0000 (+0200) Subject: Merge branch 'omu/update_doc' of https://git.salome-platform.org/git/modules/yacs... X-Git-Tag: V7_5_0a1~7^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9b44198b5b5bf3794b63693a778382952a187475;hp=9ab365f9ab292d5efd7c70341a0e277c54d0554d;p=modules%2Fyacs.git Merge branch 'omu/update_doc' of https://git.salome-platform.org/git/modules/yacs into omu/update_doc --- diff --git a/adm/cmake/SalomeMacros.cmake b/adm/cmake/SalomeMacros.cmake index 8c85651f3..15d2ca90e 100755 --- a/adm/cmake/SalomeMacros.cmake +++ b/adm/cmake/SalomeMacros.cmake @@ -832,12 +832,18 @@ MACRO(SALOME_GENERATE_TESTS_ENVIRONMENT output) SET(_env "${_item}=$ENV{${_item}};${_env_${_item}}${sep}${_env}") ENDIF() ELSE() - SET(_env "${_item}=$ENV{${_item}}:${_env_${_item}}${sep}${_env}") + STRING(REPLACE ";" ":" _iii "$ENV{${_item}}") + SET(_env "${_item}=${_iii}:${_env_${_item}}${sep}${_env}") ENDIF() ENDFOREACH() # Get module name as substring of "Salome" - STRING(SUBSTRING "${PROJECT_NAME}" 6 -1 PRNAME) + STRING(REGEX MATCH "^Salome" _is_salome_project ${PROJECT_NAME}) + IF(_is_salome_project) + STRING(SUBSTRING "${PROJECT_NAME}" 6 -1 PRNAME) + ELSE() + SET(PRNAME ${PROJECT_NAME}) + ENDIF() SET(_env "${PRNAME}_ROOT_DIR=${CMAKE_INSTALL_PREFIX}${sep}${_env}") # Creating follow string for Windows environement: diff --git a/adm/cmake/SalomeSetupPlatform.cmake b/adm/cmake/SalomeSetupPlatform.cmake index 2a0ab0823..151323728 100755 --- a/adm/cmake/SalomeSetupPlatform.cmake +++ b/adm/cmake/SalomeSetupPlatform.cmake @@ -94,26 +94,42 @@ IF(WIN32) SET(PLATFORM_LIBS Ws2_32.lib) LIST(APPEND PLATFORM_LIBS Userenv.lib) # At least for GEOM suit - # Disable iterator debugging on WINDOWS to avoid runtime error during checking iterators - # _SECURE_SCL - # If defined as 1, unsafe iterator use causes a runtime error. - # If defined as 0, checked iterators are disabled. - # The default value for _SECURE_SCL is 1 - # _SECURE_SCL_THROWS - # If defined as 1, an out of range iterator use causes an exception at runtime. - # If defined as 0, the program is terminated by calling invalid_parameter. - # The default value for _SECURE_SCL_THROWS is 0 - - ADD_DEFINITIONS(-D_SECURE_SCL=0 -D_SECURE_SCL_THROWS=0) - - # The symbol _HAS_ITERATOR_DEBUGGING can be used to turn off the iterator debugging feature in a debug build - # If defined as 1, iterator debugging is enabled. - # If defined as 0, iterator debugging is disabled. - # The default value for _HAS_ITERATOR_DEBUGGING is 1 - - IF(NOT CMAKE_BUILD_TYPE STREQUAL "RELEASE" AND NOT CMAKE_BUILD_TYPE STREQUAL "Release") - ADD_DEFINITIONS(-D_HAS_ITERATOR_DEBUGGING=0) - ENDIF(NOT CMAKE_BUILD_TYPE STREQUAL "RELEASE" AND NOT CMAKE_BUILD_TYPE STREQUAL "Release") +################################################################################################ +# +# RNV: In the SALOME sometimes operating with STL collections is done in not fully valid way. +# To avoid run-time exception in Debug mode default values of the _SECURE_SCL, +# _SECURE_SCL_THROWS and _HAS_ITERATOR_DEBUGGING macros were redefined. It solved a problem +# then we used tne Microsoft Visual Studio 2008 to build SALOME on Windows platform. +# But in the Microsoft Visual Studio 2010 these macros affect on the size of STL collection +# classes(in difference from the Microsoft Visual Studio 2008: in this version of MSVS size +# of the STL collection classes does not depend on these macros). +# All pre-requisite products are built by MSVS 2010 in Debug mode with the default +# values of the metioned above macros (namely _SECURE_SCL=1, _HAS_ITERATOR_DEBUGGING=1 and +# _SECURE_SCL_THROWS=1). So SALOME modules should be build in the same configuration. +# +################################################################################################ +# +# # Disable iterator debugging on WINDOWS to avoid runtime error during checking iterators +# # _SECURE_SCL +# # If defined as 1, unsafe iterator use causes a runtime error. +# # If defined as 0, checked iterators are disabled. +# # The default value for _SECURE_SCL is 1 +# # _SECURE_SCL_THROWS +# # If defined as 1, an out of range iterator use causes an exception at runtime. +# # If defined as 0, the program is terminated by calling invalid_parameter. +# # The default value for _SECURE_SCL_THROWS is 0 +# +# ADD_DEFINITIONS(-D_SECURE_SCL=0 -D_SECURE_SCL_THROWS=0) +# +# # The symbol _HAS_ITERATOR_DEBUGGING can be used to turn off the iterator debugging feature in a debug build +# # If defined as 1, iterator debugging is enabled. +# # If defined as 0, iterator debugging is disabled. +# # The default value for _HAS_ITERATOR_DEBUGGING is 1 +# +# IF(NOT CMAKE_BUILD_TYPE STREQUAL "RELEASE" AND NOT CMAKE_BUILD_TYPE STREQUAL "Release") +# ADD_DEFINITIONS(-D_HAS_ITERATOR_DEBUGGING=0) +# ENDIF(NOT CMAKE_BUILD_TYPE STREQUAL "RELEASE" AND NOT CMAKE_BUILD_TYPE STREQUAL "Release") +################################################################################################ IF(MACHINE_IS_64) SET(SIZE_OF_LONG 4) # set sizeof(long) to 4 byte diff --git a/doc/cppsalome.rst b/doc/cppsalome.rst index 91cca5922..f6c1bb9df 100644 --- a/doc/cppsalome.rst +++ b/doc/cppsalome.rst @@ -165,7 +165,7 @@ hello, goodbye and copyOrMove are given in the source file (HELLO.cxx):: } CMakeLists.txt --------- +-------------- Create and add library to the project:: # --- options --- diff --git a/doc/optimizer.rst b/doc/optimizer.rst index 9fda36957..9dd3dcf2f 100644 --- a/doc/optimizer.rst +++ b/doc/optimizer.rst @@ -7,6 +7,9 @@ The definition of the optimization algorithm is done by way of plugin. The plugin can be a C++ plugin implemented in a dynamic library (.so file) or a Python plugin implemented in a Python module (.py). It is possible to implement two kinds of algorithm : synchronous or asynchronous. +The algorithm uses a pool of samples to be evaluated. +When all the samples of the pool are evaluated, the algorithm stops. + Synchronous algorithm -------------------------------------------------- In synchronous mode, the OptimizerLoop calls the algorithm to know what are the types of the input port (sample sent to the internal node), @@ -19,10 +22,13 @@ must be implemented and some optional methods (in C++ and in Python): - **getTCForIn**, this method must return the YACS type of the input port of the internal node - **getTCForOut**, this method must return the YACS type of the output port of the internal node +- **getTCForAlgoInit** (optional), this method returns the type of the "algoInit" port, string if undefined +- **getTCForAlgoResult** (optional), this method returns the type of the "algoResult" port, string if undefined - **initialize** (optional), this method is called during the algorithm initialization - **start**, this method is called at the beginning of iterations - **takeDecision**, this method is called at each iteration - **finish** (optional), this method is called to finish the algorithm at the end of the iteration process +- **getAlgoResult** (optional), this method returns the value of the "algoResult" port, "NULL" if undefined In Python you need to implement another method: @@ -32,191 +38,17 @@ C++ plugin example '''''''''''''''''''' Here is a small example of a C++ synchronous algorithm: -.. code-block:: cpp - - #include - - #include "OptimizerAlg.hxx" - - using namespace YACS::ENGINE; - - extern "C" - { - OptimizerAlgBase * createOptimizerAlgSyncExample(Pool * pool); - } - - class OptimizerAlgSyncExample : public OptimizerAlgSync - { - private: - int _idTest; - TypeCode *_tcIn; - TypeCode *_tcOut; - public: - OptimizerAlgSyncExample(Pool *pool); - virtual ~OptimizerAlgSyncExample(); - TypeCode *getTCForIn() const; - TypeCode *getTCForOut() const; - void start(); - void takeDecision(); - void initialize(const Any *input) throw(YACS::Exception); - void finish(); - }; - - OptimizerAlgSyncExample::OptimizerAlgSyncExample(Pool *pool) - : OptimizerAlgSync(pool), _tcIn(0), _tcOut(0), _idTest(0) - { - _tcIn=new TypeCode(Double); - _tcOut=new TypeCode(Int); - } - - OptimizerAlgSyncExample::~OptimizerAlgSyncExample() - { - _tcIn->decrRef(); - _tcOut->decrRef(); - } - - //! Return the typecode of the expected input type - TypeCode * OptimizerAlgSyncExample::getTCForIn() const - { - return _tcIn; - } - - //! Return the typecode of the expected output type - TypeCode * OptimizerAlgSyncExample::getTCForOut() const - { - return _tcOut; - } - - //! Start to fill the pool with samples to evaluate - void OptimizerAlgSyncExample::start() - { - _idTest=0; - Any *val=AtomAny::New(1.2); - _pool->pushInSample(4,val); - val=AtomAny::New(3.4); - _pool->pushInSample(9,val); - } - - //! This method is called each time a sample has been evaluated. - /*! - * It can either add new samples to evaluate in the pool, do nothing (wait - * for more samples), or empty the pool to finish the evaluation. - */ - void OptimizerAlgSyncExample::takeDecision() - { - if(_idTest==1) - { - Any *val=AtomAny::New(5.6); - _pool->pushInSample(16,val); - val=AtomAny::New(7.8); - _pool->pushInSample(25,val); - val=AtomAny::New(9. ); - _pool->pushInSample(36,val); - val=AtomAny::New(12.3); - _pool->pushInSample(49,val); - } - else if(_idTest==4) - { - Any *val=AtomAny::New(45.6); - _pool->pushInSample(64,val); - val=AtomAny::New(78.9); - _pool->pushInSample(81,val); - } - else - { - Any *tmp= _pool->getCurrentInSample(); - if(fabs(tmp->getDoubleValue()-45.6)<1.e-12) - _pool->destroyAll(); - } - _idTest++; - } - - //! Optional method to initialize the algorithm. - /*! - * For now, the parameter input is always NULL. It might be used in the - * future to initialize an algorithm with custom data. - */ - void OptimizerAlgSyncExample::initialize(const Any *input) - throw (YACS::Exception) - { - } - - /*! - * Optional method called when the algorithm has finished, successfully or - * not, to perform any necessary clean up. - */ - void OptimizerAlgSyncExample::finish() - { - } - - //! Factory method to create the algorithm. - OptimizerAlgBase * createOptimizerAlgSyncExample(Pool *pool) - { - return new OptimizerAlgSyncExample(pool); - } - +.. literalinclude:: ../src/yacsloader/Test/OptimizerAlgSyncExample.cxx + :language: cpp Here, the entry point in the dynamic library is the name of the factory function : createOptimizerAlgSyncExample that returns an instance of the OptimizerAlgSyncExample class that implements the algorithm. Python plugin example '''''''''''''''''''''' -Here, the same example of a synchronous algorithm in Python:: - - import SALOMERuntime - - class myalgosync(SALOMERuntime.OptimizerAlgSync): - def __init__(self): - SALOMERuntime.OptimizerAlgSync.__init__(self, None) - r=SALOMERuntime.getSALOMERuntime() - self.tin=r.getTypeCode("double") - self.tout=r.getTypeCode("int") - - def setPool(self,pool): - """Must be implemented to set the pool""" - self.pool=pool - - def getTCForIn(self): - """returns typecode of type expected as Input""" - return self.tin - - def getTCForOut(self): - """returns typecode of type expected as Output""" - return self.tout - - def initialize(self,input): - """Optional method called on initialization. Do nothing here""" - - def start(self): - """Start to fill the pool with samples to evaluate.""" - self.iter=0 - self.pool.pushInSample(4,1.2) - self.pool.pushInSample(9,3.4) - - def takeDecision(self): - """ This method is called each time a sample has been evaluated. It can - either add new samples to evaluate in the pool, do nothing (wait for - more samples), or empty the pool to finish the evaluation. - """ - currentId=self.pool.getCurrentId() - - if self.iter==1: - self.pool.pushInSample(16,5.6) - self.pool.pushInSample(25,7.8) - self.pool.pushInSample(36,9.) - self.pool.pushInSample(49,12.3) - elif self.iter==4: - self.pool.pushInSample(64,45.6) - self.pool.pushInSample(81,78.9) - else: - val=self.pool.getCurrentInSample() - if abs(val.getDoubleValue()-45.6) < 1.e-12: - self.pool.destroyAll() - self.iter=self.iter+1 - - def finish(self): - """Optional method called when the algorithm has finished, successfully - or not, to perform any necessary clean up. Do nothing here""" +Here, the same example of a synchronous algorithm in Python: + +.. literalinclude:: ../src/yacsloader/Test/algosyncexample.py Here, the entry point in the Python module is directly the name of the class that implements the algorithm : myalgosync. @@ -231,9 +63,12 @@ must be implemented and some optional methods (in C++ and in Python): - **getTCForIn**, this method must return the YACS type of the input port of the internal node - **getTCForOut**, this method must return the YACS type of the output port of the internal node +- **getTCForAlgoInit** (optional), this method returns the type of the "algoInit" port, string if undefined +- **getTCForAlgoResult** (optional), this method returns the type of the "algoResult" port, string if undefined - **initialize** (optional), this method is called during the algorithm initialization - **startToTakeDecision**, this method is called to start the iteration process in a separate thread. It is the body of the algorithm. - **finish** (optional), this method is called to finish the algorithm at the end of the iteration process +- **getAlgoResult** (optional), this method returns the value of the "algoResult" port, "NULL" if undefined In Python you need to implement another method: @@ -243,94 +78,8 @@ C++ plugin example '''''''''''''''''''' Here is a small example of a C++ asynchronous algorithm: -.. code-block:: cpp - - #include "OptimizerAlg.hxx" - - using namespace YACS::ENGINE; - - extern "C" - { - OptimizerAlgBase * createOptimizerAlgASyncExample(Pool * pool); - } - - class OptimizerAlgASyncExample : public OptimizerAlgASync - { - private: - TypeCode * _tcIn; - TypeCode * _tcOut; - public: - OptimizerAlgASyncExample(Pool * pool); - virtual ~OptimizerAlgASyncExample(); - TypeCode * getTCForIn() const; - TypeCode * getTCForOut() const; - void startToTakeDecision(); - }; - - OptimizerAlgASyncExample::OptimizerAlgASyncExample(Pool * pool) - : OptimizerAlgASync(pool), _tcIn(0), _tcOut(0) - { - _tcIn = new TypeCode(Double); - _tcOut = new TypeCode(Int); - } - - OptimizerAlgASyncExample::~OptimizerAlgASyncExample() - { - _tcIn->decrRef(); - _tcOut->decrRef(); - } - - //! Return the typecode of the expected input type - TypeCode *OptimizerAlgASyncExample::getTCForIn() const - { - return _tcIn; - } - - //! Return the typecode of the expected output type - TypeCode *OptimizerAlgASyncExample::getTCForOut() const - { - return _tcOut; - } - - //! This method is called only once to launch the algorithm. - /*! - * It must first fill the pool with samples to evaluate and call - * signalMasterAndWait() to block until a sample has been evaluated. When - * returning from this method, it MUST check for an eventual termination - * request (with the method isTerminationRequested()). If the termination - * is requested, the method must perform any necessary cleanup and return - * as soon as possible. Otherwise it can either add new samples to evaluate - * in the pool, do nothing (wait for more samples), or empty the pool and - * return to finish the evaluation. - */ - void OptimizerAlgASyncExample::startToTakeDecision() - { - double val = 1.2; - for (int i=0 ; i<5 ; i++) { - // push a sample in the input of the slave node - _pool->pushInSample(i, AtomAny::New(val)); - // wait until next sample is ready - signalMasterAndWait(); - // check error notification - if (isTerminationRequested()) { - _pool->destroyAll(); - return; - } - - // get a sample from the output of the slave node - Any * v = _pool->getCurrentOutSample(); - val += v->getIntValue(); - } - - // in the end destroy the pool content - _pool->destroyAll(); - } - - //! Factory method to create the algorithm. - OptimizerAlgBase * createOptimizerAlgASyncExample(Pool * pool) - { - return new OptimizerAlgASyncExample(pool); - } +.. literalinclude:: ../src/yacsloader/Test/OptimizerAlgASyncExample.cxx + :language: cpp Here, the entry point in the dynamic library is the name of the factory function : createOptimizerAlgASyncExample @@ -338,62 +87,59 @@ that returns an instance of the OptimizerAlgASyncExample class that implements t Python plugin example '''''''''''''''''''''''' -Here is an example of an asynchronous algorithm implemented in Python:: - - import SALOMERuntime - - class myalgoasync(SALOMERuntime.OptimizerAlgASync): - def __init__(self): - SALOMERuntime.OptimizerAlgASync.__init__(self, None) - r=SALOMERuntime.getSALOMERuntime() - self.tin=r.getTypeCode("double") - self.tout=r.getTypeCode("int") - - def setPool(self,pool): - """Must be implemented to set the pool""" - self.pool=pool - - def getTCForIn(self): - """returns typecode of type expected as Input""" - return self.tin - - def getTCForOut(self): - """returns typecode of type expected as Output""" - return self.tout - - def startToTakeDecision(self): - """This method is called only once to launch the algorithm. It must - first fill the pool with samples to evaluate and call - self.signalMasterAndWait() to block until a sample has been - evaluated. When returning from this method, it MUST check for an - eventual termination request (with the method - self.isTerminationRequested()). If the termination is requested, the - method must perform any necessary cleanup and return as soon as - possible. Otherwise it can either add new samples to evaluate in the - pool, do nothing (wait for more samples), or empty the pool and - return to finish the evaluation. - """ - val=1.2 - for iter in xrange(5): - #push a sample in the input of the slave node - self.pool.pushInSample(iter,val) - #wait until next sample is ready - self.signalMasterAndWait() - #check error notification - if self.isTerminationRequested(): - self.pool.destroyAll() - return - - #get a sample from the output of the slave node - currentId=self.pool.getCurrentId() - v=self.pool.getCurrentOutSample() - val=val+v.getIntValue() - - #in the end destroy the pool content - self.pool.destroyAll() +Here is an example of an asynchronous algorithm implemented in Python: + +.. literalinclude:: ../src/yacsloader/Test/algoasyncexample.py Here, the entry point in the Python module is directly the name of the class that implements the algorithm : myalgoasync. +Managing the pool of samples +--------------------------------- + +Samples can be added to the pool at the initialization of the algorithm or +every time a sample is evaluated (while "taking decision"). +The algorithm stops to take decisions when every sample is evaluated. + +A sample has: + +- an identifier - *Id* +- a priority - it is used to choose the order of evaluation +- a value - *In* +- an evaluated or computed value - *Out* + +The current sample is the sample used by the latest terminated evaluation. + +These are the methods needed to manage the pool of samples: + +.. code-block:: cpp + + class Pool + { + //... + public: + //For algorithm use + int getCurrentId() const ; + Any *getCurrentInSample() const ; + Any *getCurrentOutSample() const ; + Any *getOutSample(int id); + void pushInSample(int id, Any *inSample, unsigned char priority = 0); + void destroyAll(); + //... + } + +In C++, the samples are of type ``YACS::ENGINE::Any``, in order to support any +type supported by YACS. For conversion to standard types, use: + +- ``getIntValue`` +- ``getBoolValue`` +- ``getDoubleValue`` +- ``getStringValue`` + +It is possible to create a pointer to a new object with: + +- ``YACS::ENGINE::AtomAny::New`` + +For further information, see `include/salome/Any.hxx `_. C++ algorithm calling Python code -------------------------------------------------- diff --git a/doc/schemapy.rst b/doc/schemapy.rst index 19b6df984..c4d4598ea 100644 --- a/doc/schemapy.rst +++ b/doc/schemapy.rst @@ -346,22 +346,21 @@ Node n3 will be executed before node n4. Dataflow link ++++++++++++++++++++++++++++ -The first step in defining a dataflow link is to obtain port objects using one of the methods described above. -The edAddDFLink method for the context node is then used, transferring the two ports to be connected to it. -The following gives an example of a dataflow link between the output port p1 of node n3 and the input port of node n4:: +The first step in defining a dataflow link is to obtain port objects using one of the methods described above. +Then, the edAddLink method links an output port to an input port:: pout=n3.getOutputPort("p1") pin=n4.getInputPort("p1") - p.edAddDFLink(pout,pin) + p.edAddLink(pout,pin) -Data link -++++++++++++++++++++++++++++ -A data link is defined as being a dataflow link using the edAddLink method instead of edAddDFLink. -The same example as above with a data link:: +Most of the time, when you need a dataflow link between two ports, you also need a control link between the nodes +of the ports. In this case you can use the method edAddDFLink:: pout=n3.getOutputPort("p1") pin=n4.getInputPort("p1") - p.edAddLink(pout,pin) + p.edAddDFLink(pout,pin) + +edAddDFLink is equivalent to edAddCFLink followed by edAddLink. Initialising an input data port ''''''''''''''''''''''''''''''''''''''''''''''' @@ -397,6 +396,7 @@ will appear as follows:: r = pilot.getRuntime() p=r.createProc("pr") ti=p.getTypeCode("int") + td=p.getTypeCode("double") #node1 n1=r.createScriptNode("","node1") p.edAddChild(n1) @@ -420,11 +420,8 @@ will appear as follows:: p.edAddCFLink(n1,n2) p.edAddCFLink(n1,n4) #dataflow links - pout=n3.getOutputPort("p1") - pin=n4.getInputPort("p1") - #dataflow links - p.edAddDFLink(n1.getOutputPort("p1"),n2.getInputPort("p1")) - p.edAddDFLink(n1.getOutputPort("p1"),n4.getInputPort("p1")) + p.edAddLink(n1.getOutputPort("p1"),n2.getInputPort("p1")) + p.edAddLink(n1.getOutputPort("p1"),n4.getInputPort("p1")) #initialisation ports n1.getInputPort("p1").edInitPy(5) @@ -454,7 +451,6 @@ Repeating a part of the example above, we will get:: n2.setScript("p1=2*p1") n2.edAddInputPort("p1",ti) n2.edAddOutputPort("p1",ti) - b.edAddCFLink(n1,n2) b.edAddDFLink(n1.getOutputPort("p1"),n2.getInputPort("p1")) .. _py_forloop: diff --git a/src/engine/Node.cxx b/src/engine/Node.cxx index 63b65d90c..b8c40da7f 100644 --- a/src/engine/Node.cxx +++ b/src/engine/Node.cxx @@ -88,6 +88,7 @@ Node::Node(const Node& other, ComposedNode *father):_inGate(this),_outGate(this) Node::~Node() { + delete _inPropertyPort; } /** diff --git a/src/engine/Pool.hxx b/src/engine/Pool.hxx index 3fd53c97c..efd293777 100644 --- a/src/engine/Pool.hxx +++ b/src/engine/Pool.hxx @@ -32,6 +32,12 @@ namespace YACS class Any; class OptimizerLoop; + /*! \brief Pool used to manage the samples of the optimizer loop plugin. + * + * Every sample has an identifier (Id), a priority, an initial value (In) + * and an evaluation value (Out). + * The current sample is the sample used by the latest terminated evaluation. + */ class YACSLIBENGINE_EXPORT Pool { friend class OptimizerLoop; diff --git a/src/engine/Proc.cxx b/src/engine/Proc.cxx index 101f7aafe..46185cc7f 100644 --- a/src/engine/Proc.cxx +++ b/src/engine/Proc.cxx @@ -487,7 +487,7 @@ Container* Proc::createContainer(const std::string& name,const std::string& kind * * \param inst: the component instance * \param name: the component instance name - * \param restCtr: try to reuse instance number previously released, false by default + * \param resetCtr: try to reuse instance number previously released, false by default */ void Proc::addComponentInstance(ComponentInstance* inst, const std::string& name, bool resetCtr) { diff --git a/src/genericgui/EditionForEachLoop.cxx b/src/genericgui/EditionForEachLoop.cxx index 9981fd54f..6df5f6233 100644 --- a/src/genericgui/EditionForEachLoop.cxx +++ b/src/genericgui/EditionForEachLoop.cxx @@ -46,6 +46,8 @@ EditionForEachLoop::EditionForEachLoop(Subject* subject, _wid->gridLayout1->addWidget(_formEachLoop); _formEachLoop->sb_nbranch->setMinimum(1); _formEachLoop->sb_nbranch->setMaximum(INT_MAX); + if (!QtGuiContext::getQtCurrent()->isEdition()) + _formEachLoop->setEnabled (false); Node* node=_subjectNode->getNode(); ForEachLoop *fe = dynamic_cast(node); if(fe) diff --git a/src/genericgui/EditionLoop.cxx b/src/genericgui/EditionLoop.cxx index bf3f5e742..4458308fe 100644 --- a/src/genericgui/EditionLoop.cxx +++ b/src/genericgui/EditionLoop.cxx @@ -55,6 +55,9 @@ EditionLoop::EditionLoop(Subject* subject, _formLoop->sb_nsteps->setMinimum(0); _formLoop->sb_nsteps->setMaximum(INT_MAX); + if (!QtGuiContext::getQtCurrent()->isEdition()) + _formLoop->setEnabled (false); + connect(_formLoop->sb_nsteps, SIGNAL(editingFinished()), this, SLOT(onNbStepsEdited())); } diff --git a/src/genericgui/EditionPyFunc.cxx b/src/genericgui/EditionPyFunc.cxx index df69cf0c9..748f2047e 100644 --- a/src/genericgui/EditionPyFunc.cxx +++ b/src/genericgui/EditionPyFunc.cxx @@ -75,6 +75,12 @@ EditionPyFunc::EditionPyFunc(Subject* subject, _glayout->addLayout( glt , 1); _glayout->addWidget( _sci ); + if (!QtGuiContext::getQtCurrent()->isEdition()) + { + gener_template->setEnabled (false); + _liFuncName->setEnabled (false); + } + connect(_liFuncName, SIGNAL(textChanged(const QString&)), this, SLOT(onFuncNameModified(const QString&))); diff --git a/src/genericgui/EditionSwitch.cxx b/src/genericgui/EditionSwitch.cxx index 99862b739..37feb71d6 100644 --- a/src/genericgui/EditionSwitch.cxx +++ b/src/genericgui/EditionSwitch.cxx @@ -52,6 +52,8 @@ EditionSwitch::EditionSwitch(Subject* subject, _valueDelegate = new ValueDelegate(parent); _tvSwitch->tv_nodes->setItemDelegateForColumn(YValue, _valueDelegate); _tvSwitch->setEditableCase(true); + if (!QtGuiContext::getQtCurrent()->isEdition()) + _tvSwitch->setEnabled (false); connect(_valueDelegate, SIGNAL(commitData(QWidget*)), this, SLOT(onCommitData(QWidget*))); diff --git a/src/genericgui/EditionWhile.cxx b/src/genericgui/EditionWhile.cxx index 50ade528b..1d7df1e43 100644 --- a/src/genericgui/EditionWhile.cxx +++ b/src/genericgui/EditionWhile.cxx @@ -20,6 +20,7 @@ #include "EditionWhile.hxx" #include "FormLoop.hxx" #include "guiObservers.hxx" +#include "QtGuiContext.hxx" //#define _DEVDEBUG_ #include "YacsTrace.hxx" @@ -43,6 +44,8 @@ EditionWhile::EditionWhile(Subject* subject, _formWhile->sb_nsteps->setMinimum(0); _formWhile->sb_nsteps->setMaximum(1); _formWhile->label->setText("Condition"); + if (!QtGuiContext::getQtCurrent()->isEdition()) + _formWhile->setEnabled (false); connect(_formWhile->sb_nsteps, SIGNAL(editingFinished()), this, SLOT(onConditionEdited())); } diff --git a/src/genericgui/GenericGui.cxx b/src/genericgui/GenericGui.cxx index 332cc483f..5094c4b68 100644 --- a/src/genericgui/GenericGui.cxx +++ b/src/genericgui/GenericGui.cxx @@ -240,8 +240,8 @@ void GenericGui::createActions() tr("Load Schema to run"), tr("Load a schema for run"), 0, _parent, false, this, SLOT(onLoadAndRunSchema())); - _chooseBatchJobAct = _wrapper->createAction(getMenuId(), tr("Choose Batch Job for watch"), QIcon("icons:batch.png"), - tr("Choose Batch Job for watch"), tr("Choose Batch Job for watch"), + _chooseBatchJobAct = _wrapper->createAction(getMenuId(), tr("Choose Batch Job to watch"), QIcon("icons:batch.png"), + tr("Choose Batch Job to watch"), tr("Choose Batch Job to watch"), 0, _parent, false, this, SLOT(onChooseBatchJob())); _startResumeAct = _wrapper->createAction(getMenuId(), tr("Start or Resume Schema execution"), QIcon("icons:suspend_resume.png"), @@ -1231,13 +1231,24 @@ void GenericGui::setLoadedPresentation(YACS::ENGINE::Proc* proc) inode->setWidth(pres._width); inode->setHeight(pres._height); inode->setExpanded(pres._expanded); - inode->setExpandedPos(QPointF(pres._expx, pres._expy)); + QPointF anExpandedPos = QPointF(pres._expx, pres._expy); + if (anExpandedPos.isNull()) + anExpandedPos = inode->pos(); + inode->setExpandedPos(anExpandedPos); inode->setExpandedWH(pres._expWidth, pres._expHeight); inode->setShownState(shownState(pres._shownState)); // collect nodes to correct it's Y-position if this collides with parent's header - if (inode->getParent() && inode->y() < inode->getParent()->getHeaderBottom()) - nodesToMove[inode] = QPointF(inode->x(), inode->getParent()->getHeaderBottom()+1); + if (inode->getParent() ) { + qreal anX = inode->x(); + qreal anY = inode->y(); + if (inode->getShownState() == shrinkHidden) { + anX = inode->getExpandedX(); + anY = inode->getExpandedY(); + } + if (anY < inode->getParent()->getHeaderBottom()) + nodesToMove[inode] = QPointF(anX, inode->getParent()->getHeaderBottom()+1); + } } } QtGuiContext::getQtCurrent()->setLoadingPresentation(false); @@ -1291,7 +1302,7 @@ void GenericGui::loadSchema(const std::string& filename,bool edit, bool arrangeL { DEBTRACE(logger->getStr()); } - QString fn=QString::fromStdString(filename); + QString fn=QString::fromUtf8(filename.c_str()); if(edit) createContext(proc, fn, "", true); else @@ -1331,11 +1342,11 @@ void GenericGui::onImportSchema() if (!fi.exists() && fi.suffix() != "xml") fn += ".xml"; - DEBTRACE("file loaded : " <load(fn.toLatin1()); + proc = _loader->load(fn.toUtf8().constData()); } catch (...) { } @@ -1529,12 +1540,12 @@ void GenericGui::onExportSchema() } if (fn.isEmpty()) return; - DEBTRACE("GenericGui::onExportSchema: " << fn.toStdString()); + DEBTRACE("GenericGui::onExportSchema: " << fn.toUtf8().constData()); //to be sure that all pending changes are effective _parent->setFocus(); QtGuiContext::getQtCurrent()->setFileName(fn); VisitorSaveGuiSchema aWriter(proc); - aWriter.openFileSchema( fn.toStdString() ); + aWriter.openFileSchema( fn.toUtf8().constData() ); aWriter.visitProc(); aWriter.closeFileSchema(); QtGuiContext::getQtCurrent()->setNotSaved(false); @@ -1555,10 +1566,10 @@ void GenericGui::onExportSchemaAs() QString fn = getSaveFileName(fo); if (fn.isEmpty()) return; - DEBTRACE("GenericGui::onExportSchemaAs: " << fn.toStdString()); + DEBTRACE("GenericGui::onExportSchemaAs: " << fn.toUtf8().constData()); QtGuiContext::getQtCurrent()->setFileName(fn); VisitorSaveGuiSchema aWriter(proc); - aWriter.openFileSchema(fn.toStdString()); + aWriter.openFileSchema(fn.toUtf8().constData()); aWriter.visitProc(); aWriter.closeFileSchema(); _isSaved = true; diff --git a/src/genericgui/SceneNodeItem.cxx b/src/genericgui/SceneNodeItem.cxx index 055a01643..fdff648d0 100644 --- a/src/genericgui/SceneNodeItem.cxx +++ b/src/genericgui/SceneNodeItem.cxx @@ -315,6 +315,10 @@ void SceneNodeItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) void SceneNodeItem::setTopLeft(QPointF topLeft) { + if (_shownState == shrinkHidden) { + _expandedPos = topLeft; + return; + } QPointF oldPos = pos(); setPos(topLeft); diff --git a/src/genericgui/SceneProcItem.cxx b/src/genericgui/SceneProcItem.cxx index 4bfa58f56..14ec4befe 100644 --- a/src/genericgui/SceneProcItem.cxx +++ b/src/genericgui/SceneProcItem.cxx @@ -87,5 +87,6 @@ void SceneProcItem::reorganizeShrinkExpand() { _height = _expandedHeight; _shownState = expandShown; adjustHeader(); + rebuildLinks(); } diff --git a/src/pmml/CMakeLists.txt b/src/pmml/CMakeLists.txt index 9c989a45c..a6709da84 100755 --- a/src/pmml/CMakeLists.txt +++ b/src/pmml/CMakeLists.txt @@ -43,15 +43,6 @@ IF(URANIE AND WIN32) ENABLE_TESTING() ENDIF(URANIE AND WIN32) -IF(SALOME_BUILD_DOC) - FIND_PACKAGE(SalomeDoxygen) - FIND_PACKAGE(SalomeGraphviz) - FIND_PACKAGE(SalomeSphinx) - SALOME_LOG_OPTIONAL_PACKAGE(Doxygen SALOME_BUILD_DOC) - SALOME_LOG_OPTIONAL_PACKAGE(Graphviz SALOME_BUILD_DOC) - SALOME_LOG_OPTIONAL_PACKAGE(Sphinx SALOME_BUILD_DOC) -ENDIF(SALOME_BUILD_DOC) - IF(SALOME_YACS_USE_SWIG) FIND_PACKAGE(SalomePython) FIND_PACKAGE(SalomeSWIG) diff --git a/src/pmml/doc/doxygen/Doxyfile_pmml_user.in b/src/pmml/doc/doxygen/Doxyfile_pmml_user.in index c021edd79..1a1a8d880 100755 --- a/src/pmml/doc/doxygen/Doxyfile_pmml_user.in +++ b/src/pmml/doc/doxygen/Doxyfile_pmml_user.in @@ -70,21 +70,21 @@ WARN_LOGFILE = log_user # configuration options related to the input files #--------------------------------------------------------------------------- -INPUT = @srcdir@/doxfiles/intro.dox \ - @srcdir@/doxfiles/cppexamples.dox \ - @srcdir@/doxfiles/pyexamples.dox \ - @srcdir@/doxfiles/pmml.dox \ - @srcdir@/doxfiles/install.dox \ - @srcdir@/../../src/PMML +INPUT = @CMAKE_CURRENT_SOURCE_DIR@/doxfiles/intro.dox \ + @CMAKE_CURRENT_SOURCE_DIR@/doxfiles/cppexamples.dox \ + @CMAKE_CURRENT_SOURCE_DIR@/doxfiles/pyexamples.dox \ + @CMAKE_CURRENT_SOURCE_DIR@/doxfiles/pmml.dox \ + @CMAKE_CURRENT_SOURCE_DIR@/doxfiles/install.dox \ + @CMAKE_SOURCE_DIR@/src/pmml FILE_PATTERNS = PMMLlib.* \ *.dox RECURSIVE = YES EXCLUDE = CVS EXCLUDE_PATTERNS = *~ -EXAMPLE_PATH = @srcdir@/../../src/PMML \ - @srcdir@/../../src/PMML/Test \ - @srcdir@/../../src/PMML_Swig +EXAMPLE_PATH = @CMAKE_SOURCE_DIR@/src/pmml \ + @CMAKE_SOURCE_DIR@/src/pmml/Test \ + @CMAKE_SOURCE_DIR@/src/pmml/pmml_Swig EXAMPLE_PATTERNS = *.cxx *.py EXAMPLE_RECURSIVE = NO @@ -109,9 +109,9 @@ IGNORE_PREFIX = #--------------------------------------------------------------------------- GENERATE_HTML = YES HTML_OUTPUT = html -HTML_HEADER = @builddir@/static/header.html -HTML_FOOTER = @srcdir@/static/footer.html -HTML_EXTRA_STYLESHEET = @srcdir@/static/salome_extra.css +HTML_HEADER = @CMAKE_CURRENT_BINARY_DIR@/static/header.html +HTML_FOOTER = @CMAKE_CURRENT_SOURCE_DIR@/static/footer.html +HTML_EXTRA_STYLESHEET = @CMAKE_CURRENT_SOURCE_DIR@/static/salome_extra.css GENERATE_HTMLHELP = NO GENERATE_CHI = YES BINARY_TOC = NO diff --git a/src/runtime/RuntimeSALOME.cxx b/src/runtime/RuntimeSALOME.cxx index 9a56086d7..da74e14ca 100644 --- a/src/runtime/RuntimeSALOME.cxx +++ b/src/runtime/RuntimeSALOME.cxx @@ -122,11 +122,11 @@ using namespace std; using namespace YACS::ENGINE; -void RuntimeSALOME::setRuntime(long flags) // singleton creation (not thread safe!) +void RuntimeSALOME::setRuntime(long flags, int argc, char* argv[]) // singleton creation (not thread safe!) { if (! Runtime::_singleton) { - RuntimeSALOME* r=new RuntimeSALOME(flags); + RuntimeSALOME* r=new RuntimeSALOME(flags, argc, argv); Runtime::_singleton = r; r->initBuiltins(); } @@ -182,7 +182,7 @@ void RuntimeSALOME::initBuiltins() typeMap["dataref"]= t; } -RuntimeSALOME::RuntimeSALOME(long flags) +RuntimeSALOME::RuntimeSALOME(long flags, int argc, char* argv[]) { // If all flags (apart the IsPyExt flags) are unset, force them to true if ((flags - flags & RuntimeSALOME::IsPyExt) == 0) @@ -209,7 +209,7 @@ RuntimeSALOME::RuntimeSALOME(long flags) if (_usePython) _setOfImplementation.insert(PythonNode::IMPL_NAME); if (_useCorba) _setOfImplementation.insert(CORBANode::IMPL_NAME); if (_useXml) _setOfImplementation.insert(XmlNode::IMPL_NAME); - init(flags); + init(flags, argc, argv); } RuntimeSALOME::~RuntimeSALOME() @@ -233,10 +233,12 @@ RuntimeSALOME::~RuntimeSALOME() * bit1 (UseXml) true if python nodes are needed * bit1 (UseCpp) true if C++ nodes are needed * bit1 (UseSalome) true if Salome nodes are needed + * \param argc number of command line arguments (used to initialize the Python interpreter) + * \param argv command line arguments (used to initialize the Python interpreter) * */ -void RuntimeSALOME::init(long flags) +void RuntimeSALOME::init(long flags, int argc, char* argv[]) { bool ispyext = flags & RuntimeSALOME::IsPyExt; if (_useCorba) @@ -270,6 +272,16 @@ void RuntimeSALOME::init(long flags) #else Py_InitializeEx(0); // do not install signal handlers #endif + if (argc > 0 && argv != NULL) + PySys_SetArgv(argc, argv); + else + { + int pyArgc = 1; + char* pyArgv[1]; + char defaultName[] = "SALOME_YACS_RUNTIME"; + pyArgv[0] = defaultName; + PySys_SetArgv(pyArgc, pyArgv); + } PyEval_InitThreads(); /* Create (and acquire) the interpreter lock (for threads)*/ PyEval_SaveThread(); /* Release the thread state */ //here we do not have the Global Interpreter Lock diff --git a/src/runtime/RuntimeSALOME.hxx b/src/runtime/RuntimeSALOME.hxx index 9a3a9dd76..20f5d63c0 100644 --- a/src/runtime/RuntimeSALOME.hxx +++ b/src/runtime/RuntimeSALOME.hxx @@ -86,13 +86,15 @@ namespace YACS UseSalome = 32 } FLAGS; - static void setRuntime(long flags = UsePython+UseCorba+UseXml+UseCpp+UseSalome); // singleton creation + // singleton creation + static void setRuntime(long flags = UsePython+UseCorba+UseXml+UseCpp+UseSalome, + int argc = 0, char* argv[] = NULL); friend RuntimeSALOME* getSALOMERuntime(); virtual std::string getVersion() const; - virtual void init(long flags); + virtual void init(long flags, int argc, char* argv[]); virtual void fini(); virtual InputPort* createInputPort(const std::string& name, @@ -250,7 +252,7 @@ namespace YACS protected: RuntimeSALOME(); // singleton - RuntimeSALOME(long flags); // singleton + RuntimeSALOME(long flags, int argc, char* argv[]); // singleton void initBuiltins(); CORBA::ORB_var _orb; PyObject * _pyorb; diff --git a/src/runtime/Test/TestComponent.cxx b/src/runtime/Test/TestComponent.cxx index 4e5ef9ac3..1517d4be7 100644 --- a/src/runtime/Test/TestComponent.cxx +++ b/src/runtime/Test/TestComponent.cxx @@ -58,11 +58,13 @@ extern "C" void __run(void *vObj, const char *service, int nIn, int nOut, obj->info.message = ""; obj->info.code = 0; + Out[0] = NULL; if (std::strncmp(service, "f", 1) == 0) { double _arg0 = In[0]->getDoubleValue(); double _res = obj->f(_arg0); - Out[0] = YACS::ENGINE::AtomAny::New(_res); + if (obj->info.code == 0) + Out[0] = YACS::ENGINE::AtomAny::New(_res); } else { @@ -70,7 +72,6 @@ extern "C" void __run(void *vObj, const char *service, int nIn, int nOut, obj->info.message = "service "; obj->info.message += service; obj->info.message += " doesn't exist in TestComponent"; - Out[0] = NULL; } *r = obj->info; } diff --git a/src/salomegui/resources/YACS_msg_fr.ts b/src/salomegui/resources/YACS_msg_fr.ts index c25ad03d2..acc337c8a 100644 --- a/src/salomegui/resources/YACS_msg_fr.ts +++ b/src/salomegui/resources/YACS_msg_fr.ts @@ -4,7 +4,7 @@ @default - Choose Batch Job for watch + Choose Batch Job to watch Choisir le job batch à surveiller diff --git a/src/salomegui/resources/YACS_msg_ja.ts b/src/salomegui/resources/YACS_msg_ja.ts index 0c10d5718..f30cce995 100644 --- a/src/salomegui/resources/YACS_msg_ja.ts +++ b/src/salomegui/resources/YACS_msg_ja.ts @@ -1,11 +1,19 @@ - + - Yacsgui + @default + + Choose Batch Job to watch + バッチジョブの監視を選択 + + + Select one Batch Job to watch + バッチジョブの監視を選択 + PREF_TAB_GENERAL - 一般的な + 一般 PREF_GROUP_COMPONENT @@ -13,15 +21,15 @@ PREF_TAB_STATE - ノードの状態 + ノード状態 PREF_GROUP_EDIT - 状態を編集します。 + 編集 PREF_GROUP_RUN - 実行状態 + 実行 PREF_TAB_NODE @@ -37,7 +45,7 @@ PREF_GROUP_NODE - ノード + 節点 PREF_GROUP_HEADER @@ -45,15 +53,15 @@ PREF_GROUP_CONTROL - 制御ポート + ポート制御 PREF_GROUP_PORT - データフロー ポート + ポートデータフロー PREF_GROUP_DRAG - ドラッグします。 + ドラッグ PREF_GROUP_GENERAL @@ -61,7 +69,63 @@ COMPONENT_INSTANCE_NEW - 新しい各サービス ノードのコンポーネントのインスタンスを作成します。 + 各新しいサービス ノードのコンポーネント インスタンスの作成 + + + Link colors + リンクの色 + + + Link draw color + リンクを作成する色 + + + Link select color + リンクを選択する色 + + + Stream link draw color + ストリーム リンクを作成する色 + + + Stream link select color + ストリーム リンクを選択する色 + + + Control link draw color + 制御リンクを作成する色 + + + Control link select color + 制御リンクを選択する色 + + + Emphasis link color + リンクを強調する色 + + + link pen darkness + 暗いペンリンク + + + Pen + ペン + + + Brush + 筆 + + + High pen + ペントップ + + + High brush + 筆トップ + + + On dragging + ドラッグ中 ERROR @@ -72,4 +136,732 @@ プラグイン + + YACS::HMI::ComposedNodeMenu + + Create Node + ノードを作成 + + + + YACS::HMI::GenericGui + + Create a new YACS Schema + 新しい YACS スキーマを作成 + + + New Schema + 新しいスキーマ + + + Import a YACS Schema for edition + 編集のためのYACSスキーマ読み込み + + + Import Schema + スキーマ読み込み + + + Import a SUPERV Schema for edition + 編集のためのSUPERV スキーマ読み込み + + + Import SUPERV Schema + SUPERV スキーマ読み込み + + + Save the current YACS Schema + 現在のYACSスキーマの保存 + + + Save Schema + スキーマの保存 + + + Save the current YACS Schema As... + 現在のYACSスキーマの保存... + + + Save Schema As + スキーマの保存... + + + Import a Schema as a Catalog + カタログとしてスキーマを読み込む + + + Import Catalog + カタログの読み込み + + + Prepare the current edited schema for run + 実行時に編集されているスキーマの準備 + + + Run Current Schema + 現在のスキーマの実行 + + + Load a previous run state for this schema, prepare to run + このスキーマの以前の実行状態を読み込み、実行するための準備 + + + Load Run State + 実行状態の読み込み + + + Load a schema for run + 起動するスキーマの読み込み + + + Load Schema to run + 実行するスキーマの読み込み + + + Load Batch Schema for edition + バッチ用のスキーマの読み込み + + + Load Batch Schema + バッチスキーマの読み込み + + + Start or Resume Schema execution + 開始または再開スキーマの実行 + + + Start/Resume execution + 実行の開始/再開 + + + Abort the current execution + 現在の実行を中止 + + + Abort execution + 実行の中止 + + + Suspend the current execution + 現在の実行を中断 + + + Suspend execution + 実行の中断 + + + Reset the current execution + 現在の実行をリセット + + + Reset execution + 実行のリセット + + + Save the current run state + 現在の実行状態を保存 + + + Save State + 状態の保存 + + + Edit again the current schema in a new context + 新しいコンテキストで現在のスキーマを再編集 + + + Edit Again + 再編集 + + + get YACS container log + YACSコンテナログの取得 + + + YACS Container Log + YACSコンテナログ + + + get Node Error Report + ノードエラーレポートの取得 + + + Node Error Report + ノードエラーレポート + + + get Node Error Details + ノードエラーの詳細を取得 + + + Node Error Details + ノードエラーの詳細 + + + get Node Container Log + ノードコンテナログの取得 + + + Node Container Log +  ノードコンテナログ + + + Edit Data Types + データ型の編集 + + + Create Data Types + データ型の作成 + + + Import Data Types, use drag and drop from catalog + データ型のインポート(カタログからのドラッグ&ドロップを使用) + + + Import Data Types + データ型のインポート + + + Create a New Container + 新しいコンテナの作成 + + + Create Container + コンテナの作成 + + + Select a Component Instance + コンポーネントインスタンスの選択 + + + Create a New SALOME Component Instance + 新しいSALOMEコンポーネントインスタンスの作成 + + + new Component Instance + 新しいコンポーネントインスタンス + + + Create a New SALOME Python Component + 新しいSALOME Python コンポーネントの作成 + + + SALOME Python Component + SALOME Python コンポーネント + + + Create a New CORBA Component + 新しい CORBA コンポーネントの作成 + + + CORBA Component + CORBAコンポーネント + + + Create a New SALOME Service Node + 新しいSALOME サービスノードの作成 + + + SALOME Service Node + SALOMEサービスノード + + + Create a New Inline Service Node + 新しいインラインサービスノードの作成 + + + Inline Service Node + インラインサービスノード + + + Create a New CORBA Service Node + 新しいCORBAサービスノードの作成 + + + CORBA Node + CORBAノード + + + Create a New Node referencing a Node + ノードを参照する新しいノードを作成 + + + Ref on Node + ノードの参照 + + + Create a New C++ Node + 新しいC++ノードの作成 + + + Cpp Node + Cppノード + + + Create a New Input data Node + 新しい入力データノードの作成 + + + Input Data Node + 入力データノード + + + Create a New Output data Node + 新しい出力データノードの作成 + + + Output Data Node + 出力データノード + + + Create a New Input Study Node + 新しい入力Studyノードの作成 + + + Input Study Node + 入力Studyノード + + + Create a New Output Study Node + 新しい出力Studyノードの作成 + + + Output Study Node + 出力Studyノード + + + Create a New Inline Python Script Node + 新しいインラインPythonスクリプトノードの作成 + + + Inline Script Node + インラインスクリプトノード + + + Create a New Inline Python Function Node + 新しいインラインPython関数ノードの作成 + + + Inline Function Node + インライン関数ノード + + + Create a New Bloc Node + 新しいブロックノードの作成 + + + bloc Node + ブロックノード + + + Create a New For Loop Node + 新しい For loop ノードの作成 + + + For Loop Node + For Loop ノード + + + Create a New For Each Loop Node + 新しい For Each Loop ノードの作成 + + + For Each Loop Node + For Each Loop ノード + + + Create a New While Loop Node + 新しい While Loop ノードの作成 + + + While Loop Node + While Loop Node + + + Create a New Switch Node + 新しいスイッチノードの作成 + + + Switch Node + スイッチノード + + + Create a New Optimizer Loop Node + 新しい最適化ループノードの作成 + + + Optimizer Loop + 最適化ループ + + + Create a New Optimizer Loop + 新しい最適化ループの作成 + + + Create a New Node from Catalog, use drag and drop from catalog + カタログから新しいノードを作成,カタログからドラッグ&ドロップを使用 + + + Node from Catalog + カタログからのノード + + + Delete a Schema Item + スキーマ項目の削除 + + + Delete Item + 項目の削除 + + + Cut a Schema Item + スキーマ項目の切り取り + + + Cut Item + 項目の切り取り + + + Copy a Schema Item + スキーマ項目のコピー + + + Copy Item + 項目のコピー + + + Paste a Schema Item + スキーマ項目のペースト + + + Paste Item + 項目のペースト + + + Put node in block + ブロック内のノードを置く + + + Put Graph Content in Node + ノード内のグラフの内容を置く + + + arrange nodes on that bloc level, without recursion + 再帰せずにそのブロックレベル上にノードを配置 + + + arrange local nodes + ローカルノードを配置 + + + arrange nodes on that bloc level, with recursion + 再帰を伴ってそのブロックレベル上にノードを配置 + + + arrange nodes recursion + ノードの再帰の配置 + + + compute orthogonal links + 直交リンクの計算 + + + compute links + リンクの計算 + + + zoom 2D view to selected bloc + 2Dビューを選択したブロックにズーム + + + zoom to bloc + ブロックにズーム + + + zoom 2D view to the selected composed node + 2Dビューを選択中の構成ノードにズーム + + + center 2D view on selected node + 選択中のノード上に2Dビューを集中 + + + center on node + ノードに集中 + + + shrink or expand the selected node + 選択中のノードを展開または縮小 + + + shrink/expand + 展開/縮小 + + + draw straight or orthogonal links + 直線または直交リンクを描画 + + + straight/orthogonal + 直線/直交 + + + compute othogonal links automatically when nodes move + ノード移動時に直交リンクを自動的に計算 + + + automatic link + 自動リンク + + + simplify links by removing unnecessary direction changes + 不要な方向変更の削除によるリンクの簡素化 + + + simplify links + リンクの簡素化 + + + force orthogonal links by adding an edge on simples links + 簡素リンク上でのエッジの追加による直交リンクの強制 + + + force ortho links + 直交リンクの強制 + + + allow more path for the links, for a better separation + リンクやより良い分離のためにより多くのパスを許可 + + + separate links + 分離リンク + + + select reference + 参照の選択 + + + active whatsThis Mode to get help on widgets + ウィジェット上のヘルプ取得のためにWhatsThisモードを有効 + + + whatsThis Mode + WhatsThisモード + + + set execution mode without stop + 停止せずに実行モードをセット + + + mode without stop + 不停止モード + + + set execution mode with stop on breakpoints + ブレイクポイントで停止する実行モードを設定 + + + mode breakpoints + モードのブレイクポイント + + + set execution mode step by step + Step by Step 実行モードの設定 + + + mode step by step + モードのStep by Step + + + Force stop on first error during execution + 実行中に発生した最初のエラーで強制停止 + + + stop on error + エラー時に停止 + + + toggle 2D scene item visibility + 2 D シーン アイテムの表示切り替え + + + visible/hidden + 表示/非表示 + + + Show all the links + すべてのリンクを表示 + + + show all links + すべてのリンクを表示 + + + Hide all the links + すべてのリンクを非表示 + + + hide all links + すべてのリンクを非表示 + + + Show only links from/to this port + このポートとのリンクのみ表示 + + + show only links + リンクのみ表示 + + + Show links from/to this port + このポートとのリンクを表示 + + + show links + リンクを表示 + + + Hide links from/to this port + このポートとのリンクを非表示 + + + hide links + リンクを非表示 + + + Show only control links from/to this node + このノードとの制御リンクのみ表示 + + + show only Control links + 制御リンクのみ表示 + + + Show control links from/to this node + このノードとの制御リンクを表示 + + + show control links + 制御リンクを表示 + + + Hide control links from/to this node + このノードとの制御リンクを非表示 + + + hide control links + 制御リンクを非表示 + + + Show only this link + このリンクのみ表示 + + + show only + 表示のみ + + + Show this link + このリンクを表示 + + + show + 表示 + + + Hide this link + このリンクを非表示 + + + hide + 非表示 + + + emphasis on links from/to this port + このポートとのリンクを強調 + + + emphasize links + 強調リンク + + + emphasis on control links from/to this node + このノードとの制御リンクの強調 + + + emphasize control links + 制御リンクの強調 + + + emphasis on this link + このリンクの強調 + + + emphasize + 強調 + + + remove all emphasis + すべての強調を削除 + + + undo last action + 最後の操作をundo + + + undo + undo + + + redo last action + 最後の操作をredo + + + redo + redo + + + show undo commands + undoコマンドを表示 + + + show undo + undoを表示 + + + show redo commands + redoコマンドを表示 + + + show redo + redoを表示 + + + File + ファイル + + + YACS Toolbar + YACSツールバー + + + XML-Files (*.xml);;All Files (*) + XMLファイル (*.xml);;すべてのファイル (*) + + + + YACS::HMI::MenusBase + + Elapse Time Statistics + 経過時間の統計 + + + + YACS::HMI::ProcMenu + + Create Node + ノードを作成 + + diff --git a/src/yacsloader/Test/OptimizerAlgASyncExample.cxx b/src/yacsloader/Test/OptimizerAlgASyncExample.cxx index 86bc84ecb..34d4a0d4e 100644 --- a/src/yacsloader/Test/OptimizerAlgASyncExample.cxx +++ b/src/yacsloader/Test/OptimizerAlgASyncExample.cxx @@ -19,86 +19,145 @@ #include "OptimizerAlg.hxx" -using namespace YACS::ENGINE; +#include +//using namespace YACS::ENGINE; extern "C" { - OptimizerAlgBase * createOptimizerAlgASyncExample(Pool * pool); + YACS::ENGINE::OptimizerAlgBase * createOptimizerAlgASyncExample(YACS::ENGINE::Pool * pool); } -class OptimizerAlgASyncExample : public OptimizerAlgASync - { +class OptimizerAlgASyncExample : public YACS::ENGINE::OptimizerAlgASync +{ private: - TypeCode * _tcIn; - TypeCode * _tcOut; + YACS::ENGINE::TypeCode *_tcInt; + YACS::ENGINE::TypeCode *_tcDouble; public: - OptimizerAlgASyncExample(Pool * pool); + OptimizerAlgASyncExample(YACS::ENGINE::Pool *pool); virtual ~OptimizerAlgASyncExample(); - TypeCode * getTCForIn() const; - TypeCode * getTCForOut() const; - void startToTakeDecision(); - }; + + //! returns typecode of type expected as Input. OwnerShip of returned pointer is held by this. + virtual YACS::ENGINE::TypeCode *getTCForIn() const; + //! returns typecode of type expected as Output. OwnerShip of returned pointer is held by this. + virtual YACS::ENGINE::TypeCode *getTCForOut() const; + //! returns typecode of type expected for algo initialization. OwnerShip of returned pointer is held by this. + virtual YACS::ENGINE::TypeCode *getTCForAlgoInit() const; + //! returns typecode of type expected as algo result. OwnerShip of returned pointer is held by this. + virtual YACS::ENGINE::TypeCode *getTCForAlgoResult() const; + virtual void initialize(const YACS::ENGINE::Any *input) throw (YACS::Exception); + virtual void startToTakeDecision(); + virtual void finish();//! Called when optimization has succeed. + virtual YACS::ENGINE::Any * getAlgoResult(); +}; -OptimizerAlgASyncExample::OptimizerAlgASyncExample(Pool * pool) : OptimizerAlgASync(pool), - _tcIn(0), _tcOut(0) +OptimizerAlgASyncExample::OptimizerAlgASyncExample(YACS::ENGINE::Pool *pool) + : YACS::ENGINE::OptimizerAlgASync(pool), _tcInt(0), _tcDouble(0) { - _tcIn = new TypeCode(Double); - _tcOut = new TypeCode(Int); + _tcDouble = new YACS::ENGINE::TypeCode(YACS::ENGINE::Double); + _tcInt = new YACS::ENGINE::TypeCode(YACS::ENGINE::Int); } OptimizerAlgASyncExample::~OptimizerAlgASyncExample() { - _tcIn->decrRef(); - _tcOut->decrRef(); + _tcDouble->decrRef(); + _tcInt->decrRef(); +} + +//! Return the typecode of the expected input of the internal node +YACS::ENGINE::TypeCode * OptimizerAlgASyncExample::getTCForIn() const +{ + return _tcDouble; +} + +//! Return the typecode of the expected output of the internal node +YACS::ENGINE::TypeCode * OptimizerAlgASyncExample::getTCForOut() const +{ + return _tcInt; } -//! Return the typecode of the expected input type -TypeCode *OptimizerAlgASyncExample::getTCForIn() const +//! Return the typecode of the expected input of the algorithm (algoInit port) +YACS::ENGINE::TypeCode * OptimizerAlgASyncExample::getTCForAlgoInit() const { - return _tcIn; + return _tcInt; } -//! Return the typecode of the expected output type -TypeCode *OptimizerAlgASyncExample::getTCForOut() const +//! Return the typecode of the expected output of the algorithm (algoResult port) +YACS::ENGINE::TypeCode * OptimizerAlgASyncExample::getTCForAlgoResult() const { - return _tcOut; + return _tcInt; +} + +//! Optional method to initialize the algorithm. +/*! + * For now, the parameter input is always NULL. It might be used in the + * future to initialize an algorithm with custom data. + */ +void OptimizerAlgASyncExample::initialize(const YACS::ENGINE::Any *input) + throw (YACS::Exception) +{ + std::cout << "Algo initialize, input = " << input->getIntValue() << std::endl; } //! This method is called only once to launch the algorithm. /*! - * It must first fill the pool with samples to evaluate and call signalMasterAndWait() - * to block until a sample has been evaluated. When returning from this method, it MUST - * check for an eventual termination request (with the method isTerminationRequested()). - * If the termination is requested, the method must perform any necessary cleanup and - * return as soon as possible. Otherwise it can either add new samples to evaluate in - * the pool, do nothing (wait for more samples), or empty the pool and return to finish - * the evaluation. + * It must first fill the pool with samples to evaluate and call + * signalMasterAndWait() to block until a sample has been evaluated. When + * returning from this method, it MUST check for an eventual termination + * request (with the method isTerminationRequested()). If the termination + * is requested, the method must perform any necessary cleanup and return + * as soon as possible. Otherwise it can either add new samples to evaluate + * in the pool, do nothing (wait for more samples), or empty the pool and + * return to finish the evaluation. */ void OptimizerAlgASyncExample::startToTakeDecision() { - double val = 1.2; - for (int i=0 ; i<5 ; i++) { - // push a sample in the input of the slave node - _pool->pushInSample(i, AtomAny::New(val)); - // wait until next sample is ready - signalMasterAndWait(); - // check error notification - if (isTerminationRequested()) { - _pool->destroyAll(); - return; + std::cout << "startToTakeDecision" << std::endl; + int iter = 0; + YACS::ENGINE::Any *val=YACS::ENGINE::AtomAny::New(0.5); + _pool->pushInSample(iter, val); + + signalMasterAndWait(); + while(!isTerminationRequested()) + { + int currentId = _pool->getCurrentId(); + double valIn = _pool->getCurrentInSample()->getDoubleValue(); + int valOut = _pool->getCurrentOutSample()->getIntValue(); + + std::cout << "Compute currentId=" << currentId; + std::cout << ", valIn=" << valIn; + std::cout << ", valOut=" << valOut << std::endl; + + iter++; + if(iter < 3) + { + YACS::ENGINE::Any *val=YACS::ENGINE::AtomAny::New(valIn + 1); + _pool->pushInSample(iter, val); } - - // get a sample from the output of the slave node - Any * v = _pool->getCurrentOutSample(); - val += v->getIntValue(); + signalMasterAndWait(); } +} - // in the end destroy the pool content +/*! + * Optional method called when the algorithm has finished, successfully or + * not, to perform any necessary clean up. + */ +void OptimizerAlgASyncExample::finish() +{ + std::cout << "Algo finish" << std::endl; _pool->destroyAll(); } +/*! + * Return the value of the algoResult port. + */ +YACS::ENGINE::Any * OptimizerAlgASyncExample::getAlgoResult() +{ + YACS::ENGINE::Any *val=YACS::ENGINE::AtomAny::New(42); + return val; +} + //! Factory method to create the algorithm. -OptimizerAlgBase * createOptimizerAlgASyncExample(Pool * pool) +YACS::ENGINE::OptimizerAlgBase * createOptimizerAlgASyncExample(YACS::ENGINE::Pool *pool) { return new OptimizerAlgASyncExample(pool); -} +} \ No newline at end of file diff --git a/src/yacsloader/Test/OptimizerAlgSyncExample.cxx b/src/yacsloader/Test/OptimizerAlgSyncExample.cxx index db7134fae..6161dbf90 100644 --- a/src/yacsloader/Test/OptimizerAlgSyncExample.cxx +++ b/src/yacsloader/Test/OptimizerAlgSyncExample.cxx @@ -22,121 +22,142 @@ #include "OptimizerAlg.hxx" -using namespace YACS::ENGINE; +#include +//using namespace YACS::ENGINE; extern "C" { - OptimizerAlgBase * createOptimizerAlgSyncExample(Pool * pool); + YACS::ENGINE::OptimizerAlgBase * createOptimizerAlgSyncExample(YACS::ENGINE::Pool * pool); } -class OptimizerAlgSyncExample : public OptimizerAlgSync - { +class OptimizerAlgSyncExample : public YACS::ENGINE::OptimizerAlgSync +{ private: - int _idTest; - TypeCode *_tcIn; - TypeCode *_tcOut; + int _iter; + YACS::ENGINE::TypeCode *_tcInt; + YACS::ENGINE::TypeCode *_tcDouble; public: - OptimizerAlgSyncExample(Pool *pool); + OptimizerAlgSyncExample(YACS::ENGINE::Pool *pool); virtual ~OptimizerAlgSyncExample(); - TypeCode *getTCForIn() const; - TypeCode *getTCForOut() const; - void start(); - void takeDecision(); - void initialize(const Any *input) throw(YACS::Exception); - void finish(); - }; - -OptimizerAlgSyncExample::OptimizerAlgSyncExample(Pool *pool) : OptimizerAlgSync(pool), - _tcIn(0), _tcOut(0), - _idTest(0) + + //! returns typecode of type expected as Input. OwnerShip of returned pointer is held by this. + virtual YACS::ENGINE::TypeCode *getTCForIn() const; + //! returns typecode of type expected as Output. OwnerShip of returned pointer is held by this. + virtual YACS::ENGINE::TypeCode *getTCForOut() const; + //! returns typecode of type expected for algo initialization. OwnerShip of returned pointer is held by this. + virtual YACS::ENGINE::TypeCode *getTCForAlgoInit() const; + //! returns typecode of type expected as algo result. OwnerShip of returned pointer is held by this. + virtual YACS::ENGINE::TypeCode *getTCForAlgoResult() const; + virtual void initialize(const YACS::ENGINE::Any *input) throw (YACS::Exception); + virtual void start(); //! Update _pool attribute before performing anything. + virtual void takeDecision();//! _pool->getCurrentId gives the \b id at the origin of this call. + //! Perform the job of analysing to know what new jobs to do (_pool->pushInSample) + //! or in case of convergence _pool->destroyAll + virtual void finish();//! Called when optimization has succeed. + virtual YACS::ENGINE::Any * getAlgoResult(); +}; + +OptimizerAlgSyncExample::OptimizerAlgSyncExample(YACS::ENGINE::Pool *pool) + : YACS::ENGINE::OptimizerAlgSync(pool), _tcInt(0), _tcDouble(0), _iter(0) { - _tcIn=new TypeCode(Double); - _tcOut=new TypeCode(Int); + _tcDouble = new YACS::ENGINE::TypeCode(YACS::ENGINE::Double); + _tcInt = new YACS::ENGINE::TypeCode(YACS::ENGINE::Int); } OptimizerAlgSyncExample::~OptimizerAlgSyncExample() { - std::cout << "Destroying OptimizerAlgSyncExample" << std::endl; - _tcIn->decrRef(); - _tcOut->decrRef(); - std::cout << "Destroyed OptimizerAlgSyncExample" << std::endl; + _tcDouble->decrRef(); + _tcInt->decrRef(); } -//! Return the typecode of the expected input type -TypeCode * OptimizerAlgSyncExample::getTCForIn() const +//! Return the typecode of the expected input of the internal node +YACS::ENGINE::TypeCode * OptimizerAlgSyncExample::getTCForIn() const { - return _tcIn; + return _tcDouble; } -//! Return the typecode of the expected output type -TypeCode * OptimizerAlgSyncExample::getTCForOut() const +//! Return the typecode of the expected output of the internal node +YACS::ENGINE::TypeCode * OptimizerAlgSyncExample::getTCForOut() const { - return _tcOut; + return _tcInt; +} + +//! Return the typecode of the expected input of the algorithm (algoInit port) +YACS::ENGINE::TypeCode * OptimizerAlgSyncExample::getTCForAlgoInit() const +{ + return _tcInt; +} + +//! Return the typecode of the expected output of the algorithm (algoResult port) +YACS::ENGINE::TypeCode * OptimizerAlgSyncExample::getTCForAlgoResult() const +{ + return _tcInt; +} + +//! Optional method to initialize the algorithm. +/*! + * For now, the parameter input is always NULL. It might be used in the + * future to initialize an algorithm with custom data. + */ +void OptimizerAlgSyncExample::initialize(const YACS::ENGINE::Any *input) + throw (YACS::Exception) +{ + std::cout << "Algo initialize, input = " << input->getIntValue() << std::endl; } //! Start to fill the pool with samples to evaluate void OptimizerAlgSyncExample::start() { - _idTest=0; - Any *val=AtomAny::New(1.2); - _pool->pushInSample(4,val); - val=AtomAny::New(3.4); - _pool->pushInSample(9,val); + std::cout << "Algo start " << std::endl; + _iter=0; + YACS::ENGINE::Any *val=YACS::ENGINE::AtomAny::New(0.5); + _pool->pushInSample(_iter,val); } //! This method is called each time a sample has been evaluated. /*! - * It can either add new samples to evaluate in the pool, do nothing (wait for more - * samples), or empty the pool to finish the evaluation. + * It can either add new samples to evaluate in the pool, do nothing (wait + * for more samples), or empty the pool to finish the evaluation. */ void OptimizerAlgSyncExample::takeDecision() { - if(_idTest==1) - { - Any *val=AtomAny::New(5.6); - _pool->pushInSample(16,val); - val=AtomAny::New(7.8); - _pool->pushInSample(25,val); - val=AtomAny::New(9. ); - _pool->pushInSample(36,val); - val=AtomAny::New(12.3); - _pool->pushInSample(49,val); - } - else if(_idTest==4) - { - Any *val=AtomAny::New(45.6); - _pool->pushInSample(64,val); - val=AtomAny::New(78.9); - _pool->pushInSample(81,val); - } - else - { - Any *tmp= _pool->getCurrentInSample(); - if(fabs(tmp->getDoubleValue()-45.6)<1.e-12) - _pool->destroyAll(); - } - _idTest++; + int currentId = _pool->getCurrentId(); + double valIn = _pool->getCurrentInSample()->getDoubleValue(); + int valOut = _pool->getCurrentOutSample()->getIntValue(); + + std::cout << "Algo takeDecision currentId=" << currentId; + std::cout << ", valIn=" << valIn; + std::cout << ", valOut=" << valOut << std::endl; + + _iter++; + if(_iter < 3) + { + YACS::ENGINE::Any *val=YACS::ENGINE::AtomAny::New(valIn + 1); + _pool->pushInSample(_iter, val); + } } -//! Optional method to initialize the algorithm. /*! - * For now, the parameter input is always NULL. It might be used in the future to - * initialize an algorithm with custom data. + * Optional method called when the algorithm has finished, successfully or + * not, to perform any necessary clean up. */ -void OptimizerAlgSyncExample::initialize(const Any *input) throw (YACS::Exception) +void OptimizerAlgSyncExample::finish() { + std::cout << "Algo finish" << std::endl; + _pool->destroyAll(); } /*! - * Optional method called when the algorithm has finished, successfully or not, to - * perform any necessary clean up. + * Return the value of the algoResult port. */ -void OptimizerAlgSyncExample::finish() +YACS::ENGINE::Any * OptimizerAlgSyncExample::getAlgoResult() { + YACS::ENGINE::Any *val=YACS::ENGINE::AtomAny::New(42); + return val; } //! Factory method to create the algorithm. -OptimizerAlgBase * createOptimizerAlgSyncExample(Pool *pool) +YACS::ENGINE::OptimizerAlgBase * createOptimizerAlgSyncExample(YACS::ENGINE::Pool *pool) { return new OptimizerAlgSyncExample(pool); -} +} \ No newline at end of file diff --git a/src/yacsloader/Test/algoasyncexample.py b/src/yacsloader/Test/algoasyncexample.py index c371890f8..430820e5c 100644 --- a/src/yacsloader/Test/algoasyncexample.py +++ b/src/yacsloader/Test/algoasyncexample.py @@ -25,44 +25,77 @@ class myalgoasync(SALOMERuntime.OptimizerAlgASync): r=SALOMERuntime.getSALOMERuntime() self.tin=r.getTypeCode("double") self.tout=r.getTypeCode("int") + self.tAlgoInit=r.getTypeCode("int") + self.tAlgoResult=r.getTypeCode("int") def setPool(self,pool): """Must be implemented to set the pool""" self.pool=pool def getTCForIn(self): - """returns typecode of type expected as Input""" + """return typecode of type expected as Input of the internal node """ return self.tin def getTCForOut(self): - """returns typecode of type expected as Output""" + """return typecode of type expected as Output of the internal node""" return self.tout - def startToTakeDecision(self): - """This method is called only once to launch the algorithm. It must first fill the - pool with samples to evaluate and call self.signalMasterAndWait() to block until a - sample has been evaluated. When returning from this method, it MUST check for an - eventual termination request (with the method self.isTerminationRequested()). If - the termination is requested, the method must perform any necessary cleanup and - return as soon as possible. Otherwise it can either add new samples to evaluate in - the pool, do nothing (wait for more samples), or empty the pool and return to - finish the evaluation. + def getTCForAlgoInit(self): + """return typecode of type expected as input for initialize """ + return self.tAlgoInit + + def getTCForAlgoResult(self): + """return typecode of type expected as output of the algorithm """ + return self.tAlgoResult + + def initialize(self,input): + """Optional method called on initialization. + The type of "input" is returned by "getTCForAlgoInit" """ - val=1.2 - for iter in xrange(5): - #push a sample in the input of the slave node - self.pool.pushInSample(iter,val) - #wait until next sample is ready - self.signalMasterAndWait() - #check error notification - if self.isTerminationRequested(): - self.pool.destroyAll() - return + print "Algo initialize, input = ", input.getIntValue() - #get a sample from the output of the slave node + def startToTakeDecision(self): + """This method is called only once to launch the algorithm. It must + first fill the pool with samples to evaluate and call + self.signalMasterAndWait() to block until a sample has been + evaluated. When returning from this method, it MUST check for an + eventual termination request (with the method + self.isTerminationRequested()). If the termination is requested, the + method must perform any necessary cleanup and return as soon as + possible. Otherwise it can either add new samples to evaluate in the + pool, do nothing (wait for more samples), or empty the pool and + return to finish the evaluation. + """ + print "startToTakeDecision" + # fill the pool with samples + iter=0 + self.pool.pushInSample(0, 0.5) + + # + self.signalMasterAndWait() + while not self.isTerminationRequested(): currentId=self.pool.getCurrentId() - v=self.pool.getCurrentOutSample() - val=val+v.getIntValue() + valIn = self.pool.getCurrentInSample().getDoubleValue() + valOut = self.pool.getCurrentOutSample().getIntValue() + print "Compute currentId=%s, valIn=%s, valOut=%s" % (currentId, valIn, valOut) + iter=iter+1 + + if iter < 3: + nextSample = valIn + 1 + self.pool.pushInSample(iter, nextSample) + + self.signalMasterAndWait() - #in the end destroy the pool content + def finish(self): + """Optional method called when the algorithm has finished, successfully + or not, to perform any necessary clean up.""" + print "Algo finish" self.pool.destroyAll() + + def getAlgoResult(self): + """return the result of the algorithm. + The object returned is of type indicated by getTCForAlgoResult. + """ + return 42 + + diff --git a/src/yacsloader/Test/algosyncexample.py b/src/yacsloader/Test/algosyncexample.py index 1ccf6bda4..d40a93764 100644 --- a/src/yacsloader/Test/algosyncexample.py +++ b/src/yacsloader/Test/algosyncexample.py @@ -25,49 +25,68 @@ class myalgosync(SALOMERuntime.OptimizerAlgSync): r=SALOMERuntime.getSALOMERuntime() self.tin=r.getTypeCode("double") self.tout=r.getTypeCode("int") + self.tAlgoInit=r.getTypeCode("int") + self.tAlgoResult=r.getTypeCode("int") def setPool(self,pool): """Must be implemented to set the pool""" self.pool=pool def getTCForIn(self): - """returns typecode of type expected as Input""" + """return typecode of type expected as Input of the internal node """ return self.tin def getTCForOut(self): - """returns typecode of type expected as Output""" + """return typecode of type expected as Output of the internal node""" return self.tout + def getTCForAlgoInit(self): + """return typecode of type expected as input for initialize """ + return self.tAlgoInit + + def getTCForAlgoResult(self): + """return typecode of type expected as output of the algorithm """ + return self.tAlgoResult + def initialize(self,input): - """Optional method called on initialization. Do nothing here""" + """Optional method called on initialization. + The type of "input" is returned by "getTCForAlgoInit" + """ + print "Algo initialize, input = ", input.getIntValue() def start(self): """Start to fill the pool with samples to evaluate.""" + print "Algo start " self.iter=0 - self.pool.pushInSample(4,1.2) - self.pool.pushInSample(9,3.4) + # pushInSample(id, value) + self.pool.pushInSample(self.iter, 0.5) def takeDecision(self): - """ This method is called each time a sample has been evaluated. It can either add - new samples to evaluate in the pool, do nothing (wait for more samples), or empty - the pool to finish the evaluation. + """ This method is called each time a sample has been evaluated. It can + either add new samples to evaluate in the pool, do nothing (wait for + more samples), or empty the pool to finish the evaluation. """ currentId=self.pool.getCurrentId() + valIn = self.pool.getCurrentInSample().getDoubleValue() + valOut = self.pool.getCurrentOutSample().getIntValue() + print "Algo takeDecision currentId=%s, valIn=%s, valOut=%s" % (currentId, valIn, valOut) - if self.iter==1: - self.pool.pushInSample(16,5.6) - self.pool.pushInSample(25,7.8) - self.pool.pushInSample(36,9.) - self.pool.pushInSample(49,12.3) - elif self.iter==4: - self.pool.pushInSample(64,45.6) - self.pool.pushInSample(81,78.9) - else: - val=self.pool.getCurrentInSample() - if abs(val.getDoubleValue()-45.6) < 1.e-12: - self.pool.destroyAll() self.iter=self.iter+1 + if self.iter < 3: + # continue + nextSample = valIn + 1 + self.pool.pushInSample(self.iter, nextSample) def finish(self): - """Optional method called when the algorithm has finished, successfully or not, to - perform any necessary clean up. Do nothing here""" + """Optional method called when the algorithm has finished, successfully + or not, to perform any necessary clean up.""" + print "Algo finish" + self.pool.destroyAll() + + def getAlgoResult(self): + """return the result of the algorithm. + The object returned is of type indicated by getTCForAlgoResult. + """ + return 42 + + diff --git a/src/yacsloader/driver.cxx b/src/yacsloader/driver.cxx index c081a97f2..cfb9350aa 100644 --- a/src/yacsloader/driver.cxx +++ b/src/yacsloader/driver.cxx @@ -312,7 +312,9 @@ int main (int argc, char* argv[]) #endif timer("Starting "); - RuntimeSALOME::setRuntime(); + long flags = RuntimeSALOME::UsePython + RuntimeSALOME::UseCorba + RuntimeSALOME::UseXml + \ + RuntimeSALOME::UseCpp + RuntimeSALOME::UseSalome; + RuntimeSALOME::setRuntime(flags, argc, argv); // Try to load the session catalog if it exists try diff --git a/src/yacsloader/samples/optimizer_async_cpp.xml b/src/yacsloader/samples/optimizer_async_cpp.xml index 223f38e06..bf6932013 100644 --- a/src/yacsloader/samples/optimizer_async_cpp.xml +++ b/src/yacsloader/samples/optimizer_async_cpp.xml @@ -32,38 +32,64 @@ + + + + + + + + + - - - - - - - + + + + + + + + + 5 + + + + + + OptimizerLoop1 OutNode5 + DataIn3 OptimizerLoop1 + + OptimizerLoop1 algoResults + OutNode5 i6 + + + OptimizerLoop1 evalSamples + OptimizerLoop1.PyScript7 i8 + - OptimizerLoop0 evalSamples - OptimizerLoop0.PyFunction1 inValue + DataIn3 o4 + OptimizerLoop1 algoInit - OptimizerLoop0.PyFunction1 outValue - OptimizerLoop0 evalResults + OptimizerLoop1.PyScript7 o9 + OptimizerLoop1 evalResults - OptimizerLoop0nbBranches - 4 + OptimizerLoop1nbBranches + 1 - - - + + + + + diff --git a/src/yacsloader/samples/optimizer_async_py.xml b/src/yacsloader/samples/optimizer_async_py.xml index de8ba0480..115bb6824 100644 --- a/src/yacsloader/samples/optimizer_async_py.xml +++ b/src/yacsloader/samples/optimizer_async_py.xml @@ -32,38 +32,64 @@ + + + + + + + + + - - - - - - - + + + + + + + + + 5 + + + + + + OptimizerLoop1 OutNode5 + DataIn3 OptimizerLoop1 + + OptimizerLoop1 algoResults + OutNode5 i6 + + + OptimizerLoop1 evalSamples + OptimizerLoop1.PyScript7 i8 + - OptimizerLoop0 evalSamples - OptimizerLoop0.PyFunction0 inputValue + DataIn3 o4 + OptimizerLoop1 algoInit - OptimizerLoop0.PyFunction0 outputValue - OptimizerLoop0 evalResults + OptimizerLoop1.PyScript7 o9 + OptimizerLoop1 evalResults - OptimizerLoop0nbBranches - 4 + OptimizerLoop1nbBranches + 1 - - - + + + + + diff --git a/src/yacsloader/samples/optimizer_sync_cpp.xml b/src/yacsloader/samples/optimizer_sync_cpp.xml index 97394e915..59b78017e 100644 --- a/src/yacsloader/samples/optimizer_sync_cpp.xml +++ b/src/yacsloader/samples/optimizer_sync_cpp.xml @@ -32,38 +32,64 @@ + + + + + + + + + - - - - - - - + + + + + + + + + 5 + + + + + + OptimizerLoop1 OutNode5 + DataIn3 OptimizerLoop1 + + OptimizerLoop1 algoResults + OutNode5 i6 + + + OptimizerLoop1 evalSamples + OptimizerLoop1.PyScript7 i8 + - OptimizerLoop0 evalSamples - OptimizerLoop0.PyFunction1 inValue + DataIn3 o4 + OptimizerLoop1 algoInit - OptimizerLoop0.PyFunction1 outValue - OptimizerLoop0 evalResults + OptimizerLoop1.PyScript7 o9 + OptimizerLoop1 evalResults - OptimizerLoop0nbBranches - 4 + OptimizerLoop1nbBranches + 1 - - - + + + + + diff --git a/src/yacsloader/samples/optimizer_sync_py.xml b/src/yacsloader/samples/optimizer_sync_py.xml index 3da9d59c6..0b69be3fc 100644 --- a/src/yacsloader/samples/optimizer_sync_py.xml +++ b/src/yacsloader/samples/optimizer_sync_py.xml @@ -32,38 +32,64 @@ + + + + + + + + + - - - - - - - + + + + + + + + + 5 + + + + + + OptimizerLoop1 OutNode5 + DataIn3 OptimizerLoop1 + + OptimizerLoop1 algoResults + OutNode5 i6 + + + OptimizerLoop1 evalSamples + OptimizerLoop1.PyScript7 i8 + - OptimizerLoop0 evalSamples - OptimizerLoop0.PyFunction0 inputValue + DataIn3 o4 + OptimizerLoop1 algoInit - OptimizerLoop0.PyFunction0 outputValue - OptimizerLoop0 evalResults + OptimizerLoop1.PyScript7 o9 + OptimizerLoop1 evalResults - OptimizerLoop0nbBranches - 4 + OptimizerLoop1nbBranches + 1 - - - + + + + +