From 1cbaac50370d660382c7c00c94a1ec13741a4e3a Mon Sep 17 00:00:00 2001 From: smh Date: Wed, 28 Jan 2004 14:20:58 +0000 Subject: [PATCH] MPV: Merge V1_2d --- idl/SUPERV.idl | 486 +++++++---- src/GraphBase/DataFlowBase_Base.hxx | 17 + src/GraphBase/DataFlowBase_ComputingNode.cxx | 103 ++- src/GraphBase/DataFlowBase_Graph.cxx | 64 +- src/GraphBase/DataFlowBase_InLineNode.cxx | 8 +- src/GraphBase/DataFlowBase_InLineNode.hxx | 3 +- src/GraphBase/DataFlowBase_LoopNode.cxx | 17 +- src/GraphBase/DataFlowBase_LoopNode.hxx | 25 +- src/GraphBase/DataFlowBase_OutPort.cxx | 7 +- .../DataFlowBase_ServicesParameter.hxx | 2 +- src/GraphBase/DataFlowBase_XmlHandler.cxx | 6 +- src/GraphBase/Makefile.in | 19 +- .../SuperVisionBase_CheckOfUndefined.cxx | 10 +- src/GraphEditor/DataFlowEditor_OutNode.cxx | 145 ++-- src/GraphEditor/Makefile.in | 12 +- .../DataFlowExecutor_DataFlow.hxx | 1 + .../DataFlowExecutor_DataFlow.lxx | 3 + .../DataFlowExecutor_DynInvoke.cxx | 12 +- .../DataFlowExecutor_FiniteStateMachine.cxx | 116 +++ .../DataFlowExecutor_FiniteStateMachine.hxx | 44 +- src/GraphExecutor/DataFlowExecutor_InNode.cxx | 273 +++--- src/GraphExecutor/DataFlowExecutor_InNode.hxx | 8 +- .../DataFlowExecutor_InNodeThreads.cxx | 567 +++++++----- .../DataFlowExecutor_OutNode.cxx | 202 ++++- .../DataFlowExecutor_OutNode.hxx | 7 +- .../DataFlowExecutor_PyDynInvoke.cxx | 813 +++++++++--------- src/GraphExecutor/Makefile.in | 11 +- src/SUPERVGUI/Makefile.in | 4 +- src/SUPERVGUI/SUPERVGUI.cxx | 10 +- src/SUPERVGUI/SUPERVGUI_BrowseNodeDlg.h | 1 - src/SUPERVGUI/SUPERVGUI_ControlNode.cxx | 45 +- src/SUPERVGUI/SUPERVGUI_Def.h | 2 +- src/SUPERVGUI/SUPERVGUI_Graph.cxx | 19 +- src/SUPERVGUI/SUPERVGUI_GraphNode.cxx | 82 +- src/SUPERVGUI/SUPERVGUI_GraphNode.h | 1 + src/SUPERVGUI/SUPERVGUI_Link.cxx | 8 +- src/SUPERVGUI/SUPERVGUI_Link.h | 1 + src/SUPERVGUI/SUPERVGUI_Main.cxx | 447 +++++++--- src/SUPERVGUI/SUPERVGUI_Main.h | 58 +- src/SUPERVGUI/SUPERVGUI_Node.cxx | 13 +- src/SUPERVGUI/SUPERVGUI_Node.h | 2 + src/SUPERVGUI/SUPERVGUI_Port.cxx | 30 +- src/SUPERVGUI/SUPERV_icons.po | 2 +- src/SUPERVGUI/SUPERV_msg_en.po | 20 +- src/Supervision/CNode_Impl.cxx | 33 +- src/Supervision/ELNode_Impl.cxx | 18 +- src/Supervision/ESNode_Impl.cxx | 5 + src/Supervision/GNode_Impl.cxx | 4 +- src/Supervision/GNode_Impl.hxx | 9 +- src/Supervision/Graph_Impl.cxx | 674 +++++++++------ src/Supervision/Graph_Impl.hxx | 8 +- src/Supervision/LNode_Impl.cxx | 12 +- src/Supervision/Makefile.in | 17 +- src/Supervision/Port_Impl.cxx | 18 +- src/Supervision/SNode_Impl.cxx | 5 + src/Supervision/SuperV.py | 10 +- src/Supervision/SuperV_Impl.cxx | 117 ++- src/Supervision/Value_Impl.cxx | 14 +- src/Supervision/batchmode_SuperV.py | 80 +- 59 files changed, 3058 insertions(+), 1692 deletions(-) diff --git a/idl/SUPERV.idl b/idl/SUPERV.idl index b78f1e4..18eae1a 100644 --- a/idl/SUPERV.idl +++ b/idl/SUPERV.idl @@ -1,27 +1,27 @@ // 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 */ @@ -32,14 +32,14 @@ #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
In general, ports represent input or output parameters of the functions, +\note
In general, ports represent input or output parameters of the functions, implemented in different kinds of nodes of the graph. */ enum KindOfPort { UndefinedParameter , ServiceParameter , GateParameter , @@ -65,7 +65,7 @@ This struct contains fields defining the date. 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). */ @@ -90,6 +90,8 @@ This enumeration contains a set of elements defining the current state of the no ReRunState , ReStartState , NumberOfGraphStates } ; +/*! A sequence of string values. +*/ typedef sequence ListOfStrings ; interface Value ; @@ -118,6 +120,9 @@ This enumeration contains a set of elements defining the current state of the no typedef sequence ListOfELNodes ; typedef sequence ListOfSNodes ; typedef sequence ListOfESNodes ; +/*! +This struct contains fields defining different types of nodes. +*/ struct ListOfNodes { ListOfCNodes CNodes ; @@ -140,53 +145,53 @@ This enumeration contains a set of elements defining the current state of the no // 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 } ; @@ -203,13 +208,13 @@ This interface contains a set of methods necessary for management of a %graph. */ 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
In this graph there is also a possibility to update nodes, coordinates of the links, of container names and input data. @@ -217,83 +222,101 @@ This interface contains a set of methods necessary for management of a %graph. */ SUPERV::Graph GraphE(in string aGraph ) ; // aGraphName or aGraphXmlFile -/*! -Creates a value for %Input method in interface %Node. +/*! +Creates a value of string type which will be used for Input method in the interface %Node. +\param aString Input value of string type. */ SUPERV::Value StringValue( in string aString ) ; +/*! +Creates a value of any type which will be used for Input 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: +
    +
  • creating a Computation node and setting its parameters (Name, Author, Comments etc.) +
  • checking the current state of the node in the data flow +
  • node execution follow-up +
  • 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) +
