// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : SUPERV.idl
// Author : Jean Rahuel
-// $Header:
+// $Header:
/*! \file SUPERV.idl This file contains a set of interfaces of the %SUPERVISION module
*/
#include "SALOME_ModuleCatalog.idl"
#include "SALOME_Component.idl"
#include "SALOMEDS.idl"
-/*!
+/*!
The main package of interfaces of %SUPERVISION module
*/
module SUPERV {
/*!
This enumeration contains a set of elements defining the type of the port.
-\note <BR>In general, ports represent <STRONG>input or output parameters</STRONG> of the functions,
+\note <BR>In general, ports represent <STRONG>input or output parameters</STRONG> of the functions,
implemented in different kinds of nodes of the graph.
*/
enum KindOfPort { UndefinedParameter , ServiceParameter , GateParameter ,
short Year;
};
/*!
-This enumeration contains a set of elements defining the type of operation, which has been performed
+This enumeration contains a set of elements defining the type of operation, which has been performed
on this node(graph).
*/
ReRunState , ReStartState ,
NumberOfGraphStates } ;
+/*! A sequence of string values.
+*/
typedef sequence<string> ListOfStrings ;
interface Value ;
typedef sequence<ELNode> ListOfELNodes ;
typedef sequence<SNode> ListOfSNodes ;
typedef sequence<ESNode> ListOfESNodes ;
+/*!
+This struct contains fields defining different types of nodes.
+*/
struct ListOfNodes {
ListOfCNodes CNodes ;
// ToSuspendStartState : will be Suspended at the beginning of execution
// ToSuspendDoneState : will be Suspended after run
/*!
-This enumeration contains a set of elements defining the %ControlState of the node.
+This enumeration contains a set of elements defining the %ControlState of the node.
The %ControlState gives a possibility to determine the "control actions" which have been done by
the user (Suspend, SuspendDone, Kill, etc...).
-*/
+*/
enum ControlState { VoidState , ToSuspendStartState ,
ToSuspendState , ToSuspendDoneState ,
ToKillState , ToKillDoneState , ToStopState ,
NumberOfControlStates } ;
/*!
The AutomatonState is an internal state of the automaton of the Executor
-of the %SuperVision %Engine. It is used for inner debugging purposes only.
+of the %Supervision %Engine. It is used for inner debugging purposes only.
*/
enum AutomatonState { UnKnownState ,
- DataUndefState ,
+ DataUndefState ,
DataWaitingState ,
DataReadyState ,
- SuspendedReadyState,
+ SuspendedReadyState,
SuspendedReadyToResumeState ,
ResumedReadyState ,
KilledReadyState ,
StoppedReadyState ,
ExecutingState ,
- SuspendedExecutingState ,
+ SuspendedExecutingState ,
ResumedExecutingState ,
- KilledExecutingState ,
+ KilledExecutingState ,
StoppedExecutingState ,
- SuccessedExecutingState ,
+ SuccessedExecutingState ,
ErroredExecutingState ,
SuspendedSuccessedState ,
SuspendedErroredState,
- ResumedSuccessedState ,
+ ResumedSuccessedState ,
ResumedErroredState ,
- KilledSuccessedState ,
+ KilledSuccessedState ,
KilledErroredState ,
StoppedSuccessedState ,
StoppedErroredState ,
- SuccessedState ,
+ SuccessedState ,
ErroredState ,
SuspendedState ,
- KilledState ,
+ KilledState ,
StoppedState ,
SuspendedSuccessedToReStartState ,
SuspendedErroredToReStartState ,
- ReRunnedState ,
+ ReRunnedState ,
ReStartedState ,
- NumberOfAutomatonStates
+ NumberOfAutomatonStates
} ;
*/
interface SuperG : Engines::Component, SALOMEDS::Driver {
////////////////
-/*!
+/*!
Constructs a graph with possibility to read/edit it
\param aGraph %aGraphName or %aGraphXmlFile
*/
SUPERV::Graph Graph(in string aGraph ) ; // aGraphName or aGraphXmlFile
-/*!
+/*!
Constructs a read Only graph ( for execution ).
\note <BR>In this graph there is also a possibility to update nodes, coordinates of the links,
of container names and input data.
*/
SUPERV::Graph GraphE(in string aGraph ) ; // aGraphName or aGraphXmlFile
-/*!
-Creates a value for %Input method in interface %Node.
+/*!
+Creates a value of <b>string</b> type which will be used for <VAR>Input</VAR> method in the interface %Node.
+\param aString Input value of string type.
*/
SUPERV::Value StringValue( in string aString ) ;
+/*!
+Creates a value of <b>any</b> type which will be used for <VAR>Input</VAR> method in the interface %Node.
+\param anAny Input value of any type.
+*/
SUPERV::Value AnyValue( in any anAny ) ;
/*!
- Gets a graph from its %IOR
+ Gets a graph with a definite %IOR
+\param ior String parameter defining %IOR of the graph.
*/
SUPERV::Graph getGraph(in string ior); // get Graph from is IOR
};
-/*! \brief Interface of a node
+/*! \brief %CNode interface
-This interface includes a set of methods used for management of the nodes in the graph.
-*/
+This is a base class of the SUPERVISION module. It contains a set of methods allowing:
+<ul>
+ <li>creating a <b>Computation</b> node and setting its parameters (Name, Author, Comments etc.)
+ <li>checking the current state of the node in the data flow
+ <li>node execution follow-up
+ <li>management of the components, which can be initialized for execution of calculations in the data flow. (For that purpose %CNode class inherits the methods of the %Engines:Component class)
+</ul>
+*/
//////////////
interface CNode : Engines::Component {
//////////////
-/*!
+/*!
Returns the name of the node(graph).
*/
string Name() ;
-/*!
+/*!
Returns the service of this node .
*/
SALOME_ModuleCatalog::Service Service() ;
-/*!
+/*!
Returns the type of the node.
*/
SUPERV::KindOfNode Kind() ;
-/*!
+/*!
Returns the date of creation of the node(graph).
-*/
+*/
SUPERV::SDate CreationDate() ;
-/*!
+/*!
Returns the date of last update of the node(graph).
*/
SUPERV::SDate LastUpdateDate() ;
-/*!
+/*!
Returns the name of the version of the node(graph).
*/
string Version() ;
-/*!
+/*!
Returns the name of the author of the node(graph).
*/
string Author() ;
-/*!
+/*!
Returns the string containing comments about this node(graph).
*/
string Comment() ;
-
-/*!
-Sets the name of the node(graph). Returns True if it is updated.
+
+/*!
+Sets the name of the node(graph).
+\param aNewName String value defining the name of the node(graph).
+\return True if the name has been updated.
*/
boolean SetName(in string aNewName ) ;
-/*!
-Sets the name of the author. Returns True if it is updated.
+/*!
+Sets the name of the author. Returns True if it is updated.
+\param anAuthor String value defining the name of the author.
+\return True if the name has been updated.
*/
boolean SetAuthor(in string anAuthor ) ;
/*!
Allows to update the comments about this node(graph).
-*/
+\param aComment String value containing a comment to this node(graph).
+\return True if the old comment has been updated.
+*/
boolean SetComment(in string aComment ) ;
/*!
Gets a port of the node.
-*/
+*/
SUPERV::Port Port( in string aParameterName ) ;
/*!
Enters a value into an Input %Port
-*/
+*/
SUPERV::Port Input( in string InputParameterName ,
in Value aValue ) ;
// out SUPERV::Port InputPort ,
// out SUPERV::Port OutputPort ) ;
-/*!
+/*!
Gets a list of ports of the node(graph)
*/
SUPERV::ListOfPorts Ports() ;
- // Get list of Links
+/*! Gets a list of links of a port
+*/
SUPERV::ListOfLinks Links() ;
/*!
-Returns True if this node is a graph.
+Returns True if this node is a graph.
\note <BR>A node of the graph can also represent in its turn another graph.
*/
boolean IsGraph() ;
Returns True if the node appears to be a %computing node.
*/
boolean IsComputing() ;
+/*!
+Returns True if the node appears to be a %factory node.
+*/
boolean IsFactory() ;
+/*!
+Returns True if the node appears to be an %inline node.
+*/
boolean IsInLine() ;
+/*!
+Returns True if the node appears to be a %GOTO node.
+*/
boolean IsGOTO() ;
+/*!
+Returns True if the node appears to be a %loop node.
+*/
boolean IsLoop() ;
+/*!
+Returns True if the node appears to be an %endloop node.
+*/
boolean IsEndLoop() ;
+/*!
+Returns True if the node appears to be a %switch node.
+*/
boolean IsSwitch() ;
+/*!
+Returns True if the node appears to be a %endswitch node.
+*/
boolean IsEndSwitch() ;
-/*!
- Returns the number of SubGraphs
+/*!
+ Returns the number of subgraphs.
*/
long SubGraph() ;
-/*!
-Returns nuber of threads.
+/*!
+Returns the number of threads of the graph.
*/
long Thread() ;
-/*!
+/*!
Returns True if the node(graph) is waiting for Data input
*/
boolean IsWaiting() ;
-/*!
+/*!
Returns True if the node(graph) is ready for execution
*/
boolean IsReady() ;
- /*!
- Returns True if the node(graph) is running
+/*!
+ Returns True if the node(graph) is currently running
*/
boolean IsRunning() ;
-/*!
- Returns True if execution is finished
+/*!
+ Returns True if execution is finished
*/
-
+
boolean IsDone() ;
-/*!
+/*!
Returns True if execution is suspended
*/
-
+
boolean IsSuspended() ;
/*!
Returns the current state of the graph.
*/
SUPERV::GraphState State() ;
- // wait for ready_to_run state, Suspend and return
+/*!
+ Waits for ready_to_run state, Suspend and return.
+*/
boolean ReadyW() ;
- // wait for running state, Suspend and return
+/*! Waits for running state, Suspend and return.
+*/
boolean RunningW() ;
- // wait for done state, Suspend and return
+/*! Waits for done state, Suspend and return.
+*/
boolean DoneW() ;
- // wait for Suspend state and return
+/*! Waits for Suspend state and return.
+*/
boolean SuspendedW() ;
// boolean Ping();
- // if not running : will be killed when ready to run
- // if running : Kill immediatly
+/*! Kills execution.
+<br>
+If not running : will be killed when ready to run.
+If running : kills immediatly.
+*/
boolean Kill();
- // will be killed only just after running (only for nodes)
+/*! Kills execution.
+<br>
+Execution will be killed only just after running (only for nodes).
+*/
boolean KillDone();
- // if not running : will be stopped when ready to run
- // if running : Stop immediatly
+/*! Stops execution.
+<br>
+If not running : will be stopped when ready to run.
+If running : stops immediatly
+*/
boolean Stop();
-
- // if not running : will be Suspended when ready to run
- // if running : Suspend immediatly
+/*! Suspends execution.
+<br>
+If not running : will be Suspended when ready to run. It is used in step-by-step execution.
+If running : suspends immediatly
+*/
boolean Suspend();
-
- // will be Suspended only just after running
+/*! Suspends execution only just after running.
+*/
boolean SuspendDone();
- // if Suspended : running will continue
- // if not Suspended : cancel current ControlState ( Suspend, Kill, ...)
+/*! Resumes execution.
+<br>
+If Suspended : running will be continued.
+If not Suspended : cancels the current ControlState ( Suspend, Kill, ...)
+*/
boolean Resume();
/*!
/*!
Restarts and suspends execution of the node(graph).
-*/
+*/
boolean ReStart();
/*!
-Restarts and suspends execution of the graph beginning from a defined node.
+Restarts and suspends execution of the graph beginning from a definite node.
+\param aNodeName String parameter defining the name of the node.
*/
boolean ReStartAt( in string aNodeName );
SUPERV::AutomatonState AutoState() ;
// Control state required : Kill, Suspend, Stop
+/*!
+ Returns control state of the node(graph).
+*/
SUPERV::ControlState Control() ;
/*!
Clears the control state of the node(graph).
void ControlClear() ;
boolean ContainerKill();
-/*!
+/*!
Sets the position of the node in the window.
*/
void Coords( in long X , in long Y ) ;
-/*!
+/*!
Returns the position of the node along X-axis.
*/
long X() ;
-/*!
+/*!
Returns the position of the node along Y-axis.
*/
long Y() ;
-/*!
-Returns the Cpu used by a node in seconds.
+/*!
+Returns the Cpu used by a node for execution of calculations in seconds.
*/
long CpuUsed() ;
} ;
+/*! \brief %FNode class
+This class is necessary for management of factory nodes in a data flow. Besides the inherited methods it contains some methods allowing to define
+the component from the container, which will be called for execution of the calculation.
+*/
//////////////
interface FNode : CNode {
//////////////
-
+/*! Gets the name of the component, which will be called for execution of the calculation.
+*/
string GetComponentName() ;
+/*! Gets the name of the interface of the component.
+*/
string GetInterfaceName() ;
+/*! Gets the container containing the component, which will be called for execution of the calculation.
+*/
string GetContainer() ;
+/*! Sets the name of the component, which will be called for execution of the calculation.
+\param aComponentName Name of the component.
+*/
boolean SetComponentName(in string aComponentName ) ;
+/*! Sets the name of the interface of the component.
+\param anInterfaceName Name of the interface.
+*/
boolean SetInterfaceName(in string anInterfaceName ) ;
+/*! Gets the container containing the component, which will be called for execution of the calculation.
+\param aContainer Container containing the component.
+*/
boolean SetContainer(in string aContainer ) ;
} ;
+/*! \brief %INode class
+This class is necessary for management of inline nodes in a data flow. Besides the inherited methods it contains some methods allowing to set a Python function, which will be
+executed for performing calculations, as well as input and output parameters for the node.
+*/
// InLine Nodes
//////////////
interface INode : CNode {
//////////////
+/*! Sets Python function for the InLine Node.
+\param FuncName Name of the function
+\param aPyInitFunction Python initialization function of the InLine Node
+*/
void SetPyFunction( in string FuncName ,
in SUPERV::ListOfStrings aPyInitFunction ) ;
+/*! Returns Python function of the InLine Node.
+*/
SUPERV::ListOfStrings PyFunction() ;
+/*! Returns the name of the Python function of the InLine Node.
+*/
string PyFuncName() ;
- // Create Input/Output Port in InLineNodes
+/*! Creates an Input port in an Inline node.
+
+\param aParameterName This value sets the name of the parameter which will be defined in this port.
+\param aParameterType This value sets the type of the parameter which will be defined in this port.
+*/
+
SUPERV::Port InPort( in string aParameterName , in string aParameterType ) ;
+/*! Creates an Output port in an Inline node.
+
+\param aParameterName This value sets the name of the parameter which will be defined in this port.
+\param aParameterType This value sets the type of the parameter which will be defined in this port.
+*/
+
SUPERV::Port OutPort( in string aParameterName , in string aParameterType ) ;
} ;
+/*! \brief %GNode class
+This class is necessary for management of GOTO/EndLoop/EndSwitch nodes in the dataflow.
+Besides the inherited methods it contains some methods allowing to define the couple node, which will be linked to this one.
+*/
// GOTO/EndLoop/EndSwitch Nodes
///////////////
interface GNode : INode {
///////////////
-
+/*! Sets the coupled InLine Node to this GOTO/EndLoop/EndSwitch Node.
+*/
boolean SetCoupled( in string anInLineNode ) ;
+/*! Returns the coupled InLine Node to this GOTO/EndLoop/EndSwitch Node.
+*/
SUPERV::INode Coupled() ;
} ;
-
+/*! %Loop Nodes class
+*/
// Loop Nodes
///////////////
interface LNode : GNode {
///////////////
-
- void SetPyInit( in string MoreName ,
- in SUPERV::ListOfStrings aPyMoreFunction ) ;
+/*! Sets Python Init function of the Loop Node.
+\param InitName Name of the Init function
+\param aPyInitFunction Python Init function
+*/
+ void SetPyInit( in string InitName ,
+ in SUPERV::ListOfStrings aPyInitFunction ) ;
+/*! Returns Python Init function of the Loop Node.
+*/
SUPERV::ListOfStrings PyInit() ;
+/*! Returns the name of the Python Init function of the Loop Node.
+*/
string PyInitName() ;
+/*! Sets Python More function of the Loop Node.
+\param MoreName Name of the More function
+\param aPyMoreFunction Python More function
+*/
void SetPyMore( in string MoreName ,
in SUPERV::ListOfStrings aPyMoreFunction ) ;
+/*! Returns Python More function of the Loop Node.
+*/
SUPERV::ListOfStrings PyMore() ;
+/*! Returns the name of the Python More function of the Loop Node.
+*/
string PyMoreName() ;
+/*! Sets Python Next function of the Loop Node.
+\param NextName Name of the Next function
+\param aPy NextFunction Python Next function
+*/
void SetPyNext( in string NextName ,
in SUPERV::ListOfStrings aPyNextFunction ) ;
+
+/*! Returns Python Next function of the Loop Node.
+*/
SUPERV::ListOfStrings PyNext() ;
+/*! Returns the name of the Python Next function of the Loop Node.
+*/
string PyNextName() ;
} ;
/*! \brief Interface of a graph
This interface includes a set of methods used for management of the graphs in %SUPERVISION module.
-*/
+*/
///////////////
interface Graph : INode {
///////////////
- // Create a Computing Node in a Graph
+ /*! Creates a Computing Node in a Graph.
+ */
SUPERV::CNode CNode( in SALOME_ModuleCatalog::Service aService ) ;
- // Create a Factory Node in a Graph
+ /*! Creates a Factory Node in a Graph.
+ */
SUPERV::FNode FNode( in string aComponentName ,
in string anInterfaceName ,
in SALOME_ModuleCatalog::Service aService ) ;
- // Create an InLine Node in a Graph
+ /*! Creates an InLine Node in a Graph.
+ */
SUPERV::INode INode( in string FuncName , in ListOfStrings aPythonFunction ) ;
- // Create a GOTO node and link to the corresponding InLine node
+ /*! Creates a GOTO Node and links it to the corresponding InLine node.
+ */
SUPERV::GNode GNode( in string FuncName , in ListOfStrings aPythonFunction ,
in string anINode ) ;
- // Create a "for" or "while" node and the corresponding end of loop node
+ /*! Creates a Loop Node ("for" or "while" loop) and links it to the corresponding end of loop node.
+ */
SUPERV::LNode LNode( in string InitName , in ListOfStrings InitFunction ,
in string MoreName , in ListOfStrings MoreFunction ,
in string NextName , in ListOfStrings NextFunction ,
out SUPERV::INode anEndOfLoop ) ;
- // Create a "if/elseif/else" or "switch" node and the corresponding end node
+ /*! Creates a conditional "if/elseif/else" or "switch" node and the corresponding end node
+ */
SUPERV::SNode SNode( in string FuncName , in ListOfStrings aPythonFunction ,
out SUPERV::INode anEndOfSwitch ) ;
- // Create a CORBA Component Object Reference
+ /*! Returns an existing node with a definite name.
+ \param aNodeName Name of the Node.
+ */
+ SUPERV::CNode Node( in string aNodeName ) ;
+
+ /*! Creates a CORBA Component Object Reference
+ */
Engines::Component ComponentRef( in string aComputerContainer ,
in string aComponentName ) ;
SUPERV::Link Link( in SUPERV::Port OutputPort ,
in SUPERV::Port InputPort ) ;
-/*!
+/*!
Imports a graph into a file with XML format
+\param anXmlFile String parameter defining the name of the XML file.
+\return True, if the graph has been successfully imported.
*/
boolean Import( in string anXmlFile ) ;
-/*!
+/*!
Exports a graph from a file with XML format
+\param anXmlFile String parameter defining the name of the XML file.
+\return True, if the graph has been successfully imported.
*/
boolean Export( in string anXmlFile ) ;
/*!
*/
boolean Run() ;
-/*!
+/*!
Assigns to the %Node an %Event and a %State of the %Node, if the Event is
available. And returns immediately Nil, NoEvent and NoState if not.
Returns false if the graph is finished, suspended, killed or stopped.
boolean EventNoW( out SUPERV::CNode aNode , out SUPERV::GraphEvent anEvent ,
out SUPERV::GraphState aState ) ;
-/*!
+/*!
Assigns to the %Node an %Event and a %State of the %Node, if the Event is
- available. Waits if it is not available at the current moment.
+ available. Waits if it is not available at the current moment.
Returns false if the graph is finished, suspended, killed or stopped.
\param aNode %Node for which this method is called
\param anEvent An operation, which has been performed on this node(graph).
// Same as Event but execution of the thread is suspended between the
// return of EventW and the next call to EventW
-/*!
+/*!
Assigns to the %Node an %Event and a %State of the %Node, if the Event is
available. And returns immediately Nil, NoEvent and NoState if not.
Returns false if the graph is finished, suspended, killed or stopped.
-\note <BR>Execution of the thread is suspended between the return of this
+\note <BR>Execution of the thread is suspended between the return of this
method and its next usage.
\param aNode %Node for which this method is called
\param anEvent An operation, which has been performed on this node(graph).
*/
boolean EventW( out SUPERV::CNode aNode , out SUPERV::GraphEvent anEvent ,
out SUPERV::GraphState aState ) ;
+/*! \name Methods used for inner debugging purposes of threads management :
+*/
+/*@{*/
+ long EventQSize() ;
long LevelMax() ;
SUPERV::ListOfNodes LevelNodes( in long aLevel ) ;
long ThreadsMax() ;
+
+/*@}*/
+
/*!
Returns the number of independent subgraphs
*/
long SuspendedThreads();
/*!
Returns True if the graph is valid.
-*/
+*/
boolean IsValid() ;
/*!
Returns True if the graph can be executed.
-*/
+*/
boolean IsExecutable() ;
/*!
Returns True if the graph represents a working algorithm.
-*/
+*/
boolean IsDataFlow() ;
/*!
-Returns True if the graph is being currently edited.
+Returns True if the graph is being currently edited.
*/
boolean IsEditing() ;
/*!
-Returns True if the graph is being currently executed.
+Returns True if the graph is being currently executed.
*/
boolean IsExecuting() ;
/*! \brief Interface of the %link
-This interface contains a set of methods used for representation and management of the links
+This interface contains a set of methods used for representation and management of the links
connecting nodes in a %graph.
-*/
+*/
//////////////
interface Link : Engines::Component {
// For GUI :
/*! \name Methods used for representation of links in GUI of %SALOME application :
*/
-/*@{*/
+/*@{*/
/*!
Returns the number of coordinate points which are included in the link.
-\note <BR>Every link can contain a set of coordinate points which constitute it. These points have
-index numbers (beginning from 1) and coordinates defining their position in the window. Indexing of
+\note <BR>Every link can contain a set of coordinate points which constitute it. These points have
+index numbers (beginning from 1) and coordinates defining their position in the window. Indexing of
the points starts from input port to output port of the corresponding link.
*/
long CoordsSize() ;
/*!
Adds a coordinate point to the link.
-\param index Index of the point.
+\param index Index of the point.
\param X Coordinates of the point.
\param Y Coordinates of the point.
*/
boolean AddCoord( in long index , in long X , in long Y ) ;
/*!
Changes the location of a definite coordinate point of the link.
-\param index Index of the point.
+\param index Index of the point.
\param X Coordinates of the point.
\param Y Coordinates of the point.
*/
boolean ChangeCoord( in long index , in long X , in long Y ) ;
/*!
Removes a coordinate point of the link.
-\param index Index of the point.
+\param index Index of the point.
*/
boolean RemoveCoord( in long index ) ;
/*!
Sets the location of a coordinate point of the link.
-\param index Index of the point.
+\param index Index of the point.
\param X Coordinates of the point.
\param Y Coordinates of the point.
*/
boolean Coords( in long index , out long X , out long Y ) ;
-/*@}*/
+/*@}*/
// void Destroy() ;
Returns True if the value represents an IOR.
*/
boolean IsIOR() ;
-/*!
+/*!
Gets data type of the component.
*/
string ComponentDataType() ;
//////////////
/*!
- Gives a value to an Input %Port
+ Gives a value to an Input %Port
+\param aValue This parameter defines the input value
*/
boolean Input( in SUPERV::Value aValue ) ;
-/*!
+/*!
Returns the node of the port
*/
SUPERV::CNode Node() ;
-/*!
+/*!
Sets the name of the port.
*/
string Name() ;
- // Type of a Port
+/* Gets the type of a port.
+\return A string defining the type of a port
+*/
+
string Type() ;
// Link of an Input Port
-/*!
+/*!
Returns the link of an %Input %Port
*/
SUPERV::Link Link() ;
*/
SUPERV::ListOfLinks Links() ;
-/*!
+/*!
Returns True if this port appears to be an %Input %Port of a Node
*/
boolean IsInput() ;
-/*!
+/*!
Returns True if an %Input %Value exists for that %Input %Port (without link)
*/
boolean HasInput() ;
-/*!
+/*!
Returns True if the %Port is linked (without value)
*/
// Port with link (without Value)
boolean IsLinked() ;
// Kind of a Port
+/*! Returns the type of this port.
+*/
SUPERV::KindOfPort Kind() ;
// Port from the service of the node
-/*!
-Returns True if the %Port is a parameter of a service
+/*!
+Returns True if the %Port is a parameter of a service
*/
boolean IsParam() ;
// Port is a Gate of the node
-/*!
-Returns True if the %Port appears to be a GatePort of the node
+/*!
+Returns True if the %Port appears to be a Gate Port of the Node
*/
boolean IsGate() ;
// Port is a parameter of an InLineNode
+/*!
+Returns True if the %Port appears to be a parameter of an InLine Node.
+*/
boolean IsInLine() ;
+
// Port is a LoopParameter (InitLoop or DoLoop) of an LoopNode
+/*!
+Returns True if the %Port appears to be a Loop Parameter (InitLoop or DoLoop) of a Loop Node
+*/
boolean IsLoop() ;
// Port is an output parameter of a SwitchNode connected to an InGate
-/*!
-Returns True if the %Port appears to be a parameter of a switch node
+/*!
+Returns True if the %Port appears to be a parameter of a switch node
*/
// Port is a parameter of a switch node
boolean IsSwitch() ;
// Port is an Input parameter of a EndSwitchNode connected to several output ports
+/*!
+Returns True if the %Port appears to be an EndSwitch Node connected to several output ports.
+*/
boolean IsEndSwitch() ;
+/*! Returns the current state of the graph.
+*/
SUPERV::GraphState State() ;
+/*! Returns True if calculation is finished.
+*/
boolean IsDone() ;
} ;
return t;
}
+inline char * my_strblkdup( const char * s ) {
+ if (s == NULL) return NULL ;
+
+ size_t l = strlen(s) + 1 ;
+ int i ;
+ for ( i = l - 2 ; i >= 0 ; i-- ) {
+ if ( s[i] != ' ' ) {
+ break ;
+ }
+ l = l - 1 ;
+ }
+ char * t = new char[l] ;
+ strncpy(t, s , l-1) ;
+ t[l-1] = '\0' ;
+ return t;
+}
+
enum StatusOfPort { NotConnected , PortConnected , PortAndDataConnected ,
DataConnected } ;
static void InitFields( SUPERV::KindOfNode &_Kind ,
SUPERV::SDate &_FirstCreation ,
SUPERV::SDate &_LastModification ,
- char * &_EditorRelease ,
- char * &_Author ,
- char * &_Comment ,
- bool &_HeadNode ,
- bool &_GeneratedName ,
- int &_ConnectedInPortsNumber ,
- int &_DecrConnectedInPortsNumber,
- int &_LinkedNodesSize ,
- int &_SubGraphNumber ) {
+ char * &_EditorRelease ,
+ char * &_Author ,
+ char * &_Comment ,
+ bool &_HeadNode ,
+ bool &_GeneratedName ,
+ int &_ConnectedInPortsNumber ,
+ int &_DecrConnectedInPortsNumber,
+ int &_LinkedNodesSize ,
+ int &_SubGraphNumber ) {
time_t T = time(NULL);
struct tm * Tm = localtime(&T);
RetVal = true ;
}
else if ( thePort ) {
+// cout << "GraphBase::ComputingNode::HasInput theInPort " << thePort << " " << thePort->PortName() << " of "
+// << thePort->NodeName() << " IsDataConnected " << thePort->IsDataConnected() << " OutPort "
+// << thePort->GetOutPort() << endl ;
RetVal = thePort->IsDataConnected() ;
}
else {
QDomElement PyFunction = Graph.createElement("PyFunction") ;
PyFunctionlist.appendChild( PyFunction ) ;
int j ;
- for ( j = 0 ; j < (int ) (*PythonFunctions[i]).length() ; j++ ) {
- if ( j == 0 ) {
-// if ( i == 0 ) {
-// f << Tabs << " <FuncName>" << FuncNames[i].c_str()
-// << "</FuncName>" << endl ;
- QDomElement FuncName = Graph.createElement("FuncName") ;
- if ( strlen( FuncNames[i].c_str() ) ) {
- aField = Graph.createTextNode( FuncNames[i].c_str() ) ;
- }
- else {
- aField = Graph.createTextNode( "?" ) ;
- }
- PyFunction.appendChild( FuncName ) ;
- FuncName.appendChild( aField ) ;
-// }
-// else if ( i == 1 ) {
-// f << Tabs << " <FuncName>" << FuncNames[i].c_str()
-// << "</FuncName>" << endl ;
-// }
-// else if ( i == 2 ) {
-// f << Tabs << " <FuncName>" << FuncNames[i].c_str()
-// << "</FuncName>" << endl ;
-// }
- }
-// f << Tabs << " <PyFunc>" << (*PythonFunctions[i])[j]
-// << "</PyFunc>" << endl ;
- QDomElement PyFunc = Graph.createElement("PyFunc") ;
- QDomCDATASection aCDATA ;
+ QDomElement FuncName = Graph.createElement("FuncName") ;
+ if ( strlen( FuncNames[i].c_str() ) ) {
+ aField = Graph.createTextNode( FuncNames[i].c_str() ) ;
+ }
+ else {
+ aField = Graph.createTextNode( "?" ) ;
+ }
+ PyFunction.appendChild( FuncName ) ;
+ FuncName.appendChild( aField ) ;
+ if ( (*PythonFunctions[i]).length() ) {
+ for ( j = 0 ; j < (int ) (*PythonFunctions[i]).length() ; j++ ) {
+ QDomElement PyFunc = Graph.createElement("PyFunc") ;
+ QDomCDATASection aCDATA ;
// mpv: Linux 8.0 compiler compatibility
-// char * aCDATAChar = (char *) (*PythonFunctions[i])[j] ;
- char * aCDATAChar = strdup ((*PythonFunctions[i])[j]) ;
- int i ;
- for ( i = 0 ; i < (int ) strlen( aCDATAChar ) ; i++ ) {
- if ( aCDATAChar[ i ] != ' ' ) {
- break ;
- }
- }
- if ( i == (int ) strlen( aCDATAChar ) ) {
- aCDATA = Graph.createCDATASection( "?" ) ;
- }
- else {
- aCDATA = Graph.createCDATASection( aCDATAChar ) ;
+ char * aCDATAChar = strdup ((*PythonFunctions[i])[j]) ;
+ int i ;
+ for ( i = 0 ; i < (int ) strlen( aCDATAChar ) ; i++ ) {
+ if ( aCDATAChar[ i ] != ' ' ) {
+ break ;
+ }
+ }
+ if ( i == (int ) strlen( aCDATAChar ) ) {
+ aCDATA = Graph.createCDATASection( "?" ) ;
+ }
+ else {
+ aCDATA = Graph.createCDATASection( aCDATAChar ) ;
+ }
+ PyFunction.appendChild( PyFunc ) ;
+ PyFunc.appendChild( aCDATA ) ;
}
+ }
+ else {
+ QDomElement PyFunc = Graph.createElement("PyFunc") ;
+ QDomCDATASection aCDATA = Graph.createCDATASection( "?" ) ;
PyFunction.appendChild( PyFunc ) ;
PyFunc.appendChild( aCDATA ) ;
}
-// f << Tabs << " </PyFunction>" << endl ;
}
-// f << Tabs << "</PyFunction-list>" << endl ;
// f << Tabs << "<creation-date>" << FirstCreation() << "</creation-date>"
// << endl ;
f << EndName << ".SetComment( '" << aCoupledNode->Comment() << "' )" << endl ;
f << EndName << ".Coords( " << aCoupledNode->XCoordinate() << " , "
<< aCoupledNode->YCoordinate() << " )" << endl ;
+ SUPERV::ListOfStrings aPyFunc = *aCoupledNode->PythonFunction() ;
+ f << "Py" << aCoupledNode->Name() << " = []" << endl ;
+ for ( i = 0 ; i < (int ) aPyFunc.length() ; i++ ) {
+ f << "Py" << aCoupledNode->Name() << ".append( '" << aPyFunc[i] << "' )"
+ << endl ;
+ }
+ f << EndName << ".SetPyFunction( 'End" << FuncNames[0].c_str() << "' , Py" << aCoupledNode->Name() << " )" << endl ;
}
else if ( IsSwitchNode() ) {
f << Name() << "," << EndName << " = " << aGraphName << ".SNode( '"
}
}
// RetVal = aNode->RemoveLinks() ; // In PortsOfNode
+// if ( RetVal ) {
+// if ( aNode->IsLoopNode() || aNode->IsEndLoopNode() || aNode->IsSwitchNode() || aNode->IsEndSwitchNode() ) {
+// GraphBase::InLineNode * anInLineNode = ((GraphBase::GOTONode * ) aNode)->CoupledNode() ;
+// if ( anInLineNode ) {
+// RetVal = RemoveNode( anInLineNode->Name() ) ;
+// }
+// }
+// }
if ( RetVal ) {
delete aNode ;
_GraphNodesSize -= 1 ;
RetVal = true ;
}
}
- else
+ else {
cdebug << "Node not found" << endl ;
+ }
cdebug_out << "GraphBase::Graph::RemoveNode" << endl;
return RetVal ;
}
-bool GraphBase::Graph::AddLink(
- const char* FromNodeName ,
- const char* FromServiceParameterName ,
- const char* ToNodeName ,
- const char* ToServiceParameterName ,
- const CORBA::Any aValue ) {
+bool GraphBase::Graph::AddLink( const char* FromNodeName ,
+ const char* FromServiceParameterName ,
+ const char* ToNodeName ,
+ const char* ToServiceParameterName ,
+ const CORBA::Any aValue ) {
bool RetVal ;
// int index ;
cdebug_in << "GraphBase::Graph::AddLink(" << FromNodeName << "("
return RetVal ;
}
-bool GraphBase::Graph::AddLink(
- GraphBase::ComputingNode *fromNode ,
- GraphBase::OutPort *fromPort ,
- GraphBase::ComputingNode *toNode ,
- GraphBase::InPort *toPort ) {
+bool GraphBase::Graph::AddLink( GraphBase::ComputingNode *fromNode ,
+ GraphBase::OutPort *fromPort ,
+ GraphBase::ComputingNode *toNode ,
+ GraphBase::InPort *toPort ) {
// bool RetVal ;
if ( !fromNode ) {
}
}
}
- else if ( !toNode->IsEndSwitchNode() ) {
+ else if ( !toNode->IsEndSwitchNode() ||
+ ( toNode->IsEndSwitchNode() && toPort->IsGate() ) ) {
if ( !RemoveLink( fromNode->Name() , fromPort->PortName() ,
toNode->Name() , toPort->PortName() ) ) {
cdebug << "RemoveLink(AddLink) toNode->IsEndSwitchNode Error." << endl ;
fromNode->AddLink( toNode ) ;
}
if ( fromNode->IsSwitchNode() ) {
- if ( fromPort->IsInLine() && toPort->IsGate() ) {
+ if ( fromPort->IsInLine() && toPort->IsGate() && !toNode->IsEndSwitchNode() ) {
fromPort->Kind( SUPERV::SwitchParameter ) ;
}
else if ( !fromPort->IsGate() && !toPort->IsGate() ){
if ( fromPort->IsGate() && !toNode->IsEndSwitchNode() ) {
GraphBase::InLineNode * anEndSwitchNode ;
anEndSwitchNode = ((GraphBase::SwitchNode * ) fromNode)->CoupledNode() ;
- GraphBase::InPort * anInPort = anEndSwitchNode->GetChangeNodeInPort(0) ;
+ GraphBase::InPort * anInPort = anEndSwitchNode->GetChangeNodeInGate() ;
GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
if ( anOutPort && !strcmp( fromNode->Name() , anOutPort->NodeName() ) &&
!strcmp( fromPort->PortName() , anOutPort->PortName() ) &&
anOutPort->IsGate() ) {
if ( !RemoveLink( fromNode->Name() , anOutPort->PortName() ,
anEndSwitchNode->Name() ,
- anEndSwitchNode->GetChangeNodeInPort(0)->PortName() ) ) {
+ anInPort->PortName() ) ) {
cdebug << "AddLink Error Removelink ( Switch , Default , EndSwitch , Default )"
<< endl ;
cdebug_out << "GraphBase::Graph::AddLink" << endl;
if ( fromNode ) {
fromNode->RemoveLink( toNode ) ;
}
- if ( fromNode->IsSwitchNode() ) {
+ if ( fromNode->IsSwitchNode() && !anOutPort->IsGate() && !toNode->IsEndSwitchNode() ) {
anOutPort->Kind( SUPERV::InLineParameter ) ;
}
#if 0
if ( _NodesNumber.size() )
_NodesNumber.resize( 0 ) ;
_SortedNodes.resize( 0 ) ;
+
for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
_Sorted[ i ] = false ;
_CnxInPortsNumber[ i ] = GraphNodes( i )->ConnectedInPortsNumber() ;
_DecrInPortsNumber[ i ] = 0 ;
}
+
while ( NotSortedNumber ) {
NewSorted = false ;
+
for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
cdebug << "Sort level " << _LevelsNumber << ". [" << i << "] "
<< GraphNodes( i )->Name() << " count "
<< _CnxInPortsNumber[ i ] << endl ;
if ( !_Sorted[ i ] && _CnxInPortsNumber[ i ] == 0 ) {
// All inputs of GraphNodes( i ) are available
- if ( (int ) _NodesNumber.size() != _LevelsNumber+1 ) {
+ if ( (int ) _NodesNumber.size() != _LevelsNumber+1 ) {
_NodesNumber.resize( _LevelsNumber+1 ) ;
_SortedNodes.resize( _LevelsNumber+1 ) ;
_NodesNumber[ _LevelsNumber ] = -1 ;
}
- _NodesNumber[ _LevelsNumber ]++ ;
+ _NodesNumber[ _LevelsNumber ]++ ;
(_SortedNodes[ _LevelsNumber ]).resize( _NodesNumber[ _LevelsNumber ]+1 ) ;
(_SortedNodes[ _LevelsNumber ])[ _NodesNumber[ _LevelsNumber ] ] = GraphNodes( i ) ;
_Sorted[ i ] = true ;
NewSorted = true ;
cdebug << GraphNodes( i )->Name() << " belongs to level "
<< _LevelsNumber << "." << endl ;
- for ( j = 0 ; j < GraphNodes( i )->LinkedNodesSize() ; j++ ) {
+ for ( j = 0 ; j < GraphNodes( i )->LinkedNodesSize() ; j++ ) {
// Outputs of GraphNodes( i ) will satisfy
// GraphNodes( i )->LinkedInPortsNumber( j ) InPorts of
// GraphNodes( i )->LinkedNodes( j )
}
if ( !NewSorted ) {
cdebug << "Loop detected level " << _LevelsNumber << endl ;
- return false ; // Loop in the Graph
+ return false ; // Loop in the Graph
}
cdebug << "Bilan level " << _LevelsNumber << " : " << endl ;
bool ChangeCount = false ;
<< " --> new count " << _CnxInPortsNumber[ i ] << endl ;
}
}
+
if ( !ChangeCount )
break ;
_LevelsNumber += 1 ;
(_SortedNodes[ 0 ])[ i ]->Level( 0 ) ;
(_SortedNodes[ 0 ])[ i ]->SubGraph( i + 1 ) ;
}
+
for ( i = 1 ; i <= _LevelsNumber ; i++ ) {
for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) {
(_SortedNodes[ i ])[ j ]->Level( i ) ;
(_SortedNodes[ i ])[ j ]->SubGraph( 0 ) ;
}
}
+
bool Graphs = true ;
while ( Graphs ) {
for ( i = 0 ; i <= _LevelsNumber ; i++ ) {
for ( j = 0 ; j <= _NodesNumber[ i ] ; j++ ) {
GraphBase::ComputingNode * aNode = (_SortedNodes[ i ])[ j ] ;
- cdebug << "Graph " << aNode->SubGraph() << " " << aNode->Name()
+ cdebug << "Graph " << aNode->SubGraph() << " " << aNode->Name()
<< endl ;
int k ;
for ( k = 0 ; k < aNode->LinkedNodesSize() ; k++ ) {
- if ( aNode->LinkedNodes( k )->SubGraph() ) {
+ if ( aNode->LinkedNodes( k )->SubGraph() ) {
if ( aNode->LinkedNodes( k )->SubGraph() != aNode->SubGraph() &&
aNode->LinkedNodes( k )->Level() == aNode->Level()+1 ) {
- aNode->SubGraph( aNode->LinkedNodes( k )->SubGraph() ) ;
- cdebug << " Linked " << aNode->LinkedNodes( k )->Name()
+ aNode->SubGraph( aNode->LinkedNodes( k )->SubGraph() ) ;
+ cdebug << " Linked " << aNode->LinkedNodes( k )->Name()
<< " Graph(" << aNode->LinkedNodes( k )->SubGraph()
<< ") ==>" << endl ;
cdebug << " Graph " << aNode->SubGraph() << " for "
X , Y ,
Graph_prof_debug , Graph_fdebug ) {
_PythonFunction = SUPERV::ListOfStrings() ;
+ _MyPyRunMethod = NULL ;
cdebug_in << "GraphBase::InLineNode::Node " << this
<< "' _Name "
<< (void *) Name() << " '" << Name() << " _Comment "
<< ServiceInParameter().length()
<< ") Out(" << ServiceOutParameter().length() << ")" << endl ;
+ _MyPyRunMethod = NULL ;
SetPythonFunction( FuncName , aPythonFunction ) ;
SALOME_ModuleCatalog::Service aNodeService ;
aNodeService.ServiceName = NodeName ;
if ( aPythonFunction.length() == 1 ) {
cdebug << " aPythonFunction[ 0 ] '" << aPythonFunction[ 0 ] << "'" ;
}
- cdebug << endl ;
- _FuncName = my_strdup( FuncName ) ;
+ cdebug << " FuncName " << FuncName << endl ;
+ _FuncName = my_strblkdup( FuncName ) ;
+ cdebug << "GraphBase::InLineNode::SetPythonFunction FuncName '" << FuncName << "' --> '"
+ << _FuncName << "'" << endl ;
if ( ( aPythonFunction.length() == 0 ) ||
( aPythonFunction.length() == 1 && strlen( aPythonFunction[ 0 ] ) == 0 ) ) {
_PythonFunction.length( 0 ) ;
void PyRunMethod( PyObject * MyPyRunMethod ) {
_MyPyRunMethod = MyPyRunMethod ; } ;
PyObject * PyRunMethod() {
- return _MyPyRunMethod ;
- }
+ return _MyPyRunMethod ; } ;
// bool SaveXML( ostream &f , char *Tabs ,
<< ServiceInParameter().length()
<< ") Out(" << ServiceOutParameter().length() << ")" << endl ;
- cdebug << "GraphBase::LoopNode::LoopNode SetMorePythonFunction " << MoreName << " "
- << aMorePythonFunction[0] << endl ;
+ _MyPyMoreMethod = NULL ;
+ _MyPyNextMethod = NULL ;
+
+ cdebug << "GraphBase::LoopNode::LoopNode SetMorePythonFunction " << MoreName << " " ;
+ if ( aMorePythonFunction.length() ) {
+ cdebug << aMorePythonFunction[0] ;
+ }
+ cdebug << endl ;
SetMorePythonFunction( MoreName , aMorePythonFunction ) ;
- cdebug << "GraphBase::LoopNode::LoopNode SetNextPythonFunction " << NextName << " "
- << aNextPythonFunction[0] << endl ;
+ cdebug << "GraphBase::LoopNode::LoopNode SetNextPythonFunction " << NextName << " " ;
+ if ( aNextPythonFunction.length() ) {
+ cdebug << aNextPythonFunction[0] ;
+ }
+ cdebug << endl ;
SetNextPythonFunction( NextName , aNextPythonFunction ) ;
cdebug_out << "GraphBase::LoopNode::LoopNode" << endl;
void SetMorePythonFunction( const char * MoreName ,
const SUPERV::ListOfStrings & aMorePythonFunction ) {
- _MoreName = my_strdup( MoreName ) ;
- _MorePythonFunction = new SUPERV::ListOfStrings( aMorePythonFunction ) ; }
+ _MoreName = my_strblkdup( MoreName ) ;
+ cdebug << "GraphBase::LoopNode::SetMorePythonFunction MoreName '" << MoreName << "' --> '"
+ << _MoreName << "'" << endl ;
+ _MorePythonFunction = new SUPERV::ListOfStrings( aMorePythonFunction ) ; } ;
+
SUPERV::ListOfStrings * MorePythonFunction() const {
SUPERV::ListOfStrings * aMorePythonFunction ;
aMorePythonFunction = new SUPERV::ListOfStrings( *_MorePythonFunction ) ;
return aMorePythonFunction ; } ;
+
char * PyMoreName() {
return my_strdup( _MoreName ) ; } ;
+
void PyMoreMethod( PyObject * MyPyMoreMethod ) {
_MyPyMoreMethod = MyPyMoreMethod ; } ;
+
PyObject * PyMoreMethod() {
- return _MyPyMoreMethod ;
- }
+ return _MyPyMoreMethod ; } ;
void SetNextPythonFunction( const char * NextName ,
const SUPERV::ListOfStrings & aNextPythonFunction ) {
- _NextName = my_strdup( NextName ) ;
- _NextPythonFunction = new SUPERV::ListOfStrings( aNextPythonFunction ) ; }
+ _NextName = my_strblkdup( NextName ) ;
+ cdebug << "GraphBase::LoopNode::SetNextPythonFunction NextName '" << NextName << "' --> '"
+ << _NextName << "'" << endl ;
+ _NextPythonFunction = new SUPERV::ListOfStrings( aNextPythonFunction ) ; } ;
+
SUPERV::ListOfStrings * NextPythonFunction() const {
SUPERV::ListOfStrings * aNextPythonFunction ;
aNextPythonFunction = new SUPERV::ListOfStrings( *_NextPythonFunction ) ;
return aNextPythonFunction ; } ;
+
char * PyNextName() {
return my_strdup( _NextName ) ; } ;
void PyNextMethod( PyObject * MyPyNextMethod ) {
_MyPyNextMethod = MyPyNextMethod ; } ;
+
PyObject * PyNextMethod() {
- return _MyPyNextMethod ;
- }
+ return _MyPyNextMethod ; } ;
// bool SaveXML(ostream &f , char *Tabs , int X , int Y ) ;
bool SaveXML(QDomDocument & Graph , QDomElement & info , int X , int Y ) ;
{
f << P.PortName() << ", "
<< "type : " << P.PortType() << ", " ;
-
- f << "from "
- << P.NodeName() << ", ";
+ f << "kind "
+ << P.Kind() << ", ";
+ f << "from "
+ << P.NodeName() << ", ";
return f;
}
public:
ServicesParameter() {
- cout << "ServicesParameter()" << endl ;
+ //cout << "ServicesParameter()" << endl ;
_ServicesParameter.Parametername = (char *) NULL ;
_ServicesParameter.Parametertype = (char *) NULL ;
} ;
dataflowxml = TRUE;
}
if ( dataflowxml ) {
- fieldname[depth++] = (const char * ) qName ;
+// fieldname[depth++] = (const char * ) qName ;
+ fieldname[depth++] = qName.latin1() ;
}
if ( depth == maxlevel+1 )
return false ;
if ( depth < 0 || fieldvalue[depth] != NULLSTRING )
return returnfalse( this , "characters " , ch ) ;
- fieldvalue[depth] = (const char * ) ch ;
+// fieldvalue[depth] = (const char * ) ch ;
+ fieldvalue[depth] = ch.latin1() ;
return TRUE;
}
BIN_SERVER_IDL =
CPPFLAGS+= $(PYTHON_INCLUDES) $(QT_MT_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) \
- -I${KERNEL_ROOT_DIR}/include/salome
-CXXFLAGS= -g -D_DEBUG_ -D__x86__ -D__linux__ -ftemplate-depth-42 \
- -I${KERNEL_ROOT_DIR}/include/salome
-#LDFLAGS= -L../../../lib $(CORBA_LIBS) -lomniORB3 -ltcpwrapGK -lomniDynamic3 -lomnithread -lCOS3 -lCOSDynamic3 -lSalomeNS -lSalomeLifeCycleCORBA -lOpUtil -lSalomeLoggerServer -lc $(PYTHON_LIBS) $(QT_MT_LIBS) $(OGL_LIBS)
-LDFLAGS= $(CORBA_LIBS) -lomniORB3 -ltcpwrapGK -lomniDynamic3 -lomnithread -lCOS3 \
- -lCOSDynamic3 -lSalomeNS -lSalomeLifeCycleCORBA -lOpUtil -lSALOMELocalTrace \
- -lc $(QT_MT_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome
-
-LIBS += -L../../lib/salome
+ -I${KERNEL_ROOT_DIR}/include/salome
+#CXXFLAGS= -g -D_DEBUG_ -D__x86__ -D__linux__ -ftemplate-depth-42
+CXXFLAGS= -g -D_DEBUG_ -D__x86__ -D__linux__ -ftemplate-depth-42 -Wall \
+ -I${KERNEL_ROOT_DIR}/include/salome
+LDFLAGS= -L../../lib/salome $(CORBA_LIBS) -lSalomeNS -lSalomeLifeCycleCORBA -lOpUtil -lSalomeLoggerServer \
+ -lc $(PYTHON_LIBS) $(QT_MT_LIBS) $(OGL_LIBS) \
+ -L${KERNEL_ROOT_DIR}/lib/salome
+#LDFLAGS= -L../../../lib $(CORBA_LIBS) -lomniORB4 -lomniDynamic4 -lomnithread -lCOS4 -lCOSDynamic4 -lSalomeNS -lSalomeLifeCycleCORBA -lOpUtil -lSalomeLoggerServer -lc $(QT_MT_LIBS)
@CONCLUDE@
-
-
SALOME_LifeCycleCORBA LCC( NamingService ) ;
objComponent = LCC.FindOrLoad_Component( "FactoryServer" , "AddComponent" );
if ( CORBA::is_nil( objComponent ) ) {
- cout << " LCC.FindOrLoad_Component( FactoryServer , AddComponent )" << endl;
+ //cout << " LCC.FindOrLoad_Component( FactoryServer , AddComponent )" << endl;
return 0 ;
}
*anAny <<= objComponent ;
IOR = orb->object_to_string( objComponent );
- cout << "objComponent " << objComponent << " IOR " << IOR << " nil " << CORBA::is_nil( objComponent )
- << endl ;
+ //cout << "objComponent " << objComponent << " IOR " << IOR << " nil " << CORBA::is_nil( objComponent )
+ // << endl ;
*anAny >>= obj ;
IOR = orb->object_to_string( obj );
- cout << "obj " << obj << " IOR " << IOR << " nil " << CORBA::is_nil( obj )
- << endl ;
+ //cout << "obj " << obj << " IOR " << IOR << " nil " << CORBA::is_nil( obj )
+ // << endl ;
return 0;
}
const int nXY ,
const int* X ,
const int* Y ) {
- GraphBase::InPort * aLink = GraphBase::Graph::GetChangeInPort( ToNodeName ,
- ToServiceParameterName ) ;
- if ( aLink ) {
- if ( aLink->IsSwitch() ) {
+ GraphBase::InPort * anInPort = GraphBase::Graph::GetChangeInPort( ToNodeName ,
+ ToServiceParameterName ) ;
+// cdebug << "GraphEditor::OutNode::AddLinkCoord " << ToNodeName << "( " << ToServiceParameterName
+// << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
+ if ( anInPort ) {
+ if ( anInPort->IsEndSwitch() ) {
+// cdebug << "GraphEditor::OutNode::AddLinkCoord " << FromNodeName << "( " << FromServiceParameterName
+// << " )" << endl ;
return GraphBase::Graph::GetChangeOutPort( FromNodeName , FromServiceParameterName )->AddCoord( nXY , X , Y ) ;
}
else {
- return aLink->AddCoord( nXY , X , Y ) ;
+ return anInPort->AddCoord( nXY , X , Y ) ;
}
}
return false ;
const int index ,
const int X ,
const int Y ) {
- GraphBase::InPort * aLink = GraphBase::Graph::GetChangeInPort( ToNodeName ,
- ToServiceParameterName ) ;
- if ( aLink ) {
- if ( aLink->IsSwitch() ) {
+ GraphBase::InPort * anInPort = GraphBase::Graph::GetChangeInPort( ToNodeName ,
+ ToServiceParameterName ) ;
+// cdebug << "GraphEditor::OutNode::AddLinkCoord " << ToNodeName << "( " << ToServiceParameterName
+// << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
+ if ( anInPort ) {
+ if ( anInPort->IsEndSwitch() ) {
+// cdebug << "GraphEditor::OutNode::AddLinkCoord " << FromNodeName << "( " << FromServiceParameterName
+// << " )" << endl ;
return GraphBase::Graph::GetChangeOutPort( FromNodeName , FromServiceParameterName )->AddCoord( index , X , Y ) ;
}
else {
- return aLink->AddCoord( index , X , Y ) ;
+ return anInPort->AddCoord( index , X , Y ) ;
}
}
return false ;
}
-bool GraphEditor::OutNode::ChangeLinkCoord(
- const char* FromNodeName ,
- const char* FromServiceParameterName ,
- const char* ToNodeName ,
- const char* ToServiceParameterName ,
- const int index ,
- const int X ,
- const int Y ) {
- GraphBase::InPort * aLink = GraphBase::Graph::GetChangeInPort( ToNodeName ,
+bool GraphEditor::OutNode::ChangeLinkCoord( const char* FromNodeName ,
+ const char* FromServiceParameterName ,
+ const char* ToNodeName ,
+ const char* ToServiceParameterName ,
+ const int index ,
+ const int X ,
+ const int Y ) {
+ GraphBase::InPort * anInPort = GraphBase::Graph::GetChangeInPort( ToNodeName ,
ToServiceParameterName ) ;
- if ( aLink ) {
- if ( aLink->IsSwitch() ) {
+// cdebug << "GraphEditor::OutNode::ChangeLinkCoord " << ToNodeName << "( " << ToServiceParameterName
+// << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
+ if ( anInPort ) {
+ if ( anInPort->IsEndSwitch() ) {
+// cdebug << "GraphEditor::OutNode::ChangeLinkCoord " << FromNodeName << "( " << FromServiceParameterName
+// << " )" << endl ;
return GraphBase::Graph::GetChangeOutPort( FromNodeName , FromServiceParameterName )->ChangeCoord( index , X , Y ) ;
}
else {
- return aLink->ChangeCoord( index , X , Y ) ;
+ return anInPort->ChangeCoord( index , X , Y ) ;
}
}
return false ;
}
-bool GraphEditor::OutNode::RemoveLinkCoord(
- const char* FromNodeName ,
- const char* FromServiceParameterName ,
- const char* ToNodeName ,
- const char* ToServiceParameterName ,
- const int index ) {
- GraphBase::InPort * aLink = GraphBase::Graph::GetChangeInPort( ToNodeName ,
- ToServiceParameterName ) ;
- if ( aLink ) {
- if ( aLink->IsSwitch() ) {
+bool GraphEditor::OutNode::RemoveLinkCoord( const char* FromNodeName ,
+ const char* FromServiceParameterName ,
+ const char* ToNodeName ,
+ const char* ToServiceParameterName ,
+ const int index ) {
+ GraphBase::InPort * anInPort = GraphBase::Graph::GetChangeInPort( ToNodeName ,
+ ToServiceParameterName ) ;
+// cdebug << "GraphEditor::OutNode::RemoveLinkCoord " << ToNodeName << "( " << ToServiceParameterName
+// << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
+ if ( anInPort ) {
+ if ( anInPort->IsEndSwitch() ) {
+// cdebug << "GraphEditor::OutNode::RemoveLinkCoord " << FromNodeName << "( " << FromServiceParameterName
+// << " )" << endl ;
return GraphBase::Graph::GetChangeOutPort( FromNodeName , FromServiceParameterName )->RemoveCoord( index ) ;
}
else {
- return aLink->RemoveCoord( index ) ;
+ return anInPort->RemoveCoord( index ) ;
}
}
return false ;
}
-int GraphEditor::OutNode::GetLinkCoordSize(
- const char* FromNodeName ,
- const char* FromServiceParameterName ,
- const char* ToNodeName ,
- const char* ToServiceParameterName ) {
- const GraphBase::InPort * aLink = GraphBase::Graph::GetInPort( ToNodeName , ToServiceParameterName ) ;
- if ( aLink ) {
- if ( aLink->IsSwitch() ) {
+int GraphEditor::OutNode::GetLinkCoordSize( const char* FromNodeName ,
+ const char* FromServiceParameterName ,
+ const char* ToNodeName ,
+ const char* ToServiceParameterName ) {
+ const GraphBase::InPort * anInPort = GraphBase::Graph::GetInPort( ToNodeName , ToServiceParameterName ) ;
+// cdebug << "GraphEditor::OutNode::GetLinkCoordSize " << ToNodeName << "( " << ToServiceParameterName
+// << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
+ if ( anInPort ) {
+ if ( anInPort->IsEndSwitch() ) {
+// cdebug << "GraphEditor::OutNode::GetLinkCoordSize " << FromNodeName << "( " << FromServiceParameterName
+// << " )" << endl ;
return GraphBase::Graph::GetChangeOutPort( FromNodeName , FromServiceParameterName )->GetCoord() ;
}
else {
- return aLink->GetCoord() ;
+ return anInPort->GetCoord() ;
}
}
return 0 ;
const char* ToNodeName ,
const char* ToServiceParameterName ,
int *X , int *Y ) {
- const GraphBase::InPort * aLink = GraphBase::Graph::GetInPort( ToNodeName , ToServiceParameterName ) ;
- if ( aLink ) {
- if ( aLink->IsSwitch() ) {
+ const GraphBase::InPort * anInPort = GraphBase::Graph::GetInPort( ToNodeName , ToServiceParameterName ) ;
+// cdebug << "GraphEditor::OutNode::GetLinkCoord " << ToNodeName << "( " << ToServiceParameterName
+// << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
+ if ( anInPort ) {
+ if ( anInPort->IsEndSwitch() ) {
+// cdebug << "GraphEditor::OutNode::GetLinkCoord " << FromNodeName << "( " << FromServiceParameterName
+// << " )" << endl ;
return GraphBase::Graph::GetChangeOutPort( FromNodeName , FromServiceParameterName )->GetCoord( X , Y ) ;
}
else {
- return aLink->GetCoord( X , Y ) ;
+ return anInPort->GetCoord( X , Y ) ;
}
}
return false ;
}
-bool GraphEditor::OutNode::GetLinkCoord(
- const char* FromNodeName ,
- const char* FromServiceParameterName ,
- const char* ToNodeName ,
- const char* ToServiceParameterName ,
- const int index , long &X , long &Y ) {
- GraphBase::InPort * aLink = GraphBase::Graph::GetChangeInPort( ToNodeName ,
- ToServiceParameterName ) ;
- if ( aLink ) {
- if ( aLink->IsSwitch() ) {
+bool GraphEditor::OutNode::GetLinkCoord( const char* FromNodeName ,
+ const char* FromServiceParameterName ,
+ const char* ToNodeName ,
+ const char* ToServiceParameterName ,
+ const int index , long &X , long &Y ) {
+ GraphBase::InPort * anInPort = GraphBase::Graph::GetChangeInPort( ToNodeName ,
+ ToServiceParameterName ) ;
+// cdebug << "GraphEditor::OutNode::GetLinkCoord " << ToNodeName << "( " << ToServiceParameterName
+// << " ) " << anInPort << " IsEndSwitch " << anInPort->IsEndSwitch() << endl ;
+ if ( anInPort ) {
+ if ( anInPort->IsEndSwitch() ) {
+// cdebug << "GraphEditor::OutNode::GetLinkCoord " << FromNodeName << "( " << FromServiceParameterName
+// << " )" << endl ;
return GraphBase::Graph::GetChangeOutPort( FromNodeName , FromServiceParameterName )->GetCoord( index , X , Y ) ;
}
else {
- return aLink->GetCoord( index , X , Y ) ;
+ return anInPort->GetCoord( index , X , Y ) ;
}
}
return false ;
_Executable = false ;
CreateService() ;
-
+
if ( !Sort() ) {
cdebug << "This DataFlow is not valid." << endl ;
return false ;
}
-
+
+
// CreateService() ;
InLineServices() ;
ComputingNodes() ;
-
+
_Valid = true ;
cdebug_out << "GraphEditor::OutNode::Valid" << endl;
BIN_SRC =
BIN_SERVER_IDL =
-CPPFLAGS+= $(PYTHON_INCLUDES) $(QT_MT_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome
-CXXFLAGS= -g -D_DEBUG_ -D__x86__ -D__linux__ -ftemplate-depth-42 -I${KERNEL_ROOT_DIR}/include/salome
+CPPFLAGS+= $(PYTHON_INCLUDES) $(QT_MT_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) \
+ -I${KERNEL_ROOT_DIR}/include/salome
+#CXXFLAGS= -g -D_DEBUG_ -D__x86__ -D__linux__ -ftemplate-depth-42 -Wno-deprecated
+CXXFLAGS= -g -D_DEBUG_ -D__x86__ -D__linux__ -ftemplate-depth-42 -Wall \
+ -I${KERNEL_ROOT_DIR}/include/salome
#LDFLAGS+= -lSalomeNS -lSalomeLifeCycleCORBA -lSalomeSuperVisionBase -lSalomeSuperVisionExecutor -lOpUtil -lSalomeLoggerServer -lc $(PYTHON_LIBS) $(QT_MT_LIBS) $(OGL_LIBS)
-LDFLAGS+= -lSalomeNS -lSalomeLifeCycleCORBA -lSalomeSuperVisionBase \
- -lSalomeSuperVisionExecutor -lOpUtil -lSALOMELocalTrace \
- -lc $(QT_MT_LIBS) $(OGL_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome
+LDFLAGS+= -lSalomeNS -lSalomeLifeCycleCORBA -lSalomeSuperVisionBase -lSalomeSuperVisionExecutor -lOpUtil -lSalomeLoggerServer \
+ -lc $(QT_MT_LIBS) $(OGL_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome
@CONCLUDE@
bool EventW( char ** aNodeName ,
SUPERV::GraphEvent & anEvent ,
SUPERV::GraphState & aState ) ;
+ long EventQSize() ;
bool IsWaiting() ;
bool IsReady() ;
SUPERV::GraphState & aState ) {
return GraphExecutor::OutNode::EventW( aNodeName , anEvent , aState ) ;
}
+inline long GraphExecutor::DataFlow::EventQSize() {
+ return GraphExecutor::OutNode::EventQSize() ;
+}
inline SUPERV::GraphState GraphExecutor::DataFlow::State() {
return GraphExecutor::OutNode::State() ;
int n_in = nInParams ;
int n_out = nOutParams ;
- char * aComponent = ObjectToString( objComponent ) ;
- MESSAGE( aComponent << "->" << method ) ;
+// char * aComponent = ObjectToString( objComponent ) ;
+// MESSAGE( aComponent << "->" << method ) ;
for ( i = 0 ; i < n_in ; i++ ) {
CORBA::Any & data = inParams[i].Value ;
ArgName = inParams[i].Name.c_str() ;
Type = data.type()->kind() ;
arguments->add_value( ArgName , data , CORBA::ARG_IN ) ;
-//#if 0
+#if 0
switch ( Type ) {
case CORBA::tk_string : {
char * t ;
}
}
MESSAGE("") ;
-//#endif
+#endif
}
for ( i = 0 ; i < n_out ; i++ ) {
ArgName = outParams[i].Name.c_str() ;
Type = data.type()->kind() ;
arguments->add_value( ArgName , data , CORBA::ARG_OUT ) ;
-//#if 0
+#if 0
switch ( Type ) {
case CORBA::tk_string : {
char * t ;
}
}
MESSAGE("") ;
-//#endif
+#endif
}
req->invoke();
perror( msg ) ;
}
+ pthread_mutex_init( &_MutexPythonWait , NULL ) ;
+ _ExecNumber = 0 ;
+ _GraphExecutingNumber = 0 ;
+ _PyInitModule = false ;
+
// cdebug_out << "FiniteStateMachine::FiniteStateMachine _TransitionTable "
// << endl;
}
pthread_exit( PTHREAD_CANCELED ) ;
}
+int GraphExecutor::FiniteStateMachine::ExecNumber() {
+ PyLock() ;
+ _ExecNumber += 1 ;
+ int RetVal = _ExecNumber ;
+ _GraphExecutingNumber += 1 ;
+ PyUnLock() ;
+ return RetVal ;
+}
+
+void GraphExecutor::FiniteStateMachine::Executed() {
+ PyLock() ;
+ _GraphExecutingNumber -= 1 ;
+ if ( _GraphExecutingNumber == 0 ) {
+ map< string , PyObject * >::iterator aPyFunction ;
+ for ( aPyFunction = _MapOfPyFunctions.begin() ; aPyFunction != _MapOfPyFunctions.end() ; aPyFunction++ ) {
+ if ( !strcmp( aPyFunction->first.c_str() , "PyObjRef" ) ||
+ !strcmp( aPyFunction->first.c_str() , "PyObjIor" ) ) {
+ //cout << "GraphExecutor::FiniteStateMachine::Executed " << aPyFunction->first << " keeped ..."<< endl ;
+ }
+ else {
+ //cout << "GraphExecutor::FiniteStateMachine::Executed " << aPyFunction->first << " erased ..."<< endl ;
+ _MapOfPyFunctions.erase( aPyFunction->first ) ;
+ }
+ }
+ }
+ else {
+ //cout << "GraphExecutor::FiniteStateMachine::Executed _GraphExecutingNumber " << _GraphExecutingNumber
+ // << " != 0 ==> no erase" << endl ;
+ }
+ PyUnLock() ;
+ return ;
+}
+
+bool GraphExecutor::FiniteStateMachine::PyInitModule() {
+ bool InitedModule = _PyInitModule ;
+ _PyInitModule = true ;
+ return InitedModule ;
+}
+
+void GraphExecutor::FiniteStateMachine::PyLock() {
+// cout << pthread_self() << " GraphExecutor::FiniteStateMachine::PyLock " << &_MutexPythonWait << endl ;
+ if ( pthread_mutex_lock( &_MutexPythonWait ) ) {
+ perror( "GraphExecutor::FiniteStateMachine::PyLock" ) ;
+ exit( 0 ) ;
+ }
+// cout << pthread_self() << " GraphExecutor::FiniteStateMachine::PyLocked " << &_MutexPythonWait << endl ;
+}
+
+void GraphExecutor::FiniteStateMachine::PyUnLock() {
+// cout << pthread_self() << " GraphExecutor::FiniteStateMachine::PyUnLock " << &_MutexPythonWait << endl ;
+ if ( pthread_mutex_unlock( &_MutexPythonWait ) ) {
+ perror( "GraphExecutor::FiniteStateMachine::PyUnLock" ) ;
+ exit( 0 ) ;
+ }
+// cout << pthread_self() << " GraphExecutor::FiniteStateMachine::PyUnLocked " << &_MutexPythonWait << endl ;
+}
+
+PyObject * GraphExecutor::FiniteStateMachine::PyFunction( const char * aPyFuncName ) {
+
+ PyObject * RetVal = NULL ;
+ bool PyObjRefIor = !strcmp( aPyFuncName , "PyObjRef" ) || !strcmp( aPyFuncName , "PyObjIor" ) ;
+ PyObject * PyFunctionMapped = _MapOfPyFunctions[ aPyFuncName ] ;
+ if ( _GraphExecutingNumber > 1 && !PyObjRefIor ) {
+ RetVal = PyFunctionMapped ;
+ //cout << "GraphExecutor::FiniteStateMachine::PyFunction( '" << aPyFuncName << "' ) --> " ;
+ if ( RetVal ) {
+ //cout << RetVal << " ob_refcnt " << RetVal->ob_refcnt ;
+ }
+ else {
+ //cout << " NULL" ;
+ }
+ //cout << endl ;
+ }
+ else {
+ RetVal = PyFunctionMapped ;
+ //cout << "GraphExecutor::FiniteStateMachine::PyFunction( '" << aPyFuncName << "' ) --> " ;
+ if ( RetVal && PyObjRefIor ) {
+ //cout << RetVal << " " << RetVal->ob_refcnt << endl ;
+ }
+ else if ( RetVal ) {
+ //cout << RetVal << " " << RetVal->ob_refcnt << endl ;
+// _MapOfPyFunctions.erase( aPyFuncName ) ;
+// cout << "GraphExecutor::FiniteStateMachine::PyFunction( '" << aPyFuncName << "' ) erased --> NULL" << endl ;
+ }
+ else {
+ //cout << " NULL" << endl ;
+ }
+ }
+
+ return RetVal ;
+}
+
+bool GraphExecutor::FiniteStateMachine::PyFunction( const char * aPyFuncName , PyObject * aPyFunction ) {
+
+ bool RetVal = false ;
+ if ( _MapOfPyFunctions[ aPyFuncName ] != NULL ) {
+ PyObject * aPyFunc = _MapOfPyFunctions[ aPyFuncName ] ;
+ //cout << "GraphExecutor::FiniteStateMachine::PyFunction( '" << aPyFuncName << "' , " << aPyFunction
+ // << " ) ob_refcnt " << aPyFunction->ob_refcnt << " already mapped : " << aPyFunc << " ob_refcnt "
+ // << aPyFunc->ob_refcnt << endl ;
+ }
+ else {
+ _MapOfPyFunctions[ aPyFuncName ] = aPyFunction ;
+ //cout << "GraphExecutor::FiniteStateMachine::PyFunction( '" << aPyFuncName << "' , " << aPyFunction
+ // << " ) ob_refcnt " << aPyFunction->ob_refcnt << " mapped" << endl ;
+ RetVal = true ;
+ }
+
+ return RetVal ;
+}
+
void GraphExecutor::FiniteStateMachine::JoinThread() {
if ( pthread_mutex_lock( &_MutexJoinWait ) ) {
perror("Join pthread_mutex_lock ") ;
#include <unistd.h>
#include <stdio.h>
+#include <Python.h>
+
+#include <string>
+#include <map>
+
#include "DataFlowBase_Base.hxx"
#include <SALOMEconfig.h>
GraphExecutor::StateEventAction _ActionTable[ SUPERV::NumberOfAutomatonStates ]
[ GraphExecutor::NumberOfEvents ] ;
+ pthread_mutex_t _MutexPythonWait ;
+ map< string , PyObject * > _MapOfPyFunctions ;
+ bool _PyInitModule ;
+ int _ExecNumber ;
+ int _GraphExecutingNumber ;
+
bool _JoinThread ;
pthread_t _JoinThreadNo ;
pthread_mutex_t _MutexJoinWait ;
FiniteStateMachine() ;
virtual ~FiniteStateMachine() {} ;
+ int ExecNumber() ;
+ void Executed() ;
+ bool PyInitModule() ;
+ void PyLock() ;
+ void PyUnLock() ;
+ bool PyFunction( const char * aPyFuncName , PyObject * aPyFunction ) ;
+ PyObject * PyFunction( const char * aPyFuncName ) ;
+
void JoinThread() ;
void JoinThread( pthread_t aThread ) ;
- const char * ControlStateName(
- const SUPERV::ControlState & aState ) const {
+ const char * ControlStateName( const SUPERV::ControlState & aState ) const {
return _ControlStateName[ aState ] ; } ;
- const char * StateName(
- const SUPERV::AutomatonState & aState ) const {
+ const char * StateName( const SUPERV::AutomatonState & aState ) const {
return _StateName[ aState ] ; } ;
- const char * StateName(
- const SUPERV::GraphState & aState ) const {
+ const char * StateName( const SUPERV::GraphState & aState ) const {
return _GraphStateName[ aState ] ; } ;
- const char * EventName(
- const GraphExecutor::NodeEvent & anEvent ) const {
+ const char * EventName( const GraphExecutor::NodeEvent & anEvent ) const {
return _EventName[ anEvent ] ; } ;
- const char * ActionName(
- const GraphExecutor::StateEventAction & anAction ) const {
+ const char * ActionName( const GraphExecutor::StateEventAction & anAction ) const {
return _ActionName[ anAction ] ; } ;
- const SUPERV::AutomatonState NextState(
- const SUPERV::AutomatonState & aState ,
- const GraphExecutor::NodeEvent & anEvent ) const {
+ const SUPERV::AutomatonState NextState( const SUPERV::AutomatonState & aState ,
+ const GraphExecutor::NodeEvent & anEvent ) const {
return _TransitionTable[ aState ][ anEvent ] ; } ;
- const GraphExecutor::StateEventAction NextAction(
- const SUPERV::AutomatonState & aState ,
- const GraphExecutor::NodeEvent & anEvent ) const {
+ const GraphExecutor::StateEventAction NextAction( const SUPERV::AutomatonState & aState ,
+ const GraphExecutor::NodeEvent & anEvent ) const {
return _ActionTable[ aState ][ anEvent ] ; } ;
};
bool &_ResumeSync ,
pthread_cond_t &_KillWait ,
bool &_KillSync ,
+ pthread_cond_t &_ThreadStartedWait ,
+ bool &_ThreadStartedSync ,
pthread_cond_t &_StopWait ,
GraphExecutor::FiniteStateMachine ** _Automaton ,
GraphExecutor::FiniteStateMachine * theAutomaton ,
exit( 0 ) ;
}
_KillSync = false ;
+ if ( pthread_cond_init( &_ThreadStartedWait , NULL ) ) {
+ perror("pthread_cond_init( &_ThreadStartedWait , NULL )") ;
+ exit( 0 ) ;
+ }
+ _ThreadStartedSync = false ;
if ( pthread_cond_init( &_StopWait , NULL ) ) {
perror("pthread_cond_init( &_StopWait , NULL )") ;
exit( 0 ) ;
*_Orb = CORBA::ORB::_nil();
}
-GraphExecutor::FiniteStateMachine * theAutomaton = new
- GraphExecutor::FiniteStateMachine() ;
+GraphExecutor::FiniteStateMachine * theAutomaton = new GraphExecutor::FiniteStateMachine() ;
//GraphExecutor::InNode::InNode() :
// GraphBase::FactoryNode() {
_ResumeSync ,
_KillWait ,
_KillSync ,
+ _ThreadStartedWait ,
+ _ThreadStartedSync ,
_StopWait ,
&_Automaton ,
theAutomaton ,
CORBA::ORB::_nil() ) ;
}
-GraphExecutor::InNode::InNode(CORBA::ORB_ptr ORB,
- SALOME_NamingService* ptrNamingService ,
- const SALOME_ModuleCatalog::Service& aService ,
- const char * ComponentName ,
- const char * NodeInterfaceName ,
- const char * NodeName ,
- const SUPERV::KindOfNode akind ,
- GraphBase::ListOfFuncName aFuncName ,
- GraphBase::ListOfPythonFunctions aPythonFunction ,
- const SUPERV::SDate NodeFirstCreation ,
- const SUPERV::SDate NodeLastModification ,
- const char * NodeEditorRelease ,
- const char * NodeAuthor ,
- const char * NodeComputer ,
- const char * NodeComment ,
- const bool GeneratedName ,
- const int NodeX ,
- const int NodeY ,
- int * Graph_prof_debug,
- ofstream * Graph_fdebug) {
+GraphExecutor::InNode::InNode( CORBA::ORB_ptr ORB,
+ SALOME_NamingService* ptrNamingService ,
+ const SALOME_ModuleCatalog::Service& aService ,
+ const char * ComponentName ,
+ const char * NodeInterfaceName ,
+ const char * NodeName ,
+ const SUPERV::KindOfNode akind ,
+ GraphBase::ListOfFuncName aFuncName ,
+ GraphBase::ListOfPythonFunctions aPythonFunction ,
+ const SUPERV::SDate NodeFirstCreation ,
+ const SUPERV::SDate NodeLastModification ,
+ const char * NodeEditorRelease ,
+ const char * NodeAuthor ,
+ const char * NodeComputer ,
+ const char * NodeComment ,
+ const bool GeneratedName ,
+ const int NodeX ,
+ const int NodeY ,
+ int * Graph_prof_debug,
+ ofstream * Graph_fdebug) {
// ostream * Graph_fdebug = NULL ) :
// GraphBase::FactoryNode( ORB , ptrNamingService , aService ,
// ComponentName , NodeInterfaceName ,
_ResumeSync ,
_KillWait ,
_KillSync ,
+ _ThreadStartedWait ,
+ _ThreadStartedSync ,
_StopWait ,
&_Automaton ,
theAutomaton ,
bool RetVal ;
if ( IsDone() ) {
ControlState( SUPERV::VoidState ) ;
+ if ( _OutNode->IsDone() ) {
+ ControlState( SUPERV::VoidState ) ;
+ }
RetVal = false ;
}
else if ( IsWaiting() || IsReady() ) {
}
else if ( IsRunning() ) {
ControlState( SUPERV::ToSuspendState ) ;
- if ( IsFactoryNode() ) {
+ if ( IsFactoryNode() || IsComputingNode() ) {
if ( !CORBA::is_nil( Component() ) ) {
RetVal = Component()->Suspend_impl() ;
if ( RetVal ) {
if ( IsRunning() ) {
+ cdebug << pthread_self() << "GraphExecutor::InNode::Suspend_impl " << Name()
+ << " --> thread" << ThreadNo() << " SuspendEvent " << endl;
SendEvent( GraphExecutor::SuspendEvent ) ;
+ cdebug << pthread_self() << "GraphExecutor::InNode::Suspended_impl in Container"
+ << Name() << " --> thread" << ThreadNo() << endl;
}
else if ( IsDone() ) {
ControlState( SUPERV::VoidState ) ;
<< endl ;
RetVal = false ;
}
- cdebug_out << "GraphExecutor::InNode::Suspend " << RetVal << endl ;
+ cdebug_out << "GraphExecutor::InNode::Suspend " << RetVal << " "
+ << Automaton()->StateName( State() ) << endl ;
return RetVal ;
}
bool RetVal ;
if ( IsFactoryNode() ) {
Kill() ;
- Container()->Kill_impl() ;
+ RetVal = Container()->Kill_impl() ;
}
cdebug_out << "GraphExecutor::InNode::ContainerKill" << endl ;
return RetVal ;
cdebug_in << "GraphExecutor::InNode::Kill " << Name() << " " << ThreadNo() << " "
<< Automaton()->StateName( State() ) << endl;
bool RetVal ;
- if ( ControlState() == SUPERV::ToKillState || IsDone() ) {
+ if ( IsDone() ) {
+ ControlState( SUPERV::ToKillState ) ; // if loop
+ if ( _OutNode->IsDone() ) {
+ ControlState( SUPERV::VoidState ) ;
+ }
RetVal = false ;
}
else {
ControlState( SUPERV::ToKillState ) ;
if ( IsDone() ) {
- ControlState( SUPERV::VoidState ) ;
+ if ( _OutNode->IsDone() ) {
+ ControlState( SUPERV::VoidState ) ;
+ }
RetVal = false ;
}
else {
if ( IsRunning() ) {
- if ( IsFactoryNode() ) {
+ if ( IsFactoryNode() || IsComputingNode() ) {
if ( !CORBA::is_nil( Component() ) ) {
RetVal = Component()->Kill_impl() ;
- if ( RetVal ) {
- if ( IsRunning() ) {
- SendEvent( GraphExecutor::KillEvent ) ;
- }
- else if ( IsDone() ) {
- ControlState( SUPERV::VoidState ) ;
- RetVal = false ; // Too late ...
- }
- else {
- cdebug << "component Killed and !IsDone and !IsRunning !"
- << endl ;
- }
+ cdebug << "Component()->Kill_impl() returns status " << RetVal << endl ;
+ RetVal = true ;
+ if ( IsRunning() ) {
+ cdebug << pthread_self() << "GraphExecutor::InNode::Kill_impl " << Name()
+ << " --> thread" << ThreadNo() << " SuspendEvent " << endl;
+ SendEvent( GraphExecutor::KillEvent ) ;
+ cdebug << pthread_self() << "GraphExecutor::InNode::Killed_impl in Container"
+ << Name() << " --> thread" << ThreadNo() << endl;
+ }
+ else if ( IsDone() ) {
+ ControlState( SUPERV::VoidState ) ;
+ RetVal = false ; // Too late ...
+ }
+ else {
+ cdebug << "component Killed and !IsDone and !IsRunning !"
+ << endl ;
}
}
else {
- cdebug << "Kill cannot Kill component !" << endl ;
+ cdebug << "Kill with nilComponent cannot Kill component !" << endl ;
RetVal = false ;
}
}
- else {
- cdebug << "Kill with nilComponent while RunningState !" << endl ;
- SendEvent( GraphExecutor::KillEvent ) ;
- RetVal = IsKilled() ;
- }
}
else if ( IsSuspended() ) {
- SendEvent( GraphExecutor::KillEvent ) ;
+ cdebug << pthread_self() << "GraphExecutor::InNode::Kill " << Name()
+ << " --> thread" << ThreadNo() << " Resume()" << endl;
+ Resume() ;
RetVal = true ;
}
else if ( IsWaiting() ) {
else {
ControlState( SUPERV::ToKillDoneState ) ;
if ( IsDone() ) {
- ControlState( SUPERV::VoidState ) ;
+ if ( _OutNode->IsDone() ) {
+ ControlState( SUPERV::VoidState ) ;
+ }
RetVal = false ;
}
else {
if ( IsRunning() ) {
- if ( IsFactoryNode() ) {
- if ( !CORBA::is_nil( Component() ) ) {
- RetVal = Component()->Kill_impl() ;
- if ( RetVal ) {
- if ( IsRunning() ) {
- SendEvent( GraphExecutor::SuspendEvent ) ;
- }
- else if ( IsDone() ) {
- ControlState( SUPERV::VoidState ) ;
- RetVal = false ; // Too late ...
- }
- else {
- cdebug << "component Suspended and !IsDone and !IsRunning !"
- << endl ;
- }
- }
- }
- else {
- cdebug << "Suspend cannot Suspend component !" << endl ;
- RetVal = false ;
- }
- }
- else {
- cdebug << "Suspend with nilComponent while RunningState !" << endl ;
- RetVal = false ;
- }
+ RetVal = true ;
}
else if ( IsWaiting() ) {
RetVal = true ;
}
else {
- cdebug << "Suspend and !IsDone and !IsRunning and !IsWaiting ?"
+ cdebug << "KillDone and !IsDone and !IsRunning and !IsWaiting ?"
<< endl ;
RetVal = false ;
}
else {
ControlState( SUPERV::ToStopState ) ;
if ( IsDone() ) {
- ControlState( SUPERV::VoidState ) ;
+ if ( _OutNode->IsDone() ) {
+ ControlState( SUPERV::VoidState ) ;
+ }
RetVal = false ;
}
else {
if ( IsRunning() ) {
- if ( IsFactoryNode() ) {
+ if ( IsFactoryNode() || IsComputingNode() ) {
if ( !CORBA::is_nil( Component() ) ) {
RetVal = Component()->Stop_impl() ;
if ( RetVal ) {
if ( IsRunning() ) {
- SendEvent( GraphExecutor::SuspendEvent ) ;
+ SendEvent( GraphExecutor::StopEvent ) ;
}
else if ( IsDone() ) {
ControlState( SUPERV::VoidState ) ;
else {
ControlState( SUPERV::ToSuspendDoneState ) ;
if ( IsDone() ) {
- ControlState( SUPERV::VoidState ) ;
+ if ( _OutNode->IsDone() ) {
+ ControlState( SUPERV::VoidState ) ;
+ }
RetVal = false ;
}
else {
RetVal = true ;
}
else if ( State() == SUPERV::SuspendedExecutingState ) {
- if ( IsFactoryNode() ) {
+ if ( IsFactoryNode() || IsComputingNode() ) {
RetVal = Component()->Resume_impl() ;
}
}
else if ( State() == SUPERV::SuspendedSuccessedState ) {
- ResumeAction( GraphExecutor::ToResumeEvent ) ;
+ ResumeAction( GraphExecutor::ResumeEvent ) ;
RetVal = true ;
}
else if ( State() == SUPERV::SuspendedErroredState ) {
- ResumeAction( GraphExecutor::ToResumeEvent ) ;
+ ResumeAction( GraphExecutor::ResumeEvent ) ;
RetVal = true ;
}
else {
<< anOutPort->IsPortConnected() << ") DataConnected("
<< anOutPort->IsDataConnected() << ")" << endl ;
}
-
- if ( !PyFuncRunned() ) {
- bool Err = false ;
- if ( IsLoopNode() ) {
- PyObject * PyRunMethod = InitPyDynInvoke( InLineNode()->PyFuncName() ,
- InLineNode()->PythonFunction() ) ;
- InLineNode()->PyRunMethod( PyRunMethod ) ;
- PyObject * PyMoreMethod = NULL ;
- if ( PyRunMethod ) {
- PyMoreMethod = InitPyDynInvoke( LoopNode()->PyMoreName() ,
- LoopNode()->MorePythonFunction() ) ;
- LoopNode()->PyMoreMethod( PyMoreMethod ) ;
- }
- PyObject * PyNextMethod = NULL ;
- if ( PyMoreMethod ) {
- PyNextMethod = InitPyDynInvoke( LoopNode()->PyNextName() ,
- LoopNode()->NextPythonFunction() ) ;
- LoopNode()->PyNextMethod( PyNextMethod ) ;
- }
- Err = !PyRunMethod || !PyMoreMethod || !PyNextMethod ;
- }
- else if ( IsInLineNode() || IsSwitchNode() ) {
- PyObject * PyRunMethod = InitPyDynInvoke( InLineNode()->PyFuncName() ,
- InLineNode()->PythonFunction() ) ;
- InLineNode()->PyRunMethod( PyRunMethod ) ;
- Err = !PyRunMethod ;
- }
- else if ( ( IsEndSwitchNode() || IsGOTONode() ) &&
- (*InLineNode()->PythonFunction()).length() ) {
- PyObject * PyRunMethod = InitPyDynInvoke( InLineNode()->PyFuncName() ,
- InLineNode()->PythonFunction() ) ;
- InLineNode()->PyRunMethod( PyRunMethod ) ;
- Err = !PyRunMethod ;
- }
- }
}
_currentState = Pc > 0 ? SUPERV::DataWaitingState
cdebug_out << "GraphExecutor::InNode::InitialState" << endl;
}
+bool GraphExecutor::InNode::InitPythonFunctions(bool WithErr ) {
+ cdebug_in << "GraphExecutor::InNode::InitPythonFunctions " << Name() << endl;
+ bool Err = false ;
+ if ( !PyFuncRunned() && IsOneOfInLineNodes() ) {
+ if ( IsLoopNode() ) {
+ PyObject * PyRunMethod = InLineNode()->PyRunMethod() ;
+ if ( PyRunMethod ) {
+ }
+ else {
+ PyObject * PyRunMethod = InitPyDynInvoke( InLineNode()->PyFuncName() ,
+ InLineNode()->PythonFunction() ) ;
+ InLineNode()->PyRunMethod( PyRunMethod ) ;
+ }
+ PyObject * PyMoreMethod = LoopNode()->PyMoreMethod() ;
+ if ( PyMoreMethod ) {
+ }
+ else {
+ PyMoreMethod = InitPyDynInvoke( LoopNode()->PyMoreName() ,
+ LoopNode()->MorePythonFunction() ) ;
+ LoopNode()->PyMoreMethod( PyMoreMethod ) ;
+ }
+ PyObject * PyNextMethod = LoopNode()->PyNextMethod() ;
+ if ( PyNextMethod ) {
+ }
+ else {
+ PyNextMethod = InitPyDynInvoke( LoopNode()->PyNextName() ,
+ LoopNode()->NextPythonFunction() ) ;
+ LoopNode()->PyNextMethod( PyNextMethod ) ;
+ }
+ cdebug << "GraphExecutor::InNode::InitPythonFunctions " << Name() << " PyRunMethod(Init) " << PyRunMethod
+ << " PyMoreMethod " << PyMoreMethod << " PyNextMethod " << PyNextMethod << endl;
+ Err = !PyRunMethod || !PyMoreMethod || !PyNextMethod ;
+ }
+ else if ( IsInLineNode() || IsSwitchNode() ) {
+ PyObject * PyRunMethod = InLineNode()->PyRunMethod() ;
+ if ( PyRunMethod ) {
+ }
+ else {
+ PyRunMethod = InitPyDynInvoke( InLineNode()->PyFuncName() ,
+ InLineNode()->PythonFunction() ) ;
+ InLineNode()->PyRunMethod( PyRunMethod ) ;
+ }
+ cdebug << "GraphExecutor::InNode::InitPythonFunctions " << Name() << " PyRunMethod " << PyRunMethod << endl;
+ Err = !PyRunMethod ;
+ }
+ else if ( ( IsEndLoopNode() || IsEndSwitchNode() || IsGOTONode() ) &&
+ (*InLineNode()->PythonFunction()).length() ) {
+ PyObject * PyRunMethod = InLineNode()->PyRunMethod() ;
+ if ( PyRunMethod ) {
+ }
+ else {
+ PyRunMethod = InitPyDynInvoke( InLineNode()->PyFuncName() ,
+ InLineNode()->PythonFunction() ) ;
+ InLineNode()->PyRunMethod( PyRunMethod ) ;
+ }
+ cdebug << "GraphExecutor::InNode::InitPythonFunctions " << Name() << " PyRunMethod " << PyRunMethod << endl;
+ Err = !PyRunMethod ;
+ }
+ }
+ Err = WithErr && Err ;
+ cdebug_out << "GraphExecutor::InNode::InitPythonFunctions " << Name() ;
+ if ( Err ) {
+ cdebug << " Error " << Err ;
+ }
+ cdebug << endl;
+ return Err ;
+}
+
const long GraphExecutor::InNode::CpuUsed( bool tot ) {
CORBA::Long cpu = 0 ;
// cdebug_in << "GraphExecutor::InNode::CpuUsed( " << tot << " )" << Name() << endl ;
bool _KillSync ;
pthread_cond_t _StopWait ;
+ pthread_cond_t _ThreadStartedWait ;
+ bool _ThreadStartedSync ;
+
pthread_t _Pythread ;
long _PyCpuUsed ;
long _PyTotCpuUsed ;
bool DoneWait() ;
bool SuspendedWait() ;
- void InitialState( GraphExecutor::OutNode * theOutNode );
+ void InitialState( GraphExecutor::OutNode * theOutNode ) ;
+ bool InitPythonFunctions(bool WithErr ) ;
void SetWaitingStates(GraphExecutor::InNode * EndNode ) ;
int SendEvent(const GraphExecutor::NodeEvent anEvent ) ;
GraphExecutor::NodeEvent anEvent ) ;
void KillAction() ;
void KilledAction() ;
+ void ThreadStartAction() ;
+ void ThreadStartedAction() ;
void StopAction() ;
void StoppedAction() ;
int executeAction() ; // New Thread or Same Thread
//static char *containerName = "FactoryServer" ;
-int GraphExecutor::InNode::SendEvent(
- const GraphExecutor::NodeEvent anEvent ) {
+int GraphExecutor::InNode::SendEvent( const GraphExecutor::NodeEvent anEvent ) {
_CurrentEvent = (GraphExecutor::NodeEvent ) anEvent ;
cdebug << pthread_self() << "/" << ThreadNo() << " -->SendEvent Node " << Name()
#endif
int sts = executeAction() ;
-
+
cdebug << pthread_self() << "/" << ThreadNo() << " <--- SendEvent Node " << Name()
<< " Event : " << Automaton()->EventName( anEvent )
<< " State : " << Automaton()->StateName( State() )
<< " NO SuspendAction pthread_cond_wait"
<< Automaton()->StateName( State() ) << endl ;
}
- SendEvent( _aResumeEvent ) ;
+// SendEvent( _aResumeEvent ) ; ===> Mutex with myself !
_SuspendSync = false ;
+ if ( ControlState() == SUPERV::ToSuspendStartState ||
+ ControlState() == SUPERV::ToSuspendState ) {
+ ControlState( SUPERV::VoidState ) ;
+ }
if ( pthread_mutex_unlock( &_MutexWait ) ) {
perror("SuspendAction pthread_mutex_unlock ") ;
exit( 0 ) ;
}
- if ( ControlState() == SUPERV::ToSuspendStartState ) {
- ControlState( SUPERV::VoidState ) ;
- }
+ SendEvent( _aResumeEvent ) ;
+// if ( ControlState() == SUPERV::ToSuspendStartState ) {
+// ControlState( SUPERV::VoidState ) ;
+// }
if ( pthread_mutex_lock( &_MutexWait ) ) {
perror("SuspendAction pthread_mutex_lock ") ;
cdebug << pthread_self() << "/" << ThreadNo() << " pthread_cond " << Name()
<< " NO ResumeAction pthread_cond_signal" << endl ;
if ( pthread_self() == ThreadNo() ) {
- RetVal = false ; // Ne pas s'attendre soi-meme !...
+ RetVal = false ; /*/ Ne pas s'attendre soi-meme !...*/
}
else {
_SuspendSync = true ;
}
}
+void GraphExecutor::InNode::ThreadStartedAction() {
+ if ( pthread_mutex_lock( &_MutexWait ) ) {
+ perror("ThreadStarted pthread_mutex_lock ") ;
+ exit( 0 ) ;
+ }
+ if ( !_ThreadStartedSync ) {
+ cdebug << "pthread_cond " << Name() << " ThreadStarted pthread_cond_wait"
+ << endl ;
+ _ThreadStartedSync = true ;
+ if ( pthread_cond_wait( &_ThreadStartedWait , &_MutexWait ) ) {
+ perror("ThreadStarted pthread_cond_wait ") ;
+ }
+ cdebug << "pthread_cond " << Name() << " ThreadStarted pthread_cond_waited"
+ << endl ;
+ }
+ else {
+ cdebug << "pthread_cond " << Name() << " NO ThreadStarted pthread_cond_wait"
+ << endl ;
+//Debug :
+ _ThreadStartedSync = false ;
+ if ( pthread_cond_signal( &_ThreadStartedWait ) ) {
+ perror("ThreadStart pthread_cond_signal ") ;
+ }
+//Debug
+ cdebug << "pthread_cond " << Name() << " NO ThreadStarted pthread_cond_signaled"
+ << endl ;
+ }
+ if ( pthread_mutex_unlock( &_MutexWait ) ) {
+ perror("ThreadStarted pthread_mutex_unlock ") ;
+ exit( 0 ) ;
+ }
+}
+
+void GraphExecutor::InNode::ThreadStartAction() {
+ if ( pthread_mutex_lock( &_MutexWait ) ) {
+ perror("ThreadStart pthread_mutex_lock ") ;
+ exit( 0 ) ;
+ }
+ if ( _ThreadStartedSync ) {
+ cdebug << "pthread_cond " << Name() << " ThreadStart pthread_cond_signal"
+ << endl ;
+ _ThreadStartedSync = false ;
+ if ( pthread_cond_signal( &_ThreadStartedWait ) ) {
+ perror("ThreadStart pthread_cond_broadcast ") ;
+ }
+ cdebug << "pthread_cond " << Name() << " ThreadStart pthread_cond_signaled"
+ << endl ;
+ }
+ else {
+ cdebug << "pthread_cond " << Name() << " NO ThreadStart pthread_cond_signal"
+ << endl ;
+ _ThreadStartedSync = true ;
+//Debug :
+ if ( pthread_cond_wait( &_ThreadStartedWait , &_MutexWait ) ) {
+ perror("ThreadStarted pthread_cond_wait ") ;
+ }
+//Debug
+ cdebug << "pthread_cond " << Name() << " NO ThreadStart pthread_cond_waited"
+ << endl ;
+ }
+ if ( pthread_mutex_unlock( &_MutexWait ) ) {
+ perror("ThreadStart pthread_mutex_unlock ") ;
+ exit( 0 ) ;
+ }
+}
+
int GraphExecutor::InNode::executeAction() {
- if ( !CreateNewThread() && _RewindStack > 101 ) {
+ int oldRewindStack = ( _RewindStack > 101 ) ;
+ if ( !CreateNewThread() && oldRewindStack ) {
+ cdebug << pthread_self() << "/" << ThreadNo()
+ << " executeAction start Thread _RewindStack " << _RewindStack << " > 101 CreateNewThread "
+ << CreateNewThread() << " " << Automaton()->ActionName( _NextAction ) << "(" << Name() << ")"
+ << endl;
CreateNewThread( true ) ;
ThreadNo( 0 ) ;
}
}
cdebug << pthread_self() << "/" << ThreadNo()
<< "executeAction has created thread " << T << endl ;
+ ThreadStartedAction() ;
+ cdebug << pthread_self() << "/" << ThreadNo()
+ << "executeAction the thread " << T << " has called NewThread and will call ExecuteAction for node "
+ << Name() << endl ;
}
else {
cdebug << pthread_self() << "/" << ThreadNo()
perror("pthread_setcancelstate ") ;
exit(0) ;
}
+ aNode->ThreadStartAction() ;
aNode->ExecuteAction() ;
char * msg = new char[40] ;
sprintf( msg , "%d" , (int ) aNode->ThreadNo() ) ;
int GraphExecutor::InNode::ExecuteAction() {
int sts ;
- GraphExecutor::StateEventAction nextaction = _NextAction ;
- const char * nextactionname = Automaton()->ActionName( nextaction ) ;
- const char * statename = Automaton()->StateName( State() ) ;
- const char * nextstatename = Automaton()->StateName( _NextState ) ;
- cdebug << pthread_self() << "/" << ThreadNo() << " --> ExecuteAction "
- << nextactionname << " " << statename << " NextState "
- << nextstatename << endl ;
+
+// const char * nextactionname = Automaton()->ActionName( _NextAction ) ;
+// const char * statename = Automaton()->StateName( State() ) ;
+// const char * nextstatename = Automaton()->StateName( _NextState ) ;
+// cdebug << pthread_self() << "/" << ThreadNo() << " --> ExecuteAction "
+// << nextactionname << " " << statename << " NextState "
+// << nextstatename << endl ;
+
State( _NextState ) ;
- switch ( nextaction ) {
+ switch ( _NextAction ) {
case GraphExecutor::ErrorAction : {
sts = ErrorAction() ;
break ;
return 0 ;
}
}
- cdebug << pthread_self() << "/" << ThreadNo() << "<-- ExecuteAction "
- << Automaton()->ActionName( nextaction ) << endl ;
+// cdebug << pthread_self() << "/" << ThreadNo() << "<-- ExecuteAction "
+// << Automaton()->ActionName( nextaction ) << endl ;
return sts ;
}
int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() {
- cdebug << pthread_self() << "/" << ThreadNo()
- << " --> DataWaiting_SomeDataReadyAction from " << DataFromNode()
- << " to " << Name() << endl;
+// cdebug << pthread_self() << "/" << ThreadNo()
+// << " --> DataWaiting_SomeDataReadyAction from " << DataFromNode()
+// << " to " << Name() << endl;
unsigned int k;
int InReady = 0 ;
int res = 1;
LoopBeginning = true ; // Beginning of Loop
}
if ( IsEndSwitchNode() && !GetChangeNodeInGate()->GetOutPort()->BoolValue() ) {
- SwitchFinished = true ;
+ SwitchFinished = true ; // End of Switch
}
+ cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " LoopFinished " << LoopFinished
+ << " LoopBeginning " << LoopBeginning << " SwitchFinished " << SwitchFinished << endl ;
for ( k = 0 ; k < (unsigned int ) GetNodeInPortsSize() ; k++ ) {
GraphBase::InPort * anInPort = GetChangeNodeInPort(k) ;
GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ;
cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " "
<< anInPort->PortName() << " Was Done from "
<< anOutPort->NodeName() << " " << anOutPort->PortName()
- << " " ;
+ << " ReadyState " ;
#ifdef _DEBUG_
if ( GraphBase::Base::_prof_debug ) {
anOutPort->StringValue( *GraphBase::Base::_fdebug ) ;
int GraphExecutor::InNode::DataUndef_NotAllDataReadyAction() {
CreateNewThreadIf( false ) ;
- cdebug << pthread_self() << " for " << ThreadNo()
- << " DataUndef_NotAllDataReadyAction " << Name() << endl;
+// cdebug << pthread_self() << " for " << ThreadNo()
+// << " DataUndef_NotAllDataReadyAction " << Name() << endl;
return 1;
}
int GraphExecutor::InNode::DataUndef_AllDataReadyAction() {
- cdebug << pthread_self() << "/" << ThreadNo()
- << " --> DataUndef_AllDataReadyAction " << Name()
- << " CreateNewThreadIf " << CreateNewThreadIf() << " IsLockedDataWait "
- << IsLockedDataWait() ;
-// if ( !CreateNewThreadIf() && IsLockedDataWait() ) {
+// cdebug << pthread_self() << "/" << ThreadNo()
+// << " --> DataUndef_AllDataReadyAction " << Name()
+// << " CreateNewThreadIf " << CreateNewThreadIf() << " IsLockedDataWait "
+// << IsLockedDataWait() ;
if ( IsLockedDataWait() ) {
- cdebug << " WOULD DEAD-LOCK" << endl ;
+// cdebug << " WOULD DEAD-LOCK" << endl ;
return 0 ; // ==> DataUndef_AllDataReadyAction() after UnLockDataWait()
}
- cdebug << endl ;
+// cdebug << endl ;
CreateNewThread( CreateNewThreadIf() ) ;
if ( !CreateNewThread() ) {
- cdebug << "Thread " << ThreadNo() << "-->" << pthread_self() << endl ;
+// cdebug << "Thread " << ThreadNo() << "-->" << pthread_self() << endl ;
ThreadNo( pthread_self() ) ;
}
_OutNode->PushEvent( this , GraphExecutor::AllDataReadyEvent ,
return 0;
}
}
- cdebug << pthread_self() << "/" << ThreadNo()
- << " <-- DataUndef_AllDataReadyAction " << Name() << endl;
+// cdebug << pthread_self() << "/" << ThreadNo()
+// << " <-- DataUndef_AllDataReadyAction " << Name() << endl;
return 1;
}
int GraphExecutor::InNode::DataReady_ExecuteAction() {
int i;
- cdebug << pthread_self() << "/" << ThreadNo() << " --> DataReady_ExecuteAction "
- << Name() << endl;
+// cdebug << pthread_self() << "/" << ThreadNo() << " --> DataReady_ExecuteAction "
+// << Name() << endl;
_OutNode->PushEvent( this , GraphExecutor::ExecuteEvent ,
SUPERV::ExecutingState ) ;
Engines::Container_var myContainer ;
Engines::Component_var myObjComponent ;
-// if ( strlen( ComponentName() ) == 0 ) {
if ( !IsFactoryNode() ) {
- cdebug << ThreadNo() << "No Component : NO StartComponent & No Ping"
- << endl ;
+// cdebug << ThreadNo() << "No Component : NO StartComponent & No Ping" << endl ;
if ( IsComputingNode() ) {
ObjInterface( true ) ;
CORBA::Object_ptr obj ;
Err = !_OutNode->StartComponent( ThreadNo() , Computer() ,
my_strdup( ComponentName() ) ,
myContainer , myObjComponent ) ;
-// if ( !Err && nInParams > 1 &&
-// strcmp( ComponentName() , InterfaceName() ) &&
-// InParametersList[ 1 ].Value.type()->kind() ==
-// CORBA::tk_objref ) {
-// }
-// else {
ObjInterface( false ) ;
-// }
SetContainer( myContainer ) ;
SetComponent( myObjComponent ) ;
}
else {
myContainer = Container() ;
myObjComponent = Component() ;
- cdebug << ThreadNo() << "Component known : NO StartComponent & Ping"
- << endl ;
+// cdebug << ThreadNo() << "Component known : NO StartComponent & Ping"
+// << endl ;
myObjComponent->ping() ;
}
ServicesAnyData * OutParametersList = new ServicesAnyData[nOutParams];
InOutParametersSet( nOutParams , OutParametersList ) ;
-// if ( strlen( ComponentName() ) ) {
if ( Err || ControlState() == SUPERV::ToKillState ||
ControlState() == SUPERV::ToKillDoneState ||
ControlState() == SUPERV::ToStopState ) {
cdebug << " , " << OutParametersList[ i ].Name << "[kind"
<< OutParametersList[ i ].Value.type()->kind() << "]" ;
}
+ if ( IsOneOfInLineNodes() ) {
+ cdebug << " , PyFuncName '" << InLineNode()->PyFuncName() << "' PyRunMethod "
+ << InLineNode()->PyRunMethod() << " length " << (*InLineNode()->PythonFunction()).length() ;
+ }
cdebug << ")" << endl ;
if ( IsOneOfInLineNodes() ) {
- bool StsPyDynInvoke = true ;
- _OutNode->PyThreadLock() ;
+ bool StsPyDynInvoke = true;
+ _OutNode->PyThreadLock() ;
SetPyCpuUsed() ;
try {
- if ( IsInLineNode() && (*InLineNode()->PythonFunction()).length() &&
+// if ( IsInLineNode() && (*InLineNode()->PythonFunction()).length() &&
+ bool CopyInOut = false ;
+ if ( IsInLineNode() && /*InLineNode()->PyRunMethod() &&*/
strlen( InLineNode()->PyFuncName() ) ) {
- cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
- << InLineNode()->PyFuncName()
- << "' IsInLineNode PyDynInvoke" << endl ;
+// cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
+// << InLineNode()->PyFuncName()
+// << "' IsInLineNode PyDynInvoke" << endl ;
StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
- InLineNode()->PyFuncName() ,
- &InParametersList[0] , ServiceInParameter().length() ,
- &OutParametersList[0] , ServiceOutParameter().length() ) ;
+ InLineNode()->PyFuncName() ,
+ &InParametersList[0] , ServiceInParameter().length() ,
+ &OutParametersList[0] , ServiceOutParameter().length() ) ;
}
else if ( IsLoopNode() ) {
- if ( GetNodeInLoop()->GetOutPort()->BoolValue() ) { // InLoop Port
- cdebug << ThreadNo() << " !ObjInterface " << Name()
- << " IsLoopNode PyDynInvoke '" << InLineNode()->PyFuncName()
- << "'" << endl ;
+ bool CopyOutIn = false ;
+ if ( GetNodeInLoop()->GetOutPort()->BoolValue() && /*InLineNode()->PyRunMethod() &&*/
+ strlen( InLineNode()->PyFuncName() ) ) { // InLoop Port
+// cdebug << ThreadNo() << " !ObjInterface " << Name()
+// << " IsLoopNode PyDynInvoke '" << InLineNode()->PyFuncName()
+// << "'" << endl ;
StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
- InLineNode()->PyFuncName() ,
- &InParametersList[1] , ServiceInParameter().length() ,
- &OutParametersList[1] , ServiceOutParameter().length() ) ;
+ InLineNode()->PyFuncName() ,
+ &InParametersList[1] , ServiceInParameter().length() ,
+ &OutParametersList[1] , ServiceOutParameter().length() ) ;
+ CopyOutIn = true ;
}
- else {
- cdebug << ThreadNo() << " !ObjInterface " << Name()
- << " IsLoopNode PyDynInvoke '" << LoopNode()->PyNextName()
- << "'" << endl ;
+ else if ( LoopNode()->PyNextMethod() &&
+ strlen( LoopNode()->PyNextName() ) ){
+// cdebug << ThreadNo() << " !ObjInterface " << Name()
+// << " IsLoopNode PyDynInvoke '" << LoopNode()->PyNextName()
+// << "'" << endl ;
StsPyDynInvoke = PyDynInvoke( LoopNode()->PyNextMethod() ,
- LoopNode()->PyNextName() ,
- &InParametersList[1] , ServiceInParameter().length() ,
- &OutParametersList[1] , ServiceOutParameter().length() ) ;
+ LoopNode()->PyNextName() ,
+ &InParametersList[1] , ServiceInParameter().length() ,
+ &OutParametersList[1] , ServiceOutParameter().length() ) ;
+ CopyOutIn = true ;
}
- if ( StsPyDynInvoke ) {
- cdebug << ThreadNo() << " !ObjInterface " << Name()
- << " IsLoopNode PyDynInvoke '" << LoopNode()->PyMoreName()
- << "' Copy of " << ServiceInParameter().length()
- << " OutParameters" << endl ;
+ if ( StsPyDynInvoke && CopyOutIn ) {
+// cdebug << ThreadNo() << " !ObjInterface " << Name()
+// << " IsLoopNode PyDynInvoke '" << LoopNode()->PyMoreName()
+// << "' Copy of " << ServiceInParameter().length()
+// << " OutParameters" << endl ;
int i ;
for ( i = 1 ; i <= (int ) ServiceInParameter().length() ; i++ ) {
InParametersList[i].Value = OutParametersList[i].Value ;
}
//#endif
}
- StsPyDynInvoke = PyDynInvoke( LoopNode()->PyMoreMethod() ,
- LoopNode()->PyMoreName() ,
- &InParametersList[1] , ServiceInParameter().length() ,
- &OutParametersList[0] , ServiceOutParameter().length()+1 ) ;
+ if ( LoopNode()->PyMoreMethod() && strlen( LoopNode()->PyMoreName() ) ) {
+ StsPyDynInvoke = PyDynInvoke( LoopNode()->PyMoreMethod() ,
+ LoopNode()->PyMoreName() ,
+ &InParametersList[1] , ServiceInParameter().length() ,
+ &OutParametersList[0] , ServiceOutParameter().length()+1 ) ;
+ }
+ else {
+ CopyInOut = true ;
+ }
}
- else {
+ else if ( !StsPyDynInvoke ) {
Err = true ;
cdebug << ThreadNo() << " InLineNode " << Name() << " "
<< InLineNode()->PyFuncName() << "/" << LoopNode()->PyNextName()
<< endl ;
}
}
- else if ( IsSwitchNode() ) {
- cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
- << InLineNode()->PyFuncName()
- << "' IsSwitchNode PyDynInvoke" << endl ;
+ else if ( IsSwitchNode() && /*InLineNode()->PyRunMethod() &&*/
+ strlen( InLineNode()->PyFuncName() ) ) {
+// cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
+// << InLineNode()->PyFuncName()
+// << "' IsSwitchNode PyDynInvoke" << endl ;
StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
- InLineNode()->PyFuncName() ,
- &InParametersList[0] , ServiceInParameter().length() ,
- &OutParametersList[0] , ServiceOutParameter().length() ) ;
+ InLineNode()->PyFuncName() ,
+ &InParametersList[0] , ServiceInParameter().length() ,
+ &OutParametersList[0] , ServiceOutParameter().length() ) ;
}
- else if ( IsGOTONode() && (*GOTONode()->PythonFunction()).length() &&
+// else if ( IsGOTONode() && (*GOTONode()->PythonFunction()).length() &&
+ else if ( IsGOTONode() && /*InLineNode()->PyRunMethod() &&*/
strlen( InLineNode()->PyFuncName() ) ) {
- cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
- << InLineNode()->PyFuncName()
- << "' IsGOTONode PyDynInvoke" << endl ;
+// cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
+// << InLineNode()->PyFuncName()
+// << "' IsGOTONode PyDynInvoke" << endl ;
StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
- InLineNode()->PyFuncName() ,
- &InParametersList[0] , ServiceInParameter().length() ,
- &OutParametersList[0] , ServiceOutParameter().length() ) ;
+ InLineNode()->PyFuncName() ,
+ &InParametersList[0] , ServiceInParameter().length() ,
+ &OutParametersList[0] , ServiceOutParameter().length() ) ;
}
- else if ( IsEndSwitchNode() && (*InLineNode()->PythonFunction()).length() &&
- strlen( InLineNode()->PyFuncName() ) ) {
- cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
- << InLineNode()->PyFuncName()
- << "' IsSwitchNode PyDynInvoke" << endl ;
+// else if ( IsEndSwitchNode() && (*InLineNode()->PythonFunction()).length() &&
+ else if ( ( IsEndSwitchNode() ) &&
+ InLineNode()->PyRunMethod() && strlen( InLineNode()->PyFuncName() ) ) {
+// cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
+// << InLineNode()->PyFuncName()
+// << "' IsSwitchNode PyDynInvoke" << endl ;
StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
- InLineNode()->PyFuncName() ,
- &InParametersList[0] , ServiceInParameter().length() ,
- &OutParametersList[0] , ServiceOutParameter().length() ) ;
+ InLineNode()->PyFuncName() ,
+ &InParametersList[0] , ServiceInParameter().length() ,
+ &OutParametersList[0] , ServiceOutParameter().length() ) ;
}
- else if ( (*InLineNode()->PythonFunction()).length() == 0 ||
- strlen( InLineNode()->PyFuncName() ) == 0 ) {
- cdebug << ThreadNo() << " !ObjInterface " << Name()
- << " Copy of " << ServiceInParameter().length()
- << " OutParameters" << endl ;
- int i ;
+ else if ( ( IsEndLoopNode() ) &&
+ InLineNode()->PyRunMethod() && strlen( InLineNode()->PyFuncName() ) ) {
+// cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '"
+// << InLineNode()->PyFuncName()
+// << "' IsSwitchNode PyDynInvoke" << endl ;
+ StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() ,
+ InLineNode()->PyFuncName() ,
+ &InParametersList[0] , ServiceInParameter().length() + 1 ,
+ &OutParametersList[0] , ServiceOutParameter().length() + 1 ) ;
+ }
+// else if ( (*InLineNode()->PythonFunction()).length() == 0 ||
+ if ( InLineNode()->PyRunMethod() == NULL ||
+ strlen( InLineNode()->PyFuncName() ) == 0 || CopyInOut ) {
+// cdebug << ThreadNo() << " !ObjInterface " << Name()
+// << " Copy of " << ServiceInParameter().length()
+// << " OutParameters" << endl ;
+ int i ;
int argout0 = 0 ;
int argin0 = 0 ;
- if ( IsEndLoopNode() ) {
+ if ( IsLoopNode() || IsEndLoopNode() ) {
argout0 = 1 ;
argin0 = 1 ; // after DoLoop
+ if ( IsLoopNode() ) {
+ OutParametersList[0].Value = InParametersList[0].Value ; // DoLoop
+ }
}
for ( i = 0 ; i < (int ) ServiceInParameter().length() ; i++ ) {
OutParametersList[argout0 + i].Value = InParametersList[argin0 + i].Value ;
cdebug << "ArgOut->In" << argin0 + i << " : "
<< InParametersList[argin0 + i].Name.c_str()
<< " Value(string) "
- << OutParametersList[argin0 + i].Name.c_str() << endl ;
+ << OutParametersList[argout0 + i].Name.c_str() << endl ;
break ;
case CORBA::tk_double :
cdebug << "ArgOut->In" << argin0 + i << " : "
<< InParametersList[argin0 + i].Name.c_str()
<< " Value(double) "
- << OutParametersList[argin0 + i].Name.c_str() << endl ;
+ << OutParametersList[argout0 + i].Name.c_str() << endl ;
break ;
case CORBA::tk_long :
cdebug << "ArgOut->In" << argin0 + i << " : "
<< InParametersList[argin0 + i].Name.c_str()
<< " Value(long) "
- << OutParametersList[ i ].Name.c_str() << endl ;
+ << OutParametersList[argout0 + i ].Name.c_str() << endl ;
break ;
case CORBA::tk_objref :
cdebug << "ArgOut->In" << argin0 + i << " : "
<< InParametersList[argin0 + i].Name.c_str()
<< " Value(object reference) "
- << OutParametersList[argin0 + i].Name.c_str() << endl ;
+ << OutParametersList[argout0 + i].Name.c_str() << endl ;
break ;
default :
cdebug << "ArgOut->In" << argin0 + i << " : "
<< InParametersList[argin0 + i].Name.c_str()
<< " Value(other) ERROR "
- << OutParametersList[argin0 + i].Name.c_str() << endl ;
+ << OutParametersList[argout0 + i].Name.c_str() << endl ;
}
//#endif
}
}
if ( !StsPyDynInvoke ) {
- Err = true ;
+ Err = true ;
cdebug << ThreadNo() << " InLineNode " << Name()
<< " Python Dynamic Call Error"
<< endl ;
}
}
catch( ... ) {
- Err = true ;
+ Err = true ;
cdebug << ThreadNo() << " InLineNode " << Name()
<< " Python Dynamic Call Exception catched ERROR"
<< endl ;
else {
try {
try {
+ cdebug << "DynInvoke -> Names " << _OutNode->Name() << " " << Name() << endl ;
DynInvoke( myObjComponent, "Names" ,
_OutNode->Name() , Name() ) ;
}
&InParametersList[0] , ServiceInParameter().length() ,
&OutParametersList[0] , ServiceOutParameter().length() ) ;
}
+// cdebug << ThreadNo() << " Component::CpuUsed " << Name() << " "
+// << myObjComponent->CpuUsed_impl() << endl ;
}
catch( ... ) {
Err = true ;
}
bool ErrOut = OutParametersSet( Err , PortState , nOutParams , OutParametersList ) ;
+
if ( !ErrOut ) {
NewEvent = GraphExecutor::ErrorEvent ;
}
+
delete [] InParametersList ;
delete [] OutParametersList ;
+
SendEvent( NewEvent );
- cdebug << ThreadNo() << " <-- DataReady_ExecuteAction " << Name() << endl;
+// cdebug << ThreadNo() << " <-- DataReady_ExecuteAction " << Name() << endl;
return 1 ;
}
}
int GraphExecutor::InNode::Executing_SuccessAction() {
- cdebug << ThreadNo() << " --> Executing_SuccessAction " << Name() << endl;
+// cdebug << ThreadNo() << " --> Executing_SuccessAction " << Name() << endl;
_OutNode->PushEvent( this , GraphExecutor::SuccessedExecutingEvent ,
SUPERV::SuccessedState ) ;
-// DoneAction() ;
SUPERV::ControlState aControl = ControlState() ;
switch ( aControl ) {
case SUPERV::VoidState : {
return 0;
}
}
- cdebug << ThreadNo() << " <-- Executing_SuccessAction " << Name() << endl;
+// cdebug << ThreadNo() << " <-- Executing_SuccessAction " << Name() << endl;
return 1 ;
}
cdebug << ThreadNo() << " --> Executing_ErrorAction " << Name() << endl;
_OutNode->PushEvent( this , GraphExecutor::ErroredExecutingEvent ,
SUPERV::ErroredState ) ;
-// DoneAction() ;
SUPERV::ControlState aControl = ControlState() ;
switch ( aControl ) {
}
else if ( anInPort->State() != SUPERV::WaitingState ) {
if ( !docdebug ) {
- cdebug << ThreadNo()
- << " --> GraphExecutor::InNodeThreads::SetWaitingStates " << Name() << endl;
+// cdebug << ThreadNo()
+// << " --> GraphExecutor::InNodeThreads::SetWaitingStates " << Name() << endl;
docdebug = true ;
}
anInPort->State( SUPERV::WaitingState ) ;
for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) {
for ( j = 0 ; j < GetChangeNodeOutPort( i )->InPortsSize() ; j++ ) {
GraphBase::OutPort * anOutPort = GetChangeNodeOutPort( i ) ;
-// if ( !( IsGOTONode() && i == 0 ) && !( IsEndLoopNode() && i <= 1 ) ) {
if ( !( IsGOTONode() && anOutPort->IsGate() ) &&
!( IsEndLoopNode() && ( anOutPort->IsGate() || anOutPort->IsLoop() ) ) ) {
GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) _OutNode->GetChangeGraphNode( anOutPort->ChangeInPorts( j )->NodeName() )->GetInNode() ;
}
int GraphExecutor::InNode::Successed_SuccessAction() {
- cdebug << ThreadNo() << " --> Successed_SuccessAction " << Name() << endl;
+// cdebug << ThreadNo() << " --> Successed_SuccessAction " << Name() << endl;
int res = 1;
int linkednodesnumber = LinkedNodesSize() ;
GraphExecutor::InNode *firstzeroNode = NULL ;
for ( i = 0 ; i < aGateOutPort->InPortsSize() ; i++ ) {
const GraphBase::InPort * anInPort = aGateOutPort->InPorts( i ) ;
GraphExecutor::InNode * aLabelNode = (GraphExecutor::InNode *) _OutNode->GetChangeGraphNode( anInPort->NodeName() )->GetInNode() ;
- cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " will Loop to HeadNode "
- << aLabelNode->Name() << " from port " << anInPort->PortName() << endl ;
+// cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " will Loop to HeadNode "
+// << aLabelNode->Name() << " from port " << anInPort->PortName() << endl ;
aLabelNode->SetWaitingStates( this ) ;
for ( j = 0 ; j < aLabelNode->GetNodeInPortsSize() ; j++ ) {
const GraphBase::InPort * anInPort = aLabelNode->GetNodeInPort( j ) ;
if ( anInPort->GetOutPort() ) {
- cdebug << aLabelNode->Name() << "(" << anInPort->PortName() << ") value : "
- << anInPort->GetOutPort()->NodeName() << "(" << anInPort->GetOutPort()->PortName() << ")"
- << endl ;
+// cdebug << aLabelNode->Name() << "(" << anInPort->PortName() << ") value : "
+// << anInPort->GetOutPort()->NodeName() << "(" << anInPort->GetOutPort()->PortName() << ")"
+// << endl ;
}
}
for ( j = 0 ; j < GetNodeOutPortsSize() ; j++ ) {
}
if ( aBusParamChangeInPort ) {
aBusParamChangeInPort->ChangeOutPort( aBusParamOutPort ) ;
- cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " ChangeOutPort to HeadNode "
- << aLabelNode->Name() << "(" << aBusParamChangeInPort->PortName() << ") from port "
- << aBusParamOutPort->PortName() << endl ;
+// cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " ChangeOutPort to HeadNode "
+// << aLabelNode->Name() << "(" << aBusParamChangeInPort->PortName() << ") from port "
+// << aBusParamOutPort->PortName() << endl ;
if ( !aLabelNode->IsLockedDataWait() ) {
res = aLabelNode->SendSomeDataReady( Name() ) ;
if ( res ) {
if ( firsttoNode == NULL &&
aLabelNode->ThreadNo() == pthread_self() ) {
firsttoNode = aLabelNode ;
- cdebug << ThreadNo() << " Successed_SuccessAction firsttoNode "
- << aLabelNode->Name() << endl ;
+// cdebug << ThreadNo() << " Successed_SuccessAction firsttoNode "
+// << aLabelNode->Name() << endl ;
}
else if ( firstzeroNode == NULL &&
aLabelNode->ThreadNo() == 0 ) {
}
else {
SomeDataNodes.push_back( aLabelNode ) ;
- cdebug << ThreadNo() << " Successed_SuccessAction push "
- << SomeDataNodes.size() << " " << aLabelNode->Name()
- << endl ;
+// cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " push "
+// << aLabelNode->Name() << " " << SomeDataNodes.size()
+// << endl ;
}
}
}
else {
- cdebug << ThreadNo()
- << " Successed_SuccessAction Loop to HeadNode "
- << aLabelNode->Name() << " with datas from " << Name() << "("
- << aBusParamOutPort->PortName() << ") to port "
- << aBusParamChangeInPort->PortName() << endl;
+// cdebug << ThreadNo()
+// << " Successed_SuccessAction Loop to HeadNode "
+// << aLabelNode->Name() << " with datas from " << Name() << "("
+// << aBusParamOutPort->PortName() << ") to port "
+// << aBusParamChangeInPort->PortName() << endl;
}
}
else {
- cdebug << ThreadNo() << " ERROR in Successed_SuccessAction of " << Name()
- << " NO port " << aBusParamOutPort->PortName() << " in "
- << aLabelNode->Name() << endl;
+// cdebug << ThreadNo() << " ERROR in Successed_SuccessAction of " << Name()
+// << " NO port " << aBusParamOutPort->PortName() << " in "
+// << aLabelNode->Name() << endl;
}
}
}
for ( j = 0 ; j < aLabelNode->GetNodeInPortsSize() ; j++ ) {
const GraphBase::InPort * anInPort = aLabelNode->GetNodeInPort( j ) ;
if ( anInPort->GetOutPort() ) {
- cdebug << aLabelNode->Name() << "(" << anInPort->PortName() << ") value : "
- << anInPort->GetOutPort()->NodeName() << "(" << anInPort->GetOutPort()->PortName() << ")"
- << endl ;
+// cdebug << aLabelNode->Name() << "(" << anInPort->PortName() << ") value : "
+// << anInPort->GetOutPort()->NodeName() << "(" << anInPort->GetOutPort()->PortName() << ")"
+// << endl ;
}
}
-// const GraphBase::OutPort * aGateOutPort = GetNodeOutPort( 0 ) ; // DoLoop or OutGate
const GraphBase::InPort * aGateInPort = aLabelNode->GetNodeInGate() ;
if ( aGateInPort ) {
if ( aGateInPort->GetOutPort() ) {
if ( firsttoNode == NULL &&
aLabelNode->ThreadNo() == pthread_self() ) {
firsttoNode = aLabelNode ;
- cdebug << ThreadNo() << " Successed_SuccessAction firsttoNode "
- << aLabelNode->Name() << endl ;
+// cdebug << ThreadNo() << " Successed_SuccessAction firsttoNode "
+// << aLabelNode->Name() << endl ;
}
else if ( firstzeroNode == NULL &&
aLabelNode->ThreadNo() == 0 ) {
}
else {
SomeDataNodes.push_back( aLabelNode ) ;
- cdebug << ThreadNo() << " Successed_SuccessAction push "
- << SomeDataNodes.size() << " " << aLabelNode->Name()
- << endl ;
+// cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " push "
+// << aLabelNode->Name() << " " << SomeDataNodes.size()
+// << endl ;
}
}
}
}
else {
- cdebug << ThreadNo() << " Successed_SuccessAction of " << Name()
- << " with " << LinkedNodesSize() << " linked nodes :" ;
+// cdebug << ThreadNo() << " Successed_SuccessAction of " << Name()
+// << " with " << LinkedNodesSize() << " linked nodes :" ;
for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
if ( LinkedNodes( i )->IsDataFlowNode() ) {
linkednodesnumber -= 1 ;
}
- cdebug << " " << LinkedNodes( i )->Name() ;
+// cdebug << " " << LinkedNodes( i )->Name() ;
}
- cdebug << endl;
-// SUPERV::ControlState aControl = ControlState() ;
+// cdebug << endl;
for ( i = 0 ; i < LinkedNodesSize() ; i++ ) {
bool IgnoreForEndLoop = false ;
toNode = (GraphExecutor::InNode *) LinkedNodes( i )->GetInNode() ;
- cdebug << ThreadNo() << " Successed_SuccessAction of " << Name()
- << " [" << i << "] " << LinkedNodes( i )->Name() << endl ;
+// cdebug << ThreadNo() << " Successed_SuccessAction of " << Name()
+// << " [" << i << "] " << LinkedNodes( i )->Name() << endl ;
if ( toNode && !toNode->IsDataFlowNode() ) {
if ( IsComputingNode() && toNode->IsInLineNode() ) {
GraphBase::InPort * toGateInPort = toNode->GetChangeNodeInGate() ;
}
else { // toNode is the EndLoopNode
GraphBase::InPort * toLoopInPort ;
-// toLoopInPort = toNode->GetChangeNodeInPort(1) ;
toLoopInPort = toNode->GetChangeNodeInLoop() ;
if ( toLoopInPort->State() != SUPERV::ReadyState ) {
toLoopInPort->State( SUPERV::ReadyState ) ;
}
if ( toNode && !IgnoreForEndLoop ) {
if ( toNode && toNode->IsLoopNode() ) {
-// GraphBase::InPort * toLoopInPort = toNode->GetChangeNodeInPort(1) ;
GraphBase::InPort * toLoopInPort = toNode->GetChangeNodeInLoop() ;
toLoopInPort->State( SUPERV::ReadyState ) ;
GraphBase::OutPort * LoopOutPort = toLoopInPort->GetOutPort() ;
if ( firsttoNode == NULL &&
toNode->ThreadNo() == pthread_self() ) {
firsttoNode = toNode ;
- cdebug << ThreadNo() << " Successed_SuccessAction firsttoNode "
- << toNode->Name() << endl ;
+// cdebug << ThreadNo() << " Successed_SuccessAction firsttoNode "
+// << toNode->Name() << endl ;
}
else if ( firstzeroNode == NULL &&
toNode->ThreadNo() == 0 ) {
}
else {
SomeDataNodes.push_back( toNode ) ;
- cdebug << ThreadNo() << " Successed_SuccessAction push "
- << SomeDataNodes.size() << " " << toNode->Name() << endl ;
+// cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " push "
+// << toNode->Name() << " " << SomeDataNodes.size() << endl ;
}
}
}
if ( firsttoNode == NULL && firstzeroNode ) {
firsttoNode = firstzeroNode ;
- cdebug << ThreadNo()
- << " Successed_SuccessAction firsttoNode = firstzeroNode "
- << endl ;
+// cdebug << ThreadNo()
+// << " Successed_SuccessAction firsttoNode = firstzeroNode "
+// << endl ;
}
else if ( firsttoNode && firstzeroNode ) {
SomeDataNodes.push_back( firstzeroNode ) ;
- cdebug << ThreadNo() << " Successed_SuccessAction push firstzeroNode "
- << SomeDataNodes.size() << " " << firstzeroNode->Name() << endl ;
+// cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " push firstzeroNode "
+// << firstzeroNode->Name() << " " << SomeDataNodes.size() << endl ;
}
while ( SomeDataNodes.size() ) {
GraphExecutor::InNode *aNode = SomeDataNodes.front() ;
SomeDataNodes.pop_front() ;
- cdebug << pthread_self() << "/" << ThreadNo()
- << " Successed_SuccessAction pop "
- << SomeDataNodes.size() << " " << aNode->Name() << endl ;
+// cdebug << pthread_self() << "/" << ThreadNo()
+// << " Successed_SuccessAction pop "
+// << SomeDataNodes.size() << " " << aNode->Name() << endl ;
if ( aNode->State() == SUPERV::DataReadyState ) {
aNode->CreateNewThreadIf( true ) ;
aNode->UnLockDataWait() ;
res = aNode->DataUndef_AllDataReadyAction() ;
}
else {
- cdebug << pthread_self() << "/" << ThreadNo() << " ERROR "
- << aNode->Name() << " "
- << Automaton()->StateName( aNode->State() ) << endl ;
+// cdebug << pthread_self() << "/" << ThreadNo() << " ERROR "
+// << aNode->Name() << " "
+// << Automaton()->StateName( aNode->State() ) << endl ;
}
}
if ( firsttoNode ) {
-// firsttoNode = SomeDataNodes.front() ;
-// SomeDataNodes.pop_front() ;
- cdebug << pthread_self() << "/" << ThreadNo()
- << " Successed_SuccessAction pop firsttoNode "
- << SomeDataNodes.size() << " " << firsttoNode->Name() << endl ;
+// cdebug << pthread_self() << "/" << ThreadNo()
+// << " Successed_SuccessAction start firsttoNode "
+// << SomeDataNodes.size() << " " << firsttoNode->Name() << endl ;
firsttoNode->CreateNewThreadIf( false ) ;
firsttoNode->RewindStack( RewindStack() ) ;
if ( firsttoNode->State() == SUPERV::SuccessedState ) {
- cdebug << pthread_self() << "/" << ThreadNo() << " " << Name()
- << " : " << firsttoNode->Name() << " "
- << Automaton()->StateName( firsttoNode->State() )
- << " --> DataWaitingState for Thread "
- << firsttoNode->ThreadNo() << endl ;
+// cdebug << pthread_self() << "/" << ThreadNo() << " " << Name()
+// << " : " << firsttoNode->Name() << " "
+// << Automaton()->StateName( firsttoNode->State() )
+// << " --> DataWaitingState for Thread "
+// << firsttoNode->ThreadNo() << endl ;
firsttoNode->State( SUPERV::DataWaitingState ) ;
}
- pthread_t OldT = firsttoNode->ThreadNo() ;
+// pthread_t OldT = firsttoNode->ThreadNo() ;
firsttoNode->ThreadNo( pthread_self() ) ;
// On continue avec le meme thread
- cdebug << pthread_self() << "/" << ThreadNo() << " firsttoNode "
- << firsttoNode->Name() << "Thread(" << OldT << "-->"
- << firsttoNode->ThreadNo() << ")" << endl ;
+// cdebug << pthread_self() << "/" << ThreadNo() << " firsttoNode "
+// << firsttoNode->Name() << "Thread(" << OldT << "-->"
+// << firsttoNode->ThreadNo() << ")" << endl ;
ThreadNo( 0 ) ;
- cdebug << ThreadNo() << " Successed_SuccessAction " << Name()
- << " for " << firsttoNode->Name()
- << " !firsttoNode->CreateNewThreadIf() "
- << !firsttoNode->CreateNewThreadIf()
- << " " << Automaton()->StateName( firsttoNode->State() ) ;
+// cdebug << ThreadNo() << " Successed_SuccessAction " << Name()
+// << " for " << firsttoNode->Name()
+// << " !firsttoNode->CreateNewThreadIf() "
+// << !firsttoNode->CreateNewThreadIf()
+// << " " << Automaton()->StateName( firsttoNode->State() ) ;
if ( firsttoNode->State() == SUPERV::DataReadyState ) {
cdebug << endl ;
firsttoNode->UnLockDataWait() ;
}
}
else {
- cdebug << ThreadNo() << " Successed_SuccessAction " << Name()
- << " NO DataReady ==> ThreadNo( 0 )" << endl ;
+// cdebug << ThreadNo() << " Successed_SuccessAction " << Name()
+// << " NO DataReady ==> ThreadNo( 0 ) firsttoNode == NULL LINKEDnodesnumber " << linkednodesnumber << endl ;
ThreadNo( 0 ) ;
}
- if ( linkednodesnumber == 0 ) {
- _OutNode->CheckAllDone() ;
- }
+// if ( linkednodesnumber == 0 && firsttoNode == NULL ) {
+// cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " LinkedNodesSize " << LinkedNodesSize()
+// << " firsttoNode == NULL LINKEDnodesnumber " << linkednodesnumber << " CHECK" << endl ;
+// _OutNode->CheckAllDone() ;
+// }
- cdebug << pthread_self() << "/" << ThreadNo()
- << " <-- Successed_SuccessAction " << Name() << " linkednodesnumber "
- << linkednodesnumber << endl;
+// cdebug << pthread_self() << "/" << ThreadNo()
+// << " <-- Successed_SuccessAction " << Name() << " linkednodesnumber "
+// << linkednodesnumber << endl;
return 1 ;
}
bool GraphExecutor::InNode::SendSomeDataReady( char * FromNodeName ) {
bool RetVal = false ;
if ( IsDataFlowNode() ) {
- cdebug << ThreadNo() << " ----> " << Name()
- << " send Result to graph " << Name() << endl;
+// cdebug << ThreadNo() << " ----> " << Name()
+// << " send Result to graph " << Name() << endl;
}
else {
- cdebug << pthread_self() << "/" << ThreadNo() << " ----> " << FromNodeName
- << " send SomeDataReady to " << Name() << " "
- << Automaton()->StateName( State() )
- << " CreateNewThreadIf() " << CreateNewThreadIf()
- << " LockedDataWait " << IsLockedDataWait() << endl;
+// cdebug << pthread_self() << "/" << ThreadNo() << " ----> " << FromNodeName
+// << " send SomeDataReady to " << Name() << " "
+// << Automaton()->StateName( State() )
+// << " CreateNewThreadIf() " << CreateNewThreadIf()
+// << " LockedDataWait " << IsLockedDataWait() << endl;
#if 0
cout << pthread_self() << "/" << ThreadNo() << " ----> " << FromNodeName
<< " send SomeDataReady to " << Name() << " "
if ( State() == SUPERV::SuccessedState ||
State() == SUPERV::SuspendedSuccessedState ||
State() == SUPERV::SuspendedSuccessedToReStartState ) {
- cdebug << ThreadNo() << " " << FromNodeName
- << " : " << Name() << " " << Automaton()->StateName( State() )
- << " --> DataWaitingState for Thread "
- << ThreadNo() << " " << endl ;
+// cdebug << ThreadNo() << " " << FromNodeName
+// << " : " << Name() << " " << Automaton()->StateName( State() )
+// << " --> DataWaitingState for Thread "
+// << ThreadNo() << " " << endl ;
State( SUPERV::DataWaitingState ) ;
}
LockDataWait() ;
return 1 ;
}
-void GraphExecutor::InNode::InParametersSet(
- bool & Err ,
- int nInParams ,
- ServicesAnyData * InParametersList ) {
+void GraphExecutor::InNode::InParametersSet( bool & Err ,
+ int nInParams ,
+ ServicesAnyData * InParametersList ) {
int i ;
for ( i = 0 ; i < nInParams ; i++ ) {
ServicesAnyData D = InParametersList[i];
}
}
-void GraphExecutor::InNode::InOutParametersSet(
- int nOutParams ,
- ServicesAnyData * OutParametersList ) {
+void GraphExecutor::InNode::InOutParametersSet( int nOutParams ,
+ ServicesAnyData * OutParametersList ) {
int i ;
for ( i = 0 ; i < nOutParams ; i++ ) {
ServicesAnyData D = OutParametersList[i] ;
}
}
-bool GraphExecutor::InNode::OutParametersSet(
- bool Err ,
- SUPERV::GraphState NewState ,
- int nOutParams ,
- ServicesAnyData * OutParametersList ) {
+bool GraphExecutor::InNode::OutParametersSet( bool Err ,
+ SUPERV::GraphState NewState ,
+ int nOutParams ,
+ ServicesAnyData * OutParametersList ) {
bool RetVal = true ;
int i ;
GraphBase::OutPort * aGateOutPort = NULL ;
PyInitialized( true ) ;
}
anInNode->InitialState( this ) ;
+ if ( anInNode->IsOneOfInLineNodes() ) {
+ anInNode->InitPythonFunctions( false ) ;
+ }
+ }
+// One more time because inline nodes may share one definition of the same function
+ for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
+ GraphExecutor::InNode * anInNode = (GraphExecutor::InNode *) GraphNodes( i )->GetInNode() ;
+ if ( anInNode->IsOneOfInLineNodes() ) {
+ if ( anInNode->InitPythonFunctions( true ) ) {
+ }
+ }
}
cdebug << "Execution starting GraphExecutor::Action_DataOk_RunService Node "
if ( anInNode->State() != SUPERV::DataReadyState ) {
cdebug << "GraphExecutor::OutNode::Run inconsistency State of Node "
<< anInNode->Name() << " : " << anInNode->State() << endl ;
+ cdebug_out << "GraphExecutor::OutNode::Run State ERROR" << endl ;
return false ;
}
// PushEvent( anInNode , GraphExecutor::ReadyEvent ,
if ( !anInNode->SendEvent( GraphExecutor::SomeDataReadyEvent ) ) {
cdebug << "InNode::SendEvent( SomeDataReadyEvent ) ERROR Node "
<< anInNode->Name() << endl ;
+ cdebug_out << "GraphExecutor::OutNode::Run SendEvent ERROR" << endl ;
return false ;
}
anInNode->SuspendedWait() ;
else if ( !anInNode->SendEvent( GraphExecutor::ExecuteEvent ) ) {
cdebug << "InNode::SendEvent( ExecuteEvent ) ERROR Node "
<< anInNode->Name() << endl ;
+ cdebug_out << "GraphExecutor::OutNode::Run SendEvent ERROR" << endl ;
return false ;
}
else {
SUPERV::AutomatonState OutNodeState = SUPERV::SuccessedState ;
SUPERV::AutomatonState InNodeState ;
bool AllDone = true ;
- if ( !_Done ) {
+ if ( !Done() ) {
for ( j = 0 ; j < QueueNodesSize() ; j++ ) {
InNodeState = ( (GraphExecutor::InNode * ) QueueNodes( j )->GetInNode() )->State() ;
cdebug << j << ". "
InNodeState != SUPERV::DataWaitingState ) {
AllDone = false ;
}
- if ( InNodeState != SUPERV::SuccessedState ) {
+ if ( InNodeState != SUPERV::SuccessedState &&
+ InNodeState != SUPERV::DataWaitingState &&
+ InNodeState != SUPERV::DataReadyState ) {
OutNodeState = InNodeState ;
}
}
}
}
if ( AllDone ) {
- State( OutNodeState ) ;
- _Done = true ;
- _JustStarted = false ;
+ int alivenodes = 0 ;
for ( j = 0 ; j < GraphNodesSize() ; j++ ) {
GraphExecutor::InNode * aNode ;
aNode = (GraphExecutor::InNode * ) GraphNodes( j )->GetInNode() ;
SUPERV::GraphState aState = AutomatonGraphState( aNode->State() ) ;
cdebug << "GraphExecutor::OutNode::CheckAllDone " << aNode->Name() << " "
- << theAutomaton->StateName( aNode->State() ) << " :" << endl ;
+ << theAutomaton->StateName( aNode->State() ) << " CreateNewThread " << aNode->CreateNewThread()
+ << endl ;
if ( aState == SUPERV::ErrorState ||
aState == SUPERV::SuspendErroredState ||
aState == SUPERV::KillState ||
aState == SUPERV::StopState ) {
OutNodeState = aNode->State() ;
+ State( OutNodeState ) ;
+ }
+ else if ( aState == SUPERV::ReadyState ||
+ aState == SUPERV::SuspendReadyState ||
+ aState == SUPERV::RunningState ||
+ aState == SUPERV::SuspendDoneState ||
+ aState == SUPERV::SuspendErroredState ||
+ aState == SUPERV::ReRunState ||
+ aState == SUPERV::ReStartState ||
+ aState == SUPERV::SuspendState ) {
+ alivenodes += 1 ;
}
aNode->SuspendedAction() ;
aNode->DoneAction() ;
}
// PushEvent AFTER State and _Done ! ...
+ if ( alivenodes == 0 ) {
+ State( OutNodeState ) ;
+ Done( true ) ;
+ _JustStarted = false ;
+ }
PushEvent( NULL , GraphExecutor::EndExecuteEvent ,
OutNodeState ) ;
// Py_Finalize() ;
// PyInitialized( false ) ;
}
}
- cdebug_out << "GraphExecutor::OutNode::CheckAllDone " << _Done
- << " GraphAutomatonState " << theAutomaton->StateName( AutomatonState() )
- << " State " << State() << " Threads " << _Threads << " SuspendedThreads "
- << _SuspendedThreads << endl ;
- if ( _Done ) {
+ if ( IsDone() ) {
MESSAGE("================================================================================") ;
- MESSAGE( Name() << " IS DONE" ) ;
+ MESSAGE( Name() << " IS DONE : " << theAutomaton->StateName( AutomatonState() ) << " EventQSize "
+ << EventQSize() ) ;
MESSAGE("================================================================================") ;
- }
+ cdebug << "================================================================================" << endl ;
+ cdebug << Name() << " IS DONE : " << theAutomaton->StateName( AutomatonState() ) << " EventQSize "
+ << EventQSize() << endl ;
+ cdebug << "================================================================================" << endl ;
+ //cout << Name() << " IS DONE : " << theAutomaton->StateName( AutomatonState() ) << " EventQSize "
+ // << EventQSize() << endl ;
+ }
+ cdebug_out << "GraphExecutor::OutNode::CheckAllDone " << IsDone()
+ << " GraphAutomatonState " << theAutomaton->StateName( AutomatonState() )
+ << " State " << State() << " Threads " << _Threads << " SuspendedThreads "
+ << _SuspendedThreads << " EventQSize " << EventQSize() << endl ;
}
void GraphExecutor::OutNode::PThreadLock( pthread_mutex_t * aMutex , char * errmsg ) {
perror( "GraphExecutor::OutNode::PyThreadLock" ) ;
exit( 0 ) ;
}
+ theAutomaton->PyLock() ;
// cout << " GraphExecutor::OutNode::PyThreadLocked " << pthread_self() << endl ;
}
perror( "GraphExecutor::OutNode::PyThreadUnLock" ) ;
exit( 0 ) ;
}
+ theAutomaton->PyUnLock() ;
// cout << " GraphExecutor::OutNode::PyThreadUnLocked " << pthread_self() << endl ;
}
exit( 0 ) ;
}
}
+
void GraphExecutor::OutNode::ExitThread() {
if ( pthread_mutex_lock( &_MutexWait ) ) {
perror("pthread_mutex_lock _ExitThread") ;
}
if ( _Threads == 0 && _SuspendedThreads == 0 ) {
CheckAllDone() ;
+ if ( IsDone() ) {
+ theAutomaton->Executed() ;
+ }
}
}
void GraphExecutor::OutNode::JoinedWait() {
exit( 0 ) ;
}
}
+
void GraphExecutor::OutNode::SuspendThread() {
if ( pthread_mutex_lock( &_MutexWait ) ) {
perror("pthread_mutex_lock _SuspendThread") ;
return aGraphState ;
}
+int GraphExecutor::OutNode::GetListSize() {
+ return _EventNodes.size();
+}
+
bool GraphExecutor::OutNode::PushEvent( GraphExecutor::InNode * aNode ,
GraphExecutor::NodeEvent anEvent ,
SUPERV::AutomatonState aState ) {
}
// cdebug_out << "PushEvent Threads " << Threads() << " SuspendedThreads "
// << SuspendedThreads() << endl ;
+#if 0
if ( _EventNodes.size() > 101 ) {
while ( _EventNodes.size() > 31 ) {
_EventNodes.pop_front() ;
_States.pop_front() ;
}
}
+#endif
if ( pthread_mutex_unlock( &_MutexWait ) ) {
perror("PushEvent pthread_mutex_unlock ") ;
exit( 0 ) ;
bool WithWait ) {
int ThreadsNumber ;
int SuspendedThreadsNumber ;
+ if ( _EventNodes.size() > 0 ) {
+ cdebug_in << "GraphExecutor::OutNode::Event " << _EventNodes.size() << " in queue" << endl ;
+ }
if ( pthread_mutex_lock( &_MutexWait ) ) {
perror("EventLoop pthread_mutex_lock ") ;
exit( 0 ) ;
SUPERV::AutomatonState theState = SUPERV::UnKnownState ;
anEvent = SUPERV::UndefinedEvent ;
aState = SUPERV::UndefinedState ;
- if ( ( IsDone() || IsKilled() || IsStopped() ) && _EventNodes.size() == 0 ) {
-// cdebug << "EventLoop IsDone()/IsKilled()/IsStopped() && _EventNodes.size() == 0" << endl ;
+ if ( ( Done() || IsKilled() || IsStopped() ) && _EventNodes.size() == 0 ) {
+// cdebug << "EventLoop Done()/IsKilled()/IsStopped() && _EventNodes.size() == 0" << endl ;
RetVal = false ;
}
else if ( !WithWait && _EventNodes.size() == 0 ) {
perror("EventLoop pthread_mutex_lock ") ;
exit( 0 ) ;
}
+ if ( _EventNodes.size() > 0 ) {
+ cdebug_out << "GraphExecutor::OutNode::Event " << _EventNodes.size() << " in queue" << endl ;
+ }
return RetVal ;
}
}
return RetVal ;
}
+long GraphExecutor::OutNode::EventQSize() {
+ return _EventNodes.size() ;
+}
+
+void GraphExecutor::OutNode::EventList() {
+ if ( pthread_mutex_lock( &_MutexWait ) ) {
+ perror("EventList pthread_mutex_lock ") ;
+ exit( 0 ) ;
+ }
+ list< char * >::iterator itEventNodes = _EventNodes.begin() ;
+ list< GraphExecutor::NodeEvent >::iterator itEvents = _Events.begin() ;
+ list< SUPERV::AutomatonState >::iterator itStates = _States.begin() ;
+ while ( itEventNodes != _EventNodes.end() ) {
+ cdebug << pthread_self() << "EVENTSTACK "
+ << *itEventNodes << " " << *itEvents << " "
+ << theAutomaton->StateName( *itStates )
+ << " Threads " << Threads() << " SuspendedThreads " << SuspendedThreads() << endl ;
+ itEventNodes++ ;
+ itEvents++ ;
+ itStates++ ;
+ }
+ if ( pthread_mutex_unlock( &_MutexWait ) ) {
+ perror("EventList pthread_mutex_lock ") ;
+ exit( 0 ) ;
+ }
+}
void GraphExecutor::OutNode::State(SUPERV::AutomatonState aState ) {
+// cdebug << "GraphExecutor::OutNode::State " << Name() << " "
+// << theAutomaton->StateName( AutomatonGraphState( _State ) ) << " ---> "
+// << theAutomaton->StateName( AutomatonGraphState( aState ) ) << endl ;
_State = aState ;
}
return AutomatonGraphState( aret ) ;
}
-SUPERV::GraphState GraphExecutor::OutNode::State(
- const char * NodeName ,
- const char * ServiceParameterName ) {
+SUPERV::GraphState GraphExecutor::OutNode::State( const char * NodeName ,
+ const char * ServiceParameterName ) {
// cdebug_in << "GraphExecutor::OutNode::State " << NodeName << " "
// << ServiceParameterName<< endl;
- SUPERV::GraphState aret =
- PortState( NodeName , ServiceParameterName ) ;
+ SUPERV::GraphState aret = PortState( NodeName , ServiceParameterName ) ;
// cdebug_out << "GraphExecutor::OutNode::State" << endl ;
return aret ;
}
bool GraphExecutor::OutNode::IsWaiting() {
// cdebug_in << "GraphExecutor::OutNode::IsWaiting" << endl;
// cdebug_out << "GraphExecutor::OutNode::IsWaiting" << endl ;
- return !_Done ;
+ return !IsDone() ;
}
bool GraphExecutor::OutNode::IsReady() {
// cdebug_in << "GraphExecutor::OutNode::IsReady" << endl;
// cdebug_out << "GraphExecutor::OutNode::IsReady" << endl ;
- return !_Done ;
+ return !IsDone() ;
}
bool GraphExecutor::OutNode::IsRunning() {
// cdebug_in << "GraphExecutor::OutNode::IsRunning" << endl;
// cdebug_out << "GraphExecutor::OutNode::IsRunning" << endl ;
- return !_Done ;
+ return !IsDone() ;
}
bool GraphExecutor::OutNode::IsDone() {
// cdebug_in << "GraphExecutor::OutNode::IsDone" << endl;
// cdebug_out << "GraphExecutor::OutNode::IsDone" << endl ;
- return ( _Done || IsKilled() || IsStopped() ) ;
+ return ( Done() || IsKilled() || IsStopped() ) ;
}
bool GraphExecutor::OutNode::IsSuspended() {
}
bool GraphExecutor::OutNode::Suspend() {
- bool RetVal = false ;
+ int RetVal = 0 ;
cdebug_in << "GraphExecutor::OutNode::Suspend" << endl;
- _ControlState = SUPERV::ToSuspendState ;
+// _ControlState = SUPERV::ToSuspendState ;
int i ;
for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) GraphNodes( i )->GetInNode() ;
bool sts = aNode->Suspend() ;
if ( sts && aNode->IsSuspended() ) {
- cdebug << aNode->Name() << " Suspend" << endl ;
+ RetVal += 1 ;
+ cdebug << aNode->Name() << " Suspended" << endl ;
}
else if ( aNode->IsWaiting() || aNode->IsDone() ) {
cdebug << aNode->Name() << " not Suspended : "
<< theAutomaton->StateName( aNode->State() ) << endl ;
}
else {
+ RetVal += 1 ;
cdebug << aNode->Name() << " cannot be Suspended : "
<< theAutomaton->StateName( aNode->State() ) << endl ;
- RetVal = false ;
}
}
- State( SUPERV::SuspendedState ) ;
- cdebug_out << "GraphExecutor::OutNode::Suspend" << endl ;
if ( RetVal ) {
+ State( SUPERV::SuspendedState ) ;
MESSAGE("================================================================================") ;
MESSAGE( Name() << " IS SUSPENDED" ) ;
MESSAGE("================================================================================") ;
}
+ else {
+ MESSAGE("================================================================================") ;
+ MESSAGE( Name() << " IS NOT SUSPENDED" ) ;
+ MESSAGE("================================================================================") ;
+ }
+ cdebug_out << "GraphExecutor::OutNode::Suspend" << theAutomaton->StateName( State() ) << endl ;
return RetVal ;
}
+
bool GraphExecutor::OutNode::Resume() {
- bool RetVal = false ;
+ int RetVal = 0 ;
cdebug_in << "GraphExecutor::OutNode::Resume" << endl;
- cdebug_out << "GraphExecutor::OutNode::Resume" << endl ;
+ if ( IsSuspended() ) {
+ State( SUPERV::ExecutingState ) ;
+ int i ;
+ for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
+ GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) GraphNodes( i )->GetInNode() ;
+ aNode->ControlState( SUPERV::VoidState ) ;
+ if ( aNode->IsSuspended() ) {
+ cdebug << aNode->Name() << "->Resume " << theAutomaton->StateName( aNode->State() )
+ << endl ;
+ if ( aNode->Resume() ) {
+ cdebug << aNode->Name() << " Resumed " << theAutomaton->StateName( aNode->State() )
+ << endl ;
+ RetVal += 1 ;
+ }
+ else {
+ cdebug << aNode->Name() << " Resume failed"
+ << theAutomaton->StateName( aNode->State() ) << endl ;
+ }
+ }
+ else {
+ cdebug << aNode->Name() << " " << theAutomaton->StateName( aNode->State() )
+ << endl ;
+ }
+ }
+ }
+ else {
+ cdebug << Name() << " not suspended " << theAutomaton->StateName( State() ) << endl ;
+ }
if ( RetVal ) {
MESSAGE("================================================================================") ;
MESSAGE( Name() << " IS RESUMED" ) ;
MESSAGE("================================================================================") ;
}
+ else {
+ MESSAGE("================================================================================") ;
+ MESSAGE( Name() << " IS NOT RESUMED" ) ;
+ MESSAGE("================================================================================") ;
+ }
+ cdebug_out << "GraphExecutor::OutNode::Resume" << theAutomaton->StateName( State() ) << " " << RetVal << endl ;
return RetVal ;
}
for ( i = 0 ; i < GraphNodesSize() ; i++ ) {
GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) GraphNodes( i )->GetInNode() ;
if ( !aNode->IsKilled() && !aNode->IsWaiting() && !aNode->IsDone() ) {
+ cdebug << aNode->Name() << " not killed : "
+ << theAutomaton->StateName( aNode->State() ) << " " << aNode->Name() << "->"
+ << "KilledAction()" << endl ;
aNode->KilledAction() ;
}
}
RetVal = true ;
}
State( SUPERV::KilledState ) ;
- cdebug_out << "GraphExecutor::OutNode::Kill" << endl ;
if ( RetVal ) {
MESSAGE("================================================================================") ;
MESSAGE( Name() << " IS KILLED" ) ;
MESSAGE("================================================================================") ;
}
+ else {
+ MESSAGE("================================================================================") ;
+ MESSAGE( Name() << " IS NOT KILLED" ) ;
+ MESSAGE("================================================================================") ;
+ }
+ cdebug_out << "GraphExecutor::OutNode::Kill" << endl ;
return RetVal ;
}
bool GraphExecutor::OutNode::Stop() {
bool RetVal = false ;
cdebug_in << "GraphExecutor::OutNode::Stop" << endl;
- Kill() ;
+ RetVal = Kill() ;
cdebug_out << "GraphExecutor::OutNode::Stop" << endl ;
if ( RetVal ) {
MESSAGE("================================================================================") ;
exit( 0 ) ;
}
aret = IsSuspended() ;
- while ( !aret && !_Done ) {
+ while ( !aret && !IsDone() ) {
pthread_cond_wait( &_EventWait , &_MutexWait );
aret = IsSuspended() ;
}
bool PushEvent( GraphExecutor::InNode * aNode ,
GraphExecutor::NodeEvent anEvent ,
SUPERV::AutomatonState aState ) ;
+ int GetListSize();
bool StateWait( SUPERV::GraphState aState ) ;
bool Event( char ** aNodeName ,
SUPERV::GraphEvent & anEvent ,
bool EventWait( char ** aNodeName ,
SUPERV::GraphEvent & anEvent ,
SUPERV::GraphState & aState ) ;
+ long EventQSize() ;
+ void EventList() ;
void State(SUPERV::AutomatonState aState ) ;
const char * StateName(SUPERV::AutomatonState aState ) {
bool ReRun() ;
bool ReStart() ;
- void Done( bool aDone ) { _Done = aDone ; } ;
-
bool IsWaiting() ;
bool IsReady() ;
bool IsRunning() ;
+ void Done( bool aDone ) { _Done = aDone ; } ;
+ bool Done() { return _Done ; } ;
bool IsDone() ;
bool IsSuspended() ;
bool IsKilled() ;
bool GraphExecutor::InNode::InitPython() {
cdebug_in << "InitPython" << endl ;
-
+
+ Automaton()->PyLock() ;
// PyObject * Module = Py_InitModule( "InitPyRunMethod" , MethodPyRunMethod ) ;
- Py_InitModule( "InitPyRunMethod" , MethodPyRunMethod ) ;
+ if ( !Automaton()->PyInitModule() ) {
+ Py_InitModule( "InitPyRunMethod" , MethodPyRunMethod ) ;
+ }
// PyObject * Dictionnary = PyModule_GetDict( Module ) ;
// InitPyDynInvokeError = PyErr_NewException( "InitPyDynInvokeError" , NULL , NULL ) ;
// PyDict_SetItemString( Dictionnary , InitPyDynInvokeError ) ;
cdebug << ThreadNo() << "Py_Initialized() " << endl ;
- string aPyFunc ;
-// aPyFunc = "print 'InitPyRunMethod'\n" ;
- aPyFunc = "import InitPyRunMethod\n" ;
-// aPyFunc += "print 'sys'\n" ;
- aPyFunc += "import sys\n" ;
-// aPyFunc += "print 'CORBA'\n" ;
- aPyFunc += "import CORBA\n" ;
-// aPyFunc += "print 'omniORB'\n" ;
- aPyFunc += "import omniORB\n" ;
-// aPyFunc += "print 'PyObjRef'\n" ;
- aPyFunc += "def PyObjRef( IORObjStr ) :\n" ;
-// aPyFunc += " print 'PyObjRef',IORObjStr\n" ;
- aPyFunc += " orb = CORBA.ORB_init( sys.argv , CORBA.ORB_ID )\n" ;
-// aPyFunc += " print 'PyObjRef orb',orb\n" ;
- aPyFunc += " objref = orb.string_to_object( IORObjStr )\n" ;
-// aPyFunc += " print 'PyObjRef IORObjStr objref',IORObjStr,objref\n" ;
- aPyFunc += " return objref\n" ;
- aPyFunc += "InitPyRunMethod.RunMethod( PyObjRef )\n" ;
- if ( PyRun_SimpleString( (char *) aPyFunc.c_str() ) ) {
- cdebug << ThreadNo() << " PyRun_SimpleString ERROR " << endl << aPyFunc << endl ;
- return false ;
+ if ( Automaton()->PyFunction( "PyObjRef" ) == NULL ) {
+ string aPyFunc ;
+// aPyFunc = "print 'InitPyRunMethod'\n" ;
+ aPyFunc = "import InitPyRunMethod\n" ;
+// aPyFunc += "print 'sys'\n" ;
+ aPyFunc += "import sys\n" ;
+// aPyFunc += "print 'CORBA'\n" ;
+ aPyFunc += "import CORBA\n" ;
+// aPyFunc += "print 'omniORB'\n" ;
+ aPyFunc += "import omniORB\n" ;
+// aPyFunc += "print 'PyObjRef'\n" ;
+ aPyFunc += "def PyObjRef( IORObjStr ) :\n" ;
+// aPyFunc += " print 'PyObjRef',IORObjStr\n" ;
+ aPyFunc += " orb = CORBA.ORB_init( sys.argv , CORBA.ORB_ID )\n" ;
+// aPyFunc += " print 'PyObjRef orb',orb\n" ;
+ aPyFunc += " objref = orb.string_to_object( IORObjStr )\n" ;
+// aPyFunc += " print 'PyObjRef IORObjStr objref',IORObjStr,objref\n" ;
+ aPyFunc += " return objref\n" ;
+ aPyFunc += "InitPyRunMethod.RunMethod( PyObjRef )\n" ;
+ if ( PyRun_SimpleString( (char *) aPyFunc.c_str() ) ) {
+ cdebug << ThreadNo() << " " << Name() << " PyRun_SimpleString ERROR " << endl << aPyFunc << endl ;
+ Automaton()->PyUnLock() ;
+ return false ;
+ }
+ MyPyObjRef = MyPyRunMethod ;
+ Automaton()->PyFunction( "PyObjRef" , MyPyObjRef ) ;
}
- MyPyObjRef = MyPyRunMethod ;
-
- aPyFunc = "import InitPyRunMethod\n" ;
- aPyFunc += "import sys\n" ;
- aPyFunc += "import CORBA\n" ;
- aPyFunc += "import omniORB\n" ;
- aPyFunc += "def PyObjIor( ObjRef ) :\n" ;
-// aPyFunc += " print 'PyObjIor',ObjRef\n" ;
- aPyFunc += " orb = CORBA.ORB_init( sys.argv , CORBA.ORB_ID )\n" ;
-// aPyFunc += " print 'PyObjIor orb',orb\n" ;
- aPyFunc += " objIor = orb.object_to_string( ObjRef )\n" ;
-// aPyFunc += " print 'PyObjIor ObjRef objIor',ObjRef,objIor\n" ;
- aPyFunc += " return objIor\n" ;
- aPyFunc += "InitPyRunMethod.RunMethod( PyObjIor )\n" ;
- if ( PyRun_SimpleString( (char *) aPyFunc.c_str() ) ) {
- cdebug << ThreadNo() << " PyRun_SimpleString ERROR " << endl << aPyFunc << endl ;
- return false ;
+ else {
+ MyPyObjRef = Automaton()->PyFunction( "PyObjRef" ) ;
+ }
+
+ if ( Automaton()->PyFunction( "PyObjIor" ) == NULL ) {
+ string aPyFunc ;
+ aPyFunc = "import InitPyRunMethod\n" ;
+ aPyFunc += "import sys\n" ;
+ aPyFunc += "import CORBA\n" ;
+ aPyFunc += "import omniORB\n" ;
+ aPyFunc += "def PyObjIor( ObjRef ) :\n" ;
+// aPyFunc += " print 'PyObjIor',ObjRef\n" ;
+ aPyFunc += " orb = CORBA.ORB_init( sys.argv , CORBA.ORB_ID )\n" ;
+// aPyFunc += " print 'PyObjIor orb',orb\n" ;
+ aPyFunc += " objIor = orb.object_to_string( ObjRef )\n" ;
+// aPyFunc += " print 'PyObjIor ObjRef objIor',ObjRef,objIor\n" ;
+ aPyFunc += " return objIor\n" ;
+ aPyFunc += "InitPyRunMethod.RunMethod( PyObjIor )\n" ;
+ if ( PyRun_SimpleString( (char *) aPyFunc.c_str() ) ) {
+ cdebug << ThreadNo() << " " << Name() << " PyRun_SimpleString ERROR " << endl << aPyFunc << endl ;
+ Automaton()->PyUnLock() ;
+ return false ;
+ }
+ MyPyObjIor = MyPyRunMethod ;
+ Automaton()->PyFunction( "PyObjIor" , MyPyObjIor ) ;
+ }
+ else {
+ MyPyObjIor = Automaton()->PyFunction( "PyObjIor" ) ;
}
- MyPyObjIor = MyPyRunMethod ;
+ Automaton()->PyUnLock() ;
cdebug_out << "InitPython" << endl ;
+
return true ;
}
-PyObject * GraphExecutor::InNode::InitPyDynInvoke(
- char * PyFuncName ,
- const SUPERV::ListOfStrings * aPythonFunction ) {
+PyObject * GraphExecutor::InNode::InitPyDynInvoke( char * PyFuncName ,
+ const SUPERV::ListOfStrings * aPythonFunction ) {
bool RetVal = true ;
string aPyFunc ;
+ PyObject * thePyRunMethod = NULL ;
- cdebug_in << "InitPyDynInvoke '" << PyFuncName << "' length "
- << (*aPythonFunction).length() << endl ;
+ cdebug_in << "InitPyDynInvoke '" << PyFuncName << "' length " << (*aPythonFunction).length() << endl ;
- if ( (*aPythonFunction).length() ) {
- unsigned int i ;
- aPyFunc += "import InitPyRunMethod\n" ;
- for ( i = 0 ; i < (*aPythonFunction).length() ; i++ ) {
- aPyFunc += (*aPythonFunction)[ i ] ;
- aPyFunc += "\n" ;
- }
- aPyFunc += "InitPyRunMethod.RunMethod( " ;
- aPyFunc += PyFuncName ;
- aPyFunc += " )\n" ;
- cdebug << "InitPyDynInvoke PyRun_SimpleString " << endl << aPyFunc << endl ;
- if ( PyRun_SimpleString( (char *) aPyFunc.c_str() ) ) {
- cdebug << ThreadNo() << " PyRun_SimpleString ERROR " << endl << aPyFunc << endl ;
- RetVal = false ;
- }
- else {
- PyFuncRunned( true ) ;
-// _MyPyRunMethod = MyPyRunMethod ; // To mutex
- cdebug << ThreadNo() << "PyRun_SimpleString( " << (*aPythonFunction)[ 0 ]
- << " )" << endl ;
+ if ( strlen( PyFuncName ) ) {
+ Automaton()->PyLock() ;
+ thePyRunMethod = Automaton()->PyFunction( PyFuncName ) ;
+ if ( (*aPythonFunction).length() ) {
+ if ( thePyRunMethod == NULL ) {
+ unsigned int i ;
+ aPyFunc += "import InitPyRunMethod\n" ;
+ for ( i = 0 ; i < (*aPythonFunction).length() ; i++ ) {
+ aPyFunc += (*aPythonFunction)[ i ] ;
+ aPyFunc += "\n" ;
+ }
+ aPyFunc += "InitPyRunMethod.RunMethod( " ;
+ aPyFunc += PyFuncName ;
+ aPyFunc += " )\n" ;
+ /*cdebug *///cout<< "InitPyDynInvoke PyRun_SimpleString " << endl << aPyFunc << endl ;
+ if ( PyRun_SimpleString( (char *) aPyFunc.c_str() ) ) {
+ cdebug << ThreadNo() << " " << Name() << " PyRun_SimpleString ERROR " << endl << aPyFunc << endl ;
+ RetVal = false ;
+ }
+ else {
+ PyFuncRunned( true ) ;
+ thePyRunMethod = MyPyRunMethod ;
+
+ Automaton()->PyFunction( PyFuncName , thePyRunMethod ) ;
+ cdebug << ThreadNo() << "PyRun_SimpleString( " << (*aPythonFunction)[ 0 ] << " ) " << endl ;
+ }
+ }
+ if ( RetVal ) {
+ Automaton()->PyUnLock() ;
+ cdebug_out << "InitPyDynInvoke '" << PyFuncName << "' thePyRunMethod " << thePyRunMethod << " "
+ << thePyRunMethod->ob_refcnt << endl ;
+ return thePyRunMethod ;
+ }
}
- cdebug_out << "InitPyDynInvoke" << endl ;
- if ( RetVal ) {
- return MyPyRunMethod ;
+ else if ( thePyRunMethod ) {
+ Automaton()->PyUnLock() ;
+ cdebug_out << "InitPyDynInvoke '" << PyFuncName << "' thePyRunMethod " << thePyRunMethod << " "
+ << thePyRunMethod->ob_refcnt << endl ;
+ return thePyRunMethod ;
}
+ Automaton()->PyUnLock() ;
}
+ cdebug_out << "InitPyDynInvoke '" << PyFuncName << "' thePyRunMethod Null" << endl ;
+
return NULL ;
}
extern "C" PyObject * PyRunMethod( PyObject * dummy , PyObject * Args ) {
-// cout << "PyRunMethod -->" << endl ;
PyObject * Result = NULL ;
PyObject * Temp = NULL ;
if ( PyArg_ParseTuple( Args , "O:set_callback" , & Temp ) ) {
Py_INCREF( Py_None ) ;
Result = Py_None ;
}
-// cout << "<-- PyRunMethod" << endl ;
return Result ;
}
int n_out = nOutParams ;
const char * sname;
- cdebug_in << ThreadNo() << "GraphExecutor::InNode::PyDynInvoke " << method << " " << n_in
- << " InArgs " << n_out << " OutArgs" << endl ;
+ cdebug_in << ThreadNo() << "GraphExecutor::InNode::PyDynInvoke Node " << Name() << " method " << method
+ << " " << n_in << " InArgs " << n_out << " OutArgs MyPyRunMethod " ;
+ if ( MyPyRunMethod ) {
+ cdebug << MyPyRunMethod << " " << MyPyRunMethod->ob_refcnt << endl ;
+ }
+ else {
+ cdebug << " NULL" << endl ;
+ return false ;
+ }
CORBA::Any data ;
CORBA::Object_ptr ObjRef ;
char * IORObjRef ;
- ArgsList = PyTuple_New( n_in ) ;
-
- for ( i = 0 ; i < n_in ; i++ ) {
- data = inParams[i].Value ;
- sname = inParams[i].Name.c_str() ;
- switch ( data.type()->kind() ) {
- case CORBA::tk_string : {
- char * t ;
- data >>= t ;
- ArgValue = Py_BuildValue( "s" , t ) ;
- PyTuple_SetItem( ArgsList , i , ArgValue ) ;
- cdebug << "ArgIn" << i << " : " << sname << " " << method << " Value " << t << " (string) "
- << " ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ArgValue->ob_refcnt"
- << ArgValue->ob_refcnt << endl ;
- break ;
- }
- case CORBA::tk_boolean : {
- bool b ;
- data >>= (CORBA::Any::to_boolean ) b ;
- ArgValue = Py_BuildValue( "b" , b ) ;
- PyTuple_SetItem( ArgsList , i , ArgValue ) ;
- cdebug << "ArgIn" << i << " : " << sname << " " << method << " Value " << b
- << " (boolean) ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ArgValue->ob_refcnt"
- << ArgValue->ob_refcnt << endl ;
- break ;
- }
- case CORBA::tk_char : {
- unsigned char c ;
- data >>= (CORBA::Any::to_char ) c ;
- ArgValue = Py_BuildValue( "c" , c ) ;
- PyTuple_SetItem( ArgsList , i , ArgValue ) ;
- cdebug << "ArgIn" << i << " : " << sname << " " << method << " Value " << c
- << " (char) ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ArgValue->ob_refcnt"
- << ArgValue->ob_refcnt << endl ;
- break ;
- }
- case CORBA::tk_short : {
- short s ;
- data >>= s ;
- ArgValue = Py_BuildValue( "h" , s ) ;
- PyTuple_SetItem( ArgsList , i , ArgValue ) ;
- cdebug << "ArgIn" << i << " : " << sname << " " << method << " Value " << s
- << " (short) ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ArgValue->ob_refcnt"
- << ArgValue->ob_refcnt << endl ;
- break ;
- }
- case CORBA::tk_long : {
- long l ;
- data >>= l ;
- ArgValue = Py_BuildValue( "l" , l ) ;
- PyTuple_SetItem( ArgsList , i , ArgValue ) ;
- cdebug << "ArgIn" << i << " : " << sname << " " << method << " Value " << l
- << " (long) ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ArgValue->ob_refcnt"
- << ArgValue->ob_refcnt << endl ;
- break ;
- }
- case CORBA::tk_float : {
- float f ;
- data >>= f ;
- ArgValue = Py_BuildValue( "f" , f ) ;
- PyTuple_SetItem( ArgsList , i , ArgValue ) ;
- cdebug << "ArgIn" << i << " : " << sname << " " << method << " Value " << f
- << " (float) ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ArgValue->ob_refcnt"
- << ArgValue->ob_refcnt << endl ;
- break ;
- }
- case CORBA::tk_double : {
- double d ;
- data >>= d ;
- ArgValue = Py_BuildValue( "d" , d ) ;
- PyTuple_SetItem( ArgsList , i , ArgValue ) ;
- cdebug << "ArgIn" << i << " : " << sname << " " << method << " Value " << d
- << " (double) ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ArgValue->ob_refcnt"
- << ArgValue->ob_refcnt << endl ;
- break ;
- }
- case CORBA::tk_objref : {
- MyPyObjRefList = PyTuple_New( 1 ) ;
- PyObject * ObjValue ;
- data >>= ObjRef ;
- IORObjRef = ObjectToString( ObjRef ) ;
- ObjValue = Py_BuildValue( "s" , IORObjRef ) ;
- PyTuple_SetItem( MyPyObjRefList , 0 , ObjValue ) ;
- cdebug << "ArgIn" << i << " : " << sname << " " << method << " " << " Value " << IORObjRef << " (objref) "
- << MyPyObjRef->ob_refcnt << "/" << MyPyObjRefList->ob_refcnt << endl ;
- ResultObj = PyEval_CallObject( MyPyObjRef , MyPyObjRefList ) ;
- cdebug << "ObjValue->ob_refcnt" << ObjValue->ob_refcnt << endl ;
- ArgValue = Py_BuildValue( "O" , ResultObj ) ;
- PyTuple_SetItem( ArgsList , i , ArgValue ) ;
- cdebug << "ArgIn" << i << " : " << sname << " " << method << " Value (objref) ArgsList->ob_refcnt"
- << ArgsList->ob_refcnt << " ArgValue->ob_refcnt" << ArgValue->ob_refcnt << endl ;
- cdebug << "MyPyObjRefList->ob_refcnt " << MyPyObjRefList->ob_refcnt-1 << endl ;
- Py_DECREF( MyPyObjRefList ) ;
- if ( CORBA::is_nil( ObjRef ) ) {
- ResultObj = NULL ;
+ if ( !PyCallable_Check( MyPyRunMethod ) ) {
+ Result = NULL ;
+ RetVal = false ;
+ }
+ else {
+ ArgsList = PyTuple_New( n_in ) ;
+
+ for ( i = 0 ; i < n_in ; i++ ) {
+ data = inParams[i].Value ;
+ sname = inParams[i].Name.c_str() ;
+ switch ( data.type()->kind() ) {
+ case CORBA::tk_string : {
+ char * t ;
+ data >>= t ;
+ ArgValue = Py_BuildValue( "s" , t ) ;
+ PyTuple_SetItem( ArgsList , i , ArgValue ) ;
+ cdebug << "ArgIn" << i << " : " << sname << " " << method << " Value " << t << " (string) "
+ << " ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ArgValue->ob_refcnt"
+ << ArgValue->ob_refcnt << endl ;
+ break ;
+ }
+ case CORBA::tk_boolean : {
+ bool b ;
+ data >>= (CORBA::Any::to_boolean ) b ;
+ ArgValue = Py_BuildValue( "b" , b ) ;
+ PyTuple_SetItem( ArgsList , i , ArgValue ) ;
+ cdebug << "ArgIn" << i << " : " << sname << " " << method << " Value " << b
+ << " (boolean) ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ArgValue->ob_refcnt"
+ << ArgValue->ob_refcnt << endl ;
+ break ;
+ }
+ case CORBA::tk_char : {
+ unsigned char c ;
+ data >>= (CORBA::Any::to_char ) c ;
+ ArgValue = Py_BuildValue( "c" , c ) ;
+ PyTuple_SetItem( ArgsList , i , ArgValue ) ;
+ cdebug << "ArgIn" << i << " : " << sname << " " << method << " Value " << c
+ << " (char) ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ArgValue->ob_refcnt"
+ << ArgValue->ob_refcnt << endl ;
+ break ;
+ }
+ case CORBA::tk_short : {
+ short s ;
+ data >>= s ;
+ ArgValue = Py_BuildValue( "h" , s ) ;
+ PyTuple_SetItem( ArgsList , i , ArgValue ) ;
+ cdebug << "ArgIn" << i << " : " << sname << " " << method << " Value " << s
+ << " (short) ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ArgValue->ob_refcnt"
+ << ArgValue->ob_refcnt << endl ;
+ break ;
+ }
+ case CORBA::tk_long : {
+ long l ;
+ data >>= l ;
+ ArgValue = Py_BuildValue( "l" , l ) ;
+ PyTuple_SetItem( ArgsList , i , ArgValue ) ;
+ cdebug << "ArgIn" << i << " : " << sname << " " << method << " Value " << l
+ << " (long) ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ArgValue->ob_refcnt"
+ << ArgValue->ob_refcnt << endl ;
+ break ;
+ }
+ case CORBA::tk_float : {
+ float f ;
+ data >>= f ;
+ ArgValue = Py_BuildValue( "f" , f ) ;
+ PyTuple_SetItem( ArgsList , i , ArgValue ) ;
+ cdebug << "ArgIn" << i << " : " << sname << " " << method << " Value " << f
+ << " (float) ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ArgValue->ob_refcnt"
+ << ArgValue->ob_refcnt << endl ;
+ break ;
+ }
+ case CORBA::tk_double : {
+ double d ;
+ data >>= d ;
+ ArgValue = Py_BuildValue( "d" , d ) ;
+ PyTuple_SetItem( ArgsList , i , ArgValue ) ;
+ cdebug << "ArgIn" << i << " : " << sname << " " << method << " Value " << d
+ << " (double) ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ArgValue->ob_refcnt"
+ << ArgValue->ob_refcnt << endl ;
+ break ;
+ }
+ case CORBA::tk_objref : {
+ MyPyObjRefList = PyTuple_New( 1 ) ;
+ PyObject * ObjValue ;
+ data >>= ObjRef ;
+ IORObjRef = ObjectToString( ObjRef ) ;
+ ObjValue = Py_BuildValue( "s" , IORObjRef ) ;
+ PyTuple_SetItem( MyPyObjRefList , 0 , ObjValue ) ;
+ cdebug << "ArgIn" << i << " : " << sname << " " << method << " " << " Value " << IORObjRef << " (objref) "
+ << MyPyObjRef->ob_refcnt << "/" << MyPyObjRefList->ob_refcnt << endl ;
+ ResultObj = PyEval_CallObject( MyPyObjRef , MyPyObjRefList ) ;
+ cdebug << "ObjValue->ob_refcnt" << ObjValue->ob_refcnt << endl ;
+ ArgValue = Py_BuildValue( "O" , ResultObj ) ;
+ PyTuple_SetItem( ArgsList , i , ArgValue ) ;
+ cdebug << "ArgIn" << i << " : " << sname << " " << method << " Value (objref) ArgsList->ob_refcnt"
+ << ArgsList->ob_refcnt << " ArgValue->ob_refcnt" << ArgValue->ob_refcnt << endl ;
+ cdebug << "MyPyObjRefList->ob_refcnt " << MyPyObjRefList->ob_refcnt-1 << endl ;
+ Py_DECREF( MyPyObjRefList ) ;
+ if ( CORBA::is_nil( ObjRef ) ) {
+ ResultObj = NULL ;
+ }
+ else {
+ cdebug << "ResultObj->ob_refcnt " << ResultObj->ob_refcnt-1 << endl ;
+ Py_DECREF( ResultObj ) ;
+ }
+ break ;
+ }
+ default : {
+ cdebug << "ArgIn" << i << " : " << sname << " Value " << "(other ERROR)" << endl ;
}
- else {
- cdebug << "ResultObj->ob_refcnt " << ResultObj->ob_refcnt-1 << endl ;
- Py_DECREF( ResultObj ) ;
}
- break ;
- }
- default : {
- cdebug << "ArgIn" << i << " : " << sname << " Value " << "(other ERROR)" << endl ;
- }
}
- }
- if (!PyCallable_Check( MyPyRunMethod )) {
- RetVal = false;
- return RetVal;
- }
- else {
Result = PyEval_CallObject( MyPyRunMethod , ArgsList ) ;
+
cdebug << "ArgsList->ob_refcnt" << ArgsList->ob_refcnt << endl ;
-
+
if ( Result == NULL ) {
- cdebug_out << "GraphExecutor::InNode::PyDynInvoke " << method << " Error Result == NULL" << endl ;
+ cdebug_out << "GraphExecutor::InNode::PyDynInvoke Node " << Name() << " " << method << " Error Result == NULL"
+ << endl ;
RetVal = false ;
}
else {
for ( i = 0 ; i < n_out ; i++ ) {
- data = outParams[i].Value ;
- sname = outParams[i].Name.c_str() ;
- switch ( data.type()->kind() ) {
- case CORBA::tk_string : {
- char * t = "" ;
- if ( PyTuple_Check( Result ) ) {
- ArgValue = PyTuple_GetItem( Result , i ) ;
- }
- else {
- ArgValue = Result ;
- }
- if ( !PyString_Check( ArgValue ) ) {
- cdebug << "ArgOut" << i << " : " << sname << " " << method << " ERROR (string)" << endl ;
- }
- else {
- t = PyString_AsString( ArgValue ) ;
- }
- data <<= t ;
- cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << t << " (string)"
- << " ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ArgValue->ob_refcnt"
- << ArgValue->ob_refcnt << endl ;
- break ;
- }
- case CORBA::tk_boolean : {
- bool b = false ;
- if ( PyTuple_Check( Result ) ) {
- ArgValue = PyTuple_GetItem( Result , i ) ;
- }
- else {
- ArgValue = Result ;
- }
- if ( !PyInt_Check( ArgValue ) ) {
- cdebug << "ArgOut" << i << " : " << sname << " " << method << " ERROR (boolean)" << endl ;
- }
- else {
- b = PyInt_AsLong( ArgValue ) ;
- }
- data <<= (CORBA::Any::from_boolean ) b ;
- cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << b << " (boolean)"
- << " ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ArgValue->ob_refcnt"
- << ArgValue->ob_refcnt << endl ;
- break ;
- }
- case CORBA::tk_char : {
- unsigned char c = 0 ;
- if ( PyTuple_Check( Result ) ) {
- ArgValue = PyTuple_GetItem( Result , i ) ;
- }
- else {
- ArgValue = Result ;
- }
- if ( !PyInt_Check( ArgValue ) ) {
- cdebug << "ArgOut" << i << " : " << sname << " " << method << " ERROR (char)" << endl ;
- }
- else {
- c = PyInt_AsLong( ArgValue ) ;
- }
- data <<= (CORBA::Any::from_char ) c ;
- cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << c << " (char)"
- << " ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ArgValue->ob_refcnt"
- << ArgValue->ob_refcnt << endl ;
- break ;
- }
- case CORBA::tk_short : {
- short s = 0 ;
- if ( PyTuple_Check( Result ) ) {
- ArgValue = PyTuple_GetItem( Result , i ) ;
- }
- else {
- ArgValue = Result ;
- }
- if ( !PyInt_Check( ArgValue ) ) {
- cdebug << "ArgOut" << i << " : " << sname << " " << method << " ERROR (short)" << endl ;
- }
- else {
- s = PyInt_AsLong( ArgValue ) ;
- }
- data <<= s ;
- cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << s << " (short)"
- << " ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ArgValue->ob_refcnt"
- << ArgValue->ob_refcnt << endl ;
- break ;
- }
- case CORBA::tk_long : {
- long l = 0 ;
- if ( PyTuple_Check( Result ) ) {
- ArgValue = PyTuple_GetItem( Result , i ) ;
- }
- else {
- ArgValue = Result ;
- }
- if ( PyLong_Check( ArgValue ) ) {
- l = PyLong_AsLong( ArgValue ) ;
- }
- else if ( PyInt_Check( ArgValue ) ) {
- l = PyInt_AsLong( ArgValue ) ;
- }
- else {
- cdebug << "ArgOut" << i << " : " << sname << " " << method << " ERROR (CORBA::tk_long)" << endl ;
- }
- data <<= l ;
- cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << l << " (long)"
- << " ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ArgValue->ob_refcnt"
- << ArgValue->ob_refcnt << endl ;
- break ;
- }
- case CORBA::tk_float : {
- float f = 0 ;
- if ( PyTuple_Check( Result ) ) {
- ArgValue = PyTuple_GetItem( Result , i ) ;
- }
- else {
- ArgValue = Result ;
- }
- if ( !PyFloat_Check( ArgValue ) ) {
- cdebug << "ArgOut" << i << " : " << sname << " " << method << " ERROR (float)" << endl ;
- }
- else {
- f = PyFloat_AsDouble( ArgValue ) ;
- }
- data <<= f ;
- cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << f << " (float)"
- << " ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ArgValue->ob_refcnt"
- << ArgValue->ob_refcnt << endl ;
- break ;
- }
- case CORBA::tk_double : {
- double d = 0 ;
- if ( PyTuple_Check( Result ) ) {
- ArgValue = PyTuple_GetItem( Result , i ) ;
- }
- else {
- ArgValue = Result ;
- }
- if ( !PyFloat_Check( ArgValue ) ) {
- cdebug << "ArgOut" << i << " : " << sname << " " << method << " ERROR (double)" << endl ;
- }
- else {
- d = PyFloat_AsDouble( ArgValue ) ;
- }
- data <<= d ;
- cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << d << " (double)"
- << " ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ArgValue->ob_refcnt"
- << ArgValue->ob_refcnt << endl ;
- break ;
- }
- case CORBA::tk_objref : {
- PyObject * ObjIor ;
- MyPyObjIorList = PyTuple_New( 1 ) ;
- if ( PyTuple_Check( Result ) ) {
- ObjIor = PyTuple_GetItem( Result , i ) ;
- }
- else {
- ObjIor = Result ;
- }
- cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << "(object reference) "
- << " ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ObjIor->ob_refcnt"
- << ObjIor->ob_refcnt << endl ;
- Py_INCREF( ObjIor ) ;
-// PyObject_Print( ObjIor , stdout , 0 ) ;
- PyTuple_SetItem( MyPyObjIorList , 0 , ObjIor ) ;
- ResultIor = PyEval_CallObject( MyPyObjIor , MyPyObjIorList ) ;
- cdebug << "ObjIor->ob_refcnt " << ObjIor->ob_refcnt-1 << endl ;
- Py_DECREF( ObjIor ) ;
- cdebug << "MyPyObjIorList->ob_refcnt " << MyPyObjIorList->ob_refcnt-1 << endl ;
- Py_DECREF( MyPyObjIorList ) ;
- cdebug << "MyPyObjIor->ob_refcnt " << MyPyObjIor->ob_refcnt << endl ;
- if ( ResultIor ) {
- char * IOR = NULL ;
- IOR = PyString_AsString( ResultIor ) ;
- ObjRef = StringToObject( IOR ) ;
- data <<= ObjRef ;
- IORObjRef = ObjectToString( ObjRef ) ;
- cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << IORObjRef << " (objref) "
- << endl ;
- if ( CORBA::is_nil( ObjRef ) ) {
- ResultIor = NULL ;
- }
- else {
- cdebug << "ResultIor->ob_refcnt " << ResultIor->ob_refcnt-1 << endl ;
- Py_DECREF( ResultIor ) ;
+ data = outParams[i].Value ;
+ sname = outParams[i].Name.c_str() ;
+ switch ( data.type()->kind() ) {
+ case CORBA::tk_string : {
+ char * t = "" ;
+ if ( PyTuple_Check( Result ) ) {
+ ArgValue = PyTuple_GetItem( Result , i ) ;
+ }
+ else {
+ ArgValue = Result ;
+ }
+ if ( !PyString_Check( ArgValue ) ) {
+ cdebug << "ArgOut" << i << " : " << sname << " " << method << " ERROR (string)" << endl ;
+ }
+ else {
+ t = PyString_AsString( ArgValue ) ;
+ }
+ data <<= t ;
+ cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << t << " (string)"
+ << " ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ArgValue->ob_refcnt"
+ << ArgValue->ob_refcnt << endl ;
+ break ;
+ }
+ case CORBA::tk_boolean : {
+ bool b = false ;
+ if ( PyTuple_Check( Result ) ) {
+ ArgValue = PyTuple_GetItem( Result , i ) ;
+ }
+ else {
+ ArgValue = Result ;
+ }
+ if ( !PyInt_Check( ArgValue ) ) {
+ cdebug << "ArgOut" << i << " : " << sname << " " << method << " ERROR (boolean)" << endl ;
+ }
+ else {
+ b = PyInt_AsLong( ArgValue ) ;
+ }
+ data <<= (CORBA::Any::from_boolean ) b ;
+ cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << b << " (boolean)"
+ << " ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ArgValue->ob_refcnt"
+ << ArgValue->ob_refcnt << endl ;
+ break ;
+ }
+ case CORBA::tk_char : {
+ unsigned char c = 0 ;
+ if ( PyTuple_Check( Result ) ) {
+ ArgValue = PyTuple_GetItem( Result , i ) ;
+ }
+ else {
+ ArgValue = Result ;
+ }
+ if ( !PyInt_Check( ArgValue ) ) {
+ cdebug << "ArgOut" << i << " : " << sname << " " << method << " ERROR (char)" << endl ;
+ }
+ else {
+ c = PyInt_AsLong( ArgValue ) ;
+ }
+ data <<= (CORBA::Any::from_char ) c ;
+ cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << c << " (char)"
+ << " ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ArgValue->ob_refcnt"
+ << ArgValue->ob_refcnt << endl ;
+ break ;
+ }
+ case CORBA::tk_short : {
+ short s = 0 ;
+ if ( PyTuple_Check( Result ) ) {
+ ArgValue = PyTuple_GetItem( Result , i ) ;
+ }
+ else {
+ ArgValue = Result ;
+ }
+ if ( !PyInt_Check( ArgValue ) ) {
+ cdebug << "ArgOut" << i << " : " << sname << " " << method << " ERROR (short)" << endl ;
+ }
+ else {
+ s = PyInt_AsLong( ArgValue ) ;
+ }
+ data <<= s ;
+ cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << s << " (short)"
+ << " ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ArgValue->ob_refcnt"
+ << ArgValue->ob_refcnt << endl ;
+ break ;
+ }
+ case CORBA::tk_long : {
+ long l = 0 ;
+ if ( PyTuple_Check( Result ) ) {
+ ArgValue = PyTuple_GetItem( Result , i ) ;
+ }
+ else {
+ ArgValue = Result ;
+ }
+ if ( PyLong_Check( ArgValue ) ) {
+ l = PyLong_AsLong( ArgValue ) ;
+ }
+ else if ( PyInt_Check( ArgValue ) ) {
+ l = PyInt_AsLong( ArgValue ) ;
+ }
+ else {
+ cdebug << "ArgOut" << i << " : " << sname << " " << method << " ERROR (CORBA::tk_long)" << endl ;
+ }
+ data <<= l ;
+ cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << l << " (long)"
+ << " ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ArgValue->ob_refcnt"
+ << ArgValue->ob_refcnt << endl ;
+ break ;
+ }
+ case CORBA::tk_float : {
+ float f = 0 ;
+ if ( PyTuple_Check( Result ) ) {
+ ArgValue = PyTuple_GetItem( Result , i ) ;
+ }
+ else {
+ ArgValue = Result ;
+ }
+ if ( !PyFloat_Check( ArgValue ) ) {
+ cdebug << "ArgOut" << i << " : " << sname << " " << method << " ERROR (float)" << endl ;
+ }
+ else {
+ f = PyFloat_AsDouble( ArgValue ) ;
+ }
+ data <<= f ;
+ cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << f << " (float)"
+ << " ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ArgValue->ob_refcnt"
+ << ArgValue->ob_refcnt << endl ;
+ break ;
+ }
+ case CORBA::tk_double : {
+ double d = 0 ;
+ if ( PyTuple_Check( Result ) ) {
+ ArgValue = PyTuple_GetItem( Result , i ) ;
+ }
+ else {
+ ArgValue = Result ;
+ }
+ if ( !PyFloat_Check( ArgValue ) ) {
+ cdebug << "ArgOut" << i << " : " << sname << " " << method << " ERROR (double)" << endl ;
+ }
+ else {
+ d = PyFloat_AsDouble( ArgValue ) ;
+ }
+ data <<= d ;
+ cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << d << " (double)"
+ << " ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ArgValue->ob_refcnt"
+ << ArgValue->ob_refcnt << endl ;
+ break ;
+ }
+ case CORBA::tk_objref : {
+ PyObject * ObjIor ;
+ MyPyObjIorList = PyTuple_New( 1 ) ;
+ if ( PyTuple_Check( Result ) ) {
+ ObjIor = PyTuple_GetItem( Result , i ) ;
+ }
+ else {
+ ObjIor = Result ;
+ }
+ cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << "(object reference) "
+ << " ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ObjIor->ob_refcnt"
+ << ObjIor->ob_refcnt << endl ;
+ Py_INCREF( ObjIor ) ;
+// PyObject_Print( ObjIor , stdout , 0 ) ;
+ PyTuple_SetItem( MyPyObjIorList , 0 , ObjIor ) ;
+ ResultIor = PyEval_CallObject( MyPyObjIor , MyPyObjIorList ) ;
+ cdebug << "ObjIor->ob_refcnt " << ObjIor->ob_refcnt-1 << endl ;
+ Py_DECREF( ObjIor ) ;
+ cdebug << "MyPyObjIorList->ob_refcnt " << MyPyObjIorList->ob_refcnt-1 << endl ;
+ Py_DECREF( MyPyObjIorList ) ;
+ cdebug << "MyPyObjIor->ob_refcnt " << MyPyObjIor->ob_refcnt << endl ;
+ if ( ResultIor ) {
+ char * IOR = NULL ;
+ IOR = PyString_AsString( ResultIor ) ;
+ ObjRef = StringToObject( IOR ) ;
+ data <<= ObjRef ;
+ IORObjRef = ObjectToString( ObjRef ) ;
+ cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << IORObjRef << " (objref) "
+ << endl ;
+ if ( CORBA::is_nil( ObjRef ) ) {
+ ResultIor = NULL ;
+ }
+ else {
+ cdebug << "ResultIor->ob_refcnt " << ResultIor->ob_refcnt-1 << endl ;
+ Py_DECREF( ResultIor ) ;
}
}
- else {
- cdebug_out << "GraphExecutor::InNode::PyDynInvoke Error ResultIor == NULL"
- << method << " " << endl ;
- RetVal = false ;
- }
- break ;
- }
- default : {
- cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << "(other ERROR)" << endl ;
- }
- }
- outParams[i].Value = data ;
+ else {
+ cdebug_out << "GraphExecutor::InNode::PyDynInvoke Error ResultIor == NULL Node "
+ << Name() << " method " << method << " " << endl ;
+ RetVal = false ;
+ }
+ break ;
+ }
+ default : {
+ cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << "(other ERROR)" << endl ;
+ }
+ }
+ outParams[i].Value = data ;
}
-
+
cdebug << "Result->ob_refcnt" << Result->ob_refcnt-1 << endl ;
Py_DECREF( Result ) ;
}
-
+
cdebug << "GraphExecutor::InNode::PyDynInvoke ArgsList->ob_refcnt"
- << ArgsList->ob_refcnt-1 << endl ;
+ << ArgsList->ob_refcnt-1 << endl ;
Py_DECREF( ArgsList ) ;
-
- cdebug_out << "GraphExecutor::InNode::PyDynInvoke " << method << endl ;
-
- return RetVal ;
}
+ cdebug_out << "GraphExecutor::InNode::PyDynInvoke Node " << Name() << " method " << method << " " << RetVal
+ << endl ;
+
+ return RetVal ;
+
}
BIN_SRC =
BIN_SERVER_IDL =
-CPPFLAGS+= $(PYTHON_INCLUDES) $(QT_MT_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome
-CXXFLAGS= -g -D_DEBUG_ -D__x86__ -D__linux__ -ftemplate-depth-42 -I${KERNEL_ROOT_DIR}/include/salome
+CPPFLAGS+= $(PYTHON_INCLUDES) $(QT_MT_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) \
+ -I${KERNEL_ROOT_DIR}/include/salome
+#CXXFLAGS= -g -D_DEBUG_ -D__x86__ -D__linux__ -ftemplate-depth-42 -Wno-deprecated
+CXXFLAGS= -g -D_DEBUG_ -D__x86__ -D__linux__ -ftemplate-depth-42 -Wall \
+ -I${KERNEL_ROOT_DIR}/include/salome
#LDFLAGS+= -lSalomeNS -lSalomeLifeCycleCORBA -lSalomeSuperVisionBase -lOpUtil -lSalomeLoggerServer -lc $(PYTHON_LIBS) $(QT_MT_LIBS) $(OGL_LIBS)
-LDFLAGS+= -export-dynamic -lSalomeNS -lSalomeLifeCycleCORBA -lSalomeSuperVisionBase -lOpUtil -lSALOMELocalTrace -lc $(QT_MT_LIBS) $(OGL_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome
+LDFLAGS+= -export-dynamic -lSalomeNS -lSalomeLifeCycleCORBA -lSalomeSuperVisionBase -lOpUtil -lSalomeLoggerServer \
+ -lc $(QT_MT_LIBS) $(OGL_LIBS) \
+ -L${KERNEL_ROOT_DIR}/lib/salome
@CONCLUDE@
CPPFLAGS+=$(QT_INCLUDES) $(PYTHON_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) \
-ftemplate-depth-42 -I${KERNEL_ROOT_DIR}/include/salome
-LDFLAGS+=$(QT_MT_LIBS) $(OCC_LIBS) $(VTK_LIBS) $(OGL_LIBS) \
+LDFLAGS+=$(QT_MT_LIBS) $(VTK_LIBS) $(OGL_LIBS) $(PYTHON_LIBS)\
-lSalomeGUI -lSalomeNS -lqsplitterP \
-lSalomeLifeCycleCORBA -lSalomeNotification -lSUPERVGraph \
- -L${KERNEL_ROOT_DIR}/lib/salome
+ -L${KERNEL_ROOT_DIR}/lib/salome
LIBS+= $(PYTHON_LIBS)
SUPERV::SuperG_var aSuperVisionComponent;
aSuperVisionComponent = SUPERV::SuperG::_narrow(objComponent);
- if (CORBA::is_nil(aSuperVisionComponent)) {
+ if (CORBA::is_nil(aSuperVisionComponent)) {
QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_NARROW_SUPERV"));
return;
};
if (comp->FindAttribute(anAttr, "AttributeName")) {
aName = SALOMEDS::AttributeName::_narrow(anAttr);
QString compName(aName->Value());
- // if (compName.compare(STUDY_SUPERVISION) == 0) {
- if (compName.compare( QAD_Application::getDesktop()->getComponentUserName( "SUPERV" ) ) == 0) {
+ //if (compName.compare(STUDY_SUPERVISION) == 0) {
+ if (compName.compare(QAD_Application::getDesktop()->getComponentUserName("SUPERV")) == 0) {
SALOMEDS::GenericAttribute_var anAttr;
if (obj->FindAttribute(anAttr, "AttributeIOR")) {
SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
{
return (int)VIEW_GRAPHSUPERV;
}
+
+extern "C" void buildPresentation ( const Handle(SALOME_InteractiveObject)& theIO )
+{
+}
#ifndef SUPERVGUI_BrowseNodeDlg_H
#define SUPERVGUI_BrowseNodeDlg_H
-using namespace std;
#include <qdialog.h>
#include "SUPERVGUI_Def.h"
#include "SUPERVGUI_Port.h"
void SUPERVGUI_StartControlNode::remove() {
myEndNode->deleteLinks();
deleteLinks();
- myEndNode->getEngine()->destroy();
myNode->destroy();
myMain->getGraph()->deleteNode(myEndNode);
myMain->getGraph()->deleteNode(this);
void SUPERVGUI_StartControlNode::deletePort(SUPERVGUI_Port* thePort) {
if (getNodeType() == SUPERV::LoopNode) {
+
SUPERV_Port aPortEngine = thePort->getPort();
QString aName(aPortEngine->Name());
QString aNameIn = aName + "Input";
myPIcount--;
myPOcount--;
+
myEndNode->getPIcount()--;
myEndNode->getPOcount()--;
-
+
aPortEngine->destroy();
+
updatePorts();
updateShape();
myEndNode->updatePorts();
myPortsBox->reparent(this, pos());
- myPIcount = 0;
- myPOcount = 0;
- SUPERV_Ports ports = myNode->Ports();
- int n = ports->length();
-
- for (int i=0; i<n; i++) {
- if (ports[i]->IsInput()) {
- if (getComputingNode()->IsEndSwitch()) {
- if (ports[i]->IsGate())
- myGatesLayout->addWidget(new SUPERVGUI_PortInESNode(myGatesBox, myMain, ports[i]),
- 0, 0);
- else {
- myPortLayout->addWidget(new SUPERVGUI_PortInESNode(myValuesBox, myMain, ports[i]),
- myPIcount, 0);
- myPIcount++;
- }
- } else {
- if (ports[i]->IsGate())
- myGatesLayout->addWidget(new SUPERVGUI_PortIn(myGatesBox, myMain, ports[i]),
- 0, 0);
- else {
- myPortLayout->addWidget(new SUPERVGUI_PortIn(myValuesBox, myMain, ports[i]),
- myPIcount, 0);
- myPIcount++;
- }
- }
- } else {
- if (ports[i]->IsGate())
- myGatesLayout->addWidget(new SUPERVGUI_PortOut(myGatesBox, myMain, ports[i]),
- 0, 1, Qt::AlignRight);
- else {
- myPortLayout->addWidget(new SUPERVGUI_PortOut(myValuesBox, myMain, ports[i]),
- myPOcount, 1, Qt::AlignRight);
- myPOcount++;
- }
- }
- }
aGridLayout->addMultiCellWidget(myPortsBox, 1, 1, 1, 2);
-
+
myStatus->reparent(this, pos());
myTime->reparent(this, pos());
aGridLayout->addMultiCellWidget(myStatus, 2, 2, 0, 1);
#define MAIN_NEW "aNewDataFlow"
-#define MAIN_COLOR QColor(165, 255, 176)
+#define MAIN_COLOR QColor(144, 208, 211)
#define MAIN_TITLE QColor( 63, 213, 255)
#define MAIN_CTRL QColor(255, 108, 106)
#define MAIN_BACK QColor(NODE_RED, NODE_GREEN, NODE_BLUE)
#include "SUPERVGUI_Main.h"
#include "SUPERVGUI_ComputeNode.h"
#include "SUPERVGUI_ControlNode.h"
+#include "SUPERVGUI.h"
//#define CHECKTIME
void SUPERVGUI_Graph::deleteLink(SUPERVGUI_Link* theLink) {
- theLink->destroyEngine();
+ //update values of input ports of theLink if theLink is deleted
+ if ( theLink->getInputPort() ) {
+ //input port exist
+ SUPERVGUI_PortIn* aInPort = theLink->getInputPort();
+ if (aInPort->getPort()->IsParam() || aInPort->getPort()->IsInLine()) {
+ QString aPortValue = QString(aInPort->getPort()->ToString());
+ if (!aPortValue.isNull()) {
+ //gives a value to an input port
+ theLink->destroyEngine();
+ aInPort->getPort()->Input( Supervision.getEngine()->StringValue( aPortValue ) );
+ aInPort->sync();
+ }
+ }
+ }
+ else
+ theLink->destroyEngine();
+
myLinksList.removeRef(theLink);
if (myLinksList.count() == 0) clearView();
}
myPOcount = 0;
SUPERV_Ports ports = myNode->Ports();
int n = ports->length();
-
+
for (int i=0; i<n; i++) {
if (ports[i]->IsInput()) {
- if (ports[i]->IsGate())
- myGatesLayout->addWidget(new SUPERVGUI_PortIn(myGatesBox, myMain, ports[i]),
- 0, 0);
- else {
- myPortLayout->addWidget(new SUPERVGUI_PortIn(myValuesBox, myMain, ports[i]),
- myPIcount, 0);
- myPIcount++;
+ if (getComputingNode()->IsEndSwitch()) {
+ if (ports[i]->IsGate())
+ myGatesLayout->addWidget(new SUPERVGUI_PortInESNode(myGatesBox, myMain, ports[i]),
+ 0, 0);
+ else {
+ myPortLayout->addWidget(new SUPERVGUI_PortInESNode(myValuesBox, myMain, ports[i]),
+ myPIcount, 0);
+ myPIcount++;
+ }
+ } else {
+ if (ports[i]->IsGate())
+ myGatesLayout->addWidget(new SUPERVGUI_PortIn(myGatesBox, myMain, ports[i]),
+ 0, 0);
+ else {
+ myPortLayout->addWidget(new SUPERVGUI_PortIn(myValuesBox, myMain, ports[i]),
+ myPIcount, 0);
+ myPIcount++;
+ }
}
} else {
if (ports[i]->IsGate())
}
}
}
+
}
* If toCheckExisting = true the existing of links will be checked before creation
*/
void SUPERVGUI_GraphNode::updateLinksPrs(bool toCheckExisting) {
+
SUPERVGUI_Graph* aGraph= myMain->getGraph();
- SUPERVGUI_PortIn* pi;
- QObjectList* ihmList = queryList("SUPERVGUI_PortIn");
- QObjectListIt i(*ihmList);
- while ((pi=(SUPERVGUI_PortIn*)i.current()) != 0) {
- ++i;
- if (pi->getPort()->IsLinked()) {
- SUPERV_Link aLink = pi->getPort()->Link();
- if (toCheckExisting) {
- if (aGraph->isLinkPrsExists(aLink))
- continue;
- }
- aGraph->createLinkPrs(aLink);
- }
- }
- delete ihmList;
-
//Find PortInESNode
SUPERVGUI_PortInESNode* piES;
QObjectList* ihmListES = queryList("SUPERVGUI_PortInESNode");
QObjectListIt iES(*ihmListES);
- while ((piES=(SUPERVGUI_PortInESNode*)iES.current()) != 0) {
- ++iES;
- if (piES->getPort()->IsLinked()) {
- SUPERV_Links aLinks = piES->getPort()->Links();
- for (int j=0; j<aLinks->length(); j++) {
+ if (iES.count()) {
+ while ((piES=(SUPERVGUI_PortInESNode*)iES.current()) != 0) {
+ ++iES;
+ if (piES->getPort()->IsLinked()) {
+ SUPERV_Links aLinks = piES->getPort()->Links();
+ for (int j=0; j<aLinks->length(); j++) {
+ if (toCheckExisting) {
+ if (aGraph->isLinkPrsExists(aLinks[j]))
+ continue;
+ }
+ aGraph->createLinkPrs(aLinks[j]);
+ }
+ }
+ }
+ }
+ else {
+ SUPERVGUI_PortIn* pi;
+ QObjectList* ihmList = queryList("SUPERVGUI_PortIn");
+ QObjectListIt i(*ihmList);
+ while ((pi=(SUPERVGUI_PortIn*)i.current()) != 0) {
+ ++i;
+ if (pi->getPort()->IsLinked()) {
+ SUPERV_Link aLink = pi->getPort()->Link();
if (toCheckExisting) {
- if (aGraph->isLinkPrsExists(aLinks[j]))
+ if (aGraph->isLinkPrsExists(aLink))
continue;
}
- aGraph->createLinkPrs(aLinks[j]);
+ aGraph->createLinkPrs(aLink);
}
}
+ delete ihmList;
}
+
delete ihmListES;
}
thePort->deleteLinks();
thePort->getPort()->destroy();
+
thePort->close(true);
+
updatePorts();
updateShape();
}
QObjectListIt aLI(*aShownPortsList);
SUPERVGUI_Port* aVisPort;
+
while ((aVisPort=(SUPERVGUI_Port*)aLI.current()) != 0) {
++aLI;
QString aNameVisible(aVisPort->getPort()->Name());
#include "SUPERVGUI_Node.h"
#include <qlayout.h>
+
class SUPERVGUI_GraphNode: public SUPERVGUI_Node {
Q_OBJECT
x = x * x;
int y = y2 - y1;
y = y * y;
- return (int) sqrt(double(x + y));
+ return (int) sqrt((double)(x + y));
}
r = r * r;
s = py - ly;
s = s * s;
- a = (int) sqrt(double(r + s));
+ a = (int) sqrt((double)(r + s));
r = px - nx;
r = r * r;
s = py - ny;
s = s * s;
- b = (int) sqrt(double(r + s));
+ b = (int) sqrt((double)(r + s));
r = nx - lx;
r = r * r;
s = ny - ly;
s = s * s;
- c = (int) sqrt(double(r + s));
+ c = (int) sqrt((double)(r + s));
return (a+b-c);
}
#define SUPERVGUI_Link_H
using namespace std;
+
#include "SUPERVGUI_Def.h"
#include "SUPERVGUI_Port.h"
#include <qvaluevector.h>
choosing = false;
myIsLocked = false;
+ myThread = new SUPERVGUI_Thread();
+ myThread->setMain(this);
+
myIsKilled = false;
//myIsRunned = false;
myCurrentView = GRAPH;
myIsFromStudy = false;
study = theDesktop->getActiveStudy();
- timer = new QTimer(this);
- connect(timer, SIGNAL(timeout()), this, SLOT(execute()));
-
- SALOMEDS::Study_var studyDoc = study->getStudyDocument();
- SALOMEDS::StudyBuilder_var builder = studyDoc->NewBuilder();
- SALOMEDS::SComponent_var father = studyDoc->FindComponent(STUDY_SUPERVISION);
- SALOMEDS::GenericAttribute_var anAttr;
- SALOMEDS::AttributeName_var aName;
- SALOMEDS::AttributePixMap_var aPixmap;
- if (father->_is_nil()) {
- QAD_Operation* op = new SALOMEGUI_ImportOperation( study );
- op->start();
- father = builder->NewComponent(STUDY_SUPERVISION);
- anAttr = builder->FindOrCreateAttribute(father, "AttributeName");
- aName = SALOMEDS::AttributeName::_narrow(anAttr);
- // aName->SetValue("Supervision");
- aName->SetValue( QAD_Application::getDesktop()->getComponentUserName( "SUPERV" ) );
-
-
-
- anAttr = builder->FindOrCreateAttribute(father, "AttributePixMap");
- aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
- aPixmap->SetPixMap( "ICON_OBJBROWSER_Supervision" );
-
- builder->DefineComponentInstance(father, Supervision.getEngine());
- op->finish();
- };
-
- objectBrowser = study->getActiveStudyFrame()->getLeftFrame()->getObjectBrowser();
+
+ SALOMEDS::Study_var studyDoc = study->getStudyDocument();
+ bool aLocked = studyDoc->GetProperties()->IsLocked();
+ SALOMEDS::StudyBuilder_var builder = studyDoc->NewBuilder();
+ SALOMEDS::SComponent_var father = studyDoc->FindComponent(STUDY_SUPERVISION);
+ SALOMEDS::GenericAttribute_var anAttr;
+ SALOMEDS::AttributeName_var aName;
+ SALOMEDS::AttributePixMap_var aPixmap;
+ if (father->_is_nil()) {
+ QAD_Operation* op = new SALOMEGUI_ImportOperation( study );
+ op->start();
+ if (aLocked) studyDoc->GetProperties()->SetLocked(false);
+ father = builder->NewComponent(STUDY_SUPERVISION);
+ anAttr = builder->FindOrCreateAttribute(father, "AttributeName");
+ aName = SALOMEDS::AttributeName::_narrow(anAttr);
+ //aName->SetValue("Supervision");
+ aName->SetValue(QAD_Application::getDesktop()->getComponentUserName( "SUPERV" ) );
+
+ anAttr = builder->FindOrCreateAttribute(father, "AttributePixMap");
+ aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
+ aPixmap->SetPixMap( "ICON_OBJBROWSER_Supervision" );
+ builder->DefineComponentInstance(father, Supervision.getEngine());
+ if (aLocked) studyDoc->GetProperties()->SetLocked(true);
+ op->finish();
+ };
- graph = new SUPERVGUI_Graph(this);
- array = new SUPERVGUI_Array(this);
+ objectBrowser = study->getActiveStudyFrame()->getLeftFrame()->getObjectBrowser();
+
- message = study->getActiveStudyFrame()->getRightFrame()->getMessage();
- notification = new NOTIFICATION_Consumer();
+ graph = new SUPERVGUI_Graph(this);
+ array = new SUPERVGUI_Array(this);
+
+ message = study->getActiveStudyFrame()->getRightFrame()->getMessage();
+ notification = new NOTIFICATION_Consumer();
- QBoxLayout * layout = new QVBoxLayout(this);
- layout->setMargin(0);
- layout->setSpacing(0);
- layout->addWidget(graph);
- layout->addWidget(array);
+ QBoxLayout * layout = new QVBoxLayout(this);
+ layout->setMargin(0);
+ layout->setSpacing(0);
+ layout->addWidget(graph);
+ layout->addWidget(array);
- sync();
- show();
- if ( myLogged && !myLogFileName.isEmpty() && QFile::exists( myLogFileName ) ) {
- myLogFile = fopen( myLogFileName.latin1(), "a" );
- if ( myLogFile == NULL )
- myLogged = false;
- }
+ sync();
+ show();
+ if ( myLogged && !myLogFileName.isEmpty() && QFile::exists( myLogFileName ) ) {
+ myLogFile = fopen( myLogFileName.latin1(), "a" );
+ if ( myLogFile == NULL )
+ myLogged = false;
+ }
+ myTimer = new QTimer( this );
+ connect( myTimer, SIGNAL(timeout()), this, SLOT(checkExecution()) );
}
SUPERVGUI_Main::~SUPERVGUI_Main() {
}
}
-void SUPERVGUI_Main::StartTimer(const char* m) {
- Trace("SUPERVGUI_Main::StartTimer")
- if (!timer->isActive()) {
- timer->start(5);
- message->setMessage(m);
- };
-}
-
-void SUPERVGUI_Main::StopTimer(const char* m) {
- Trace("SUPERVGUI_Main::StopTimer")
- if (timer->isActive()) {
- timer->stop();
- syncNotification();
- message->setMessage(m);
- sync();
- };
-}
-
void SUPERVGUI_Main::filterNotification() {
Trace("SUPERVGUI_Main::filterNotification");
SUPERVGUI_Notification* dlg = new SUPERVGUI_Notification(this);
/**
- * Called by timer when dataflow is executing
+ * Called by thread when dataflow is executing
*/
-void SUPERVGUI_Main::execute() {
- SUPERV_CNode aNode;
- SUPERV::GraphEvent aEvent;
- SUPERV::GraphState aState;
- dataflow->EventNoW(aNode, aEvent, aState);
- if ((aEvent == SUPERV::NoEvent) && (aState == SUPERV::NoState)) return;
-
- if (!SUPERV_isNull(aNode)) {
- SUPERVGUI_Node* aNodePrs;
- if (myCurrentView == TABLE) {
- aNodePrs = (SUPERVGUI_Node*) array->child(aNode->Name(), "SUPERVGUI_Node");
- } else {
- aNodePrs = (SUPERVGUI_Node*) graph->child(aNode->Name(), "SUPERVGUI_Node");
- }
- if (aNodePrs)
- aNodePrs->sync();
- }
- switch (dataflow->State()) {
- case SUPERV_Editing :
- StopTimer(dataflow->IsReadOnly()? tr("MSG_GRAPH_READONLY"): tr("MSG_GRAPH_EDITING"));
- break;
+void SUPERVGUI_Main::execute(char * theNodeName, SUPERV::GraphState theNodeState) {
- case SUPERV_Suspend :
- StopTimer(tr("MSG_GRAPH_SUSPENDED"));
- break;
-
- case SUPERV_Done :
- StopTimer(tr("MSG_GRAPH_FINISHED"));
- break;
-
- case SUPERV_Error :
- StopTimer(tr("MSG_GRAPH_ABORTED"));
- break;
-
- case SUPERV_Kill :
- StopTimer(tr("MSG_GRAPH_KILLED"));
- break;
-
+ SUPERVGUI_Node* aNodePrs;
+ SUPERVGUI_GraphNode* aGraphNodePrs;
+ if (myCurrentView == TABLE) {
+ aNodePrs = (SUPERVGUI_Node*) array->child(theNodeName, "SUPERVGUI_Node");
+ aGraphNodePrs = (SUPERVGUI_GraphNode*) array->child(theNodeName, "SUPERVGUI_GraphNode");
+ } else {
+ aNodePrs = (SUPERVGUI_Node*) graph->child(theNodeName, "SUPERVGUI_Node");
+ aGraphNodePrs = (SUPERVGUI_GraphNode*) graph->child(theNodeName, "SUPERVGUI_GraphNode");
+ }
+ if (aGraphNodePrs) {
+ aGraphNodePrs->sync();
+ }
+ else if (aNodePrs) {
+ //aNodePrs->sync();
+ aNodePrs->syncOnEvent(theNodeState);
}
}
if (!dataflow->ReRun()) {
QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE"));
} else {
- StartTimer(tr("MSG_GRAPH_STARTED"));
- syncNotification();
+ myThread->startThread(tr("MSG_GRAPH_STARTED"));
+ //syncNotification();
sync();
}
} else {
if (!dataflow->Run()) {
QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE"));
} else {
- StartTimer(tr("MSG_GRAPH_STARTED"));
- syncNotification();
+ myThread->startThread(tr("MSG_GRAPH_STARTED"));
+ //syncNotification();
//myIsRunned = true;
sync();
}
if (!dataflow->ReStart()) {
QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE"));
} else {
- StartTimer(tr("MSG_GRAPH_STARTED"));
- syncNotification();
+ myThread->startThread(tr("MSG_GRAPH_STARTED"));
+ //syncNotification();
}
}
else {
if (!dataflow->Start()) {
QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE"));
} else {
- StartTimer(tr("MSG_GRAPH_STARTED"));
- syncNotification();
+ myThread->startThread(tr("MSG_GRAPH_STARTED"));
+ //syncNotification();
}
}
}
QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTRUNNING"));
} else if (dataflow->Kill()) {
myIsKilled = true;
+ myThread->stopThread(tr("MSG_GRAPH_KILLED"));
sync();
} else {
QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANTKILL_DF"));
QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTRUNNING"));
} else if (dataflow->State() == SUPERV_Suspend) {
if (dataflow->Resume()) {
- message->setMessage(tr("MSG_DF_RESUMED"));
- sync();
+ myThread->startThread(tr("MSG_DF_RESUMED"));
} else {
QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_RESUME"));
}
} else {
if (dataflow->Suspend()) {
sync();
+ myThread->stopThread(tr("MSG_GRAPH_SUSPENDED"));
} else {
QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_SUSPEND"));
}
// To check is Supervision active?
if (myIsLocked) return;
- // if (QAD_Application::getDesktop()->getActiveComponent().compare(STUDY_SUPERVISION) !=0) return;
- if (QAD_Application::getDesktop()->getActiveComponent().compare( QAD_Application::getDesktop()->getComponentUserName( "SUPERV" ) ) !=0) return;
+ //if (QAD_Application::getDesktop()->getActiveComponent().compare(STUDY_SUPERVISION) !=0) return;
+ if (QAD_Application::getDesktop()->getActiveComponent().compare(QAD_Application::getDesktop()->getComponentUserName( "SUPERV" ) ) !=0) return;
checkIsInStudy();
if (e->button() == RightButton) {
aComponent = aBuilder->NewComponent(STUDY_SUPERVISION);
anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName");
aName = SALOMEDS::AttributeName::_narrow(anAttr);
- //aName->SetValue("Supervision");
- aName->SetValue( QAD_Application::getDesktop()->getComponentUserName( "SUPERV" ) );
-
+ //aName->SetValue(STUDY_SUPERVISION);
+ aName->SetValue(QAD_Application::getDesktop()->getComponentUserName( "SUPERV" ) );
anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributePixMap");
aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
aPixmap->SetPixMap( "ICON_OBJBROWSER_Supervision" );
SALOMEDS::SObject_var SearchOrCreateSOWithName(const SALOMEDS::Study_var theStudy,
const SALOMEDS::SObject_var theSO,
const char* theName,
- QAD_Operation* theOperation,
+ //QAD_Operation* theOperation,
bool* theStarted) {
SALOMEDS::SObject_var aResult;
SALOMEDS::AttributeName_var aName;
}
if (!aResult->_is_nil()) return aResult;
// add new SObject
+ SALOMEDS::StudyBuilder_var aBuilder = theStudy->NewBuilder();
if (!*theStarted) {
*theStarted = true;
- theOperation->start();
+ //theOperation->start();
+ aBuilder->NewCommand();
}
- SALOMEDS::StudyBuilder_var aBuilder = theStudy->NewBuilder();
aResult = aBuilder->NewObject(theSO);
anAttr = aBuilder->FindOrCreateAttribute(aResult, "AttributeName");
aName = SALOMEDS::AttributeName::_narrow(anAttr);
SALOMEDS::AttributePixMap_var aPixmap;
bool aTransaction = false;
bool aLocked = aStudy->GetProperties()->IsLocked();
- QAD_Operation* op = new SALOMEGUI_ImportOperation( study );
+ // QAD_Operation* op = new SALOMEGUI_ImportOperation( study );
// searching dataflow
SALOMEDS::SObject_var aSO = aStudy->FindObjectIOR(dataflow->getIOR());
if (aSO->_is_nil()) { // create new dataflow SObject
SALOMEDS::SComponent_ptr aComponent = aStudy->FindComponent(STUDY_SUPERVISION);
if (aComponent->_is_nil()) { // is supervision component not found, then create it
- QAD_Operation* anOperation = new SALOMEGUI_ImportOperation( study );
- anOperation->start();
+ //QAD_Operation* anOperation = new SALOMEGUI_ImportOperation( study );
+ //anOperation->start();
+ aBuilder->NewCommand();
if (aLocked) aStudy->GetProperties()->SetLocked(false);
aComponent = aBuilder->NewComponent(STUDY_SUPERVISION);
anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName");
aName = SALOMEDS::AttributeName::_narrow(anAttr);
- aName->SetValue( QAD_Application::getDesktop()->getComponentUserName( "SUPERV" ) );
+ //aName->SetValue(STUDY_SUPERVISION);
+ aName->SetValue(QAD_Application::getDesktop()->getComponentUserName( "SUPERV" ) );
anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributePixMap");
aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
aPixmap->SetPixMap( "ICON_OBJBROWSER_Supervision" );
aBuilder->DefineComponentInstance(aComponent, Supervision.getEngine());
if (aLocked) aStudy->GetProperties()->SetLocked(true);
- anOperation->finish();
+ // anOperation->finish();
+ aBuilder->CommitCommand();
}
aTransaction = true;
- op->start();
+ //op->start();
+ aBuilder->NewCommand();
aSO = aBuilder->NewObject(aComponent);
anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeName");
aName = SALOMEDS::AttributeName::_narrow(anAttr);
anIORAttr = SALOMEDS::AttributeIOR::_narrow(anAttr);
anIORAttr->SetValue(dataflow->getIOR());
}
+ //QAD_Operation* anOperation = new SALOMEGUI_ImportOperation( study );
aSO = SearchOrCreateSOWithName(aStudy, aSO, // get run time SO
- QString("Run ") + myRunTime.toString() , op, &aTransaction);
- aSO = SearchOrCreateSOWithName(aStudy, aSO, p->Node()->Name(), op, &aTransaction); // get node SO
- aSO = SearchOrCreateSOWithName(aStudy, aSO, inout, op, &aTransaction); // get in/out SO
- aSO = SearchOrCreateSOWithName(aStudy, aSO, p->Name(), op, &aTransaction); // get port SO
+ QString("Run ") + myRunTime.toString() /*, anOperation*/, &aTransaction);
+ aSO = SearchOrCreateSOWithName(aStudy, aSO, p->Node()->Name()/*, anOperation*/, &aTransaction); // get node SO
+ aSO = SearchOrCreateSOWithName(aStudy, aSO, inout/*, anOperation*/, &aTransaction); // get in/out SO
+ aSO = SearchOrCreateSOWithName(aStudy, aSO, p->Name()/*, anOperation*/, &aTransaction); // get port SO
if (aLocked) {
- if (aTransaction) op->finish();
+ if (aTransaction) aBuilder->CommitCommand();
+ //op->finish();
isIn = false;
return false;
}
if (!aTransaction) {
aTmpSO = aSO;
aTransaction = true;
- op->start();
+ //op->start();
+ aBuilder->NewCommand();
}
aTmpSO = aDriver->PublishInStudy(aStudy, aTmpSO, anObject, "");
aBuilder->Addreference(aSO, aTmpSO);
} else { // can't publish object: abort transaction
- if (aTransaction) op->abort();
+ if (aTransaction) aBuilder->AbortCommand();
+ //op->abort();
isIn = false;
return false;
}
} else {
if (!aTransaction) {
aTransaction = true;
- op->start();
+ // op->start();
+ aBuilder->NewCommand();
}
anIORAttr->SetValue(p->ToString()); // ior attribute already set for the prevoius condition
}
- if (aTransaction) op->finish();
- study->updateObjBrowser();
+ if (aTransaction)
+ //op->finish();
+ aBuilder->CommitCommand();
+ if (!myThread->running())
+ study->updateObjBrowser();
isIn = false;
return true;
}
SUPERVGraph_View::setPaletteBackgroundColor(color);
}
+QPtrList< char * > SUPERVGUI_Main::getEventNodes() {
+ return myEventNodes;
+}
+
+void SUPERVGUI_Main::setEventNodes(QPtrList< char * > theEventNodes) {
+ myEventNodes = theEventNodes;
+}
+
+QPtrList< SUPERV::GraphState > SUPERVGUI_Main::getStates() {
+ return myStates;
+}
+
+void SUPERVGUI_Main::setStates(QPtrList< SUPERV::GraphState > theStates) {
+ myStates = theStates;
+}
+
+int SUPERVGUI_Main::getNodesNumber() {
+ //create a list of nodes of the graph
+ SUPERV_Nodes nodes = getDataflow()->Nodes();
+ int RetVal = nodes->CNodes.length() + nodes->FNodes.length() +
+ nodes->INodes.length() + nodes->GNodes.length() +
+ nodes->LNodes.length() + nodes->SNodes.length();
+ return RetVal;
+}
+
+SUPERVGUI_Thread* SUPERVGUI_Main::getMyThread() {
+ return myThread;
+}
+
+void SUPERVGUI_Main::startTimer() {
+ myTimer->start(500);
+}
+
+void SUPERVGUI_Main::executionFinished() {
+ getStudy()->updateObjBrowser();
+}
+
+void SUPERVGUI_Main::checkExecution() {
+ if (myThread->finished()) {
+ myTimer->stop();
+ executionFinished();
+ }
+}
+
+
+
+/******************************* SUPERVGUI_Thread class ****************************************/
+SUPERVGUI_Thread::SUPERVGUI_Thread()
+ :QThread()
+{
+ myIsActive = false;
+}
+
+SUPERVGUI_Thread::~SUPERVGUI_Thread()
+{
+ //it is a virtual destructor and needs to be determine here
+}
+
+void SUPERVGUI_Thread::startThread(const char* m)
+{
+ if (!myIsActive) {
+ myIsActive = true;
+ QThread::start();
+ myMain->getMessage()->setMessage(m);
+ myMain->sync();
+ }
+}
+
+void SUPERVGUI_Thread::stopThread(const char* m)
+{
+ //myIsActive = false;
+ //myMain->sync();
+ myMain->getMessage()->setMessage(m);
+}
+
+void SUPERVGUI_Thread::setMain(SUPERVGUI_Main* theMain)
+{
+ myMain = theMain;
+}
+
+void SUPERVGUI_Thread::run()
+{
+ SUPERV_CNode aNode = NULL;
+ SUPERV::GraphEvent aEvent = SUPERV::UndefinedEvent ;
+ SUPERV::GraphState aState = SUPERV::UndefinedState ;
+
+ SUPERV_CNode aPrevNode = NULL;
+ SUPERV::GraphEvent aPrevEvent = SUPERV::UndefinedEvent ;
+ SUPERV::GraphState aPrevState = SUPERV::UndefinedState ;
+
+ char * aName;
+ char * aPrevName;
+
+ QPtrList< char * > anEventNodes;
+ QPtrList< SUPERV::GraphState > aStates;
+
+ myMain->startTimer();
+ while(myIsActive) {
+ myMain->getDataflow()->Event(aNode, aEvent, aState);
+
+ if (aEvent == SUPERV::UndefinedEvent && aState == SUPERV::UndefinedState
+ ||
+ aEvent == SUPERV::NoEvent && aState == SUPERV::NoState) {
+ if (myMain->getEventNodes().count()) {
+ myMain->removeEventNodes();
+ }
+ if (myMain->getStates().count()) {
+ myMain->removeStates();
+ }
+ myIsActive = false;
+ }
+ else {
+ if ( aNode != NULL) {
+ aName = aNode->Name();
+ }
+
+ if ( aPrevNode == NULL ) { //first initialize aPrev... variables
+ anEventNodes = myMain->getEventNodes();
+ anEventNodes.append( &aName ) ;
+ myMain->setEventNodes(anEventNodes);
+
+ aStates = myMain->getStates();
+ aStates.append( &aState ) ;
+ myMain->setStates(aStates);
+ }
+ else {
+ if ( aEvent == aPrevEvent && aState == aPrevState) {
+ QString aNameStr = aName;
+ QString aPrevNameStr = aPrevName;
+ if ( aNameStr != aPrevNameStr ) {
+ anEventNodes = myMain->getEventNodes();
+ anEventNodes.append( &aName ) ;
+ myMain->setEventNodes(anEventNodes);
+
+ aStates = myMain->getStates();
+ aStates.append( &aState ) ;
+ myMain->setStates(aStates);
+ }
+ }
+ else {
+ anEventNodes = myMain->getEventNodes();
+ anEventNodes.append( &aName ) ;
+ myMain->setEventNodes(anEventNodes);
+
+ aStates = myMain->getStates();
+ aStates.append( &aState ) ;
+ myMain->setStates(aStates);
+ }
+ }
+ }
+ if (!myIsActive) {
+ switch (myMain->getDataflow()->State()) {
+ case SUPERV_Editing :
+ stopThread(myMain->getDataflow()->IsReadOnly()? tr("MSG_GRAPH_READONLY"): tr("MSG_GRAPH_EDITING"));
+ break;
+
+ case SUPERV_Suspend :
+ stopThread(tr("MSG_GRAPH_SUSPENDED"));
+ break;
+
+ case SUPERV_Done :
+ stopThread(tr("MSG_GRAPH_FINISHED"));
+ break;
+
+ case SUPERV_Error :
+ stopThread(tr("MSG_GRAPH_ABORTED"));
+ break;
+ }
+
+ break;
+ }
+
+ if (myMain->getEventNodes().count()) {
+ //if list not empty call execute() -> sync()
+ char * aNodeName = *(myMain->getEventNodes().getFirst());
+ SUPERV::GraphState aNodeState = *(myMain->getStates().getFirst());
+ qApp->lock();
+ myMain->execute(aNodeName,aNodeState); //this is from main
+ qApp->unlock();
+ myMain->removeFirstEN();
+ myMain->removeFirstS();
+ }
+
+ aPrevNode = aNode;
+ aPrevEvent = aEvent;
+ aPrevState = aState;
+ aPrevName = aPrevNode->Name();
+
+ //usleep(10);
+ //msleep(5);
+ }
+ // VSR: 04/12/03 ---> update object browser ufter finishing
+// qApp->lock();
+// myMain->getStudy()->updateObjBrowser();
+// qApp->unlock();
+ // VSR: 04/12/03 <---
+ QThread::exit();
+}
+
#include "QAD_Desktop.h"
#include "SUPERVGUI_Port.h"
+#include <qobject.h>
+#include <qapplication.h>
+#include <qthread.h>
+
class QAD_Study;
class QAD_ObjectBrowser;
class QAD_Message;
class NOTIFICATION_Consumer;
-
+class SUPERVGUI_Thread;
class SUPERVGUI_Main: public SUPERVGraph_View {
Q_OBJECT
void lockedGraph(bool theLock) { myIsLocked = theLock; }
bool isLocked() { return myIsLocked; }
+ SUPERV::GraphState getNodeExecState();
+ void setNodeExecState(SUPERV::GraphState theNodeExecState);
+
+ QPtrList< char * > getEventNodes();
+ void setEventNodes(QPtrList< char * > theEventNodes);
+ bool removeFirstEN() { return myEventNodes.removeFirst(); }
+ void removeEventNodes() { myEventNodes.clear(); }
+
+ QPtrList< SUPERV::GraphState > getStates();
+ void setStates(QPtrList< SUPERV::GraphState > theStates);
+ bool removeFirstS() { return myStates.removeFirst(); }
+ void removeStates() { myStates.clear(); }
+
+ int getNodesNumber();
+ SUPERVGUI_Thread* getMyThread();
+
+ void startTimer();
+ void executionFinished();
+
public slots:
- void execute();
+ void execute(char * theNodeNode, SUPERV::GraphState theNodeState);
void sync();
void syncAsync();
bool addStudy();
private slots:
void chooseData(QListViewItem* item);
+ void checkExecution();
private:
void init(QAD_Desktop* parent);
- void StartTimer(const char* m);
- void StopTimer(const char* m);
void syncNotification();
bool isFiltered(char* graph, char* node, char* type, char* message, char* sender, long counter, char* date, long stamp);
QAD_ObjectBrowser* objectBrowser;
QAD_Message* message;
SUPERVGUI_Graph* graph;
- QTimer* timer;
-
+
GraphViewType myCurrentView;
SUPERVGUI_Array* array;
bool myVerbose;
bool myIsKilled;
bool myIsLocked;
+
+ SUPERVGUI_Thread* myThread;
+
+ QPtrList< char * > myEventNodes ;
+ QPtrList< SUPERV::GraphState > myStates ;
+ QTimer* myTimer;
+};
+
+class SUPERVGUI_Thread : public QObject, public QThread {
+ Q_OBJECT;
+ public:
+ SUPERVGUI_Thread();
+ ~SUPERVGUI_Thread();
+
+ void startThread(const char* m);
+ void stopThread(const char* m);
+ void setMain(SUPERVGUI_Main* theMain);
+
+ protected:
+ void run();
+
+ private:
+ bool myIsActive;
+ SUPERVGUI_Main* myMain;
+
};
#endif
mySuspendItem = myRunPopup->insertItem(tr("MSG_SUSPEND"), this, SLOT(suspendResume()));
myKillItem = myRunPopup->insertItem(tr("MSG_KILL"), this, SLOT(kill()));
//myStopItem = myRunPopup->insertItem(tr("MSG_STOP"), this, SLOT(stopRestart()));
-
+
setState(myNode->State());
}
setState(myNode->State());
}
+void SUPERVGUI_Node::syncOnEvent(SUPERV::GraphState theStateFromEvent) {
+ setState(theStateFromEvent);
+}
void SUPERVGUI_Node::setState(SUPERV::GraphState theState)
{
myStatus->setPaletteBackgroundColor(QColor(35, 192, 255));
break;
case SUPERV_Running:
+ case SUPERV::ReadyState:
myStatus->setText("Running");
myStatus->setPaletteBackgroundColor(QColor(32,210,32));
myRunPopup->changeItem(myStopItem, tr("MSG_STOP"));
myRunPopup->changeItem(myStopItem, tr("MSG_RESTART"));
myRunPopup->setItemEnabled(myStopItem, true);
break;
- default:
+ default:
//cout<<"### Node state = "<<theState<<endl;
myStatus->setText("No Status");
myStatus->setPaletteBackgroundColor(QColor(NODE_RED, NODE_GREEN, NODE_BLUE));
if (!((n==1)? myMain->getDataflow()->Resume() : myNode->Resume())) {
QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_RESUMENODE"));
}
+ else {
+ myMain->getMyThread()->startThread(tr("MSG_NODE_RESUMED1")+myNode->Name()+tr("MSG_NODE_RESUMED2"));
+ }
} else {
if (!((n==1)? myMain->getDataflow()->Suspend() : myNode->Suspend())) {
QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_SUSPENDNODE"));
} else {
myStatus->setPaletteBackgroundColor(QColor(255,180, 0));
myTime->setPaletteBackgroundColor(QColor(255,180, 0));
+ myMain->getMyThread()->stopThread(tr("MSG_NODE_SUSPENDED1")+myNode->Name()+tr("MSG_NODE_SUSPENDED2"));
}
}
}
} else {
myStatus->setPaletteBackgroundColor(Qt::red);
myTime->setPaletteBackgroundColor(Qt::red);
+ myMain->getMyThread()->stopThread(tr("MSG_NODE_KILLED1")+myNode->Name()+tr("MSG_NODE_KILLED2"));
}
}
bool eventFilter( QObject* o, QEvent* e );
virtual void sync();
+ void syncOnEvent(SUPERV::GraphState theStateFromEvent);
virtual void hideAll()=0;
virtual void showAll()=0;
bool step;
bool trace;
bool verbose;
+
};
mySketchItem = popup->insertItem(tr("MSG_SKETCH_LINK"), this, SLOT(sketchLink()));
popup->insertSeparator();
}
- if (port->IsInLine()) {
+ //for Loop Node: enable "Delete" popup item only for the input port
+ if ( ( port->IsInLine()
+ &&
+ ( port->Node()->Kind()!=SUPERV::EndLoopNode )
+ &&
+ !( port->Node()->Kind()==SUPERV::LoopNode && !port->IsInput() )
+ )
+ ||
+ ( port->IsEndSwitch() && port->IsInput())) {
myDelItem = popup->insertItem(tr("ITM_DEL_PORT"), this, SLOT(deletePort()));
}
connect(this, SIGNAL(MousePress(QMouseEvent*)), this, SLOT(showPopup(QMouseEvent*)));
void SUPERVGUI_PortOut::toStudy() {
Trace("SUPERVGUI_PortOut::toStudy")
- if (!main->isFromStudy()) {
- if (main->addStudy()) main->setAsFromStudy(true);
- }
- if (!main->getStudy()->getStudyDocument()->GetProperties()->IsLocked()) study = !study;
+
+ if (main->getStudy()->getStudyDocument()->GetProperties()->IsLocked()) {
+ QMessageBox::warning(QAD_Application::getDesktop(), tr("WRN_WARNING"), tr("WRN_STUDY_LOCKED"));
+ return;
+ }
+
+ if (!main->isFromStudy()) {
+ if (main->addStudy()) main->setAsFromStudy(true);
+ }
+ study = !study;
sync();
}
-//***********************************************************
+// ----------------------------
// Input Port of EndSwitch Node
// ----------------------------
SUPERVGUI_PortInESNode::SUPERVGUI_PortInESNode(QWidget* parent, SUPERVGUI_Main* m, SUPERV_Port p)
bool editing = port->IsInput() && ( !port->IsLinked() ); //main->isEditable();
if ((!port->IsGate()) && editing ) {
- psc = popup->insertItem(tr("MSG_SETVALUE"), this, SLOT(setInput()));
+ psc = popup->insertItem(tr("MSG_SETVALUE"),this, SLOT(setInput()));
}
- browser = popup->insertItem(tr("MSG_BROWSE"), this, SLOT(browse()));
+ browser = popup->insertItem(tr("MSG_BROWSE"),this, SLOT(browse()));
}
SUPERVGUI_PortInESNode::~SUPERVGUI_PortInESNode() {
#: QAD_ObjectBrowser.cxx:140
msgid "ICON_OBJBROWSER_Supervision"
-msgstr "Superv_tree_superv.png"
+msgstr "Superv_tree_superv.png"
\ No newline at end of file
#:SUPERVGUI_Main.cxx:195
msgid "MSG_GRAPH_STARTED"
-msgstr "===> Dataflow Execution is started"
+msgstr "===> Dataflow Execution is Started"
#:SUPERVGUI_Main.cxx:191
msgid "MSG_GRAPH_READONLY"
msgid "MSG_GRAPH_SUSPENDED"
msgstr "===> Dataflow Execution is Suspended"
+msgid "MSG_NODE_SUSPENDED1"
+msgstr "===> Node "
+
+msgid "MSG_NODE_SUSPENDED2"
+msgstr " Execution is Suspended"
+
#:SUPERVGUI_Main.cxx:204
msgid "MSG_GRAPH_FINISHED"
msgstr "===> Dataflow Execution is Finished"
msgid "MSG_GRAPH_KILLED"
msgstr "===> Dataflow Execution is Killed"
+msgid "MSG_NODE_KILLED1"
+msgstr "===> Node "
+
+msgid "MSG_NODE_KILLED2"
+msgstr " Execution is Killed"
+
#:SUPERVGUI_Main.cxx:265
msgid "MSG_GRAPH_INSERT"
msgstr "Insert a Dataflow"
msgid "MSG_DF_RESUMED"
msgstr "===> Dataflow Execution is Resumed"
+msgid "MSG_NODE_RESUMED1"
+msgstr "===> Node "
+
+msgid "MSG_NODE_RESUMED2"
+msgstr " Execution is Resumed"
+
#:SUPERVGUI_Main.cxx:318
msgid "MSG_CANT_RESUME"
msgstr "Can't Resume Dataflow"
bool RetVal = false ;
if ( _DataFlowEditor->IsEditing() ) {
RetVal = _DataFlowEditor->RemoveNode( Name() ) ;
- if ( RetVal )
+ if ( RetVal ) {
RetVal = _DataFlowEditor->IsValid() ;
+ }
}
endService( "CNode_Impl::Delete" );
return RetVal ;
RetVal = _DataFlowNode->Name() ;
}
else {
- RetVal = _DataFlowEditor->Name() ;
+ RetVal = _DataFlowEditor->Name() ;
}
// endService( "CNode_Impl::Name" );
return CORBA::string_dup( RetVal );
aDataFlowName ) ;
}
else {
- RetVal = _DataFlowEditor->Name( aDataFlowName ) ;
+ RetVal = _DataFlowEditor->Name( aDataFlowName ) ;
}
}
// endService( "CNode_Impl::SetName" );
bool begin = true ;
SUPERV::Port_var iobject = SUPERV::Port::_nil() ;
GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ;
+ bool sts = false ;
+ GraphBase::InPort * anInPort = NULL ;
if ( _DataFlowEditor->IsEditing() ) {
- bool sts = false ;
- GraphBase::InPort * anInPort ;
if ( _IsNode ) {
sts = _DataFlowEditor->AddInputData( _DataFlowNode->Name() ,
ToServiceParameterName ,
}
}
else if ( _DataFlowExecutor ) {
- bool sts = false ;
- GraphBase::InPort * anInPort ;
if ( _IsNode ) {
sts = _DataFlowExecutor->ChangeInputData( _DataFlowNode->Name() ,
ToServiceParameterName ,
if ( !begin ) {
endService( "CNode_Impl::Input" );
}
+ if ( CORBA::is_nil( iobject ) ) {
+ MESSAGE( "CNode_Impl::Input returns nil object _IsNode " << _IsNode << " sts " << sts << " anInPort "
+ << anInPort ) ;
+ }
return SUPERV::Port::_duplicate( iobject ) ;
}
}
if ( anInPort->IsLoop() || ( anInPort->IsGate() && !anInPort->IsConnected() &&
( _DataFlowEditor->IsExecuting() || _DataFlowEditor->IsReadOnly() ) ) ) {
- MESSAGE( "InPort " << i << " " << anInPort->PortName() << " of Node " << Name() << " ignored" ) ;
+// MESSAGE( "InPort " << i << " " << anInPort->PortName() << " of Node " << Name() << " ignored" ) ;
RetVal[ i ] = SUPERV::Port::_duplicate( SUPERV::Port::_narrow( CORBA::Object::_nil() ) ) ;
}
else if ( CORBA::is_nil( anInPort->ObjRef() ) ) {
- MESSAGE( "InPort " << i << " " << anInPort->PortName() << " of Node " << Name() << " IsExecuting "
- << _DataFlowEditor->IsExecuting() << " IsGate/IsConnected " << anInPort->IsGate()
- << "/" << anInPort->IsConnected() ) ;
+// MESSAGE( "InPort " << i << " " << anInPort->PortName() << " of Node " << Name() << " IsExecuting "
+// << _DataFlowEditor->IsExecuting() << " IsGate/IsConnected " << anInPort->IsGate()
+// << "/" << anInPort->IsConnected() ) ;
Port_Impl * myPort ;
if ( _DataFlowNode->HasInput( anInPort->PortName() ) ) {
const CORBA::Any * anAny = anInPort->GetOutPort()->Value() ;
anInPort->ObjRef( SUPERV::Port::_duplicate( iobject ) ) ;
}
else {
- MESSAGE( "InPort " << i << " " << anInPort->PortName() << " of Node " << Name() ) ;
+// MESSAGE( "InPort " << i << " " << anInPort->PortName() << " of Node " << Name() ) ;
RetVal[ i ] = SUPERV::Port::_duplicate( anInPort->ObjRef() ) ;
}
}
}
if ( anOutPort->IsLoop() || ( anOutPort->IsGate() && !anOutPort->IsConnected() &&
( _DataFlowEditor->IsExecuting() || _DataFlowEditor->IsReadOnly() ) ) ) {
- MESSAGE( "OutPort " << i << " " << anOutPort->PortName() << " of Node " << Name() << " ignored" ) ;
+// MESSAGE( "OutPort " << i << " " << anOutPort->PortName() << " of Node " << Name() << " ignored" ) ;
RetVal[ _DataFlowNode->GetNodeInPortsSize() + i ] = SUPERV::Port::_duplicate( SUPERV::Port::_narrow( CORBA::Object::_nil() ) ) ;
}
else if ( CORBA::is_nil( anOutPort->ObjRef() ) ) {
- MESSAGE( "OutPort " << i << " " << anOutPort->PortName() << " of Node " << Name() ) ;
+// MESSAGE( "OutPort " << i << " " << anOutPort->PortName() << " of Node " << Name() ) ;
const CORBA::Any * anAny = anOutPort->Value() ;
Port_Impl * myPort = new Port_Impl( _Orb , _Poa , _ContId ,
instanceName() , interfaceName() ,
anOutPort->ObjRef( SUPERV::Port::_duplicate( iobject ) ) ;
}
else {
- MESSAGE( "OutPort " << i << " " << anOutPort->PortName() << " of Node " << Name() ) ;
+// MESSAGE( "OutPort " << i << " " << anOutPort->PortName() << " of Node " << Name() ) ;
RetVal[ _DataFlowNode->GetNodeInPortsSize() + i ] = SUPERV::Port::_duplicate( anOutPort->ObjRef() ) ;
}
}
}
void ELNode_Impl::destroy() {
+ MESSAGE("--------> ELNode_Impl::destroy() BEGIN");
beginService( "ELNode_Impl::Destroy" );
if ( DataFlowEditor()->IsEditing() ) {
+ MESSAGE("--------> Editing dataflow");
+ SUPERV::GNode_ptr aCoupled = SUPERV::GNode::_narrow( Coupled() ) ;
if ( Delete() ) {
+ MESSAGE("--------> Delete return true");
_poa->deactivate_object(*_id) ;
CORBA::release(_poa) ;
delete(_id) ;
_thisObj->_remove_ref();
}
+ if ( !CORBA::is_nil( aCoupled ) ) {
+ aCoupled->SetCoupled( "" ) ;
+ aCoupled->destroy() ;
+ }
}
endService( "ELNode_Impl::Destroy" );
+ MESSAGE("--------> ELNode_Impl::destroy() END");
}
bool ELNode_Impl::Delete() {
// beginService( "ELNode_Impl::Delete" );
+ MESSAGE("--------> ELNode_Impl::Delete() BEGIN");
bool RetVal = false ;
if ( DataFlowEditor()->IsEditing() ) {
+ MESSAGE("--------> In Delete: Editing dataflow");
RetVal = DataFlowEditor()->RemoveNode( Name() ) ;
- if ( RetVal )
+ MESSAGE("--------> RetVal = "<<RetVal);
+ if ( RetVal ) {
+ MESSAGE("--------> Before IsValid");
RetVal = DataFlowEditor()->IsValid() ;
+ MESSAGE("--------> After IsValid");
+ }
}
// endService( "ELNode_Impl::Delete" );
+ MESSAGE("--------> ELNode_Impl::Delete() END");
return RetVal ;
}
void ESNode_Impl::destroy() {
beginService( "ESNode_Impl::Destroy" );
if ( DataFlowEditor()->IsEditing() ) {
+ SUPERV::GNode_ptr aCoupled = SUPERV::GNode::_narrow( Coupled() ) ;
if ( Delete() ) {
_poa->deactivate_object(*_id) ;
CORBA::release(_poa) ;
delete(_id) ;
_thisObj->_remove_ref();
}
+ if ( !CORBA::is_nil( aCoupled ) ) {
+ aCoupled->SetCoupled( "" ) ;
+ aCoupled->destroy() ;
+ }
}
endService( "ESNode_Impl::Destroy" );
}
}
bool GNode_Impl::Delete() {
-// beginService( "GNode_Impl::Delete" );
+ beginService( "GNode_Impl::Delete" );
bool RetVal = false ;
if ( DataFlowEditor()->IsEditing() ) {
RetVal = DataFlowEditor()->RemoveNode( Name() ) ;
if ( RetVal )
RetVal = DataFlowEditor()->IsValid() ;
}
-// endService( "GNode_Impl::Delete" );
+ endService( "GNode_Impl::Delete" );
return RetVal ;
}
virtual bool SetCoupled( const char * anInLineNode ) {
GraphBase::InLineNode * CoupledINode = (GraphBase::InLineNode * ) DataFlowEditor()->GetGraphNode( anInLineNode ) ;
// cout << Name() << ".SetCoupled " << anInLineNode << endl ;
- if ( CoupledINode && ( IsGOTO() &&
+// if ( CoupledINode && ( IsGOTO() &&
+ if ( ( IsGOTO() &&
( CoupledINode->IsInLineNode() || CoupledINode->IsLoopNode() ||
CoupledINode->IsSwitchNode() ) ) ||
( !IsGOTO() && ( IsLoop() || IsSwitch() ||
IsEndLoop() || IsEndSwitch() ) ) ) {
DataFlowNode()->CoupledNode( CoupledINode ) ;
- if ( IsSwitch() ) {
+ if ( CoupledINode && IsSwitch() ) {
DataFlowEditor()->AddLink( Name() , "Default" ,
CoupledINode->Name() , "Default" ) ;
}
- else if ( IsLoop() || IsEndLoop() ) {
+ else if ( CoupledINode && ( IsLoop() || IsEndLoop() ) ) {
DataFlowEditor()->AddLink( Name() , "DoLoop" ,
CoupledINode->Name() , "DoLoop" ) ;
}
- else if ( IsGOTO() ) {
+ else if ( CoupledINode && IsGOTO() ) {
DataFlowEditor()->AddLink( Name() , "OutGate" ,
CoupledINode->Name() , "InGate" ) ;
}
#include "DataFlowEditor_DataFlow.hxx"
+extern GraphExecutor::FiniteStateMachine * theAutomaton ;
+
Graph_Impl::Graph_Impl( CORBA::ORB_ptr orb ,
PortableServer::POA_ptr poa ,
PortableServer::ObjectId * contId ,
_Orb = CORBA::ORB::_duplicate(orb);
_Poa = poa ;
_ContId = contId ;
- _ExecNumber = 0 ;
string dbgfile = "/tmp/" ;
dbgfile += instanceName ;
_DebugFileName ) ;
DataFlowEditor( aDataFlowEditor ) ;
DataFlowEditor()->SetObjImpl( this ) ;
+ pthread_mutex_init( &_MutexExecutorWait , NULL ) ;
_DataFlowExecutor = NULL ;
delete [] theDataFlowName ;
endService( "Graph_Impl::Graph_Impl" );
DataFlowEditor()->ReadOnly() ;
}
-SUPERV::INode_ptr Graph_Impl::GetNode() {
-// beginService( "Graph_Impl::GetNode" );
+SUPERV::INode_ptr Graph_Impl::Node() {
+// beginService( "Graph_Impl::Node" );
PortableServer::ObjectId * id = getId() ;
CORBA::Object_var obj = _poa->id_to_reference(*id);
SUPERV::Graph_var iobject ;
iobject = SUPERV::Graph::_narrow(obj) ;
-// endService( "Graph_Impl::GetNode" );
+// endService( "Graph_Impl::Node" );
return SUPERV::Graph::_duplicate(iobject) ;
}
}
#endif
-SUPERV::CNode_ptr Graph_Impl::CNode(
- const SALOME_ModuleCatalog::Service &NodeService ) {
+SUPERV::CNode_ptr Graph_Impl::CNode( const SALOME_ModuleCatalog::Service &NodeService ) {
beginService( "Graph_Impl::CNode" );
SUPERV::CNode_var iobject = SUPERV::CNode::_nil() ;
if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() ) {
return SUPERV::CNode::_duplicate( iobject ) ;
}
-SUPERV::FNode_ptr Graph_Impl::FNode(
- const char * NodeComponentName ,
- const char * NodeInterfaceName ,
- const SALOME_ModuleCatalog::Service &NodeService ) {
+SUPERV::FNode_ptr Graph_Impl::FNode( const char * NodeComponentName ,
+ const char * NodeInterfaceName ,
+ const SALOME_ModuleCatalog::Service &NodeService ) {
beginService( "Graph_Impl::FNode" );
SUPERV::FNode_var iobject = SUPERV::FNode::_nil() ;
if ( DataFlowEditor()->IsEditing() && !DataFlowEditor()->IsReadOnly() ) {
return SUPERV::GNode::_duplicate( iobject ) ;
}
-SUPERV::LNode_ptr Graph_Impl::LNode(
- const char * InitName ,
- const SUPERV::ListOfStrings & InitFunction ,
- const char * MoreName ,
- const SUPERV::ListOfStrings & MoreFunction ,
- const char * NextName ,
- const SUPERV::ListOfStrings & NextFunction ,
- SUPERV::INode_out anEndOfLoop ) {
+SUPERV::LNode_ptr Graph_Impl::LNode( const char * InitName ,
+ const SUPERV::ListOfStrings & InitFunction ,
+ const char * MoreName ,
+ const SUPERV::ListOfStrings & MoreFunction ,
+ const char * NextName ,
+ const SUPERV::ListOfStrings & NextFunction ,
+ SUPERV::INode_out anEndOfLoop ) {
beginService( "Graph_Impl::LNode" );
SUPERV::LNode_var iobject = SUPERV::LNode::_nil() ;
SUPERV::ELNode_var iendobject = SUPERV::ELNode::_nil() ;
return SUPERV::LNode::_duplicate( iobject ) ;
}
-SUPERV::SNode_ptr Graph_Impl::SNode(
- const char * FuncName ,
- const SUPERV::ListOfStrings & PythonFunction ,
- SUPERV::INode_out anEndOfSwitch ) {
+SUPERV::SNode_ptr Graph_Impl::SNode( const char * FuncName ,
+ const SUPERV::ListOfStrings & PythonFunction ,
+ SUPERV::INode_out anEndOfSwitch ) {
beginService( "Graph_Impl::SNode" );
SUPERV::SNode_var iobject = SUPERV::SNode::_nil() ;
SUPERV::ESNode_var iendobject = SUPERV::ESNode::_nil() ;
}
-SUPERV::CNode_ptr Graph_Impl::GetNode(char const * aNodeName ) {
-// beginService( "Graph_Impl::GetNode" );
+SUPERV::CNode_ptr Graph_Impl::Node(char const * aNodeName ) {
+// beginService( "Graph_Impl::Node" );
SUPERV::CNode_var iobject = SUPERV::CNode::_nil() ;
/* JR : 13/06/03
if ( CORBA::is_nil( DataFlowEditor()->GetNode( aNodeName )->ObjRef() ) ) {
GraphEditor::InNode * anInNode = DataFlowEditor()->GetNode( aNodeName ) ;
if ( anInNode ) {
if ( CORBA::is_nil( anInNode->ObjRef() ) ) {
- CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
- instanceName() , interfaceName() ,
- DataFlowEditor() ,
- DataFlowEditor()->GetNode( aNodeName ) ) ;
- PortableServer::ObjectId * id = myNode->getId() ;
- CORBA::Object_var obj = _poa->id_to_reference(*id);
- iobject = SUPERV::CNode::_narrow(obj) ;
- myNode->SetObjRef( SUPERV::CNode::_duplicate( iobject ) ) ;
- }
- else {
- iobject = DataFlowEditor()->GetNode( aNodeName )->ObjRef() ;
+ SetNodeObjRef( anInNode ) ;
}
+ iobject = anInNode->ObjRef() ;
}
-// endService( "Graph_Impl::GetNode" );
+// endService( "Graph_Impl::Node" );
return SUPERV::CNode::_duplicate( iobject ) ;
}
return SUPERV::Link::_duplicate( iobject ) ;
}
+void Graph_Impl::SetNodeObjRef( GraphEditor::InNode * anInNode ) {
+ CORBA::Object_var obj ;
+ if ( anInNode->IsComputingNode() ) {
+ CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
+ instanceName() , interfaceName() ,
+ DataFlowEditor() ,
+ anInNode ) ;
+ PortableServer::ObjectId * id = myNode->getId() ;
+ obj = _poa->id_to_reference(*id);
+ SUPERV::CNode_var iobject = SUPERV::CNode::_narrow(obj) ;
+ myNode->SetObjRef( SUPERV::CNode::_duplicate( iobject ) ) ;
+ }
+ else if ( anInNode->IsFactoryNode() ) {
+ FNode_Impl * myNode = new FNode_Impl( _Orb , _Poa , _ContId ,
+ instanceName() , interfaceName() ,
+ DataFlowEditor() ,
+ anInNode ) ;
+ PortableServer::ObjectId * id = myNode->getId() ;
+ obj = _poa->id_to_reference(*id);
+ SUPERV::FNode_var iobject = SUPERV::FNode::_narrow(obj) ;
+ myNode->SetObjRef( SUPERV::FNode::_duplicate( iobject ) ) ;
+ }
+ else if ( anInNode->IsInLineNode() ) {
+ INode_Impl * myNode = new INode_Impl( _Orb , _Poa , _ContId ,
+ instanceName() , interfaceName() ,
+ DataFlowEditor() ,
+ anInNode ) ;
+ PortableServer::ObjectId * id = myNode->getId() ;
+ obj = _poa->id_to_reference(*id);
+ SUPERV::INode_var iobject = SUPERV::INode::_narrow(obj) ;
+ myNode->SetObjRef( SUPERV::INode::_duplicate( iobject ) ) ;
+ }
+ else if ( anInNode->IsGOTONode() ) {
+ GNode_Impl * myNode = new GNode_Impl( _Orb , _Poa , _ContId ,
+ instanceName() , interfaceName() ,
+ DataFlowEditor() ,
+ anInNode ) ;
+ PortableServer::ObjectId * id = myNode->getId() ;
+ obj = _poa->id_to_reference(*id);
+ SUPERV::GNode_var iobject = SUPERV::GNode::_narrow(obj) ;
+ myNode->SetObjRef( SUPERV::GNode::_duplicate( iobject ) ) ;
+ }
+ else if ( anInNode->IsLoopNode() ) {
+ LNode_Impl * myNode = new LNode_Impl( _Orb , _Poa , _ContId ,
+ instanceName() , interfaceName() ,
+ DataFlowEditor() ,
+ anInNode ) ;
+ PortableServer::ObjectId * id = myNode->getId() ;
+ obj = _poa->id_to_reference(*id);
+ SUPERV::LNode_var iobject = SUPERV::LNode::_narrow(obj) ;
+ myNode->SetObjRef( SUPERV::LNode::_duplicate( iobject ) ) ;
+ }
+ else if ( anInNode->IsEndLoopNode() ) {
+ ELNode_Impl * myNode = new ELNode_Impl( _Orb , _Poa , _ContId ,
+ instanceName() , interfaceName() ,
+ DataFlowEditor() ,
+ anInNode ) ;
+ PortableServer::ObjectId * id = myNode->getId() ;
+ obj = _poa->id_to_reference(*id);
+ SUPERV::ELNode_var iobject = SUPERV::ELNode::_narrow(obj) ;
+ myNode->SetObjRef( SUPERV::ELNode::_duplicate( iobject ) ) ;
+ }
+ else if ( anInNode->IsSwitchNode() ) {
+ SNode_Impl * myNode = new SNode_Impl( _Orb , _Poa , _ContId ,
+ instanceName() , interfaceName() ,
+ DataFlowEditor() ,
+ anInNode ) ;
+ PortableServer::ObjectId * id = myNode->getId() ;
+ obj = _poa->id_to_reference(*id);
+ SUPERV::SNode_var iobject = SUPERV::SNode::_narrow(obj) ;
+ myNode->SetObjRef( SUPERV::SNode::_duplicate( iobject ) ) ;
+ }
+ else if ( anInNode->IsEndSwitchNode() ) {
+ ESNode_Impl * myNode = new ESNode_Impl( _Orb , _Poa , _ContId ,
+ instanceName() , interfaceName() ,
+ DataFlowEditor() ,
+ anInNode ) ;
+ PortableServer::ObjectId * id = myNode->getId() ;
+ obj = _poa->id_to_reference(*id);
+ SUPERV::ESNode_var iobject = SUPERV::ESNode::_narrow(obj) ;
+ myNode->SetObjRef( SUPERV::ESNode::_duplicate( iobject ) ) ;
+ }
+}
+
SUPERV::ListOfNodes_var Graph_Impl::SetNode( SUPERV::ListOfNodes_var RetVal ,
GraphBase::ComputingNode * aNode ) {
int index = 0 ;
RetVal->ESNodes.length( index+1 );
}
if ( CORBA::is_nil( aNode->ObjRef() ) ) {
- if ( aNode->IsComputingNode() ) {
- CNode_Impl * myNode = new CNode_Impl( _Orb , _Poa , _ContId ,
- instanceName() , interfaceName() ,
- DataFlowEditor() ,
- (GraphEditor::InNode * ) aNode->GetInNode() ) ;
- PortableServer::ObjectId * id = myNode->getId() ;
- CORBA::Object_var obj = _poa->id_to_reference(*id);
- SUPERV::CNode_var iobject ;
- iobject = SUPERV::CNode::_narrow(obj) ;
- myNode->SetObjRef( SUPERV::CNode::_duplicate( iobject ) ) ;
- RetVal->CNodes[index] = SUPERV::CNode::_duplicate( iobject ) ;
- }
- else if ( aNode->IsFactoryNode() ) {
- FNode_Impl * myNode = new FNode_Impl( _Orb , _Poa , _ContId ,
- instanceName() , interfaceName() ,
- DataFlowEditor() ,
- (GraphEditor::InNode * ) aNode->GetInNode() ) ;
- PortableServer::ObjectId * id = myNode->getId() ;
- CORBA::Object_var obj = _poa->id_to_reference(*id);
- SUPERV::FNode_var iobject ;
- iobject = SUPERV::FNode::_narrow(obj) ;
- myNode->SetObjRef( SUPERV::FNode::_duplicate( iobject ) ) ;
- RetVal->FNodes[index] = SUPERV::FNode::_duplicate( iobject ) ;
- }
- else if ( aNode->IsInLineNode() ) {
- INode_Impl * myNode = new INode_Impl( _Orb , _Poa , _ContId ,
- instanceName() , interfaceName() ,
- DataFlowEditor() ,
- (GraphEditor::InNode * ) aNode->GetInNode() ) ;
- PortableServer::ObjectId * id = myNode->getId() ;
- CORBA::Object_var obj = _poa->id_to_reference(*id);
- SUPERV::INode_var iobject ;
- iobject = SUPERV::INode::_narrow(obj) ;
- myNode->SetObjRef( SUPERV::INode::_duplicate( iobject ) ) ;
- RetVal->INodes[index] = SUPERV::INode::_duplicate( iobject ) ;
- }
- else if ( aNode->IsGOTONode() ) {
- GNode_Impl * myNode = new GNode_Impl( _Orb , _Poa , _ContId ,
- instanceName() , interfaceName() ,
- DataFlowEditor() ,
- (GraphEditor::InNode * ) aNode->GetInNode() ) ;
- PortableServer::ObjectId * id = myNode->getId() ;
- CORBA::Object_var obj = _poa->id_to_reference(*id);
- SUPERV::GNode_var iobject ;
- iobject = SUPERV::GNode::_narrow(obj) ;
- myNode->SetObjRef( SUPERV::GNode::_duplicate( iobject ) ) ;
- RetVal->GNodes[index] = SUPERV::GNode::_duplicate( iobject ) ;
- }
- else if ( aNode->IsLoopNode() ) {
- LNode_Impl * myNode = new LNode_Impl( _Orb , _Poa , _ContId ,
- instanceName() , interfaceName() ,
- DataFlowEditor() ,
- (GraphEditor::InNode * ) aNode->GetInNode() ) ;
- PortableServer::ObjectId * id = myNode->getId() ;
- CORBA::Object_var obj = _poa->id_to_reference(*id);
- SUPERV::LNode_var iobject ;
- iobject = SUPERV::LNode::_narrow(obj) ;
- myNode->SetObjRef( SUPERV::LNode::_duplicate( iobject ) ) ;
- RetVal->LNodes[index] = SUPERV::LNode::_duplicate( iobject ) ;
- }
- else if ( aNode->IsEndLoopNode() ) {
- ELNode_Impl * myNode = new ELNode_Impl( _Orb , _Poa , _ContId ,
- instanceName() , interfaceName() ,
- DataFlowEditor() ,
- (GraphEditor::InNode * ) aNode->GetInNode() ) ;
- PortableServer::ObjectId * id = myNode->getId() ;
- CORBA::Object_var obj = _poa->id_to_reference(*id);
- SUPERV::ELNode_var iobject ;
- iobject = SUPERV::ELNode::_narrow(obj) ;
- myNode->SetObjRef( SUPERV::ELNode::_duplicate( iobject ) ) ;
- RetVal->ELNodes[index] = SUPERV::ELNode::_duplicate( iobject ) ;
- }
- else if ( aNode->IsSwitchNode() ) {
- SNode_Impl * myNode = new SNode_Impl( _Orb , _Poa , _ContId ,
- instanceName() , interfaceName() ,
- DataFlowEditor() ,
- (GraphEditor::InNode * ) aNode->GetInNode() ) ;
- PortableServer::ObjectId * id = myNode->getId() ;
- CORBA::Object_var obj = _poa->id_to_reference(*id);
- SUPERV::SNode_var iobject ;
- iobject = SUPERV::SNode::_narrow(obj) ;
- myNode->SetObjRef( SUPERV::SNode::_duplicate( iobject ) ) ;
- RetVal->SNodes[index] = SUPERV::SNode::_duplicate( iobject ) ;
- }
- else if ( aNode->IsEndSwitchNode() ) {
- ESNode_Impl * myNode = new ESNode_Impl( _Orb , _Poa , _ContId ,
- instanceName() , interfaceName() ,
- DataFlowEditor() ,
- (GraphEditor::InNode * ) aNode->GetInNode() ) ;
- PortableServer::ObjectId * id = myNode->getId() ;
- CORBA::Object_var obj = _poa->id_to_reference(*id);
- SUPERV::ESNode_var iobject ;
- iobject = SUPERV::ESNode::_narrow(obj) ;
- myNode->SetObjRef( SUPERV::ESNode::_duplicate( iobject ) ) ;
- RetVal->ESNodes[index] = SUPERV::ESNode::_duplicate( iobject ) ;
- }
+ SetNodeObjRef( (GraphEditor::InNode * ) aNode->GetInNode() ) ;
}
- else if ( aNode->IsComputingNode() ) {
- RetVal->CNodes[index] = SUPERV::CNode::_duplicate( aNode->ObjRef() ) ;
+ SUPERV::CNode_var aNodeObjRef = aNode->ObjRef() ;
+ if ( aNode->IsComputingNode() ) {
+ RetVal->CNodes[index] = SUPERV::CNode::_duplicate( aNodeObjRef ) ;
}
else if ( aNode->IsFactoryNode() ) {
- RetVal->FNodes[index] = SUPERV::FNode::_duplicate( SUPERV::FNode::_narrow( aNode->ObjRef() ) ) ;
+ RetVal->FNodes[index] = SUPERV::FNode::_duplicate( SUPERV::FNode::_narrow( aNodeObjRef ) ) ;
}
else if ( aNode->IsInLineNode() ) {
- RetVal->INodes[index] = SUPERV::INode::_duplicate( SUPERV::INode::_narrow( aNode->ObjRef() ) ) ;
+ RetVal->INodes[index] = SUPERV::INode::_duplicate( SUPERV::INode::_narrow( aNodeObjRef ) ) ;
}
else if ( aNode->IsGOTONode() ) {
- RetVal->GNodes[index] = SUPERV::GNode::_duplicate( SUPERV::GNode::_narrow( aNode->ObjRef() ) ) ;
+ RetVal->GNodes[index] = SUPERV::GNode::_duplicate( SUPERV::GNode::_narrow( aNodeObjRef ) ) ;
}
else if ( aNode->IsLoopNode() ) {
- RetVal->LNodes[index] = SUPERV::LNode::_duplicate( SUPERV::LNode::_narrow( aNode->ObjRef() ) ) ;
+ RetVal->LNodes[index] = SUPERV::LNode::_duplicate( SUPERV::LNode::_narrow( aNodeObjRef ) ) ;
}
else if ( aNode->IsEndLoopNode() ) {
- RetVal->ELNodes[index] = SUPERV::ELNode::_duplicate( SUPERV::ELNode::_narrow( aNode->ObjRef() ) ) ;
+ RetVal->ELNodes[index] = SUPERV::ELNode::_duplicate( SUPERV::ELNode::_narrow( aNodeObjRef ) ) ;
}
else if ( aNode->IsSwitchNode() ) {
- RetVal->SNodes[index] = SUPERV::SNode::_duplicate( SUPERV::SNode::_narrow( aNode->ObjRef() ) ) ;
+ RetVal->SNodes[index] = SUPERV::SNode::_duplicate( SUPERV::SNode::_narrow( aNodeObjRef ) ) ;
}
else if ( aNode->IsEndSwitchNode() ) {
- RetVal->ESNodes[index] = SUPERV::ESNode::_duplicate( SUPERV::ESNode::_narrow( aNode->ObjRef() ) ) ;
+ RetVal->ESNodes[index] = SUPERV::ESNode::_duplicate( SUPERV::ESNode::_narrow( aNodeObjRef ) ) ;
}
return ( RetVal._retn() ) ;
}
GraphBase::OutPort * anOutPort = NULL ;
anOutPort = anInPort->GetOutPort() ;
if ( strcmp( anOutPort->NodeName() , Name() ) ) {
- MESSAGE("Graph_Impl::Links " << anOutPort->NodeName() << "("
- << anOutPort->PortName() << ") --> " << aNode->Name() << "("
- << anInPort->PortName() << ")" ) ;
+// MESSAGE("Graph_Impl::Links " << anOutPort->NodeName() << "("
+// << anOutPort->PortName() << ") --> " << aNode->Name() << "("
+// << anInPort->PortName() << ")" ) ;
if ( theNode == NULL ||
( theNode != NULL && theNode->IsEndSwitchNode() &&
!strcmp( theNode->Name() , aNode->Name() ) ) ) {
if ( anInPort->IsLoop() || anOutPort->IsLoop() ||
( aNode->IsEndLoopNode() && !strcmp( aNode->CoupledNode()->Name() ,
anOutPort->NodeName() ) ) ) {
- MESSAGE( "Link " << anOutPort->NodeName() << "("
- << anOutPort->PortName() << ") --> " << aNode->Name() << "("
- << anInPort->PortName() << ")" << " ignored" ) ;
+// MESSAGE( "Link " << anOutPort->NodeName() << "("
+// << anOutPort->PortName() << ") --> " << aNode->Name() << "("
+// << anInPort->PortName() << ")" << " ignored" ) ;
}
else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
if ( begin ) {
if ( anInPort->IsLoop() || anOutPort->IsLoop() ||
( toNode->IsEndLoopNode() && !strcmp( toNode->CoupledNode()->Name() ,
anOutPort->NodeName() ) ) ) {
- MESSAGE( "Link " << anOutPort->NodeName() << "("
- << anOutPort->PortName() << ") --> " << aNode->Name() << "("
- << anInPort->PortName() << ")" << " ignored" ) ;
+// MESSAGE( "Link " << anOutPort->NodeName() << "("
+// << anOutPort->PortName() << ") --> " << aNode->Name() << "("
+// << anInPort->PortName() << ")" << " ignored" ) ;
}
else if ( CORBA::is_nil( anOutPort->InPortObjRef( anInPort ) ) ) {
if ( begin ) {
bool Graph_Impl::Begin() {
bool RetVal = false ;
if ( DataFlowEditor()->IsEditing() ) {
+ if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
+ perror("pthread_mutex_lock _MutexExecutorWait") ;
+ exit( 0 ) ;
+ }
if ( _DataFlowExecutor ) {
MESSAGE( "Graph_Impl::Begin " << _DataFlowExecutor->Threads() << " threads" )
if ( _DataFlowExecutor->Threads() ) {
DataFlowEditor()->Executor( NULL ) ;
}
DataFlowEditor()->EditedAfterExecution( false ) ;
- _ExecNumber += 1 ;
+ int _ExecNumber = theAutomaton->ExecNumber() ;
char ExecNumber[30] ;
sprintf( ExecNumber , "_%d" , _ExecNumber ) ;
int len = strlen( _DebugFileName ) ;
if ( RetVal ) {
DataFlowEditor()->Executor( _DataFlowExecutor ) ;
}
+ if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
+ perror("pthread_mutex_unlock _MutexExecutorWait") ;
+ exit( 0 ) ;
+ }
}
return RetVal ;
}
if ( DataFlowEditor()->IsEditing() ) {
MESSAGE( "Graph_Impl::Run IsEditing" );
RetVal = Begin() ;
- MESSAGE( "Graph_Impl::(Re)Run " );
- RetVal = CNode_Impl::Run() ;
+ if ( RetVal ) {
+ MESSAGE( "Graph_Impl::(Re)Run " );
+ RetVal = CNode_Impl::Run() ;
+ }
}
else {
MESSAGE( "Graph_Impl::(Re)Run " );
char * aNodeName = NULL ;
SUPERV::GraphEvent theEvent = SUPERV::UndefinedEvent ;
SUPERV::GraphState theState = SUPERV::UndefinedState ;
- if ( !DataFlowEditor()->IsEditing() ) {
+ if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
+ perror("pthread_mutex_lock _MutexExecutorWait") ;
+ exit( 0 ) ;
+ }
+ if ( _DataFlowExecutor &&
+ ( _DataFlowExecutor->GetListSize() || !DataFlowEditor()->IsEditing() ) ) {
RetVal = _DataFlowExecutor->Event( & aNodeName , theEvent , theState , false ) ;
// endService( "Graph_Impl::Event" );
if ( strlen( aNodeName ) ) {
if ( strcmp( aNodeName , Name() ) ) {
- aNode = GetNode( aNodeName ) ;
+ aNode = Node( aNodeName ) ;
}
else {
- aNode = GetNode() ;
+ aNode = Node() ;
}
}
else {
aNode = SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
}
+// cout << "Graph_Impl::EventNoW " << aNode->Name() << " QSize " << _DataFlowExecutor->GetListSize() << endl ;
+ }
+ else {
+// cout << "Graph_Impl::EventNoW NO DataFlowExecutor or QSize=0 " << endl ;
+ }
+ if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
+ perror("pthread_mutex_unlock _MutexExecutorWait") ;
+ exit( 0 ) ;
}
anEvent = theEvent ;
aState = theState ;
char * aNodeName = NULL ;
SUPERV::GraphEvent theEvent = SUPERV::UndefinedEvent ;
SUPERV::GraphState theState = SUPERV::UndefinedState ;
- if ( !DataFlowEditor()->IsEditing() ) {
+ if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
+ perror("pthread_mutex_lock _MutexExecutorWait") ;
+ exit( 0 ) ;
+ }
+ if ( _DataFlowExecutor &&
+ ( _DataFlowExecutor->GetListSize() || !DataFlowEditor()->IsEditing() ) ){
RetVal = _DataFlowExecutor->Event( & aNodeName , theEvent , theState ) ;
// endService( "Graph_Impl::Event" );
if ( strlen( aNodeName ) ) {
if ( strcmp( aNodeName , Name() ) ) {
- aNode = GetNode( aNodeName ) ;
+ aNode = Node( aNodeName ) ;
}
else {
- aNode = GetNode() ;
+ aNode = Node() ;
}
}
else {
aNode = SUPERV::Graph::_duplicate( SUPERV::Graph::_nil() ) ;
}
+// cout << "Graph_Impl::Event " << aNode->Name() << " QSize " << _DataFlowExecutor->GetListSize() << endl ;
+ }
+ else {
+// cout << "Graph_Impl::Event NO DataFlowExecutor or QSize=0 " << endl ;
+ }
+ if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
+ perror("pthread_mutex_unlock _MutexExecutorWait") ;
+ exit( 0 ) ;
}
anEvent = theEvent ;
aState = theState ;
char * aNodeName = NULL ;
SUPERV::GraphEvent theEvent = SUPERV::UndefinedEvent ;
SUPERV::GraphState theState = SUPERV::UndefinedState ;
- if ( !DataFlowEditor()->IsEditing() ) {
+ if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
+ perror("pthread_mutex_lock _MutexExecutorWait") ;
+ exit( 0 ) ;
+ }
+ if ( _DataFlowExecutor &&
+ ( _DataFlowExecutor->GetListSize() || !DataFlowEditor()->IsEditing() ) ) {
RetVal = _DataFlowExecutor->EventW( & aNodeName , theEvent , theState ) ;
if ( RetVal && strcmp( aNodeName , Name() ) ) {
- aNode = GetNode( aNodeName ) ;
+ aNode = Node( aNodeName ) ;
}
else {
- aNode = GetNode() ;
+ aNode = Node() ;
}
}
+ if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
+ perror("pthread_mutex_unlock _MutexExecutorWait") ;
+ exit( 0 ) ;
+ }
anEvent = theEvent ;
aState = theState ;
// endService( "Graph_Impl::EventW" );
return RetVal ;
}
+long Graph_Impl::EventQSize() {
+// beginService( "Graph_Impl::EventQSize" );
+ long QSize = -1 ;
+ if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
+ perror("pthread_mutex_lock _MutexExecutorWait") ;
+ exit( 0 ) ;
+ }
+ if ( _DataFlowExecutor ) {
+ QSize = _DataFlowExecutor->EventQSize() ;
+ }
+ if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
+ perror("pthread_mutex_unlock _MutexExecutorWait") ;
+ exit( 0 ) ;
+ }
+// endService( "Graph_Impl::EventQSize" );
+ return QSize ;
+}
+
long Graph_Impl::LastLevelDone() {
// beginService( "Graph_Impl::LastLevelDone" );
- long RetVal = _DataFlowExecutor->LastLevelDone() ;
+ if ( pthread_mutex_lock( &_MutexExecutorWait ) ) {
+ perror("pthread_mutex_lock _MutexExecutorWait") ;
+ exit( 0 ) ;
+ }
+ long RetVal = 0 ;
+ if ( _DataFlowExecutor ) {
+ RetVal = _DataFlowExecutor->LastLevelDone() ;
+ }
+ if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) {
+ perror("pthread_mutex_unlock _MutexExecutorWait") ;
+ exit( 0 ) ;
+ }
// endService( "Graph_Impl::LastLevelDone" );
return RetVal ;
}
bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph ) {
-// beginService( "Graph_Impl::Merge" );
- bool RetVal = false ;
+ beginService( "Graph_Impl::Merge" );
+ bool RetVal = true ;
if ( DataFlowEditor()->IsEditing() ) {
SUPERV::ListOfNodes * aGraphNodes = aGraph->Nodes() ;
- SUPERV::ListOfLinks * aGraphLinks = aGraph->Links() ;
- SUPERV::ListOfPorts * aGraphPorts = aGraph->Ports() ;
int i ;
map< string , int > aMapOfNodes ;
for ( i = 0 ; i < (int ) aGraphNodes->CNodes.length() ; i++ ) {
SUPERV::CNode_var aNode = (aGraphNodes->CNodes)[ i ] ;
- GraphEditor::InNode * myNode ;
- GraphBase::ListOfFuncName aFuncName = GraphBase::ListOfFuncName() ;
- GraphBase::ListOfPythonFunctions aPythonFunction = GraphBase::ListOfPythonFunctions() ;
- myNode = DataFlowEditor()->AddNode( *(aNode->Service()) ,
- "" ,
- "" ,
- NULLSTRING ,
- SUPERV::ComputingNode ,
- aFuncName ,
- aPythonFunction ,
- aNode->CreationDate() ,
- aNode->LastUpdateDate() ,
- aNode->Version() ,
- aNode->Author() ,
- "" ,
- aNode->Comment() ,
- aNode->X() ,
- aNode->Y() ) ;
- if ( myNode ) {
+ SUPERV::CNode_ptr myNode = CNode( *(aNode->Service()) ) ;
+ if ( !CORBA::is_nil( myNode ) ) {
+ myNode->SetName( aNode->Name() ) ;
+ myNode->SetAuthor( aNode->Author() ) ;
+ myNode->SetComment( aNode->Comment() ) ;
+ myNode->Coords( aNode->X() , aNode->Y() ) ;
string * aNodetheName = new string( aNode->Name() ) ;
aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->GetGraphNodeIndex( myNode->Name() ) ;
delete aNodetheName ;
break ;
}
}
- for ( i = 0 ; i < (int ) aGraphNodes->FNodes.length() ; i++ ) {
- SUPERV::FNode_var aNode = (aGraphNodes->FNodes)[ i ] ;
- GraphEditor::InNode * myNode ;
- GraphBase::ListOfFuncName aFuncName = GraphBase::ListOfFuncName() ;
- GraphBase::ListOfPythonFunctions aPythonFunction = GraphBase::ListOfPythonFunctions() ;
- myNode = DataFlowEditor()->AddNode( *(aNode->Service()) ,
- aNode->GetComponentName() ,
- aNode->GetInterfaceName() ,
- NULLSTRING ,
- SUPERV::ComputingNode ,
- aFuncName ,
- aPythonFunction ,
- aNode->CreationDate() ,
- aNode->LastUpdateDate() ,
- aNode->Version() ,
- aNode->Author() ,
- aNode->GetContainer() ,
- aNode->Comment() ,
- aNode->X() ,
- aNode->Y() ) ;
- if ( myNode ) {
- string * aNodetheName = new string( aNode->Name() ) ;
- aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->GetGraphNodeIndex( myNode->Name() ) ;
- delete aNodetheName ;
- RetVal = true ;
+ if ( RetVal ) {
+ for ( i = 0 ; i < (int ) aGraphNodes->FNodes.length() ; i++ ) {
+ SUPERV::FNode_var aNode = (aGraphNodes->FNodes)[ i ] ;
+ SUPERV::FNode_ptr myNode = FNode( aNode->GetComponentName() ,
+ aNode->GetInterfaceName() ,
+ *(aNode->Service()) ) ;
+ if ( !CORBA::is_nil( myNode ) ) {
+ myNode->SetName( aNode->Name() ) ;
+ myNode->SetAuthor( aNode->Author() ) ;
+ myNode->SetComment( aNode->Comment() ) ;
+ myNode->Coords( aNode->X() , aNode->Y() ) ;
+ string * aNodetheName = new string( aNode->Name() ) ;
+ aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->GetGraphNodeIndex( myNode->Name() ) ;
+ delete aNodetheName ;
+ RetVal = true ;
+ }
+ else {
+ RetVal = false ;
+ break ;
+ }
}
- else {
- RetVal = false ;
- break ;
+ }
+ if ( RetVal ) {
+ for ( i = 0 ; i < (int ) aGraphNodes->INodes.length() ; i++ ) {
+ SUPERV::INode_var aNode = (aGraphNodes->INodes)[ i ] ;
+ SUPERV::INode_ptr myNode = INode( aNode->PyFuncName() , *(aNode->PyFunction()) ) ;
+ if ( !CORBA::is_nil( myNode ) ) {
+ myNode->SetName( aNode->Name() ) ;
+ myNode->SetAuthor( aNode->Author() ) ;
+ myNode->SetComment( aNode->Comment() ) ;
+ myNode->Coords( aNode->X() , aNode->Y() ) ;
+ string * aNodetheName = new string( aNode->Name() ) ;
+ aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->GetGraphNodeIndex( myNode->Name() ) ;
+ delete aNodetheName ;
+ SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
+ int j ;
+ for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
+ if ( myPorts[ j ]->IsInput() ) {
+ myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
+ }
+ else {
+ myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
+ }
+ }
+ RetVal = true ;
+ }
+ else {
+ RetVal = false ;
+ break ;
+ }
+ }
+ }
+ if ( RetVal ) {
+ for ( i = 0 ; i < (int ) aGraphNodes->GNodes.length() ; i++ ) {
+ SUPERV::GNode_var aNode = (aGraphNodes->GNodes)[ i ] ;
+ SUPERV::GNode_ptr myNode = GNode( aNode->PyFuncName() , *(aNode->PyFunction()) , aNode->Coupled()->Name() ) ;
+ if ( !CORBA::is_nil( myNode ) ) {
+ myNode->SetName( aNode->Name() ) ;
+ myNode->SetAuthor( aNode->Author() ) ;
+ myNode->SetComment( aNode->Comment() ) ;
+ myNode->Coords( aNode->X() , aNode->Y() ) ;
+ string * aNodetheName = new string( aNode->Name() ) ;
+ aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->GetGraphNodeIndex( myNode->Name() ) ;
+ delete aNodetheName ;
+ SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
+ int j ;
+ for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
+ if ( myPorts[ j ]->IsInput() ) {
+ myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
+ }
+ else {
+ myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
+ }
+ }
+ RetVal = true ;
+ }
+ else {
+ RetVal = false ;
+ break ;
+ }
}
}
if ( RetVal ) {
+ for ( i = 0 ; i < (int ) aGraphNodes->LNodes.length() ; i++ ) {
+ SUPERV::LNode_var aNode = (aGraphNodes->LNodes)[ i ] ;
+ SUPERV::INode_ptr anEndOfLoop ;
+ SUPERV::LNode_ptr myNode = LNode( aNode->PyInitName() ,
+ *(aNode->PyInit()) ,
+ aNode->PyMoreName() ,
+ *(aNode->PyMore()) ,
+ aNode->PyNextName() ,
+ *(aNode->PyNext()) ,
+ anEndOfLoop ) ;
+ if ( !CORBA::is_nil( myNode ) ) {
+ myNode->SetName( aNode->Name() ) ;
+ myNode->SetAuthor( aNode->Author() ) ;
+ myNode->SetComment( aNode->Comment() ) ;
+ myNode->Coords( aNode->X() , aNode->Y() ) ;
+ string * aNodetheName = new string( aNode->Name() ) ;
+ aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->GetGraphNodeIndex( myNode->Name() ) ;
+ delete aNodetheName ;
+ SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
+ int j ;
+ for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
+ if ( myPorts[ j ]->IsInput() ) {
+ myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
+ }
+ }
+ SUPERV::INode_ptr myEndOfLoop = aNode->Coupled() ;
+ anEndOfLoop->SetName( myEndOfLoop->Name() ) ;
+ anEndOfLoop->SetAuthor( myEndOfLoop->Author() ) ;
+ anEndOfLoop->SetComment( myEndOfLoop->Comment() ) ;
+ anEndOfLoop->Coords( myEndOfLoop->X() , myEndOfLoop->Y() ) ;
+ anEndOfLoop->SetPyFunction( myEndOfLoop->PyFuncName() , *(myEndOfLoop->PyFunction()) ) ;
+ aNodetheName = new string( myEndOfLoop->Name() ) ;
+ aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->GetGraphNodeIndex( anEndOfLoop->Name() ) ;
+ delete aNodetheName ;
+ RetVal = true ;
+ }
+ else {
+ RetVal = false ;
+ break ;
+ }
+ }
+ }
+ if ( RetVal ) {
+ for ( i = 0 ; i < (int ) aGraphNodes->SNodes.length() ; i++ ) {
+ SUPERV::SNode_var aNode = (aGraphNodes->SNodes)[ i ] ;
+ SUPERV::INode_ptr anEndOfSwitch ;
+ SUPERV::SNode_ptr myNode = SNode( aNode->PyFuncName() , *(aNode->PyFunction()) , anEndOfSwitch ) ;
+ if ( !CORBA::is_nil( myNode ) ) {
+ myNode->SetName( aNode->Name() ) ;
+ myNode->SetAuthor( aNode->Author() ) ;
+ myNode->SetComment( aNode->Comment() ) ;
+ myNode->Coords( aNode->X() , aNode->Y() ) ;
+ string * aNodetheName = new string( aNode->Name() ) ;
+ aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->GetGraphNodeIndex( myNode->Name() ) ;
+ delete aNodetheName ;
+ SUPERV::ListOfPorts myPorts = *(aNode->Ports()) ;
+ int j ;
+ for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
+ if ( myPorts[ j ]->IsInput() ) {
+ myNode->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
+ }
+ else {
+ myNode->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
+ }
+ }
+ SUPERV::INode_ptr myEndOfSwitch = aNode->Coupled() ;
+ anEndOfSwitch->SetName( myEndOfSwitch->Name() ) ;
+ anEndOfSwitch->SetAuthor( myEndOfSwitch->Author() ) ;
+ anEndOfSwitch->SetComment( myEndOfSwitch->Comment() ) ;
+ anEndOfSwitch->Coords( myEndOfSwitch->X() , myEndOfSwitch->Y() ) ;
+ anEndOfSwitch->SetPyFunction( myEndOfSwitch->PyFuncName() , *(myEndOfSwitch->PyFunction()) ) ;
+ aNodetheName = new string( myEndOfSwitch->Name() ) ;
+ aMapOfNodes[ *aNodetheName ] = DataFlowEditor()->GetGraphNodeIndex( anEndOfSwitch->Name() ) ;
+ delete aNodetheName ;
+ myPorts = *(myEndOfSwitch->Ports()) ;
+ for ( j = 0 ; j < (int ) myPorts.length() ; j++ ) {
+ if ( myPorts[ j ]->IsInput() ) {
+ anEndOfSwitch->InPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
+ }
+ else {
+ anEndOfSwitch->OutPort( myPorts[ j ]->Name() , myPorts[ j ]->Type() ) ;
+ }
+ }
+ RetVal = true ;
+ }
+ else {
+ RetVal = false ;
+ break ;
+ }
+ }
+ }
+ if ( RetVal ) {
+ SUPERV::ListOfLinks * aGraphLinks = aGraph->GLinks() ;
+ SUPERV::ListOfPorts * aGraphPorts = aGraph->Ports() ;
+// cout << "Graph_Impl::Merge " << aGraphLinks->length() << " links " << aGraphPorts->length() << " GraphPorts"
+// << endl ;
for ( i = 0 ; i < (int ) aGraphLinks->length() ; i++ ) {
SUPERV::Link_var aLink = (*aGraphLinks)[ i ] ;
SUPERV::Port_var OutPort = aLink->OutPort() ;
OutPort->Name() ,
DataFlowEditor()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
InPort->Name() ) ;
+ if ( RetVal ) {
+ int j ;
+ for ( j = 1 ; j <= aLink->CoordsSize() ; j++ ) {
+ long X , Y ;
+ RetVal = aLink->Coords( j , X , Y ) ;
+ if ( !RetVal )
+ break ;
+ RetVal = DataFlowEditor()->AddLinkCoord( DataFlowEditor()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
+ OutPort->Name() ,
+ DataFlowEditor()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
+ InPort->Name() ,
+ j , X , Y ) ;
+ if ( !RetVal ) {
+ break ;
+ }
+ }
+ }
delete aLinkFromNodeName ;
delete aLinkToNodeName ;
- if ( !RetVal )
+ if ( !RetVal ) {
break ;
- int j ;
- for ( j = 1 ; j <= aLink->CoordsSize() ; j++ ) {
- long X , Y ;
- RetVal = aLink->Coords( j , X , Y ) ;
- if ( !RetVal )
- break ;
- RetVal = DataFlowEditor()->AddLinkCoord( DataFlowEditor()->GetGraphNode( aMapOfNodes[ aLinkFromNodeName->c_str() ] )->Name() ,
- OutPort->Name() ,
- DataFlowEditor()->GetGraphNode( aMapOfNodes[ aLinkToNodeName->c_str() ] )->Name() ,
- InPort->Name() ,
- j , X , Y ) ;
- if ( !RetVal )
- break ;
}
}
if ( RetVal ) {
for ( i = 0 ; i < (int ) aGraphPorts->length() ; i++ ) {
SUPERV::Port_var aPort = (*aGraphPorts)[ i ] ;
- if ( aPort->HasInput() ) {
- char * aNode = new char[ strlen( aPort->Name() + 1 ) ] ;
- strcpy( aNode , aPort->Name() ) ;
- char * thePort = strchr( aNode , '\\' ) ;
- thePort[ 0 ] = '\0' ;
- RetVal = DataFlowEditor()->AddInputData( DataFlowEditor()->GetGraphNode( aMapOfNodes[ aNode ] )->Name() ,
- thePort + 1 ,
- *(aPort->ToAny()) ) ;
- delete aNode ;
- if ( !RetVal )
- break ;
+ char * aPortName = aPort->Name() ;
+ char * aNodeName = new char[ strlen( aPortName ) + 1 ] ;
+ strcpy( aNodeName , aPortName ) ;
+ char * thePortName = strchr( aNodeName , '\\' ) ;
+ thePortName[ 0 ] = '\0' ;
+ bool hasinput = aGraph->Node( aNodeName )->Port( thePortName + 1 )->HasInput() ;
+// cout << "Graph_Impl::Merge " << " aNodeName " << aNodeName << " aPort " << thePortName + 1
+// << " HasInput " << hasinput << endl ;
+ if ( hasinput ) {
+ RetVal = DataFlowEditor()->AddInputData( DataFlowEditor()->GetGraphNode( aMapOfNodes[ aNodeName ] )->Name() ,
+ thePortName + 1 ,
+ *(aPort->ToAny()) ) ;
+ }
+ delete [] aNodeName ;
+ if ( !RetVal ) {
+ break ;
}
}
}
}
}
-// endService( "Graph_Impl::Merge" );
+ endService( "Graph_Impl::Merge" );
return RetVal ;
}
SALOME_NamingService * _NamingService ;
char * _DebugFileName ;
+ pthread_mutex_t _MutexExecutorWait ;
GraphExecutor::DataFlow * _DataFlowExecutor ;
- int _ExecNumber ;
SUPERV::Graph_var myServant; // mpv 23.12.2002: store servant of graph to get constant IOR
public:
virtual void ReadOnly() ;
- virtual SUPERV::INode_ptr GetNode() ;
+ virtual SUPERV::INode_ptr Node() ;
// virtual char * DataFlowInfo() ;
// virtual char * DataNodeInfo() ;
const SUPERV::ListOfStrings & PythonFunction ,
SUPERV::INode_out anEndOfSwitch ) ;
- virtual SUPERV::CNode_ptr GetNode( const char * NodeName );
+ virtual SUPERV::CNode_ptr Node( const char * NodeName );
virtual SUPERV::Link_ptr Link( SUPERV::Port_ptr OutPort ,
SUPERV::Port_ptr InPort ) ;
virtual SUPERV::ListOfNodes_var Graph_Impl::SetNode( SUPERV::ListOfNodes_var RetVal ,
GraphBase::ComputingNode * aNode ) ;
virtual SUPERV::ListOfNodes * Nodes() ;
+ virtual void SetNodeObjRef( GraphEditor::InNode * anInNode ) ;
virtual SUPERV::ListOfLinks * GLinks() ;
virtual SUPERV::ListOfLinks * Links( GraphBase::ComputingNode * aNode ,
const char * anInputParam ) ;
virtual bool EventW( SUPERV::CNode_out aNode ,
SUPERV::GraphEvent & anEvent ,
SUPERV::GraphState & aState ) ;
+ virtual long EventQSize() ;
virtual bool Merge(const SUPERV::Graph_ptr aGraph ) ;
void LNode_Impl::destroy() {
beginService( "LNode_Impl::Destroy" );
if ( DataFlowEditor()->IsEditing() ) {
+ SUPERV::GNode_ptr aCoupled = SUPERV::GNode::_narrow( Coupled() ) ;
if ( Delete() ) {
_poa->deactivate_object(*_id) ;
CORBA::release(_poa) ;
delete(_id) ;
_thisObj->_remove_ref();
}
+ if ( !CORBA::is_nil( aCoupled ) ) {
+ aCoupled->SetCoupled( "" ) ;
+ aCoupled->destroy() ;
+ }
}
endService( "LNode_Impl::Destroy" );
}
bool LNode_Impl::Delete() {
-// beginService( "LNode_Impl::Delete" );
+ beginService( "LNode_Impl::Delete" );
bool RetVal = false ;
if ( DataFlowEditor()->IsEditing() ) {
RetVal = DataFlowEditor()->RemoveNode( Name() ) ;
- if ( RetVal )
+ if ( RetVal ) {
RetVal = DataFlowEditor()->IsValid() ;
+ }
}
-// endService( "LNode_Impl::Delete" );
+ endService( "LNode_Impl::Delete" );
return RetVal ;
}
@COMMENCE@
EXPORT_PYSCRIPTS = SuperV.py batchmode_SuperV.py
-
EXPORT_SHAREDPYSCRIPTS = SUPERV_shared_modules.py
EXPORT_HEADERS = \
BIN_SRC =
BIN_SERVER_IDL =
-CPPFLAGS+= $(PYTHON_INCLUDES) $(QT_MT_INCLUDES) $(VTK_INCLUDES) \
- $(OGL_INCLUDES) $(OCC_INCLUDES) \
+CPPFLAGS+= $(PYTHON_INCLUDES) $(QT_MT_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) $(OCC_INCLUDES) \
-I${KERNEL_ROOT_DIR}/include/salome
-CXXFLAGS= -g -D_DEBUG_ -D__x86__ -D__linux__ -ftemplate-depth-42 \
+#CXXFLAGS= -g -D_DEBUG_ -D__x86__ -D__linux__ -ftemplate-depth-42 -Wno-deprecated
+#CXXFLAGS= -g -D_DEBUG_ -D__x86__ -D__linux__ -ftemplate-depth-42 -Wall ### mpv: D_DEBUG key must be set only on DEBUG compilation mode
+CXXFLAGS += -g -D__x86__ -D__linux__ -ftemplate-depth-42 -Wall \
-I${KERNEL_ROOT_DIR}/include/salome
LDFLAGS+= -lSalomeSuperVisionEditor -lSalomeSuperVisionExecutor -lSalomeSuperVisionBase \
- -lSalomeContainer -lSalomeNotification -lSalomeDS -lSalomeNS -lSalomeLifeCycleCORBA \
- -lOpUtil -lRegistry -lSalomeHDFPersist -lSALOMELocalTrace \
- $(QT_MT_LIBS) $(OGL_LIBS) $(HDF5_LIBS) \
- -L${KERNEL_ROOT_DIR}/lib/salome
-
-#LDFLAGS+= -lSalomeSuperVisionEditor -lSalomeSuperVisionExecutor -lSalomeSuperVisionBase -lSalomeContainer -lSalomeNotification -lSalomeNS -lSalomeLifeCycleCORBA -lOpUtil -lRegistry -lSalomeHDFPersist -lSalomeLoggerServer $(QT_MT_LIBS) $(OGL_LIBS) $(HDF5_LIBS)
+ -lSalomeContainer -lSalomeNotification -lSalomeNS -lSalomeLifeCycleCORBA \
+ -lOpUtil -lRegistry -lTOOLSDS -lSalomeLoggerServer \
+ $(QT_MT_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome
@CONCLUDE@
*anAny ) ;
}
}
+ if ( !RetVal ) {
+ MESSAGE( "Port_Impl::Input returns false _InputPort " << _InputPort << " IsEditing "
+ << _DataFlowEditor->IsEditing() << " Executor " << _DataFlowEditor->Executor() ) ;
+ }
endService( "Port_Impl::Input" );
return RetVal ;
}
SUPERV::ListOfLinks_var Links = new SUPERV::ListOfLinks ;
// cout << "Port_Impl::Link " << _DataFlowNode->Name() << " "
// << _DataFlowPort->PortName() << endl ;
- Links = _DataFlowEditor->ObjImpl()->Links(
- _DataFlowNode->ComputingNode() ,
- _DataFlowPort->PortName() ) ;
+ Links = _DataFlowEditor->ObjImpl()->Links( _DataFlowNode->ComputingNode() ,
+ _DataFlowPort->PortName() ) ;
if ( Links->length() ) {
iobject = Links[ 0 ] ;
}
}
}
if ( !begin ) {
+ MESSAGE( "Link " << iobject->OutPort()->Node()->Name() << "( " << iobject->OutPort()->Name() << " ) --> "
+ << iobject->InPort()->Node()->Name() << "( " << iobject->InPort()->Name() << " ) " ) ;
endService( "Port_Impl::Link" ) ;
}
return SUPERV::Link::_duplicate( iobject ) ;
bool Port_Impl::HasInput() {
// beginService( "Port_Impl::" ) ;
- bool RetVal = _DataFlowNode->HasInput( _DataFlowPort->PortName() ) ;
+ bool RetVal = false ;
+ if ( _DataFlowNode ) {
+ RetVal = _DataFlowNode->HasInput( _DataFlowPort->PortName() ) ;
+// cout << "Port_Impl::HasInput " << RetVal << " NodeName " << _DataFlowPort->NodeName() << " PortName "
+// << _DataFlowPort->PortName() << endl ;
+ }
// endService( "Port_Impl::" ) ;
return RetVal ;
}
void SNode_Impl::destroy() {
beginService( "SNode_Impl::Destroy" );
if ( DataFlowEditor()->IsEditing() ) {
+ SUPERV::GNode_ptr aCoupled = SUPERV::GNode::_narrow( Coupled() ) ;
if ( Delete() ) {
_poa->deactivate_object(*_id) ;
CORBA::release(_poa) ;
delete(_id) ;
_thisObj->_remove_ref();
}
+ if ( !CORBA::is_nil( aCoupled ) ) {
+ aCoupled->SetCoupled( "" ) ;
+ aCoupled->destroy() ;
+ }
}
endService( "SNode_Impl::Destroy" );
}
def Input( self , *args ):
types, realargs = getRealArgs(self.N,args)
fn = bs_AddInput_valuedict[types]
+ print types,realargs,fn
anInput = apply( fn, realargs)
if anInput != None :
myInput = Port( anInput , self.N.Verbose )
import random
suf = str(random.randrange(1,10000))
file = '/tmp/' + FuncName + '_' + suf + '.py'
- i = 0
try :
+ #d = dir ()
+ #print "dir()",d
fd = os.open( file , os.O_CREAT | os.O_WRONLY | os.O_TRUNC )
+ #d = dir (fd)
+ #print "dir(fd)",d
+ i = 0
while ( i < len( PyFunc ) ) :
+ print i,'/',len( PyFunc ),PyFunc[ i ]
os.write( fd , PyFunc[ i ] + '\n' )
i = i + 1
+ os.close( fd )
edit = '${EDITOR} ' + file
os.system( edit )
fd = os.open( file , os.O_RDONLY )
while len( line ) :
res = res + line
line = os.read( fd , 132 )
+ os.close( fd )
PyFunc = res.splitlines()
i = 0
while i < len( PyFunc ) :
// Create a list to store names of created files
SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames;
- CORBA::String_var myStudyName = strdup(SALOMEDS_Tool::GetNameFromPath(theComponent->GetStudy()->URL()));
+ TCollection_AsciiString myStudyName("");
+ if (isMultiFile) myStudyName = strdup(SALOMEDS_Tool::GetNameFromPath(theComponent->GetStudy()->URL()));
SALOMEDS::ChildIterator_var anIter = theComponent->GetStudy()->NewChildIterator(theComponent);
TColStd_SequenceOfAsciiString aFileNames;
SALOMEDS::SObject_var aSO = anIter->Value();
SALOMEDS::GenericAttribute_var anAttr;
if (aSO->FindAttribute(anAttr,"AttributeIOR")) {
- aName = TCollection_AsciiString(myStudyName) +
+ aName = myStudyName +
TCollection_AsciiString("_SUPERVISION_") +
TCollection_AsciiString(aSO->Tag()) +
TCollection_AsciiString(".xml");
}
// sprintf(aName, "%s_SUPERVISION_tmp_%d.xml",myStudyName,myCounter);
- CORBA::String_var myStudyName = strdup(SALOMEDS_Tool::GetNameFromPath(theSObject->GetStudy()->URL()));
- TCollection_AsciiString aName = TCollection_AsciiString(myStudyName) +
+// CORBA::String_var myStudyName("");
+// if (isMultiFile) myStudyName = strdup(SALOMEDS_Tool::GetNameFromPath(theSObject->GetStudy()->URL()));
+ TCollection_AsciiString aName = //TCollection_AsciiString(myStudyName) +
TCollection_AsciiString("_SUPERVISION_") +
TCollection_AsciiString(theSObject->Tag()) +
TCollection_AsciiString(".xml");
CORBA::String_var aComponentID = theSObject->GetFatherComponent()->GetID();
if (strcmp(aFatherID, aComponentID)) return CORBA::string_dup(aLocalPersistentID);
+ string myStudyName("");
+ if (isMultiFile) myStudyName = strdup(SALOMEDS_Tool::GetNameFromPath(theSObject->GetStudy()->URL()));
+
string aStr(myStrURL);
- aStr += string(aLocalPersistentID);
+ aStr += myStudyName + string(aLocalPersistentID);
SUPERV::Graph_ptr graph = Graph(aStr.c_str());
if (graph->_is_nil())
THROW_SALOME_CORBA_EXCEPTION("Unable to find graph in the file",SALOME::BAD_PARAM);
+ // mpv: remove IORs input ports on loading
+ MESSAGE("Remove IORs input ports on loading");
+ SUPERV::ListOfNodes_var aNodes = graph->Nodes();
+ SUPERV::CNode_var aNode;
+ const char* aStrIOR = "";
+ CORBA::Any * anAny = new CORBA::Any();
+ *anAny <<= aStrIOR ;
+ int i, j;
+ for(i = aNodes->CNodes.length() - 1; i >= 0; i--) {
+ aNode = aNodes->CNodes[i];
+ SUPERV::ListOfPorts_var aPorts = aNode->Ports();
+ for(j = aPorts->length() - 1; j >= 0; j--) {
+ SUPERV::Port_var aPort = aPorts[j];
+ if (aPort->IsIOR()) {
+ aPort->Input(AnyValue(*anAny));
+ }
+ }
+ }
+ for(i = aNodes->FNodes.length() - 1; i >= 0; i--) {
+ aNode = aNodes->FNodes[i];
+ SUPERV::ListOfPorts_var aPorts = aNode->Ports();
+ for(j = aPorts->length() - 1; j >= 0; j--) {
+ SUPERV::Port_var aPort = aPorts[j];
+ if (aPort->IsIOR()) {
+ //CORBA::Any * anAny = new CORBA::Any(CORBA::TypeCode::PR_null_tc(), (void*)NULL, 0) ;
+ aPort->Input(AnyValue(*anAny));
+ }
+ }
+ }
+ for(i = aNodes->INodes.length() - 1; i >= 0; i--) {
+ aNode = aNodes->INodes[i];
+ SUPERV::ListOfPorts_var aPorts = aNode->Ports();
+ for(j = aPorts->length() - 1; j >= 0; j--) {
+ SUPERV::Port_var aPort = aPorts[j];
+ if (aPort->IsIOR()) {
+ aPort->Input(AnyValue(*anAny));
+ }
+ }
+ }
+ for(i = aNodes->GNodes.length() - 1; i >= 0; i--) {
+ aNode = aNodes->GNodes[i];
+ SUPERV::ListOfPorts_var aPorts = aNode->Ports();
+ for(j = aPorts->length() - 1; j >= 0; j--) {
+ SUPERV::Port_var aPort = aPorts[j];
+ if (aPort->IsIOR()) {
+ aPort->Input(AnyValue(*anAny));
+ }
+ }
+ }
+ for(i = aNodes->GNodes.length() - 1; i >= 0; i--) {
+ aNode = aNodes->GNodes[i];
+ SUPERV::ListOfPorts_var aPorts = aNode->Ports();
+ for(j = aPorts->length() - 1; j >= 0; j--) {
+ SUPERV::Port_var aPort = aPorts[j];
+ if (aPort->IsIOR()) {
+ aPort->Input(AnyValue(*anAny));
+ }
+ }
+ }
+ for(i = aNodes->LNodes.length() - 1; i >= 0; i--) {
+ aNode = aNodes->LNodes[i];
+ SUPERV::ListOfPorts_var aPorts = aNode->Ports();
+ for(j = aPorts->length() - 1; j >= 0; j--) {
+ SUPERV::Port_var aPort = aPorts[j];
+ if (aPort->IsIOR()) {
+ aPort->Input(AnyValue(*anAny));
+ }
+ }
+ }
+ for(i = aNodes->ELNodes.length() - 1; i >= 0; i--) {
+ aNode = aNodes->ELNodes[i];
+ SUPERV::ListOfPorts_var aPorts = aNode->Ports();
+ for(j = aPorts->length() - 1; j >= 0; j--) {
+ SUPERV::Port_var aPort = aPorts[j];
+ if (aPort->IsIOR()) {
+ aPort->Input(AnyValue(*anAny));
+ }
+ }
+ }
+ for(i = aNodes->SNodes.length() - 1; i >= 0; i--) {
+ aNode = aNodes->SNodes[i];
+ SUPERV::ListOfPorts_var aPorts = aNode->Ports();
+ for(j = aPorts->length() - 1; j >= 0; j--) {
+ SUPERV::Port_var aPort = aPorts[j];
+ if (aPort->IsIOR()) {
+ aPort->Input(AnyValue(*anAny));
+ }
+ }
+ }
+ for(i = aNodes->ESNodes.length() - 1; i >= 0; i--) {
+ aNode = aNodes->ESNodes[i];
+ SUPERV::ListOfPorts_var aPorts = aNode->Ports();
+ for(j = aPorts->length() - 1; j >= 0; j--) {
+ SUPERV::Port_var aPort = aPorts[j];
+ if (aPort->IsIOR()) {
+ aPort->Input(AnyValue(*anAny));
+ }
+ }
+ }
+
+
SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames;
aSeq->length(1);
aSeq[0]=aLocalPersistentID;
if ( !Comp->_is_nil() ) {
aName->SetValue( Comp->componentusername() );
}
-
anAttr = aBuilder->FindOrCreateAttribute(aFather, "AttributePixMap");
aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
aPixmap->SetPixMap( "ICON_OBJBROWSER_Supervision" );
switch (anAny.type()->kind()) {
case CORBA::tk_string: {
anAny >>= retstr;
-// MESSAGE( "ToString( string ) " << retstr );
+ MESSAGE( "ToString( string ) '" << retstr << "'" );
break ;
}
case CORBA::tk_long: {
anAny >>= l;
astr << l << ends ;
retstr = astr.str().c_str() ;
-// retstr = new char[13];
-// snprintf(retstr, 13, "%ld", l);
-// MESSAGE( "ToString( long ) " << l << " " << retstr );
+ MESSAGE( "ToString( long ) '" << l << " " << retstr << "'" );
break ;
}
case CORBA::tk_double: {
anAny >>= d;
astr << setw(25) << setprecision(18) << d << ends ;
retstr = astr.str().c_str() ;
-// retstr = new char[13];
-// snprintf(retstr, 13, "%lf", d);
int i = 0 ;
while ( i < (int ) strlen( retstr ) && retstr[ i++ ] == ' ' ) {
- startstr = i - 1 ;
+ startstr = i ;
}
MESSAGE( "ToString( double ) '" << d << "' '" << retstr << "' '" << &retstr[ startstr ] << "'");
break ;
try {
anAny >>= obj ;
retstr = _Orb->object_to_string( obj );
-// MESSAGE( "ToString( object ) " << retstr );
+ MESSAGE( "ToString( object ) '" << retstr << "'" );
}
catch ( ... ) {
retstr = "object_to_string catched " ;
}
default: {
retstr = "Unknown CORBA::Any Type" ;
- MESSAGE( retstr );
+// MESSAGE( retstr );
break ;
}
}
from batchmode_salome import naming_service
from batchmode_salome import CORBA
from batchmode_salome import myStudy
- import SUPERV
- import SUPERV_idl
except :
import curses
from LifeCycleCORBA import *
father = myBuilder.NewComponent("SUPERV")
A1 = myBuilder.FindOrCreateAttribute(father, "AttributeName");
FName = A1._narrow(SALOMEDS.AttributeName)
-
-# FName.SetValue("Supervision")
- Comp = modulecatalog.GetComponent( "SUPERV" )
- FName.SetValue( Comp._get_componentusername() )
-
- A2 = myBuilder.FindOrCreateAttribute(father, "AttributePixMap");
+ #FName.SetValue("Supervision")
+ Comp = modulecatalog.GetComponent( "SUPERV" )
+ FName.SetValue(Comp._get_componentusername())
+ A2 = myBuilder.FindOrCreateAttribute(father, "AttributePixMap");
aPixmap = A2._narrow(SALOMEDS.AttributePixMap);
aPixmap.SetPixMap( "ICON_OBJBROWSER_Supervision" );
myBuilder.DefineComponentInstance(father,SuperVision)
if bs != -1 :
portsname1,portsname2 = portsname.split('\\')
portsname = portsname1 + portsname2
- listofports = aName + portsname
+ if ports[ 0 ].IsInput():
+ listofports = aName + 'In' + portsname
+ else :
+ listofports = aName + 'Out' + portsname
i = 1
while i < len( ports ) :
portsname = ports[ i ].Name()
if bs != -1 :
portsname1,portsname2 = portsname.split('\\')
portsname = portsname1 + portsname2
- listofports = listofports + ',' + aName + portsname
+ if ports[ i ].IsInput():
+ listofports = listofports + ',' + aName + 'In' + portsname
+ else :
+ listofports = listofports + ',' + aName + 'Out' + portsname
i = i + 1
print listofports
if len( ports ) == 1 :
return self.N.Y()
def destroy( self ):
self.N.destroy()
+ def CpuUsed( self ):
+ return self.N.CpuUsed()
##########################################################
class FNode(CNode):
self.N = aNode
self.N.Verbose = Verbose
def GetComponentName( self ):
- return self.N.ComponentName()
+ return self.N.GetComponentName()
def GetInterfaceName( self ):
return self.N._get_interfaceName()
def GetContainer( self ):
- return self.N.Container()
+ return self.N.GetContainer()
def SetComponentName( self , aComponentName ):
return self.N.SetComponentName( aComponentName )
def SetInterfaceName( self , anInterfaceName ):
self.N.Verbose = Verbose
def Edit( self , FuncName , PyFunc ) :
import os
- file = '/tmp/' + FuncName + '.py'
- i = 0
- fd = os.open( file , os.O_CREAT | os.O_WRONLY | os.O_TRUNC )
- while ( i < len( PyFunc ) ) :
- os.write( fd , PyFunc[ i ] + '\n' )
- i = i + 1
- edit = '${EDITOR} ' + file
- os.system( edit )
- fd = os.open( file , os.O_RDONLY )
- line = os.read( fd , 132 )
- res = ''
- while len( line ) :
- res = res + line
+ import random
+ suf = str(random.randrange(1,10000))
+ file = '/tmp/' + FuncName + '_' + suf + '.py'
+ try :
+ #d = dir ()
+ #print "dir()",d
+ fd = os.open( file , os.O_CREAT | os.O_WRONLY | os.O_TRUNC )
+ #d = dir (fd)
+ #print "dir(fd)",d
+ i = 0
+ while ( i < len( PyFunc ) ) :
+ print i,'/',len( PyFunc ),PyFunc[ i ]
+ os.write( fd , PyFunc[ i ] + '\n' )
+ i = i + 1
+ os.close( fd )
+ edit = '${EDITOR} ' + file
+ os.system( edit )
+ fd = os.open( file , os.O_RDONLY )
line = os.read( fd , 132 )
- PyFunc = res.splitlines()
- i = 0
- while i < len( PyFunc ) :
- print PyFunc[i]
- i = i + 1
+ res = ''
+ while len( line ) :
+ res = res + line
+ line = os.read( fd , 132 )
+ os.close( fd )
+ PyFunc = res.splitlines()
+ i = 0
+ while i < len( PyFunc ) :
+ print PyFunc[i]
+ i = i + 1
+ except :
+ print "Open of",file,"failed."
return PyFunc
def SetPyFunction( self , FuncName , aPyFunction ):
return self.N.SetPyFunction( FuncName , aPyFunction )
sts,aNode,anEvent,aState = self.G.Event()
self.S = sts
return sts,aNode,anEvent,aState
+ def EventNoW( self ):
+ sts,aNode,anEvent,aState = self.G.EventNoW()
+ self.S = sts
+ return sts,aNode,anEvent,aState
def EventW( self ):
sts,aNode,anEvent,aState = self.G.EventW()
self.S = sts