+*/ ////////////// 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 ) ; @@ -310,16 +333,17 @@ Allows to update the comments about this node(graph). // 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
A node of the graph can also represent in its turn another graph. */ boolean IsGraph() ; @@ -327,88 +351,128 @@ Returns True if this node is a graph. 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. +
+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. +
+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. +
+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. +
+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. +
+If Suspended : running will be continued. +If not Suspended : cancels the current ControlState ( Suspend, Kill, ...) +*/ boolean Resume(); /*! @@ -422,10 +486,11 @@ Restarts execution of the graph beginning from a definite node. /*! 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 ); @@ -435,6 +500,9 @@ Restarts and suspends execution of the graph beginning from a defined node. 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). @@ -442,79 +510,152 @@ 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() ; } ; @@ -540,38 +681,50 @@ Returns the Cpu used by a node in seconds. /*! \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 ) ; @@ -581,12 +734,16 @@ This interface includes a set of methods used for management of the graphs in %S 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 ) ; /*! @@ -599,7 +756,7 @@ Returns True if the graph is read Only. */ 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. @@ -610,9 +767,9 @@ Returns True if the graph is read Only. 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). @@ -623,11 +780,11 @@ Returns True if the graph is read Only. // 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
Execution of the thread is suspended between the return of this +\note
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). @@ -635,10 +792,17 @@ method and its next usage. */ 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 */ @@ -653,23 +817,23 @@ Returns the number of suspended threads. 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() ; @@ -716,9 +880,9 @@ Returns a list of graphs. /*! \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 { @@ -736,24 +900,24 @@ Associates an %Input %Port to the Link // 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
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
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. */ @@ -761,20 +925,20 @@ Changes the location of a definite coordinate point of the link. 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() ; @@ -800,7 +964,7 @@ Converts the given value into a value of independant data type. Returns True if the value represents an IOR. */ boolean IsIOR() ; -/*! +/*! Gets data type of the component. */ string ComponentDataType() ; @@ -818,24 +982,28 @@ This interface contains a set of methods used for management of the ports. ////////////// /*! - 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() ; @@ -845,49 +1013,65 @@ Returns a list of links of an Input %Port of an EndSwitchNode */ 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() ; } ; diff --git a/src/GraphBase/DataFlowBase_Base.hxx b/src/GraphBase/DataFlowBase_Base.hxx index 3b0a7fc..2d77bdd 100644 --- a/src/GraphBase/DataFlowBase_Base.hxx +++ b/src/GraphBase/DataFlowBase_Base.hxx @@ -64,6 +64,23 @@ inline char * my_strdup( const char * s ) { 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 } ; diff --git a/src/GraphBase/DataFlowBase_ComputingNode.cxx b/src/GraphBase/DataFlowBase_ComputingNode.cxx index bb47f9e..aab8cea 100644 --- a/src/GraphBase/DataFlowBase_ComputingNode.cxx +++ b/src/GraphBase/DataFlowBase_ComputingNode.cxx @@ -19,15 +19,15 @@ using namespace std; 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); @@ -357,6 +357,9 @@ bool GraphBase::ComputingNode::HasInput(const char * ToServiceParameterName ) { 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 { @@ -717,55 +720,44 @@ bool GraphBase::ComputingNode::SaveXML( QDomDocument & Graph , QDomElement & inf 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 << " " << FuncNames[i].c_str() -// << "" << 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 << " " << FuncNames[i].c_str() -// << "" << endl ; -// } -// else if ( i == 2 ) { -// f << Tabs << " " << FuncNames[i].c_str() -// << "" << endl ; -// } - } -// f << Tabs << " " << (*PythonFunctions[i])[j] -// << "" << 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 << " " << endl ; } -// f << Tabs << "" << endl ; // f << Tabs << "" << FirstCreation() << "" // << endl ; @@ -926,6 +918,13 @@ bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName , 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( '" diff --git a/src/GraphBase/DataFlowBase_Graph.cxx b/src/GraphBase/DataFlowBase_Graph.cxx index c57f950..edf6218 100644 --- a/src/GraphBase/DataFlowBase_Graph.cxx +++ b/src/GraphBase/DataFlowBase_Graph.cxx @@ -546,6 +546,14 @@ bool GraphBase::Graph::RemoveNode( const char* aNodeName ) { } } // 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 ; @@ -558,19 +566,19 @@ bool GraphBase::Graph::RemoveNode( const char* aNodeName ) { 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 << "(" @@ -622,11 +630,10 @@ bool GraphBase::Graph::AddLink( 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 ) { @@ -680,7 +687,8 @@ bool GraphBase::Graph::AddLink( } } } - 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 ; @@ -765,7 +773,7 @@ bool GraphBase::Graph::AddLink( 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() ){ @@ -774,14 +782,14 @@ bool GraphBase::Graph::AddLink( 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; @@ -816,7 +824,7 @@ bool GraphBase::Graph::RemoveLink( const char* FromNodeName , if ( fromNode ) { fromNode->RemoveLink( toNode ) ; } - if ( fromNode->IsSwitchNode() ) { + if ( fromNode->IsSwitchNode() && !anOutPort->IsGate() && !toNode->IsEndSwitchNode() ) { anOutPort->Kind( SUPERV::InLineParameter ) ; } #if 0 @@ -1380,32 +1388,35 @@ bool GraphBase::Graph::Sort() { 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 ) @@ -1427,7 +1438,7 @@ bool GraphBase::Graph::Sort() { } 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 ; @@ -1442,6 +1453,7 @@ bool GraphBase::Graph::Sort() { << " --> new count " << _CnxInPortsNumber[ i ] << endl ; } } + if ( !ChangeCount ) break ; _LevelsNumber += 1 ; @@ -1492,26 +1504,28 @@ bool GraphBase::Graph::Sort() { (_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 " diff --git a/src/GraphBase/DataFlowBase_InLineNode.cxx b/src/GraphBase/DataFlowBase_InLineNode.cxx index e182718..315e6ed 100644 --- a/src/GraphBase/DataFlowBase_InLineNode.cxx +++ b/src/GraphBase/DataFlowBase_InLineNode.cxx @@ -58,6 +58,7 @@ GraphBase::InLineNode::InLineNode( CORBA::ORB_ptr ORB , X , Y , Graph_prof_debug , Graph_fdebug ) { _PythonFunction = SUPERV::ListOfStrings() ; + _MyPyRunMethod = NULL ; cdebug_in << "GraphBase::InLineNode::Node " << this << "' _Name " << (void *) Name() << " '" << Name() << " _Comment " @@ -103,6 +104,7 @@ GraphBase::InLineNode::InLineNode( CORBA::ORB_ptr ORB , << ServiceInParameter().length() << ") Out(" << ServiceOutParameter().length() << ")" << endl ; + _MyPyRunMethod = NULL ; SetPythonFunction( FuncName , aPythonFunction ) ; SALOME_ModuleCatalog::Service aNodeService ; aNodeService.ServiceName = NodeName ; @@ -135,8 +137,10 @@ void GraphBase::InLineNode::SetPythonFunction( const char * FuncName , 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 ) ; diff --git a/src/GraphBase/DataFlowBase_InLineNode.hxx b/src/GraphBase/DataFlowBase_InLineNode.hxx index 0e34176..903b6e4 100644 --- a/src/GraphBase/DataFlowBase_InLineNode.hxx +++ b/src/GraphBase/DataFlowBase_InLineNode.hxx @@ -76,8 +76,7 @@ namespace GraphBase { void PyRunMethod( PyObject * MyPyRunMethod ) { _MyPyRunMethod = MyPyRunMethod ; } ; PyObject * PyRunMethod() { - return _MyPyRunMethod ; - } + return _MyPyRunMethod ; } ; // bool SaveXML( ostream &f , char *Tabs , diff --git a/src/GraphBase/DataFlowBase_LoopNode.cxx b/src/GraphBase/DataFlowBase_LoopNode.cxx index aa87e30..b062881 100644 --- a/src/GraphBase/DataFlowBase_LoopNode.cxx +++ b/src/GraphBase/DataFlowBase_LoopNode.cxx @@ -59,11 +59,20 @@ GraphBase::LoopNode::LoopNode( CORBA::ORB_ptr ORB , << 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; diff --git a/src/GraphBase/DataFlowBase_LoopNode.hxx b/src/GraphBase/DataFlowBase_LoopNode.hxx index 833aeed..45d80ca 100644 --- a/src/GraphBase/DataFlowBase_LoopNode.hxx +++ b/src/GraphBase/DataFlowBase_LoopNode.hxx @@ -54,35 +54,44 @@ namespace GraphBase { 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 ) ; diff --git a/src/GraphBase/DataFlowBase_OutPort.cxx b/src/GraphBase/DataFlowBase_OutPort.cxx index 67a16e1..751d0df 100644 --- a/src/GraphBase/DataFlowBase_OutPort.cxx +++ b/src/GraphBase/DataFlowBase_OutPort.cxx @@ -155,9 +155,10 @@ ostream & operator<< (ostream &f ,const GraphBase::OutPort &P) { f << P.PortName() << ", " << "type : " << P.PortType() << ", " ; - - f << "from " - << P.NodeName() << ", "; + f << "kind " + << P.Kind() << ", "; + f << "from " + << P.NodeName() << ", "; return f; } diff --git a/src/GraphBase/DataFlowBase_ServicesParameter.hxx b/src/GraphBase/DataFlowBase_ServicesParameter.hxx index f20f4a7..786cab9 100644 --- a/src/GraphBase/DataFlowBase_ServicesParameter.hxx +++ b/src/GraphBase/DataFlowBase_ServicesParameter.hxx @@ -38,7 +38,7 @@ namespace GraphBase { public: ServicesParameter() { - cout << "ServicesParameter()" << endl ; + //cout << "ServicesParameter()" << endl ; _ServicesParameter.Parametername = (char *) NULL ; _ServicesParameter.Parametertype = (char *) NULL ; } ; diff --git a/src/GraphBase/DataFlowBase_XmlHandler.cxx b/src/GraphBase/DataFlowBase_XmlHandler.cxx index 662a680..3a6f82d 100644 --- a/src/GraphBase/DataFlowBase_XmlHandler.cxx +++ b/src/GraphBase/DataFlowBase_XmlHandler.cxx @@ -80,7 +80,8 @@ bool GraphBase::XmlHandler::startElement( const QString&, const QString&, dataflowxml = TRUE; } if ( dataflowxml ) { - fieldname[depth++] = (const char * ) qName ; +// fieldname[depth++] = (const char * ) qName ; + fieldname[depth++] = qName.latin1() ; } if ( depth == maxlevel+1 ) return false ; @@ -1059,7 +1060,8 @@ bool GraphBase::XmlHandler::characters( const QString& ch ) { 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; } diff --git a/src/GraphBase/Makefile.in b/src/GraphBase/Makefile.in index eabaf6c..22235ea 100644 --- a/src/GraphBase/Makefile.in +++ b/src/GraphBase/Makefile.in @@ -91,16 +91,13 @@ 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 -#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@ - - diff --git a/src/GraphBase/SuperVisionBase_CheckOfUndefined.cxx b/src/GraphBase/SuperVisionBase_CheckOfUndefined.cxx index 8787352..e41144b 100644 --- a/src/GraphBase/SuperVisionBase_CheckOfUndefined.cxx +++ b/src/GraphBase/SuperVisionBase_CheckOfUndefined.cxx @@ -54,19 +54,19 @@ int main(int argc, char **argv) { 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; } diff --git a/src/GraphEditor/DataFlowEditor_OutNode.cxx b/src/GraphEditor/DataFlowEditor_OutNode.cxx index 7b3d503..cd7876c 100644 --- a/src/GraphEditor/DataFlowEditor_OutNode.cxx +++ b/src/GraphEditor/DataFlowEditor_OutNode.cxx @@ -504,14 +504,18 @@ bool GraphEditor::OutNode::AddLinkCoord( const char* FromNodeName , 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 ; @@ -524,71 +528,84 @@ bool GraphEditor::OutNode::AddLinkCoord( const char* FromNodeName , 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 ; @@ -599,32 +616,39 @@ bool GraphEditor::OutNode::GetLinkCoord( const char* FromNodeName , 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 ; @@ -652,18 +676,19 @@ bool GraphEditor::OutNode::Valid() { _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; diff --git a/src/GraphEditor/Makefile.in b/src/GraphEditor/Makefile.in index 108f146..5a5bfd7 100644 --- a/src/GraphEditor/Makefile.in +++ b/src/GraphEditor/Makefile.in @@ -58,12 +58,14 @@ LIB_CLIENT_IDL = SALOME_ModuleCatalog.idl \ 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@ diff --git a/src/GraphExecutor/DataFlowExecutor_DataFlow.hxx b/src/GraphExecutor/DataFlowExecutor_DataFlow.hxx index 3d94a13..5f1f153 100644 --- a/src/GraphExecutor/DataFlowExecutor_DataFlow.hxx +++ b/src/GraphExecutor/DataFlowExecutor_DataFlow.hxx @@ -103,6 +103,7 @@ namespace GraphExecutor { bool EventW( char ** aNodeName , SUPERV::GraphEvent & anEvent , SUPERV::GraphState & aState ) ; + long EventQSize() ; bool IsWaiting() ; bool IsReady() ; diff --git a/src/GraphExecutor/DataFlowExecutor_DataFlow.lxx b/src/GraphExecutor/DataFlowExecutor_DataFlow.lxx index 41397d5..ce3c606 100644 --- a/src/GraphExecutor/DataFlowExecutor_DataFlow.lxx +++ b/src/GraphExecutor/DataFlowExecutor_DataFlow.lxx @@ -103,6 +103,9 @@ inline bool GraphExecutor::DataFlow::EventW( char ** aNodeName , 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() ; diff --git a/src/GraphExecutor/DataFlowExecutor_DynInvoke.cxx b/src/GraphExecutor/DataFlowExecutor_DynInvoke.cxx index dba4753..713df92 100644 --- a/src/GraphExecutor/DataFlowExecutor_DynInvoke.cxx +++ b/src/GraphExecutor/DataFlowExecutor_DynInvoke.cxx @@ -51,14 +51,14 @@ void GraphExecutor::InNode::DynInvoke(Engines::Component_ptr objComponent , 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 ; @@ -119,7 +119,7 @@ void GraphExecutor::InNode::DynInvoke(Engines::Component_ptr objComponent , } } MESSAGE("") ; -//#endif +#endif } for ( i = 0 ; i < n_out ; i++ ) { @@ -127,7 +127,7 @@ void GraphExecutor::InNode::DynInvoke(Engines::Component_ptr objComponent , 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 ; @@ -188,7 +188,7 @@ void GraphExecutor::InNode::DynInvoke(Engines::Component_ptr objComponent , } } MESSAGE("") ; -//#endif +#endif } req->invoke(); diff --git a/src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.cxx b/src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.cxx index 5449455..e63271f 100644 --- a/src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.cxx +++ b/src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.cxx @@ -451,6 +451,11 @@ GraphExecutor::FiniteStateMachine::FiniteStateMachine() { perror( msg ) ; } + pthread_mutex_init( &_MutexPythonWait , NULL ) ; + _ExecNumber = 0 ; + _GraphExecutingNumber = 0 ; + _PyInitModule = false ; + // cdebug_out << "FiniteStateMachine::FiniteStateMachine _TransitionTable " // << endl; } @@ -469,6 +474,117 @@ void * start_function( void *p ) { 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 ") ; diff --git a/src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.hxx b/src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.hxx index aaeac24..2ce5d9d 100644 --- a/src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.hxx +++ b/src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.hxx @@ -34,6 +34,11 @@ #include #include +#include + +#include +#include + #include "DataFlowBase_Base.hxx" #include @@ -110,6 +115,12 @@ namespace GraphExecutor { 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 ; @@ -121,33 +132,34 @@ namespace GraphExecutor { 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 ] ; } ; }; diff --git a/src/GraphExecutor/DataFlowExecutor_InNode.cxx b/src/GraphExecutor/DataFlowExecutor_InNode.cxx index 8663bad..45ebcad 100644 --- a/src/GraphExecutor/DataFlowExecutor_InNode.cxx +++ b/src/GraphExecutor/DataFlowExecutor_InNode.cxx @@ -68,6 +68,8 @@ static void InitInNode( int &_RewindStack , bool &_ResumeSync , pthread_cond_t &_KillWait , bool &_KillSync , + pthread_cond_t &_ThreadStartedWait , + bool &_ThreadStartedSync , pthread_cond_t &_StopWait , GraphExecutor::FiniteStateMachine ** _Automaton , GraphExecutor::FiniteStateMachine * theAutomaton , @@ -113,6 +115,11 @@ static void InitInNode( int &_RewindStack , 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 ) ; @@ -121,8 +128,7 @@ static void InitInNode( int &_RewindStack , *_Orb = CORBA::ORB::_nil(); } -GraphExecutor::FiniteStateMachine * theAutomaton = new - GraphExecutor::FiniteStateMachine() ; +GraphExecutor::FiniteStateMachine * theAutomaton = new GraphExecutor::FiniteStateMachine() ; //GraphExecutor::InNode::InNode() : // GraphBase::FactoryNode() { @@ -146,6 +152,8 @@ GraphExecutor::InNode::InNode() { _ResumeSync , _KillWait , _KillSync , + _ThreadStartedWait , + _ThreadStartedSync , _StopWait , &_Automaton , theAutomaton , @@ -153,26 +161,26 @@ GraphExecutor::InNode::InNode() { 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 , @@ -201,6 +209,8 @@ GraphExecutor::InNode::InNode(CORBA::ORB_ptr ORB, _ResumeSync , _KillWait , _KillSync , + _ThreadStartedWait , + _ThreadStartedSync , _StopWait , &_Automaton , theAutomaton , @@ -425,6 +435,9 @@ bool GraphExecutor::InNode::Suspend() { bool RetVal ; if ( IsDone() ) { ControlState( SUPERV::VoidState ) ; + if ( _OutNode->IsDone() ) { + ControlState( SUPERV::VoidState ) ; + } RetVal = false ; } else if ( IsWaiting() || IsReady() ) { @@ -433,12 +446,16 @@ bool GraphExecutor::InNode::Suspend() { } 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 ) ; @@ -465,7 +482,8 @@ bool GraphExecutor::InNode::Suspend() { << endl ; RetVal = false ; } - cdebug_out << "GraphExecutor::InNode::Suspend " << RetVal << endl ; + cdebug_out << "GraphExecutor::InNode::Suspend " << RetVal << " " + << Automaton()->StateName( State() ) << endl ; return RetVal ; } @@ -475,7 +493,7 @@ bool GraphExecutor::InNode::ContainerKill() { bool RetVal ; if ( IsFactoryNode() ) { Kill() ; - Container()->Kill_impl() ; + RetVal = Container()->Kill_impl() ; } cdebug_out << "GraphExecutor::InNode::ContainerKill" << endl ; return RetVal ; @@ -485,47 +503,54 @@ bool GraphExecutor::InNode::Kill() { 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() ) { @@ -552,43 +577,20 @@ bool GraphExecutor::InNode::KillDone() { 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 ; } @@ -608,17 +610,19 @@ bool GraphExecutor::InNode::Stop() { 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 ) ; @@ -664,7 +668,9 @@ bool GraphExecutor::InNode::SuspendDone() { else { ControlState( SUPERV::ToSuspendDoneState ) ; if ( IsDone() ) { - ControlState( SUPERV::VoidState ) ; + if ( _OutNode->IsDone() ) { + ControlState( SUPERV::VoidState ) ; + } RetVal = false ; } else { @@ -686,16 +692,16 @@ bool GraphExecutor::InNode::Resume() { 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 { @@ -1118,41 +1124,6 @@ void GraphExecutor::InNode::InitialState( GraphExecutor::OutNode * theOutNode ) << 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 @@ -1175,6 +1146,74 @@ void GraphExecutor::InNode::InitialState( GraphExecutor::OutNode * theOutNode ) 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 ; diff --git a/src/GraphExecutor/DataFlowExecutor_InNode.hxx b/src/GraphExecutor/DataFlowExecutor_InNode.hxx index ec6d305..6351e1f 100644 --- a/src/GraphExecutor/DataFlowExecutor_InNode.hxx +++ b/src/GraphExecutor/DataFlowExecutor_InNode.hxx @@ -106,6 +106,9 @@ namespace GraphExecutor { bool _KillSync ; pthread_cond_t _StopWait ; + pthread_cond_t _ThreadStartedWait ; + bool _ThreadStartedSync ; + pthread_t _Pythread ; long _PyCpuUsed ; long _PyTotCpuUsed ; @@ -350,7 +353,8 @@ namespace GraphExecutor { 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 ) ; @@ -370,6 +374,8 @@ namespace GraphExecutor { GraphExecutor::NodeEvent anEvent ) ; void KillAction() ; void KilledAction() ; + void ThreadStartAction() ; + void ThreadStartedAction() ; void StopAction() ; void StoppedAction() ; int executeAction() ; // New Thread or Same Thread diff --git a/src/GraphExecutor/DataFlowExecutor_InNodeThreads.cxx b/src/GraphExecutor/DataFlowExecutor_InNodeThreads.cxx index 70deb4e..ab2e17f 100644 --- a/src/GraphExecutor/DataFlowExecutor_InNodeThreads.cxx +++ b/src/GraphExecutor/DataFlowExecutor_InNodeThreads.cxx @@ -48,8 +48,7 @@ using namespace std; //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() @@ -98,7 +97,7 @@ int GraphExecutor::InNode::SendEvent( #endif int sts = executeAction() ; - + cdebug << pthread_self() << "/" << ThreadNo() << " <--- SendEvent Node " << Name() << " Event : " << Automaton()->EventName( anEvent ) << " State : " << Automaton()->StateName( State() ) @@ -204,16 +203,21 @@ GraphExecutor::InNode * GraphExecutor::InNode::SuspendAction() { << " 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 ") ; @@ -271,7 +275,7 @@ bool GraphExecutor::InNode::ResumeAction( GraphExecutor::NodeEvent aResumeEvent 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 ; @@ -416,8 +420,79 @@ void GraphExecutor::InNode::StopAction() { } } +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 ) ; } @@ -452,6 +527,10 @@ int GraphExecutor::InNode::executeAction() { } 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() @@ -505,6 +584,7 @@ void * run_function(void *p) { perror("pthread_setcancelstate ") ; exit(0) ; } + aNode->ThreadStartAction() ; aNode->ExecuteAction() ; char * msg = new char[40] ; sprintf( msg , "%d" , (int ) aNode->ThreadNo() ) ; @@ -519,15 +599,16 @@ void * run_function(void *p) { 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 ; @@ -655,8 +736,8 @@ int GraphExecutor::InNode::ExecuteAction() { return 0 ; } } - cdebug << pthread_self() << "/" << ThreadNo() << "<-- ExecuteAction " - << Automaton()->ActionName( nextaction ) << endl ; +// cdebug << pthread_self() << "/" << ThreadNo() << "<-- ExecuteAction " +// << Automaton()->ActionName( nextaction ) << endl ; return sts ; } @@ -673,9 +754,9 @@ int GraphExecutor::InNode::VoidAction() { 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; @@ -690,8 +771,10 @@ int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() { 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() ; @@ -707,7 +790,7 @@ int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() { 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 ) ; @@ -840,25 +923,24 @@ int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() { 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 , @@ -901,8 +983,8 @@ int GraphExecutor::InNode::DataUndef_AllDataReadyAction() { return 0; } } - cdebug << pthread_self() << "/" << ThreadNo() - << " <-- DataUndef_AllDataReadyAction " << Name() << endl; +// cdebug << pthread_self() << "/" << ThreadNo() +// << " <-- DataUndef_AllDataReadyAction " << Name() << endl; return 1; } @@ -958,8 +1040,8 @@ int GraphExecutor::InNode::DataReady_StopAction() { 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 ) ; @@ -976,10 +1058,8 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { 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 ; @@ -994,22 +1074,15 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { 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() ; } @@ -1017,7 +1090,6 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { ServicesAnyData * OutParametersList = new ServicesAnyData[nOutParams]; InOutParametersSet( nOutParams , OutParametersList ) ; -// if ( strlen( ComponentName() ) ) { if ( Err || ControlState() == SUPERV::ToKillState || ControlState() == SUPERV::ToKillDoneState || ControlState() == SUPERV::ToStopState ) { @@ -1035,47 +1107,58 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { 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 ; @@ -1126,12 +1209,17 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { } //#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() @@ -1139,46 +1227,63 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { << 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 ; @@ -1188,44 +1293,44 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { 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 ; @@ -1236,6 +1341,7 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { else { try { try { + cdebug << "DynInvoke -> Names " << _OutNode->Name() << " " << Name() << endl ; DynInvoke( myObjComponent, "Names" , _OutNode->Name() , Name() ) ; } @@ -1260,6 +1366,8 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { &InParametersList[0] , ServiceInParameter().length() , &OutParametersList[0] , ServiceOutParameter().length() ) ; } +// cdebug << ThreadNo() << " Component::CpuUsed " << Name() << " " +// << myObjComponent->CpuUsed_impl() << endl ; } catch( ... ) { Err = true ; @@ -1296,15 +1404,18 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { } 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 ; } @@ -1368,10 +1479,9 @@ int GraphExecutor::InNode::Executing_StopAction() { } 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 : { @@ -1405,7 +1515,7 @@ int GraphExecutor::InNode::Executing_SuccessAction() { return 0; } } - cdebug << ThreadNo() << " <-- Executing_SuccessAction " << Name() << endl; +// cdebug << ThreadNo() << " <-- Executing_SuccessAction " << Name() << endl; return 1 ; } @@ -1413,7 +1523,6 @@ int GraphExecutor::InNode::Executing_ErrorAction() { cdebug << ThreadNo() << " --> Executing_ErrorAction " << Name() << endl; _OutNode->PushEvent( this , GraphExecutor::ErroredExecutingEvent , SUPERV::ErroredState ) ; -// DoneAction() ; SUPERV::ControlState aControl = ControlState() ; switch ( aControl ) { @@ -1471,8 +1580,8 @@ void GraphExecutor::InNode::SetWaitingStates(GraphExecutor::InNode * EndNode ) { } 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 ) ; @@ -1481,7 +1590,6 @@ void GraphExecutor::InNode::SetWaitingStates(GraphExecutor::InNode * EndNode ) { 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() ; @@ -1494,7 +1602,7 @@ void GraphExecutor::InNode::SetWaitingStates(GraphExecutor::InNode * EndNode ) { } 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 ; @@ -1518,15 +1626,15 @@ int GraphExecutor::InNode::Successed_SuccessAction() { 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++ ) { @@ -1541,17 +1649,17 @@ int GraphExecutor::InNode::Successed_SuccessAction() { } 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 ) { @@ -1559,36 +1667,35 @@ int GraphExecutor::InNode::Successed_SuccessAction() { } 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() ) { @@ -1600,8 +1707,8 @@ int GraphExecutor::InNode::Successed_SuccessAction() { 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 ) { @@ -1609,9 +1716,9 @@ int GraphExecutor::InNode::Successed_SuccessAction() { } 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 ; } } } @@ -1625,21 +1732,20 @@ int GraphExecutor::InNode::Successed_SuccessAction() { } 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() ; @@ -1660,7 +1766,6 @@ int GraphExecutor::InNode::Successed_SuccessAction() { } else { // toNode is the EndLoopNode GraphBase::InPort * toLoopInPort ; -// toLoopInPort = toNode->GetChangeNodeInPort(1) ; toLoopInPort = toNode->GetChangeNodeInLoop() ; if ( toLoopInPort->State() != SUPERV::ReadyState ) { toLoopInPort->State( SUPERV::ReadyState ) ; @@ -1678,7 +1783,6 @@ int GraphExecutor::InNode::Successed_SuccessAction() { } 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() ; @@ -1698,8 +1802,8 @@ int GraphExecutor::InNode::Successed_SuccessAction() { 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 ) { @@ -1707,8 +1811,8 @@ int GraphExecutor::InNode::Successed_SuccessAction() { } 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 ; } } } @@ -1717,62 +1821,60 @@ int GraphExecutor::InNode::Successed_SuccessAction() { 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() ; @@ -1783,33 +1885,35 @@ int GraphExecutor::InNode::Successed_SuccessAction() { } } 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() << " " @@ -1820,10 +1924,10 @@ bool GraphExecutor::InNode::SendSomeDataReady( char * FromNodeName ) { 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() ; @@ -2000,10 +2104,9 @@ int GraphExecutor::InNode::SuspendedErrored_ReStartAndSuspendAction() { 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]; @@ -2288,9 +2391,8 @@ void GraphExecutor::InNode::InParametersSet( } } -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] ; @@ -2387,11 +2489,10 @@ void GraphExecutor::InNode::InOutParametersSet( } } -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 ; diff --git a/src/GraphExecutor/DataFlowExecutor_OutNode.cxx b/src/GraphExecutor/DataFlowExecutor_OutNode.cxx index 1d8705d..d9e0fb8 100644 --- a/src/GraphExecutor/DataFlowExecutor_OutNode.cxx +++ b/src/GraphExecutor/DataFlowExecutor_OutNode.cxx @@ -440,6 +440,17 @@ bool GraphExecutor::OutNode::Run( const bool AndSuspend ) { 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 " @@ -454,6 +465,7 @@ bool GraphExecutor::OutNode::Run( const bool AndSuspend ) { 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 , @@ -466,6 +478,7 @@ bool GraphExecutor::OutNode::Run( const bool AndSuspend ) { 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() ; @@ -473,6 +486,7 @@ bool GraphExecutor::OutNode::Run( const bool AndSuspend ) { 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 { @@ -523,7 +537,7 @@ void GraphExecutor::OutNode::CheckAllDone() { 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 << ". " @@ -534,7 +548,9 @@ void GraphExecutor::OutNode::CheckAllDone() { InNodeState != SUPERV::DataWaitingState ) { AllDone = false ; } - if ( InNodeState != SUPERV::SuccessedState ) { + if ( InNodeState != SUPERV::SuccessedState && + InNodeState != SUPERV::DataWaitingState && + InNodeState != SUPERV::DataReadyState ) { OutNodeState = InNodeState ; } } @@ -549,40 +565,62 @@ void GraphExecutor::OutNode::CheckAllDone() { } } 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 ) { @@ -617,6 +655,7 @@ void GraphExecutor::OutNode::PyThreadLock() { perror( "GraphExecutor::OutNode::PyThreadLock" ) ; exit( 0 ) ; } + theAutomaton->PyLock() ; // cout << " GraphExecutor::OutNode::PyThreadLocked " << pthread_self() << endl ; } @@ -626,6 +665,7 @@ void GraphExecutor::OutNode::PyThreadUnLock() { perror( "GraphExecutor::OutNode::PyThreadUnLock" ) ; exit( 0 ) ; } + theAutomaton->PyUnLock() ; // cout << " GraphExecutor::OutNode::PyThreadUnLocked " << pthread_self() << endl ; } @@ -643,6 +683,7 @@ void GraphExecutor::OutNode::NewThread() { exit( 0 ) ; } } + void GraphExecutor::OutNode::ExitThread() { if ( pthread_mutex_lock( &_MutexWait ) ) { perror("pthread_mutex_lock _ExitThread") ; @@ -662,6 +703,9 @@ void GraphExecutor::OutNode::ExitThread() { } if ( _Threads == 0 && _SuspendedThreads == 0 ) { CheckAllDone() ; + if ( IsDone() ) { + theAutomaton->Executed() ; + } } } void GraphExecutor::OutNode::JoinedWait() { @@ -679,6 +723,7 @@ void GraphExecutor::OutNode::JoinedWait() { exit( 0 ) ; } } + void GraphExecutor::OutNode::SuspendThread() { if ( pthread_mutex_lock( &_MutexWait ) ) { perror("pthread_mutex_lock _SuspendThread") ; @@ -1008,6 +1053,10 @@ SUPERV::GraphState GraphExecutor::OutNode::AutomatonGraphState(SUPERV::Automaton return aGraphState ; } +int GraphExecutor::OutNode::GetListSize() { + return _EventNodes.size(); +} + bool GraphExecutor::OutNode::PushEvent( GraphExecutor::InNode * aNode , GraphExecutor::NodeEvent anEvent , SUPERV::AutomatonState aState ) { @@ -1040,6 +1089,7 @@ bool GraphExecutor::OutNode::PushEvent( GraphExecutor::InNode * aNode , } // cdebug_out << "PushEvent Threads " << Threads() << " SuspendedThreads " // << SuspendedThreads() << endl ; +#if 0 if ( _EventNodes.size() > 101 ) { while ( _EventNodes.size() > 31 ) { _EventNodes.pop_front() ; @@ -1047,6 +1097,7 @@ bool GraphExecutor::OutNode::PushEvent( GraphExecutor::InNode * aNode , _States.pop_front() ; } } +#endif if ( pthread_mutex_unlock( &_MutexWait ) ) { perror("PushEvent pthread_mutex_unlock ") ; exit( 0 ) ; @@ -1064,6 +1115,9 @@ bool GraphExecutor::OutNode::Event( char ** aNodeName , 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 ) ; @@ -1078,8 +1132,8 @@ bool GraphExecutor::OutNode::Event( char ** aNodeName , 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 ) { @@ -1121,6 +1175,9 @@ bool GraphExecutor::OutNode::Event( char ** aNodeName , perror("EventLoop pthread_mutex_lock ") ; exit( 0 ) ; } + if ( _EventNodes.size() > 0 ) { + cdebug_out << "GraphExecutor::OutNode::Event " << _EventNodes.size() << " in queue" << endl ; + } return RetVal ; } @@ -1270,8 +1327,37 @@ bool GraphExecutor::OutNode::EventWait( char ** aNodeName , } 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 ; } @@ -1299,13 +1385,11 @@ SUPERV::GraphState GraphExecutor::OutNode::State( const char * NodeName ) { 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 ; } @@ -1359,25 +1443,25 @@ void GraphExecutor::OutNode::ControlClear( const char * NodeName ) { 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() { @@ -1510,44 +1594,84 @@ bool GraphExecutor::OutNode::ContainerKill() { } 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 ; } @@ -1576,25 +1700,33 @@ bool GraphExecutor::OutNode::Kill() { 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("================================================================================") ; @@ -1693,7 +1825,7 @@ bool GraphExecutor::OutNode::SuspendedWait() { exit( 0 ) ; } aret = IsSuspended() ; - while ( !aret && !_Done ) { + while ( !aret && !IsDone() ) { pthread_cond_wait( &_EventWait , &_MutexWait ); aret = IsSuspended() ; } diff --git a/src/GraphExecutor/DataFlowExecutor_OutNode.hxx b/src/GraphExecutor/DataFlowExecutor_OutNode.hxx index e16f0ef..1f764f5 100644 --- a/src/GraphExecutor/DataFlowExecutor_OutNode.hxx +++ b/src/GraphExecutor/DataFlowExecutor_OutNode.hxx @@ -152,6 +152,7 @@ namespace GraphExecutor { 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 , @@ -163,6 +164,8 @@ namespace GraphExecutor { 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 ) { @@ -193,11 +196,11 @@ namespace GraphExecutor { 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() ; diff --git a/src/GraphExecutor/DataFlowExecutor_PyDynInvoke.cxx b/src/GraphExecutor/DataFlowExecutor_PyDynInvoke.cxx index 9df177b..03fe20f 100644 --- a/src/GraphExecutor/DataFlowExecutor_PyDynInvoke.cxx +++ b/src/GraphExecutor/DataFlowExecutor_PyDynInvoke.cxx @@ -29,101 +29,137 @@ static PyMethodDef MethodPyRunMethod[] = { 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 ) ) { @@ -139,7 +175,6 @@ extern "C" PyObject * PyRunMethod( PyObject * dummy , PyObject * Args ) { Py_INCREF( Py_None ) ; Result = Py_None ; } -// cout << "<-- PyRunMethod" << endl ; return Result ; } @@ -155,8 +190,15 @@ bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod , 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 ; @@ -171,336 +213,339 @@ bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod , 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 ; + } diff --git a/src/GraphExecutor/Makefile.in b/src/GraphExecutor/Makefile.in index ae14ab0..e843b1f 100644 --- a/src/GraphExecutor/Makefile.in +++ b/src/GraphExecutor/Makefile.in @@ -45,10 +45,15 @@ LIB_CLIENT_IDL = SALOME_ModuleCatalog.idl \ 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@ diff --git a/src/SUPERVGUI/Makefile.in b/src/SUPERVGUI/Makefile.in index 28464a5..1598252 100644 --- a/src/SUPERVGUI/Makefile.in +++ b/src/SUPERVGUI/Makefile.in @@ -95,10 +95,10 @@ LIB_SERVER_IDL = 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) diff --git a/src/SUPERVGUI/SUPERVGUI.cxx b/src/SUPERVGUI/SUPERVGUI.cxx index 142ee04..5f57e85 100644 --- a/src/SUPERVGUI/SUPERVGUI.cxx +++ b/src/SUPERVGUI/SUPERVGUI.cxx @@ -120,7 +120,7 @@ void SUPERVGUI::loadEngine(SALOME_NamingService* namingService) { 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; }; @@ -509,8 +509,8 @@ void SUPERVGUI::whatIsSelected(const Handle(SALOME_InteractiveObject)& theObj, b 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); @@ -671,3 +671,7 @@ extern "C" int supportedViewType() { return (int)VIEW_GRAPHSUPERV; } + +extern "C" void buildPresentation ( const Handle(SALOME_InteractiveObject)& theIO ) +{ +} diff --git a/src/SUPERVGUI/SUPERVGUI_BrowseNodeDlg.h b/src/SUPERVGUI/SUPERVGUI_BrowseNodeDlg.h index 371fda1..9575f2a 100644 --- a/src/SUPERVGUI/SUPERVGUI_BrowseNodeDlg.h +++ b/src/SUPERVGUI/SUPERVGUI_BrowseNodeDlg.h @@ -11,7 +11,6 @@ #ifndef SUPERVGUI_BrowseNodeDlg_H #define SUPERVGUI_BrowseNodeDlg_H -using namespace std; #include #include "SUPERVGUI_Def.h" #include "SUPERVGUI_Port.h" diff --git a/src/SUPERVGUI/SUPERVGUI_ControlNode.cxx b/src/SUPERVGUI/SUPERVGUI_ControlNode.cxx index fd5ab5e..a97a43e 100644 --- a/src/SUPERVGUI/SUPERVGUI_ControlNode.cxx +++ b/src/SUPERVGUI/SUPERVGUI_ControlNode.cxx @@ -88,7 +88,6 @@ void SUPERVGUI_StartControlNode::rename() { void SUPERVGUI_StartControlNode::remove() { myEndNode->deleteLinks(); deleteLinks(); - myEndNode->getEngine()->destroy(); myNode->destroy(); myMain->getGraph()->deleteNode(myEndNode); myMain->getGraph()->deleteNode(this); @@ -148,6 +147,7 @@ void SUPERVGUI_StartControlNode::addInputPort() { void SUPERVGUI_StartControlNode::deletePort(SUPERVGUI_Port* thePort) { if (getNodeType() == SUPERV::LoopNode) { + SUPERV_Port aPortEngine = thePort->getPort(); QString aName(aPortEngine->Name()); QString aNameIn = aName + "Input"; @@ -171,10 +171,12 @@ void SUPERVGUI_StartControlNode::deletePort(SUPERVGUI_Port* thePort) { myPIcount--; myPOcount--; + myEndNode->getPIcount()--; myEndNode->getPOcount()--; - + aPortEngine->destroy(); + updatePorts(); updateShape(); myEndNode->updatePorts(); @@ -215,45 +217,8 @@ SUPERVGUI_EndControlNode::SUPERVGUI_EndControlNode(QWidget* theParent, SUPERVGUI myPortsBox->reparent(this, pos()); - myPIcount = 0; - myPOcount = 0; - SUPERV_Ports ports = myNode->Ports(); - int n = ports->length(); - - for (int i=0; iIsInput()) { - 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); diff --git a/src/SUPERVGUI/SUPERVGUI_Def.h b/src/SUPERVGUI/SUPERVGUI_Def.h index 1239c14..2145c27 100644 --- a/src/SUPERVGUI/SUPERVGUI_Def.h +++ b/src/SUPERVGUI/SUPERVGUI_Def.h @@ -25,7 +25,7 @@ #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) diff --git a/src/SUPERVGUI/SUPERVGUI_Graph.cxx b/src/SUPERVGUI/SUPERVGUI_Graph.cxx index bd45007..b1f2084 100644 --- a/src/SUPERVGUI/SUPERVGUI_Graph.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Graph.cxx @@ -31,6 +31,7 @@ using namespace std; #include "SUPERVGUI_Main.h" #include "SUPERVGUI_ComputeNode.h" #include "SUPERVGUI_ControlNode.h" +#include "SUPERVGUI.h" //#define CHECKTIME @@ -319,7 +320,23 @@ void SUPERVGUI_Graph::deleteLink() { 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(); } diff --git a/src/SUPERVGUI/SUPERVGUI_GraphNode.cxx b/src/SUPERVGUI/SUPERVGUI_GraphNode.cxx index 3a1676f..af07998 100644 --- a/src/SUPERVGUI/SUPERVGUI_GraphNode.cxx +++ b/src/SUPERVGUI/SUPERVGUI_GraphNode.cxx @@ -54,16 +54,27 @@ SUPERVGUI_GraphNode::SUPERVGUI_GraphNode(QWidget* theParent, SUPERVGUI_Main* the myPOcount = 0; SUPERV_Ports ports = myNode->Ports(); int n = ports->length(); - + for (int i=0; iIsInput()) { - 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()) @@ -76,6 +87,7 @@ SUPERVGUI_GraphNode::SUPERVGUI_GraphNode(QWidget* theParent, SUPERVGUI_Main* the } } } + } @@ -290,40 +302,45 @@ void SUPERVGUI_GraphNode::sync() { * 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; jlength(); 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; jlength(); 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; } @@ -344,7 +361,9 @@ void SUPERVGUI_GraphNode::deletePort(SUPERVGUI_Port* thePort) { thePort->deleteLinks(); thePort->getPort()->destroy(); + thePort->close(true); + updatePorts(); updateShape(); } @@ -435,6 +454,7 @@ void SUPERVGUI_GraphNode::updatePorts() { QObjectListIt aLI(*aShownPortsList); SUPERVGUI_Port* aVisPort; + while ((aVisPort=(SUPERVGUI_Port*)aLI.current()) != 0) { ++aLI; QString aNameVisible(aVisPort->getPort()->Name()); diff --git a/src/SUPERVGUI/SUPERVGUI_GraphNode.h b/src/SUPERVGUI/SUPERVGUI_GraphNode.h index fde17f9..1378581 100644 --- a/src/SUPERVGUI/SUPERVGUI_GraphNode.h +++ b/src/SUPERVGUI/SUPERVGUI_GraphNode.h @@ -14,6 +14,7 @@ #include "SUPERVGUI_Node.h" #include + class SUPERVGUI_GraphNode: public SUPERVGUI_Node { Q_OBJECT diff --git a/src/SUPERVGUI/SUPERVGUI_Link.cxx b/src/SUPERVGUI/SUPERVGUI_Link.cxx index 1dacbea..d7e5a82 100644 --- a/src/SUPERVGUI/SUPERVGUI_Link.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Link.cxx @@ -747,7 +747,7 @@ int distance(int x1, int y1, int x2, int y2) { x = x * x; int y = y2 - y1; y = y * y; - return (int) sqrt(double(x + y)); + return (int) sqrt((double)(x + y)); } @@ -772,19 +772,19 @@ int distance(QPoint thePnt, QPoint thePntLn1, QPoint thePntLn2) { 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); } diff --git a/src/SUPERVGUI/SUPERVGUI_Link.h b/src/SUPERVGUI/SUPERVGUI_Link.h index 34cfd6f..cfa22dc 100644 --- a/src/SUPERVGUI/SUPERVGUI_Link.h +++ b/src/SUPERVGUI/SUPERVGUI_Link.h @@ -12,6 +12,7 @@ #define SUPERVGUI_Link_H using namespace std; + #include "SUPERVGUI_Def.h" #include "SUPERVGUI_Port.h" #include diff --git a/src/SUPERVGUI/SUPERVGUI_Main.cxx b/src/SUPERVGUI/SUPERVGUI_Main.cxx index 8f83224..2848887 100644 --- a/src/SUPERVGUI/SUPERVGUI_Main.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Main.cxx @@ -155,61 +155,65 @@ void SUPERVGUI_Main::init(QAD_Desktop* theDesktop) { 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() { @@ -231,24 +235,6 @@ 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); @@ -288,46 +274,25 @@ void SUPERVGUI_Main::syncAsync() { /** - * 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); } } @@ -457,16 +422,16 @@ void SUPERVGUI_Main::run() { 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(); } @@ -497,16 +462,16 @@ void SUPERVGUI_Main::startExecute() { 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(); } } } @@ -524,6 +489,7 @@ void SUPERVGUI_Main::kill() { 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")); @@ -538,14 +504,14 @@ void SUPERVGUI_Main::suspendResume() { 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")); } @@ -743,8 +709,8 @@ void SUPERVGUI_Main::showPopup(QPopupMenu* p, QMouseEvent* e) { // 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) { @@ -791,9 +757,8 @@ bool SUPERVGUI_Main::addStudy() { 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" ); @@ -857,7 +822,7 @@ void SUPERVGUI_Main::setData(SUPERVGUI_PortIn* p) { 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; @@ -876,11 +841,12 @@ SALOMEDS::SObject_var SearchOrCreateSOWithName(const SALOMEDS::Study_var theStud } 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); @@ -902,30 +868,34 @@ bool SUPERVGUI_Main::putDataStudy(SUPERV_Port p, const char* inout) { 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); @@ -934,14 +904,16 @@ bool SUPERVGUI_Main::putDataStudy(SUPERV_Port p, const char* inout) { 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; } @@ -972,12 +944,14 @@ bool SUPERVGUI_Main::putDataStudy(SUPERV_Port p, const char* inout) { 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; } @@ -989,13 +963,17 @@ bool SUPERVGUI_Main::putDataStudy(SUPERV_Port p, const char* inout) { } 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; } @@ -1112,3 +1090,202 @@ void SUPERVGUI_Main::setPaletteBackgroundColor(const QColor& color) { 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(); +} + diff --git a/src/SUPERVGUI/SUPERVGUI_Main.h b/src/SUPERVGUI/SUPERVGUI_Main.h index 300b1c2..0869204 100644 --- a/src/SUPERVGUI/SUPERVGUI_Main.h +++ b/src/SUPERVGUI/SUPERVGUI_Main.h @@ -35,11 +35,15 @@ #include "QAD_Desktop.h" #include "SUPERVGUI_Port.h" +#include +#include +#include + class QAD_Study; class QAD_ObjectBrowser; class QAD_Message; class NOTIFICATION_Consumer; - +class SUPERVGUI_Thread; class SUPERVGUI_Main: public SUPERVGraph_View { Q_OBJECT @@ -95,8 +99,27 @@ class SUPERVGUI_Main: public SUPERVGraph_View { 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(); @@ -111,11 +134,10 @@ class SUPERVGUI_Main: public SUPERVGraph_View { 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); @@ -124,8 +146,7 @@ class SUPERVGUI_Main: public SUPERVGraph_View { QAD_ObjectBrowser* objectBrowser; QAD_Message* message; SUPERVGUI_Graph* graph; - QTimer* timer; - + GraphViewType myCurrentView; SUPERVGUI_Array* array; @@ -152,6 +173,31 @@ class SUPERVGUI_Main: public SUPERVGraph_View { 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 diff --git a/src/SUPERVGUI/SUPERVGUI_Node.cxx b/src/SUPERVGUI/SUPERVGUI_Node.cxx index 99b1d9b..f8e56a6 100644 --- a/src/SUPERVGUI/SUPERVGUI_Node.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Node.cxx @@ -106,7 +106,7 @@ SUPERVGUI_Node::SUPERVGUI_Node(QWidget* theParent, SUPERVGUI_Main* theMain, SUPE 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()); } @@ -120,6 +120,9 @@ void SUPERVGUI_Node::sync() { setState(myNode->State()); } +void SUPERVGUI_Node::syncOnEvent(SUPERV::GraphState theStateFromEvent) { + setState(theStateFromEvent); +} void SUPERVGUI_Node::setState(SUPERV::GraphState theState) { @@ -134,6 +137,7 @@ 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")); @@ -166,7 +170,7 @@ void SUPERVGUI_Node::setState(SUPERV::GraphState theState) myRunPopup->changeItem(myStopItem, tr("MSG_RESTART")); myRunPopup->setItemEnabled(myStopItem, true); break; - default: + default: //cout<<"### Node state = "<setText("No Status"); myStatus->setPaletteBackgroundColor(QColor(NODE_RED, NODE_GREEN, NODE_BLUE)); @@ -216,12 +220,16 @@ void SUPERVGUI_Node::suspendResume() { 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")); } } } @@ -234,6 +242,7 @@ void SUPERVGUI_Node::kill() { } else { myStatus->setPaletteBackgroundColor(Qt::red); myTime->setPaletteBackgroundColor(Qt::red); + myMain->getMyThread()->stopThread(tr("MSG_NODE_KILLED1")+myNode->Name()+tr("MSG_NODE_KILLED2")); } } diff --git a/src/SUPERVGUI/SUPERVGUI_Node.h b/src/SUPERVGUI/SUPERVGUI_Node.h index 97923f7..ec81d87 100644 --- a/src/SUPERVGUI/SUPERVGUI_Node.h +++ b/src/SUPERVGUI/SUPERVGUI_Node.h @@ -47,6 +47,7 @@ class SUPERVGUI_Node: public QFrame { bool eventFilter( QObject* o, QEvent* e ); virtual void sync(); + void syncOnEvent(SUPERV::GraphState theStateFromEvent); virtual void hideAll()=0; virtual void showAll()=0; @@ -147,6 +148,7 @@ class SUPERVGUI_Node: public QFrame { bool step; bool trace; bool verbose; + }; diff --git a/src/SUPERVGUI/SUPERVGUI_Port.cxx b/src/SUPERVGUI/SUPERVGUI_Port.cxx index 335d050..40fbd64 100644 --- a/src/SUPERVGUI/SUPERVGUI_Port.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Port.cxx @@ -70,7 +70,15 @@ SUPERVGUI_Port::SUPERVGUI_Port(QWidget* parent, SUPERVGUI_Main* m, SUPERV_Port p 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*))); @@ -335,10 +343,16 @@ void SUPERVGUI_PortOut::updateStudy() { 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(); } @@ -395,7 +409,7 @@ void SUPERVGUI_PortOut::deleteLinks() { -//*********************************************************** +// ---------------------------- // Input Port of EndSwitch Node // ---------------------------- SUPERVGUI_PortInESNode::SUPERVGUI_PortInESNode(QWidget* parent, SUPERVGUI_Main* m, SUPERV_Port p) @@ -406,9 +420,9 @@ SUPERVGUI_PortInESNode::SUPERVGUI_PortInESNode(QWidget* parent, SUPERVGUI_Main* 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() { diff --git a/src/SUPERVGUI/SUPERV_icons.po b/src/SUPERVGUI/SUPERV_icons.po index a71f998..9f0e10f 100644 --- a/src/SUPERVGUI/SUPERV_icons.po +++ b/src/SUPERVGUI/SUPERV_icons.po @@ -34,4 +34,4 @@ msgstr "" #: QAD_ObjectBrowser.cxx:140 msgid "ICON_OBJBROWSER_Supervision" -msgstr "Superv_tree_superv.png" +msgstr "Superv_tree_superv.png" \ No newline at end of file diff --git a/src/SUPERVGUI/SUPERV_msg_en.po b/src/SUPERVGUI/SUPERV_msg_en.po index 1b0a8d8..d53ad9c 100644 --- a/src/SUPERVGUI/SUPERV_msg_en.po +++ b/src/SUPERVGUI/SUPERV_msg_en.po @@ -102,7 +102,7 @@ msgstr "Supervision: " #: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" @@ -116,6 +116,12 @@ msgstr "===> Dataflow is Modifiable" 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" @@ -128,6 +134,12 @@ msgstr "===> Dataflow Execution is Aborted" 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" @@ -156,6 +168,12 @@ msgstr "Can't Kill 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" diff --git a/src/Supervision/CNode_Impl.cxx b/src/Supervision/CNode_Impl.cxx index 860dd16..02cf4ad 100644 --- a/src/Supervision/CNode_Impl.cxx +++ b/src/Supervision/CNode_Impl.cxx @@ -175,8 +175,9 @@ bool CNode_Impl::Delete() { bool RetVal = false ; if ( _DataFlowEditor->IsEditing() ) { RetVal = _DataFlowEditor->RemoveNode( Name() ) ; - if ( RetVal ) + if ( RetVal ) { RetVal = _DataFlowEditor->IsValid() ; + } } endService( "CNode_Impl::Delete" ); return RetVal ; @@ -202,7 +203,7 @@ char * CNode_Impl::Name() { RetVal = _DataFlowNode->Name() ; } else { - RetVal = _DataFlowEditor->Name() ; + RetVal = _DataFlowEditor->Name() ; } // endService( "CNode_Impl::Name" ); return CORBA::string_dup( RetVal ); @@ -216,7 +217,7 @@ bool CNode_Impl::SetName( const char * aDataFlowName ) { aDataFlowName ) ; } else { - RetVal = _DataFlowEditor->Name( aDataFlowName ) ; + RetVal = _DataFlowEditor->Name( aDataFlowName ) ; } } // endService( "CNode_Impl::SetName" ); @@ -611,9 +612,9 @@ SUPERV::Port_ptr CNode_Impl::Input( const char * ToServiceParameterName , 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 , @@ -652,8 +653,6 @@ SUPERV::Port_ptr CNode_Impl::Input( const char * ToServiceParameterName , } } else if ( _DataFlowExecutor ) { - bool sts = false ; - GraphBase::InPort * anInPort ; if ( _IsNode ) { sts = _DataFlowExecutor->ChangeInputData( _DataFlowNode->Name() , ToServiceParameterName , @@ -694,6 +693,10 @@ SUPERV::Port_ptr CNode_Impl::Input( const char * 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 ) ; } @@ -712,13 +715,13 @@ SUPERV::ListOfPorts * CNode_Impl::Ports() { } 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() ; @@ -748,7 +751,7 @@ SUPERV::ListOfPorts * CNode_Impl::Ports() { 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() ) ; } } @@ -760,11 +763,11 @@ SUPERV::ListOfPorts * CNode_Impl::Ports() { } 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() , @@ -782,7 +785,7 @@ SUPERV::ListOfPorts * CNode_Impl::Ports() { 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() ) ; } } diff --git a/src/Supervision/ELNode_Impl.cxx b/src/Supervision/ELNode_Impl.cxx index d58c3ab..d0d4c86 100644 --- a/src/Supervision/ELNode_Impl.cxx +++ b/src/Supervision/ELNode_Impl.cxx @@ -72,26 +72,42 @@ ELNode_Impl::~ELNode_Impl() { } 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 = "< Before IsValid"); RetVal = DataFlowEditor()->IsValid() ; + MESSAGE("--------> After IsValid"); + } } // endService( "ELNode_Impl::Delete" ); + MESSAGE("--------> ELNode_Impl::Delete() END"); return RetVal ; } diff --git a/src/Supervision/ESNode_Impl.cxx b/src/Supervision/ESNode_Impl.cxx index 8e096aa..ee2230f 100644 --- a/src/Supervision/ESNode_Impl.cxx +++ b/src/Supervision/ESNode_Impl.cxx @@ -79,12 +79,17 @@ ESNode_Impl::~ESNode_Impl() { 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" ); } diff --git a/src/Supervision/GNode_Impl.cxx b/src/Supervision/GNode_Impl.cxx index bee2651..2612505 100644 --- a/src/Supervision/GNode_Impl.cxx +++ b/src/Supervision/GNode_Impl.cxx @@ -124,14 +124,14 @@ void GNode_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 ; } diff --git a/src/Supervision/GNode_Impl.hxx b/src/Supervision/GNode_Impl.hxx index ca6cff4..72eed81 100644 --- a/src/Supervision/GNode_Impl.hxx +++ b/src/Supervision/GNode_Impl.hxx @@ -68,21 +68,22 @@ class GNode_Impl : public INode_Impl , 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" ) ; } diff --git a/src/Supervision/Graph_Impl.cxx b/src/Supervision/Graph_Impl.cxx index 531b19f..5a33219 100644 --- a/src/Supervision/Graph_Impl.cxx +++ b/src/Supervision/Graph_Impl.cxx @@ -38,6 +38,8 @@ using namespace std; #include "DataFlowEditor_DataFlow.hxx" +extern GraphExecutor::FiniteStateMachine * theAutomaton ; + Graph_Impl::Graph_Impl( CORBA::ORB_ptr orb , PortableServer::POA_ptr poa , PortableServer::ObjectId * contId , @@ -54,7 +56,6 @@ Graph_Impl::Graph_Impl( CORBA::ORB_ptr orb , _Orb = CORBA::ORB::_duplicate(orb); _Poa = poa ; _ContId = contId ; - _ExecNumber = 0 ; string dbgfile = "/tmp/" ; dbgfile += instanceName ; @@ -90,6 +91,7 @@ Graph_Impl::Graph_Impl( CORBA::ORB_ptr orb , _DebugFileName ) ; DataFlowEditor( aDataFlowEditor ) ; DataFlowEditor()->SetObjImpl( this ) ; + pthread_mutex_init( &_MutexExecutorWait , NULL ) ; _DataFlowExecutor = NULL ; delete [] theDataFlowName ; endService( "Graph_Impl::Graph_Impl" ); @@ -143,13 +145,13 @@ void Graph_Impl::ReadOnly() { 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) ; } @@ -246,8 +248,7 @@ GraphBase::ListOfLinks * Graph_Impl::GetDatas() { } #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() ) { @@ -267,10 +268,9 @@ SUPERV::CNode_ptr Graph_Impl::CNode( 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() ) { @@ -342,14 +342,13 @@ SUPERV::GNode_ptr Graph_Impl::GNode( const char * FuncName , 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() ; @@ -409,10 +408,9 @@ SUPERV::LNode_ptr Graph_Impl::LNode( 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() ; @@ -464,8 +462,8 @@ SUPERV::SNode_ptr Graph_Impl::SNode( } -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() ) ) { @@ -484,20 +482,11 @@ SUPERV::CNode_ptr Graph_Impl::GetNode(char const * aNodeName ) { 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 ) ; } @@ -530,6 +519,90 @@ SUPERV::Link_ptr Graph_Impl::Link( SUPERV::Port_ptr OutPort , 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 ; @@ -574,126 +647,32 @@ SUPERV::ListOfNodes_var Graph_Impl::SetNode( SUPERV::ListOfNodes_var RetVal , 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() ) ; } @@ -769,18 +748,18 @@ SUPERV::ListOfLinks * Graph_Impl::Links( GraphBase::ComputingNode * theNode , 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 ) { @@ -832,9 +811,9 @@ SUPERV::ListOfLinks * Graph_Impl::Links( GraphBase::ComputingNode * theNode , 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 ) { @@ -987,6 +966,10 @@ long Graph_Impl::SuspendedThreads() { 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() ) { @@ -997,7 +980,7 @@ bool Graph_Impl::Begin() { DataFlowEditor()->Executor( NULL ) ; } DataFlowEditor()->EditedAfterExecution( false ) ; - _ExecNumber += 1 ; + int _ExecNumber = theAutomaton->ExecNumber() ; char ExecNumber[30] ; sprintf( ExecNumber , "_%d" , _ExecNumber ) ; int len = strlen( _DebugFileName ) ; @@ -1015,6 +998,10 @@ bool Graph_Impl::Begin() { if ( RetVal ) { DataFlowEditor()->Executor( _DataFlowExecutor ) ; } + if ( pthread_mutex_unlock( &_MutexExecutorWait ) ) { + perror("pthread_mutex_unlock _MutexExecutorWait") ; + exit( 0 ) ; + } } return RetVal ; } @@ -1024,8 +1011,10 @@ bool Graph_Impl::Run() { 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 " ); @@ -1059,20 +1048,33 @@ bool Graph_Impl::EventNoW( SUPERV::CNode_out aNode , 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 ; @@ -1087,20 +1089,33 @@ bool Graph_Impl::Event( SUPERV::CNode_out aNode , 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 ; @@ -1115,59 +1130,82 @@ bool Graph_Impl::EventW( SUPERV::CNode_out aNode , 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 ; @@ -1178,38 +1216,185 @@ bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph ) { 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() ; @@ -1220,45 +1405,54 @@ bool Graph_Impl::Merge(const SUPERV::Graph_ptr aGraph ) { 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 ; } diff --git a/src/Supervision/Graph_Impl.hxx b/src/Supervision/Graph_Impl.hxx index 2560596..d7b8d9a 100644 --- a/src/Supervision/Graph_Impl.hxx +++ b/src/Supervision/Graph_Impl.hxx @@ -59,9 +59,9 @@ class Graph_Impl :public INode_Impl , 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: @@ -81,7 +81,7 @@ class Graph_Impl :public INode_Impl , virtual void ReadOnly() ; - virtual SUPERV::INode_ptr GetNode() ; + virtual SUPERV::INode_ptr Node() ; // virtual char * DataFlowInfo() ; // virtual char * DataNodeInfo() ; @@ -126,7 +126,7 @@ class Graph_Impl :public INode_Impl , 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 ) ; @@ -134,6 +134,7 @@ class Graph_Impl :public INode_Impl , 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 ) ; @@ -172,6 +173,7 @@ class Graph_Impl :public INode_Impl , virtual bool EventW( SUPERV::CNode_out aNode , SUPERV::GraphEvent & anEvent , SUPERV::GraphState & aState ) ; + virtual long EventQSize() ; virtual bool Merge(const SUPERV::Graph_ptr aGraph ) ; diff --git a/src/Supervision/LNode_Impl.cxx b/src/Supervision/LNode_Impl.cxx index 2bef195..436a59e 100644 --- a/src/Supervision/LNode_Impl.cxx +++ b/src/Supervision/LNode_Impl.cxx @@ -79,25 +79,31 @@ LNode_Impl::~LNode_Impl() { 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 ; } diff --git a/src/Supervision/Makefile.in b/src/Supervision/Makefile.in index ed6e26d..1f2b942 100755 --- a/src/Supervision/Makefile.in +++ b/src/Supervision/Makefile.in @@ -35,7 +35,6 @@ VPATH=.:@srcdir@:@top_srcdir@/idl:$(top_builddir)/idl @COMMENCE@ EXPORT_PYSCRIPTS = SuperV.py batchmode_SuperV.py - EXPORT_SHAREDPYSCRIPTS = SUPERV_shared_modules.py EXPORT_HEADERS = \ @@ -82,18 +81,16 @@ LIB_CLIENT_IDL = SALOME_ModuleCatalog.idl \ 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@ diff --git a/src/Supervision/Port_Impl.cxx b/src/Supervision/Port_Impl.cxx index 3883bd4..3e0ee67 100644 --- a/src/Supervision/Port_Impl.cxx +++ b/src/Supervision/Port_Impl.cxx @@ -175,6 +175,10 @@ bool Port_Impl::Input( const CORBA::Any * anAny ) { *anAny ) ; } } + if ( !RetVal ) { + MESSAGE( "Port_Impl::Input returns false _InputPort " << _InputPort << " IsEditing " + << _DataFlowEditor->IsEditing() << " Executor " << _DataFlowEditor->Executor() ) ; + } endService( "Port_Impl::Input" ); return RetVal ; } @@ -238,9 +242,8 @@ SUPERV::Link_ptr Port_Impl::Link() { 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 ] ; } @@ -292,6 +295,8 @@ SUPERV::Link_ptr Port_Impl::Link() { } } 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 ) ; @@ -378,7 +383,12 @@ bool Port_Impl::IsEndSwitch() { 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 ; } diff --git a/src/Supervision/SNode_Impl.cxx b/src/Supervision/SNode_Impl.cxx index e716e60..79d244c 100644 --- a/src/Supervision/SNode_Impl.cxx +++ b/src/Supervision/SNode_Impl.cxx @@ -76,12 +76,17 @@ SNode_Impl::~SNode_Impl() { 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" ); } diff --git a/src/Supervision/SuperV.py b/src/Supervision/SuperV.py index 9e3062d..7d23166 100644 --- a/src/Supervision/SuperV.py +++ b/src/Supervision/SuperV.py @@ -244,6 +244,7 @@ class CNode: 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 ) @@ -440,12 +441,18 @@ class INode(CNode): 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 ) @@ -454,6 +461,7 @@ class INode(CNode): while len( line ) : res = res + line line = os.read( fd , 132 ) + os.close( fd ) PyFunc = res.splitlines() i = 0 while i < len( PyFunc ) : diff --git a/src/Supervision/SuperV_Impl.cxx b/src/Supervision/SuperV_Impl.cxx index 9f42895..2c42ac0 100644 --- a/src/Supervision/SuperV_Impl.cxx +++ b/src/Supervision/SuperV_Impl.cxx @@ -99,7 +99,8 @@ SALOMEDS::TMPFile* SuperV_Impl::Save(SALOMEDS::SComponent_ptr theComponent, // 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; @@ -109,7 +110,7 @@ SALOMEDS::TMPFile* SuperV_Impl::Save(SALOMEDS::SComponent_ptr theComponent, 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"); @@ -215,8 +216,9 @@ char* SuperV_Impl::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject, } // 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"); @@ -234,13 +236,117 @@ char* SuperV_Impl::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject, 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; @@ -284,7 +390,6 @@ SALOMEDS::SObject_ptr SuperV_Impl::PublishInStudy(SALOMEDS::Study_ptr theStudy, if ( !Comp->_is_nil() ) { aName->SetValue( Comp->componentusername() ); } - anAttr = aBuilder->FindOrCreateAttribute(aFather, "AttributePixMap"); aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); aPixmap->SetPixMap( "ICON_OBJBROWSER_Supervision" ); diff --git a/src/Supervision/Value_Impl.cxx b/src/Supervision/Value_Impl.cxx index 1a226c1..9544348 100644 --- a/src/Supervision/Value_Impl.cxx +++ b/src/Supervision/Value_Impl.cxx @@ -242,7 +242,7 @@ char * Value_Impl::ToString() { switch (anAny.type()->kind()) { case CORBA::tk_string: { anAny >>= retstr; -// MESSAGE( "ToString( string ) " << retstr ); + MESSAGE( "ToString( string ) '" << retstr << "'" ); break ; } case CORBA::tk_long: { @@ -250,9 +250,7 @@ char * Value_Impl::ToString() { 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: { @@ -260,11 +258,9 @@ char * Value_Impl::ToString() { 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 ; @@ -274,7 +270,7 @@ char * Value_Impl::ToString() { try { anAny >>= obj ; retstr = _Orb->object_to_string( obj ); -// MESSAGE( "ToString( object ) " << retstr ); + MESSAGE( "ToString( object ) '" << retstr << "'" ); } catch ( ... ) { retstr = "object_to_string catched " ; @@ -283,7 +279,7 @@ char * Value_Impl::ToString() { } default: { retstr = "Unknown CORBA::Any Type" ; - MESSAGE( retstr ); +// MESSAGE( retstr ); break ; } } diff --git a/src/Supervision/batchmode_SuperV.py b/src/Supervision/batchmode_SuperV.py index 5d79f84..81c7577 100644 --- a/src/Supervision/batchmode_SuperV.py +++ b/src/Supervision/batchmode_SuperV.py @@ -15,8 +15,6 @@ try : 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 * @@ -57,12 +55,10 @@ if father is None: 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) @@ -325,7 +321,10 @@ class CNode: 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() @@ -333,7 +332,10 @@ class CNode: 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 : @@ -439,6 +441,8 @@ class CNode: return self.N.Y() def destroy( self ): self.N.destroy() + def CpuUsed( self ): + return self.N.CpuUsed() ########################################################## class FNode(CNode): @@ -447,11 +451,11 @@ 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 ): @@ -467,25 +471,37 @@ class INode(CNode): 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 ) @@ -846,6 +862,10 @@ class Graph(INode): 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 -- 2.39.2