From 7d3931c54614b3d73351551e662ccbd3be07a0d8 Mon Sep 17 00:00:00 2001 From: asv Date: Fri, 21 Jan 2005 05:44:50 +0000 Subject: [PATCH] Merging with JR_ASV_2_1_0_deb_with_KERNEL_Head branch, which contains many bug fixes and improvements implemented by JR,ASV,MKR since December 2004. --- examples/GraphBadInputInLoop.py | 162 +++ examples/GraphBadInputInLoop.xml | 400 ++++++ examples/GraphBadInputInLoop1.py | 162 +++ examples/GraphBadInputInLoop1.xml | 400 ++++++ examples/GraphBadInputInLoop2.py | 163 +++ examples/GraphBadInputInLoop2.xml | 403 ++++++ examples/GraphBadInputInLoop3.py | 167 +++ examples/GraphBadInputInLoop3.xml | 409 ++++++ examples/GraphBadOutputOfLoop.py | 164 +++ examples/GraphBadOutputOfLoop.xml | 415 ++++++ examples/GraphBadOutputOfLoop1.py | 163 +++ examples/GraphBadOutputOfLoop1.xml | 412 ++++++ examples/GraphBadOutputOfLoop2.py | 164 +++ examples/GraphBadOutputOfLoop2.xml | 415 ++++++ examples/GraphConvertObjRefCheck.py | 174 +-- examples/GraphConvertObjRefCheck.xml | 425 +++--- examples/GraphCpuUsed.py | 10 +- examples/GraphEmbeddedComponents.py | 151 +++ examples/GraphEmbeddedComponents.xml | 365 ++++++ examples/GraphGOTO.py | 570 +++++---- examples/GraphGOTO.xml | 1138 +++++++++-------- examples/GraphImportSalome.py | 37 + examples/GraphImportSalome.xml | 60 + examples/GraphInputInLoop.py | 152 +++ examples/GraphInputInLoop.xml | 378 ++++++ examples/GraphKillSuspend.py | 40 + examples/GraphLoop.py | 161 +-- examples/GraphLoop.xml | 349 ++--- examples/GraphLoopDoWhile.py | 76 ++ examples/GraphLoopDoWhile.xml | 169 +++ examples/GraphLoopGates.py | 179 +++ examples/GraphLoopGates.xml | 514 ++++++++ examples/GraphLoopSwitch.py | 280 ++-- examples/GraphLoopSwitch.xml | 540 ++++---- examples/GraphLoopWhile.py | 74 ++ examples/GraphLoopWhile.xml | 168 +++ examples/GraphLoopsCoupled.py | 215 ++++ examples/GraphLoopsCoupled.xml | 553 ++++++++ examples/GraphLoopsGates.py | 255 ++++ examples/GraphLoopsGates.xml | 692 ++++++++++ examples/GraphMacroNodes.py | 16 +- examples/GraphMacroNodes.xml | 16 +- examples/GraphNonVoidEndLoop.py | 101 ++ examples/GraphNonVoidEndLoop.xml | 243 ++++ examples/GraphObjRef.xml | 2 +- examples/GraphPyFunctions.xml | 4 +- examples/GraphSIGFPE.py | 37 + examples/GraphSIGFPE.xml | 83 ++ examples/GraphSIGFPEPython.py | 35 + examples/GraphSIGFPEPython.xml | 54 + examples/GraphSIGSEGV.py | 31 + examples/GraphSIGSEGV.xml | 53 + examples/GraphSIGSEGVPython.py | 35 + examples/GraphSIGSEGVPython.xml | 54 + examples/GraphStreamInLines.py | 2 +- examples/GraphStreamInLines.xml | 2 +- examples/GraphStreams.py | 2 +- examples/GraphStreams.xml | 2 +- examples/GraphSwitch.xml | 2 +- examples/GraphSwitch1.xml | 2 +- examples/GraphSwitch2.py | 162 +++ examples/GraphSwitch2.xml | 383 ++++++ examples/GraphSwitchCheck.py | 268 ++++ examples/GraphSwitchCheck.xml | 628 +++++++++ examples/GraphSwitchCheckDefault.py | 299 +++++ examples/GraphSwitchCheckDefault.xml | 708 ++++++++++ examples/GraphSwitchCheckDefault1.py | 298 +++++ examples/GraphSwitchCheckDefault1.xml | 705 ++++++++++ examples/GraphSwitchCheckDefault2.py | 334 +++++ examples/GraphSwitchCheckDefault2.xml | 787 ++++++++++++ examples/GraphSwitchCrash.xml | 4 +- examples/GraphSwitchErrExec.py | 164 +++ examples/GraphSwitchErrExec.xml | 385 ++++++ examples/GraphSwitchOutput.py | 211 +++ examples/GraphSwitchOutput.xml | 500 ++++++++ examples/GraphSwitchs.xml | 4 +- examples/GraphSyracuseC.py | 171 --- examples/GraphSyracuseC.xml | 315 ----- examples/GraphSyracuseCEv.py | 168 --- examples/GraphSyracuseCEv.xml | 315 ----- examples/GraphSyracuseC_Void.py | 160 --- examples/GraphSyracuseCpp.py | 223 ---- examples/GraphSyracuseCpp.xml | 457 ------- examples/GraphTwoLoops.py | 132 ++ examples/GraphTwoLoops.xml | 321 +++++ examples/GraphUndefinedSymbol.py | 31 + examples/GraphUndefinedSymbol.xml | 53 + examples/GraphVoidMoreLoop.py | 97 ++ examples/GraphVoidMoreLoop.xml | 239 ++++ examples/Loop.xml | 2 +- examples/SyrStruct.xml | 8 +- examples/TestSupervMedfieldLoopFori.xml | 2 +- examples/TestSupervMedfieldLoopForiVisu.xml | 2 +- examples/test_events.xml | 2 +- examples/test_superv_basic_loop.xml | 2 +- examples/testvisu20.xml | 2 +- examples/testvisu20_multi.xml | 4 +- idl/SUPERV.idl | 321 ++--- src/GraphBase/DataFlowBase_ComputingNode.cxx | 69 + src/GraphBase/DataFlowBase_ComputingNode.hxx | 17 +- src/GraphBase/DataFlowBase_Graph.cxx | 331 ++++- src/GraphBase/DataFlowBase_Graph.hxx | 3 +- src/GraphBase/DataFlowBase_InPort.cxx | 24 +- src/GraphBase/DataFlowBase_InPort.hxx | 7 +- src/GraphBase/DataFlowBase_PortsOfNode.cxx | 10 +- src/GraphBase/DataFlowBase_StreamNode.cxx | 161 ++- src/GraphBase/DataFlowBase_StreamNode.hxx | 52 +- src/GraphEditor/DataFlowEditor_DataFlow.hxx | 4 +- src/GraphEditor/DataFlowEditor_DataFlow.lxx | 5 +- src/GraphEditor/DataFlowEditor_OutNode.cxx | 64 +- src/GraphEditor/DataFlowEditor_OutNode.hxx | 9 + .../DataFlowExecutor_DataFlow.hxx | 2 - .../DataFlowExecutor_DataFlow.lxx | 5 - .../DataFlowExecutor_FiniteStateMachine.cxx | 35 +- .../DataFlowExecutor_FiniteStateMachine.hxx | 87 +- src/GraphExecutor/DataFlowExecutor_InNode.cxx | 447 +++++-- src/GraphExecutor/DataFlowExecutor_InNode.hxx | 15 +- .../DataFlowExecutor_InNodeThreads.cxx | 555 +++++--- .../DataFlowExecutor_OutNode.cxx | 197 +-- .../DataFlowExecutor_OutNode.hxx | 10 +- .../DataFlowExecutor_PyDynInvoke.cxx | 134 +- src/GraphExecutor/Makefile.in | 2 +- src/SUPERVGUI/Makefile.in | 95 +- src/SUPERVGUI/SUPERVGUI.cxx | 64 +- src/SUPERVGUI/SUPERVGUI.h | 8 + src/SUPERVGUI/SUPERVGUI_Array.cxx | 404 ------ src/SUPERVGUI/SUPERVGUI_Array.h | 111 -- src/SUPERVGUI/SUPERVGUI_ArrayView.cxx | 194 +++ src/SUPERVGUI/SUPERVGUI_ArrayView.h | 67 + src/SUPERVGUI/SUPERVGUI_BrowseNodeDlg.cxx | 174 +-- src/SUPERVGUI/SUPERVGUI_BrowseNodeDlg.h | 16 - src/SUPERVGUI/SUPERVGUI_Canvas.cxx | 9 +- src/SUPERVGUI/SUPERVGUI_CanvasArray.cxx | 249 ++++ src/SUPERVGUI/SUPERVGUI_CanvasArray.h | 45 + src/SUPERVGUI/SUPERVGUI_CanvasCellNodePrs.cxx | 211 +++ src/SUPERVGUI/SUPERVGUI_CanvasCellNodePrs.h | 52 + src/SUPERVGUI/SUPERVGUI_CanvasControlNode.cxx | 211 ++- src/SUPERVGUI/SUPERVGUI_CanvasControlNode.h | 62 +- src/SUPERVGUI/SUPERVGUI_CanvasLink.cxx | 80 +- src/SUPERVGUI/SUPERVGUI_CanvasLink.h | 14 +- src/SUPERVGUI/SUPERVGUI_CanvasNode.cxx | 234 ++-- src/SUPERVGUI/SUPERVGUI_CanvasNode.h | 35 +- src/SUPERVGUI/SUPERVGUI_CanvasNodePrs.cxx | 74 +- src/SUPERVGUI/SUPERVGUI_CanvasNodePrs.h | 14 +- src/SUPERVGUI/SUPERVGUI_CanvasPort.cxx | 37 +- src/SUPERVGUI/SUPERVGUI_CanvasPort.h | 1 + src/SUPERVGUI/SUPERVGUI_CanvasView.cxx | 235 +++- src/SUPERVGUI/SUPERVGUI_CanvasView.h | 10 +- src/SUPERVGUI/SUPERVGUI_Clipboard.cxx | 390 ++++++ src/SUPERVGUI/SUPERVGUI_Clipboard.h | 79 ++ src/SUPERVGUI/SUPERVGUI_ComputeNode.cxx | 157 --- src/SUPERVGUI/SUPERVGUI_ComputeNode.h | 51 - src/SUPERVGUI/SUPERVGUI_ControlNode.cxx | 432 ------- src/SUPERVGUI/SUPERVGUI_ControlNode.h | 130 -- src/SUPERVGUI/SUPERVGUI_CtrlLink.cxx | 47 - src/SUPERVGUI/SUPERVGUI_CtrlLink.h | 39 - src/SUPERVGUI/SUPERVGUI_Def.h | 4 +- src/SUPERVGUI/SUPERVGUI_Graph.cxx | 643 ---------- src/SUPERVGUI/SUPERVGUI_Graph.h | 123 -- src/SUPERVGUI/SUPERVGUI_GraphNode.cxx | 511 -------- src/SUPERVGUI/SUPERVGUI_GraphNode.h | 94 -- src/SUPERVGUI/SUPERVGUI_Label.cxx | 58 - src/SUPERVGUI/SUPERVGUI_Label.h | 51 - src/SUPERVGUI/SUPERVGUI_Library.cxx | 653 ++++++++++ src/SUPERVGUI/SUPERVGUI_Library.h | 113 ++ src/SUPERVGUI/SUPERVGUI_Link.cxx | 819 ------------ src/SUPERVGUI/SUPERVGUI_Link.h | 148 --- src/SUPERVGUI/SUPERVGUI_Main.cxx | 583 +++------ src/SUPERVGUI/SUPERVGUI_Main.h | 45 +- src/SUPERVGUI/SUPERVGUI_ManagePortsDlg.cxx | 605 +++++++++ src/SUPERVGUI/SUPERVGUI_ManagePortsDlg.h | 109 ++ src/SUPERVGUI/SUPERVGUI_Node.cxx | 581 --------- src/SUPERVGUI/SUPERVGUI_Node.h | 183 --- src/SUPERVGUI/SUPERVGUI_Notification.cxx | 17 +- src/SUPERVGUI/SUPERVGUI_Notification.h | 8 +- src/SUPERVGUI/SUPERVGUI_Port.cxx | 620 --------- src/SUPERVGUI/SUPERVGUI_Port.h | 239 ---- src/SUPERVGUI/SUPERVGUI_Python.cxx | 119 -- src/SUPERVGUI/SUPERVGUI_Python.h | 53 - src/SUPERVGUI/SUPERVGUI_Service.cxx | 423 +++--- src/SUPERVGUI/SUPERVGUI_Service.h | 70 +- src/SUPERVGUI/SUPERVGUI_View.cxx | 256 ---- src/SUPERVGUI/SUPERVGUI_View.h | 76 -- src/SUPERVGUI/SUPERV_msg_en.po | 134 +- src/SUPERVGUI/SUPERV_msg_fr.po | 50 +- src/Supervision/CNode_Impl.cxx | 100 +- src/Supervision/CNode_Impl.hxx | 6 - src/Supervision/ELNode_Impl.cxx | 19 +- src/Supervision/ESNode_Impl.cxx | 24 +- src/Supervision/FNode_Impl.cxx | 3 + src/Supervision/GNode_Impl.cxx | 3 + src/Supervision/Graph_Impl.cxx | 106 +- src/Supervision/Graph_Impl.hxx | 10 +- src/Supervision/INode_Impl.cxx | 3 + src/Supervision/LNode_Impl.cxx | 14 +- src/Supervision/Link_Impl.cxx | 23 + src/Supervision/Link_Impl.hxx | 4 + src/Supervision/SNode_Impl.cxx | 19 +- src/Supervision/SuperV.py | 16 +- src/Supervision/Value_Impl.cxx | 64 +- src/Supervision/batchmode_SuperV.py | 41 +- 201 files changed, 23926 insertions(+), 11560 deletions(-) create mode 100755 examples/GraphBadInputInLoop.py create mode 100755 examples/GraphBadInputInLoop.xml create mode 100755 examples/GraphBadInputInLoop1.py create mode 100755 examples/GraphBadInputInLoop1.xml create mode 100755 examples/GraphBadInputInLoop2.py create mode 100755 examples/GraphBadInputInLoop2.xml create mode 100755 examples/GraphBadInputInLoop3.py create mode 100755 examples/GraphBadInputInLoop3.xml create mode 100755 examples/GraphBadOutputOfLoop.py create mode 100755 examples/GraphBadOutputOfLoop.xml create mode 100755 examples/GraphBadOutputOfLoop1.py create mode 100755 examples/GraphBadOutputOfLoop1.xml create mode 100755 examples/GraphBadOutputOfLoop2.py create mode 100755 examples/GraphBadOutputOfLoop2.xml create mode 100644 examples/GraphEmbeddedComponents.py create mode 100644 examples/GraphEmbeddedComponents.xml create mode 100644 examples/GraphImportSalome.py create mode 100644 examples/GraphImportSalome.xml create mode 100644 examples/GraphInputInLoop.py create mode 100644 examples/GraphInputInLoop.xml create mode 100644 examples/GraphKillSuspend.py create mode 100644 examples/GraphLoopDoWhile.py create mode 100644 examples/GraphLoopDoWhile.xml create mode 100644 examples/GraphLoopGates.py create mode 100644 examples/GraphLoopGates.xml create mode 100644 examples/GraphLoopWhile.py create mode 100644 examples/GraphLoopWhile.xml create mode 100644 examples/GraphLoopsCoupled.py create mode 100644 examples/GraphLoopsCoupled.xml create mode 100644 examples/GraphLoopsGates.py create mode 100644 examples/GraphLoopsGates.xml create mode 100644 examples/GraphNonVoidEndLoop.py create mode 100644 examples/GraphNonVoidEndLoop.xml create mode 100644 examples/GraphSIGFPE.py create mode 100644 examples/GraphSIGFPE.xml create mode 100644 examples/GraphSIGFPEPython.py create mode 100644 examples/GraphSIGFPEPython.xml create mode 100644 examples/GraphSIGSEGV.py create mode 100644 examples/GraphSIGSEGV.xml create mode 100644 examples/GraphSIGSEGVPython.py create mode 100644 examples/GraphSIGSEGVPython.xml create mode 100644 examples/GraphSwitch2.py create mode 100644 examples/GraphSwitch2.xml create mode 100644 examples/GraphSwitchCheck.py create mode 100644 examples/GraphSwitchCheck.xml create mode 100644 examples/GraphSwitchCheckDefault.py create mode 100644 examples/GraphSwitchCheckDefault.xml create mode 100644 examples/GraphSwitchCheckDefault1.py create mode 100644 examples/GraphSwitchCheckDefault1.xml create mode 100644 examples/GraphSwitchCheckDefault2.py create mode 100644 examples/GraphSwitchCheckDefault2.xml create mode 100644 examples/GraphSwitchErrExec.py create mode 100644 examples/GraphSwitchErrExec.xml create mode 100644 examples/GraphSwitchOutput.py create mode 100644 examples/GraphSwitchOutput.xml delete mode 100644 examples/GraphSyracuseC.py delete mode 100755 examples/GraphSyracuseC.xml delete mode 100644 examples/GraphSyracuseCEv.py delete mode 100755 examples/GraphSyracuseCEv.xml delete mode 100644 examples/GraphSyracuseC_Void.py delete mode 100644 examples/GraphSyracuseCpp.py delete mode 100755 examples/GraphSyracuseCpp.xml create mode 100644 examples/GraphTwoLoops.py create mode 100644 examples/GraphTwoLoops.xml create mode 100644 examples/GraphUndefinedSymbol.py create mode 100644 examples/GraphUndefinedSymbol.xml create mode 100644 examples/GraphVoidMoreLoop.py create mode 100644 examples/GraphVoidMoreLoop.xml delete mode 100644 src/SUPERVGUI/SUPERVGUI_Array.cxx delete mode 100644 src/SUPERVGUI/SUPERVGUI_Array.h create mode 100644 src/SUPERVGUI/SUPERVGUI_ArrayView.cxx create mode 100644 src/SUPERVGUI/SUPERVGUI_ArrayView.h create mode 100644 src/SUPERVGUI/SUPERVGUI_CanvasArray.cxx create mode 100644 src/SUPERVGUI/SUPERVGUI_CanvasArray.h create mode 100644 src/SUPERVGUI/SUPERVGUI_CanvasCellNodePrs.cxx create mode 100644 src/SUPERVGUI/SUPERVGUI_CanvasCellNodePrs.h create mode 100644 src/SUPERVGUI/SUPERVGUI_Clipboard.cxx create mode 100644 src/SUPERVGUI/SUPERVGUI_Clipboard.h delete mode 100644 src/SUPERVGUI/SUPERVGUI_ComputeNode.cxx delete mode 100644 src/SUPERVGUI/SUPERVGUI_ComputeNode.h delete mode 100644 src/SUPERVGUI/SUPERVGUI_ControlNode.cxx delete mode 100644 src/SUPERVGUI/SUPERVGUI_ControlNode.h delete mode 100644 src/SUPERVGUI/SUPERVGUI_CtrlLink.cxx delete mode 100644 src/SUPERVGUI/SUPERVGUI_CtrlLink.h delete mode 100644 src/SUPERVGUI/SUPERVGUI_Graph.cxx delete mode 100644 src/SUPERVGUI/SUPERVGUI_Graph.h delete mode 100644 src/SUPERVGUI/SUPERVGUI_GraphNode.cxx delete mode 100644 src/SUPERVGUI/SUPERVGUI_GraphNode.h delete mode 100644 src/SUPERVGUI/SUPERVGUI_Label.cxx delete mode 100644 src/SUPERVGUI/SUPERVGUI_Label.h create mode 100644 src/SUPERVGUI/SUPERVGUI_Library.cxx create mode 100644 src/SUPERVGUI/SUPERVGUI_Library.h delete mode 100644 src/SUPERVGUI/SUPERVGUI_Link.cxx delete mode 100644 src/SUPERVGUI/SUPERVGUI_Link.h create mode 100644 src/SUPERVGUI/SUPERVGUI_ManagePortsDlg.cxx create mode 100644 src/SUPERVGUI/SUPERVGUI_ManagePortsDlg.h delete mode 100644 src/SUPERVGUI/SUPERVGUI_Node.cxx delete mode 100644 src/SUPERVGUI/SUPERVGUI_Node.h delete mode 100644 src/SUPERVGUI/SUPERVGUI_Port.cxx delete mode 100644 src/SUPERVGUI/SUPERVGUI_Port.h delete mode 100644 src/SUPERVGUI/SUPERVGUI_Python.cxx delete mode 100644 src/SUPERVGUI/SUPERVGUI_Python.h delete mode 100644 src/SUPERVGUI/SUPERVGUI_View.cxx delete mode 100644 src/SUPERVGUI/SUPERVGUI_View.h diff --git a/examples/GraphBadInputInLoop.py b/examples/GraphBadInputInLoop.py new file mode 100755 index 0000000..f8c17e3 --- /dev/null +++ b/examples/GraphBadInputInLoop.py @@ -0,0 +1,162 @@ + +# Generated python file of Graph GraphBadInputInLoop + +from SuperV import * + +# Graph creation of GraphBadInputInLoop +def DefGraphBadInputInLoop() : + GraphBadInputInLoop = Graph( 'GraphBadInputInLoop' ) + GraphBadInputInLoop.SetName( 'GraphBadInputInLoop' ) + GraphBadInputInLoop.SetAuthor( '' ) + GraphBadInputInLoop.SetComment( '' ) + GraphBadInputInLoop.Coords( 0 , 0 ) + + # Creation of Factory Nodes + + # Creation of InLine Nodes + PyIsOdd = [] + PyIsOdd.append( 'from time import * ' ) + PyIsOdd.append( 'def IsOdd(a,Even) : ' ) + PyIsOdd.append( ' print a,"IsOdd (GraphLoopSwitch1)" ' ) + PyIsOdd.append( ' sleep( 1 ) ' ) + PyIsOdd.append( ' return a ' ) + IsOdd = GraphBadInputInLoop.INode( 'IsOdd' , PyIsOdd ) + IsOdd.SetName( 'IsOdd' ) + IsOdd.SetAuthor( '' ) + IsOdd.SetComment( 'Python function' ) + IsOdd.Coords( 397 , 1 ) + IIsOdda = IsOdd.InPort( 'a' , 'long' ) + IIsOddEven = IsOdd.InPort( 'Even' , 'boolean' ) + IIsOddGate = IsOdd.GetInPort( 'Gate' ) + OIsOdda = IsOdd.OutPort( 'a' , 'long' ) + OIsOddGate = IsOdd.GetOutPort( 'Gate' ) + + PyBadInputOfLoop = [] + PyBadInputOfLoop.append( 'def BadInputOfLoop() : ' ) + PyBadInputOfLoop.append( ' return 1 ' ) + PyBadInputOfLoop.append( '' ) + BadInputOfLoop = GraphBadInputInLoop.INode( 'BadInputOfLoop' , PyBadInputOfLoop ) + BadInputOfLoop.SetName( 'BadInputOfLoop' ) + BadInputOfLoop.SetAuthor( '' ) + BadInputOfLoop.SetComment( 'Compute Node' ) + BadInputOfLoop.Coords( 15 , 307 ) + IBadInputOfLoopGate = BadInputOfLoop.GetInPort( 'Gate' ) + OBadInputOfLoopInputInLoop = BadInputOfLoop.OutPort( 'InputInLoop' , 'boolean' ) + OBadInputOfLoopGate = BadInputOfLoop.GetOutPort( 'Gate' ) + + # Creation of Loop Nodes + PyInitLoop = [] + PyMoreInitLoop = [] + PyMoreInitLoop.append( '' ) + PyNextInitLoop = [] + PyNextInitLoop.append( '' ) + InitLoop,EndOfInitLoop = GraphBadInputInLoop.LNode( '' , PyInitLoop , '' , PyMoreInitLoop , '' , PyNextInitLoop ) + EndOfInitLoop.SetName( 'EndOfInitLoop' ) + EndOfInitLoop.SetAuthor( '' ) + EndOfInitLoop.SetComment( 'Compute Node' ) + EndOfInitLoop.Coords( 767 , 102 ) + PyEndOfInitLoop = [] + PyEndOfInitLoop.append( 'def EndOfInitLoop( DoLoop , Index , Min , Max ) :' ) + PyEndOfInitLoop.append( ' Index = Index + 1 ' ) + PyEndOfInitLoop.append( ' if Index <= Max : ' ) + PyEndOfInitLoop.append( ' DoLoop = 1 ' ) + PyEndOfInitLoop.append( ' else : ' ) + PyEndOfInitLoop.append( ' DoLoop = 0 ' ) + PyEndOfInitLoop.append( ' return DoLoop,Index,Min,Max ' ) + EndOfInitLoop.SetPyFunction( 'EndOfInitLoop' , PyEndOfInitLoop ) + IInitLoopInitLoop = InitLoop.GetInPort( 'InitLoop' ) + IInitLoopIndex = InitLoop.InPort( 'Index' , 'long' ) + IInitLoopMin = InitLoop.InPort( 'Min' , 'long' ) + IInitLoopMax = InitLoop.InPort( 'Max' , 'long' ) + IInitLoopGate = InitLoop.GetInPort( 'Gate' ) + OInitLoopDoLoop = InitLoop.GetOutPort( 'DoLoop' ) + OInitLoopIndex = InitLoop.GetOutPort( 'Index' ) + OInitLoopMin = InitLoop.GetOutPort( 'Min' ) + OInitLoopMax = InitLoop.GetOutPort( 'Max' ) + IEndOfInitLoopDoLoop = EndOfInitLoop.GetInPort( 'DoLoop' ) + IEndOfInitLoopIndex = EndOfInitLoop.GetInPort( 'Index' ) + IEndOfInitLoopMin = EndOfInitLoop.GetInPort( 'Min' ) + IEndOfInitLoopMax = EndOfInitLoop.GetInPort( 'Max' ) + IEndOfInitLoopGate = EndOfInitLoop.GetInPort( 'Gate' ) + OEndOfInitLoopDoLoop = EndOfInitLoop.GetOutPort( 'DoLoop' ) + OEndOfInitLoopIndex = EndOfInitLoop.GetOutPort( 'Index' ) + OEndOfInitLoopMin = EndOfInitLoop.GetOutPort( 'Min' ) + OEndOfInitLoopMax = EndOfInitLoop.GetOutPort( 'Max' ) + InitLoop.SetName( 'InitLoop' ) + InitLoop.SetAuthor( '' ) + InitLoop.SetComment( 'Compute Node' ) + InitLoop.Coords( 10 , 108 ) + + # Creation of Switch Nodes + PySwitch = [] + PySwitch.append( 'from time import * ' ) + PySwitch.append( 'def Switch(a) : ' ) + PySwitch.append( ' if ( a & 1 ) == 0 : ' ) + PySwitch.append( ' sleep(1) ' ) + PySwitch.append( ' return a & 1,1-(a&1),a ' ) + Switch,EndSwitch = GraphBadInputInLoop.SNode( 'Switch' , PySwitch ) + EndSwitch.SetName( 'EndSwitch' ) + EndSwitch.SetAuthor( '' ) + EndSwitch.SetComment( 'Compute Node' ) + EndSwitch.Coords( 587 , 103 ) + PyEndSwitch = [] + PyEndSwitch.append( 'def EndSwitch(a) : ' ) + PyEndSwitch.append( ' if ( a & 1 ) == 0 : ' ) + PyEndSwitch.append( ' sleep(1) ' ) + PyEndSwitch.append( ' return a ' ) + EndSwitch.SetPyFunction( 'EndSwitch' , PyEndSwitch ) + IEndSwitcha = EndSwitch.InPort( 'a' , 'long' ) + IEndSwitchDefault = EndSwitch.GetInPort( 'Default' ) + OEndSwitcha = EndSwitch.OutPort( 'a' , 'long' ) + OEndSwitchGate = EndSwitch.GetOutPort( 'Gate' ) + Switch.SetName( 'Switch' ) + Switch.SetAuthor( '' ) + Switch.SetComment( 'Compute Node' ) + Switch.Coords( 194 , 109 ) + ISwitcha = Switch.InPort( 'a' , 'long' ) + ISwitchGate = Switch.GetInPort( 'Gate' ) + OSwitchOdd = Switch.OutPort( 'Odd' , 'long' ) + OSwitchEven = Switch.OutPort( 'Even' , 'int' ) + OSwitcha = Switch.OutPort( 'a' , 'int' ) + OSwitchDefault = Switch.GetOutPort( 'Default' ) + + # Creation of Links + LIsOddaEndSwitcha = GraphBadInputInLoop.Link( OIsOdda , IEndSwitcha ) + LIsOddaEndSwitcha.AddCoord( 1 , 576 , 136 ) + LIsOddaEndSwitcha.AddCoord( 2 , 575 , 81 ) + + LInitLoopIndexSwitcha = GraphBadInputInLoop.Link( OInitLoopIndex , ISwitcha ) + + LInitLoopMinEndOfInitLoopMin = GraphBadInputInLoop.Link( OInitLoopMin , IEndOfInitLoopMin ) + + LSwitchOddIsOddGate = GraphBadInputInLoop.Link( OSwitchOdd , IIsOddGate ) + + LSwitchEvenEndSwitchDefault = GraphBadInputInLoop.Link( OSwitchEven , IEndSwitchDefault ) + + LSwitchEvenIsOddEven = GraphBadInputInLoop.Link( OSwitchEven , IIsOddEven ) + LSwitchEvenIsOddEven.AddCoord( 1 , 375 , 111 ) + LSwitchEvenIsOddEven.AddCoord( 2 , 375 , 172 ) + + LSwitchaIsOdda = GraphBadInputInLoop.Link( OSwitcha , IIsOdda ) + LSwitchaIsOdda.AddCoord( 1 , 362 , 82 ) + LSwitchaIsOdda.AddCoord( 2 , 360 , 201 ) + + LEndSwitchaEndOfInitLoopIndex = GraphBadInputInLoop.Link( OEndSwitcha , IEndOfInitLoopIndex ) + + LBadInputOfLoopInputInLoopSwitchGate = GraphBadInputInLoop.Link( OBadInputOfLoopInputInLoop , ISwitchGate ) + + # Input datas + IInitLoopIndex.Input( 0 ) + IInitLoopMin.Input( 0 ) + IInitLoopMax.Input( 100 ) + IEndOfInitLoopMax.Input( 136221856 ) + + # Output Ports of the graph + #OInitLoopMax = InitLoop.GetOutPort( 'Max' ) + #OEndOfInitLoopIndex = EndOfInitLoop.GetOutPort( 'Index' ) + #OEndOfInitLoopMin = EndOfInitLoop.GetOutPort( 'Min' ) + #OEndOfInitLoopMax = EndOfInitLoop.GetOutPort( 'Max' ) + return GraphBadInputInLoop + + +GraphBadInputInLoop = DefGraphBadInputInLoop() diff --git a/examples/GraphBadInputInLoop.xml b/examples/GraphBadInputInLoop.xml new file mode 100755 index 0000000..ccec624 --- /dev/null +++ b/examples/GraphBadInputInLoop.xml @@ -0,0 +1,400 @@ + + + + + +? + ? + GraphBadInputInLoop + 1 + ? + +GraphBadInputInLoop + + +long + InitLoop__Index + +long + InitLoop__Min + +long + InitLoop__Max + +long + EndOfInitLoop__Max + + +long + InitLoop__Max + +long + EndOfInitLoop__Index + +long + EndOfInitLoop__Min + +long + EndOfInitLoop__Max + + + 22/10/2003 - 10:36:39 + 14/12/2004 - 15:56:35 + 1.05 + ? + ? + ? + 0 + 0 + + +? + ? + IsOdd + 3 + ? + +IsOdd + + +long + a + +boolean + Even + + +long + a + + + +IsOdd + + + + + + 14/12/2004 - 15:56:35 + 14/12/2004 - 15:56:35 + 1.05 + ? + ? + Python function + 397 + 1 + +? + ? + InitLoop + 4 + EndOfInitLoop + +InitLoop + + +long + Index + +long + Min + +long + Max + + +long + Index + +long + Min + +long + Max + + + +? + + +? + + +? + + 14/12/2004 - 15:56:35 + 14/12/2004 - 15:56:35 + 1.05 + ? + ? + Compute Node + 10 + 108 + +? + ? + EndOfInitLoop + 5 + InitLoop + +EndOfInitLoop + + +long + Index + +long + Min + +long + Max + + +long + Index + +long + Min + +long + Max + + + +EndOfInitLoop + + + + + + + + 14/12/2004 - 15:56:35 + 14/12/2004 - 15:56:35 + 1.05 + ? + ? + Compute Node + 767 + 102 + +? + ? + Switch + 6 + EndSwitch + +Switch + + +long + a + + +long + Odd + +int + Even + +int + a + + + +Switch + + + + + + 14/12/2004 - 15:56:35 + 14/12/2004 - 15:56:35 + 1.05 + ? + ? + Compute Node + 194 + 109 + +? + ? + EndSwitch + 7 + Switch + +EndSwitch + + +long + a + + +long + a + + + +EndSwitch + + + + + 14/12/2004 - 15:56:35 + 14/12/2004 - 15:56:35 + 1.05 + ? + ? + Compute Node + 587 + 103 + +? + ? + BadInputOfLoop + 3 + ? + +BadInputOfLoop + + + +boolean + InputInLoop + + + +BadInputOfLoop + + + + 14/12/2004 - 15:56:35 + 14/12/2004 - 15:56:35 + 2.0 + ? + ? + Compute Node + 15 + 307 + + +IsOdd + a + EndSwitch + a + + +576 + 136 + +575 + 81 + +InitLoop + DoLoop + EndOfInitLoop + DoLoop + + +InitLoop + Index + Switch + a + + +InitLoop + Min + EndOfInitLoop + Min + + +EndOfInitLoop + DoLoop + InitLoop + InitLoop + + +Switch + Odd + IsOdd + Gate + + +Switch + Even + EndSwitch + Default + + +Switch + Even + IsOdd + Even + + +375 + 111 + +375 + 172 + +Switch + a + IsOdd + a + + +362 + 82 + +360 + 201 + +EndSwitch + a + EndOfInitLoop + Index + + +BadInputOfLoop + InputInLoop + Switch + Gate + + + +GraphBadInputInLoop + InitLoop__Index + InitLoop + Index + +3 + 0 + + +GraphBadInputInLoop + InitLoop__Min + InitLoop + Min + +3 + 0 + + +GraphBadInputInLoop + InitLoop__Max + InitLoop + Max + +3 + 100 + + +GraphBadInputInLoop + EndOfInitLoop__Max + EndOfInitLoop + Max + +3 + 136221856 + diff --git a/examples/GraphBadInputInLoop1.py b/examples/GraphBadInputInLoop1.py new file mode 100755 index 0000000..d5d1da8 --- /dev/null +++ b/examples/GraphBadInputInLoop1.py @@ -0,0 +1,162 @@ + +# Generated python file of Graph GraphBadInputInLoop1 + +from SuperV import * + +# Graph creation of GraphBadInputInLoop1 +def DefGraphBadInputInLoop1() : + GraphBadInputInLoop1 = Graph( 'GraphBadInputInLoop1' ) + GraphBadInputInLoop1.SetName( 'GraphBadInputInLoop1' ) + GraphBadInputInLoop1.SetAuthor( '' ) + GraphBadInputInLoop1.SetComment( '' ) + GraphBadInputInLoop1.Coords( 0 , 0 ) + + # Creation of Factory Nodes + + # Creation of InLine Nodes + PyIsOdd = [] + PyIsOdd.append( 'from time import * ' ) + PyIsOdd.append( 'def IsOdd(a,Even) : ' ) + PyIsOdd.append( ' print a,"IsOdd (GraphLoopSwitch1)" ' ) + PyIsOdd.append( ' sleep( 1 ) ' ) + PyIsOdd.append( ' return a ' ) + IsOdd = GraphBadInputInLoop1.INode( 'IsOdd' , PyIsOdd ) + IsOdd.SetName( 'IsOdd' ) + IsOdd.SetAuthor( '' ) + IsOdd.SetComment( 'Python function' ) + IsOdd.Coords( 397 , 1 ) + IIsOdda = IsOdd.InPort( 'a' , 'long' ) + IIsOddEven = IsOdd.InPort( 'Even' , 'boolean' ) + IIsOddGate = IsOdd.GetInPort( 'Gate' ) + OIsOdda = IsOdd.OutPort( 'a' , 'long' ) + OIsOddGate = IsOdd.GetOutPort( 'Gate' ) + + PyBadInputOfLoop = [] + PyBadInputOfLoop.append( 'def BadInputOfLoop() : ' ) + PyBadInputOfLoop.append( ' return 1 ' ) + PyBadInputOfLoop.append( '' ) + BadInputOfLoop = GraphBadInputInLoop1.INode( 'BadInputOfLoop' , PyBadInputOfLoop ) + BadInputOfLoop.SetName( 'BadInputOfLoop' ) + BadInputOfLoop.SetAuthor( '' ) + BadInputOfLoop.SetComment( 'Compute Node' ) + BadInputOfLoop.Coords( 15 , 307 ) + IBadInputOfLoopGate = BadInputOfLoop.GetInPort( 'Gate' ) + OBadInputOfLoopInputInLoop = BadInputOfLoop.OutPort( 'InputInLoop' , 'boolean' ) + OBadInputOfLoopGate = BadInputOfLoop.GetOutPort( 'Gate' ) + + # Creation of Loop Nodes + PyInitLoop = [] + PyMoreInitLoop = [] + PyMoreInitLoop.append( '' ) + PyNextInitLoop = [] + PyNextInitLoop.append( '' ) + InitLoop,EndOfInitLoop = GraphBadInputInLoop1.LNode( '' , PyInitLoop , '' , PyMoreInitLoop , '' , PyNextInitLoop ) + EndOfInitLoop.SetName( 'EndOfInitLoop' ) + EndOfInitLoop.SetAuthor( '' ) + EndOfInitLoop.SetComment( 'Compute Node' ) + EndOfInitLoop.Coords( 767 , 102 ) + PyEndOfInitLoop = [] + PyEndOfInitLoop.append( 'def EndOfInitLoop( DoLoop , Index , Min , Max ) :' ) + PyEndOfInitLoop.append( ' Index = Index + 1 ' ) + PyEndOfInitLoop.append( ' if Index <= Max : ' ) + PyEndOfInitLoop.append( ' DoLoop = 1 ' ) + PyEndOfInitLoop.append( ' else : ' ) + PyEndOfInitLoop.append( ' DoLoop = 0 ' ) + PyEndOfInitLoop.append( ' return DoLoop,Index,Min,Max ' ) + EndOfInitLoop.SetPyFunction( 'EndOfInitLoop' , PyEndOfInitLoop ) + IInitLoopInitLoop = InitLoop.GetInPort( 'InitLoop' ) + IInitLoopIndex = InitLoop.InPort( 'Index' , 'long' ) + IInitLoopMin = InitLoop.InPort( 'Min' , 'long' ) + IInitLoopMax = InitLoop.InPort( 'Max' , 'long' ) + IInitLoopGate = InitLoop.GetInPort( 'Gate' ) + OInitLoopDoLoop = InitLoop.GetOutPort( 'DoLoop' ) + OInitLoopIndex = InitLoop.GetOutPort( 'Index' ) + OInitLoopMin = InitLoop.GetOutPort( 'Min' ) + OInitLoopMax = InitLoop.GetOutPort( 'Max' ) + IEndOfInitLoopDoLoop = EndOfInitLoop.GetInPort( 'DoLoop' ) + IEndOfInitLoopIndex = EndOfInitLoop.GetInPort( 'Index' ) + IEndOfInitLoopMin = EndOfInitLoop.GetInPort( 'Min' ) + IEndOfInitLoopMax = EndOfInitLoop.GetInPort( 'Max' ) + IEndOfInitLoopGate = EndOfInitLoop.GetInPort( 'Gate' ) + OEndOfInitLoopDoLoop = EndOfInitLoop.GetOutPort( 'DoLoop' ) + OEndOfInitLoopIndex = EndOfInitLoop.GetOutPort( 'Index' ) + OEndOfInitLoopMin = EndOfInitLoop.GetOutPort( 'Min' ) + OEndOfInitLoopMax = EndOfInitLoop.GetOutPort( 'Max' ) + InitLoop.SetName( 'InitLoop' ) + InitLoop.SetAuthor( '' ) + InitLoop.SetComment( 'Compute Node' ) + InitLoop.Coords( 10 , 108 ) + + # Creation of Switch Nodes + PySwitch = [] + PySwitch.append( 'from time import * ' ) + PySwitch.append( 'def Switch(a) : ' ) + PySwitch.append( ' if ( a & 1 ) == 0 : ' ) + PySwitch.append( ' sleep(1) ' ) + PySwitch.append( ' return a & 1,1-(a&1),a ' ) + Switch,EndSwitch = GraphBadInputInLoop1.SNode( 'Switch' , PySwitch ) + EndSwitch.SetName( 'EndSwitch' ) + EndSwitch.SetAuthor( '' ) + EndSwitch.SetComment( 'Compute Node' ) + EndSwitch.Coords( 587 , 103 ) + PyEndSwitch = [] + PyEndSwitch.append( 'def EndSwitch(a) : ' ) + PyEndSwitch.append( ' if ( a & 1 ) == 0 : ' ) + PyEndSwitch.append( ' sleep(1) ' ) + PyEndSwitch.append( ' return a ' ) + EndSwitch.SetPyFunction( 'EndSwitch' , PyEndSwitch ) + IEndSwitcha = EndSwitch.InPort( 'a' , 'long' ) + IEndSwitchDefault = EndSwitch.GetInPort( 'Default' ) + OEndSwitcha = EndSwitch.OutPort( 'a' , 'long' ) + OEndSwitchGate = EndSwitch.GetOutPort( 'Gate' ) + Switch.SetName( 'Switch' ) + Switch.SetAuthor( '' ) + Switch.SetComment( 'Compute Node' ) + Switch.Coords( 194 , 109 ) + ISwitcha = Switch.InPort( 'a' , 'long' ) + ISwitchGate = Switch.GetInPort( 'Gate' ) + OSwitchOdd = Switch.OutPort( 'Odd' , 'long' ) + OSwitchEven = Switch.OutPort( 'Even' , 'int' ) + OSwitcha = Switch.OutPort( 'a' , 'int' ) + OSwitchDefault = Switch.GetOutPort( 'Default' ) + + # Creation of Links + LIsOddaEndSwitcha = GraphBadInputInLoop1.Link( OIsOdda , IEndSwitcha ) + LIsOddaEndSwitcha.AddCoord( 1 , 576 , 136 ) + LIsOddaEndSwitcha.AddCoord( 2 , 575 , 81 ) + + LInitLoopIndexSwitcha = GraphBadInputInLoop1.Link( OInitLoopIndex , ISwitcha ) + + LInitLoopMinEndOfInitLoopMin = GraphBadInputInLoop1.Link( OInitLoopMin , IEndOfInitLoopMin ) + + LSwitchOddIsOddGate = GraphBadInputInLoop1.Link( OSwitchOdd , IIsOddGate ) + + LSwitchEvenEndSwitchDefault = GraphBadInputInLoop1.Link( OSwitchEven , IEndSwitchDefault ) + + LSwitchEvenIsOddEven = GraphBadInputInLoop1.Link( OSwitchEven , IIsOddEven ) + LSwitchEvenIsOddEven.AddCoord( 1 , 375 , 111 ) + LSwitchEvenIsOddEven.AddCoord( 2 , 375 , 172 ) + + LSwitchaIsOdda = GraphBadInputInLoop1.Link( OSwitcha , IIsOdda ) + LSwitchaIsOdda.AddCoord( 1 , 362 , 82 ) + LSwitchaIsOdda.AddCoord( 2 , 360 , 201 ) + + LEndSwitchaEndOfInitLoopIndex = GraphBadInputInLoop1.Link( OEndSwitcha , IEndOfInitLoopIndex ) + + LBadInputOfLoopInputInLoopEndOfInitLoopGate = GraphBadInputInLoop1.Link( OBadInputOfLoopInputInLoop , IEndOfInitLoopGate ) + + # Input datas + IInitLoopIndex.Input( 0 ) + IInitLoopMin.Input( 0 ) + IInitLoopMax.Input( 100 ) + IEndOfInitLoopMax.Input( 136221856 ) + + # Output Ports of the graph + #OInitLoopMax = InitLoop.GetOutPort( 'Max' ) + #OEndOfInitLoopIndex = EndOfInitLoop.GetOutPort( 'Index' ) + #OEndOfInitLoopMin = EndOfInitLoop.GetOutPort( 'Min' ) + #OEndOfInitLoopMax = EndOfInitLoop.GetOutPort( 'Max' ) + return GraphBadInputInLoop1 + + +GraphBadInputInLoop1 = DefGraphBadInputInLoop1() diff --git a/examples/GraphBadInputInLoop1.xml b/examples/GraphBadInputInLoop1.xml new file mode 100755 index 0000000..5efd5ef --- /dev/null +++ b/examples/GraphBadInputInLoop1.xml @@ -0,0 +1,400 @@ + + + + + +? + ? + GraphBadInputInLoop1 + 1 + ? + +GraphBadInputInLoop1 + + +long + InitLoop__Index + +long + InitLoop__Min + +long + InitLoop__Max + +long + EndOfInitLoop__Max + + +long + InitLoop__Max + +long + EndOfInitLoop__Index + +long + EndOfInitLoop__Min + +long + EndOfInitLoop__Max + + + 22/10/2003 - 10:36:39 + 14/12/2004 - 15:57:27 + 1.05 + ? + ? + ? + 0 + 0 + + +? + ? + IsOdd + 3 + ? + +IsOdd + + +long + a + +boolean + Even + + +long + a + + + +IsOdd + + + + + + 14/12/2004 - 15:57:27 + 14/12/2004 - 15:57:27 + 1.05 + ? + ? + Python function + 397 + 1 + +? + ? + InitLoop + 4 + EndOfInitLoop + +InitLoop + + +long + Index + +long + Min + +long + Max + + +long + Index + +long + Min + +long + Max + + + +? + + +? + + +? + + 14/12/2004 - 15:57:27 + 14/12/2004 - 15:57:27 + 1.05 + ? + ? + Compute Node + 10 + 108 + +? + ? + EndOfInitLoop + 5 + InitLoop + +EndOfInitLoop + + +long + Index + +long + Min + +long + Max + + +long + Index + +long + Min + +long + Max + + + +EndOfInitLoop + + + + + + + + 14/12/2004 - 15:57:27 + 14/12/2004 - 15:57:27 + 1.05 + ? + ? + Compute Node + 767 + 102 + +? + ? + Switch + 6 + EndSwitch + +Switch + + +long + a + + +long + Odd + +int + Even + +int + a + + + +Switch + + + + + + 14/12/2004 - 15:57:27 + 14/12/2004 - 15:57:27 + 1.05 + ? + ? + Compute Node + 194 + 109 + +? + ? + EndSwitch + 7 + Switch + +EndSwitch + + +long + a + + +long + a + + + +EndSwitch + + + + + 14/12/2004 - 15:57:27 + 14/12/2004 - 15:57:27 + 1.05 + ? + ? + Compute Node + 587 + 103 + +? + ? + BadInputOfLoop + 3 + ? + +BadInputOfLoop + + + +boolean + InputInLoop + + + +BadInputOfLoop + + + + 14/12/2004 - 15:57:27 + 14/12/2004 - 15:57:27 + 2.0 + ? + ? + Compute Node + 15 + 307 + + +IsOdd + a + EndSwitch + a + + +576 + 136 + +575 + 81 + +InitLoop + DoLoop + EndOfInitLoop + DoLoop + + +InitLoop + Index + Switch + a + + +InitLoop + Min + EndOfInitLoop + Min + + +EndOfInitLoop + DoLoop + InitLoop + InitLoop + + +Switch + Odd + IsOdd + Gate + + +Switch + Even + EndSwitch + Default + + +Switch + Even + IsOdd + Even + + +375 + 111 + +375 + 172 + +Switch + a + IsOdd + a + + +362 + 82 + +360 + 201 + +EndSwitch + a + EndOfInitLoop + Index + + +BadInputOfLoop + InputInLoop + EndOfInitLoop + Gate + + + +GraphBadInputInLoop1 + InitLoop__Index + InitLoop + Index + +3 + 0 + + +GraphBadInputInLoop1 + InitLoop__Min + InitLoop + Min + +3 + 0 + + +GraphBadInputInLoop1 + InitLoop__Max + InitLoop + Max + +3 + 100 + + +GraphBadInputInLoop1 + EndOfInitLoop__Max + EndOfInitLoop + Max + +3 + 136221856 + diff --git a/examples/GraphBadInputInLoop2.py b/examples/GraphBadInputInLoop2.py new file mode 100755 index 0000000..eea51de --- /dev/null +++ b/examples/GraphBadInputInLoop2.py @@ -0,0 +1,163 @@ + +# Generated python file of Graph GraphBadInputInLoop2 + +from SuperV import * + +# Graph creation of GraphBadInputInLoop2 +def DefGraphBadInputInLoop2() : + GraphBadInputInLoop2 = Graph( 'GraphBadInputInLoop2' ) + GraphBadInputInLoop2.SetName( 'GraphBadInputInLoop2' ) + GraphBadInputInLoop2.SetAuthor( '' ) + GraphBadInputInLoop2.SetComment( '' ) + GraphBadInputInLoop2.Coords( 0 , 0 ) + + # Creation of Factory Nodes + + # Creation of InLine Nodes + PyIsOdd = [] + PyIsOdd.append( 'from time import * ' ) + PyIsOdd.append( 'def IsOdd(a,Even,InputInLoop) : ' ) + PyIsOdd.append( ' print a,"IsOdd (GraphLoopSwitch1)" ' ) + PyIsOdd.append( ' sleep( 1 ) ' ) + PyIsOdd.append( ' return a ' ) + IsOdd = GraphBadInputInLoop2.INode( 'IsOdd' , PyIsOdd ) + IsOdd.SetName( 'IsOdd' ) + IsOdd.SetAuthor( '' ) + IsOdd.SetComment( 'Python function' ) + IsOdd.Coords( 397 , 1 ) + IIsOdda = IsOdd.InPort( 'a' , 'long' ) + IIsOddEven = IsOdd.InPort( 'Even' , 'boolean' ) + IIsOddInputInLoop = IsOdd.InPort( 'InputInLoop' , 'boolean' ) + IIsOddGate = IsOdd.GetInPort( 'Gate' ) + OIsOdda = IsOdd.OutPort( 'a' , 'long' ) + OIsOddGate = IsOdd.GetOutPort( 'Gate' ) + + PyBadInputOfLoop = [] + PyBadInputOfLoop.append( 'def BadInputOfLoop() : ' ) + PyBadInputOfLoop.append( ' return 1 ' ) + PyBadInputOfLoop.append( '' ) + BadInputOfLoop = GraphBadInputInLoop2.INode( 'BadInputOfLoop' , PyBadInputOfLoop ) + BadInputOfLoop.SetName( 'BadInputOfLoop' ) + BadInputOfLoop.SetAuthor( '' ) + BadInputOfLoop.SetComment( 'Compute Node' ) + BadInputOfLoop.Coords( 15 , 307 ) + IBadInputOfLoopGate = BadInputOfLoop.GetInPort( 'Gate' ) + OBadInputOfLoopInputInLoop = BadInputOfLoop.OutPort( 'InputInLoop' , 'boolean' ) + OBadInputOfLoopGate = BadInputOfLoop.GetOutPort( 'Gate' ) + + # Creation of Loop Nodes + PyInitLoop = [] + PyMoreInitLoop = [] + PyMoreInitLoop.append( '' ) + PyNextInitLoop = [] + PyNextInitLoop.append( '' ) + InitLoop,EndOfInitLoop = GraphBadInputInLoop2.LNode( '' , PyInitLoop , '' , PyMoreInitLoop , '' , PyNextInitLoop ) + EndOfInitLoop.SetName( 'EndOfInitLoop' ) + EndOfInitLoop.SetAuthor( '' ) + EndOfInitLoop.SetComment( 'Compute Node' ) + EndOfInitLoop.Coords( 767 , 102 ) + PyEndOfInitLoop = [] + PyEndOfInitLoop.append( 'def EndOfInitLoop( DoLoop , Index , Min , Max ) :' ) + PyEndOfInitLoop.append( ' Index = Index + 1 ' ) + PyEndOfInitLoop.append( ' if Index <= Max : ' ) + PyEndOfInitLoop.append( ' DoLoop = 1 ' ) + PyEndOfInitLoop.append( ' else : ' ) + PyEndOfInitLoop.append( ' DoLoop = 0 ' ) + PyEndOfInitLoop.append( ' return DoLoop,Index,Min,Max ' ) + EndOfInitLoop.SetPyFunction( 'EndOfInitLoop' , PyEndOfInitLoop ) + IInitLoopInitLoop = InitLoop.GetInPort( 'InitLoop' ) + IInitLoopIndex = InitLoop.InPort( 'Index' , 'long' ) + IInitLoopMin = InitLoop.InPort( 'Min' , 'long' ) + IInitLoopMax = InitLoop.InPort( 'Max' , 'long' ) + IInitLoopGate = InitLoop.GetInPort( 'Gate' ) + OInitLoopDoLoop = InitLoop.GetOutPort( 'DoLoop' ) + OInitLoopIndex = InitLoop.GetOutPort( 'Index' ) + OInitLoopMin = InitLoop.GetOutPort( 'Min' ) + OInitLoopMax = InitLoop.GetOutPort( 'Max' ) + IEndOfInitLoopDoLoop = EndOfInitLoop.GetInPort( 'DoLoop' ) + IEndOfInitLoopIndex = EndOfInitLoop.GetInPort( 'Index' ) + IEndOfInitLoopMin = EndOfInitLoop.GetInPort( 'Min' ) + IEndOfInitLoopMax = EndOfInitLoop.GetInPort( 'Max' ) + IEndOfInitLoopGate = EndOfInitLoop.GetInPort( 'Gate' ) + OEndOfInitLoopDoLoop = EndOfInitLoop.GetOutPort( 'DoLoop' ) + OEndOfInitLoopIndex = EndOfInitLoop.GetOutPort( 'Index' ) + OEndOfInitLoopMin = EndOfInitLoop.GetOutPort( 'Min' ) + OEndOfInitLoopMax = EndOfInitLoop.GetOutPort( 'Max' ) + InitLoop.SetName( 'InitLoop' ) + InitLoop.SetAuthor( '' ) + InitLoop.SetComment( 'Compute Node' ) + InitLoop.Coords( 10 , 108 ) + + # Creation of Switch Nodes + PySwitch = [] + PySwitch.append( 'from time import * ' ) + PySwitch.append( 'def Switch(a) : ' ) + PySwitch.append( ' if ( a & 1 ) == 0 : ' ) + PySwitch.append( ' sleep(1) ' ) + PySwitch.append( ' return a & 1,1-(a&1),a ' ) + Switch,EndSwitch = GraphBadInputInLoop2.SNode( 'Switch' , PySwitch ) + EndSwitch.SetName( 'EndSwitch' ) + EndSwitch.SetAuthor( '' ) + EndSwitch.SetComment( 'Compute Node' ) + EndSwitch.Coords( 587 , 103 ) + PyEndSwitch = [] + PyEndSwitch.append( 'def EndSwitch(a) : ' ) + PyEndSwitch.append( ' if ( a & 1 ) == 0 : ' ) + PyEndSwitch.append( ' sleep(1) ' ) + PyEndSwitch.append( ' return a ' ) + EndSwitch.SetPyFunction( 'EndSwitch' , PyEndSwitch ) + IEndSwitcha = EndSwitch.InPort( 'a' , 'long' ) + IEndSwitchDefault = EndSwitch.GetInPort( 'Default' ) + OEndSwitcha = EndSwitch.OutPort( 'a' , 'long' ) + OEndSwitchGate = EndSwitch.GetOutPort( 'Gate' ) + Switch.SetName( 'Switch' ) + Switch.SetAuthor( '' ) + Switch.SetComment( 'Compute Node' ) + Switch.Coords( 194 , 109 ) + ISwitcha = Switch.InPort( 'a' , 'long' ) + ISwitchGate = Switch.GetInPort( 'Gate' ) + OSwitchOdd = Switch.OutPort( 'Odd' , 'long' ) + OSwitchEven = Switch.OutPort( 'Even' , 'int' ) + OSwitcha = Switch.OutPort( 'a' , 'int' ) + OSwitchDefault = Switch.GetOutPort( 'Default' ) + + # Creation of Links + LIsOddaEndSwitcha = GraphBadInputInLoop2.Link( OIsOdda , IEndSwitcha ) + LIsOddaEndSwitcha.AddCoord( 1 , 576 , 136 ) + LIsOddaEndSwitcha.AddCoord( 2 , 575 , 81 ) + + LInitLoopIndexSwitcha = GraphBadInputInLoop2.Link( OInitLoopIndex , ISwitcha ) + + LInitLoopMinEndOfInitLoopMin = GraphBadInputInLoop2.Link( OInitLoopMin , IEndOfInitLoopMin ) + + LSwitchOddIsOddGate = GraphBadInputInLoop2.Link( OSwitchOdd , IIsOddGate ) + + LSwitchEvenEndSwitchDefault = GraphBadInputInLoop2.Link( OSwitchEven , IEndSwitchDefault ) + + LSwitchEvenIsOddEven = GraphBadInputInLoop2.Link( OSwitchEven , IIsOddEven ) + LSwitchEvenIsOddEven.AddCoord( 1 , 375 , 111 ) + LSwitchEvenIsOddEven.AddCoord( 2 , 375 , 172 ) + + LSwitchaIsOdda = GraphBadInputInLoop2.Link( OSwitcha , IIsOdda ) + LSwitchaIsOdda.AddCoord( 1 , 362 , 82 ) + LSwitchaIsOdda.AddCoord( 2 , 360 , 201 ) + + LEndSwitchaEndOfInitLoopIndex = GraphBadInputInLoop2.Link( OEndSwitcha , IEndOfInitLoopIndex ) + + LBadInputOfLoopInputInLoopIsOddInputInLoop = GraphBadInputInLoop2.Link( OBadInputOfLoopInputInLoop , IIsOddInputInLoop ) + + # Input datas + IInitLoopIndex.Input( 0 ) + IInitLoopMin.Input( 0 ) + IInitLoopMax.Input( 100 ) + IEndOfInitLoopMax.Input( 136221856 ) + + # Output Ports of the graph + #OInitLoopMax = InitLoop.GetOutPort( 'Max' ) + #OEndOfInitLoopIndex = EndOfInitLoop.GetOutPort( 'Index' ) + #OEndOfInitLoopMin = EndOfInitLoop.GetOutPort( 'Min' ) + #OEndOfInitLoopMax = EndOfInitLoop.GetOutPort( 'Max' ) + return GraphBadInputInLoop2 + + +GraphBadInputInLoop2 = DefGraphBadInputInLoop2() diff --git a/examples/GraphBadInputInLoop2.xml b/examples/GraphBadInputInLoop2.xml new file mode 100755 index 0000000..3e5ec3c --- /dev/null +++ b/examples/GraphBadInputInLoop2.xml @@ -0,0 +1,403 @@ + + + + + +? + ? + GraphBadInputInLoop2 + 1 + ? + +GraphBadInputInLoop2 + + +long + InitLoop__Index + +long + InitLoop__Min + +long + InitLoop__Max + +long + EndOfInitLoop__Max + + +long + InitLoop__Max + +long + EndOfInitLoop__Index + +long + EndOfInitLoop__Min + +long + EndOfInitLoop__Max + + + 22/10/2003 - 10:36:39 + 14/12/2004 - 15:57:56 + 1.05 + ? + ? + ? + 0 + 0 + + +? + ? + IsOdd + 3 + ? + +IsOdd + + +long + a + +boolean + Even + +boolean + InputInLoop + + +long + a + + + +IsOdd + + + + + + 14/12/2004 - 15:57:56 + 14/12/2004 - 15:57:56 + 1.05 + ? + ? + Python function + 397 + 1 + +? + ? + InitLoop + 4 + EndOfInitLoop + +InitLoop + + +long + Index + +long + Min + +long + Max + + +long + Index + +long + Min + +long + Max + + + +? + + +? + + +? + + 14/12/2004 - 15:57:56 + 14/12/2004 - 15:57:56 + 1.05 + ? + ? + Compute Node + 10 + 108 + +? + ? + EndOfInitLoop + 5 + InitLoop + +EndOfInitLoop + + +long + Index + +long + Min + +long + Max + + +long + Index + +long + Min + +long + Max + + + +EndOfInitLoop + + + + + + + + 14/12/2004 - 15:57:56 + 14/12/2004 - 15:57:56 + 1.05 + ? + ? + Compute Node + 767 + 102 + +? + ? + Switch + 6 + EndSwitch + +Switch + + +long + a + + +long + Odd + +int + Even + +int + a + + + +Switch + + + + + + 14/12/2004 - 15:57:56 + 14/12/2004 - 15:57:56 + 1.05 + ? + ? + Compute Node + 194 + 109 + +? + ? + EndSwitch + 7 + Switch + +EndSwitch + + +long + a + + +long + a + + + +EndSwitch + + + + + 14/12/2004 - 15:57:56 + 14/12/2004 - 15:57:56 + 1.05 + ? + ? + Compute Node + 587 + 103 + +? + ? + BadInputOfLoop + 3 + ? + +BadInputOfLoop + + + +boolean + InputInLoop + + + +BadInputOfLoop + + + + 14/12/2004 - 15:57:56 + 14/12/2004 - 15:57:56 + 2.0 + ? + ? + Compute Node + 15 + 307 + + +IsOdd + a + EndSwitch + a + + +576 + 136 + +575 + 81 + +InitLoop + DoLoop + EndOfInitLoop + DoLoop + + +InitLoop + Index + Switch + a + + +InitLoop + Min + EndOfInitLoop + Min + + +EndOfInitLoop + DoLoop + InitLoop + InitLoop + + +Switch + Odd + IsOdd + Gate + + +Switch + Even + EndSwitch + Default + + +Switch + Even + IsOdd + Even + + +375 + 111 + +375 + 172 + +Switch + a + IsOdd + a + + +362 + 82 + +360 + 201 + +EndSwitch + a + EndOfInitLoop + Index + + +BadInputOfLoop + InputInLoop + IsOdd + InputInLoop + + + +GraphBadInputInLoop2 + InitLoop__Index + InitLoop + Index + +3 + 0 + + +GraphBadInputInLoop2 + InitLoop__Min + InitLoop + Min + +3 + 0 + + +GraphBadInputInLoop2 + InitLoop__Max + InitLoop + Max + +3 + 100 + + +GraphBadInputInLoop2 + EndOfInitLoop__Max + EndOfInitLoop + Max + +3 + 136221856 + diff --git a/examples/GraphBadInputInLoop3.py b/examples/GraphBadInputInLoop3.py new file mode 100755 index 0000000..71c7c77 --- /dev/null +++ b/examples/GraphBadInputInLoop3.py @@ -0,0 +1,167 @@ + +# Generated python file of Graph GraphBadInputInLoop3 + +from SuperV import * + +# Graph creation of GraphBadInputInLoop3 +def DefGraphBadInputInLoop3() : + GraphBadInputInLoop3 = Graph( 'GraphBadInputInLoop3' ) + GraphBadInputInLoop3.SetName( 'GraphBadInputInLoop3' ) + GraphBadInputInLoop3.SetAuthor( '' ) + GraphBadInputInLoop3.SetComment( '' ) + GraphBadInputInLoop3.Coords( 0 , 0 ) + + # Creation of Factory Nodes + + # Creation of InLine Nodes + PyIsOdd = [] + PyIsOdd.append( 'from time import * ' ) + PyIsOdd.append( 'def IsOdd(a,Even,InputInLoop) : ' ) + PyIsOdd.append( ' print a,"IsOdd (GraphLoopSwitch1)" ' ) + PyIsOdd.append( ' sleep( 1 ) ' ) + PyIsOdd.append( ' return a ' ) + IsOdd = GraphBadInputInLoop3.INode( 'IsOdd' , PyIsOdd ) + IsOdd.SetName( 'IsOdd' ) + IsOdd.SetAuthor( '' ) + IsOdd.SetComment( 'Python function' ) + IsOdd.Coords( 397 , 1 ) + IIsOdda = IsOdd.InPort( 'a' , 'long' ) + IIsOddEven = IsOdd.InPort( 'Even' , 'boolean' ) + IIsOddInputInLoop = IsOdd.InPort( 'InputInLoop' , 'boolean' ) + IIsOddGate = IsOdd.GetInPort( 'Gate' ) + OIsOdda = IsOdd.OutPort( 'a' , 'long' ) + OIsOddGate = IsOdd.GetOutPort( 'Gate' ) + + PyBadInputOfLoop = [] + PyBadInputOfLoop.append( 'def BadInputOfLoop() : ' ) + PyBadInputOfLoop.append( ' return 1 ' ) + PyBadInputOfLoop.append( '' ) + BadInputOfLoop = GraphBadInputInLoop3.INode( 'BadInputOfLoop' , PyBadInputOfLoop ) + BadInputOfLoop.SetName( 'BadInputOfLoop' ) + BadInputOfLoop.SetAuthor( '' ) + BadInputOfLoop.SetComment( 'Compute Node' ) + BadInputOfLoop.Coords( 359 , 318 ) + IBadInputOfLoopGate = BadInputOfLoop.GetInPort( 'Gate' ) + OBadInputOfLoopInputInLoop = BadInputOfLoop.OutPort( 'InputInLoop' , 'boolean' ) + OBadInputOfLoopGate = BadInputOfLoop.GetOutPort( 'Gate' ) + + # Creation of Loop Nodes + PyInitLoop = [] + PyMoreInitLoop = [] + PyMoreInitLoop.append( '' ) + PyNextInitLoop = [] + PyNextInitLoop.append( '' ) + InitLoop,EndOfInitLoop = GraphBadInputInLoop3.LNode( '' , PyInitLoop , '' , PyMoreInitLoop , '' , PyNextInitLoop ) + EndOfInitLoop.SetName( 'EndOfInitLoop' ) + EndOfInitLoop.SetAuthor( '' ) + EndOfInitLoop.SetComment( 'Compute Node' ) + EndOfInitLoop.Coords( 767 , 102 ) + PyEndOfInitLoop = [] + PyEndOfInitLoop.append( 'def EndOfInitLoop( DoLoop , Index , Min , Max ) :' ) + PyEndOfInitLoop.append( ' Index = Index + 1 ' ) + PyEndOfInitLoop.append( ' if Index <= Max : ' ) + PyEndOfInitLoop.append( ' DoLoop = 1 ' ) + PyEndOfInitLoop.append( ' else : ' ) + PyEndOfInitLoop.append( ' DoLoop = 0 ' ) + PyEndOfInitLoop.append( ' return DoLoop,Index,Min,Max ' ) + EndOfInitLoop.SetPyFunction( 'EndOfInitLoop' , PyEndOfInitLoop ) + IInitLoopInitLoop = InitLoop.GetInPort( 'InitLoop' ) + IInitLoopIndex = InitLoop.InPort( 'Index' , 'long' ) + IInitLoopMin = InitLoop.InPort( 'Min' , 'long' ) + IInitLoopMax = InitLoop.InPort( 'Max' , 'long' ) + IInitLoopGate = InitLoop.GetInPort( 'Gate' ) + OInitLoopDoLoop = InitLoop.GetOutPort( 'DoLoop' ) + OInitLoopIndex = InitLoop.GetOutPort( 'Index' ) + OInitLoopMin = InitLoop.GetOutPort( 'Min' ) + OInitLoopMax = InitLoop.GetOutPort( 'Max' ) + IEndOfInitLoopDoLoop = EndOfInitLoop.GetInPort( 'DoLoop' ) + IEndOfInitLoopIndex = EndOfInitLoop.GetInPort( 'Index' ) + IEndOfInitLoopMin = EndOfInitLoop.GetInPort( 'Min' ) + IEndOfInitLoopMax = EndOfInitLoop.GetInPort( 'Max' ) + IEndOfInitLoopGate = EndOfInitLoop.GetInPort( 'Gate' ) + OEndOfInitLoopDoLoop = EndOfInitLoop.GetOutPort( 'DoLoop' ) + OEndOfInitLoopIndex = EndOfInitLoop.GetOutPort( 'Index' ) + OEndOfInitLoopMin = EndOfInitLoop.GetOutPort( 'Min' ) + OEndOfInitLoopMax = EndOfInitLoop.GetOutPort( 'Max' ) + InitLoop.SetName( 'InitLoop' ) + InitLoop.SetAuthor( '' ) + InitLoop.SetComment( 'Compute Node' ) + InitLoop.Coords( 10 , 108 ) + + # Creation of Switch Nodes + PySwitch = [] + PySwitch.append( 'from time import * ' ) + PySwitch.append( 'def Switch(a) : ' ) + PySwitch.append( ' if ( a & 1 ) == 0 : ' ) + PySwitch.append( ' sleep(1) ' ) + PySwitch.append( ' return a & 1,1-(a&1),a ' ) + Switch,EndSwitch = GraphBadInputInLoop3.SNode( 'Switch' , PySwitch ) + EndSwitch.SetName( 'EndSwitch' ) + EndSwitch.SetAuthor( '' ) + EndSwitch.SetComment( 'Compute Node' ) + EndSwitch.Coords( 587 , 103 ) + PyEndSwitch = [] + PyEndSwitch.append( 'def EndSwitch(a) : ' ) + PyEndSwitch.append( ' if ( a & 1 ) == 0 : ' ) + PyEndSwitch.append( ' sleep(1) ' ) + PyEndSwitch.append( ' return a ' ) + EndSwitch.SetPyFunction( 'EndSwitch' , PyEndSwitch ) + IEndSwitcha = EndSwitch.InPort( 'a' , 'long' ) + IEndSwitchDefault = EndSwitch.GetInPort( 'Default' ) + OEndSwitcha = EndSwitch.OutPort( 'a' , 'long' ) + OEndSwitchGate = EndSwitch.GetOutPort( 'Gate' ) + Switch.SetName( 'Switch' ) + Switch.SetAuthor( '' ) + Switch.SetComment( 'Compute Node' ) + Switch.Coords( 194 , 109 ) + ISwitcha = Switch.InPort( 'a' , 'long' ) + ISwitchGate = Switch.GetInPort( 'Gate' ) + OSwitchOdd = Switch.OutPort( 'Odd' , 'long' ) + OSwitchEven = Switch.OutPort( 'Even' , 'int' ) + OSwitcha = Switch.OutPort( 'a' , 'int' ) + OSwitchDefault = Switch.GetOutPort( 'Default' ) + + # Creation of Links + LIsOddaEndSwitcha = GraphBadInputInLoop3.Link( OIsOdda , IEndSwitcha ) + LIsOddaEndSwitcha.AddCoord( 1 , 576 , 136 ) + LIsOddaEndSwitcha.AddCoord( 2 , 575 , 81 ) + + LInitLoopIndexSwitcha = GraphBadInputInLoop3.Link( OInitLoopIndex , ISwitcha ) + + LInitLoopMinEndOfInitLoopMin = GraphBadInputInLoop3.Link( OInitLoopMin , IEndOfInitLoopMin ) + + LSwitchOddIsOddGate = GraphBadInputInLoop3.Link( OSwitchOdd , IIsOddGate ) + + LSwitchEvenEndSwitchDefault = GraphBadInputInLoop3.Link( OSwitchEven , IEndSwitchDefault ) + + LSwitchEvenIsOddEven = GraphBadInputInLoop3.Link( OSwitchEven , IIsOddEven ) + LSwitchEvenIsOddEven.AddCoord( 1 , 375 , 111 ) + LSwitchEvenIsOddEven.AddCoord( 2 , 375 , 172 ) + + LSwitchaIsOdda = GraphBadInputInLoop3.Link( OSwitcha , IIsOdda ) + LSwitchaIsOdda.AddCoord( 1 , 362 , 82 ) + LSwitchaIsOdda.AddCoord( 2 , 360 , 201 ) + + LEndSwitchaEndOfInitLoopIndex = GraphBadInputInLoop3.Link( OEndSwitcha , IEndOfInitLoopIndex ) + + LBadInputOfLoopGateEndOfInitLoopGate = GraphBadInputInLoop3.Link( OBadInputOfLoopGate , IEndOfInitLoopGate ) + + # Input datas + IInitLoopIndex.Input( 0 ) + IInitLoopMin.Input( 0 ) + IInitLoopMax.Input( 100 ) + IEndOfInitLoopMax.Input( 136221856 ) + + # Input Ports of the graph + #IIsOddInputInLoop = IsOdd.GetInPort( 'InputInLoop' ) + + # Output Ports of the graph + #OInitLoopMax = InitLoop.GetOutPort( 'Max' ) + #OEndOfInitLoopIndex = EndOfInitLoop.GetOutPort( 'Index' ) + #OEndOfInitLoopMin = EndOfInitLoop.GetOutPort( 'Min' ) + #OEndOfInitLoopMax = EndOfInitLoop.GetOutPort( 'Max' ) + #OBadInputOfLoopInputInLoop = BadInputOfLoop.GetOutPort( 'InputInLoop' ) + return GraphBadInputInLoop3 + + +GraphBadInputInLoop3 = DefGraphBadInputInLoop3() diff --git a/examples/GraphBadInputInLoop3.xml b/examples/GraphBadInputInLoop3.xml new file mode 100755 index 0000000..46199ef --- /dev/null +++ b/examples/GraphBadInputInLoop3.xml @@ -0,0 +1,409 @@ + + + + + +? + ? + GraphBadInputInLoop3 + 1 + ? + +GraphBadInputInLoop3 + + +boolean + IsOdd__InputInLoop + +long + InitLoop__Index + +long + InitLoop__Min + +long + InitLoop__Max + +long + EndOfInitLoop__Max + + +long + InitLoop__Max + +long + EndOfInitLoop__Index + +long + EndOfInitLoop__Min + +long + EndOfInitLoop__Max + +boolean + BadInputOfLoop__InputInLoop + + + 22/10/2003 - 10:36:39 + 14/12/2004 - 15:58:23 + 1.05 + ? + ? + ? + 0 + 0 + + +? + ? + IsOdd + 3 + ? + +IsOdd + + +long + a + +boolean + Even + +boolean + InputInLoop + + +long + a + + + +IsOdd + + + + + + 14/12/2004 - 15:58:23 + 14/12/2004 - 15:58:23 + 1.05 + ? + ? + Python function + 397 + 1 + +? + ? + InitLoop + 4 + EndOfInitLoop + +InitLoop + + +long + Index + +long + Min + +long + Max + + +long + Index + +long + Min + +long + Max + + + +? + + +? + + +? + + 14/12/2004 - 15:58:23 + 14/12/2004 - 15:58:23 + 1.05 + ? + ? + Compute Node + 10 + 108 + +? + ? + EndOfInitLoop + 5 + InitLoop + +EndOfInitLoop + + +long + Index + +long + Min + +long + Max + + +long + Index + +long + Min + +long + Max + + + +EndOfInitLoop + + + + + + + + 14/12/2004 - 15:58:23 + 14/12/2004 - 15:58:23 + 1.05 + ? + ? + Compute Node + 767 + 102 + +? + ? + Switch + 6 + EndSwitch + +Switch + + +long + a + + +long + Odd + +int + Even + +int + a + + + +Switch + + + + + + 14/12/2004 - 15:58:23 + 14/12/2004 - 15:58:23 + 1.05 + ? + ? + Compute Node + 194 + 109 + +? + ? + EndSwitch + 7 + Switch + +EndSwitch + + +long + a + + +long + a + + + +EndSwitch + + + + + 14/12/2004 - 15:58:23 + 14/12/2004 - 15:58:23 + 1.05 + ? + ? + Compute Node + 587 + 103 + +? + ? + BadInputOfLoop + 3 + ? + +BadInputOfLoop + + + +boolean + InputInLoop + + + +BadInputOfLoop + + + + 14/12/2004 - 15:58:23 + 14/12/2004 - 15:58:23 + 2.0 + ? + ? + Compute Node + 359 + 318 + + +IsOdd + a + EndSwitch + a + + +576 + 136 + +575 + 81 + +InitLoop + DoLoop + EndOfInitLoop + DoLoop + + +InitLoop + Index + Switch + a + + +InitLoop + Min + EndOfInitLoop + Min + + +EndOfInitLoop + DoLoop + InitLoop + InitLoop + + +Switch + Odd + IsOdd + Gate + + +Switch + Even + EndSwitch + Default + + +Switch + Even + IsOdd + Even + + +375 + 111 + +375 + 172 + +Switch + a + IsOdd + a + + +362 + 82 + +360 + 201 + +EndSwitch + a + EndOfInitLoop + Index + + +BadInputOfLoop + Gate + EndOfInitLoop + Gate + + + +GraphBadInputInLoop3 + InitLoop__Index + InitLoop + Index + +3 + 0 + + +GraphBadInputInLoop3 + InitLoop__Min + InitLoop + Min + +3 + 0 + + +GraphBadInputInLoop3 + InitLoop__Max + InitLoop + Max + +3 + 100 + + +GraphBadInputInLoop3 + EndOfInitLoop__Max + EndOfInitLoop + Max + +3 + 136221856 + diff --git a/examples/GraphBadOutputOfLoop.py b/examples/GraphBadOutputOfLoop.py new file mode 100755 index 0000000..28c91d9 --- /dev/null +++ b/examples/GraphBadOutputOfLoop.py @@ -0,0 +1,164 @@ + +# Generated python file of Graph GraphBadOutputOfLoop + +from SuperV import * + +# Graph creation of GraphBadOutputOfLoop +def DefGraphBadOutputOfLoop() : + GraphBadOutputOfLoop = Graph( 'GraphBadOutputOfLoop' ) + GraphBadOutputOfLoop.SetName( 'GraphBadOutputOfLoop' ) + GraphBadOutputOfLoop.SetAuthor( '' ) + GraphBadOutputOfLoop.SetComment( '' ) + GraphBadOutputOfLoop.Coords( 0 , 0 ) + + # Creation of Factory Nodes + + # Creation of InLine Nodes + PyIsOdd = [] + PyIsOdd.append( 'from time import * ' ) + PyIsOdd.append( 'def IsOdd(a,Even,InputInLoop) : ' ) + PyIsOdd.append( ' print a,"IsOdd (GraphLoopSwitch1)" ' ) + PyIsOdd.append( ' sleep( 1 ) ' ) + PyIsOdd.append( ' return a ' ) + IsOdd = GraphBadOutputOfLoop.INode( 'IsOdd' , PyIsOdd ) + IsOdd.SetName( 'IsOdd' ) + IsOdd.SetAuthor( '' ) + IsOdd.SetComment( 'Python function' ) + IsOdd.Coords( 397 , 1 ) + IIsOdda = IsOdd.InPort( 'a' , 'long' ) + IIsOddEven = IsOdd.InPort( 'Even' , 'boolean' ) + IIsOddInputInLoop = IsOdd.InPort( 'InputInLoop' , 'boolean' ) + IIsOddGate = IsOdd.GetInPort( 'Gate' ) + OIsOdda = IsOdd.OutPort( 'a' , 'long' ) + OIsOddGate = IsOdd.GetOutPort( 'Gate' ) + + PyBadOutputOfLoop = [] + PyBadOutputOfLoop.append( 'def BadOutputOfLoop() : ' ) + PyBadOutputOfLoop.append( ' return 1 ' ) + PyBadOutputOfLoop.append( '' ) + BadOutputOfLoop = GraphBadOutputOfLoop.INode( 'BadOutputOfLoop' , PyBadOutputOfLoop ) + BadOutputOfLoop.SetName( 'BadOutputOfLoop' ) + BadOutputOfLoop.SetAuthor( '' ) + BadOutputOfLoop.SetComment( 'Compute Node' ) + BadOutputOfLoop.Coords( 768 , 323 ) + IBadOutputOfLoopOutputOfLoop = BadOutputOfLoop.InPort( 'OutputOfLoop' , 'long' ) + IBadOutputOfLoopGate = BadOutputOfLoop.GetInPort( 'Gate' ) + OBadOutputOfLoopGate = BadOutputOfLoop.GetOutPort( 'Gate' ) + + # Creation of Loop Nodes + PyInitLoop = [] + PyMoreInitLoop = [] + PyMoreInitLoop.append( '' ) + PyNextInitLoop = [] + PyNextInitLoop.append( '' ) + InitLoop,EndOfInitLoop = GraphBadOutputOfLoop.LNode( '' , PyInitLoop , '' , PyMoreInitLoop , '' , PyNextInitLoop ) + EndOfInitLoop.SetName( 'EndOfInitLoop' ) + EndOfInitLoop.SetAuthor( '' ) + EndOfInitLoop.SetComment( 'Compute Node' ) + EndOfInitLoop.Coords( 767 , 102 ) + PyEndOfInitLoop = [] + PyEndOfInitLoop.append( 'def EndOfInitLoop( DoLoop , Index , Min , Max ) :' ) + PyEndOfInitLoop.append( ' Index = Index + 1 ' ) + PyEndOfInitLoop.append( ' if Index <= Max : ' ) + PyEndOfInitLoop.append( ' DoLoop = 1 ' ) + PyEndOfInitLoop.append( ' else : ' ) + PyEndOfInitLoop.append( ' DoLoop = 0 ' ) + PyEndOfInitLoop.append( ' return DoLoop,Index,Min,Max ' ) + EndOfInitLoop.SetPyFunction( 'EndOfInitLoop' , PyEndOfInitLoop ) + IInitLoopInitLoop = InitLoop.GetInPort( 'InitLoop' ) + IInitLoopIndex = InitLoop.InPort( 'Index' , 'long' ) + IInitLoopMin = InitLoop.InPort( 'Min' , 'long' ) + IInitLoopMax = InitLoop.InPort( 'Max' , 'long' ) + IInitLoopGate = InitLoop.GetInPort( 'Gate' ) + OInitLoopDoLoop = InitLoop.GetOutPort( 'DoLoop' ) + OInitLoopIndex = InitLoop.GetOutPort( 'Index' ) + OInitLoopMin = InitLoop.GetOutPort( 'Min' ) + OInitLoopMax = InitLoop.GetOutPort( 'Max' ) + IEndOfInitLoopDoLoop = EndOfInitLoop.GetInPort( 'DoLoop' ) + IEndOfInitLoopIndex = EndOfInitLoop.GetInPort( 'Index' ) + IEndOfInitLoopMin = EndOfInitLoop.GetInPort( 'Min' ) + IEndOfInitLoopMax = EndOfInitLoop.GetInPort( 'Max' ) + IEndOfInitLoopGate = EndOfInitLoop.GetInPort( 'Gate' ) + OEndOfInitLoopDoLoop = EndOfInitLoop.GetOutPort( 'DoLoop' ) + OEndOfInitLoopIndex = EndOfInitLoop.GetOutPort( 'Index' ) + OEndOfInitLoopMin = EndOfInitLoop.GetOutPort( 'Min' ) + OEndOfInitLoopMax = EndOfInitLoop.GetOutPort( 'Max' ) + InitLoop.SetName( 'InitLoop' ) + InitLoop.SetAuthor( '' ) + InitLoop.SetComment( 'Compute Node' ) + InitLoop.Coords( 10 , 108 ) + + # Creation of Switch Nodes + PySwitch = [] + PySwitch.append( 'from time import * ' ) + PySwitch.append( 'def Switch(a) : ' ) + PySwitch.append( ' if ( a & 1 ) == 0 : ' ) + PySwitch.append( ' sleep(1) ' ) + PySwitch.append( ' return a & 1,1-(a&1),a ' ) + Switch,EndSwitch = GraphBadOutputOfLoop.SNode( 'Switch' , PySwitch ) + EndSwitch.SetName( 'EndSwitch' ) + EndSwitch.SetAuthor( '' ) + EndSwitch.SetComment( 'Compute Node' ) + EndSwitch.Coords( 587 , 103 ) + PyEndSwitch = [] + PyEndSwitch.append( 'def EndSwitch(a) : ' ) + PyEndSwitch.append( ' if ( a & 1 ) == 0 : ' ) + PyEndSwitch.append( ' sleep(1) ' ) + PyEndSwitch.append( ' return a ' ) + EndSwitch.SetPyFunction( 'EndSwitch' , PyEndSwitch ) + IEndSwitcha = EndSwitch.InPort( 'a' , 'long' ) + IEndSwitchDefault = EndSwitch.GetInPort( 'Default' ) + OEndSwitcha = EndSwitch.OutPort( 'a' , 'long' ) + OEndSwitchGate = EndSwitch.GetOutPort( 'Gate' ) + Switch.SetName( 'Switch' ) + Switch.SetAuthor( '' ) + Switch.SetComment( 'Compute Node' ) + Switch.Coords( 194 , 109 ) + ISwitcha = Switch.InPort( 'a' , 'long' ) + ISwitchGate = Switch.GetInPort( 'Gate' ) + OSwitchOdd = Switch.OutPort( 'Odd' , 'long' ) + OSwitchEven = Switch.OutPort( 'Even' , 'int' ) + OSwitcha = Switch.OutPort( 'a' , 'int' ) + OSwitchDefault = Switch.GetOutPort( 'Default' ) + + # Creation of Links + LIsOddaEndSwitcha = GraphBadOutputOfLoop.Link( OIsOdda , IEndSwitcha ) + LIsOddaEndSwitcha.AddCoord( 1 , 576 , 136 ) + LIsOddaEndSwitcha.AddCoord( 2 , 575 , 81 ) + + LInitLoopIndexSwitcha = GraphBadOutputOfLoop.Link( OInitLoopIndex , ISwitcha ) + + LInitLoopMinEndOfInitLoopMin = GraphBadOutputOfLoop.Link( OInitLoopMin , IEndOfInitLoopMin ) + + LSwitchOddIsOddGate = GraphBadOutputOfLoop.Link( OSwitchOdd , IIsOddGate ) + + LSwitchEvenEndSwitchDefault = GraphBadOutputOfLoop.Link( OSwitchEven , IEndSwitchDefault ) + + LSwitchEvenIsOddEven = GraphBadOutputOfLoop.Link( OSwitchEven , IIsOddEven ) + LSwitchEvenIsOddEven.AddCoord( 1 , 375 , 111 ) + LSwitchEvenIsOddEven.AddCoord( 2 , 375 , 172 ) + + LSwitchaIsOdda = GraphBadOutputOfLoop.Link( OSwitcha , IIsOdda ) + LSwitchaIsOdda.AddCoord( 1 , 362 , 82 ) + LSwitchaIsOdda.AddCoord( 2 , 360 , 201 ) + + LEndSwitchaEndOfInitLoopIndex = GraphBadOutputOfLoop.Link( OEndSwitcha , IEndOfInitLoopIndex ) + + LEndSwitchaBadOutputOfLoopOutputOfLoop = GraphBadOutputOfLoop.Link( OEndSwitcha , IBadOutputOfLoopOutputOfLoop ) + + # Input datas + IIsOddInputInLoop.Input( 136306160 ) + IInitLoopIndex.Input( 0 ) + IInitLoopMin.Input( 0 ) + IInitLoopMax.Input( 100 ) + IEndOfInitLoopMax.Input( 136221856 ) + + # Output Ports of the graph + #OInitLoopMax = InitLoop.GetOutPort( 'Max' ) + #OEndOfInitLoopIndex = EndOfInitLoop.GetOutPort( 'Index' ) + #OEndOfInitLoopMin = EndOfInitLoop.GetOutPort( 'Min' ) + #OEndOfInitLoopMax = EndOfInitLoop.GetOutPort( 'Max' ) + return GraphBadOutputOfLoop + + +GraphBadOutputOfLoop = DefGraphBadOutputOfLoop() diff --git a/examples/GraphBadOutputOfLoop.xml b/examples/GraphBadOutputOfLoop.xml new file mode 100755 index 0000000..1965e84 --- /dev/null +++ b/examples/GraphBadOutputOfLoop.xml @@ -0,0 +1,415 @@ + + + + + +? + ? + GraphBadOutputOfLoop + 1 + ? + +GraphBadOutputOfLoop + + +boolean + IsOdd__InputInLoop + +long + InitLoop__Index + +long + InitLoop__Min + +long + InitLoop__Max + +long + EndOfInitLoop__Max + + +long + InitLoop__Max + +long + EndOfInitLoop__Index + +long + EndOfInitLoop__Min + +long + EndOfInitLoop__Max + + + 22/10/2003 - 10:36:39 + 14/12/2004 - 15:58:56 + 1.05 + ? + ? + ? + 0 + 0 + + +? + ? + IsOdd + 3 + ? + +IsOdd + + +long + a + +boolean + Even + +boolean + InputInLoop + + +long + a + + + +IsOdd + + + + + + 14/12/2004 - 15:58:56 + 14/12/2004 - 15:58:56 + 1.05 + ? + ? + Python function + 397 + 1 + +? + ? + InitLoop + 4 + EndOfInitLoop + +InitLoop + + +long + Index + +long + Min + +long + Max + + +long + Index + +long + Min + +long + Max + + + +? + + +? + + +? + + 14/12/2004 - 15:58:56 + 14/12/2004 - 15:58:56 + 1.05 + ? + ? + Compute Node + 10 + 108 + +? + ? + EndOfInitLoop + 5 + InitLoop + +EndOfInitLoop + + +long + Index + +long + Min + +long + Max + + +long + Index + +long + Min + +long + Max + + + +EndOfInitLoop + + + + + + + + 14/12/2004 - 15:58:56 + 14/12/2004 - 15:58:56 + 1.05 + ? + ? + Compute Node + 767 + 102 + +? + ? + Switch + 6 + EndSwitch + +Switch + + +long + a + + +long + Odd + +int + Even + +int + a + + + +Switch + + + + + + 14/12/2004 - 15:58:56 + 14/12/2004 - 15:58:56 + 1.05 + ? + ? + Compute Node + 194 + 109 + +? + ? + EndSwitch + 7 + Switch + +EndSwitch + + +long + a + + +long + a + + + +EndSwitch + + + + + 14/12/2004 - 15:58:56 + 14/12/2004 - 15:58:56 + 1.05 + ? + ? + Compute Node + 587 + 103 + +? + ? + BadOutputOfLoop + 3 + ? + +BadOutputOfLoop + + +long + OutputOfLoop + + + + +BadOutputOfLoop + + + + 14/12/2004 - 15:58:56 + 14/12/2004 - 15:58:56 + 2.0 + ? + ? + Compute Node + 768 + 323 + + +IsOdd + a + EndSwitch + a + + +576 + 136 + +575 + 81 + +InitLoop + DoLoop + EndOfInitLoop + DoLoop + + +InitLoop + Index + Switch + a + + +InitLoop + Min + EndOfInitLoop + Min + + +EndOfInitLoop + DoLoop + InitLoop + InitLoop + + +Switch + Odd + IsOdd + Gate + + +Switch + Even + EndSwitch + Default + + +Switch + Even + IsOdd + Even + + +375 + 111 + +375 + 172 + +Switch + a + IsOdd + a + + +362 + 82 + +360 + 201 + +EndSwitch + a + EndOfInitLoop + Index + + +EndSwitch + a + BadOutputOfLoop + OutputOfLoop + + + +GraphBadOutputOfLoop + IsOdd__InputInLoop + IsOdd + InputInLoop + +3 + 136306160 + + +GraphBadOutputOfLoop + InitLoop__Index + InitLoop + Index + +3 + 0 + + +GraphBadOutputOfLoop + InitLoop__Min + InitLoop + Min + +3 + 0 + + +GraphBadOutputOfLoop + InitLoop__Max + InitLoop + Max + +3 + 100 + + +GraphBadOutputOfLoop + EndOfInitLoop__Max + EndOfInitLoop + Max + +3 + 136221856 + diff --git a/examples/GraphBadOutputOfLoop1.py b/examples/GraphBadOutputOfLoop1.py new file mode 100755 index 0000000..3405c93 --- /dev/null +++ b/examples/GraphBadOutputOfLoop1.py @@ -0,0 +1,163 @@ + +# Generated python file of Graph GraphBadOutputOfLoop1 + +from SuperV import * + +# Graph creation of GraphBadOutputOfLoop1 +def DefGraphBadOutputOfLoop1() : + GraphBadOutputOfLoop1 = Graph( 'GraphBadOutputOfLoop1' ) + GraphBadOutputOfLoop1.SetName( 'GraphBadOutputOfLoop1' ) + GraphBadOutputOfLoop1.SetAuthor( '' ) + GraphBadOutputOfLoop1.SetComment( '' ) + GraphBadOutputOfLoop1.Coords( 0 , 0 ) + + # Creation of Factory Nodes + + # Creation of InLine Nodes + PyIsOdd = [] + PyIsOdd.append( 'from time import * ' ) + PyIsOdd.append( 'def IsOdd(a,Even,InputInLoop) : ' ) + PyIsOdd.append( ' print a,"IsOdd (GraphLoopSwitch1)" ' ) + PyIsOdd.append( ' sleep( 1 ) ' ) + PyIsOdd.append( ' return a ' ) + IsOdd = GraphBadOutputOfLoop1.INode( 'IsOdd' , PyIsOdd ) + IsOdd.SetName( 'IsOdd' ) + IsOdd.SetAuthor( '' ) + IsOdd.SetComment( 'Python function' ) + IsOdd.Coords( 397 , 1 ) + IIsOdda = IsOdd.InPort( 'a' , 'long' ) + IIsOddEven = IsOdd.InPort( 'Even' , 'boolean' ) + IIsOddInputInLoop = IsOdd.InPort( 'InputInLoop' , 'boolean' ) + IIsOddGate = IsOdd.GetInPort( 'Gate' ) + OIsOdda = IsOdd.OutPort( 'a' , 'long' ) + OIsOddGate = IsOdd.GetOutPort( 'Gate' ) + + PyBadOutputOfLoop = [] + PyBadOutputOfLoop.append( 'def BadOutputOfLoop() : ' ) + PyBadOutputOfLoop.append( ' return 1 ' ) + PyBadOutputOfLoop.append( '' ) + BadOutputOfLoop = GraphBadOutputOfLoop1.INode( 'BadOutputOfLoop' , PyBadOutputOfLoop ) + BadOutputOfLoop.SetName( 'BadOutputOfLoop' ) + BadOutputOfLoop.SetAuthor( '' ) + BadOutputOfLoop.SetComment( 'Compute Node' ) + BadOutputOfLoop.Coords( 287 , 349 ) + IBadOutputOfLoopOutputOfLoop = BadOutputOfLoop.InPort( 'OutputOfLoop' , 'long' ) + IBadOutputOfLoopGate = BadOutputOfLoop.GetInPort( 'Gate' ) + OBadOutputOfLoopGate = BadOutputOfLoop.GetOutPort( 'Gate' ) + + # Creation of Loop Nodes + PyInitLoop = [] + PyMoreInitLoop = [] + PyMoreInitLoop.append( '' ) + PyNextInitLoop = [] + PyNextInitLoop.append( '' ) + InitLoop,EndOfInitLoop = GraphBadOutputOfLoop1.LNode( '' , PyInitLoop , '' , PyMoreInitLoop , '' , PyNextInitLoop ) + EndOfInitLoop.SetName( 'EndOfInitLoop' ) + EndOfInitLoop.SetAuthor( '' ) + EndOfInitLoop.SetComment( 'Compute Node' ) + EndOfInitLoop.Coords( 767 , 102 ) + PyEndOfInitLoop = [] + PyEndOfInitLoop.append( 'def EndOfInitLoop( DoLoop , Index , Min , Max ) :' ) + PyEndOfInitLoop.append( ' Index = Index + 1 ' ) + PyEndOfInitLoop.append( ' if Index <= Max : ' ) + PyEndOfInitLoop.append( ' DoLoop = 1 ' ) + PyEndOfInitLoop.append( ' else : ' ) + PyEndOfInitLoop.append( ' DoLoop = 0 ' ) + PyEndOfInitLoop.append( ' return DoLoop,Index,Min,Max ' ) + EndOfInitLoop.SetPyFunction( 'EndOfInitLoop' , PyEndOfInitLoop ) + IInitLoopInitLoop = InitLoop.GetInPort( 'InitLoop' ) + IInitLoopIndex = InitLoop.InPort( 'Index' , 'long' ) + IInitLoopMin = InitLoop.InPort( 'Min' , 'long' ) + IInitLoopMax = InitLoop.InPort( 'Max' , 'long' ) + IInitLoopGate = InitLoop.GetInPort( 'Gate' ) + OInitLoopDoLoop = InitLoop.GetOutPort( 'DoLoop' ) + OInitLoopIndex = InitLoop.GetOutPort( 'Index' ) + OInitLoopMin = InitLoop.GetOutPort( 'Min' ) + OInitLoopMax = InitLoop.GetOutPort( 'Max' ) + IEndOfInitLoopDoLoop = EndOfInitLoop.GetInPort( 'DoLoop' ) + IEndOfInitLoopIndex = EndOfInitLoop.GetInPort( 'Index' ) + IEndOfInitLoopMin = EndOfInitLoop.GetInPort( 'Min' ) + IEndOfInitLoopMax = EndOfInitLoop.GetInPort( 'Max' ) + IEndOfInitLoopGate = EndOfInitLoop.GetInPort( 'Gate' ) + OEndOfInitLoopDoLoop = EndOfInitLoop.GetOutPort( 'DoLoop' ) + OEndOfInitLoopIndex = EndOfInitLoop.GetOutPort( 'Index' ) + OEndOfInitLoopMin = EndOfInitLoop.GetOutPort( 'Min' ) + OEndOfInitLoopMax = EndOfInitLoop.GetOutPort( 'Max' ) + InitLoop.SetName( 'InitLoop' ) + InitLoop.SetAuthor( '' ) + InitLoop.SetComment( 'Compute Node' ) + InitLoop.Coords( 10 , 108 ) + + # Creation of Switch Nodes + PySwitch = [] + PySwitch.append( 'from time import * ' ) + PySwitch.append( 'def Switch(a) : ' ) + PySwitch.append( ' if ( a & 1 ) == 0 : ' ) + PySwitch.append( ' sleep(1) ' ) + PySwitch.append( ' return a & 1,1-(a&1),a ' ) + Switch,EndSwitch = GraphBadOutputOfLoop1.SNode( 'Switch' , PySwitch ) + EndSwitch.SetName( 'EndSwitch' ) + EndSwitch.SetAuthor( '' ) + EndSwitch.SetComment( 'Compute Node' ) + EndSwitch.Coords( 587 , 103 ) + PyEndSwitch = [] + PyEndSwitch.append( 'def EndSwitch(a) : ' ) + PyEndSwitch.append( ' if ( a & 1 ) == 0 : ' ) + PyEndSwitch.append( ' sleep(1) ' ) + PyEndSwitch.append( ' return a ' ) + EndSwitch.SetPyFunction( 'EndSwitch' , PyEndSwitch ) + IEndSwitcha = EndSwitch.InPort( 'a' , 'long' ) + IEndSwitchDefault = EndSwitch.GetInPort( 'Default' ) + OEndSwitcha = EndSwitch.OutPort( 'a' , 'long' ) + OEndSwitchGate = EndSwitch.GetOutPort( 'Gate' ) + Switch.SetName( 'Switch' ) + Switch.SetAuthor( '' ) + Switch.SetComment( 'Compute Node' ) + Switch.Coords( 194 , 109 ) + ISwitcha = Switch.InPort( 'a' , 'long' ) + ISwitchGate = Switch.GetInPort( 'Gate' ) + OSwitchOdd = Switch.OutPort( 'Odd' , 'long' ) + OSwitchEven = Switch.OutPort( 'Even' , 'int' ) + OSwitcha = Switch.OutPort( 'a' , 'int' ) + OSwitchDefault = Switch.GetOutPort( 'Default' ) + + # Creation of Links + LIsOddaEndSwitcha = GraphBadOutputOfLoop1.Link( OIsOdda , IEndSwitcha ) + LIsOddaEndSwitcha.AddCoord( 1 , 576 , 136 ) + LIsOddaEndSwitcha.AddCoord( 2 , 575 , 81 ) + + LInitLoopIndexSwitcha = GraphBadOutputOfLoop1.Link( OInitLoopIndex , ISwitcha ) + + LInitLoopMinEndOfInitLoopMin = GraphBadOutputOfLoop1.Link( OInitLoopMin , IEndOfInitLoopMin ) + + LInitLoopMaxBadOutputOfLoopOutputOfLoop = GraphBadOutputOfLoop1.Link( OInitLoopMax , IBadOutputOfLoopOutputOfLoop ) + + LSwitchOddIsOddGate = GraphBadOutputOfLoop1.Link( OSwitchOdd , IIsOddGate ) + + LSwitchEvenEndSwitchDefault = GraphBadOutputOfLoop1.Link( OSwitchEven , IEndSwitchDefault ) + + LSwitchEvenIsOddEven = GraphBadOutputOfLoop1.Link( OSwitchEven , IIsOddEven ) + LSwitchEvenIsOddEven.AddCoord( 1 , 375 , 111 ) + LSwitchEvenIsOddEven.AddCoord( 2 , 375 , 172 ) + + LSwitchaIsOdda = GraphBadOutputOfLoop1.Link( OSwitcha , IIsOdda ) + LSwitchaIsOdda.AddCoord( 1 , 362 , 82 ) + LSwitchaIsOdda.AddCoord( 2 , 360 , 201 ) + + LEndSwitchaEndOfInitLoopIndex = GraphBadOutputOfLoop1.Link( OEndSwitcha , IEndOfInitLoopIndex ) + + # Input datas + IIsOddInputInLoop.Input( 136306160 ) + IInitLoopIndex.Input( 0 ) + IInitLoopMin.Input( 0 ) + IInitLoopMax.Input( 100 ) + IEndOfInitLoopMax.Input( 136221856 ) + + # Output Ports of the graph + #OEndOfInitLoopIndex = EndOfInitLoop.GetOutPort( 'Index' ) + #OEndOfInitLoopMin = EndOfInitLoop.GetOutPort( 'Min' ) + #OEndOfInitLoopMax = EndOfInitLoop.GetOutPort( 'Max' ) + return GraphBadOutputOfLoop1 + + +GraphBadOutputOfLoop1 = DefGraphBadOutputOfLoop1() diff --git a/examples/GraphBadOutputOfLoop1.xml b/examples/GraphBadOutputOfLoop1.xml new file mode 100755 index 0000000..6f0ed94 --- /dev/null +++ b/examples/GraphBadOutputOfLoop1.xml @@ -0,0 +1,412 @@ + + + + + +? + ? + GraphBadOutputOfLoop1 + 1 + ? + +GraphBadOutputOfLoop1 + + +boolean + IsOdd__InputInLoop + +long + InitLoop__Index + +long + InitLoop__Min + +long + InitLoop__Max + +long + EndOfInitLoop__Max + + +long + EndOfInitLoop__Index + +long + EndOfInitLoop__Min + +long + EndOfInitLoop__Max + + + 22/10/2003 - 10:36:39 + 14/12/2004 - 15:59:22 + 1.05 + ? + ? + ? + 0 + 0 + + +? + ? + IsOdd + 3 + ? + +IsOdd + + +long + a + +boolean + Even + +boolean + InputInLoop + + +long + a + + + +IsOdd + + + + + + 14/12/2004 - 15:59:22 + 14/12/2004 - 15:59:22 + 1.05 + ? + ? + Python function + 397 + 1 + +? + ? + InitLoop + 4 + EndOfInitLoop + +InitLoop + + +long + Index + +long + Min + +long + Max + + +long + Index + +long + Min + +long + Max + + + +? + + +? + + +? + + 14/12/2004 - 15:59:22 + 14/12/2004 - 15:59:22 + 1.05 + ? + ? + Compute Node + 10 + 108 + +? + ? + EndOfInitLoop + 5 + InitLoop + +EndOfInitLoop + + +long + Index + +long + Min + +long + Max + + +long + Index + +long + Min + +long + Max + + + +EndOfInitLoop + + + + + + + + 14/12/2004 - 15:59:22 + 14/12/2004 - 15:59:22 + 1.05 + ? + ? + Compute Node + 767 + 102 + +? + ? + Switch + 6 + EndSwitch + +Switch + + +long + a + + +long + Odd + +int + Even + +int + a + + + +Switch + + + + + + 14/12/2004 - 15:59:22 + 14/12/2004 - 15:59:22 + 1.05 + ? + ? + Compute Node + 194 + 109 + +? + ? + EndSwitch + 7 + Switch + +EndSwitch + + +long + a + + +long + a + + + +EndSwitch + + + + + 14/12/2004 - 15:59:22 + 14/12/2004 - 15:59:22 + 1.05 + ? + ? + Compute Node + 587 + 103 + +? + ? + BadOutputOfLoop + 3 + ? + +BadOutputOfLoop + + +long + OutputOfLoop + + + + +BadOutputOfLoop + + + + 14/12/2004 - 15:59:22 + 14/12/2004 - 15:59:22 + 2.0 + ? + ? + Compute Node + 287 + 349 + + +IsOdd + a + EndSwitch + a + + +576 + 136 + +575 + 81 + +InitLoop + DoLoop + EndOfInitLoop + DoLoop + + +InitLoop + Index + Switch + a + + +InitLoop + Min + EndOfInitLoop + Min + + +InitLoop + Max + BadOutputOfLoop + OutputOfLoop + + +EndOfInitLoop + DoLoop + InitLoop + InitLoop + + +Switch + Odd + IsOdd + Gate + + +Switch + Even + EndSwitch + Default + + +Switch + Even + IsOdd + Even + + +375 + 111 + +375 + 172 + +Switch + a + IsOdd + a + + +362 + 82 + +360 + 201 + +EndSwitch + a + EndOfInitLoop + Index + + + +GraphBadOutputOfLoop1 + IsOdd__InputInLoop + IsOdd + InputInLoop + +3 + 136306160 + + +GraphBadOutputOfLoop1 + InitLoop__Index + InitLoop + Index + +3 + 0 + + +GraphBadOutputOfLoop1 + InitLoop__Min + InitLoop + Min + +3 + 0 + + +GraphBadOutputOfLoop1 + InitLoop__Max + InitLoop + Max + +3 + 100 + + +GraphBadOutputOfLoop1 + EndOfInitLoop__Max + EndOfInitLoop + Max + +3 + 136221856 + diff --git a/examples/GraphBadOutputOfLoop2.py b/examples/GraphBadOutputOfLoop2.py new file mode 100755 index 0000000..a0a71f1 --- /dev/null +++ b/examples/GraphBadOutputOfLoop2.py @@ -0,0 +1,164 @@ + +# Generated python file of Graph GraphBadOutputOfLoop2 + +from SuperV import * + +# Graph creation of GraphBadOutputOfLoop2 +def DefGraphBadOutputOfLoop2() : + GraphBadOutputOfLoop2 = Graph( 'GraphBadOutputOfLoop2' ) + GraphBadOutputOfLoop2.SetName( 'GraphBadOutputOfLoop2' ) + GraphBadOutputOfLoop2.SetAuthor( '' ) + GraphBadOutputOfLoop2.SetComment( '' ) + GraphBadOutputOfLoop2.Coords( 0 , 0 ) + + # Creation of Factory Nodes + + # Creation of InLine Nodes + PyIsOdd = [] + PyIsOdd.append( 'from time import * ' ) + PyIsOdd.append( 'def IsOdd(a,Even,InputInLoop) : ' ) + PyIsOdd.append( ' print a,"IsOdd (GraphLoopSwitch1)" ' ) + PyIsOdd.append( ' sleep( 1 ) ' ) + PyIsOdd.append( ' return a ' ) + IsOdd = GraphBadOutputOfLoop2.INode( 'IsOdd' , PyIsOdd ) + IsOdd.SetName( 'IsOdd' ) + IsOdd.SetAuthor( '' ) + IsOdd.SetComment( 'Python function' ) + IsOdd.Coords( 397 , 1 ) + IIsOdda = IsOdd.InPort( 'a' , 'long' ) + IIsOddEven = IsOdd.InPort( 'Even' , 'boolean' ) + IIsOddInputInLoop = IsOdd.InPort( 'InputInLoop' , 'boolean' ) + IIsOddGate = IsOdd.GetInPort( 'Gate' ) + OIsOdda = IsOdd.OutPort( 'a' , 'long' ) + OIsOddGate = IsOdd.GetOutPort( 'Gate' ) + + PyBadOutputOfLoop = [] + PyBadOutputOfLoop.append( 'def BadOutputOfLoop() : ' ) + PyBadOutputOfLoop.append( ' return 1 ' ) + PyBadOutputOfLoop.append( '' ) + BadOutputOfLoop = GraphBadOutputOfLoop2.INode( 'BadOutputOfLoop' , PyBadOutputOfLoop ) + BadOutputOfLoop.SetName( 'BadOutputOfLoop' ) + BadOutputOfLoop.SetAuthor( '' ) + BadOutputOfLoop.SetComment( 'Compute Node' ) + BadOutputOfLoop.Coords( 503 , 338 ) + IBadOutputOfLoopOutputOfLoop = BadOutputOfLoop.InPort( 'OutputOfLoop' , 'long' ) + IBadOutputOfLoopGate = BadOutputOfLoop.GetInPort( 'Gate' ) + OBadOutputOfLoopGate = BadOutputOfLoop.GetOutPort( 'Gate' ) + + # Creation of Loop Nodes + PyInitLoop = [] + PyMoreInitLoop = [] + PyMoreInitLoop.append( '' ) + PyNextInitLoop = [] + PyNextInitLoop.append( '' ) + InitLoop,EndOfInitLoop = GraphBadOutputOfLoop2.LNode( '' , PyInitLoop , '' , PyMoreInitLoop , '' , PyNextInitLoop ) + EndOfInitLoop.SetName( 'EndOfInitLoop' ) + EndOfInitLoop.SetAuthor( '' ) + EndOfInitLoop.SetComment( 'Compute Node' ) + EndOfInitLoop.Coords( 767 , 102 ) + PyEndOfInitLoop = [] + PyEndOfInitLoop.append( 'def EndOfInitLoop( DoLoop , Index , Min , Max ) :' ) + PyEndOfInitLoop.append( ' Index = Index + 1 ' ) + PyEndOfInitLoop.append( ' if Index <= Max : ' ) + PyEndOfInitLoop.append( ' DoLoop = 1 ' ) + PyEndOfInitLoop.append( ' else : ' ) + PyEndOfInitLoop.append( ' DoLoop = 0 ' ) + PyEndOfInitLoop.append( ' return DoLoop,Index,Min,Max ' ) + EndOfInitLoop.SetPyFunction( 'EndOfInitLoop' , PyEndOfInitLoop ) + IInitLoopInitLoop = InitLoop.GetInPort( 'InitLoop' ) + IInitLoopIndex = InitLoop.InPort( 'Index' , 'long' ) + IInitLoopMin = InitLoop.InPort( 'Min' , 'long' ) + IInitLoopMax = InitLoop.InPort( 'Max' , 'long' ) + IInitLoopGate = InitLoop.GetInPort( 'Gate' ) + OInitLoopDoLoop = InitLoop.GetOutPort( 'DoLoop' ) + OInitLoopIndex = InitLoop.GetOutPort( 'Index' ) + OInitLoopMin = InitLoop.GetOutPort( 'Min' ) + OInitLoopMax = InitLoop.GetOutPort( 'Max' ) + IEndOfInitLoopDoLoop = EndOfInitLoop.GetInPort( 'DoLoop' ) + IEndOfInitLoopIndex = EndOfInitLoop.GetInPort( 'Index' ) + IEndOfInitLoopMin = EndOfInitLoop.GetInPort( 'Min' ) + IEndOfInitLoopMax = EndOfInitLoop.GetInPort( 'Max' ) + IEndOfInitLoopGate = EndOfInitLoop.GetInPort( 'Gate' ) + OEndOfInitLoopDoLoop = EndOfInitLoop.GetOutPort( 'DoLoop' ) + OEndOfInitLoopIndex = EndOfInitLoop.GetOutPort( 'Index' ) + OEndOfInitLoopMin = EndOfInitLoop.GetOutPort( 'Min' ) + OEndOfInitLoopMax = EndOfInitLoop.GetOutPort( 'Max' ) + InitLoop.SetName( 'InitLoop' ) + InitLoop.SetAuthor( '' ) + InitLoop.SetComment( 'Compute Node' ) + InitLoop.Coords( 10 , 108 ) + + # Creation of Switch Nodes + PySwitch = [] + PySwitch.append( 'from time import * ' ) + PySwitch.append( 'def Switch(a) : ' ) + PySwitch.append( ' if ( a & 1 ) == 0 : ' ) + PySwitch.append( ' sleep(1) ' ) + PySwitch.append( ' return a & 1,1-(a&1),a ' ) + Switch,EndSwitch = GraphBadOutputOfLoop2.SNode( 'Switch' , PySwitch ) + EndSwitch.SetName( 'EndSwitch' ) + EndSwitch.SetAuthor( '' ) + EndSwitch.SetComment( 'Compute Node' ) + EndSwitch.Coords( 587 , 103 ) + PyEndSwitch = [] + PyEndSwitch.append( 'def EndSwitch(a) : ' ) + PyEndSwitch.append( ' if ( a & 1 ) == 0 : ' ) + PyEndSwitch.append( ' sleep(1) ' ) + PyEndSwitch.append( ' return a ' ) + EndSwitch.SetPyFunction( 'EndSwitch' , PyEndSwitch ) + IEndSwitcha = EndSwitch.InPort( 'a' , 'long' ) + IEndSwitchDefault = EndSwitch.GetInPort( 'Default' ) + OEndSwitcha = EndSwitch.OutPort( 'a' , 'long' ) + OEndSwitchGate = EndSwitch.GetOutPort( 'Gate' ) + Switch.SetName( 'Switch' ) + Switch.SetAuthor( '' ) + Switch.SetComment( 'Compute Node' ) + Switch.Coords( 194 , 109 ) + ISwitcha = Switch.InPort( 'a' , 'long' ) + ISwitchGate = Switch.GetInPort( 'Gate' ) + OSwitchOdd = Switch.OutPort( 'Odd' , 'long' ) + OSwitchEven = Switch.OutPort( 'Even' , 'int' ) + OSwitcha = Switch.OutPort( 'a' , 'int' ) + OSwitchDefault = Switch.GetOutPort( 'Default' ) + + # Creation of Links + LIsOddaEndSwitcha = GraphBadOutputOfLoop2.Link( OIsOdda , IEndSwitcha ) + LIsOddaEndSwitcha.AddCoord( 1 , 576 , 136 ) + LIsOddaEndSwitcha.AddCoord( 2 , 575 , 81 ) + + LInitLoopIndexSwitcha = GraphBadOutputOfLoop2.Link( OInitLoopIndex , ISwitcha ) + + LInitLoopMinEndOfInitLoopMin = GraphBadOutputOfLoop2.Link( OInitLoopMin , IEndOfInitLoopMin ) + + LSwitchOddIsOddGate = GraphBadOutputOfLoop2.Link( OSwitchOdd , IIsOddGate ) + + LSwitchEvenEndSwitchDefault = GraphBadOutputOfLoop2.Link( OSwitchEven , IEndSwitchDefault ) + + LSwitchEvenIsOddEven = GraphBadOutputOfLoop2.Link( OSwitchEven , IIsOddEven ) + LSwitchEvenIsOddEven.AddCoord( 1 , 375 , 111 ) + LSwitchEvenIsOddEven.AddCoord( 2 , 375 , 172 ) + + LSwitchaIsOdda = GraphBadOutputOfLoop2.Link( OSwitcha , IIsOdda ) + LSwitchaIsOdda.AddCoord( 1 , 362 , 82 ) + LSwitchaIsOdda.AddCoord( 2 , 360 , 201 ) + + LSwitchaBadOutputOfLoopOutputOfLoop = GraphBadOutputOfLoop2.Link( OSwitcha , IBadOutputOfLoopOutputOfLoop ) + + LEndSwitchaEndOfInitLoopIndex = GraphBadOutputOfLoop2.Link( OEndSwitcha , IEndOfInitLoopIndex ) + + # Input datas + IIsOddInputInLoop.Input( 136306160 ) + IInitLoopIndex.Input( 0 ) + IInitLoopMin.Input( 0 ) + IInitLoopMax.Input( 100 ) + IEndOfInitLoopMax.Input( 136221856 ) + + # Output Ports of the graph + #OInitLoopMax = InitLoop.GetOutPort( 'Max' ) + #OEndOfInitLoopIndex = EndOfInitLoop.GetOutPort( 'Index' ) + #OEndOfInitLoopMin = EndOfInitLoop.GetOutPort( 'Min' ) + #OEndOfInitLoopMax = EndOfInitLoop.GetOutPort( 'Max' ) + return GraphBadOutputOfLoop2 + + +GraphBadOutputOfLoop2 = DefGraphBadOutputOfLoop2() diff --git a/examples/GraphBadOutputOfLoop2.xml b/examples/GraphBadOutputOfLoop2.xml new file mode 100755 index 0000000..83617b0 --- /dev/null +++ b/examples/GraphBadOutputOfLoop2.xml @@ -0,0 +1,415 @@ + + + + + +? + ? + GraphBadOutputOfLoop2 + 1 + ? + +GraphBadOutputOfLoop2 + + +boolean + IsOdd__InputInLoop + +long + InitLoop__Index + +long + InitLoop__Min + +long + InitLoop__Max + +long + EndOfInitLoop__Max + + +long + InitLoop__Max + +long + EndOfInitLoop__Index + +long + EndOfInitLoop__Min + +long + EndOfInitLoop__Max + + + 22/10/2003 - 10:36:39 + 14/12/2004 - 15:59:49 + 1.05 + ? + ? + ? + 0 + 0 + + +? + ? + IsOdd + 3 + ? + +IsOdd + + +long + a + +boolean + Even + +boolean + InputInLoop + + +long + a + + + +IsOdd + + + + + + 14/12/2004 - 15:59:49 + 14/12/2004 - 15:59:49 + 1.05 + ? + ? + Python function + 397 + 1 + +? + ? + InitLoop + 4 + EndOfInitLoop + +InitLoop + + +long + Index + +long + Min + +long + Max + + +long + Index + +long + Min + +long + Max + + + +? + + +? + + +? + + 14/12/2004 - 15:59:49 + 14/12/2004 - 15:59:49 + 1.05 + ? + ? + Compute Node + 10 + 108 + +? + ? + EndOfInitLoop + 5 + InitLoop + +EndOfInitLoop + + +long + Index + +long + Min + +long + Max + + +long + Index + +long + Min + +long + Max + + + +EndOfInitLoop + + + + + + + + 14/12/2004 - 15:59:49 + 14/12/2004 - 15:59:49 + 1.05 + ? + ? + Compute Node + 767 + 102 + +? + ? + Switch + 6 + EndSwitch + +Switch + + +long + a + + +long + Odd + +int + Even + +int + a + + + +Switch + + + + + + 14/12/2004 - 15:59:49 + 14/12/2004 - 15:59:49 + 1.05 + ? + ? + Compute Node + 194 + 109 + +? + ? + EndSwitch + 7 + Switch + +EndSwitch + + +long + a + + +long + a + + + +EndSwitch + + + + + 14/12/2004 - 15:59:49 + 14/12/2004 - 15:59:49 + 1.05 + ? + ? + Compute Node + 587 + 103 + +? + ? + BadOutputOfLoop + 3 + ? + +BadOutputOfLoop + + +long + OutputOfLoop + + + + +BadOutputOfLoop + + + + 14/12/2004 - 15:59:49 + 14/12/2004 - 15:59:49 + 2.0 + ? + ? + Compute Node + 503 + 338 + + +IsOdd + a + EndSwitch + a + + +576 + 136 + +575 + 81 + +InitLoop + DoLoop + EndOfInitLoop + DoLoop + + +InitLoop + Index + Switch + a + + +InitLoop + Min + EndOfInitLoop + Min + + +EndOfInitLoop + DoLoop + InitLoop + InitLoop + + +Switch + Odd + IsOdd + Gate + + +Switch + Even + EndSwitch + Default + + +Switch + Even + IsOdd + Even + + +375 + 111 + +375 + 172 + +Switch + a + IsOdd + a + + +362 + 82 + +360 + 201 + +Switch + a + BadOutputOfLoop + OutputOfLoop + + +EndSwitch + a + EndOfInitLoop + Index + + + +GraphBadOutputOfLoop2 + IsOdd__InputInLoop + IsOdd + InputInLoop + +3 + 136306160 + + +GraphBadOutputOfLoop2 + InitLoop__Index + InitLoop + Index + +3 + 0 + + +GraphBadOutputOfLoop2 + InitLoop__Min + InitLoop + Min + +3 + 0 + + +GraphBadOutputOfLoop2 + InitLoop__Max + InitLoop + Max + +3 + 100 + + +GraphBadOutputOfLoop2 + EndOfInitLoop__Max + EndOfInitLoop + Max + +3 + 136221856 + diff --git a/examples/GraphConvertObjRefCheck.py b/examples/GraphConvertObjRefCheck.py index 55a45ae..08908c7 100755 --- a/examples/GraphConvertObjRefCheck.py +++ b/examples/GraphConvertObjRefCheck.py @@ -2,77 +2,105 @@ # Generated python file of Graph GraphConvertObjRefCheck from SuperV import * -# Graph creation -GraphConvertObjRefCheck = Graph( 'GraphConvertObjRefCheck' ) -GraphConvertObjRefCheck.SetName( 'GraphConvertObjRefCheck' ) -GraphConvertObjRefCheck.SetAuthor( 'JR' ) -GraphConvertObjRefCheck.SetComment( 'Check conversions of ObjRef' ) -GraphConvertObjRefCheck.Coords( 0 , 0 ) -# Creation of Factory Nodes - -MiscTypes = GraphConvertObjRefCheck.FNode( 'TypesCheck' , 'TypesCheck' , 'MiscTypes' ) -MiscTypes.SetName( 'MiscTypes' ) -MiscTypes.SetAuthor( '' ) -MiscTypes.SetContainer( 'localhost/FactoryServer' ) -MiscTypes.SetComment( 'MiscTypes from TypesCheck' ) -MiscTypes.Coords( 284 , 28 ) - -# Creation of InLine Nodes -PySyrComponent = [] -PySyrComponent.append( 'from LifeCycleCORBA import * ' ) -PySyrComponent.append( 'def SyrComponent( aContainer , aComponent ) : ' ) -PySyrComponent.append( ' print "SyrComponent(",aContainer,",",aComponent,")" ' ) -PySyrComponent.append( ' orb = CORBA.ORB_init([], CORBA.ORB_ID) ' ) -PySyrComponent.append( ' print "SyrComponent orb",orb ' ) -PySyrComponent.append( ' lcc = LifeCycleCORBA(orb) ' ) -PySyrComponent.append( ' print "SyrComponent lcc",lcc ' ) -PySyrComponent.append( ' print "SyrComponent(",aContainer,",",aComponent,")" ' ) -PySyrComponent.append( ' ComponentRef = lcc.FindOrLoadComponent( aContainer , aComponent ) ' ) -PySyrComponent.append( ' print "SyrComponent(",aContainer,",",aComponent,") --> ",ComponentRef ' ) -PySyrComponent.append( ' return ComponentRef ' ) -PySyrComponent.append( '' ) -SyrComponent = GraphConvertObjRefCheck.INode( 'SyrComponent' , PySyrComponent ) -SyrComponent.InPort( 'aContainer' , 'string' ) -SyrComponent.InPort( 'aComponent' , 'string' ) -SyrComponent.OutPort( 'anObjRef' , 'objref' ) -SyrComponent.SetName( 'SyrComponent' ) -SyrComponent.SetAuthor( 'JR' ) -SyrComponent.SetComment( 'InLine Node' ) -SyrComponent.Coords( 14 , 114 ) - -# Creation of Links -SyrComponentanObjRef = SyrComponent.Port( 'anObjRef' ) -MiscTypesInShort = GraphConvertObjRefCheck.Link( SyrComponentanObjRef , MiscTypes.Port( 'InShort' ) ) - -MiscTypesInString = GraphConvertObjRefCheck.Link( SyrComponentanObjRef , MiscTypes.Port( 'InString' ) ) - -MiscTypesInBool = GraphConvertObjRefCheck.Link( SyrComponentanObjRef , MiscTypes.Port( 'InBool' ) ) - -MiscTypesInChar = GraphConvertObjRefCheck.Link( SyrComponentanObjRef , MiscTypes.Port( 'InChar' ) ) - -MiscTypesInLong = GraphConvertObjRefCheck.Link( SyrComponentanObjRef , MiscTypes.Port( 'InLong' ) ) - -MiscTypesInFloat = GraphConvertObjRefCheck.Link( SyrComponentanObjRef , MiscTypes.Port( 'InFloat' ) ) - -MiscTypesInDouble = GraphConvertObjRefCheck.Link( SyrComponentanObjRef , MiscTypes.Port( 'InDouble' ) ) - -MiscTypesInObjRef = GraphConvertObjRefCheck.Link( SyrComponentanObjRef , MiscTypes.Port( 'InObjRef' ) ) - -# Creation of Input datas -SyrComponentaContainer = SyrComponent.Input( 'aContainer' , 'FactoryServerPy') -SyrComponentaComponent = SyrComponent.Input( 'aComponent' , 'SyrControlComponent') - -# Creation of Output variables -MiscTypesOutString = MiscTypes.Port( 'OutString' ) -MiscTypesOutBool = MiscTypes.Port( 'OutBool' ) -MiscTypesOutChar = MiscTypes.Port( 'OutChar' ) -MiscTypesOutShort = MiscTypes.Port( 'OutShort' ) -MiscTypesOutLong = MiscTypes.Port( 'OutLong' ) -MiscTypesOutFloat = MiscTypes.Port( 'OutFloat' ) -MiscTypesOutDouble = MiscTypes.Port( 'OutDouble' ) -MiscTypesOutObjRef = MiscTypes.Port( 'OutObjRef' ) - -GraphConvertObjRefCheck.Run() -GraphConvertObjRefCheck.DoneW() -GraphConvertObjRefCheck.PrintPorts() +# Graph creation of GraphConvertObjRefCheck +def DefGraphConvertObjRefCheck() : + GraphConvertObjRefCheck = Graph( 'GraphConvertObjRefCheck' ) + GraphConvertObjRefCheck.SetName( 'GraphConvertObjRefCheck' ) + GraphConvertObjRefCheck.SetAuthor( 'JR' ) + GraphConvertObjRefCheck.SetComment( 'Check conversions of ObjRef' ) + GraphConvertObjRefCheck.Coords( 0 , 0 ) + + # Creation of Factory Nodes + + MiscTypes = GraphConvertObjRefCheck.FNode( 'TypesCheck' , 'TypesCheck' , 'MiscTypes' ) + MiscTypes.SetName( 'MiscTypes' ) + MiscTypes.SetAuthor( '' ) + MiscTypes.SetContainer( 'localhost/FactoryServer' ) + MiscTypes.SetComment( 'MiscTypes from TypesCheck' ) + MiscTypes.Coords( 284 , 28 ) + IMiscTypesInString = MiscTypes.GetInPort( 'InString' ) + IMiscTypesInBool = MiscTypes.GetInPort( 'InBool' ) + IMiscTypesInChar = MiscTypes.GetInPort( 'InChar' ) + IMiscTypesInShort = MiscTypes.GetInPort( 'InShort' ) + IMiscTypesInLong = MiscTypes.GetInPort( 'InLong' ) + IMiscTypesInFloat = MiscTypes.GetInPort( 'InFloat' ) + IMiscTypesInDouble = MiscTypes.GetInPort( 'InDouble' ) + IMiscTypesInObjRef = MiscTypes.GetInPort( 'InObjRef' ) + IMiscTypesGate = MiscTypes.GetInPort( 'Gate' ) + OMiscTypesOutString = MiscTypes.GetOutPort( 'OutString' ) + OMiscTypesOutBool = MiscTypes.GetOutPort( 'OutBool' ) + OMiscTypesOutChar = MiscTypes.GetOutPort( 'OutChar' ) + OMiscTypesOutShort = MiscTypes.GetOutPort( 'OutShort' ) + OMiscTypesOutLong = MiscTypes.GetOutPort( 'OutLong' ) + OMiscTypesOutFloat = MiscTypes.GetOutPort( 'OutFloat' ) + OMiscTypesOutDouble = MiscTypes.GetOutPort( 'OutDouble' ) + OMiscTypesOutObjRef = MiscTypes.GetOutPort( 'OutObjRef' ) + OMiscTypesGate = MiscTypes.GetOutPort( 'Gate' ) + + # Creation of InLine Nodes + PySyrComponent = [] + PySyrComponent.append( 'from LifeCycleCORBA import * ' ) + PySyrComponent.append( 'def SyrComponent( aContainer , aComponent ) : ' ) + PySyrComponent.append( ' print "SyrComponent(",aContainer,",",aComponent,")" ' ) + PySyrComponent.append( ' orb = CORBA.ORB_init([], CORBA.ORB_ID) ' ) + PySyrComponent.append( ' print "SyrComponent orb",orb ' ) + PySyrComponent.append( ' lcc = LifeCycleCORBA(orb) ' ) + PySyrComponent.append( ' print "SyrComponent lcc",lcc ' ) + PySyrComponent.append( ' print "SyrComponent(",aContainer,",",aComponent,")" ' ) + PySyrComponent.append( ' ComponentRef = lcc.FindOrLoadComponent( aContainer , aComponent ) ' ) + PySyrComponent.append( ' print "SyrComponent(",aContainer,",",aComponent,") --> ",ComponentRef ' ) + PySyrComponent.append( ' return ComponentRef ' ) + PySyrComponent.append( '' ) + SyrComponent = GraphConvertObjRefCheck.INode( 'SyrComponent' , PySyrComponent ) + SyrComponent.SetName( 'SyrComponent' ) + SyrComponent.SetAuthor( 'JR' ) + SyrComponent.SetComment( 'InLine Node' ) + SyrComponent.Coords( 14 , 114 ) + ISyrComponentaContainer = SyrComponent.InPort( 'aContainer' , 'string' ) + ISyrComponentaComponent = SyrComponent.InPort( 'aComponent' , 'string' ) + ISyrComponentGate = SyrComponent.GetInPort( 'Gate' ) + OSyrComponentanObjRef = SyrComponent.OutPort( 'anObjRef' , 'objref' ) + OSyrComponentGate = SyrComponent.GetOutPort( 'Gate' ) + + PyObjRefToInline = [] + PyObjRefToInline.append( 'def ObjRefToInline(objRef): ' ) + PyObjRefToInline.append( ' return objRef ' ) + ObjRefToInline = GraphConvertObjRefCheck.INode( 'ObjRefToInline' , PyObjRefToInline ) + ObjRefToInline.SetName( 'ObjRefToInline' ) + ObjRefToInline.SetAuthor( '' ) + ObjRefToInline.SetComment( 'Compute Node' ) + ObjRefToInline.Coords( 496 , 168 ) + IObjRefToInlinetoInLine = ObjRefToInline.InPort( 'toInLine' , 'int' ) + IObjRefToInlineGate = ObjRefToInline.GetInPort( 'Gate' ) + OObjRefToInlineGate = ObjRefToInline.GetOutPort( 'Gate' ) + + # Creation of Links + LSyrComponentanObjRefMiscTypesInObjRef = GraphConvertObjRefCheck.Link( OSyrComponentanObjRef , IMiscTypesInObjRef ) + + LSyrComponentanObjRefMiscTypesInString = GraphConvertObjRefCheck.Link( OSyrComponentanObjRef , IMiscTypesInString ) + + LMiscTypesOutObjRefObjRefToInlinetoInLine = GraphConvertObjRefCheck.Link( OMiscTypesOutObjRef , IObjRefToInlinetoInLine ) + + # Input datas + ISyrComponentaContainer.Input( 'FactoryServerPy' ) + ISyrComponentaComponent.Input( 'SyrControlComponent' ) + IMiscTypesInBool.Input( 138492744 ) + IMiscTypesInChar.Input( 135402800 ) + IMiscTypesInShort.Input( 135448464 ) + IMiscTypesInLong.Input( 135469224 ) + IMiscTypesInFloat.Input( 65.6954 ) + IMiscTypesInDouble.Input( 65.6954 ) + + # Output Ports of the graph + #OMiscTypesOutString = MiscTypes.GetOutPort( 'OutString' ) + #OMiscTypesOutBool = MiscTypes.GetOutPort( 'OutBool' ) + #OMiscTypesOutChar = MiscTypes.GetOutPort( 'OutChar' ) + #OMiscTypesOutShort = MiscTypes.GetOutPort( 'OutShort' ) + #OMiscTypesOutLong = MiscTypes.GetOutPort( 'OutLong' ) + #OMiscTypesOutFloat = MiscTypes.GetOutPort( 'OutFloat' ) + #OMiscTypesOutDouble = MiscTypes.GetOutPort( 'OutDouble' ) + return GraphConvertObjRefCheck + + +GraphConvertObjRefCheck = DefGraphConvertObjRefCheck() diff --git a/examples/GraphConvertObjRefCheck.xml b/examples/GraphConvertObjRefCheck.xml index 59cee23..24d4edd 100755 --- a/examples/GraphConvertObjRefCheck.xml +++ b/examples/GraphConvertObjRefCheck.xml @@ -1,233 +1,300 @@ - + + ? - ? - GraphConvertObjRefCheck - 1 - ? - + ? + GraphConvertObjRefCheck + 1 + ? + GraphConvertObjRefCheck - + string - SyrComponent\aContainer - + SyrComponent__aContainer + string - SyrComponent\aComponent - + SyrComponent__aComponent + +boolean + MiscTypes__InBool + +char + MiscTypes__InChar + +short + MiscTypes__InShort + +long + MiscTypes__InLong + +float + MiscTypes__InFloat + +double + MiscTypes__InDouble + string - MiscTypes\OutString - + MiscTypes__OutString + boolean - MiscTypes\OutBool - + MiscTypes__OutBool + char - MiscTypes\OutChar - + MiscTypes__OutChar + short - MiscTypes\OutShort - + MiscTypes__OutShort + long - MiscTypes\OutLong - + MiscTypes__OutLong + float - MiscTypes\OutFloat - + MiscTypes__OutFloat + double - MiscTypes\OutDouble - -SuperVisionTest::Adder - MiscTypes\OutObjRef - - - 30/7/2003 - 14:23:52 - 11/9/2003 - 15:18:16 - 1.04 - JR - ? - Check conversions of ObjRef - 0 - 0 - + MiscTypes__OutDouble + + + 30/7/2003 - 14:23:52 + 29/12/2004 - 16:1:50 + 1.04 + JR + ? + Check conversions of ObjRef + 0 + 0 + ? - ? - SyrComponent - 3 - ? - + ? + SyrComponent + 3 + ? + SyrComponent - + string - aContainer - + aContainer + string - aComponent - + aComponent + objref - anObjRef - - + anObjRef + + SyrComponent - - - - - - - - - - ",ComponentRef ]]> - - - 11/9/2003 - 15:16:43 - 11/9/2003 - 15:16:43 - 1.04 - JR - ? - InLine Node - 14 - 114 - + + + + + + + + + + ",ComponentRef ]]> + + + 29/12/2004 - 15:57:21 + 29/12/2004 - 15:57:21 + 1.04 + JR + ? + InLine Node + 14 + 114 + TypesCheck - TypesCheck - MiscTypes - 0 - ? - + TypesCheck + MiscTypes + 0 + ? + MiscTypes - + string - InString - + InString + boolean - InBool - + InBool + char - InChar - + InChar + short - InShort - + InShort + long - InLong - + InLong + float - InFloat - + InFloat + double - InDouble - + InDouble + SuperVisionTest::Adder - InObjRef - + InObjRef + string - OutString - + OutString + boolean - OutBool - + OutBool + char - OutChar - + OutChar + short - OutShort - + OutShort + long - OutLong - + OutLong + float - OutFloat - + OutFloat + double - OutDouble - + OutDouble + SuperVisionTest::Adder - OutObjRef - - - 11/9/2003 - 15:16:43 - 11/9/2003 - 15:16:43 - 1.05 - ? - localhost/FactoryServer - MiscTypes from TypesCheck - 284 - 28 - + OutObjRef + + + 29/12/2004 - 15:57:21 + 29/12/2004 - 15:57:21 + 1.05 + ? + localhost/FactoryServer + MiscTypes from TypesCheck + 284 + 28 + +? + ? + ObjRefToInline + 3 + ? + +ObjRefToInline + + +int + toInLine + + + + +ObjRefToInline + + + 29/12/2004 - 15:58:56 + 29/12/2004 - 15:58:56 + 2.0 + ? + ? + Compute Node + 496 + 168 + SyrComponent - anObjRef - MiscTypes - InShort - - -SyrComponent - anObjRef - MiscTypes - InString - - + anObjRef + MiscTypes + InObjRef + + SyrComponent - anObjRef - MiscTypes - InBool - - -SyrComponent - anObjRef - MiscTypes - InChar - - -SyrComponent - anObjRef - MiscTypes - InLong - - -SyrComponent - anObjRef - MiscTypes - InFloat - - -SyrComponent - anObjRef - MiscTypes - InDouble - - -SyrComponent - anObjRef - MiscTypes - InObjRef - - + anObjRef + MiscTypes + InString + + +MiscTypes + OutObjRef + ObjRefToInline + toInLine + + GraphConvertObjRefCheck - SyrComponent\aContainer - SyrComponent - aContainer - + SyrComponent__aContainer + SyrComponent + aContainer + 18 - FactoryServerPy - - + FactoryServerPy + + GraphConvertObjRefCheck - SyrComponent\aComponent - SyrComponent - aComponent - + SyrComponent__aComponent + SyrComponent + aComponent + 18 - SyrControlComponent - + SyrControlComponent + + +GraphConvertObjRefCheck + MiscTypes__InBool + MiscTypes + InBool + +3 + 138492744 + + +GraphConvertObjRefCheck + MiscTypes__InChar + MiscTypes + InChar + +3 + 135402800 + + +GraphConvertObjRefCheck + MiscTypes__InShort + MiscTypes + InShort + +3 + 135448464 + + +GraphConvertObjRefCheck + MiscTypes__InLong + MiscTypes + InLong + +3 + 135469224 + + +GraphConvertObjRefCheck + MiscTypes__InFloat + MiscTypes + InFloat + +7 + 65.6954 + + +GraphConvertObjRefCheck + MiscTypes__InDouble + MiscTypes + InDouble + +7 + 65.6954 + diff --git a/examples/GraphCpuUsed.py b/examples/GraphCpuUsed.py index 1fc954a..79b7dd2 100755 --- a/examples/GraphCpuUsed.py +++ b/examples/GraphCpuUsed.py @@ -2,6 +2,7 @@ # Generated python file of Graph GraphCpuUsed from SuperV import * +import time # Graph creation GraphCpuUsed = Graph( 'GraphCpuUsed' ) GraphCpuUsed.SetName( 'GraphCpuUsed' ) @@ -133,7 +134,14 @@ Subb = Sub.Input( 'b' , 1) CompareResult = Compare.Port( 'Result' ) GraphCpuUsed.Run() -GraphCpuUsed.DoneW() +while GraphCpuUsed.IsDone() == 0 : + time.sleep(1) + print "sigma",sigma.CpuUsed(),"seconds" + print "Sigma",Sigma.CpuUsed(),"seconds" + print "Add",Add.CpuUsed(),"seconds" + print "Sub",Sub.CpuUsed(),"seconds" + print "Compare",Compare.CpuUsed(),"seconds" + print GraphCpuUsed.State() GraphCpuUsed.PrintPorts() print "sigma",sigma.CpuUsed(),"seconds" diff --git a/examples/GraphEmbeddedComponents.py b/examples/GraphEmbeddedComponents.py new file mode 100644 index 0000000..01ac324 --- /dev/null +++ b/examples/GraphEmbeddedComponents.py @@ -0,0 +1,151 @@ + +# Generated python file of Graph GraphEssai3 + +from SuperV import * + +# Graph creation of GraphEssai3 +def DefGraphEssai3() : + GraphEssai3 = Graph( 'GraphEssai3' ) + GraphEssai3.SetName( 'GraphEssai3' ) + GraphEssai3.SetAuthor( '' ) + GraphEssai3.SetComment( '' ) + GraphEssai3.Coords( 0 , 0 ) + + # Creation of Factory Nodes + + Add = GraphEssai3.FNode( 'AddComponent' , 'AddComponent' , 'Add' ) + Add.SetName( 'Add' ) + Add.SetAuthor( '' ) + Add.SetContainer( 'localhost/FactoryServer' ) + Add.SetComment( 'Add from AddComponent' ) + Add.Coords( 1 , 152 ) + IAddx = Add.GetInPort( 'x' ) + IAddy = Add.GetInPort( 'y' ) + IAddGate = Add.GetInPort( 'Gate' ) + OAddFuncValue = Add.GetOutPort( 'FuncValue' ) + OAddz = Add.GetOutPort( 'z' ) + OAddGate = Add.GetOutPort( 'Gate' ) + + Sub = GraphEssai3.FNode( 'SubComponent' , 'SubComponent' , 'Sub' ) + Sub.SetName( 'Sub' ) + Sub.SetAuthor( '' ) + Sub.SetContainer( 'localhost/FactoryServer' ) + Sub.SetComment( 'Sub from SubComponent' ) + Sub.Coords( 412 , 377 ) + ISubx = Sub.GetInPort( 'x' ) + ISuby = Sub.GetInPort( 'y' ) + ISubGate = Sub.GetInPort( 'Gate' ) + OSubz = Sub.GetOutPort( 'z' ) + OSubGate = Sub.GetOutPort( 'Gate' ) + + Mul = GraphEssai3.FNode( 'MulComponent' , 'MulComponent' , 'Mul' ) + Mul.SetName( 'Mul' ) + Mul.SetAuthor( '' ) + Mul.SetContainer( 'localhost/FactoryServer' ) + Mul.SetComment( 'Mul from MulComponent' ) + Mul.Coords( 412 , 152 ) + IMulx = Mul.GetInPort( 'x' ) + IMuly = Mul.GetInPort( 'y' ) + IMulGate = Mul.GetInPort( 'Gate' ) + OMulz = Mul.GetOutPort( 'z' ) + OMulGate = Mul.GetOutPort( 'Gate' ) + + Div = GraphEssai3.FNode( 'DivComponent' , 'DivComponent' , 'Div' ) + Div.SetName( 'Div' ) + Div.SetAuthor( '' ) + Div.SetContainer( 'localhost/FactoryServer' ) + Div.SetComment( 'Div from DivComponent' ) + Div.Coords( 622 , 124 ) + IDivx = Div.GetInPort( 'x' ) + IDivy = Div.GetInPort( 'y' ) + IDivGate = Div.GetInPort( 'Gate' ) + ODivz = Div.GetOutPort( 'z' ) + ODivGate = Div.GetOutPort( 'Gate' ) + + Addition = GraphEssai3.FNode( 'AddComponent' , 'AddComponent' , 'Addition' ) + Addition.SetName( 'Addition' ) + Addition.SetAuthor( '' ) + Addition.SetContainer( 'localhost/AdditionServer' ) + Addition.SetComment( 'Addition from AddComponent' ) + Addition.Coords( 0 , 0 ) + IAdditionGate = Addition.GetInPort( 'Gate' ) + OAdditionAdder = Addition.GetOutPort( 'Adder' ) + OAdditionGate = Addition.GetOutPort( 'Gate' ) + + Addition_1 = GraphEssai3.FNode( 'AddComponent' , 'AddComponent' , 'Addition' ) + Addition_1.SetName( 'Addition_1' ) + Addition_1.SetAuthor( '' ) + Addition_1.SetContainer( 'localhost/Addition_1Server' ) + Addition_1.SetComment( 'Addition from AddComponent' ) + Addition_1.Coords( 4 , 327 ) + IAddition_1Gate = Addition_1.GetInPort( 'Gate' ) + OAddition_1Adder = Addition_1.GetOutPort( 'Adder' ) + OAddition_1Gate = Addition_1.GetOutPort( 'Gate' ) + + # Creation of Computing Nodes + AddAndCompare_ServiceinParameter = [] + AddAndCompare_ServiceinParameter.append( SALOME_ModuleCatalog.ServicesParameter( 'Adder' , 'Adder' ) ) + AddAndCompare_ServiceinParameter.append( SALOME_ModuleCatalog.ServicesParameter( 'double' , 'x' ) ) + AddAndCompare_ServiceinParameter.append( SALOME_ModuleCatalog.ServicesParameter( 'double' , 'y' ) ) + AddAndCompare_ServiceinParameter.append( SALOME_ModuleCatalog.ServicesParameter( 'Adder' , 'anOtherAdder' ) ) + AddAndCompare_ServiceoutParameter = [] + AddAndCompare_ServiceoutParameter.append( SALOME_ModuleCatalog.ServicesParameter( 'double' , 'FuncValue' ) ) + AddAndCompare_ServiceoutParameter.append( SALOME_ModuleCatalog.ServicesParameter( 'double' , 'z' ) ) + AddAndCompare_ServiceinStreamParameter = [] + AddAndCompare_ServiceoutStreamParameter = [] + AddAndCompare_Service = SALOME_ModuleCatalog.Service( 'AddAndCompare' , AddAndCompare_ServiceinParameter , AddAndCompare_ServiceoutParameter , AddAndCompare_ServiceinStreamParameter , AddAndCompare_ServiceoutStreamParameter , 0 , 0 ) + AddAndCompare = GraphEssai3.CNode( AddAndCompare_Service ) + AddAndCompare.SetName( 'AddAndCompare' ) + AddAndCompare.SetAuthor( '' ) + AddAndCompare.SetComment( 'Python function' ) + AddAndCompare.Coords( 233 , 0 ) + IAddAndCompareAdder = AddAndCompare.GetInPort( 'Adder' ) + IAddAndComparex = AddAndCompare.GetInPort( 'x' ) + IAddAndComparey = AddAndCompare.GetInPort( 'y' ) + IAddAndCompareanOtherAdder = AddAndCompare.GetInPort( 'anOtherAdder' ) + IAddAndCompareGate = AddAndCompare.GetInPort( 'Gate' ) + OAddAndCompareFuncValue = AddAndCompare.GetOutPort( 'FuncValue' ) + OAddAndComparez = AddAndCompare.GetOutPort( 'z' ) + OAddAndCompareGate = AddAndCompare.GetOutPort( 'Gate' ) + + # Creation of Links + LAddFuncValueMulx = GraphEssai3.Link( OAddFuncValue , IMulx ) + + LAddFuncValueAddAndComparex = GraphEssai3.Link( OAddFuncValue , IAddAndComparex ) + LAddFuncValueAddAndComparex.AddCoord( 1 , 195 , 108 ) + LAddFuncValueAddAndComparex.AddCoord( 2 , 195 , 233 ) + + LAddzSubx = GraphEssai3.Link( OAddz , ISubx ) + LAddzSubx.AddCoord( 1 , 187 , 459 ) + LAddzSubx.AddCoord( 2 , 186 , 262 ) + + LAddzAddAndComparey = GraphEssai3.Link( OAddz , IAddAndComparey ) + LAddzAddAndComparey.AddCoord( 1 , 187 , 139 ) + LAddzAddAndComparey.AddCoord( 2 , 186 , 261 ) + + LSubzDivx = GraphEssai3.Link( OSubz , IDivx ) + LSubzDivx.AddCoord( 1 , 598 , 203 ) + LSubzDivx.AddCoord( 2 , 598 , 457 ) + + LMulzDivy = GraphEssai3.Link( OMulz , IDivy ) + + LAdditionAdderAddAndCompareAdder = GraphEssai3.Link( OAdditionAdder , IAddAndCompareAdder ) + + LAddition_1AdderAddAndCompareanOtherAdder = GraphEssai3.Link( OAddition_1Adder , IAddAndCompareanOtherAdder ) + LAddition_1AdderAddAndCompareanOtherAdder.AddCoord( 1 , 215 , 168 ) + LAddition_1AdderAddAndCompareanOtherAdder.AddCoord( 2 , 214 , 407 ) + + # Input datas + IAddx.Input( 1 ) + IAddy.Input( 2 ) + ISuby.Input( 3 ) + IMuly.Input( 4 ) + + # Output Ports of the graph + #ODivz = Div.GetOutPort( 'z' ) + #OAddAndCompareFuncValue = AddAndCompare.GetOutPort( 'FuncValue' ) + #OAddAndComparez = AddAndCompare.GetOutPort( 'z' ) + return GraphEssai3 + + +GraphEssai3 = DefGraphEssai3() diff --git a/examples/GraphEmbeddedComponents.xml b/examples/GraphEmbeddedComponents.xml new file mode 100644 index 0000000..ab9c151 --- /dev/null +++ b/examples/GraphEmbeddedComponents.xml @@ -0,0 +1,365 @@ + + + + + +? + ? + GraphEssai3 + 1 + ? + +GraphEssai3 + + +double + Add__x + +double + Add__y + +double + Sub__y + +double + Mul__y + + +double + Div__z + +double + AddAndCompare__FuncValue + +double + AddAndCompare__z + + + 11/3/2003 - 10:59:37 + 11/1/2005 - 16:42:5 + 1.04 + ? + ? + ? + 0 + 0 + + +AddComponent + AddComponent + Add + 0 + ? + +Add + + +double + x + +double + y + + +double + FuncValue + +double + z + + + 11/1/2005 - 16:42:5 + 11/1/2005 - 16:42:5 + 1.04 + ? + localhost/FactoryServer + Add from AddComponent + 1 + 152 + +SubComponent + SubComponent + Sub + 0 + ? + +Sub + + +double + x + +double + y + + +double + z + + + 11/1/2005 - 16:42:5 + 11/1/2005 - 16:42:5 + 1.04 + ? + localhost/FactoryServer + Sub from SubComponent + 412 + 377 + +MulComponent + MulComponent + Mul + 0 + ? + +Mul + + +double + x + +double + y + + +double + z + + + 11/1/2005 - 16:42:5 + 11/1/2005 - 16:42:5 + 1.04 + ? + localhost/FactoryServer + Mul from MulComponent + 412 + 152 + +DivComponent + DivComponent + Div + 0 + ? + +Div + + +double + x + +double + y + + +double + z + + + 11/1/2005 - 16:42:5 + 11/1/2005 - 16:42:5 + 1.04 + ? + localhost/FactoryServer + Div from DivComponent + 622 + 124 + +AddComponent + AddComponent + Addition + 0 + ? + +Addition + + + +Adder + Adder + + + 11/1/2005 - 16:42:5 + 11/1/2005 - 16:42:5 + 1.04 + ? + localhost/AdditionServer + Addition from AddComponent + 0 + 0 + +AddComponent + AddComponent + Addition_1 + 0 + ? + +Addition + + + +Adder + Adder + + + 11/1/2005 - 16:42:5 + 11/1/2005 - 16:42:5 + 1.04 + ? + localhost/Addition_1Server + Addition from AddComponent + 4 + 327 + +? + ? + AddAndCompare + 2 + ? + +AddAndCompare + + +Adder + Adder + +double + x + +double + y + +Adder + anOtherAdder + + +double + FuncValue + +double + z + + + 11/1/2005 - 16:42:5 + 11/1/2005 - 16:42:5 + 1.04 + ? + ? + Python function + 233 + 0 + + +Add + FuncValue + Mul + x + + +Add + FuncValue + AddAndCompare + x + + +195 + 108 + +195 + 233 + +Add + z + Sub + x + + +187 + 459 + +186 + 262 + +Add + z + AddAndCompare + y + + +187 + 139 + +186 + 261 + +Sub + z + Div + x + + +598 + 203 + +598 + 457 + +Mul + z + Div + y + + +Addition + Adder + AddAndCompare + Adder + + +Addition_1 + Adder + AddAndCompare + anOtherAdder + + +215 + 168 + +214 + 407 + + +GraphEssai3 + Add__x + Add + x + +7 + 1 + + +GraphEssai3 + Add__y + Add + y + +7 + 2 + + +GraphEssai3 + Sub__y + Sub + y + +7 + 3 + + +GraphEssai3 + Mul__y + Mul + y + +7 + 4 + diff --git a/examples/GraphGOTO.py b/examples/GraphGOTO.py index 00b7414..4d555c2 100644 --- a/examples/GraphGOTO.py +++ b/examples/GraphGOTO.py @@ -2,277 +2,307 @@ # Generated python file of Graph GraphGOTO from SuperV import * -# Graph creation -GraphGOTO = Graph( 'GraphGOTO' ) -GraphGOTO.SetName( 'GraphGOTO' ) -GraphGOTO.SetAuthor( 'JR' ) -GraphGOTO.SetComment( 'Syracuse algorithm' ) -GraphGOTO.Coords( 0 , 0 ) -# Creation of Factory Nodes - -test_ISEVEN = GraphGOTO.FNode( 'SyrComponent' , 'SyrComponent' , 'C_ISEVEN' ) -test_ISEVEN.SetName( 'test_ISEVEN' ) -test_ISEVEN.SetAuthor( '' ) -test_ISEVEN.SetContainer( 'localhost/FactoryServer' ) -test_ISEVEN.SetComment( 'C_ISEVEN from SyrComponent' ) -test_ISEVEN.Coords( 195 , 417 ) - -test_ISONE = GraphGOTO.FNode( 'SyrComponent' , 'SyrComponent' , 'C_ISONE' ) -test_ISONE.SetName( 'test_ISONE' ) -test_ISONE.SetAuthor( '' ) -test_ISONE.SetContainer( 'localhost/FactoryServer' ) -test_ISONE.SetComment( 'C_ISONE from SyrComponent' ) -test_ISONE.Coords( 201 , 145 ) - -m3p1 = GraphGOTO.FNode( 'SyrComponent' , 'SyrComponent' , 'C_M3P1' ) -m3p1.SetName( 'm3p1' ) -m3p1.SetAuthor( '' ) -m3p1.SetContainer( 'localhost/FactoryServer' ) -m3p1.SetComment( 'C_M3P1 from SyrComponent' ) -m3p1.Coords( 784 , 36 ) - -div2 = GraphGOTO.FNode( 'SyrComponent' , 'SyrComponent' , 'C_DIV2' ) -div2.SetName( 'div2' ) -div2.SetAuthor( '' ) -div2.SetContainer( 'localhost/FactoryServer' ) -div2.SetComment( 'C_DIV2 from SyrComponent' ) -div2.Coords( 788 , 409 ) - -incr = GraphGOTO.FNode( 'SyrComponent' , 'SyrComponent' , 'C_INCR' ) -incr.SetName( 'incr' ) -incr.SetAuthor( '' ) -incr.SetContainer( 'localhost/FactoryServer' ) -incr.SetComment( 'C_INCR from SyrComponent' ) -incr.Coords( 788 , 230 ) - -# Creation of InLine Nodes -Pylabel_begin = [] -Pylabel_begin.append( 'def label_begin( NB , KB ):' ) -Pylabel_begin.append( ' print "label_begin",NB,KB' ) -Pylabel_begin.append( ' return NB,KB' ) -label_begin = GraphGOTO.INode( 'label_begin' , Pylabel_begin ) -label_begin.InPort( 'NB' , 'long' ) -label_begin.InPort( 'KB' , 'long' ) -label_begin.OutPort( 'NT' , 'long' ) -label_begin.OutPort( 'KT' , 'long' ) -label_begin.SetName( 'label_begin' ) -label_begin.SetAuthor( '' ) -label_begin.SetComment( 'Python function' ) -label_begin.Coords( 9 , 250 ) - -Pylabel_test = [] -Pylabel_test.append( 'def label_test( ValEven , ValOne , NB , KB ):' ) -Pylabel_test.append( ' print "label_begin",ValEven,ValOne,NB,KB' ) -Pylabel_test.append( ' return ValEven,ValOne,NB,KB' ) -label_test = GraphGOTO.INode( 'label_test' , Pylabel_test ) -label_test.InPort( 'ValEven' , 'long' ) -label_test.InPort( 'ValOne' , 'long' ) -label_test.InPort( 'NT' , 'long' ) -label_test.InPort( 'KT' , 'long' ) -label_test.OutPort( 'ValEven' , 'long' ) -label_test.OutPort( 'ValOne' , 'long' ) -label_test.OutPort( 'NT' , 'long' ) -label_test.OutPort( 'KT' , 'long' ) -label_test.SetName( 'label_test' ) -label_test.SetAuthor( '' ) -label_test.SetComment( 'Python function' ) -label_test.Coords( 396 , 193 ) - -# Creation of Switch Nodes -Pytest = [] -Pytest.append( 'def Switch_OneEven( ValOne , ValEven , NT , KT ) :' ) -Pytest.append( ' Finished = ValOne' ) -Pytest.append( ' if Finished == 0 :' ) -Pytest.append( ' Incr = 1' ) -Pytest.append( ' Even = ValEven' ) -Pytest.append( ' if Even == 0 :' ) -Pytest.append( ' Odd = 1' ) -Pytest.append( ' else :' ) -Pytest.append( ' Odd = 0' ) -Pytest.append( ' else :' ) -Pytest.append( ' Incr = 0' ) -Pytest.append( ' Even = 0' ) -Pytest.append( ' Odd = 0' ) -Pytest.append( ' Even = ValEven' ) -Pytest.append( ' return Finished,Incr,Even,Odd,NT,KT' ) -test,EndSwitch_OneEven = GraphGOTO.SNode( 'Switch_OneEven' , Pytest ) -EndSwitch_OneEven.SetName( 'EndSwitch_OneEven' ) -EndSwitch_OneEven.SetAuthor( '' ) -EndSwitch_OneEven.SetComment( '' ) -EndSwitch_OneEven.Coords( 1152 , 292 ) -PyEndSwitch_OneEven = [] -PyEndSwitch_OneEven.append( 'def EndSwitch_OneEven( Finished , K ):' ) -PyEndSwitch_OneEven.append( ' print "label_begin",Finished,K' ) -PyEndSwitch_OneEven.append( ' return Finished,K' ) -EndSwitch_OneEven.SetPyFunction( 'EndSwitch_OneEven' , PyEndSwitch_OneEven ) -EndSwitch_OneEven.InPort( 'Finished' , 'long' ) -EndSwitch_OneEven.InPort( 'K' , 'long' ) -EndSwitch_OneEven.OutPort( 'Finished' , 'long' ) -EndSwitch_OneEven.OutPort( 'K' , 'long' ) -test.InPort( 'ValOne' , 'long' ) -test.InPort( 'ValEven' , 'long' ) -test.InPort( 'NT' , 'long' ) -test.InPort( 'KT' , 'long' ) -test.OutPort( 'Finished' , 'long' ) -test.OutPort( 'Incr' , 'long' ) -test.OutPort( 'Even' , 'long' ) -test.OutPort( 'Odd' , 'long' ) -test.OutPort( 'N' , 'long' ) -test.OutPort( 'K' , 'long' ) -test.SetName( 'test' ) -test.SetAuthor( '' ) -test.SetComment( '' ) -test.Coords( 595 , 239 ) - -# Creation of GOTO Nodes -Pycontrol_m3p1 = [] -Pycontrol_m3p1.append( 'def control_m3p1( N , K ):' ) -Pycontrol_m3p1.append( ' return 0,1,N,K' ) -control_m3p1 = GraphGOTO.GNode( 'control_m3p1' , Pycontrol_m3p1 , 'label_test' ) -control_m3p1.InPort( 'N' , 'long' ) -control_m3p1.InPort( 'K' , 'long' ) -control_m3p1.OutPort( 'ValOne' , 'long' ) -control_m3p1.OutPort( 'ValEven' , 'long' ) -control_m3p1.OutPort( 'NT' , 'long' ) -control_m3p1.OutPort( 'KT' , 'long' ) -control_m3p1.SetName( 'control_m3p1' ) -control_m3p1.SetAuthor( '' ) -control_m3p1.SetComment( '' ) -control_m3p1.Coords( 980 , 81 ) - -Pycontrol_div2 = [] -Pycontrol_div2.append( 'def control_div2( N , NB ) :' ) -Pycontrol_div2.append( ' return N,NB' ) -control_div2 = GraphGOTO.GNode( 'control_div2' , Pycontrol_div2 , 'label_begin' ) -control_div2.InPort( 'N' , 'long' ) -control_div2.InPort( 'K' , 'long' ) -control_div2.OutPort( 'NB' , 'long' ) -control_div2.OutPort( 'KB' , 'long' ) -control_div2.SetName( 'control_div2' ) -control_div2.SetAuthor( '' ) -control_div2.SetComment( '' ) -control_div2.Coords( 1039 , 454 ) - -# Creation of Links -test_ISEVENBoolEven = test_ISEVEN.Port( 'BoolEven' ) -label_testValEven = GraphGOTO.Link( test_ISEVENBoolEven , label_test.Port( 'ValEven' ) ) -label_testValEven.AddCoord( 1 , 369 , 273 ) -label_testValEven.AddCoord( 2 , 370 , 498 ) - -test_ISONEBoolOne = test_ISONE.Port( 'BoolOne' ) -label_testValOne = GraphGOTO.Link( test_ISONEBoolOne , label_test.Port( 'ValOne' ) ) -label_testValOne.AddCoord( 1 , 385 , 303 ) -label_testValOne.AddCoord( 2 , 384 , 225 ) - -m3p1anEvenInteger = m3p1.Port( 'anEvenInteger' ) -control_m3p1N = GraphGOTO.Link( m3p1anEvenInteger , control_m3p1.Port( 'N' ) ) - -div2anInteger = div2.Port( 'anInteger' ) -control_div2N = GraphGOTO.Link( div2anInteger , control_div2.Port( 'N' ) ) - -incraNewCount = incr.Port( 'aNewCount' ) -control_m3p1K = GraphGOTO.Link( incraNewCount , control_m3p1.Port( 'K' ) ) -control_m3p1K.AddCoord( 1 , 964 , 145 ) -control_m3p1K.AddCoord( 2 , 964 , 309 ) - -control_div2K = GraphGOTO.Link( incraNewCount , control_div2.Port( 'K' ) ) -control_div2K.AddCoord( 1 , 963 , 518 ) -control_div2K.AddCoord( 2 , 964 , 312 ) - -label_beginNT = label_begin.Port( 'NT' ) -label_testNT = GraphGOTO.Link( label_beginNT , label_test.Port( 'NT' ) ) - -test_ISONEanInteger = GraphGOTO.Link( label_beginNT , test_ISONE.Port( 'anInteger' ) ) -test_ISONEanInteger.AddCoord( 1 , 192 , 226 ) -test_ISONEanInteger.AddCoord( 2 , 191 , 331 ) - -test_ISEVENanInteger = GraphGOTO.Link( label_beginNT , test_ISEVEN.Port( 'anInteger' ) ) -test_ISEVENanInteger.AddCoord( 1 , 191 , 494 ) -test_ISEVENanInteger.AddCoord( 2 , 192 , 331 ) - -label_beginKT = label_begin.Port( 'KT' ) -label_testKT = GraphGOTO.Link( label_beginKT , label_test.Port( 'KT' ) ) - -label_testValEven = label_test.Port( 'ValEven' ) -testValEven = GraphGOTO.Link( label_testValEven , test.Port( 'ValEven' ) ) -testValEven.AddCoord( 1 , 587 , 318 ) -testValEven.AddCoord( 2 , 570 , 318 ) -testValEven.AddCoord( 3 , 569 , 272 ) - -label_testValOne = label_test.Port( 'ValOne' ) -testValOne = GraphGOTO.Link( label_testValOne , test.Port( 'ValOne' ) ) -testValOne.AddCoord( 1 , 585 , 273 ) -testValOne.AddCoord( 2 , 586 , 303 ) - -label_testNT = label_test.Port( 'NT' ) -testNT = GraphGOTO.Link( label_testNT , test.Port( 'NT' ) ) - -label_testKT = label_test.Port( 'KT' ) -testKT = GraphGOTO.Link( label_testKT , test.Port( 'KT' ) ) - -testFinished = test.Port( 'Finished' ) -EndSwitch_OneEvenFinished = GraphGOTO.Link( testFinished , EndSwitch_OneEven.Port( 'Finished' ) ) - -testIncr = test.Port( 'Incr' ) -incrInGate = GraphGOTO.Link( testIncr , incr.Port( 'InGate' ) ) -incrInGate.AddCoord( 1 , 783 , 341 ) -incrInGate.AddCoord( 2 , 782 , 302 ) - -testEven = test.Port( 'Even' ) -div2InGate = GraphGOTO.Link( testEven , div2.Port( 'InGate' ) ) -div2InGate.AddCoord( 1 , 754 , 518 ) -div2InGate.AddCoord( 2 , 753 , 330 ) - -testOdd = test.Port( 'Odd' ) -m3p1InGate = GraphGOTO.Link( testOdd , m3p1.Port( 'InGate' ) ) -m3p1InGate.AddCoord( 1 , 758 , 145 ) -m3p1InGate.AddCoord( 2 , 760 , 359 ) - -testN = test.Port( 'N' ) -m3p1anOddInteger = GraphGOTO.Link( testN , m3p1.Port( 'anOddInteger' ) ) -m3p1anOddInteger.AddCoord( 1 , 767 , 116 ) -m3p1anOddInteger.AddCoord( 2 , 767 , 116 ) -m3p1anOddInteger.AddCoord( 3 , 767 , 390 ) - -div2anEvenInteger = GraphGOTO.Link( testN , div2.Port( 'anEvenInteger' ) ) -div2anEvenInteger.AddCoord( 1 , 767 , 489 ) -div2anEvenInteger.AddCoord( 2 , 766 , 389 ) - -testK = test.Port( 'K' ) -EndSwitch_OneEvenK = GraphGOTO.Link( testK , EndSwitch_OneEven.Port( 'K' ) ) - -incraCount = GraphGOTO.Link( testK , incr.Port( 'aCount' ) ) -incraCount.AddCoord( 1 , 772 , 311 ) -incraCount.AddCoord( 2 , 772 , 417 ) -incraCount.AddCoord( 3 , 772 , 417 ) - -testDefault = test.Port( 'Default' ) -EndSwitch_OneEvenDefault = GraphGOTO.Link( testDefault , EndSwitch_OneEven.Port( 'Default' ) ) -EndSwitch_OneEvenDefault.AddCoord( 1 , 778 , 384 ) -EndSwitch_OneEvenDefault.AddCoord( 2 , 778 , 448 ) - -control_m3p1OutGate = control_m3p1.Port( 'OutGate' ) -label_testInGate = GraphGOTO.Link( control_m3p1OutGate , label_test.Port( 'InGate' ) ) -label_testInGate.AddCoord( 1 , 388 , 388 ) -label_testInGate.AddCoord( 2 , 389 , 597 ) -label_testInGate.AddCoord( 3 , 1319 , 597 ) -label_testInGate.AddCoord( 4 , 1318 , 231 ) - -control_div2OutGate = control_div2.Port( 'OutGate' ) -label_beginInGate = GraphGOTO.Link( control_div2OutGate , label_begin.Port( 'InGate' ) ) -label_beginInGate.AddCoord( 1 , 4 , 388 ) -label_beginInGate.AddCoord( 2 , 3 , 587 ) -label_beginInGate.AddCoord( 3 , 1214 , 588 ) -label_beginInGate.AddCoord( 4 , 1213 , 546 ) - -# Creation of Input datas -label_beginNB = label_begin.Input( 'NB' , 7) -label_beginKB = label_begin.Input( 'KB' , 0) - -# Creation of Output variables -EndSwitch_OneEvenFinished = EndSwitch_OneEven.Port( 'Finished' ) -EndSwitch_OneEvenK = EndSwitch_OneEven.Port( 'K' ) +# Graph creation of GraphGOTO +def DefGraphGOTO() : + GraphGOTO = Graph( 'GraphGOTO' ) + GraphGOTO.SetName( 'GraphGOTO' ) + GraphGOTO.SetAuthor( 'JR' ) + GraphGOTO.SetComment( 'Syracuse algorithm' ) + GraphGOTO.Coords( 0 , 0 ) + + # Creation of Factory Nodes + + test_ISEVEN = GraphGOTO.FNode( 'SyrComponent' , 'SyrComponent' , 'C_ISEVEN' ) + test_ISEVEN.SetName( 'test_ISEVEN' ) + test_ISEVEN.SetAuthor( '' ) + test_ISEVEN.SetContainer( 'localhost/FactoryServer' ) + test_ISEVEN.SetComment( 'C_ISEVEN from SyrComponent' ) + test_ISEVEN.Coords( 195 , 417 ) + Itest_ISEVENanInteger = test_ISEVEN.GetInPort( 'anInteger' ) + Itest_ISEVENGate = test_ISEVEN.GetInPort( 'Gate' ) + Otest_ISEVENBoolEven = test_ISEVEN.GetOutPort( 'BoolEven' ) + Otest_ISEVENGate = test_ISEVEN.GetOutPort( 'Gate' ) + + test_ISONE = GraphGOTO.FNode( 'SyrComponent' , 'SyrComponent' , 'C_ISONE' ) + test_ISONE.SetName( 'test_ISONE' ) + test_ISONE.SetAuthor( '' ) + test_ISONE.SetContainer( 'localhost/FactoryServer' ) + test_ISONE.SetComment( 'C_ISONE from SyrComponent' ) + test_ISONE.Coords( 201 , 145 ) + Itest_ISONEanInteger = test_ISONE.GetInPort( 'anInteger' ) + Itest_ISONEGate = test_ISONE.GetInPort( 'Gate' ) + Otest_ISONEBoolOne = test_ISONE.GetOutPort( 'BoolOne' ) + Otest_ISONEGate = test_ISONE.GetOutPort( 'Gate' ) + + m3p1 = GraphGOTO.FNode( 'SyrComponent' , 'SyrComponent' , 'C_M3P1' ) + m3p1.SetName( 'm3p1' ) + m3p1.SetAuthor( '' ) + m3p1.SetContainer( 'localhost/FactoryServer' ) + m3p1.SetComment( 'C_M3P1 from SyrComponent' ) + m3p1.Coords( 861 , 46 ) + Im3p1anOddInteger = m3p1.GetInPort( 'anOddInteger' ) + Im3p1Gate = m3p1.GetInPort( 'Gate' ) + Om3p1anEvenInteger = m3p1.GetOutPort( 'anEvenInteger' ) + Om3p1Gate = m3p1.GetOutPort( 'Gate' ) + + div2 = GraphGOTO.FNode( 'SyrComponent' , 'SyrComponent' , 'C_DIV2' ) + div2.SetName( 'div2' ) + div2.SetAuthor( '' ) + div2.SetContainer( 'localhost/FactoryServer' ) + div2.SetComment( 'C_DIV2 from SyrComponent' ) + div2.Coords( 858 , 466 ) + Idiv2anEvenInteger = div2.GetInPort( 'anEvenInteger' ) + Idiv2Gate = div2.GetInPort( 'Gate' ) + Odiv2anInteger = div2.GetOutPort( 'anInteger' ) + Odiv2Gate = div2.GetOutPort( 'Gate' ) + + incr = GraphGOTO.FNode( 'SyrComponent' , 'SyrComponent' , 'C_INCR' ) + incr.SetName( 'incr' ) + incr.SetAuthor( '' ) + incr.SetContainer( 'localhost/FactoryServer' ) + incr.SetComment( 'C_INCR from SyrComponent' ) + incr.Coords( 865 , 169 ) + IincraCount = incr.GetInPort( 'aCount' ) + IincrGate = incr.GetInPort( 'Gate' ) + OincraNewCount = incr.GetOutPort( 'aNewCount' ) + OincrGate = incr.GetOutPort( 'Gate' ) + + incr_1 = GraphGOTO.FNode( 'SyrComponent' , 'SyrComponent' , 'C_INCR' ) + incr_1.SetName( 'incr_1' ) + incr_1.SetAuthor( '' ) + incr_1.SetContainer( 'localhost/FactoryServer' ) + incr_1.SetComment( 'C_INCR from SyrComponent' ) + incr_1.Coords( 859 , 338 ) + Iincr_1aCount = incr_1.GetInPort( 'aCount' ) + Iincr_1Gate = incr_1.GetInPort( 'Gate' ) + Oincr_1aNewCount = incr_1.GetOutPort( 'aNewCount' ) + Oincr_1Gate = incr_1.GetOutPort( 'Gate' ) + + # Creation of InLine Nodes + Pylabel_begin = [] + Pylabel_begin.append( 'def label_begin( NB , KB ):' ) + Pylabel_begin.append( ' print "label_begin",NB,KB' ) + Pylabel_begin.append( ' return NB,KB' ) + label_begin = GraphGOTO.INode( 'label_begin' , Pylabel_begin ) + label_begin.SetName( 'label_begin' ) + label_begin.SetAuthor( '' ) + label_begin.SetComment( 'Python function' ) + label_begin.Coords( 9 , 250 ) + Ilabel_beginNB = label_begin.InPort( 'NB' , 'long' ) + Ilabel_beginKB = label_begin.InPort( 'KB' , 'long' ) + Ilabel_beginGate = label_begin.GetInPort( 'Gate' ) + Olabel_beginNT = label_begin.OutPort( 'NT' , 'long' ) + Olabel_beginKT = label_begin.OutPort( 'KT' , 'long' ) + Olabel_beginGate = label_begin.GetOutPort( 'Gate' ) + + Pylabel_test = [] + Pylabel_test.append( 'def label_test( ValEven , ValOne , NB , KB ):' ) + Pylabel_test.append( ' print "label_begin",ValEven,ValOne,NB,KB' ) + Pylabel_test.append( ' return ValEven,ValOne,NB,KB' ) + label_test = GraphGOTO.INode( 'label_test' , Pylabel_test ) + label_test.SetName( 'label_test' ) + label_test.SetAuthor( '' ) + label_test.SetComment( 'Python function' ) + label_test.Coords( 396 , 193 ) + Ilabel_testValEven = label_test.InPort( 'ValEven' , 'long' ) + Ilabel_testValOne = label_test.InPort( 'ValOne' , 'long' ) + Ilabel_testNT = label_test.InPort( 'NT' , 'long' ) + Ilabel_testKT = label_test.InPort( 'KT' , 'long' ) + Ilabel_testGate = label_test.GetInPort( 'Gate' ) + Olabel_testValEven = label_test.OutPort( 'ValEven' , 'long' ) + Olabel_testValOne = label_test.OutPort( 'ValOne' , 'long' ) + Olabel_testNT = label_test.OutPort( 'NT' , 'long' ) + Olabel_testKT = label_test.OutPort( 'KT' , 'long' ) + Olabel_testGate = label_test.GetOutPort( 'Gate' ) + + # Creation of Switch Nodes + Pytest = [] + Pytest.append( 'def Switch_OneEven( ValOne , ValEven , NT , KT ) :' ) + Pytest.append( ' Finished = ValOne' ) + Pytest.append( ' if Finished == 0 :' ) + Pytest.append( ' Incr = 1' ) + Pytest.append( ' Even = ValEven' ) + Pytest.append( ' if Even == 0 :' ) + Pytest.append( ' Odd = 1' ) + Pytest.append( ' else :' ) + Pytest.append( ' Odd = 0' ) + Pytest.append( ' else :' ) + Pytest.append( ' Incr = 0' ) + Pytest.append( ' Even = 0' ) + Pytest.append( ' Odd = 0' ) + Pytest.append( ' Even = ValEven' ) + Pytest.append( ' return Finished,Incr,Even,Odd,NT,KT' ) + test,EndSwitch_OneEven = GraphGOTO.SNode( 'Switch_OneEven' , Pytest ) + EndSwitch_OneEven.SetName( 'EndSwitch_OneEven' ) + EndSwitch_OneEven.SetAuthor( '' ) + EndSwitch_OneEven.SetComment( 'Compute Node' ) + EndSwitch_OneEven.Coords( 1256 , 305 ) + PyEndSwitch_OneEven = [] + PyEndSwitch_OneEven.append( 'def EndSwitch_OneEven( Finished , K ):' ) + PyEndSwitch_OneEven.append( ' print "label_begin",Finished,K' ) + PyEndSwitch_OneEven.append( ' return Finished,K' ) + EndSwitch_OneEven.SetPyFunction( 'EndSwitch_OneEven' , PyEndSwitch_OneEven ) + IEndSwitch_OneEvenFinished = EndSwitch_OneEven.InPort( 'Finished' , 'long' ) + IEndSwitch_OneEvenK = EndSwitch_OneEven.InPort( 'K' , 'long' ) + IEndSwitch_OneEvenDefault = EndSwitch_OneEven.GetInPort( 'Default' ) + OEndSwitch_OneEvenFinished = EndSwitch_OneEven.OutPort( 'Finished' , 'long' ) + OEndSwitch_OneEvenK = EndSwitch_OneEven.OutPort( 'K' , 'long' ) + OEndSwitch_OneEvenGate = EndSwitch_OneEven.GetOutPort( 'Gate' ) + test.SetName( 'test' ) + test.SetAuthor( '' ) + test.SetComment( 'Compute Node' ) + test.Coords( 595 , 239 ) + ItestValOne = test.InPort( 'ValOne' , 'long' ) + ItestValEven = test.InPort( 'ValEven' , 'long' ) + ItestNT = test.InPort( 'NT' , 'long' ) + ItestKT = test.InPort( 'KT' , 'long' ) + ItestGate = test.GetInPort( 'Gate' ) + OtestFinished = test.OutPort( 'Finished' , 'long' ) + OtestIncr = test.OutPort( 'Incr' , 'long' ) + OtestEven = test.OutPort( 'Even' , 'long' ) + OtestOdd = test.OutPort( 'Odd' , 'long' ) + OtestN = test.OutPort( 'N' , 'long' ) + OtestK = test.OutPort( 'K' , 'long' ) + OtestDefault = test.GetOutPort( 'Default' ) + + # Creation of GOTO Nodes + Pycontrol_m3p1 = [] + Pycontrol_m3p1.append( 'def control_m3p1( N , K ):' ) + Pycontrol_m3p1.append( ' return 0,1,N,K' ) + control_m3p1 = GraphGOTO.GNode( 'control_m3p1' , Pycontrol_m3p1 , 'label_test' ) + control_m3p1.SetName( 'control_m3p1' ) + control_m3p1.SetAuthor( '' ) + control_m3p1.SetComment( 'Compute Node' ) + control_m3p1.Coords( 1073 , 87 ) + Icontrol_m3p1N = control_m3p1.InPort( 'N' , 'long' ) + Icontrol_m3p1K = control_m3p1.InPort( 'K' , 'long' ) + Icontrol_m3p1Gate = control_m3p1.GetInPort( 'Gate' ) + Ocontrol_m3p1ValOne = control_m3p1.OutPort( 'ValOne' , 'long' ) + Ocontrol_m3p1ValEven = control_m3p1.OutPort( 'ValEven' , 'long' ) + Ocontrol_m3p1NT = control_m3p1.OutPort( 'NT' , 'long' ) + Ocontrol_m3p1KT = control_m3p1.OutPort( 'KT' , 'long' ) + Ocontrol_m3p1Gate = control_m3p1.GetOutPort( 'Gate' ) + + Pycontrol_div2 = [] + Pycontrol_div2.append( 'def control_div2( N , NB ) :' ) + Pycontrol_div2.append( ' return N,NB' ) + control_div2 = GraphGOTO.GNode( 'control_div2' , Pycontrol_div2 , 'label_begin' ) + control_div2.SetName( 'control_div2' ) + control_div2.SetAuthor( '' ) + control_div2.SetComment( 'Compute Node' ) + control_div2.Coords( 1128 , 453 ) + Icontrol_div2N = control_div2.InPort( 'N' , 'long' ) + Icontrol_div2K = control_div2.InPort( 'K' , 'long' ) + Icontrol_div2Gate = control_div2.GetInPort( 'Gate' ) + Ocontrol_div2NB = control_div2.OutPort( 'NB' , 'long' ) + Ocontrol_div2KB = control_div2.OutPort( 'KB' , 'long' ) + Ocontrol_div2Gate = control_div2.GetOutPort( 'Gate' ) + + # Creation of Links + Ltest_ISEVENBoolEvenlabel_testValEven = GraphGOTO.Link( Otest_ISEVENBoolEven , Ilabel_testValEven ) + Ltest_ISEVENBoolEvenlabel_testValEven.AddCoord( 1 , 369 , 273 ) + Ltest_ISEVENBoolEvenlabel_testValEven.AddCoord( 2 , 370 , 498 ) + + Ltest_ISONEBoolOnelabel_testValOne = GraphGOTO.Link( Otest_ISONEBoolOne , Ilabel_testValOne ) + Ltest_ISONEBoolOnelabel_testValOne.AddCoord( 1 , 385 , 303 ) + Ltest_ISONEBoolOnelabel_testValOne.AddCoord( 2 , 384 , 225 ) + + Lm3p1anEvenIntegercontrol_m3p1N = GraphGOTO.Link( Om3p1anEvenInteger , Icontrol_m3p1N ) + + Ldiv2anIntegercontrol_div2N = GraphGOTO.Link( Odiv2anInteger , Icontrol_div2N ) + + LincraNewCountcontrol_m3p1K = GraphGOTO.Link( OincraNewCount , Icontrol_m3p1K ) + LincraNewCountcontrol_m3p1K.AddCoord( 1 , 1048 , 139 ) + LincraNewCountcontrol_m3p1K.AddCoord( 2 , 1048 , 241 ) + + Lincr_1aNewCountcontrol_div2K = GraphGOTO.Link( Oincr_1aNewCount , Icontrol_div2K ) + + Llabel_beginNTlabel_testNT = GraphGOTO.Link( Olabel_beginNT , Ilabel_testNT ) + + Llabel_beginNTtest_ISONEanInteger = GraphGOTO.Link( Olabel_beginNT , Itest_ISONEanInteger ) + Llabel_beginNTtest_ISONEanInteger.AddCoord( 1 , 192 , 226 ) + Llabel_beginNTtest_ISONEanInteger.AddCoord( 2 , 191 , 331 ) + + Llabel_beginNTtest_ISEVENanInteger = GraphGOTO.Link( Olabel_beginNT , Itest_ISEVENanInteger ) + Llabel_beginNTtest_ISEVENanInteger.AddCoord( 1 , 191 , 494 ) + Llabel_beginNTtest_ISEVENanInteger.AddCoord( 2 , 192 , 331 ) + + Llabel_beginKTlabel_testKT = GraphGOTO.Link( Olabel_beginKT , Ilabel_testKT ) + + Llabel_testValEventestValEven = GraphGOTO.Link( Olabel_testValEven , ItestValEven ) + Llabel_testValEventestValEven.AddCoord( 1 , 587 , 318 ) + Llabel_testValEventestValEven.AddCoord( 2 , 570 , 318 ) + Llabel_testValEventestValEven.AddCoord( 3 , 569 , 272 ) + + Llabel_testValOnetestValOne = GraphGOTO.Link( Olabel_testValOne , ItestValOne ) + Llabel_testValOnetestValOne.AddCoord( 1 , 585 , 273 ) + Llabel_testValOnetestValOne.AddCoord( 2 , 586 , 303 ) + + Llabel_testNTtestNT = GraphGOTO.Link( Olabel_testNT , ItestNT ) + + Llabel_testKTtestKT = GraphGOTO.Link( Olabel_testKT , ItestKT ) + + LtestFinishedEndSwitch_OneEvenFinished = GraphGOTO.Link( OtestFinished , IEndSwitch_OneEvenFinished ) + + LtestEvenincr_1Gate = GraphGOTO.Link( OtestEven , Iincr_1Gate ) + + LtestEvendiv2Gate = GraphGOTO.Link( OtestEven , Idiv2Gate ) + LtestEvendiv2Gate.AddCoord( 1 , 793 , 561 ) + LtestEvendiv2Gate.AddCoord( 2 , 794 , 310 ) + + LtestOddincrGate = GraphGOTO.Link( OtestOdd , IincrGate ) + + LtestOddm3p1Gate = GraphGOTO.Link( OtestOdd , Im3p1Gate ) + LtestOddm3p1Gate.AddCoord( 1 , 778 , 138 ) + LtestOddm3p1Gate.AddCoord( 2 , 780 , 328 ) + + LtestNm3p1anOddInteger = GraphGOTO.Link( OtestN , Im3p1anOddInteger ) + LtestNm3p1anOddInteger.AddCoord( 1 , 808 , 113 ) + LtestNm3p1anOddInteger.AddCoord( 2 , 807 , 352 ) + + LtestNdiv2anEvenInteger = GraphGOTO.Link( OtestN , Idiv2anEvenInteger ) + LtestNdiv2anEvenInteger.AddCoord( 1 , 806 , 537 ) + LtestNdiv2anEvenInteger.AddCoord( 2 , 807 , 351 ) + + LtestKEndSwitch_OneEvenK = GraphGOTO.Link( OtestK , IEndSwitch_OneEvenK ) + + LtestKincraCount = GraphGOTO.Link( OtestK , IincraCount ) + LtestKincraCount.AddCoord( 1 , 773 , 236 ) + LtestKincraCount.AddCoord( 2 , 773 , 370 ) + + LtestKincr_1aCount = GraphGOTO.Link( OtestK , Iincr_1aCount ) + LtestKincr_1aCount.AddCoord( 1 , 774 , 409 ) + LtestKincr_1aCount.AddCoord( 2 , 773 , 368 ) + + LtestDefaultEndSwitch_OneEvenDefault = GraphGOTO.Link( OtestDefault , IEndSwitch_OneEvenDefault ) + LtestDefaultEndSwitch_OneEvenDefault.AddCoord( 1 , 840 , 381 ) + LtestDefaultEndSwitch_OneEvenDefault.AddCoord( 2 , 839 , 394 ) + + Lcontrol_m3p1Gatelabel_testGate = GraphGOTO.Link( Ocontrol_m3p1Gate , Ilabel_testGate ) + Lcontrol_m3p1Gatelabel_testGate.AddCoord( 1 , 388 , 388 ) + Lcontrol_m3p1Gatelabel_testGate.AddCoord( 2 , 389 , 597 ) + Lcontrol_m3p1Gatelabel_testGate.AddCoord( 3 , 1441 , 604 ) + Lcontrol_m3p1Gatelabel_testGate.AddCoord( 4 , 1441 , 199 ) + + Lcontrol_div2Gatelabel_beginGate = GraphGOTO.Link( Ocontrol_div2Gate , Ilabel_beginGate ) + Lcontrol_div2Gatelabel_beginGate.AddCoord( 1 , 4 , 388 ) + Lcontrol_div2Gatelabel_beginGate.AddCoord( 2 , 3 , 587 ) + Lcontrol_div2Gatelabel_beginGate.AddCoord( 3 , 1307 , 586 ) + Lcontrol_div2Gatelabel_beginGate.AddCoord( 4 , 1307 , 528 ) + + # Input datas + Ilabel_beginNB.Input( 7 ) + Ilabel_beginKB.Input( 0 ) + + # Output Ports of the graph + #OtestIncr = test.GetOutPort( 'Incr' ) + #OEndSwitch_OneEvenFinished = EndSwitch_OneEven.GetOutPort( 'Finished' ) + #OEndSwitch_OneEvenK = EndSwitch_OneEven.GetOutPort( 'K' ) + return GraphGOTO + + +GraphGOTO = DefGraphGOTO() GraphGOTO.Run() diff --git a/examples/GraphGOTO.xml b/examples/GraphGOTO.xml index 27ba57d..fc3884b 100644 --- a/examples/GraphGOTO.xml +++ b/examples/GraphGOTO.xml @@ -1,727 +1,757 @@ - + + ? - ? - GraphSyrControl - 1 - ? - -GraphSyrControl - + ? + GraphGOTO_2 + 1 + ? + +GraphGOTO_2 + long - label_begin\NB - + label_begin__NB + long - label_begin\KB - + label_begin__KB + long - EndSwitch_OneEven\Finished - + test__Incr + long - EndSwitch_OneEven\K - - - 11/3/2003 - 18:34:21 - 18/9/2003 - 17:27:23 - 1.04 - JR - ? - Syracuse algorithm - 0 - 0 - + EndSwitch_OneEven__Finished + +long + EndSwitch_OneEven__K + + + 17/1/2005 - 13:44:46 + 17/1/2005 - 13:47:40 + 2.0 + JR + ? + Syracuse algorithm + 0 + 0 + SyrComponent - SyrComponent - test_ISEVEN - 0 - ? - + SyrComponent + test_ISEVEN + 0 + ? + C_ISEVEN - + long - anInteger - + anInteger + long - BoolEven - - - 18/9/2003 - 17:27:22 - 18/9/2003 - 17:27:22 - 1.04 - ? - localhost/FactoryServer - C_ISEVEN from SyrComponent - 195 - 417 - + BoolEven + + + 17/1/2005 - 13:45:36 + 17/1/2005 - 13:45:36 + 2.0 + ? + localhost/FactoryServer + C_ISEVEN from SyrComponent + 195 + 417 + SyrComponent - SyrComponent - test_ISONE - 0 - ? - + SyrComponent + test_ISONE + 0 + ? + C_ISONE - + long - anInteger - + anInteger + long - BoolOne - - - 18/9/2003 - 17:27:22 - 18/9/2003 - 17:27:22 - 1.04 - ? - localhost/FactoryServer - C_ISONE from SyrComponent - 201 - 145 - + BoolOne + + + 17/1/2005 - 13:45:36 + 17/1/2005 - 13:45:36 + 2.0 + ? + localhost/FactoryServer + C_ISONE from SyrComponent + 201 + 145 + SyrComponent - SyrComponent - m3p1 - 0 - ? - + SyrComponent + m3p1 + 0 + ? + C_M3P1 - + long - anOddInteger - + anOddInteger + long - anEvenInteger - - - 18/9/2003 - 17:27:22 - 18/9/2003 - 17:27:22 - 1.04 - ? - localhost/FactoryServer - C_M3P1 from SyrComponent - 784 - 36 - + anEvenInteger + + + 17/1/2005 - 13:45:36 + 17/1/2005 - 13:45:36 + 2.0 + ? + localhost/FactoryServer + C_M3P1 from SyrComponent + 861 + 46 + SyrComponent - SyrComponent - div2 - 0 - ? - + SyrComponent + div2 + 0 + ? + C_DIV2 - + + +long + anEvenInteger + + +long + anInteger + + + 17/1/2005 - 13:45:36 + 17/1/2005 - 13:45:36 + 2.0 + ? + localhost/FactoryServer + C_DIV2 from SyrComponent + 858 + 466 + +SyrComponent + SyrComponent + incr + 0 + ? + +C_INCR + long - anEvenInteger - + aCount + long - anInteger - - - 18/9/2003 - 17:27:22 - 18/9/2003 - 17:27:22 - 1.04 - ? - localhost/FactoryServer - C_DIV2 from SyrComponent - 788 - 409 - + aNewCount + + + 17/1/2005 - 13:45:36 + 17/1/2005 - 13:45:36 + 2.0 + ? + localhost/FactoryServer + C_INCR from SyrComponent + 865 + 169 + SyrComponent - SyrComponent - incr - 0 - ? - + SyrComponent + incr_1 + 0 + ? + C_INCR - + long - aCount - + aCount + long - aNewCount - - - 18/9/2003 - 17:27:23 - 18/9/2003 - 17:27:23 - 1.04 - ? - localhost/FactoryServer - C_INCR from SyrComponent - 788 - 230 - + aNewCount + + + 17/1/2005 - 13:45:36 + 17/1/2005 - 13:45:36 + 2.0 + ? + localhost/FactoryServer + C_INCR from SyrComponent + 859 + 338 + ? - ? - label_begin - 3 - ? - + ? + label_begin + 3 + ? + label_begin - + long - NB - + NB + long - KB - + KB + long - NT - + NT + long - KT - - + KT + + label_begin - - - - 18/9/2003 - 17:27:23 - 18/9/2003 - 17:27:23 - 1.04 - ? - ? - Python function - 9 - 250 - + + + + 17/1/2005 - 13:45:36 + 17/1/2005 - 13:45:36 + 2.0 + ? + ? + Python function + 9 + 250 + ? - ? - label_test - 3 - ? - + ? + label_test + 3 + ? + label_test - + long - ValEven - + ValEven + long - ValOne - + ValOne + long - NT - + NT + long - KT - + KT + long - ValEven - + ValEven + long - ValOne - + ValOne + long - NT - + NT + long - KT - - + KT + + label_test - - - - 18/9/2003 - 17:27:23 - 18/9/2003 - 17:27:23 - 1.04 - ? - ? - Python function - 396 - 193 - + + + + 17/1/2005 - 13:45:36 + 17/1/2005 - 13:45:36 + 2.0 + ? + ? + Python function + 396 + 193 + ? - ? - test - 6 - EndSwitch_OneEven - + ? + test + 6 + EndSwitch_OneEven + test - + long - ValOne - + ValOne + long - ValEven - + ValEven + long - NT - + NT + long - KT - + KT + long - Finished - + Finished + long - Incr - + Incr + long - Even - + Even + long - Odd - + Odd + long - N - + N + long - K - - + K + + Switch_OneEven - - - - - - - - - - - - - - - - 18/9/2003 - 17:27:23 - 18/9/2003 - 17:27:23 - 1.04 - ? - ? - ? - 595 - 239 - + + + + + + + + + + + + + + + + 17/1/2005 - 13:45:36 + 17/1/2005 - 13:45:36 + 2.0 + ? + ? + Compute Node + 595 + 239 + ? - ? - EndSwitch_OneEven - 7 - test - + ? + EndSwitch_OneEven + 7 + test + EndSwitch_OneEven - + long - Finished - + Finished + long - K - + K + long - Finished - + Finished + long - K - - + K + + EndSwitch_OneEven - - - - 18/9/2003 - 17:27:23 - 18/9/2003 - 17:27:23 - 1.04 - ? - ? - ? - 1152 - 292 - + + + + 17/1/2005 - 13:45:36 + 17/1/2005 - 13:45:36 + 2.0 + ? + ? + Compute Node + 1256 + 305 + ? - ? - control_m3p1 - 8 - label_test - + ? + control_m3p1 + 8 + label_test + control_m3p1 - + long - N - + N + long - K - + K + long - ValOne - + ValOne + long - ValEven - + ValEven + long - NT - + NT + long - KT - - + KT + + control_m3p1 - - - 18/9/2003 - 17:27:23 - 18/9/2003 - 17:27:23 - 1.04 - ? - ? - ? - 980 - 81 - + + + 17/1/2005 - 13:45:36 + 17/1/2005 - 13:45:36 + 2.0 + ? + ? + Compute Node + 1073 + 87 + ? - ? - control_div2 - 8 - label_begin - + ? + control_div2 + 8 + label_begin + control_div2 - + long - N - + N + long - K - + K + long - NB - + NB + long - KB - - + KB + + control_div2 - - - 18/9/2003 - 17:27:23 - 18/9/2003 - 17:27:23 - 1.04 - ? - ? - ? - 1039 - 454 - + + + 17/1/2005 - 13:45:36 + 17/1/2005 - 13:45:36 + 2.0 + ? + ? + Compute Node + 1128 + 453 + test_ISEVEN - BoolEven - label_test - ValEven - + BoolEven + label_test + ValEven + 369 - 273 - + 273 + 370 - 498 - + 498 + test_ISONE - BoolOne - label_test - ValOne - + BoolOne + label_test + ValOne + 385 - 303 - + 303 + 384 - 225 - + 225 + m3p1 - anEvenInteger - control_m3p1 - N - - + anEvenInteger + control_m3p1 + N + + div2 - anInteger - control_div2 - N - - -incr - aNewCount - control_m3p1 - K - - -964 - 145 - -964 - 309 - + anInteger + control_div2 + N + + incr - aNewCount - control_div2 - K - + aNewCount + control_m3p1 + K + -963 - 518 - -964 - 312 - +1048 + 139 + +1048 + 241 + +incr_1 + aNewCount + control_div2 + K + + label_begin - NT - label_test - NT - - + NT + label_test + NT + + label_begin - NT - test_ISONE - anInteger - + NT + test_ISONE + anInteger + 192 - 226 - + 226 + 191 - 331 - + 331 + label_begin - NT - test_ISEVEN - anInteger - + NT + test_ISEVEN + anInteger + 191 - 494 - + 494 + 192 - 331 - + 331 + label_begin - KT - label_test - KT - - + KT + label_test + KT + + label_test - ValEven - test - ValEven - + ValEven + test + ValEven + 587 - 318 - + 318 + 570 - 318 - + 318 + 569 - 272 - + 272 + label_test - ValOne - test - ValOne - + ValOne + test + ValOne + 585 - 273 - + 273 + 586 - 303 - + 303 + label_test - NT - test - NT - - + NT + test + NT + + label_test - KT - test - KT - - + KT + test + KT + + test - Finished - EndSwitch_OneEven - Finished - - + Finished + EndSwitch_OneEven + Finished + + test - Incr - incr - InGate - - -783 - 341 - -782 - 302 - + Even + incr_1 + Gate + + test - Even - div2 - InGate - + Even + div2 + Gate + -754 - 518 - -753 - 330 - +793 + 561 + +794 + 310 + test - Odd - m3p1 - InGate - + Odd + incr + Gate + + +test + Odd + m3p1 + Gate + -758 - 145 - -760 - 359 - +778 + 138 + +780 + 328 + test - N - m3p1 - anOddInteger - + N + m3p1 + anOddInteger + -767 - 116 - -767 - 116 - -767 - 390 - +808 + 113 + +807 + 352 + test - N - div2 - anEvenInteger - + N + div2 + anEvenInteger + -767 - 489 - -766 - 389 - +806 + 537 + +807 + 351 + test - K - EndSwitch_OneEven - K - - + K + EndSwitch_OneEven + K + + test - K - incr - aCount - + K + incr + aCount + -772 - 311 - -772 - 417 - -772 - 417 - +773 + 236 + +773 + 370 + test - Default - EndSwitch_OneEven - Default - + K + incr_1 + aCount + -778 - 384 - -778 - 448 - +774 + 409 + +773 + 368 + +test + Default + EndSwitch_OneEven + Default + + +840 + 381 + +839 + 394 + control_m3p1 - OutGate - label_test - InGate - + Gate + label_test + Gate + 388 - 388 - + 388 + 389 - 597 - -1319 - 597 - -1318 - 231 - + 597 + +1441 + 604 + +1441 + 199 + control_div2 - OutGate - label_begin - InGate - + Gate + label_begin + Gate + 4 - 388 - + 388 + 3 - 587 - -1214 - 588 - -1213 - 546 - + 587 + +1307 + 586 + +1307 + 528 + -GraphSyrControl - label_begin\NB - label_begin - NB - +GraphGOTO_2 + label_begin__NB + label_begin + NB + 3 - 7 - - -GraphSyrControl - label_begin\KB - label_begin - KB - + 7 + + +GraphGOTO_2 + label_begin__KB + label_begin + KB + 3 - 0 - + 0 + diff --git a/examples/GraphImportSalome.py b/examples/GraphImportSalome.py new file mode 100644 index 0000000..71e7de5 --- /dev/null +++ b/examples/GraphImportSalome.py @@ -0,0 +1,37 @@ + +# Generated python file of Graph aNewDataFlow + +from SuperV import * + +# Graph creation of aNewDataFlow +def DefaNewDataFlow() : + aNewDataFlow = Graph( 'aNewDataFlow' ) + aNewDataFlow.SetName( 'aNewDataFlow' ) + aNewDataFlow.SetAuthor( '' ) + aNewDataFlow.SetComment( '' ) + aNewDataFlow.Coords( 0 , 0 ) + + # Creation of Factory Nodes + + # Creation of InLine Nodes + PyVoidFunction = [] + PyVoidFunction.append( 'import salome ' ) + PyVoidFunction.append( 'def VoidFunction() : ' ) + PyVoidFunction.append( ' print 'VoidFunction()' ' ) + PyVoidFunction.append( ' return 'Done' ' ) + PyVoidFunction.append( '' ) + VoidFunction = aNewDataFlow.INode( 'VoidFunction' , PyVoidFunction ) + VoidFunction.SetName( 'VoidFunction' ) + VoidFunction.SetAuthor( '' ) + VoidFunction.SetComment( 'Compute Node' ) + VoidFunction.Coords( 60 , 58 ) + IVoidFunctionGate = VoidFunction.GetInPort( 'Gate' ) + OVoidFunctionDone = VoidFunction.OutPort( 'Done' , 'string' ) + OVoidFunctionGate = VoidFunction.GetOutPort( 'Gate' ) + + # Output Ports of the graph + #OVoidFunctionDone = VoidFunction.GetOutPort( 'Done' ) + return aNewDataFlow + + +aNewDataFlow = DefaNewDataFlow() diff --git a/examples/GraphImportSalome.xml b/examples/GraphImportSalome.xml new file mode 100644 index 0000000..86db1d1 --- /dev/null +++ b/examples/GraphImportSalome.xml @@ -0,0 +1,60 @@ + + + + + +? + ? + aNewDataFlow + 1 + ? + +aNewDataFlow + + + +string + VoidFunction__Done + + + 8/12/2004 - 12:52:44 + 8/12/2004 - 16:0:49 + 2.0 + ? + ? + ? + 0 + 0 + + +? + ? + VoidFunction + 3 + ? + +VoidFunction + + + +string + Done + + + +VoidFunction + + + + + + 8/12/2004 - 16:0:49 + 8/12/2004 - 16:0:49 + 2.0 + ? + ? + Compute Node + 60 + 58 + + diff --git a/examples/GraphInputInLoop.py b/examples/GraphInputInLoop.py new file mode 100644 index 0000000..eff96a9 --- /dev/null +++ b/examples/GraphInputInLoop.py @@ -0,0 +1,152 @@ + +# Generated python file of Graph GraphInputInLoop_2 + +from SuperV import * + +# Graph creation of GraphInputInLoop_2 +def DefGraphInputInLoop_2() : + GraphInputInLoop_2 = Graph( 'GraphInputInLoop_2' ) + GraphInputInLoop_2.SetName( 'GraphInputInLoop_2' ) + GraphInputInLoop_2.SetAuthor( '' ) + GraphInputInLoop_2.SetComment( '' ) + GraphInputInLoop_2.Coords( 0 , 0 ) + + # Creation of Factory Nodes + + # Creation of InLine Nodes + PyIsOdd = [] + PyIsOdd.append( 'from time import * ' ) + PyIsOdd.append( 'def IsOdd(a,Even,Const) : ' ) + PyIsOdd.append( ' print 'IsOdd',a,Even,Const ' ) + PyIsOdd.append( ' sleep( 1 ) ' ) + PyIsOdd.append( ' return a,Const ' ) + IsOdd = GraphInputInLoop_2.INode( 'IsOdd' , PyIsOdd ) + IsOdd.SetName( 'IsOdd' ) + IsOdd.SetAuthor( '' ) + IsOdd.SetComment( 'Python function' ) + IsOdd.Coords( 397 , 1 ) + IIsOdda = IsOdd.InPort( 'a' , 'long' ) + IIsOddEven = IsOdd.InPort( 'Even' , 'boolean' ) + IIsOddConst = IsOdd.InPort( 'Const' , 'string' ) + IIsOddGate = IsOdd.GetInPort( 'Gate' ) + OIsOdda = IsOdd.OutPort( 'a' , 'long' ) + OIsOddConst = IsOdd.OutPort( 'Const' , 'string' ) + OIsOddGate = IsOdd.GetOutPort( 'Gate' ) + + # Creation of Loop Nodes + PyInitLoop = [] + PyMoreInitLoop = [] + PyMoreInitLoop.append( '' ) + PyNextInitLoop = [] + PyNextInitLoop.append( '' ) + InitLoop,EndOfInitLoop = GraphInputInLoop_2.LNode( '' , PyInitLoop , '' , PyMoreInitLoop , '' , PyNextInitLoop ) + EndOfInitLoop.SetName( 'EndOfInitLoop' ) + EndOfInitLoop.SetAuthor( '' ) + EndOfInitLoop.SetComment( 'Compute Node' ) + EndOfInitLoop.Coords( 767 , 105 ) + PyEndOfInitLoop = [] + PyEndOfInitLoop.append( 'def EndOfInitLoop( DoLoop , Index , Min , Max ) :' ) + PyEndOfInitLoop.append( ' Index = Index + 1 ' ) + PyEndOfInitLoop.append( ' if Index <= Max : ' ) + PyEndOfInitLoop.append( ' DoLoop = 1 ' ) + PyEndOfInitLoop.append( ' else : ' ) + PyEndOfInitLoop.append( ' DoLoop = 0 ' ) + PyEndOfInitLoop.append( ' return DoLoop,Index,Min,Max ' ) + EndOfInitLoop.SetPyFunction( 'EndOfInitLoop' , PyEndOfInitLoop ) + IInitLoopDoLoop = InitLoop.GetInPort( 'DoLoop' ) + IInitLoopIndex = InitLoop.InPort( 'Index' , 'long' ) + IInitLoopMin = InitLoop.InPort( 'Min' , 'long' ) + IInitLoopMax = InitLoop.InPort( 'Max' , 'long' ) + IInitLoopGate = InitLoop.GetInPort( 'Gate' ) + OInitLoopDoLoop = InitLoop.GetOutPort( 'DoLoop' ) + OInitLoopIndex = InitLoop.GetOutPort( 'Index' ) + OInitLoopMin = InitLoop.GetOutPort( 'Min' ) + OInitLoopMax = InitLoop.GetOutPort( 'Max' ) + IEndOfInitLoopDoLoop = EndOfInitLoop.GetInPort( 'DoLoop' ) + IEndOfInitLoopIndex = EndOfInitLoop.GetInPort( 'Index' ) + IEndOfInitLoopMin = EndOfInitLoop.GetInPort( 'Min' ) + IEndOfInitLoopMax = EndOfInitLoop.GetInPort( 'Max' ) + IEndOfInitLoopGate = EndOfInitLoop.GetInPort( 'Gate' ) + OEndOfInitLoopDoLoop = EndOfInitLoop.GetOutPort( 'DoLoop' ) + OEndOfInitLoopIndex = EndOfInitLoop.GetOutPort( 'Index' ) + OEndOfInitLoopMin = EndOfInitLoop.GetOutPort( 'Min' ) + OEndOfInitLoopMax = EndOfInitLoop.GetOutPort( 'Max' ) + OEndOfInitLoopGate = EndOfInitLoop.GetOutPort( 'Gate' ) + InitLoop.SetName( 'InitLoop' ) + InitLoop.SetAuthor( '' ) + InitLoop.SetComment( 'Compute Node' ) + InitLoop.Coords( 10 , 108 ) + + # Creation of Switch Nodes + PySwitch = [] + PySwitch.append( 'from time import * ' ) + PySwitch.append( 'def Switch(a) : ' ) + PySwitch.append( ' if ( a & 1 ) == 0 : ' ) + PySwitch.append( ' sleep(1) ' ) + PySwitch.append( ' return a & 1,1-(a&1),a ' ) + Switch,EndSwitch = GraphInputInLoop_2.SNode( 'Switch' , PySwitch ) + EndSwitch.SetName( 'EndSwitch' ) + EndSwitch.SetAuthor( '' ) + EndSwitch.SetComment( 'Compute Node' ) + EndSwitch.Coords( 587 , 105 ) + PyEndSwitch = [] + PyEndSwitch.append( 'def EndSwitch(a) : ' ) + PyEndSwitch.append( ' if ( a & 1 ) == 0 : ' ) + PyEndSwitch.append( ' sleep(1) ' ) + PyEndSwitch.append( ' return a ' ) + EndSwitch.SetPyFunction( 'EndSwitch' , PyEndSwitch ) + IEndSwitcha = EndSwitch.InPort( 'a' , 'long' ) + IEndSwitchDefault = EndSwitch.GetInPort( 'Default' ) + OEndSwitcha = EndSwitch.OutPort( 'a' , 'long' ) + OEndSwitchGate = EndSwitch.GetOutPort( 'Gate' ) + Switch.SetName( 'Switch' ) + Switch.SetAuthor( '' ) + Switch.SetComment( 'Compute Node' ) + Switch.Coords( 194 , 109 ) + ISwitcha = Switch.InPort( 'a' , 'long' ) + ISwitchGate = Switch.GetInPort( 'Gate' ) + OSwitchOdd = Switch.OutPort( 'Odd' , 'long' ) + OSwitchEven = Switch.OutPort( 'Even' , 'int' ) + OSwitcha = Switch.OutPort( 'a' , 'int' ) + OSwitchDefault = Switch.GetOutPort( 'Default' ) + + # Creation of Links + LIsOddaEndSwitcha = GraphInputInLoop_2.Link( OIsOdda , IEndSwitcha ) + LIsOddaEndSwitcha.AddCoord( 1 , 576 , 136 ) + LIsOddaEndSwitcha.AddCoord( 2 , 576 , 73 ) + + LInitLoopIndexSwitcha = GraphInputInLoop_2.Link( OInitLoopIndex , ISwitcha ) + + LInitLoopMinEndOfInitLoopMin = GraphInputInLoop_2.Link( OInitLoopMin , IEndOfInitLoopMin ) + + LInitLoopMaxEndOfInitLoopMax = GraphInputInLoop_2.Link( OInitLoopMax , IEndOfInitLoopMax ) + + LSwitchOddIsOddGate = GraphInputInLoop_2.Link( OSwitchOdd , IIsOddGate ) + + LSwitchEvenEndSwitchDefault = GraphInputInLoop_2.Link( OSwitchEven , IEndSwitchDefault ) + + LSwitchEvenIsOddEven = GraphInputInLoop_2.Link( OSwitchEven , IIsOddEven ) + LSwitchEvenIsOddEven.AddCoord( 1 , 375 , 92 ) + LSwitchEvenIsOddEven.AddCoord( 2 , 375 , 159 ) + + LSwitchaIsOdda = GraphInputInLoop_2.Link( OSwitcha , IIsOdda ) + LSwitchaIsOdda.AddCoord( 1 , 366 , 71 ) + LSwitchaIsOdda.AddCoord( 2 , 366 , 182 ) + + LEndSwitchaEndOfInitLoopIndex = GraphInputInLoop_2.Link( OEndSwitcha , IEndOfInitLoopIndex ) + + # Input datas + IIsOddConst.Input( 'Const Input Value' ) + IInitLoopIndex.Input( 0 ) + IInitLoopMin.Input( 0 ) + IInitLoopMax.Input( 100 ) + + # Output Ports of the graph + #OIsOddConst = IsOdd.GetOutPort( 'Const' ) + #OEndOfInitLoopIndex = EndOfInitLoop.GetOutPort( 'Index' ) + #OEndOfInitLoopMin = EndOfInitLoop.GetOutPort( 'Min' ) + #OEndOfInitLoopMax = EndOfInitLoop.GetOutPort( 'Max' ) + return GraphInputInLoop_2 + + +GraphInputInLoop_2 = DefGraphInputInLoop_2() diff --git a/examples/GraphInputInLoop.xml b/examples/GraphInputInLoop.xml new file mode 100644 index 0000000..b15d875 --- /dev/null +++ b/examples/GraphInputInLoop.xml @@ -0,0 +1,378 @@ + + + + + +? + ? + GraphInputInLoop_2 + 1 + ? + +GraphInputInLoop_2 + + +string + IsOdd__Const + +long + InitLoop__Index + +long + InitLoop__Min + +long + InitLoop__Max + + +string + IsOdd__Const + +long + EndOfInitLoop__Index + +long + EndOfInitLoop__Min + +long + EndOfInitLoop__Max + + + 22/10/2003 - 10:36:39 + 7/1/2005 - 16:47:59 + 1.05 + ? + ? + ? + 0 + 0 + + +? + ? + IsOdd + 3 + ? + +IsOdd + + +long + a + +boolean + Even + +string + Const + + +long + a + +string + Const + + + +IsOdd + + + + + + 7/1/2005 - 16:47:59 + 7/1/2005 - 16:47:59 + 1.05 + ? + ? + Python function + 397 + 1 + +? + ? + InitLoop + 4 + EndOfInitLoop + +InitLoop + + +long + Index + +long + Min + +long + Max + + +long + Index + +long + Min + +long + Max + + + +? + + +? + + +? + + 7/1/2005 - 16:47:59 + 7/1/2005 - 16:47:59 + 1.05 + ? + ? + Compute Node + 10 + 108 + +? + ? + EndOfInitLoop + 5 + InitLoop + +EndOfInitLoop + + +long + Index + +long + Min + +long + Max + + +long + Index + +long + Min + +long + Max + + + +EndOfInitLoop + + + + + + + + 7/1/2005 - 16:47:59 + 7/1/2005 - 16:47:59 + 1.05 + ? + ? + Compute Node + 767 + 105 + +? + ? + Switch + 6 + EndSwitch + +Switch + + +long + a + + +long + Odd + +int + Even + +int + a + + + +Switch + + + + + + 7/1/2005 - 16:47:59 + 7/1/2005 - 16:47:59 + 1.05 + ? + ? + Compute Node + 194 + 109 + +? + ? + EndSwitch + 7 + Switch + +EndSwitch + + +long + a + + +long + a + + + +EndSwitch + + + + + 7/1/2005 - 16:47:59 + 7/1/2005 - 16:47:59 + 1.05 + ? + ? + Compute Node + 587 + 105 + + +IsOdd + a + EndSwitch + a + + +576 + 136 + +576 + 73 + +InitLoop + DoLoop + EndOfInitLoop + DoLoop + + +InitLoop + Index + Switch + a + + +InitLoop + Min + EndOfInitLoop + Min + + +InitLoop + Max + EndOfInitLoop + Max + + +EndOfInitLoop + DoLoop + InitLoop + DoLoop + + +Switch + Odd + IsOdd + Gate + + +Switch + Even + EndSwitch + Default + + +Switch + Even + IsOdd + Even + + +375 + 92 + +375 + 159 + +Switch + a + IsOdd + a + + +366 + 71 + +366 + 182 + +EndSwitch + a + EndOfInitLoop + Index + + + +GraphInputInLoop_2 + IsOdd__Const + IsOdd + Const + +18 + Const Input Value + + +GraphInputInLoop_2 + InitLoop__Index + InitLoop + Index + +3 + 0 + + +GraphInputInLoop_2 + InitLoop__Min + InitLoop + Min + +3 + 0 + + +GraphInputInLoop_2 + InitLoop__Max + InitLoop + Max + +3 + 100 + diff --git a/examples/GraphKillSuspend.py b/examples/GraphKillSuspend.py new file mode 100644 index 0000000..03edd48 --- /dev/null +++ b/examples/GraphKillSuspend.py @@ -0,0 +1,40 @@ +from GraphEssai import * +import time + +exec GraphEssai.ListNodes('GraphEssai') + +GraphEssai.Run() +time.sleep(10) +GraphEssai.Kill() +print 'Add :',Add.State() +print 'Sub :',Sub.State() +print 'Mul :',Mul.State() +print 'Div :',Div.State() +print 'GraphEssai :',GraphEssai.State() + + +GraphEssai.Run() +time.sleep(5) +GraphEssai.Suspend() +print 'Add :',Add.State() +print 'Sub :',Sub.State() +print 'Mul :',Mul.State() +print 'Div :',Div.State() +print 'GraphEssai :',GraphEssai.State() +GraphEssai.Resume() +time.sleep(5) +print 'Add :',Add.State() +print 'Sub :',Sub.State() +print 'Mul :',Mul.State() +print 'Div :',Div.State() +print 'GraphEssai :',GraphEssai.State() + +GraphEssai.DoneW() +GraphEssai.PrintPorts() +time.sleep(1) +print 'Add :',Add.State() +print 'Sub :',Sub.State() +print 'Mul :',Mul.State() +print 'Div :',Div.State() +print 'GraphEssai :',GraphEssai.State() + diff --git a/examples/GraphLoop.py b/examples/GraphLoop.py index 8488517..9bb211b 100644 --- a/examples/GraphLoop.py +++ b/examples/GraphLoop.py @@ -2,80 +2,93 @@ # Generated python file of Graph GraphLoop from SuperV import * -# Graph creation -GraphLoop = Graph( 'GraphLoop' ) -GraphLoop.SetName( 'GraphLoop' ) -GraphLoop.SetAuthor( '' ) -GraphLoop.SetComment( '' ) -GraphLoop.Coords( 0 , 0 ) -# Creation of Factory Nodes +# Graph creation of GraphLoop +def DefGraphLoop() : + GraphLoop = Graph( 'GraphLoop' ) + GraphLoop.SetName( 'GraphLoop' ) + GraphLoop.SetAuthor( '' ) + GraphLoop.SetComment( '' ) + GraphLoop.Coords( 0 , 0 ) + + # Creation of Factory Nodes + + # Creation of Loop Nodes + PyInit = [] + PyInit.append( 'def Init(Index,Min,Max,Incr) : ' ) + PyInit.append( ' if Min <= Max : ' ) + PyInit.append( ' Index = Min ' ) + PyInit.append( ' else : ' ) + PyInit.append( ' Index = Max ' ) + PyInit.append( ' return Index,Min,Max,Incr ' ) + PyMoreInit = [] + PyMoreInit.append( 'import time ' ) + PyMoreInit.append( 'def More(Index,Min,Max,Incr) : ' ) + PyMoreInit.append( ' time.sleep(2) ' ) + PyMoreInit.append( ' if Index < Max : ' ) + PyMoreInit.append( ' DoLoop = 1 ' ) + PyMoreInit.append( ' else : ' ) + PyMoreInit.append( ' DoLoop = 0 ' ) + PyMoreInit.append( ' return DoLoop,Index,Min,Max,Incr ' ) + PyNextInit = [] + PyNextInit.append( 'def Next(Index,Min,Max,Incr) : ' ) + PyNextInit.append( ' Index = Index + Incr ' ) + PyNextInit.append( ' return Index,Min,Max,Incr ' ) + Init,EndInit = GraphLoop.LNode( 'Init' , PyInit , 'More' , PyMoreInit , 'Next' , PyNextInit ) + EndInit.SetName( 'EndInit' ) + EndInit.SetAuthor( '' ) + EndInit.SetComment( 'Compute Node' ) + EndInit.Coords( 366 , 262 ) + PyEndInit = [] + EndInit.SetPyFunction( '' , PyEndInit ) + IInitInitLoop = Init.GetInPort( 'DoLoop' ) + IInitIndex = Init.InPort( 'Index' , 'long' ) + IInitMin = Init.InPort( 'Min' , 'long' ) + IInitMax = Init.InPort( 'Max' , 'long' ) + IInitIncr = Init.InPort( 'Incr' , 'long' ) + IInitGate = Init.GetInPort( 'Gate' ) + OInitDoLoop = Init.GetOutPort( 'DoLoop' ) + OInitIndex = Init.GetOutPort( 'Index' ) + OInitMin = Init.GetOutPort( 'Min' ) + OInitMax = Init.GetOutPort( 'Max' ) + OInitIncr = Init.GetOutPort( 'Incr' ) + IEndInitDoLoop = EndInit.GetInPort( 'DoLoop' ) + IEndInitIndex = EndInit.GetInPort( 'Index' ) + IEndInitMin = EndInit.GetInPort( 'Min' ) + IEndInitMax = EndInit.GetInPort( 'Max' ) + IEndInitIncr = EndInit.GetInPort( 'Incr' ) + IEndInitGate = EndInit.GetInPort( 'Gate' ) + OEndInitDoLoop = EndInit.GetOutPort( 'DoLoop' ) + OEndInitIndex = EndInit.GetOutPort( 'Index' ) + OEndInitMin = EndInit.GetOutPort( 'Min' ) + OEndInitMax = EndInit.GetOutPort( 'Max' ) + OEndInitIncr = EndInit.GetOutPort( 'Incr' ) + Init.SetName( 'Init' ) + Init.SetAuthor( '' ) + Init.SetComment( 'Compute Node' ) + Init.Coords( 17 , 257 ) + + # Creation of Links + LInitIndexEndInitIndex = GraphLoop.Link( OInitIndex , IEndInitIndex ) + + LInitMinEndInitMin = GraphLoop.Link( OInitMin , IEndInitMin ) + + LInitMaxEndInitMax = GraphLoop.Link( OInitMax , IEndInitMax ) + + LInitIncrEndInitIncr = GraphLoop.Link( OInitIncr , IEndInitIncr ) + + # Input datas + IInitIndex.Input( 0 ) + IInitMin.Input( 5 ) + IInitMax.Input( 10 ) + IInitIncr.Input( 1 ) + + # Output Ports of the graph + #OEndInitIndex = EndInit.GetOutPort( 'Index' ) + #OEndInitMin = EndInit.GetOutPort( 'Min' ) + #OEndInitMax = EndInit.GetOutPort( 'Max' ) + #OEndInitIncr = EndInit.GetOutPort( 'Incr' ) + return GraphLoop -# Creation of Loop Nodes -PyInit = [] -PyInit.append( 'def Init(Index,Min,Max,Incr) : ' ) -PyInit.append( ' if Min <= Max : ' ) -PyInit.append( ' Index = Min ' ) -PyInit.append( ' else : ' ) -PyInit.append( ' Index = Max ' ) -PyInit.append( ' return Index,Min,Max,Incr ' ) -PyMoreInit = [] -PyMoreInit.append( 'def More(Index,Min,Max,Incr) : ' ) -PyMoreInit.append( ' if Index < Max : ' ) -PyMoreInit.append( ' DoLoop = 1 ' ) -PyMoreInit.append( ' else : ' ) -PyMoreInit.append( ' DoLoop = 0 ' ) -PyMoreInit.append( ' return DoLoop,Index,Min,Max,Incr ' ) -PyNextInit = [] -PyNextInit.append( 'def Next(Index,Min,Max,Incr) : ' ) -PyNextInit.append( ' Index = Index + Incr ' ) -PyNextInit.append( ' return Index,Min,Max,Incr ' ) -Init,EndInit = GraphLoop.LNode( 'Init' , PyInit , 'More' , PyMoreInit , 'Next' , PyNextInit ) -EndInit.SetName( 'EndInit' ) -EndInit.SetAuthor( '' ) -EndInit.SetComment( '' ) -EndInit.Coords( 314 , 91 ) -Init.InPort( 'Index' , 'long' ) -Init.InPort( 'Min' , 'long' ) -Init.InPort( 'Max' , 'long' ) -Init.InPort( 'Incr' , 'long' ) -Init.OutPort( 'Index' , 'long' ) -Init.OutPort( 'Min' , 'long' ) -Init.OutPort( 'Max' , 'long' ) -Init.OutPort( 'Incr' , 'long' ) -Init.SetName( 'Init' ) -Init.SetAuthor( '' ) -Init.SetComment( '' ) -Init.Coords( 31 , 74 ) - -# Creation of Links -InitIndex = Init.Port( 'Index' ) -EndInitIndex = GraphLoop.Link( InitIndex , EndInit.Port( 'Index' ) ) - -InitMin = Init.Port( 'Min' ) -EndInitMin = GraphLoop.Link( InitMin , EndInit.Port( 'Min' ) ) - -InitMax = Init.Port( 'Max' ) -EndInitMax = GraphLoop.Link( InitMax , EndInit.Port( 'Max' ) ) - -InitIncr = Init.Port( 'Incr' ) -EndInitIncr = GraphLoop.Link( InitIncr , EndInit.Port( 'Incr' ) ) - -# Creation of Input datas -InitIndex = Init.Input( 'Index' , 0) -InitMin = Init.Input( 'Min' , 0) -InitMax = Init.Input( 'Max' , 1000) -InitIncr = Init.Input( 'Incr' , 1) - -# Creation of Output variables -EndInitIndex = EndInit.Port( 'Index' ) -EndInitMin = EndInit.Port( 'Min' ) -EndInitMax = EndInit.Port( 'Max' ) -EndInitIncr = EndInit.Port( 'Incr' ) - -GraphLoop.Run() - -GraphLoop.DoneW() - -GraphLoop.PrintPorts() +GraphLoop = DefGraphLoop() diff --git a/examples/GraphLoop.xml b/examples/GraphLoop.xml index 57ef977..f2ce0e4 100644 --- a/examples/GraphLoop.xml +++ b/examples/GraphLoop.xml @@ -1,232 +1,237 @@ - + + ? - ? - GraphLoop - 1 - ? - + ? + GraphLoop + 1 + ? + GraphLoop - + long - Init\Index - + Init__Index + long - Init\Min - + Init__Min + long - Init\Max - + Init__Max + long - Init\Incr - + Init__Incr + long - EndInit\Index - + EndInit__Index + long - EndInit\Min - + EndInit__Min + long - EndInit\Max - + EndInit__Max + long - EndInit\Incr - - - 24/3/2003 - 14:44:35 - 25/3/2003 - 9:50:2 - 1.04 - ? - ? - ? - 0 - 0 - + EndInit__Incr + + + 24/3/2003 - 14:44:35 + 16/12/2004 - 11:8:15 + 1.04 + ? + ? + ? + 0 + 0 + ? - ? - Init - 4 - EndInit - + ? + Init + 4 + EndInit + Init - + long - Index - + Index + long - Min - + Min + long - Max - + Max + long - Incr - + Incr + long - Index - + Index + long - Min - + Min + long - Max - + Max + long - Incr - - + Incr + + Init - - - - - - - + + + + + + + More - - - - - - - + + + + + + + + + Next - - - - 25/3/2003 - 9:50:2 - 25/3/2003 - 9:50:2 - 1.04 - ? - ? - ? - 17 - 257 - + + + + 16/12/2004 - 11:8:15 + 16/12/2004 - 11:8:15 + 1.04 + ? + ? + Compute Node + 17 + 257 + ? - ? - EndInit - 5 - Init - + ? + EndInit + 5 + Init + EndInit - + long - Index - + Index + long - Min - + Min + long - Max - + Max + long - Incr - + Incr + long - Index - + Index + long - Min - + Min + long - Max - + Max + long - Incr - - - - 25/3/2003 - 9:50:2 - 25/3/2003 - 9:50:2 - 1.04 - ? - ? - ? - 626 - 259 - + Incr + + + +? + + 16/12/2004 - 11:8:15 + 16/12/2004 - 11:8:15 + 1.04 + ? + ? + Compute Node + 366 + 262 + Init - DoLoop - EndInit - DoLoop - - + DoLoop + EndInit + DoLoop + + Init - Index - EndInit - Index - - + Index + EndInit + Index + + Init - Min - EndInit - Min - - + Min + EndInit + Min + + Init - Max - EndInit - Max - - + Max + EndInit + Max + + Init - Incr - EndInit - Incr - - + Incr + EndInit + Incr + + EndInit - DoLoop - Init - InitLoop - - + DoLoop + Init + DoLoop + + GraphLoop - Init\Index - Init - Index - + Init__Index + Init + Index + 3 - 0 - - + 0 + + GraphLoop - Init\Min - Init - Min - + Init__Min + Init + Min + 3 - 0 - - + 5 + + GraphLoop - Init\Max - Init - Max - + Init__Max + Init + Max + 3 - 10 - - + 10 + + GraphLoop - Init\Incr - Init - Incr - + Init__Incr + Init + Incr + 3 - 1 - + 1 + diff --git a/examples/GraphLoopDoWhile.py b/examples/GraphLoopDoWhile.py new file mode 100644 index 0000000..130a495 --- /dev/null +++ b/examples/GraphLoopDoWhile.py @@ -0,0 +1,76 @@ + +# Generated python file of Graph GraphLoopDoWhile + +from SuperV import * + +# Graph creation of GraphLoopDoWhile +def DefGraphLoopDoWhile() : + GraphLoopDoWhile = Graph( 'GraphLoopDoWhile' ) + GraphLoopDoWhile.SetName( 'GraphLoopDoWhile' ) + GraphLoopDoWhile.SetAuthor( 'JR' ) + GraphLoopDoWhile.SetComment( '' ) + GraphLoopDoWhile.Coords( 0 , 0 ) + + # Creation of Factory Nodes + + # Creation of Loop Nodes + PyLoop = [] + PyMoreLoop = [] + PyMoreLoop.append( '' ) + PyNextLoop = [] + PyNextLoop.append( 'def LoopWhileNext(Index,Max) : ' ) + PyNextLoop.append( ' Index = Index + 1 ' ) + PyNextLoop.append( ' return Index,Max ' ) + PyNextLoop.append( '' ) + Loop,EndLoop = GraphLoopDoWhile.LNode( '' , PyLoop , '' , PyMoreLoop , 'LoopWhileNext' , PyNextLoop ) + EndLoop.SetName( 'EndLoop' ) + EndLoop.SetAuthor( '' ) + EndLoop.SetComment( 'Compute Node' ) + EndLoop.Coords( 414 , 232 ) + PyEndLoop = [] + PyEndLoop.append( 'import time ' ) + PyEndLoop.append( 'def DoWhile(DoLoop,Index,Max) : ' ) + PyEndLoop.append( ' print 'DoWhile',DoLoop,Index,Max ' ) + PyEndLoop.append( ' time.sleep(2) ' ) + PyEndLoop.append( ' if Index == Max : ' ) + PyEndLoop.append( ' DoLoop = 0 ' ) + PyEndLoop.append( ' else : ' ) + PyEndLoop.append( ' DoLoop = 1 ' ) + PyEndLoop.append( ' print 'DoWhile',DoLoop,Index,Max ' ) + PyEndLoop.append( ' return DoLoop,Index,Max ' ) + EndLoop.SetPyFunction( 'DoWhile' , PyEndLoop ) + ILoopDoLoop = Loop.GetInPort( 'DoLoop' ) + ILoopIndex = Loop.InPort( 'Index' , 'long' ) + ILoopMax = Loop.InPort( 'Max' , 'long' ) + ILoopGate = Loop.GetInPort( 'Gate' ) + OLoopDoLoop = Loop.GetOutPort( 'DoLoop' ) + OLoopIndex = Loop.GetOutPort( 'Index' ) + OLoopMax = Loop.GetOutPort( 'Max' ) + IEndLoopDoLoop = EndLoop.GetInPort( 'DoLoop' ) + IEndLoopIndex = EndLoop.GetInPort( 'Index' ) + IEndLoopMax = EndLoop.GetInPort( 'Max' ) + IEndLoopGate = EndLoop.GetInPort( 'Gate' ) + OEndLoopDoLoop = EndLoop.GetOutPort( 'DoLoop' ) + OEndLoopIndex = EndLoop.GetOutPort( 'Index' ) + OEndLoopMax = EndLoop.GetOutPort( 'Max' ) + Loop.SetName( 'Loop' ) + Loop.SetAuthor( '' ) + Loop.SetComment( 'Compute Node' ) + Loop.Coords( 105 , 226 ) + + # Creation of Links + LLoopIndexEndLoopIndex = GraphLoopDoWhile.Link( OLoopIndex , IEndLoopIndex ) + + LLoopMaxEndLoopMax = GraphLoopDoWhile.Link( OLoopMax , IEndLoopMax ) + + # Input datas + ILoopIndex.Input( 5 ) + ILoopMax.Input( 10 ) + + # Output Ports of the graph + #OEndLoopIndex = EndLoop.GetOutPort( 'Index' ) + #OEndLoopMax = EndLoop.GetOutPort( 'Max' ) + return GraphLoopDoWhile + + +GraphLoopDoWhile = DefGraphLoopDoWhile() diff --git a/examples/GraphLoopDoWhile.xml b/examples/GraphLoopDoWhile.xml new file mode 100644 index 0000000..e57d955 --- /dev/null +++ b/examples/GraphLoopDoWhile.xml @@ -0,0 +1,169 @@ + + + + + +? + ? + GraphLoopDoWhile + 1 + ? + +GraphLoopDoWhile + + +long + Loop__Index + +long + Loop__Max + + +long + EndLoop__Index + +long + EndLoop__Max + + + 16/12/2004 - 15:39:50 + 16/12/2004 - 18:44:10 + 2.0 + JR + ? + ? + 0 + 0 + + +? + ? + Loop + 4 + EndLoop + +Loop + + +long + Index + +long + Max + + +long + Index + +long + Max + + + +? + + +? + + +LoopWhileNext + + + + + 16/12/2004 - 18:44:10 + 16/12/2004 - 18:44:10 + 2.0 + ? + ? + Compute Node + 105 + 226 + +? + ? + EndLoop + 5 + Loop + +EndLoop + + +long + Index + +long + Max + + +long + Index + +long + Max + + + +DoWhile + + + + + + + + + + + 16/12/2004 - 18:44:10 + 16/12/2004 - 18:44:10 + 2.0 + ? + ? + Compute Node + 414 + 232 + + +Loop + DoLoop + EndLoop + DoLoop + + +Loop + Index + EndLoop + Index + + +Loop + Max + EndLoop + Max + + +EndLoop + DoLoop + Loop + DoLoop + + + +GraphLoopDoWhile + Loop__Index + Loop + Index + +3 + 5 + + +GraphLoopDoWhile + Loop__Max + Loop + Max + +3 + 10 + diff --git a/examples/GraphLoopGates.py b/examples/GraphLoopGates.py new file mode 100644 index 0000000..0126d3b --- /dev/null +++ b/examples/GraphLoopGates.py @@ -0,0 +1,179 @@ + +# Generated python file of Graph GraphLoopGates + +from SuperV import * + +# Graph creation of GraphLoopGates +def DefGraphLoopGates() : + GraphLoopGates = Graph( 'GraphLoopGates' ) + GraphLoopGates.SetName( 'GraphLoopGates' ) + GraphLoopGates.SetAuthor( 'JR' ) + GraphLoopGates.SetComment( '' ) + GraphLoopGates.Coords( 0 , 0 ) + + # Creation of Factory Nodes + + Add = GraphLoopGates.FNode( 'AddComponent' , 'AddComponent' , 'Add' ) + Add.SetName( 'Add' ) + Add.SetAuthor( '' ) + Add.SetContainer( 'localhost/FactoryServer' ) + Add.SetComment( 'Add from AddComponent' ) + Add.Coords( 248 , 70 ) + IAddx = Add.GetInPort( 'x' ) + IAddy = Add.GetInPort( 'y' ) + IAddGate = Add.GetInPort( 'Gate' ) + OAddFuncValue = Add.GetOutPort( 'FuncValue' ) + OAddz = Add.GetOutPort( 'z' ) + OAddGate = Add.GetOutPort( 'Gate' ) + + Add_1 = GraphLoopGates.FNode( 'AddComponent' , 'AddComponent' , 'Add' ) + Add_1.SetName( 'Add_1' ) + Add_1.SetAuthor( '' ) + Add_1.SetContainer( 'localhost/FactoryServer' ) + Add_1.SetComment( 'Add from AddComponent' ) + Add_1.Coords( 249 , 305 ) + IAdd_1x = Add_1.GetInPort( 'x' ) + IAdd_1y = Add_1.GetInPort( 'y' ) + IAdd_1Gate = Add_1.GetInPort( 'Gate' ) + OAdd_1FuncValue = Add_1.GetOutPort( 'FuncValue' ) + OAdd_1z = Add_1.GetOutPort( 'z' ) + OAdd_1Gate = Add_1.GetOutPort( 'Gate' ) + + Sub = GraphLoopGates.FNode( 'SubComponent' , 'SubComponent' , 'Sub' ) + Sub.SetName( 'Sub' ) + Sub.SetAuthor( '' ) + Sub.SetContainer( 'localhost/FactoryServer' ) + Sub.SetComment( 'Sub from SubComponent' ) + Sub.Coords( 453 , 72 ) + ISubx = Sub.GetInPort( 'x' ) + ISuby = Sub.GetInPort( 'y' ) + ISubGate = Sub.GetInPort( 'Gate' ) + OSubz = Sub.GetOutPort( 'z' ) + OSubGate = Sub.GetOutPort( 'Gate' ) + + Sub_1 = GraphLoopGates.FNode( 'SubComponent' , 'SubComponent' , 'Sub' ) + Sub_1.SetName( 'Sub_1' ) + Sub_1.SetAuthor( '' ) + Sub_1.SetContainer( 'localhost/FactoryServer' ) + Sub_1.SetComment( 'Sub from SubComponent' ) + Sub_1.Coords( 455 , 304 ) + ISub_1x = Sub_1.GetInPort( 'x' ) + ISub_1y = Sub_1.GetInPort( 'y' ) + ISub_1Gate = Sub_1.GetInPort( 'Gate' ) + OSub_1z = Sub_1.GetOutPort( 'z' ) + OSub_1Gate = Sub_1.GetOutPort( 'Gate' ) + + # Creation of InLine Nodes + PyGate = [] + PyGate.append( 'from time import * ' ) + PyGate.append( 'def Gate(G1,G2) : ' ) + PyGate.append( ' sleep(1) ' ) + PyGate.append( ' return G1&G2 ' ) + Gate = GraphLoopGates.INode( 'Gate' , PyGate ) + Gate.SetName( 'Gate' ) + Gate.SetAuthor( '' ) + Gate.SetComment( 'Compute Node' ) + Gate.Coords( 650 , 227 ) + IGateG1 = Gate.InPort( 'G1' , 'long' ) + IGateG2 = Gate.InPort( 'G2' , 'long' ) + IGateGate = Gate.GetInPort( 'Gate' ) + OGateG = Gate.OutPort( 'G' , 'long' ) + OGateGate = Gate.GetOutPort( 'Gate' ) + + # Creation of Loop Nodes + PyInit = [] + PyInit.append( 'from time import * ' ) + PyInit.append( 'def Init(Index,Min,Max) : ' ) + PyInit.append( ' Index = Min ' ) + PyInit.append( ' sleep(1) ' ) + PyInit.append( ' return Index,Min,Max ' ) + PyMoreInit = [] + PyMoreInit.append( 'def More(Index,Min,Max) : ' ) + PyMoreInit.append( ' if Index < Max : ' ) + PyMoreInit.append( ' DoLoop = 1 ' ) + PyMoreInit.append( ' else : ' ) + PyMoreInit.append( ' DoLoop = 0 ' ) + PyMoreInit.append( ' return DoLoop,Index,Min,Max ' ) + PyNextInit = [] + PyNextInit.append( 'def Next(Index,Min,Max) : ' ) + PyNextInit.append( ' Index = Index + 1 ' ) + PyNextInit.append( ' return Index,Min,Max ' ) + Init,EndInit = GraphLoopGates.LNode( 'Init' , PyInit , 'More' , PyMoreInit , 'Next' , PyNextInit ) + EndInit.SetName( 'EndInit' ) + EndInit.SetAuthor( '' ) + EndInit.SetComment( 'Compute Node' ) + EndInit.Coords( 840 , 204 ) + PyEndInit = [] + EndInit.SetPyFunction( 'EndInit' , PyEndInit ) + IInitDoLoop = Init.GetInPort( 'DoLoop' ) + IInitIndex = Init.InPort( 'Index' , 'long' ) + IInitMin = Init.InPort( 'Min' , 'long' ) + IInitMax = Init.InPort( 'Max' , 'long' ) + IInitGate = Init.GetInPort( 'Gate' ) + OInitDoLoop = Init.GetOutPort( 'DoLoop' ) + OInitIndex = Init.GetOutPort( 'Index' ) + OInitMin = Init.GetOutPort( 'Min' ) + OInitMax = Init.GetOutPort( 'Max' ) + IEndInitDoLoop = EndInit.GetInPort( 'DoLoop' ) + IEndInitIndex = EndInit.GetInPort( 'Index' ) + IEndInitMin = EndInit.GetInPort( 'Min' ) + IEndInitMax = EndInit.GetInPort( 'Max' ) + IEndInitGate = EndInit.GetInPort( 'Gate' ) + OEndInitDoLoop = EndInit.GetOutPort( 'DoLoop' ) + OEndInitGate = EndInit.GetOutPort( 'Gate' ) + OEndInitIndex = EndInit.GetOutPort( 'Index' ) + OEndInitMin = EndInit.GetOutPort( 'Min' ) + OEndInitMax = EndInit.GetOutPort( 'Max' ) + Init.SetName( 'Init' ) + Init.SetAuthor( '' ) + Init.SetComment( 'Compute Node' ) + Init.Coords( 10 , 181 ) + + # Creation of Links + LInitGateAdd_1Gate = GraphLoopGates.Link( OInitGate , IAdd_1Gate ) + + LInitGateAddGate = GraphLoopGates.Link( OInitGate , IAddGate ) + + LInitIndexEndInitIndex = GraphLoopGates.Link( OInitIndex , IEndInitIndex ) + + LInitMinEndInitMin = GraphLoopGates.Link( OInitMin , IEndInitMin ) + + LInitMaxEndInitMax = GraphLoopGates.Link( OInitMax , IEndInitMax ) + + LAddGateSubGate = GraphLoopGates.Link( OAddGate , ISubGate ) + + LAdd_1GateSub_1Gate = GraphLoopGates.Link( OAdd_1Gate , ISub_1Gate ) + + LSubGateGateG1 = GraphLoopGates.Link( OSubGate , IGateG1 ) + + LSub_1GateGateG2 = GraphLoopGates.Link( OSub_1Gate , IGateG2 ) + + LGateGEndInitGate = GraphLoopGates.Link( OGateG , IEndInitGate ) + + # Input datas + IInitIndex.Input( 0 ) + IInitMin.Input( 5 ) + IInitMax.Input( 13 ) + IAddx.Input( 1 ) + IAddy.Input( 2 ) + IAdd_1x.Input( 3 ) + IAdd_1y.Input( 4 ) + ISubx.Input( 5 ) + ISuby.Input( 6 ) + ISub_1x.Input( 7 ) + ISub_1y.Input( 8 ) + + # Output Ports of the graph + #OEndInitIndex = EndInit.GetOutPort( 'Index' ) + #OEndInitMin = EndInit.GetOutPort( 'Min' ) + #OEndInitMax = EndInit.GetOutPort( 'Max' ) + #OAddFuncValue = Add.GetOutPort( 'FuncValue' ) + #OAddz = Add.GetOutPort( 'z' ) + #OAdd_1FuncValue = Add_1.GetOutPort( 'FuncValue' ) + #OAdd_1z = Add_1.GetOutPort( 'z' ) + #OSubz = Sub.GetOutPort( 'z' ) + #OSub_1z = Sub_1.GetOutPort( 'z' ) + return GraphLoopGates + + +GraphLoopGates = DefGraphLoopGates() diff --git a/examples/GraphLoopGates.xml b/examples/GraphLoopGates.xml new file mode 100644 index 0000000..f495d5a --- /dev/null +++ b/examples/GraphLoopGates.xml @@ -0,0 +1,514 @@ + + + + + +? + ? + GraphLoopGates + 1 + ? + +GraphLoopsGates + + +long + Init__Index + +long + Init__Min + +long + Init__Max + +double + Add__x + +double + Add__y + +double + Add_1__x + +double + Add_1__y + +double + Sub__x + +double + Sub__y + +double + Sub_1__x + +double + Sub_1__y + + +long + EndInit__Index + +long + EndInit__Min + +long + EndInit__Max + +double + Add__FuncValue + +double + Add__z + +double + Add_1__FuncValue + +double + Add_1__z + +double + Sub__z + +double + Sub_1__z + + + 7/1/2005 - 16:57:1 + 7/1/2005 - 17:8:8 + 2.0 + JR + ? + ? + 0 + 0 + + +? + ? + Init + 4 + EndInit + +Init + + +long + Index + +long + Min + +long + Max + + +long + Index + +long + Min + +long + Max + + + +Init + + + + + + +More + + + + + + + +Next + + + + 7/1/2005 - 16:59:3 + 7/1/2005 - 16:59:3 + 2.0 + ? + ? + Compute Node + 10 + 181 + +? + ? + EndInit + 5 + Init + +EndInit + + +long + Index + +long + Min + +long + Max + + +long + Index + +long + Min + +long + Max + + + +EndInit + + 7/1/2005 - 16:59:3 + 7/1/2005 - 16:59:3 + 2.0 + ? + ? + Compute Node + 840 + 204 + +AddComponent + AddComponent + Add + 0 + ? + +Add + + +double + x + +double + y + + +double + FuncValue + +double + z + + + 7/1/2005 - 17:3:59 + 7/1/2005 - 17:3:59 + 2.0 + ? + localhost/FactoryServer + Add from AddComponent + 248 + 70 + +AddComponent + AddComponent + Add_1 + 0 + ? + +Add + + +double + x + +double + y + + +double + FuncValue + +double + z + + + 7/1/2005 - 17:4:5 + 7/1/2005 - 17:4:5 + 2.0 + ? + localhost/FactoryServer + Add from AddComponent + 249 + 305 + +SubComponent + SubComponent + Sub + 0 + ? + +Sub + + +double + x + +double + y + + +double + z + + + 7/1/2005 - 17:4:31 + 7/1/2005 - 17:4:31 + 2.0 + ? + localhost/FactoryServer + Sub from SubComponent + 453 + 72 + +SubComponent + SubComponent + Sub_1 + 0 + ? + +Sub + + +double + x + +double + y + + +double + z + + + 7/1/2005 - 17:4:32 + 7/1/2005 - 17:4:32 + 2.0 + ? + localhost/FactoryServer + Sub from SubComponent + 455 + 304 + +? + ? + Gate + 3 + ? + +Gate + + +long + G1 + +long + G2 + + +long + G + + + +Gate + + + + + 7/1/2005 - 17:7:9 + 7/1/2005 - 17:7:9 + 2.0 + ? + ? + Compute Node + 650 + 227 + + +Init + DoLoop + EndInit + DoLoop + + +Init + Gate + Add_1 + Gate + + +Init + Gate + Add + Gate + + +Init + Index + EndInit + Index + + +Init + Min + EndInit + Min + + +Init + Max + EndInit + Max + + +EndInit + DoLoop + Init + DoLoop + + +Add + Gate + Sub + Gate + + +Add_1 + Gate + Sub_1 + Gate + + +Sub + Gate + Gate + G1 + + +Sub_1 + Gate + Gate + G2 + + +Gate + G + EndInit + Gate + + + +GraphLoopGates + Init__Index + Init + Index + +3 + 0 + + +GraphLoopGates + Init__Min + Init + Min + +3 + 5 + + +GraphLoopGates + Init__Max + Init + Max + +3 + 13 + + +GraphLoopGates + Add__x + Add + x + +7 + 1 + + +GraphLoopGates + Add__y + Add + y + +7 + 2 + + +GraphLoopGates + Add_1__x + Add_1 + x + +7 + 3 + + +GraphLoopGates + Add_1__y + Add_1 + y + +7 + 4 + + +GraphLoopGates + Sub__x + Sub + x + +7 + 5 + + +GraphLoopGates + Sub__y + Sub + y + +7 + 6 + + +GraphLoopGates + Sub_1__x + Sub_1 + x + +7 + 7 + + +GraphLoopGates + Sub_1__y + Sub_1 + y + +7 + 8 + diff --git a/examples/GraphLoopSwitch.py b/examples/GraphLoopSwitch.py index c14aad1..f9998e6 100755 --- a/examples/GraphLoopSwitch.py +++ b/examples/GraphLoopSwitch.py @@ -1,137 +1,151 @@ -# Generated python file of Graph GraphLoopSwitch +# Generated python file of Graph GraphLoopSwitch_1 from SuperV import * -# Graph creation -GraphLoopSwitch = Graph( 'GraphLoopSwitch' ) -GraphLoopSwitch.SetName( 'GraphLoopSwitch' ) -GraphLoopSwitch.SetAuthor( '' ) -GraphLoopSwitch.SetComment( '' ) -GraphLoopSwitch.Coords( 0 , 0 ) -# Creation of Factory Nodes - -# Creation of InLine Nodes -PyIsOdd = [] -PyIsOdd.append( 'from time import * ' ) -PyIsOdd.append( 'def IsOdd(a,Even) : ' ) -PyIsOdd.append( ' print a,"IsOdd (GraphLoopSwitch1)" ' ) -PyIsOdd.append( ' sleep( 1 ) ' ) -PyIsOdd.append( ' return a ' ) -IsOdd = GraphLoopSwitch.INode( 'IsOdd' , PyIsOdd ) -IsOdd.SetName( 'IsOdd' ) -IsOdd.SetAuthor( '' ) -IsOdd.SetComment( 'Python function' ) -IsOdd.Coords( 397 , 1 ) -IsOdd.InPort( 'a' , 'long' ) -IsOdd.InPort( 'Even' , 'boolean' ) -IsOdd.OutPort( 'a' , 'long' ) - -# Creation of Loop Nodes -PyInitLoop = [] -PyInitLoop.append( ' ' ) -PyMoreInitLoop = [] -PyMoreInitLoop.append( ' ' ) -PyNextInitLoop = [] -PyNextInitLoop.append( ' ' ) -InitLoop,EndOfInitLoop = GraphLoopSwitch.LNode( '' , PyInitLoop , '' , PyMoreInitLoop , '' , PyNextInitLoop ) -EndOfInitLoop.SetName( 'EndOfInitLoop' ) -EndOfInitLoop.SetAuthor( '' ) -EndOfInitLoop.SetComment( '' ) -EndOfInitLoop.Coords( 767 , 102 ) -PyEndOfInitLoop = [] -PyEndOfInitLoop.append( 'def EndOfInitLoop( DoLoop , Index , Min , Max ) :' ) -PyEndOfInitLoop.append( ' Index = Index + 1 ' ) -PyEndOfInitLoop.append( ' if Index <= Max : ' ) -PyEndOfInitLoop.append( ' DoLoop = 1 ' ) -PyEndOfInitLoop.append( ' else : ' ) -PyEndOfInitLoop.append( ' DoLoop = 0 ' ) -PyEndOfInitLoop.append( ' return DoLoop,Index,Min,Max ' ) -EndOfInitLoop.SetPyFunction( 'EndOfInitLoop' , PyEndOfInitLoop ) -InitLoop.SetName( 'InitLoop' ) -InitLoop.SetAuthor( '' ) -InitLoop.SetComment( '' ) -InitLoop.Coords( 10 , 108 ) -InitLoop.InPort( 'Index' , 'long' ) -InitLoop.InPort( 'Min' , 'long' ) -InitLoop.InPort( 'Max' , 'long' ) -InitLoop.OutPort( 'Index' , 'long' ) -InitLoop.OutPort( 'Min' , 'long' ) -InitLoop.OutPort( 'Max' , 'long' ) - -# Creation of Switch Nodes -PySwitch = [] -PySwitch.append( 'from time import * ' ) -PySwitch.append( 'def Switch(a) : ' ) -PySwitch.append( ' if ( a & 1 ) == 0 : ' ) -PySwitch.append( ' sleep(1) ' ) -PySwitch.append( ' return a & 1,1-(a&1),a ' ) -Switch,EndSwitch = GraphLoopSwitch.SNode( 'Switch' , PySwitch ) -EndSwitch.SetName( 'EndSwitch' ) -EndSwitch.SetAuthor( '' ) -EndSwitch.SetComment( '' ) -EndSwitch.Coords( 587 , 103 ) -PyEndSwitch = [] -PyEndSwitch.append( 'def EndSwitch(a) : ' ) -PyEndSwitch.append( ' if ( a & 1 ) == 0 : ' ) -PyEndSwitch.append( ' sleep(1) ' ) -PyEndSwitch.append( ' return a ' ) -EndSwitch.SetPyFunction( 'EndSwitch' , PyEndSwitch ) -EndSwitch.InPort( 'a' , 'long' ) -EndSwitch.OutPort( 'a' , 'long' ) -Switch.SetName( 'Switch' ) -Switch.SetAuthor( '' ) -Switch.SetComment( '' ) -Switch.Coords( 194 , 109 ) -Switch.InPort( 'a' , 'long' ) -Switch.OutPort( 'Odd' , 'long' ) -Switch.OutPort( 'Even' , 'int' ) -Switch.OutPort( 'a' , 'int' ) - -# Creation of Links -IsOdda = IsOdd.Port( 'a' ) -EndSwitcha = GraphLoopSwitch.Link( IsOdda , EndSwitch.Port( 'a' ) ) -EndSwitcha.AddCoord( 1 , 576 , 136 ) -EndSwitcha.AddCoord( 2 , 575 , 81 ) - -InitLoopIndex = InitLoop.Port( 'Index' ) -Switcha = GraphLoopSwitch.Link( InitLoopIndex , Switch.Port( 'a' ) ) - -InitLoopMin = InitLoop.Port( 'Min' ) -EndOfInitLoopMin = GraphLoopSwitch.Link( InitLoopMin , EndOfInitLoop.Port( 'Min' ) ) - -InitLoopMax = InitLoop.Port( 'Max' ) -EndOfInitLoopMax = GraphLoopSwitch.Link( InitLoopMax , EndOfInitLoop.Port( 'Max' ) ) - -SwitchOdd = Switch.Port( 'Odd' ) -IsOddInGate = GraphLoopSwitch.Link( SwitchOdd , IsOdd.Port( 'InGate' ) ) - -SwitchEven = Switch.Port( 'Even' ) -EndSwitchDefault = GraphLoopSwitch.Link( SwitchEven , EndSwitch.Port( 'Default' ) ) - -IsOddEven = GraphLoopSwitch.Link( SwitchEven , IsOdd.Port( 'Even' ) ) -IsOddEven.AddCoord( 1 , 375 , 111 ) -IsOddEven.AddCoord( 2 , 375 , 172 ) - -Switcha = Switch.Port( 'a' ) -IsOdda = GraphLoopSwitch.Link( Switcha , IsOdd.Port( 'a' ) ) -IsOdda.AddCoord( 1 , 362 , 82 ) -IsOdda.AddCoord( 2 , 360 , 201 ) - -EndSwitcha = EndSwitch.Port( 'a' ) -EndOfInitLoopIndex = GraphLoopSwitch.Link( EndSwitcha , EndOfInitLoop.Port( 'Index' ) ) - -# Creation of Input datas -InitLoopIndex = InitLoop.Input( 'Index' , 0) -InitLoopMin = InitLoop.Input( 'Min' , 0) -InitLoopMax = InitLoop.Input( 'Max' , 100) - -# Creation of Output variables -EndOfInitLoopIndex = EndOfInitLoop.Port( 'Index' ) -EndOfInitLoopMin = EndOfInitLoop.Port( 'Min' ) -EndOfInitLoopMax = EndOfInitLoop.Port( 'Max' ) - -GraphLoopSwitch.Run() -GraphLoopSwitch.DoneW() -GraphLoopSwitch.State() -GraphLoopSwitch.PrintPorts() +# Graph creation of GraphLoopSwitch_1 +def DefGraphLoopSwitch_1() : + GraphLoopSwitch_1 = Graph( 'GraphLoopSwitch_1' ) + GraphLoopSwitch_1.SetName( 'GraphLoopSwitch_1' ) + GraphLoopSwitch_1.SetAuthor( '' ) + GraphLoopSwitch_1.SetComment( '' ) + GraphLoopSwitch_1.Coords( 0 , 0 ) + + # Creation of Factory Nodes + + # Creation of InLine Nodes + PyIsOdd = [] + PyIsOdd.append( 'from time import * ' ) + PyIsOdd.append( 'def IsOdd(a,Even) : ' ) + PyIsOdd.append( ' print a,"IsOdd (GraphLoopSwitch1)" ' ) + PyIsOdd.append( ' sleep( 1 ) ' ) + PyIsOdd.append( ' return a ' ) + IsOdd = GraphLoopSwitch_1.INode( 'IsOdd' , PyIsOdd ) + IsOdd.SetName( 'IsOdd' ) + IsOdd.SetAuthor( '' ) + IsOdd.SetComment( 'Python function' ) + IsOdd.Coords( 397 , 1 ) + IIsOdda = IsOdd.InPort( 'a' , 'long' ) + IIsOddEven = IsOdd.InPort( 'Even' , 'boolean' ) + IIsOddGate = IsOdd.GetInPort( 'Gate' ) + OIsOdda = IsOdd.OutPort( 'a' , 'long' ) + OIsOddGate = IsOdd.GetOutPort( 'Gate' ) + + # Creation of Loop Nodes + PyInitLoop = [] + PyInitLoop.append( 'def InitLoop(Index,Min,Max) : ' ) + PyInitLoop.append( ' Index = Min ' ) + PyInitLoop.append( ' return Index,Min,Max ' ) + PyInitLoop.append( ' ' ) + PyMoreInitLoop = [] + PyMoreInitLoop.append( ' ' ) + PyNextInitLoop = [] + PyNextInitLoop.append( ' ' ) + InitLoop,EndOfInitLoop = GraphLoopSwitch_1.LNode( 'InitLoop' , PyInitLoop , '' , PyMoreInitLoop , '' , PyNextInitLoop ) + EndOfInitLoop.SetName( 'EndOfInitLoop' ) + EndOfInitLoop.SetAuthor( '' ) + EndOfInitLoop.SetComment( 'Compute Node' ) + EndOfInitLoop.Coords( 767 , 102 ) + PyEndOfInitLoop = [] + PyEndOfInitLoop.append( 'def EndOfInitLoop( DoLoop , Index , Min , Max ) :' ) + PyEndOfInitLoop.append( ' Index = Index + 1 ' ) + PyEndOfInitLoop.append( ' if Index <= Max : ' ) + PyEndOfInitLoop.append( ' DoLoop = 1 ' ) + PyEndOfInitLoop.append( ' else : ' ) + PyEndOfInitLoop.append( ' DoLoop = 0 ' ) + PyEndOfInitLoop.append( ' return DoLoop,Index,Min,Max ' ) + EndOfInitLoop.SetPyFunction( 'EndOfInitLoop' , PyEndOfInitLoop ) + IInitLoopDoLoop = InitLoop.GetInPort( 'DoLoop' ) + IInitLoopIndex = InitLoop.InPort( 'Index' , 'long' ) + IInitLoopMin = InitLoop.InPort( 'Min' , 'long' ) + IInitLoopMax = InitLoop.InPort( 'Max' , 'long' ) + IInitLoopGate = InitLoop.GetInPort( 'Gate' ) + OInitLoopDoLoop = InitLoop.GetOutPort( 'DoLoop' ) + OInitLoopIndex = InitLoop.GetOutPort( 'Index' ) + OInitLoopMin = InitLoop.GetOutPort( 'Min' ) + OInitLoopMax = InitLoop.GetOutPort( 'Max' ) + IEndOfInitLoopDoLoop = EndOfInitLoop.GetInPort( 'DoLoop' ) + IEndOfInitLoopIndex = EndOfInitLoop.GetInPort( 'Index' ) + IEndOfInitLoopMin = EndOfInitLoop.GetInPort( 'Min' ) + IEndOfInitLoopMax = EndOfInitLoop.GetInPort( 'Max' ) + IEndOfInitLoopGate = EndOfInitLoop.GetInPort( 'Gate' ) + OEndOfInitLoopDoLoop = EndOfInitLoop.GetOutPort( 'DoLoop' ) + OEndOfInitLoopIndex = EndOfInitLoop.GetOutPort( 'Index' ) + OEndOfInitLoopMin = EndOfInitLoop.GetOutPort( 'Min' ) + OEndOfInitLoopMax = EndOfInitLoop.GetOutPort( 'Max' ) + InitLoop.SetName( 'InitLoop' ) + InitLoop.SetAuthor( '' ) + InitLoop.SetComment( 'Compute Node' ) + InitLoop.Coords( 10 , 108 ) + + # Creation of Switch Nodes + PySwitch = [] + PySwitch.append( 'from time import * ' ) + PySwitch.append( 'def Switch(a) : ' ) + PySwitch.append( ' if ( a & 1 ) == 0 : ' ) + PySwitch.append( ' sleep(1) ' ) + PySwitch.append( ' return a & 1,1-(a&1),a ' ) + Switch,EndSwitch = GraphLoopSwitch_1.SNode( 'Switch' , PySwitch ) + EndSwitch.SetName( 'EndSwitch' ) + EndSwitch.SetAuthor( '' ) + EndSwitch.SetComment( 'Compute Node' ) + EndSwitch.Coords( 587 , 103 ) + PyEndSwitch = [] + PyEndSwitch.append( 'def EndSwitch(a) : ' ) + PyEndSwitch.append( ' if ( a & 1 ) == 0 : ' ) + PyEndSwitch.append( ' sleep(1) ' ) + PyEndSwitch.append( ' return a ' ) + EndSwitch.SetPyFunction( 'EndSwitch' , PyEndSwitch ) + IEndSwitcha = EndSwitch.InPort( 'a' , 'long' ) + IEndSwitchDefault = EndSwitch.GetInPort( 'Default' ) + OEndSwitcha = EndSwitch.OutPort( 'a' , 'long' ) + OEndSwitchGate = EndSwitch.GetOutPort( 'Gate' ) + Switch.SetName( 'Switch' ) + Switch.SetAuthor( '' ) + Switch.SetComment( 'Compute Node' ) + Switch.Coords( 194 , 109 ) + ISwitcha = Switch.InPort( 'a' , 'long' ) + ISwitchGate = Switch.GetInPort( 'Gate' ) + OSwitchOdd = Switch.OutPort( 'Odd' , 'long' ) + OSwitchEven = Switch.OutPort( 'Even' , 'int' ) + OSwitcha = Switch.OutPort( 'a' , 'int' ) + OSwitchDefault = Switch.GetOutPort( 'Default' ) + + # Creation of Links + LIsOddaEndSwitcha = GraphLoopSwitch_1.Link( OIsOdda , IEndSwitcha ) + LIsOddaEndSwitcha.AddCoord( 1 , 576 , 136 ) + LIsOddaEndSwitcha.AddCoord( 2 , 575 , 81 ) + + LInitLoopIndexSwitcha = GraphLoopSwitch_1.Link( OInitLoopIndex , ISwitcha ) + + LInitLoopMinEndOfInitLoopMin = GraphLoopSwitch_1.Link( OInitLoopMin , IEndOfInitLoopMin ) + + LInitLoopMaxEndOfInitLoopMax = GraphLoopSwitch_1.Link( OInitLoopMax , IEndOfInitLoopMax ) + + LSwitchOddIsOddGate = GraphLoopSwitch_1.Link( OSwitchOdd , IIsOddGate ) + + LSwitchEvenEndSwitchDefault = GraphLoopSwitch_1.Link( OSwitchEven , IEndSwitchDefault ) + + LSwitchEvenIsOddEven = GraphLoopSwitch_1.Link( OSwitchEven , IIsOddEven ) + LSwitchEvenIsOddEven.AddCoord( 1 , 375 , 111 ) + LSwitchEvenIsOddEven.AddCoord( 2 , 375 , 172 ) + + LSwitchaIsOdda = GraphLoopSwitch_1.Link( OSwitcha , IIsOdda ) + LSwitchaIsOdda.AddCoord( 1 , 362 , 82 ) + LSwitchaIsOdda.AddCoord( 2 , 360 , 201 ) + + LEndSwitchaEndOfInitLoopIndex = GraphLoopSwitch_1.Link( OEndSwitcha , IEndOfInitLoopIndex ) + + # Input datas + IInitLoopIndex.Input( 0 ) + IInitLoopMin.Input( 5 ) + IInitLoopMax.Input( 100 ) + + # Output Ports of the graph + #OEndOfInitLoopIndex = EndOfInitLoop.GetOutPort( 'Index' ) + #OEndOfInitLoopMin = EndOfInitLoop.GetOutPort( 'Min' ) + #OEndOfInitLoopMax = EndOfInitLoop.GetOutPort( 'Max' ) + return GraphLoopSwitch_1 + + +GraphLoopSwitch_1 = DefGraphLoopSwitch_1() diff --git a/examples/GraphLoopSwitch.xml b/examples/GraphLoopSwitch.xml index a5e717d..d52d92f 100755 --- a/examples/GraphLoopSwitch.xml +++ b/examples/GraphLoopSwitch.xml @@ -1,356 +1,360 @@ - + + ? - ? - GraphLoopSwitch - 1 - ? - -GraphLoopSwitch - + ? + GraphLoopSwitch_1 + 1 + ? + +GraphLoopSwitch_1 + long - InitLoop\Index - + InitLoop__Index + long - InitLoop\Min - + InitLoop__Min + long - InitLoop\Max - + InitLoop__Max + long - EndOfInitLoop\Index - + EndOfInitLoop__Index + long - EndOfInitLoop\Min - + EndOfInitLoop__Min + long - EndOfInitLoop\Max - - - 22/10/2003 - 10:36:39 - 22/10/2003 - 10:37:20 - 1.05 - ? - ? - ? - 0 - 0 - + EndOfInitLoop__Max + + + 22/10/2003 - 10:36:39 + 16/12/2004 - 16:45:0 + 1.05 + ? + ? + ? + 0 + 0 + ? - ? - IsOdd - 3 - ? - + ? + IsOdd + 3 + ? + IsOdd - + long - a - + a + boolean - Even - + Even + long - a - - + a + + IsOdd - - - - - - 22/10/2003 - 10:36:39 - 22/10/2003 - 10:36:39 - 1.05 - ? - ? - Python function - 397 - 1 - + + + + + + 16/12/2004 - 16:45:0 + 16/12/2004 - 16:45:0 + 1.05 + ? + ? + Python function + 397 + 1 + ? - ? - InitLoop - 4 - EndOfInitLoop - -Loop - + ? + InitLoop + 4 + EndOfInitLoop + +InitLoop + long - Index - + Index + long - Min - + Min + long - Max - + Max + long - Index - + Index + long - Min - + Min + long - Max - - + Max + + +InitLoop + + + + + ? - - + + ? - - -? - - 22/10/2003 - 10:36:40 - 22/10/2003 - 10:36:40 - 1.05 - ? - ? - ? - 10 - 108 - + + 16/12/2004 - 16:45:0 + 16/12/2004 - 16:45:0 + 1.05 + ? + ? + Compute Node + 10 + 108 + ? - ? - EndOfInitLoop - 5 - InitLoop - -EndLoop - + ? + EndOfInitLoop + 5 + InitLoop + +EndOfInitLoop + long - Index - + Index + long - Min - + Min + long - Max - + Max + long - Index - + Index + long - Min - + Min + long - Max - - + Max + + EndOfInitLoop - - - - - - - - 22/10/2003 - 10:36:40 - 22/10/2003 - 10:36:40 - 1.05 - ? - ? - ? - 767 - 102 - + + + + + + + + 16/12/2004 - 16:45:0 + 16/12/2004 - 16:45:0 + 1.05 + ? + ? + Compute Node + 767 + 102 + ? - ? - Switch - 6 - EndSwitch - + ? + Switch + 6 + EndSwitch + Switch - + long - a - + a + long - Odd - + Odd + int - Even - + Even + int - a - - + a + + Switch - - - - - - 22/10/2003 - 10:36:59 - 22/10/2003 - 10:36:59 - 1.05 - ? - ? - ? - 194 - 109 - + + + + + + 16/12/2004 - 16:45:0 + 16/12/2004 - 16:45:0 + 1.05 + ? + ? + Compute Node + 194 + 109 + ? - ? - EndSwitch - 7 - Switch - + ? + EndSwitch + 7 + Switch + EndSwitch - + long - a - + a + long - a - - + a + + EndSwitch - - - - - 22/10/2003 - 10:36:59 - 22/10/2003 - 10:36:59 - 1.05 - ? - ? - ? - 587 - 103 - + + + + + 16/12/2004 - 16:45:0 + 16/12/2004 - 16:45:0 + 1.05 + ? + ? + Compute Node + 587 + 103 + IsOdd - a - EndSwitch - a - + a + EndSwitch + a + 576 - 136 - + 136 + 575 - 81 - + 81 + InitLoop - DoLoop - EndOfInitLoop - DoLoop - - + DoLoop + EndOfInitLoop + DoLoop + + InitLoop - Index - Switch - a - - + Index + Switch + a + + InitLoop - Min - EndOfInitLoop - Min - - + Min + EndOfInitLoop + Min + + InitLoop - Max - EndOfInitLoop - Max - - + Max + EndOfInitLoop + Max + + EndOfInitLoop - DoLoop - InitLoop - InitLoop - - + DoLoop + InitLoop + DoLoop + + Switch - Odd - IsOdd - InGate - - + Odd + IsOdd + Gate + + Switch - Even - EndSwitch - Default - - + Even + EndSwitch + Default + + Switch - Even - IsOdd - Even - + Even + IsOdd + Even + 375 - 111 - + 111 + 375 - 172 - + 172 + Switch - a - IsOdd - a - + a + IsOdd + a + 362 - 82 - + 82 + 360 - 201 - + 201 + EndSwitch - a - EndOfInitLoop - Index - - + a + EndOfInitLoop + Index + + -GraphLoopSwitch - InitLoop\Index - InitLoop - Index - +GraphLoopSwitch_1 + InitLoop__Index + InitLoop + Index + 3 - 0 - - -GraphLoopSwitch - InitLoop\Min - InitLoop - Min - + 0 + + +GraphLoopSwitch_1 + InitLoop__Min + InitLoop + Min + 3 - 0 - - -GraphLoopSwitch - InitLoop\Max - InitLoop - Max - + 5 + + +GraphLoopSwitch_1 + InitLoop__Max + InitLoop + Max + 3 - 100 - + 100 + diff --git a/examples/GraphLoopWhile.py b/examples/GraphLoopWhile.py new file mode 100644 index 0000000..c6f8f8d --- /dev/null +++ b/examples/GraphLoopWhile.py @@ -0,0 +1,74 @@ + +# Generated python file of Graph GraphLoopWhile + +from SuperV import * + +# Graph creation of GraphLoopWhile +def DefGraphLoopWhile() : + GraphLoopWhile = Graph( 'GraphLoopWhile' ) + GraphLoopWhile.SetName( 'GraphLoopWhile' ) + GraphLoopWhile.SetAuthor( 'JR' ) + GraphLoopWhile.SetComment( '' ) + GraphLoopWhile.Coords( 0 , 0 ) + + # Creation of Factory Nodes + + # Creation of Loop Nodes + PyLoop = [] + PyMoreLoop = [] + PyMoreLoop.append( 'import time ' ) + PyMoreLoop.append( 'def LoopWhileMore(Index,Max) : ' ) + PyMoreLoop.append( ' time.sleep(2) ' ) + PyMoreLoop.append( ' if Index < Max : ' ) + PyMoreLoop.append( ' DoLoop = 1 ' ) + PyMoreLoop.append( ' else : ' ) + PyMoreLoop.append( ' DoLoop = 0 ' ) + PyMoreLoop.append( ' return DoLoop,Index,Max ' ) + PyMoreLoop.append( '' ) + PyNextLoop = [] + PyNextLoop.append( 'def LoopWhileNext(Index,Max) : ' ) + PyNextLoop.append( ' Index = Index + 1 ' ) + PyNextLoop.append( ' return Index,Max ' ) + PyNextLoop.append( '' ) + Loop,EndLoop = GraphLoopWhile.LNode( '' , PyLoop , 'LoopWhileMore' , PyMoreLoop , 'LoopWhileNext' , PyNextLoop ) + EndLoop.SetName( 'EndLoop' ) + EndLoop.SetAuthor( '' ) + EndLoop.SetComment( 'Compute Node' ) + EndLoop.Coords( 414 , 232 ) + PyEndLoop = [] + EndLoop.SetPyFunction( 'EndLoop' , PyEndLoop ) + ILoopDoLoop = Loop.GetInPort( 'DoLoop' ) + ILoopIndex = Loop.InPort( 'Index' , 'long' ) + ILoopMax = Loop.InPort( 'Max' , 'long' ) + ILoopGate = Loop.GetInPort( 'Gate' ) + OLoopDoLoop = Loop.GetOutPort( 'DoLoop' ) + OLoopIndex = Loop.GetOutPort( 'Index' ) + OLoopMax = Loop.GetOutPort( 'Max' ) + IEndLoopDoLoop = EndLoop.GetInPort( 'DoLoop' ) + IEndLoopIndex = EndLoop.GetInPort( 'Index' ) + IEndLoopMax = EndLoop.GetInPort( 'Max' ) + IEndLoopGate = EndLoop.GetInPort( 'Gate' ) + OEndLoopDoLoop = EndLoop.GetOutPort( 'DoLoop' ) + OEndLoopIndex = EndLoop.GetOutPort( 'Index' ) + OEndLoopMax = EndLoop.GetOutPort( 'Max' ) + Loop.SetName( 'Loop' ) + Loop.SetAuthor( '' ) + Loop.SetComment( 'Compute Node' ) + Loop.Coords( 105 , 226 ) + + # Creation of Links + LLoopIndexEndLoopIndex = GraphLoopWhile.Link( OLoopIndex , IEndLoopIndex ) + + LLoopMaxEndLoopMax = GraphLoopWhile.Link( OLoopMax , IEndLoopMax ) + + # Input datas + ILoopIndex.Input( 5 ) + ILoopMax.Input( 10 ) + + # Output Ports of the graph + #OEndLoopIndex = EndLoop.GetOutPort( 'Index' ) + #OEndLoopMax = EndLoop.GetOutPort( 'Max' ) + return GraphLoopWhile + + +GraphLoopWhile = DefGraphLoopWhile() diff --git a/examples/GraphLoopWhile.xml b/examples/GraphLoopWhile.xml new file mode 100644 index 0000000..1733430 --- /dev/null +++ b/examples/GraphLoopWhile.xml @@ -0,0 +1,168 @@ + + + + + +? + ? + GraphLoopWhile + 1 + ? + +GraphLoopWhile_1 + + +long + Loop__Index + +long + Loop__Max + + +long + EndLoop__Index + +long + EndLoop__Max + + + 16/12/2004 - 15:39:50 + 16/12/2004 - 16:51:46 + 2.0 + JR + ? + ? + 0 + 0 + + +? + ? + Loop + 4 + EndLoop + +Loop + + +long + Index + +long + Max + + +long + Index + +long + Max + + + +? + + +LoopWhileMore + + + + + + + + + + +LoopWhileNext + + + + + 16/12/2004 - 16:51:46 + 16/12/2004 - 16:51:46 + 2.0 + ? + ? + Compute Node + 105 + 226 + +? + ? + EndLoop + 5 + Loop + +EndLoop + + +long + Index + +long + Max + + +long + Index + +long + Max + + + +EndLoop + + 16/12/2004 - 16:51:46 + 16/12/2004 - 16:51:46 + 2.0 + ? + ? + Compute Node + 414 + 232 + + +Loop + DoLoop + EndLoop + DoLoop + + +Loop + Index + EndLoop + Index + + +Loop + Max + EndLoop + Max + + +EndLoop + DoLoop + Loop + DoLoop + + + +GraphLoopWhile + Loop__Index + Loop + Index + +3 + 5 + + +GraphLoopWhile + Loop__Max + Loop + Max + +3 + 10 + diff --git a/examples/GraphLoopsCoupled.py b/examples/GraphLoopsCoupled.py new file mode 100644 index 0000000..26e5c5d --- /dev/null +++ b/examples/GraphLoopsCoupled.py @@ -0,0 +1,215 @@ + +# Generated python file of Graph GraphLoopsCoupled_3 + +from SuperV import * + +# Graph creation of GraphLoopsCoupled_3 +def DefGraphLoopsCoupled_3() : + GraphLoopsCoupled_3 = Graph( 'GraphLoopsCoupled_3' ) + GraphLoopsCoupled_3.SetName( 'GraphLoopsCoupled_3' ) + GraphLoopsCoupled_3.SetAuthor( 'JR' ) + GraphLoopsCoupled_3.SetComment( '' ) + GraphLoopsCoupled_3.Coords( 0 , 0 ) + + # Creation of Factory Nodes + + # Creation of InLine Nodes + PyAdd = [] + PyAdd.append( 'def Add(x,y) : ' ) + PyAdd.append( ' return x+y ' ) + PyAdd.append( '' ) + Add = GraphLoopsCoupled_3.INode( 'Add' , PyAdd ) + Add.SetName( 'Add' ) + Add.SetAuthor( '' ) + Add.SetComment( 'Compute Node' ) + Add.Coords( 245 , 38 ) + IAddx = Add.InPort( 'x' , 'long' ) + IAddy = Add.InPort( 'y' , 'long' ) + IAddGate = Add.GetInPort( 'Gate' ) + OAddz = Add.OutPort( 'z' , 'long' ) + OAddGate = Add.GetOutPort( 'Gate' ) + + PyAdd_1 = [] + PyAdd_1.append( 'def Add(x,y) : ' ) + PyAdd_1.append( ' return x+y ' ) + PyAdd_1.append( '' ) + Add_1 = GraphLoopsCoupled_3.INode( 'Add' , PyAdd_1 ) + Add_1.SetName( 'Add_1' ) + Add_1.SetAuthor( '' ) + Add_1.SetComment( 'Compute Node' ) + Add_1.Coords( 243 , 288 ) + IAdd_1x = Add_1.InPort( 'x' , 'long' ) + IAdd_1y = Add_1.InPort( 'y' , 'long' ) + IAdd_1Gate = Add_1.GetInPort( 'Gate' ) + OAdd_1z = Add_1.OutPort( 'z' , 'long' ) + OAdd_1Gate = Add_1.GetOutPort( 'Gate' ) + + PySub = [] + PySub.append( 'def Sub(x,y) : ' ) + PySub.append( ' return x-y ' ) + PySub.append( '' ) + Sub = GraphLoopsCoupled_3.INode( 'Sub' , PySub ) + Sub.SetName( 'Sub' ) + Sub.SetAuthor( '' ) + Sub.SetComment( 'Compute Node' ) + Sub.Coords( 458 , 18 ) + ISubx = Sub.InPort( 'x' , 'long' ) + ISuby = Sub.InPort( 'y' , 'long' ) + ISubGate = Sub.GetInPort( 'Gate' ) + OSubz = Sub.OutPort( 'z' , 'long' ) + OSubGate = Sub.GetOutPort( 'Gate' ) + + PySub_1 = [] + PySub_1.append( 'def Sub(x,y) : ' ) + PySub_1.append( ' return x-y ' ) + PySub_1.append( '' ) + Sub_1 = GraphLoopsCoupled_3.INode( 'Sub' , PySub_1 ) + Sub_1.SetName( 'Sub_1' ) + Sub_1.SetAuthor( '' ) + Sub_1.SetComment( 'Compute Node' ) + Sub_1.Coords( 461 , 268 ) + ISub_1x = Sub_1.InPort( 'x' , 'long' ) + ISub_1y = Sub_1.InPort( 'y' , 'long' ) + ISub_1Gate = Sub_1.GetInPort( 'Gate' ) + OSub_1z = Sub_1.OutPort( 'z' , 'long' ) + OSub_1Gate = Sub_1.GetOutPort( 'Gate' ) + + # Creation of Loop Nodes + PyLoop = [] + PyLoop.append( ' ' ) + PyMoreLoop = [] + PyMoreLoop.append( 'def More(Index,Max,z) : ' ) + PyMoreLoop.append( ' DoLoop = 0 ' ) + PyMoreLoop.append( ' if Index < Max : ' ) + PyMoreLoop.append( ' DoLoop = 1 ' ) + PyMoreLoop.append( ' return DoLoop,Index,Max,z ' ) + PyMoreLoop.append( ' ' ) + PyNextLoop = [] + PyNextLoop.append( 'def Next(Index,Max,z) : ' ) + PyNextLoop.append( ' Index = Index + 1 ' ) + PyNextLoop.append( ' return Index,Max,z ' ) + PyNextLoop.append( ' ' ) + Loop,EndLoop = GraphLoopsCoupled_3.LNode( '' , PyLoop , 'More' , PyMoreLoop , 'Next' , PyNextLoop ) + EndLoop.SetName( 'EndLoop' ) + EndLoop.SetAuthor( '' ) + EndLoop.SetComment( 'Compute Node' ) + EndLoop.Coords( 662 , 38 ) + PyEndLoop = [] + EndLoop.SetPyFunction( 'EndLoop' , PyEndLoop ) + ILoopDoLoop = Loop.GetInPort( 'DoLoop' ) + ILoopIndex = Loop.InPort( 'Index' , 'long' ) + ILoopMax = Loop.InPort( 'Max' , 'long' ) + ILoopz = Loop.InPort( 'z' , 'long' ) + ILoopGate = Loop.GetInPort( 'Gate' ) + OLoopDoLoop = Loop.GetOutPort( 'DoLoop' ) + OLoopIndex = Loop.GetOutPort( 'Index' ) + OLoopMax = Loop.GetOutPort( 'Max' ) + OLoopz = Loop.GetOutPort( 'z' ) + IEndLoopDoLoop = EndLoop.GetInPort( 'DoLoop' ) + IEndLoopIndex = EndLoop.GetInPort( 'Index' ) + IEndLoopMax = EndLoop.GetInPort( 'Max' ) + IEndLoopz = EndLoop.GetInPort( 'z' ) + IEndLoopGate = EndLoop.GetInPort( 'Gate' ) + OEndLoopDoLoop = EndLoop.GetOutPort( 'DoLoop' ) + OEndLoopIndex = EndLoop.GetOutPort( 'Index' ) + OEndLoopMax = EndLoop.GetOutPort( 'Max' ) + OEndLoopz = EndLoop.GetOutPort( 'z' ) + OEndLoopGate = EndLoop.GetOutPort( 'Gate' ) + Loop.SetName( 'Loop' ) + Loop.SetAuthor( '' ) + Loop.SetComment( 'Compute Node' ) + Loop.Coords( 15 , 58 ) + + PyInit = [] + PyInit.append( ' ' ) + PyMoreInit = [] + PyMoreInit.append( 'def More(Index,Max,z) : ' ) + PyMoreInit.append( ' DoLoop = 0 ' ) + PyMoreInit.append( ' if Index < Max : ' ) + PyMoreInit.append( ' DoLoop = 1 ' ) + PyMoreInit.append( ' return DoLoop,Index,Max,z ' ) + PyMoreInit.append( ' ' ) + PyNextInit = [] + PyNextInit.append( 'def Next(Index,Max,z) : ' ) + PyNextInit.append( ' Index = Index + 1 ' ) + PyNextInit.append( ' return Index,Max,z ' ) + PyNextInit.append( ' ' ) + Init,EndInit = GraphLoopsCoupled_3.LNode( '' , PyInit , 'More' , PyMoreInit , 'Next' , PyNextInit ) + EndInit.SetName( 'EndInit' ) + EndInit.SetAuthor( '' ) + EndInit.SetComment( 'Compute Node' ) + EndInit.Coords( 670 , 288 ) + PyEndInit = [] + EndInit.SetPyFunction( 'EndInit' , PyEndInit ) + IInitDoLoop = Init.GetInPort( 'DoLoop' ) + IInitIndex = Init.InPort( 'Index' , 'long' ) + IInitMax = Init.InPort( 'Max' , 'long' ) + IInitz = Init.InPort( 'z' , 'long' ) + IInitGate = Init.GetInPort( 'Gate' ) + OInitDoLoop = Init.GetOutPort( 'DoLoop' ) + OInitIndex = Init.GetOutPort( 'Index' ) + OInitMax = Init.GetOutPort( 'Max' ) + OInitz = Init.GetOutPort( 'z' ) + IEndInitDoLoop = EndInit.GetInPort( 'DoLoop' ) + IEndInitIndex = EndInit.GetInPort( 'Index' ) + IEndInitMax = EndInit.GetInPort( 'Max' ) + IEndInitz = EndInit.GetInPort( 'z' ) + IEndInitGate = EndInit.GetInPort( 'Gate' ) + OEndInitDoLoop = EndInit.GetOutPort( 'DoLoop' ) + OEndInitIndex = EndInit.GetOutPort( 'Index' ) + OEndInitMax = EndInit.GetOutPort( 'Max' ) + OEndInitz = EndInit.GetOutPort( 'z' ) + OEndInitGate = EndInit.GetOutPort( 'Gate' ) + Init.SetName( 'Init' ) + Init.SetAuthor( '' ) + Init.SetComment( 'Compute Node' ) + Init.Coords( 10 , 308 ) + + # Creation of Links + LAddzSuby = GraphLoopsCoupled_3.Link( OAddz , ISuby ) + + LAddzSub_1x = GraphLoopsCoupled_3.Link( OAddz , ISub_1x ) + + LAdd_1zSub_1y = GraphLoopsCoupled_3.Link( OAdd_1z , ISub_1y ) + + LAdd_1zSubx = GraphLoopsCoupled_3.Link( OAdd_1z , ISubx ) + + LSubzEndInitz = GraphLoopsCoupled_3.Link( OSubz , IEndInitz ) + + LSub_1zEndLoopz = GraphLoopsCoupled_3.Link( OSub_1z , IEndLoopz ) + + LLoopIndexEndLoopIndex = GraphLoopsCoupled_3.Link( OLoopIndex , IEndLoopIndex ) + + LLoopMaxEndLoopMax = GraphLoopsCoupled_3.Link( OLoopMax , IEndLoopMax ) + + LLoopMaxAddx = GraphLoopsCoupled_3.Link( OLoopMax , IAddx ) + + LLoopzAddy = GraphLoopsCoupled_3.Link( OLoopz , IAddy ) + + LInitIndexEndInitIndex = GraphLoopsCoupled_3.Link( OInitIndex , IEndInitIndex ) + + LInitMaxEndInitMax = GraphLoopsCoupled_3.Link( OInitMax , IEndInitMax ) + + LInitMaxAdd_1x = GraphLoopsCoupled_3.Link( OInitMax , IAdd_1x ) + + LInitzAdd_1y = GraphLoopsCoupled_3.Link( OInitz , IAdd_1y ) + + # Input datas + ILoopIndex.Input( 5 ) + ILoopMax.Input( 15 ) + ILoopz.Input( -1 ) + IInitIndex.Input( 3 ) + IInitMax.Input( 13 ) + IInitz.Input( -2 ) + + # Output Ports of the graph + #OEndLoopIndex = EndLoop.GetOutPort( 'Index' ) + #OEndLoopMax = EndLoop.GetOutPort( 'Max' ) + #OEndLoopz = EndLoop.GetOutPort( 'z' ) + #OEndInitIndex = EndInit.GetOutPort( 'Index' ) + #OEndInitMax = EndInit.GetOutPort( 'Max' ) + #OEndInitz = EndInit.GetOutPort( 'z' ) + return GraphLoopsCoupled_3 + + +GraphLoopsCoupled_3 = DefGraphLoopsCoupled_3() diff --git a/examples/GraphLoopsCoupled.xml b/examples/GraphLoopsCoupled.xml new file mode 100644 index 0000000..33d583e --- /dev/null +++ b/examples/GraphLoopsCoupled.xml @@ -0,0 +1,553 @@ + + + + + +? + ? + GraphLoopsCoupled_3 + 1 + ? + +GraphLoopsCoupled_3 + + +long + Loop__Index + +long + Loop__Max + +long + Loop__z + +long + Init__Index + +long + Init__Max + +long + Init__z + + +long + EndLoop__Index + +long + EndLoop__Max + +long + EndLoop__z + +long + EndInit__Index + +long + EndInit__Max + +long + EndInit__z + + + 17/12/2004 - 17:11:7 + 17/12/2004 - 18:26:39 + 2.0 + JR + ? + ? + 0 + 0 + + +? + ? + Add + 3 + ? + +Add + + +long + x + +long + y + + +long + z + + + +Add + + + + 17/12/2004 - 18:26:39 + 17/12/2004 - 18:26:39 + 2.0 + ? + ? + Compute Node + 245 + 38 + +? + ? + Add_1 + 3 + ? + +Add_1 + + +long + x + +long + y + + +long + z + + + +Add + + + + 17/12/2004 - 18:26:39 + 17/12/2004 - 18:26:39 + 2.0 + ? + ? + Compute Node + 243 + 288 + +? + ? + Sub + 3 + ? + +Sub + + +long + x + +long + y + + +long + z + + + +Sub + + + + 17/12/2004 - 18:26:39 + 17/12/2004 - 18:26:39 + 2.0 + ? + ? + Compute Node + 458 + 18 + +? + ? + Sub_1 + 3 + ? + +Sub_1 + + +long + x + +long + y + + +long + z + + + +Sub + + + + 17/12/2004 - 18:26:39 + 17/12/2004 - 18:26:39 + 2.0 + ? + ? + Compute Node + 461 + 268 + +? + ? + Loop + 4 + EndLoop + +Loop + + +long + Index + +long + Max + +long + z + + +long + Index + +long + Max + +long + z + + + +? + + +More + + + + + + + +Next + + + + + 17/12/2004 - 18:26:39 + 17/12/2004 - 18:26:39 + 2.0 + ? + ? + Compute Node + 15 + 58 + +? + ? + EndLoop + 5 + Loop + +EndLoop + + +long + Index + +long + Max + +long + z + + +long + Index + +long + Max + +long + z + + + +EndLoop + + 17/12/2004 - 18:26:39 + 17/12/2004 - 18:26:39 + 2.0 + ? + ? + Compute Node + 662 + 38 + +? + ? + Init + 4 + EndInit + +Init + + +long + Index + +long + Max + +long + z + + +long + Index + +long + Max + +long + z + + + +? + + +More + + + + + + + +Next + + + + + 17/12/2004 - 18:26:39 + 17/12/2004 - 18:26:39 + 2.0 + ? + ? + Compute Node + 10 + 308 + +? + ? + EndInit + 5 + Init + +EndInit + + +long + Index + +long + Max + +long + z + + +long + Index + +long + Max + +long + z + + + +EndInit + + 17/12/2004 - 18:26:39 + 17/12/2004 - 18:26:39 + 2.0 + ? + ? + Compute Node + 670 + 288 + + +Add + z + Sub + y + + +Add + z + Sub_1 + x + + +Add_1 + z + Sub_1 + y + + +Add_1 + z + Sub + x + + +Sub + z + EndInit + z + + +Sub_1 + z + EndLoop + z + + +Loop + DoLoop + EndLoop + DoLoop + + +Loop + Index + EndLoop + Index + + +Loop + Max + EndLoop + Max + + +Loop + Max + Add + x + + +Loop + z + Add + y + + +EndLoop + DoLoop + Loop + DoLoop + + +Init + DoLoop + EndInit + DoLoop + + +Init + Index + EndInit + Index + + +Init + Max + EndInit + Max + + +Init + Max + Add_1 + x + + +Init + z + Add_1 + y + + +EndInit + DoLoop + Init + DoLoop + + + +GraphLoopsCoupled_3 + Loop__Index + Loop + Index + +3 + 5 + + +GraphLoopsCoupled_3 + Loop__Max + Loop + Max + +3 + 15 + + +GraphLoopsCoupled_3 + Loop__z + Loop + z + +3 + -1 + + +GraphLoopsCoupled_3 + Init__Index + Init + Index + +3 + 3 + + +GraphLoopsCoupled_3 + Init__Max + Init + Max + +3 + 13 + + +GraphLoopsCoupled_3 + Init__z + Init + z + +3 + -2 + diff --git a/examples/GraphLoopsGates.py b/examples/GraphLoopsGates.py new file mode 100644 index 0000000..9d63e77 --- /dev/null +++ b/examples/GraphLoopsGates.py @@ -0,0 +1,255 @@ + +# Generated python file of Graph GraphLoopsGates_1 + +from SuperV import * + +# Graph creation of GraphLoopsGates_1 +def DefGraphLoopsGates_1() : + GraphLoopsGates_1 = Graph( 'GraphLoopsGates_1' ) + GraphLoopsGates_1.SetName( 'GraphLoopsGates_1' ) + GraphLoopsGates_1.SetAuthor( 'JR' ) + GraphLoopsGates_1.SetComment( '' ) + GraphLoopsGates_1.Coords( 0 , 0 ) + + # Creation of Factory Nodes + + Add = GraphLoopsGates_1.FNode( 'AddComponent' , 'AddComponent' , 'Add' ) + Add.SetName( 'Add' ) + Add.SetAuthor( '' ) + Add.SetContainer( 'localhost/FactoryServer' ) + Add.SetComment( 'Add from AddComponent' ) + Add.Coords( 230 , 76 ) + IAddx = Add.GetInPort( 'x' ) + IAddy = Add.GetInPort( 'y' ) + IAddGate = Add.GetInPort( 'Gate' ) + OAddFuncValue = Add.GetOutPort( 'FuncValue' ) + OAddz = Add.GetOutPort( 'z' ) + OAddGate = Add.GetOutPort( 'Gate' ) + + Add_1 = GraphLoopsGates_1.FNode( 'AddComponent' , 'AddComponent' , 'Add' ) + Add_1.SetName( 'Add_1' ) + Add_1.SetAuthor( '' ) + Add_1.SetContainer( 'localhost/FactoryServer' ) + Add_1.SetComment( 'Add from AddComponent' ) + Add_1.Coords( 225 , 304 ) + IAdd_1x = Add_1.GetInPort( 'x' ) + IAdd_1y = Add_1.GetInPort( 'y' ) + IAdd_1Gate = Add_1.GetInPort( 'Gate' ) + OAdd_1FuncValue = Add_1.GetOutPort( 'FuncValue' ) + OAdd_1z = Add_1.GetOutPort( 'z' ) + OAdd_1Gate = Add_1.GetOutPort( 'Gate' ) + + Sub = GraphLoopsGates_1.FNode( 'SubComponent' , 'SubComponent' , 'Sub' ) + Sub.SetName( 'Sub' ) + Sub.SetAuthor( '' ) + Sub.SetContainer( 'localhost/FactoryServer' ) + Sub.SetComment( 'Sub from SubComponent' ) + Sub.Coords( 447 , 77 ) + ISubx = Sub.GetInPort( 'x' ) + ISuby = Sub.GetInPort( 'y' ) + ISubGate = Sub.GetInPort( 'Gate' ) + OSubz = Sub.GetOutPort( 'z' ) + OSubGate = Sub.GetOutPort( 'Gate' ) + + Sub_1 = GraphLoopsGates_1.FNode( 'SubComponent' , 'SubComponent' , 'Sub' ) + Sub_1.SetName( 'Sub_1' ) + Sub_1.SetAuthor( '' ) + Sub_1.SetContainer( 'localhost/FactoryServer' ) + Sub_1.SetComment( 'Sub from SubComponent' ) + Sub_1.Coords( 448 , 304 ) + ISub_1x = Sub_1.GetInPort( 'x' ) + ISub_1y = Sub_1.GetInPort( 'y' ) + ISub_1Gate = Sub_1.GetInPort( 'Gate' ) + OSub_1z = Sub_1.GetOutPort( 'z' ) + OSub_1Gate = Sub_1.GetOutPort( 'Gate' ) + + # Creation of InLine Nodes + PyGate = [] + PyGate.append( 'from time import * ' ) + PyGate.append( 'def Gate(G1,G2) : ' ) + PyGate.append( ' sleep(1) ' ) + PyGate.append( ' return G1&G2 ' ) + Gate = GraphLoopsGates_1.INode( 'Gate' , PyGate ) + Gate.SetName( 'Gate' ) + Gate.SetAuthor( '' ) + Gate.SetComment( 'Compute Node' ) + Gate.Coords( 640 , 224 ) + IGateG1 = Gate.InPort( 'G1' , 'long' ) + IGateG2 = Gate.InPort( 'G2' , 'long' ) + IGateGate = Gate.GetInPort( 'Gate' ) + OGateG = Gate.OutPort( 'G' , 'long' ) + OGateGate = Gate.GetOutPort( 'Gate' ) + + # Creation of Loop Nodes + PyInit = [] + PyInit.append( 'from time import * ' ) + PyInit.append( 'def Init(Index,Min,Max) : ' ) + PyInit.append( ' Index = Min ' ) + PyInit.append( ' sleep(1) ' ) + PyInit.append( ' return Index,Min,Max ' ) + PyMoreInit = [] + PyMoreInit.append( 'def More(Index,Min,Max) : ' ) + PyMoreInit.append( ' if Index < Max : ' ) + PyMoreInit.append( ' DoLoop = 1 ' ) + PyMoreInit.append( ' else : ' ) + PyMoreInit.append( ' DoLoop = 0 ' ) + PyMoreInit.append( ' return DoLoop,Index,Min,Max ' ) + PyNextInit = [] + PyNextInit.append( 'from time import * ' ) + PyNextInit.append( 'def Next(Index,Min,Max) : ' ) + PyNextInit.append( ' Index = Index + 1 ' ) + PyNextInit.append( ' sleep(1) ' ) + PyNextInit.append( ' return Index,Min,Max ' ) + Init,EndInit = GraphLoopsGates_1.LNode( 'Init' , PyInit , 'More' , PyMoreInit , 'Next' , PyNextInit ) + EndInit.SetName( 'EndInit' ) + EndInit.SetAuthor( '' ) + EndInit.SetComment( 'Compute Node' ) + EndInit.Coords( 851 , 200 ) + PyEndInit = [] + EndInit.SetPyFunction( 'EndInit' , PyEndInit ) + IInitDoLoop = Init.GetInPort( 'DoLoop' ) + IInitIndex = Init.InPort( 'Index' , 'long' ) + IInitMin = Init.InPort( 'Min' , 'long' ) + IInitMax = Init.InPort( 'Max' , 'long' ) + IInitGate = Init.GetInPort( 'Gate' ) + OInitDoLoop = Init.GetOutPort( 'DoLoop' ) + OInitIndex = Init.GetOutPort( 'Index' ) + OInitMin = Init.GetOutPort( 'Min' ) + OInitMax = Init.GetOutPort( 'Max' ) + IEndInitDoLoop = EndInit.GetInPort( 'DoLoop' ) + IEndInitIndex = EndInit.GetInPort( 'Index' ) + IEndInitMin = EndInit.GetInPort( 'Min' ) + IEndInitMax = EndInit.GetInPort( 'Max' ) + IEndInitGate = EndInit.GetInPort( 'Gate' ) + OEndInitDoLoop = EndInit.GetOutPort( 'DoLoop' ) + OEndInitIndex = EndInit.GetOutPort( 'Index' ) + OEndInitMin = EndInit.GetOutPort( 'Min' ) + OEndInitMax = EndInit.GetOutPort( 'Max' ) + OEndInitGate = EndInit.GetOutPort( 'Gate' ) + Init.SetName( 'Init' ) + Init.SetAuthor( '' ) + Init.SetComment( 'Compute Node' ) + Init.Coords( 29 , 251 ) + + PyInit_1 = [] + PyInit_1.append( 'from time import * ' ) + PyInit_1.append( 'def Init_1(Index,Min,Max) : ' ) + PyInit_1.append( ' Index = Min ' ) + PyInit_1.append( ' sleep(1) ' ) + PyInit_1.append( ' return Index,Min,Max ' ) + PyMoreInit_1 = [] + PyMoreInit_1.append( 'def More_1(Index,Min,Max) : ' ) + PyMoreInit_1.append( ' if Index < Max : ' ) + PyMoreInit_1.append( ' DoLoop = 1 ' ) + PyMoreInit_1.append( ' else : ' ) + PyMoreInit_1.append( ' DoLoop = 0 ' ) + PyMoreInit_1.append( ' return DoLoop,Index,Min,Max ' ) + PyNextInit_1 = [] + PyNextInit_1.append( 'from time import * ' ) + PyNextInit_1.append( 'def Next_1(Index,Min,Max) : ' ) + PyNextInit_1.append( ' Index = Index + 1 ' ) + PyNextInit_1.append( ' sleep(1) ' ) + PyNextInit_1.append( ' return Index,Min,Max ' ) + Init_1,EndInit_1 = GraphLoopsGates_1.LNode( 'Init_1' , PyInit_1 , 'More_1' , PyMoreInit_1 , 'Next_1' , PyNextInit_1 ) + EndInit_1.SetName( 'EndInit_1' ) + EndInit_1.SetAuthor( '' ) + EndInit_1.SetComment( 'Compute Node' ) + EndInit_1.Coords( 1049 , 201 ) + PyEndInit_1 = [] + EndInit_1.SetPyFunction( 'EndInit_1' , PyEndInit_1 ) + IInit_1DoLoop = Init_1.GetInPort( 'DoLoop' ) + IInit_1Index = Init_1.InPort( 'Index' , 'long' ) + IInit_1Min = Init_1.InPort( 'Min' , 'long' ) + IInit_1Max = Init_1.InPort( 'Max' , 'long' ) + IInit_1Gate = Init_1.GetInPort( 'Gate' ) + OInit_1DoLoop = Init_1.GetOutPort( 'DoLoop' ) + OInit_1Index = Init_1.GetOutPort( 'Index' ) + OInit_1Min = Init_1.GetOutPort( 'Min' ) + OInit_1Max = Init_1.GetOutPort( 'Max' ) + IEndInit_1DoLoop = EndInit_1.GetInPort( 'DoLoop' ) + IEndInit_1Index = EndInit_1.GetInPort( 'Index' ) + IEndInit_1Min = EndInit_1.GetInPort( 'Min' ) + IEndInit_1Max = EndInit_1.GetInPort( 'Max' ) + IEndInit_1Gate = EndInit_1.GetInPort( 'Gate' ) + OEndInit_1DoLoop = EndInit_1.GetOutPort( 'DoLoop' ) + OEndInit_1Index = EndInit_1.GetOutPort( 'Index' ) + OEndInit_1Min = EndInit_1.GetOutPort( 'Min' ) + OEndInit_1Max = EndInit_1.GetOutPort( 'Max' ) + OEndInit_1Gate = EndInit_1.GetOutPort( 'Gate' ) + Init_1.SetName( 'Init_1' ) + Init_1.SetAuthor( '' ) + Init_1.SetComment( 'Compute Node' ) + Init_1.Coords( 9 , 24 ) + + # Creation of Links + LInitIndexEndInitIndex = GraphLoopsGates_1.Link( OInitIndex , IEndInitIndex ) + + LInitIndexSubx = GraphLoopsGates_1.Link( OInitIndex , ISubx ) + + LInitMinEndInitMin = GraphLoopsGates_1.Link( OInitMin , IEndInitMin ) + + LInitMinSuby = GraphLoopsGates_1.Link( OInitMin , ISuby ) + + LInitMinSub_1x = GraphLoopsGates_1.Link( OInitMin , ISub_1x ) + + LInitMaxEndInitMax = GraphLoopsGates_1.Link( OInitMax , IEndInitMax ) + + LInitMaxSub_1y = GraphLoopsGates_1.Link( OInitMax , ISub_1y ) + + LInitGateAdd_1Gate = GraphLoopsGates_1.Link( OInitGate , IAdd_1Gate ) + + LInitGateAddGate = GraphLoopsGates_1.Link( OInitGate , IAddGate ) + + LEndInitGateEndInit_1Gate = GraphLoopsGates_1.Link( OEndInitGate , IEndInit_1Gate ) + + LAddGateSubGate = GraphLoopsGates_1.Link( OAddGate , ISubGate ) + + LAdd_1GateSub_1Gate = GraphLoopsGates_1.Link( OAdd_1Gate , ISub_1Gate ) + + LSubGateGateG1 = GraphLoopsGates_1.Link( OSubGate , IGateG1 ) + + LSub_1GateGateG2 = GraphLoopsGates_1.Link( OSub_1Gate , IGateG2 ) + + LGateGEndInitGate = GraphLoopsGates_1.Link( OGateG , IEndInitGate ) + + LInit_1IndexEndInit_1Index = GraphLoopsGates_1.Link( OInit_1Index , IEndInit_1Index ) + + LInit_1MinEndInit_1Min = GraphLoopsGates_1.Link( OInit_1Min , IEndInit_1Min ) + + LInit_1MaxEndInit_1Max = GraphLoopsGates_1.Link( OInit_1Max , IEndInit_1Max ) + + LInit_1GateInitGate = GraphLoopsGates_1.Link( OInit_1Gate , IInitGate ) + LInit_1GateInitGate.AddCoord( 1 , 9 , 346 ) + LInit_1GateInitGate.AddCoord( 2 , 9 , 199 ) + LInit_1GateInitGate.AddCoord( 3 , 194 , 199 ) + LInit_1GateInitGate.AddCoord( 4 , 194 , 119 ) + + # Input datas + IInitIndex.Input( 0 ) + IInitMin.Input( 5 ) + IInitMax.Input( 8 ) + IAddx.Input( 1 ) + IAddy.Input( 2 ) + IAdd_1x.Input( 3 ) + IAdd_1y.Input( 4 ) + IInit_1Index.Input( 0 ) + IInit_1Min.Input( 1 ) + IInit_1Max.Input( 3 ) + + # Output Ports of the graph + #OEndInitIndex = EndInit.GetOutPort( 'Index' ) + #OEndInitMin = EndInit.GetOutPort( 'Min' ) + #OEndInitMax = EndInit.GetOutPort( 'Max' ) + #OAddFuncValue = Add.GetOutPort( 'FuncValue' ) + #OAddz = Add.GetOutPort( 'z' ) + #OAdd_1FuncValue = Add_1.GetOutPort( 'FuncValue' ) + #OAdd_1z = Add_1.GetOutPort( 'z' ) + #OSubz = Sub.GetOutPort( 'z' ) + #OSub_1z = Sub_1.GetOutPort( 'z' ) + #OEndInit_1Index = EndInit_1.GetOutPort( 'Index' ) + #OEndInit_1Min = EndInit_1.GetOutPort( 'Min' ) + #OEndInit_1Max = EndInit_1.GetOutPort( 'Max' ) + return GraphLoopsGates_1 + + +GraphLoopsGates_1 = DefGraphLoopsGates_1() diff --git a/examples/GraphLoopsGates.xml b/examples/GraphLoopsGates.xml new file mode 100644 index 0000000..38c05b6 --- /dev/null +++ b/examples/GraphLoopsGates.xml @@ -0,0 +1,692 @@ + + + + + +? + ? + GraphLoopsGates_1 + 1 + ? + +GraphLoopsGates_1 + + +long + Init__Index + +long + Init__Min + +long + Init__Max + +double + Add__x + +double + Add__y + +double + Add_1__x + +double + Add_1__y + +long + Init_1__Index + +long + Init_1__Min + +long + Init_1__Max + + +long + EndInit__Index + +long + EndInit__Min + +long + EndInit__Max + +double + Add__FuncValue + +double + Add__z + +double + Add_1__FuncValue + +double + Add_1__z + +double + Sub__z + +double + Sub_1__z + +long + EndInit_1__Index + +long + EndInit_1__Min + +long + EndInit_1__Max + + + 7/1/2005 - 16:57:1 + 7/1/2005 - 17:57:7 + 2.0 + JR + ? + ? + 0 + 0 + + +? + ? + Init + 4 + EndInit + +Init + + +long + Index + +long + Min + +long + Max + + +long + Index + +long + Min + +long + Max + + + +Init + + + + + + +More + + + + + + + +Next + + + + + + 7/1/2005 - 17:57:7 + 7/1/2005 - 17:57:7 + 2.0 + ? + ? + Compute Node + 29 + 251 + +? + ? + EndInit + 5 + Init + +EndInit + + +long + Index + +long + Min + +long + Max + + +long + Index + +long + Min + +long + Max + + + +EndInit + + 7/1/2005 - 17:57:7 + 7/1/2005 - 17:57:7 + 2.0 + ? + ? + Compute Node + 851 + 200 + +AddComponent + AddComponent + Add + 0 + ? + +Add + + +double + x + +double + y + + +double + FuncValue + +double + z + + + 7/1/2005 - 17:57:7 + 7/1/2005 - 17:57:7 + 2.0 + ? + localhost/FactoryServer + Add from AddComponent + 230 + 76 + +AddComponent + AddComponent + Add_1 + 0 + ? + +Add + + +double + x + +double + y + + +double + FuncValue + +double + z + + + 7/1/2005 - 17:57:7 + 7/1/2005 - 17:57:7 + 2.0 + ? + localhost/FactoryServer + Add from AddComponent + 225 + 304 + +SubComponent + SubComponent + Sub + 0 + ? + +Sub + + +double + x + +double + y + + +double + z + + + 7/1/2005 - 17:57:7 + 7/1/2005 - 17:57:7 + 2.0 + ? + localhost/FactoryServer + Sub from SubComponent + 447 + 77 + +SubComponent + SubComponent + Sub_1 + 0 + ? + +Sub + + +double + x + +double + y + + +double + z + + + 7/1/2005 - 17:57:7 + 7/1/2005 - 17:57:7 + 2.0 + ? + localhost/FactoryServer + Sub from SubComponent + 448 + 304 + +? + ? + Gate + 3 + ? + +Gate + + +long + G1 + +long + G2 + + +long + G + + + +Gate + + + + + 7/1/2005 - 17:57:7 + 7/1/2005 - 17:57:7 + 2.0 + ? + ? + Compute Node + 640 + 224 + +? + ? + Init_1 + 4 + EndInit_1 + +Init_1 + + +long + Index + +long + Min + +long + Max + + +long + Index + +long + Min + +long + Max + + + +Init_1 + + + + + + +More_1 + + + + + + + +Next_1 + + + + + + 7/1/2005 - 17:57:7 + 7/1/2005 - 17:57:7 + 2.0 + ? + ? + Compute Node + 9 + 24 + +? + ? + EndInit_1 + 5 + Init_1 + +EndInit_1 + + +long + Index + +long + Min + +long + Max + + +long + Index + +long + Min + +long + Max + + + +EndInit_1 + + 7/1/2005 - 17:57:7 + 7/1/2005 - 17:57:7 + 2.0 + ? + ? + Compute Node + 1049 + 201 + + +Init + DoLoop + EndInit + DoLoop + + +Init + Index + EndInit + Index + + +Init + Index + Sub + x + + +Init + Min + EndInit + Min + + +Init + Min + Sub + y + + +Init + Min + Sub_1 + x + + +Init + Max + EndInit + Max + + +Init + Max + Sub_1 + y + + +Init + Gate + Add_1 + Gate + + +Init + Gate + Add + Gate + + +EndInit + DoLoop + Init + DoLoop + + +EndInit + Gate + EndInit_1 + Gate + + +Add + Gate + Sub + Gate + + +Add_1 + Gate + Sub_1 + Gate + + +Sub + Gate + Gate + G1 + + +Sub_1 + Gate + Gate + G2 + + +Gate + G + EndInit + Gate + + +Init_1 + DoLoop + EndInit_1 + DoLoop + + +Init_1 + Index + EndInit_1 + Index + + +Init_1 + Min + EndInit_1 + Min + + +Init_1 + Max + EndInit_1 + Max + + +Init_1 + Gate + Init + Gate + + +9 + 346 + +9 + 199 + +194 + 199 + +194 + 119 + +EndInit_1 + DoLoop + Init_1 + DoLoop + + + +GraphLoopsGates_1 + Init__Index + Init + Index + +3 + 0 + + +GraphLoopsGates_1 + Init__Min + Init + Min + +3 + 5 + + +GraphLoopsGates_1 + Init__Max + Init + Max + +3 + 8 + + +GraphLoopsGates_1 + Add__x + Add + x + +7 + 1 + + +GraphLoopsGates_1 + Add__y + Add + y + +7 + 2 + + +GraphLoopsGates_1 + Add_1__x + Add_1 + x + +7 + 3 + + +GraphLoopsGates_1 + Add_1__y + Add_1 + y + +7 + 4 + + +GraphLoopsGates_1 + Init_1__Index + Init_1 + Index + +3 + 0 + + +GraphLoopsGates_1 + Init_1__Min + Init_1 + Min + +3 + 1 + + +GraphLoopsGates_1 + Init_1__Max + Init_1 + Max + +3 + 3 + diff --git a/examples/GraphMacroNodes.py b/examples/GraphMacroNodes.py index d917ab5..75fdfe0 100644 --- a/examples/GraphMacroNodes.py +++ b/examples/GraphMacroNodes.py @@ -277,7 +277,7 @@ def DefSyrStruct_1() : EndOfforN.Coords( 1535 , 332 ) PyEndOfforN = [] EndOfforN.SetPyFunction( '' , PyEndOfforN ) - IforNInitLoop = forN.GetInPort( 'InitLoop' ) + IforNInitLoop = forN.GetInPort( 'DoLoop' ) IforNN = forN.InPort( 'N' , 'long' ) IforNK = forN.InPort( 'K' , 'long' ) IforNSyrComponent = forN.InPort( 'SyrComponent' , 'objref' ) @@ -329,7 +329,7 @@ def DefSyrStruct_1() : EndOfwhileNotOne.Coords( 1366 , 303 ) PyEndOfwhileNotOne = [] EndOfwhileNotOne.SetPyFunction( '' , PyEndOfwhileNotOne ) - IwhileNotOneInitLoop = whileNotOne.GetInPort( 'InitLoop' ) + IwhileNotOneInitLoop = whileNotOne.GetInPort( 'DoLoop' ) IwhileNotOneSyrComponent = whileNotOne.InPort( 'SyrComponent' , 'objref' ) IwhileNotOneN = whileNotOne.InPort( 'N' , 'long' ) IwhileNotOneK = whileNotOne.InPort( 'K' , 'long' ) @@ -372,7 +372,7 @@ def DefSyrStruct_1() : EndOffori.Coords( 976 , 212 ) PyEndOffori = [] EndOffori.SetPyFunction( '' , PyEndOffori ) - IforiInitLoop = fori.GetInPort( 'InitLoop' ) + IforiInitLoop = fori.GetInPort( 'DoLoop' ) Iforii = fori.InPort( 'i' , 'long' ) IforiK = fori.InPort( 'K' , 'long' ) IforiGate = fori.GetInPort( 'Gate' ) @@ -411,7 +411,7 @@ def DefSyrStruct_1() : EndOfwhileEven.Coords( 988 , 451 ) PyEndOfwhileEven = [] EndOfwhileEven.SetPyFunction( '' , PyEndOfwhileEven ) - IwhileEvenInitLoop = whileEven.GetInPort( 'InitLoop' ) + IwhileEvenInitLoop = whileEven.GetInPort( 'DoLoop' ) IwhileEvenSyrComponent = whileEven.InPort( 'SyrComponent' , 'objref' ) IwhileEvenN = whileEven.InPort( 'N' , 'long' ) IwhileEvenK = whileEven.InPort( 'K' , 'long' ) @@ -712,7 +712,7 @@ def DefSyrStruct_1_1() : EndOfforN.Coords( 1535 , 332 ) PyEndOfforN = [] EndOfforN.SetPyFunction( '' , PyEndOfforN ) - IforNInitLoop = forN.GetInPort( 'InitLoop' ) + IforNInitLoop = forN.GetInPort( 'DoLoop' ) IforNN = forN.InPort( 'N' , 'long' ) IforNK = forN.InPort( 'K' , 'long' ) IforNSyrComponent = forN.InPort( 'SyrComponent' , 'objref' ) @@ -764,7 +764,7 @@ def DefSyrStruct_1_1() : EndOfwhileNotOne.Coords( 1366 , 303 ) PyEndOfwhileNotOne = [] EndOfwhileNotOne.SetPyFunction( '' , PyEndOfwhileNotOne ) - IwhileNotOneInitLoop = whileNotOne.GetInPort( 'InitLoop' ) + IwhileNotOneInitLoop = whileNotOne.GetInPort( 'DoLoop' ) IwhileNotOneSyrComponent = whileNotOne.InPort( 'SyrComponent' , 'objref' ) IwhileNotOneN = whileNotOne.InPort( 'N' , 'long' ) IwhileNotOneK = whileNotOne.InPort( 'K' , 'long' ) @@ -807,7 +807,7 @@ def DefSyrStruct_1_1() : EndOffori.Coords( 976 , 212 ) PyEndOffori = [] EndOffori.SetPyFunction( '' , PyEndOffori ) - IforiInitLoop = fori.GetInPort( 'InitLoop' ) + IforiInitLoop = fori.GetInPort( 'DoLoop' ) Iforii = fori.InPort( 'i' , 'long' ) IforiK = fori.InPort( 'K' , 'long' ) IforiGate = fori.GetInPort( 'Gate' ) @@ -846,7 +846,7 @@ def DefSyrStruct_1_1() : EndOfwhileEven.Coords( 988 , 451 ) PyEndOfwhileEven = [] EndOfwhileEven.SetPyFunction( '' , PyEndOfwhileEven ) - IwhileEvenInitLoop = whileEven.GetInPort( 'InitLoop' ) + IwhileEvenInitLoop = whileEven.GetInPort( 'DoLoop' ) IwhileEvenSyrComponent = whileEven.InPort( 'SyrComponent' , 'objref' ) IwhileEvenN = whileEven.InPort( 'N' , 'long' ) IwhileEvenK = whileEven.InPort( 'K' , 'long' ) diff --git a/examples/GraphMacroNodes.xml b/examples/GraphMacroNodes.xml index 230ec63..584f9f3 100644 --- a/examples/GraphMacroNodes.xml +++ b/examples/GraphMacroNodes.xml @@ -1422,7 +1422,7 @@ EndOfforN DoLoop forN - InitLoop + DoLoop whileNotOne @@ -1458,7 +1458,7 @@ EndOfwhileNotOne DoLoop whileNotOne - InitLoop + DoLoop EndOfwhileNotOne @@ -1488,7 +1488,7 @@ EndOffori DoLoop fori - InitLoop + DoLoop EndOffori @@ -1536,7 +1536,7 @@ EndOfwhileEven DoLoop whileEven - InitLoop + DoLoop EndOfwhileEven @@ -2525,7 +2525,7 @@ EndOfforN DoLoop forN - InitLoop + DoLoop whileNotOne @@ -2561,7 +2561,7 @@ EndOfwhileNotOne DoLoop whileNotOne - InitLoop + DoLoop EndOfwhileNotOne @@ -2591,7 +2591,7 @@ EndOffori DoLoop fori - InitLoop + DoLoop EndOffori @@ -2639,7 +2639,7 @@ EndOfwhileEven DoLoop whileEven - InitLoop + DoLoop EndOfwhileEven diff --git a/examples/GraphNonVoidEndLoop.py b/examples/GraphNonVoidEndLoop.py new file mode 100644 index 0000000..5131b3b --- /dev/null +++ b/examples/GraphNonVoidEndLoop.py @@ -0,0 +1,101 @@ + +# Generated python file of Graph GraphNonVoidEndLoop + +from SuperV import * + +# Graph creation of GraphNonVoidEndLoop +def DefGraphNonVoidEndLoop() : + GraphNonVoidEndLoop = Graph( 'GraphNonVoidEndLoop' ) + GraphNonVoidEndLoop.SetName( 'GraphNonVoidEndLoop' ) + GraphNonVoidEndLoop.SetAuthor( '' ) + GraphNonVoidEndLoop.SetComment( '' ) + GraphNonVoidEndLoop.Coords( 0 , 0 ) + + # Creation of Factory Nodes + + # Creation of Loop Nodes + PyInit = [] + PyInit.append( 'def Init(Index,Min,Max,Incr) : ' ) + PyInit.append( ' if Min <= Max : ' ) + PyInit.append( ' Index = Min ' ) + PyInit.append( ' else : ' ) + PyInit.append( ' Index = Max ' ) + PyInit.append( ' print 'Init',Index,Min,Max,Incr ' ) + PyInit.append( ' return Index,Min,Max,Incr ' ) + PyMoreInit = [] + PyMoreInit.append( 'import time ' ) + PyMoreInit.append( 'def More(Index,Min,Max,Incr) : ' ) + PyMoreInit.append( ' time.sleep(2) ' ) + PyMoreInit.append( ' if Index < Max : ' ) + PyMoreInit.append( ' DoLoop = 1 ' ) + PyMoreInit.append( ' else : ' ) + PyMoreInit.append( ' DoLoop = 0 ' ) + PyMoreInit.append( ' print 'More', DoLoop,Index,Min,Max,Incr ' ) + PyMoreInit.append( ' return DoLoop,Index,Min,Max,Incr ' ) + PyNextInit = [] + PyNextInit.append( 'def Next(Index,Min,Max,Incr) : ' ) + PyNextInit.append( ' Index = Index + Incr ' ) + PyNextInit.append( ' print 'Next', Index,Min,Max,Incr ' ) + PyNextInit.append( ' return Index,Min,Max,Incr ' ) + Init,EndInit = GraphNonVoidEndLoop.LNode( 'Init' , PyInit , 'More' , PyMoreInit , 'Next' , PyNextInit ) + EndInit.SetName( 'EndInit' ) + EndInit.SetAuthor( '' ) + EndInit.SetComment( 'Compute Node' ) + EndInit.Coords( 411 , 260 ) + PyEndInit = [] + PyEndInit.append( 'def EndLoop(DoLoop,Index,Min,Max,Incr) : ' ) + PyEndInit.append( ' print 'EndLoop',DoLoop,Index,Min,Max,Incr ' ) + PyEndInit.append( ' return DoLoop,Index,Min,Max,Incr ' ) + PyEndInit.append( '' ) + EndInit.SetPyFunction( 'EndLoop' , PyEndInit ) + IInitDoLoop = Init.GetInPort( 'DoLoop' ) + IInitIndex = Init.InPort( 'Index' , 'long' ) + IInitMin = Init.InPort( 'Min' , 'long' ) + IInitMax = Init.InPort( 'Max' , 'long' ) + IInitIncr = Init.InPort( 'Incr' , 'long' ) + IInitGate = Init.GetInPort( 'Gate' ) + OInitDoLoop = Init.GetOutPort( 'DoLoop' ) + OInitIndex = Init.GetOutPort( 'Index' ) + OInitMin = Init.GetOutPort( 'Min' ) + OInitMax = Init.GetOutPort( 'Max' ) + OInitIncr = Init.GetOutPort( 'Incr' ) + IEndInitDoLoop = EndInit.GetInPort( 'DoLoop' ) + IEndInitIndex = EndInit.GetInPort( 'Index' ) + IEndInitMin = EndInit.GetInPort( 'Min' ) + IEndInitMax = EndInit.GetInPort( 'Max' ) + IEndInitIncr = EndInit.GetInPort( 'Incr' ) + IEndInitGate = EndInit.GetInPort( 'Gate' ) + OEndInitDoLoop = EndInit.GetOutPort( 'DoLoop' ) + OEndInitIndex = EndInit.GetOutPort( 'Index' ) + OEndInitMin = EndInit.GetOutPort( 'Min' ) + OEndInitMax = EndInit.GetOutPort( 'Max' ) + OEndInitIncr = EndInit.GetOutPort( 'Incr' ) + Init.SetName( 'Init' ) + Init.SetAuthor( '' ) + Init.SetComment( 'Compute Node' ) + Init.Coords( 17 , 257 ) + + # Creation of Links + LInitIndexEndInitIndex = GraphNonVoidEndLoop.Link( OInitIndex , IEndInitIndex ) + + LInitMinEndInitMin = GraphNonVoidEndLoop.Link( OInitMin , IEndInitMin ) + + LInitMaxEndInitMax = GraphNonVoidEndLoop.Link( OInitMax , IEndInitMax ) + + LInitIncrEndInitIncr = GraphNonVoidEndLoop.Link( OInitIncr , IEndInitIncr ) + + # Input datas + IInitIndex.Input( 0 ) + IInitMin.Input( 5 ) + IInitMax.Input( 10 ) + IInitIncr.Input( 1 ) + + # Output Ports of the graph + #OEndInitIndex = EndInit.GetOutPort( 'Index' ) + #OEndInitMin = EndInit.GetOutPort( 'Min' ) + #OEndInitMax = EndInit.GetOutPort( 'Max' ) + #OEndInitIncr = EndInit.GetOutPort( 'Incr' ) + return GraphNonVoidEndLoop + + +GraphNonVoidEndLoop = DefGraphNonVoidEndLoop() diff --git a/examples/GraphNonVoidEndLoop.xml b/examples/GraphNonVoidEndLoop.xml new file mode 100644 index 0000000..8094cb0 --- /dev/null +++ b/examples/GraphNonVoidEndLoop.xml @@ -0,0 +1,243 @@ + + + + + +? + ? + GraphNonVoidEndLoop + 1 + ? + +GraphNonVoidEndLoop_1 + + +long + Init__Index + +long + Init__Min + +long + Init__Max + +long + Init__Incr + + +long + EndInit__Index + +long + EndInit__Min + +long + EndInit__Max + +long + EndInit__Incr + + + 24/3/2003 - 14:44:35 + 16/12/2004 - 16:53:28 + 1.04 + ? + ? + ? + 0 + 0 + + +? + ? + Init + 4 + EndInit + +Init + + +long + Index + +long + Min + +long + Max + +long + Incr + + +long + Index + +long + Min + +long + Max + +long + Incr + + + +Init + + + + + + + + +More + + + + + + + + + + +Next + + + + + 16/12/2004 - 16:53:28 + 16/12/2004 - 16:53:28 + 1.04 + ? + ? + Compute Node + 17 + 257 + +? + ? + EndInit + 5 + Init + +EndInit + + +long + Index + +long + Min + +long + Max + +long + Incr + + +long + Index + +long + Min + +long + Max + +long + Incr + + + +EndLoop + + + + + 16/12/2004 - 16:53:28 + 16/12/2004 - 16:53:28 + 1.04 + ? + ? + Compute Node + 411 + 260 + + +Init + DoLoop + EndInit + DoLoop + + +Init + Index + EndInit + Index + + +Init + Min + EndInit + Min + + +Init + Max + EndInit + Max + + +Init + Incr + EndInit + Incr + + +EndInit + DoLoop + Init + DoLoop + + + +GraphNonVoidEndLoop + Init__Index + Init + Index + +3 + 0 + + +GraphNonVoidEndLoop + Init__Min + Init + Min + +3 + 5 + + +GraphNonVoidEndLoop + Init__Max + Init + Max + +3 + 10 + + +GraphNonVoidEndLoop + Init__Incr + Init + Incr + +3 + 1 + diff --git a/examples/GraphObjRef.xml b/examples/GraphObjRef.xml index 7350c0d..ec02fa8 100755 --- a/examples/GraphObjRef.xml +++ b/examples/GraphObjRef.xml @@ -255,7 +255,7 @@ EndInit DoLoop Init - InitLoop + DoLoop diff --git a/examples/GraphPyFunctions.xml b/examples/GraphPyFunctions.xml index d99958d..91826b5 100755 --- a/examples/GraphPyFunctions.xml +++ b/examples/GraphPyFunctions.xml @@ -492,7 +492,7 @@ EndOfInitLoop DoLoop InitLoop - InitLoop + DoLoop InitLoop_1 @@ -522,7 +522,7 @@ EndOfInitLoop_1 DoLoop InitLoop_1 - InitLoop + DoLoop Switch diff --git a/examples/GraphSIGFPE.py b/examples/GraphSIGFPE.py new file mode 100644 index 0000000..45578ea --- /dev/null +++ b/examples/GraphSIGFPE.py @@ -0,0 +1,37 @@ + +# Generated python file of Graph GraphSIGFPE + +from SuperV import * + +# Graph creation of GraphSIGFPE +def DefGraphSIGFPE() : + GraphSIGFPE = Graph( 'GraphSIGFPE' ) + GraphSIGFPE.SetName( 'GraphSIGFPE' ) + GraphSIGFPE.SetAuthor( 'JR' ) + GraphSIGFPE.SetComment( '' ) + GraphSIGFPE.Coords( 0 , 0 ) + + # Creation of Factory Nodes + + SIGFPEfunc = GraphSIGFPE.FNode( 'SIGNALSComponent' , 'SIGNALSComponent' , 'SIGFPEfunc' ) + SIGFPEfunc.SetName( 'SIGFPEfunc' ) + SIGFPEfunc.SetAuthor( '' ) + SIGFPEfunc.SetContainer( 'localhost/FactoryServer' ) + SIGFPEfunc.SetComment( 'SIGFPEfunc from SIGNALSComponent' ) + SIGFPEfunc.Coords( 134 , 137 ) + ISIGFPEfunca = SIGFPEfunc.GetInPort( 'a' ) + ISIGFPEfuncb = SIGFPEfunc.GetInPort( 'b' ) + ISIGFPEfuncGate = SIGFPEfunc.GetInPort( 'Gate' ) + OSIGFPEfuncreturn = SIGFPEfunc.GetOutPort( 'return' ) + OSIGFPEfuncGate = SIGFPEfunc.GetOutPort( 'Gate' ) + + # Input datas + ISIGFPEfunca.Input( 1 ) + ISIGFPEfuncb.Input( 0 ) + + # Output Ports of the graph + #OSIGFPEfuncreturn = SIGFPEfunc.GetOutPort( 'return' ) + return GraphSIGFPE + + +GraphSIGFPE = DefGraphSIGFPE() diff --git a/examples/GraphSIGFPE.xml b/examples/GraphSIGFPE.xml new file mode 100644 index 0000000..0d4b961 --- /dev/null +++ b/examples/GraphSIGFPE.xml @@ -0,0 +1,83 @@ + + + + + +? + ? + GraphSIGFPE + 1 + ? + +GraphSIGFPE + + +long + SIGFPEfunc__a + +long + SIGFPEfunc__b + + +long + SIGFPEfunc__return + + + 8/12/2004 - 18:15:9 + 8/12/2004 - 18:15:36 + 2.0 + JR + ? + ? + 0 + 0 + + +SIGNALSComponent + SIGNALSComponent + SIGFPEfunc + 0 + ? + +SIGFPEfunc + + +long + a + +long + b + + +long + return + + + 8/12/2004 - 18:15:36 + 8/12/2004 - 18:15:36 + 2.0 + ? + localhost/FactoryServer + SIGFPEfunc from SIGNALSComponent + 134 + 137 + + + +GraphSIGFPE + SIGFPEfunc__a + SIGFPEfunc + a + +3 + 1 + + +GraphSIGFPE + SIGFPEfunc__b + SIGFPEfunc + b + +3 + 0 + diff --git a/examples/GraphSIGFPEPython.py b/examples/GraphSIGFPEPython.py new file mode 100644 index 0000000..30962c3 --- /dev/null +++ b/examples/GraphSIGFPEPython.py @@ -0,0 +1,35 @@ + +# Generated python file of Graph SIGFPEPython + +from SuperV import * + +# Graph creation of SIGFPEPython +def DefSIGFPEPython() : + SIGFPEPython = Graph( 'SIGFPEPython' ) + SIGFPEPython.SetName( 'SIGFPEPython' ) + SIGFPEPython.SetAuthor( 'JR' ) + SIGFPEPython.SetComment( '' ) + SIGFPEPython.Coords( 0 , 0 ) + + # Creation of Factory Nodes + + # Creation of InLine Nodes + PySIGFPEPython = [] + PySIGFPEPython.append( 'def SIGFPEPython() : ' ) + PySIGFPEPython.append( ' import libSIGNALSComponent_Swig ' ) + PySIGFPEPython.append( ' s = libSIGNALSComponent_Swig.SIGNALSComponentEngine() ' ) + PySIGFPEPython.append( ' s.SIGFPEfunc(1,0) ' ) + PySIGFPEPython.append( ' ' ) + SIGFPEPython = SIGFPEPython.INode( 'SIGFPEPython' , PySIGFPEPython ) + SIGFPEPython.SetName( 'SIGFPEPython' ) + SIGFPEPython.SetAuthor( '' ) + SIGFPEPython.SetComment( 'Compute Node' ) + SIGFPEPython.Coords( 118 , 159 ) + ISIGFPEPythonGate = SIGFPEPython.GetInPort( 'Gate' ) + OSIGFPEPythonGate = SIGFPEPython.GetOutPort( 'Gate' ) + + # Output Ports of the graph + return SIGFPEPython + + +SIGFPEPython = DefSIGFPEPython() diff --git a/examples/GraphSIGFPEPython.xml b/examples/GraphSIGFPEPython.xml new file mode 100644 index 0000000..4e53f67 --- /dev/null +++ b/examples/GraphSIGFPEPython.xml @@ -0,0 +1,54 @@ + + + + + +? + ? + SIGFPEPython + 1 + ? + +SIGFPEPython + + + + + 9/12/2004 - 18:7:31 + 10/12/2004 - 12:35:36 + 2.0 + JR + ? + ? + 0 + 0 + + +? + ? + SIGFPEPython + 3 + ? + +SIGFPEPython + + + + + +SIGFPEPython + + + + + + 10/12/2004 - 12:35:36 + 10/12/2004 - 12:35:36 + 2.0 + ? + ? + Compute Node + 118 + 159 + + diff --git a/examples/GraphSIGSEGV.py b/examples/GraphSIGSEGV.py new file mode 100644 index 0000000..8eb30d1 --- /dev/null +++ b/examples/GraphSIGSEGV.py @@ -0,0 +1,31 @@ + +# Generated python file of Graph GraphSIGSEGV + +from SuperV import * + +# Graph creation of GraphSIGSEGV +def DefGraphSIGSEGV() : + GraphSIGSEGV = Graph( 'GraphSIGSEGV' ) + GraphSIGSEGV.SetName( 'GraphSIGSEGV' ) + GraphSIGSEGV.SetAuthor( 'JR' ) + GraphSIGSEGV.SetComment( '' ) + GraphSIGSEGV.Coords( 0 , 0 ) + + # Creation of Factory Nodes + + SIGSEGVfunc = GraphSIGSEGV.FNode( 'SIGNALSComponent' , 'SIGNALSComponent' , 'SIGSEGVfunc' ) + SIGSEGVfunc.SetName( 'SIGSEGVfunc' ) + SIGSEGVfunc.SetAuthor( '' ) + SIGSEGVfunc.SetContainer( 'localhost/FactoryServer' ) + SIGSEGVfunc.SetComment( 'SIGSEGVfunc from SIGNALSComponent' ) + SIGSEGVfunc.Coords( 152 , 197 ) + ISIGSEGVfuncGate = SIGSEGVfunc.GetInPort( 'Gate' ) + OSIGSEGVfuncreturn = SIGSEGVfunc.GetOutPort( 'return' ) + OSIGSEGVfuncGate = SIGSEGVfunc.GetOutPort( 'Gate' ) + + # Output Ports of the graph + #OSIGSEGVfuncreturn = SIGSEGVfunc.GetOutPort( 'return' ) + return GraphSIGSEGV + + +GraphSIGSEGV = DefGraphSIGSEGV() diff --git a/examples/GraphSIGSEGV.xml b/examples/GraphSIGSEGV.xml new file mode 100644 index 0000000..e0562a6 --- /dev/null +++ b/examples/GraphSIGSEGV.xml @@ -0,0 +1,53 @@ + + + + + +? + ? + GraphSIGSEGV + 1 + ? + +GraphSIGSEGV + + + +long + SIGSEGVfunc__return + + + 8/12/2004 - 18:9:47 + 8/12/2004 - 18:13:40 + 2.0 + JR + ? + ? + 0 + 0 + + +SIGNALSComponent + SIGNALSComponent + SIGSEGVfunc + 0 + ? + +SIGSEGVfunc + + + +long + return + + + 8/12/2004 - 18:10:12 + 8/12/2004 - 18:10:12 + 2.0 + ? + localhost/FactoryServer + SIGSEGVfunc from SIGNALSComponent + 152 + 197 + + diff --git a/examples/GraphSIGSEGVPython.py b/examples/GraphSIGSEGVPython.py new file mode 100644 index 0000000..e78f8e0 --- /dev/null +++ b/examples/GraphSIGSEGVPython.py @@ -0,0 +1,35 @@ + +# Generated python file of Graph GraphSIGSEGVPython + +from SuperV import * + +# Graph creation of GraphSIGSEGVPython +def DefGraphSIGSEGVPython() : + GraphSIGSEGVPython = Graph( 'GraphSIGSEGVPython' ) + GraphSIGSEGVPython.SetName( 'GraphSIGSEGVPython' ) + GraphSIGSEGVPython.SetAuthor( 'JR' ) + GraphSIGSEGVPython.SetComment( '' ) + GraphSIGSEGVPython.Coords( 0 , 0 ) + + # Creation of Factory Nodes + + # Creation of InLine Nodes + PySIGSEGVPython = [] + PySIGSEGVPython.append( 'def SIGSEGVPython() : ' ) + PySIGSEGVPython.append( ' import libSIGNALSComponent_Swig ' ) + PySIGSEGVPython.append( ' s = libSIGNALSComponent_Swig.SIGNALSComponentEngine() ' ) + PySIGSEGVPython.append( ' s.SIGSEGVfunc() ' ) + PySIGSEGVPython.append( ' ' ) + SIGSEGVPython = GraphSIGSEGVPython.INode( 'SIGSEGVPython' , PySIGSEGVPython ) + SIGSEGVPython.SetName( 'SIGSEGVPython' ) + SIGSEGVPython.SetAuthor( '' ) + SIGSEGVPython.SetComment( 'Compute Node' ) + SIGSEGVPython.Coords( 105 , 143 ) + ISIGSEGVPythonGate = SIGSEGVPython.GetInPort( 'Gate' ) + OSIGSEGVPythonGate = SIGSEGVPython.GetOutPort( 'Gate' ) + + # Output Ports of the graph + return GraphSIGSEGVPython + + +GraphSIGSEGVPython = DefGraphSIGSEGVPython() diff --git a/examples/GraphSIGSEGVPython.xml b/examples/GraphSIGSEGVPython.xml new file mode 100644 index 0000000..7f8e74f --- /dev/null +++ b/examples/GraphSIGSEGVPython.xml @@ -0,0 +1,54 @@ + + + + + +? + ? + GraphSIGSEGVPython + 1 + ? + +GraphSIGSEGVPython + + + + + 9/12/2004 - 18:13:21 + 10/12/2004 - 12:39:15 + 2.0 + JR + ? + ? + 0 + 0 + + +? + ? + SIGSEGVPython + 3 + ? + +SIGSEGVPython + + + + + +SIGSEGVPython + + + + + + 10/12/2004 - 12:39:15 + 10/12/2004 - 12:39:15 + 2.0 + ? + ? + Compute Node + 105 + 143 + + diff --git a/examples/GraphStreamInLines.py b/examples/GraphStreamInLines.py index b46483a..0f88773 100644 --- a/examples/GraphStreamInLines.py +++ b/examples/GraphStreamInLines.py @@ -54,7 +54,7 @@ PyEndOfInitLoop.append( ' else : ' ) PyEndOfInitLoop.append( ' DoLoop = 0 ' ) PyEndOfInitLoop.append( ' return DoLoop,Index,Min,Max ' ) EndOfInitLoop.SetPyFunction( 'EndOfInitLoop' , PyEndOfInitLoop ) -IInitLoopInitLoop = InitLoop.GetInPort( 'InitLoop' ) +IInitLoopInitLoop = InitLoop.GetInPort( 'DoLoop' ) IInitLoopIndex = InitLoop.InPort( 'Index' , 'long' ) IInitLoopMin = InitLoop.InPort( 'Min' , 'long' ) IInitLoopMax = InitLoop.InPort( 'Max' , 'long' ) diff --git a/examples/GraphStreamInLines.xml b/examples/GraphStreamInLines.xml index d450676..0af8182 100644 --- a/examples/GraphStreamInLines.xml +++ b/examples/GraphStreamInLines.xml @@ -380,7 +380,7 @@ EndOfInitLoop DoLoop InitLoop - InitLoop + DoLoop Switch diff --git a/examples/GraphStreams.py b/examples/GraphStreams.py index c9a9601..77cfeaf 100644 --- a/examples/GraphStreams.py +++ b/examples/GraphStreams.py @@ -164,7 +164,7 @@ EndLoop.SetComment( '' ) EndLoop.Coords( 1158 , 393 ) PyEndLoop = [] EndLoop.SetPyFunction( 'EndInit' , PyEndLoop ) -ILoopInitLoop = Loop.GetInPort( 'InitLoop' ) +ILoopInitLoop = Loop.GetInPort( 'DoLoop' ) ILoopIndex = Loop.InPort( 'Index' , 'long' ) ILoopMin = Loop.InPort( 'Min' , 'long' ) ILoopMax = Loop.InPort( 'Max' , 'long' ) diff --git a/examples/GraphStreams.xml b/examples/GraphStreams.xml index c374a34..796ffaf 100644 --- a/examples/GraphStreams.xml +++ b/examples/GraphStreams.xml @@ -896,7 +896,7 @@ EndLoop DoLoop Loop - InitLoop + DoLoop diff --git a/examples/GraphSwitch.xml b/examples/GraphSwitch.xml index 5267cfc..f25242c 100644 --- a/examples/GraphSwitch.xml +++ b/examples/GraphSwitch.xml @@ -277,7 +277,7 @@ EndOfInitLoopSwitch DoLoop InitLoopSwitch - InitLoop + DoLoop Switch diff --git a/examples/GraphSwitch1.xml b/examples/GraphSwitch1.xml index ad2f10e..bff16b1 100755 --- a/examples/GraphSwitch1.xml +++ b/examples/GraphSwitch1.xml @@ -274,7 +274,7 @@ EndOfInitLoop DoLoop InitLoop - InitLoop + DoLoop Switch diff --git a/examples/GraphSwitch2.py b/examples/GraphSwitch2.py new file mode 100644 index 0000000..3bdae8d --- /dev/null +++ b/examples/GraphSwitch2.py @@ -0,0 +1,162 @@ + +# Generated python file of Graph GraphSwitch_1_1 + +from SuperV import * + +# Graph creation of GraphSwitch_1_1 +def DefGraphSwitch_1_1() : + GraphSwitch_1_1 = Graph( 'GraphSwitch_1_1' ) + GraphSwitch_1_1.SetName( 'GraphSwitch_1_1' ) + GraphSwitch_1_1.SetAuthor( '' ) + GraphSwitch_1_1.SetComment( '' ) + GraphSwitch_1_1.Coords( 0 , 0 ) + + # Creation of Factory Nodes + + # Creation of InLine Nodes + PyIsOdd = [] + PyIsOdd.append( 'from time import * ' ) + PyIsOdd.append( 'def IsOdd(a) : ' ) + PyIsOdd.append( ' print a,"IsOdd (GraphSwitch)" ' ) + PyIsOdd.append( ' sleep( 1 ) ' ) + PyIsOdd.append( ' return a ' ) + IsOdd = GraphSwitch_1_1.INode( 'IsOdd' , PyIsOdd ) + IsOdd.SetName( 'IsOdd' ) + IsOdd.SetAuthor( '' ) + IsOdd.SetComment( 'Python function' ) + IsOdd.Coords( 388 , 50 ) + IIsOdda = IsOdd.InPort( 'a' , 'long' ) + IIsOddGate = IsOdd.GetInPort( 'Gate' ) + OIsOdda = IsOdd.OutPort( 'a' , 'long' ) + OIsOddGate = IsOdd.GetOutPort( 'Gate' ) + + PyIsEven = [] + PyIsEven.append( 'from time import * ' ) + PyIsEven.append( 'def IsEven(a) : ' ) + PyIsEven.append( ' print a,"IsEven (GraphSwitch)" ' ) + PyIsEven.append( ' sleep( 1 ) ' ) + PyIsEven.append( ' return a ' ) + IsEven = GraphSwitch_1_1.INode( 'IsEven' , PyIsEven ) + IsEven.SetName( 'IsEven' ) + IsEven.SetAuthor( '' ) + IsEven.SetComment( 'Compute Node' ) + IsEven.Coords( 397 , 279 ) + IIsEvena = IsEven.InPort( 'a' , 'long' ) + IIsEvenGate = IsEven.GetInPort( 'Gate' ) + OIsEvena = IsEven.OutPort( 'a' , 'long' ) + OIsEvenGate = IsEven.GetOutPort( 'Gate' ) + + # Creation of Loop Nodes + PyInitLoopSwitch = [] + PyInitLoopSwitch.append( 'def InitLoop(Index,Min,Max) : ' ) + PyInitLoopSwitch.append( ' Index = Max ' ) + PyInitLoopSwitch.append( ' return Index,Min,Max ' ) + PyMoreInitLoopSwitch = [] + PyMoreInitLoopSwitch.append( 'def MoreLoop(Index,Min,Max) : ' ) + PyMoreInitLoopSwitch.append( ' if Index >= Min : ' ) + PyMoreInitLoopSwitch.append( ' DoLoop = 1 ' ) + PyMoreInitLoopSwitch.append( ' else : ' ) + PyMoreInitLoopSwitch.append( ' DoLoop = 0 ' ) + PyMoreInitLoopSwitch.append( ' return DoLoop,Index,Min,Max ' ) + PyNextInitLoopSwitch = [] + PyNextInitLoopSwitch.append( 'def NextLoop(Index,Min,Max) : ' ) + PyNextInitLoopSwitch.append( ' Index = Index - 1 ' ) + PyNextInitLoopSwitch.append( ' return Index,Min,Max ' ) + InitLoopSwitch,EndOfInitLoopSwitch = GraphSwitch_1_1.LNode( 'InitLoop' , PyInitLoopSwitch , 'MoreLoop' , PyMoreInitLoopSwitch , 'NextLoop' , PyNextInitLoopSwitch ) + EndOfInitLoopSwitch.SetName( 'EndOfInitLoopSwitch' ) + EndOfInitLoopSwitch.SetAuthor( '' ) + EndOfInitLoopSwitch.SetComment( 'Compute Node' ) + EndOfInitLoopSwitch.Coords( 766 , 127 ) + PyEndOfInitLoopSwitch = [] + EndOfInitLoopSwitch.SetPyFunction( '' , PyEndOfInitLoopSwitch ) + IInitLoopSwitchDoLoop = InitLoopSwitch.GetInPort( 'DoLoop' ) + IInitLoopSwitchIndex = InitLoopSwitch.InPort( 'Index' , 'long' ) + IInitLoopSwitchMin = InitLoopSwitch.InPort( 'Min' , 'long' ) + IInitLoopSwitchMax = InitLoopSwitch.InPort( 'Max' , 'long' ) + IInitLoopSwitchGate = InitLoopSwitch.GetInPort( 'Gate' ) + OInitLoopSwitchDoLoop = InitLoopSwitch.GetOutPort( 'DoLoop' ) + OInitLoopSwitchIndex = InitLoopSwitch.GetOutPort( 'Index' ) + OInitLoopSwitchMin = InitLoopSwitch.GetOutPort( 'Min' ) + OInitLoopSwitchMax = InitLoopSwitch.GetOutPort( 'Max' ) + IEndOfInitLoopSwitchDoLoop = EndOfInitLoopSwitch.GetInPort( 'DoLoop' ) + IEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetInPort( 'Index' ) + IEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetInPort( 'Min' ) + IEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetInPort( 'Max' ) + IEndOfInitLoopSwitchGate = EndOfInitLoopSwitch.GetInPort( 'Gate' ) + OEndOfInitLoopSwitchDoLoop = EndOfInitLoopSwitch.GetOutPort( 'DoLoop' ) + OEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetOutPort( 'Index' ) + OEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetOutPort( 'Min' ) + OEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetOutPort( 'Max' ) + OEndOfInitLoopSwitchGate = EndOfInitLoopSwitch.GetOutPort( 'Gate' ) + InitLoopSwitch.SetName( 'InitLoopSwitch' ) + InitLoopSwitch.SetAuthor( '' ) + InitLoopSwitch.SetComment( 'Compute Node' ) + InitLoopSwitch.Coords( 10 , 129 ) + + # Creation of Switch Nodes + PySwitch = [] + PySwitch.append( 'from time import * ' ) + PySwitch.append( 'def Switch(a) : ' ) + PySwitch.append( ' if a <= 0 : ' ) + PySwitch.append( ' return 0,0,a ' ) + PySwitch.append( ' if ( a & 1 ) == 0 : ' ) + PySwitch.append( ' sleep(1) ' ) + PySwitch.append( ' return a & 1,1-(a&1),a ' ) + Switch,EndOfSwitch = GraphSwitch_1_1.SNode( 'Switch' , PySwitch ) + EndOfSwitch.SetName( 'EndOfSwitch' ) + EndOfSwitch.SetAuthor( '' ) + EndOfSwitch.SetComment( 'Compute Node' ) + EndOfSwitch.Coords( 580 , 147 ) + PyEndOfSwitch = [] + EndOfSwitch.SetPyFunction( 'EndSwitch_1' , PyEndOfSwitch ) + IEndOfSwitcha = EndOfSwitch.InPort( 'a' , 'long' ) + IEndOfSwitchDefault = EndOfSwitch.GetInPort( 'Default' ) + OEndOfSwitcha = EndOfSwitch.OutPort( 'a' , 'long' ) + OEndOfSwitchGate = EndOfSwitch.GetOutPort( 'Gate' ) + Switch.SetName( 'Switch' ) + Switch.SetAuthor( '' ) + Switch.SetComment( 'Compute Node' ) + Switch.Coords( 195 , 129 ) + ISwitcha = Switch.InPort( 'a' , 'long' ) + ISwitchGate = Switch.GetInPort( 'Gate' ) + OSwitchOdd = Switch.OutPort( 'Odd' , 'long' ) + OSwitchEven = Switch.OutPort( 'Even' , 'int' ) + OSwitcha = Switch.OutPort( 'a' , 'int' ) + OSwitchDefault = Switch.GetOutPort( 'Default' ) + + # Creation of Links + LIsOddaEndOfSwitcha = GraphSwitch_1_1.Link( OIsOdda , IEndOfSwitcha ) + + LInitLoopSwitchIndexSwitcha = GraphSwitch_1_1.Link( OInitLoopSwitchIndex , ISwitcha ) + + LInitLoopSwitchMinEndOfInitLoopSwitchMin = GraphSwitch_1_1.Link( OInitLoopSwitchMin , IEndOfInitLoopSwitchMin ) + + LInitLoopSwitchMaxEndOfInitLoopSwitchMax = GraphSwitch_1_1.Link( OInitLoopSwitchMax , IEndOfInitLoopSwitchMax ) + + LIsEvenaEndOfSwitcha = GraphSwitch_1_1.Link( OIsEvena , IEndOfSwitcha ) + + LSwitchOddIsOddGate = GraphSwitch_1_1.Link( OSwitchOdd , IIsOddGate ) + + LSwitchEvenIsEvenGate = GraphSwitch_1_1.Link( OSwitchEven , IIsEvenGate ) + + LSwitchaIsOdda = GraphSwitch_1_1.Link( OSwitcha , IIsOdda ) + + LSwitchaIsEvena = GraphSwitch_1_1.Link( OSwitcha , IIsEvena ) + + LSwitchDefaultEndOfSwitchDefault = GraphSwitch_1_1.Link( OSwitchDefault , IEndOfSwitchDefault ) + + LEndOfSwitchaEndOfInitLoopSwitchIndex = GraphSwitch_1_1.Link( OEndOfSwitcha , IEndOfInitLoopSwitchIndex ) + + # Input datas + IInitLoopSwitchIndex.Input( 0 ) + IInitLoopSwitchMin.Input( -5 ) + IInitLoopSwitchMax.Input( 10 ) + + # Output Ports of the graph + #OEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetOutPort( 'Index' ) + #OEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetOutPort( 'Min' ) + #OEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetOutPort( 'Max' ) + return GraphSwitch_1_1 + + +GraphSwitch_1_1 = DefGraphSwitch_1_1() diff --git a/examples/GraphSwitch2.xml b/examples/GraphSwitch2.xml new file mode 100644 index 0000000..98d34c1 --- /dev/null +++ b/examples/GraphSwitch2.xml @@ -0,0 +1,383 @@ + + + + + +? + ? + GraphSwitch_1_1 + 1 + ? + +GraphSwitch_1_1 + + +long + InitLoopSwitch__Index + +long + InitLoopSwitch__Min + +long + InitLoopSwitch__Max + + +long + EndOfInitLoopSwitch__Index + +long + EndOfInitLoopSwitch__Min + +long + EndOfInitLoopSwitch__Max + + + 1/10/2003 - 17:23:54 + 12/1/2005 - 17:7:20 + 1.05 + ? + ? + ? + 0 + 0 + + +? + ? + IsOdd + 3 + ? + +IsOdd + + +long + a + + +long + a + + + +IsOdd + + + + + + 12/1/2005 - 17:7:20 + 12/1/2005 - 17:7:20 + 1.05 + ? + ? + Python function + 388 + 50 + +? + ? + InitLoopSwitch + 4 + EndOfInitLoopSwitch + +InitLoopSwitch + + +long + Index + +long + Min + +long + Max + + +long + Index + +long + Min + +long + Max + + + +InitLoop + + + + +MoreLoop + + = Min : ]]> + + + + + +NextLoop + + + + 12/1/2005 - 17:7:20 + 12/1/2005 - 17:7:20 + 1.05 + ? + ? + Compute Node + 10 + 129 + +? + ? + EndOfInitLoopSwitch + 5 + InitLoopSwitch + +EndOfInitLoopSwitch + + +long + Index + +long + Min + +long + Max + + +long + Index + +long + Min + +long + Max + + + +? + + 12/1/2005 - 17:7:20 + 12/1/2005 - 17:7:20 + 1.05 + ? + ? + Compute Node + 766 + 127 + +? + ? + IsEven + 3 + ? + +IsEven + + +long + a + + +long + a + + + +IsEven + + + + + + 12/1/2005 - 17:7:20 + 12/1/2005 - 17:7:20 + 2.0 + ? + ? + Compute Node + 397 + 279 + +? + ? + Switch + 6 + EndOfSwitch + +Switch + + +long + a + + +long + Odd + +int + Even + +int + a + + + +Switch + + + + + + + + 12/1/2005 - 17:7:20 + 12/1/2005 - 17:7:20 + 2.0 + ? + ? + Compute Node + 195 + 129 + +? + ? + EndOfSwitch + 7 + Switch + +EndOfSwitch + + +long + a + + +long + a + + + +EndSwitch_1 + + 12/1/2005 - 17:7:20 + 12/1/2005 - 17:7:20 + 2.0 + ? + ? + Compute Node + 580 + 147 + + +IsOdd + a + EndOfSwitch + a + + +InitLoopSwitch + DoLoop + EndOfInitLoopSwitch + DoLoop + + +InitLoopSwitch + Index + Switch + a + + +InitLoopSwitch + Min + EndOfInitLoopSwitch + Min + + +InitLoopSwitch + Max + EndOfInitLoopSwitch + Max + + +EndOfInitLoopSwitch + DoLoop + InitLoopSwitch + DoLoop + + +IsEven + a + EndOfSwitch + a + + +Switch + Odd + IsOdd + Gate + + +Switch + Even + IsEven + Gate + + +Switch + a + IsOdd + a + + +Switch + a + IsEven + a + + +Switch + Default + EndOfSwitch + Default + + +EndOfSwitch + a + EndOfInitLoopSwitch + Index + + + +GraphSwitch_1_1 + InitLoopSwitch__Index + InitLoopSwitch + Index + +3 + 0 + + +GraphSwitch_1_1 + InitLoopSwitch__Min + InitLoopSwitch + Min + +3 + -5 + + +GraphSwitch_1_1 + InitLoopSwitch__Max + InitLoopSwitch + Max + +3 + 10 + diff --git a/examples/GraphSwitchCheck.py b/examples/GraphSwitchCheck.py new file mode 100644 index 0000000..c060357 --- /dev/null +++ b/examples/GraphSwitchCheck.py @@ -0,0 +1,268 @@ + +# Generated python file of Graph GraphSwitchCheck + +from SuperV import * + +# Graph creation of GraphSwitchCheck +def DefGraphSwitchCheck() : + GraphSwitchCheck = Graph( 'GraphSwitchCheck' ) + GraphSwitchCheck.SetName( 'GraphSwitchCheck' ) + GraphSwitchCheck.SetAuthor( 'JR' ) + GraphSwitchCheck.SetComment( '' ) + GraphSwitchCheck.Coords( 0 , 0 ) + + # Creation of Factory Nodes + + # Creation of InLine Nodes + PyIsOdd = [] + PyIsOdd.append( 'from time import * ' ) + PyIsOdd.append( 'def IsOdd(a) : ' ) + PyIsOdd.append( ' print a,"IsOdd (GraphSwitch)" ' ) + PyIsOdd.append( ' sleep( 1 ) ' ) + PyIsOdd.append( ' return a ' ) + IsOdd = GraphSwitchCheck.INode( 'IsOdd' , PyIsOdd ) + IsOdd.SetName( 'IsOdd' ) + IsOdd.SetAuthor( '' ) + IsOdd.SetComment( 'Python function' ) + IsOdd.Coords( 415 , 7 ) + IIsOdda = IsOdd.InPort( 'a' , 'long' ) + IIsOddGate = IsOdd.GetInPort( 'Gate' ) + OIsOdda = IsOdd.OutPort( 'a' , 'long' ) + OIsOddGate = IsOdd.GetOutPort( 'Gate' ) + + PyIsEven = [] + PyIsEven.append( 'from time import * ' ) + PyIsEven.append( 'def IsEven(a) : ' ) + PyIsEven.append( ' print a,"IsEven (GraphSwitch)" ' ) + PyIsEven.append( ' sleep( 1 ) ' ) + PyIsEven.append( ' return a ' ) + IsEven = GraphSwitchCheck.INode( 'IsEven' , PyIsEven ) + IsEven.SetName( 'IsEven' ) + IsEven.SetAuthor( '' ) + IsEven.SetComment( 'Compute Node' ) + IsEven.Coords( 421 , 438 ) + IIsEvena = IsEven.InPort( 'a' , 'long' ) + IIsEvenGate = IsEven.GetInPort( 'Gate' ) + OIsEvena = IsEven.OutPort( 'a' , 'long' ) + OIsEvenGate = IsEven.GetOutPort( 'Gate' ) + + PyPrintOdd = [] + PyPrintOdd.append( 'from time import * ' ) + PyPrintOdd.append( 'def Print(a,Branch) : ' ) + PyPrintOdd.append( ' print "Print ",a,Branch ' ) + PyPrintOdd.append( ' sleep(1) ' ) + PyPrintOdd.append( ' return Branch ' ) + PrintOdd = GraphSwitchCheck.INode( 'Print' , PyPrintOdd ) + PrintOdd.SetName( 'PrintOdd' ) + PrintOdd.SetAuthor( '' ) + PrintOdd.SetComment( 'Compute Node' ) + PrintOdd.Coords( 415 , 130 ) + IPrintOdda = PrintOdd.InPort( 'a' , 'long' ) + IPrintOddBranch = PrintOdd.InPort( 'Branch' , 'string' ) + IPrintOddGate = PrintOdd.GetInPort( 'Gate' ) + OPrintOddBranch = PrintOdd.OutPort( 'Branch' , 'string' ) + OPrintOddGate = PrintOdd.GetOutPort( 'Gate' ) + + PyPrintEven = [] + PyPrintEven.append( 'from time import * ' ) + PyPrintEven.append( 'def Print_1(a,Branch) : ' ) + PyPrintEven.append( ' print "Print ",a,Branch ' ) + PyPrintEven.append( ' sleep(1) ' ) + PyPrintEven.append( ' return Branch ' ) + PrintEven = GraphSwitchCheck.INode( 'Print_1' , PyPrintEven ) + PrintEven.SetName( 'PrintEven' ) + PrintEven.SetAuthor( '' ) + PrintEven.SetComment( 'Compute Node' ) + PrintEven.Coords( 423 , 289 ) + IPrintEvena = PrintEven.InPort( 'a' , 'long' ) + IPrintEvenBranch = PrintEven.InPort( 'Branch' , 'string' ) + IPrintEvenGate = PrintEven.GetInPort( 'Gate' ) + OPrintEvenBranch = PrintEven.OutPort( 'Branch' , 'string' ) + OPrintEvenGate = PrintEven.GetOutPort( 'Gate' ) + + PyEmptyNode = [] + PyEmptyNode.append( 'from time import * ' ) + PyEmptyNode.append( 'def EmptyNode(a,Branch) : ' ) + PyEmptyNode.append( ' sleep(1) ' ) + PyEmptyNode.append( ' return a,Branch ' ) + EmptyNode = GraphSwitchCheck.INode( 'EmptyNode' , PyEmptyNode ) + EmptyNode.SetName( 'EmptyNode' ) + EmptyNode.SetAuthor( '' ) + EmptyNode.SetComment( 'Compute Node' ) + EmptyNode.Coords( 652 , 110 ) + IEmptyNodea = EmptyNode.InPort( 'a' , 'long' ) + IEmptyNodeBranch = EmptyNode.InPort( 'Branch' , 'string' ) + IEmptyNodeGate = EmptyNode.GetInPort( 'Gate' ) + OEmptyNodea = EmptyNode.OutPort( 'a' , 'long' ) + OEmptyNodeBranch = EmptyNode.OutPort( 'Branch' , 'string' ) + OEmptyNodeGate = EmptyNode.GetOutPort( 'Gate' ) + + # Creation of Loop Nodes + PyInitLoopSwitch = [] + PyInitLoopSwitch.append( 'def InitLoop(Index,Min,Max) : ' ) + PyInitLoopSwitch.append( ' Index = Max ' ) + PyInitLoopSwitch.append( ' return Index,Min,Max ' ) + PyMoreInitLoopSwitch = [] + PyMoreInitLoopSwitch.append( 'from time import * ' ) + PyMoreInitLoopSwitch.append( 'def MoreLoop(Index,Min,Max) : ' ) + PyMoreInitLoopSwitch.append( ' sleep(1) ' ) + PyMoreInitLoopSwitch.append( ' if Index >= Min : ' ) + PyMoreInitLoopSwitch.append( ' DoLoop = 1 ' ) + PyMoreInitLoopSwitch.append( ' else : ' ) + PyMoreInitLoopSwitch.append( ' DoLoop = 0 ' ) + PyMoreInitLoopSwitch.append( ' return DoLoop,Index,Min,Max ' ) + PyNextInitLoopSwitch = [] + PyNextInitLoopSwitch.append( 'def NextLoop(Index,Min,Max) : ' ) + PyNextInitLoopSwitch.append( ' Index = Index - 1 ' ) + PyNextInitLoopSwitch.append( ' return Index,Min,Max ' ) + InitLoopSwitch,EndOfInitLoopSwitch = GraphSwitchCheck.LNode( 'InitLoop' , PyInitLoopSwitch , 'MoreLoop' , PyMoreInitLoopSwitch , 'NextLoop' , PyNextInitLoopSwitch ) + EndOfInitLoopSwitch.SetName( 'EndOfInitLoopSwitch' ) + EndOfInitLoopSwitch.SetAuthor( '' ) + EndOfInitLoopSwitch.SetComment( 'Compute Node' ) + EndOfInitLoopSwitch.Coords( 1074 , 194 ) + PyEndOfInitLoopSwitch = [] + PyEndOfInitLoopSwitch.append( 'from time import * ' ) + PyEndOfInitLoopSwitch.append( 'def EndOfInitLoopSwitch(DoLoop,Index,Min,Max) : ' ) + PyEndOfInitLoopSwitch.append( ' sleep(1) ' ) + PyEndOfInitLoopSwitch.append( ' return DoLoop,Index,Min,Max ' ) + EndOfInitLoopSwitch.SetPyFunction( 'EndOfInitLoopSwitch' , PyEndOfInitLoopSwitch ) + IInitLoopSwitchDoLoop = InitLoopSwitch.GetInPort( 'DoLoop' ) + IInitLoopSwitchIndex = InitLoopSwitch.InPort( 'Index' , 'long' ) + IInitLoopSwitchMin = InitLoopSwitch.InPort( 'Min' , 'long' ) + IInitLoopSwitchMax = InitLoopSwitch.InPort( 'Max' , 'long' ) + IInitLoopSwitchGate = InitLoopSwitch.GetInPort( 'Gate' ) + OInitLoopSwitchDoLoop = InitLoopSwitch.GetOutPort( 'DoLoop' ) + OInitLoopSwitchIndex = InitLoopSwitch.GetOutPort( 'Index' ) + OInitLoopSwitchMin = InitLoopSwitch.GetOutPort( 'Min' ) + OInitLoopSwitchMax = InitLoopSwitch.GetOutPort( 'Max' ) + IEndOfInitLoopSwitchDoLoop = EndOfInitLoopSwitch.GetInPort( 'DoLoop' ) + IEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetInPort( 'Index' ) + IEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetInPort( 'Min' ) + IEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetInPort( 'Max' ) + IEndOfInitLoopSwitchGate = EndOfInitLoopSwitch.GetInPort( 'Gate' ) + OEndOfInitLoopSwitchDoLoop = EndOfInitLoopSwitch.GetOutPort( 'DoLoop' ) + OEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetOutPort( 'Index' ) + OEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetOutPort( 'Min' ) + OEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetOutPort( 'Max' ) + OEndOfInitLoopSwitchGate = EndOfInitLoopSwitch.GetOutPort( 'Gate' ) + InitLoopSwitch.SetName( 'InitLoopSwitch' ) + InitLoopSwitch.SetAuthor( '' ) + InitLoopSwitch.SetComment( 'Compute Node' ) + InitLoopSwitch.Coords( 10 , 129 ) + + # Creation of Switch Nodes + PySwitch = [] + PySwitch.append( 'from time import * ' ) + PySwitch.append( 'def Switch(a) : ' ) + PySwitch.append( ' sleep(1) ' ) + PySwitch.append( ' Branch = "Negative or null" ' ) + PySwitch.append( ' if a <= 0 : ' ) + PySwitch.append( ' return 0,0,a,Branch,1 ' ) + PySwitch.append( ' if ( a & 1 ) == 0 : ' ) + PySwitch.append( ' Branch = "Even" ' ) + PySwitch.append( ' else : ' ) + PySwitch.append( ' Branch = "Odd" ' ) + PySwitch.append( ' return a & 1,1-(a&1),a,Branch,0 ' ) + Switch,EndOfSwitch = GraphSwitchCheck.SNode( 'Switch' , PySwitch ) + EndOfSwitch.SetName( 'EndOfSwitch' ) + EndOfSwitch.SetAuthor( '' ) + EndOfSwitch.SetComment( 'Compute Node' ) + EndOfSwitch.Coords( 882 , 194 ) + PyEndOfSwitch = [] + PyEndOfSwitch.append( 'from time import * ' ) + PyEndOfSwitch.append( 'def EndOfSwitch(a,Branch) : ' ) + PyEndOfSwitch.append( ' sleep(1) ' ) + PyEndOfSwitch.append( ' return a ' ) + EndOfSwitch.SetPyFunction( 'EndOfSwitch' , PyEndOfSwitch ) + IEndOfSwitcha = EndOfSwitch.InPort( 'a' , 'long' ) + IEndOfSwitchBranch = EndOfSwitch.InPort( 'Branch' , 'string' ) + IEndOfSwitchDefault = EndOfSwitch.GetInPort( 'Default' ) + OEndOfSwitcha = EndOfSwitch.OutPort( 'a' , 'long' ) + OEndOfSwitchGate = EndOfSwitch.GetOutPort( 'Gate' ) + Switch.SetName( 'Switch' ) + Switch.SetAuthor( '' ) + Switch.SetComment( 'Compute Node' ) + Switch.Coords( 195 , 129 ) + ISwitcha = Switch.InPort( 'a' , 'long' ) + ISwitchGate = Switch.GetInPort( 'Gate' ) + OSwitchOdd = Switch.OutPort( 'Odd' , 'long' ) + OSwitchEven = Switch.OutPort( 'Even' , 'int' ) + OSwitcha = Switch.OutPort( 'a' , 'int' ) + OSwitchBranch = Switch.OutPort( 'Branch' , 'string' ) + OSwitchdefault = Switch.OutPort( 'default' , 'boolean' ) + OSwitchDefault = Switch.GetOutPort( 'Default' ) + + # Creation of Links + LIsOddaEmptyNodea = GraphSwitchCheck.Link( OIsOdda , IEmptyNodea ) + LIsOddaEmptyNodea.AddCoord( 1 , 646 , 78 ) + + LIsEvenaEndOfSwitcha = GraphSwitchCheck.Link( OIsEvena , IEndOfSwitcha ) + + LPrintOddBranchEmptyNodeBranch = GraphSwitchCheck.Link( OPrintOddBranch , IEmptyNodeBranch ) + + LPrintEvenBranchEndOfSwitchBranch = GraphSwitchCheck.Link( OPrintEvenBranch , IEndOfSwitchBranch ) + + LEmptyNodeaEndOfSwitcha = GraphSwitchCheck.Link( OEmptyNodea , IEndOfSwitcha ) + + LEmptyNodeBranchEndOfSwitchBranch = GraphSwitchCheck.Link( OEmptyNodeBranch , IEndOfSwitchBranch ) + + LInitLoopSwitchIndexSwitcha = GraphSwitchCheck.Link( OInitLoopSwitchIndex , ISwitcha ) + + LInitLoopSwitchMinEndOfInitLoopSwitchMin = GraphSwitchCheck.Link( OInitLoopSwitchMin , IEndOfInitLoopSwitchMin ) + + LInitLoopSwitchMaxEndOfInitLoopSwitchMax = GraphSwitchCheck.Link( OInitLoopSwitchMax , IEndOfInitLoopSwitchMax ) + + LSwitchOddIsOddGate = GraphSwitchCheck.Link( OSwitchOdd , IIsOddGate ) + LSwitchOddIsOddGate.AddCoord( 1 , 401 , 101 ) + LSwitchOddIsOddGate.AddCoord( 2 , 401 , 160 ) + + LSwitchOddPrintOddGate = GraphSwitchCheck.Link( OSwitchOdd , IPrintOddGate ) + LSwitchOddPrintOddGate.AddCoord( 1 , 401 , 245 ) + LSwitchOddPrintOddGate.AddCoord( 2 , 401 , 159 ) + + LSwitchEvenIsEvenGate = GraphSwitchCheck.Link( OSwitchEven , IIsEvenGate ) + LSwitchEvenIsEvenGate.AddCoord( 1 , 392 , 533 ) + LSwitchEvenIsEvenGate.AddCoord( 2 , 392 , 182 ) + + LSwitchEvenPrintEvenGate = GraphSwitchCheck.Link( OSwitchEven , IPrintEvenGate ) + LSwitchEvenPrintEvenGate.AddCoord( 1 , 392 , 403 ) + LSwitchEvenPrintEvenGate.AddCoord( 2 , 392 , 181 ) + + LSwitchaIsOdda = GraphSwitchCheck.Link( OSwitcha , IIsOdda ) + LSwitchaIsOdda.AddCoord( 1 , 382 , 78 ) + LSwitchaIsOdda.AddCoord( 2 , 382 , 199 ) + + LSwitchaIsEvena = GraphSwitchCheck.Link( OSwitcha , IIsEvena ) + LSwitchaIsEvena.AddCoord( 1 , 381 , 509 ) + LSwitchaIsEvena.AddCoord( 2 , 382 , 200 ) + + LSwitchaPrintOdda = GraphSwitchCheck.Link( OSwitcha , IPrintOdda ) + + LSwitchaPrintEvena = GraphSwitchCheck.Link( OSwitcha , IPrintEvena ) + LSwitchaPrintEvena.AddCoord( 1 , 381 , 361 ) + LSwitchaPrintEvena.AddCoord( 2 , 382 , 200 ) + + LSwitchBranchPrintOddBranch = GraphSwitchCheck.Link( OSwitchBranch , IPrintOddBranch ) + + LSwitchBranchPrintEvenBranch = GraphSwitchCheck.Link( OSwitchBranch , IPrintEvenBranch ) + LSwitchBranchPrintEvenBranch.AddCoord( 1 , 369 , 381 ) + LSwitchBranchPrintEvenBranch.AddCoord( 2 , 369 , 219 ) + + LSwitchDefaultEndOfSwitchDefault = GraphSwitchCheck.Link( OSwitchDefault , IEndOfSwitchDefault ) + + LEndOfSwitchaEndOfInitLoopSwitchIndex = GraphSwitchCheck.Link( OEndOfSwitcha , IEndOfInitLoopSwitchIndex ) + + # Input datas + IInitLoopSwitchIndex.Input( 0 ) + IInitLoopSwitchMin.Input( -5 ) + IInitLoopSwitchMax.Input( 10 ) + + # Output Ports of the graph + #OEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetOutPort( 'Index' ) + #OEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetOutPort( 'Min' ) + #OEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetOutPort( 'Max' ) + #OSwitchdefault = Switch.GetOutPort( 'default' ) + return GraphSwitchCheck + + +GraphSwitchCheck = DefGraphSwitchCheck() diff --git a/examples/GraphSwitchCheck.xml b/examples/GraphSwitchCheck.xml new file mode 100644 index 0000000..4587b78 --- /dev/null +++ b/examples/GraphSwitchCheck.xml @@ -0,0 +1,628 @@ + + + + + +? + ? + GraphSwitchCheck + 1 + ? + +GraphSwitchCheck + + +long + InitLoopSwitch__Index + +long + InitLoopSwitch__Min + +long + InitLoopSwitch__Max + + +long + EndOfInitLoopSwitch__Index + +long + EndOfInitLoopSwitch__Min + +long + EndOfInitLoopSwitch__Max + +boolean + Switch__default + + + 13/1/2005 - 11:48:50 + 13/1/2005 - 11:51:24 + 2.0 + JR + ? + ? + 0 + 0 + + +? + ? + IsOdd + 3 + ? + +IsOdd + + +long + a + + +long + a + + + +IsOdd + + + + + + 13/1/2005 - 11:50:18 + 13/1/2005 - 11:50:18 + 2.0 + ? + ? + Python function + 415 + 7 + +? + ? + IsEven + 3 + ? + +IsEven + + +long + a + + +long + a + + + +IsEven + + + + + + 13/1/2005 - 11:50:18 + 13/1/2005 - 11:50:18 + 2.0 + ? + ? + Compute Node + 421 + 438 + +? + ? + PrintOdd + 3 + ? + +Print + + +long + a + +string + Branch + + +string + Branch + + + +Print + + + + + + 13/1/2005 - 11:50:18 + 13/1/2005 - 11:50:18 + 2.0 + ? + ? + Compute Node + 415 + 130 + +? + ? + PrintEven + 3 + ? + +Print_1 + + +long + a + +string + Branch + + +string + Branch + + + +Print_1 + + + + + + 13/1/2005 - 11:50:18 + 13/1/2005 - 11:50:18 + 2.0 + ? + ? + Compute Node + 423 + 289 + +? + ? + EmptyNode + 3 + ? + +EmptyNode + + +long + a + +string + Branch + + +long + a + +string + Branch + + + +EmptyNode + + + + + 13/1/2005 - 11:50:18 + 13/1/2005 - 11:50:18 + 2.0 + ? + ? + Compute Node + 652 + 110 + +? + ? + InitLoopSwitch + 4 + EndOfInitLoopSwitch + +InitLoopSwitch + + +long + Index + +long + Min + +long + Max + + +long + Index + +long + Min + +long + Max + + + +InitLoop + + + + +MoreLoop + + + + = Min : ]]> + + + + + +NextLoop + + + + 13/1/2005 - 11:50:18 + 13/1/2005 - 11:50:18 + 2.0 + ? + ? + Compute Node + 10 + 129 + +? + ? + EndOfInitLoopSwitch + 5 + InitLoopSwitch + +EndOfInitLoopSwitch + + +long + Index + +long + Min + +long + Max + + +long + Index + +long + Min + +long + Max + + + +EndOfInitLoopSwitch + + + + + 13/1/2005 - 11:50:18 + 13/1/2005 - 11:50:18 + 2.0 + ? + ? + Compute Node + 1074 + 194 + +? + ? + Switch + 6 + EndOfSwitch + +Switch + + +long + a + + +long + Odd + +int + Even + +int + a + +string + Branch + +boolean + default + + + +Switch + + + + + + + + + + + + 13/1/2005 - 11:50:18 + 13/1/2005 - 11:50:18 + 2.0 + ? + ? + Compute Node + 195 + 129 + +? + ? + EndOfSwitch + 7 + Switch + +EndOfSwitch + + +long + a + +string + Branch + + +long + a + + + +EndOfSwitch + + + + + 13/1/2005 - 11:50:18 + 13/1/2005 - 11:50:18 + 2.0 + ? + ? + Compute Node + 882 + 194 + + +IsOdd + a + EmptyNode + a + + +646 + 78 + +IsEven + a + EndOfSwitch + a + + +PrintOdd + Branch + EmptyNode + Branch + + +PrintEven + Branch + EndOfSwitch + Branch + + +EmptyNode + a + EndOfSwitch + a + + +EmptyNode + Branch + EndOfSwitch + Branch + + +InitLoopSwitch + DoLoop + EndOfInitLoopSwitch + DoLoop + + +InitLoopSwitch + Index + Switch + a + + +InitLoopSwitch + Min + EndOfInitLoopSwitch + Min + + +InitLoopSwitch + Max + EndOfInitLoopSwitch + Max + + +EndOfInitLoopSwitch + DoLoop + InitLoopSwitch + DoLoop + + +Switch + Odd + IsOdd + Gate + + +401 + 101 + +401 + 160 + +Switch + Odd + PrintOdd + Gate + + +401 + 245 + +401 + 159 + +Switch + Even + IsEven + Gate + + +392 + 533 + +392 + 182 + +Switch + Even + PrintEven + Gate + + +392 + 403 + +392 + 181 + +Switch + a + IsOdd + a + + +382 + 78 + +382 + 199 + +Switch + a + IsEven + a + + +381 + 509 + +382 + 200 + +Switch + a + PrintOdd + a + + +Switch + a + PrintEven + a + + +381 + 361 + +382 + 200 + +Switch + Branch + PrintOdd + Branch + + +Switch + Branch + PrintEven + Branch + + +369 + 381 + +369 + 219 + +Switch + Default + EndOfSwitch + Default + + +EndOfSwitch + a + EndOfInitLoopSwitch + Index + + + +GraphSwitchCheck + InitLoopSwitch__Index + InitLoopSwitch + Index + +3 + 0 + + +GraphSwitchCheck + InitLoopSwitch__Min + InitLoopSwitch + Min + +3 + -5 + + +GraphSwitchCheck + InitLoopSwitch__Max + InitLoopSwitch + Max + +3 + 10 + diff --git a/examples/GraphSwitchCheckDefault.py b/examples/GraphSwitchCheckDefault.py new file mode 100644 index 0000000..8232e30 --- /dev/null +++ b/examples/GraphSwitchCheckDefault.py @@ -0,0 +1,299 @@ + +# Generated python file of Graph GraphSwitchCheckDefault + +from SuperV import * + +# Graph creation of GraphSwitchCheckDefault +def DefGraphSwitchCheckDefault() : + GraphSwitchCheckDefault = Graph( 'GraphSwitchCheckDefault' ) + GraphSwitchCheckDefault.SetName( 'GraphSwitchCheckDefault' ) + GraphSwitchCheckDefault.SetAuthor( 'JR' ) + GraphSwitchCheckDefault.SetComment( '' ) + GraphSwitchCheckDefault.Coords( 0 , 0 ) + + # Creation of Factory Nodes + + # Creation of InLine Nodes + PyIsOdd = [] + PyIsOdd.append( 'from time import * ' ) + PyIsOdd.append( 'def IsOdd(a) : ' ) + PyIsOdd.append( ' print a,"IsOdd (GraphSwitch)" ' ) + PyIsOdd.append( ' sleep( 1 ) ' ) + PyIsOdd.append( ' return a ' ) + IsOdd = GraphSwitchCheckDefault.INode( 'IsOdd' , PyIsOdd ) + IsOdd.SetName( 'IsOdd' ) + IsOdd.SetAuthor( '' ) + IsOdd.SetComment( 'Python function' ) + IsOdd.Coords( 415 , 7 ) + IIsOdda = IsOdd.InPort( 'a' , 'long' ) + IIsOddGate = IsOdd.GetInPort( 'Gate' ) + OIsOdda = IsOdd.OutPort( 'a' , 'long' ) + OIsOddGate = IsOdd.GetOutPort( 'Gate' ) + + PyIsEven = [] + PyIsEven.append( 'from time import * ' ) + PyIsEven.append( 'def IsEven(a) : ' ) + PyIsEven.append( ' print a,"IsEven (GraphSwitch)" ' ) + PyIsEven.append( ' sleep( 1 ) ' ) + PyIsEven.append( ' return a ' ) + IsEven = GraphSwitchCheckDefault.INode( 'IsEven' , PyIsEven ) + IsEven.SetName( 'IsEven' ) + IsEven.SetAuthor( '' ) + IsEven.SetComment( 'Compute Node' ) + IsEven.Coords( 421 , 438 ) + IIsEvena = IsEven.InPort( 'a' , 'long' ) + IIsEvenGate = IsEven.GetInPort( 'Gate' ) + OIsEvena = IsEven.OutPort( 'a' , 'long' ) + OIsEvenGate = IsEven.GetOutPort( 'Gate' ) + + PyPrintOdd = [] + PyPrintOdd.append( 'from time import * ' ) + PyPrintOdd.append( 'def Print(a,Branch) : ' ) + PyPrintOdd.append( ' print "Print ",a,Branch ' ) + PyPrintOdd.append( ' sleep(1) ' ) + PyPrintOdd.append( ' return Branch ' ) + PrintOdd = GraphSwitchCheckDefault.INode( 'Print' , PyPrintOdd ) + PrintOdd.SetName( 'PrintOdd' ) + PrintOdd.SetAuthor( '' ) + PrintOdd.SetComment( 'Compute Node' ) + PrintOdd.Coords( 415 , 130 ) + IPrintOdda = PrintOdd.InPort( 'a' , 'long' ) + IPrintOddBranch = PrintOdd.InPort( 'Branch' , 'string' ) + IPrintOddGate = PrintOdd.GetInPort( 'Gate' ) + OPrintOddBranch = PrintOdd.OutPort( 'Branch' , 'string' ) + OPrintOddGate = PrintOdd.GetOutPort( 'Gate' ) + + PyPrintEven = [] + PyPrintEven.append( 'from time import * ' ) + PyPrintEven.append( 'def Print_1(a,Branch) : ' ) + PyPrintEven.append( ' print "Print ",a,Branch ' ) + PyPrintEven.append( ' sleep(1) ' ) + PyPrintEven.append( ' return Branch ' ) + PrintEven = GraphSwitchCheckDefault.INode( 'Print_1' , PyPrintEven ) + PrintEven.SetName( 'PrintEven' ) + PrintEven.SetAuthor( '' ) + PrintEven.SetComment( 'Compute Node' ) + PrintEven.Coords( 423 , 289 ) + IPrintEvena = PrintEven.InPort( 'a' , 'long' ) + IPrintEvenBranch = PrintEven.InPort( 'Branch' , 'string' ) + IPrintEvenGate = PrintEven.GetInPort( 'Gate' ) + OPrintEvenBranch = PrintEven.OutPort( 'Branch' , 'string' ) + OPrintEvenGate = PrintEven.GetOutPort( 'Gate' ) + + PyEmptyNode = [] + PyEmptyNode.append( 'from time import * ' ) + PyEmptyNode.append( 'def EmptyNode(a,Branch) : ' ) + PyEmptyNode.append( ' sleep(1) ' ) + PyEmptyNode.append( ' return a,Branch ' ) + EmptyNode = GraphSwitchCheckDefault.INode( 'EmptyNode' , PyEmptyNode ) + EmptyNode.SetName( 'EmptyNode' ) + EmptyNode.SetAuthor( '' ) + EmptyNode.SetComment( 'Compute Node' ) + EmptyNode.Coords( 652 , 110 ) + IEmptyNodea = EmptyNode.InPort( 'a' , 'long' ) + IEmptyNodeBranch = EmptyNode.InPort( 'Branch' , 'string' ) + IEmptyNodeGate = EmptyNode.GetInPort( 'Gate' ) + OEmptyNodea = EmptyNode.OutPort( 'a' , 'long' ) + OEmptyNodeBranch = EmptyNode.OutPort( 'Branch' , 'string' ) + OEmptyNodeGate = EmptyNode.GetOutPort( 'Gate' ) + + PyDefault = [] + PyDefault.append( 'from time import * ' ) + PyDefault.append( 'def Default(a,Branch) : ' ) + PyDefault.append( ' sleep(1) ' ) + PyDefault.append( ' return a,Branch ' ) + Default = GraphSwitchCheckDefault.INode( 'Default' , PyDefault ) + Default.SetName( 'Default' ) + Default.SetAuthor( '' ) + Default.SetComment( 'Compute Node' ) + Default.Coords( 421 , 592 ) + IDefaulta = Default.InPort( 'a' , 'long' ) + IDefaultBranch = Default.InPort( 'Branch' , 'string' ) + IDefaultGate = Default.GetInPort( 'Gate' ) + ODefaulta = Default.OutPort( 'a' , 'long' ) + ODefaultBranch = Default.OutPort( 'Branch' , 'string' ) + ODefaultGate = Default.GetOutPort( 'Gate' ) + + # Creation of Loop Nodes + PyInitLoopSwitch = [] + PyInitLoopSwitch.append( 'def InitLoop(Index,Min,Max) : ' ) + PyInitLoopSwitch.append( ' Index = Max ' ) + PyInitLoopSwitch.append( ' return Index,Min,Max ' ) + PyMoreInitLoopSwitch = [] + PyMoreInitLoopSwitch.append( 'from time import * ' ) + PyMoreInitLoopSwitch.append( 'def MoreLoop(Index,Min,Max) : ' ) + PyMoreInitLoopSwitch.append( ' sleep(1) ' ) + PyMoreInitLoopSwitch.append( ' if Index >= Min : ' ) + PyMoreInitLoopSwitch.append( ' DoLoop = 1 ' ) + PyMoreInitLoopSwitch.append( ' else : ' ) + PyMoreInitLoopSwitch.append( ' DoLoop = 0 ' ) + PyMoreInitLoopSwitch.append( ' return DoLoop,Index,Min,Max ' ) + PyNextInitLoopSwitch = [] + PyNextInitLoopSwitch.append( 'def NextLoop(Index,Min,Max) : ' ) + PyNextInitLoopSwitch.append( ' Index = Index - 1 ' ) + PyNextInitLoopSwitch.append( ' return Index,Min,Max ' ) + InitLoopSwitch,EndOfInitLoopSwitch = GraphSwitchCheckDefault.LNode( 'InitLoop' , PyInitLoopSwitch , 'MoreLoop' , PyMoreInitLoopSwitch , 'NextLoop' , PyNextInitLoopSwitch ) + EndOfInitLoopSwitch.SetName( 'EndOfInitLoopSwitch' ) + EndOfInitLoopSwitch.SetAuthor( '' ) + EndOfInitLoopSwitch.SetComment( 'Compute Node' ) + EndOfInitLoopSwitch.Coords( 1074 , 194 ) + PyEndOfInitLoopSwitch = [] + PyEndOfInitLoopSwitch.append( 'from time import * ' ) + PyEndOfInitLoopSwitch.append( 'def EndOfInitLoopSwitch(DoLoop,Index,Min,Max) : ' ) + PyEndOfInitLoopSwitch.append( ' sleep(1) ' ) + PyEndOfInitLoopSwitch.append( ' return DoLoop,Index,Min,Max ' ) + EndOfInitLoopSwitch.SetPyFunction( 'EndOfInitLoopSwitch' , PyEndOfInitLoopSwitch ) + IInitLoopSwitchDoLoop = InitLoopSwitch.GetInPort( 'DoLoop' ) + IInitLoopSwitchIndex = InitLoopSwitch.InPort( 'Index' , 'long' ) + IInitLoopSwitchMin = InitLoopSwitch.InPort( 'Min' , 'long' ) + IInitLoopSwitchMax = InitLoopSwitch.InPort( 'Max' , 'long' ) + IInitLoopSwitchGate = InitLoopSwitch.GetInPort( 'Gate' ) + OInitLoopSwitchDoLoop = InitLoopSwitch.GetOutPort( 'DoLoop' ) + OInitLoopSwitchIndex = InitLoopSwitch.GetOutPort( 'Index' ) + OInitLoopSwitchMin = InitLoopSwitch.GetOutPort( 'Min' ) + OInitLoopSwitchMax = InitLoopSwitch.GetOutPort( 'Max' ) + IEndOfInitLoopSwitchDoLoop = EndOfInitLoopSwitch.GetInPort( 'DoLoop' ) + IEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetInPort( 'Index' ) + IEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetInPort( 'Min' ) + IEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetInPort( 'Max' ) + IEndOfInitLoopSwitchGate = EndOfInitLoopSwitch.GetInPort( 'Gate' ) + OEndOfInitLoopSwitchDoLoop = EndOfInitLoopSwitch.GetOutPort( 'DoLoop' ) + OEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetOutPort( 'Index' ) + OEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetOutPort( 'Min' ) + OEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetOutPort( 'Max' ) + OEndOfInitLoopSwitchGate = EndOfInitLoopSwitch.GetOutPort( 'Gate' ) + InitLoopSwitch.SetName( 'InitLoopSwitch' ) + InitLoopSwitch.SetAuthor( '' ) + InitLoopSwitch.SetComment( 'Compute Node' ) + InitLoopSwitch.Coords( 10 , 129 ) + + # Creation of Switch Nodes + PySwitch = [] + PySwitch.append( 'from time import * ' ) + PySwitch.append( 'def Switch(a) : ' ) + PySwitch.append( ' sleep(1) ' ) + PySwitch.append( ' Branch = "Negative or null" ' ) + PySwitch.append( ' if a <= 0 : ' ) + PySwitch.append( ' return 0,0,a,Branch,1 ' ) + PySwitch.append( ' if ( a & 1 ) == 0 : ' ) + PySwitch.append( ' Branch = "Even" ' ) + PySwitch.append( ' else : ' ) + PySwitch.append( ' Branch = "Odd" ' ) + PySwitch.append( ' return a & 1,1-(a&1),a,Branch,0 ' ) + Switch,EndOfSwitch = GraphSwitchCheckDefault.SNode( 'Switch' , PySwitch ) + EndOfSwitch.SetName( 'EndOfSwitch' ) + EndOfSwitch.SetAuthor( '' ) + EndOfSwitch.SetComment( 'Compute Node' ) + EndOfSwitch.Coords( 882 , 194 ) + PyEndOfSwitch = [] + PyEndOfSwitch.append( 'from time import * ' ) + PyEndOfSwitch.append( 'def EndOfSwitch(a,Branch) : ' ) + PyEndOfSwitch.append( ' sleep(1) ' ) + PyEndOfSwitch.append( ' return a ' ) + EndOfSwitch.SetPyFunction( 'EndOfSwitch' , PyEndOfSwitch ) + IEndOfSwitcha = EndOfSwitch.InPort( 'a' , 'long' ) + IEndOfSwitchBranch = EndOfSwitch.InPort( 'Branch' , 'string' ) + IEndOfSwitchDefault = EndOfSwitch.GetInPort( 'Default' ) + OEndOfSwitcha = EndOfSwitch.OutPort( 'a' , 'long' ) + OEndOfSwitchGate = EndOfSwitch.GetOutPort( 'Gate' ) + Switch.SetName( 'Switch' ) + Switch.SetAuthor( '' ) + Switch.SetComment( 'Compute Node' ) + Switch.Coords( 190 , 129 ) + ISwitcha = Switch.InPort( 'a' , 'long' ) + ISwitchGate = Switch.GetInPort( 'Gate' ) + OSwitchOdd = Switch.OutPort( 'Odd' , 'long' ) + OSwitchEven = Switch.OutPort( 'Even' , 'int' ) + OSwitcha = Switch.OutPort( 'a' , 'int' ) + OSwitchBranch = Switch.OutPort( 'Branch' , 'string' ) + OSwitchdefault = Switch.OutPort( 'default' , 'boolean' ) + OSwitchDefault = Switch.GetOutPort( 'Default' ) + + # Creation of Links + LIsOddaEmptyNodea = GraphSwitchCheckDefault.Link( OIsOdda , IEmptyNodea ) + LIsOddaEmptyNodea.AddCoord( 1 , 646 , 78 ) + + LIsEvenaEndOfSwitcha = GraphSwitchCheckDefault.Link( OIsEvena , IEndOfSwitcha ) + + LPrintOddBranchEmptyNodeBranch = GraphSwitchCheckDefault.Link( OPrintOddBranch , IEmptyNodeBranch ) + + LPrintEvenBranchEndOfSwitchBranch = GraphSwitchCheckDefault.Link( OPrintEvenBranch , IEndOfSwitchBranch ) + + LEmptyNodeaEndOfSwitcha = GraphSwitchCheckDefault.Link( OEmptyNodea , IEndOfSwitcha ) + + LEmptyNodeBranchEndOfSwitchBranch = GraphSwitchCheckDefault.Link( OEmptyNodeBranch , IEndOfSwitchBranch ) + + LDefaultaEndOfSwitcha = GraphSwitchCheckDefault.Link( ODefaulta , IEndOfSwitcha ) + + LDefaultBranchEndOfSwitchBranch = GraphSwitchCheckDefault.Link( ODefaultBranch , IEndOfSwitchBranch ) + + LInitLoopSwitchIndexSwitcha = GraphSwitchCheckDefault.Link( OInitLoopSwitchIndex , ISwitcha ) + + LInitLoopSwitchMinEndOfInitLoopSwitchMin = GraphSwitchCheckDefault.Link( OInitLoopSwitchMin , IEndOfInitLoopSwitchMin ) + + LInitLoopSwitchMaxEndOfInitLoopSwitchMax = GraphSwitchCheckDefault.Link( OInitLoopSwitchMax , IEndOfInitLoopSwitchMax ) + + LSwitchOddIsOddGate = GraphSwitchCheckDefault.Link( OSwitchOdd , IIsOddGate ) + LSwitchOddIsOddGate.AddCoord( 1 , 401 , 101 ) + LSwitchOddIsOddGate.AddCoord( 2 , 401 , 160 ) + + LSwitchOddPrintOddGate = GraphSwitchCheckDefault.Link( OSwitchOdd , IPrintOddGate ) + LSwitchOddPrintOddGate.AddCoord( 1 , 401 , 245 ) + LSwitchOddPrintOddGate.AddCoord( 2 , 401 , 159 ) + + LSwitchEvenIsEvenGate = GraphSwitchCheckDefault.Link( OSwitchEven , IIsEvenGate ) + LSwitchEvenIsEvenGate.AddCoord( 1 , 392 , 533 ) + LSwitchEvenIsEvenGate.AddCoord( 2 , 392 , 182 ) + + LSwitchEvenPrintEvenGate = GraphSwitchCheckDefault.Link( OSwitchEven , IPrintEvenGate ) + LSwitchEvenPrintEvenGate.AddCoord( 1 , 392 , 403 ) + LSwitchEvenPrintEvenGate.AddCoord( 2 , 392 , 181 ) + + LSwitchaIsOdda = GraphSwitchCheckDefault.Link( OSwitcha , IIsOdda ) + LSwitchaIsOdda.AddCoord( 1 , 382 , 78 ) + LSwitchaIsOdda.AddCoord( 2 , 382 , 199 ) + + LSwitchaIsEvena = GraphSwitchCheckDefault.Link( OSwitcha , IIsEvena ) + LSwitchaIsEvena.AddCoord( 1 , 381 , 509 ) + LSwitchaIsEvena.AddCoord( 2 , 382 , 200 ) + + LSwitchaPrintOdda = GraphSwitchCheckDefault.Link( OSwitcha , IPrintOdda ) + + LSwitchaPrintEvena = GraphSwitchCheckDefault.Link( OSwitcha , IPrintEvena ) + LSwitchaPrintEvena.AddCoord( 1 , 381 , 361 ) + LSwitchaPrintEvena.AddCoord( 2 , 382 , 200 ) + + LSwitchaDefaulta = GraphSwitchCheckDefault.Link( OSwitcha , IDefaulta ) + LSwitchaDefaulta.AddCoord( 1 , 382 , 663 ) + LSwitchaDefaulta.AddCoord( 2 , 382 , 199 ) + + LSwitchBranchPrintOddBranch = GraphSwitchCheckDefault.Link( OSwitchBranch , IPrintOddBranch ) + + LSwitchBranchPrintEvenBranch = GraphSwitchCheckDefault.Link( OSwitchBranch , IPrintEvenBranch ) + LSwitchBranchPrintEvenBranch.AddCoord( 1 , 369 , 381 ) + LSwitchBranchPrintEvenBranch.AddCoord( 2 , 369 , 219 ) + + LSwitchBranchDefaultBranch = GraphSwitchCheckDefault.Link( OSwitchBranch , IDefaultBranch ) + LSwitchBranchDefaultBranch.AddCoord( 1 , 370 , 683 ) + LSwitchBranchDefaultBranch.AddCoord( 2 , 370 , 220 ) + + LSwitchDefaultDefaultGate = GraphSwitchCheckDefault.Link( OSwitchDefault , IDefaultGate ) + LSwitchDefaultDefaultGate.AddCoord( 1 , 360 , 707 ) + LSwitchDefaultDefaultGate.AddCoord( 2 , 360 , 263 ) + + LEndOfSwitchaEndOfInitLoopSwitchIndex = GraphSwitchCheckDefault.Link( OEndOfSwitcha , IEndOfInitLoopSwitchIndex ) + + # Input datas + IInitLoopSwitchIndex.Input( 0 ) + IInitLoopSwitchMin.Input( -5 ) + IInitLoopSwitchMax.Input( 10 ) + + # Output Ports of the graph + #OEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetOutPort( 'Index' ) + #OEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetOutPort( 'Min' ) + #OEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetOutPort( 'Max' ) + #OSwitchdefault = Switch.GetOutPort( 'default' ) + return GraphSwitchCheckDefault + + +GraphSwitchCheckDefault = DefGraphSwitchCheckDefault() diff --git a/examples/GraphSwitchCheckDefault.xml b/examples/GraphSwitchCheckDefault.xml new file mode 100644 index 0000000..81e7ab6 --- /dev/null +++ b/examples/GraphSwitchCheckDefault.xml @@ -0,0 +1,708 @@ + + + + + +? + ? + GraphSwitchCheckDefault + 1 + ? + +GraphSwitchCheck_2 + + +long + InitLoopSwitch__Index + +long + InitLoopSwitch__Min + +long + InitLoopSwitch__Max + + +long + EndOfInitLoopSwitch__Index + +long + EndOfInitLoopSwitch__Min + +long + EndOfInitLoopSwitch__Max + +boolean + Switch__default + + + 13/1/2005 - 12:21:43 + 13/1/2005 - 12:23:17 + 2.0 + JR + ? + ? + 0 + 0 + + +? + ? + IsOdd + 3 + ? + +IsOdd + + +long + a + + +long + a + + + +IsOdd + + + + + + 13/1/2005 - 12:23:17 + 13/1/2005 - 12:23:17 + 2.0 + ? + ? + Python function + 415 + 7 + +? + ? + IsEven + 3 + ? + +IsEven + + +long + a + + +long + a + + + +IsEven + + + + + + 13/1/2005 - 12:23:17 + 13/1/2005 - 12:23:17 + 2.0 + ? + ? + Compute Node + 421 + 438 + +? + ? + PrintOdd + 3 + ? + +PrintOdd + + +long + a + +string + Branch + + +string + Branch + + + +Print + + + + + + 13/1/2005 - 12:23:17 + 13/1/2005 - 12:23:17 + 2.0 + ? + ? + Compute Node + 415 + 130 + +? + ? + PrintEven + 3 + ? + +PrintEven + + +long + a + +string + Branch + + +string + Branch + + + +Print_1 + + + + + + 13/1/2005 - 12:23:17 + 13/1/2005 - 12:23:17 + 2.0 + ? + ? + Compute Node + 423 + 289 + +? + ? + EmptyNode + 3 + ? + +EmptyNode + + +long + a + +string + Branch + + +long + a + +string + Branch + + + +EmptyNode + + + + + 13/1/2005 - 12:23:17 + 13/1/2005 - 12:23:17 + 2.0 + ? + ? + Compute Node + 652 + 110 + +? + ? + Default + 3 + ? + +Default + + +long + a + +string + Branch + + +long + a + +string + Branch + + + +Default + + + + + 13/1/2005 - 12:23:17 + 13/1/2005 - 12:23:17 + 2.0 + ? + ? + Compute Node + 421 + 592 + +? + ? + InitLoopSwitch + 4 + EndOfInitLoopSwitch + +InitLoopSwitch + + +long + Index + +long + Min + +long + Max + + +long + Index + +long + Min + +long + Max + + + +InitLoop + + + + +MoreLoop + + + + = Min : ]]> + + + + + +NextLoop + + + + 13/1/2005 - 12:23:17 + 13/1/2005 - 12:23:17 + 2.0 + ? + ? + Compute Node + 10 + 129 + +? + ? + EndOfInitLoopSwitch + 5 + InitLoopSwitch + +EndOfInitLoopSwitch + + +long + Index + +long + Min + +long + Max + + +long + Index + +long + Min + +long + Max + + + +EndOfInitLoopSwitch + + + + + 13/1/2005 - 12:23:17 + 13/1/2005 - 12:23:17 + 2.0 + ? + ? + Compute Node + 1074 + 194 + +? + ? + Switch + 6 + EndOfSwitch + +Switch + + +long + a + + +long + Odd + +int + Even + +int + a + +string + Branch + +boolean + default + + + +Switch + + + + + + + + + + + + 13/1/2005 - 12:23:17 + 13/1/2005 - 12:23:17 + 2.0 + ? + ? + Compute Node + 190 + 129 + +? + ? + EndOfSwitch + 7 + Switch + +EndOfSwitch + + +long + a + +string + Branch + + +long + a + + + +EndOfSwitch + + + + + 13/1/2005 - 12:23:17 + 13/1/2005 - 12:23:17 + 2.0 + ? + ? + Compute Node + 882 + 194 + + +IsOdd + a + EmptyNode + a + + +646 + 78 + +IsEven + a + EndOfSwitch + a + + +PrintOdd + Branch + EmptyNode + Branch + + +PrintEven + Branch + EndOfSwitch + Branch + + +EmptyNode + a + EndOfSwitch + a + + +EmptyNode + Branch + EndOfSwitch + Branch + + +Default + a + EndOfSwitch + a + + +Default + Branch + EndOfSwitch + Branch + + +InitLoopSwitch + DoLoop + EndOfInitLoopSwitch + DoLoop + + +InitLoopSwitch + Index + Switch + a + + +InitLoopSwitch + Min + EndOfInitLoopSwitch + Min + + +InitLoopSwitch + Max + EndOfInitLoopSwitch + Max + + +EndOfInitLoopSwitch + DoLoop + InitLoopSwitch + DoLoop + + +Switch + Odd + IsOdd + Gate + + +401 + 101 + +401 + 160 + +Switch + Odd + PrintOdd + Gate + + +401 + 245 + +401 + 159 + +Switch + Even + IsEven + Gate + + +392 + 533 + +392 + 182 + +Switch + Even + PrintEven + Gate + + +392 + 403 + +392 + 181 + +Switch + a + IsOdd + a + + +382 + 78 + +382 + 199 + +Switch + a + IsEven + a + + +381 + 509 + +382 + 200 + +Switch + a + PrintOdd + a + + +Switch + a + PrintEven + a + + +381 + 361 + +382 + 200 + +Switch + a + Default + a + + +382 + 663 + +382 + 199 + +Switch + Branch + PrintOdd + Branch + + +Switch + Branch + PrintEven + Branch + + +369 + 381 + +369 + 219 + +Switch + Branch + Default + Branch + + +370 + 683 + +370 + 220 + +Switch + Default + Default + Gate + + +360 + 707 + +360 + 263 + +EndOfSwitch + a + EndOfInitLoopSwitch + Index + + + +GraphSwitchCheckDefault + InitLoopSwitch__Index + InitLoopSwitch + Index + +3 + 0 + + +GraphSwitchCheckDefault + InitLoopSwitch__Min + InitLoopSwitch + Min + +3 + -5 + + +GraphSwitchCheckDefault + InitLoopSwitch__Max + InitLoopSwitch + Max + +3 + 10 + diff --git a/examples/GraphSwitchCheckDefault1.py b/examples/GraphSwitchCheckDefault1.py new file mode 100644 index 0000000..a7cbc2a --- /dev/null +++ b/examples/GraphSwitchCheckDefault1.py @@ -0,0 +1,298 @@ + +# Generated python file of Graph GraphSwitchCheckDefault1 + +from SuperV import * + +# Graph creation of GraphSwitchCheckDefault1 +def DefGraphSwitchCheckDefault1() : + GraphSwitchCheckDefault1 = Graph( 'GraphSwitchCheckDefault1' ) + GraphSwitchCheckDefault1.SetName( 'GraphSwitchCheckDefault1' ) + GraphSwitchCheckDefault1.SetAuthor( 'JR' ) + GraphSwitchCheckDefault1.SetComment( '' ) + GraphSwitchCheckDefault1.Coords( 0 , 0 ) + + # Creation of Factory Nodes + + # Creation of InLine Nodes + PyIsOdd = [] + PyIsOdd.append( 'from time import * ' ) + PyIsOdd.append( 'def IsOdd(a) : ' ) + PyIsOdd.append( ' print a,"IsOdd (GraphSwitch)" ' ) + PyIsOdd.append( ' sleep( 1 ) ' ) + PyIsOdd.append( ' return a ' ) + IsOdd = GraphSwitchCheckDefault1.INode( 'IsOdd' , PyIsOdd ) + IsOdd.SetName( 'IsOdd' ) + IsOdd.SetAuthor( '' ) + IsOdd.SetComment( 'Python function' ) + IsOdd.Coords( 415 , 7 ) + IIsOdda = IsOdd.InPort( 'a' , 'long' ) + IIsOddGate = IsOdd.GetInPort( 'Gate' ) + OIsOdda = IsOdd.OutPort( 'a' , 'long' ) + OIsOddGate = IsOdd.GetOutPort( 'Gate' ) + + PyIsEven = [] + PyIsEven.append( 'from time import * ' ) + PyIsEven.append( 'def IsEven(a) : ' ) + PyIsEven.append( ' print a,"IsEven (GraphSwitch)" ' ) + PyIsEven.append( ' sleep( 1 ) ' ) + PyIsEven.append( ' return a ' ) + IsEven = GraphSwitchCheckDefault1.INode( 'IsEven' , PyIsEven ) + IsEven.SetName( 'IsEven' ) + IsEven.SetAuthor( '' ) + IsEven.SetComment( 'Compute Node' ) + IsEven.Coords( 421 , 438 ) + IIsEvena = IsEven.InPort( 'a' , 'long' ) + IIsEvenGate = IsEven.GetInPort( 'Gate' ) + OIsEvena = IsEven.OutPort( 'a' , 'long' ) + OIsEvenGate = IsEven.GetOutPort( 'Gate' ) + + PyPrintOdd = [] + PyPrintOdd.append( 'from time import * ' ) + PyPrintOdd.append( 'def Print(a,Branch) : ' ) + PyPrintOdd.append( ' print "Print ",a,Branch ' ) + PyPrintOdd.append( ' sleep(1) ' ) + PyPrintOdd.append( ' return Branch ' ) + PrintOdd = GraphSwitchCheckDefault1.INode( 'Print' , PyPrintOdd ) + PrintOdd.SetName( 'PrintOdd' ) + PrintOdd.SetAuthor( '' ) + PrintOdd.SetComment( 'Compute Node' ) + PrintOdd.Coords( 415 , 130 ) + IPrintOdda = PrintOdd.InPort( 'a' , 'long' ) + IPrintOddBranch = PrintOdd.InPort( 'Branch' , 'string' ) + IPrintOddGate = PrintOdd.GetInPort( 'Gate' ) + OPrintOddBranch = PrintOdd.OutPort( 'Branch' , 'string' ) + OPrintOddGate = PrintOdd.GetOutPort( 'Gate' ) + + PyPrintEven = [] + PyPrintEven.append( 'from time import * ' ) + PyPrintEven.append( 'def Print_1(a,Branch) : ' ) + PyPrintEven.append( ' print "Print ",a,Branch ' ) + PyPrintEven.append( ' sleep(1) ' ) + PyPrintEven.append( ' return Branch ' ) + PrintEven = GraphSwitchCheckDefault1.INode( 'Print_1' , PyPrintEven ) + PrintEven.SetName( 'PrintEven' ) + PrintEven.SetAuthor( '' ) + PrintEven.SetComment( 'Compute Node' ) + PrintEven.Coords( 423 , 289 ) + IPrintEvena = PrintEven.InPort( 'a' , 'long' ) + IPrintEvenBranch = PrintEven.InPort( 'Branch' , 'string' ) + IPrintEvenGate = PrintEven.GetInPort( 'Gate' ) + OPrintEvenBranch = PrintEven.OutPort( 'Branch' , 'string' ) + OPrintEvenGate = PrintEven.GetOutPort( 'Gate' ) + + PyEmptyNode = [] + PyEmptyNode.append( 'from time import * ' ) + PyEmptyNode.append( 'def EmptyNode(a,Branch) : ' ) + PyEmptyNode.append( ' sleep(1) ' ) + PyEmptyNode.append( ' return a,Branch ' ) + EmptyNode = GraphSwitchCheckDefault1.INode( 'EmptyNode' , PyEmptyNode ) + EmptyNode.SetName( 'EmptyNode' ) + EmptyNode.SetAuthor( '' ) + EmptyNode.SetComment( 'Compute Node' ) + EmptyNode.Coords( 652 , 110 ) + IEmptyNodea = EmptyNode.InPort( 'a' , 'long' ) + IEmptyNodeBranch = EmptyNode.InPort( 'Branch' , 'string' ) + IEmptyNodeGate = EmptyNode.GetInPort( 'Gate' ) + OEmptyNodea = EmptyNode.OutPort( 'a' , 'long' ) + OEmptyNodeBranch = EmptyNode.OutPort( 'Branch' , 'string' ) + OEmptyNodeGate = EmptyNode.GetOutPort( 'Gate' ) + + PyDefault = [] + PyDefault.append( 'from time import * ' ) + PyDefault.append( 'def Default(a,Branch) : ' ) + PyDefault.append( ' sleep(1) ' ) + PyDefault.append( ' return a,Branch ' ) + Default = GraphSwitchCheckDefault1.INode( 'Default' , PyDefault ) + Default.SetName( 'Default' ) + Default.SetAuthor( '' ) + Default.SetComment( 'Compute Node' ) + Default.Coords( 421 , 592 ) + IDefaulta = Default.InPort( 'a' , 'long' ) + IDefaultBranch = Default.InPort( 'Branch' , 'string' ) + IDefaultGate = Default.GetInPort( 'Gate' ) + ODefaulta = Default.OutPort( 'a' , 'long' ) + ODefaultBranch = Default.OutPort( 'Branch' , 'string' ) + ODefaultGate = Default.GetOutPort( 'Gate' ) + + # Creation of Loop Nodes + PyInitLoopSwitch = [] + PyInitLoopSwitch.append( 'def InitLoop(Index,Min,Max) : ' ) + PyInitLoopSwitch.append( ' Index = Max ' ) + PyInitLoopSwitch.append( ' return Index,Min,Max ' ) + PyMoreInitLoopSwitch = [] + PyMoreInitLoopSwitch.append( 'from time import * ' ) + PyMoreInitLoopSwitch.append( 'def MoreLoop(Index,Min,Max) : ' ) + PyMoreInitLoopSwitch.append( ' sleep(1) ' ) + PyMoreInitLoopSwitch.append( ' if Index >= Min : ' ) + PyMoreInitLoopSwitch.append( ' DoLoop = 1 ' ) + PyMoreInitLoopSwitch.append( ' else : ' ) + PyMoreInitLoopSwitch.append( ' DoLoop = 0 ' ) + PyMoreInitLoopSwitch.append( ' return DoLoop,Index,Min,Max ' ) + PyNextInitLoopSwitch = [] + PyNextInitLoopSwitch.append( 'def NextLoop(Index,Min,Max) : ' ) + PyNextInitLoopSwitch.append( ' Index = Index - 1 ' ) + PyNextInitLoopSwitch.append( ' return Index,Min,Max ' ) + InitLoopSwitch,EndOfInitLoopSwitch = GraphSwitchCheckDefault1.LNode( 'InitLoop' , PyInitLoopSwitch , 'MoreLoop' , PyMoreInitLoopSwitch , 'NextLoop' , PyNextInitLoopSwitch ) + EndOfInitLoopSwitch.SetName( 'EndOfInitLoopSwitch' ) + EndOfInitLoopSwitch.SetAuthor( '' ) + EndOfInitLoopSwitch.SetComment( 'Compute Node' ) + EndOfInitLoopSwitch.Coords( 1074 , 194 ) + PyEndOfInitLoopSwitch = [] + PyEndOfInitLoopSwitch.append( 'from time import * ' ) + PyEndOfInitLoopSwitch.append( 'def EndOfInitLoopSwitch(DoLoop,Index,Min,Max) : ' ) + PyEndOfInitLoopSwitch.append( ' sleep(1) ' ) + PyEndOfInitLoopSwitch.append( ' return DoLoop,Index,Min,Max ' ) + EndOfInitLoopSwitch.SetPyFunction( 'EndOfInitLoopSwitch' , PyEndOfInitLoopSwitch ) + IInitLoopSwitchDoLoop = InitLoopSwitch.GetInPort( 'DoLoop' ) + IInitLoopSwitchIndex = InitLoopSwitch.InPort( 'Index' , 'long' ) + IInitLoopSwitchMin = InitLoopSwitch.InPort( 'Min' , 'long' ) + IInitLoopSwitchMax = InitLoopSwitch.InPort( 'Max' , 'long' ) + IInitLoopSwitchGate = InitLoopSwitch.GetInPort( 'Gate' ) + OInitLoopSwitchDoLoop = InitLoopSwitch.GetOutPort( 'DoLoop' ) + OInitLoopSwitchIndex = InitLoopSwitch.GetOutPort( 'Index' ) + OInitLoopSwitchMin = InitLoopSwitch.GetOutPort( 'Min' ) + OInitLoopSwitchMax = InitLoopSwitch.GetOutPort( 'Max' ) + IEndOfInitLoopSwitchDoLoop = EndOfInitLoopSwitch.GetInPort( 'DoLoop' ) + IEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetInPort( 'Index' ) + IEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetInPort( 'Min' ) + IEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetInPort( 'Max' ) + IEndOfInitLoopSwitchGate = EndOfInitLoopSwitch.GetInPort( 'Gate' ) + OEndOfInitLoopSwitchDoLoop = EndOfInitLoopSwitch.GetOutPort( 'DoLoop' ) + OEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetOutPort( 'Index' ) + OEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetOutPort( 'Min' ) + OEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetOutPort( 'Max' ) + OEndOfInitLoopSwitchGate = EndOfInitLoopSwitch.GetOutPort( 'Gate' ) + InitLoopSwitch.SetName( 'InitLoopSwitch' ) + InitLoopSwitch.SetAuthor( '' ) + InitLoopSwitch.SetComment( 'Compute Node' ) + InitLoopSwitch.Coords( 10 , 129 ) + + # Creation of Switch Nodes + PySwitch = [] + PySwitch.append( 'from time import * ' ) + PySwitch.append( 'def Switch(a) : ' ) + PySwitch.append( ' sleep(1) ' ) + PySwitch.append( ' Branch = "Negative or null" ' ) + PySwitch.append( ' if a <= 0 : ' ) + PySwitch.append( ' return 0,0,a,Branch,1 ' ) + PySwitch.append( ' if ( a & 1 ) == 0 : ' ) + PySwitch.append( ' Branch = "Even" ' ) + PySwitch.append( ' else : ' ) + PySwitch.append( ' Branch = "Odd" ' ) + PySwitch.append( ' return a & 1,1-(a&1),a,Branch,0 ' ) + Switch,EndOfSwitch = GraphSwitchCheckDefault1.SNode( 'Switch' , PySwitch ) + EndOfSwitch.SetName( 'EndOfSwitch' ) + EndOfSwitch.SetAuthor( '' ) + EndOfSwitch.SetComment( 'Compute Node' ) + EndOfSwitch.Coords( 882 , 194 ) + PyEndOfSwitch = [] + PyEndOfSwitch.append( 'from time import * ' ) + PyEndOfSwitch.append( 'def EndOfSwitch(a,Branch) : ' ) + PyEndOfSwitch.append( ' sleep(1) ' ) + PyEndOfSwitch.append( ' return a ' ) + EndOfSwitch.SetPyFunction( 'EndOfSwitch' , PyEndOfSwitch ) + IEndOfSwitcha = EndOfSwitch.InPort( 'a' , 'long' ) + IEndOfSwitchBranch = EndOfSwitch.InPort( 'Branch' , 'string' ) + IEndOfSwitchDefault = EndOfSwitch.GetInPort( 'Default' ) + OEndOfSwitcha = EndOfSwitch.OutPort( 'a' , 'long' ) + OEndOfSwitchGate = EndOfSwitch.GetOutPort( 'Gate' ) + Switch.SetName( 'Switch' ) + Switch.SetAuthor( '' ) + Switch.SetComment( 'Compute Node' ) + Switch.Coords( 190 , 129 ) + ISwitcha = Switch.InPort( 'a' , 'long' ) + ISwitchGate = Switch.GetInPort( 'Gate' ) + OSwitchOdd = Switch.OutPort( 'Odd' , 'long' ) + OSwitchEven = Switch.OutPort( 'Even' , 'int' ) + OSwitcha = Switch.OutPort( 'a' , 'int' ) + OSwitchBranch = Switch.OutPort( 'Branch' , 'string' ) + OSwitchdefault = Switch.OutPort( 'default' , 'boolean' ) + OSwitchDefault = Switch.GetOutPort( 'Default' ) + + # Creation of Links + LIsOddaEmptyNodea = GraphSwitchCheckDefault1.Link( OIsOdda , IEmptyNodea ) + LIsOddaEmptyNodea.AddCoord( 1 , 646 , 78 ) + + LIsEvenaEndOfSwitcha = GraphSwitchCheckDefault1.Link( OIsEvena , IEndOfSwitcha ) + + LPrintOddBranchEmptyNodeBranch = GraphSwitchCheckDefault1.Link( OPrintOddBranch , IEmptyNodeBranch ) + + LPrintEvenBranchEndOfSwitchBranch = GraphSwitchCheckDefault1.Link( OPrintEvenBranch , IEndOfSwitchBranch ) + + LEmptyNodeaEndOfSwitcha = GraphSwitchCheckDefault1.Link( OEmptyNodea , IEndOfSwitcha ) + + LEmptyNodeBranchEndOfSwitchBranch = GraphSwitchCheckDefault1.Link( OEmptyNodeBranch , IEndOfSwitchBranch ) + + LDefaultaEndOfSwitcha = GraphSwitchCheckDefault1.Link( ODefaulta , IEndOfSwitcha ) + + LDefaultBranchEndOfSwitchBranch = GraphSwitchCheckDefault1.Link( ODefaultBranch , IEndOfSwitchBranch ) + + LInitLoopSwitchIndexSwitcha = GraphSwitchCheckDefault1.Link( OInitLoopSwitchIndex , ISwitcha ) + + LInitLoopSwitchMinEndOfInitLoopSwitchMin = GraphSwitchCheckDefault1.Link( OInitLoopSwitchMin , IEndOfInitLoopSwitchMin ) + + LInitLoopSwitchMaxEndOfInitLoopSwitchMax = GraphSwitchCheckDefault1.Link( OInitLoopSwitchMax , IEndOfInitLoopSwitchMax ) + + LSwitchOddIsOddGate = GraphSwitchCheckDefault1.Link( OSwitchOdd , IIsOddGate ) + LSwitchOddIsOddGate.AddCoord( 1 , 401 , 101 ) + LSwitchOddIsOddGate.AddCoord( 2 , 401 , 160 ) + + LSwitchOddPrintOddGate = GraphSwitchCheckDefault1.Link( OSwitchOdd , IPrintOddGate ) + LSwitchOddPrintOddGate.AddCoord( 1 , 401 , 245 ) + LSwitchOddPrintOddGate.AddCoord( 2 , 401 , 159 ) + + LSwitchEvenIsEvenGate = GraphSwitchCheckDefault1.Link( OSwitchEven , IIsEvenGate ) + LSwitchEvenIsEvenGate.AddCoord( 1 , 392 , 533 ) + LSwitchEvenIsEvenGate.AddCoord( 2 , 392 , 182 ) + + LSwitchEvenPrintEvenGate = GraphSwitchCheckDefault1.Link( OSwitchEven , IPrintEvenGate ) + LSwitchEvenPrintEvenGate.AddCoord( 1 , 392 , 403 ) + LSwitchEvenPrintEvenGate.AddCoord( 2 , 392 , 181 ) + + LSwitchaIsOdda = GraphSwitchCheckDefault1.Link( OSwitcha , IIsOdda ) + LSwitchaIsOdda.AddCoord( 1 , 382 , 78 ) + LSwitchaIsOdda.AddCoord( 2 , 382 , 199 ) + + LSwitchaIsEvena = GraphSwitchCheckDefault1.Link( OSwitcha , IIsEvena ) + LSwitchaIsEvena.AddCoord( 1 , 381 , 509 ) + LSwitchaIsEvena.AddCoord( 2 , 382 , 200 ) + + LSwitchaPrintOdda = GraphSwitchCheckDefault1.Link( OSwitcha , IPrintOdda ) + + LSwitchaPrintEvena = GraphSwitchCheckDefault1.Link( OSwitcha , IPrintEvena ) + LSwitchaPrintEvena.AddCoord( 1 , 381 , 361 ) + LSwitchaPrintEvena.AddCoord( 2 , 382 , 200 ) + + LSwitchaDefaulta = GraphSwitchCheckDefault1.Link( OSwitcha , IDefaulta ) + LSwitchaDefaulta.AddCoord( 1 , 382 , 663 ) + LSwitchaDefaulta.AddCoord( 2 , 382 , 199 ) + + LSwitchBranchPrintOddBranch = GraphSwitchCheckDefault1.Link( OSwitchBranch , IPrintOddBranch ) + + LSwitchBranchPrintEvenBranch = GraphSwitchCheckDefault1.Link( OSwitchBranch , IPrintEvenBranch ) + LSwitchBranchPrintEvenBranch.AddCoord( 1 , 369 , 381 ) + LSwitchBranchPrintEvenBranch.AddCoord( 2 , 369 , 219 ) + + LSwitchBranchDefaultBranch = GraphSwitchCheckDefault1.Link( OSwitchBranch , IDefaultBranch ) + LSwitchBranchDefaultBranch.AddCoord( 1 , 370 , 683 ) + LSwitchBranchDefaultBranch.AddCoord( 2 , 370 , 220 ) + + LSwitchdefaultDefaultGate = GraphSwitchCheckDefault1.Link( OSwitchdefault , IDefaultGate ) + LSwitchdefaultDefaultGate.AddCoord( 1 , 363 , 707 ) + LSwitchdefaultDefaultGate.AddCoord( 2 , 362 , 239 ) + + LEndOfSwitchaEndOfInitLoopSwitchIndex = GraphSwitchCheckDefault1.Link( OEndOfSwitcha , IEndOfInitLoopSwitchIndex ) + + # Input datas + IInitLoopSwitchIndex.Input( 0 ) + IInitLoopSwitchMin.Input( -5 ) + IInitLoopSwitchMax.Input( 10 ) + + # Output Ports of the graph + #OEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetOutPort( 'Index' ) + #OEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetOutPort( 'Min' ) + #OEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetOutPort( 'Max' ) + return GraphSwitchCheckDefault1 + + +GraphSwitchCheckDefault1 = DefGraphSwitchCheckDefault1() diff --git a/examples/GraphSwitchCheckDefault1.xml b/examples/GraphSwitchCheckDefault1.xml new file mode 100644 index 0000000..317bc92 --- /dev/null +++ b/examples/GraphSwitchCheckDefault1.xml @@ -0,0 +1,705 @@ + + + + + +? + ? + GraphSwitchCheckDefault1 + 1 + ? + +GraphSwitchCheckDefault + + +long + InitLoopSwitch__Index + +long + InitLoopSwitch__Min + +long + InitLoopSwitch__Max + + +long + EndOfInitLoopSwitch__Index + +long + EndOfInitLoopSwitch__Min + +long + EndOfInitLoopSwitch__Max + + + 13/1/2005 - 12:21:43 + 13/1/2005 - 12:28:19 + 2.0 + JR + ? + ? + 0 + 0 + + +? + ? + IsOdd + 3 + ? + +IsOdd + + +long + a + + +long + a + + + +IsOdd + + + + + + 13/1/2005 - 12:23:17 + 13/1/2005 - 12:23:17 + 2.0 + ? + ? + Python function + 415 + 7 + +? + ? + IsEven + 3 + ? + +IsEven + + +long + a + + +long + a + + + +IsEven + + + + + + 13/1/2005 - 12:23:17 + 13/1/2005 - 12:23:17 + 2.0 + ? + ? + Compute Node + 421 + 438 + +? + ? + PrintOdd + 3 + ? + +PrintOdd + + +long + a + +string + Branch + + +string + Branch + + + +Print + + + + + + 13/1/2005 - 12:23:17 + 13/1/2005 - 12:23:17 + 2.0 + ? + ? + Compute Node + 415 + 130 + +? + ? + PrintEven + 3 + ? + +PrintEven + + +long + a + +string + Branch + + +string + Branch + + + +Print_1 + + + + + + 13/1/2005 - 12:23:17 + 13/1/2005 - 12:23:17 + 2.0 + ? + ? + Compute Node + 423 + 289 + +? + ? + EmptyNode + 3 + ? + +EmptyNode + + +long + a + +string + Branch + + +long + a + +string + Branch + + + +EmptyNode + + + + + 13/1/2005 - 12:23:17 + 13/1/2005 - 12:23:17 + 2.0 + ? + ? + Compute Node + 652 + 110 + +? + ? + Default + 3 + ? + +Default + + +long + a + +string + Branch + + +long + a + +string + Branch + + + +Default + + + + + 13/1/2005 - 12:23:17 + 13/1/2005 - 12:23:17 + 2.0 + ? + ? + Compute Node + 421 + 592 + +? + ? + InitLoopSwitch + 4 + EndOfInitLoopSwitch + +InitLoopSwitch + + +long + Index + +long + Min + +long + Max + + +long + Index + +long + Min + +long + Max + + + +InitLoop + + + + +MoreLoop + + + + = Min : ]]> + + + + + +NextLoop + + + + 13/1/2005 - 12:23:17 + 13/1/2005 - 12:23:17 + 2.0 + ? + ? + Compute Node + 10 + 129 + +? + ? + EndOfInitLoopSwitch + 5 + InitLoopSwitch + +EndOfInitLoopSwitch + + +long + Index + +long + Min + +long + Max + + +long + Index + +long + Min + +long + Max + + + +EndOfInitLoopSwitch + + + + + 13/1/2005 - 12:23:17 + 13/1/2005 - 12:23:17 + 2.0 + ? + ? + Compute Node + 1074 + 194 + +? + ? + Switch + 6 + EndOfSwitch + +Switch + + +long + a + + +long + Odd + +int + Even + +int + a + +string + Branch + +boolean + default + + + +Switch + + + + + + + + + + + + 13/1/2005 - 12:23:17 + 13/1/2005 - 12:23:17 + 2.0 + ? + ? + Compute Node + 190 + 129 + +? + ? + EndOfSwitch + 7 + Switch + +EndOfSwitch + + +long + a + +string + Branch + + +long + a + + + +EndOfSwitch + + + + + 13/1/2005 - 12:23:17 + 13/1/2005 - 12:23:17 + 2.0 + ? + ? + Compute Node + 882 + 194 + + +IsOdd + a + EmptyNode + a + + +646 + 78 + +IsEven + a + EndOfSwitch + a + + +PrintOdd + Branch + EmptyNode + Branch + + +PrintEven + Branch + EndOfSwitch + Branch + + +EmptyNode + a + EndOfSwitch + a + + +EmptyNode + Branch + EndOfSwitch + Branch + + +Default + a + EndOfSwitch + a + + +Default + Branch + EndOfSwitch + Branch + + +InitLoopSwitch + DoLoop + EndOfInitLoopSwitch + DoLoop + + +InitLoopSwitch + Index + Switch + a + + +InitLoopSwitch + Min + EndOfInitLoopSwitch + Min + + +InitLoopSwitch + Max + EndOfInitLoopSwitch + Max + + +EndOfInitLoopSwitch + DoLoop + InitLoopSwitch + DoLoop + + +Switch + Odd + IsOdd + Gate + + +401 + 101 + +401 + 160 + +Switch + Odd + PrintOdd + Gate + + +401 + 245 + +401 + 159 + +Switch + Even + IsEven + Gate + + +392 + 533 + +392 + 182 + +Switch + Even + PrintEven + Gate + + +392 + 403 + +392 + 181 + +Switch + a + IsOdd + a + + +382 + 78 + +382 + 199 + +Switch + a + IsEven + a + + +381 + 509 + +382 + 200 + +Switch + a + PrintOdd + a + + +Switch + a + PrintEven + a + + +381 + 361 + +382 + 200 + +Switch + a + Default + a + + +382 + 663 + +382 + 199 + +Switch + Branch + PrintOdd + Branch + + +Switch + Branch + PrintEven + Branch + + +369 + 381 + +369 + 219 + +Switch + Branch + Default + Branch + + +370 + 683 + +370 + 220 + +Switch + default + Default + Gate + + +363 + 707 + +362 + 239 + +EndOfSwitch + a + EndOfInitLoopSwitch + Index + + + +GraphSwitchCheckDefault1 + InitLoopSwitch__Index + InitLoopSwitch + Index + +3 + 0 + + +GraphSwitchCheckDefault1 + InitLoopSwitch__Min + InitLoopSwitch + Min + +3 + -5 + + +GraphSwitchCheckDefault1 + InitLoopSwitch__Max + InitLoopSwitch + Max + +3 + 10 + diff --git a/examples/GraphSwitchCheckDefault2.py b/examples/GraphSwitchCheckDefault2.py new file mode 100644 index 0000000..e26b64a --- /dev/null +++ b/examples/GraphSwitchCheckDefault2.py @@ -0,0 +1,334 @@ + +# Generated python file of Graph GraphSwitchCheckDefault1 + +from SuperV import * + +# Graph creation of GraphSwitchCheckDefault1 +def DefGraphSwitchCheckDefault1() : + GraphSwitchCheckDefault1 = Graph( 'GraphSwitchCheckDefault1' ) + GraphSwitchCheckDefault1.SetName( 'GraphSwitchCheckDefault1' ) + GraphSwitchCheckDefault1.SetAuthor( 'JR' ) + GraphSwitchCheckDefault1.SetComment( '' ) + GraphSwitchCheckDefault1.Coords( 0 , 0 ) + + # Creation of Factory Nodes + + # Creation of InLine Nodes + PyIsOdd = [] + PyIsOdd.append( 'from time import * ' ) + PyIsOdd.append( 'def IsOdd(a) : ' ) + PyIsOdd.append( ' print a,"IsOdd (GraphSwitch)" ' ) + PyIsOdd.append( ' sleep( 1 ) ' ) + PyIsOdd.append( ' return a ' ) + IsOdd = GraphSwitchCheckDefault1.INode( 'IsOdd' , PyIsOdd ) + IsOdd.SetName( 'IsOdd' ) + IsOdd.SetAuthor( '' ) + IsOdd.SetComment( 'Python function' ) + IsOdd.Coords( 415 , 7 ) + IIsOdda = IsOdd.InPort( 'a' , 'long' ) + IIsOddGate = IsOdd.GetInPort( 'Gate' ) + OIsOdda = IsOdd.OutPort( 'a' , 'long' ) + OIsOddGate = IsOdd.GetOutPort( 'Gate' ) + + PyIsEven = [] + PyIsEven.append( 'from time import * ' ) + PyIsEven.append( 'def IsEven(a) : ' ) + PyIsEven.append( ' print a,"IsEven (GraphSwitch)" ' ) + PyIsEven.append( ' sleep( 1 ) ' ) + PyIsEven.append( ' return a ' ) + IsEven = GraphSwitchCheckDefault1.INode( 'IsEven' , PyIsEven ) + IsEven.SetName( 'IsEven' ) + IsEven.SetAuthor( '' ) + IsEven.SetComment( 'Compute Node' ) + IsEven.Coords( 421 , 438 ) + IIsEvena = IsEven.InPort( 'a' , 'long' ) + IIsEvenGate = IsEven.GetInPort( 'Gate' ) + OIsEvena = IsEven.OutPort( 'a' , 'long' ) + OIsEvenGate = IsEven.GetOutPort( 'Gate' ) + + PyPrintOdd = [] + PyPrintOdd.append( 'from time import * ' ) + PyPrintOdd.append( 'def Print(a,Branch) : ' ) + PyPrintOdd.append( ' print "Print ",a,Branch ' ) + PyPrintOdd.append( ' sleep(1) ' ) + PyPrintOdd.append( ' return Branch ' ) + PrintOdd = GraphSwitchCheckDefault1.INode( 'Print' , PyPrintOdd ) + PrintOdd.SetName( 'PrintOdd' ) + PrintOdd.SetAuthor( '' ) + PrintOdd.SetComment( 'Compute Node' ) + PrintOdd.Coords( 415 , 130 ) + IPrintOdda = PrintOdd.InPort( 'a' , 'long' ) + IPrintOddBranch = PrintOdd.InPort( 'Branch' , 'string' ) + IPrintOddGate = PrintOdd.GetInPort( 'Gate' ) + OPrintOddBranch = PrintOdd.OutPort( 'Branch' , 'string' ) + OPrintOddGate = PrintOdd.GetOutPort( 'Gate' ) + + PyPrintEven = [] + PyPrintEven.append( 'from time import * ' ) + PyPrintEven.append( 'def Print_1(a,Branch) : ' ) + PyPrintEven.append( ' print "Print ",a,Branch ' ) + PyPrintEven.append( ' sleep(1) ' ) + PyPrintEven.append( ' return Branch ' ) + PrintEven = GraphSwitchCheckDefault1.INode( 'Print_1' , PyPrintEven ) + PrintEven.SetName( 'PrintEven' ) + PrintEven.SetAuthor( '' ) + PrintEven.SetComment( 'Compute Node' ) + PrintEven.Coords( 423 , 289 ) + IPrintEvena = PrintEven.InPort( 'a' , 'long' ) + IPrintEvenBranch = PrintEven.InPort( 'Branch' , 'string' ) + IPrintEvenGate = PrintEven.GetInPort( 'Gate' ) + OPrintEvenBranch = PrintEven.OutPort( 'Branch' , 'string' ) + OPrintEvenGate = PrintEven.GetOutPort( 'Gate' ) + + PyEmptyNode = [] + PyEmptyNode.append( 'from time import * ' ) + PyEmptyNode.append( 'def EmptyNode(a,Branch) : ' ) + PyEmptyNode.append( ' sleep(1) ' ) + PyEmptyNode.append( ' return a,Branch ' ) + EmptyNode = GraphSwitchCheckDefault1.INode( 'EmptyNode' , PyEmptyNode ) + EmptyNode.SetName( 'EmptyNode' ) + EmptyNode.SetAuthor( '' ) + EmptyNode.SetComment( 'Compute Node' ) + EmptyNode.Coords( 652 , 110 ) + IEmptyNodea = EmptyNode.InPort( 'a' , 'long' ) + IEmptyNodeBranch = EmptyNode.InPort( 'Branch' , 'string' ) + IEmptyNodeGate = EmptyNode.GetInPort( 'Gate' ) + OEmptyNodea = EmptyNode.OutPort( 'a' , 'long' ) + OEmptyNodeBranch = EmptyNode.OutPort( 'Branch' , 'string' ) + OEmptyNodeGate = EmptyNode.GetOutPort( 'Gate' ) + + PyDefault = [] + PyDefault.append( 'from time import * ' ) + PyDefault.append( 'def Default(a,Branch) : ' ) + PyDefault.append( ' sleep(1) ' ) + PyDefault.append( ' return a,Branch ' ) + Default = GraphSwitchCheckDefault1.INode( 'Default' , PyDefault ) + Default.SetName( 'Default' ) + Default.SetAuthor( '' ) + Default.SetComment( 'Compute Node' ) + Default.Coords( 421 , 592 ) + IDefaulta = Default.InPort( 'a' , 'long' ) + IDefaultBranch = Default.InPort( 'Branch' , 'string' ) + IDefaultGate = Default.GetInPort( 'Gate' ) + ODefaulta = Default.OutPort( 'a' , 'long' ) + ODefaultBranch = Default.OutPort( 'Branch' , 'string' ) + ODefaultGate = Default.GetOutPort( 'Gate' ) + + PyPuta = [] + PyPuta.append( 'from time import * ' ) + PyPuta.append( 'def Puta(a) : ' ) + PyPuta.append( ' sleep(1) ' ) + PyPuta.append( ' return a ' ) + Puta = GraphSwitchCheckDefault1.INode( 'Puta' , PyPuta ) + Puta.SetName( 'Puta' ) + Puta.SetAuthor( '' ) + Puta.SetComment( 'Compute Node' ) + Puta.Coords( 658 , 472 ) + IPutaa = Puta.InPort( 'a' , 'long' ) + IPutaGate = Puta.GetInPort( 'Gate' ) + OPutaa = Puta.OutPort( 'a' , 'long' ) + OPutaGate = Puta.GetOutPort( 'Gate' ) + + PyPutBranch = [] + PyPutBranch.append( 'from time import * ' ) + PyPutBranch.append( 'def PutBranch(Branch) : ' ) + PyPutBranch.append( ' sleep(1) ' ) + PyPutBranch.append( ' return Branch ' ) + PutBranch = GraphSwitchCheckDefault1.INode( 'PutBranch' , PyPutBranch ) + PutBranch.SetName( 'PutBranch' ) + PutBranch.SetAuthor( '' ) + PutBranch.SetComment( 'Compute Node' ) + PutBranch.Coords( 662 , 613 ) + IPutBranchBranch = PutBranch.InPort( 'Branch' , 'string' ) + IPutBranchGate = PutBranch.GetInPort( 'Gate' ) + OPutBranchBranch = PutBranch.OutPort( 'Branch' , 'string' ) + OPutBranchGate = PutBranch.GetOutPort( 'Gate' ) + + # Creation of Loop Nodes + PyInitLoopSwitch = [] + PyInitLoopSwitch.append( 'def InitLoop(Index,Min,Max) : ' ) + PyInitLoopSwitch.append( ' Index = Max ' ) + PyInitLoopSwitch.append( ' return Index,Min,Max ' ) + PyMoreInitLoopSwitch = [] + PyMoreInitLoopSwitch.append( 'from time import * ' ) + PyMoreInitLoopSwitch.append( 'def MoreLoop(Index,Min,Max) : ' ) + PyMoreInitLoopSwitch.append( ' sleep(1) ' ) + PyMoreInitLoopSwitch.append( ' if Index >= Min : ' ) + PyMoreInitLoopSwitch.append( ' DoLoop = 1 ' ) + PyMoreInitLoopSwitch.append( ' else : ' ) + PyMoreInitLoopSwitch.append( ' DoLoop = 0 ' ) + PyMoreInitLoopSwitch.append( ' return DoLoop,Index,Min,Max ' ) + PyNextInitLoopSwitch = [] + PyNextInitLoopSwitch.append( 'def NextLoop(Index,Min,Max) : ' ) + PyNextInitLoopSwitch.append( ' Index = Index - 1 ' ) + PyNextInitLoopSwitch.append( ' return Index,Min,Max ' ) + InitLoopSwitch,EndOfInitLoopSwitch = GraphSwitchCheckDefault1.LNode( 'InitLoop' , PyInitLoopSwitch , 'MoreLoop' , PyMoreInitLoopSwitch , 'NextLoop' , PyNextInitLoopSwitch ) + EndOfInitLoopSwitch.SetName( 'EndOfInitLoopSwitch' ) + EndOfInitLoopSwitch.SetAuthor( '' ) + EndOfInitLoopSwitch.SetComment( 'Compute Node' ) + EndOfInitLoopSwitch.Coords( 1074 , 194 ) + PyEndOfInitLoopSwitch = [] + PyEndOfInitLoopSwitch.append( 'from time import * ' ) + PyEndOfInitLoopSwitch.append( 'def EndOfInitLoopSwitch(DoLoop,Index,Min,Max) : ' ) + PyEndOfInitLoopSwitch.append( ' sleep(1) ' ) + PyEndOfInitLoopSwitch.append( ' return DoLoop,Index,Min,Max ' ) + EndOfInitLoopSwitch.SetPyFunction( 'EndOfInitLoopSwitch' , PyEndOfInitLoopSwitch ) + IInitLoopSwitchDoLoop = InitLoopSwitch.GetInPort( 'DoLoop' ) + IInitLoopSwitchIndex = InitLoopSwitch.InPort( 'Index' , 'long' ) + IInitLoopSwitchMin = InitLoopSwitch.InPort( 'Min' , 'long' ) + IInitLoopSwitchMax = InitLoopSwitch.InPort( 'Max' , 'long' ) + IInitLoopSwitchGate = InitLoopSwitch.GetInPort( 'Gate' ) + OInitLoopSwitchDoLoop = InitLoopSwitch.GetOutPort( 'DoLoop' ) + OInitLoopSwitchIndex = InitLoopSwitch.GetOutPort( 'Index' ) + OInitLoopSwitchMin = InitLoopSwitch.GetOutPort( 'Min' ) + OInitLoopSwitchMax = InitLoopSwitch.GetOutPort( 'Max' ) + IEndOfInitLoopSwitchDoLoop = EndOfInitLoopSwitch.GetInPort( 'DoLoop' ) + IEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetInPort( 'Index' ) + IEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetInPort( 'Min' ) + IEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetInPort( 'Max' ) + IEndOfInitLoopSwitchGate = EndOfInitLoopSwitch.GetInPort( 'Gate' ) + OEndOfInitLoopSwitchDoLoop = EndOfInitLoopSwitch.GetOutPort( 'DoLoop' ) + OEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetOutPort( 'Index' ) + OEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetOutPort( 'Min' ) + OEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetOutPort( 'Max' ) + OEndOfInitLoopSwitchGate = EndOfInitLoopSwitch.GetOutPort( 'Gate' ) + InitLoopSwitch.SetName( 'InitLoopSwitch' ) + InitLoopSwitch.SetAuthor( '' ) + InitLoopSwitch.SetComment( 'Compute Node' ) + InitLoopSwitch.Coords( 10 , 129 ) + + # Creation of Switch Nodes + PySwitch = [] + PySwitch.append( 'from time import * ' ) + PySwitch.append( 'def Switch(a) : ' ) + PySwitch.append( ' sleep(1) ' ) + PySwitch.append( ' Branch = "Negative or null" ' ) + PySwitch.append( ' if a <= 0 : ' ) + PySwitch.append( ' return 0,0,a,Branch,1 ' ) + PySwitch.append( ' if ( a & 1 ) == 0 : ' ) + PySwitch.append( ' Branch = "Even" ' ) + PySwitch.append( ' else : ' ) + PySwitch.append( ' Branch = "Odd" ' ) + PySwitch.append( ' return a & 1,1-(a&1),a,Branch,0 ' ) + Switch,EndOfSwitch = GraphSwitchCheckDefault1.SNode( 'Switch' , PySwitch ) + EndOfSwitch.SetName( 'EndOfSwitch' ) + EndOfSwitch.SetAuthor( '' ) + EndOfSwitch.SetComment( 'Compute Node' ) + EndOfSwitch.Coords( 882 , 194 ) + PyEndOfSwitch = [] + PyEndOfSwitch.append( 'from time import * ' ) + PyEndOfSwitch.append( 'def EndOfSwitch(a,Branch) : ' ) + PyEndOfSwitch.append( ' sleep(1) ' ) + PyEndOfSwitch.append( ' return a ' ) + EndOfSwitch.SetPyFunction( 'EndOfSwitch' , PyEndOfSwitch ) + IEndOfSwitcha = EndOfSwitch.InPort( 'a' , 'long' ) + IEndOfSwitchBranch = EndOfSwitch.InPort( 'Branch' , 'string' ) + IEndOfSwitchDefault = EndOfSwitch.GetInPort( 'Default' ) + OEndOfSwitcha = EndOfSwitch.OutPort( 'a' , 'long' ) + OEndOfSwitchGate = EndOfSwitch.GetOutPort( 'Gate' ) + Switch.SetName( 'Switch' ) + Switch.SetAuthor( '' ) + Switch.SetComment( 'Compute Node' ) + Switch.Coords( 190 , 129 ) + ISwitcha = Switch.InPort( 'a' , 'long' ) + ISwitchGate = Switch.GetInPort( 'Gate' ) + OSwitchOdd = Switch.OutPort( 'Odd' , 'long' ) + OSwitchEven = Switch.OutPort( 'Even' , 'int' ) + OSwitcha = Switch.OutPort( 'a' , 'int' ) + OSwitchBranch = Switch.OutPort( 'Branch' , 'string' ) + OSwitchdefault = Switch.OutPort( 'default' , 'boolean' ) + OSwitchDefault = Switch.GetOutPort( 'Default' ) + + # Creation of Links + LIsOddaEmptyNodea = GraphSwitchCheckDefault1.Link( OIsOdda , IEmptyNodea ) + LIsOddaEmptyNodea.AddCoord( 1 , 646 , 78 ) + + LPrintOddBranchEmptyNodeBranch = GraphSwitchCheckDefault1.Link( OPrintOddBranch , IEmptyNodeBranch ) + + LEmptyNodeaEndOfSwitcha = GraphSwitchCheckDefault1.Link( OEmptyNodea , IEndOfSwitcha ) + + LEmptyNodeBranchEndOfSwitchBranch = GraphSwitchCheckDefault1.Link( OEmptyNodeBranch , IEndOfSwitchBranch ) + + LDefaultaEndOfSwitcha = GraphSwitchCheckDefault1.Link( ODefaulta , IEndOfSwitcha ) + + LDefaultaPutaa = GraphSwitchCheckDefault1.Link( ODefaulta , IPutaa ) + + LDefaultBranchEndOfSwitchBranch = GraphSwitchCheckDefault1.Link( ODefaultBranch , IEndOfSwitchBranch ) + + LDefaultBranchPutBranchBranch = GraphSwitchCheckDefault1.Link( ODefaultBranch , IPutBranchBranch ) + + LInitLoopSwitchIndexSwitcha = GraphSwitchCheckDefault1.Link( OInitLoopSwitchIndex , ISwitcha ) + + LInitLoopSwitchMinEndOfInitLoopSwitchMin = GraphSwitchCheckDefault1.Link( OInitLoopSwitchMin , IEndOfInitLoopSwitchMin ) + + LInitLoopSwitchMaxEndOfInitLoopSwitchMax = GraphSwitchCheckDefault1.Link( OInitLoopSwitchMax , IEndOfInitLoopSwitchMax ) + + LSwitchOddIsOddGate = GraphSwitchCheckDefault1.Link( OSwitchOdd , IIsOddGate ) + LSwitchOddIsOddGate.AddCoord( 1 , 401 , 101 ) + LSwitchOddIsOddGate.AddCoord( 2 , 401 , 160 ) + + LSwitchOddPrintOddGate = GraphSwitchCheckDefault1.Link( OSwitchOdd , IPrintOddGate ) + LSwitchOddPrintOddGate.AddCoord( 1 , 401 , 245 ) + LSwitchOddPrintOddGate.AddCoord( 2 , 401 , 159 ) + + LSwitchEvenIsEvenGate = GraphSwitchCheckDefault1.Link( OSwitchEven , IIsEvenGate ) + LSwitchEvenIsEvenGate.AddCoord( 1 , 392 , 533 ) + LSwitchEvenIsEvenGate.AddCoord( 2 , 392 , 182 ) + + LSwitchEvenPrintEvenGate = GraphSwitchCheckDefault1.Link( OSwitchEven , IPrintEvenGate ) + LSwitchEvenPrintEvenGate.AddCoord( 1 , 392 , 403 ) + LSwitchEvenPrintEvenGate.AddCoord( 2 , 392 , 181 ) + + LSwitchaIsOdda = GraphSwitchCheckDefault1.Link( OSwitcha , IIsOdda ) + LSwitchaIsOdda.AddCoord( 1 , 382 , 78 ) + LSwitchaIsOdda.AddCoord( 2 , 382 , 199 ) + + LSwitchaIsEvena = GraphSwitchCheckDefault1.Link( OSwitcha , IIsEvena ) + LSwitchaIsEvena.AddCoord( 1 , 381 , 509 ) + LSwitchaIsEvena.AddCoord( 2 , 382 , 200 ) + + LSwitchaPrintOdda = GraphSwitchCheckDefault1.Link( OSwitcha , IPrintOdda ) + + LSwitchaPrintEvena = GraphSwitchCheckDefault1.Link( OSwitcha , IPrintEvena ) + LSwitchaPrintEvena.AddCoord( 1 , 381 , 361 ) + LSwitchaPrintEvena.AddCoord( 2 , 382 , 200 ) + + LSwitchaDefaulta = GraphSwitchCheckDefault1.Link( OSwitcha , IDefaulta ) + LSwitchaDefaulta.AddCoord( 1 , 382 , 663 ) + LSwitchaDefaulta.AddCoord( 2 , 382 , 199 ) + + LSwitchBranchPrintOddBranch = GraphSwitchCheckDefault1.Link( OSwitchBranch , IPrintOddBranch ) + + LSwitchBranchPrintEvenBranch = GraphSwitchCheckDefault1.Link( OSwitchBranch , IPrintEvenBranch ) + LSwitchBranchPrintEvenBranch.AddCoord( 1 , 369 , 381 ) + LSwitchBranchPrintEvenBranch.AddCoord( 2 , 369 , 219 ) + + LSwitchBranchDefaultBranch = GraphSwitchCheckDefault1.Link( OSwitchBranch , IDefaultBranch ) + LSwitchBranchDefaultBranch.AddCoord( 1 , 370 , 683 ) + LSwitchBranchDefaultBranch.AddCoord( 2 , 370 , 220 ) + + LSwitchdefaultDefaultGate = GraphSwitchCheckDefault1.Link( OSwitchdefault , IDefaultGate ) + LSwitchdefaultDefaultGate.AddCoord( 1 , 363 , 707 ) + LSwitchdefaultDefaultGate.AddCoord( 2 , 362 , 239 ) + + LEndOfSwitchaEndOfInitLoopSwitchIndex = GraphSwitchCheckDefault1.Link( OEndOfSwitcha , IEndOfInitLoopSwitchIndex ) + + LPutaaEndOfSwitcha = GraphSwitchCheckDefault1.Link( OPutaa , IEndOfSwitcha ) + + LPutBranchBranchEndOfSwitchBranch = GraphSwitchCheckDefault1.Link( OPutBranchBranch , IEndOfSwitchBranch ) + + # Input datas + IInitLoopSwitchIndex.Input( 0 ) + IInitLoopSwitchMin.Input( -5 ) + IInitLoopSwitchMax.Input( 10 ) + + # Output Ports of the graph + #OIsEvena = IsEven.GetOutPort( 'a' ) + #OPrintEvenBranch = PrintEven.GetOutPort( 'Branch' ) + #OEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetOutPort( 'Index' ) + #OEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetOutPort( 'Min' ) + #OEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetOutPort( 'Max' ) + return GraphSwitchCheckDefault1 + + +GraphSwitchCheckDefault1 = DefGraphSwitchCheckDefault1() diff --git a/examples/GraphSwitchCheckDefault2.xml b/examples/GraphSwitchCheckDefault2.xml new file mode 100644 index 0000000..3022d34 --- /dev/null +++ b/examples/GraphSwitchCheckDefault2.xml @@ -0,0 +1,787 @@ + + + + + +? + ? + GraphSwitchCheckDefault1 + 1 + ? + +GraphSwitchCheckDefault1 + + +long + InitLoopSwitch__Index + +long + InitLoopSwitch__Min + +long + InitLoopSwitch__Max + + +long + IsEven__a + +string + PrintEven__Branch + +long + EndOfInitLoopSwitch__Index + +long + EndOfInitLoopSwitch__Min + +long + EndOfInitLoopSwitch__Max + + + 13/1/2005 - 12:21:43 + 13/1/2005 - 12:33:25 + 2.0 + JR + ? + ? + 0 + 0 + + +? + ? + IsOdd + 3 + ? + +IsOdd + + +long + a + + +long + a + + + +IsOdd + + + + + + 13/1/2005 - 12:23:17 + 13/1/2005 - 12:23:17 + 2.0 + ? + ? + Python function + 415 + 7 + +? + ? + IsEven + 3 + ? + +IsEven + + +long + a + + +long + a + + + +IsEven + + + + + + 13/1/2005 - 12:23:17 + 13/1/2005 - 12:23:17 + 2.0 + ? + ? + Compute Node + 421 + 438 + +? + ? + PrintOdd + 3 + ? + +PrintOdd + + +long + a + +string + Branch + + +string + Branch + + + +Print + + + + + + 13/1/2005 - 12:23:17 + 13/1/2005 - 12:23:17 + 2.0 + ? + ? + Compute Node + 415 + 130 + +? + ? + PrintEven + 3 + ? + +PrintEven + + +long + a + +string + Branch + + +string + Branch + + + +Print_1 + + + + + + 13/1/2005 - 12:23:17 + 13/1/2005 - 12:23:17 + 2.0 + ? + ? + Compute Node + 423 + 289 + +? + ? + EmptyNode + 3 + ? + +EmptyNode + + +long + a + +string + Branch + + +long + a + +string + Branch + + + +EmptyNode + + + + + 13/1/2005 - 12:23:17 + 13/1/2005 - 12:23:17 + 2.0 + ? + ? + Compute Node + 652 + 110 + +? + ? + Default + 3 + ? + +Default + + +long + a + +string + Branch + + +long + a + +string + Branch + + + +Default + + + + + 13/1/2005 - 12:23:17 + 13/1/2005 - 12:23:17 + 2.0 + ? + ? + Compute Node + 421 + 592 + +? + ? + InitLoopSwitch + 4 + EndOfInitLoopSwitch + +InitLoopSwitch + + +long + Index + +long + Min + +long + Max + + +long + Index + +long + Min + +long + Max + + + +InitLoop + + + + +MoreLoop + + + + = Min : ]]> + + + + + +NextLoop + + + + 13/1/2005 - 12:23:17 + 13/1/2005 - 12:23:17 + 2.0 + ? + ? + Compute Node + 10 + 129 + +? + ? + EndOfInitLoopSwitch + 5 + InitLoopSwitch + +EndOfInitLoopSwitch + + +long + Index + +long + Min + +long + Max + + +long + Index + +long + Min + +long + Max + + + +EndOfInitLoopSwitch + + + + + 13/1/2005 - 12:23:17 + 13/1/2005 - 12:23:17 + 2.0 + ? + ? + Compute Node + 1074 + 194 + +? + ? + Switch + 6 + EndOfSwitch + +Switch + + +long + a + + +long + Odd + +int + Even + +int + a + +string + Branch + +boolean + default + + + +Switch + + + + + + + + + + + + 13/1/2005 - 12:23:17 + 13/1/2005 - 12:23:17 + 2.0 + ? + ? + Compute Node + 190 + 129 + +? + ? + EndOfSwitch + 7 + Switch + +EndOfSwitch + + +long + a + +string + Branch + + +long + a + + + +EndOfSwitch + + + + + 13/1/2005 - 12:23:17 + 13/1/2005 - 12:23:17 + 2.0 + ? + ? + Compute Node + 882 + 194 + +? + ? + Puta + 3 + ? + +Puta + + +long + a + + +long + a + + + +Puta + + + + + 13/1/2005 - 12:31:48 + 13/1/2005 - 12:31:48 + 2.0 + ? + ? + Compute Node + 658 + 472 + +? + ? + PutBranch + 3 + ? + +PutBranch + + +string + Branch + + +string + Branch + + + +PutBranch + + + + + 13/1/2005 - 12:32:11 + 13/1/2005 - 12:32:11 + 2.0 + ? + ? + Compute Node + 662 + 613 + + +IsOdd + a + EmptyNode + a + + +646 + 78 + +PrintOdd + Branch + EmptyNode + Branch + + +EmptyNode + a + EndOfSwitch + a + + +EmptyNode + Branch + EndOfSwitch + Branch + + +Default + a + EndOfSwitch + a + + +Default + a + Puta + a + + +Default + Branch + EndOfSwitch + Branch + + +Default + Branch + PutBranch + Branch + + +InitLoopSwitch + DoLoop + EndOfInitLoopSwitch + DoLoop + + +InitLoopSwitch + Index + Switch + a + + +InitLoopSwitch + Min + EndOfInitLoopSwitch + Min + + +InitLoopSwitch + Max + EndOfInitLoopSwitch + Max + + +EndOfInitLoopSwitch + DoLoop + InitLoopSwitch + DoLoop + + +Switch + Odd + IsOdd + Gate + + +401 + 101 + +401 + 160 + +Switch + Odd + PrintOdd + Gate + + +401 + 245 + +401 + 159 + +Switch + Even + IsEven + Gate + + +392 + 533 + +392 + 182 + +Switch + Even + PrintEven + Gate + + +392 + 403 + +392 + 181 + +Switch + a + IsOdd + a + + +382 + 78 + +382 + 199 + +Switch + a + IsEven + a + + +381 + 509 + +382 + 200 + +Switch + a + PrintOdd + a + + +Switch + a + PrintEven + a + + +381 + 361 + +382 + 200 + +Switch + a + Default + a + + +382 + 663 + +382 + 199 + +Switch + Branch + PrintOdd + Branch + + +Switch + Branch + PrintEven + Branch + + +369 + 381 + +369 + 219 + +Switch + Branch + Default + Branch + + +370 + 683 + +370 + 220 + +Switch + default + Default + Gate + + +363 + 707 + +362 + 239 + +EndOfSwitch + a + EndOfInitLoopSwitch + Index + + +Puta + a + EndOfSwitch + a + + +PutBranch + Branch + EndOfSwitch + Branch + + + +GraphSwitchCheckDefault1 + InitLoopSwitch__Index + InitLoopSwitch + Index + +3 + 0 + + +GraphSwitchCheckDefault1 + InitLoopSwitch__Min + InitLoopSwitch + Min + +3 + -5 + + +GraphSwitchCheckDefault1 + InitLoopSwitch__Max + InitLoopSwitch + Max + +3 + 10 + diff --git a/examples/GraphSwitchCrash.xml b/examples/GraphSwitchCrash.xml index 88341e0..50c0b25 100755 --- a/examples/GraphSwitchCrash.xml +++ b/examples/GraphSwitchCrash.xml @@ -491,7 +491,7 @@ EndOfInitLoopSwitch DoLoop InitLoopSwitch - InitLoop + DoLoop Switch @@ -569,7 +569,7 @@ EndOfInitLoop DoLoop InitLoop - InitLoop + DoLoop Switch_1 diff --git a/examples/GraphSwitchErrExec.py b/examples/GraphSwitchErrExec.py new file mode 100644 index 0000000..4706bb0 --- /dev/null +++ b/examples/GraphSwitchErrExec.py @@ -0,0 +1,164 @@ + +# Generated python file of Graph GraphSwitch_1 + +from SuperV import * + +# Graph creation of GraphSwitch_1 +def DefGraphSwitch_1() : + GraphSwitch_1 = Graph( 'GraphSwitch_1' ) + GraphSwitch_1.SetName( 'GraphSwitch_1' ) + GraphSwitch_1.SetAuthor( '' ) + GraphSwitch_1.SetComment( '' ) + GraphSwitch_1.Coords( 0 , 0 ) + + # Creation of Factory Nodes + + # Creation of InLine Nodes + PyIsOdd = [] + PyIsOdd.append( 'from time import * ' ) + PyIsOdd.append( 'def IsOdd(a) : ' ) + PyIsOdd.append( ' print a,"IsOdd (GraphSwitch)" ' ) + PyIsOdd.append( ' sleep( 1 ) ' ) + PyIsOdd.append( ' return a ' ) + IsOdd = GraphSwitch_1.INode( 'IsOdd' , PyIsOdd ) + IsOdd.SetName( 'IsOdd' ) + IsOdd.SetAuthor( '' ) + IsOdd.SetComment( 'Python function' ) + IsOdd.Coords( 388 , 50 ) + IIsOdda = IsOdd.InPort( 'a' , 'long' ) + IIsOddGate = IsOdd.GetInPort( 'Gate' ) + OIsOdda = IsOdd.OutPort( 'a' , 'long' ) + OIsOddGate = IsOdd.GetOutPort( 'Gate' ) + + PyIsEven = [] + PyIsEven.append( 'from time import * ' ) + PyIsEven.append( 'def IsEven(a) : ' ) + PyIsEven.append( ' print a,"IsEven (GraphSwitch)" ' ) + PyIsEven.append( ' sleep( 1 ) ' ) + PyIsEven.append( ' return a ' ) + IsEven = GraphSwitch_1.INode( 'IsEven' , PyIsEven ) + IsEven.SetName( 'IsEven' ) + IsEven.SetAuthor( '' ) + IsEven.SetComment( 'Compute Node' ) + IsEven.Coords( 397 , 279 ) + IIsEvena = IsEven.InPort( 'a' , 'long' ) + IIsEvenGate = IsEven.GetInPort( 'Gate' ) + OIsEvena = IsEven.OutPort( 'a' , 'long' ) + OIsEvenGate = IsEven.GetOutPort( 'Gate' ) + + # Creation of Loop Nodes + PyInitLoopSwitch = [] + PyInitLoopSwitch.append( 'def InitLoop(Index,Min,Max) : ' ) + PyInitLoopSwitch.append( ' Index = Max ' ) + PyInitLoopSwitch.append( ' return Index,Min,Max ' ) + PyMoreInitLoopSwitch = [] + PyMoreInitLoopSwitch.append( 'def MoreLoop(Index,Min,Max) : ' ) + PyMoreInitLoopSwitch.append( ' if Index >= Min : ' ) + PyMoreInitLoopSwitch.append( ' DoLoop = 1 ' ) + PyMoreInitLoopSwitch.append( ' else : ' ) + PyMoreInitLoopSwitch.append( ' DoLoop = 0 ' ) + PyMoreInitLoopSwitch.append( ' return DoLoop,Index,Min,Max ' ) + PyNextInitLoopSwitch = [] + PyNextInitLoopSwitch.append( 'def NextLoop(Index,Min,Max) : ' ) + PyNextInitLoopSwitch.append( ' Index = Index - 1 ' ) + PyNextInitLoopSwitch.append( ' return Index,Min,Max ' ) + InitLoopSwitch,EndOfInitLoopSwitch = GraphSwitch_1.LNode( 'InitLoop' , PyInitLoopSwitch , 'MoreLoop' , PyMoreInitLoopSwitch , 'NextLoop' , PyNextInitLoopSwitch ) + EndOfInitLoopSwitch.SetName( 'EndOfInitLoopSwitch' ) + EndOfInitLoopSwitch.SetAuthor( '' ) + EndOfInitLoopSwitch.SetComment( 'Compute Node' ) + EndOfInitLoopSwitch.Coords( 766 , 127 ) + PyEndOfInitLoopSwitch = [] + EndOfInitLoopSwitch.SetPyFunction( '' , PyEndOfInitLoopSwitch ) + IInitLoopSwitchDoLoop = InitLoopSwitch.GetInPort( 'DoLoop' ) + IInitLoopSwitchIndex = InitLoopSwitch.InPort( 'Index' , 'long' ) + IInitLoopSwitchMin = InitLoopSwitch.InPort( 'Min' , 'long' ) + IInitLoopSwitchMax = InitLoopSwitch.InPort( 'Max' , 'long' ) + IInitLoopSwitchGate = InitLoopSwitch.GetInPort( 'Gate' ) + OInitLoopSwitchDoLoop = InitLoopSwitch.GetOutPort( 'DoLoop' ) + OInitLoopSwitchIndex = InitLoopSwitch.GetOutPort( 'Index' ) + OInitLoopSwitchMin = InitLoopSwitch.GetOutPort( 'Min' ) + OInitLoopSwitchMax = InitLoopSwitch.GetOutPort( 'Max' ) + IEndOfInitLoopSwitchDoLoop = EndOfInitLoopSwitch.GetInPort( 'DoLoop' ) + IEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetInPort( 'Index' ) + IEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetInPort( 'Min' ) + IEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetInPort( 'Max' ) + IEndOfInitLoopSwitchGate = EndOfInitLoopSwitch.GetInPort( 'Gate' ) + OEndOfInitLoopSwitchDoLoop = EndOfInitLoopSwitch.GetOutPort( 'DoLoop' ) + OEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetOutPort( 'Index' ) + OEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetOutPort( 'Min' ) + OEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetOutPort( 'Max' ) + OEndOfInitLoopSwitchGate = EndOfInitLoopSwitch.GetOutPort( 'Gate' ) + InitLoopSwitch.SetName( 'InitLoopSwitch' ) + InitLoopSwitch.SetAuthor( '' ) + InitLoopSwitch.SetComment( 'Compute Node' ) + InitLoopSwitch.Coords( 10 , 129 ) + + # Creation of Switch Nodes + PySwitch = [] + PySwitch.append( 'from time import * ' ) + PySwitch.append( 'def Switch(a) : ' ) + PySwitch.append( ' if a == 0 : ' ) + PySwitch.append( ' return 0,0,a ' ) + PySwitch.append( ' if a < 0 : ' ) + PySwitch.append( ' return 1,1,a ' ) + PySwitch.append( ' if ( a & 1 ) == 0 : ' ) + PySwitch.append( ' sleep(1) ' ) + PySwitch.append( ' return a & 1,1-(a&1),a ' ) + Switch,EndOfSwitch = GraphSwitch_1.SNode( 'Switch' , PySwitch ) + EndOfSwitch.SetName( 'EndOfSwitch' ) + EndOfSwitch.SetAuthor( '' ) + EndOfSwitch.SetComment( 'Compute Node' ) + EndOfSwitch.Coords( 580 , 147 ) + PyEndOfSwitch = [] + EndOfSwitch.SetPyFunction( 'EndSwitch_1' , PyEndOfSwitch ) + IEndOfSwitcha = EndOfSwitch.InPort( 'a' , 'long' ) + IEndOfSwitchDefault = EndOfSwitch.GetInPort( 'Default' ) + OEndOfSwitcha = EndOfSwitch.OutPort( 'a' , 'long' ) + OEndOfSwitchGate = EndOfSwitch.GetOutPort( 'Gate' ) + Switch.SetName( 'Switch' ) + Switch.SetAuthor( '' ) + Switch.SetComment( 'Compute Node' ) + Switch.Coords( 195 , 129 ) + ISwitcha = Switch.InPort( 'a' , 'long' ) + ISwitchGate = Switch.GetInPort( 'Gate' ) + OSwitchOdd = Switch.OutPort( 'Odd' , 'long' ) + OSwitchEven = Switch.OutPort( 'Even' , 'int' ) + OSwitcha = Switch.OutPort( 'a' , 'int' ) + OSwitchDefault = Switch.GetOutPort( 'Default' ) + + # Creation of Links + LIsOddaEndOfSwitcha = GraphSwitch_1.Link( OIsOdda , IEndOfSwitcha ) + + LInitLoopSwitchIndexSwitcha = GraphSwitch_1.Link( OInitLoopSwitchIndex , ISwitcha ) + + LInitLoopSwitchMinEndOfInitLoopSwitchMin = GraphSwitch_1.Link( OInitLoopSwitchMin , IEndOfInitLoopSwitchMin ) + + LInitLoopSwitchMaxEndOfInitLoopSwitchMax = GraphSwitch_1.Link( OInitLoopSwitchMax , IEndOfInitLoopSwitchMax ) + + LIsEvenaEndOfSwitcha = GraphSwitch_1.Link( OIsEvena , IEndOfSwitcha ) + + LSwitchOddIsOddGate = GraphSwitch_1.Link( OSwitchOdd , IIsOddGate ) + + LSwitchEvenIsEvenGate = GraphSwitch_1.Link( OSwitchEven , IIsEvenGate ) + + LSwitchaIsOdda = GraphSwitch_1.Link( OSwitcha , IIsOdda ) + + LSwitchaIsEvena = GraphSwitch_1.Link( OSwitcha , IIsEvena ) + + LSwitchDefaultEndOfSwitchDefault = GraphSwitch_1.Link( OSwitchDefault , IEndOfSwitchDefault ) + + LEndOfSwitchaEndOfInitLoopSwitchIndex = GraphSwitch_1.Link( OEndOfSwitcha , IEndOfInitLoopSwitchIndex ) + + # Input datas + IInitLoopSwitchIndex.Input( 0 ) + IInitLoopSwitchMin.Input( -5 ) + IInitLoopSwitchMax.Input( 10 ) + + # Output Ports of the graph + #OEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetOutPort( 'Index' ) + #OEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetOutPort( 'Min' ) + #OEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetOutPort( 'Max' ) + return GraphSwitch_1 + + +GraphSwitch_1 = DefGraphSwitch_1() diff --git a/examples/GraphSwitchErrExec.xml b/examples/GraphSwitchErrExec.xml new file mode 100644 index 0000000..e588ff6 --- /dev/null +++ b/examples/GraphSwitchErrExec.xml @@ -0,0 +1,385 @@ + + + + + +? + ? + GraphSwitch_1 + 1 + ? + +GraphSwitch_1 + + +long + InitLoopSwitch__Index + +long + InitLoopSwitch__Min + +long + InitLoopSwitch__Max + + +long + EndOfInitLoopSwitch__Index + +long + EndOfInitLoopSwitch__Min + +long + EndOfInitLoopSwitch__Max + + + 1/10/2003 - 17:23:54 + 12/1/2005 - 16:10:58 + 1.05 + ? + ? + ? + 0 + 0 + + +? + ? + IsOdd + 3 + ? + +IsOdd + + +long + a + + +long + a + + + +IsOdd + + + + + + 12/1/2005 - 16:10:58 + 12/1/2005 - 16:10:58 + 1.05 + ? + ? + Python function + 388 + 50 + +? + ? + InitLoopSwitch + 4 + EndOfInitLoopSwitch + +InitLoopSwitch + + +long + Index + +long + Min + +long + Max + + +long + Index + +long + Min + +long + Max + + + +InitLoop + + + + +MoreLoop + + = Min : ]]> + + + + + +NextLoop + + + + 12/1/2005 - 16:10:58 + 12/1/2005 - 16:10:58 + 1.05 + ? + ? + Compute Node + 10 + 129 + +? + ? + EndOfInitLoopSwitch + 5 + InitLoopSwitch + +EndOfInitLoopSwitch + + +long + Index + +long + Min + +long + Max + + +long + Index + +long + Min + +long + Max + + + +? + + 12/1/2005 - 16:10:58 + 12/1/2005 - 16:10:58 + 1.05 + ? + ? + Compute Node + 766 + 127 + +? + ? + IsEven + 3 + ? + +IsEven + + +long + a + + +long + a + + + +IsEven + + + + + + 12/1/2005 - 16:10:58 + 12/1/2005 - 16:10:58 + 2.0 + ? + ? + Compute Node + 397 + 279 + +? + ? + Switch + 6 + EndOfSwitch + +Switch + + +long + a + + +long + Odd + +int + Even + +int + a + + + +Switch + + + + + + + + + + 12/1/2005 - 16:10:58 + 12/1/2005 - 16:10:58 + 2.0 + ? + ? + Compute Node + 195 + 129 + +? + ? + EndOfSwitch + 7 + Switch + +EndOfSwitch + + +long + a + + +long + a + + + +EndSwitch_1 + + 12/1/2005 - 16:10:58 + 12/1/2005 - 16:10:58 + 2.0 + ? + ? + Compute Node + 580 + 147 + + +IsOdd + a + EndOfSwitch + a + + +InitLoopSwitch + DoLoop + EndOfInitLoopSwitch + DoLoop + + +InitLoopSwitch + Index + Switch + a + + +InitLoopSwitch + Min + EndOfInitLoopSwitch + Min + + +InitLoopSwitch + Max + EndOfInitLoopSwitch + Max + + +EndOfInitLoopSwitch + DoLoop + InitLoopSwitch + DoLoop + + +IsEven + a + EndOfSwitch + a + + +Switch + Odd + IsOdd + Gate + + +Switch + Even + IsEven + Gate + + +Switch + a + IsOdd + a + + +Switch + a + IsEven + a + + +Switch + Default + EndOfSwitch + Default + + +EndOfSwitch + a + EndOfInitLoopSwitch + Index + + + +GraphSwitch_1 + InitLoopSwitch__Index + InitLoopSwitch + Index + +3 + 0 + + +GraphSwitch_1 + InitLoopSwitch__Min + InitLoopSwitch + Min + +3 + -5 + + +GraphSwitch_1 + InitLoopSwitch__Max + InitLoopSwitch + Max + +3 + 10 + diff --git a/examples/GraphSwitchOutput.py b/examples/GraphSwitchOutput.py new file mode 100644 index 0000000..2c9c777 --- /dev/null +++ b/examples/GraphSwitchOutput.py @@ -0,0 +1,211 @@ + +# Generated python file of Graph GraphSwitch_1_1 + +from SuperV import * + +# Graph creation of GraphSwitch_1_1 +def DefGraphSwitch_1_1() : + GraphSwitch_1_1 = Graph( 'GraphSwitch_1_1' ) + GraphSwitch_1_1.SetName( 'GraphSwitch_1_1' ) + GraphSwitch_1_1.SetAuthor( '' ) + GraphSwitch_1_1.SetComment( '' ) + GraphSwitch_1_1.Coords( 0 , 0 ) + + # Creation of Factory Nodes + + # Creation of InLine Nodes + PyIsOdd = [] + PyIsOdd.append( 'from time import * ' ) + PyIsOdd.append( 'def IsOdd(a) : ' ) + PyIsOdd.append( ' print a,"IsOdd (GraphSwitch)" ' ) + PyIsOdd.append( ' sleep( 1 ) ' ) + PyIsOdd.append( ' return a ' ) + IsOdd = GraphSwitch_1_1.INode( 'IsOdd' , PyIsOdd ) + IsOdd.SetName( 'IsOdd' ) + IsOdd.SetAuthor( '' ) + IsOdd.SetComment( 'Python function' ) + IsOdd.Coords( 388 , 50 ) + IIsOdda = IsOdd.InPort( 'a' , 'long' ) + IIsOddGate = IsOdd.GetInPort( 'Gate' ) + OIsOdda = IsOdd.OutPort( 'a' , 'long' ) + OIsOddGate = IsOdd.GetOutPort( 'Gate' ) + + PyIsEven = [] + PyIsEven.append( 'from time import * ' ) + PyIsEven.append( 'def IsEven(a) : ' ) + PyIsEven.append( ' print a,"IsEven (GraphSwitch)" ' ) + PyIsEven.append( ' sleep( 1 ) ' ) + PyIsEven.append( ' return a ' ) + IsEven = GraphSwitch_1_1.INode( 'IsEven' , PyIsEven ) + IsEven.SetName( 'IsEven' ) + IsEven.SetAuthor( '' ) + IsEven.SetComment( 'Compute Node' ) + IsEven.Coords( 395 , 334 ) + IIsEvena = IsEven.InPort( 'a' , 'long' ) + IIsEvenGate = IsEven.GetInPort( 'Gate' ) + OIsEvena = IsEven.OutPort( 'a' , 'long' ) + OIsEvenGate = IsEven.GetOutPort( 'Gate' ) + + PyPrint = [] + PyPrint.append( 'def Print(a,Branch) : ' ) + PyPrint.append( ' print "Print ",Branch ' ) + PyPrint.append( ' return a,Branch ' ) + Print = GraphSwitch_1_1.INode( 'Print' , PyPrint ) + Print.SetName( 'Print' ) + Print.SetAuthor( '' ) + Print.SetComment( 'Compute Node' ) + Print.Coords( 639 , 63 ) + IPrinta = Print.InPort( 'a' , 'long' ) + IPrintBranch = Print.InPort( 'Branch' , 'string' ) + IPrintGate = Print.GetInPort( 'Gate' ) + OPrinta = Print.OutPort( 'a' , 'long' ) + OPrintBranch = Print.OutPort( 'Branch' , 'string' ) + OPrintGate = Print.GetOutPort( 'Gate' ) + + PyPrint_1 = [] + PyPrint_1.append( 'def Print_1(a,Branch) : ' ) + PyPrint_1.append( ' print "Print ",Branch ' ) + PyPrint_1.append( ' return a,Branch ' ) + Print_1 = GraphSwitch_1_1.INode( 'Print_1' , PyPrint_1 ) + Print_1.SetName( 'Print_1' ) + Print_1.SetAuthor( '' ) + Print_1.SetComment( 'Compute Node' ) + Print_1.Coords( 639 , 263 ) + IPrint_1a = Print_1.InPort( 'a' , 'long' ) + IPrint_1Branch = Print_1.InPort( 'Branch' , 'string' ) + IPrint_1Gate = Print_1.GetInPort( 'Gate' ) + OPrint_1a = Print_1.OutPort( 'a' , 'long' ) + OPrint_1Branch = Print_1.OutPort( 'Branch' , 'string' ) + OPrint_1Gate = Print_1.GetOutPort( 'Gate' ) + + # Creation of Loop Nodes + PyInitLoopSwitch = [] + PyInitLoopSwitch.append( 'def InitLoop(Index,Min,Max) : ' ) + PyInitLoopSwitch.append( ' Index = Max ' ) + PyInitLoopSwitch.append( ' return Index,Min,Max ' ) + PyMoreInitLoopSwitch = [] + PyMoreInitLoopSwitch.append( 'def MoreLoop(Index,Min,Max) : ' ) + PyMoreInitLoopSwitch.append( ' if Index >= Min : ' ) + PyMoreInitLoopSwitch.append( ' DoLoop = 1 ' ) + PyMoreInitLoopSwitch.append( ' else : ' ) + PyMoreInitLoopSwitch.append( ' DoLoop = 0 ' ) + PyMoreInitLoopSwitch.append( ' return DoLoop,Index,Min,Max ' ) + PyNextInitLoopSwitch = [] + PyNextInitLoopSwitch.append( 'def NextLoop(Index,Min,Max) : ' ) + PyNextInitLoopSwitch.append( ' Index = Index - 1 ' ) + PyNextInitLoopSwitch.append( ' return Index,Min,Max ' ) + InitLoopSwitch,EndOfInitLoopSwitch = GraphSwitch_1_1.LNode( 'InitLoop' , PyInitLoopSwitch , 'MoreLoop' , PyMoreInitLoopSwitch , 'NextLoop' , PyNextInitLoopSwitch ) + EndOfInitLoopSwitch.SetName( 'EndOfInitLoopSwitch' ) + EndOfInitLoopSwitch.SetAuthor( '' ) + EndOfInitLoopSwitch.SetComment( 'Compute Node' ) + EndOfInitLoopSwitch.Coords( 1082 , 150 ) + PyEndOfInitLoopSwitch = [] + EndOfInitLoopSwitch.SetPyFunction( '' , PyEndOfInitLoopSwitch ) + IInitLoopSwitchDoLoop = InitLoopSwitch.GetInPort( 'DoLoop' ) + IInitLoopSwitchIndex = InitLoopSwitch.InPort( 'Index' , 'long' ) + IInitLoopSwitchMin = InitLoopSwitch.InPort( 'Min' , 'long' ) + IInitLoopSwitchMax = InitLoopSwitch.InPort( 'Max' , 'long' ) + IInitLoopSwitchGate = InitLoopSwitch.GetInPort( 'Gate' ) + OInitLoopSwitchDoLoop = InitLoopSwitch.GetOutPort( 'DoLoop' ) + OInitLoopSwitchIndex = InitLoopSwitch.GetOutPort( 'Index' ) + OInitLoopSwitchMin = InitLoopSwitch.GetOutPort( 'Min' ) + OInitLoopSwitchMax = InitLoopSwitch.GetOutPort( 'Max' ) + IEndOfInitLoopSwitchDoLoop = EndOfInitLoopSwitch.GetInPort( 'DoLoop' ) + IEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetInPort( 'Index' ) + IEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetInPort( 'Min' ) + IEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetInPort( 'Max' ) + IEndOfInitLoopSwitchGate = EndOfInitLoopSwitch.GetInPort( 'Gate' ) + OEndOfInitLoopSwitchDoLoop = EndOfInitLoopSwitch.GetOutPort( 'DoLoop' ) + OEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetOutPort( 'Index' ) + OEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetOutPort( 'Min' ) + OEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetOutPort( 'Max' ) + OEndOfInitLoopSwitchGate = EndOfInitLoopSwitch.GetOutPort( 'Gate' ) + InitLoopSwitch.SetName( 'InitLoopSwitch' ) + InitLoopSwitch.SetAuthor( '' ) + InitLoopSwitch.SetComment( 'Compute Node' ) + InitLoopSwitch.Coords( 10 , 129 ) + + # Creation of Switch Nodes + PySwitch = [] + PySwitch.append( 'from time import * ' ) + PySwitch.append( 'def Switch(a) : ' ) + PySwitch.append( ' Branch = 'Negative or null' ' ) + PySwitch.append( ' if a <= 0 : ' ) + PySwitch.append( ' return 0,0,a,Branch,1 ' ) + PySwitch.append( ' if ( a & 1 ) == 0 : ' ) + PySwitch.append( ' Branch = 'Even' ' ) + PySwitch.append( ' else : ' ) + PySwitch.append( ' Branch = 'Odd' ' ) + PySwitch.append( ' sleep(1) ' ) + PySwitch.append( ' return a & 1,1-(a&1),a,Branch,0 ' ) + Switch,EndOfSwitch = GraphSwitch_1_1.SNode( 'Switch' , PySwitch ) + EndOfSwitch.SetName( 'EndOfSwitch' ) + EndOfSwitch.SetAuthor( '' ) + EndOfSwitch.SetComment( 'Compute Node' ) + EndOfSwitch.Coords( 880 , 150 ) + PyEndOfSwitch = [] + EndOfSwitch.SetPyFunction( 'EndSwitch_1' , PyEndOfSwitch ) + IEndOfSwitcha = EndOfSwitch.InPort( 'a' , 'long' ) + IEndOfSwitchDefault = EndOfSwitch.GetInPort( 'Default' ) + OEndOfSwitcha = EndOfSwitch.OutPort( 'a' , 'long' ) + OEndOfSwitchGate = EndOfSwitch.GetOutPort( 'Gate' ) + Switch.SetName( 'Switch' ) + Switch.SetAuthor( '' ) + Switch.SetComment( 'Compute Node' ) + Switch.Coords( 195 , 129 ) + ISwitcha = Switch.InPort( 'a' , 'long' ) + ISwitchGate = Switch.GetInPort( 'Gate' ) + OSwitchOdd = Switch.OutPort( 'Odd' , 'long' ) + OSwitchEven = Switch.OutPort( 'Even' , 'int' ) + OSwitcha = Switch.OutPort( 'a' , 'int' ) + OSwitchBranch = Switch.OutPort( 'Branch' , 'string' ) + OSwitchdefault = Switch.OutPort( 'default' , 'boolean' ) + OSwitchDefault = Switch.GetOutPort( 'Default' ) + + # Creation of Links + LIsOddaPrinta = GraphSwitch_1_1.Link( OIsOdda , IPrinta ) + + LInitLoopSwitchIndexSwitcha = GraphSwitch_1_1.Link( OInitLoopSwitchIndex , ISwitcha ) + + LInitLoopSwitchMinEndOfInitLoopSwitchMin = GraphSwitch_1_1.Link( OInitLoopSwitchMin , IEndOfInitLoopSwitchMin ) + + LInitLoopSwitchMaxEndOfInitLoopSwitchMax = GraphSwitch_1_1.Link( OInitLoopSwitchMax , IEndOfInitLoopSwitchMax ) + + LIsEvenaPrint_1a = GraphSwitch_1_1.Link( OIsEvena , IPrint_1a ) + + LSwitchOddIsOddGate = GraphSwitch_1_1.Link( OSwitchOdd , IIsOddGate ) + + LSwitchEvenIsEvenGate = GraphSwitch_1_1.Link( OSwitchEven , IIsEvenGate ) + + LSwitchaIsOdda = GraphSwitch_1_1.Link( OSwitcha , IIsOdda ) + + LSwitchaIsEvena = GraphSwitch_1_1.Link( OSwitcha , IIsEvena ) + + LSwitchBranchPrintBranch = GraphSwitch_1_1.Link( OSwitchBranch , IPrintBranch ) + + LSwitchBranchPrint_1Branch = GraphSwitch_1_1.Link( OSwitchBranch , IPrint_1Branch ) + + LSwitchDefaultEndOfSwitchDefault = GraphSwitch_1_1.Link( OSwitchDefault , IEndOfSwitchDefault ) + + LEndOfSwitchaEndOfInitLoopSwitchIndex = GraphSwitch_1_1.Link( OEndOfSwitcha , IEndOfInitLoopSwitchIndex ) + + LPrintaEndOfSwitcha = GraphSwitch_1_1.Link( OPrinta , IEndOfSwitcha ) + + LPrint_1aEndOfSwitcha = GraphSwitch_1_1.Link( OPrint_1a , IEndOfSwitcha ) + + # Input datas + IInitLoopSwitchIndex.Input( 0 ) + IInitLoopSwitchMin.Input( -5 ) + IInitLoopSwitchMax.Input( 10 ) + + # Output Ports of the graph + #OEndOfInitLoopSwitchIndex = EndOfInitLoopSwitch.GetOutPort( 'Index' ) + #OEndOfInitLoopSwitchMin = EndOfInitLoopSwitch.GetOutPort( 'Min' ) + #OEndOfInitLoopSwitchMax = EndOfInitLoopSwitch.GetOutPort( 'Max' ) + #OSwitchdefault = Switch.GetOutPort( 'default' ) + #OPrintBranch = Print.GetOutPort( 'Branch' ) + #OPrint_1Branch = Print_1.GetOutPort( 'Branch' ) + return GraphSwitch_1_1 + + +GraphSwitch_1_1 = DefGraphSwitch_1_1() diff --git a/examples/GraphSwitchOutput.xml b/examples/GraphSwitchOutput.xml new file mode 100644 index 0000000..86d6720 --- /dev/null +++ b/examples/GraphSwitchOutput.xml @@ -0,0 +1,500 @@ + + + + + +? + ? + GraphSwitch_1_1 + 1 + ? + +GraphSwitch_1_1 + + +long + InitLoopSwitch__Index + +long + InitLoopSwitch__Min + +long + InitLoopSwitch__Max + + +long + EndOfInitLoopSwitch__Index + +long + EndOfInitLoopSwitch__Min + +long + EndOfInitLoopSwitch__Max + +boolean + Switch__default + +string + Print__Branch + +string + Print_1__Branch + + + 1/10/2003 - 17:23:54 + 13/1/2005 - 11:21:30 + 1.05 + ? + ? + ? + 0 + 0 + + +? + ? + IsOdd + 3 + ? + +IsOdd + + +long + a + + +long + a + + + +IsOdd + + + + + + 13/1/2005 - 11:17:18 + 13/1/2005 - 11:17:18 + 1.05 + ? + ? + Python function + 388 + 50 + +? + ? + InitLoopSwitch + 4 + EndOfInitLoopSwitch + +InitLoopSwitch + + +long + Index + +long + Min + +long + Max + + +long + Index + +long + Min + +long + Max + + + +InitLoop + + + + +MoreLoop + + = Min : ]]> + + + + + +NextLoop + + + + 13/1/2005 - 11:17:18 + 13/1/2005 - 11:17:18 + 1.05 + ? + ? + Compute Node + 10 + 129 + +? + ? + EndOfInitLoopSwitch + 5 + InitLoopSwitch + +EndOfInitLoopSwitch + + +long + Index + +long + Min + +long + Max + + +long + Index + +long + Min + +long + Max + + + +? + + 13/1/2005 - 11:17:18 + 13/1/2005 - 11:17:18 + 1.05 + ? + ? + Compute Node + 1082 + 150 + +? + ? + IsEven + 3 + ? + +IsEven + + +long + a + + +long + a + + + +IsEven + + + + + + 13/1/2005 - 11:17:18 + 13/1/2005 - 11:17:18 + 2.0 + ? + ? + Compute Node + 395 + 334 + +? + ? + Switch + 6 + EndOfSwitch + +Switch + + +long + a + + +long + Odd + +int + Even + +int + a + +string + Branch + +boolean + default + + + +Switch + + + + + + + + + + + + 13/1/2005 - 11:17:18 + 13/1/2005 - 11:17:18 + 2.0 + ? + ? + Compute Node + 195 + 129 + +? + ? + EndOfSwitch + 7 + Switch + +EndOfSwitch + + +long + a + + +long + a + + + +EndSwitch_1 + + 13/1/2005 - 11:17:18 + 13/1/2005 - 11:17:18 + 2.0 + ? + ? + Compute Node + 880 + 150 + +? + ? + Print + 3 + ? + +Void + + +long + a + +string + Branch + + +long + a + +string + Branch + + + +Print + + + + 13/1/2005 - 11:17:18 + 13/1/2005 - 11:17:18 + 2.0 + ? + ? + Compute Node + 639 + 63 + +? + ? + Print_1 + 3 + ? + +Print_1 + + +long + a + +string + Branch + + +long + a + +string + Branch + + + +Print_1 + + + + 13/1/2005 - 11:20:58 + 13/1/2005 - 11:20:58 + 2.0 + ? + ? + Compute Node + 639 + 263 + + +IsOdd + a + Print + a + + +InitLoopSwitch + DoLoop + EndOfInitLoopSwitch + DoLoop + + +InitLoopSwitch + Index + Switch + a + + +InitLoopSwitch + Min + EndOfInitLoopSwitch + Min + + +InitLoopSwitch + Max + EndOfInitLoopSwitch + Max + + +EndOfInitLoopSwitch + DoLoop + InitLoopSwitch + DoLoop + + +IsEven + a + Print_1 + a + + +Switch + Odd + IsOdd + Gate + + +Switch + Even + IsEven + Gate + + +Switch + a + IsOdd + a + + +Switch + a + IsEven + a + + +Switch + Branch + Print + Branch + + +Switch + Branch + Print_1 + Branch + + +Switch + Default + EndOfSwitch + Default + + +EndOfSwitch + a + EndOfInitLoopSwitch + Index + + +Print + a + EndOfSwitch + a + + +Print_1 + a + EndOfSwitch + a + + + +GraphSwitch_1_1 + InitLoopSwitch__Index + InitLoopSwitch + Index + +3 + 0 + + +GraphSwitch_1_1 + InitLoopSwitch__Min + InitLoopSwitch + Min + +3 + -5 + + +GraphSwitch_1_1 + InitLoopSwitch__Max + InitLoopSwitch + Max + +3 + 10 + diff --git a/examples/GraphSwitchs.xml b/examples/GraphSwitchs.xml index cda215c..059040e 100755 --- a/examples/GraphSwitchs.xml +++ b/examples/GraphSwitchs.xml @@ -488,7 +488,7 @@ EndOfInitLoopSwitch DoLoop InitLoopSwitch - InitLoop + DoLoop Switch @@ -566,7 +566,7 @@ EndOfInitLoop DoLoop InitLoop - InitLoop + DoLoop Switch_1 diff --git a/examples/GraphSyracuseC.py b/examples/GraphSyracuseC.py deleted file mode 100644 index 7b27496..0000000 --- a/examples/GraphSyracuseC.py +++ /dev/null @@ -1,171 +0,0 @@ -# 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 -# -# -# -# File : GraphSyracuseC.py -# Module : SuperVisionTest - -from SuperV import * -# Graph creation -GraphSyracuseC = Graph( 'GraphSyracuseC' ) -GraphSyracuseC.SetName( 'GraphSyracuseC' ) -GraphSyracuseC.SetAuthor( 'JR' ) -GraphSyracuseC.SetComment( 'Syracuse algorithm' ) -GraphSyracuseC.Coords( 0 , 0 ) - -# Creation of Computing Nodes -test_ISEVEN = GraphSyracuseC.Node( 'SyrComponent' , 'SyrComponent' , 'C_ISEVEN' ) -test_ISEVEN.SetName( 'test_ISEVEN' ) -test_ISEVEN.SetAuthor( '' ) -test_ISEVEN.SetContainer( 'localhost/FactoryServer' ) -test_ISEVEN.SetComment( '' ) -test_ISEVEN.Coords( 252 , 266 ) -test_ISONE = GraphSyracuseC.Node( 'SyrComponent' , 'SyrComponent' , 'C_ISONE' ) -test_ISONE.SetName( 'test_ISONE' ) -test_ISONE.SetAuthor( '' ) -test_ISONE.SetContainer( 'localhost/FactoryServer' ) -test_ISONE.SetComment( '' ) -test_ISONE.Coords( 268 , 29 ) -m3p1 = GraphSyracuseC.Node( 'SyrComponent' , 'SyrComponent' , 'C_M3P1' ) -m3p1.SetName( 'm3p1' ) -m3p1.SetAuthor( '' ) -m3p1.SetContainer( 'localhost/FactoryServer' ) -m3p1.SetComment( '' ) -m3p1.Coords( 644 , 410 ) -div2 = GraphSyracuseC.Node( 'SyrComponent' , 'SyrComponent' , 'C_DIV2' ) -div2.SetName( 'div2' ) -div2.SetAuthor( '' ) -div2.SetContainer( 'localhost/FactoryServer' ) -div2.SetComment( '' ) -div2.Coords( 648 , 209 ) -incr = GraphSyracuseC.Node( 'SyrComponent' , 'SyrComponent' , 'C_INCR' ) -incr.SetName( 'incr' ) -incr.SetAuthor( '' ) -incr.SetContainer( 'localhost/FactoryServer' ) -incr.SetComment( '' ) -incr.Coords( 640 , 2 ) - -# Creation of Input datas -test_ISEVENanInteger = test_ISEVEN.Input( 'anInteger' , 7) -test_ISONEanInteger = test_ISONE.Input( 'anInteger' , 7) -m3p1anOddInteger = m3p1.Input( 'anOddInteger' , 7) -div2anEvenInteger = div2.Input( 'anEvenInteger' , 7) -incraCount = incr.Input( 'aCount' , 0) - -# Creation of Output variables -test_ISEVENBoolEven = test_ISEVEN.Port( 'BoolEven' ) -test_ISONEBoolOne = test_ISONE.Port( 'BoolOne' ) -m3p1anEvenInteger = m3p1.Port( 'anEvenInteger' ) -div2anInteger = div2.Port( 'anInteger' ) -incraNewCount = incr.Port( 'aNewCount' ) - -GraphSyracuseC.IsValid() - -GraphSyracuseC.ThreadsMax() - -GraphSyracuseC.LevelMax() - -GraphSyracuseC.SubGraphsNumber() - -GraphSyracuseC.IsExecutable() - -exec GraphSyracuseC.ListNodes() -test_ISEVENanInteger = test_ISEVEN.Port( 'anInteger' ) -test_ISONEanInteger = test_ISONE.Port( 'anInteger' ) -m3p1anOddInteger = m3p1.Port( 'anOddInteger' ) -div2anEvenInteger = div2.Port( 'anEvenInteger' ) -incraCount = incr.Port( 'aCount' ) - -# Creation of Output variables -test_ISEVENBoolEven = test_ISEVEN.Port( 'BoolEven' ) -test_ISONEBoolOne = test_ISONE.Port( 'BoolOne' ) -m3p1anEvenInteger = m3p1.Port( 'anEvenInteger' ) -div2anInteger = div2.Port( 'anInteger' ) -incraNewCount = incr.Port( 'aNewCount' ) - - -GraphSyracuseC.Start() - -test_ISEVEN.SuspendDone() -test_ISONE.SuspendDone() - -test_ISEVEN.Resume() -test_ISONE.Resume() - -# Suspend des nodes de tete des sous-graphes sauf test -m3p1.Suspend() -div2.Suspend() -incr.Suspend() - -# Attentes de suspension de m3p1, div2, incr et result. -# Puis demandes de suspension après exécution -m3p1.SuspendDone() -div2.SuspendDone() -incr.SuspendDone() - -# Attente de fin d'exécution de test -test_ISONE.DoneW() -test_ISEVEN.DoneW() - -# Etats et Threads des nodes -GraphSyracuseC.PrintThreads() - -while int( test_ISONEBoolOne.ToString() ) == 0 : - if int( test_ISEVENBoolEven.ToString() ) == 0 : - sts = m3p1.ReRun() - sts = incr.ReRun() - sts = m3p1.DoneW() - sts = test_ISEVENanInteger.Input( m3p1anEvenInteger.ToString() ) - sts = test_ISONEanInteger.Input( m3p1anEvenInteger.ToString() ) - sts = test_ISEVEN.ReRun() - sts = test_ISONE.ReRun() - sts = test_ISEVEN.DoneW() - sts = test_ISONE.DoneW() - sts = incr.DoneW() - sts = incraCount.Input( incraNewCount.ToString() ) - print incraNewCount.ToString(),"m3p1",m3p1anEvenInteger.ToString(),test_ISEVENBoolEven.ToString() - while int( test_ISEVENBoolEven.ToString() ) == 1 : - sts = div2anEvenInteger.Input( test_ISEVENanInteger.ToString() ) - sts = div2.ReRun() - sts = incr.ReRun() - sts = div2.DoneW() - sts = test_ISEVENanInteger.Input( div2anInteger.ToString() ) - sts = test_ISONEanInteger.Input( div2anInteger.ToString() ) - sts = test_ISEVEN.ReRun() - sts = test_ISONE.ReRun() - sts = test_ISEVEN.DoneW() - sts = test_ISONE.DoneW() - sts = incr.DoneW() - sts = incraCount.Input( incraNewCount.ToString() ) - print incraNewCount.ToString(),"div2",div2anInteger.ToString(),test_ISEVENBoolEven.ToString() - sts = m3p1anOddInteger.Input( div2anInteger.ToString() ) - - -GraphSyracuseC.PrintThreads() -m3p1.Resume() -div2.Resume() -incr.Resume() -test_ISONE.Resume() -test_ISEVEN.Resume() -GraphSyracuseC.DoneW() -print GraphSyracuseC.State() -GraphSyracuseC.PrintPorts() -GraphSyracuseC.PrintThreads() - diff --git a/examples/GraphSyracuseC.xml b/examples/GraphSyracuseC.xml deleted file mode 100755 index 9219318..0000000 --- a/examples/GraphSyracuseC.xml +++ /dev/null @@ -1,315 +0,0 @@ - - - - - - - - - ? - ? - GraphSyracuseC - 1 - ? - - GraphSyracuseC - - - long - test_ISEVEN\anInteger - - - long - test_ISONE\anInteger - - - long - m3p1\anOddInteger - - - long - div2\anEvenInteger - - - long - incr\aCount - - - - - long - test_ISEVEN\BoolEven - - - long - test_ISONE\BoolOne - - - long - m3p1\anEvenInteger - - - long - div2\anInteger - - - long - incr\aNewCount - - - - - - - - 11/3/2003 - 17:0:26 - 11/3/2003 - 17:0:26 - 1.04 - JR - ? - Syracuse algorithm - 0 - 0 - - - - - - SyrComponent - SyrComponent - test_ISEVEN - 0 - ? - - C_ISEVEN - - - long - anInteger - - - - - long - BoolEven - - - - - - - - 11/3/2003 - 17:0:26 - 11/3/2003 - 17:0:26 - 1.04 - ? - localhost/FactoryServer - ? - 252 - 266 - - - SyrComponent - SyrComponent - test_ISONE - 0 - ? - - C_ISONE - - - long - anInteger - - - - - long - BoolOne - - - - - - - - 11/3/2003 - 17:0:26 - 11/3/2003 - 17:0:26 - 1.04 - ? - localhost/FactoryServer - ? - 268 - 29 - - - SyrComponent - SyrComponent - m3p1 - 0 - ? - - C_M3P1 - - - long - anOddInteger - - - - - long - anEvenInteger - - - - - - - - 11/3/2003 - 17:0:26 - 11/3/2003 - 17:0:26 - 1.04 - ? - localhost/FactoryServer - ? - 644 - 410 - - - SyrComponent - SyrComponent - div2 - 0 - ? - - C_DIV2 - - - long - anEvenInteger - - - - - long - anInteger - - - - - - - - 11/3/2003 - 17:0:26 - 11/3/2003 - 17:0:26 - 1.04 - ? - localhost/FactoryServer - ? - 648 - 209 - - - SyrComponent - SyrComponent - incr - 0 - ? - - C_INCR - - - long - aCount - - - - - long - aNewCount - - - - - - - - 11/3/2003 - 17:0:26 - 11/3/2003 - 17:0:26 - 1.04 - ? - localhost/FactoryServer - ? - 640 - 2 - - - - - - - - - GraphSyracuseC - test_ISEVEN\anInteger - test_ISEVEN - anInteger - - 3 - 7 - - - - - - GraphSyracuseC - test_ISONE\anInteger - test_ISONE - anInteger - - 3 - 7 - - - - - - GraphSyracuseC - m3p1\anOddInteger - m3p1 - anOddInteger - - 3 - 7 - - - - - - GraphSyracuseC - div2\anEvenInteger - div2 - anEvenInteger - - 3 - 7 - - - - - - GraphSyracuseC - incr\aCount - incr - aCount - - 3 - 0 - - - - - - - diff --git a/examples/GraphSyracuseCEv.py b/examples/GraphSyracuseCEv.py deleted file mode 100644 index 5961ab5..0000000 --- a/examples/GraphSyracuseCEv.py +++ /dev/null @@ -1,168 +0,0 @@ -# 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 -# -# -# -# File : GraphSyracuseCEv.py -# Module : SuperVisionTest - -from SuperV import * -import SUPERV -import SUPERV_idl - -# Graph creation -GraphSyracuseCEv = Graph( 'GraphSyracuseCEv' ) -GraphSyracuseCEv.SetName( 'GraphSyracuseCEv' ) -GraphSyracuseCEv.SetAuthor( 'JR' ) -GraphSyracuseCEv.SetComment( 'Syracuse algorithm' ) -GraphSyracuseCEv.Coords( 0 , 0 ) - -# Creation of Computing Nodes -test_ISEVEN = GraphSyracuseCEv.Node( 'SyrComponent' , 'SyrComponent' , 'C_ISEVEN' ) -test_ISEVEN.SetName( 'test_ISEVEN' ) -test_ISEVEN.SetAuthor( '' ) -test_ISEVEN.SetContainer( 'localhost/FactoryServer' ) -test_ISEVEN.SetComment( '' ) -test_ISEVEN.Coords( 252 , 266 ) -test_ISONE = GraphSyracuseCEv.Node( 'SyrComponent' , 'SyrComponent' , 'C_ISONE' ) -test_ISONE.SetName( 'test_ISONE' ) -test_ISONE.SetAuthor( '' ) -test_ISONE.SetContainer( 'localhost/FactoryServer' ) -test_ISONE.SetComment( '' ) -test_ISONE.Coords( 268 , 29 ) -m3p1 = GraphSyracuseCEv.Node( 'SyrComponent' , 'SyrComponent' , 'C_M3P1' ) -m3p1.SetName( 'm3p1' ) -m3p1.SetAuthor( '' ) -m3p1.SetContainer( 'localhost/FactoryServer' ) -m3p1.SetComment( '' ) -m3p1.Coords( 644 , 410 ) -div2 = GraphSyracuseCEv.Node( 'SyrComponent' , 'SyrComponent' , 'C_DIV2' ) -div2.SetName( 'div2' ) -div2.SetAuthor( '' ) -div2.SetContainer( 'localhost/FactoryServer' ) -div2.SetComment( '' ) -div2.Coords( 648 , 209 ) -incr = GraphSyracuseCEv.Node( 'SyrComponent' , 'SyrComponent' , 'C_INCR' ) -incr.SetName( 'incr' ) -incr.SetAuthor( '' ) -incr.SetContainer( 'localhost/FactoryServer' ) -incr.SetComment( '' ) -incr.Coords( 640 , 2 ) - -# Creation of Input datas -test_ISEVENanInteger = test_ISEVEN.Input( 'anInteger' , 31) -test_ISONEanInteger = test_ISONE.Input( 'anInteger' , 31) -m3p1anOddInteger = m3p1.Input( 'anOddInteger' , 31) -div2anEvenInteger = div2.Input( 'anEvenInteger' , 31) -incraCount = incr.Input( 'aCount' , 0) - -GraphSyracuseCEv.IsValid() - -GraphSyracuseCEv.ThreadsMax() - -GraphSyracuseCEv.LevelMax() - -GraphSyracuseCEv.SubGraphsNumber() - -GraphSyracuseCEv.IsExecutable() - - - - -exec GraphSyracuseCEv.ListNodes() - -test_ISEVENanInteger = test_ISEVEN.Port( 'anInteger' ) -test_ISEVENBoolEven = test_ISEVEN.Port( 'BoolEven' ) -test_ISONEanInteger = test_ISONE.Port( 'anInteger' ) -test_ISONEBoolOne = test_ISONE.Port( 'BoolOne' ) -m3p1anOddInteger = m3p1.Port( 'anOddInteger' ) -m3p1anEvenInteger = m3p1.Port( 'anEvenInteger' ) -div2anEvenInteger = div2.Port( 'anEvenInteger' ) -div2anInteger = div2.Port( 'anInteger' ) -incraCount = incr.Port( 'aCount' ) -incraNewCount = incr.Port( 'aNewCount' ) - -GraphSyracuseCEv.Start() - -test_ISEVEN.SuspendDone() -test_ISONE.SuspendDone() - -test_ISEVEN.Resume() -test_ISONE.Resume() - -m3p1.SuspendDone() -div2.SuspendDone() -incr.SuspendDone() - -test_ISEVEN.DoneW() -test_ISONE.DoneW() - -aStatus,aNode,anEvent,aState = GraphSyracuseCEv.Event() -while aNode != None : - if int( test_ISONEBoolOne.ToString() ) == 0 : - if int( test_ISEVENBoolEven.ToString() ) == 0 : - while aNode != None : - if aNode.Name() == 'm3p1' : - if aState == SUPERV_idl._0_SUPERV.SuspendReadyState : - sts = m3p1.ReRun() - sts = incr.ReRun() - else : - if aState == SUPERV_idl._0_SUPERV.SuspendDoneState : - sts = test_ISEVENanInteger.Input( m3p1anEvenInteger.ToString() ) - sts = test_ISONEanInteger.Input( m3p1anEvenInteger.ToString() ) - sts = test_ISEVEN.ReRun() - sts = test_ISONE.ReRun() - else : - if ( aNode.Name() == 'incr' ) & ( aState == SUPERV_idl._0_SUPERV.SuspendDoneState ) : - sts = incraCount.Input( incraNewCount.ToString() ) - aStatus,aNode,anEvent,aState = GraphSyracuseCEv.Event() - print incraNewCount.ToString(),"m3p1",m3p1anEvenInteger.ToString() - sts = div2anEvenInteger.Input( m3p1anEvenInteger.ToString() ) - while int( test_ISEVENBoolEven.ToString() ) == 1 : - sts = div2.ReRun() - sts = incr.ReRun() - aStatus,aNode,anEvent,aState = GraphSyracuseCEv.Event() - while aNode != None : - if ( aNode.Name() == 'div2' ) & ( aState == SUPERV_idl._0_SUPERV.SuspendDoneState ) : - sts = test_ISEVENanInteger.Input( div2anInteger.ToString() ) - sts = test_ISONEanInteger.Input( div2anInteger.ToString() ) - sts = test_ISEVEN.ReRun() - sts = test_ISONE.ReRun() - aStatus,aNode,anEvent,aState = GraphSyracuseCEv.Event() - sts = incraCount.Input( incraNewCount.ToString() ) - print incraNewCount.ToString(),"div2",div2anInteger.ToString() - sts = m3p1anOddInteger.Input( div2anInteger.ToString() ) - sts = div2anEvenInteger.Input( div2anInteger.ToString() ) - if int( test_ISONEBoolOne.ToString() ) == 0 : - sts = m3p1.ReRun() - sts = incr.ReRun() - aStatus,aNode,anEvent,aState = GraphSyracuseCEv.Event() - else : - GraphSyracuseCEv.PrintThreads() - m3p1.Resume() - div2.Resume() - incr.Resume() - test_ISONE.Resume() - test_ISEVEN.Resume() - aStatus,aNode,anEvent,aState = GraphSyracuseCEv.Event() - -GraphSyracuseCEv.DoneW() -print GraphSyracuseCEv.State() -GraphSyracuseCEv.PrintThreads() -GraphSyracuseCEv.PrintPorts() diff --git a/examples/GraphSyracuseCEv.xml b/examples/GraphSyracuseCEv.xml deleted file mode 100755 index 3e7ee23..0000000 --- a/examples/GraphSyracuseCEv.xml +++ /dev/null @@ -1,315 +0,0 @@ - - - - - - - - - ? - ? - GraphSyracuseCEv - 1 - ? - - GraphSyracuseCEv - - - long - test_ISEVEN\anInteger - - - long - test_ISONE\anInteger - - - long - m3p1\anOddInteger - - - long - div2\anEvenInteger - - - long - incr\aCount - - - - - long - test_ISEVEN\BoolEven - - - long - test_ISONE\BoolOne - - - long - m3p1\anEvenInteger - - - long - div2\anInteger - - - long - incr\aNewCount - - - - - - - - 11/3/2003 - 15:7:39 - 11/3/2003 - 15:7:39 - 1.04 - JR - ? - Syracuse algorithm - 0 - 0 - - - - - - SyrComponent - SyrComponent - test_ISEVEN - 0 - ? - - C_ISEVEN - - - long - anInteger - - - - - long - BoolEven - - - - - - - - 11/3/2003 - 15:7:39 - 11/3/2003 - 15:7:39 - 1.04 - ? - localhost/FactoryServer - ? - 252 - 266 - - - SyrComponent - SyrComponent - test_ISONE - 0 - ? - - C_ISONE - - - long - anInteger - - - - - long - BoolOne - - - - - - - - 11/3/2003 - 15:7:39 - 11/3/2003 - 15:7:39 - 1.04 - ? - localhost/FactoryServer - ? - 268 - 29 - - - SyrComponent - SyrComponent - m3p1 - 0 - ? - - C_M3P1 - - - long - anOddInteger - - - - - long - anEvenInteger - - - - - - - - 11/3/2003 - 15:7:39 - 11/3/2003 - 15:7:39 - 1.04 - ? - localhost/FactoryServer - ? - 644 - 410 - - - SyrComponent - SyrComponent - div2 - 0 - ? - - C_DIV2 - - - long - anEvenInteger - - - - - long - anInteger - - - - - - - - 11/3/2003 - 15:7:39 - 11/3/2003 - 15:7:39 - 1.04 - ? - localhost/FactoryServer - ? - 648 - 209 - - - SyrComponent - SyrComponent - incr - 0 - ? - - C_INCR - - - long - aCount - - - - - long - aNewCount - - - - - - - - 11/3/2003 - 15:7:39 - 11/3/2003 - 15:7:39 - 1.04 - ? - localhost/FactoryServer - ? - 640 - 2 - - - - - - - - - GraphSyracuseCEv - test_ISEVEN\anInteger - test_ISEVEN - anInteger - - 3 - 31 - - - - - - GraphSyracuseCEv - test_ISONE\anInteger - test_ISONE - anInteger - - 3 - 31 - - - - - - GraphSyracuseCEv - m3p1\anOddInteger - m3p1 - anOddInteger - - 3 - 31 - - - - - - GraphSyracuseCEv - div2\anEvenInteger - div2 - anEvenInteger - - 3 - 31 - - - - - - GraphSyracuseCEv - incr\aCount - incr - aCount - - 3 - 0 - - - - - - - diff --git a/examples/GraphSyracuseC_Void.py b/examples/GraphSyracuseC_Void.py deleted file mode 100644 index bb2a62d..0000000 --- a/examples/GraphSyracuseC_Void.py +++ /dev/null @@ -1,160 +0,0 @@ - -# Generated python file of Graph GraphSyracuseC_Void - -from SuperV import * -# Graph creation -GraphSyracuseC_Void = Graph( 'GraphSyracuseC_Void' ) -print GraphSyracuseC_Void.SetName( 'GraphSyracuseC_Void' ) -print GraphSyracuseC_Void.SetAuthor( 'JR' ) -print GraphSyracuseC_Void.SetComment( 'Syracuse algorithm' ) -GraphSyracuseC_Void.Coords( 0 , 0 ) - -# Creation of Nodes -test_ISEVEN = GraphSyracuseC_Void.Node( 'SyrComponent' , 'SyrComponent' , 'C_ISEVEN' ) -print test_ISEVEN.SetName( 'test_ISEVEN' ) -print test_ISEVEN.SetAuthor( '' ) -print test_ISEVEN.SetContainer( 'localhost/FactoryServer' ) -print test_ISEVEN.SetComment( '' ) -test_ISEVEN.Coords( 5 , 416 ) -test_ISONE = GraphSyracuseC_Void.Node( 'SyrComponent' , 'SyrComponent' , 'C_ISONE' ) -print test_ISONE.SetName( 'test_ISONE' ) -print test_ISONE.SetAuthor( '' ) -print test_ISONE.SetContainer( 'localhost/FactoryServer' ) -print test_ISONE.SetComment( '' ) -test_ISONE.Coords( 7 , 232 ) -m3p1 = GraphSyracuseC_Void.Node( 'SyrComponent' , 'SyrComponent' , 'C_M3P1' ) -print m3p1.SetName( 'm3p1' ) -print m3p1.SetAuthor( '' ) -print m3p1.SetContainer( 'localhost/FactoryServer' ) -print m3p1.SetComment( '' ) -m3p1.Coords( 180 , 417 ) -div2 = GraphSyracuseC_Void.Node( 'SyrComponent' , 'SyrComponent' , 'C_DIV2' ) -print div2.SetName( 'div2' ) -print div2.SetAuthor( '' ) -print div2.SetContainer( 'localhost/FactoryServer' ) -print div2.SetComment( '' ) -div2.Coords( 435 , 7 ) -div2_ISEVEN = GraphSyracuseC_Void.Node( 'SyrComponent' , 'SyrComponent' , 'C_ISEVEN' ) -print div2_ISEVEN.SetName( 'div2_ISEVEN' ) -print div2_ISEVEN.SetAuthor( '' ) -print div2_ISEVEN.SetContainer( 'localhost/FactoryServer' ) -print div2_ISEVEN.SetComment( '' ) -div2_ISEVEN.Coords( 619 , 191 ) -div2_ISONE = GraphSyracuseC_Void.Node( 'SyrComponent' , 'SyrComponent' , 'C_ISONE' ) -print div2_ISONE.SetName( 'div2_ISONE' ) -print div2_ISONE.SetAuthor( '' ) -print div2_ISONE.SetContainer( 'localhost/FactoryServer' ) -print div2_ISONE.SetComment( '' ) -div2_ISONE.Coords( 616 , 6 ) -incr = GraphSyracuseC_Void.Node( 'SyrComponent' , 'SyrComponent' , 'C_INCR' ) -print incr.SetName( 'incr' ) -print incr.SetAuthor( '' ) -print incr.SetContainer( 'localhost/FactoryServer' ) -print incr.SetComment( '' ) -incr.Coords( 434 , 193 ) - -# Creation of intermediate Output variables and of links -test_ISEVENOutVoid = test_ISEVEN.Port( 'OutVoid' ) -m3p1InVoid = GraphSyracuseC_Void.Link( test_ISEVENOutVoid , m3p1.Port( 'InVoid' ) ) -m3p1anEvenInteger = m3p1.Port( 'anEvenInteger' ) -div2anEvenInteger = GraphSyracuseC_Void.Link( m3p1anEvenInteger , div2.Port( 'anEvenInteger' ) ) -print div2anEvenInteger.AddCoord( 1 , 368 , 158 ) -print div2anEvenInteger.AddCoord( 2 , 369 , 568 ) -div2anInteger = div2.Port( 'anInteger' ) -div2_ISONEanInteger = GraphSyracuseC_Void.Link( div2anInteger , div2_ISONE.Port( 'anInteger' ) ) -div2_ISEVENanInteger = GraphSyracuseC_Void.Link( div2anInteger , div2_ISEVEN.Port( 'anInteger' ) ) -print div2_ISEVENanInteger.AddCoord( 1 , 603 , 342 ) -print div2_ISEVENanInteger.AddCoord( 2 , 603 , 158 ) - -# Creation of Input datas -test_ISEVENanInteger = test_ISEVEN.Input( 'anInteger' , 31) -test_ISONEanInteger = test_ISONE.Input( 'anInteger' , 31) -m3p1anOddInteger = m3p1.Input( 'anOddInteger' , 31) -div2InanEvenInteger = div2.Port( 'anEvenInteger' ) -incraCount = incr.Input( 'aCount' , 0) - -# Missing Input datas - -# Creation of Output variables -test_ISEVENBoolEven = test_ISEVEN.Port( 'BoolEven' ) -test_ISONEBoolOne = test_ISONE.Port( 'BoolOne' ) -div2_ISEVENBoolEven = div2_ISEVEN.Port( 'BoolEven' ) -div2_ISONEBoolOne = div2_ISONE.Port( 'BoolOne' ) -incraNewCount = incr.Port( 'aNewCount' ) - -GraphSyracuseC_Void.IsValid() - -GraphSyracuseC_Void.ThreadsMax() - -GraphSyracuseC_Void.LevelMax() - -GraphSyracuseC_Void.GraphsNumber() - -curM3P1 = m3p1.Input( 'anOddInteger' , 31 ) -curtestISEVEN = test_ISEVEN.Input( 'anInteger' , curM3P1.ToAny() ) -curtestISONE = test_ISONE.Input( 'anInteger' , curM3P1.ToAny() ) - -GraphSyracuseC_Void.IsExecutable() - -GraphSyracuseC_Void.Start() - -m3p1.Suspend() - -div2_ISEVEN.SuspendDone() -div2_ISONE.SuspendDone() - -test_ISEVEN.Resume() -test_ISONE.Resume() - -# Attente de fin d'exécution de test -test_ISONE.DoneW() -test_ISEVEN.DoneW() - -m3p1.SuspendedW() -incr.SuspendedW() -incr.SuspendDone() - -# Etats et Threads des nodes -GraphSyracuseC_Void.PrintThreads() - -BoolOne = int( test_ISONEBoolOne.ToString() ) -BoolEven = int( test_ISEVENBoolEven.ToString() ) -while BoolOne == 0 : - if BoolEven == 0 : - sts = div2_ISONE.ReRunAt('m3p1') - sts = incr.ReRun() - sts = m3p1.DoneW() - sts = incr.DoneW() - sts = incraCount.Input( int( incraNewCount.ToString() ) + 1 ) - BoolEven = 1 - BoolOne = 0 - Current = int( m3p1anEvenInteger.ToString() ) - print "m3p1",Current,BoolEven - while BoolEven == 1 : - sts = incr.ReRun() - sts = div2.DoneW() - sts = div2_ISEVEN.DoneW() - sts = div2_ISONE.DoneW() - sts = incr.DoneW() - sts = incraCount.Input( incraNewCount.ToString() ) - BoolOne = int( div2_ISONEBoolOne.ToString() ) - BoolEven = int( div2_ISEVENBoolEven.ToString() ) - Current = int( div2anInteger.ToString() ) - print "div2",Current,BoolEven,BoolOne - if BoolEven == 1 : - div2InanEvenInteger.Input( Current ) - sts = div2_ISONE.ReRunAt('div2') - sts = curM3P1.Input( Current ) - - -GraphSyracuseC_Void.PrintThreads() -m3p1.Resume() -div2.Resume() -incr.Resume() -div2_ISONE.Resume() -div2_ISEVEN.Resume() -GraphSyracuseC_Void.DoneW() -print GraphSyracuseC_Void.State() -GraphSyracuseC_Void.PrintPorts() -GraphSyracuseC_Void.PrintThreads() - diff --git a/examples/GraphSyracuseCpp.py b/examples/GraphSyracuseCpp.py deleted file mode 100644 index 6f4d67f..0000000 --- a/examples/GraphSyracuseCpp.py +++ /dev/null @@ -1,223 +0,0 @@ -# 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 -# -# -# -# File : GraphSyracuseCpp.py -# Module : SuperVisionTest - -from SuperV import * -# Graph creation -GraphSyracuseCpp = Graph( 'GraphSyracuseCpp' ) -GraphSyracuseCpp.SetName( 'GraphSyracuseCpp' ) -GraphSyracuseCpp.SetAuthor( 'JR' ) -GraphSyracuseCpp.SetComment( 'Syracuse algorithm' ) -GraphSyracuseCpp.Coords( 0 , 0 ) - -# Creation of Computing Nodes -Syracuse = GraphSyracuseCpp.Node( 'SyrComponent' , 'SyrComponent' , 'Init' ) -Syracuse.SetName( 'Syracuse' ) -Syracuse.SetAuthor( '' ) -#Syracuse.SetContainer( 'localhost/FactoryServer' ) -Syracuse.SetComment( '' ) -Syracuse.Coords( 9 , 207 ) -test_IsEven = GraphSyracuseCpp.CNode( 'SyrComponent' , 'Syr' , 'IsEven' ) -test_IsEven.SetName( 'test_IsEven' ) -test_IsEven.SetAuthor( '' ) -#test_IsEven.SetContainer( 'localhost/FactoryServer' ) -test_IsEven.SetComment( '' ) -test_IsEven.Coords( 197 , 407 ) -test_IsOne = GraphSyracuseCpp.CNode( 'SyrComponent' , 'Syr' , 'IsOne' ) -test_IsOne.SetName( 'test_IsOne' ) -test_IsOne.SetAuthor( '' ) -#test_IsOne.SetContainer( 'localhost/FactoryServer' ) -test_IsOne.SetComment( '' ) -test_IsOne.Coords( 208 , 59 ) -m3p1_M3p1 = GraphSyracuseCpp.CNode( 'SyrComponent' , 'Syr' , 'M3p1' ) -m3p1_M3p1.SetName( 'm3p1_M3p1' ) -m3p1_M3p1.SetAuthor( '' ) -#m3p1_M3p1.SetContainer( 'localhost/FactoryServer' ) -m3p1_M3p1.SetComment( '' ) -m3p1_M3p1.Coords( 418 , 408 ) -div2_Div2 = GraphSyracuseCpp.CNode( 'SyrComponent' , 'Syr' , 'Div2' ) -div2_Div2.SetName( 'div2_Div2' ) -div2_Div2.SetAuthor( '' ) -#div2_Div2.SetContainer( 'localhost/FactoryServer' ) -div2_Div2.SetComment( '' ) -div2_Div2.Coords( 414 , 10 ) -incr_Incr = GraphSyracuseCpp.CNode( 'SyrComponent' , 'Syr' , 'Incr' ) -incr_Incr.SetName( 'incr_Incr' ) -incr_Incr.SetAuthor( '' ) -#incr_Incr.SetContainer( 'localhost/FactoryServer' ) -incr_Incr.SetComment( '' ) -incr_Incr.Coords( 416 , 207 ) -result_Current = GraphSyracuseCpp.CNode( 'SyrComponent' , 'Syr' , 'Current' ) -result_Current.SetName( 'result_Current' ) -result_Current.SetAuthor( '' ) -#result_Current.SetContainer( 'localhost/FactoryServer' ) -result_Current.SetComment( '' ) -result_Current.Coords( 603 , 216 ) -result_Count = GraphSyracuseCpp.CNode( 'SyrComponent' , 'Syr' , 'Count' ) -result_Count.SetName( 'result_Count' ) -result_Count.SetAuthor( '' ) -#result_Count.SetContainer( 'localhost/FactoryServer' ) -result_Count.SetComment( '' ) -result_Count.Coords( 803 , 212 ) - -# Creation of intermediate Output variables and of Computing Links -SyracuseaSyracuse = Syracuse.Port( 'aSyracuse' ) -test_IsEvenaSyracuse = GraphSyracuseCpp.Link( SyracuseaSyracuse , test_IsEven.Port( 'aSyracuse' ) ) -test_IsEvenaSyracuse.AddCoord( 1 , 175 , 559 ) -test_IsEvenaSyracuse.AddCoord( 2 , 175 , 359 ) -test_IsOneaSyracuse = GraphSyracuseCpp.Link( SyracuseaSyracuse , test_IsOne.Port( 'aSyracuse' ) ) -test_IsOneaSyracuse.AddCoord( 1 , 177 , 211 ) -test_IsOneaSyracuse.AddCoord( 2 , 177 , 359 ) -m3p1_M3p1aSyracuse = GraphSyracuseCpp.Link( SyracuseaSyracuse , m3p1_M3p1.Port( 'aSyracuse' ) ) -m3p1_M3p1aSyracuse.AddCoord( 1 , 388 , 560 ) -m3p1_M3p1aSyracuse.AddCoord( 2 , 388 , 359 ) -div2_Div2aSyracuse = GraphSyracuseCpp.Link( SyracuseaSyracuse , div2_Div2.Port( 'aSyracuse' ) ) -div2_Div2aSyracuse.AddCoord( 1 , 389 , 162 ) -div2_Div2aSyracuse.AddCoord( 2 , 389 , 359 ) -incr_IncraSyracuse = GraphSyracuseCpp.Link( SyracuseaSyracuse , incr_Incr.Port( 'aSyracuse' ) ) -result_CurrentaSyracuse = GraphSyracuseCpp.Link( SyracuseaSyracuse , result_Current.Port( 'aSyracuse' ) ) -result_CurrentaSyracuse.AddCoord( 1 , 590 , 368 ) -result_CurrentaSyracuse.AddCoord( 2 , 590 , 390 ) -result_CurrentaSyracuse.AddCoord( 3 , 388 , 390 ) -result_CurrentaSyracuse.AddCoord( 4 , 388 , 359 ) -result_CountaSyracuse = GraphSyracuseCpp.Link( SyracuseaSyracuse , result_Count.Port( 'aSyracuse' ) ) -result_CountaSyracuse.AddCoord( 1 , 785 , 364 ) -result_CountaSyracuse.AddCoord( 2 , 785 , 391 ) -result_CountaSyracuse.AddCoord( 3 , 389 , 391 ) -result_CountaSyracuse.AddCoord( 4 , 389 , 357 ) - -# Missing Input datas -SyracuseanOddInteger = Syracuse.Input( 'anOddInteger' , 7 ) - -# Creation of Output variables -test_IsEvenBoolEven = test_IsEven.Port( 'BoolEven' ) -test_IsOneBoolOne = test_IsOne.Port( 'BoolOne' ) -count_incr_Incr = incr_Incr.Port('aSyracuse') -result_CurrentaCurrent = result_Current.Port( 'aCurrent' ) - -GraphSyracuseCpp.IsValid() -GraphSyracuseCpp.LevelMax() -GraphSyracuseCpp.ThreadsMax() - -exec GraphSyracuseCpp.ListNodes() -SyracuseanOddInteger = Syracuse.Input( 'anOddInteger' , 7 ) -test_IsEvenBoolEven = test_IsEven.Port( 'BoolEven' ) -test_IsOneBoolOne = test_IsOne.Port( 'BoolOne' ) -count_incr_Incr = incr_Incr.Port('aSyracuse') -result_CurrentaCurrent = result_Current.Port( 'aCurrent' ) - - -GraphSyracuseCpp.Start( 7 ) - -# Suspend des nodes de tete de Syr -sts = test_IsOne.Suspend() -sts = test_IsEven.Suspend() -sts = m3p1_M3p1.Suspend() -sts = div2_Div2.Suspend() -sts = incr_Incr.Suspend() -sts = result_Current.Suspend() -sts = result_Count.Suspend() - -# Exécution du node de tete -sts = Syracuse.Resume() -sts = Syracuse.DoneW() - -# Attente de suspension de test et demandes de suspension après exécution -sts = test_IsOne.SuspendedW() -sts = test_IsOne.SuspendDone() -sts = test_IsEven.SuspendedW() -sts = test_IsEven.SuspendDone() - -# Exécution de test avec la valeur de départ -sts = test_IsOne.Resume() -sts = test_IsEven.Resume() - -# Attentes de suspension de m3p1, div2, incr et result. -# Puis demandes de suspension après exécution -sts = m3p1_M3p1.SuspendedW() -sts = div2_Div2.SuspendedW() -sts = incr_Incr.SuspendedW() -sts = result_Current.SuspendedW() -sts = result_Count.SuspendedW() -sts = m3p1_M3p1.SuspendDone() -sts = div2_Div2.SuspendDone() -sts = incr_Incr.SuspendDone() -sts = result_Current.SuspendDone() - -# Attente de fin d'exécution de test -sts = test_IsOne.SuspendedW() -sts = test_IsEven.SuspendedW() - -GraphSyracuseCpp.PrintThreads() - -IsOneBoolOne = test_IsOneBoolOne.ToString() -while int( IsOneBoolOne ) == 0 : - IsEvenBoolEven = test_IsEvenBoolEven.ToString() - if int( IsEvenBoolEven ) == 0 : - sts = m3p1_M3p1.ReRun() - sts = incr_Incr.ReRun() - sts = m3p1_M3p1.SuspendedW() - sts = result_Current.ReRun() - sts = test_IsOne.ReRun() - sts = test_IsEven.ReRun() - sts = test_IsOne.SuspendedW() - sts = test_IsEven.SuspendedW() - sts = incr_Incr.SuspendedW() - sts = result_Current.SuspendedW() - print "m3p1_M3p1",result_CurrentaCurrent.ToString(),IsEvenBoolEven - IsEvenBoolEven = test_IsEvenBoolEven.ToString() - while int( IsEvenBoolEven ) == 1 : - sts = div2_Div2.ReRun() - sts = incr_Incr.ReRun() - sts = div2_Div2.SuspendedW() - sts = result_Current.ReRun() - sts = test_IsOne.ReRun() - sts = test_IsEven.ReRun() - sts = test_IsOne.SuspendedW() - sts = test_IsEven.SuspendedW() - sts = incr_Incr.SuspendedW() - sts = IsEvenBoolEven = test_IsEvenBoolEven.ToString() - sts = result_Current.SuspendedW() - print "div2_Div2",result_CurrentaCurrent.ToString(),IsEvenBoolEven - IsOneBoolOne = test_IsOneBoolOne.ToString() - - - -GraphSyracuseCpp.PrintThreads() -sts = m3p1_M3p1.ControlClear() -sts = m3p1_M3p1.Resume() -sts = div2_Div2.ControlClear() -sts = div2_Div2.Resume() -sts = incr_Incr.ControlClear() -sts = incr_Incr.Resume() -sts = test_IsOne.Resume() -sts = test_IsEven.Resume() -sts = result_Current.ControlClear() -sts = result_Current.Resume() -sts = result_Count.ControlClear() -sts = result_Count.Resume() -sts = GraphSyracuseCpp.DoneW() -print sts -GraphSyracuseCpp.PrintPorts() -GraphSyracuseCpp.PrintThreads() - diff --git a/examples/GraphSyracuseCpp.xml b/examples/GraphSyracuseCpp.xml deleted file mode 100755 index 09d8a38..0000000 --- a/examples/GraphSyracuseCpp.xml +++ /dev/null @@ -1,457 +0,0 @@ - - - - - - - - - ? - ? - GraphSyracuseCpp - 1 - ? - - GraphSyracuseCpp - - - long - Syracuse\anOddInteger - - - - - long - test_IsEven\BoolEven - - - long - test_IsOne\BoolOne - - - long - result_Current\aCurrent - - - long - result_Count\aCount - - - - - - - - 11/3/2003 - 16:43:27 - 11/3/2003 - 16:43:37 - 1.04 - JR - ? - Syracuse algorithm - 0 - 0 - - - - - - SyrComponent - SyrComponent - Syracuse - 0 - ? - - Init - - - long - anOddInteger - - - - - Syr - aSyracuse - - - - - - - - 11/3/2003 - 16:43:27 - 11/3/2003 - 16:43:27 - 1.04 - ? - localhost/FactoryServer - ? - 9 - 207 - - - ? - ? - test_IsEven - 2 - ? - - IsEven - - - Syr - aSyracuse - - - - - long - BoolEven - - - - - - - - 11/3/2003 - 16:43:27 - 11/3/2003 - 16:43:27 - 1.04 - ? - ? - ? - 197 - 407 - - - ? - ? - test_IsOne - 2 - ? - - IsOne - - - Syr - aSyracuse - - - - - long - BoolOne - - - - - - - - 11/3/2003 - 16:43:27 - 11/3/2003 - 16:43:27 - 1.04 - ? - ? - ? - 208 - 59 - - - ? - ? - m3p1_M3p1 - 2 - ? - - M3p1 - - - Syr - aSyracuse - - - - - - - - - - 11/3/2003 - 16:43:27 - 11/3/2003 - 16:43:27 - 1.04 - ? - ? - ? - 418 - 408 - - - ? - ? - div2_Div2 - 2 - ? - - Div2 - - - Syr - aSyracuse - - - - - - - - - - 11/3/2003 - 16:43:27 - 11/3/2003 - 16:43:27 - 1.04 - ? - ? - ? - 414 - 10 - - - ? - ? - incr_Incr - 2 - ? - - Incr - - - Syr - aSyracuse - - - - - - - - - - 11/3/2003 - 16:43:27 - 11/3/2003 - 16:43:27 - 1.04 - ? - ? - ? - 416 - 207 - - - ? - ? - result_Current - 2 - ? - - Current - - - Syr - aSyracuse - - - - - long - aCurrent - - - - - - - - 11/3/2003 - 16:43:27 - 11/3/2003 - 16:43:27 - 1.04 - ? - ? - ? - 603 - 216 - - - ? - ? - result_Count - 2 - ? - - Count - - - Syr - aSyracuse - - - - - long - aCount - - - - - - - - 11/3/2003 - 16:43:27 - 11/3/2003 - 16:43:27 - 1.04 - ? - ? - ? - 803 - 212 - - - - - - Syracuse - aSyracuse - test_IsEven - aSyracuse - - - 175 - 559 - - - 175 - 359 - - - - - Syracuse - aSyracuse - test_IsOne - aSyracuse - - - 177 - 211 - - - 177 - 359 - - - - - Syracuse - aSyracuse - m3p1_M3p1 - aSyracuse - - - 388 - 560 - - - 388 - 359 - - - - - Syracuse - aSyracuse - div2_Div2 - aSyracuse - - - 389 - 162 - - - 389 - 359 - - - - - Syracuse - aSyracuse - incr_Incr - aSyracuse - - - - - Syracuse - aSyracuse - result_Current - aSyracuse - - - 590 - 368 - - - 590 - 390 - - - 388 - 390 - - - 388 - 359 - - - - - Syracuse - aSyracuse - result_Count - aSyracuse - - - 785 - 364 - - - 785 - 391 - - - 389 - 391 - - - 389 - 357 - - - - - - - - GraphSyracuseCpp - Syracuse\anOddInteger - Syracuse - anOddInteger - - 3 - 31 - - - - - - - diff --git a/examples/GraphTwoLoops.py b/examples/GraphTwoLoops.py new file mode 100644 index 0000000..98b1989 --- /dev/null +++ b/examples/GraphTwoLoops.py @@ -0,0 +1,132 @@ + +# Generated python file of Graph GraphTwoLoops + +from SuperV import * + +# Graph creation of GraphTwoLoops +def DefGraphTwoLoops() : + GraphTwoLoops = Graph( 'GraphTwoLoops' ) + GraphTwoLoops.SetName( 'GraphTwoLoops' ) + GraphTwoLoops.SetAuthor( 'JR' ) + GraphTwoLoops.SetComment( '' ) + GraphTwoLoops.Coords( 0 , 0 ) + + # Creation of Factory Nodes + + # Creation of Loop Nodes + PyLoop1 = [] + PyLoop1.append( 'def Loop1(Index,Max) : ' ) + PyLoop1.append( ' return Index,Max ' ) + PyLoop1.append( '' ) + PyMoreLoop1 = [] + PyMoreLoop1.append( 'import time ' ) + PyMoreLoop1.append( 'def More(Index,Max) : ' ) + PyMoreLoop1.append( ' time.sleep(2) ' ) + PyMoreLoop1.append( ' DoLoop = 0 ' ) + PyMoreLoop1.append( ' if Index < Max : ' ) + PyMoreLoop1.append( ' DoLoop = 1 ' ) + PyMoreLoop1.append( ' return DoLoop,Index,Max ' ) + PyMoreLoop1.append( '' ) + PyNextLoop1 = [] + PyNextLoop1.append( 'def Next(Index,Max) : ' ) + PyNextLoop1.append( ' Index = Index + 1 ' ) + PyNextLoop1.append( ' return Index,Max ' ) + PyNextLoop1.append( '' ) + Loop1,EndLoop1 = GraphTwoLoops.LNode( 'Loop1' , PyLoop1 , 'More' , PyMoreLoop1 , 'Next' , PyNextLoop1 ) + EndLoop1.SetName( 'EndLoop1' ) + EndLoop1.SetAuthor( '' ) + EndLoop1.SetComment( 'Compute Node' ) + EndLoop1.Coords( 634 , 177 ) + PyEndLoop1 = [] + EndLoop1.SetPyFunction( 'EndLoop1' , PyEndLoop1 ) + ILoop1DoLoop = Loop1.GetInPort( 'DoLoop' ) + ILoop1Index = Loop1.InPort( 'Index' , 'long' ) + ILoop1Max = Loop1.InPort( 'Max' , 'long' ) + ILoop1Gate = Loop1.GetInPort( 'Gate' ) + OLoop1DoLoop = Loop1.GetOutPort( 'DoLoop' ) + OLoop1Index = Loop1.GetOutPort( 'Index' ) + OLoop1Max = Loop1.GetOutPort( 'Max' ) + IEndLoop1DoLoop = EndLoop1.GetInPort( 'DoLoop' ) + IEndLoop1Index = EndLoop1.GetInPort( 'Index' ) + IEndLoop1Max = EndLoop1.GetInPort( 'Max' ) + IEndLoop1Gate = EndLoop1.GetInPort( 'Gate' ) + OEndLoop1DoLoop = EndLoop1.GetOutPort( 'DoLoop' ) + OEndLoop1Index = EndLoop1.GetOutPort( 'Index' ) + OEndLoop1Max = EndLoop1.GetOutPort( 'Max' ) + OEndLoop1Gate = EndLoop1.GetOutPort( 'Gate' ) + Loop1.SetName( 'Loop1' ) + Loop1.SetAuthor( '' ) + Loop1.SetComment( 'Compute Node' ) + Loop1.Coords( 7 , 175 ) + + PyLoop = [] + PyMoreLoop = [] + PyMoreLoop.append( '' ) + PyNextLoop = [] + PyNextLoop.append( 'def Next(Index,Max) : ' ) + PyNextLoop.append( ' Index = Index + 1 ' ) + PyNextLoop.append( ' return Index,Max ' ) + PyNextLoop.append( '' ) + Loop,EndLoop = GraphTwoLoops.LNode( '' , PyLoop , '' , PyMoreLoop , 'Next' , PyNextLoop ) + EndLoop.SetName( 'EndLoop' ) + EndLoop.SetAuthor( '' ) + EndLoop.SetComment( 'Compute Node' ) + EndLoop.Coords( 426 , 180 ) + PyEndLoop = [] + PyEndLoop.append( 'import time ' ) + PyEndLoop.append( 'def EndLoop(DoLoop,Index,Max) : ' ) + PyEndLoop.append( ' time.sleep(1) ' ) + PyEndLoop.append( ' DoLoop = 0 ' ) + PyEndLoop.append( ' if Index < Max : ' ) + PyEndLoop.append( ' DoLoop = 1 ' ) + PyEndLoop.append( ' return DoLoop,Index,Max ' ) + PyEndLoop.append( '' ) + EndLoop.SetPyFunction( 'EndLoop' , PyEndLoop ) + ILoopDoLoop = Loop.GetInPort( 'DoLoop' ) + ILoopIndex = Loop.InPort( 'Index' , 'long' ) + ILoopMax = Loop.InPort( 'Max' , 'long' ) + ILoopGate = Loop.GetInPort( 'Gate' ) + OLoopDoLoop = Loop.GetOutPort( 'DoLoop' ) + OLoopIndex = Loop.GetOutPort( 'Index' ) + OLoopMax = Loop.GetOutPort( 'Max' ) + IEndLoopDoLoop = EndLoop.GetInPort( 'DoLoop' ) + IEndLoopIndex = EndLoop.GetInPort( 'Index' ) + IEndLoopMax = EndLoop.GetInPort( 'Max' ) + IEndLoopGate = EndLoop.GetInPort( 'Gate' ) + OEndLoopDoLoop = EndLoop.GetOutPort( 'DoLoop' ) + OEndLoopIndex = EndLoop.GetOutPort( 'Index' ) + OEndLoopMax = EndLoop.GetOutPort( 'Max' ) + OEndLoopGate = EndLoop.GetOutPort( 'Gate' ) + Loop.SetName( 'Loop' ) + Loop.SetAuthor( '' ) + Loop.SetComment( 'Compute Node' ) + Loop.Coords( 208 , 179 ) + + # Creation of Links + LLoop1IndexEndLoop1Index = GraphTwoLoops.Link( OLoop1Index , IEndLoop1Index ) + + LLoop1MaxEndLoop1Max = GraphTwoLoops.Link( OLoop1Max , IEndLoop1Max ) + + LLoop1GateLoopGate = GraphTwoLoops.Link( OLoop1Gate , ILoopGate ) + + LLoopIndexEndLoopIndex = GraphTwoLoops.Link( OLoopIndex , IEndLoopIndex ) + + LLoopMaxEndLoopMax = GraphTwoLoops.Link( OLoopMax , IEndLoopMax ) + + LEndLoopGateEndLoop1Gate = GraphTwoLoops.Link( OEndLoopGate , IEndLoop1Gate ) + + # Input datas + ILoop1Index.Input( 5 ) + ILoop1Max.Input( 15 ) + ILoopIndex.Input( 2 ) + ILoopMax.Input( 20 ) + + # Output Ports of the graph + #OEndLoop1Index = EndLoop1.GetOutPort( 'Index' ) + #OEndLoop1Max = EndLoop1.GetOutPort( 'Max' ) + #OEndLoopIndex = EndLoop.GetOutPort( 'Index' ) + #OEndLoopMax = EndLoop.GetOutPort( 'Max' ) + return GraphTwoLoops + + +GraphTwoLoops = DefGraphTwoLoops() diff --git a/examples/GraphTwoLoops.xml b/examples/GraphTwoLoops.xml new file mode 100644 index 0000000..2809c05 --- /dev/null +++ b/examples/GraphTwoLoops.xml @@ -0,0 +1,321 @@ + + + + + +? + ? + GraphTwoLoops + 1 + ? + +aNewDataFlow + + +long + Loop1__Index + +long + Loop1__Max + +long + Loop__Index + +long + Loop__Max + + +long + EndLoop1__Index + +long + EndLoop1__Max + +long + EndLoop__Index + +long + EndLoop__Max + + + 17/12/2004 - 11:3:21 + 17/12/2004 - 16:23:40 + 2.0 + JR + ? + ? + 0 + 0 + + +? + ? + Loop1 + 4 + EndLoop1 + +Loop1 + + +long + Index + +long + Max + + +long + Index + +long + Max + + + +Loop1 + + + + +More + + + + + + + + + +Next + + + + + 17/12/2004 - 16:23:40 + 17/12/2004 - 16:23:40 + 2.0 + ? + ? + Compute Node + 7 + 175 + +? + ? + EndLoop1 + 5 + Loop1 + +EndLoop1 + + +long + Index + +long + Max + + +long + Index + +long + Max + + + +EndLoop1 + + 17/12/2004 - 16:23:40 + 17/12/2004 - 16:23:40 + 2.0 + ? + ? + Compute Node + 634 + 177 + +? + ? + Loop + 4 + EndLoop + +Loop + + +long + Index + +long + Max + + +long + Index + +long + Max + + + +? + + +? + + +Next + + + + + 17/12/2004 - 16:23:40 + 17/12/2004 - 16:23:40 + 2.0 + ? + ? + Compute Node + 208 + 179 + +? + ? + EndLoop + 5 + Loop + +EndLoop + + +long + Index + +long + Max + + +long + Index + +long + Max + + + +EndLoop + + + + + + + + + 17/12/2004 - 16:23:40 + 17/12/2004 - 16:23:40 + 2.0 + ? + ? + Compute Node + 426 + 180 + + +Loop1 + DoLoop + EndLoop1 + DoLoop + + +Loop1 + Index + EndLoop1 + Index + + +Loop1 + Max + EndLoop1 + Max + + +Loop1 + Gate + Loop + Gate + + +EndLoop1 + DoLoop + Loop1 + DoLoop + + +Loop + DoLoop + EndLoop + DoLoop + + +Loop + Index + EndLoop + Index + + +Loop + Max + EndLoop + Max + + +EndLoop + DoLoop + Loop + DoLoop + + +EndLoop + Gate + EndLoop1 + Gate + + + +GraphTwoLoops + Loop1__Index + Loop1 + Index + +3 + 5 + + +GraphTwoLoops + Loop1__Max + Loop1 + Max + +3 + 15 + + +GraphTwoLoops + Loop__Index + Loop + Index + +3 + 2 + + +GraphTwoLoops + Loop__Max + Loop + Max + +3 + 20 + diff --git a/examples/GraphUndefinedSymbol.py b/examples/GraphUndefinedSymbol.py new file mode 100644 index 0000000..fe825f8 --- /dev/null +++ b/examples/GraphUndefinedSymbol.py @@ -0,0 +1,31 @@ + +# Generated python file of Graph GraphUndefinedSymbol + +from SuperV import * + +# Graph creation of GraphUndefinedSymbol +def DefGraphUndefinedSymbol() : + GraphUndefinedSymbol = Graph( 'GraphUndefinedSymbol' ) + GraphUndefinedSymbol.SetName( 'GraphUndefinedSymbol' ) + GraphUndefinedSymbol.SetAuthor( 'JR' ) + GraphUndefinedSymbol.SetComment( '' ) + GraphUndefinedSymbol.Coords( 0 , 0 ) + + # Creation of Factory Nodes + + UndefinedSymbol = GraphUndefinedSymbol.FNode( 'UndefinedSymbolComponent' , 'UndefinedSymbolComponent' , 'UndefinedSymbol' ) + UndefinedSymbol.SetName( 'UndefinedSymbol' ) + UndefinedSymbol.SetAuthor( '' ) + UndefinedSymbol.SetContainer( 'localhost/FactoryServer' ) + UndefinedSymbol.SetComment( 'UndefinedSymbol from UndefinedSymbolComponent' ) + UndefinedSymbol.Coords( 146 , 166 ) + IUndefinedSymbolGate = UndefinedSymbol.GetInPort( 'Gate' ) + OUndefinedSymbolreturn = UndefinedSymbol.GetOutPort( 'return' ) + OUndefinedSymbolGate = UndefinedSymbol.GetOutPort( 'Gate' ) + + # Output Ports of the graph + #OUndefinedSymbolreturn = UndefinedSymbol.GetOutPort( 'return' ) + return GraphUndefinedSymbol + + +GraphUndefinedSymbol = DefGraphUndefinedSymbol() diff --git a/examples/GraphUndefinedSymbol.xml b/examples/GraphUndefinedSymbol.xml new file mode 100644 index 0000000..f4d8d26 --- /dev/null +++ b/examples/GraphUndefinedSymbol.xml @@ -0,0 +1,53 @@ + + + + + +? + ? + GraphUndefinedSymbol + 1 + ? + +GraphUndefinedSymbol + + + +long + UndefinedSymbol__return + + + 8/12/2004 - 18:16:21 + 8/12/2004 - 18:16:32 + 2.0 + JR + ? + ? + 0 + 0 + + +UndefinedSymbolComponent + UndefinedSymbolComponent + UndefinedSymbol + 0 + ? + +UndefinedSymbol + + + +long + return + + + 8/12/2004 - 18:16:32 + 8/12/2004 - 18:16:32 + 2.0 + ? + localhost/FactoryServer + UndefinedSymbol from UndefinedSymbolComponent + 146 + 166 + + diff --git a/examples/GraphVoidMoreLoop.py b/examples/GraphVoidMoreLoop.py new file mode 100644 index 0000000..e83d66d --- /dev/null +++ b/examples/GraphVoidMoreLoop.py @@ -0,0 +1,97 @@ + +# Generated python file of Graph GraphNonVoidEndLoop_1 + +from SuperV import * + +# Graph creation of GraphNonVoidEndLoop_1 +def DefGraphNonVoidEndLoop_1() : + GraphNonVoidEndLoop_1 = Graph( 'GraphNonVoidEndLoop_1' ) + GraphNonVoidEndLoop_1.SetName( 'GraphNonVoidEndLoop_1' ) + GraphNonVoidEndLoop_1.SetAuthor( '' ) + GraphNonVoidEndLoop_1.SetComment( '' ) + GraphNonVoidEndLoop_1.Coords( 0 , 0 ) + + # Creation of Factory Nodes + + # Creation of Loop Nodes + PyInit = [] + PyInit.append( 'def Init(Index,Min,Max,Incr) : ' ) + PyInit.append( ' if Min <= Max : ' ) + PyInit.append( ' Index = Min ' ) + PyInit.append( ' else : ' ) + PyInit.append( ' Index = Max ' ) + PyInit.append( ' print 'Init',Index,Min,Max,Incr ' ) + PyInit.append( ' return Index,Min,Max,Incr ' ) + PyMoreInit = [] + PyMoreInit.append( ' ' ) + PyNextInit = [] + PyNextInit.append( 'import time ' ) + PyNextInit.append( 'def Next(Index,Min,Max,Incr) : ' ) + PyNextInit.append( ' time.sleep(2) ' ) + PyNextInit.append( ' Index = Index + Incr ' ) + PyNextInit.append( ' print 'Next', Index,Min,Max,Incr ' ) + PyNextInit.append( ' return Index,Min,Max,Incr ' ) + Init,EndInit = GraphNonVoidEndLoop_1.LNode( 'Init' , PyInit , '' , PyMoreInit , 'Next' , PyNextInit ) + EndInit.SetName( 'EndInit' ) + EndInit.SetAuthor( '' ) + EndInit.SetComment( 'Compute Node' ) + EndInit.Coords( 411 , 260 ) + PyEndInit = [] + PyEndInit.append( 'def EndLoop(DoLoop,Index,Min,Max,Incr) : ' ) + PyEndInit.append( ' print 'EndLoop',DoLoop,Index,Min,Max,Incr ' ) + PyEndInit.append( ' if Index == Max : ' ) + PyEndInit.append( ' DoLoop = 0 ' ) + PyEndInit.append( ' return DoLoop,Index,Min,Max,Incr ' ) + PyEndInit.append( '' ) + EndInit.SetPyFunction( 'EndLoop' , PyEndInit ) + IInitInitLoop = Init.GetInPort( 'InitLoop' ) + IInitIndex = Init.InPort( 'Index' , 'long' ) + IInitMin = Init.InPort( 'Min' , 'long' ) + IInitMax = Init.InPort( 'Max' , 'long' ) + IInitIncr = Init.InPort( 'Incr' , 'long' ) + IInitGate = Init.GetInPort( 'Gate' ) + OInitDoLoop = Init.GetOutPort( 'DoLoop' ) + OInitIndex = Init.GetOutPort( 'Index' ) + OInitMin = Init.GetOutPort( 'Min' ) + OInitMax = Init.GetOutPort( 'Max' ) + OInitIncr = Init.GetOutPort( 'Incr' ) + IEndInitDoLoop = EndInit.GetInPort( 'DoLoop' ) + IEndInitIndex = EndInit.GetInPort( 'Index' ) + IEndInitMin = EndInit.GetInPort( 'Min' ) + IEndInitMax = EndInit.GetInPort( 'Max' ) + IEndInitIncr = EndInit.GetInPort( 'Incr' ) + IEndInitGate = EndInit.GetInPort( 'Gate' ) + OEndInitDoLoop = EndInit.GetOutPort( 'DoLoop' ) + OEndInitIndex = EndInit.GetOutPort( 'Index' ) + OEndInitMin = EndInit.GetOutPort( 'Min' ) + OEndInitMax = EndInit.GetOutPort( 'Max' ) + OEndInitIncr = EndInit.GetOutPort( 'Incr' ) + Init.SetName( 'Init' ) + Init.SetAuthor( '' ) + Init.SetComment( 'Compute Node' ) + Init.Coords( 17 , 257 ) + + # Creation of Links + LInitIndexEndInitIndex = GraphNonVoidEndLoop_1.Link( OInitIndex , IEndInitIndex ) + + LInitMinEndInitMin = GraphNonVoidEndLoop_1.Link( OInitMin , IEndInitMin ) + + LInitMaxEndInitMax = GraphNonVoidEndLoop_1.Link( OInitMax , IEndInitMax ) + + LInitIncrEndInitIncr = GraphNonVoidEndLoop_1.Link( OInitIncr , IEndInitIncr ) + + # Input datas + IInitIndex.Input( 0 ) + IInitMin.Input( 5 ) + IInitMax.Input( 10 ) + IInitIncr.Input( 1 ) + + # Output Ports of the graph + #OEndInitIndex = EndInit.GetOutPort( 'Index' ) + #OEndInitMin = EndInit.GetOutPort( 'Min' ) + #OEndInitMax = EndInit.GetOutPort( 'Max' ) + #OEndInitIncr = EndInit.GetOutPort( 'Incr' ) + return GraphNonVoidEndLoop_1 + + +GraphNonVoidEndLoop_1 = DefGraphNonVoidEndLoop_1() diff --git a/examples/GraphVoidMoreLoop.xml b/examples/GraphVoidMoreLoop.xml new file mode 100644 index 0000000..6126ed7 --- /dev/null +++ b/examples/GraphVoidMoreLoop.xml @@ -0,0 +1,239 @@ + + + + + +? + ? + GraphNonVoidEndLoop_1 + 1 + ? + +GraphNonVoidEndLoop_1 + + +long + Init__Index + +long + Init__Min + +long + Init__Max + +long + Init__Incr + + +long + EndInit__Index + +long + EndInit__Min + +long + EndInit__Max + +long + EndInit__Incr + + + 24/3/2003 - 14:44:35 + 16/12/2004 - 11:17:3 + 1.04 + ? + ? + ? + 0 + 0 + + +? + ? + Init + 4 + EndInit + +Init + + +long + Index + +long + Min + +long + Max + +long + Incr + + +long + Index + +long + Min + +long + Max + +long + Incr + + + +Init + + + + + + + + +? + + +Next + + + + + + + 16/12/2004 - 11:17:3 + 16/12/2004 - 11:17:3 + 1.04 + ? + ? + Compute Node + 17 + 257 + +? + ? + EndInit + 5 + Init + +EndInit + + +long + Index + +long + Min + +long + Max + +long + Incr + + +long + Index + +long + Min + +long + Max + +long + Incr + + + +EndLoop + + + + + + + 16/12/2004 - 11:17:3 + 16/12/2004 - 11:17:3 + 1.04 + ? + ? + Compute Node + 411 + 260 + + +Init + DoLoop + EndInit + DoLoop + + +Init + Index + EndInit + Index + + +Init + Min + EndInit + Min + + +Init + Max + EndInit + Max + + +Init + Incr + EndInit + Incr + + +EndInit + DoLoop + Init + InitLoop + + + +GraphNonVoidEndLoop_1 + Init__Index + Init + Index + +3 + 0 + + +GraphNonVoidEndLoop_1 + Init__Min + Init + Min + +3 + 5 + + +GraphNonVoidEndLoop_1 + Init__Max + Init + Max + +3 + 10 + + +GraphNonVoidEndLoop_1 + Init__Incr + Init + Incr + +3 + 1 + diff --git a/examples/Loop.xml b/examples/Loop.xml index 10776dd..7d4c2b0 100755 --- a/examples/Loop.xml +++ b/examples/Loop.xml @@ -253,7 +253,7 @@ Endfori DoLoop fori - InitLoop + DoLoop 8 diff --git a/examples/SyrStruct.xml b/examples/SyrStruct.xml index f5ca1dc..8038092 100644 --- a/examples/SyrStruct.xml +++ b/examples/SyrStruct.xml @@ -831,7 +831,7 @@ EndOfforN DoLoop forN - InitLoop + DoLoop whileNotOne @@ -867,7 +867,7 @@ EndOfwhileNotOne DoLoop whileNotOne - InitLoop + DoLoop EndOfwhileNotOne @@ -897,7 +897,7 @@ EndOffori DoLoop fori - InitLoop + DoLoop EndOffori @@ -945,7 +945,7 @@ EndOfwhileEven DoLoop whileEven - InitLoop + DoLoop EndOfwhileEven diff --git a/examples/TestSupervMedfieldLoopFori.xml b/examples/TestSupervMedfieldLoopFori.xml index 3641c63..0d10269 100755 --- a/examples/TestSupervMedfieldLoopFori.xml +++ b/examples/TestSupervMedfieldLoopFori.xml @@ -370,7 +370,7 @@ EndInit DoLoop Init - InitLoop + DoLoop 205 diff --git a/examples/TestSupervMedfieldLoopForiVisu.xml b/examples/TestSupervMedfieldLoopForiVisu.xml index 5086e6d..569f0f7 100755 --- a/examples/TestSupervMedfieldLoopForiVisu.xml +++ b/examples/TestSupervMedfieldLoopForiVisu.xml @@ -471,7 +471,7 @@ EndInit DoLoop Init - InitLoop + DoLoop 205 diff --git a/examples/test_events.xml b/examples/test_events.xml index 97a7ce8..5b10f82 100644 --- a/examples/test_events.xml +++ b/examples/test_events.xml @@ -147,7 +147,7 @@ EndInit DoLoop Init - InitLoop + DoLoop Func diff --git a/examples/test_superv_basic_loop.xml b/examples/test_superv_basic_loop.xml index 071f311..453f797 100755 --- a/examples/test_superv_basic_loop.xml +++ b/examples/test_superv_basic_loop.xml @@ -251,7 +251,7 @@ Endfori DoLoop fori - InitLoop + DoLoop 8 diff --git a/examples/testvisu20.xml b/examples/testvisu20.xml index 7d8e60e..bfb5866 100644 --- a/examples/testvisu20.xml +++ b/examples/testvisu20.xml @@ -437,7 +437,7 @@ EndOfInit DoLoop Init - InitLoop + DoLoop DisplayVitesse diff --git a/examples/testvisu20_multi.xml b/examples/testvisu20_multi.xml index 346e044..024ac2c 100644 --- a/examples/testvisu20_multi.xml +++ b/examples/testvisu20_multi.xml @@ -619,7 +619,7 @@ EndOfInit DoLoop Init - InitLoop + DoLoop EndOfInit @@ -721,7 +721,7 @@ EndOfLoopOnViews DoLoop LoopOnViews - InitLoop + DoLoop CreateView diff --git a/idl/SUPERV.idl b/idl/SUPERV.idl index 59157a4..f52bf13 100644 --- a/idl/SUPERV.idl +++ b/idl/SUPERV.idl @@ -42,9 +42,15 @@ 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, implemented in different kinds of nodes of the graph. */ - enum KindOfPort { UndefinedParameter , ServiceParameter , GateParameter , - InLineParameter , LoopParameter , SwitchParameter , - EndSwitchParameter , GOTOParameter , DataStreamParameter } ; + enum KindOfPort { UndefinedParameter , + ServiceParameter , + GateParameter , + InLineParameter , + LoopParameter , + SwitchParameter , + EndSwitchParameter , + GOTOParameter , + DataStreamParameter } ; /*! This enumeration contains a set of dependencies of InPorts and OutPorts. @@ -74,10 +80,18 @@ This enumeration contains a set of dependencies of Ports. /*! This enumeration contains a set of elements defining the type of the node. */ - enum KindOfNode { FactoryNode , DataFlowGraph , ComputingNode , - InLineNode , LoopNode , EndLoopNode , - SwitchNode , EndSwitchNode , GOTONode , DataStreamGraph , - MacroNode ,UnknownNode }; + enum KindOfNode { FactoryNode , + DataFlowGraph , + ComputingNode , + InLineNode , + LoopNode , + EndLoopNode , + SwitchNode , + EndSwitchNode , + GOTONode , + DataStreamGraph , + MacroNode , + UnknownNode }; /*! This struct contains fields defining the date. @@ -95,26 +109,40 @@ This enumeration contains a set of elements defining the type of operation, whic on this node(graph). */ - enum GraphEvent { UndefinedEvent , NoEvent , NewThreadEvent , - WaitingEvent , ReadyEvent , - RunningEvent , DoneEvent , ErroredEvent , - SuspendEvent , ResumeEvent , - KillEvent , StopEvent , - ReRunEvent , ReStartEvent } ; + enum GraphEvent { UndefinedEvent , + NoEvent , + NewThreadEvent , + WaitingEvent , + ReadyEvent , + RunningEvent , + DoneEvent , + ErroredEvent , + SuspendEvent , + ResumeEvent , + KillEvent , + StopEvent } ; // UndefinedState : Non existing Node, Port etc... /*! This enumeration contains a set of elements defining the current state of the node(graph). */ - enum GraphState { UndefinedState , NoState , EditingState , SuspendState , - WaitingState , ReadyState , SuspendReadyState , + enum GraphState { UndefinedState , + NoState , + EditingState , + SuspendState , + WaitingState , + ReadyState , + SuspendReadyState , RunningState , - DoneState , ErrorState , - SuspendDoneState , SuspendErroredState , - KillState , StopState , - ReRunState , ReStartState , - NumberOfGraphStates } ; + DoneState , + ErrorState , + SuspendDoneState , + SuspendErroredState , + KillState , + StopState , + LoadingState, + NumberOfGraphStates } ; /*! A sequence of string values. */ @@ -181,18 +209,17 @@ This enumeration contains a set of elements defining the %ControlState of the no 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 , + enum ControlState { VoidState , + ToSuspendStartState , + ToSuspendState , + ToSuspendDoneState , + ToKillState , + ToKillDoneState , + ToStopState , NumberOfControlStates } ; - - - - - //////////////// /*! \brief interface %SuperG @@ -538,26 +565,8 @@ If not Suspended : cancels the current ControlState ( Suspend, Kill, ...) */ boolean Resume(); -/*! - Restarts execution of the node. -*/ - boolean ReRun(); -/*! -Restarts execution of the graph beginning from a definite node. -*/ - boolean ReRunAt( in string aNodeName ); -/*! - Restarts and suspends execution of the node(graph). -*/ - boolean ReStart(); -/*! -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 ); - - // Control state required : Kill, Suspend, Stop +// Control state required : Kill, Suspend, Stop /*! Returns control state of the node(graph). */ @@ -568,6 +577,7 @@ Clears the control state of the node(graph). void ControlClear() ; boolean ContainerKill(); + /*! Sets the position of the node in the window. */ @@ -811,148 +821,153 @@ This interface includes a set of methods used for management of the graphs in %S Engines::Component ComponentRef( in string aComputerContainer , in string aComponentName ) ; -/*! - Creates a link connecting two ports (%Output %Port and %Input %Port) of the nodes in a Graph -*/ + /*! Creates a link connecting two ports (%Output %Port and %Input %Port) of the nodes in a Graph + */ 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. -*/ + /*! + 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. -*/ + + /*! + 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 ) ; -/*! -Returns True if the graph is read Only. -*/ + + /*! + Returns True if the graph is read Only. + */ boolean IsReadOnly() ; -/*! - Starts asynchronous execution of the graph. -*/ + /*! + Starts asynchronous execution of the graph. + */ 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. -\param aNode %Node for which this method is called -\param anEvent An operation, which has been performed on this node(graph). -\param aState Current state of the graph -*/ + /*! + 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. + \param aNode %Node for which this method is called + \param anEvent An operation, which has been performed on this node(graph). + \param aState Current state of the graph + */ 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. - 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). -\param aState Current state of the graph -*/ + /*! + 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. + 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). + \param aState Current state of the graph + */ boolean Event( out SUPERV::CNode aNode , out SUPERV::GraphEvent anEvent , out SUPERV::GraphState aState ) ; - + // 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 -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). -\param aState Current state of the graph -*/ + /*! + 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 + 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). + \param aState Current state of the graph + */ boolean EventW( out SUPERV::CNode aNode , out SUPERV::GraphEvent anEvent , out SUPERV::GraphState aState ) ; -/*! \name Methods used for inner debugging purposes of threads management : -*/ -/*@{*/ - + /*! \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 currently running threads. -*/ + /*! + Returns the number of currently running threads. + */ long Threads(); -/*! -Returns the number of suspended threads. -*/ + /*! + Returns the number of suspended threads. + */ long SuspendedThreads(); -/*! -Returns True if the graph is valid. -*/ + /*! + Returns True if the graph is valid. + */ boolean IsValid() ; -/*! -Returns True if the graph can be executed. -*/ + /*! + Returns True if the graph can be executed. + */ boolean IsExecutable() ; -/*! -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() ; - + long LastLevelDone() ; - -/*! - Launches step-by-step execution of the graph. -\note The execution is suspended immediatly after performance of operations of the first node and -user can specify the nodes, where execution will be again suspended after its resuming. -*/ + + /*! + Launches step-by-step execution of the graph. + \note The execution is suspended immediatly after performance of operations of the first node and + user can specify the nodes, where execution will be again suspended after its resuming. + */ boolean Start() ; -/*! -Allows to copy one graph into another. -*/ + /*! + Allows to copy one graph into another. + */ SUPERV::Graph Copy() ; -/*! -Convert a FlowGraph to a StreamGraph. -*/ + /*! + Convert a FlowGraph to a StreamGraph. + */ SUPERV::StreamGraph ToStreamGraph() ; -/*! -Merges two graphs -*/ + /*! + Merges two graphs + */ boolean Merge( in Graph aGraph ) ; -/*! -Returns a list of nodes of the graph. -*/ + /*! + Returns a list of nodes of the graph. + */ SUPERV::ListOfNodes Nodes() ; -/*! -Returns a list of links of the graph. -*/ + /*! + Returns a list of links of the graph. + */ SUPERV::ListOfLinks GLinks() ; -/*! -Gets IOR of the garph. -*/ + /*! + Gets IOR of the garph. + */ string getIOR(); - -/*! -Returns the number of independent subgraphs -*/ + + /*! + Returns the number of independent subgraphs + */ long SubGraphsNumber() ; -/*! -Returns a list of Nodes of a SubGraph. -*/ + /*! + Returns a list of Nodes of a SubGraph. + */ SUPERV::ListOfNodes SubGraphsNodes( in long SubGraphNumber ) ; + /*! Forces use of Editor's data model and destroy of Executor + */ + void Editing(); + } ; @@ -1087,6 +1102,14 @@ Sets the location of a coordinate point of the link. // void Destroy() ; + /*! Checks if the types of Ports that it connects are compatible + */ + boolean IsValid(); + + /*! Check if the Link equals to the another given Link + */ + boolean IsEqual( in SUPERV::Link aLink ); + } ; diff --git a/src/GraphBase/DataFlowBase_ComputingNode.cxx b/src/GraphBase/DataFlowBase_ComputingNode.cxx index 46c4407..8b1d3e7 100644 --- a/src/GraphBase/DataFlowBase_ComputingNode.cxx +++ b/src/GraphBase/DataFlowBase_ComputingNode.cxx @@ -608,6 +608,11 @@ GraphBase::InPort * GraphBase::ComputingNode::AddInPort( const char * InputParam const SUPERV::KindOfPort aKindOfPort , int index ) { cdebug << "AddInPort " << Name() << " ConnectedInPortsNumber " << ConnectedInPortsNumber() << endl ; +// JR 12.01.2005 : InitLoop and DoLoop are reserved parameter names in LoopNodes : + if ( IsLoopNode() && ( strcmp( InputParameterName , "InitLoop" ) == 0 || + strcmp( InputParameterName , "DoLoop" ) == 0 ) ) { + return NULL ; + } return GraphBase::PortsOfNode::AddInPort( _ORB , NamePtr() , Kind() , InputParameterName , @@ -678,6 +683,70 @@ GraphBase::OutDataStreamPort * GraphBase::ComputingNode::AddOutDataStreamPort( c } +bool GraphBase::ComputingNode::CheckLoop(GraphBase::LoopNode * aLoopNode , + GraphBase::EndOfLoopNode * anEndLoopNode ) const { + cdebug_in << Name() << "->GraphBase::ComputingNode::CheckLoop( " << aLoopNode->Name() << " , " + << anEndLoopNode->Name() << ") LinkedNodesSize " + << LinkedNodesSize() << endl; + + int i ; + if ( LinkedNodesSize() == 0 && !IsDataFlowNode() && !IsDataStreamNode() ) { + cdebug_out << Name() << "->GraphBase::ComputingNode::CheckLoop( " << aLoopNode->Name() + << " , " << anEndLoopNode->Name() << ") LinkedNodesSize " + << LinkedNodesSize() << " false" << endl; + return false ; + } +// We check that all nodes linked to that node go to the end of LoopNode : + for ( i = 0 ; i < LinkedNodesSize() ; i++ ) { + GraphBase::ComputingNode * aNode = (GraphBase::ComputingNode * ) LinkedNodes( i ) ; + cdebug << i << ". " << Name() << " Linked to " << aNode->Name() << endl ; + if ( !aNode->IsEndLoopNode() || aNode != anEndLoopNode ) { + if ( !aNode->CheckLoop( aLoopNode , anEndLoopNode ) ) { + cdebug_out << Name() << "->GraphBase::ComputingNode::CheckLoop( " << aLoopNode->Name() + << " , " << anEndLoopNode->Name() << ") LinkedNodesSize " + << LinkedNodesSize() << " false" << endl; + return false ; + } + } + } + cdebug_out << Name() << "->GraphBase::ComputingNode::CheckLoop( " << aLoopNode->Name() << " , " + << anEndLoopNode->Name() << ") LinkedNodesSize " + << LinkedNodesSize() << " true" << endl; + return true ; +} + +bool GraphBase::ComputingNode::CheckEndLoop(GraphBase::LoopNode * aLoopNode , + GraphBase::EndOfLoopNode * anEndLoopNode ) const { + cdebug_in << Name() << "->GraphBase::ComputingNode::CheckEndLoop( " << aLoopNode->Name() << " , " + << anEndLoopNode->Name() << ") LinkedFromNodesSize " + << LinkedFromNodesSize() << endl; + + int i ; + if ( LinkedFromNodesSize() == 0 ) { + cdebug_out << Name() << "->GraphBase::ComputingNode::CheckEndLoop( " << aLoopNode->Name() + << " , " << anEndLoopNode->Name() << ") LinkedFromNodesSize " + << LinkedFromNodesSize() << " false" << endl; + return false ; + } +// We have to check that all nodes linked from that node go to the beginning of LoopNode : + for ( i = 0 ; i < LinkedFromNodesSize() ; i++ ) { + GraphBase::ComputingNode * aNode = (GraphBase::ComputingNode * ) LinkedFromNodes( i ) ; + cdebug << i << ". " << Name() << " Linked from " << aNode->Name() << endl ; + if ( !aNode->IsLoopNode() || aNode != aLoopNode ) { + if ( !aNode->CheckEndLoop( aLoopNode , anEndLoopNode ) ) { + cdebug_out << Name() << "->GraphBase::ComputingNode::CheckEndLoop( " << aLoopNode->Name() + << " , " << anEndLoopNode->Name() << ") LinkedFromNodesSize " + << LinkedFromNodesSize() << " false" << endl; + return false ; + } + } + } + cdebug_out << Name() << "->GraphBase::ComputingNode::CheckEndLoop( " << aLoopNode->Name() << " , " + << anEndLoopNode->Name() << ") LinkedFromNodesSize " + << LinkedFromNodesSize() << " true" << endl; + return true ; +} + #include #include #include diff --git a/src/GraphBase/DataFlowBase_ComputingNode.hxx b/src/GraphBase/DataFlowBase_ComputingNode.hxx index f11309c..35145a8 100644 --- a/src/GraphBase/DataFlowBase_ComputingNode.hxx +++ b/src/GraphBase/DataFlowBase_ComputingNode.hxx @@ -24,6 +24,9 @@ namespace GraphBase { class InLineNode ; + class LoopNode ; + class EndOfLoopNode ; + class ComputingNode : public StreamNode { private: @@ -225,10 +228,11 @@ namespace GraphBase { << " + 1 Service " << ServiceName() << endl ; ToNode->IncrConnectedInPortsNumber() ; } ; - bool RemoveLinkedNode( GraphBase::ComputingNode * ToNode ) { - bool RetVal = GraphBase::StreamNode::RemoveLinkedNode( ToNode ) ; + bool RemoveLinkedNode( GraphBase::ComputingNode * ToNode , + bool DoLinkedFromNode = true ) { + bool RetVal = GraphBase::StreamNode::RemoveLinkedNode( ToNode , DoLinkedFromNode ) ; if ( RetVal ) { - cdebug << "GraphBase::StreamNode::RemoveLinkedNode to " << ToNode->Name() << " from " + cdebug << "ComputingNode::RemoveLinkedNode to " << ToNode->Name() << " from " << Name() << " ConnectedInPortsNumber " << ToNode->ConnectedInPortsNumber() - 1 << endl ; ToNode->DecrConnectedInPortsNumber() ; @@ -240,7 +244,7 @@ namespace GraphBase { GraphBase::StreamNode::ReNameLinkedNode( OldNodeName , NewNodeName ) ; } ; void IncrConnectedInPortsNumber() { - cdebug << "IncrConnectedInPortsNumber " << Name() << " -> " + cdebug << "ComputingNode::IncrConnectedInPortsNumber " << Name() << " -> " << _ConnectedInPortsNumber+1 << endl ; _ConnectedInPortsNumber++ ; } ; void DecrConnectedInPortsNumber() { @@ -262,6 +266,11 @@ namespace GraphBase { } return false ; } ; + bool CheckLoop(GraphBase::LoopNode * aLoopNode , + GraphBase::EndOfLoopNode * anEndLoopNode ) const ; + bool CheckEndLoop(GraphBase::LoopNode * aLoopNode , + GraphBase::EndOfLoopNode * anEndLoopNode ) const ; + // const GraphBase::ListOfParameters * GetListOfParameters() const ; const long CpuUsed() ; diff --git a/src/GraphBase/DataFlowBase_Graph.cxx b/src/GraphBase/DataFlowBase_Graph.cxx index 1d057a0..d72d31d 100644 --- a/src/GraphBase/DataFlowBase_Graph.cxx +++ b/src/GraphBase/DataFlowBase_Graph.cxx @@ -526,9 +526,16 @@ bool GraphBase::Graph::AddNode( GraphBase::ComputingNode * aNode ) { bool GraphBase::Graph::ReNameNode( const char* OldNodeName , const char* NewNodeName ) { - cdebug_in << "GraphBase::Graph::ReNameNode (" << OldNodeName << " , " << NewNodeName << ")" << endl; + cdebug_in << "GraphBase::Graph::ReNameNode (" << OldNodeName << " , " << NewNodeName << ") " + << endl; int i ; bool RetVal = false ; +//#if 0 + GraphBase::ComputingNode * anOldNode = GetChangeGraphNode( OldNodeName ) ; + for ( i = 0 ; i < anOldNode->LinkedNodesSize() ; i++ ) { + cdebug << "LinkedNode " << i << " " << anOldNode->LinkedNodes( i )->Name() << endl ; + } +//#endif if ( !strcmp( OldNodeName , NewNodeName ) ) { RetVal = true ; } @@ -542,8 +549,18 @@ bool GraphBase::Graph::ReNameNode( const char* OldNodeName , SetGraphNodeIndex( NewNodeName , index ) ; GraphBase::ComputingNode * aNode = GetChangeGraphNode( index ) ; +// Update 'ToNode's Map from 'aNode' + cdebug << "Graph::ReNameNode " << aNode->Name() << " LinkedNodesSize " + << aNode->LinkedNodesSize() << endl ; + for ( i = 0 ; i < aNode->LinkedNodesSize() ; i++ ) { + GraphBase::StreamNode * ToNode = aNode->LinkedNodes( i ) ; + ToNode->ReNameLinkedFromNode( OldNodeName , NewNodeName ) ; + } +// Update 'FomNode's Map to 'aNode' +// Inports 'anInPort' of 'aNode' for ( i = aNode->GetNodeInPortsSize()-1 ; i >= 0 ; i-- ) { GraphBase::InPort * anInPort = aNode->GetChangeNodeInPort( i ) ; +// OutPort 'anOutPort' linked to 'anInPort' GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ; cdebug << i << ". " << aNode->Name() << " " << "GraphBase::Graph::ReNameNode of LinkedNode : from " ; if ( anOutPort ) { @@ -558,6 +575,7 @@ bool GraphBase::Graph::ReNameNode( const char* OldNodeName , cdebug << " fromDataConnected " << anOutPort->NodeName() << endl ; } else { +// Node 'FromNode' of 'anOutPort' GraphBase::ComputingNode * FromNode ; if ( strcmp( anOutPort->NodeName() , Name() ) ) { FromNode = GetChangeGraphNode( anOutPort->NodeName() ) ; @@ -565,6 +583,7 @@ bool GraphBase::Graph::ReNameNode( const char* OldNodeName , else { FromNode = this ; } +// Rename in _MapOfLinkedFromNodes of 'FromNode' cdebug << " fromConnected " << anOutPort->NodeName() << endl ; if ( anInPort->IsDataStream() ) { FromNode->ReNameStreamLinkedNode( OldNodeName , NewNodeName ) ; @@ -611,63 +630,135 @@ bool GraphBase::Graph::ReNameNode( const char* OldNodeName , } bool GraphBase::Graph::RemoveNode( const char* aNodeName ) { - cdebug_in << "Graph::RemoveNode (" << aNodeName << ") " << LinkedNodesSize() << " LinkedNodes :" - << endl; + cdebug_in << "Graph::RemoveNode (" << aNodeName << ") " << endl; int i ; bool RetVal = false ; int index = GetGraphNodeIndex( aNodeName ) ; GraphBase::ComputingNode * aNode = GetChangeGraphNode( index ) ; - for ( i = 0 ; i < LinkedNodesSize() ; i++ ) { - cdebug << " " << i << ". " << LinkedNodes( i ) << endl ; - } if ( aNode ) { - cdebug << "Graph::RemoveNode " << aNode->GetNodeInPortsSize() << " InPorts " << aNode->GetNodeOutPortsSize() - << " OutPorts" << endl ; - if ( aNode->GetNodeInPortsSize() ) { - for ( i = aNode->GetNodeInPortsSize()-1 ; i >= 0 ; i-- ) { - GraphBase::InPort * anInPort = aNode->GetChangeNodeInPort( i ) ; - cdebug << "InPort" << i << ". " << aNodeName << "( " << anInPort->PortName() << ") " - << anInPort->PortStatus() << " <-- " ; - GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ; - if ( anOutPort ) { - cdebug << anOutPort->NodeName() << "( " << anOutPort->PortName() << ") " << anOutPort->PortStatus() ; - } - cdebug << endl ; - if ( !anInPort->IsNotConnected() ) { - RetVal = true ; - if ( anOutPort->IsDataConnected() || anOutPort->IsExternConnected() ) { - cdebug << " Data/Extern" << endl ; - } + cdebug << "Graph::RemoveNode " << aNode->Name() << " : " << aNode->GetNodeInPortsSize() + << " InPorts " << aNode->GetNodeOutPortsSize() << " OutPorts " + << aNode->LinkedNodesSize() << " LinkedNodes " << aNode->LinkedFromNodesSize() + << " LinkedFromNodes IsEndSwitchNode " << aNode->IsEndSwitchNode() << endl ; + for ( i = 0 ; i < aNode->LinkedNodesSize() ; i++ ) { + cdebug << " LinkedNode" << i << ". " << aNode->LinkedNodes( i ) << " " + << aNode->LinkedNodes( i )->Name() << endl ; + } + if ( !aNode->IsEndLoopNode() ) { // The LoopNode is already deleted + for ( i = 0 ; i < aNode->LinkedFromNodesSize() ; i++ ) { + cdebug << " LinkedFromNode" << i << ". " << aNode->LinkedFromNodes( i ) << " " + << aNode->LinkedFromNodes( i )->Name() << endl ; + } + } + if ( !aNode->IsEndSwitchNode() ) { + if ( aNode->GetNodeInPortsSize() ) { + for ( i = aNode->GetNodeInPortsSize()-1 ; i >= 0 ; i-- ) { + GraphBase::InPort * anInPort = aNode->GetChangeNodeInPort( i ) ; + cdebug << "InPort" << i << ". " << aNodeName << "( " << anInPort->PortName() << ") " + << anInPort->PortStatus() << " <-- " ; + GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ; + if ( anOutPort && !( aNode->IsEndLoopNode() && anInPort->IsLoop() ) ) { + cdebug << anOutPort->NodeName() << "( " << anOutPort->PortName() << ") " << anOutPort->PortStatus() ; + } + cdebug << endl ; + if ( !anInPort->IsNotConnected() ) { + RetVal = true ; + if ( anOutPort->IsDataConnected() || anOutPort->IsExternConnected() ) { + cdebug << " Data/Extern" << endl ; + } + else { + GraphBase::ComputingNode * FromNode = GetChangeGraphNode( anOutPort->NodeName() ) ; + cdebug << "FromNode " << FromNode->Name() << " LinkedNodesSize " + << FromNode->LinkedNodesSize() << " and " << aNode->Name() + << " LinkedFromNodesSize " << aNode->LinkedFromNodesSize() << endl ; + // asv : 04.11.04 : IsGOTO -> IsOneOfGOTO, I believe that it fixes the bug 7120. +// JR 05.01.05 : IsOneOfGOTO is not ok : I shall check the bug 7120 with IsGOTONode +// if ( !FromNode->IsOneOfGOTONodes() ) { +// if ( !FromNode->IsGOTONode() ) { + if ( !FromNode->IsGOTONode() && + !( FromNode->IsEndLoopNode() && anInPort->IsLoop() ) ) { + if ( anInPort->IsDataStream() ) { + RetVal = FromNode->RemoveStreamLinkedNode( aNode ) ; + } + else { + RetVal = FromNode->RemoveLinkedNode( aNode ) ; + } + if ( !RetVal ) { + cdebug << "anOutPort->RemoveLinkedNode Error RetVal " << RetVal << endl ; + break ; + } + } + } + RetVal = anOutPort->RemoveInPort( anInPort ) ; + if ( !RetVal ) { + cdebug << "anOutPort->RemoveInPort( anInPort ) Error RetVal " << RetVal << endl ; + break ; + } + } else { - GraphBase::ComputingNode * FromNode = GetChangeGraphNode( anOutPort->NodeName() ) ; - // asv : 04.11.04 : IsGOTO -> IsOneOfGOTO, I believe that it fixes the bug 7120. - if ( !FromNode->IsOneOfGOTONodes() ) { - if ( anInPort->IsDataStream() ) { - RetVal = FromNode->RemoveStreamLinkedNode( aNode ) ; + RetVal = true ; + } + } + } + else { + RetVal = true ; + } + } + else { +// Special case of EndSwitchNodes : each Input port must be multi-connected. +// There is one link for each branch of the switch +// But in GraphBase::InPort there is only one field GraphBase::OutPort * +// At execution time there is no problem because only one branch of the switch +// may be executed and the Executor set the right OutPort in the field +// GraphBase::OutPort * of each InPort of the EndSwitchNode +// But here we must remove that node EndSwitch from the LinkedNodes field of +// terminal nodes of all branches. +// And also in the OutPorts of that terminal nodes of branches we must remove +// references to InPorts of the EndSwitchNode. + +// Explore LinkedFromnodes of the EndSwitchNode : + for ( i = aNode->LinkedFromNodesSize() - 1 ; i >= 0 ; i-- ) { + GraphBase::ComputingNode * aLinkedFromNode = (GraphBase::ComputingNode * ) aNode->LinkedFromNodes( i ) ; + cdebug << aLinkedFromNode->Name() << " linked to " << aNode->Name() << endl ; + int j ; + for ( j = aLinkedFromNode->GetNodeOutPortsSize() - 1 ; j >= 0 ; j-- ) { + GraphBase::OutPort * anOutPort = aLinkedFromNode->GetChangeNodeOutPort( j ) ; + cdebug << "OutPort" << j << ". Remove " << anOutPort->InPortsSize() + << " InPortsof OutPort : " << anOutPort->NodeName() << "( " + << anOutPort->PortName() << ") " + << anOutPort->PortStatus() << " :" << endl ; + int k ; + for ( k = anOutPort->InPortsSize() - 1 ; k >= 0 ; k-- ) { + GraphBase::InPort * anInPort = anOutPort->ChangeInPorts( k ) ; + if ( strcmp( anInPort->NodeName() , aNode->Name() ) == NULL ) { +// InPort of the EndSwitchNode + cdebug << " to InPort" << j << ". " << anInPort->NodeName() << "( " + << anInPort->PortName() << ") " + << anInPort->PortStatus() << endl ; + anInPort->RemoveOutPort() ; + if ( anOutPort->IsDataStream() ) { + aLinkedFromNode->RemoveStreamLinkedNode( aNode ) ; } else { - RetVal = FromNode->RemoveLinkedNode( aNode ) ; +// false ==> No error for aNode->LinkedFromNode() + RetVal = aLinkedFromNode->RemoveLinkedNode( aNode , false ) ; + if ( !RetVal ) { + cdebug << "aLinkedFromNode->RemoveLinkedNode Error RetVal " << RetVal << endl ; + break ; + } } +// Remove the InPort of the EndSwitchNode from that OutPort + RetVal = anOutPort->RemoveInPort( anInPort ) ; if ( !RetVal ) { - cdebug << "anOutPort->RemoveLinkedNode Error RetVal " << RetVal << endl ; + cdebug << "anOutPort->RemoveInPort( anInPort ) Error RetVal " << RetVal << endl ; break ; } } } - RetVal = anOutPort->RemoveInPort( anInPort ) ; - if ( !RetVal ) { - cdebug << "anOutPort->RemoveInPort( anInPort ) Error RetVal " << RetVal << endl ; - break ; - } - } - else { - RetVal = true ; - } + } } } - else { - RetVal = true ; - } + if ( RetVal ) { for ( i = aNode->GetNodeOutPortsSize() - 1 ; i >= 0 ; i-- ) { GraphBase::OutPort * anOutPort = aNode->GetChangeNodeOutPort( i ) ; @@ -699,7 +790,7 @@ bool GraphBase::Graph::RemoveNode( const char* aNodeName ) { cdebug << "anOutPort->RemoveLinkedNode Error RetVal " << RetVal << endl ; break ; } - RetVal = anOutPort->RemoveInPort( anOutPort->ChangeInPorts( j ) ) ; + RetVal = anOutPort->RemoveInPort( anInPort ) ; if ( !RetVal ) { cdebug << "anOutPort->RemoveInPort( anInPort ) Error RetVal " << RetVal << endl ; break ; @@ -712,15 +803,49 @@ bool GraphBase::Graph::RemoveNode( const char* aNodeName ) { } } } - if ( RetVal ) { + cdebug << "Graph::RemoveNode " << aNode->Name() << " : " << aNode->GetNodeInPortsSize() + << " InPorts " << aNode->GetNodeOutPortsSize() << " OutPorts " + << aNode->LinkedNodesSize() << " LinkedNodes " << aNode->LinkedFromNodesSize() + << " LinkedFromNodes " << endl ; + for ( i = 0 ; i < aNode->LinkedNodesSize() ; i++ ) { + cdebug << " LinkedNode" << i << ". " << aNode->LinkedNodes( i ) << " " + << aNode->LinkedNodes( i )->Name() << endl ; + } + for ( i = 0 ; i < aNode->LinkedFromNodesSize() ; i++ ) { + cdebug << " LinkedFromNode" << i << ". " << aNode->LinkedFromNodes( i ) << " " + << aNode->LinkedFromNodes( i )->Name() << endl ; + } +// Delete of aNode from the Graph : +// The LoopNode is needed by the delete of the EndLoopNode. So the LoopNode will be deleted +// when the EndLoopNode is deleted. It is the same for SwitchNode & EndSwitchNode + if ( RetVal && !aNode->IsLoopNode() && !aNode->IsSwitchNode() ) { + GraphBase::InLineNode * theCoupledNode = NULL ; + char * theCoupledNodeName = NULL ; + int CoupledIndex = -1 ; + if ( aNode->IsEndLoopNode() || aNode->IsEndSwitchNode() ) { + theCoupledNode = ((GraphBase::GOTONode * ) aNode)->CoupledNode() ; + theCoupledNodeName = ((GraphBase::GOTONode * ) aNode)->CoupledNodeName() ; + CoupledIndex = GetGraphNodeIndex( theCoupledNode->Name() ) ; + } delete aNode ; _GraphNodesSize -= 1 ; for ( i = index ; i < _GraphNodesSize ; i++ ) { - SetGraphNodeIndex( _GraphNodes[ i+1 ]->Name() , i ) ; _GraphNodes[ i ] = _GraphNodes[ i+1 ] ; + SetGraphNodeIndex( _GraphNodes[ i ]->Name() , i ) ; } _GraphNodes.resize( _GraphNodesSize+1 ) ; _MapOfGraphNodes.erase( aNodeName ) ; +// Delete of the LoopNode of that EndLoopNode or of the SwitchNode of that EndSwitchNode : + if ( theCoupledNode ) { + delete theCoupledNode ; + _GraphNodesSize -= 1 ; + for ( i = CoupledIndex ; i < _GraphNodesSize ; i++ ) { + _GraphNodes[ i ] = _GraphNodes[ i+1 ] ; + SetGraphNodeIndex( _GraphNodes[ i ]->Name() , i ) ; + } + _GraphNodes.resize( _GraphNodesSize+1 ) ; + _MapOfGraphNodes.erase( theCoupledNodeName ) ; + } RetVal = true ; } } @@ -750,7 +875,23 @@ bool GraphBase::Graph::AddLink( const char* FromNodeName , GraphBase::InPort *toPort = NULL ; if ( fromNode ) { - fromPort = fromNode->GetChangeOutPort( FromServiceParameterName ) ; + // asv : 29.12.04 : as I understand, replacement of "InitLoop" by "DoLoop" was + // done by JR in order to keep old graphs and batch test scripts working after change + // of special Loop's port name from "InitLoop" to "DoLoop". I suppose, it is not + // needed, all old graphs and tests must be changed to use "DoLoop" name for addressing + // this port.. It we don't do it, ANY port with "InitLoop" name will be replaced by "DoLoop" + // and it can cause unexpected bugs in future... So I comment out the replacement code. + //if ( strcmp( FromServiceParameterName , "InitLoop" ) ) { +//JR 12.01.05 : Yes the test is not good ; now I test that PortName only in LoopNodes ==> +// + old graphs will runs normally (it is not possible to ask CEA to edit their graphs) +// + in old graphs "InitLoop" and "DoLoop" were reserved parameter names (but not controlled) +// + in new graphs, I have added a control at port creation of that names : they are refused + if ( !(fromNode->IsLoopNode() && strcmp( FromServiceParameterName , "InitLoop" ) == 0 ) ) { + fromPort = fromNode->GetChangeOutPort( FromServiceParameterName ) ; + } + else { + fromPort = fromNode->GetChangeOutPort( "DoLoop" ) ; + } if ( !fromPort ) { cdebug << "ERROR AddLink fromPort " << FromServiceParameterName << " FromNode(" << FromNodeName << ") not found." << endl ; @@ -760,7 +901,14 @@ bool GraphBase::Graph::AddLink( const char* FromNodeName , cdebug << "ERROR AddLink FromNode " << FromNodeName << " not found." << endl ; } if ( toNode ) { - toPort = toNode->GetChangeInPort( ToServiceParameterName ) ; + // see comment above +// if ( strcmp( ToServiceParameterName , "InitLoop" ) ) { + if ( !(toNode->IsLoopNode() && strcmp( ToServiceParameterName , "InitLoop" ) == 0 ) ) { + toPort = toNode->GetChangeInPort( ToServiceParameterName ) ; + } + else { + toPort = toNode->GetChangeInPort( "DoLoop" ) ; + } if ( !toPort ) { cdebug << "ERROR AddLink toPort " << ToServiceParameterName << " ToNode(" << ToNodeName << ") not found." << endl ; @@ -921,6 +1069,12 @@ bool GraphBase::Graph::AddLink( GraphBase::ComputingNode *fromNode , toPort->Kind( SUPERV::EndSwitchParameter ) ; } } +// JR 12.01.2005 : an OutPort of a SwitchNode connected to a Gate can be connected only to Gate + else if ( fromNode->IsSwitchNode() && fromPort->IsSwitch() && !toPort->IsGate() ) { + cdebug << "toPort->AddLink Error( fromPort->IsSwitch() && !toPort->IsGate())." << endl ; + cdebug_out << "GraphBase::Graph::AddLink 0" << endl; + return false ; + } else if ( !fromPort->AddInPort( toPort ) ) { // --> MapOfInports in the OutPort cdebug << "!fromPort->AddLink Error." << endl ; cdebug_out << "GraphBase::Graph::AddLink 0" << endl; @@ -1030,11 +1184,19 @@ bool GraphBase::Graph::RemoveLink( const char* FromNodeName , if ( anInPort && ( anInPort->IsPortConnected() || anInPort->IsDataConnected() || anInPort->IsExternConnected() ) ) { - GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ; - RetVal = anOutPort->RemoveInPort( anInPort ) ; // ==> : -// anInPort->RemoveOutPort() ; - const char * FromNodeName = anOutPort->NodeName() ; +// JR 13.01.2005 : Bug if it is a link to an EndSwitchNode. The OutPort may be an other one !!! GraphBase::ComputingNode * fromNode = GetChangeGraphNode( FromNodeName ) ; + GraphBase::OutPort * anOutPort = NULL ; + if ( toNode->IsEndSwitchNode() ) { + anOutPort = fromNode->GetChangeOutPort( FromServiceParameterName ) ; + RetVal = anOutPort->RemoveInPort( anInPort ) ; + } + else { + anOutPort = anInPort->GetOutPort() ; + RetVal = anOutPort->RemoveInPort( anInPort ) ; + } +// anInPort->RemoveOutPort() ; // Already done in RemoveInPort +// const char * FromNodeName = anOutPort->NodeName() ; if ( RetVal ) { if ( fromNode ) { if ( anInPort->IsDataStream() ) { @@ -1047,6 +1209,36 @@ bool GraphBase::Graph::RemoveLink( const char* FromNodeName , if ( fromNode->IsSwitchNode() && !anOutPort->IsGate() && !toNode->IsEndSwitchNode() ) { anOutPort->Kind( SUPERV::InLineParameter ) ; } +// JR 13.01.2005 : Bug if it is a link to an EndSwitchNode. The InPort may be linked !!! + if ( toNode->IsEndSwitchNode() ) { + int i ; + int done = false ; + for ( i = 0 ; i < toNode->LinkedFromNodesSize() ; i++ ) { + GraphBase::StreamNode * fromNode = toNode->LinkedFromNodes( i ) ; + int j ; + for ( j = 0 ; j < fromNode->GetNodeOutPortsSize() ; j++ ) { + GraphBase::OutPort * fromOutPort = fromNode->GetChangeNodeOutPort( j ) ; + int k ; + for ( k = 0 ; k < fromOutPort->InPortsSize() ; k++ ) { + if ( strcmp( toNode->Name() , fromOutPort->InPorts( k )->NodeName() ) == 0 ) { +// Restore an OutPort in the InPort + anInPort->ChangeOutPort( fromOutPort ) ; + cdebug << "Graph::RemoveLink reestablish " << fromOutPort->NodeName() << "( " + << fromOutPort->PortName() << " ) in the InPort of EndSwitch : " + << toNode->Name() << "( " << anInPort->PortName() << " )" << endl; + done = true ; + break ; + } + } + if ( done ) { + break ; + } + } + if ( done ) { + break ; + } + } + } } } } @@ -2211,6 +2403,33 @@ bool GraphBase::Graph::Sort( int & SubStreamGraphsNumber ) { return true ; } +bool GraphBase::Graph::ValidLoops() const { + cdebug_in << "GraphBase::Graph::ValidLoops" << endl; + + int i ; + GraphBase::ComputingNode * aNode ; + for ( i = 0 ; i < GraphNodesSize() ; i++ ) { + aNode = GraphNodes( i ) ; + if ( aNode->IsLoopNode() ) { + GraphBase::LoopNode * aLoopNode = (GraphBase::LoopNode * ) aNode ; + GraphBase::EndOfLoopNode * anEndLoopNode ; + anEndLoopNode = (GraphBase::EndOfLoopNode * ) aLoopNode->CoupledNode() ; + if ( !aLoopNode->CheckLoop( aLoopNode , anEndLoopNode ) ) { + cdebug_out << "GraphBase::Graph::ValidLoops false aLoopNode " << aLoopNode->Name() + << endl; + return false ; + } + else if ( !anEndLoopNode->CheckEndLoop( aLoopNode , anEndLoopNode ) ) { + cdebug_out << "GraphBase::Graph::ValidLoops false anEndLoopNode " << anEndLoopNode->Name() + << endl; + return false ; + } + } + } + cdebug_out << "GraphBase::Graph::ValidLoops true" << endl; + return true ; +} + // Controle de la coherence des noeuds de calcul // Enregistrement dans la liste des noeuds "tete" de graphe @@ -2501,12 +2720,12 @@ const CORBA::Any * GraphBase::Graph::PortInData( const char* ToNodeName , anOutPort = anInPort->GetOutPort() ; if ( anOutPort ) { aRet = anOutPort->Value() ; - cdebug << "OutPort value " << anOutPort->NodeName() << "(" + cdebug << "Graph::PortInData OutPort value " << anOutPort->NodeName() << "(" << anOutPort->PortName() << ") --> InPort " << anInPort->NodeName() << "(" << anInPort->PortName() << ") " << anInPort->PortStatus() << endl ; } else { - cdebug << "GraphBase::Graph::PortInData " << ToNodeName << " " + cdebug << "Graph::PortInData GraphBase::Graph::PortInData " << ToNodeName << " " << ToServiceParameterName << " ERROR no OutPort" << endl ; } } @@ -2585,7 +2804,7 @@ bool GraphBase::Graph::StartComponent(const int aThread , if ( CORBA::is_nil( objComponent ) ) { cdebug_out << aThread << " StartComponent cannot FindOrLoad " << aComputerContainer - << " " << ComponentName << endl; + << " " << ComponentName << " ERROR" << endl; return 0 ; } else { @@ -2593,11 +2812,11 @@ bool GraphBase::Graph::StartComponent(const int aThread , if ( CORBA::is_nil( myContainer ) ) { cdebug_out << aThread << " GraphBase::Graph::StartComponent myContainer = LCC.FindContainer( '" - << aComputerContainer << "' ) Container does not exist" + << aComputerContainer << "' ) Container does not exist ERROR" << endl ; return 0 ; } } - cdebug_out << aThread << " GraphBase::Graph::StartComponent" << endl; + cdebug_out << aThread << " GraphBase::Graph::StartComponent " << RetVal << endl; return RetVal ; } diff --git a/src/GraphBase/DataFlowBase_Graph.hxx b/src/GraphBase/DataFlowBase_Graph.hxx index 8035528..6f4e1fd 100644 --- a/src/GraphBase/DataFlowBase_Graph.hxx +++ b/src/GraphBase/DataFlowBase_Graph.hxx @@ -149,7 +149,7 @@ namespace GraphBase { void SetGraphNodeIndex( const char *name , const int index ) { _MapOfGraphNodes[ name ] = index + 1 ; cdebug << "SetGraphNodeIndex of " << name << " in _MapOfGraphNodes : " - << index << " Node " << hex << (void *) _GraphNodes[ index ] + << index << " Node " << (void *) _GraphNodes[ index ] << " '" << _GraphNodes[ index ]->Name() << "'" << endl ; } ; void DelGraphNodeIndex( const char *name ) { @@ -299,6 +299,7 @@ namespace GraphBase { bool InLineServices() ; bool Sort( int & SubStreamGraphsNumber ) ; + bool ValidLoops() const ; bool ComputingNodes() const ; bool LinkLoopNodes(bool & NewLink ) ; bool DataServerNodes() const ; diff --git a/src/GraphBase/DataFlowBase_InPort.cxx b/src/GraphBase/DataFlowBase_InPort.cxx index a87227a..9f8f7b5 100644 --- a/src/GraphBase/DataFlowBase_InPort.cxx +++ b/src/GraphBase/DataFlowBase_InPort.cxx @@ -88,6 +88,24 @@ void GraphBase::InPort::StringValue(ostream & f ) const { f << "(undefined)" ; } +bool GraphBase::InPort::ChangeOutPort( OutPort * anOutPort ) { + if ( _OutPort ) { +// cdebug << "InPort::ChangeOutPort OutPort of InPort " << NodeName() << "( " +// << PortName() << " ) : " << _OutPort->NodeName() << "( " +// << _OutPort->PortName() << " ) changed to " << anOutPort->NodeName() +// << "( " << anOutPort->PortName() << " )" << endl ; +// cout << "InPort::ChangeOutPort OutPort of InPort " << NodeName() << "( " +// << PortName() << " ) : " << _OutPort->NodeName() << "( " +// << _OutPort->PortName() << " ) changed to " << anOutPort->NodeName() +// << "( " << anOutPort->PortName() << " )" << endl ; + } + if ( _InitialOutPort == NULL ) { + _InitialOutPort = _OutPort ; + } + _OutPort = anOutPort ; + return true ; +} + bool GraphBase::InPort::RemoveOutPort() { // Before to return the real status, callers should be checked ... if ( _OutPort == NULL ) { @@ -162,12 +180,6 @@ ostream & operator<< (ostream &f ,const SUPERV::GraphState & aState ) { case SUPERV::StopState : f << "StopState"; break; - case SUPERV::ReRunState : - f << "ReRunState"; - break; - case SUPERV::ReStartState : - f << "ReStartState"; - break; default : f << "SUPERV::GraphState_?"; break; diff --git a/src/GraphBase/DataFlowBase_InPort.hxx b/src/GraphBase/DataFlowBase_InPort.hxx index 467f360..5716725 100644 --- a/src/GraphBase/DataFlowBase_InPort.hxx +++ b/src/GraphBase/DataFlowBase_InPort.hxx @@ -81,12 +81,7 @@ namespace GraphBase { return false ; _OutPort = anOutPort ; return true ; } ; - bool ChangeOutPort( OutPort * anOutPort ) { - if ( _InitialOutPort == NULL ) { - _InitialOutPort = _OutPort ; - } - _OutPort = anOutPort ; - return true ; } ; + bool ChangeOutPort( OutPort * anOutPort ) ; bool InitialOutPort() { if ( _InitialOutPort ) { _OutPort = _InitialOutPort ; diff --git a/src/GraphBase/DataFlowBase_PortsOfNode.cxx b/src/GraphBase/DataFlowBase_PortsOfNode.cxx index a1ffbf4..e464f54 100644 --- a/src/GraphBase/DataFlowBase_PortsOfNode.cxx +++ b/src/GraphBase/DataFlowBase_PortsOfNode.cxx @@ -91,6 +91,8 @@ void GraphBase::PortsOfNode::DefPortsOfNode( const bool WithOutGate = (aKind == SUPERV::DataFlowGraph) || (aKind == SUPERV::DataStreamGraph) || (aKind == SUPERV::ComputingNode) || (aKind == SUPERV::FactoryNode) || (aKind == SUPERV::InLineNode) || (aKind == SUPERV::GOTONode) || + /* asv : 15.12.04 : adding out gate ports for Loop/EndLoop, too. p2.5, PAL7385*/ + (aKind == SUPERV::LoopNode) || (aKind == SUPERV::EndLoopNode) || (aKind == SUPERV::SwitchNode) || (aKind == SUPERV::EndSwitchNode) || (aKind == SUPERV::MacroNode) ; SUPERV::KindOfPort aPortKind = SUPERV::ServiceParameter ; @@ -132,10 +134,10 @@ void GraphBase::PortsOfNode::DefPortsOfNode( SALOME_ModuleCatalog::ServicesParameter anInLoopParameter ; _NodeInPortsSize = _NodeInPortsSize + 1 ; iVec += 1 ; - char *aParametername = "InitLoop" ; - if ( aKind == SUPERV::EndLoopNode ) { - aParametername = "DoLoop" ; - } +// char *aParametername = "InitLoop" ; +// if ( aKind == SUPERV::EndLoopNode ) { + char * aParametername = "DoLoop" ; +// } anInLoopParameter.Parametertype = CORBA::string_dup( "long" ) ; anInLoopParameter.Parametername = CORBA::string_dup( aParametername ) ; if ( _NodeInPortsSize > (int ) _NodeInPorts.size() ) { diff --git a/src/GraphBase/DataFlowBase_StreamNode.cxx b/src/GraphBase/DataFlowBase_StreamNode.cxx index 9b8c9a4..b3048d7 100644 --- a/src/GraphBase/DataFlowBase_StreamNode.cxx +++ b/src/GraphBase/DataFlowBase_StreamNode.cxx @@ -18,6 +18,7 @@ GraphBase::StreamNode::StreamNode() : _Name = NULL ; _Kind = SUPERV::UnknownNode ; _LinkedNodesSize = 0 ; + _LinkedFromNodesSize = 0 ; _LinkedStreamNodesSize = 0 ; _HeadNode = false ; _LevelNumber = -1 ; @@ -45,6 +46,7 @@ GraphBase::StreamNode::StreamNode( const char * NodeName , } Kind( DataFlowkind ) ; _LinkedNodesSize = 0 ; + _LinkedFromNodesSize = 0 ; _LinkedStreamNodesSize = 0 ; _HeadNode = false ; _LevelNumber = -1 ; @@ -136,12 +138,61 @@ void GraphBase::StreamNode::AddLinkedNode( GraphBase::StreamNode * ToNode ) { cdebug << Name() << "->GraphBase::StreamNode::AddLinkedNode( " << ToNode->Name() << " ) LinkedNodesSize " << _LinkedNodesSize << " [ " << index << " ] _LinkedInPortsNumber " << _LinkedInPortsNumber[ index ] << endl ; + + index = ToNode->GetLinkedFromNodeIndex( Name() ) ; + if ( index < 0 ) { + cdebug << ToNode->Name() << "<-GraphBase::StreamNode::AddLinkedFromNode( " << Name() + << " ) new LinkedFromNode " << endl ; + ToNode->_LinkedFromNodes.resize( ToNode->_LinkedFromNodesSize+1 ) ; + ToNode->_LinkedFromInPortsNumber.resize( ToNode->_LinkedFromNodesSize+1 ) ; + ToNode->_LinkedFromNodes[ ToNode->_LinkedFromNodesSize ] = this ; + ToNode->_LinkedFromInPortsNumber[ ToNode->_LinkedFromNodesSize ] = 1 ; + ToNode->SetLinkedFromNodeIndex( Name() , ToNode->_LinkedFromNodesSize ) ; + index = ToNode->_LinkedFromNodesSize ; + ToNode->_LinkedFromNodesSize++ ; + } + else { + cdebug << Name() << "->GraphBase::StreamNode::AddLinkedFromNode( " << ToNode->Name() + << " ) old LinkedFromNode " << ToNode->_LinkedFromNodes[index ]->Name() << endl ; + ToNode->_LinkedFromInPortsNumber[ index ] += 1 ; + } + cdebug << ToNode->Name() << "->GraphBase::StreamNode::AddLinkedFromNode( " << Name() + << " ) LinkedFromNodesSize " << ToNode->_LinkedFromNodesSize << " [ " << index + << " ] _LinkedFromInPortsNumber " << ToNode->_LinkedFromInPortsNumber[ index ] << endl ; } -bool GraphBase::StreamNode::RemoveLinkedNode( GraphBase::StreamNode * ToNode ) { - int index = GetLinkedNodeIndex( ToNode->Name() ) ; +bool GraphBase::StreamNode::RemoveLinkedNode( GraphBase::StreamNode * ToNode , + bool DoLinkedFromNode ) { + cdebug_in << "StreamNode::RemoveLinkedNode between " << Name() << " LinkedNodesSize " + << LinkedNodesSize() << " and " << ToNode->Name() << " LinkedFromNodesSize " + << ToNode->LinkedFromNodesSize() << endl ; +#if 1 + map< string , int >::iterator aMapOfLinkedNodesIterator ; + int i = 0 ; + for ( aMapOfLinkedNodesIterator = _MapOfLinkedNodes.begin() ; + aMapOfLinkedNodesIterator != _MapOfLinkedNodes.end() ; aMapOfLinkedNodesIterator++ ) { + cdebug << "_MapOfLinkedNodes" << i++ << " of " << Name() << " : " + << aMapOfLinkedNodesIterator->first << " --> " << aMapOfLinkedNodesIterator->second + << endl ; + } +#endif +#if 1 + map< string , int >::iterator aMapOfLinkedFromNodesIterator ; + int ifrom = 0 ; + for ( aMapOfLinkedFromNodesIterator = ToNode->_MapOfLinkedFromNodes.begin() ; + aMapOfLinkedFromNodesIterator != ToNode->_MapOfLinkedFromNodes.end() ; aMapOfLinkedFromNodesIterator++ ) { + cdebug << "_MapOfLinkedFromNodes" << ifrom++ << " of " << ToNode->Name() << " : " + << aMapOfLinkedFromNodesIterator->first << " --> " + << aMapOfLinkedFromNodesIterator->second << endl ; + } +#endif + + int index = -1 ; + if ( _LinkedNodesSize ) { + index = GetLinkedNodeIndex( ToNode->Name() ) ; + } if ( index >= 0 ) { - cdebug << "GraphBase::StreamNode::RemoveLinkedNode( to " << ToNode->Name() << " from " + cdebug << "GraphBase::StreamNode::RemoveLinkedNode to " << ToNode->Name() << " from " << Name() << " index : " << index << " LinkedInPortsNumber " << _LinkedInPortsNumber[ index ] << " - 1" << endl ; _LinkedInPortsNumber[ index ] -= 1 ; @@ -162,24 +213,81 @@ bool GraphBase::StreamNode::RemoveLinkedNode( GraphBase::StreamNode * ToNode ) { } } else { - cdebug << "StreamNode::RemoveLinkedNode index Error " << Name() << " --> " << ToNode->Name() << " : " << index - << " _LinkedNodesSize " << _LinkedNodesSize << endl ; -#if 1 - map< string , int >::iterator aMapOfLinkedNodesIterator ; - int i = 0 ; - for ( aMapOfLinkedNodesIterator = _MapOfLinkedNodes.begin() ; - aMapOfLinkedNodesIterator != _MapOfLinkedNodes.end() ; aMapOfLinkedNodesIterator++ ) { - cdebug << "_MapOfLinkedNodes" << i++ << " " << aMapOfLinkedNodesIterator->first << " --> " - << aMapOfLinkedNodesIterator->second << endl ; + cdebug << "StreamNode::RemoveLinkedNode index Error " << ToNode->Name() << " <-- " << Name() << " : " << index + << " _LinkedNodesSize " << ToNode->_LinkedNodesSize << endl ; + } + int fromindex = 0 ; + fromindex = -1 ; + if ( ToNode->_LinkedFromNodesSize ) { + fromindex = ToNode->GetLinkedFromNodeIndex( Name() ) ; + } + if ( fromindex >= 0 ) { + cdebug << "GraphBase::StreamNode::RemoveLinkedFromNode from " << ToNode->Name() << " to " + << Name() << " index : " << fromindex << " LinkedFromInPortsNumber " + << ToNode->_LinkedFromInPortsNumber[ fromindex ] << " - 1" << endl ; + ToNode->_LinkedFromInPortsNumber[ fromindex ] -= 1 ; + if ( ToNode->_LinkedFromInPortsNumber[ fromindex ] == 0 ) { + ToNode->_LinkedFromNodesSize-- ; + cdebug << "GraphBase::StreamNode::RemoveLinkedFromNode new LinkedFromNodesSize " + << ToNode->_LinkedFromNodesSize << " " << Name() << " removed from " + << " linkedFromnodes of " << ToNode->Name() << endl ; + int i ; + for ( i = 0 ; i < ToNode->_LinkedFromNodesSize ; i++ ) { + if ( i >= fromindex ) { + ToNode->_LinkedFromNodes[ i ] = ToNode->_LinkedFromNodes[ i+1 ] ; + ToNode->_LinkedFromInPortsNumber[ i ] = ToNode->_LinkedFromInPortsNumber[ i+1 ] ; + ToNode->SetLinkedFromNodeIndex( ToNode->_LinkedFromNodes[ i ]->Name() , i ) ; + } + cdebug << "StreamNode::RemoveLinkedFromNode" << i << " " + << ToNode->_LinkedFromNodes[ i ]->Name() << endl ; + } + ToNode->DelLinkedFromNodeIndex( Name() ) ; + ToNode->_LinkedFromNodes.resize( ToNode->_LinkedFromNodesSize+1 ) ; + ToNode->_LinkedFromInPortsNumber.resize( ToNode->_LinkedFromNodesSize+1 ) ; } + } + else if ( DoLinkedFromNode ) { + cdebug << "StreamNode::RemoveLinkedFromNode index Error " << ToNode->Name() << " --> " + << Name() << " : " << fromindex + << " _LinkedFromNodesSize " << ToNode->_LinkedFromNodesSize << endl ; + } + else { + cdebug << "StreamNode::RemoveLinkedFromNode index " << ToNode->Name() << " --> " << Name() + << " : " << fromindex + << " _LinkedFromNodesSize " << ToNode->_LinkedFromNodesSize << endl ; + fromindex = 0 ; // No error in EndSwitchNodes + } + +#if 1 + map< string , int >::iterator aMapOfLinkedNodesIterator1 ; + int ii = 0 ; + for ( aMapOfLinkedNodesIterator1 = _MapOfLinkedNodes.begin() ; + aMapOfLinkedNodesIterator1 != _MapOfLinkedNodes.end() ; aMapOfLinkedNodesIterator1++ ) { + cdebug << "_MapOfLinkedNodes" << ii++ << " of " << Name() << " : " + << aMapOfLinkedNodesIterator1->first << " --> " << aMapOfLinkedNodesIterator1->second + << " " << _LinkedNodes[ aMapOfLinkedNodesIterator1->second - 1 ]->Name() << endl ; + } #endif +#if 1 + map< string , int >::iterator aMapOfLinkedFromNodesIterator1 ; + int iifrom = 0 ; + for ( aMapOfLinkedFromNodesIterator1 = ToNode->_MapOfLinkedFromNodes.begin() ; + aMapOfLinkedFromNodesIterator1 != ToNode->_MapOfLinkedFromNodes.end() ; aMapOfLinkedFromNodesIterator1++ ) { + cdebug << "_MapOfLinkedFromNodes" << iifrom++ << " of " << ToNode->Name() << " : " + << aMapOfLinkedFromNodesIterator1->first << " --> " + << aMapOfLinkedFromNodesIterator1->second << " " + << ToNode->_LinkedFromNodes[ aMapOfLinkedFromNodesIterator1->second - 1 ]->Name() + << endl ; } - return (index >= 0 ) ; +#endif + cdebug_out << "StreamNode::RemoveLinkedNode between " << Name() << " and " << ToNode->Name() + << " " << (index >= 0) << " " << (fromindex >= 0) << endl ; + return (index >= 0 ) && (fromindex >= 0 ) ; } void GraphBase::StreamNode::ReNameLinkedNode( const char* OldNodeName , - const char* NewNodeName ) { - cdebug_in << "GraphBase::StreamNode::ReNameLink (" << OldNodeName << " , " + const char* NewNodeName ) { + cdebug_in << Name() << "->GraphBase::StreamNode::ReNameLinkedNode (" << OldNodeName << " , " << NewNodeName << ")" << endl; int index = GetLinkedNodeIndex( OldNodeName ) ; if ( index >= 0 ) { @@ -187,7 +295,28 @@ void GraphBase::StreamNode::ReNameLinkedNode( const char* OldNodeName , DelLinkedNodeIndex( OldNodeName ) ; SetLinkedNodeIndex( NewNodeName , index ) ; } - cdebug_out << "GraphBase::StreamNode::ReNameLink" << endl ; + else { + cdebug << "GraphBase::StreamNode::ReNameLinkedNode ERROR " << OldNodeName << " not found in " + << Name() << endl ; + } + cdebug_out << Name() << "->GraphBase::StreamNode::ReNameLinkedNode" << endl ; +} + +void GraphBase::StreamNode::ReNameLinkedFromNode( const char* OldNodeName , + const char* NewNodeName ) { + cdebug_in << Name() << "->GraphBase::StreamNode::ReNameLinkedFromNode (" << OldNodeName << " , " + << NewNodeName << ")" << endl; + int index = GetLinkedFromNodeIndex( OldNodeName ) ; + if ( index >= 0 ) { +// _MapOfLinkedFromNodes.erase( OldNodeName ) ; + DelLinkedFromNodeIndex( OldNodeName ) ; + SetLinkedFromNodeIndex( NewNodeName , index ) ; + } + else { + cdebug << Name() << "->GraphBase::StreamNode::ReNameLinkedFromNode ERROR " << OldNodeName + << " not found in " << Name() << endl ; + } + cdebug_out << Name() << "->GraphBase::StreamNode::ReNameLinkedFromNode" << endl ; } void GraphBase::StreamNode::AddStreamLinkedNode( GraphBase::StreamNode * ToNode ) { diff --git a/src/GraphBase/DataFlowBase_StreamNode.hxx b/src/GraphBase/DataFlowBase_StreamNode.hxx index 10860c0..122d152 100644 --- a/src/GraphBase/DataFlowBase_StreamNode.hxx +++ b/src/GraphBase/DataFlowBase_StreamNode.hxx @@ -31,12 +31,19 @@ namespace GraphBase { char * _Name ; SUPERV::KindOfNode _Kind ; +// _LinkedNodes are the nodes with link(s) from OutPort(s) of this node // Nodes with LinkedInPortsNumber InPort(s) linked to Outport(s) of this node : map< string , int > _MapOfLinkedNodes ; int _LinkedNodesSize ; vector _LinkedNodes ; vector _LinkedInPortsNumber ; +// _LinkedFromNodes are the nodes with link(s) to InPort(s) of this node + map< string , int > _MapOfLinkedFromNodes ; + int _LinkedFromNodesSize ; + vector _LinkedFromNodes ; + vector _LinkedFromInPortsNumber ; + // Nodes with InStreamPort(s) linked to OutStreamport(s) of this node : // NodeName <--> index of that linked node in _LinkedNodes map< string , int > _MapOfLinkedStreamNodes ; @@ -130,8 +137,8 @@ namespace GraphBase { return index ; } ; void SetLinkedNodeIndex( const char * name , const int index ) { _MapOfLinkedNodes[ name ] = index +1 ; - cdebug << "SetLinkedNodeIndex of " << name << " in _MapOfLinkedNodes : " - << index << " Node " << hex << (void *) _LinkedNodes[ index ] + cdebug << "SetLinkedNodeIndex of " << name << " in _MapOfLinkedNodes : index " + << index << " of " << Name() << " Node " << hex << (void *) _LinkedNodes[ index ] << dec << " '" << _LinkedNodes[ index ]->Name() << "'" << " _MapOfLinkedNodes " << _MapOfLinkedNodes[ name ] - 1 << endl ; @@ -145,6 +152,34 @@ namespace GraphBase { StreamNode * LinkedNodes( int i ) const { return _LinkedNodes[ i ] ; } ; + int GetLinkedFromNodeIndex( const char * name ) { + int index = _MapOfLinkedFromNodes[ name ] -1 ; + if ( index >= 0 ) { + cdebug << "GetLinkedFromNodeIndex of " << name + << " in _MapOfLinkedFromNodes : " + << index << " FromNode " << hex << (void *) _LinkedFromNodes[ index ] + << dec << " '" << _LinkedFromNodes[ index ]->Name() << "'" + << endl ; + } + return index ; } ; + void SetLinkedFromNodeIndex( const char * name , const int index ) { + _MapOfLinkedFromNodes[ name ] = index +1 ; + cdebug << "SetLinkedFromNodeIndex of " << name << " in _MapOfLinkedFromNodes : index " + << index << " of " << Name() << " FromNode " << hex + << (void *) _LinkedFromNodes[ index ] + << dec << " '" << _LinkedFromNodes[ index ]->Name() << "'" + << " _MapOfLinkedFromNodes " << _MapOfLinkedFromNodes[ name ] - 1 + << endl ; + } ; + void DelLinkedFromNodeIndex( const char * name ) { + _MapOfLinkedFromNodes.erase( name ) ; } ; + + int LinkedFromNodesSize() const { return _LinkedFromNodesSize ; } ; + + const int LinkedFromInPortsNumber( int i ) const { return _LinkedFromInPortsNumber[ i ] ; } ; + + StreamNode * LinkedFromNodes( int i ) const { return _LinkedFromNodes[ i ] ; } ; + int GetLinkedStreamNodeIndex( const char * name ) { int index = _MapOfLinkedStreamNodes[ name ] -1 ; if ( index >= 0 ) { @@ -218,6 +253,8 @@ namespace GraphBase { void GraphOfNode( GraphBase::Graph * aGraph ) { _GraphOfNode = aGraph ; } ; + GraphBase::Graph * GraphOfNode() const { + return _GraphOfNode ; } ; GraphBase::Graph * GraphOfNode() { return _GraphOfNode ; } ; @@ -229,13 +266,16 @@ namespace GraphBase { void SubStreamGraph( int SubStreamGraphNumber ) { _SubStreamGraphNumber = SubStreamGraphNumber ; } ; - void AddLinkedNode( StreamNode * aNode ) ; - bool RemoveLinkedNode( StreamNode * aNode ) ; + void AddLinkedNode( StreamNode * ToNode ) ; + bool RemoveLinkedNode( StreamNode * ToNode , + bool DoLinkedFromNode = true ) ; void ReNameLinkedNode( const char* OldNodeName , const char* NewNodeName ) ; + void ReNameLinkedFromNode( const char* OldNodeName , + const char* NewNodeName ) ; - void AddStreamLinkedNode( StreamNode * aNode ) ; - bool RemoveStreamLinkedNode( StreamNode * aNode ) ; + void AddStreamLinkedNode( StreamNode * ToNode ) ; + bool RemoveStreamLinkedNode( StreamNode * ToNode ) ; void ReNameStreamLinkedNode( const char* OldNodeName , const char* NewNodeName ) ; diff --git a/src/GraphEditor/DataFlowEditor_DataFlow.hxx b/src/GraphEditor/DataFlowEditor_DataFlow.hxx index 174aded..1bc4096 100644 --- a/src/GraphEditor/DataFlowEditor_DataFlow.hxx +++ b/src/GraphEditor/DataFlowEditor_DataFlow.hxx @@ -213,12 +213,10 @@ namespace GraphEditor { bool IsValid() ; bool IsExecutable() ; - void Executing() ; // asv : removed a bool parameter, use Editing() to set _Executing = false; + void Executing() ; // asv : removed a bool parameter, use Editing() to set _Executing = false bool IsExecuting() ; - void Editing() ; bool IsEditing() ; - bool UnValid() ; void EditedAfterExecution(bool EditedAfterExecution ) ; bool EditedAfterExecution() ; diff --git a/src/GraphEditor/DataFlowEditor_DataFlow.lxx b/src/GraphEditor/DataFlowEditor_DataFlow.lxx index b5519aa..93bfb43 100644 --- a/src/GraphEditor/DataFlowEditor_DataFlow.lxx +++ b/src/GraphEditor/DataFlowEditor_DataFlow.lxx @@ -429,7 +429,7 @@ inline bool GraphEditor::DataFlow::IsExecutable() { } inline void GraphEditor::DataFlow::Executing() { - cdebug << "Executing() : set _Executing = true " << endl ; + cdebug << "Editor::DataFlow::Executing() : set _Executing = true " << endl ; _Executing = true ; } @@ -437,8 +437,9 @@ inline bool GraphEditor::DataFlow::IsExecuting() { return _Executing ; } + inline void GraphEditor::DataFlow::Editing() { - cdebug << "Editing() : set _Executing = false " << endl ; + cdebug << "Editor::DataFlow::Editing() : set _Executing = false " << endl ; _Executing = false ; } diff --git a/src/GraphEditor/DataFlowEditor_OutNode.cxx b/src/GraphEditor/DataFlowEditor_OutNode.cxx index 0b4f09d..e0dfda4 100644 --- a/src/GraphEditor/DataFlowEditor_OutNode.cxx +++ b/src/GraphEditor/DataFlowEditor_OutNode.cxx @@ -552,7 +552,7 @@ bool GraphEditor::OutNode::SavePy( const char* filename ) { IsValid() ; test = SavePY( f , true ); f << endl << Graph()->Name() << " = Def" << Graph()->Name() << "()" << endl ; - cdebug_out << "GraphEditor::OutNode::SavePy" << endl; + cdebug_out << "GraphEditor::OutNode::SavePy " << test << endl; return test; } @@ -966,6 +966,10 @@ bool GraphEditor::OutNode::Valid() { if ( Graph()->IsDataStreamNode() ) { StreamGraph()->SubStreamGraphsNumber( SubStreamGraphsNumber ) ; } + if ( !Graph()->ValidLoops() ) { + cdebug_out << "This DataFlow have not valid Loops." << endl ; + return false ; + } // CreateService() ; @@ -982,6 +986,7 @@ bool GraphEditor::OutNode::Valid() { bool GraphEditor::OutNode::Executable() { cdebug_in << "GraphEditor::OutNode::Executable" << endl; bool NewLink ; +// LinkLoopNodes manage input values of LoopNodes and EndLoopNodes if ( Graph()->LinkLoopNodes( NewLink ) ) { if ( NewLink ) { _Valid = false ; @@ -1008,6 +1013,11 @@ bool GraphEditor::OutNode::Executable() { StreamGraph()->CreateStreamTopology( "/tmp/" ) ; } + // asv : 13.12.04 : introducing check for compatibility of linked ports' types. + if ( !IsLinksCompatible() ) { + _Executable = false; + } + cdebug_out << "GraphEditor::OutNode::Executable" << endl; return _Executable ; } @@ -1673,7 +1683,59 @@ bool GraphEditor::OutNode::SavePY( ostream & f , bool importSuperV ) { return true ; } +/** Iterate through ALL links (OutPort-InPort pairs) and check if their types are + * compatible - call GraphEditor::DataFlow::IsCompatible(type1, type2). + * Returns true if all are compatible. + */ +bool GraphEditor::OutNode::IsLinksCompatible() { + const GraphBase::ListOfSLinks * Links = Graph()->GetLinks( true ) ; + bool b = true; + for ( int i = 0 ; i < (int ) Links->size() && b ; i++ ) { + GraphBase::SLink aLink = (*Links)[i]; + GraphBase::ComputingNode* anOutNode = Graph()->GetChangeGraphNode( aLink.FromNodeName.c_str() ); + GraphBase::ComputingNode* anInNode = Graph()->GetChangeGraphNode( aLink.ToNodeName.c_str() ); + const GraphBase::OutPort* anOutPort = anOutNode->GetOutPort( aLink.FromServiceParameterName.c_str() ); + const GraphBase::InPort* anInPort = anInNode->GetInPort( aLink.ToServiceParameterName.c_str() ); + b = IsCompatible( anOutPort->PortType(), anInPort->PortType() ); + cdebug << "GraphEditor::OutNode::IsLinksCompatible: "< "< _MapOfPyFunctions ; bool _PyInitModule ; int _ExecNumber ; @@ -180,11 +202,14 @@ namespace GraphExecutor { int ExecNumber() ; void Executed() ; + void PyInitModule(bool) ; bool PyInitModule() ; void PyLock() ; void PyUnLock() ; + void PyLockReset() ; bool PyFunction( const char * aPyFuncName , PyObject * aPyFunction ) ; PyObject * PyFunction( const char * aPyFuncName ) ; + bool ErasePyFunction( const char * aPyFuncName ) ; string DbgFileNumber() { diff --git a/src/GraphExecutor/DataFlowExecutor_InNode.cxx b/src/GraphExecutor/DataFlowExecutor_InNode.cxx index 485e76d..4fa3a64 100644 --- a/src/GraphExecutor/DataFlowExecutor_InNode.cxx +++ b/src/GraphExecutor/DataFlowExecutor_InNode.cxx @@ -32,6 +32,7 @@ using namespace std; #include #include #include +#include #include "OpUtil.hxx" @@ -47,7 +48,8 @@ using namespace std; #include "DataFlowBase_SwitchNode.hxx" #include "DataFlowBase_EndOfSwitchNode.hxx" -#include "DataFlowExecutor_OutNode.hxx" +#include "DataFlowExecutor_DataFlow.hxx" +#include "DataFlowEditor_DataFlow.hxx" // GraphEditor package must be built BEFORE static void InitInNode( int &_RewindStack , SUPERV::ControlState &_ControlState , @@ -74,7 +76,8 @@ static void InitInNode( int &_RewindStack , GraphExecutor::FiniteStateMachine ** _Automaton , GraphExecutor::FiniteStateMachine * theAutomaton , CORBA::ORB_ptr * _Orb , - CORBA::ORB_ptr ORB ) { + CORBA::ORB_ptr ORB, + bool &_Loading ) { _RewindStack = 0 ; _ControlState = SUPERV::VoidState ; _currentState = GraphExecutor::UnKnownState ; @@ -126,6 +129,7 @@ static void InitInNode( int &_RewindStack , } *_Automaton = theAutomaton ; *_Orb = CORBA::ORB::_nil(); + _Loading = false; } GraphExecutor::FiniteStateMachine * theAutomaton = new GraphExecutor::FiniteStateMachine() ; @@ -158,7 +162,8 @@ GraphExecutor::InNode::InNode() { &_Automaton , theAutomaton , &_Orb , - CORBA::ORB::_nil() ) ; + CORBA::ORB::_nil(), + _Loading ) ; } GraphExecutor::InNode::InNode( CORBA::ORB_ptr ORB, @@ -215,7 +220,8 @@ GraphExecutor::InNode::InNode( CORBA::ORB_ptr ORB, &_Automaton , theAutomaton , &_Orb , - ORB ) ; + ORB, + _Loading ) ; SetDebug( ORB , Graph_prof_debug , Graph_fdebug ) ; _ComputingNode = NULL ; @@ -431,7 +437,7 @@ bool GraphExecutor::InNode::Ping() { _FactoryNode->Component()->ping() ; } catch( ... ) { - cdebug << "InNode::Ping() catched" << endl ; + cdebug << "InNode::Ping() ERROR catched" << endl ; State( GraphExecutor::ErroredState ) ; _OutNode->State( GraphExecutor::ErroredState ) ; RetVal = false ; @@ -458,7 +464,7 @@ void GraphExecutor::InNode::ExitThread() { bool GraphExecutor::InNode::Suspend() { cdebug_in << "GraphExecutor::InNode::Suspend " << Name() << " " << ThreadNo() - << endl; + << " " << Automaton()->StateName( State() ) << endl; bool RetVal = false ; if ( IsDone() ) { //If loop we need to suspend also ControlState( SUPERV::VoidState ) ; @@ -476,47 +482,128 @@ bool GraphExecutor::InNode::Suspend() { else if ( IsRunning() ) { ControlState( SUPERV::ToSuspendState ) ; if ( IsFactoryNode() || IsComputingNode() ) { - if ( !CORBA::is_nil( Component() ) ) { - try { - RetVal = Component()->Suspend_impl() ; - } - catch( ... ) { - cdebug << "InNode::Suspend() catched" << endl ; - State( GraphExecutor::ErroredState ) ; - _OutNode->State( GraphExecutor::ErroredState ) ; - RetVal = false ; - } - 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 ) ; - RetVal = false ; // Too late ... +// We have to suspend in the container of that node + int TrySuspend = 10 ; + while ( TrySuspend ) { + if ( !CORBA::is_nil( Component() ) ) { +// We can call that component + try { + RetVal = Component()->Suspend_impl() ; + } + catch( ... ) { + cdebug << "InNode::Suspend() ERROR catched" << endl ; + State( GraphExecutor::ErroredState ) ; + _OutNode->State( GraphExecutor::ErroredState ) ; + RetVal = false ; + TrySuspend = 1 ; + } + cdebug << "Component()->Suspend_impl() returns status " << RetVal << endl ; + 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; + TrySuspend = 1 ; + } + else if ( IsDone() ) { + ControlState( SUPERV::VoidState ) ; + RetVal = false ; // Too late ... + TrySuspend = 1 ; + } + else { + cdebug << "InNode::Suspend component Suspended and !IsDone and !IsRunning !" + << endl ; + MESSAGE("InNode::Suspend component Suspended and !IsDone and !IsRunning !") ; + TrySuspend = 1 ; + } } else { - cdebug << "component Suspended and !IsDone and !IsRunning !" +// Suspend in the Container failed : it is always false if it is a Python Container + cdebug << "InNode::Suspend cannot Suspend component ! Python Component ?" << endl ; + if ( TrySuspend == 1 ) { + if ( IsSuspended() ) { + RetVal = true ; + } + else { + RetVal = false ; + } + } + } + } + else { + cdebug << "InNode::Suspend with nilComponent while RunningState !. Loading Component ?" + << endl ; +// Wait for the end of loading of the component + while ( IsLoading() ) { + sleep( 1 ) ; + } + if ( TrySuspend == 1 ) { + if ( IsSuspended() ) { + RetVal = true ; + } + else { + RetVal = false ; + } } } + TrySuspend -= 1 ; + if ( TrySuspend ) { + sleep( 1 ) ; + } } - else { - cdebug << "Suspend cannot Suspend component !" << endl ; - RetVal = false ; + } + else if ( IsMacroNode() ) { +// It should be like that but it is not completely implemented + GraphBase::Graph * aGraph = (GraphBase::Graph * ) GraphMacroNode()->CoupledNode() ; + RetVal = aGraph->GraphEditor()->Executor()->Suspend() ; + if ( RetVal ) { + State( GraphExecutor::SuspendedState ) ; } } else { - cdebug << "Suspend with nilComponent while RunningState !" << endl ; - RetVal = false ; +// Now we can suspend an InLineNode with the handler of the SuperVision Container + // asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL + State( GraphExecutor::ErroredState ) ; + _OutNode->State( GraphExecutor::ErroredState ) ; RetVal = false; + cdebug << "Suspend of InLine nodes is NOT implemented." << endl; + MESSAGE( "Suspend of InLine nodes is NOT implemented." ); + /* + if ( pthread_kill( _OutNode->MainThreadId() , SIGUSR2 ) == -1 ) { + perror("Suspend pthread_kill error") ; + State( GraphExecutor::ErroredState ) ; + _OutNode->State( GraphExecutor::ErroredState ) ; + RetVal = false ; + } + else { + RetVal = true ; + } + if ( RetVal ) { + if ( IsRunning() ) { + cdebug << pthread_self() << "GraphExecutor::InNode::Suspend " << Name() + << " --> thread" << ThreadNo() << " SuspendEvent " << endl; + SendEvent( GraphExecutor::SuspendEvent ) ; + cdebug << pthread_self() << "GraphExecutor::InNode::Suspended in SuperVision Container" + << Name() << " --> thread" << ThreadNo() << endl; + } + else if ( IsDone() ) { + ControlState( SUPERV::VoidState ) ; + RetVal = false ; // Too late ... + } + else { + cdebug << "component Suspended and !IsDone and !IsRunning !" + << endl ; + } + } + */ } } else { - cdebug << "Suspend and !IsDone and !IsRunning and !IsWaiting ?" - << endl ; + cdebug << "Suspend and IsDone " << IsDone() << " and IsRunning " << IsRunning() + << " and IsWaiting " << IsWaiting() << " and IsReady " << IsReady() + << " ?" << endl ; RetVal = false ; } cdebug_out << "GraphExecutor::InNode::Suspend " << RetVal << " " @@ -539,7 +626,8 @@ bool GraphExecutor::InNode::ContainerKill() { bool GraphExecutor::InNode::Kill() { cdebug_in << "GraphExecutor::InNode::Kill " << Name() << " " << ThreadNo() << " " << Automaton()->StateName( State() ) << " Threads " << _OutNode->Threads() - << " SuspendedThreads " << _OutNode->SuspendedThreads() << endl; + << " SuspendedThreads " << _OutNode->SuspendedThreads() + << " EventQSize " << _OutNode->EventQSize() << endl; bool RetVal ; if ( IsDone() ) { ControlState( SUPERV::ToKillState ) ; // if loop @@ -559,62 +647,145 @@ bool GraphExecutor::InNode::Kill() { else { if ( IsRunning() ) { if ( IsFactoryNode() || IsComputingNode() ) { - if ( !CORBA::is_nil( Component() ) ) { - try { - RetVal = Component()->Kill_impl() ; - } - catch( ... ) { - cdebug << "InNode::Suspend() catched" << endl ; - State( GraphExecutor::ErroredState ) ; - _OutNode->State( GraphExecutor::ErroredState ) ; - RetVal = false ; - } - 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 ... +// We have to suspend in the container of that node + int TryKill = 10 ; + while ( TryKill ) { + if ( !CORBA::is_nil( Component() ) ) { +// We can call that component + try { + RetVal = Component()->Kill_impl() ; + } + catch( ... ) { + cdebug << "InNode::Kill_impl ERROR catched" << endl ; + State( GraphExecutor::ErroredState ) ; + _OutNode->State( GraphExecutor::ErroredState ) ; + RetVal = false ; + TryKill = 1 ; + } + cdebug << "Component()->Kill_impl() returns status " << RetVal << endl ; + if ( RetVal ) { + if ( IsRunning() ) { + cdebug << pthread_self() << "GraphExecutor::InNode::Kill_impl " << Name() + << " --> thread" << ThreadNo() << " KillEvent " << endl; + SendEvent( GraphExecutor::KillEvent ) ; + cdebug << pthread_self() << "GraphExecutor::InNode::Killed_impl in Container" + << Name() << " --> thread" << ThreadNo() << endl; + TryKill = 1 ; + } + else if ( IsDone() ) { + ControlState( SUPERV::VoidState ) ; + RetVal = false ; // Too late ... + TryKill = 1 ; + } + else { + cdebug << "Kill component Killed and !IsDone and !IsRunning !" + << endl ; + TryKill = 1 ; + } + } + else { +// Kill in the Container failed : it is always false if it is a Python Container + cdebug << "InNode::Suspend cannot Kill component ! Python Component ?" + << endl ; + if ( TryKill == 1 ) { + if ( IsKilled() ) { + RetVal = true ; + } + else { + RetVal = false ; + } + } + } } else { - cdebug << "component Killed and !IsDone and !IsRunning !" + cdebug << "InNode::Kill with nilComponent while RunningState !. Loading Component ?" << endl ; +// Wait for the end of loading of the component + while ( IsLoading() ) { + sleep( 1 ) ; + } + if ( TryKill == 1 ) { + if ( IsKilled() ) { + RetVal = true ; + } + else { + RetVal = false ; + } + } } + TryKill -= 1 ; + if ( TryKill ) { + sleep( 1 ) ; + } } - else { - cdebug << "Kill with nilComponent cannot Kill component !" << endl ; + } + else if ( IsMacroNode() ) { +// It should be like that but it is not completely implemented + GraphBase::Graph * aGraph = (GraphBase::Graph * ) GraphMacroNode()->CoupledNode() ; + RetVal = aGraph->GraphEditor()->Executor()->Kill() ; + if ( RetVal ) { + State( GraphExecutor::KilledState ) ; + } + } + else { +//PAL6886 +// Now we can kill an InLineNode with the handler of the SuperVision Container + // asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL + State( GraphExecutor::ErroredState ) ; + _OutNode->State( GraphExecutor::ErroredState ) ; + RetVal = false ; + cdebug << "Kill of InLine nodes is NOT implemented." << endl; + MESSAGE( "Kill of InLine nodes is NOT implemented." ); + /* + cdebug << pthread_self() << "Kill of InLineNode " << Name() << " MainThreadId " + << _OutNode->MainThreadId() << " :" << endl ; + MESSAGE( pthread_self() << "Kill of InLineNode " << Name() << " MainThreadId " + << _OutNode->MainThreadId() << " :" ) ; + if ( pthread_kill( _OutNode->MainThreadId() , SIGINT ) == -1 ) { +// python signals run only in main thread ... + perror("Kill pthread_kill error") ; + State( GraphExecutor::ErroredState ) ; + _OutNode->State( GraphExecutor::ErroredState ) ; RetVal = false ; } + else { + cdebug << pthread_self() << "pthread_kill of InLineNode " << Name() + << " done. MainThreadId " << _OutNode->MainThreadId() << endl ; + MESSAGE( pthread_self() << "pthread_kill of InLineNode " << Name() + << " done. MainThreadId " << _OutNode->MainThreadId() ) ; + RetVal = true ; + } + */ } } else if ( IsSuspended() ) { cdebug << pthread_self() << "GraphExecutor::InNode::Kill " << Name() << " --> thread" << ThreadNo() << " Resume()" << endl; - Resume() ; - RetVal = true ; + if ( Resume() ) { + RetVal = Kill() ; + } + else { + RetVal = false ; + } } else if ( IsWaiting() ) { - RetVal = true ; + RetVal = false ; } else if ( IsReady() ) { RetVal = true ; } else { - cdebug << "Kill and !IsDone and !IsRunning and !IsWaiting and !IsReady ?" - << endl ; + cdebug << "Kill and IsDone " << IsDone() << " and IsRunning " << IsRunning() + << " and IsWaiting " << IsWaiting() << " and IsReady " << IsReady() + << " ?" << endl ; RetVal = false ; } } } - cdebug_out << "GraphExecutor::InNode::Kill" << Name() << " " << ThreadNo() << " " + cdebug_out << "GraphExecutor::InNode::Kill " << Name() << " " << ThreadNo() << " " << Automaton()->StateName( State() ) << " Threads " << _OutNode->Threads() - << " SuspendedThreads " << _OutNode->SuspendedThreads() << endl ; + << " SuspendedThreads " << _OutNode->SuspendedThreads() + << " EventQSize " << _OutNode->EventQSize() << endl ; return RetVal ; } @@ -674,7 +845,7 @@ bool GraphExecutor::InNode::Stop() { RetVal = Component()->Stop_impl() ; } catch( ... ) { - cdebug << "InNode::Stop() catched" << endl ; + cdebug << "InNode::Stop() ERROR catched" << endl ; State( GraphExecutor::ErroredState ) ; _OutNode->State( GraphExecutor::ErroredState ) ; RetVal = false ; @@ -694,7 +865,7 @@ bool GraphExecutor::InNode::Stop() { } } else { - cdebug << "Suspend cannot Suspend component !" << endl ; + cdebug << "Suspend cannot Stop component ! Python Component ?" << endl ; RetVal = false ; } } @@ -752,15 +923,57 @@ bool GraphExecutor::InNode::Resume() { } else if ( State() == GraphExecutor::SuspendedExecutingState ) { if ( IsFactoryNode() || IsComputingNode() ) { + if ( pthread_mutex_lock( &_MutexWait ) ) { + perror("ResumeAction pthread_mutex_lock ") ; + exit( 0 ) ; + } try { RetVal = Component()->Resume_impl() ; + if ( RetVal ) { + State( GraphExecutor::ExecutingState ) ; + } } catch( ... ) { - cdebug << "InNode::Resume() catched" << endl ; + cdebug << "InNode::Resume() ERROR catched" << endl ; State( GraphExecutor::ErroredState ) ; _OutNode->State( GraphExecutor::ErroredState ) ; RetVal = false ; } + if ( pthread_mutex_unlock( &_MutexWait ) ) { + perror("ResumeAction pthread_mutex_unlock ") ; + exit( 0 ) ; + } + } + else if ( IsMacroNode() ) { + cdebug << "Suspend of MacroNode not yet implemented ? Trying" << endl ; + GraphBase::Graph * aGraph = (GraphBase::Graph * ) GraphMacroNode()->CoupledNode() ; + RetVal = aGraph->GraphEditor()->Executor()->Resume() ; + if ( RetVal ) { + State( GraphExecutor::ExecutingState ) ; + } + } + else { +// Resume of InLinePythonNode in the Node of the SuperVisionContainer ... + // asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL + State( GraphExecutor::ErroredState ) ; + _OutNode->State( GraphExecutor::ErroredState ) ; + RetVal = false ; + cdebug << "Resume of InLine nodes is NOT implemented." << endl; + MESSAGE( "Resume of InLine nodes is NOT implemented." ); + /* + cdebug << ThreadNo() << "/" << pthread_self() + << "Resume of InLineNode pthread_kill" << Name() << endl ; + if ( pthread_kill( _OutNode->MainThreadId() , SIGCONT ) == -1 ) { + perror("Resume pthread_kill error") ; + State( GraphExecutor::ErroredState ) ; + _OutNode->State( GraphExecutor::ErroredState ) ; + RetVal = false ; + } + else { + State( GraphExecutor::ExecutingState ) ; + RetVal = true ; + } + */ } } else if ( State() == GraphExecutor::SuspendedSuccessedState ) { @@ -853,37 +1066,8 @@ bool GraphExecutor::InNode::Resume() { } } #endif - cdebug_out << "GraphExecutor::InNode::Resume " << RetVal << endl ; - return RetVal ; -} - -bool GraphExecutor::InNode::ReStart( const char * AtNodeName , - const bool AndSuspend ) { - bool RetVal = false ; - GraphExecutor::InNode * aRestartNode = (GraphExecutor::InNode *) _OutNode->Graph()->GetGraphNode( AtNodeName )->GetInNode() ; - cdebug_in << pthread_self() << "/" << ThreadNo() - << " --> GraphExecutor::InNode::ReStartAt( " - << AtNodeName << " , " << AndSuspend << ") " << endl - << "thread " << aRestartNode->ThreadNo() << " " - << Automaton()->StateName( aRestartNode->State() ) - << " from " << Name() << " " << Automaton()->StateName( State() ) - << endl ; - if ( IsWaiting() && aRestartNode->IsSuspended() ) { - RetVal = aRestartNode->Resume() ; - } - else if ( IsSuspended() ) { - if ( strcmp( AtNodeName , Name() ) ) { - aRestartNode->State( GraphExecutor::SuspendedSuccessedState ) ; - } - if ( AndSuspend ) { - ReStartAction( aRestartNode , GraphExecutor::ReStartAndSuspendEvent ) ; - } - else { - ReStartAction( aRestartNode , GraphExecutor::ReStartEvent ) ; - } - RetVal = true ; - } - cdebug_out << "<-- GraphExecutor::InNode::ReStartAt" << endl ; + cdebug_out << "GraphExecutor::InNode::Resume " << Name() << " " << RetVal << " " + << Automaton()->StateName( State() ) << endl ; return RetVal ; } @@ -957,7 +1141,8 @@ bool GraphExecutor::InNode::IsSuspended() { if ( aState == GraphExecutor::SuspendedReadyState || aState == GraphExecutor::SuspendedExecutingState || aState == GraphExecutor::SuspendedSuccessedState || - aState == GraphExecutor::SuspendedErroredState ) + aState == GraphExecutor::SuspendedErroredState || + aState == GraphExecutor::SuspendedState ) aret = true ; // cdebug_out << "GraphExecutor::InNode::IsSuspended" << endl ; return aret ; @@ -1020,12 +1205,14 @@ bool GraphExecutor::InNode::StateWait( SUPERV::GraphState aState ) { << " " << Automaton()->StateName( _currentState ) << " pthread_cond_wait _RunningWait " << Name() << endl ; while ( !RetVal && !IsDone() ) { - cdebug << pthread_self() << " pthread_cond_wait RunningWait" << endl ; + cdebug << pthread_self() << " pthread_cond_wait RunningWait " << Name() << endl ; pthread_cond_wait( &_RunningWait , &_MutexWait ); - RetVal = IsRunning() ; +//We may have pthread_cond_waited but !IsRunning and !IsDone : + RetVal = IsRunning() || State() == GraphExecutor::SuccessedExecutingState || + State() == GraphExecutor::ErroredExecutingState ; cdebug << pthread_self() << " pthread_cond_waited RunningWait " << Automaton()->StateName( _currentState ) << " " << RetVal - << endl ; + << " " << Name() << endl ; } cdebug_out << pthread_self() << " StateWait( Running ) " << RetVal << " " << Automaton()->StateName( _currentState ) @@ -1089,9 +1276,12 @@ bool GraphExecutor::InNode::ReadyWait() { } bool GraphExecutor::InNode::RunningWait() { -// cdebug_in << "GraphExecutor::InNode::RunningWait " << Name() << endl; + cdebug_in << pthread_self() << "GraphExecutor::InNode::RunningWait " << Name() + << " " << Automaton()->StateName( State() ) << endl; bool aret ; aret = StateWait( SUPERV::RunningState ) ; + cdebug_out << pthread_self() << "GraphExecutor::InNode::RunningWait " << Name() + << " " << Automaton()->StateName( State() ) << endl; return aret ; } @@ -1109,18 +1299,24 @@ bool GraphExecutor::InNode::SuspendedWait() { return aret ; } -void GraphExecutor::InNode::InitialState( GraphExecutor::OutNode * theOutNode ) +void GraphExecutor::InNode::InitialState() { cdebug_in << "GraphExecutor::InNode::InitialState Node " << Name() << endl; - _OutNode = theOutNode ; - int i; _ControlState = SUPERV::VoidState ; CreateNewThread( false ) ; CreateNewThreadIf( false ) ; _SuspendSync = false ; _ResumeSync = false ; + _InitLoop = false ; + + // asv : 13.12.04 : Decided to set "Loading" state for factory and computing nodes ONLY. + // See extended comment in p.2.19 of "Bugs and Improvements" about IsLoading for InLine. + if ( IsComputingNode() || IsFactoryNode() ) { + IsLoading( true ) ; + } + // ThreadNo( pthread_self() ) ; ThreadNo( 0 ) ; @@ -1146,15 +1342,18 @@ void GraphExecutor::InNode::InitialState( GraphExecutor::OutNode * theOutNode ) CORBA::Any * anAny = new CORBA::Any() ; *anAny <<= (long ) 1 ; anOutPort->Value( anAny ) ; + _InitLoop = true ; } // JR 15_09_2004 if backward link from GOTONode or EndLoopNode ==> DataConnected else if ( anInPort->IsGate() && anOutPort ) { anOutPort->State( SUPERV::WaitingState ) ; anOutPort->Done( false ) ; const GraphBase::ComputingNode * aFromNode = _OutNode->Graph()->GetGraphNode( anOutPort->NodeName() ) ; - if ( aFromNode->IsGOTONode() || aFromNode->IsEndLoopNode() ) { // ASV: bug with synchronization of Inline nodes (via Gate ports) fixed. - // before was "else if ( IsOneOfInlineNodes() )" - // IsOneOfInline() == ( Inline || IsOneOfGOTO() ), so Inline are removed.. +//JR if ( aFromNode->IsGOTONode() || aFromNode->IsEndLoopNode() ) { + if ( aFromNode->IsGOTONode() || ( IsLoopNode() && CoupledNode() == aFromNode ) ) { +// ASV: bug with synchronization of Inline nodes (via Gate ports) fixed. +// before was "else if ( IsOneOfInlineNodes() )" +// IsOneOfInline() == ( Inline || IsOneOfGOTO() ), so Inline are removed.. anOutPort->PortStatus( DataConnected ); anOutPort->State( SUPERV::ReadyState ) ; anOutPort->Done( true ) ; @@ -1254,7 +1453,8 @@ void GraphExecutor::InNode::InitialState( GraphExecutor::OutNode * theOutNode ) } bool GraphExecutor::InNode::InitPythonFunctions(bool WithErr ) { - cdebug_in << "GraphExecutor::InNode::InitPythonFunctions " << Name() << endl; + cdebug_in << "GraphExecutor::InNode::InitPythonFunctions " << Name() << " WithErr " << WithErr + << " PyFuncRunned() " << PyFuncRunned() << endl; bool Err = false ; if ( !PyFuncRunned() && IsOneOfInLineNodes() ) { if ( IsLoopNode() ) { @@ -1331,7 +1531,9 @@ bool GraphExecutor::InNode::InitPythonFunctions(bool WithErr ) { const long GraphExecutor::InNode::CpuUsed( bool tot ) { CORBA::Long cpu = 0 ; -// cdebug_in << "GraphExecutor::InNode::CpuUsed( " << tot << " )" << Name() << endl ; +// cout << "Begin CpuUsed " << Name() << " CpuUsed : " << cpu << " State " +// << theAutomaton->StateName( _currentState ) << endl ; + cdebug_in << "GraphExecutor::InNode::CpuUsed( " << tot << " )" << Name() << endl ; if ( IsOneOfInLineNodes() ) { // cdebug << "CpuUsed " << Name() << " --> PyCpuUsed()" << endl ; // cout << "CpuUsed " << Name() << " --> PyCpuUsed()" << endl ; @@ -1352,8 +1554,9 @@ const long GraphExecutor::InNode::CpuUsed( bool tot ) { } } } -// cdebug_out << "GraphExecutor::InNode::CpuUsed " << Name() << " CpuUsed : " << cpu << endl ; -// cout << "CpuUsed " << Name() << " CpuUsed : " << cpu << endl ; + cdebug_out << "GraphExecutor::InNode::CpuUsed " << Name() << " CpuUsed : " << cpu << endl ; +// cout << "End CpuUsed " << Name() << " CpuUsed : " << cpu << " State " +// << theAutomaton->StateName( _currentState ) << endl ; return cpu ; } @@ -1409,3 +1612,13 @@ void GraphExecutor::InNode::SetPyCpuUsed() { // << _PyCpuUsed << endl ; } +void GraphExecutor::InNode::IsLoading( bool Loading ) { + _Loading = Loading ; + + // asv : 09.12.04 : "Bugs and Improvents" 2.19 : how it works: + // LoadingState is returned by OutNode::State( NodeName ) if InNode->IsLoading() + // after Loading is finished (here below), ExecutingState must be pushed for GUI. + if ( !Loading ) + _OutNode->PushEvent( this, GraphExecutor::ExecuteEvent, GraphExecutor::ExecutingState ); +} + diff --git a/src/GraphExecutor/DataFlowExecutor_InNode.hxx b/src/GraphExecutor/DataFlowExecutor_InNode.hxx index 0100701..1b25ab5 100644 --- a/src/GraphExecutor/DataFlowExecutor_InNode.hxx +++ b/src/GraphExecutor/DataFlowExecutor_InNode.hxx @@ -33,6 +33,8 @@ #include +#include "SALOME_Container_i.hxx" + #include "DataFlowBase_Graph.hxx" #include "DataFlowBase_FactoryNode.hxx" #include "DataFlowBase_GOTONode.hxx" @@ -87,6 +89,7 @@ namespace GraphExecutor { GraphExecutor::AutomatonState _NextState ; GraphExecutor::StateEventAction _NextAction ; bool _PyFuncRunned ; + bool _Loading ; pthread_mutex_t _MutexDataWait ; bool _DataWait ; @@ -124,6 +127,7 @@ namespace GraphExecutor { GraphExecutor::OutNode * _OutNode ; char * _DataFromNode ; + bool _InitLoop ; public: @@ -315,10 +319,14 @@ namespace GraphExecutor { bool PyFuncRunned() { return _PyFuncRunned ; } ; + void OutNode( GraphExecutor::OutNode * theOutNode ) { + _OutNode = theOutNode ; } ; + bool InitPython() ; PyObject * InitPyDynInvoke( char * PyFuncName , const SUPERV::ListOfStrings * aPythonFunction , bool & Err ) ; + void RemovePyDynInvoke( char * PyFuncName ) ; void LockDataWait() ; void UnLockDataWait() ; @@ -332,7 +340,6 @@ namespace GraphExecutor { bool Suspend() ; bool SuspendDone() ; bool Resume() ; - bool ReStart( const char * AtNodeName , const bool AndSuspend ) ; bool Stop() ; void CreateNewThread( bool k_create ) { _createNewThread = k_create ; } ; @@ -370,6 +377,8 @@ namespace GraphExecutor { bool IsSuspended() ; bool IsKilled() ; bool IsStopped() ; + void IsLoading( bool Loading ); + bool IsLoading() { return _Loading ; } ; bool StateWait( SUPERV::GraphState aState ) ; bool ReadyWait() ; @@ -377,7 +386,7 @@ namespace GraphExecutor { bool DoneWait() ; bool SuspendedWait() ; - void InitialState( GraphExecutor::OutNode * theOutNode ) ; + void InitialState() ; bool InitPythonFunctions(bool WithErr ) ; void SetWaitingStates(GraphExecutor::InNode * EndNode ) ; @@ -466,6 +475,8 @@ namespace GraphExecutor { long PyCpu() ; bool PyRunSimpleString( char* thePyString ); + PyObject * PyEvalCallObject( PyObject * MyPyRunMethod , + PyObject * ArgsList ) ; } ; } ; diff --git a/src/GraphExecutor/DataFlowExecutor_InNodeThreads.cxx b/src/GraphExecutor/DataFlowExecutor_InNodeThreads.cxx index 18b6ade..b33fa38 100644 --- a/src/GraphExecutor/DataFlowExecutor_InNodeThreads.cxx +++ b/src/GraphExecutor/DataFlowExecutor_InNodeThreads.cxx @@ -157,6 +157,7 @@ void GraphExecutor::InNode::RunningAction() { cdebug << pthread_self() << "/" << ThreadNo() << "RunningAction pthread_cond_broadcast _RunningWait " << Name() << endl ; +// That activate the pthread_cond_wait for RunninWait if ( pthread_cond_broadcast( &_RunningWait ) ) { perror("Running pthread_cond_broadcast ") ; } @@ -449,17 +450,20 @@ void GraphExecutor::InNode::ThreadStartedAction() { exit( 0 ) ; } if ( !_ThreadStartedSync ) { - cdebug << "pthread_cond " << Name() << " ThreadStarted pthread_cond_wait" + cdebug << pthread_self() << "/" << ThreadNo() + << "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" + cdebug << pthread_self() << "/" << ThreadNo() + << "pthread_cond " << Name() << " ThreadStarted pthread_cond_waited" << endl ; } else { - cdebug << "pthread_cond " << Name() << " NO ThreadStarted pthread_cond_wait" + cdebug << pthread_self() << "/" << ThreadNo() + << "pthread_cond " << Name() << " NO ThreadStarted pthread_cond_wait" << endl ; //Debug : _ThreadStartedSync = false ; @@ -467,7 +471,8 @@ void GraphExecutor::InNode::ThreadStartedAction() { perror("ThreadStart pthread_cond_signal ") ; } //Debug - cdebug << "pthread_cond " << Name() << " NO ThreadStarted pthread_cond_signaled" + cdebug << pthread_self() << "/" << ThreadNo() + << "pthread_cond " << Name() << " NO ThreadStarted pthread_cond_signaled" << endl ; } if ( pthread_mutex_unlock( &_MutexWait ) ) { @@ -482,17 +487,20 @@ void GraphExecutor::InNode::ThreadStartAction() { exit( 0 ) ; } if ( _ThreadStartedSync ) { - cdebug << "pthread_cond " << Name() << " ThreadStart pthread_cond_signal" + cdebug << pthread_self() << "/" << ThreadNo() + << "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" + cdebug << pthread_self() << "/" << ThreadNo() + << "pthread_cond " << Name() << " ThreadStart pthread_cond_signaled" << endl ; } else { - cdebug << "pthread_cond " << Name() << " NO ThreadStart pthread_cond_signal" + cdebug << pthread_self() << "/" << ThreadNo() + << "pthread_cond " << Name() << " NO ThreadStart pthread_cond_signal" << endl ; _ThreadStartedSync = true ; //Debug : @@ -500,7 +508,8 @@ void GraphExecutor::InNode::ThreadStartAction() { perror("ThreadStarted pthread_cond_wait ") ; } //Debug - cdebug << "pthread_cond " << Name() << " NO ThreadStart pthread_cond_waited" + cdebug << pthread_self() << "/" << ThreadNo() + << "pthread_cond " << Name() << " NO ThreadStart pthread_cond_waited" << endl ; } if ( pthread_mutex_unlock( &_MutexWait ) ) { @@ -589,7 +598,7 @@ int GraphExecutor::InNode::executeAction() { } void GraphExecutor::InNode::coutbegin() { - cdebug << ThreadNo() << " " << pthread_self() << " run_function begin" + cdebug << pthread_self() << "/" << ThreadNo() << " run_function begin" << " " << Name() << " " << Automaton()->StateName( State() ) << endl ; } void GraphExecutor::InNode::coutexit() { @@ -626,12 +635,12 @@ void * run_function(void *p) { int GraphExecutor::InNode::ExecuteAction() { int sts ; -// 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_in << pthread_self() << "/" << ThreadNo() << " --> ExecuteAction " + << nextactionname << " " << statename << " NextState " + << nextstatename << endl ; State( _NextState ) ; switch ( _NextAction ) { @@ -762,8 +771,8 @@ int GraphExecutor::InNode::ExecuteAction() { return 0 ; } } -// cdebug << pthread_self() << "/" << ThreadNo() << "<-- ExecuteAction " -// << Automaton()->ActionName( nextaction ) << endl ; + cdebug_out << pthread_self() << "/" << ThreadNo() << "<-- ExecuteAction " + << nextactionname << endl ; return sts ; } @@ -786,25 +795,34 @@ int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() { unsigned int k; int InReady = 0 ; int res = 1; - bool LoopFinished = false ; bool LoopBeginning = false ; + bool LoopFinished = false ; bool SwitchFinished = false ; - if ( IsEndLoopNode() && !GetChangeNodeInLoop()->GetOutPort()->BoolValue() ) { - LoopFinished = true ; // End of Loop + if ( IsLoopNode() ) { + GraphBase::OutPort * anOutLoopPort = GetChangeNodeInLoop()->GetOutPort() ; + if ( anOutLoopPort && anOutLoopPort->BoolValue() ) { + LoopBeginning = true ; // Beginning of Loop + } } - if ( IsLoopNode() && GetChangeNodeInLoop()->GetOutPort()->BoolValue() ) { - LoopBeginning = true ; // Beginning of Loop + if ( IsEndLoopNode() ) { + GraphBase::OutPort * anOutLoopPort = GetChangeNodeInLoop()->GetOutPort() ; + if ( anOutLoopPort && !anOutLoopPort->BoolValue() ) { + LoopFinished = true ; // End of Loop + } } - if ( IsEndSwitchNode() && !GetChangeNodeInGate()->GetOutPort()->BoolValue() ) { - SwitchFinished = true ; // End of Switch + if ( IsEndSwitchNode() ) { + GraphBase::OutPort * anOutGateSwitchPort = GetChangeNodeInGate()->GetOutPort() ; + if ( anOutGateSwitchPort && !anOutGateSwitchPort->BoolValue() ) { + SwitchFinished = true ; // End of Switch + } } cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " LoopFinished " << LoopFinished << " LoopBeginning " << LoopBeginning << " SwitchFinished " << SwitchFinished << endl ; for ( k = 0 ; k < (unsigned int ) GetNodeInPortsSize() ; k++ ) { GraphBase::InPort * anInPort = GetChangeNodeInPort(k) ; GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ; - cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " InPort " << anInPort->PortName() << endl ; + cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " InPort " << anInPort->PortName() << " " << anInPort->State() << " " << anInPort->PortStatus() << endl ; if ( anInPort->IsGate() && anOutPort == NULL ) { InReady += 1 ; anInPort->State( SUPERV::ReadyState ) ; @@ -816,9 +834,9 @@ int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() { if ( anInPort->State() == SUPERV::ReadyState ) { InReady += 1 ; cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " " - << anInPort->PortName() << " Was Done from " - << anOutPort->NodeName() << " " << anOutPort->PortName() - << " ReadyState " ; + << anInPort->PortName() << " Was Done from Node " + << anOutPort->NodeName() << "( " << anOutPort->PortName() + << ") ReadyState " ; #ifdef _DEBUG_ if ( GraphBase::Base::_prof_debug ) { anOutPort->StringValue( *GraphBase::Base::_fdebug ) ; @@ -830,9 +848,9 @@ int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() { anInPort->State( SUPERV::ReadyState ) ; InReady += 1 ; cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " " - << anInPort->PortName() << " Was Done from " - << anOutPort->NodeName() << " " << anOutPort->PortName() - << " LoopBeginning " << LoopBeginning ; + << anInPort->PortName() << " Was Done from Node " + << anOutPort->NodeName() << "( " << anOutPort->PortName() + << ") LoopBeginning " << LoopBeginning ; #ifdef _DEBUG_ if ( GraphBase::Base::_prof_debug ) { anOutPort->StringValue( *GraphBase::Base::_fdebug ) ; @@ -844,9 +862,9 @@ int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() { anInPort->State( SUPERV::ReadyState ) ; InReady += 1 ; cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " " - << anInPort->PortName() << " Was Done from " - << anOutPort->NodeName() << " " << anOutPort->PortName() - << " LoopFinished" ; + << anInPort->PortName() << " Was Done from Node " + << anOutPort->NodeName() << "( " << anOutPort->PortName() + << ") LoopFinished" ; #ifdef _DEBUG_ if ( GraphBase::Base::_prof_debug ) { anOutPort->StringValue( *GraphBase::Base::_fdebug ) ; @@ -858,9 +876,28 @@ int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() { anInPort->State( SUPERV::ReadyState ) ; InReady += 1 ; cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " " - << anInPort->PortName() << " Was Done from " - << anOutPort->NodeName() << " " << anOutPort->PortName() - << " SwitchFinished" ; + << anInPort->PortName() << " Was Done from Node " + << anOutPort->NodeName() << "( " << anOutPort->PortName() + << ") SwitchFinished" ; +#ifdef _DEBUG_ + if ( GraphBase::Base::_prof_debug ) { + anOutPort->StringValue( *GraphBase::Base::_fdebug ) ; + } +#endif + cdebug << endl ; + } + else if ( anInPort->IsGate() && + _OutNode->Graph()->GetGraphNode( anOutPort->NodeName() )->IsGOTONode() ) { +// GateOutPort of GOTONodes are always opened + anInPort->State( SUPERV::ReadyState ) ; + InReady += 1 ; + CORBA::Any * anAny = new CORBA::Any() ; + *anAny <<= (long ) 1 ; + _OutNode->Graph()->GetGraphNode( anOutPort->NodeName() )->GetChangeNodeOutGate()->Value( anAny ) ; + cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " " + << anInPort->PortName() << " Was Done from Node " + << anOutPort->NodeName() << "( " << anOutPort->PortName() + << ") GOTONode" ; #ifdef _DEBUG_ if ( GraphBase::Base::_prof_debug ) { anOutPort->StringValue( *GraphBase::Base::_fdebug ) ; @@ -870,8 +907,8 @@ int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() { } else { cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " " - << anInPort->PortName() << " Was NOT Done from " - << anOutPort->NodeName() << " " << anOutPort->PortName() << " " + << anInPort->PortName() << " Was NOT Done from Node " + << anOutPort->NodeName() << "( " << anOutPort->PortName() << ") " << " " << Automaton()->StateName( State() ) << " DataConnected " << anInPort->IsDataConnected() << " LoopBeginning " << LoopBeginning << endl ; @@ -886,9 +923,9 @@ int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() { InReady += 1 ; anInPort->State( SUPERV::ReadyState ) ; cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " " - << anInPort->PortName() << " Gate is Opened from " - << anOutPort->NodeName() << " " << anOutPort->PortName() - << " " ; + << anInPort->PortName() << " Gate is Opened from Node " + << anOutPort->NodeName() << "( " << anOutPort->PortName() + << ") " ; #ifdef _DEBUG_ if ( GraphBase::Base::_prof_debug ) { anOutPort->StringValue( *GraphBase::Base::_fdebug ) ; @@ -899,9 +936,9 @@ int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() { else if ( LoopFinished ) { anInPort->State( SUPERV::ReadyState ) ; cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " " - << anInPort->PortName() << " GATE IS CLOSED from " - << anOutPort->NodeName() << " " << anOutPort->PortName() - << " LoopFinished" ; + << anInPort->PortName() << " GATE IS CLOSED from Node " + << anOutPort->NodeName() << "( " << anOutPort->PortName() + << ") LoopFinished" ; #ifdef _DEBUG_ if ( GraphBase::Base::_prof_debug ) { anOutPort->StringValue( *GraphBase::Base::_fdebug ) ; @@ -911,9 +948,9 @@ int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() { } else { cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " " - << anInPort->PortName() << " GATE IS CLOSED from " - << anOutPort->NodeName() << " " << anOutPort->PortName() - << " " ; + << anInPort->PortName() << " GATE IS CLOSED from Node " + << anOutPort->NodeName() << "( " << anOutPort->PortName() + << ") " ; #ifdef _DEBUG_ if ( GraphBase::Base::_prof_debug ) { anOutPort->StringValue( *GraphBase::Base::_fdebug ) ; @@ -926,8 +963,9 @@ int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() { InReady += 1 ; anInPort->State( SUPERV::ReadyState ) ; cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " " - << anInPort->PortName() << " " << anInPort->PortStatus() << " is Done from " - << anOutPort->NodeName() << " " << anOutPort->PortName() << " " << anOutPort->PortStatus() << " " ; + << anInPort->PortName() << " " << anInPort->PortStatus() << " is Done from Node " + << anOutPort->NodeName() << "( " << anOutPort->PortName() << ") " + << anOutPort->PortStatus() << " " ; #ifdef _DEBUG_ if ( GraphBase::Base::_prof_debug ) { anOutPort->StringValue( *GraphBase::Base::_fdebug ) ; @@ -946,9 +984,11 @@ int GraphExecutor::InNode::DataWaiting_SomeDataReadyAction() { } } else { - cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " " - << anInPort->PortName() << " " << anInPort->PortStatus() << " is NOT Done from " - << anOutPort->NodeName() << " " << anOutPort->PortName() << " " << anOutPort->PortStatus() << " " ; + cdebug << pthread_self() << "/" << ThreadNo() << " Node " << Name() << "( " + << anInPort->PortName() << ") " << anInPort->PortStatus() + << " is NOT Done from Node " + << anOutPort->NodeName() << "( " << anOutPort->PortName() << ") " + << anOutPort->PortStatus() << " " ; } } @@ -1157,9 +1197,16 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { ControlState() == SUPERV::ToKillDoneState || ControlState() == SUPERV::ToStopState ) { cdebug << ThreadNo() << "StartComponent Error or ToKillState" << endl ; + MESSAGE(pthread_self() << "Executor::InNode::DataReady_ExecuteAction of " << Name() + << " ControlState " << Automaton()->ControlStateName( ControlState() ) + << " BEFORE execution ThreadNo " << ThreadNo() ) ; Err = true ; } else { + if ( ControlState() == SUPERV::ToSuspendState ) { + cdebug << ThreadNo() << "ToSuspendState before running." << endl ; + MESSAGE(ThreadNo() << "ToSuspendState before running.") ; + } if ( !Err ) { // ostringstream astr ; // astr << "Graph " << _OutNode->Graph()->Name() << " Run of Node " << Name() ; @@ -1175,7 +1222,8 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { } if ( IsOneOfInLineNodes() ) { cdebug << " , PyFuncName '" << InLineNode()->PyFuncName() << "' PyRunMethod " - << InLineNode()->PyRunMethod() << " length " << (*InLineNode()->PythonFunction()).length() ; + << InLineNode()->PyRunMethod() << " length " + << (*InLineNode()->PythonFunction()).length() ; } cdebug << ")" << endl ; @@ -1185,107 +1233,146 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { SetPyCpuUsed() ; try { // if ( IsInLineNode() && (*InLineNode()->PythonFunction()).length() && + bool ItIsaLoop = false ; 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() ) ; - } + if ( !StsPyDynInvoke ) { + RemovePyDynInvoke( InLineNode()->PyFuncName() ) ; + } } else if ( IsLoopNode() ) { + ItIsaLoop = true ; 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() ) ; - CopyOutIn = true ; +// Switch between Init() and Next() +// if InLoop port is true and does not come from EndLoop ==> execute Init +// if InLoop port is false or come from EndLoop ==> execute Next +// GraphExecutor::InNode * anEndLoopNode = (GraphExecutor::InNode * ) CoupledNode()->GetInNode() ; +// if ( GetNodeInLoop()->GetOutPort()->BoolValue() && + if ( _InitLoop ) { + if ( strlen( InLineNode()->PyFuncName() ) ) { // InLoop Port = true ==> Init() + cdebug << ThreadNo() << " !ObjInterface " << Name() + << " IsLoopNode PyDynInvoke '" << InLineNode()->PyFuncName() + << "' InitLoop " << LoopNode()->PyRunMethod() << endl ; + StsPyDynInvoke = PyDynInvoke( InLineNode()->PyRunMethod() , + InLineNode()->PyFuncName() , + &InParametersList[1] , ServiceInParameter().length() , + &OutParametersList[1] , ServiceOutParameter().length() ) ; + if ( !StsPyDynInvoke ) { + RemovePyDynInvoke( InLineNode()->PyFuncName() ) ; + } + CopyOutIn = true ; + } + else { + cdebug << ThreadNo() << " !ObjInterface " << Name() + << " IsLoopNode NO PyDynInvoke Void PyFuncName InitLoop" << endl ; + } + cdebug << ThreadNo() << " !ObjInterface " << Name() + << " IsLoopNode _InitLoop Reset after Init() Python Function" << endl ; + _InitLoop = false ; } else if ( LoopNode()->PyNextMethod() && - strlen( LoopNode()->PyNextName() ) ){ -// cdebug << ThreadNo() << " !ObjInterface " << Name() -// << " IsLoopNode PyDynInvoke '" << LoopNode()->PyNextName() -// << "'" << endl ; + strlen( LoopNode()->PyNextName() ) ){ // InLoop Port = false ==> Next() + cdebug << ThreadNo() << " !ObjInterface " << Name() + << " IsLoopNode PyDynInvoke '" << LoopNode()->PyNextName() + << "' " << LoopNode()->PyNextMethod() << endl ; StsPyDynInvoke = PyDynInvoke( LoopNode()->PyNextMethod() , LoopNode()->PyNextName() , &InParametersList[1] , ServiceInParameter().length() , &OutParametersList[1] , ServiceOutParameter().length() ) ; + if ( !StsPyDynInvoke ) { + RemovePyDynInvoke( LoopNode()->PyNextName() ) ; + } CopyOutIn = true ; } - 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 ; - InParametersList[i].Name = OutParametersList[i].Name ; + else { + cdebug << ThreadNo() << " !ObjInterface " << Name() + << " IsLoopNode NO PyDynInvoke Void PyFuncName NextLoop" << endl ; + } + if ( StsPyDynInvoke ) { + if ( CopyOutIn ) { + cdebug << ThreadNo() << " !ObjInterface " << Name() + << " IsLoopNode PyDynInvoke '" << LoopNode()->PyMoreName() + << "' Copy of " << ServiceInParameter().length() + << " OutParameters" << endl ; + int i ; +// Start at 1 : Do not copy InLoop ( InLoop == true <==> Init ; InLoop == false <==> Next ) + for ( i = 1 ; i <= (int ) ServiceInParameter().length() ; i++ ) { + InParametersList[i].Value = OutParametersList[i].Value ; + InParametersList[i].Name = OutParametersList[i].Name ; //#if 0 - switch ( InParametersList[i].Value.type()->kind() ) { - case CORBA::tk_string : - char * t; - InParametersList[i].Value >>= t ; - cdebug << "ArgOut->In" << i << " : " - << InParametersList[i].Name.c_str() - << " Value(string) " << t << endl ; - break ; - case CORBA::tk_double : - double d; - InParametersList[i].Value >>= d; - cdebug << "ArgOut->In" << i << " : " - << InParametersList[i].Name.c_str() - << " Value(double) " << d << endl ; - break ; - case CORBA::tk_long : - long l; - InParametersList[i].Value >>= l; - cdebug << "ArgOut->In" << i << " : " - << InParametersList[i].Name.c_str() - << " Value(long) " << l << endl ; - break ; - case CORBA::tk_objref : - CORBA::Object_ptr obj ; - char * retstr ; - try { - InParametersList[i].Value >>= obj ; - retstr = ObjectToString( obj ); + switch ( InParametersList[i].Value.type()->kind() ) { + case CORBA::tk_string : + char * t; + InParametersList[i].Value >>= t ; cdebug << "ArgOut->In" << i << " : " << InParametersList[i].Name.c_str() - << " Value(object reference) " << retstr << endl ; - } - catch ( ... ) { + << " Value(string) " << t << endl ; + break ; + case CORBA::tk_double : + double d; + InParametersList[i].Value >>= d; cdebug << "ArgOut->In" << i << " : " << InParametersList[i].Name.c_str() - << " Value(object reference) Catched ERROR" << endl ; - } - break ; - default : - cdebug << "ArgOut->In" << i << " : " - << InParametersList[i].Name.c_str() - << " Value(other) ERROR" << endl ; - } + << " Value(double) " << d << endl ; + break ; + case CORBA::tk_long : + long l; + InParametersList[i].Value >>= l; + cdebug << "ArgOut->In" << i << " : " + << InParametersList[i].Name.c_str() + << " Value(long) " << l << endl ; + break ; + case CORBA::tk_objref : + CORBA::Object_ptr obj ; + char * retstr ; + try { + InParametersList[i].Value >>= obj ; + retstr = ObjectToString( obj ); + cdebug << "ArgOut->In" << i << " : " + << InParametersList[i].Name.c_str() + << " Value(object reference) " << retstr << endl ; + } + catch ( ... ) { + cdebug << "ArgOut->In" << i << " : " + << InParametersList[i].Name.c_str() + << " Value(object reference) Catched ERROR" << endl ; + } + break ; + default : + cdebug << "ArgOut->In" << i << " : " + << InParametersList[i].Name.c_str() + << " Value(other) ERROR" << endl ; + } //#endif + } } if ( LoopNode()->PyMoreMethod() && strlen( LoopNode()->PyMoreName() ) ) { + cdebug << ThreadNo() << " !ObjInterface " << Name() + << " IsLoopNode PyDynInvoke '" << LoopNode()->PyMoreName() + << "' " << LoopNode()->PyMoreMethod() << endl ; StsPyDynInvoke = PyDynInvoke( LoopNode()->PyMoreMethod() , LoopNode()->PyMoreName() , &InParametersList[1] , ServiceInParameter().length() , &OutParametersList[0] , ServiceOutParameter().length()+1 ) ; + if ( !StsPyDynInvoke ) { + RemovePyDynInvoke( LoopNode()->PyMoreName() ) ; + } } else { + cdebug << ThreadNo() << " !ObjInterface " << Name() + << " IsLoopNode PyDynInvoke '" << LoopNode()->PyMoreName() + << "' No MoreMethod" << endl ; CopyInOut = true ; } } - else if ( !StsPyDynInvoke ) { + else { Err = true ; cdebug << ThreadNo() << " InLineNode " << Name() << " " << InLineNode()->PyFuncName() << "/" << LoopNode()->PyNextName() @@ -1302,6 +1389,9 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { InLineNode()->PyFuncName() , &InParametersList[0] , ServiceInParameter().length() , &OutParametersList[0] , ServiceOutParameter().length() ) ; + if ( !StsPyDynInvoke ) { + RemovePyDynInvoke( InLineNode()->PyFuncName() ) ; + } } // else if ( IsGOTONode() && (*GOTONode()->PythonFunction()).length() && else if ( IsGOTONode() && /*InLineNode()->PyRunMethod() &&*/ @@ -1313,6 +1403,9 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { InLineNode()->PyFuncName() , &InParametersList[0] , ServiceInParameter().length() , &OutParametersList[0] , ServiceOutParameter().length() ) ; + if ( !StsPyDynInvoke ) { + RemovePyDynInvoke( GOTONode()->PyFuncName() ) ; + } } // else if ( IsEndSwitchNode() && (*InLineNode()->PythonFunction()).length() && else if ( ( IsEndSwitchNode() ) && @@ -1324,20 +1417,28 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { InLineNode()->PyFuncName() , &InParametersList[0] , ServiceInParameter().length() , &OutParametersList[0] , ServiceOutParameter().length() ) ; + if ( !StsPyDynInvoke ) { + RemovePyDynInvoke( InLineNode()->PyFuncName() ) ; + } } else if ( ( IsEndLoopNode() ) && InLineNode()->PyRunMethod() && strlen( InLineNode()->PyFuncName() ) ) { -// cdebug << ThreadNo() << " !ObjInterface " << Name() << " PyFuncName '" -// << InLineNode()->PyFuncName() -// << "' IsSwitchNode PyDynInvoke" << endl ; + 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 ) ; + if ( !StsPyDynInvoke ) { + RemovePyDynInvoke( InLineNode()->PyFuncName() ) ; + } } + // else if ( (*InLineNode()->PythonFunction()).length() == 0 || - if ( InLineNode()->PyRunMethod() == NULL || - strlen( InLineNode()->PyFuncName() ) == 0 || CopyInOut ) { + if ( (!ItIsaLoop && ( InLineNode()->PyRunMethod() == NULL || + strlen( InLineNode()->PyFuncName() ) == 0 ) ) || CopyInOut ) { +// This is a void Python Function : without code (No PyFuncName) // cdebug << ThreadNo() << " !ObjInterface " << Name() // << " Copy of " << ServiceInParameter().length() // << " OutParameters" << endl ; @@ -1347,8 +1448,12 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { if ( IsLoopNode() || IsEndLoopNode() ) { argout0 = 1 ; argin0 = 1 ; // after DoLoop - if ( IsLoopNode() ) { - OutParametersList[0].Value = InParametersList[0].Value ; // DoLoop + if ( IsLoopNode() ) { // More() is void +// OutParametersList[0].Value = InParametersList[0].Value ; // DoLoop + cdebug << Name() << " Not Beginning of loop and non void EndLoop : DoLoop = EndLoop(DoLoop)" + << endl ; + GraphExecutor::InNode * anEndLoopNode = (GraphExecutor::InNode * ) CoupledNode()->GetInNode() ; + OutParametersList[0].Value = *anEndLoopNode->GetNodeOutLoop()->Value() ; // DoLoop = EndLoop(DoLoop) } } for ( i = 0 ; i < (int ) ServiceInParameter().length() ; i++ ) { @@ -1443,7 +1548,7 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { } catch( ... ) { cdebug << "DynInvoke setProperties catched ERROR" << endl ; - Err = true ; + Err = true; } } if ( !Err && IsComputingNode() ) { @@ -1451,16 +1556,18 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { << " IsComputingNode DynInvoke" << endl ; cdebug << ServiceInParameter().length()-1 << " input parameters and " << ServiceOutParameter().length() << " output parameters" << endl ; + IsLoading( false ) ; DynInvoke( myObjComponent, ServiceName() , &InParametersList[1] , ServiceInParameter().length()-1 , &OutParametersList[0] , ServiceOutParameter().length() ) ; } - else if ( !Err &&IsFactoryNode() ) { + else if ( !Err && IsFactoryNode() ) { cdebug << ThreadNo() << " !ObjInterface " << Name() << " IsFactoryNode DynInvoke" << endl ; cdebug << ServiceInParameter().length() << " input parameters and " << ServiceOutParameter().length() << " output parameters" << endl ; + IsLoading( false ) ; DynInvoke( myObjComponent, ServiceName() , &InParametersList[0] , ServiceInParameter().length() , @@ -1474,20 +1581,29 @@ int GraphExecutor::InNode::DataReady_ExecuteAction() { cdebug << ThreadNo() << " !ObjInterface " << Name() << " Node(Component) Dynamic Call Exception catched ERROR" << endl ; +//Reset of _ThreadId in the Container ... + try { + myObjComponent->Kill_impl() ; + } + catch( ... ) { + } } } } } } -// else { -// sleep( 1 ) ; -// } // ostringstream astr ; // astr << "Graph " << _OutNode->Graph()->Name() << " Node " << Name() << " is done : " // << Automaton()->StateName( State() ) ; // _OutNode->Graph()->ObjImpl()->sendMessage( NOTIF_STEP, astr.str().c_str() ) ; + if ( Err ) { + + // if exception or something else - IsLoading( false ) may not NOT has been called + if ( IsLoading() ) + IsLoading( false ); + if ( ControlState() == SUPERV::ToKillState || ControlState() == SUPERV::ToKillDoneState || ControlState() == SUPERV::ToStopState ) { @@ -1622,6 +1738,9 @@ int GraphExecutor::InNode::Executing_SuccessAction() { // cdebug << ThreadNo() << " --> Executing_SuccessAction " << Name() << endl; _OutNode->PushEvent( this , GraphExecutor::SuccessedExecutingEvent , GraphExecutor::SuccessedState ) ; + MESSAGE(pthread_self() << "Executor::InNode::Executing_SuccessAction of " << Name() + << " ControlState " << Automaton()->ControlStateName( ControlState() ) + << " AFTER execution ThreadNo " << ThreadNo() ) ; SUPERV::ControlState aControl = ControlState() ; switch ( aControl ) { case SUPERV::VoidState : { @@ -1709,16 +1828,21 @@ void GraphExecutor::InNode::SetWaitingStates(GraphExecutor::InNode * EndNode ) { State( GraphExecutor::DataWaitingState ) ; for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) { GraphBase::InPort * anInPort = GetChangeNodeInPort( i ) ; - if ( anInPort->IsGate() ) { // Loop : Open the doors + cdebug << "SetWaitingStates InPort " << Name() << "( " << anInPort->PortName() << " ) " + << anInPort->PortStatus() << " " << anInPort->State() << endl ; +// JR Debug 07.01.2005 : Close the Gates instead of open !!! + if ( anInPort->IsGate() ) { // Loop : Close the doors GraphBase::OutPort * anOutPort = anInPort->GetOutPort() ; if ( anOutPort ) { CORBA::Any * anAny = new CORBA::Any() ; - *anAny <<= (long ) 1 ; +// *anAny <<= (long ) 1 ; + *anAny <<= (long ) 0 ; anOutPort->Value( anAny ) ; - anInPort->State( SUPERV::ReadyState ) ; + anInPort->State( SUPERV::WaitingState ) ; } } - else if ( anInPort->State() != SUPERV::WaitingState ) { + else if ( anInPort->State() != SUPERV::WaitingState && + !anInPort->IsDataConnected() ) { if ( !docdebug ) { cdebug << ThreadNo() << " --> GraphExecutor::InNodeThreads::SetWaitingStates " << Name() << endl; @@ -1728,13 +1852,14 @@ void GraphExecutor::InNode::SetWaitingStates(GraphExecutor::InNode * EndNode ) { anInPort->State( SUPERV::WaitingState ) ; } } + cdebug << " --> " << Name() << "( " << anInPort->PortName() << " ) " + << anInPort->PortStatus() << " " << anInPort->State() << endl ; } for ( i = 0 ; i < GetNodeOutPortsSize() ; i++ ) { GraphBase::OutPort * anOutPort = GetChangeNodeOutPort( i ) ; for ( j = 0 ; j < anOutPort->InPortsSize() ; j++ ) { if ( !( IsGOTONode() && anOutPort->IsGate() ) && - !( IsEndLoopNode() && ( anOutPort->IsGate() || - anOutPort->IsLoop() ) ) && + !( IsEndLoopNode() && ( anOutPort->IsGate() || anOutPort->IsLoop() ) ) && !anOutPort->IsDataStream() && !anOutPort->ChangeInPorts( j )->IsDataStream() && !anOutPort->ChangeInPorts( j )->IsExternConnected() ) { @@ -1745,17 +1870,23 @@ void GraphExecutor::InNode::SetWaitingStates(GraphExecutor::InNode * EndNode ) { << anOutPort->ChangeInPorts( j )->NodeName() << "( " << anOutPort->ChangeInPorts( j )->PortName() << " " << anOutPort->ChangeInPorts( j )->PortStatus() << " )" << endl; - if ( strcmp( anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName() , Name() ) ) { + GraphBase::ComputingNode * aToNode ; + aToNode = _OutNode->Graph()->GetChangeGraphNode( anOutPort->ChangeInPorts( j )->NodeName() ) ; +// JR 12.01.2005 : the OutPort linked to the InPort of a EndSwitchNode was changed so final +// values of InPorts of EndSwitchNode may be wrong + if ( !aToNode->IsEndSwitchNode() && + strcmp( anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName() , Name() ) ) { // After EndLoopNode or GOTONode the Input Ports of LoopNode or LabelNode have their values from // EndLoopNode or GOTONode. But if there is several nested loops we should re-establish. cdebug << ThreadNo() - << " InNodeThreads::SetWaitingStates OutPort->ChangeInPorts( j )->OutPort()->NodeName " - << anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName() << " != " + << " InNodeThreads::SetWaitingStates Node " << Name() << " " + << anOutPort->ChangeInPorts( j )->GetOutPort()->NodeName() << "( " + << anOutPort->ChangeInPorts( j )->GetOutPort()->PortName() << " ) != " << Name() << " : Restored to " << anOutPort->NodeName() << "( " << anOutPort->PortName() << " )" << endl ; anOutPort->ChangeInPorts( j )->ChangeOutPort( anOutPort ) ; } - GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) _OutNode->Graph()->GetChangeGraphNode( anOutPort->ChangeInPorts( j )->NodeName() )->GetInNode() ; + GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) aToNode->GetInNode() ; if ( aNode != EndNode ) { aNode->SetWaitingStates( EndNode ) ; } @@ -1778,14 +1909,14 @@ int GraphExecutor::InNode::Successed_SuccessAction() { DoneAction() ; if ( IsMacroNode() ) { - cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " LinkedNodes->SomeDataReady already done" + cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " LinkedNodes->SomeDataReady already done" << endl ; return 1; } if ( IsGOTONode() || ( IsEndLoopNode() && GetNodeInLoop()->GetOutPort()->BoolValue() ) ) { - cdebug << ThreadNo() << " Successed_SuccessAction " << Name() + cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " SetWaitingStates " << endl ; const GraphBase::OutPort * aGateOutPort ; if ( IsGOTONode() ) { @@ -1794,12 +1925,25 @@ int GraphExecutor::InNode::Successed_SuccessAction() { else { aGateOutPort = GetNodeOutLoop() ; } + if ( aGateOutPort->InPortsSize() != 1 ) { + cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction aGateOutPort->InPortsSize " + << aGateOutPort->InPortsSize() << " != 1 ERROR " << Name() << endl ; + } + GraphExecutor::InNode * aLabelNode = NULL ; for ( i = 0 ; i < aGateOutPort->InPortsSize() ; i++ ) { const GraphBase::InPort * anInPort = aGateOutPort->InPorts( i ) ; - GraphExecutor::InNode * aLabelNode = (GraphExecutor::InNode *) _OutNode->Graph()->GetChangeGraphNode( anInPort->NodeName() )->GetInNode() ; - cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " will Loop to HeadNode " + aLabelNode = (GraphExecutor::InNode *) _OutNode->Graph()->GetChangeGraphNode( anInPort->NodeName() )->GetInNode() ; + cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " will Loop to HeadNode " << aLabelNode->Name() << " from port " << anInPort->PortName() << endl ; aLabelNode->SetWaitingStates( this ) ; +// JR 07.01.2005 Debug : Open the Gate of the coupledNode closed by SetWaitingStates + GraphBase::OutPort * anOutPort = aLabelNode->GetChangeNodeInGate()->GetOutPort() ; + if ( anOutPort ) { + CORBA::Any * anAny = new CORBA::Any() ; + *anAny <<= (long ) 1 ; + anOutPort->Value( anAny ) ; + aLabelNode->GetChangeNodeInGate()->State( SUPERV::ReadyState ) ; + } for ( j = 0 ; j < aLabelNode->GetNodeInPortsSize() ; j++ ) { const GraphBase::InPort * anInPort = aLabelNode->GetNodeInPort( j ) ; if ( anInPort->GetOutPort() ) { @@ -1813,52 +1957,43 @@ int GraphExecutor::InNode::Successed_SuccessAction() { if ( !aBusParamOutPort->IsGate() ) { GraphBase::InPort * aBusParamChangeInPort = NULL ; if ( aBusParamOutPort->IsLoop() ) { - aBusParamChangeInPort = aLabelNode->GetChangeNodeInLoop() ; +// For EndLoop do not copy EndLoop(DoLoop) in Loop(InLoop) +// aBusParamChangeInPort = aLabelNode->GetChangeNodeInLoop() ; } else { aBusParamChangeInPort = aLabelNode->GetChangeInPort( aBusParamOutPort->PortName() ) ; } if ( aBusParamChangeInPort ) { aBusParamChangeInPort->ChangeOutPort( aBusParamOutPort ) ; - cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " ChangeOutPort to HeadNode " + cdebug << pthread_self() << "/" << 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 ; - } - else if ( firstzeroNode == NULL && - aLabelNode->ThreadNo() == 0 ) { - firstzeroNode = aLabelNode ; - } - else { - SomeDataNodes.push_back( aLabelNode ) ; - 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; - } - } - else { - cdebug << ThreadNo() << " ERROR in Successed_SuccessAction of " << Name() - << " NO port " << aBusParamOutPort->PortName() << " in " - << aLabelNode->Name() << endl; } + } + } + } + + if ( aLabelNode && !aLabelNode->IsLockedDataWait() ) { + res = aLabelNode->SendSomeDataReady( Name() ) ; + if ( res ) { + if ( firsttoNode == NULL && + aLabelNode->ThreadNo() == pthread_self() ) { + firsttoNode = aLabelNode ; + cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction firsttoNode " + << aLabelNode->Name() << endl ; } + else if ( firstzeroNode == NULL && + aLabelNode->ThreadNo() == 0 ) { + firstzeroNode = aLabelNode ; + } + else { + SomeDataNodes.push_back( aLabelNode ) ; + cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " push " + << aLabelNode->Name() << " " << SomeDataNodes.size() + << endl ; + } } + for ( j = 0 ; j < aLabelNode->GetNodeInPortsSize() ; j++ ) { const GraphBase::InPort * anInPort = aLabelNode->GetNodeInPort( j ) ; if ( anInPort->GetOutPort() ) { @@ -1878,7 +2013,7 @@ int GraphExecutor::InNode::Successed_SuccessAction() { if ( firsttoNode == NULL && aLabelNode->ThreadNo() == pthread_self() ) { firsttoNode = aLabelNode ; - cdebug << ThreadNo() << " Successed_SuccessAction firsttoNode " + cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction firsttoNode " << aLabelNode->Name() << endl ; } else if ( firstzeroNode == NULL && @@ -1887,7 +2022,7 @@ int GraphExecutor::InNode::Successed_SuccessAction() { } else { SomeDataNodes.push_back( aLabelNode ) ; - cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " push " + cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " push " << aLabelNode->Name() << " " << SomeDataNodes.size() << endl ; } @@ -1895,7 +2030,7 @@ int GraphExecutor::InNode::Successed_SuccessAction() { } } else { - cdebug << ThreadNo() << " ERROR in Successed_SuccessAction of " << Name() + cdebug << pthread_self() << "/" << ThreadNo() << " ERROR in Successed_SuccessAction of " << Name() << " NO port " << aGateOutPort->PortName() << " in " << aLabelNode->Name() << endl; } @@ -1917,7 +2052,7 @@ int GraphExecutor::InNode::Successed_SuccessAction() { GraphBase::ComputingNode * aComputingNode ; aComputingNode = (GraphBase::ComputingNode * ) LinkedNodes( i ) ; toNode = (GraphExecutor::InNode *) aComputingNode->GetInNode() ; - cdebug << ThreadNo() << " Successed_SuccessAction of " << Name() + cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction of " << Name() << " [" << i << "] " << LinkedNodes( i )->Name() << " toNode " << toNode << " IgnoreForEndLoop " << IgnoreForEndLoop ; if ( toNode ) { @@ -1966,7 +2101,7 @@ int GraphExecutor::InNode::Successed_SuccessAction() { LoopOutPort->PortStatus( DataConnected ); LoopOutPort->State( SUPERV::ReadyState ) ; LoopOutPort->Done( true ) ; - CORBA::Any * anAny = new CORBA::Any() ; + CORBA::Any * anAny = new CORBA::Any() ; // InitLoop *anAny <<= (long ) 1 ; LoopOutPort->Value( anAny ) ; int j ; @@ -1974,14 +2109,14 @@ int GraphExecutor::InNode::Successed_SuccessAction() { toNode->GetChangeNodeInPort( j )->InitialOutPort() ; } } - cdebug << ThreadNo() << " Successed_SuccessAction " << toNode->Name() << "->SendSomeDataReady( " + cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << toNode->Name() << "->SendSomeDataReady( " << Name() << " )" << endl ; res = toNode->SendSomeDataReady( Name() ) ; if ( res ) { if ( firsttoNode == NULL && toNode->ThreadNo() == pthread_self() ) { firsttoNode = toNode ; - cdebug << ThreadNo() << " Successed_SuccessAction firsttoNode " + cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction firsttoNode " << toNode->Name() << endl ; } else if ( firstzeroNode == NULL && @@ -1990,7 +2125,7 @@ int GraphExecutor::InNode::Successed_SuccessAction() { } else { SomeDataNodes.push_back( toNode ) ; - cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " push " + cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " push " << toNode->Name() << " " << SomeDataNodes.size() << endl ; } } @@ -2000,17 +2135,17 @@ int GraphExecutor::InNode::Successed_SuccessAction() { if ( firsttoNode == NULL && firstzeroNode ) { firsttoNode = firstzeroNode ; - cdebug << ThreadNo() + cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction firsttoNode = firstzeroNode " << endl ; } else if ( firsttoNode && firstzeroNode ) { SomeDataNodes.push_back( firstzeroNode ) ; - cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " push firstzeroNode " + cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " push firstzeroNode " << firstzeroNode->Name() << " " << SomeDataNodes.size() << endl ; } else { - cdebug << ThreadNo() << " Successed_SuccessAction " << Name() << " firsttoNode " << firsttoNode + cdebug << pthread_self() << "/" << ThreadNo() << " Successed_SuccessAction " << Name() << " firsttoNode " << firsttoNode << " firstzeroNode " << firstzeroNode << endl ; } @@ -2088,7 +2223,7 @@ int GraphExecutor::InNode::Successed_SuccessAction() { bool GraphExecutor::InNode::SendSomeDataReady( char * FromNodeName ) { bool RetVal = false ; if ( IsDataFlowNode() ) { - cdebug << ThreadNo() << " ----> " << Name() + cdebug << ThreadNo() << "InNode::SendSomeDataReady ----> " << Name() << " send Result to graph " << Name() << endl; } else { @@ -2113,6 +2248,12 @@ bool GraphExecutor::InNode::SendSomeDataReady( char * FromNodeName ) { // << ThreadNo() << " " << endl ; State( GraphExecutor::DataWaitingState ) ; } +// We begin that LoopNode if SendSomeDataReady does not come from the corresponding EndLoopNode + if ( IsLoopNode() && strcmp( LoopNode()->CoupledNodeName() , FromNodeName ) ) { + cdebug << ThreadNo() << "InNode::SendSomeDataReady " << Name() << " Set _InitLoop from " + << FromNodeName << endl ; + _InitLoop = true ; + } LockDataWait() ; DataFromNode( FromNodeName ) ; RetVal = !SendEvent( GraphExecutor::SomeDataReadyEvent ); @@ -2291,6 +2432,7 @@ void GraphExecutor::InNode::InParametersSet( bool & Err , int nInParams , ServicesAnyData * InParametersList ) { int i ; + cdebug << ThreadNo() << " InParametersSet " << Name() << endl ; for ( i = 0 ; i < nInParams ; i++ ) { ServicesAnyData D = InParametersList[i]; GraphBase::InPort * anInPort = GetChangeNodeInPort(i) ; @@ -2306,11 +2448,13 @@ void GraphExecutor::InNode::InParametersSet( bool & Err , *anAny <<= (long ) 0 ; theOutPort->Value( anAny ) ; } - if ( !anInPort->IsDataStream() ) { + if ( !anInPort->IsDataStream() && + !anInPort->IsDataConnected() ) { anInPort->State( SUPERV::WaitingState ) ; } D.Name = CORBA::string_dup( anInPort->GetServicesParameter().Parametername ) ; - cdebug << ThreadNo() << " ArgIn" << i << " " << anInPort->Kind() ; + cdebug << ThreadNo() << " ArgIn" << i << " " << anInPort->Kind() + << " " << anInPort->State() ; cdebug << " " << D.Name << " " << anInPort->GetServicesParameter().Parametertype << " : " ; D.Value = *theOutPort->Value() ; // CORBA::Any string _Type = CORBA::string_dup( anInPort->GetServicesParameter().Parametertype ) ; @@ -2682,7 +2826,8 @@ bool GraphExecutor::InNode::OutParametersSet( bool Err , int i ; GraphBase::OutPort * aGateOutPort = NULL ; bool OrSwitch = false ; - cdebug << "OutParametersSet " << Name() << " nOutParams " << nOutParams << " NewState " << NewState << endl ; + cdebug_in << "OutParametersSet " << Name() << " nOutParams " << nOutParams << " NewState " + << NewState << endl ; // cout << "OutParametersSet " << Name() << " nOutParams " << nOutParams << " NewState " << NewState << endl ; if ( nOutParams && !IsMacroNode() ) { GraphBase::OutPort * anOutPort ; @@ -2784,14 +2929,16 @@ bool GraphExecutor::InNode::OutParametersSet( bool Err , anOutPort->Value( OutParametersList[i].Value ); if ( anOutPort->InPortsSize() && anOutPort->ChangeInPorts( 0 )->IsGate() ) { if ( OrSwitch && anOutPort->BoolValue() ) { - cdebug << "GraphExecutor::InNodeThreads::OutParameters more than one switch is true WARNING" + cdebug << "GraphExecutor::InNodeThreads::OutParameters more than one switch is true ERROR" << endl ; + RetVal = false ; } else { OrSwitch = OrSwitch | anOutPort->BoolValue() ; + cdebug << "InNodeThreads::OutParameters OrSwitch = true" << endl ; } } - cdebug << "OrSwitch " << OrSwitch ; + cdebug << "OutParametersSet OrSwitch " << OrSwitch ; } else { cdebug << " Param " ; @@ -2906,15 +3053,15 @@ bool GraphExecutor::InNode::OutParametersSet( bool Err , } if ( aGateOutPort && IsSwitchNode() ) { if ( OrSwitch ) { -// cdebug << ThreadNo() << " " << "Out0 " << Name() << " Close of " -// << aGateOutPort->PortName() << " " << aGateOutPort->Kind() ; + cdebug << ThreadNo() << " " << "Out0 " << Name() << " Close of " + << aGateOutPort->PortName() << " " << aGateOutPort->Kind() ; long l = 0; OutParametersList[0].Value <<= l ; aGateOutPort->Value( OutParametersList[0].Value ) ; } else { -// cdebug << ThreadNo() << " " << "Out0 " << Name() << " Open of " -// << aGateOutPort->PortName() << " " << aGateOutPort->Kind() ; + cdebug << ThreadNo() << " " << "Out0 " << Name() << " Open of " + << aGateOutPort->PortName() << " " << aGateOutPort->Kind() ; long l = 1; OutParametersList[0].Value <<= l ; aGateOutPort->Value( OutParametersList[0].Value ) ; @@ -2929,5 +3076,7 @@ bool GraphExecutor::InNode::OutParametersSet( bool Err , } } } + cdebug_out << "OutParametersSet " << Name() << " nOutParams " << nOutParams << " NewState " + << NewState << " RetVal " << RetVal << endl ; return RetVal ; } diff --git a/src/GraphExecutor/DataFlowExecutor_OutNode.cxx b/src/GraphExecutor/DataFlowExecutor_OutNode.cxx index b1d8b2c..88e0cb3 100644 --- a/src/GraphExecutor/DataFlowExecutor_OutNode.cxx +++ b/src/GraphExecutor/DataFlowExecutor_OutNode.cxx @@ -32,6 +32,9 @@ using namespace std; #include "DataFlowEditor_DataFlow.hxx" +// asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL +//extern Engines_Container_i * _TheContainer ; + extern GraphExecutor::FiniteStateMachine * theAutomaton ; // static const char *ComponentName = "SalomeSuperVisionComponent" ; @@ -41,6 +44,9 @@ extern char ** _ArgV ; GraphExecutor::OutNode::OutNode() { // Graph() { + // asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL + //_SuperVisionContainer = _TheContainer ; + //_MainThreadId = SuperVisionContainer()->MainThreadId() ; _Valid = false ; _Executable = false ; _Done = false ; @@ -80,6 +86,9 @@ GraphExecutor::OutNode::OutNode( CORBA::ORB_ptr ORB, _prof_debug , _fdebug ) ; _Graph = _StreamGraph ; } + // asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL + //_SuperVisionContainer = _TheContainer ; + //_MainThreadId = SuperVisionContainer()->MainThreadId() ; _Valid = false ; _Executable = false ; _Done = false ; @@ -142,6 +151,9 @@ GraphExecutor::OutNode::OutNode( CORBA::ORB_ptr ORB, _prof_debug , _fdebug ) ; _Graph = _StreamGraph ; } + // asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL + //_SuperVisionContainer = _TheContainer ; + //_MainThreadId = SuperVisionContainer()->MainThreadId() ; _Valid = false ; _Executable = false ; _Done = false ; @@ -440,17 +452,21 @@ bool GraphExecutor::OutNode::Valid() { _Executable = false ; if ( !Graph()->CreateService() ) { - cdebug << "This DataFlow has invalid type(s)." << endl ; + cdebug_out << "This DataFlow has invalid type(s)." << endl ; return false ; } int SubStreamGraphsNumber = 0 ; if ( !Graph()->Sort( SubStreamGraphsNumber ) ) { - cdebug << "This DataFlow is not valid." << endl ; + cdebug_out << "This DataFlow is not valid." << endl ; return false ; } if ( Graph()->IsDataStreamNode() ) { StreamGraph()->SubStreamGraphsNumber( SubStreamGraphsNumber ) ; } + if ( !Graph()->ValidLoops() ) { + cdebug_out << "This DataFlow have not valid Loops." << endl ; + return false ; + } // CreateService() ; @@ -484,7 +500,8 @@ bool GraphExecutor::OutNode::Executable() { bool GraphExecutor::OutNode::Run( const bool AndSuspend ) { bool RetVal = false ; - cdebug_in << "GraphExecutor::OutNode::Run( AndSuspend " << AndSuspend << " )" << endl; + cdebug_in << pthread_self() << "GraphExecutor::OutNode::Run( AndSuspend " << AndSuspend << " )" + << endl; if ( Executable() ) { _ControlState = SUPERV::VoidState ; @@ -496,15 +513,20 @@ bool GraphExecutor::OutNode::Run( const bool AndSuspend ) { int i ; for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) { GraphExecutor::InNode * anInNode = (GraphExecutor::InNode *) Graph()->GraphNodes( i )->GetInNode() ; + anInNode->OutNode( this ) ; +// Initialize in python interpretor the python functions if ( !PyInitialized() && anInNode->IsOneOfInLineNodes() ) { if ( !Py_IsInitialized() ) { +// PyEval_InitThreads() ; // Py_Initialize() ; + // asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL + // 1 line below uncommented PySys_SetArgv( _ArgC , _ArgV ) ; } anInNode->InitPython() ; PyInitialized( true ) ; } - anInNode->InitialState( this ) ; + anInNode->InitialState() ; if ( anInNode->IsOneOfInLineNodes() ) { anInNode->InitPythonFunctions( false ) ; } @@ -567,19 +589,25 @@ bool GraphExecutor::OutNode::Run( const bool AndSuspend ) { } // PushEvent( anInNode , GraphExecutor::ReadyEvent , // GraphExecutor::DataReadyState ) ; +// We say that we have to create a thread for that HeadNode 'anInNode' anInNode->CreateNewThread( true ) ; anInNode->DataFromNode( Graph()->Name() ) ; +// AndSuspend == true <==> Start() if ( AndSuspend ) { anInNode->State( GraphExecutor::DataWaitingState ) ; anInNode->ControlState( SUPERV::ToSuspendStartState ) ; +// We send SomeDataReadyEvent +// It is a HeadNode ==> AllDataReadyEvent ==> InNode::executeAction() ==> pthread_create if ( !anInNode->SendEvent( GraphExecutor::SomeDataReadyEvent ) ) { cdebug << "InNode::SendEvent( SomeDataReadyEvent ) ERROR Node " << anInNode->Name() << endl ; cdebug_out << "GraphExecutor::OutNode::Run SendEvent ERROR" << endl ; return false ; } +// ==> We wait for SuspendedState anInNode->SuspendedWait() ; } +// AndSuspend == false <==> Run() else if ( anInNode->IsMacroNode() ) { if ( !anInNode->SendEvent( GraphExecutor::SomeDataReadyEvent ) ) { cdebug << "InNode::SendEvent( SomeDataReadyEvent ) ERROR Node " @@ -589,17 +617,20 @@ bool GraphExecutor::OutNode::Run( const bool AndSuspend ) { } cdebug << pthread_self() << " GraphExecutor::OutNode::Run " << anInNode->Name() << "->RunningWait" << endl ; +// ==> We wait for RunningState anInNode->RunningWait() ; cdebug << pthread_self() << " GraphExecutor::OutNode::Run " << anInNode->Name() << "->RunningWaited" << endl ; } else if ( !anInNode->IsMacroNode() ) { +// It is a HeadNode ==> AllDataReadyEvent ==> InNode::executeAction() ==> pthread_create if ( !anInNode->SendEvent( GraphExecutor::ExecuteEvent ) ) { cdebug << "InNode::SendEvent( ExecuteEvent ) ERROR Node " << anInNode->Name() << endl ; cdebug_out << "GraphExecutor::OutNode::Run SendEvent ERROR" << endl ; return false ; } +// ==> We wait for RunningState anInNode->RunningWait() ; } } @@ -622,25 +653,12 @@ bool GraphExecutor::OutNode::Run( const bool AndSuspend ) { } } - cdebug_out << "GraphExecutor::OutNode::Run " << Graph()->Name() << " GraphMacroLevel " + cdebug_out << pthread_self() << "GraphExecutor::OutNode::Run " << Graph()->Name() + << " GraphMacroLevel " << Graph()->GraphMacroLevel() << " RetVal " << RetVal << endl ; return RetVal ; } -bool GraphExecutor::OutNode::Run( const char * aNodeName , - const char * AtNodeName , - const bool AndSuspend ) { - bool RetVal = false ; - cdebug_in << "GraphExecutor::OutNode::Run( " << aNodeName << " , " - << AtNodeName << " , " << AndSuspend << ")" << endl; - GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *) Graph()->GetGraphNode( aNodeName )->GetInNode() ; - if ( anInNode ) { - RetVal = anInNode->ReStart( AtNodeName , AndSuspend ) ; - } - cdebug_out << "GraphExecutor::OutNode::Run" << endl ; - return RetVal ; -} - void GraphExecutor::OutNode::CheckAllDone() { int j ; cdebug_in << "GraphExecutor::OutNode::CheckAllDone " << endl; @@ -695,8 +713,6 @@ void GraphExecutor::OutNode::CheckAllDone() { aState == SUPERV::RunningState || aState == SUPERV::SuspendDoneState || aState == SUPERV::SuspendErroredState || - aState == SUPERV::ReRunState || - aState == SUPERV::ReStartState || aState == SUPERV::SuspendState ) { alivenodes += 1 ; } @@ -740,6 +756,15 @@ void GraphExecutor::OutNode::CheckAllDone() { << _SuspendedThreads << " EventQSize " << EventQSize() << endl ; } +// asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL +//Engines_Container_i * GraphExecutor::OutNode::SuperVisionContainer() { +// return _SuperVisionContainer ; +//} + +//const pthread_t GraphExecutor::OutNode::MainThreadId() const { +// return _MainThreadId ; +//} + void GraphExecutor::OutNode::PThreadLock( pthread_mutex_t * aMutex , char * errmsg ) { // if ( strcmp( errmsg , "EventLoop" ) && strcmp( errmsg , "EventW" ) ) { // cdebug << "GraphExecutor::OutNode::PThreadLock " << pthread_self() << " " << aMutex << " " @@ -924,14 +949,6 @@ SUPERV::GraphEvent GraphExecutor::OutNode::AutomatonGraphEvent(GraphExecutor::No aGraphEvent = SUPERV::ErroredEvent ; break ; } - case GraphExecutor::ReStartEvent : { - aGraphEvent = SUPERV::ReRunEvent ; - break ; - } - case GraphExecutor::ReStartAndSuspendEvent : { - aGraphEvent = SUPERV::ReStartEvent ; - break ; - } case GraphExecutor::NoDataReadyEvent : { aGraphEvent = SUPERV::WaitingEvent ; break ; @@ -1020,14 +1037,6 @@ SUPERV::GraphEvent GraphExecutor::OutNode::AutomatonGraphEvent(GraphExecutor::No aGraphEvent = SUPERV::StopEvent ; break ; } - case GraphExecutor::ReStartedEvent : { - aGraphEvent = SUPERV::ReRunEvent ; - break ; - } - case GraphExecutor::ReStartedAndSuspendEvent : { - aGraphEvent = SUPERV::ReStartEvent ; - break ; - } case GraphExecutor::EndExecuteEvent : { aGraphEvent = SUPERV::DoneEvent ; break ; @@ -1156,13 +1165,9 @@ SUPERV::GraphState GraphExecutor::OutNode::AutomatonGraphState(GraphExecutor::Au aGraphState = SUPERV::StopState ; break ; } - case GraphExecutor::ReRunnedState : { - aGraphState = SUPERV::ReRunState ; - break ; - } - case GraphExecutor::ReStartedState : { - aGraphState = SUPERV::ReStartState ; - break ; + case GraphExecutor::LoadingState : { + aGraphState = SUPERV::LoadingState ; + break; } default : { cdebug << " GraphExecutor::OutNode::AutomatonGraphState Error Undefined State : " @@ -1241,8 +1246,10 @@ bool GraphExecutor::OutNode::Event( char ** aNodeName , int ThreadsNumber ; int SuspendedThreadsNumber ; + bool cdebuginout = false ; if ( _EventNodes.size() > 0 ) { - cdebug_in << "GraphExecutor::OutNode::Event " << _EventNodes.size() << " in queue" << endl ; +// cdebug_in << "GraphExecutor::OutNode::Event " << _EventNodes.size() << " in queue" << endl ; + cdebuginout = true ; } if ( pthread_mutex_lock( &_MutexWait ) ) { perror("EventLoop pthread_mutex_lock ") ; @@ -1301,9 +1308,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 " - << *aNodeName << " " << anEvent << " " << aState << endl ; + if ( cdebuginout ) { +// cdebug_out << "GraphExecutor::OutNode::Event " << _EventNodes.size() << " in queue" +// << *aNodeName << " " << anEvent << " " << aState << endl ; } return RetVal ; } @@ -1511,7 +1518,10 @@ SUPERV::GraphState GraphExecutor::OutNode::State( const char * NodeName ) { if ( aCNode ) { GraphExecutor::InNode *anInNode = (GraphExecutor::InNode *)aCNode->GetInNode() ; if ( anInNode ) { - aret = anInNode->State() ; + if ( anInNode->IsLoading() ) + aret = GraphExecutor::LoadingState; + else + aret = anInNode->State() ; // cdebug << "GraphExecutor::OutNode::State( " << NodeName << " ) " // << theAutomaton->StateName( AutomatonGraphState( aret ) ) << endl ; } @@ -1614,7 +1624,8 @@ bool GraphExecutor::OutNode::IsDone() { bool GraphExecutor::OutNode::IsSuspended() { // cdebug_in << "GraphExecutor::OutNode::IsSuspended" << endl; bool aret = false ; - if ( _SuspendedThreads == _Threads && _Threads != 0 ) { +// if ( _SuspendedThreads == _Threads && _Threads != 0 ) { + if ( AutomatonGraphState( _State ) == SUPERV::SuspendState ) { aret = true ; } // cdebug_out << "GraphExecutor::OutNode::IsSuspended" << endl ; @@ -1752,12 +1763,16 @@ bool GraphExecutor::OutNode::Suspend() { RetVal += 1 ; cdebug << aNode->Name() << " Suspended" << endl ; } - else if ( aNode->IsWaiting() || aNode->IsDone() ) { + else if ( aNode->IsWaiting() || aNode->IsReady() ) { + RetVal += 1 ; + cdebug << aNode->Name() << " will be Suspended" << endl ; + } + else if ( aNode->IsDone() ) { cdebug << aNode->Name() << " not Suspended : " << theAutomaton->StateName( aNode->State() ) << endl ; } else { - RetVal += 1 ; +// RetVal += 1 ; cdebug << aNode->Name() << " cannot be Suspended : " << theAutomaton->StateName( aNode->State() ) << endl ; } @@ -1773,13 +1788,20 @@ bool GraphExecutor::OutNode::Suspend() { MESSAGE( Graph()->Name() << " IS NOT SUSPENDED" ) ; MESSAGE("================================================================================") ; } - cdebug_out << "GraphExecutor::OutNode::Suspend" << theAutomaton->StateName( State() ) << endl ; + for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) { + GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) Graph()->GraphNodes( i )->GetInNode() ; + MESSAGE(aNode->Name() << " " << theAutomaton->StateName( aNode->State() ) ) ; + cdebug << aNode->Name() << " " << theAutomaton->StateName( aNode->State() ) << endl ; + } + cdebug_out << "GraphExecutor::OutNode::Suspend " << theAutomaton->StateName( State() ) + << " EventQSize " << EventQSize() << endl ; return RetVal ; } bool GraphExecutor::OutNode::Resume() { int RetVal = 0 ; - cdebug_in << "GraphExecutor::OutNode::Resume" << endl; + cdebug_in << "GraphExecutor::OutNode::Resume " + << theAutomaton->StateName( State() ) << endl; if ( IsSuspended() ) { State( GraphExecutor::ExecutingState ) ; int i ; @@ -1818,20 +1840,38 @@ bool GraphExecutor::OutNode::Resume() { MESSAGE( Graph()->Name() << " IS NOT RESUMED" ) ; MESSAGE("================================================================================") ; } - cdebug_out << "GraphExecutor::OutNode::Resume" << theAutomaton->StateName( State() ) << " " << RetVal << endl ; + int i ; + for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) { + GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) Graph()->GraphNodes( i )->GetInNode() ; + MESSAGE(aNode->Name() << " " << theAutomaton->StateName( aNode->State() ) ) ; + cdebug << aNode->Name() << " " << theAutomaton->StateName( aNode->State() ) << endl ; + } + cdebug_out << "GraphExecutor::OutNode::Resume" << theAutomaton->StateName( State() ) << " " << RetVal + << " EventQSize " << EventQSize() << endl ; return RetVal ; } bool GraphExecutor::OutNode::Kill() { - bool RetVal = true ; - cdebug_in << "GraphExecutor::OutNode::Kill" << endl; + bool RetVal = false ; + cdebug_in << "GraphExecutor::OutNode::Kill" + << " EventQSize " << EventQSize() << endl; _ControlState = SUPERV::ToSuspendState ; int i ; for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) { GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) Graph()->GraphNodes( i )->GetInNode() ; bool sts = aNode->Kill() ; - if ( sts && aNode->IsKilled() ) { - cdebug << aNode->Name() << " killed" << endl ; + if ( sts && Threads() != 0 ) { + if ( !aNode->IsKilled() ) { + cdebug << aNode->Name() << " not killed : " + << theAutomaton->StateName( aNode->State() ) << " " << aNode->Name() << "->" + << "KilledAction()" << endl ; + MESSAGE( aNode->Name() << " not killed : KilledAction()" ) ; + aNode->KilledAction() ; + } + if ( aNode->IsKilled() ) { + cdebug << aNode->Name() << " killed" << endl ; + RetVal = true ; + } } else if ( aNode->IsWaiting() || aNode->IsDone() ) { cdebug << aNode->Name() << " not killed : " @@ -1840,23 +1880,10 @@ bool GraphExecutor::OutNode::Kill() { else { cdebug << aNode->Name() << " cannot be killed : " << theAutomaton->StateName( aNode->State() ) << endl ; - RetVal = false ; - } - } - if ( !RetVal || Threads() != 0 ) { - for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) { - GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) Graph()->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( GraphExecutor::KilledState ) ; if ( RetVal ) { + State( GraphExecutor::KilledState ) ; MESSAGE("================================================================================") ; MESSAGE( Graph()->Name() << " IS KILLED" << theAutomaton->StateName( AutomatonState() ) << " EventQSize " << EventQSize() ) ; @@ -1867,8 +1894,14 @@ bool GraphExecutor::OutNode::Kill() { MESSAGE( Graph()->Name() << " IS NOT KILLED" ) ; MESSAGE("================================================================================") ; } + for ( i = 0 ; i < Graph()->GraphNodesSize() ; i++ ) { + GraphExecutor::InNode * aNode = (GraphExecutor::InNode * ) Graph()->GraphNodes( i )->GetInNode() ; + MESSAGE(aNode->Name() << " " << theAutomaton->StateName( aNode->State() ) ) ; + cdebug << aNode->Name() << " " << theAutomaton->StateName( aNode->State() ) << endl ; + } cdebug_out << "GraphExecutor::OutNode::Kill " << RetVal - << " Threads " << _Threads << " SuspendedThreads " << _SuspendedThreads << endl ; + << " Threads " << _Threads << " SuspendedThreads " << _SuspendedThreads + << " EventQSize " << EventQSize() << endl ; // remove "extra" events from the event queue siftEvents(); @@ -1891,22 +1924,6 @@ bool GraphExecutor::OutNode::Stop() { } return RetVal ; } -bool GraphExecutor::OutNode::ReRun() { - bool RetVal = false ; - cdebug_in << "GraphExecutor::OutNode::ReRun" << endl; - if ( IsSuspended() ) { - } - cdebug_out << "GraphExecutor::OutNode::ReRun" << endl ; - return RetVal ; -} -bool GraphExecutor::OutNode::ReStart() { - bool RetVal = false ; - cdebug_in << "GraphExecutor::OutNode::ReStart" << endl; - if ( IsSuspended() ) { - } - cdebug_out << "GraphExecutor::OutNode::ReStart" << endl ; - return RetVal ; -} bool GraphExecutor::OutNode::ReadyWait() { cdebug_in << "GraphExecutor::OutNode::ReadyWait" << endl; diff --git a/src/GraphExecutor/DataFlowExecutor_OutNode.hxx b/src/GraphExecutor/DataFlowExecutor_OutNode.hxx index a882cf3..277d93f 100644 --- a/src/GraphExecutor/DataFlowExecutor_OutNode.hxx +++ b/src/GraphExecutor/DataFlowExecutor_OutNode.hxx @@ -54,6 +54,9 @@ namespace GraphExecutor { SUPERV::ControlState _ControlState ; bool _Done ; + // asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL + //Engines_Container_i * _SuperVisionContainer ; + //pthread_t _MainThreadId ; pthread_mutex_t _PyMutexWait ; pthread_mutex_t _MutexWait ; pthread_cond_t _EventWait ; @@ -140,8 +143,6 @@ namespace GraphExecutor { return _Executable ; } ; bool Run( const bool AndSuspend ) ; - bool Run( const char * aNodeName , const char * AtNodeName , - const bool AndSuspend ) ; void PyInitialized( bool init ) { _PyInitialized = init ; } ; @@ -150,6 +151,9 @@ namespace GraphExecutor { void CheckAllDone() ; + // asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL + //Engines_Container_i * SuperVisionContainer() ; + //const pthread_t MainThreadId() const ; void PThreadLock( pthread_mutex_t * aMutex , char * errmsg ) ; void PThreadUnLock( pthread_mutex_t * aMutex , char * errmsg ) ; void PyThreadLock() ; @@ -213,8 +217,6 @@ namespace GraphExecutor { bool Resume() ; bool Kill() ; bool Stop() ; - bool ReRun() ; - bool ReStart() ; bool IsWaiting() ; bool IsReady() ; diff --git a/src/GraphExecutor/DataFlowExecutor_PyDynInvoke.cxx b/src/GraphExecutor/DataFlowExecutor_PyDynInvoke.cxx index 0d39581..4a553e4 100644 --- a/src/GraphExecutor/DataFlowExecutor_PyDynInvoke.cxx +++ b/src/GraphExecutor/DataFlowExecutor_PyDynInvoke.cxx @@ -17,10 +17,9 @@ using namespace std; #include "DataFlowExecutor_InNode.hxx" #include "DataFlowExecutor_OutNode.hxx" -#include "CASCatch_SignalsHandler.h" // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC - using namespace CORBA ; +//static PyObject * MyPyObjSignal = NULL ; static PyObject * MyPyObjRef = NULL ; static PyObject * MyPyObjIor = NULL ; static PyObject * MyPyRunMethod = NULL ; @@ -37,32 +36,59 @@ bool GraphExecutor::InNode::InitPython() { // PyObject * Module = Py_InitModule( "InitPyRunMethod" , MethodPyRunMethod ) ; if ( !Automaton()->PyInitModule() ) { Py_InitModule( "InitPyRunMethod" , MethodPyRunMethod ) ; + // asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL + //_OutNode->SuperVisionContainer()->ActivatePythonExecution( "InitPyRunMethod" , MethodPyRunMethod ) ; } // PyObject * Dictionnary = PyModule_GetDict( Module ) ; // InitPyDynInvokeError = PyErr_NewException( "InitPyDynInvokeError" , NULL , NULL ) ; // PyDict_SetItemString( Dictionnary , InitPyDynInvokeError ) ; cdebug << ThreadNo() << "Py_Initialized() " << endl ; +#if 0 +//JR : Python documentation says that there is no sense to set a handler of synchronous +// signals as SIGSEGV and SIGFPE !!! + if ( Automaton()->PyFunction( "PyObjSignal" ) == NULL ) { + string aPyFunc ; + aPyFunc = "import signal\n" ; + aPyFunc += "import InitPyRunMethod\n" ; + aPyFunc += "import sys\n" ; + aPyFunc += "import CORBA\n" ; + aPyFunc += "import omniORB\n" ; + aPyFunc += "def PySignalHandler( aSignal , aStackFrame ) :\n" ; + aPyFunc += " print 'PySignalHandler(aSignal =',aSignal,',aStackFrame= ',aStackFrame,')'\n" ; + aPyFunc += "InitPyRunMethod.RunMethod( PySignalHandler )\n" ; + aPyFunc += "PrevHandler = signal.signal( signal.SIGSEGV , PySignalHandler )\n" ; + aPyFunc += "print 'PyObjSignal PrevHandler of SIGSEGV :', PrevHandler\n" ; + aPyFunc += "print 'PyObjSignal actual handler of SIGSEGV :', signal.getsignal( signal.SIGSEGV )\n" ; +// if ( PyRun_SimpleString( (char *) aPyFunc.c_str() ) ) { + if ( PyRunSimpleString( (char *) aPyFunc.c_str() ) ) { + cdebug << ThreadNo() << " " << Name() << " PyRun_SimpleString ERROR " << endl << aPyFunc << endl ; + Automaton()->PyUnLock() ; + return false ; + } + MyPyObjSignal = MyPyRunMethod ; + Automaton()->PyFunction( "PyObjSignal" , MyPyObjSignal ) ; + } + else { + MyPyObjSignal = Automaton()->PyFunction( "PyObjSignal" ) ; + } +#endif + +// PyObjRef convert an IOR (string) to an Python ObjectReference 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() ) ) { + // asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL + //if ( PyRunSimpleString( (char *) aPyFunc.c_str() ) ) { cdebug << ThreadNo() << " " << Name() << " PyRun_SimpleString ERROR " << endl << aPyFunc << endl ; Automaton()->PyUnLock() ; return false ; @@ -74,6 +100,7 @@ bool GraphExecutor::InNode::InitPython() { MyPyObjRef = Automaton()->PyFunction( "PyObjRef" ) ; } +// PyObjRef convert an Python ObjectReference to an IOR (string) if ( Automaton()->PyFunction( "PyObjIor" ) == NULL ) { string aPyFunc ; aPyFunc = "import InitPyRunMethod\n" ; @@ -81,14 +108,13 @@ bool GraphExecutor::InNode::InitPython() { 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() ) ) { + // asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL + //if ( PyRunSimpleString( (char *) aPyFunc.c_str() ) ) { cdebug << ThreadNo() << " " << Name() << " PyRun_SimpleString ERROR " << endl << aPyFunc << endl ; Automaton()->PyUnLock() ; return false ; @@ -106,6 +132,17 @@ bool GraphExecutor::InNode::InitPython() { return true ; } +void GraphExecutor::InNode::RemovePyDynInvoke( char * PyFuncName ) { +// Automaton()->PyLock() ; // Already done ... + if ( Automaton()->ErasePyFunction( PyFuncName ) ) { + cdebug << "InNode::RemovePyDynInvoke( " << PyFuncName << " ) success" << endl ; + } + else { + cdebug << "InNode::RemovePyDynInvoke( " << PyFuncName << " ) ERROR failed" << endl ; + } +// Automaton()->PyUnLock() ; +} + PyObject * GraphExecutor::InNode::InitPyDynInvoke( char * PyFuncName , const SUPERV::ListOfStrings * aPythonFunction , bool & Err ) { @@ -131,8 +168,10 @@ PyObject * GraphExecutor::InNode::InitPyDynInvoke( char * PyFuncName , aPyFunc += PyFuncName ; aPyFunc += " )\n" ; /*cdebug *///cout<< "InitPyDynInvoke PyRun_SimpleString " << endl << aPyFunc << endl ; +// if ( PyRun_SimpleString( (char *) aPyFunc.c_str() ) ) { if ( PyRunSimpleString( (char *) aPyFunc.c_str() ) ) { cdebug << ThreadNo() << " " << Name() << " PyRunSimpleString ERROR " << endl << aPyFunc << endl ; + PyFuncRunned( false ) ; RetVal = false ; Err = true ; } @@ -160,7 +199,7 @@ PyObject * GraphExecutor::InNode::InitPyDynInvoke( char * PyFuncName , Automaton()->PyUnLock() ; } - cdebug_out << "InitPyDynInvoke '" << PyFuncName << "' thePyRunMethod Null" << endl ; + cdebug_out << "InitPyDynInvoke '" << PyFuncName << "' thePyRunMethod Null Err " << Err << endl ; return NULL ; } @@ -309,7 +348,8 @@ bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod , 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 ) ; +// ResultObj = PyEval_CallObject( MyPyObjRef , MyPyObjRefList ) ; + ResultObj = PyEvalCallObject( MyPyObjRef , MyPyObjRefList ) ; cdebug << "ObjValue->ob_refcnt" << ObjValue->ob_refcnt << endl ; ArgValue = Py_BuildValue( "O" , ResultObj ) ; PyTuple_SetItem( ArgsList , i , ArgValue ) ; @@ -332,7 +372,8 @@ bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod , } } - Result = PyEval_CallObject( MyPyRunMethod , ArgsList ) ; +// Result = PyEval_CallObject( MyPyRunMethod , ArgsList ) ; + Result = PyEvalCallObject( MyPyRunMethod , ArgsList ) ; cdebug << "ArgsList->ob_refcnt" << ArgsList->ob_refcnt << endl ; @@ -504,7 +545,8 @@ bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod , Py_INCREF( ObjIor ) ; // PyObject_Print( ObjIor , stdout , 0 ) ; PyTuple_SetItem( MyPyObjIorList , 0 , ObjIor ) ; - ResultIor = PyEval_CallObject( MyPyObjIor , MyPyObjIorList ) ; +// ResultIor = PyEval_CallObject( MyPyObjIor , MyPyObjIorList ) ; + ResultIor = PyEvalCallObject( MyPyObjIor , MyPyObjIorList ) ; cdebug << "ObjIor->ob_refcnt " << ObjIor->ob_refcnt-1 << endl ; Py_DECREF( ObjIor ) ; cdebug << "MyPyObjIorList->ob_refcnt " << MyPyObjIorList->ob_refcnt-1 << endl ; @@ -556,25 +598,24 @@ bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod , } -// This method was created in order to wrap PyRun_SimpleString() with exception handling wrapper. -// Python does not throw usual C++ style exceptions, so try-catch construct does not work for this -// purpose. Instead Python raises signals. If these signals are not caught by the application -// it will be caught by the OS and the application will be terminated : BUG PAL6869 -// Declaring CASCatch_SignalsHandler object redefines (!) standard C++ reserved words "try" and "catch". -// Standard_Failure "exception" is a signal in fact, and it will be caught in the catch section. -// Why do we finalize and re-initialize Python after catching the signal? Because the Python stack -// is corrupted after that. -// Declaration of CASCatch_SignalsHandler forces us to add linkage with CASCADE libraries.. See Makefile.in. bool GraphExecutor::InNode::PyRunSimpleString( char* thePyString ) { - CASCatch_SignalsHandler aSignalsHandler; const bool ErrorValue = true; bool aRet; try { + MESSAGE( pthread_self() << "Python method beginning : " << thePyString ); + cdebug_in << pthread_self() << "Python method beginning : " << thePyString << endl ; aRet = PyRun_SimpleString( thePyString ); - } catch( Standard_Failure ) { - MESSAGE( "ERROR: Exception caught running Python method." ); + // asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL + //aRet = _OutNode->SuperVisionContainer()->ActivatePythonExecution( thePyString ) ; + MESSAGE( pthread_self() << "Python method finished." ); + cdebug_out << pthread_self() << "Python method finished." << endl ; + } catch( ... ) { + MESSAGE( pthread_self() << "ERROR: Exception caught running Python method." ); + cdebug_out << pthread_self() << "ERROR: Exception caught running Python method." + << endl ; MESSAGE( " Python was reinitialized. Previous Python definitions are lost" ); + // asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL Py_Finalize(); Py_Initialize(); Py_InitModule( "InitPyRunMethod" , MethodPyRunMethod ); @@ -583,3 +624,38 @@ bool GraphExecutor::InNode::PyRunSimpleString( char* thePyString ) } return aRet; } + +PyObject * GraphExecutor::InNode::PyEvalCallObject( PyObject * MyPyRunMethod , + PyObject * ArgsList ) { + cdebug_in << "Executor::InNode::PyEvalCallObject " << Name() << endl ; + PyObject * Result = NULL ; + try { + MESSAGE( pthread_self() << "PyEval_CallObject method beginning : " ); + cdebug << pthread_self() << "PyEval_CallObject method beginning : " << Name() << endl ; + Result = PyEval_CallObject( MyPyRunMethod , ArgsList ) ; + // asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL + //Result = _OutNode->SuperVisionContainer()->ActivatePythonExecution( MyPyRunMethod , ArgsList ) ; + MESSAGE( pthread_self() << "PyEval_CallObject method finished. Result " << Result ); + cdebug << pthread_self() << "PyEval_CallObject method finished. Result " << Result << endl ; + cdebug_out << "Executor::InNode::PyEvalCallObject " << Name() << endl ; + } catch( ... ) { + MESSAGE( pthread_self() << "ERROR: Exception caught PyEval_CallObject Python method. Result " << Result ); + cdebug << pthread_self() << "ERROR: Exception caught PyEval_CallObject Python method. Result " + << Result << endl ; + MESSAGE( " Python was reinitialized. Previous Python definitions are lost Py_IsInitialized " << Py_IsInitialized() ); +//JR ===> fatal error in python : no current thread + // asv : 20.01.05 : changes involved with switching to old (HEAD) KERNEL + Py_Finalize(); + Py_Initialize(); + Automaton()->PyInitModule( false ) ; + Py_InitModule( "InitPyRunMethod" , MethodPyRunMethod ); + _OutNode->PyInitialized( false ); + + if ( Result == NULL ) { + Kill() ; // Reset of _ThreadId + } + cdebug_out << "Executor::InNode::PyEvalCallObject ERROR catched " << Name() + << " Py_IsInitialized " << Py_IsInitialized() << endl ; + } + return Result ; +} diff --git a/src/GraphExecutor/Makefile.in b/src/GraphExecutor/Makefile.in index 10707c9..97cf9df 100644 --- a/src/GraphExecutor/Makefile.in +++ b/src/GraphExecutor/Makefile.in @@ -49,7 +49,7 @@ CPPFLAGS+= $(PYTHON_INCLUDES) $(QT_MT_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome CXXFLAGS+= -g -D__x86__ -D__linux__ -ftemplate-depth-42 -Wall \ -I${KERNEL_ROOT_DIR}/include/salome -LDFLAGS+= -export-dynamic -lSalomeNS -lSalomeLifeCycleCORBA -lSalomeSuperVisionBase -lSalomeSuperVisionEditor -lOpUtil -lSALOMELocalTrace -lCASCatch\ +LDFLAGS+= -export-dynamic -lSalomeNS -lSalomeLifeCycleCORBA -lSalomeSuperVisionBase -lSalomeSuperVisionEditor -lOpUtil -lSALOMELocalTrace\ -lc $(QT_MT_LIBS) $(OGL_LIBS) \ -L${KERNEL_ROOT_DIR}/lib/salome #LIBS += -Xlinker -export-dynamic $(PYTHON_LIBS) diff --git a/src/SUPERVGUI/Makefile.in b/src/SUPERVGUI/Makefile.in index d5a2faf..52c9472 100644 --- a/src/SUPERVGUI/Makefile.in +++ b/src/SUPERVGUI/Makefile.in @@ -47,62 +47,50 @@ PO_FILES = \ LIB = libSUPERVGUI.la -LIB_SRC = SUPERVGUI.cxx \ - SUPERVGUI_Service.cxx \ - SUPERVGUI_Python.cxx \ - SUPERVGUI_Information.cxx \ - SUPERVGUI_Notification.cxx \ - SUPERVGUI_Main.cxx \ - SUPERVGUI_View.cxx \ - SUPERVGUI_Graph.cxx \ - SUPERVGUI_Array.cxx \ - SUPERVGUI_Node.cxx \ - SUPERVGUI_GraphNode.cxx \ - SUPERVGUI_ComputeNode.cxx \ - SUPERVGUI_ControlNode.cxx \ - SUPERVGUI_Port.cxx \ - SUPERVGUI_BrowseNodeDlg.cxx \ - SUPERVGUI_Link.cxx \ - SUPERVGUI_CtrlLink.cxx \ - SUPERVGUI_Label.cxx \ - SUPERVGUI_CanvasView.cxx \ - SUPERVGUI_Canvas.cxx \ - SUPERVGUI_CanvasNode.cxx \ - SUPERVGUI_CanvasNodePrs.cxx \ - SUPERVGUI_CanvasControlNode.cxx \ - SUPERVGUI_CanvasControlNodePrs.cxx \ - SUPERVGUI_CanvasPort.cxx \ - SUPERVGUI_CanvasLink.cxx +LIB_SRC = SUPERVGUI.cxx \ + SUPERVGUI_ArrayView.cxx \ + SUPERVGUI_Canvas.cxx \ + SUPERVGUI_CanvasArray.cxx \ + SUPERVGUI_CanvasView.cxx \ + SUPERVGUI_CanvasNode.cxx \ + SUPERVGUI_CanvasNodePrs.cxx \ + SUPERVGUI_CanvasControlNode.cxx \ + SUPERVGUI_CanvasControlNodePrs.cxx \ + SUPERVGUI_CanvasCellNodePrs.cxx \ + SUPERVGUI_CanvasPort.cxx \ + SUPERVGUI_CanvasLink.cxx \ + SUPERVGUI_Service.cxx \ + SUPERVGUI_Main.cxx \ + SUPERVGUI_BrowseNodeDlg.cxx \ + SUPERVGUI_Information.cxx \ + SUPERVGUI_Notification.cxx \ + SUPERVGUI_ManagePortsDlg.cxx \ + SUPERVGUI_Library.cxx \ + SUPERVGUI_Clipboard.cxx -LIB_MOC = SUPERVGUI.h \ - SUPERVGUI_Service.h \ - SUPERVGUI_Python.h \ - SUPERVGUI_Information.h \ - SUPERVGUI_Notification.h \ - SUPERVGUI_Main.h \ - SUPERVGUI_View.h \ - SUPERVGUI_Graph.h \ - SUPERVGUI_Array.h \ - SUPERVGUI_Node.h \ - SUPERVGUI_GraphNode.h \ - SUPERVGUI_ComputeNode.h \ - SUPERVGUI_ControlNode.h \ - SUPERVGUI_Port.h \ - SUPERVGUI_BrowseNodeDlg.h \ - SUPERVGUI_Link.h \ - SUPERVGUI_Label.h \ - SUPERVGUI_Canvas.h \ - SUPERVGUI_CanvasView.h \ - SUPERVGUI_CanvasNode.h \ - SUPERVGUI_CanvasControlNode.h \ - SUPERVGUI_CanvasPort.h \ - SUPERVGUI_CanvasLink.h +LIB_MOC = SUPERVGUI.h \ + SUPERVGUI_ArrayView.h \ + SUPERVGUI_Canvas.h \ + SUPERVGUI_CanvasArray.h \ + SUPERVGUI_CanvasView.h \ + SUPERVGUI_CanvasNode.h \ + SUPERVGUI_CanvasControlNode.h \ + SUPERVGUI_CanvasPort.h \ + SUPERVGUI_CanvasLink.h \ + SUPERVGUI_Service.h \ + SUPERVGUI_Main.h \ + SUPERVGUI_BrowseNodeDlg.h \ + SUPERVGUI_Information.h \ + SUPERVGUI_Notification.h \ + SUPERVGUI_ManagePortsDlg.h \ + SUPERVGUI_Library.h \ + SUPERVGUI_Clipboard.h -LIB_CLIENT_IDL = SALOMEDS.idl \ +LIB_CLIENT_IDL = SALOMEDS.idl \ SALOMEDS_Attributes.idl \ - SALOME_ModuleCatalog.idl \ - SALOME_Component.idl \ - SUPERV.idl \ + SALOME_ModuleCatalog.idl \ + SALOME_Component.idl \ + SUPERV.idl \ SALOME_Exception.idl LIB_SERVER_IDL = @@ -113,7 +101,6 @@ LDFLAGS+=$(PYTHON_LIBS) $(QT_MT_LIBS) $(VTK_LIBS) $(OGL_LIBS) \ -lSalomeGUI -lSalomeNS -lqsplitterP -lEvent \ -lSalomeLifeCycleCORBA -lSalomeNotification -lSUPERVGraph \ -L${KERNEL_ROOT_DIR}/lib/salome - LIBS+= @CONCLUDE@ diff --git a/src/SUPERVGUI/SUPERVGUI.cxx b/src/SUPERVGUI/SUPERVGUI.cxx index bf390ac..11ac798 100644 --- a/src/SUPERVGUI/SUPERVGUI.cxx +++ b/src/SUPERVGUI/SUPERVGUI.cxx @@ -378,26 +378,72 @@ void SUPERVGUI::renameDataflow() { } } - void SUPERVGUI::exportDataflow() { Trace("SUPERVGUI::exportDataflow") - if (main==0) { - QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOWINDOW_TO_EXPORT")); - } else { + if ( main==0 ) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOWINDOW_TO_EXPORT")); + } + else if ( SUPERV_isNull( main->getDataflow() ) ) { // should not normally happen.. + QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOWINDOW_TO_EXPORT")); + } + else { QString f = QAD_FileDlg::getFileName(QAD_Application::getDesktop(), "", "*.xml", tr("TTL_EXPORT_DATAFLOW"), false); - if (!f.isEmpty()) { - if (main->exportDataflow(f)) { + if ( !f.isEmpty() ) { + + // asv : bug [VSR Bugs and Improvements in Supervisor] 1.8 : when exporting a file, + // a backup copy of an existing file must be created (in case Export fails..) + QString aBackupFile = SUPERVGUI::createBackupFile( f ); + + if ( main->getDataflow()->Export(f.latin1()) ) { unregisterGraph(main); registerGraph(f, main); + + // remove a backup file if export was successfull + if ( !aBackupFile.isNull() && !aBackupFile.isEmpty() ) + QFile::remove( aBackupFile ); + } + else { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_BAD_WRITING").arg(aBackupFile)); } } } } +/** + *If a file with theOriginalFileName exists, then the function tries to create + * its backup copy of it (the_name + ".bakX", X = 0,1,2,..,99). Returns backup file's name + * If a file with theOriginalFileName does not exist, or creation fails - Return empty string. + */ +QString SUPERVGUI::createBackupFile( const QString& theOriginalFileName ) { + QString theBackupFileName(""); + if ( QFile::exists( theOriginalFileName ) ) { + // 1. construct a backup file name + int i = 0; + do { + theBackupFileName = theOriginalFileName; + theBackupFileName += ".bak"; + theBackupFileName += QString::number(i++); + } + while ( QFile::exists( theBackupFileName ) && i < 100 ); // max 99 backup files + // if *.bak99 exists -- it will be overwritten + + // 2. copy the original file to theBackupFileName + QString cmd( "cp \""); + cmd += theOriginalFileName; + cmd += "\" \""; + cmd += theBackupFileName; + cmd += "\""; + bool res = system( cmd.latin1() ); + if ( res ) + theBackupFileName = QString(""); + } + return theBackupFileName; +} + void SUPERVGUI::newDataflow() { Trace("SUPERVGUI::editDataflow"); @@ -469,6 +515,7 @@ void SUPERVGUI::runDataflow() { if (main==0) { QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOWINDOW_TO_RUN")); } else { + main->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag main->run(); }; } @@ -478,6 +525,7 @@ void SUPERVGUI::stepByStep() { if (main==0) { QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NOWINDOW_TO_RUN")); } else { + main->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag main->startExecute(); } } @@ -608,12 +656,10 @@ void SUPERVGUI::whatIsSelected(const Handle(SALOME_InteractiveObject)& theObj, b } } - - void SUPERVGUI::deleteObject() { SALOME_Selection* Sel = SALOME_Selection::Selection(study->getSelection() ); if ((Sel==NULL) || (Sel->IObjectCount() == 0)) return; - + // sak : 24.11.04 : fix for PAL6899 : if the study is locked - warn the user and return. SALOMEDS::Study_var aStudy = study->getStudyDocument(); if ( aStudy->GetProperties()->IsLocked() ) { diff --git a/src/SUPERVGUI/SUPERVGUI.h b/src/SUPERVGUI/SUPERVGUI.h index 06c87a5..eb8e903 100644 --- a/src/SUPERVGUI/SUPERVGUI.h +++ b/src/SUPERVGUI/SUPERVGUI.h @@ -100,6 +100,14 @@ class SUPERVGUI: public SALOMEGUI { */ void whatIsSelected(const Handle(SALOME_InteractiveObject)& theObj, bool& theIsOwner, bool& theIsDataflow); + /* asv : bug [VSR Bugs and Improvements in Supervisor] 1.8 : when exporting a file, + a backup copy of an existing file must be created (in case Export fails..) + This method creates a backup file and returns its name or QString::null if it fails + Function is static because it is called from + SUPERVGUI::exportDataflow() and SUPERVGUI_CanvasMacroNode::exportDataflow() + */ + static QString createBackupFile( const QString& theOriginalFileName ); + signals: void KillMainThread(bool theValue); diff --git a/src/SUPERVGUI/SUPERVGUI_Array.cxx b/src/SUPERVGUI/SUPERVGUI_Array.cxx deleted file mode 100644 index 673793d..0000000 --- a/src/SUPERVGUI/SUPERVGUI_Array.cxx +++ /dev/null @@ -1,404 +0,0 @@ -// SUPERV SUPERVGUI : GUI for Supervisor component -// -// 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 -// -// -// -// File : SUPERVGUI_Array.cxx -// Author : Francis KLOSS -// Module : SUPERV - -using namespace std; -#include "SUPERVGUI_Def.h" -#include "SUPERVGUI_Array.h" -#include "SUPERVGUI_Main.h" -#include "SUPERVGUI_ComputeNode.h" -#include "SUPERVGUI_BrowseNodeDlg.h" -#include "SUPERVGUI_Node.h" -#include "SUPERVGUI_GraphNode.h" -#include "SUPERVGUI_ControlNode.h" -#include -#include - -#define ADDNODES(NodesName,LevelHasDiffNT) \ - ncols = nodes->NodesName.length(); \ - for (int co=0; coNodesName[co]); \ - if (!LevelHasDiffNT) x = 50 + co * (CELL_WIDTH + CELL_SPACE); \ - else x += (CELL_WIDTH + CELL_SPACE); \ - SUPERVGUI_Node* aNode = new SUPERVGUI_Cell(viewport(), main, aCNode); \ - ResizeGraph(aNode, x, y); \ - addChild(aNode, x, y); \ - } - - - -#define ADDCONTROLNODES(NodesName,LevelHasDiffNT) \ - ncols = nodes->NodesName.length(); \ - if (!LevelHasDiffNT) x = 50; \ - else x += (CELL_WIDTH + CELL_SPACE); \ - for (int co=0; coNodesName[co]); \ - SUPERVGUI_Node* aNode = new SUPERVGUI_Cell(viewport(), main, aCNode); \ - ResizeGraph(aNode, x, y); \ - addChild(aNode, x, y); \ - y += (CELL_HEIGHT + CELL_SPACE); \ - SUPERV_CNode aCNodeEnd = SUPERV::CNode::_narrow(nodes->NodesName[co]->Coupled()); \ - SUPERVGUI_Node* aNodeEnd = new SUPERVGUI_CellEndControl(viewport(), main, aCNodeEnd, dynamic_cast(aNode)); \ - ResizeGraph(aNodeEnd, x, y); \ - addChild(aNodeEnd, x, y); \ - x += (CELL_WIDTH + CELL_SPACE); \ - } - - - - -SUPERVGUI_Array::SUPERVGUI_Array(SUPERVGUI_Main* m): - SUPERVGUI_View(m) -{ - resizeContents(GRAPH_WIDTH, GRAPH_HEIGHT); - setName("TableView"); - hide(); -} - -SUPERVGUI_Array::~SUPERVGUI_Array() { - Trace("SUPERVGUI_Array::~SUPERVGUI_Array") -} - -bool SUPERVGUI_Array::create() { - Trace("SUPERVGUI_Array::create"); - SUPERV_Nodes nodes = main->getDataflow()->Nodes(); - int aCount = 0; - aCount += nodes->CNodes.length(); - aCount += nodes->FNodes.length(); - aCount += nodes->INodes.length(); - aCount += nodes->GNodes.length(); - aCount += nodes->LNodes.length(); - aCount += nodes->SNodes.length(); - if (aCount == 0) { - show(); - return true; - } - - //SUPERV_Nodes nodes; - SUPERVGUI_Cell* cell; - QString aLabel; - int x, y; - int nligs = main->getDataflow()->LevelMax(); - int ncols = main->getDataflow()->ThreadsMax(); - - // there is no any calculations - if (ncols == 0) return false; - - for (int co=0; cosetAlignment(QLabel::AlignCenter | QLabel::AlignVCenter); - aTitle->setLineWidth(1); - aTitle->setPaletteBackgroundColor(MAIN_TITLE); - aTitle->setMinimumSize(CELL_WIDTH, CELL_HEIGHT); - aTitle->setFrameStyle(QFrame::Panel | QFrame::Plain); - addChild(aTitle, 50 + co * (CELL_WIDTH + CELL_SPACE), 20); - } - y = 60; - bool LevelHasDiffNT = false; - for (int li=0; li<=nligs; li++) { - nodes = main->getDataflow()->LevelNodes(li); - int aSumNum = nodes->CNodes.length()+nodes->FNodes.length()+nodes->INodes.length()+ - nodes->GNodes.length()+nodes->LNodes.length()+nodes->SNodes.length(); - if (nodes->CNodes.length() != 0 ) { - ADDNODES(CNodes,LevelHasDiffNT); - if (aSumNum > nodes->CNodes.length()) - LevelHasDiffNT = true; - } - if (nodes->FNodes.length() != 0 ) { - ADDNODES(FNodes,LevelHasDiffNT); - if (aSumNum > nodes->FNodes.length()) - LevelHasDiffNT = true; - } - if (nodes->INodes.length() != 0 ) { - ADDNODES(INodes,LevelHasDiffNT); - if (aSumNum > nodes->INodes.length()) - LevelHasDiffNT = true; - } - if (nodes->GNodes.length() != 0 ) { - ADDNODES(GNodes,LevelHasDiffNT); - if (aSumNum > nodes->GNodes.length()) - LevelHasDiffNT = true; - } - if (nodes->LNodes.length() != 0 ) { - ADDCONTROLNODES(LNodes,LevelHasDiffNT); - if (aSumNum > nodes->LNodes.length()) - LevelHasDiffNT = true; - } - if (nodes->SNodes.length() != 0 ) { - ADDCONTROLNODES(SNodes,LevelHasDiffNT); - if (aSumNum > nodes->SNodes.length()) - LevelHasDiffNT = true; - } - y += (CELL_HEIGHT + CELL_SPACE); - - LevelHasDiffNT = false; - } - nodeX = 50; - nodeY = y + CELL_HEIGHT*2; - - show(); - return true; -} - -void SUPERVGUI_Array::destroy() { - Trace("SUPERVGUI_Array::destroy") - hide(); - - SUPERVGUI_Cell* cell; - QObjectList* ihmList = queryList("SUPERVGUI_Cell"); - QObjectListIt i(*ihmList); - - while ((cell=(SUPERVGUI_Cell*)i.current()) != 0) { - ++i; - cell->updateStudy(); - cell->close(true); - }; - - delete ihmList; - - SUPERVGUI_CellEndControl* cellEC; - QObjectList* ihmListEC = queryList("SUPERVGUI_CellEndControl"); - QObjectListIt iEC(*ihmListEC); - - while ((cellEC=(SUPERVGUI_CellEndControl*)iEC.current()) != 0) { - ++iEC; - cellEC->updateStudy(); - cellEC->close(true); - }; - - delete ihmListEC; - -} - -void SUPERVGUI_Array::sync() { - Trace("SUPERVGUI_Array::sync") - if (SUPERV_isNull(main->getDataflow())) return; - - SUPERVGUI_Cell* cell; - QObjectList* ihmList = queryList("SUPERVGUI_Cell"); - QObjectListIt i(*ihmList); - while ((cell=(SUPERVGUI_Cell*)i.current()) != 0) { - ++i; - cell->sync(); - } - delete ihmList; -} - -SUPERVGUI_Node* SUPERVGUI_Array::addNode(SUPERV_CNode node) { - Trace("SUPERVGUI_Array::Array") - SUPERVGUI_Node* n = new SUPERVGUI_ComputeNode(viewport(), main, node); - ResizeGraph(n, nodeX, nodeY); - addChild(n, nodeX, nodeY); - nodeX += NODE_DX; - nodeY += NODE_DY; - n->sync(); - return(n); -} - -void SUPERVGUI_Array::contentsMousePressEvent(QMouseEvent* e) { - Trace("SUPERVGUI_Array::contentsMousePressEvent") - if (e->button() == RightButton) { - myPopup->exec(e->globalPos()); - }; -} - - - - - -// ------------------------------------ -// Cell widget of the table -// ------------------------------------ - - -SUPERVGUI_Cell::SUPERVGUI_Cell(QWidget* parent, SUPERVGUI_Main* m, SUPERV_CNode n): - SUPERVGUI_Node(parent, m, n), - guiNode(NULL) -{ - Trace("SUPERVGUI_Cell::SUPERVGUI_Cell"); - setLineWidth(2); - setFrameStyle(QFrame::Panel | QFrame::Raised); - - QHBoxLayout* aBox = new QHBoxLayout(this); - aBox->setMargin(3); - aBox->setSpacing(3); - - QString aCommentVis; - if (getNodeType() == SUPERV::FactoryNode) - aCommentVis = QString(myNode->Service()->ServiceName) + QString(tr("COMMENT_FROM")) - + QString(getFactoryNode()->GetComponentName()); - else - //aCommentVis = tr("COMMENT_PYTHON"); - aCommentVis = tr("COMMENT_CNODE"); - - component = new SUPERVGUI_Label(this, CELL_WIDTH_PART, LABEL_HEIGHT, aCommentVis, QLabel::AlignLeft); - connect(component, SIGNAL(MousePress(QMouseEvent*)), this, SLOT(showPopup(QMouseEvent*))); - - myTitle = new SUPERVGUI_Label(this, CELL_WIDTH_PART, LABEL_HEIGHT, name(), QLabel::AlignLeft); - connect(myTitle, SIGNAL(MousePress(QMouseEvent*)), this, SLOT(showPopup(QMouseEvent*))); - myTitle->setMinimumSize(CELL_WIDTH_PART, LABEL_HEIGHT); - myTitle->setMaximumSize(CELL_WIDTH_PART, LABEL_HEIGHT); - - // aBox->addWidget(service); - aBox->addWidget(myTitle); - aBox->addWidget(component); - - myStatus->reparent(this, pos()); - aBox->addWidget(myStatus); - - if(m->isEditable()) { - // QToolTip::add(service, myNode->Name()); - QToolTip::add(myTitle, myTitle->text()); - QToolTip::add(component, component->text()); - } - - myPopup->setItemEnabled(myDeleteItem, false); - adjustSize(); - - myIsControl = false; - myIsStart = false; - - //check for control nodes - if (n->IsLoop() || n->IsSwitch()) { - myIsControl = true; - myIsStart = true; - } - if (n->IsEndLoop() || n->IsEndSwitch()) - myIsControl = true; -} - -SUPERVGUI_Cell::~SUPERVGUI_Cell() { - Trace("SUPERVGUI_Cell::~SUPERVGUI_Cell"); - QToolTip::remove(myTitle); - if (guiNode != NULL) { - guiNode->close(); - } -} - -void SUPERVGUI_Cell::sync() { - Trace("SUPERVGUI_Cell::sync"); - if (myMain == NULL) return; - myTitle->setText(myNode->Name()); - //component->setText(myNode->Comment()); - - if (guiNode != NULL) { - guiNode->sync(); - - SUPERVGUI_PortIn* pi; - QObjectList* ihmList = guiNode->queryList("SUPERVGUI_PortIn"); - QObjectListIt i(*ihmList); - while ((pi=(SUPERVGUI_PortIn*)i.current()) != 0) { - ++i; - pi->sync(); - } - delete ihmList; - - SUPERVGUI_PortOut* po; - ihmList = guiNode->queryList("SUPERVGUI_PortOut"); - i = *ihmList; - while ((po=(SUPERVGUI_PortOut*)i.current()) != 0) { - ++i; - po->sync(); - } - delete ihmList; - } - SUPERVGUI_Node::sync(); -} - - -void SUPERVGUI_Cell::updateStudy() -{ - Trace("SUPERVGUI_Cell::updateStudy") - if (guiNode != NULL) - { - SUPERVGUI_PortOut* po; - QObjectList* ihmList = guiNode->queryList("SUPERVGUI_PortOut"); - QObjectListIt i(*ihmList); - while ((po=(SUPERVGUI_PortOut*)i.current()) != 0) - { - ++i; - po->updateStudy(); - } - delete ihmList; - } -} - - -void SUPERVGUI_Cell::rename() { - SUPERVGUI_Node::rename(); - if (!myIsControl) { //not ControlNode - myTitle->setText(myNode->Name()); - } - else { - if (myIsStart) { //StartControlNode - if (myPairCell) { - QString nm = myNode->Name(); - if (!nm.isEmpty()) { - myTitle->setText(nm); - QString aStr(tr("ENDNODE_PREFIX")); - aStr += nm; - myPairCell->getTitle()->setText(aStr); - myPairCell->setNodeName(aStr); - // QToolTip::remove(myPairCell->getTitle()); - QToolTip::add(myPairCell->getTitle(), myPairCell->getTitle()->text()); - - } - } - } - } - - // QToolTip::remove(myTitle); - QToolTip::add(myTitle, myTitle->text()); -} - -void SUPERVGUI_Cell::setPairCell(SUPERVGUI_Cell* thePairCell) { - if (myIsControl) { //only for ControlNode - myPairCell = thePairCell; - } - else - myPairCell = 0; -} - -SUPERVGUI_Cell* SUPERVGUI_Cell::getPairCell() { - return myPairCell; -} - -SUPERVGUI_CellEndControl::SUPERVGUI_CellEndControl(QWidget* parent, SUPERVGUI_Main* m, SUPERV_CNode n, - SUPERVGUI_Cell* theStart) - :SUPERVGUI_Cell(parent, m, n) -{ - myPairCell = theStart; //set start cell for end cell as pair - myPairCell->setPairCell(dynamic_cast(this)); //set end cell for start cell as pair -} - -SUPERVGUI_CellEndControl::~SUPERVGUI_CellEndControl() { - Trace("SUPERVGUI_CellEndControl::~SUPERVGUI_CellEndControl"); - QToolTip::remove(myTitle); - if (guiNode != NULL) { - guiNode->close(); - } -} diff --git a/src/SUPERVGUI/SUPERVGUI_Array.h b/src/SUPERVGUI/SUPERVGUI_Array.h deleted file mode 100644 index dc0529a..0000000 --- a/src/SUPERVGUI/SUPERVGUI_Array.h +++ /dev/null @@ -1,111 +0,0 @@ -// SUPERV SUPERVGUI : GUI for Supervisor component -// -// 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 -// -// -// -// File : SUPERVGUI_Array.h -// Author : Francis KLOSS -// Module : SUPERV - -#ifndef SUPERVGUI_Array_H -#define SUPERVGUI_Array_H - -using namespace std; -#include "SUPERVGUI_Def.h" -#include -#include "SUPERVGUI_Node.h" -#include "SUPERVGUI_ControlNode.h" -#include "SUPERVGUI_View.h" -#include "SUPERVGUI_Label.h" - -class SUPERVGUI_Main; - - -class SUPERVGUI_Array: public SUPERVGUI_View { - Q_OBJECT - - public: - SUPERVGUI_Array(SUPERVGUI_Main* m); - virtual ~SUPERVGUI_Array(); - - void sync(); - bool create(); - void destroy(); - - SUPERVGUI_Node* addNode(SUPERV_CNode node); - - private: - void contentsMousePressEvent(QMouseEvent* e); - - - int nodeX; - int nodeY; -}; - - - - - - - -class SUPERVGUI_Cell: public SUPERVGUI_Node { - Q_OBJECT - - public: - SUPERVGUI_Cell(QWidget* parent, SUPERVGUI_Main* m, SUPERV_CNode n); - virtual ~SUPERVGUI_Cell(); - - void sync(); - void hideAll() {}; - void showAll() {}; - - void updateStudy(); - SUPERVGUI_Label* getTitle() { return myTitle; } - SUPERVGUI_Label* getComponent() { return component; } - void setPairCell(SUPERVGUI_Cell* thePairCell); - SUPERVGUI_Cell* getPairCell(); - - public slots: - virtual void rename(); - - protected: - SUPERVGUI_Cell* myPairCell; //for ControlNodes - SUPERVGUI_Label* myTitle; - SUPERVGUI_Node* guiNode; - - private: - SUPERVGUI_Label* component; - //SUPERVGUI_Label* service; - - int myShowItem; - bool myIsControl; - bool myIsStart; -}; - -class SUPERVGUI_CellEndControl: public SUPERVGUI_Cell { - Q_OBJECT - - public: - SUPERVGUI_CellEndControl(QWidget* parent, SUPERVGUI_Main* m, SUPERV_CNode n, SUPERVGUI_Cell* theStart); - virtual ~SUPERVGUI_CellEndControl(); -}; - -#endif diff --git a/src/SUPERVGUI/SUPERVGUI_ArrayView.cxx b/src/SUPERVGUI/SUPERVGUI_ArrayView.cxx new file mode 100644 index 0000000..16561b0 --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_ArrayView.cxx @@ -0,0 +1,194 @@ +// SUPERV SUPERVGUI : GUI for Supervisor component +// +// Copyright (C) 2003 OPEN CASCADE +// +// File : SUPERVGUI_ArrayView.cxx +// Author : +// Module : SUPERV + + +using namespace std; +#include "SUPERVGUI_ArrayView.h" +#include "SUPERVGUI_Main.h" +#include "SUPERVGUI_CanvasCellNodePrs.h" + +#include + +#if QT_VERSION >= 0x030005 +QCursor PanCursor(Qt::SizeAllCursor); +#else +QCursor PanCursor(SizeAllCursor); +#endif + +SUPERVGUI_ArrayView::SUPERVGUI_ArrayView(SUPERVGUI_CanvasArray* theArray, SUPERVGUI_Main* theMain): + QCanvasView(theArray, theMain), + myMain(theMain) +{ + setName("TableView"); + + myIsPanActivated = false; + + myAddStudyItem = 0; + myCursor = cursor(); + + viewport()->setMouseTracking(true); //widget receives mouse move events + //even if no buttons are pressed down + + myPopup = new QPopupMenu(viewport()); + + if (myMain->isEditable()) { + myPopup->insertItem(tr("MSG_ADD_NODE"), myMain, SLOT(addNode())); + myPopup->insertItem(tr("MSG_INS_FILE"), myMain, SLOT(insertFile())); + myPopup->insertSeparator(); + } + + QPopupMenu* aViewPopup = new QPopupMenu(viewport()); + aViewPopup->insertItem(tr("POP_FULLVIEW"), myMain, SLOT(showCanvas())); + aViewPopup->insertItem(tr("POP_CONTROLVIEW"), myMain, SLOT(showContolFlow())); + aViewPopup->insertItem(tr("POP_TABLEVIEW"), myMain, SLOT(showCanvasTable())); + + myPopup->insertItem(tr("POP_VIEW"), aViewPopup); + myPopup->insertSeparator(); + + /*QPopupMenu* aZoomPopup = new QPopupMenu(viewport()); + aZoomPopup->insertItem("200%", this, SLOT(zoomIn())); + aZoomPopup->insertItem("100%", this, SLOT(zoomReset())); + aZoomPopup->insertItem("50%", this, SLOT(zoomOut())); + aZoomPopup->insertSeparator(); + aZoomPopup->insertItem("Fit All", this, SLOT(fitAll())); + + myPopup->insertItem("Zoom", aZoomPopup); + myPopup->insertSeparator();*/ + + myAddStudyItem = myPopup->insertItem(tr("MSG_ADD_STUDY"), this, SLOT(addToStudy())); + myPopup->insertItem(tr("MSG_CHANGE_INFO"), myMain, SLOT(changeInformation())); + myPopup->insertSeparator(); + + myPopup->insertItem(tr("MSG_COPY_DATAFLOW"), myMain, SLOT(copy())); + myPopup->insertItem(tr("MSG_FILTER_NOTIFY"), myMain, SLOT(filterNotification())); + + myPopup->insertSeparator(); + myPopup->insertItem(tr("MSG_CHANGE_BACKGROUND"), this, SLOT(changeBackground())); + + hide(); +} + + +SUPERVGUI_ArrayView::~SUPERVGUI_ArrayView() +{ +} + +void SUPERVGUI_ArrayView::ActivatePanning() +{ + myIsPanActivated = true; + viewport()->setMouseTracking(false); +} + +void SUPERVGUI_ArrayView::ResetView() +{ + setContentsPos(0,0); + QWMatrix m; + setWorldMatrix(m); +} + +void SUPERVGUI_ArrayView::addToStudy() +{ + if (myMain->addStudy()) myMain->setAsFromStudy(true); +} + +void SUPERVGUI_ArrayView::changeBackground() +{ + QColor aColor = QColorDialog::getColor(canvas()->backgroundColor(), this ); + if ( aColor.isValid() ) { + canvas()->setBackgroundColor(aColor); + setPaletteBackgroundColor(aColor.light(120)); + } +} + +void SUPERVGUI_ArrayView::contentsMousePressEvent(QMouseEvent* theEvent) { + myGlobalPoint = theEvent->globalPos(); + + if (((theEvent->button() == Qt::MidButton) + && + (theEvent->state() == Qt::ControlButton)) || myIsPanActivated) { + myIsPanActivated = true; + viewport()->setMouseTracking(false); //widget only receives mouse move events when at least one + //mouse button is pressed down while the mouse is being moved + myCursor = cursor(); + setCursor(PanCursor); + return; + } + + QPoint thePoint = inverseWorldMatrix().map(theEvent->pos()); + // compute collision rectangle + QRect aSel(thePoint.x()-MARGIN, thePoint.y()-MARGIN, 1+2*MARGIN, 1+2*MARGIN); + + if (theEvent->button() == RightButton) { + QCanvasItemList l = canvas()->collisions(aSel); + for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) { + if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_Node) { + SUPERVGUI_CanvasCellNodePrs* aNodePrs = (SUPERVGUI_CanvasCellNodePrs*) (*it); + QObject* anObj = aNodePrs->getObject(thePoint); + if (anObj->inherits("SUPERVGUI_CanvasCellNode")) { + myMain->showPopup(((SUPERVGUI_CanvasCellNode*)anObj)->getPopupMenu(viewport()), + theEvent); + return; + } + } + } + + myPopup->setItemEnabled(myAddStudyItem, !myMain->isFromStudy()); + myMain->showPopup(myPopup, theEvent); + return; + } +} + +void SUPERVGUI_ArrayView::contentsMouseMoveEvent(QMouseEvent* theEvent) { + QPoint g = theEvent->globalPos(); + if (myIsPanActivated) { + scrollBy(myGlobalPoint.x() - g.x(), + myGlobalPoint.y() - g.y()); + myGlobalPoint = g; + return; + } + + // QToolTip for title and label for SUPERVGUI_CanvasCellNode + SUPERVGUI_ToolTip* aTT = new SUPERVGUI_ToolTip(this); + QPoint aPoint1 = inverseWorldMatrix().map(theEvent->pos()); + aTT->maybeTip(aPoint1); +} + +void SUPERVGUI_ArrayView::contentsMouseReleaseEvent(QMouseEvent* theEvent) { + if (myIsPanActivated) { + myIsPanActivated = false; + viewport()->setMouseTracking(true); + setCursor(myCursor); + } +} + +void SUPERVGUI_ToolTip::maybeTip(const QPoint& theP) { + // compute collision rectangle + QRect aSel(theP.x()-MARGIN, theP.y()-MARGIN, 1+2*MARGIN, 1+2*MARGIN); + + QCanvasItemList l = ((SUPERVGUI_ArrayView*)parentWidget())->canvas()->collisions(aSel); + for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) { + if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_Node) { + SUPERVGUI_CanvasCellNodePrs* aNodePrs = (SUPERVGUI_CanvasCellNodePrs*) (*it); + QObject* anObj = aNodePrs->getObject(theP); + if (anObj->inherits("SUPERVGUI_CanvasCellNode")) { + + QRect aTitleRect = aNodePrs->getTitleRect(); + if (aTitleRect.contains(theP, true)) { + tip(aTitleRect, ((SUPERVGUI_CanvasCellNode*)anObj)->getEngine()->Name()); + return; + } + + QRect aLabelRect = aNodePrs->getLabelRect(); + if (aLabelRect.contains(theP, true)) { + tip(aLabelRect, ((SUPERVGUI_CanvasCellNode*)anObj)->getLabelText()); + return; + } + } + } + } +} diff --git a/src/SUPERVGUI/SUPERVGUI_ArrayView.h b/src/SUPERVGUI/SUPERVGUI_ArrayView.h new file mode 100644 index 0000000..e851d56 --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_ArrayView.h @@ -0,0 +1,67 @@ +// SUPERV SUPERVGUI : GUI for Supervisor component +// +// Copyright (C) 2003 OPEN CASCADE +// +// File : SUPERVGUI_ArrayView.h +// Author : +// Module : SUPERV + +#ifndef SUPERVGUI_ArrayView_H +#define SUPERVGUI_ArrayView_H + +#include "SUPERVGUI_CanvasArray.h" +#include +#include + +//VRV: porting on Qt 3.0.5 +#if QT_VERSION >= 0x030005 +#include +#endif +//VRV: porting on Qt 3.0.5 + +class SUPERVGUI_Main; + +class SUPERVGUI_ArrayView: public QCanvasView { + Q_OBJECT + + public: + SUPERVGUI_ArrayView(SUPERVGUI_CanvasArray* theArray, SUPERVGUI_Main* theMain); + virtual ~SUPERVGUI_ArrayView(); + + SUPERVGUI_Main* getMain() const { return myMain; } + + void ActivatePanning(); + void ResetView(); + + public slots: + void addToStudy(); + void changeBackground(); + + private: + void contentsMousePressEvent(QMouseEvent* theEvent); + void contentsMouseMoveEvent(QMouseEvent* theEvent); + void contentsMouseReleaseEvent(QMouseEvent* theEvent); + + SUPERVGUI_Main* myMain; + QPopupMenu* myPopup; + int myAddStudyItem; + + QCursor myCursor; + + QPoint myGlobalPoint; + + bool myIsPanActivated; + +}; + +class SUPERVGUI_ToolTip: public QToolTip { + + public: + SUPERVGUI_ToolTip(QWidget* theWidget, QToolTipGroup* theGroup = 0): + QToolTip(theWidget, theGroup) {} + ~SUPERVGUI_ToolTip() { remove(parentWidget()); } + + virtual void maybeTip(const QPoint& theP); +}; + +#endif diff --git a/src/SUPERVGUI/SUPERVGUI_BrowseNodeDlg.cxx b/src/SUPERVGUI/SUPERVGUI_BrowseNodeDlg.cxx index 7a95cb0..655c710 100644 --- a/src/SUPERVGUI/SUPERVGUI_BrowseNodeDlg.cxx +++ b/src/SUPERVGUI/SUPERVGUI_BrowseNodeDlg.cxx @@ -9,12 +9,12 @@ // Module : SUPERV using namespace std; + #include "SUPERVGUI_BrowseNodeDlg.h" -#include "SUPERVGUI_Node.h" #include "SUPERVGUI_CanvasNode.h" -#include "SUPERVGUI_Port.h" #include "SUPERVGUI_CanvasPort.h" #include "SUPERVGUI.h" + #include #include #include @@ -88,25 +88,12 @@ bool SUPERVGUI_PortField::eventFilter( QObject* o, QEvent* e ) } -/** - * Constructor (SUPERVGUI_Node) - */ -SUPERVGUI_BrowseNodeDlg::SUPERVGUI_BrowseNodeDlg( SUPERVGUI_Node* theNode ) - : QDialog( theNode, 0, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ) -{ - myNode = theNode; - myNodeCanvas = 0; - - init(); -} - /** * Constructor (SUPERVGUI_CanvasNode) */ SUPERVGUI_BrowseNodeDlg::SUPERVGUI_BrowseNodeDlg( SUPERVGUI_CanvasNode* theNode ) : QDialog( QAD_Application::getDesktop(), 0, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ) { - myNode = 0; myNodeCanvas = theNode; init(); @@ -118,11 +105,7 @@ void SUPERVGUI_BrowseNodeDlg::init() setSizeGripEnabled( true ); myPortsList.setAutoDelete( true ); - SUPERV_CNode aEngine; - if (myNode != 0) - aEngine = myNode->getEngine(); - else - aEngine = myNodeCanvas->getEngine(); + SUPERV_CNode aEngine = myNodeCanvas->getEngine(); mySelection = SALOME_Selection::Selection( Supervision.getActiveStudy()->getSelection() ); // mySelection->ClearIObjects(); @@ -151,7 +134,8 @@ void SUPERVGUI_BrowseNodeDlg::init() if ( ports[i]->IsInput() ) { if ( !ports[i]->IsGate() ) { // not a gate SUPERVGUI_PortField* aField = new SUPERVGUI_PortField( aInBox, ports[i] ); - if ( aField->isEditable() ) myIsEditable = true; + if ( aField->isEditable() ) + myIsEditable = true; myPortsList.append( aField ); if ( !myActiveField ) myActiveField = aField; @@ -197,10 +181,7 @@ void SUPERVGUI_BrowseNodeDlg::init() aBtnLayout->addStretch(); connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) ); - if (myNode != 0) - myNode->getMain()->lockedGraph(true); - else - myNodeCanvas->getMain()->lockedGraph(true); + myNodeCanvas->getMain()->lockedGraph(true); } /** @@ -228,17 +209,10 @@ void SUPERVGUI_BrowseNodeDlg::accept() { for ( aField = myPortsList.first(); aField; aField = myPortsList.next() ) { aField->setNewValue(); } - if (myNode != 0) - myNode->sync(); - else { - myNodeCanvas->sync(); - myNodeCanvas->getMain()->getCanvas()->update(); - } + myNodeCanvas->sync(); + myNodeCanvas->getMain()->getCanvas()->update(); } - if (myNode != 0) - myNode->getMain()->lockedGraph(false); - else - myNodeCanvas->getMain()->lockedGraph(false); + myNodeCanvas->getMain()->lockedGraph(false); QDialog::accept(); close(); } @@ -248,10 +222,7 @@ void SUPERVGUI_BrowseNodeDlg::accept() { * Closes and destroys dialog */ void SUPERVGUI_BrowseNodeDlg::reject() { - if (myNode != 0) - myNode->getMain()->lockedGraph(false); - else - myNodeCanvas->getMain()->lockedGraph(false); + myNodeCanvas->getMain()->lockedGraph(false); QDialog::reject(); close(); } @@ -304,31 +275,6 @@ void SUPERVGUI_BrowseNodeDlg::onSelectionChanged() } } -/** - * Constructor (SUPERVGUI_PortIn) - */ -SUPERVGUI_GetValueDlg::SUPERVGUI_GetValueDlg( SUPERVGUI_PortIn* thePort ) - : QDialog( thePort, 0, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ) -{ - myPort = thePort; - myPortESNode = 0; - myPortCanvas = 0; - - init(); -} - -/** - * Constructor (SUPERVGUI_PortInESNode) - */ -SUPERVGUI_GetValueDlg::SUPERVGUI_GetValueDlg( SUPERVGUI_PortInESNode* thePort ) - : QDialog( thePort, 0, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ) -{ - myPort = 0; - myPortESNode = thePort; - myPortCanvas = 0; - - init(); -} /** * Constructor (SUPERVGUI_CanvasPort) @@ -336,8 +282,6 @@ SUPERVGUI_GetValueDlg::SUPERVGUI_GetValueDlg( SUPERVGUI_PortInESNode* thePort ) SUPERVGUI_GetValueDlg::SUPERVGUI_GetValueDlg( SUPERVGUI_CanvasPort* thePort ) : QDialog( QAD_Application::getDesktop(), 0, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ) { - myPort = 0; - myPortESNode = 0; myPortCanvas = thePort; init(); @@ -369,14 +313,8 @@ void SUPERVGUI_GetValueDlg::init() QLabel* aInfoLab = new QLabel( tr( "ENTER_OR_SELECT_LBL" ), aBox ); QFont fnt = aInfoLab->font(); fnt.setBold( true ); aInfoLab->setFont( fnt ); aBoxLayout->addMultiCellWidget( aInfoLab, 0, 0, 0, 1 ); - SUPERV_Port aEngine; - if (myPort != 0) - aEngine = myPort->getPort(); - else if (myPortESNode != 0) - aEngine = myPortESNode->getPort(); - else { - aEngine = myPortCanvas->getEngine(); - } + SUPERV_Port aEngine = myPortCanvas->getEngine(); + myField = new SUPERVGUI_PortField( aBox, aEngine ); bool myIsEditable = myField->isEditable(); aBoxLayout->addWidget( myField->myLabel, 1, 0 ); @@ -407,12 +345,8 @@ void SUPERVGUI_GetValueDlg::init() myField->updateGUI(); connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) ); - if (myPort != 0) - myPort->getMain()->lockedGraph(true); - else if (myPortESNode != 0) - myPortESNode->getMain()->lockedGraph(true); - else - myPortCanvas->getMain()->lockedGraph(true); + + myPortCanvas->getMain()->lockedGraph(true); } /** @@ -427,21 +361,16 @@ SUPERVGUI_GetValueDlg::~SUPERVGUI_GetValueDlg() { void SUPERVGUI_GetValueDlg::accept() { if ( myField->setNewValue() ) { - if (myPort != 0) - myPort->sync(); - else if (myPortESNode != 0) - myPortESNode->sync(); - else { - myPortCanvas->sync(); + myPortCanvas->sync(); - // asv : 19.11.04 : fix for 6170, last comment of it about BrowsePort - update node status - if ( myPortCanvas->parent() && myPortCanvas->parent()->inherits( "SUPERVGUI_CanvasNode" ) ) { - SUPERVGUI_CanvasNode* aNode = (SUPERVGUI_CanvasNode*)myPortCanvas->parent(); - aNode->sync(); - } + // asv : 19.11.04 : fix for 6170, last comment of it about BrowsePort - update node status + // asv : 13.12.04 : commented out sync() of Node. See 2.21. + //if ( myPortCanvas->parent() && myPortCanvas->parent()->inherits( "SUPERVGUI_CanvasNode" ) ) { + // SUPERVGUI_CanvasNode* aNode = (SUPERVGUI_CanvasNode*)myPortCanvas->parent(); + // aNode->sync(); + //} - myPortCanvas->getMain()->getCanvas()->update(); - } + myPortCanvas->getMain()->getCanvas()->update(); } else { if ( QMessageBox::warning( QAD_Application::getDesktop(), @@ -450,12 +379,8 @@ void SUPERVGUI_GetValueDlg::accept() { return; } - if (myPort != 0) - myPort->getMain()->lockedGraph(false); - else if (myPortESNode != 0) - myPortESNode->getMain()->lockedGraph(false); - else - myPortCanvas->getMain()->lockedGraph(false); + myPortCanvas->getMain()->lockedGraph(false); + QDialog::accept(); close(); } @@ -464,12 +389,7 @@ void SUPERVGUI_GetValueDlg::accept() { * Closes and destroys dialog */ void SUPERVGUI_GetValueDlg::reject() { - if (myPort != 0) - myPort->getMain()->lockedGraph(false); - else if (myPortESNode != 0) - myPortESNode->getMain()->lockedGraph(false); - else - myPortCanvas->getMain()->lockedGraph(false); + myPortCanvas->getMain()->lockedGraph(false); QDialog::reject(); close(); } @@ -507,18 +427,9 @@ void SUPERVGUI_GetValueDlg::onSelectionChanged() // Stream Ports // ---------------------------- -SUPERVGUI_StreamInDlg::SUPERVGUI_StreamInDlg(SUPERVGUI_StreamPortIn* thePort) - :QDialog( QAD_Application::getDesktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) -{ - myPort = thePort; - myPortCanvas = 0; - init(); -} - SUPERVGUI_StreamInDlg::SUPERVGUI_StreamInDlg(SUPERVGUI_CanvasStreamPortIn* thePort) :QDialog( QAD_Application::getDesktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) { - myPort = 0; myPortCanvas = thePort; init(); } @@ -598,10 +509,7 @@ void SUPERVGUI_StreamInDlg::setData() { SUPERV::KindOfInterpolation aInterpolat; SUPERV::KindOfExtrapolation aExtrapolat; - if (myPort != 0) - myPort->getStreamPort()->Params(aSchema, aInterpolat, aExtrapolat); - else - myPortCanvas->getStreamEngine()->Params(aSchema, aInterpolat, aExtrapolat); + myPortCanvas->getStreamEngine()->Params(aSchema, aInterpolat, aExtrapolat); mySchemaCombo->setCurrentItem((int)aSchema); myInterCombo->setCurrentItem((int)aInterpolat); @@ -609,30 +517,17 @@ void SUPERVGUI_StreamInDlg::setData() { } void SUPERVGUI_StreamInDlg::accept() { - if (myPort != 0) - myPort->getStreamPort()->SetParams((SUPERV::KindOfSchema) mySchemaCombo->currentItem(), - (SUPERV::KindOfInterpolation) myInterCombo->currentItem(), - (SUPERV::KindOfExtrapolation) myExterCombo->currentItem()); - else - myPortCanvas->getStreamEngine()->SetParams((SUPERV::KindOfSchema) mySchemaCombo->currentItem(), - (SUPERV::KindOfInterpolation) myInterCombo->currentItem(), - (SUPERV::KindOfExtrapolation) myExterCombo->currentItem()); + myPortCanvas->getStreamEngine()->SetParams((SUPERV::KindOfSchema) mySchemaCombo->currentItem(), + (SUPERV::KindOfInterpolation) myInterCombo->currentItem(), + (SUPERV::KindOfExtrapolation) myExterCombo->currentItem()); QDialog::accept(); } //------------------------------------------------------------------------- -SUPERVGUI_StreamOutDlg::SUPERVGUI_StreamOutDlg(SUPERVGUI_StreamPortOut* thePort) - :QDialog( QAD_Application::getDesktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) -{ - myPort = thePort; - myPortCanvas = 0; - init(); -} SUPERVGUI_StreamOutDlg::SUPERVGUI_StreamOutDlg(SUPERVGUI_CanvasStreamPortOut* thePort) :QDialog( QAD_Application::getDesktop(), "", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) { - myPort = 0; myPortCanvas = thePort; init(); } @@ -653,11 +548,7 @@ void SUPERVGUI_StreamOutDlg::init() myValEdit = new QLineEdit( aCtrlPane, "ValEdit" ); myValEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); myValEdit->setValidator( new QIntValidator(this) ); - SUPERV_StreamPort aEngine; - if (myPort != 0) - aEngine = myPort->getStreamPort(); - else - aEngine = myPortCanvas->getStreamEngine(); + SUPERV_StreamPort aEngine = myPortCanvas->getStreamEngine(); myValEdit->setText(QString("%1").arg(aEngine->NumberOfValues())); aCtrlLayout->addWidget(myValEdit, 0, 1); TopLayout->addWidget( aCtrlPane ); @@ -690,10 +581,7 @@ void SUPERVGUI_StreamOutDlg::accept() { QString aStr = myValEdit->text(); if (!aStr.isEmpty()) aRes = aStr.toLong(); - if (myPort != 0) - myPort->getStreamPort()->SetNumberOfValues(aRes); - else - myPortCanvas->getStreamEngine()->SetNumberOfValues(aRes); + myPortCanvas->getStreamEngine()->SetNumberOfValues(aRes); QDialog::accept(); } diff --git a/src/SUPERVGUI/SUPERVGUI_BrowseNodeDlg.h b/src/SUPERVGUI/SUPERVGUI_BrowseNodeDlg.h index 21526db..e330d33 100644 --- a/src/SUPERVGUI/SUPERVGUI_BrowseNodeDlg.h +++ b/src/SUPERVGUI/SUPERVGUI_BrowseNodeDlg.h @@ -50,7 +50,6 @@ public: /** * Browse Node Dialog box */ -class SUPERVGUI_Node; class SUPERVGUI_CanvasNode; class SUPERVGUI_BrowseNodeDlg: public QDialog { @@ -58,7 +57,6 @@ class SUPERVGUI_BrowseNodeDlg: public QDialog { Q_OBJECT public: - SUPERVGUI_BrowseNodeDlg( SUPERVGUI_Node* theNode ); SUPERVGUI_BrowseNodeDlg( SUPERVGUI_CanvasNode* theNode ); virtual ~SUPERVGUI_BrowseNodeDlg(); @@ -76,7 +74,6 @@ protected: private: void init(); - SUPERVGUI_Node* myNode; SUPERVGUI_CanvasNode* myNodeCanvas; bool myIsEditable; @@ -88,17 +85,12 @@ private: /** * Get Value dialog box */ -class SUPERVGUI_PortIn; -class SUPERVGUI_PortInESNode; class SUPERVGUI_CanvasPort; class SUPERVGUI_GetValueDlg: public QDialog { Q_OBJECT public: -// SUPERVGUI_GetValueDlg( SUPERVGUI_Port thePort ); - SUPERVGUI_GetValueDlg( SUPERVGUI_PortIn* thePort ); - SUPERVGUI_GetValueDlg( SUPERVGUI_PortInESNode* thePort ); SUPERVGUI_GetValueDlg( SUPERVGUI_CanvasPort* thePort ); ~SUPERVGUI_GetValueDlg(); @@ -114,8 +106,6 @@ private: QPushButton* myCancelBtn; SUPERVGUI_PortField* myField; - SUPERVGUI_PortIn* myPort; - SUPERVGUI_PortInESNode* myPortESNode; //last correction SUPERVGUI_CanvasPort* myPortCanvas; SALOME_Selection* mySelection; @@ -125,13 +115,11 @@ private: /** * Stream Port Parameter dialog box */ -class SUPERVGUI_StreamPortIn; class SUPERVGUI_CanvasStreamPortIn; class SUPERVGUI_StreamInDlg: public QDialog { Q_OBJECT public: - SUPERVGUI_StreamInDlg(SUPERVGUI_StreamPortIn* thePort); SUPERVGUI_StreamInDlg(SUPERVGUI_CanvasStreamPortIn* thePort); virtual ~SUPERVGUI_StreamInDlg() {}; @@ -142,20 +130,17 @@ private: void init(); void setData(); - SUPERVGUI_StreamPortIn* myPort; SUPERVGUI_CanvasStreamPortIn* myPortCanvas; QComboBox* mySchemaCombo; QComboBox* myInterCombo; QComboBox* myExterCombo; }; -class SUPERVGUI_StreamPortOut; class SUPERVGUI_CanvasStreamPortOut; class SUPERVGUI_StreamOutDlg: public QDialog { Q_OBJECT public: - SUPERVGUI_StreamOutDlg(SUPERVGUI_StreamPortOut* thePort); SUPERVGUI_StreamOutDlg(SUPERVGUI_CanvasStreamPortOut* thePort); virtual ~SUPERVGUI_StreamOutDlg() {}; @@ -165,7 +150,6 @@ protected slots: private: void init(); - SUPERVGUI_StreamPortOut* myPort; SUPERVGUI_CanvasStreamPortOut* myPortCanvas; QLineEdit* myValEdit; }; diff --git a/src/SUPERVGUI/SUPERVGUI_Canvas.cxx b/src/SUPERVGUI/SUPERVGUI_Canvas.cxx index fb1f77c..566a761 100644 --- a/src/SUPERVGUI/SUPERVGUI_Canvas.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Canvas.cxx @@ -98,13 +98,18 @@ SUPERVGUI_Canvas::SUPERVGUI_Canvas(SUPERVGUI_Main* m): SUPERVGUI_Canvas::~SUPERVGUI_Canvas() { + // asv : 17.01.05 : why delete its own children (CanvasNode-s)? + // they must be destroyed automatically. QObjectList* aNodeList = queryList("SUPERVGUI_CanvasNode"); QObjectListIt aIt(*aNodeList); QObject* anObj; - while ((anObj = aIt.current()) != 0) { + while ( (anObj = aIt.current()) != 0 ) { ++aIt; + aNodeList->removeRef(anObj); delete anObj; } + // asv : list returned by queryList() must be removed + delete aNodeList; } void SUPERVGUI_Canvas::addView(QCanvasView* theView) @@ -157,7 +162,6 @@ void SUPERVGUI_Canvas::updateLinks() } void SUPERVGUI_Canvas::sync() { - // MESSAGE("===> SUPERVGUI_Canvas::sync()"); if (SUPERV_isNull(myMain->getDataflow())) return; SUPERVGUI_CanvasNode* ihmNode; @@ -174,7 +178,6 @@ void SUPERVGUI_Canvas::sync() { * Synchronizes Graph presentation with internal graph structure */ void SUPERVGUI_Canvas::merge() { - // MESSAGE("===> SUPERVGUI_Canvas::merge()"); if (SUPERV_isNull(myMain->getDataflow())) return; SUPERVGUI_CanvasNode* ihmNode; diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasArray.cxx b/src/SUPERVGUI/SUPERVGUI_CanvasArray.cxx new file mode 100644 index 0000000..7e18e79 --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_CanvasArray.cxx @@ -0,0 +1,249 @@ +// SUPERV SUPERVGUI : GUI for Supervisor component +// +// Copyright (C) 2003 OPEN CASCADE +// +// File : SUPERVGUI_CanvasArray.cxx +// Author : +// Module : SUPERV + +using namespace std; +#include "SUPERVGUI_CanvasArray.h" +#include "SUPERVGUI_Main.h" +#include "SUPERVGUI_BrowseNodeDlg.h" +#include "QAD_Config.h" +#include "SUPERVGUI_CanvasCellNodePrs.h" + +#include +#define TEXT_MARGIN 5 + +#define ADDNODES(NodesName,LevelHasDiffNT) \ + ncols = nodes->NodesName.length(); \ + for (int co=0; coNodesName[co]); \ + if (!LevelHasDiffNT) x = 50 + co * (CELL_WIDTH + CELL_SPACE); \ + else x += (CELL_WIDTH + CELL_SPACE); \ + cell = getCellNode(aCNode); \ + if (cell == NULL) { \ + SUPERVGUI_CanvasCellNode* aNode = new SUPERVGUI_CanvasCellNode(this, myMain, aCNode); \ + aNode->move(x, y); \ + aNode->show(); \ + aNode->sync(); \ + } else { \ + cell->move(x, y); \ + cell->show(); \ + } \ + update(); \ + } + + + +#define ADDCONTROLNODES(NodesName,LevelHasDiffNT) \ + ncols = nodes->NodesName.length(); \ + if (!LevelHasDiffNT) x = 50; \ + else x += (CELL_WIDTH + CELL_SPACE); \ + for (int co=0; coNodesName[co]); \ + SUPERV_CNode aCNodeEnd = SUPERV::CNode::_narrow(nodes->NodesName[co]->Coupled()); \ + cell = getCellNode(aCNode); \ + if (cell == NULL) { \ + SUPERVGUI_CanvasCellNode* aNode = new SUPERVGUI_CanvasCellNode(this, myMain, aCNode); \ + aNode->move(x, y); \ + aNode->show(); \ + aNode->sync(); \ + y += (CELL_HEIGHT + CELL_SPACE); \ + SUPERVGUI_CanvasCellNode* aNodeEnd = new SUPERVGUI_CanvasCellEndNode(this, myMain, aCNodeEnd, aNode); \ + aNodeEnd->move(x, y); \ + aNodeEnd->show(); \ + aNodeEnd->sync(); \ + } else { \ + cell->move(x, y); \ + cell->show(); \ + y += (CELL_HEIGHT + CELL_SPACE); \ + cell = getCellNode(aCNodeEnd); \ + cell->move(x, y); \ + cell->show(); \ + } \ + update(); \ + if (co < (ncols-1)) x += (CELL_WIDTH + CELL_SPACE); \ + } + + +// ---------------------------------------------------------- +// SUPERVGUI_Array on QCanvas +// ---------------------------------------------------------- + +SUPERVGUI_CanvasArray::SUPERVGUI_CanvasArray(SUPERVGUI_Main* m): + QCanvas(), + myMain(m) +{ + Trace("SUPERVGUI_CanvasArray::SUPERVGUI_CanvasArray"); + //resize(GRAPH_WIDTH, GRAPH_HEIGHT); + resize(800, 600); + setDoubleBuffering(true); + + QColor aColor(MAIN_COLOR); + QString aRed = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorRed"); + QString aGreen = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorGreen"); + QString aBlue = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorBlue"); + if( (!aRed.isEmpty()) && (!aGreen.isEmpty()) && (!aBlue.isEmpty()) ) + aColor = QColor(aRed.toInt(), aGreen.toInt(), aBlue.toInt()); + setBackgroundColor(aColor); +} + +SUPERVGUI_CanvasArray::~SUPERVGUI_CanvasArray() { + Trace("SUPERVGUI_Array::~SUPERVGUI_CanvasArray"); + //delete all cells which SUPERVGUI_CanvasArray contains + //destroy(); + QObjectList* aCellList = queryList("SUPERVGUI_CanvasCellNode"); + QObjectListIt aIt(*aCellList); + QObject* anObj; + while ((anObj = aIt.current()) != 0) { + ++aIt; + delete anObj; + } + delete aCellList; +} + +void SUPERVGUI_CanvasArray::sync() { + if (SUPERV_isNull(myMain->getDataflow())) return; + + SUPERVGUI_CanvasCellNode* ihmNode; + QObjectList* ihmList = queryList("SUPERVGUI_CanvasCellNode"); + QObjectListIt it(*ihmList); + while ((ihmNode=(SUPERVGUI_CanvasCellNode*)it.current()) != 0) { + ++it; + ihmNode->sync(); + } + delete ihmList; +} + +bool SUPERVGUI_CanvasArray::create() { + Trace("SUPERVGUI_Array::create"); + SUPERV_Nodes nodes = myMain->getDataflow()->Nodes(); + int aCount = 0; + aCount += nodes->CNodes.length(); + aCount += nodes->FNodes.length(); + aCount += nodes->INodes.length(); + aCount += nodes->GNodes.length(); + aCount += nodes->LNodes.length(); + aCount += nodes->SNodes.length(); + if (aCount == 0) return true; + + SUPERVGUI_CanvasCellNode* cell; + QString aLabel; + int x, y; + int nligs = myMain->getDataflow()->LevelMax(); + int ncols = myMain->getDataflow()->ThreadsMax(); + + // there is no any calculations + if (ncols == 0) return false; + + QPen pen(Qt::SolidLine); + pen.setWidth(1); + QBrush br(MAIN_TITLE); + + for (int co = 0; co < ncols; co++) { + aLabel = QString("Thread %1").arg(co); + QRect aRect = QRect(50 + co * (CELL_WIDTH + CELL_SPACE), 20, CELL_WIDTH, CELL_HEIGHT); + QCanvasRectangle* aThread = new QCanvasRectangle(aRect, this); + aThread->setPen(pen); + aThread->setBrush(br); + aThread->setZ(0); + aThread->show(); + + QCanvasText* aText = new QCanvasText(aLabel, this); + QRect aBRect = aText->boundingRect(); + aText->setX(aRect.x() + aRect.width()/2 - aBRect.width()/2); + aText->setY(aRect.y() + aRect.height()/2 - aBRect.height()/2); + aText->setZ(1); + aText->show(); + } + + y = 60; + bool LevelHasDiffNT = false; + for (int li = 0; li <= nligs; li++) { + nodes = myMain->getDataflow()->LevelNodes(li); + int aSumNum = nodes->CNodes.length()+nodes->FNodes.length()+nodes->INodes.length()+ + nodes->GNodes.length()+nodes->LNodes.length()+nodes->SNodes.length(); + if (nodes->CNodes.length() != 0 ) { + ADDNODES(CNodes,LevelHasDiffNT); + if (aSumNum > nodes->CNodes.length()) + LevelHasDiffNT = true; + } + if (nodes->FNodes.length() != 0 ) { + ADDNODES(FNodes,LevelHasDiffNT); + if (aSumNum > nodes->FNodes.length()) + LevelHasDiffNT = true; + } + if (nodes->INodes.length() != 0 ) { + ADDNODES(INodes,LevelHasDiffNT); + if (aSumNum > nodes->INodes.length()) + LevelHasDiffNT = true; + } + if (nodes->GNodes.length() != 0 ) { + ADDNODES(GNodes,LevelHasDiffNT); + if (aSumNum > nodes->GNodes.length()) + LevelHasDiffNT = true; + } + if (nodes->LNodes.length() != 0 ) { + ADDCONTROLNODES(LNodes,LevelHasDiffNT); + if (aSumNum > nodes->LNodes.length()) + LevelHasDiffNT = true; + } + if (nodes->SNodes.length() != 0 ) { + ADDCONTROLNODES(SNodes,LevelHasDiffNT); + if (aSumNum > nodes->SNodes.length()) + LevelHasDiffNT = true; + } + y += (CELL_HEIGHT + CELL_SPACE); + + LevelHasDiffNT = false; + } + nodeX = 50; + nodeY = y + CELL_HEIGHT*2; + + return true; + +} + +void SUPERVGUI_CanvasArray::destroy() { + Trace("SUPERVGUI_Array::destroy"); + + QObjectList* aCellList = queryList("SUPERVGUI_CanvasCellNode"); + QObjectListIt aIt(*aCellList); + QObject* anObj; + while ((anObj = aIt.current()) != 0) { + ++aIt; + ((SUPERVGUI_CanvasCellNode*)anObj)->getPrs()->hide(); + } + delete aCellList; + + // mkr : delete QCanvasRectangle and QCanvasText canvas items for each Thread. + // Threads will be recreate when create() function is called + QCanvasItemList aTextList = allItems(); + for (QCanvasItemList::Iterator aItText = aTextList.begin(); aItText != aTextList.end(); ++aItText) { + SUPERVGUI_CanvasCellNodePrs* aPrs = dynamic_cast(*aItText); + if (!aPrs) { + (*aItText)->hide(); + delete *aItText; + } + } +} + +SUPERVGUI_CanvasCellNode* SUPERVGUI_CanvasArray::getCellNode(SUPERV::CNode_ptr theNode) const +{ + return (SUPERVGUI_CanvasCellNode*) + ((SUPERVGUI_CanvasArray*)this)->child(theNode->Name(), "SUPERVGUI_CanvasCellNode"); +} + +SUPERVGUI_CanvasCellNode* SUPERVGUI_CanvasArray::addNode(SUPERV_CNode node) { + Trace("SUPERVGUI_CanvasArray::addNode"); + SUPERVGUI_CanvasCellNode* n = new SUPERVGUI_CanvasCellNode(this, myMain, node); + n->move(nodeX, nodeY); + n->show(); + update(); + nodeX += NODE_DX; + nodeY += NODE_DY; + n->sync(); + return(n); +} diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasArray.h b/src/SUPERVGUI/SUPERVGUI_CanvasArray.h new file mode 100644 index 0000000..fc8e3ce --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_CanvasArray.h @@ -0,0 +1,45 @@ +// SUPERV SUPERVGUI : GUI for Supervisor component +// +// Copyright (C) 2003 OPEN CASCADE +// +// File : SUPERVGUI_CanvasArray.h +// Author : +// Module : SUPERV + +#ifndef SUPERVGUI_CanvasArray_H +#define SUPERVGUI_CanvasArray_H + +using namespace std; +#include "SUPERVGUI_Def.h" +#include "SUPERVGUI_CanvasControlNode.h" + +#include +#include + +class SUPERVGUI_Main; + +class SUPERVGUI_CanvasArray: public QCanvas { + Q_OBJECT + + public: + SUPERVGUI_CanvasArray(SUPERVGUI_Main* m); + virtual ~SUPERVGUI_CanvasArray(); + + void sync(); + bool create(); + void destroy(); + + SUPERVGUI_CanvasCellNode* getCellNode(SUPERV::CNode_ptr theNode) const; + + SUPERVGUI_CanvasCellNode* addNode(SUPERV_CNode node); + + private: + + SUPERVGUI_Main* myMain; + + int nodeX; + int nodeY; + +}; + +#endif diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasCellNodePrs.cxx b/src/SUPERVGUI/SUPERVGUI_CanvasCellNodePrs.cxx new file mode 100644 index 0000000..c7a7f65 --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_CanvasCellNodePrs.cxx @@ -0,0 +1,211 @@ +// SUPERV SUPERVGUI : GUI for Supervisor component +// +// Copyright (C) 2003 OPEN CASCADE +// +// File : SUPERVGUI_CanvasCellNodePrs.cxx +// Author : +// Module : SUPERV + +#include "SUPERVGUI_CanvasCellNodePrs.h" +#include "SUPERVGUI_Canvas.h" + +#define TEXT_MARGIN 5 + +// ---------------------------------------------------------- +// Cell widget of the table on QCanvas +// ---------------------------------------------------------- +SUPERVGUI_CanvasCellNodePrs::SUPERVGUI_CanvasCellNodePrs(QCanvas* theCanvas, SUPERVGUI_CanvasCellNode* theNode): + myTitleWidth(CELL_WIDTH_PART), + myLabelWidth(CELL_WIDTH_PART), + myStatusWidth(CELL_WIDTH_PART), + SUPERVGUI_CanvasNodePrs(theCanvas, theNode, true) +{ + myPortVisible = false; +} + +SUPERVGUI_CanvasCellNodePrs::~SUPERVGUI_CanvasCellNodePrs() +{ +} + +void SUPERVGUI_CanvasCellNodePrs::moveBy(double dx, double dy) { +//Trace("SUPERVGUI_CanvasCellNodePrs::moveBy"); + int aX = (int) (x()+dx); + int aY = (int) (y()+dy); + + int w = aX + width() + GRAPH_MARGIN; + int h = aY + height() + GRAPH_MARGIN; + if (canvas()->width() > w) w = canvas()->width(); + if (canvas()->height() > h) h = canvas()->height(); + if (canvas()->width() < w || canvas()->height() < h) + canvas()->resize(w, h); + QCanvasPolygonalItem::moveBy(dx, dy); +} + +void SUPERVGUI_CanvasCellNodePrs::drawShape(QPainter& thePainter) { + drawTitle(thePainter); + drawLabel(thePainter); + drawStatus(thePainter); + drawFrame(thePainter); +} + +void drawCellText(QPainter& thePainter, const QString& theText, + const QRect& theRect, int theHAlign = Qt::AlignAuto) +{ + int flags = theHAlign | Qt::AlignVCenter; + QRect r(theRect.x() + TEXT_MARGIN, theRect.y(), + theRect.width() - 2*TEXT_MARGIN, theRect.height()); + + QWMatrix aMat = thePainter.worldMatrix(); + if (aMat.m11() != 1.0) { + // for scaled picture only + QRect r1 = aMat.mapRect(r); + QFont saved = thePainter.font(); + QFont f(saved); + if (f.pointSize() == -1) { + f.setPixelSize((int)(f.pixelSize()*aMat.m11())); + } + else { + f.setPointSize((int)(f.pointSize()*aMat.m11())); + } + thePainter.save(); + QWMatrix m; + thePainter.setWorldMatrix(m); + thePainter.setFont(f); + thePainter.drawText(r1, flags, theText); + thePainter.setFont(saved); + thePainter.restore(); + } + else { + thePainter.drawText(r, flags, theText); + } +} + +void SUPERVGUI_CanvasCellNodePrs::drawTitle(QPainter& thePainter) { + QBrush saved = thePainter.brush(); + if (getNode()->getEngine()->IsLoop() || getNode()->getEngine()->IsEndLoop() + || + getNode()->getEngine()->IsSwitch() || getNode()->getEngine()->IsEndSwitch()) + thePainter.setBrush(Qt::red.light()); + else if (getNode()->getEngine()->IsGOTO()) + thePainter.setBrush(Qt::green.light()); + else { + QBrush br(MAIN_TITLE); + thePainter.setBrush(br); + } + drawTitleShape(thePainter); + thePainter.setBrush(saved); + + drawCellText(thePainter, getNode()->getEngine()->Name(), getTitleRect(), Qt::AlignLeft); +} + +void SUPERVGUI_CanvasCellNodePrs::drawLabel(QPainter& thePainter) +{ + QRect r = getLabelRect(); + + QPen saved = thePainter.pen(); + thePainter.setPen(NoPen); + thePainter.drawRect(r); + thePainter.setPen(saved); + + drawCellText(thePainter, getNode()->getLabelText(), r, Qt::AlignLeft); +} + +void SUPERVGUI_CanvasCellNodePrs::drawStatus(QPainter& thePainter) +{ + QRect r = getStatusRect(); + + QBrush savedB = thePainter.brush(); + thePainter.setBrush(getStatusColor()); + drawStatusShape(thePainter); + thePainter.setBrush(savedB); + + drawCellText(thePainter, getStatus(), r, Qt::AlignHCenter); +} + +QRect SUPERVGUI_CanvasCellNodePrs::getTitleRect() const +{ + return QRect((int)x(), (int)y(), getTitleWidth(), getTitleHeight()); +} + +QRect SUPERVGUI_CanvasCellNodePrs::getLabelRect() const +{ + return QRect(((int)x())+getTitleWidth(), (int)y(), getLabelWidth(), getLabelHeight()); +} + +QRect SUPERVGUI_CanvasCellNodePrs::getStatusRect() const +{ + return QRect(((int)x())+getTitleWidth()+getLabelWidth(), (int)y(), + getStatusWidth(), getStatusHeight()); +} + +int SUPERVGUI_CanvasCellNodePrs::getTitleWidth() const { + return myTitleWidth; +} + +int SUPERVGUI_CanvasCellNodePrs::getLabelWidth() const { + return myLabelWidth; +} + +int SUPERVGUI_CanvasCellNodePrs::getStatusWidth() const { + return myStatusWidth; +} + +int SUPERVGUI_CanvasCellNodePrs::width() const +{ + return myTitleWidth + myLabelWidth + myStatusWidth; +} + +int SUPERVGUI_CanvasCellNodePrs::height() const +{ + return getTitleHeight(); +} + +void SUPERVGUI_CanvasCellNodePrs::setState(SUPERV::GraphState theState) +{ + switch(theState) { + case SUPERV_Waiting: + setStatus("Waiting"); + setStatusColor(QColor(35, 192, 255)); + break; + + case SUPERV_Running: + case SUPERV::ReadyState: + setStatus("Running"); + setStatusColor(QColor(32,210,32)); + break; + + case SUPERV_Suspend: + case SUPERV::SuspendReadyState: + setStatus("Suspended"); + setStatusColor(QColor(255,180, 0)); + break; + + case SUPERV_Done: + setStatus("Finished"); + setStatusColor(QColor(255, 158, 255)); + break; + + case SUPERV_Error: + setStatus("Aborted"); + setStatusColor(Qt::red); + break; + + case SUPERV_Kill: + setStatus("Killed"); + setStatusColor(Qt::red); + break; + + case SUPERV::LoadingState: + setStatus("Loading"); + setStatusColor(QColor(56,255,56)); + break; + + default: + setStatus("No Status"); + setStatusColor(MAIN_BACK); + break; + } + + canvas()->setChanged(getStatusRect()); + canvas()->update(); +} diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasCellNodePrs.h b/src/SUPERVGUI/SUPERVGUI_CanvasCellNodePrs.h new file mode 100644 index 0000000..2e21708 --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_CanvasCellNodePrs.h @@ -0,0 +1,52 @@ +// SUPERV SUPERVGUI : GUI for Supervisor component +// +// Copyright (C) 2003 OPEN CASCADE +// +// File : SUPERVGUI_CanvasCellNodePrs.h +// Author : +// Module : SUPERV + +#ifndef SUPERVGUI_CanvasCellNodePrs_H +#define SUPERVGUI_CanvasCellNodePrs_H + +using namespace std; +#include "SUPERVGUI_Def.h" +#include "SUPERVGUI_CanvasNodePrs.h" +#include "SUPERVGUI_CanvasControlNode.h" + +class SUPERVGUI_CanvasCellNodePrs: public SUPERVGUI_CanvasNodePrs { + + public: + SUPERVGUI_CanvasCellNodePrs(QCanvas* theCanvas, SUPERVGUI_CanvasCellNode* theNode); + virtual ~SUPERVGUI_CanvasCellNodePrs(); + + virtual void moveBy(double dx, double dy); + + virtual QRect getTitleRect() const; + virtual QRect getLabelRect() const; + virtual QRect getStatusRect() const; + + int getTitleWidth() const; + int getLabelWidth() const; + int getStatusWidth() const; + + virtual int width() const; + virtual int height() const; + + virtual void setState(SUPERV::GraphState theState); + + protected: + virtual void drawShape(QPainter& thePainter); + + virtual void drawTitle(QPainter& thePainter); + virtual void drawLabel(QPainter& thePainter); + virtual void drawStatus(QPainter& thePainter); + + private: + int myTitleWidth; + int myLabelWidth; + int myStatusWidth; + +}; + +#endif diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasControlNode.cxx b/src/SUPERVGUI/SUPERVGUI_CanvasControlNode.cxx index 400fa1e..a41424b 100644 --- a/src/SUPERVGUI/SUPERVGUI_CanvasControlNode.cxx +++ b/src/SUPERVGUI/SUPERVGUI_CanvasControlNode.cxx @@ -9,13 +9,17 @@ using namespace std; #include "SUPERVGUI_CanvasControlNode.h" #include "SUPERVGUI_CanvasControlNodePrs.h" +#include "SUPERVGUI_CanvasCellNodePrs.h" +#include "SUPERVGUI_Clipboard.h" #include "SUPERVGUI_Main.h" +#include "SUPERVGUI.h" #include "SUPERVGUI_Canvas.h" -#include "SUPERVGUI_ControlNode.h" // access to SelectInlineDlg #include "QAD_FileDlg.h" #include "QAD_Application.h" +#include + //===================================================================== // Compute node //===================================================================== @@ -84,11 +88,36 @@ void SUPERVGUI_CanvasStartNode::remove() SUPERVGUI_Canvas* aCanvas = getMain()->getCanvas(); setDestroyed(); - if (myCoupled) myCoupled->setDestroyed(); + SUPERVGUI_Clipboard* aCB = SUPERVGUI_Clipboard::getClipboard(); + if (myCoupled) { + + //set myCopyPort from Main object to empty if engine of this port is deleted + //check if any port of this deleted node has been copied + if ( aCB->isCopyPort() ) + if ( QString(getEngine()->Name()) == QString(aCB->getCopyPort()->Node()->Name()) || + QString(myCoupled->getEngine()->Name()) == QString(aCB->getCopyPort()->Node()->Name()) ) + aCB->setCopyPort( 0 ); + + myCoupled->setDestroyed(); + } + + //set myCopyNode from Main object to empty if engine of this node is deleted + //check if myCopyNode and this node engine is equal + if ( aCB->isCopyNode() ) + if ( QString(getEngine()->Name()) == QString(aCB->getCopyNode()->Name()) ) + aCB->setCopyNode( 0 ); + + // mkr: since the deletion of the node allow only in CANVAS view, + // it is necessary to remove the CanvasArray's children, which + // have the same CNode engine as deleting node + getMain()->removeArrayChild(getEngine()); + getMain()->removeArrayChild(myCoupled->getEngine()); getEngine()->destroy(); - if (myCoupled) delete myCoupled; + if (myCoupled) + delete myCoupled; + delete this; aCanvas->update(); @@ -115,6 +144,16 @@ void SUPERVGUI_CanvasStartNode::addOutputPort() SUPERVGUI_CanvasNode::addOutputPort(); if (myCoupled) myCoupled->merge(); } + +void SUPERVGUI_CanvasStartNode::pastePort() +{ + SUPERVGUI_Clipboard* aCB = SUPERVGUI_Clipboard::getClipboard(); + SUPERVGUI_CanvasNode::pastePort(); + if ( aCB->getCopyPort()->IsInput() && getEngine()->IsLoop() ) + merge(); + if ( myCoupled ) + myCoupled->merge(); +} //===================================================================== // End control node @@ -244,10 +283,172 @@ void SUPERVGUI_CanvasMacroNode::exportDataflow() "*.xml", tr("TTL_EXPORT_DATAFLOW"), false); - if (!aFileName.isEmpty()) { + if ( !aFileName.isEmpty() ) { + // asv : bug [VSR Bugs and Improvements in Supervisor] 1.8 : when exporting a file, + // a backup copy of an existing file must be created (in case Export fails..) + QString aBackupFile = SUPERVGUI::createBackupFile( aFileName ); + if (!aGraph->Export(aFileName.latin1())) { - QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_BAD_WRITING")); + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_BAD_WRITING").arg(aBackupFile)); + } + // remove a backup file if export was successfull + else if ( !aBackupFile.isNull() && !aBackupFile.isEmpty() ) { + QFile::remove( aBackupFile ); } } } } + +//===================================================================== +// Cell node: node for table view +//===================================================================== +SUPERVGUI_CanvasCellNode::SUPERVGUI_CanvasCellNode(QObject* theParent, + SUPERVGUI_Main* theMain, + SUPERV_CNode theNode): + SUPERVGUI_CanvasNode(theParent, theMain, theNode, true) +{ + Trace("SUPERVGUI_CanvasCellNode::SUPERVGUI_CanvasCellNode"); + + myIsControl = false; + myIsStart = false; + + //check for control nodes + if (getEngine()->IsLoop() || getEngine()->IsSwitch()) { + myIsControl = true; + myIsStart = true; + } + if (getEngine()->IsEndLoop() || getEngine()->IsEndSwitch()) + myIsControl = true; +} + +SUPERVGUI_CanvasCellNode::~SUPERVGUI_CanvasCellNode() +{ +} + +QPopupMenu* SUPERVGUI_CanvasCellNode::getPopupMenu(QWidget* theParent) +{ + QPopupMenu* popup = SUPERVGUI_CanvasNode::getPopupMenu(theParent); + popup->setItemEnabled(myDeleteItem, false); + return popup; +} + +void SUPERVGUI_CanvasCellNode::setPairCell(SUPERVGUI_CanvasCellNode* thePairCell) { + if (myIsControl) { //only for ControlNode + myPairCell = thePairCell; + } + else + myPairCell = 0; +} + +SUPERVGUI_CanvasCellNode* SUPERVGUI_CanvasCellNode::getPairCell() { + return myPairCell; +} + +void SUPERVGUI_CanvasCellNode::sync() { + const bool isExecuting = getMain()->getDataflow()->IsExecuting(); + //if getEngine() is a MacroNode then set it state to state of its subgraph + if ( getEngine()->IsMacro() && isExecuting ) { + // get SubGraph from MacroNode + SUPERV_Graph aMacro = SUPERV::Graph::_narrow(getEngine()); + if (!SUPERV_isNull(aMacro)) { + SUPERV_Graph aGraph; + if (aMacro->IsStreamMacro()) + aGraph = aMacro->StreamObjRef(); + else + aGraph = aMacro->FlowObjRef(); + if (!SUPERV_isNull(aGraph)) { + if (aGraph->State() != SUPERV::UndefinedState && aGraph->State() != SUPERV::NoState) + getPrs()->setState(aGraph->State()); + else + getPrs()->setState(getEngine()->State()); + } + } + } + else { + getPrs()->setState(getEngine()->State()); + } +} + +bool SUPERVGUI_CanvasCellNode::setNodeName(QString aName) +{ + bool result = SUPERVGUI_CanvasNode::setNodeName(aName); + if (result && myPairCell) { + result = myPairCell->setNodeName(QString(tr("ENDNODE_PREFIX"))+aName); + } + return result; +} + +SUPERVGUI_CanvasNodePrs* SUPERVGUI_CanvasCellNode::createPrs() const +{ + SUPERVGUI_CanvasNodePrs* aPrs = + new SUPERVGUI_CanvasCellNodePrs(getMain()->getCanvasArray(), + (SUPERVGUI_CanvasCellNode*)this); + return aPrs; +} + +SUPERVGUI_CanvasCellEndNode::SUPERVGUI_CanvasCellEndNode( QObject* theParent, + SUPERVGUI_Main* theMain, + SUPERV_CNode theNode, + SUPERVGUI_CanvasCellNode* theStart): + SUPERVGUI_CanvasCellNode(theParent, theMain, theNode) +{ + //set start cell for end cell as pair + myPairCell = theStart; + //set end cell for start cell as pair + myPairCell->setPairCell(dynamic_cast(this)); +} + +bool SUPERVGUI_CanvasCellEndNode::setNodeName(QString theName) +{ + return SUPERVGUI_CanvasNode::setNodeName(theName); +} + +//----------------------------------------------------------- +//*************** Select Inline node dialog****************** +// Taken from SUPERVGUI_ControlNode.cxx without change +//----------------------------------------------------------- + +SUPERVGUI_SelectInlineDlg::SUPERVGUI_SelectInlineDlg(SUPERVGUI_Main* theMain) + :QDialog(theMain, 0, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) +{ + setSizeGripEnabled( true ); + setCaption(tr("TIT_FUNC_PYTHON")); + QGridLayout* aMainLayout = new QGridLayout(this, 2, 2, 7, 4); + + QLabel* aLabel = new QLabel("Connect to", this ); + aMainLayout->addWidget(aLabel, 0, 0); + + myCombo = new QComboBox(this); + myCombo->clear(); //for the additional check from GUI side for bug PAL7007 + SUPERV_Nodes aNodesList = theMain->getDataflow()->Nodes(); + int i; + for (i = 0; i < aNodesList->INodes.length(); i++) { + myCombo->insertItem(QString(aNodesList->INodes[i]->Name())); + } + for (i = 0; i < aNodesList->LNodes.length(); i++) { + myCombo->insertItem(QString(aNodesList->LNodes[i]->Name())); + } + for (i = 0; i < aNodesList->SNodes.length(); i++) { + myCombo->insertItem(QString(aNodesList->SNodes[i]->Name())); + } + aMainLayout->addWidget(myCombo, 0, 1); + + QGroupBox* aBtnBox = new QGroupBox( this ); + aBtnBox->setColumnLayout( 0, Qt::Vertical ); + aBtnBox->layout()->setSpacing( 0 ); aBtnBox->layout()->setMargin( 0 ); + QHBoxLayout* aBtnLayout = new QHBoxLayout( aBtnBox->layout() ); + aBtnLayout->setAlignment( Qt::AlignTop ); + aBtnLayout->setSpacing( 6 ); aBtnLayout->setMargin( 11 ); + + QPushButton* aOKBtn = new QPushButton( tr( "BUT_OK" ), aBtnBox ); + connect( aOKBtn, SIGNAL( clicked() ), this, SLOT( accept() ) ); + aBtnLayout->addWidget( aOKBtn ); + + aBtnLayout->addStretch(); + + QPushButton* aCancelBtn = new QPushButton( tr("BUT_CANCEL"), aBtnBox ); + connect( aCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) ); + aBtnLayout->addWidget( aCancelBtn ); + + aMainLayout->addMultiCellWidget(aBtnBox, 1, 1, 0, 1); +} diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasControlNode.h b/src/SUPERVGUI/SUPERVGUI_CanvasControlNode.h index 137836c..686fcbf 100644 --- a/src/SUPERVGUI/SUPERVGUI_CanvasControlNode.h +++ b/src/SUPERVGUI/SUPERVGUI_CanvasControlNode.h @@ -12,7 +12,8 @@ using namespace std; #include "SUPERVGUI_Def.h" #include "SUPERVGUI_CanvasNode.h" - +#include +#include class SUPERVGUI_CanvasComputeNode : public SUPERVGUI_CanvasNode { Q_OBJECT @@ -61,6 +62,7 @@ class SUPERVGUI_CanvasStartNode : public SUPERVGUI_CanvasNode { virtual void addInputPort(); virtual void addOutputPort(); + virtual void pastePort(); protected: virtual SUPERVGUI_CanvasNodePrs* createPrs() const; @@ -117,4 +119,62 @@ class SUPERVGUI_CanvasGotoNode : public SUPERVGUI_CanvasNode { virtual SUPERVGUI_CanvasNodePrs* createPrs() const; }; +class SUPERVGUI_CanvasCellNode : public SUPERVGUI_CanvasNode { + Q_OBJECT + + public: + SUPERVGUI_CanvasCellNode(QObject* theParent, + SUPERVGUI_Main* theMain, + SUPERV_CNode theNode); + virtual ~SUPERVGUI_CanvasCellNode(); + + virtual QPopupMenu* getPopupMenu(QWidget* theParent); + + void setPairCell(SUPERVGUI_CanvasCellNode* thePairCell); + SUPERVGUI_CanvasCellNode* getPairCell(); + + virtual void sync(); + virtual bool setNodeName(QString aName); + + protected: + virtual SUPERVGUI_CanvasNodePrs* createPrs() const; + + protected: + SUPERVGUI_CanvasCellNode* myPairCell; //for ControlNodes + + private: + bool myIsControl; + bool myIsStart; + +}; + +class SUPERVGUI_CanvasCellEndNode: public SUPERVGUI_CanvasCellNode { + + public: + SUPERVGUI_CanvasCellEndNode(QObject* theParent, + SUPERVGUI_Main* theMain, + SUPERV_CNode theNode, + SUPERVGUI_CanvasCellNode* theStart); + virtual ~SUPERVGUI_CanvasCellEndNode() {} + + virtual bool setNodeName(QString theName); +}; + +/** + * Taken from SUPERVGUI_ControlNode.h without change + */ +class SUPERVGUI_SelectInlineDlg: public QDialog { + Q_OBJECT + + public: + SUPERVGUI_SelectInlineDlg(SUPERVGUI_Main* theMain); + virtual ~SUPERVGUI_SelectInlineDlg() {}; + + QString getName() { return myCombo->currentText(); } + + private: + QComboBox* myCombo; +}; + + #endif diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasLink.cxx b/src/SUPERVGUI/SUPERVGUI_CanvasLink.cxx index 74b6b76..4855b18 100644 --- a/src/SUPERVGUI/SUPERVGUI_CanvasLink.cxx +++ b/src/SUPERVGUI/SUPERVGUI_CanvasLink.cxx @@ -214,6 +214,8 @@ void SUPERVGUI_CanvasLink::setColor(const QColor& theColor) } void SUPERVGUI_CanvasLink::remove() { + myMain->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag + QString aValue; SUPERVGUI_CanvasPortIn* aPort = 0; SUPERVGUI_Canvas* aCanvas = myMain->getCanvas(); @@ -324,7 +326,6 @@ SUPERVGUI_CanvasLinkBuilder::~SUPERVGUI_CanvasLinkBuilder() bool SUPERVGUI_CanvasLinkBuilder::canCreateEngine(SUPERVGUI_CanvasPort* thePort) { - bool result = false; if (thePort && myPort) { SUPERVGUI_CanvasPort* aInPort; SUPERVGUI_CanvasPort* aOutPort; @@ -343,17 +344,10 @@ bool SUPERVGUI_CanvasLinkBuilder::canCreateEngine(SUPERVGUI_CanvasPort* thePort) aInPort = thePort; } - // control if node is different + // control if nodes are different, not the same node QString aInNode(aInPort->getEngine()->Node()->Name()); QString aOutNode(aOutPort->getEngine()->Node()->Name()); - if (aInNode.compare(aOutNode) == 0) - return false; - - // control if no port is "Default" - QString aInName(aInPort->getEngine()->Name()); - QString aOutName(aOutPort->getEngine()->Name()); - if (aInName.compare("Default") == 0 || - aOutName.compare("Default") == 0) + if (aInNode.compare(aOutNode) == 0) // linking outport and inport of the same node return false; // control types of ports @@ -365,23 +359,30 @@ bool SUPERVGUI_CanvasLinkBuilder::canCreateEngine(SUPERVGUI_CanvasPort* thePort) (aOutKind == SUPERV::DataStreamParameter && aInKind != SUPERV::DataStreamParameter)) return false; - // connect gate port with gate or inline port - if (aInKind == SUPERV::GateParameter || aOutKind == SUPERV::GateParameter) { - if (aInKind != aOutKind && - aInKind != SUPERV::InLineParameter && - aOutKind != SUPERV::InLineParameter) - return false; - } + // asv : 15.12.04 : NOT allow to connect Gate-to-InLine --> it does not make sence! + // Out Gate port can be connected only to In Gate port + if ( aOutKind == SUPERV::GateParameter && aInKind != SUPERV::GateParameter ) + return false; - // control if port is already linked except for input port of end switch node - if (!(aInKind == SUPERV::EndSwitchParameter || - aInPort->getEngine()->Node()->Kind() == SUPERV::EndSwitchNode)) { - if (aInPort->getEngine()->IsLinked()) + // In Gate can be connected to (receive links from) Gate port and InLine ports (important for Switch nodes) + if ( aInKind == SUPERV::GateParameter && aOutKind != SUPERV::GateParameter && aOutKind != SUPERV::InLineParameter ) return false; - } - result = true; + + // asv : 15.12.04 : PAL7374, p.2.2 "Bugs and Improvements": multiple links into Gate port + // for InGate it's OK to accept more than 1 link + // THESE NEEDS REVISION, ALSO DON'T ALLOW MANY LINKS TO "DEFAULT" PORT OF EndSwitch + //if ( aInPort->getEngine()->IsLinked() && aInKind != SUPERV::GateParameter ) + + // control if port is already linked except for input inline ports of end switch node (check for EndSwitchParameter) + // and "Default" port of Switch node (check for aNode->isEndSwitch()). "Default" port is linked by default, but we + // let it to be "re-linked" to another port. + const bool isEndSwitch = ( aInKind == SUPERV::EndSwitchParameter || aInPort->getEngine()->Node()->IsEndSwitch() ); + if ( !isEndSwitch && aInPort->getEngine()->IsLinked() ) + return false; + + return true; } - return result; + return false; } void SUPERVGUI_CanvasLinkBuilder::setCoords(SUPERV::Link_ptr theLink) @@ -508,20 +509,20 @@ int SUPERVGUI_CanvasPointPrs::rtti() const void SUPERVGUI_CanvasPointPrs::setInEdge(SUPERVGUI_CanvasEdgePrs* theEdge) { myInEdge = theEdge; - theEdge->setFromPoint((int)x(), (int)y()); + theEdge->setFromPoint(this); } void SUPERVGUI_CanvasPointPrs::setOutEdge(SUPERVGUI_CanvasEdgePrs* theEdge) { myOutEdge = theEdge; - theEdge->setToPoint((int)x(), (int)y()); + theEdge->setToPoint(this); } void SUPERVGUI_CanvasPointPrs::moveBy(double dx, double dy) { QCanvasEllipse::moveBy(dx, dy); - if (myInEdge) myInEdge->setFromPoint((int)x(), (int)y()); - if (myOutEdge) myOutEdge->setToPoint((int)x(), (int)y()); + if (myInEdge) myInEdge->setFromPoint(this); + if (myOutEdge) myOutEdge->setToPoint(this); //resize canvas view if mouse is outside int w = (int)(x()+dx) + width() + GRAPH_MARGIN; int h = (int)(y()+dy) + height() + GRAPH_MARGIN; @@ -554,17 +555,32 @@ int SUPERVGUI_CanvasEdgePrs::rtti() const return SUPERVGUI_Canvas::Rtti_LinkEdge; } -void SUPERVGUI_CanvasEdgePrs::setFromPoint(int x, int y) +void SUPERVGUI_CanvasEdgePrs::setFromPoint(SUPERVGUI_CanvasPointPrs* thePoint) { - setPoints(x, y, endPoint().x(), endPoint().y()); + myStartPoint = thePoint; + setPoints((int)(thePoint->x()), (int)(thePoint->y()), endPoint().x(), endPoint().y()); } -void SUPERVGUI_CanvasEdgePrs::setToPoint(int x, int y) +void SUPERVGUI_CanvasEdgePrs::setToPoint(SUPERVGUI_CanvasPointPrs* thePoint) { - setPoints(startPoint().x(), startPoint().y(), x, y); + myEndPoint = thePoint; + setPoints(startPoint().x(), startPoint().y(), (int)(thePoint->x()), (int)(thePoint->y())); } void SUPERVGUI_CanvasEdgePrs::setColor(const QColor& theColor) { setPen(QPen(theColor, LINE_WIDTH)); } + +void SUPERVGUI_CanvasEdgePrs::moveBy(double dx, double dy) +{ + //mkr: for moving segment of link + if (myStartPoint && myEndPoint) { + myStartPoint->setMoving(true); + myStartPoint->moveBy(dx, dy); + + myEndPoint->setMoving(true); + myEndPoint->moveBy(dx,dy); + } +} + diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasLink.h b/src/SUPERVGUI/SUPERVGUI_CanvasLink.h index cb54d0c..3865950 100644 --- a/src/SUPERVGUI/SUPERVGUI_CanvasLink.h +++ b/src/SUPERVGUI/SUPERVGUI_CanvasLink.h @@ -151,16 +151,24 @@ class SUPERVGUI_CanvasEdgePrs : public QCanvasLine SUPERVGUI_CanvasLink* getLink() const { return myLink; } - void setFromPoint(int x, int y); - void setToPoint(int x, int y); + void setFromPoint(SUPERVGUI_CanvasPointPrs* thePoint); + void setToPoint(SUPERVGUI_CanvasPointPrs* thePoint); - void moveBy(double dx, double dy) {} + void moveBy(double dx, double dy); void setColor(const QColor& theColor); + void setMoving(bool b) { myMoving = b; } + bool isMoving() const { return myMoving; } + virtual int rtti() const; private: + bool myMoving; SUPERVGUI_CanvasLink* myLink; + + //mkr: for moving segment of link + SUPERVGUI_CanvasPointPrs* myStartPoint; + SUPERVGUI_CanvasPointPrs* myEndPoint; }; #endif diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasNode.cxx b/src/SUPERVGUI/SUPERVGUI_CanvasNode.cxx index 9a9f532..bd8602a 100644 --- a/src/SUPERVGUI/SUPERVGUI_CanvasNode.cxx +++ b/src/SUPERVGUI/SUPERVGUI_CanvasNode.cxx @@ -10,19 +10,18 @@ using namespace std; #include "SUPERVGUI_CanvasNode.h" #include "SUPERVGUI_CanvasNodePrs.h" #include "SUPERVGUI_CanvasPort.h" +#include "SUPERVGUI_Clipboard.h" #include "SUPERVGUI_Main.h" -#include "SUPERVGUI_Python.h" #include "SUPERVGUI.h" #include "SUPERVGUI_BrowseNodeDlg.h" -#include "SALOMEGUI_NameDlg.h" +#include "SUPERVGUI_ManagePortsDlg.h" #include "SUPERVGUI_Information.h" -/* -#include "SUPERVGUI_CanvasControlNode.h" +#include "SUPERVGUI_Library.h" -#include -*/ +#include "SALOMEGUI_NameDlg.h" +#include "QAD_MessageBox.h" -SUPERVGUI_CanvasNode::SUPERVGUI_CanvasNode(QObject* theParent, SUPERVGUI_Main* theMain, SUPERV_CNode theNode): +SUPERVGUI_CanvasNode::SUPERVGUI_CanvasNode(QObject* theParent, SUPERVGUI_Main* theMain, SUPERV_CNode theNode, bool theIsCell): QObject(theParent), myMain(theMain), myNode(theNode), @@ -57,20 +56,19 @@ SUPERVGUI_CanvasNode::SUPERVGUI_CanvasNode(QObject* theParent, SUPERVGUI_Main* t myLabelText = aNewComment; - // create node ports - isIgnore = true; - //cout << " get port list... " ; - SUPERV_Ports aPortList = myNode->Ports(); - //cout << aPortList->length() << endl; - for (int i = 0; i < aPortList->length(); i++) { - createPort(aPortList[i].in()); - } - - //cout << " get stream port list... " ; - SUPERV_StreamPorts aStreamPortList = myNode->StreamPorts(); - //cout << aStreamPortList->length() << endl; - for (int i = 0; i < aStreamPortList->length(); i++) { - createStreamPort(aStreamPortList[i].in()); + // mkr : if the SUPERVGUI_CavasCellNode created (for CANVASTABLE view), + // we haven't create its ports + if (!theIsCell) { + // create node ports + isIgnore = true; + SUPERV_Ports aPortList = myNode->Ports(); + for (int i = 0; i < aPortList->length(); i++) + createPort(aPortList[i].in()); + + SUPERV_StreamPorts aStreamPortList = myNode->StreamPorts(); + for (int i = 0; i < aStreamPortList->length(); i++) { + createStreamPort(aStreamPortList[i].in()); + } } isIgnore = false; @@ -79,7 +77,11 @@ SUPERVGUI_CanvasNode::SUPERVGUI_CanvasNode(QObject* theParent, SUPERVGUI_Main* t SUPERVGUI_CanvasNode::~SUPERVGUI_CanvasNode() { isIgnore = true; - if (myPrs) delete myPrs; + if ( myPrs ) { + myPrs->hide(); + delete myPrs; + myPrs = 0; + } } void SUPERVGUI_CanvasNode::setDestroyed() @@ -88,11 +90,11 @@ void SUPERVGUI_CanvasNode::setDestroyed() getPrs()->hide(); } -SUPERVGUI_CanvasNodePrs* SUPERVGUI_CanvasNode::getPrs() const +SUPERVGUI_CanvasNodePrs* SUPERVGUI_CanvasNode::getPrs() { - if (myPrs == 0) { - ((SUPERVGUI_CanvasNode*)this)->myPrs = createPrs(); - } + if ( !myPrs ) + myPrs = createPrs(); + return myPrs; } @@ -101,7 +103,7 @@ SUPERVGUI_CanvasNodePrs* SUPERVGUI_CanvasNode::createPrs() const return new SUPERVGUI_CanvasNodePrs(myMain->getCanvas(), (SUPERVGUI_CanvasNode*)this); } -void SUPERVGUI_CanvasNode::createPort(SUPERV::Port_ptr thePort) const +void SUPERVGUI_CanvasNode::createPort(SUPERV::Port_ptr thePort) { SUPERVGUI_CanvasPort* aPort = 0; if (thePort->IsInput()) @@ -115,7 +117,7 @@ void SUPERVGUI_CanvasNode::createPort(SUPERV::Port_ptr thePort) const } } -void SUPERVGUI_CanvasNode::createStreamPort(SUPERV::StreamPort_ptr thePort) const +void SUPERVGUI_CanvasNode::createStreamPort(SUPERV::StreamPort_ptr thePort) { SUPERVGUI_CanvasPort* aPort = 0; if (thePort->IsInput()) @@ -140,40 +142,60 @@ void SUPERVGUI_CanvasNode::onDestroyed(QObject* theObject) QPopupMenu* SUPERVGUI_CanvasNode::getPopupMenu(QWidget* theParent) { QPopupMenu* popup = new QPopupMenu(theParent); - if (myMain->getDataflow()->IsExecuting()) { - popup->insertItem((myNode->IsSuspended()?tr("MSG_RESUME"):tr("MSG_SUSPEND")), - this, SLOT(suspendResume())); + + if (myMain->getDataflow()->IsExecuting()) { // Execution time + popup->insertItem((myNode->IsSuspended()?tr("MSG_RESUME"):tr("MSG_SUSPEND")), this, SLOT(suspendResume())); popup->insertItem(tr("MSG_KILL"), this, SLOT(kill())); } - else { - if (myMain->isEditable() && getNodeType() != SUPERV::EndLoopNode - && getNodeType() != SUPERV::EndSwitchNode) { + else { // Edition time + const int type = getNodeType(); + + // for all nodes except EndLoop and EndSwitch : Rename, Delete, Copy + if ( myMain->isEditable() && type != SUPERV::EndLoopNode && type != SUPERV::EndSwitchNode ) { popup->insertItem(tr("MSG_RENAME"), this, SLOT(rename())); - popup->insertItem(tr("MSG_DELETE"), this, SLOT(remove())); - popup->insertSeparator(); + myDeleteItem = popup->insertItem(tr("MSG_DELETE"), this, SLOT(remove())); } + + // tmp: Copy temporary does not work for Macro nodes... + if ( type != SUPERV::MacroNode ) + popup->insertItem(tr("ITM_COPY_NODE"), this, SLOT(copy())); // Copy Node functionality + popup->insertSeparator(); + + // for all nodes : Browse popup->insertItem(tr("MSG_BROWSE"), this, SLOT(browse())); - if (getNodeType() != SUPERV::EndLoopNode && - getNodeType() != SUPERV::EndSwitchNode) + // for all nodes except EndLoop and EndSwitch : Change info + if (type != SUPERV::EndLoopNode && type != SUPERV::EndSwitchNode) popup->insertItem(tr("MSG_CHANGE_INFO"), this, SLOT(changeInformation())); - if (myMain->isEditable() && getNodeType() != SUPERV::FactoryNode - && getNodeType() != SUPERV::ComputingNode - && getNodeType() != SUPERV::EndLoopNode - && getNodeType() != SUPERV::MacroNode) { - QPopupMenu* addPortMenu = new QPopupMenu(theParent); - addPortMenu->insertItem("Input", this, SLOT(addInputPort())); - if (getNodeType() != SUPERV::LoopNode) - addPortMenu->insertItem("Output", this, SLOT(addOutputPort())); - - popup->insertSeparator(); - if ((getNodeType() != SUPERV::EndSwitchNode)) - popup->insertItem("Edit Function", this, SLOT(editFunction())); - popup->insertItem("Add Port", addPortMenu); + // for all InLine nodes + if ( type != SUPERV::FactoryNode && type != SUPERV::ComputingNode && type != SUPERV::MacroNode ) { + if ( myMain->isEditable() ) { + popup->insertSeparator(); + popup->insertItem( tr( "MNU_EDIT_FUNC" ), this, SLOT(editFunction())); + } + + // for all InLine, regardless isEditable() : Export to Library + popup->insertItem( tr( "MNU_EXPORT" ), this, SLOT( exportToLib())); + + // for all InLine except EndLoop : Add Ports menu, Paste, Manage Ports + if ( myMain->isEditable() && type != SUPERV::EndLoopNode ) { + QPopupMenu* addPortMenu = new QPopupMenu(theParent); + addPortMenu->insertItem( tr( "MNU_INPUT" ), this, SLOT(addInputPort())); + if (getNodeType() != SUPERV::LoopNode) + addPortMenu->insertItem( tr( "MNU_OUTPUT" ), this, SLOT(addOutputPort())); + + popup->insertItem( tr( "MNU_ADD_PORT" ), addPortMenu); + popup->insertItem( tr( "MNU_MANAGE_PORTS" ), this, SLOT(managePorts())); + + // Paste Port functionality + int aPasteItem = popup->insertItem(tr("ITM_PASTE_PORT"), this, SLOT(pastePort())); + SUPERVGUI_Clipboard* aCB = SUPERVGUI_Clipboard::getClipboard(); + if ( !aCB->isCopyPort() || (type == SUPERV::LoopNode && !aCB->getCopyPort()->IsInput()) ) + popup->setItemEnabled( aPasteItem, false ); + } } } - return popup; } @@ -212,49 +234,39 @@ void SUPERVGUI_CanvasNode::move(int x, int y) void SUPERVGUI_CanvasNode::merge() { - //MESSAGE("===> SUPERVGUI_CanvasNode::merge() " << myNode->Name()); // synchronize port list bool update = false; isIgnore = true; SUPERVGUI_CanvasPort* aPort; QObjectList* aPortList = queryList("SUPERVGUI_CanvasPort"); - //cout << " get port list... " ; SUPERV_Ports aPorts = myNode->Ports(); - //cout << aPorts->length() << endl; for (int i = 0; i < aPorts->length(); i++) { aPort = (SUPERVGUI_CanvasPort*) child(myMain->getCanvas()->getPortName(aPorts[i].in()), "SUPERVGUI_CanvasPort"); if (aPort) { - //cout << " update port " << aPort->name() << endl; aPortList->removeRef(aPort); aPort->update(); } else { - //cout << " create port " << myMain->getCanvas()->getPortName(aPorts[i].in()) << endl; createPort(aPorts[i].in()); update = true; } } - //cout << " get stream port list... " ; SUPERV_StreamPorts aStreamPorts = myNode->StreamPorts(); - //cout << aStreamPorts->length() << endl; for (int i = 0; i < aStreamPorts->length(); i++) { aPort = (SUPERVGUI_CanvasPort*) child(myMain->getCanvas()->getPortName(aStreamPorts[i].in()), "SUPERVGUI_CanvasPort"); if (aPort) { - //cout << " update stream port " << aPort->name() << endl; aPortList->removeRef(aPort); aPort->update(); } else { - //cout << " create stream port " << myMain->getCanvas()->getPortName(aStreamPorts[i].in()) << endl; createPort(aStreamPorts[i].in()); update = true; } } - //cout << " remove inexistant " << endl; QObjectListIt it(*aPortList); while ((aPort=(SUPERVGUI_CanvasPort*)it.current()) != 0) { ++it; @@ -269,12 +281,8 @@ void SUPERVGUI_CanvasNode::merge() sync(); // update node state also } -void SUPERVGUI_CanvasNode::sync() -{ - //MESSAGE("===> SUPERVGUI_CanvasNode::sync() " << myNode->Name() << ", state " << myNode->State()); - +void SUPERVGUI_CanvasNode::sync() { const bool isExecuting = myMain->getDataflow()->IsExecuting(); - //if myNode is a MacroNode then set it state to state of its subgraph if ( myNode->IsMacro() && isExecuting ) { // get SubGraph from MacroNode SUPERV_Graph aMacro = SUPERV::Graph::_narrow(myNode); @@ -296,9 +304,10 @@ void SUPERVGUI_CanvasNode::sync() SUPERV::GraphState aState = myNode->State(); // asv : 18.11.04 : fix for 6170 : after execution is finished, nodes' status must be reset. - if ( !isExecuting && myMain->IsGUIEventLoopFinished() && (aState == SUPERV::DoneState || - aState == SUPERV::KillState || aState == SUPERV::StopState ) ) - aState = SUPERV::EditingState; + // asv : 13.12.04 : commented out setting EditingState. See 2.21. + //if ( !isExecuting && myMain->IsGUIEventLoopFinished() && (aState == SUPERV::DoneState || + // aState == SUPERV::KillState || aState == SUPERV::StopState ) ) + // aState = SUPERV::EditingState; getPrs()->setState(aState); } @@ -320,8 +329,7 @@ void SUPERVGUI_CanvasNode::syncOnEvent(SUPERV::GraphState theStateFromEvent) getPrs()->setState(theStateFromEvent); } -bool SUPERVGUI_CanvasNode::setNodeName(QString aName) -{ +bool SUPERVGUI_CanvasNode::setNodeName(QString aName) { bool result = myNode->SetName(aName.latin1()); if (result) { setName(myNode->Name()); @@ -334,8 +342,7 @@ bool SUPERVGUI_CanvasNode::setNodeName(QString aName) return result; } -void SUPERVGUI_CanvasNode::rename() -{ +void SUPERVGUI_CanvasNode::rename() { QString aName = SALOMEGUI_NameDlg::getName(QAD_Application::getDesktop(), myNode->Name()); if (!aName.isEmpty()) { setNodeName(aName); @@ -344,6 +351,26 @@ void SUPERVGUI_CanvasNode::rename() void SUPERVGUI_CanvasNode::remove() { Trace("SUPERVGUI_CanvasNode::remove"); + myMain->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag + + //set myCopyPort from Main object to empty if engine of this port is deleted + //check if any port of this deleted node has been copied + SUPERVGUI_Clipboard* aCB = SUPERVGUI_Clipboard::getClipboard(); + if ( aCB->isCopyPort() ) + if ( QString(myNode->Name()) == QString(aCB->getCopyPort()->Node()->Name()) ) + aCB->setCopyPort( 0 ); + + //set myCopyNode from Main object to empty if engine of this node is deleted + //check if myCopyNode and this node engine is equal + if ( aCB->isCopyNode() ) + if ( QString(myNode->Name()) == QString(aCB->getCopyNode()->Name()) ) + aCB->setCopyNode( 0 ); + + // mkr: since the deletion of the node allow only in CANVAS view, + // it is necessary to remove the CanvasArray's children, which + // have the same CNode engine as deleting node + myMain->removeArrayChild(myNode); + SUPERVGUI_Canvas* aCanvas = myMain->getCanvas(); setDestroyed(); myNode->destroy(); @@ -351,6 +378,16 @@ void SUPERVGUI_CanvasNode::remove() { aCanvas->update(); } +void SUPERVGUI_CanvasNode::copy() { + Trace("SUPERVGUI_CanvasNode::copy()"); + SUPERVGUI_Clipboard* aCB = SUPERVGUI_Clipboard::getClipboard(); + const int aKind = getNodeType(); + if ( aKind == SUPERV::EndLoopNode || aKind == SUPERV::EndSwitchNode ) + aCB->setCopyNode( SUPERV::CNode::_duplicate(SUPERV::GNode::_narrow(getEngine())->Coupled()) ); + else + aCB->setCopyNode( SUPERV::CNode::_duplicate( getEngine() ) ); +} + void SUPERVGUI_CanvasNode::suspendResume() { Trace("SUPERVGUI_CanvasNode::suspendResume"); int n = queryList("SUPERVGUI_CanvasNode")->count(); @@ -382,7 +419,8 @@ void SUPERVGUI_CanvasNode::kill() { myMain->getMyThread()->stopThread(tr("MSG_NODE_KILLED1")+myNode->Name()+tr("MSG_NODE_KILLED2")); } } - +/* asv : 15.12.04 : commented out stopRestart() in Main and CanvasNode because it's not called from anywhere, + the comment from kloss (in Main.cxx) may be explaining it, but it's in French and I do not understand it.. void SUPERVGUI_CanvasNode::stopRestart() { Trace("SUPERVGUI_CanvasNode::stopRestart"); @@ -397,7 +435,7 @@ void SUPERVGUI_CanvasNode::stopRestart() { } } } - +*/ void SUPERVGUI_CanvasNode::changeInformation() { SUPERVGUI_Information* aDlg = new SUPERVGUI_Information(myNode, !myMain->isEditable()); if (aDlg->exec()) { @@ -408,6 +446,7 @@ void SUPERVGUI_CanvasNode::changeInformation() { delete aDlg; } +/* asv : 13.12.04 : The functions below are not called from anywhere, so commenting them out... void SUPERVGUI_CanvasNode::configure() { Trace("SUPERVGUI_CanvasNode::configure"); @@ -420,6 +459,7 @@ void SUPERVGUI_CanvasNode::showPython() SUPERVGUI_Python cp(myMain->getStudy()->get_PyInterp(), !myMain->isEditable()); cp.exec(); } +*/ bool SUPERVGUI_CanvasNode::isWarning() { @@ -472,6 +512,7 @@ void SUPERVGUI_CanvasNode::setVerbose(bool b) void SUPERVGUI_CanvasNode::browse() { + myMain->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag if (!myBrowseDlg) { myBrowseDlg = new SUPERVGUI_BrowseNodeDlg(this); myBrowseDlg->installEventFilter(this); @@ -489,7 +530,6 @@ bool SUPERVGUI_CanvasNode::eventFilter( QObject* o, QEvent* e ) { if (o == myBrowseDlg && e->type() == QEvent::Close) myBrowseDlg = 0; - return QObject::eventFilter(o, e); } @@ -547,6 +587,8 @@ SUPERV_Port SUPERVGUI_CanvasNode::createOutPort() } void SUPERVGUI_CanvasNode::addInputPort() { + myMain->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag + SUPERV_Port aPort = createInPort(); if (aPort == NULL) return; @@ -555,6 +597,8 @@ void SUPERVGUI_CanvasNode::addInputPort() { void SUPERVGUI_CanvasNode::addOutputPort() { + myMain->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag + SUPERV_Port aPort = createOutPort(); if (aPort == NULL) return; @@ -562,8 +606,9 @@ void SUPERVGUI_CanvasNode::addOutputPort() { } -void SUPERVGUI_CanvasNode::editFunction() -{ +void SUPERVGUI_CanvasNode::editFunction() { + myMain->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag + if (getNodeType() == SUPERV::LoopNode) { SUPERVGUI_EditPythonDlg* aDlg = new SUPERVGUI_EditPythonDlg(true); SUPERV_LNode aLNode = getLoopNode(); @@ -587,3 +632,34 @@ void SUPERVGUI_CanvasNode::editFunction() delete aDlg; } } + +/** + * Called on "Paste port" command of popup menu + */ +void SUPERVGUI_CanvasNode::pastePort() { + SUPERVGUI_Clipboard::getClipboard()->pastePort( this ); +} + +/** + * Called on "Edit ports" popup menu command. See SUPERVGUI_ManagePortsDlg.h + * for detailed description of the functionality + */ +void SUPERVGUI_CanvasNode::managePorts() { + myMain->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag + + SUPERVGUI_ManagePortsDlg* aDlg = new SUPERVGUI_ManagePortsDlg( this ); + aDlg->exec(); + delete aDlg; +} + +/** + * Called on "Export to Library" popup menu command. See SUPERVGUI_Library.h + * for details on InLine nodes library functionality + */ +void SUPERVGUI_CanvasNode::exportToLib() { + SUPERV::INode_var anINode = SUPERV::INode::_narrow( getEngine() ); + if ( !CORBA::is_nil( anINode ) ) + SUPERVGUI_Library::getLibrary()->Export( anINode ); + else + QAD_MessageBox::error1( QAD_Application::getDesktop(), tr( "ERROR" ), tr( "MSG_BAD_INODE" ), tr( "OK" ) ); +} diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasNode.h b/src/SUPERVGUI/SUPERVGUI_CanvasNode.h index f33d6ce..12b6b2b 100644 --- a/src/SUPERVGUI/SUPERVGUI_CanvasNode.h +++ b/src/SUPERVGUI/SUPERVGUI_CanvasNode.h @@ -18,10 +18,13 @@ class SUPERVGUI_Main; class SUPERVGUI_CanvasNodePrs; class SUPERVGUI_CanvasNode : public QObject { + friend class SUPERVGUI_ManagePortsDlg; + friend class SUPERVGUI_Clipboard; + Q_OBJECT public: - SUPERVGUI_CanvasNode(QObject* theParent, SUPERVGUI_Main* theMain, SUPERV_CNode theNode); + SUPERVGUI_CanvasNode(QObject* theParent, SUPERVGUI_Main* theMain, SUPERV_CNode theNode, bool theIsCell=false); virtual ~SUPERVGUI_CanvasNode(); // done to ignore port update when node is removed @@ -39,9 +42,9 @@ class SUPERVGUI_CanvasNode : public QObject { virtual void showAll(); virtual bool setNodeName(QString aName); - SUPERV_CNode getEngine() const { return myNode; } - SUPERVGUI_Main* getMain() const { return myMain; } - SUPERVGUI_CanvasNodePrs* getPrs() const; + SUPERV_CNode getEngine() const { return myNode; } + SUPERVGUI_Main* getMain() const { return myMain; } + SUPERVGUI_CanvasNodePrs* getPrs(); bool isWarning(); bool isStep(); @@ -55,10 +58,10 @@ class SUPERVGUI_CanvasNode : public QObject { SUPERV_INode getInlineNode() const { return SUPERV::INode::_narrow(myNode); } SUPERV_GNode getGotoNode() const { return SUPERV::GNode::_narrow(myNode); } SUPERV_LNode getLoopNode() const { return SUPERV::LNode::_narrow(myNode); } - SUPERV_ELNode getEndLoopNode() const { return SUPERV::ELNode::_narrow(myNode); } + SUPERV_ELNode getEndLoopNode() const { return SUPERV::ELNode::_narrow(myNode);} SUPERV_SNode getSwitchNode() const { return SUPERV::SNode::_narrow(myNode); } - SUPERV_ESNode getEndSwitchNode() const { return SUPERV::ESNode::_narrow(myNode); } - SUPERV_Graph getMacroNode() const { return SUPERV::Graph::_narrow(myNode); } + SUPERV_ESNode getEndSwitchNode() const { return SUPERV::ESNode::_narrow(myNode);} + SUPERV_Graph getMacroNode() const { return SUPERV::Graph::_narrow(myNode); } SUPERV_Port createInPort(); SUPERV_Port createOutPort(); @@ -71,12 +74,14 @@ class SUPERVGUI_CanvasNode : public QObject { public slots: void suspendResume(); void kill(); - void stopRestart(); - void configure(); - void showPython(); + //void stopRestart(); + + //asv: 13.12.04: ??? --> void configure(); + //asv: 13.12.04: ??? --> void showPython(); virtual void rename(); virtual void remove(); + void copy(); void changeInformation(); void browse(); @@ -91,16 +96,22 @@ class SUPERVGUI_CanvasNode : public QObject { virtual void addInputPort(); virtual void addOutputPort(); virtual void editFunction(); + virtual void pastePort(); + void managePorts(); + void exportToLib(); protected: + // redefined by most of CanvasNode successors virtual SUPERVGUI_CanvasNodePrs* createPrs() const; - virtual void createPort(SUPERV::Port_ptr thePort) const; - virtual void createStreamPort(SUPERV::StreamPort_ptr thePort) const; + + void createPort(SUPERV::Port_ptr thePort); + void createStreamPort(SUPERV::StreamPort_ptr thePort); virtual bool eventFilter(QObject* o, QEvent* e); SUPERVGUI_BrowseNodeDlg* myBrowseDlg; bool isIgnore; + int myDeleteItem; protected slots: virtual void onDestroyed(QObject*); diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasNodePrs.cxx b/src/SUPERVGUI/SUPERVGUI_CanvasNodePrs.cxx index f7e8793..969b433 100644 --- a/src/SUPERVGUI/SUPERVGUI_CanvasNodePrs.cxx +++ b/src/SUPERVGUI/SUPERVGUI_CanvasNodePrs.cxx @@ -11,6 +11,7 @@ using namespace std; #include "SUPERVGUI_CanvasNode.h" #include "SUPERVGUI_CanvasPort.h" #include "SUPERVGUI_Canvas.h" +#include "SUPERVGUI_CanvasCellNodePrs.h" //#define CHECKTIME @@ -28,7 +29,8 @@ using namespace std; // Node presentation //===================================================================== SUPERVGUI_CanvasNodePrs::SUPERVGUI_CanvasNodePrs(QCanvas* theCanvas, - SUPERVGUI_CanvasNode* theNode): + SUPERVGUI_CanvasNode* theNode, + bool theCellPrs): QCanvasPolygonalItem(theCanvas), myNode(theNode) { @@ -46,25 +48,34 @@ SUPERVGUI_CanvasNodePrs::SUPERVGUI_CanvasNodePrs(QCanvas* theCanvas, myLabelVisible = true; myPortVisible = true; + myCellPrs = theCellPrs; myColor = MAIN_BACK; - // create in/out connection points prs - myPointIn = new SUPERVGUI_CanvasHookPrs(theCanvas, this, true); - myPointOut = new SUPERVGUI_CanvasHookPrs(theCanvas, this, false); + if (!myCellPrs) { + // create in/out connection points prs + myPointIn = new SUPERVGUI_CanvasHookPrs(theCanvas, this, true); + myPointOut = new SUPERVGUI_CanvasHookPrs(theCanvas, this, false); - setZ(0); - setState(myNode->getEngine()->State()); - updatePorts(); + setZ(0); + setState(myNode->getEngine()->State()); + updatePorts(); + } } SUPERVGUI_CanvasNodePrs::~SUPERVGUI_CanvasNodePrs() { - Trace("SUPERVGUI_CanvasNodePrs::~SUPERVGUI_CanvasNodePrs"); - if (myPointIn) delete myPointIn; - if (myPointOut) delete myPointOut; - hide(); + if ( !myCellPrs ) { + if ( myPointIn ) { + delete myPointIn; + myPointIn = 0; + } + if ( myPointOut ) { + delete myPointOut; + myPointOut = 0; + } + } } int SUPERVGUI_CanvasNodePrs::rtti() const @@ -199,8 +210,10 @@ void SUPERVGUI_CanvasNodePrs::moveBy(double dx, double dy) } } - myPointIn->moveBy(dx, dy); - myPointOut->moveBy(dx, dy); + if (!myCellPrs) { + myPointIn->moveBy(dx, dy); + myPointOut->moveBy(dx, dy); + } } void SUPERVGUI_CanvasNodePrs::setZ(double z) @@ -257,7 +270,7 @@ void SUPERVGUI_CanvasNodePrs::setLabelVisible(bool b) myLabelVisible = b; updatePorts(); - if (!isPortVisible()) updatePoints(); + if (!isPortVisible() && !myCellPrs) updatePoints(); if (aDisp) { show(); @@ -272,16 +285,20 @@ void SUPERVGUI_CanvasNodePrs::setPortVisible(bool b) myPortVisible = b; if (b) { - myPointIn->hide(); - myPointOut->hide(); + if (!myCellPrs) { + myPointIn->hide(); + myPointOut->hide(); + } updateGates(); } else { - updatePoints(); - - myPointIn->show(); - myPointOut->show(); + if (!myCellPrs) { + updatePoints(); + + myPointIn->show(); + myPointOut->show(); + } } const QObjectList* list = myNode->children(); @@ -519,10 +536,10 @@ void drawText(QPainter& thePainter, const QString& theText, QFont saved = thePainter.font(); QFont f(saved); if (f.pointSize() == -1) { - f.setPixelSize(f.pixelSize()*aMat.m11()); + f.setPixelSize((int)(f.pixelSize()*aMat.m11())); } else { - f.setPointSize(f.pointSize()*aMat.m11()); + f.setPointSize((int)(f.pointSize()*aMat.m11())); } thePainter.save(); QWMatrix m; @@ -667,7 +684,7 @@ void SUPERVGUI_CanvasNodePrs::drawGate(QPainter& thePainter) QRect r = getGateRect(); // r.setHeight(r.height()+1); thePainter.drawRect(r); - int x0 = (r.left() + r.right())/2; + //int x0 = (r.left() + r.right())/2; // thePainter.drawLine(x0, r.top(), x0, r.bottom()); const QObjectList* list = myNode->children(); @@ -723,6 +740,11 @@ void SUPERVGUI_CanvasNodePrs::setState(SUPERV::GraphState theState) myStatusColor = red; break; + case SUPERV::LoadingState: + myStatus = "Loading"; + myStatusColor = QColor(56,255,56); + break; + default: myStatus = "No Status"; myStatusColor = MAIN_BACK; @@ -954,7 +976,7 @@ void SUPERVGUI_CanvasHookPrs::init(QCanvas* theCanvas) SUPERVGUI_CanvasHookPrs::~SUPERVGUI_CanvasHookPrs() { hide(); - if (myLine) { + if ( myLine ) { delete myLine; myLine = 0; } @@ -963,9 +985,9 @@ SUPERVGUI_CanvasHookPrs::~SUPERVGUI_CanvasHookPrs() QObject* SUPERVGUI_CanvasHookPrs::getObject() const { QObject* anObj = 0; - if (myNodePrs) + if ( myNodePrs ) anObj = myNodePrs->getNode(); - else if (myPortPrs) + else if ( myPortPrs ) anObj = myPortPrs->getPort(); return anObj; } diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasNodePrs.h b/src/SUPERVGUI/SUPERVGUI_CanvasNodePrs.h index de23786..d8aa906 100644 --- a/src/SUPERVGUI/SUPERVGUI_CanvasNodePrs.h +++ b/src/SUPERVGUI/SUPERVGUI_CanvasNodePrs.h @@ -50,12 +50,18 @@ class SUPERVGUI_CanvasNode; class SUPERVGUI_CanvasNodePrs: public QCanvasPolygonalItem { public: - SUPERVGUI_CanvasNodePrs(QCanvas* theCanvas, SUPERVGUI_CanvasNode* theNode); + SUPERVGUI_CanvasNodePrs(QCanvas* theCanvas, SUPERVGUI_CanvasNode* theNode, bool theCellPrs=false); virtual ~SUPERVGUI_CanvasNodePrs(); SUPERVGUI_CanvasNode* getNode() const { return myNode; } QObject* getObject(const QPoint& thePos) const; + QString getStatus() const { return myStatus; } + QColor getStatusColor() const { return myStatusColor; } + + void setStatus(QString theStatus) { myStatus = theStatus; } + void setStatusColor(QColor theStatusColor) { myStatusColor = theStatusColor; } + virtual int width() const; virtual int height() const; @@ -104,7 +110,7 @@ class SUPERVGUI_CanvasNodePrs: public QCanvasPolygonalItem { protected: void draw(QPainter& thePainter); - void drawShape(QPainter& thePainter); + virtual void drawShape(QPainter& thePainter); virtual void drawTitle(QPainter& thePainter); virtual void drawLabel(QPainter& thePainter); @@ -116,6 +122,8 @@ class SUPERVGUI_CanvasNodePrs: public QCanvasPolygonalItem { virtual void drawTitleShape(QPainter& thePainter); virtual void drawStatusShape(QPainter& thePainter); + bool myPortVisible; + private: SUPERVGUI_CanvasNode* myNode; @@ -129,7 +137,7 @@ class SUPERVGUI_CanvasNodePrs: public QCanvasPolygonalItem { int myGateHeight; bool myLabelVisible; - bool myPortVisible; + bool myCellPrs; bool myMoving; QString myStatus; diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasPort.cxx b/src/SUPERVGUI/SUPERVGUI_CanvasPort.cxx index 91f32e5..198c5ed 100644 --- a/src/SUPERVGUI/SUPERVGUI_CanvasPort.cxx +++ b/src/SUPERVGUI/SUPERVGUI_CanvasPort.cxx @@ -11,6 +11,7 @@ using namespace std; #include "SUPERVGUI_CanvasNode.h" #include "SUPERVGUI_CanvasLink.h" #include "SUPERVGUI_CanvasNodePrs.h" +#include "SUPERVGUI_Clipboard.h" #include "SUPERVGUI_Main.h" #include "SUPERVGUI.h" #include "SUPERVGUI_BrowseNodeDlg.h" @@ -55,7 +56,7 @@ SUPERVGUI_CanvasPortPrs* SUPERVGUI_CanvasPort::createPrs() const QPopupMenu* SUPERVGUI_CanvasPort::getPopupMenu(QWidget* theParent) { QPopupMenu* popup = new QPopupMenu(theParent); - if (myMain->isEditable()) { + if ( myMain->isEditable() && !myMain->getDataflow()->IsExecuting() ) { int anItem = popup->insertItem(tr("MSG_SKETCH_LINK"), this, SLOT(sketchLink())); if (myMain->getDataflow()->IsExecuting()) popup->setItemEnabled(anItem, false); @@ -64,7 +65,7 @@ QPopupMenu* SUPERVGUI_CanvasPort::getPopupMenu(QWidget* theParent) || myPort->Kind() == SUPERV::EndSwitchParameter); popup->insertSeparator(); } - if (myMain->isEditable() + if (myMain->isEditable() && !myMain->getDataflow()->IsExecuting() && ((myPort->IsEndSwitch() && myPort->IsInput()) || @@ -73,8 +74,13 @@ QPopupMenu* SUPERVGUI_CanvasPort::getPopupMenu(QWidget* theParent) !(myPort->Node()->Kind() == SUPERV::LoopNode && !myPort->IsInput())))) { popup->insertItem(tr("ITM_DEL_PORT"), this, SLOT(remove())); } + // Copy Port functionality + if (myMain->isEditable() && !myPort->Node()->IsFactory() + && !myPort->Node()->IsComputing() + && !myPort->Node()->IsMacro()) + popup->insertItem(tr("ITM_COPY_PORT"), this, SLOT(copy())); - int anItem = popup->insertItem(tr("MSG_BROWSE"), this, SLOT(browse())); +//int anItem = popup->insertItem(tr("MSG_BROWSE"), this, SLOT(browse())); // if (getEngine()->IsLinked()) // popup->setItemEnabled(anItem, getEngine()->State() == SUPERV_Ready); // else @@ -111,12 +117,24 @@ void SUPERVGUI_CanvasPort::sync() getPrs()->update(); } -void SUPERVGUI_CanvasPort::sketchLink() -{ +void SUPERVGUI_CanvasPort::sketchLink() { + myMain->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag + myMain->getCanvasView()->startSketch(this); } void SUPERVGUI_CanvasPort::remove() { + myMain->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag + + //set myCopyPort from Main object to empty if engine of this port is deleted + //check if myCopyPort and this port engine is equal + SUPERVGUI_Clipboard* aCB = SUPERVGUI_Clipboard::getClipboard(); + if ( aCB->isCopyPort() ) + if ( QString(myPort->Node()->Name()) == QString(aCB->getCopyPort()->Node()->Name()) && + QString(myPort->Name()) == QString(aCB->getCopyPort()->Name()) && + myPort->IsInput() == aCB->getCopyPort()->IsInput() ) + aCB->setCopyPort( 0 ); + Trace("SUPERVGUI_CanvasPort::remove"); myPort->destroy(); delete this; @@ -161,6 +179,11 @@ void SUPERVGUI_CanvasPort::browse() QMessageBox::information(QAD_Application::getDesktop(), tr("MSG_INFO"), aMes); } +void SUPERVGUI_CanvasPort::copy() +{ + SUPERVGUI_Clipboard* aCB = SUPERVGUI_Clipboard::getClipboard(); + aCB->setCopyPort(SUPERV::Port::_duplicate(getEngine())); +} //*********************************************************** // Input Port @@ -180,7 +203,7 @@ SUPERVGUI_CanvasPortIn::~SUPERVGUI_CanvasPortIn() QPopupMenu* SUPERVGUI_CanvasPortIn::getPopupMenu(QWidget* theParent) { QPopupMenu* popup = SUPERVGUI_CanvasPort::getPopupMenu(theParent); - bool editable = getEngine()->IsInput() && (!getEngine()->IsLinked()); + bool editable = getEngine()->IsInput() && !getEngine()->IsLinked() && !getMain()->getDataflow()->IsExecuting(); if (!getEngine()->IsGate() && editable) popup->insertItem(tr("MSG_SETVALUE"), this, SLOT(setInput())); @@ -198,6 +221,7 @@ void SUPERVGUI_CanvasPortIn::setValue(const char* theValue) void SUPERVGUI_CanvasPortIn::setInput() { + getMain()->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag if (!myDlg) { myDlg = new SUPERVGUI_GetValueDlg(this); myDlg->installEventFilter(this); @@ -209,7 +233,6 @@ void SUPERVGUI_CanvasPortIn::setInput() myDlg->setActiveWindow(); myDlg->setFocus(); } - } bool SUPERVGUI_CanvasPortIn::eventFilter(QObject* o, QEvent* e) diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasPort.h b/src/SUPERVGUI/SUPERVGUI_CanvasPort.h index c7f81a4..0d964ed 100644 --- a/src/SUPERVGUI/SUPERVGUI_CanvasPort.h +++ b/src/SUPERVGUI/SUPERVGUI_CanvasPort.h @@ -46,6 +46,7 @@ class SUPERVGUI_CanvasPort : public QObject { void sketchLink(); virtual void remove(); void browse(); + void copy(); protected: virtual SUPERVGUI_CanvasPortPrs* createPrs() const; diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasView.cxx b/src/SUPERVGUI/SUPERVGUI_CanvasView.cxx index 172d416..e4587d9 100644 --- a/src/SUPERVGUI/SUPERVGUI_CanvasView.cxx +++ b/src/SUPERVGUI/SUPERVGUI_CanvasView.cxx @@ -9,13 +9,17 @@ // Module : SUPERV using namespace std; + #include "SUPERVGUI_CanvasView.h" #include "SUPERVGUI_Main.h" #include "SUPERVGUI_CanvasNode.h" #include "SUPERVGUI_CanvasPort.h" #include "SUPERVGUI_CanvasLink.h" #include "SUPERVGUI_CanvasNodePrs.h" +#include "SUPERVGUI_Clipboard.h" + #include "QAD_Config.h" +#include "QAD_MessageBox.h" #include #include @@ -64,6 +68,7 @@ const char* imageZoomCursor[] = { QPixmap zoomPix(imageZoomCursor); QCursor zoom2Cursor(zoomPix); +QCursor handCursor(Qt::PointingHandCursor); #if QT_VERSION >= 0x030005 QCursor pan2Cursor(Qt::SizeAllCursor); @@ -79,10 +84,12 @@ SUPERVGUI_CanvasView::SUPERVGUI_CanvasView(SUPERVGUI_Canvas* theCanvas, SUPERVGU myIsPanBtnClicked = false; myIsPanActivated = false; + myIsFitWRActivated = false; myIsZoomActivated = false; myIsLinkCreating = false; myAddStudyItem = 0; + mySelectedRect = 0; myCursor = cursor(); myTimer = new QTimer(this); @@ -93,17 +100,19 @@ SUPERVGUI_CanvasView::SUPERVGUI_CanvasView(SUPERVGUI_Canvas* theCanvas, SUPERVGU const bool isEdit = myMain->isEditable(); if (isEdit) { myPopup->insertItem(tr("MSG_ADD_NODE"), myMain, SLOT(addNode())); + + // Paste Node functionality + SUPERVGUI_Clipboard* aCB = SUPERVGUI_Clipboard::getClipboard(); + myPasteNodeItem = myPopup->insertItem(tr("ITM_PASTE_NODE"), aCB, SLOT(pasteNode())); + myPopup->insertItem(tr("MSG_INS_FILE"), myMain, SLOT(insertFile())); myPopup->insertSeparator(); } QPopupMenu* aViewPopup = new QPopupMenu(viewport()); - // aViewPopup->insertItem(tr("POP_FULLVIEW"), myMain, SLOT(showFullGraph())); aViewPopup->insertItem(tr("POP_FULLVIEW"), myMain, SLOT(showCanvas())); aViewPopup->insertItem(tr("POP_CONTROLVIEW"), myMain, SLOT(showContolFlow())); - aViewPopup->insertItem(tr("POP_TABLEVIEW"), myMain, SLOT(showTable())); - // aViewPopup->insertItem("Previous Full View", myMain, SLOT(showFullGraph())); - // aViewPopup->insertItem(tr("POP_CANVASVIEW"), myMain, SLOT(showCanvas())); + aViewPopup->insertItem(tr("POP_TABLEVIEW"), myMain, SLOT(showCanvasTable())); myPopup->insertItem(tr("POP_VIEW"), aViewPopup); myPopup->insertSeparator(); @@ -113,9 +122,13 @@ SUPERVGUI_CanvasView::SUPERVGUI_CanvasView(SUPERVGUI_Canvas* theCanvas, SUPERVGU aZoomPopup->insertItem("100%", this, SLOT(zoomReset())); aZoomPopup->insertItem("50%", this, SLOT(zoomOut())); aZoomPopup->insertSeparator(); - aZoomPopup->insertItem("Fit All", this, SLOT(fitAll())); + //mkr: "Fit within rectangle" functionality + aZoomPopup->insertItem(tr("POP_FITWITHINRECT"), this, SLOT(fitWithinRect())); + aZoomPopup->insertSeparator(); + aZoomPopup->insertItem(tr("POP_FITALL"), this, SLOT(fitAll())); + - myPopup->insertItem("Zoom", aZoomPopup); + myPopup->insertItem(tr("POP_ZOOM"), aZoomPopup); myPopup->insertSeparator(); myAddStudyItem = myPopup->insertItem(tr("MSG_ADD_STUDY"), this, SLOT(addToStudy())); @@ -145,7 +158,6 @@ SUPERVGUI_CanvasView::~SUPERVGUI_CanvasView() void SUPERVGUI_CanvasView::contentsMousePressEvent(QMouseEvent* theEvent) { - // MESSAGE("===> SUPERVGUI_CanvasView::contentsMousePressEvent(...) "); myPoint = inverseWorldMatrix().map(theEvent->pos()); myGlobalPoint = theEvent->globalPos(); myCurrentItem = 0; @@ -210,45 +222,50 @@ void SUPERVGUI_CanvasView::contentsMousePressEvent(QMouseEvent* theEvent) } myPopup->setItemEnabled(myAddStudyItem, !myMain->isFromStudy()); + // Paste Node functionality + SUPERVGUI_Clipboard* aCB = SUPERVGUI_Clipboard::getClipboard(); + myPopup->setItemEnabled(myPasteNodeItem, aCB->isCopyNode() ); myMain->showPopup(myPopup, theEvent); return; } if (theEvent->button() == Qt::LeftButton) { - QCanvasItemList l = canvas()->collisions(myPoint); - if (myIsLinkCreating) { - for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) { - if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_Node) { - SUPERVGUI_CanvasNodePrs* aNodePrs = (SUPERVGUI_CanvasNodePrs*) (*it); - QObject* anObj = aNodePrs->getObject(myPoint); - if (anObj->inherits("SUPERVGUI_CanvasPort")) { - endSketch((SUPERVGUI_CanvasPort*)anObj); - return; + if (!myIsFitWRActivated) {//not moving items if fit within rectangle + //functionality is enable + QCanvasItemList l = canvas()->collisions(myPoint); + if (myIsLinkCreating) { + for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) { + if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_Node) { + SUPERVGUI_CanvasNodePrs* aNodePrs = (SUPERVGUI_CanvasNodePrs*) (*it); + QObject* anObj = aNodePrs->getObject(myPoint); + if (anObj->inherits("SUPERVGUI_CanvasPort")) { + endSketch((SUPERVGUI_CanvasPort*)anObj); + return; + } + else { + myCurrentItem = *it; + ((SUPERVGUI_CanvasNodePrs*)myCurrentItem)->setZ(2); + ((SUPERVGUI_CanvasNodePrs*)myCurrentItem)->setMoving(true); + return; + } } - else { - myCurrentItem = *it; - ((SUPERVGUI_CanvasNodePrs*)myCurrentItem)->setZ(2); - ((SUPERVGUI_CanvasNodePrs*)myCurrentItem)->setMoving(true); - return; + if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_Hook) { + SUPERVGUI_CanvasHookPrs* aHookPrs = (SUPERVGUI_CanvasHookPrs*) (*it); + QObject* anObj = aHookPrs->getObject(); + if (anObj->inherits("SUPERVGUI_CanvasPort")) { + endSketch((SUPERVGUI_CanvasPort*)anObj); + return; + } } } - if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_Hook) { - SUPERVGUI_CanvasHookPrs* aHookPrs = (SUPERVGUI_CanvasHookPrs*) (*it); - QObject* anObj = aHookPrs->getObject(); - if (anObj->inherits("SUPERVGUI_CanvasPort")) { - endSketch((SUPERVGUI_CanvasPort*)anObj); - return; - } + if (myLinkBuilder) { + myLinkBuilder->addNextPoint(myPoint, mySketchPopup->isItemChecked(myOrtoItem)); + canvas()->update(); + mySketchPopup->setItemEnabled(myDelPntItem, true); + return; } } - if (myLinkBuilder) { - myLinkBuilder->addNextPoint(myPoint, mySketchPopup->isItemChecked(myOrtoItem)); - canvas()->update(); - mySketchPopup->setItemEnabled(myDelPntItem, true); - return; - } - } - + // if (myMain->isEditable()) { // allow to move nodes and link point on imported graph for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it) { if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_Node) { @@ -265,8 +282,25 @@ void SUPERVGUI_CanvasView::contentsMousePressEvent(QMouseEvent* theEvent) return; } } + if ((*it)->rtti() == SUPERVGUI_Canvas::Rtti_LinkEdge) { + //mkr: for moving segment of link + SUPERVGUI_CanvasEdgePrs* aPrs = (SUPERVGUI_CanvasEdgePrs*) (*it); + if (aPrs->getLink()->getInputPort()->getConnectionPoint() == aPrs->startPoint() + || + aPrs->getLink()->getInputPort()->getConnectionPoint() == aPrs->endPoint() + || + aPrs->getLink()->getOutputPort()->getConnectionPoint() == aPrs->startPoint() + || + aPrs->getLink()->getOutputPort()->getConnectionPoint() == aPrs->endPoint()) { + return; + } + myCurrentItem = *it; + aPrs->setMoving(true); + return; + } } // } + } } } @@ -289,10 +323,13 @@ void SUPERVGUI_CanvasView::contentsMouseMoveEvent(QMouseEvent* theEvent) if (myCurrentItem) { // setHilighted(0); - double cx = myCurrentItem->x() - myPoint.x(); - double cy = myCurrentItem->y() - myPoint.y(); - if (p.x()+cx < 0) p.setX(-(int)cx); - if (p.y()+cy < 0) p.setY(-(int)cy); + if (myCurrentItem->x() && myCurrentItem->y()) { + double cx = myCurrentItem->x() - myPoint.x(); + double cy = myCurrentItem->y() - myPoint.y(); + + if (p.x()+cx < 0) p.setX(-(int)cx); + if (p.y()+cy < 0) p.setY(-(int)cy); + } myCurrentItem->moveBy(p.x() - myPoint.x(), p.y() - myPoint.y()); myPoint = p; @@ -339,6 +376,30 @@ void SUPERVGUI_CanvasView::contentsMouseMoveEvent(QMouseEvent* theEvent) return; } + //mkr: "Fit within rectangle" functionality + if (myIsFitWRActivated) { + int aLX, aTY; //left x and top y + if (myPoint.x() < p.x()) aLX = myPoint.x(); + else aLX = p.x(); + if (myPoint.y() < p.y()) aTY = myPoint.y(); + else aTY = p.y(); + QRect aRect(aLX, aTY, abs(myPoint.x()-p.x()), abs(myPoint.y()-p.y())); + QCanvasRectangle* aRect1 = new QCanvasRectangle(aRect, canvas()); + + //hide old selected rectangle + if (mySelectedRect) + mySelectedRect->hide(); + //draw new selected rectangle + QPen pen(Qt::SolidLine); + pen.setWidth(1); + aRect1->setPen(pen); + aRect1->setZ(3); + aRect1->show(); + + mySelectedRect = aRect1; + canvas()->update(); + } + if (!myIsLinkCreating && myMain->isEditable() && !myMain->getCanvas()->isControlView()) { // compute collision rectangle @@ -366,7 +427,6 @@ void SUPERVGUI_CanvasView::contentsMouseMoveEvent(QMouseEvent* theEvent) void SUPERVGUI_CanvasView::contentsMouseReleaseEvent(QMouseEvent* theEvent) { - // MESSAGE("===> SUPERVGUI_CanvasView::contentsMouseReleaseEvent(...) "); if (myTimer->isActive()) myTimer->stop(); if (myCurrentItem) { @@ -391,15 +451,47 @@ void SUPERVGUI_CanvasView::contentsMouseReleaseEvent(QMouseEvent* theEvent) myIsZoomActivated = false; setCursor(myCursor); } + + //mkr: "Fit within rectangle" functionality + if (myIsFitWRActivated) { + if (mySelectedRect) { + mySelectedRect->hide(); + mySelectedRect = 0; + canvas()->update(); + } + + //myPoint is the start point for selecting rectangle now + QPoint anEndPoint = inverseWorldMatrix().map(theEvent->pos()); + int aLX, aTY; //left x and top y + if (myPoint.x() < anEndPoint.x()) aLX = myPoint.x(); + else aLX = anEndPoint.x(); + if (myPoint.y() < anEndPoint.y()) aTY = myPoint.y(); + else aTY = anEndPoint.y(); + + //calculate width and height for new view and new zoom factor + double aXzoom = ((double)visibleWidth())/((double)(abs(myPoint.x()-anEndPoint.x()))); + double aYzoom = ((double)visibleHeight())/((double)(abs(myPoint.y()-anEndPoint.y()))); + if (aXzoom > aYzoom) aXzoom = aYzoom; + + QWMatrix m; + m.scale(aXzoom, aXzoom); + setWorldMatrix(m); + setContentsPos((int)(aLX*aXzoom), (int)(aTY*aYzoom)); + + canvas()->update(); + + myIsFitWRActivated = false; + viewport()->setMouseTracking(true); + setCursor(myCursor); + } } void SUPERVGUI_CanvasView::contentsMouseDoubleClickEvent(QMouseEvent* theEvent) { - // MESSAGE("===> SUPERVGUI_CanvasView::contentsMouseDoubleClickEvent(...) "); QPoint p = inverseWorldMatrix().map(theEvent->pos()); // compute collision rectangle - QRect aSel(p.x()-MARGIN, p.y()-MARGIN, 1+2*MARGIN, 1+2*MARGIN); + //QRect aSel(p.x()-MARGIN, p.y()-MARGIN, 1+2*MARGIN, 1+2*MARGIN); if (theEvent->button() == Qt::LeftButton) { QCanvasItemList l = canvas()->collisions(p); @@ -485,7 +577,6 @@ void SUPERVGUI_CanvasView::startSketch(SUPERVGUI_CanvasPort* thePort) void SUPERVGUI_CanvasView::endSketch(SUPERVGUI_CanvasPort* thePort) { - // MESSAGE("===> SUPERVGUI_CanvasView::endSketch(" << thePort->name() << ")"); if (!myIsLinkCreating) return; if (myLinkBuilder && myLinkBuilder->canCreateEngine(thePort)) { @@ -510,7 +601,43 @@ void SUPERVGUI_CanvasView::endSketch(SUPERVGUI_CanvasPort* thePort) SUPERVGUI_CanvasPort* aOutPort = (input ? myLinkBuilder->getStartPort() : thePort); aLinkEngine = myMain->getDataflow()->Link(aOutPort->getEngine(), aInPort->getEngine()); } - if (SUPERV_isNull(aLinkEngine)) return; + if (SUPERV_isNull(aLinkEngine)) + return; + + // here, in fact, aLinkEngine may NOT be a newly created link. If a link already existed between the + // the 2 given ports - it will be return (NOT created again). + // this should be checked and new presentation should NOT be created for existing link. + // Solution 1: NOT to allow creation of a link if it already exists between the ports in + // myLinkBuilder->canCreateEngine() + // Solution 2: check here if aLinkEngine is "new" or "old" + // Implement 2nd solution, because canCreateEngine() checks for types of ports, etc.. - it's another thing + // THE CHECK: + QObjectList* canvasLinks = canvas()->queryList("SUPERVGUI_CanvasLink"); + SUPERVGUI_CanvasLink* canvasLink = 0; + QObjectListIt it(*canvasLinks); + bool prsAlreadyExists = false; + while ( (canvasLink=(SUPERVGUI_CanvasLink*)it.current()) ) { + ++it; + SUPERV_Link existingLinkWithPrs = canvasLink->getEngine(); + if ( !SUPERV_isNull( existingLinkWithPrs ) ) { + if ( existingLinkWithPrs->IsEqual( aLinkEngine ) ) { + prsAlreadyExists = true; + break; + } + } + } + delete canvasLinks; + if ( prsAlreadyExists ) { // aLinkEngine is already bound with a SUPERVGUI_CanvasLink object + //return; // -> if return here, than the old CanvasLink is kept + + // we want to delete old and create a new CanvasLink for this Link + delete canvasLink; + canvasLink = 0; + // clear old corrdinates in Engine link + for ( int i = 1; i <= aLinkEngine->CoordsSize(); i++ ) + aLinkEngine->RemoveCoord( i ); + // now we are ready to set coords for a link and create a new CanvasLink presentation that will use them. + } myLinkBuilder->setCoords(aLinkEngine.in()); @@ -522,6 +649,15 @@ void SUPERVGUI_CanvasView::endSketch(SUPERVGUI_CanvasPort* thePort) canvas()->update(); myIsLinkCreating = false; + + // asv : 13.12.04 : introducing a check for ports' types compatibility (Bugs and Improvements p.1.16, PAL7380) + if ( !aLinkEngine->IsValid() ) { + const int id = QAD_MessageBox::warn2( this, tr( "TLT_INVALID_LINK" ), tr( "MSG_INVALID_LINK" ), + tr( "Keep" ), tr( "Remove" ), 0, 1, 0 ); + if ( id == 1 ) { // "Remove" was selected in Message Box + aLink->remove(); // the new link did not live long... + } + } } } @@ -600,3 +736,12 @@ void SUPERVGUI_CanvasView::fitAll() setWorldMatrix(m); canvas()->update(); } + +void SUPERVGUI_CanvasView::fitWithinRect() +{ + //mkr: "Fit within rectangle" functionality + myIsFitWRActivated = true; + viewport()->setMouseTracking(false); + myCursor = cursor(); + setCursor(handCursor); +} diff --git a/src/SUPERVGUI/SUPERVGUI_CanvasView.h b/src/SUPERVGUI/SUPERVGUI_CanvasView.h index 564e28a..52b5b5f 100644 --- a/src/SUPERVGUI/SUPERVGUI_CanvasView.h +++ b/src/SUPERVGUI/SUPERVGUI_CanvasView.h @@ -44,6 +44,7 @@ class SUPERVGUI_CanvasView: public QCanvasView { void zoomOut(); void zoomReset(); void fitAll(); + void fitWithinRect(); void changeBackground(); protected: @@ -66,18 +67,21 @@ class SUPERVGUI_CanvasView: public QCanvasView { SUPERVGUI_Main* myMain; QPopupMenu* myPopup; int myAddStudyItem; + int myPasteNodeItem; QPopupMenu* mySketchPopup; int myDelPntItem; int myOrtoItem; bool myIsPanBtnClicked; bool myIsPanActivated; + bool myIsFitWRActivated; bool myIsZoomActivated; bool myIsLinkCreating; - QCanvasItem* myCurrentItem; - QPoint myPoint; - QCursor myCursor; + QCanvasItem* myCurrentItem; + QPoint myPoint; + QCanvasRectangle* mySelectedRect; + QCursor myCursor; QTimer* myTimer; QPoint myGlobalPoint; diff --git a/src/SUPERVGUI/SUPERVGUI_Clipboard.cxx b/src/SUPERVGUI/SUPERVGUI_Clipboard.cxx new file mode 100644 index 0000000..d286581 --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_Clipboard.cxx @@ -0,0 +1,390 @@ +// SUPERV SUPERVGUI : GUI for Supervisor component +// +// 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 +// +// +// +// File : SUPERVGUI_Clipboard.cxx +// Author : Alexander SLADKOV +// Module : SUPERV + + +#include "SUPERVGUI_Clipboard.h" +#include "SUPERVGUI_CanvasNode.h" +#include "SUPERVGUI.h" + + +SUPERVGUI_Clipboard* SUPERVGUI_Clipboard::myCB = 0; + + +/** + * Compute the next valid name for a Python function (add "_N" if a function with given name already exists) + */ +QString getNewName( QStringList& allNames, const QString& oldName ) { + QString newName; + int id = 1; //increment index + newName = oldName + QString("_") + QString::number( id ); + while ( allNames.contains( newName ) ) + newName = oldName + QString("_") + QString::number( ++id ); + + return newName; +} + +/** + * Replaces origName string with newName string in all lines of theFunc + * origName must be preceeded by space and end by space or '('. + * asv : 14.01.05 : fix of a bug (exception on node creation): + * if origName and theFunc is null, return non-null empty strings! + */ +void replaceName( SUPERV::ListOfStrings_var& theFunc, const QString& origName, const QString& newName ) { + for ( int i = 0, n = theFunc->length(); i < n; i++ ) { + QString aLine( theFunc[i] ); + int index = aLine.find( origName, 0 ); // find FIRST occurance of origName in aLine + while ( index >= 0 ) { + bool preceedingCharOk = ( index==0 || ( index > 0 && aLine[index-1].isSpace() ) ); + const int ll = aLine.length(); + const int ol = origName.length(); + const int ni = index + ol; + bool nextCharOk = ( ll==ni || ( ll>ni && ( aLine[ni].isSpace() || aLine[ni]=='(' ) ) ); + if ( preceedingCharOk && nextCharOk ) { + aLine = aLine.replace( index, origName.length(), newName ); + theFunc[i] = aLine.latin1(); + } + index = aLine.find( origName, index+newName.length() ); // find NEXT occurance of origName in aLine + } + } +} + +/** + * "Copies" all ports from fromNode to toNode: creates the sames ports in toNode in fact + */ +void copyPorts( const SUPERV::CNode_var& fromNode, const SUPERV::INode_var& toNode ) { + if ( CORBA::is_nil( fromNode ) || CORBA::is_nil( toNode ) ) + return; + SUPERV::ListOfPorts_var aPList = fromNode->Ports(); + QString aName, aType; + for (int i = 0; i < aPList->length(); i++) { + aName = aPList[i].in()->Name(); + aType = aPList[i].in()->Type(); + if ( aPList[i].in()->IsInput() ) + toNode->InPort( aName.latin1(), aType.latin1() ); + else + toNode->OutPort( aName.latin1(), aType.latin1() ); + } +} + +/** + * Constructor + */ +SUPERVGUI_Clipboard::SUPERVGUI_Clipboard( QObject* parent ) +: QObject( parent ) { +} + +/** + * Destructor + */ +SUPERVGUI_Clipboard::~SUPERVGUI_Clipboard() { +} + +/** + * Returns all inline functions defined in inline (switch, loop, goto) nodes of given dataflow + */ +QStringList getAllFunctions( SUPERV::Graph_var dataflow ) { + QStringList aFuncNames; + if ( !CORBA::is_nil( dataflow ) ) { + SUPERV::ListOfNodes_var nodes = dataflow->Nodes(); + //InLine nodes + for(int i = 0; i < nodes->INodes.length(); i++) + aFuncNames.append(nodes->INodes[i]->PyFuncName()); + //Loop nodes + for(int i = 0; i < nodes->LNodes.length(); i++) { + aFuncNames.append(nodes->LNodes[i]->PyInitName()); + aFuncNames.append(nodes->LNodes[i]->PyMoreName()); + aFuncNames.append(nodes->LNodes[i]->PyNextName()); + } + //Switch nodes + for(int i = 0; i < nodes->SNodes.length(); i++) + aFuncNames.append(nodes->SNodes[i]->PyFuncName()); + //GOTO nodes + for(int i = 0; i < nodes->GNodes.length(); i++) + aFuncNames.append(nodes->GNodes[i]->PyFuncName()); + } + return aFuncNames; +} + +/** + * Called on Paste Node command. Inserts a new node to the dataflow equal to the copied node. + * For InLine nodes the Python function name is changed ("_N" added). + */ +void SUPERVGUI_Clipboard::pasteNode() { + Trace("SUPERVGUI_Main::pasteNode"); + SUPERV::CNode_var aNode = getCopyNode(); + if ( !CORBA::is_nil( aNode ) ) { + + SUPERV::Graph_var dataflow = Supervision.getMain()->getDataflow(); + + switch ( aNode->Kind() ) { + + case SUPERV::FactoryNode : + { + SUPERV::FNode_var aFNode = dataflow->FNode( SUPERV::FNode::_narrow(aNode)->GetComponentName(), + SUPERV::FNode::_narrow(aNode)->GetInterfaceName(), + *SUPERV::FNode::_narrow(aNode)->Service() ); + if (CORBA::is_nil(aFNode)) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_CREATE_NODE")); + return; + } + + SUPERV::INode_var aDummyEndNode; + Supervision.getBrowser()->addNode(SUPERV::CNode::_narrow(aFNode), aDummyEndNode, myXCopyNode, myYCopyNode); + } + break; + + case SUPERV::ComputingNode : + { + SUPERV::CNode_var aCNode = dataflow->CNode(*SUPERV::CNode::_narrow(aNode)->Service()); + if (CORBA::is_nil(aCNode)) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_CREATE_NODE")); + return; + } + + SUPERV::INode_var aDummyEndNode; + Supervision.getBrowser()->addNode(aCNode, aDummyEndNode, myXCopyNode, myYCopyNode); + } + break; + + case SUPERV::InLineNode : + { + QString aFName; // new node's Py_function name + SUPERV::ListOfStrings_var aFunc; // new node's Py_function body + + // Automatic change of Py_function name ( + "_1", etc.) + // 1. collect all python functions names of allready exist InLine nodes + QStringList aFuncNames = getAllFunctions( dataflow ); + // 2. "fix" Main function_name and Main function_strings + QString aOriginalName = SUPERV::INode::_narrow(aNode)->PyFuncName(); + if ( !aOriginalName.isEmpty() ) { + aFName = getNewName( aFuncNames, aOriginalName ); + aFunc = SUPERV::INode::_narrow(aNode)->PyFunction(); + replaceName( aFunc, aOriginalName, aFName ); + } + else { // empty function name and body + aFName = QString( "" ); + aFunc = new SUPERV::ListOfStrings(); + } + + // create the Engine's node + SUPERV::INode_var aINode = dataflow->INode( aFName, aFunc ); + + if (CORBA::is_nil(aINode)) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_CREATE_NODE")); + return; + } + copyPorts( aNode, aINode ); + + SUPERV::INode_var aDummyEndNode; + Supervision.getBrowser()->addNode(SUPERV::CNode::_narrow(aINode), aDummyEndNode, myXCopyNode, myYCopyNode); + } + break; + + case SUPERV::LoopNode : + { + QString aInitFName, aMoreFName, aNextFName; // new node's Py_functions names + SUPERV::ListOfStrings_var aInitFunc, aMoreFunc, aNextFunc; // new node's Py_functions bodies + + // Automatic change of Py_function name ( + "_1", etc.) + // 1. collect all python functions names of allready exist InLine nodes + QStringList aFuncNames = getAllFunctions( dataflow ); + // 2.1 "fix" Init function_name and Init function_strings + QString aOriginalName = SUPERV::LNode::_narrow(aNode)->PyInitName(); + if (!aOriginalName.isEmpty()) { + aInitFName = getNewName( aFuncNames, aOriginalName ); + aInitFunc = SUPERV::LNode::_narrow(aNode)->PyInit(); + replaceName( aInitFunc, aOriginalName, aInitFName ); + } + else { // empty function name and body + aInitFName = QString( "" ); + aInitFunc = new SUPERV::ListOfStrings(); + } + // 2.2 "fix" More function_name and More function_strings + aOriginalName = SUPERV::LNode::_narrow(aNode)->PyMoreName(); + if (!aOriginalName.isEmpty()) { + aMoreFName = getNewName( aFuncNames, aOriginalName ); + aMoreFunc = SUPERV::LNode::_narrow(aNode)->PyMore(); + replaceName( aMoreFunc, aOriginalName, aMoreFName ); + } + else { // empty function name and body + aMoreFName = QString( "" ); + aMoreFunc = new SUPERV::ListOfStrings(); + } + // 2.3 "fix" Next function_name and Next function_strings + aOriginalName = SUPERV::LNode::_narrow(aNode)->PyNextName(); + if (!aOriginalName.isEmpty()) { + aNextFName = getNewName( aFuncNames, aOriginalName ); + aNextFunc = SUPERV::LNode::_narrow(aNode)->PyNext(); + replaceName( aNextFunc, aOriginalName, aNextFName ); + } + else { // empty function name and body + aNextFName = QString( "" ); + aNextFunc = new SUPERV::ListOfStrings(); + } + + // create the Engine's node + SUPERV::INode_var aEndNode; + SUPERV::LNode_var aStartNode = dataflow->LNode(aInitFName, aInitFunc, aMoreFName, aMoreFunc, aNextFName, aNextFunc, aEndNode); + if (CORBA::is_nil(aStartNode) || CORBA::is_nil(aEndNode)) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_CREATE_NODE")); + return; + } + copyPorts( aNode, SUPERV::INode::_narrow( aStartNode ) ); + + Supervision.getBrowser()->addNode(SUPERV::CNode::_narrow(aStartNode), aEndNode, myXCopyNode, myYCopyNode); + } + break; + + case SUPERV::SwitchNode : + { + QString aFName; // new node's Py_function name + SUPERV::ListOfStrings_var aFunc; // new node's Py_function body + + // Automatic change of Py_function name ( + "_1", etc.) + // 1. collect all python functions names of allready exist InLine nodes + QStringList aFuncNames = getAllFunctions( dataflow ); + // 2. "fix" Main function_name and Main function_strings + QString aOriginalName = SUPERV::INode::_narrow(aNode)->PyFuncName(); + if ( !aOriginalName.isEmpty() ) { + aFName = getNewName( aFuncNames, aOriginalName ); + aFunc = SUPERV::INode::_narrow(aNode)->PyFunction(); + replaceName( aFunc, aOriginalName, aFName ); + } + else { // empty function name and body + aFName = QString( "" ); + aFunc = new SUPERV::ListOfStrings(); + } + + // create the Engine's node + SUPERV::INode_var aEndNode; + SUPERV::SNode_var aStartNode = dataflow->SNode(aFName, aFunc, aEndNode); + if (CORBA::is_nil(aStartNode) || CORBA::is_nil(aEndNode)) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_CREATE_NODE")); + return; + } + copyPorts( aNode, SUPERV::INode::_narrow( aStartNode ) ); + SUPERV::INode_var aNodeEnd = SUPERV::SNode::_narrow(aNode)->Coupled(); + copyPorts( SUPERV::CNode::_narrow( aNodeEnd ), aEndNode ); + + Supervision.getBrowser()->addNode(SUPERV::CNode::_narrow(aStartNode), aEndNode, myXCopyNode, myYCopyNode); + } + break; + + case SUPERV::GOTONode : + { + QString aFName; // new node's Py_function name + SUPERV::ListOfStrings_var aFunc; // new node's Py_function body + + // Automatic change of Py_function name ( + "_1", etc.) + // 1. collect all python functions names of allready exist InLine nodes + QStringList aFuncNames = getAllFunctions( dataflow ); + // 2. "fix" Main function_name and Main function_strings + QString aOriginalName = SUPERV::INode::_narrow(aNode)->PyFuncName(); + if ( !aOriginalName.isEmpty() ) { + aFName = getNewName( aFuncNames, aOriginalName ); + aFunc = SUPERV::INode::_narrow(aNode)->PyFunction(); + replaceName( aFunc, aOriginalName, aFName ); + } + else { // empty function name and body + aFName = QString( "" ); + aFunc = new SUPERV::ListOfStrings(); + } + + // create the Engine's node + SUPERV::GNode_var aGNode = dataflow->GNode(aFName, aFunc, ""); + if (CORBA::is_nil(aGNode)) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_CREATE_NODE")); + return; + } + copyPorts( aNode, SUPERV::INode::_narrow( aGNode ) ); + + SUPERV::INode_var aDummyEndNode; + Supervision.getBrowser()->addNode(SUPERV::CNode::_narrow(aGNode), aDummyEndNode, myXCopyNode, myYCopyNode); + } + break; + + case SUPERV::MacroNode : + { + /* to implement in the future */ + /* + //get SubGraph from MacroNode + SUPERV::Graph_var aMacro = SUPERV::Graph::_narrow(aNode); + SUPERV::Graph_var aGraph; + if (aMacro->IsStreamMacro()) + aGraph = aMacro->StreamObjRef(); + else + aGraph = aMacro->FlowObjRef(); + SUPERV::Graph_var aMacroNode = dataflow->GraphMNode(aGraph); + + if (CORBA::is_nil(aMacroNode)) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_CREATE_NODE")); + return; + } + + SUPERV::INode_var aDummyEndNode; + Supervision.getBrowser()->addNode(SUPERV::CNode::_narrow(aMacroNode), aDummyEndNode, myXCopyNode, myYCopyNode); + */ + } + break; + } + } +} + + +/** + * Called from CanvasNode on "Paste port" command of popup menu + */ +void SUPERVGUI_Clipboard::pastePort( SUPERVGUI_CanvasNode* node ) +{ + SUPERV::Port_var aPort = getCopyPort(); + if ( !CORBA::is_nil(aPort) ) { + SUPERV::INode_var aNode = node->getInlineNode(); + if (!CORBA::is_nil(aNode)) { + QString aName = aPort->Name(); + QString aType = aPort->Type(); + SUPERV::Port_var aPastePort; + if (aPort->IsInput()) { + //check if port with such name is alredy exists + QStringList aNames = node->getPortsNamesIN(aNode, true); + if (aNames.contains(aName)) + QMessageBox::warning( QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_PORT_EXIST") ); + else + aPastePort = aNode->InPort(aName.latin1(), aType.latin1()); + } + else { + //check if port with such name is already exists + QStringList aNames = node->getPortsNamesIN(aNode, false); + if (aNames.contains(aName)) + QMessageBox::warning( QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_PORT_EXIST") ); + else + aPastePort = aNode->OutPort(aName.latin1(), aType.latin1()); + } + if ( !CORBA::is_nil(aPastePort) ) + node->createPort( aPastePort.in() ); + } + } +} diff --git a/src/SUPERVGUI/SUPERVGUI_Clipboard.h b/src/SUPERVGUI/SUPERVGUI_Clipboard.h new file mode 100644 index 0000000..4ac5d8c --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_Clipboard.h @@ -0,0 +1,79 @@ +// SUPERV SUPERVGUI : GUI for Supervisor component +// +// 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 +// +// +// +// File : SUPERVGUI_Clipboard.h +// Author : Alexander SLADKOV +// Module : SUPERV + +#ifndef SUPERVGUI_Clipboard_H +#define SUPERVGUI_Clipboard_H + +#include + +#include "utilities.h" +#include "SALOME_LifeCycleCORBA.hxx" +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include CORBA_CLIENT_HEADER(SUPERV) + +class SUPERVGUI_CanvasNode; + +class SUPERVGUI_Clipboard : public QObject { + +Q_OBJECT + +protected: + // constructor made protected. Access via getClipboard() member function. + SUPERVGUI_Clipboard( QObject* parent ); + virtual ~SUPERVGUI_Clipboard(); + +public: + + static SUPERVGUI_Clipboard* getClipboard() { + if ( !myCB ) + myCB = new SUPERVGUI_Clipboard( QAD_Application::getDesktop() ); + return myCB; + } + + bool isCopyPort() const { return ( myCopyPort && !CORBA::is_nil( myCopyPort ) ); } + SUPERV::Port_var getCopyPort() const { return myCopyPort; } + void setCopyPort( SUPERV::Port_var theObj ) { myCopyPort = theObj; } + + bool isCopyNode() const { return ( myCopyNode && !CORBA::is_nil( myCopyNode ) ); } + SUPERV::CNode_var getCopyNode() const { return myCopyNode; } + void setCopyNode( SUPERV::CNode_var theObj ) { myCopyNode = theObj; } + +public slots: + void pasteNode(); + void pastePort( SUPERVGUI_CanvasNode* node ); + +private: + static SUPERVGUI_Clipboard* myCB; + + SUPERV::Port_var myCopyPort; + SUPERV::CNode_var myCopyNode; + int myXCopyNode; + int myYCopyNode; +}; + +#endif diff --git a/src/SUPERVGUI/SUPERVGUI_ComputeNode.cxx b/src/SUPERVGUI/SUPERVGUI_ComputeNode.cxx deleted file mode 100644 index 38fa828..0000000 --- a/src/SUPERVGUI/SUPERVGUI_ComputeNode.cxx +++ /dev/null @@ -1,157 +0,0 @@ -// SUPERV SUPERVGUI : GUI for Supervisor component -// -// Copyright (C) 2003 CEA/DEN, EDF R&D -// -// -// -// File : SUPERVGUI_ComputeNode.cxx -// Author : Vitaly SMETANNIKOV -// Module : SUPERV - -using namespace std; -#include "SUPERVGUI_ComputeNode.h" -#include "SUPERVGUI_Main.h" -#include -#include - - -SUPERVGUI_ComputeNode::SUPERVGUI_ComputeNode(QWidget* theParent, SUPERVGUI_Main* theMain, SUPERV_CNode theNode) -:SUPERVGUI_GraphNode(theParent, theMain, theNode) -{ - setLineWidth(2); - setFrameStyle(QFrame::Panel | QFrame::Raised); - - QGridLayout* aGridLayout = new QGridLayout(this, 0, 2, 3, 1); - - myTitle->setPaletteBackgroundColor(QColor(63, 213, 255)); - myTitle->reparent(this, pos()); - aGridLayout->addMultiCellWidget(myTitle, 0, 0, 0, 1); - - QString aComment(theNode->Comment()); - - QString aCommentVis = aComment; - if (getNodeType() == SUPERV::FactoryNode) - aCommentVis = QString(myNode->Service()->ServiceName) + QString(tr("COMMENT_FROM")) - + QString(getFactoryNode()->GetComponentName()); - else - //aCommentVis = tr("COMMENT_PYTHON"); - aCommentVis = tr("COMMENT_CNODE"); - - if (aComment.isNull() || aComment.isEmpty()) { - theNode->SetComment(aCommentVis.latin1()); - } - - myServiceBox = new QVBox(this, "service"); - myComment = new SUPERVGUI_Label(myServiceBox, LABEL_WIDTH, LABEL_HEIGHT, aCommentVis, QLabel::AlignLeft); - connect(myComment, SIGNAL(MousePress(QMouseEvent*)), this, SLOT(showPopup(QMouseEvent*))); - QToolTip::add(myTitle, myTitle->text()); - QToolTip::add(myComment, myComment->text()); - aGridLayout->addMultiCellWidget(myServiceBox, 1, 1, 0, 1); - - myStatus->reparent(this, pos()); - myTime->reparent(this, pos()); - aGridLayout->addWidget(myStatus, 2, 0); - aGridLayout->addWidget(myTime, 2, 1); - - myPortsBox->reparent(this, pos()); - - aGridLayout->addMultiCellWidget(myPortsBox, 3, 3, 0, 1); - adjustSize(); - - myShowPopup = new QPopupMenu(this); - myServiceItem = myShowPopup->insertItem(tr("POP_SHOWTITLES"), this, SLOT(switchService())); - myPortsItem = myShowPopup->insertItem(tr("POP_SHOWPORTS"), this, SLOT(switchPorts())); - - myPopup->insertSeparator(); - myPopup->insertItem(tr("POP_SHOW"), myShowPopup); - myShowPopup->setItemChecked(myServiceItem, true); - myShowPopup->setItemChecked(myPortsItem, true); - - show(); -} - - -SUPERVGUI_ComputeNode::~SUPERVGUI_ComputeNode() { - QToolTip::remove(myTitle); - QToolTip::remove(myComment); -} - - -void SUPERVGUI_ComputeNode::sync() -{ - Trace("SUPERVGUI_Node::sync"); - setName(myNode->Name()); - myTitle->setText(name()); - - //myComment->setText(myNode->Comment()); - - bool editing = myMain->getDataflow()->IsEditing(); - myPopup->setItemEnabled(myKillItem, !editing); - if (myMain->isEditable()) { - myPopup->setItemEnabled(myRenameItem, editing); - myPopup->setItemEnabled(myDeleteItem, editing); - } - SUPERVGUI_GraphNode::sync(); -} - - - -/** - * Hides services info and ports - */ -void SUPERVGUI_ComputeNode::hideAll() { - myServiceBox->hide(); - myShowPopup->setItemChecked(myServiceItem, false); - myPortsBox->hide(); - myShowPopup->setItemChecked(myPortsItem, false); - - updateShape(); -} - - -/** - * Shows services info and ports - */ -void SUPERVGUI_ComputeNode::showAll() { - myServiceBox->show(); - myShowPopup->setItemChecked(myServiceItem, true); - myPortsBox->show(); - myShowPopup->setItemChecked(myPortsItem, true); - - updateShape(); -} - - -/** - * Switches visibility of Service names in the node - */ -void SUPERVGUI_ComputeNode::switchService() { - bool aIsVisible = myServiceBox->isVisible(); - if (aIsVisible) myServiceBox->hide(); - else myServiceBox->show(); - updateShape(); - myShowPopup->setItemChecked(myServiceItem, !aIsVisible); -} - - -/** - * Switches visibility of Ports in the node - */ -void SUPERVGUI_ComputeNode::switchPorts() { - bool aIsVisible = myPortsBox->isVisible(); - if (aIsVisible) myPortsBox->hide(); - else myPortsBox->show(); - updateShape(); - myShowPopup->setItemChecked(myPortsItem, !aIsVisible); -} - -void SUPERVGUI_ComputeNode::rename() { - SUPERVGUI_Node::rename(); - // QToolTip::remove(myTitle); - QToolTip::add(myTitle, myTitle->text()); -} - -void SUPERVGUI_ComputeNode::updateShape() { - qApp->processEvents(); - adjustSize(); -} diff --git a/src/SUPERVGUI/SUPERVGUI_ComputeNode.h b/src/SUPERVGUI/SUPERVGUI_ComputeNode.h deleted file mode 100644 index 04f6887..0000000 --- a/src/SUPERVGUI/SUPERVGUI_ComputeNode.h +++ /dev/null @@ -1,51 +0,0 @@ -// SUPERV SUPERVGUI : GUI for Supervisor component -// -// Copyright (C) 2003 CEA/DEN, EDF R&D -// -// -// -// File : SUPERVGUI_ComputeNode.h -// Author : Vitaly SMETANNIKOV -// Module : SUPERV - -#ifndef SUPERVGUI_ComputeNode_H -#define SUPERVGUI_ComputeNode_H - -#include "SUPERVGUI_GraphNode.h" - - -class SUPERVGUI_ComputeNode: public SUPERVGUI_GraphNode { - Q_OBJECT - - public: - SUPERVGUI_ComputeNode(QWidget* theParent, SUPERVGUI_Main* theMain, SUPERV_CNode theNode); - virtual ~SUPERVGUI_ComputeNode(); - - void sync(); - void hideAll(); - void showAll(); - SUPERVGUI_Label* getCommLabel() { return myComment; } - SUPERVGUI_Label* getTitleLabel() { return myTitle; } - virtual void updateShape(); - - public slots: - void switchService(); - void switchPorts(); - virtual void rename(); - - - private: - QPopupMenu* myShowPopup; - int myServiceItem; - int myPortsItem; - - //int myPIcount; - //int myPOcount; - - SUPERVGUI_Label* myComment; - QVBox* myServiceBox; - //QFrame* myPortsBox; - //QGridLayout* myPortLayout; -}; - -#endif diff --git a/src/SUPERVGUI/SUPERVGUI_ControlNode.cxx b/src/SUPERVGUI/SUPERVGUI_ControlNode.cxx deleted file mode 100644 index 0d40243..0000000 --- a/src/SUPERVGUI/SUPERVGUI_ControlNode.cxx +++ /dev/null @@ -1,432 +0,0 @@ -// SUPERV SUPERVGUI : GUI for Supervisor component -// -// Copyright (C) 2003 CEA/DEN, EDF R&D -// -// -// -// File : SUPERVGUI_ControlNode.cxx -// Author : Vitaly SMETANNIKOV -// Module : SUPERV - -using namespace std; -#include "SUPERVGUI_ControlNode.h" -#include -#include "SUPERVGUI_Main.h" -#include - -#define TITLECOLOR Qt::red.light() -#define BACKCOLOR Qt::cyan.light() - -//----------------------------------------------------------- -//******************* Start Node **************************** -//----------------------------------------------------------- -SUPERVGUI_StartControlNode::SUPERVGUI_StartControlNode(QWidget* theParent, SUPERVGUI_Main* theMain, - SUPERV_CNode theNode): - SUPERVGUI_GraphNode(theParent, theMain, theNode) -{ - setPaletteBackgroundColor(BACKCOLOR); - QGridLayout* aGridLayout = new QGridLayout(this, 0, 3, 0, 0); - aGridLayout->setColStretch(0, 1); - aGridLayout->setColStretch(1, 1); - aGridLayout->addColSpacing(2, LABEL_HEIGHT/2); - - myTitle->setAlignment(Qt::AlignHCenter); - myTitle->reparent(this, pos()); - myTitle->setPaletteBackgroundColor(TITLECOLOR); - - aGridLayout->addMultiCellWidget(myTitle, 0, 0, 0, 2); - - myPortsBox->reparent(this, pos()); - aGridLayout->addMultiCellWidget(myPortsBox, 1, 1, 0, 1); - // myGatesBox->setPaletteBackgroundColor(backgroundColor().dark(105)); - - myStatus->reparent(this, pos()); - myTime->reparent(this, pos()); - aGridLayout->addWidget(myStatus, 2, 0); - aGridLayout->addMultiCellWidget(myTime, 2, 2, 1, 2); - - myPopup->insertSeparator(); - myPortsItem = myPopup->insertItem(tr("POP_HIDEPORTS"), this, SLOT(switchPorts())); - - adjustSize(); - setShape(); - show(); -} - - -void SUPERVGUI_StartControlNode::switchPorts() { - bool aIsVisible = myPortsBox->isVisible(); - if (aIsVisible) myPortsBox->hide(); - else myPortsBox->show(); - updateShape(); - myPopup->setItemChecked(myPortsItem, aIsVisible); -} - - -void SUPERVGUI_StartControlNode::hideAll() { - myPortsBox->hide(); - updateShape(); - myPopup->setItemChecked(myPortsItem, true); -} - - -void SUPERVGUI_StartControlNode::showAll() { - myPortsBox->show(); - updateShape(); - myPopup->setItemChecked(myPortsItem, false); -} - - -void SUPERVGUI_StartControlNode::rename() { - SUPERVGUI_Node::rename(); - QString aStr(tr("ENDNODE_PREFIX")); - aStr+=name(); - myEndNode->setNodeName(aStr); -} - - -void SUPERVGUI_StartControlNode::remove() { - myEndNode->deleteLinks(); - deleteLinks(); - myNode->destroy(); - myMain->getGraph()->deleteNode(myEndNode); - myMain->getGraph()->deleteNode(this); -} - - -void SUPERVGUI_StartControlNode::setEndNode(SUPERVGUI_EndControlNode* theEndNode) { - myEndNode = theEndNode; -} - -SUPERVGUI_EndControlNode* SUPERVGUI_StartControlNode::getEndNode() { - return myEndNode; -} - - -void SUPERVGUI_StartControlNode::setShape() { - int aH = height(); - int aW = width(); - int aOffset = LABEL_HEIGHT/2; - QPointArray aArray(8); - aArray.setPoint(0, aOffset, aH); - aArray.setPoint(1, 0, aH-LABEL_HEIGHT); - aArray.setPoint(2, 0, LABEL_HEIGHT); - aArray.setPoint(3, aOffset, 0); - aArray.setPoint(4, aW, 0); - aArray.setPoint(5, aW-aOffset, LABEL_HEIGHT); - aArray.setPoint(6, aW-aOffset, aH-LABEL_HEIGHT); - aArray.setPoint(7, aW, aH); - QRegion aRegion(aArray); - - setMask(aRegion); -} - - -void SUPERVGUI_StartControlNode::updateShape() { - qApp->processEvents(); - adjustSize(); - setShape(); -} - - -void SUPERVGUI_StartControlNode::addOutputPort() { - SUPERVGUI_GraphNode::addOutputPort(); - myEndNode->updatePorts(); - myEndNode->updateShape(); - updateLinksPrs(true); - myEndNode->updateLinksPrs(true); -} - -void SUPERVGUI_StartControlNode::addInputPort() { - SUPERVGUI_GraphNode::addInputPort(); - myEndNode->updatePorts(); - myEndNode->updateShape(); - updateLinksPrs(true); - myEndNode->updateLinksPrs(true); -} - -void SUPERVGUI_StartControlNode::deletePort(SUPERVGUI_Port* thePort) { - if (getNodeType() == SUPERV::LoopNode) { - - SUPERV_Port aPortEngine = thePort->getPort(); - QString aName(aPortEngine->Name()); - QString aNameIn = aName + "Input"; - QString aNameOut = aName + "Output"; - - SUPERVGUI_Port* aPort = (SUPERVGUI_Port*) child(aNameOut, "SUPERVGUI_Port"); - aPort->deleteLinks(); - aPort->close(true); - - aPort = (SUPERVGUI_Port*) child(aNameIn, "SUPERVGUI_Port"); - aPort->deleteLinks(); - aPort->close(true); - - aPort = (SUPERVGUI_Port*) myEndNode->child(aNameIn, "SUPERVGUI_Port"); - aPort->deleteLinks(); - aPort->close(true); - - aPort = (SUPERVGUI_Port*) myEndNode->child(aNameOut, "SUPERVGUI_Port"); - aPort->deleteLinks(); - aPort->close(true); - - myPIcount--; - myPOcount--; - - myEndNode->getPIcount()--; - myEndNode->getPOcount()--; - - aPortEngine->destroy(); - - updatePorts(); - updateShape(); - myEndNode->updatePorts(); - myEndNode->updateShape(); - } else { - SUPERVGUI_GraphNode::deletePort(thePort); - } -} - - -QPoint SUPERVGUI_StartControlNode::getOutConnectPnt() { - return QPoint(pos().x() + width() - LABEL_HEIGHT/2, - pos().y() + (height()/2)); -} - - -//----------------------------------------------------------- -//******************* End Node ****************************** -//----------------------------------------------------------- - -SUPERVGUI_EndControlNode::SUPERVGUI_EndControlNode(QWidget* theParent, SUPERVGUI_Main* theMain, - SUPERV_CNode theNode, SUPERVGUI_StartControlNode* theStart): - SUPERVGUI_GraphNode(theParent, theMain, theNode) -{ - myStartNode = theStart; - - setPaletteBackgroundColor(BACKCOLOR); - - QGridLayout* aGridLayout = new QGridLayout(this, 0, 3, 0, 0); - aGridLayout->setColStretch(1, 1); - aGridLayout->setColStretch(2, 1); - aGridLayout->addColSpacing(0, LABEL_HEIGHT/2); - - myTitle->setAlignment(Qt::AlignHCenter); - myTitle->reparent(this, pos()); - myTitle->setPaletteBackgroundColor(TITLECOLOR); - aGridLayout->addMultiCellWidget(myTitle, 0, 0, 0, 2); - - myPortsBox->reparent(this, pos()); - - aGridLayout->addMultiCellWidget(myPortsBox, 1, 1, 1, 2); - - myStatus->reparent(this, pos()); - myTime->reparent(this, pos()); - aGridLayout->addMultiCellWidget(myStatus, 2, 2, 0, 1); - aGridLayout->addWidget(myTime, 2, 2); - - adjustSize(); - setShape(); - - myPopup->removeItem(myRenameItem); - myPopup->removeItem(myDeleteItem); - myPopup->removeItem(mySeparatorId); - - myPopup->insertSeparator(); - myPortsItem = myPopup->insertItem(tr("POP_HIDEPORTS"), this, SLOT(switchPorts())); - myStartNode->setEndNode(this); - show(); -} - - -void SUPERVGUI_EndControlNode::switchPorts() { - bool aIsVisible = myPortsBox->isVisible(); - if (aIsVisible) myPortsBox->hide(); - else myPortsBox->show(); - updateShape(); - myPopup->setItemChecked(myPortsItem, aIsVisible); -} - -void SUPERVGUI_EndControlNode::hideAll() { - myPortsBox->hide(); - updateShape(); - myPopup->setItemChecked(myPortsItem, true); -} - - -void SUPERVGUI_EndControlNode::showAll() { - myPortsBox->show(); - updateShape(); - myPopup->setItemChecked(myPortsItem, false); -} - - -void SUPERVGUI_EndControlNode::setShape() { - int aH = height(); - int aW = width(); - int aOffset = LABEL_HEIGHT/2; - QPointArray aArray(8); - aArray.setPoint(0, 0, aH); - aArray.setPoint(1, aOffset, aH-LABEL_HEIGHT); - aArray.setPoint(2, aOffset, LABEL_HEIGHT); - aArray.setPoint(3, 0, 0); - aArray.setPoint(4, aW-aOffset, 0); - aArray.setPoint(5, aW, LABEL_HEIGHT); - aArray.setPoint(6, aW, aH-LABEL_HEIGHT); - aArray.setPoint(7, aW-aOffset, aH); - QRegion aRegion(aArray); - - setMask(aRegion); -} - - -void SUPERVGUI_EndControlNode::updateShape() { - qApp->processEvents(); - adjustSize(); - setShape(); -} - - -QPoint SUPERVGUI_EndControlNode::getInConnectPnt() { - return QPoint(pos().x() + LABEL_HEIGHT/2, - pos().y() + (height()/2)); -} - - -//----------------------------------------------------------- -//******************* GoTo Node ***************************** -//----------------------------------------------------------- -SUPERVGUI_GotoNode::SUPERVGUI_GotoNode(QWidget* theParent, SUPERVGUI_Main* theMain, - SUPERV_CNode theNode): - SUPERVGUI_GraphNode(theParent, theMain, theNode) -{ - setPaletteBackgroundColor(BACKCOLOR); - - QGridLayout* aGridLayout = new QGridLayout(this, 3, 2, 0, 0); - - myTitle->setAlignment(Qt::AlignHCenter); - myTitle->reparent(this, pos()); - myTitle->setPaletteBackgroundColor(Qt::green.light()); - aGridLayout->addMultiCellWidget(myTitle, 0, 0, 0, 1); - - myPortsBox->reparent(this, pos()); - aGridLayout->addMultiCellWidget(myPortsBox, 1, 1, 0, 1); - - myStatus->reparent(this, pos()); - myTime->reparent(this, pos()); - aGridLayout->addWidget(myStatus, 2, 0); - aGridLayout->addWidget(myTime, 2, 1); - - myPopup->insertSeparator(); - myPopup->insertItem("Link to Node...", this, SLOT(linkToNode())); - - adjustSize(); - setShape(); - show(); - - //SUPERV_Ports aPorts = getEngine()->Ports(); //existing - //int n = aPorts->length(); -} - - -void SUPERVGUI_GotoNode::setShape() { - int aH = height(); - int aW = width(); - QPointArray aArray(8); - aArray.setPoint(0, LABEL_HEIGHT, aH); - aArray.setPoint(1, 0, aH-LABEL_HEIGHT); - aArray.setPoint(2, 0, LABEL_HEIGHT); - aArray.setPoint(3, LABEL_HEIGHT, 0); - aArray.setPoint(4, aW-LABEL_HEIGHT, 0); - aArray.setPoint(5, aW, LABEL_HEIGHT); - aArray.setPoint(6, aW, aH-LABEL_HEIGHT); - aArray.setPoint(7, aW-LABEL_HEIGHT, aH); - QRegion aRegion(aArray); - - setMask(aRegion); -} - - -void SUPERVGUI_GotoNode::hideAll() { - myPortsBox->hide(); - updateShape(); - //myPopup->setItemChecked(myPortsItem, true); -} - - -void SUPERVGUI_GotoNode::showAll() { - myPortsBox->show(); - updateShape(); - //myPopup->setItemChecked(myPortsItem, false); -} - -void SUPERVGUI_GotoNode::updateShape() { - qApp->processEvents(); - adjustSize(); - setShape(); -} - - -void SUPERVGUI_GotoNode::linkToNode() { - SUPERVGUI_SelectInlineDlg* aDlg = new SUPERVGUI_SelectInlineDlg(getMain()); - if (aDlg->exec()) { - setLinkedNode((char*)aDlg->getName().latin1()); - myMain->getGraph()->sync(); - } - delete aDlg; -} - - -void SUPERVGUI_GotoNode::setLinkedNode(char* theNodeName) { - getGotoNode()->SetCoupled(theNodeName); -} - - - -//----------------------------------------------------------- -//*************** Select Inline node dialog****************** -//----------------------------------------------------------- - -SUPERVGUI_SelectInlineDlg::SUPERVGUI_SelectInlineDlg(SUPERVGUI_Main* theMain) - :QDialog(theMain, 0, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) -{ - setSizeGripEnabled( true ); - setCaption(tr("TIT_FUNC_PYTHON")); - QGridLayout* aMainLayout = new QGridLayout(this, 2, 2, 7, 4); - - QLabel* aLabel = new QLabel("Connect to", this ); - aMainLayout->addWidget(aLabel, 0, 0); - - myCombo = new QComboBox(this); - myCombo->clear(); //for the additional check from GUI side for bug PAL7007 - SUPERV_Nodes aNodesList = theMain->getDataflow()->Nodes(); - int i; - for (i = 0; i < aNodesList->INodes.length(); i++) { - myCombo->insertItem(QString(aNodesList->INodes[i]->Name())); - } - for (i = 0; i < aNodesList->LNodes.length(); i++) { - myCombo->insertItem(QString(aNodesList->LNodes[i]->Name())); - } - for (i = 0; i < aNodesList->SNodes.length(); i++) { - myCombo->insertItem(QString(aNodesList->SNodes[i]->Name())); - } - aMainLayout->addWidget(myCombo, 0, 1); - - QGroupBox* aBtnBox = new QGroupBox( this ); - aBtnBox->setColumnLayout( 0, Qt::Vertical ); - aBtnBox->layout()->setSpacing( 0 ); aBtnBox->layout()->setMargin( 0 ); - QHBoxLayout* aBtnLayout = new QHBoxLayout( aBtnBox->layout() ); - aBtnLayout->setAlignment( Qt::AlignTop ); - aBtnLayout->setSpacing( 6 ); aBtnLayout->setMargin( 11 ); - - QPushButton* aOKBtn = new QPushButton( tr( "BUT_OK" ), aBtnBox ); - connect( aOKBtn, SIGNAL( clicked() ), this, SLOT( accept() ) ); - aBtnLayout->addWidget( aOKBtn ); - - aBtnLayout->addStretch(); - - QPushButton* aCancelBtn = new QPushButton( tr("BUT_CANCEL"), aBtnBox ); - connect( aCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) ); - aBtnLayout->addWidget( aCancelBtn ); - - aMainLayout->addMultiCellWidget(aBtnBox, 1, 1, 0, 1); -} diff --git a/src/SUPERVGUI/SUPERVGUI_ControlNode.h b/src/SUPERVGUI/SUPERVGUI_ControlNode.h deleted file mode 100644 index 5fa06bc..0000000 --- a/src/SUPERVGUI/SUPERVGUI_ControlNode.h +++ /dev/null @@ -1,130 +0,0 @@ -// SUPERV SUPERVGUI : GUI for Supervisor component -// -// Copyright (C) 2003 CEA/DEN, EDF R&D -// -// -// -// File : SUPERVGUI_ControlNode.h -// Author : Vitaly SMETANNIKOV -// Module : SUPERV - -#ifndef SUPERVGUI_ControlNode_H -#define SUPERVGUI_ControlNode_H - -#include "SUPERVGUI_GraphNode.h" -#include -#include -#include - - -class SUPERVGUI_EndControlNode; - - -/** - * Start node of Switch and Loop - */ -class SUPERVGUI_StartControlNode: public SUPERVGUI_GraphNode { - Q_OBJECT - - public: - SUPERVGUI_StartControlNode(QWidget* theParent, SUPERVGUI_Main* theMain, - SUPERV_CNode theNode); - virtual ~SUPERVGUI_StartControlNode() {}; - - virtual void hideAll(); - virtual void showAll(); - virtual void updateShape(); - virtual void deletePort(SUPERVGUI_Port* thePort); - - void setEndNode(SUPERVGUI_EndControlNode* theEndNode); - SUPERVGUI_EndControlNode* getEndNode(); - - virtual QPoint getOutConnectPnt(); - - public slots: - void switchPorts(); - virtual void rename(); - virtual void remove(); - virtual void addInputPort(); - virtual void addOutputPort(); - - private: - void setShape(); - - SUPERVGUI_EndControlNode* myEndNode; - int myPortsItem; -}; - - - - -/** - * End node of Switch and Loop - */ -class SUPERVGUI_EndControlNode: public SUPERVGUI_GraphNode { - Q_OBJECT - - public: - SUPERVGUI_EndControlNode(QWidget* theParent, SUPERVGUI_Main* theMain, - SUPERV_CNode theNode, SUPERVGUI_StartControlNode* theStart); - virtual ~SUPERVGUI_EndControlNode() {}; - - virtual void hideAll(); - virtual void showAll(); - virtual void updateShape(); - - virtual QPoint getInConnectPnt(); - - public slots: - void switchPorts(); - - private: - void setShape(); - - SUPERVGUI_StartControlNode* myStartNode; - int myPortsItem; -}; - - -class SUPERVGUI_SelectInlineDlg: public QDialog { - Q_OBJECT - - public: - SUPERVGUI_SelectInlineDlg(SUPERVGUI_Main* theMain); - virtual ~SUPERVGUI_SelectInlineDlg() {}; - - QString getName() { return myCombo->currentText(); } - - private: - QComboBox* myCombo; -}; - - -/** - * GOTO node - */ -class SUPERVGUI_GotoNode: public SUPERVGUI_GraphNode { - Q_OBJECT - - public: - SUPERVGUI_GotoNode(QWidget* theParent, SUPERVGUI_Main* theMain, - SUPERV_CNode theNode); - virtual ~SUPERVGUI_GotoNode() {}; - - virtual void hideAll(); - virtual void showAll(); - virtual void updateShape(); - - void setLinkedNode(char* theNodeName); - - public slots: - void linkToNode(); - - private: - void setShape(); - - -}; - - -#endif diff --git a/src/SUPERVGUI/SUPERVGUI_CtrlLink.cxx b/src/SUPERVGUI/SUPERVGUI_CtrlLink.cxx deleted file mode 100644 index 65b9557..0000000 --- a/src/SUPERVGUI/SUPERVGUI_CtrlLink.cxx +++ /dev/null @@ -1,47 +0,0 @@ -// SUPERV SUPERVGUI : GUI for Supervisor component -// -// Copyright (C) 2003 CEA/DEN, EDF R&D -// -// -// -// File : SUPERVGUI_CtrlLink.cxx -// Author : Vitaly SMETANNIKOV -// Module : SUPERV - -using namespace std; -#include "SUPERVGUI_CtrlLink.h" -#include "SUPERVGUI_Graph.h" -#include "SUPERVGUI_GraphNode.h" - -#define LINE_WIDTH 2 -#define DRAW_CLR Qt::black - -SUPERVGUI_CtrlLink::SUPERVGUI_CtrlLink(SUPERVGUI_Graph* theGraph, - SUPERVGUI_GraphNode* theFromNode, - SUPERVGUI_GraphNode* theToNode) -{ - myOutNode = theFromNode; - myInNode = theToNode; - myGraph = theGraph; -} - - - -void SUPERVGUI_CtrlLink::paint(QPainter* thePainter, bool toErase) { - if ((myGraph == NULL) || (myInNode == NULL) || (myOutNode == NULL)) - return; - thePainter->save(); - - QPen aDataPen; - aDataPen.setWidth(LINE_WIDTH); - if (toErase) { - aDataPen.setColor(myGraph->viewport()->paletteBackgroundColor()); - } else { - aDataPen.setColor(DRAW_CLR); - } - thePainter->setPen(aDataPen); - thePainter->moveTo(myOutNode->getOutConnectPnt()); - thePainter->lineTo(myInNode->getInConnectPnt()); - - thePainter->restore(); -} diff --git a/src/SUPERVGUI/SUPERVGUI_CtrlLink.h b/src/SUPERVGUI/SUPERVGUI_CtrlLink.h deleted file mode 100644 index 36f1e1e..0000000 --- a/src/SUPERVGUI/SUPERVGUI_CtrlLink.h +++ /dev/null @@ -1,39 +0,0 @@ -// SUPERV SUPERVGUI : GUI for Supervisor component -// -// Copyright (C) 2003 CEA/DEN, EDF R&D -// -// -// -// File : SUPERVGUI_CtrlLink.h -// Author : Vitaly SMETANNIKOV -// Module : SUPERV - -#ifndef SUPERVGUI_CTRLLink_H -#define SUPERVGUI_CTRLLink_H - - -#include "SUPERVGUI_Def.h" - -class SUPERVGUI_Graph; -class SUPERVGUI_GraphNode; - -class SUPERVGUI_CtrlLink { -public: - SUPERVGUI_CtrlLink() { myOutNode=NULL; myInNode=NULL; myGraph=NULL; } - - SUPERVGUI_CtrlLink(SUPERVGUI_Graph* theGraph, - SUPERVGUI_GraphNode* theFromNode, - SUPERVGUI_GraphNode* theToNode); - - ~SUPERVGUI_CtrlLink() {}; - - - void paint(QPainter* thePainter, bool toErase); - -private: - SUPERVGUI_GraphNode* myOutNode; - SUPERVGUI_GraphNode* myInNode; - SUPERVGUI_Graph* myGraph; -}; - -#endif diff --git a/src/SUPERVGUI/SUPERVGUI_Def.h b/src/SUPERVGUI/SUPERVGUI_Def.h index dac075d..5c93893 100644 --- a/src/SUPERVGUI/SUPERVGUI_Def.h +++ b/src/SUPERVGUI/SUPERVGUI_Def.h @@ -52,6 +52,8 @@ #define CELL_SPACE 5 +#define MARGIN 2 + // Noeuds // ------ /* @@ -218,7 +220,7 @@ NODE_Editing "", NODE_RED, NODE_GREEN, NODE_BLUE, true, false, true #define SUPERV_isNull(oc) (CORBA::is_nil(oc)) -enum GraphViewType { GRAPH, CONTROLFLOW, TABLE, CANVAS }; +enum GraphViewType { CONTROLFLOW, CANVAS, CANVASTABLE }; //enum NodeType { COMPUTE, SWITCH, LOOP, GOTO, LABEL }; diff --git a/src/SUPERVGUI/SUPERVGUI_Graph.cxx b/src/SUPERVGUI/SUPERVGUI_Graph.cxx deleted file mode 100644 index afcddc3..0000000 --- a/src/SUPERVGUI/SUPERVGUI_Graph.cxx +++ /dev/null @@ -1,643 +0,0 @@ -// SUPERV SUPERVGUI : GUI for Supervisor component -// -// 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 -// -// -// -// File : SUPERVGUI_Graph.cxx -// Author : Francis KLOSS -// Module : SUPERV - -using namespace std; -#include "SUPERVGUI_Def.h" -#include "SUPERVGUI_Graph.h" -#include "SUPERVGUI_Main.h" -#include "SUPERVGUI_ComputeNode.h" -#include "SUPERVGUI_ControlNode.h" -#include "SUPERVGUI.h" - -#include -#include -#include -#include - -//#define CHECKTIME - -#ifdef CHECKTIME -#include -#endif - - -#define UPDATECONTROLNODES(NodesName) \ - n = nodes->NodesName.length(); \ - for (int i=0; iNodesName[i]); \ - SUPERV_CNode aCNodeEnd = SUPERV::CNode::_narrow(nodes->NodesName[i]->Coupled()); \ - ihmNode = (SUPERVGUI_Node *)child(aCNode->Name(), "SUPERVGUI_Node"); \ - if (ihmNode == NULL) { \ - main->addControlNode(aCNode, aCNodeEnd, false); \ - } else { \ - ResizeGraph(ihmNode, aCNode->X(), aCNode->Y()); \ - moveChild(ihmNode, aCNode->X(), aCNode->Y()); \ - ihmList->removeRef(ihmNode); \ - ihmNode->sync(); \ - aEndNodePrs = (SUPERVGUI_EndControlNode*)child(aCNodeEnd->Name(), "SUPERVGUI_EndControlNode"); \ - ResizeGraph(aEndNodePrs, aCNodeEnd->X(), aCNodeEnd->Y()); \ - moveChild(aEndNodePrs, aCNodeEnd->X(), aCNodeEnd->Y()); \ - ihmList->removeRef(aEndNodePrs); \ - aEndNodePrs->sync(); \ - } \ - } - - -#define UPDATENODES(NodesName, FuncName) \ - n = nodes->NodesName.length(); \ - for (int i=0; iNodesName[i]); \ - ihmNode = (SUPERVGUI_Node *)child(aCNode->Name(), "SUPERVGUI_Node"); \ - if (ihmNode == NULL) { \ - main->FuncName(aCNode); \ - } else { \ - ResizeGraph(ihmNode, aCNode->X(), aCNode->Y()); \ - moveChild(ihmNode, aCNode->X(), aCNode->Y()); \ - ihmList->removeRef(ihmNode); \ - ihmNode->sync(); \ - } \ - } - - -SUPERVGUI_Graph::SUPERVGUI_Graph(SUPERVGUI_Main* m): - SUPERVGUI_View(m), - myNewLink(0) -{ - Trace("SUPERVGUI_Graph::SUPERVGUI_Graph"); - myIsControlView = false; - myLinksList.setAutoDelete(true); - viewport()->setMouseTracking(true); - - resizeContents(GRAPH_WIDTH, GRAPH_HEIGHT); - - if (SUPERV_isNull(main->getDataflow())) return; - - - //create sketching popup menu - mySketchPopup = new QPopupMenu(viewport()); - if (!mySketchPopup->isCheckable()) - mySketchPopup->setCheckable(true); - myDelPntItem = mySketchPopup->insertItem(tr("MSG_DEL_LAST_PNT"), this, SLOT(delLastPnt())); - mySketchPopup->insertItem(tr("MSG_DEL_LINK"), this, SLOT(delCreatingLink())); - myOrtoItem = mySketchPopup->insertItem(tr("MSG_ORTHO_LINE"), this, SLOT(setOrtho())); - - //create link popup menu - myLinkPopup = new QPopupMenu(viewport()); - myDelLinkItem = myLinkPopup->insertItem(tr("MSG_DELLINK"), this, SLOT(deleteLink())); - myAddLinkPntItem = myLinkPopup->insertItem(tr("MSG_ADD_POINT"), this, SLOT(addPoint())); - myDelLinkPntItem = myLinkPopup->insertItem(tr("MSG_DEL_POINT"), this, SLOT(deletePoint())); -} - - - -SUPERVGUI_Graph::~SUPERVGUI_Graph() { -} - -/** - * Synchronizes Graph presentation with internal graph structure - */ -void SUPERVGUI_Graph::sync() { - if (SUPERV_isNull(main->getDataflow())) return; - - myLinksList.clear(); - - SUPERVGUI_Node* ihmNode; - QObjectList* ihmList = queryList("SUPERVGUI_Node"); - SUPERV_Nodes nodes = main->getDataflow()->Nodes(); - - MESSAGE("CNodes="<CNodes.length()); - MESSAGE("FNodes="<FNodes.length()); - MESSAGE("INodes="<INodes.length()); - MESSAGE("GNodes="<GNodes.length()); - MESSAGE("LNodes="<LNodes.length()); - MESSAGE("SNodes="<SNodes.length()); - - int n; - UPDATENODES(CNodes, addComputeNode); - UPDATENODES(FNodes, addComputeNode); - UPDATENODES(INodes, addComputeNode); - UPDATENODES(GNodes, addGOTONode); - - SUPERVGUI_EndControlNode* aEndNodePrs; - UPDATECONTROLNODES(LNodes); - UPDATECONTROLNODES(SNodes); - - QObjectListIt i(*ihmList); - while ((ihmNode=(SUPERVGUI_Node*)i.current()) != 0) { - ++i; - ihmNode->close(true); - } - delete ihmList; - - ihmList = queryList("SUPERVGUI_GraphNode"); - i=(*ihmList); - SUPERVGUI_GraphNode* aGraphNode; - while ((aGraphNode=(SUPERVGUI_GraphNode*)i.current()) != 0) { - ++i; - aGraphNode->updateLinksPrs(); - } - delete ihmList; - - draw(); -} - - -/** - * Reimplemented for repainting links - */ -bool SUPERVGUI_Graph::eventFilter(QObject* object, QEvent* event) { - if (event->type() == QEvent::Paint) { - draw(); - return true; - } - return QScrollView::eventFilter(object, event); -} - - -/** - * Clears content of Graph (links) - */ -void SUPERVGUI_Graph::clearView() { - QPainter aPainter(viewport()); - aPainter.eraseRect(viewport()->rect()); -} - - -/** - * Draws links using off screen buffer - */ -void SUPERVGUI_Graph::draw() { -#ifdef CHECKTIME - struct timeb aTm1; - ftime(&aTm1); -#endif - if (myLinksList.count() == 0) { - return; - } - int aWidth = viewport()->width(); - int aHeight = viewport()->height(); - QPixmap aPixmap(aWidth, aHeight); - aPixmap.setOptimization(QPixmap::BestOptim); - aPixmap.fill(viewport()->paletteBackgroundColor()); - - QPainter aPainter(&aPixmap); - QPoint aPos = viewportToContents(viewport()->pos()); - - if (myIsControlView) { - SUPERVGUI_CtrlLink* aLink; - QMap::Iterator it; - for ( it = myCtrlLinks.begin(); it != myCtrlLinks.end(); ++it ) { - it.data().paint(&aPainter, false); - } - } else { - SUPERVGUI_Link* aLink; - for (aLink = myLinksList.first(); aLink; aLink = myLinksList.next()) { - aLink->isInRect(aPos.x(), aPos.y(), aWidth, aHeight); - if (aLink->isInRect(aPos.x(), aPos.y(), aWidth, aHeight)) { - aLink->paint(&aPainter, false); - } - } - } - bitBlt(viewport(), 0, 0, - &aPixmap, 0, 0, aWidth, aHeight, - Qt::CopyROP, true); - - if (myNewLink) { - myNewLink->repaintSketch(); - } -#ifdef CHECKTIME - struct timeb aTm2; - ftime(&aTm2); - ulong aTm = 1000*(aTm2.time-aTm1.time)+(aTm2.millitm-aTm1.millitm); - //cout<<"### Time="<button() == Qt::RightButton) { - if (myNewLink) { - main->showPopup(mySketchPopup, e); - } else { - SUPERVGUI_Link* aLink = SUPERVGUI_Link::getSelectedLink(); - if (aLink && main->isEditable()) { - myLinkPopup->setItemEnabled(myAddLinkPntItem, - !aLink->haveSelectedPoint()); - myLinkPopup->setItemEnabled(myDelLinkPntItem, - aLink->haveSelectedPoint()); - - - if (!aLink->isESInputPort()) { - SUPERV::KindOfPort aOutType = aLink->getOutputPort()->getPort()->Kind(); - SUPERV::KindOfPort aInType = aLink->getInputPort()->getPort()->Kind(); - myLinkPopup->setItemEnabled(myDelLinkItem, - ((aOutType != SUPERV::LoopParameter) - && - (aInType != SUPERV::LoopParameter))); - } - - myMousePos = e->pos(); - mySelectedLink = aLink; - mySelectedPoint = mySelectedLink->getSelectedPoint(); - main->showPopup(myLinkPopup, e); - } else { - mySelectedLink = 0; - addDSPopupItem(); - main->showPopup(myPopup, e); - } - } - } - emit mousePressed(e); - - SUPERVGUI_View::contentsMousePressEvent(e); -} - - -void SUPERVGUI_Graph::contentsMouseReleaseEvent(QMouseEvent* e) { - Trace("SUPERVGUI_Graph::contentsMouseReleaseEvent"); - if (myNewLink && (e->button() == Qt::LeftButton)) { - myNewLink->addTmpPoint(e->pos()); - mySketchPopup->setItemEnabled(myDelPntItem, true); - } - emit mouseReleased(e); - SUPERVGUI_View::contentsMouseReleaseEvent(e); -} - - -void SUPERVGUI_Graph::contentsMouseMoveEvent(QMouseEvent* e) { - Trace("SUPERVGUI_Graph::contentsMouseMoveEvent"); - if (myNewLink) { - myNewLink->drawTo(e->pos()); - } - emit mouseMoved(e); - SUPERVGUI_View::contentsMouseMoveEvent(e); -} - - -void SUPERVGUI_Graph::addPoint() { - mySelectedLink->addPoint(myMousePos.x(), myMousePos.y()); -} - - -void SUPERVGUI_Graph::deletePoint() { - mySelectedLink->removePoint(mySelectedPoint); -} - - -void SUPERVGUI_Graph::deleteLink() { - QString aName; - if (mySelectedLink->isESInputPort()) - aName = mySelectedLink->getInputPortES()->getPort()->Name(); - else - aName = mySelectedLink->getInputPort()->getPort()->Name(); - - if (aName != "Default") { - deleteLink(mySelectedLink); - mySelectedLink = 0; - repaintContents(); - } -} - - -void SUPERVGUI_Graph::deleteLink(SUPERVGUI_Link* theLink) { - if (getMain()->getDataflow()->IsDone()) { - //update values of input ports of theLink if theLink is deleted and dataflow has been executed any times - SUPERVGUI_PortIn* aInPort = theLink->getInputPort(); - if ( aInPort ) { - //input port exist - QString aPortValue = QString(aInPort->getPort()->ToString()); - if ( (aInPort->getPort()->IsParam() || aInPort->getPort()->IsInLine()) - && - !aPortValue.isNull()) { - //gives a value to an input port - theLink->destroyEngine(); - aInPort->getPort()->Input( Supervision.getEngine()->StringValue( aPortValue ) ); - aInPort->sync(); - } - else - theLink->destroyEngine(); - } - else - theLink->destroyEngine(); - } - else - theLink->destroyEngine(); - - myLinksList.removeRef(theLink); - if (myLinksList.count() == 0) clearView(); -} - - -void SUPERVGUI_Graph::setAsFromStudy(bool theToStudy) { - SUPERVGUI_View::setAsFromStudy(theToStudy); - if (theToStudy) return; - - SUPERVGUI_PortOut* aPortOut; - QObjectList* aPortsList = queryList("SUPERVGUI_PortOut"); - QObjectListIt aPortIt(*aPortsList); - while ((aPortOut=(SUPERVGUI_PortOut*)aPortIt.current()) != 0) { - ++aPortIt; - if (aPortOut->isInStudy()) { - aPortOut->setStudyState(false); - aPortOut->sync(); - } - } - delete aPortsList; -} - - -/** - * Begins Link sketching - */ -void SUPERVGUI_Graph::sketchBegin(SUPERVGUI_Port* thePort) { - if (thePort == 0) return; - - SUPERV_Port aPort = thePort->getPort(); - myNewLink = new SUPERVGUI_Link(this); - mySketchPopup->setItemEnabled(myDelPntItem, false); - mySketchPopup->setItemChecked(myOrtoItem, myNewLink->isOrthoMode()); - - myNewLink->setBeginPort(thePort); - - if (aPort->IsInput()) { - if (aPort->Kind() == SUPERV::EndSwitchParameter - || - aPort->Node()->Kind() == SUPERV::EndSwitchNode) { - myNewLink->setInputPortES(dynamic_cast(thePort)); - } - else - myNewLink->setInputPort(dynamic_cast(thePort)); - } - else - myNewLink->setOutputPort(dynamic_cast(thePort)); -} - - -void SUPERVGUI_Graph::sketchEnd(SUPERVGUI_Port* thePort) { - if (!myNewLink) return; - - bool aIsInput = myNewLink->getBeginPort()->getPort()->IsInput(); - if (aIsInput && thePort->getPort()->IsInput() - || - !aIsInput && !thePort->getPort()->IsInput()) { - return; - } - - - SUPERV_Port aPort = thePort->getPort(); - if (aPort->IsInput()) { - - int aKind = myNewLink->getOutputPort()->getPort()->Kind(); - - if ((aPort->Kind() == SUPERV::EndSwitchParameter - || - aPort->Node()->Kind() == SUPERV::EndSwitchNode) - && - (aKind == SUPERV::InLineParameter || aKind == SUPERV::ServiceParameter)) - { - QString aName(aPort->Name()); - if (aName != "Default") - myNewLink->setInputPortES(dynamic_cast(thePort)); - } - else if (aPort->Kind() == SUPERV::DataStreamParameter){ - myNewLink->setInputPort(dynamic_cast(thePort)); - } else { - if (aPort->IsLinked()) return; - - if (aKind == SUPERV::GateParameter || aPort->Kind() == SUPERV::GateParameter) { - if (aKind != aPort->Kind() && aKind != SUPERV::InLineParameter - && aPort->Kind() != SUPERV::InLineParameter) { - return; - } - else { //connection like Gate <--> Gate - myNewLink->setInputPort(dynamic_cast(thePort)); - } - } else { - myNewLink->setInputPort(dynamic_cast(thePort)); - } - } - - } else { - if (myNewLink->isESInputPort()) { - if(aPort->Kind() == SUPERV::InLineParameter || aPort->Kind() == SUPERV::ServiceParameter) - { - myNewLink->setOutputPort(dynamic_cast(thePort)); - } - else - return; - } else { - int aKind = myNewLink->getInputPort()->getPort()->Kind(); - - if (aKind == SUPERV::GateParameter || aPort->Kind() == SUPERV::GateParameter) { - if (aKind != aPort->Kind() && - aKind != SUPERV::InLineParameter && - aPort->Kind() != SUPERV::InLineParameter) { - return; - } else //connection like Gate <--> Gate - myNewLink->setOutputPort(dynamic_cast(thePort)); - } else if (aPort->Kind() == SUPERV::DataStreamParameter){ - myNewLink->setOutputPort(dynamic_cast(thePort)); - } else - myNewLink->setOutputPort(dynamic_cast(thePort)); - } - } - - if (myNewLink->isCreationComplete()) { // if everything is defined - if (myNewLink->createEngine()) { - myLinksList.append(myNewLink); - myNewLink = 0; - } else { - QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_CREATE_LINK")); - delete myNewLink; - } - } -} - - -/** - * Returns true if presentation of link exists - */ -bool SUPERVGUI_Graph::isLinkPrsExists(SUPERV_Link theLink) { - SUPERVGUI_Link* aTmpLink; - for (aTmpLink = myLinksList.first(); aTmpLink; aTmpLink = myLinksList.next()) { - SUPERVGUI_PortOut* aOutPort = aTmpLink->getOutputPort(); - if (strcmp(aOutPort->getPort()->Node()->Name(), - theLink->OutPort()->Node()->Name()) == 0) { - QString aName(theLink->OutPort()->Name()); - aName += "Output"; - if (aOutPort->name() == aName) { - return true; - } - } - } - return false; -} - - -/** - * Creates link presentation from link engine - * Returns false if fails - */ -bool SUPERVGUI_Graph::createLinkPrs(SUPERV_Link theLink) { - SUPERVGUI_Link* aNewLink = new SUPERVGUI_Link(this, theLink); - - // Find output node - SUPERVGUI_Node* aOutNode = (SUPERVGUI_Node*) - child(theLink->OutPort()->Node()->Name(), "SUPERVGUI_Node"); - if (aOutNode) { - QString aName(theLink->OutPort()->Name()); - aName += "Output"; - SUPERVGUI_PortOut* aOutPort = (SUPERVGUI_PortOut*) - aOutNode->child(aName, "SUPERVGUI_PortOut"); - if (aOutPort) - aNewLink->setOutputPort(aOutPort); - else { - delete aNewLink; - return false; - } - } else { - delete aNewLink; - return false; - } - // Find input node - SUPERVGUI_Node* aInNode = (SUPERVGUI_Node*) - child(theLink->InPort()->Node()->Name(), "SUPERVGUI_Node"); - if (aInNode) { - QString aName(theLink->InPort()->Name()); - aName += "Input"; - if (theLink->InPort()->Kind() == SUPERV::EndSwitchParameter) { - //If input port is EndSwitchParameter - SUPERVGUI_PortInESNode* aInPortES =(SUPERVGUI_PortInESNode*) - aInNode->child(aName, "SUPERVGUI_PortInESNode"); //returns null - if (aInPortES) - aNewLink->setInputPortES(aInPortES); - else { - delete aNewLink; - return false; - } - } else { - SUPERVGUI_PortIn* aInPort =(SUPERVGUI_PortIn*) - aInNode->child(aName, "SUPERVGUI_PortIn"); - if (aInPort) - aNewLink->setInputPort(aInPort); - else { - delete aNewLink; - return false; - } - } - } else { - delete aNewLink; - return false; - } - aNewLink->setVisible(!myIsControlView); - myLinksList.append(aNewLink); - return true; -} - - -void SUPERVGUI_Graph::delLastPnt() { - if (myNewLink) { - myNewLink->delLastTmpPoint(); - } -} - -void SUPERVGUI_Graph::delCreatingLink() { - myNewLink->abortCreation(); - delete myNewLink; - myNewLink=0; - repaintContents(); -} - -void SUPERVGUI_Graph::setOrtho() { - if (myNewLink) { - bool aIsOrtho = !mySketchPopup->isItemChecked(myOrtoItem); - myNewLink->setOrthoMode(aIsOrtho); - mySketchPopup->setItemChecked(myOrtoItem, aIsOrtho); - } -} - - - -void SUPERVGUI_Graph::setFullView() { - QObjectList* aNodeList = queryList("SUPERVGUI_Node"); - QObjectListIt aIt(*aNodeList); - SUPERVGUI_Node* aNode; - while ((aNode=(SUPERVGUI_Node*)aIt.current()) != 0) { - ++aIt; - aNode->showAll(); - } - delete aNodeList; - - myCtrlLinks.clear(); - SUPERVGUI_Link* aLink; - for (aLink = myLinksList.first(); aLink; aLink = myLinksList.next()) { - aLink->setVisible(true); - } - draw(); - myIsControlView = false; -} - - -void SUPERVGUI_Graph::setControlView() { - QObjectList* aNodeList = queryList("SUPERVGUI_Node"); - QObjectListIt aIt(*aNodeList); - SUPERVGUI_Node* aNode; - while ((aNode=(SUPERVGUI_Node*)aIt.current()) != 0) { - ++aIt; - aNode->hideAll(); - } - delete aNodeList; - myCtrlLinks.clear(); - SUPERVGUI_Link* aLink; - for (aLink = myLinksList.first(); aLink; aLink = myLinksList.next()) { - aLink->setVisible(false); - - QString aOutName(aLink->getEngineLink()->OutPort()->Node()->Name()); - QString aInName(aLink->getEngineLink()->InPort()->Node()->Name()); - QString aKey = aOutName + aInName; - - if (!myCtrlLinks.contains(aKey)) { - SUPERVGUI_GraphNode* aOutNode = (SUPERVGUI_GraphNode*) - child(aOutName, "SUPERVGUI_GraphNode"); - if (!aOutNode) continue; - SUPERVGUI_GraphNode* aInNode = (SUPERVGUI_GraphNode*) - child(aInName, "SUPERVGUI_GraphNode"); - if (!aInNode) continue; - - myCtrlLinks[aKey] = SUPERVGUI_CtrlLink(this, aOutNode, aInNode); - } - } - draw(); - myIsControlView = true; -} - - -void SUPERVGUI_Graph::deleteNode(SUPERVGUI_Node* theNode) { - theNode->close(true); - draw(); -} diff --git a/src/SUPERVGUI/SUPERVGUI_Graph.h b/src/SUPERVGUI/SUPERVGUI_Graph.h deleted file mode 100644 index 1efe20c..0000000 --- a/src/SUPERVGUI/SUPERVGUI_Graph.h +++ /dev/null @@ -1,123 +0,0 @@ -// SUPERV SUPERVGUI : GUI for Supervisor component -// -// 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 -// -// -// -// File : SUPERVGUI_Graph.h -// Author : Francis KLOSS -// Module : SUPERV - -#ifndef SUPERVGUI_Graph_H -#define SUPERVGUI_Graph_H - -using namespace std; -//#include "SUPERVGUI.h" -#include "SUPERVGUI_View.h" -#include "SUPERVGUI_Node.h" -#include "SUPERVGUI_Link.h" -#include "SUPERVGUI_CtrlLink.h" -#include "SUPERVGUI_Def.h" -#include "QAD_SpinBoxDbl.h" -#include -#include -#include - - -class SUPERVGUI_Main; - -class SUPERVGUI_Graph: public SUPERVGUI_View { - Q_OBJECT - - public: - SUPERVGUI_Graph(SUPERVGUI_Main* m); - virtual ~SUPERVGUI_Graph(); - - void sync(); - void contentsMousePressEvent(QMouseEvent* e); - void contentsMouseReleaseEvent(QMouseEvent* e); - void contentsMouseMoveEvent(QMouseEvent* e); - - - virtual void setAsFromStudy(bool theToStudy); - - bool isLinkPrsExists(SUPERV_Link theLink); - bool createLinkPrs(SUPERV_Link theLink); - void removeLinks() - { myLinksList.clear(); }; - - void setFullView(); - void setControlView(); - bool isControlView() { return myIsControlView; } - - void deleteLink(SUPERVGUI_Link* theLink); - - void deleteNode(SUPERVGUI_Node* theNode); - - void draw(); - void clearView(); - - bool isAnyLinkCreating() { return (myNewLink != 0);}; - -signals: - void mouseMoved(QMouseEvent* theEvent); - void mousePressed(QMouseEvent* theEvent); - void mouseReleased(QMouseEvent* theEvent); - -public slots: - void sketchBegin(SUPERVGUI_Port* thePort); - void sketchEnd(SUPERVGUI_Port* thePort); - - -private slots: - void addPoint(); - void deleteLink(); - void deletePoint(); - void delLastPnt(); - void delCreatingLink(); - void setOrtho(); - - protected: - bool eventFilter(QObject* object, QEvent* event); - - private: - - QPoint myMousePos; - SUPERVGUI_Link* mySelectedLink; - int mySelectedPoint; - - // Popup menu for link creation management - QPopupMenu* mySketchPopup; - int myDelPntItem; - int myOrtoItem; - - // Popup menu for link - QPopupMenu* myLinkPopup; - int myDelLinkPntItem; - int myAddLinkPntItem; - int myDelLinkItem; - - bool myIsControlView; - SUPERVGUI_Link* myNewLink; - QPtrList myLinksList; - QMap myCtrlLinks; -}; - -#endif diff --git a/src/SUPERVGUI/SUPERVGUI_GraphNode.cxx b/src/SUPERVGUI/SUPERVGUI_GraphNode.cxx deleted file mode 100644 index 75a214f..0000000 --- a/src/SUPERVGUI/SUPERVGUI_GraphNode.cxx +++ /dev/null @@ -1,511 +0,0 @@ -// SUPERV SUPERVGUI : GUI for Supervisor component -// -// Copyright (C) 2003 CEA/DEN, EDF R&D -// -// -// -// File : SUPERVGUI_ComputeNode.cxx -// Author : Vitaly SMETANNIKOV -// Module : SUPERV - -using namespace std; -#include "SUPERVGUI_GraphNode.h" -#include "SUPERVGUI_Graph.h" -#include "SUPERVGUI_Main.h" - - -SUPERVGUI_GraphNode::SUPERVGUI_GraphNode(QWidget* theParent, SUPERVGUI_Main* theMain, SUPERV_CNode theNode) - :SUPERVGUI_Node(theParent, theMain, theNode), - MouseX(MouseNo), - MouseY(MouseNo) -{ - //disconnect(myTitle, 0, this, 0); - myTitle = new SUPERVGUI_Label(this, LABEL_WIDTH, LABEL_HEIGHT, name(), QLabel::AlignLeft); - myTitle->hide(); - connect(myTitle, SIGNAL(MousePress(QMouseEvent*)), this, SLOT(mouseTitlePress(QMouseEvent*))); - connect(myTitle, SIGNAL(MouseMove (QMouseEvent*)), this, SLOT(mouseTitleMove(QMouseEvent*))); - connect(myTitle, SIGNAL(MouseRelease(QMouseEvent*)), this, SLOT(mouseTitleRelease(QMouseEvent*))); - - myPortsBox = new QVBox(0); - myPortsBox->setSpacing(3); - myValuesBox = new QWidget(myPortsBox); - myPortLayout = new QGridLayout(myValuesBox, 0, 2, 0, 1); - - SUPERV_StreamPorts aStreamPorts = myNode->StreamPorts(); - int aStreamNb = aStreamPorts->length(); - if (aStreamNb) { - myStreamBox = new QFrame(myPortsBox); - myStreamBox->setPaletteForegroundColor(red.dark()); - myStreamBox->setPaletteBackgroundColor(paletteBackgroundColor()); - myStreamBox->setFrameStyle( QFrame::Box | QFrame::Plain ); - myStreamBox->setLineWidth(1); - myStreamLayout = new QGridLayout(myStreamBox, 0, 2, 2, 3); - } else { - myStreamBox = 0; - myStreamLayout = 0; - } - myGatesBox = new QFrame(myPortsBox); - myGatesBox->setFrameStyle( QFrame::Panel | QFrame::Raised ); - myGatesBox->setLineWidth(2); - // myGatesBox->setPaletteBackgroundColor(backgroundColor().dark(105)); - myGatesBox->setPaletteBackgroundColor(green.light(170)); - myGatesLayout = new QGridLayout(myGatesBox, 0, 2); - myGatesLayout->setMargin(3); - - myTimer = new QTimer(this); - connect(myTimer, SIGNAL(timeout()), this, SLOT(movingNode(/*QMouseEvent* e*/))); - myStopFlag = true; - - myX = -1; - myY = -1; - myDifX = 0; - myDifY = 0; - myFirstDifX = 0; - myFirstDifY = 0; - - 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].in()), - 0, 0); - else { - myPortLayout->addWidget(new SUPERVGUI_PortInESNode(myValuesBox, myMain, ports[i].in()), - myPIcount, 0); - myPIcount++; - } - } else { - if (ports[i]->IsGate()) - myGatesLayout->addWidget(new SUPERVGUI_PortIn(myGatesBox, myMain, ports[i].in()), - 0, 0); - else { - myPortLayout->addWidget(new SUPERVGUI_PortIn(myValuesBox, myMain, ports[i].in()), - myPIcount, 0); - myPIcount++; - } - } - } else { - if (ports[i]->IsGate()) - myGatesLayout->addWidget(new SUPERVGUI_PortOut(myGatesBox, myMain, ports[i].in()), - 0, 1, Qt::AlignRight); - else { - myPortLayout->addWidget(new SUPERVGUI_PortOut(myValuesBox, myMain, ports[i].in()), - myPOcount, 1, Qt::AlignRight); - myPOcount++; - } - } - } - myStrPIcount = 0; - myStrPOcount = 0; - for (int i=0; i < aStreamNb; i++) { - if (aStreamPorts[i]->IsInput()) { - myStreamLayout->addWidget(new SUPERVGUI_StreamPortIn(myStreamBox, myMain, aStreamPorts[i].in()), - myStrPIcount, 0); - myStrPIcount++; - } else { - myStreamLayout->addWidget(new SUPERVGUI_StreamPortOut(myStreamBox, myMain, aStreamPorts[i].in()), - myStrPOcount, 1, Qt::AlignRight); - myStrPOcount++; - } - } -} - - - -SUPERVGUI_GraphNode::~SUPERVGUI_GraphNode() { -} - -void SUPERVGUI_GraphNode::mouseTitlePress(QMouseEvent* e) { - if (!myMain->getGraph()->isAnyLinkCreating()) { - if (e->button() == RightButton) { - MouseLeft = 0; - showPopup(e); - } else { - MouseLeft = 1; - SUPERVGUI_Graph* sv = myMain->getGraph(); - MouseX = sv->childX(this) - e->globalX(); - MouseY = sv->childY(this) - e->globalY(); - } - } -} - -void SUPERVGUI_GraphNode::mouseTitleMove(QMouseEvent* e) { - Trace("SUPERVGUI_Node::moveAgain") - SUPERVGUI_Graph* sv = myMain->getGraph(); - - if ((MouseX == MouseNo) && (MouseY == MouseNo)) { - MouseX = sv->childX(this) - e->globalX(); - MouseY = sv->childY(this) - e->globalY(); - MouseLeft = (e->state() == RightButton? 0: 1); - }; - - if (MouseLeft == 1) { - - int x = e->globalX()+MouseX; - int y = e->globalY()+MouseY; - x = x<0? 0: x; - y = y<0? 0: y; - - if (x > myMain->getGraph()->horizontalScrollBar()->value() - + myMain->getGraph()->viewport()->width() - width()/2 - || - y > myMain->getGraph()->verticalScrollBar()->value() - + myMain->getGraph()->viewport()->height() - height()/2 - || - x < myMain->getGraph()->horizontalScrollBar()->value() - || - y < myMain->getGraph()->verticalScrollBar()->value()){ - if (!myTimer->isActive()) { - myX = x; - myY = y; - myDifX = x - myNode->X(); - myDifY = y - myNode->Y(); - myFirstDifX = myDifX; - myFirstDifY = myDifY; - } - - StartTimer(); - myStopFlag = false; - - if (x - myNode->X() > 15 && abs(myDifX) < abs(myDifY)) { - if (x > myMain->getGraph()->horizontalScrollBar()->value() - + myMain->getGraph()->viewport()->width() - width()/2) - myDifX = 5; // or another positive number - else { - //not out of the right boundary - sv->moveChild(this, x, myNode->Y()); //new X and old Y - myNode->Coords(x, myNode->Y()); - myX = x; - } - } - - if (x - myNode->X() < -15 && abs(myDifX) < abs(myDifY)) { - if(x < myMain->getGraph()->horizontalScrollBar()->value()) - myDifX = -5; //or another negative number - else { - //not out of the left boundary - sv->moveChild(this, x, myNode->Y()); //new X and old Y - myNode->Coords(x, myNode->Y()); - myX = x; - } - } - - if (y - myNode->Y() > 15 && abs(myDifX) > abs(myDifY)) { - if (y > myMain->getGraph()->verticalScrollBar()->value() - + myMain->getGraph()->viewport()->height() - height()/2) - myDifY = 5; //or another positive number - else { - //not out of the lower boundary - sv->moveChild(this, myNode->X(), y); //old X and new Y - myNode->Coords(myNode->X(), y); - myY = y; - } - } - - if (y - myNode->Y() < -15 && abs(myDifX) > abs(myDifY)) { - if (y < myMain->getGraph()->verticalScrollBar()->value()) - myDifY = -5; //or another negative number - else { - //not out of the upper boundary - sv->moveChild(this, myNode->X(), y); //old X and new Y - myNode->Coords(myNode->X(), y); - myY = y; - } - } - - } - else { - if ((myDifX*(x - myNode->X()) < 0 || myDifY*(y - myNode->Y()) < 0)) { - StopTimer(); - myStopFlag = true; - } - //for mouse moving to boundaries from outside space (chack then node must be move) - int xp1, yp1, xp2, yp2; - xp1 = myMain->getGraph()->horizontalScrollBar()->value(); - xp2 = myMain->getGraph()->horizontalScrollBar()->value() + - myMain->getGraph()->viewport()->width(); - yp1 = myMain->getGraph()->verticalScrollBar()->value(); - yp2 = myMain->getGraph()->verticalScrollBar()->value() + - myMain->getGraph()->viewport()->height(); - if (x >= xp1 - && x <= xp1+myMain->getGraph()->viewport()->visibleRect().width() - && y >= yp1 - && y <= yp1+myMain->getGraph()->viewport()->visibleRect().height()) { - sv->moveChild(this, x, y); - myNode->Coords(x, y); - } - - } - } -} - -void SUPERVGUI_GraphNode::mouseTitleRelease(QMouseEvent* e) { - StopTimer(); - myStopFlag = true; -} - -void SUPERVGUI_GraphNode::movingNode() { - SUPERVGUI_Graph* sv = myMain->getGraph(); - - myX = myX<0 ? 0: myX; - myY = myY<0 ? 0: myY; - - if (myDifX > 0) - myX = myX + 5; - if (myDifX < 0) - myX = myX - 5; - if (myDifY > 0) - myY = myY + 5; - if (myDifY < 0) - myY = myY - 5; - - myMain->getGraph()->ResizeGraph(this, myX, myY); - myMain->getGraph()->scrollBy( myX - myNode->X(), myY - myNode->Y() ); - sv->moveChild(this, myX, myY); - myNode->Coords(myX, myY); -} - -void SUPERVGUI_GraphNode::StartTimer() { - Trace("SUPERVGUI_Main::StartTimer") - if (!myTimer->isActive()) { - myTimer->start(170); - }; -} - -void SUPERVGUI_GraphNode::StopTimer() { - Trace("SUPERVGUI_Main::StopTimer") - if (myTimer->isActive()) { - myTimer->stop(); - }; -} - -void SUPERVGUI_GraphNode::deleteLinks() { - QObjectList* aList = queryList("SUPERVGUI_Port"); - SUPERVGUI_Port* aPort; - QObjectListIt aIt(*aList); - while ((aPort=(SUPERVGUI_Port*)aIt.current()) != 0) { - ++aIt; - aPort->deleteLinks(); - } - delete aList; -} - - -void SUPERVGUI_GraphNode::sync() { - SUPERVGUI_Node::sync(); - - SUPERVGUI_Port* pi; - QObjectList* ihmList = queryList("SUPERVGUI_Port"); - QObjectListIt i(*ihmList); - while ((pi=(SUPERVGUI_Port*)i.current()) != 0) { - ++i; - pi->sync(); - } - delete ihmList; - - //check: is creation of link is complete - if (myMain->getGraph()->isAnyLinkCreating()) { - //not creation complete - myPopup->setItemEnabled(myDeleteItem, false); - } - else { - //creation complete - myPopup->setItemEnabled(myDeleteItem, true); - } -} - - -/** - * Creates presentation of links to In ports - * If toCheckExisting = false the links will be created without checking - * of their existing in Graph - * If toCheckExisting = true the existing of links will be checked before creation - */ -void SUPERVGUI_GraphNode::updateLinksPrs(bool toCheckExisting) { - - SUPERVGUI_Graph* aGraph= myMain->getGraph(); - //Find PortInESNode - SUPERVGUI_PortInESNode* piES; - QObjectList* ihmListES = queryList("SUPERVGUI_PortInESNode"); - QObjectListIt iES(*ihmListES); - 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(aLink)) - continue; - } - aGraph->createLinkPrs(aLink); - } - } - delete ihmList; - } - - delete ihmListES; -} - - -void SUPERVGUI_GraphNode::setNodeName(QString theName) { - SUPERVGUI_Node::setNodeName(theName); - myTitle->setText(name()); -} - - -void SUPERVGUI_GraphNode::deletePort(SUPERVGUI_Port* thePort) { - if (thePort->isA("SUPERVGUI_PortIn") || thePort->isA("SUPERVGUI_PortInESNode")) { - myPIcount--; - } - else { - myPOcount--; - } - thePort->deleteLinks(); - - thePort->getPort()->destroy(); - - thePort->close(true); - - updatePorts(); - updateShape(); -} - - -void SUPERVGUI_GraphNode::addInputPort() { - SUPERV_Port aPort = createInPort(); - if (aPort == NULL) return; - - if (getNodeType() == SUPERV::EndSwitchNode) { - SUPERVGUI_PortInESNode* aPortPrs = new SUPERVGUI_PortInESNode(myValuesBox, myMain, aPort.in()); - myPortLayout->addWidget(aPortPrs, myPIcount, 0); - - if (myPortsBox->isVisible()) { - aPortPrs->show(); - } - } - else { - SUPERVGUI_PortIn* aPortPrs = new SUPERVGUI_PortIn(myValuesBox, myMain, aPort.in()); - myPortLayout->addWidget(aPortPrs, myPIcount, 0); - - if (myPortsBox->isVisible()) { - aPortPrs->show(); - } - } - - myPIcount++; - updatePorts(); - updateShape(); -} - - -void SUPERVGUI_GraphNode::addOutputPort() { - SUPERV_Port aPort = createOutPort(); - if (aPort == NULL) return; - - SUPERVGUI_PortOut* aPortPrs = new SUPERVGUI_PortOut(myValuesBox, myMain, aPort.in()); - myPortLayout->addWidget(aPortPrs, myPOcount, 1, Qt::AlignRight); - myPOcount++; - if (myPortsBox->isVisible()) { - aPortPrs->show(); - } - updatePorts(); - updateShape(); -} - - -void SUPERVGUI_GraphNode::updatePorts() { - bool isAdded = false; - SUPERV_Ports aPorts = getEngine()->Ports(); - int n = aPorts->length(); - SUPERVGUI_Port* aPortPrs; - bool aIsVisible = myPortsBox->isVisible(); - for (int i=0; i < n; i++) { - QString aName(aPorts[i]->Name()); - aName += (aPorts[i]->IsInput())? "Input":"Output"; - aPortPrs = (SUPERVGUI_Port*) child(aName, "SUPERVGUI_Port"); - if (aPortPrs == NULL) { - if (aPorts[i]->IsInput()) { - SUPERVGUI_PortIn* aPortIn; - if (aPorts[i]->IsGate()) { - aPortIn = new SUPERVGUI_PortIn(myGatesBox, myMain, aPorts[i].in()); - myGatesLayout->addWidget(aPortIn, myPIcount, 0); - } else { - aPortIn = new SUPERVGUI_PortIn(myValuesBox, myMain, aPorts[i].in()); - myPortLayout->addWidget(aPortIn, myPIcount, 0); - myPIcount++; - } - if (aIsVisible) aPortIn->show(); - isAdded = true; - } else { - SUPERVGUI_PortOut* aPortOut; - if (aPorts[i]->IsGate()) { - aPortOut = new SUPERVGUI_PortOut(myGatesBox, myMain, aPorts[i].in()); - myGatesLayout->addWidget(aPortOut, myPOcount, 1, Qt::AlignRight); - } else { - aPortOut = new SUPERVGUI_PortOut(myValuesBox, myMain, aPorts[i].in()); - myPortLayout->addWidget(aPortOut, myPOcount, 1, Qt::AlignRight); - myPOcount++; - } - if (aIsVisible) aPortOut->show(); - isAdded = true; - } - } - } - - QObjectList* aShownPortsList = queryList("SUPERVGUI_Port"); - QObjectListIt aLI(*aShownPortsList); - SUPERVGUI_Port* aVisPort; - - - while ((aVisPort=(SUPERVGUI_Port*)aLI.current()) != 0) { - ++aLI; - QString aNameVisible(aVisPort->getPort()->Name()); - - bool aIsExists = false; - for (int i=0; i < n; i++) { - QString aName(aPorts[i]->Name()); - if (aName == aNameVisible) - aIsExists = true; - } - - if (!aIsExists) { //we have a visible object, which has no engine entity - aVisPort->close(true); - } - } -} - - -/** - * Returns coordinates of connection point in content coordinates - */ -QPoint SUPERVGUI_GraphNode::getInConnectPnt() { - return QPoint(pos().x(), - pos().y() + (height()/2)); -} -QPoint SUPERVGUI_GraphNode::getOutConnectPnt() { - return QPoint(pos().x() + width(), - pos().y() + (height()/2)); -} diff --git a/src/SUPERVGUI/SUPERVGUI_GraphNode.h b/src/SUPERVGUI/SUPERVGUI_GraphNode.h deleted file mode 100644 index 03c227f..0000000 --- a/src/SUPERVGUI/SUPERVGUI_GraphNode.h +++ /dev/null @@ -1,94 +0,0 @@ -// SUPERV SUPERVGUI : GUI for Supervisor component -// -// Copyright (C) 2003 CEA/DEN, EDF R&D -// -// -// -// File : SUPERVGUI_GraphNode.h -// Author : Vitaly SMETANNIKOV -// Module : SUPERV - -#ifndef SUPERVGUI_GraphNode_H -#define SUPERVGUI_GraphNode_H - -#include "SUPERVGUI_Node.h" -#include - - -class SUPERVGUI_GraphNode: public SUPERVGUI_Node { - Q_OBJECT - - public: - SUPERVGUI_GraphNode(QWidget* theParent, SUPERVGUI_Main* theMain, SUPERV_CNode theNode); - virtual ~SUPERVGUI_GraphNode(); - - virtual void hideAll() {}; - virtual void showAll() {}; - - virtual void deleteLinks(); - virtual void sync(); - - virtual void updateLinksPrs(bool toCheckExisting = false); - virtual void setNodeName(QString aName); - - virtual void deletePort(SUPERVGUI_Port* thePort); - - virtual QPoint getInConnectPnt(); - virtual QPoint getOutConnectPnt(); - - virtual void updateShape() {}; - virtual void updatePorts(); - - int& getPIcount() - { return myPIcount;} - - int& getPOcount() - { return myPOcount;} - - public slots: - void mouseTitlePress(QMouseEvent* e); - void mouseTitleMove(QMouseEvent* e); - void mouseTitleRelease(QMouseEvent* e); - void movingNode(); - virtual void addInputPort(); - virtual void addOutputPort(); - -// virtual void addInputPortES(); -// virtual void addOutputPortES(); - - protected: - SUPERVGUI_Label* myTitle; - - QVBox* myPortsBox; - QWidget* myValuesBox; - QGridLayout* myPortLayout; - - QFrame* myGatesBox; - QGridLayout* myGatesLayout; - - QFrame * myStreamBox; - QGridLayout* myStreamLayout; - - QTimer* myTimer; - int myPIcount; - int myPOcount; - - int myStrPIcount; - int myStrPOcount; - - private: - void StartTimer(); - void StopTimer(); - int MouseX; - int MouseY; - int MouseLeft; - int myX; - int myY; - int myDifX; - int myDifY; - int myFirstDifX; - int myFirstDifY; - bool myStopFlag; - -}; -#endif diff --git a/src/SUPERVGUI/SUPERVGUI_Label.cxx b/src/SUPERVGUI/SUPERVGUI_Label.cxx deleted file mode 100644 index 862519c..0000000 --- a/src/SUPERVGUI/SUPERVGUI_Label.cxx +++ /dev/null @@ -1,58 +0,0 @@ -// SUPERV SUPERVGUI : GUI for Supervisor component -// -// 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 -// -// -// -// File : SUPERVGUI_Label.cxx -// Author : Francis KLOSS -// Module : SUPERV - -using namespace std; -#include "SUPERVGUI_Label.h" -#include "SUPERVGUI_Def.h" - -SUPERVGUI_Label::SUPERVGUI_Label(QWidget* parent, int dx, int dy, const char* text, int a) - : QLabel(parent) { - Trace("SUPERVGUI_Label::SUPERVGUI_Label") - setMinimumSize(dx, dy); - setMaximumSize(dx, dy); - setText((QString)text); - setAlignment(a | QLabel::AlignVCenter); -} - -SUPERVGUI_Label::~SUPERVGUI_Label() { - Trace("SUPERVGUI_Label::~SUPERVGUI_Label") -} - -void SUPERVGUI_Label::mousePressEvent(QMouseEvent* e) { - Trace("SUPERVGUI_Label::mousePressEvent") - emit MousePress(e); -} - -void SUPERVGUI_Label::mouseReleaseEvent(QMouseEvent* e) { - Trace("SUPERVGUI_Label::mouseReleaseEvent") - emit MouseRelease(e); -} - -void SUPERVGUI_Label::mouseMoveEvent(QMouseEvent* e) { - Trace("SUPERVGUI_Label::mouseMoveEvent") - emit MouseMove(e); -} diff --git a/src/SUPERVGUI/SUPERVGUI_Label.h b/src/SUPERVGUI/SUPERVGUI_Label.h deleted file mode 100644 index 21d374b..0000000 --- a/src/SUPERVGUI/SUPERVGUI_Label.h +++ /dev/null @@ -1,51 +0,0 @@ -// SUPERV SUPERVGUI : GUI for Supervisor component -// -// 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 -// -// -// -// File : SUPERVGUI_Label.h -// Author : Francis KLOSS -// Module : SUPERV - -#ifndef SUPERVGUI_Label_H -#define SUPERVGUI_Label_H - -using namespace std; -#include - -class SUPERVGUI_Label: public QLabel { - Q_OBJECT - - public: - SUPERVGUI_Label(QWidget* parent, int dx, int dy, const char* text, int a); - virtual ~SUPERVGUI_Label(); - - void mousePressEvent(QMouseEvent* e); - void mouseReleaseEvent(QMouseEvent* e); - void mouseMoveEvent(QMouseEvent* e); - - signals: - void MousePress(QMouseEvent* e); - void MouseRelease(QMouseEvent* e); - void MouseMove(QMouseEvent* e); -}; - -#endif diff --git a/src/SUPERVGUI/SUPERVGUI_Library.cxx b/src/SUPERVGUI/SUPERVGUI_Library.cxx new file mode 100644 index 0000000..d9473ed --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_Library.cxx @@ -0,0 +1,653 @@ +// SUPERV SUPERVGUI : GUI for Supervisor component +// +// 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 +// +// +// +// File : SUPERVGUI_Library.cxx +// Author : Alexander SLADKOV +// Module : SUPERV + + +#include "SUPERVGUI_Library.h" +#include "SUPERVGUI_Main.h" +#include "SUPERVGUI.h" + +#include "QAD_MessageBox.h" +#include "QAD_Application.h" + +#include +#include +#include +#include +#include + +using namespace std; + +#define LIBFILE "/.salome/InLineLibrary.xml" // $HOME+LIBFILE +#define DOCTYPE "InLineNodesLibrary" // XML DocType +#define ROOT_ELEMENT "inlinenodeslibrary" // XML Element and Attribute tags (many) +#define NODE_ELEMENT "INode" +#define NODE_NAME_ATT "Name" +#define NODE_KIND_ATT "Kind" +#define PORT_ELEMENT "Port" +#define ES_PORT_ELEMENT "ESPort" +#define PORT_INPUT_ATT "IsInput" +#define PORT_NAME_ATT "Name" +#define PORT_TYPE_ATT "Type" + +#define FUNC_NAME_ATT "PyFuncName" // XML attributes and elements +#define FUNC_ELEMENT "PyFunc" // for Python functions defined +#define FUNC_INIT_NAME_ATT "InitFuncName" // in different types of InLine nodes +#define FUNC_INIT_ELEMENT "InitPyFunc" +#define FUNC_MORE_NAME_ATT "MoreFuncName" +#define FUNC_MORE_ELEMENT "MorePyFunc" +#define FUNC_NEXT_NAME_ATT "NextFuncName" +#define FUNC_NEXT_ELEMENT "NextPyFunc" +#define FUNC_EL_NAME_ATT "ELFuncName" // EndLoop +#define FUNC_EL_ELEMENT "ELPyFunc" +#define FUNC_ES_NAME_ATT "ESFuncName" // EndSwitch +#define FUNC_ES_ELEMENT "ESPyFunc" + + +SUPERVGUI_Library* SUPERVGUI_Library::myLibrary = 0; + +/** + * Inline nodes library. constructor. + */ +SUPERVGUI_Library::SUPERVGUI_Library() { +} + +/** + * Returns the XML file name used as InLine nodes repository + */ +const char* SUPERVGUI_Library::GetLibraryFileName() const { + string aFileName = getenv( "HOME" ); + aFileName += LIBFILE; + return aFileName.c_str(); +} + +/** + * Creates a new library file, truncates the length to zero, writes an empty + * XML stub to it. If fails - displays an error message box and returns false + */ +bool SUPERVGUI_Library::createLibFile() const { + QFile libFile( GetLibraryFileName() ); + try { + if ( libFile.open( IO_WriteOnly | IO_Truncate ) ) { + QDomDocument doc( DOCTYPE ); // create a simple XML stub + doc.appendChild( doc.createElement( ROOT_ELEMENT ) ); // IMPORTANT: do not delete this root element + QTextStream stream( &libFile ); + doc.save( stream, 0 ); + libFile.close(); + return true; + } + else { + QAD_MessageBox::error1( (QWidget*)QAD_Application::getDesktop(), tr( "ERROR" ), tr( "MSG_ERROR_LIB1" ), tr( "OK" ) ); + return false; // error opening library file for writing + } + } + catch ( ... ) { + QAD_MessageBox::error1( (QWidget*)QAD_Application::getDesktop(), tr( "ERROR" ), tr( "MSG_ERROR_LIB_IO" ), tr( "OK" ) ); + } + return false; +} + +/** + * Save Function Name as attribute of given DomElement, and Function strings as its children with CDATASection + * saveStrings() is called to save 'main' Py function of a node, and Init(), More(), Next() for Loop node + */ +void saveStrings( QDomDocument doc, QDomElement element, const char* theNameAtt, const char* theFuncName, + const char* theFuncElem, SUPERV::ListOfStrings_var pyFunc ) { + QString pyFuncName( theFuncName ); + element.setAttribute( theNameAtt, pyFuncName ); // store Py function name + + // store Py functions as children of 'element'. + for ( int i = 0, n = pyFunc->length(); i < n; i++ ) { + QString pyFuncStr( pyFunc[i] ); + QDomCDATASection aCDATA = doc.createCDATASection( pyFuncStr ); + QDomElement funcElement = doc.createElement( theFuncElem ); + element.appendChild( funcElement ); + funcElement.appendChild( aCDATA ); + } +} + +/** + * Export an InLine node to Library + */ +bool SUPERVGUI_Library::Export( SUPERV::INode_var theNode ) const { + try { + if ( CORBA::is_nil( theNode ) ) { + QAD_MessageBox::error1( (QWidget*)QAD_Application::getDesktop(), tr( "ERROR" ), tr( "MSG_ERROR_LIB_NIL_NODE" ), tr( "OK" ) ); + return false; // null node + } + + // open existing library file or create a new one and set some empty XML content + QFile libFile( GetLibraryFileName() ); + if ( !libFile.exists() ) { // new library + if ( !createLibFile() ) + return false; // error opening library file for writing. MB was already displayed + } + + // create the main XML document object + QString docName( DOCTYPE ) ; + QDomDocument doc( docName ); + bool xmlOk = doc.setContent( &libFile ); + if ( xmlOk ) + xmlOk = ( doc.elementsByTagName( ROOT_ELEMENT ).length() == 1 ); // find "root" element + QDomNode rootElement; + if ( xmlOk ) { + rootElement = doc.elementsByTagName( ROOT_ELEMENT ).item( 0 ); + xmlOk = ( !rootElement.isNull() ); + } + if ( !xmlOk ) { + const int toRecreate = QAD_MessageBox::error2( (QWidget*)QAD_Application::getDesktop(), tr( "ERROR" ), + tr( "MSG_ERROR_LIB_IS_RECREATE" ), tr( "BUT_YES" ), tr( "BUT_NO" ), 1, 0, 0 ); + if ( toRecreate ) { // user selected to recreate a bad XML file + libFile.close(); // in case it was opened by doc.setContent() + if ( !createLibFile() ) + return false; // error opening library file for writing. MB was already displayed + + // library file was successfully recreated. now re-set content, init rooElement. No checking - it MUST be OK. + libFile.setName( GetLibraryFileName() ); // IMPORTANT: re-read the file + doc.setContent( &libFile ); // no checking of setContent() and find root element is done, since we are sure + rootElement = doc.elementsByTagName( ROOT_ELEMENT ).item( 0 ); // that in newly created file everything is OK + } + else // user chose not to recreate a bad library file + return false; // library file is corrupt (bad XML structure), don't recreate + } + + // if theNode is EndSwitch or EndLoop -> first export Switch or Loop node + if ( theNode->IsEndLoop() || theNode->IsEndSwitch() ) { + SUPERV::GNode_var aTmpNode = SUPERV::GNode::_narrow( theNode ); + theNode = aTmpNode->Coupled(); + if ( CORBA::is_nil( theNode ) ) { + QAD_MessageBox::error1( (QWidget*)QAD_Application::getDesktop(), tr( "ERROR" ), tr( "MSG_ERROR_LIB_NIL_COUPLED" ), tr( "OK" ) ); + return false; // null coupled node + } + } + + // create element under main document + QDomElement element = doc.createElement( NODE_ELEMENT ) ; + rootElement.appendChild( element ); + + // save node's name and kind + element.setAttribute( NODE_NAME_ATT, theNode->Name() ); + element.setAttribute( NODE_KIND_ATT, theNode->Kind() ); + // save the 'main' Py function of the node + saveStrings( doc, element, FUNC_NAME_ATT, theNode->PyFuncName(), FUNC_ELEMENT, theNode->PyFunction() ); + + // create DOM elements for ports + SUPERV::ListOfPorts_var aPorts = theNode->Ports(); + for ( int i = 0, n = aPorts->length(); i < n; i++) { + if ( !CORBA::is_nil( aPorts[i] ) && !aPorts[i]->IsGate() ) { + QDomElement portElement = doc.createElement( PORT_ELEMENT ); + portElement.setAttribute( PORT_INPUT_ATT, aPorts[i]->IsInput() ); + portElement.setAttribute( PORT_NAME_ATT, aPorts[i]->Name() ); + portElement.setAttribute( PORT_TYPE_ATT, aPorts[i]->Type() ); + element.appendChild( portElement ); + } + } + + // if the node is Loop -> additionally export Init(), More(), Next() and EndLoop's function + if ( theNode->IsLoop() ) { + SUPERV::LNode_var aLoopNode = SUPERV::LNode::_narrow( theNode ); + if ( CORBA::is_nil( aLoopNode ) ) { + QAD_MessageBox::error1( (QWidget*)QAD_Application::getDesktop(), tr( "ERROR" ), tr( "MSG_ERROR_LIB_BAD_LOOP" ), tr( "OK" ) ); + return false; + } + SUPERV::INode_var aEndLoopNode = aLoopNode->Coupled(); + if ( CORBA::is_nil( aEndLoopNode ) ) { + QAD_MessageBox::error1( (QWidget*)QAD_Application::getDesktop(), tr( "ERROR" ), tr( "MSG_ERROR_LIB_BAD_LOOP" ), tr( "OK" ) ); + return false; + } + // save init, more, next, end-loop functions of the Loop node + saveStrings( doc, element, FUNC_INIT_NAME_ATT, aLoopNode->PyInitName(), FUNC_INIT_ELEMENT, aLoopNode->PyInit() ); + saveStrings( doc, element, FUNC_MORE_NAME_ATT, aLoopNode->PyMoreName(), FUNC_MORE_ELEMENT, aLoopNode->PyMore() ); + saveStrings( doc, element, FUNC_NEXT_NAME_ATT, aLoopNode->PyNextName(), FUNC_NEXT_ELEMENT, aLoopNode->PyNext() ); + saveStrings( doc, element, FUNC_EL_NAME_ATT, aEndLoopNode->PyFuncName(), FUNC_EL_ELEMENT, aEndLoopNode->PyFunction() ); + } + + // if the node is Switch -> additionally export EndSwitch's function and ports + if ( theNode->IsSwitch() ) { + SUPERV::SNode_var aSwitchNode = SUPERV::SNode::_narrow( theNode ); + if ( CORBA::is_nil( aSwitchNode ) ) { + QAD_MessageBox::error1( (QWidget*)QAD_Application::getDesktop(), tr( "ERROR" ), tr( "MSG_ERROR_LIB_BAD_SWITCH" ), tr( "OK" ) ); + return false; + } + SUPERV::INode_var aEndSwitchNode = aSwitchNode->Coupled(); + if ( CORBA::is_nil( aEndSwitchNode ) ) { + QAD_MessageBox::error1( (QWidget*)QAD_Application::getDesktop(), tr( "ERROR" ), tr( "MSG_ERROR_LIB_BAD_SWITCH" ), tr( "OK" ) ); + return false; + } + // save EndSwitch function + saveStrings( doc, element, FUNC_ES_NAME_ATT, aEndSwitchNode->PyFuncName(), FUNC_ES_ELEMENT, aEndSwitchNode->PyFunction() ); + + // save ports of EndSwitch + SUPERV::ListOfPorts_var aESPorts = aEndSwitchNode->Ports(); + for ( int i = 0, n = aESPorts->length(); i < n; i++) { + if ( !CORBA::is_nil( aESPorts[i] ) && !aESPorts[i]->IsGate() ) { + QDomElement portElement = doc.createElement( ES_PORT_ELEMENT ); + portElement.setAttribute( PORT_INPUT_ATT, aESPorts[i]->IsInput() ); + portElement.setAttribute( PORT_NAME_ATT, aESPorts[i]->Name() ); + portElement.setAttribute( PORT_TYPE_ATT, aESPorts[i]->Type() ); + element.appendChild( portElement ); + } + } + } // end of IsSwitch() + + // OK, done with file export. write the document to the file + libFile.close(); // it seems that QDomDocument opens the file when doing + // setContent() and does not close it + if ( libFile.open( IO_WriteOnly ) ) { // IO_WriteOnly truncates the file! + QTextStream stream( &libFile ); + doc.save( stream, 0 ); + libFile.close(); + return true; + } + else { // error opening library file for final writing + QAD_MessageBox::error1( (QWidget*)QAD_Application::getDesktop(), tr( "ERROR" ), tr( "MSG_ERROR_LIB_WRITE" ), tr( "OK" ) ); + return false; + } + } // try + catch ( ... ) { + } + + // should get here only in case of exception + QAD_MessageBox::error1( (QWidget*)QAD_Application::getDesktop(), tr( "ERROR" ), tr( "MSG_ERROR_EXPORT_EXCEPTION" ), tr( "OK" ) ); + return false; +} + +/** + * Returns in out parameters Py function name and Py function body + */ +void getStrings( QDomElement element, const char* pyFuncName, QString& thePyFuncName, + const char* theFuncElem, SUPERV::ListOfStrings_var& pyFunc ) { + QDomNamedNodeMap aNodeAtt = element.attributes(); + if ( !aNodeAtt.namedItem( pyFuncName ).isNull() ) { // if pyFuncName is found - fill pyFunc. + thePyFuncName = aNodeAtt.namedItem( pyFuncName ).nodeValue(); + + // every 'theFuncElem' element has a CDATA child - one line + // iterate through all of them twice: 1) to count the number of these items (number of strings) + // 2) to fill pyFunc out-parameter + int nStrings( 0 ); + QDomNode n = element.firstChild(); + while ( !n.isNull() ) { + if ( n.isElement() && n.nodeName() == theFuncElem && n.firstChild().isCDATASection() ) + nStrings++; + n = n.nextSibling(); + } + + pyFunc->length( nStrings ); + + int i( 0 ); + n = element.firstChild(); + while ( !n.isNull() ) { + if ( n.isElement() && n.nodeName() == theFuncElem && n.firstChild().isCDATASection() ) { + QDomCDATASection aCDATA = n.firstChild().toCDATASection(); + pyFunc[i++] = aCDATA.nodeValue(); + } + n = n.nextSibling(); + } + } // if ( pyFuncName ) +} +/** + * Adds ports stored in Dom node to the CNode + */ +void addPorts( SUPERV::INode_var theINode, QDomElement element, const char* portElement ) { + QDomNodeList aPorts = element.elementsByTagName( portElement ); + for ( int i = 0, n = aPorts.length(); i < n; i++ ) { + QDomNode aPort = aPorts.item( i ); + QDomNamedNodeMap anAtt = aPort.attributes(); + bool isInput = ( anAtt.namedItem( PORT_INPUT_ATT ).nodeValue() == "1" ); + QString portName = anAtt.namedItem( PORT_NAME_ATT ).nodeValue(); + QString portType = anAtt.namedItem( PORT_TYPE_ATT ).nodeValue(); + if ( isInput ) + theINode->InPort( portName.latin1(), portType.latin1() ); + else + theINode->OutPort( portName.latin1(), portType.latin1() ); + } +} + +/** + * Import an InLine node from Library into the dataflow + */ +bool SUPERVGUI_Library::Import( SUPERV::Graph_var theDataflow, SUPERV::INode_var& theNode, + SUPERV::INode_var& theEndNode, const int i ) const { + try { + QDomNodeList aNodes; + QDomDocument doc; + if ( getNodes( doc, aNodes ) ) { // xml is ok + if ( i >=0 && i < aNodes.length() ) { // index is ok + // 1. retrieve the node with given index + QDomElement aNode = aNodes.item( i ).toElement(); + // 2. create an Engines node + QDomNamedNodeMap aNodeAtt = aNode.attributes(); + const int aKind = aNodeAtt.namedItem( NODE_KIND_ATT ).nodeValue().toInt(); + QString aNodeName = aNodeAtt.namedItem( NODE_NAME_ATT ).nodeValue(); + switch ( aKind ) { + case SUPERV::InLineNode : // PyFunction + case SUPERV::GOTONode : + { + // get all the Python function + QString aPyFuncName; + SUPERV::ListOfStrings_var aPyFunc = new SUPERV::ListOfStrings(); + getStrings( aNode, FUNC_NAME_ATT, aPyFuncName, FUNC_ELEMENT, aPyFunc ); + + // create the corresponding Engines node + SUPERV::INode_var aINode; + if ( aKind == SUPERV::InLineNode ) + aINode = theDataflow->INode( aPyFuncName.latin1(), aPyFunc ); + else + aINode = theDataflow->GNode( aPyFuncName.latin1(), aPyFunc, "" ); + + aINode->SetName( aNodeName.latin1() ); // try to set the same name of node (might be changed by CNode::SetName) + addPorts( aINode, aNode, PORT_ELEMENT ); // add stored ports + + theNode = aINode; // init out-parameter + return true; + } + case SUPERV::LoopNode : // PyInit, PyNext, PyMore, PyEndLoopFunction + { + // get all required Python function + QString aInitName, aMoreName, aNextName, aELName; + SUPERV::ListOfStrings_var aInitFunc = new SUPERV::ListOfStrings(), + aMoreFunc = new SUPERV::ListOfStrings(), + aNextFunc = new SUPERV::ListOfStrings(), + aELFunc = new SUPERV::ListOfStrings(); + getStrings( aNode, FUNC_INIT_NAME_ATT, aInitName, FUNC_INIT_ELEMENT, aInitFunc ); + getStrings( aNode, FUNC_MORE_NAME_ATT, aMoreName, FUNC_MORE_ELEMENT, aMoreFunc ); + getStrings( aNode, FUNC_NEXT_NAME_ATT, aNextName, FUNC_NEXT_ELEMENT, aNextFunc ); + getStrings( aNode, FUNC_EL_NAME_ATT, aELName, FUNC_EL_ELEMENT, aELFunc ); + + // create Engines Loop node + SUPERV::INode_var aELNode; + SUPERV::INode_var aINode = theDataflow->LNode( aInitName.latin1(), aInitFunc, + aMoreName.latin1(), aMoreFunc, + aNextName.latin1(), aNextFunc, aELNode ); + // EndLoop node may have or may NOT have pyFunc. set it if it was stored. + if ( !aELName.isEmpty() ) + aELNode->SetPyFunction( aELName.latin1(), aELFunc ); + + aINode->SetName( aNodeName.latin1() );// try to set the same name of node (might be changed by CNode::SetName) + addPorts( aINode, aNode, PORT_ELEMENT ); // add stored ports + + theNode = aINode; // init out-parameters + theEndNode = aELNode; + return true; + } + case SUPERV::SwitchNode : // PyFunction, PyESFunction, ESPorts + { + // get all required Python function + QString aPyFuncName, aESPyFuncName; + SUPERV::ListOfStrings_var aPyFunc = new SUPERV::ListOfStrings(), + aESPyFunc = new SUPERV::ListOfStrings(); + getStrings( aNode, FUNC_NAME_ATT, aPyFuncName, FUNC_ELEMENT, aPyFunc ); + getStrings( aNode, FUNC_ES_NAME_ATT, aESPyFuncName, FUNC_ES_ELEMENT, aESPyFunc ); + + // create Engines Switch node + SUPERV::INode_var aESNode; + SUPERV::INode_var aINode = theDataflow->SNode( aPyFuncName.latin1(), aPyFunc, aESNode ); + + // EndSwitch node may have or may NOT have pyFunc + if ( !aESPyFuncName.isEmpty() ) + aESNode->SetPyFunction( aESPyFuncName.latin1(), aESPyFunc ); + + aINode->SetName( aNodeName.latin1() );// try to set the same name of node (might be changed by CNode::SetName) + addPorts( aINode, aNode, PORT_ELEMENT ); // add stored ports + addPorts( aESNode, aNode, ES_PORT_ELEMENT ); // add stores ports of EndSwitch + + theNode = aINode; // init out-parameters + theEndNode = aESNode; + return true; + } + default: // wrong kind of node error + QAD_MessageBox::error1( (QWidget*)QAD_Application::getDesktop(), tr( "ERROR" ), tr( "MSG_ERROR_IMPORT_BAD_KIND_OF_NODE" ), tr( "OK" ) ); + return false; + } // switch ( kind_of_node ) + } // if ( index >= 0...) + else { + QAD_MessageBox::error1( (QWidget*)QAD_Application::getDesktop(), tr( "ERROR" ), tr( "MSG_ERROR_IMPORT_BAD_INDEX" ), tr( "OK" ) ); + } + } // if ( getNodes() ) + else { + return false; // no MB, getNodes() in case of errors displays MB itself + } + } // try + catch ( ... ) { + } + + // Normally we get here ONLY if an exception occured. All other paths of execution must return before. + // But - who knows, maybe we can get here by some other means.. anyway, it's an error and we report it here + QAD_MessageBox::error1( (QWidget*)QAD_Application::getDesktop(), tr( "ERROR" ), tr( "MSG_ERROR_IMPORT_EXCEPTION" ), tr( "OK" ) ); + return false; +} + +/** + * Returns list of NODE_ELEMENT-s and error result (false) if failed (also displays MB) + */ +bool SUPERVGUI_Library::getNodes( QDomDocument& doc, QDomNodeList& theNodes ) const { + QFile libFile( GetLibraryFileName() ); // open existing library file + if ( !libFile.exists() ) { + QAD_MessageBox::error1( (QWidget*)QAD_Application::getDesktop(), tr( "ERROR" ), tr( "MSG_ERROR_IMPORT_LIB_NO_XML" ), tr( "OK" ) ); + return false; + } + + // create the main XML document object + QString docName( DOCTYPE ) ; + doc = QDomDocument( docName ); + bool xmlOk = doc.setContent( &libFile ); + // check XML for validity: 1) find root element with predefined name 2) check xml doctype + if ( xmlOk ) + xmlOk = ( doc.doctype().name() == DOCTYPE && doc.elementsByTagName( ROOT_ELEMENT ).length() == 1 ); + if ( !xmlOk ) { + QAD_MessageBox::error1( (QWidget*)QAD_Application::getDesktop(), tr( "ERROR" ), tr( "MSG_ERROR_IMPORT_LIB_BAD_XML" ), tr( "OK" ) ); + return false; + } + + theNodes = doc.elementsByTagName( NODE_ELEMENT ); + return true; +} + +/** + * Remove an InLine node with given index from Library + */ +bool SUPERVGUI_Library::Remove( const int i ) const { + QDomNodeList aNodes; + QDomDocument doc; + if ( getNodes( doc, aNodes ) && doc.elementsByTagName( ROOT_ELEMENT ).length() == 1 ) { // xml is ok + if ( i >=0 && i < aNodes.length() ) { + // 1. remove the child element (node) from Dom Document + QDomElement root = doc.elementsByTagName( ROOT_ELEMENT ).item( 0 ).toElement(); + root.removeChild( aNodes.item( i ) ); + // 2. write the modified document to the file + QFile libFile( GetLibraryFileName() ); + if ( libFile.open( IO_WriteOnly | IO_Truncate ) ) { + QTextStream stream( &libFile ); + doc.save( stream, 0 ); + libFile.close(); + return true; + } + } + } + return false; +} + +/** + * Returns a string descriptor of KindOfNode enumeration + */ +QString getKindStr( const QString& theKind ) { + switch ( theKind.toInt() ) { + case SUPERV::InLineNode : return "InLine"; + case SUPERV::LoopNode : return "Loop"; + case SUPERV::SwitchNode : return "Switch"; + case SUPERV::GOTONode : return "GOTO"; + case SUPERV::FactoryNode : + case SUPERV::DataFlowGraph : + case SUPERV::ComputingNode : + case SUPERV::EndLoopNode : + case SUPERV::EndSwitchNode : + case SUPERV::DataStreamGraph : + case SUPERV::MacroNode : + case SUPERV::UnknownNode : + default: + ; + } + return "INCORRECT kind"; +} + +/** + * returns a list of node names currently stored in the library. Indexes of the nodes in + * this list can be used for futher calls to Import(.., index) + */ +SUPERV::ListOfStrings SUPERVGUI_Library::GetLibraryNodesNames() const { + SUPERV::ListOfStrings aNodesNames; + aNodesNames.length( 0 ); + + QDomNodeList aNodes; + QDomDocument doc; + if ( !getNodes( doc, aNodes ) ) + return aNodesNames; + + const int n = aNodes.length(); + aNodesNames.length( n ); + QDomNode aNode; + for ( int i = 0; i < n; i++ ) { + QString aNodeName( "" ); + aNode = aNodes.item( i ); + if ( !aNode.isNull() ) { + QDomNode aNameAtt = aNode.attributes().namedItem( NODE_NAME_ATT ); + QDomNode aTypeAtt = aNode.attributes().namedItem( NODE_KIND_ATT ); + if ( !aNameAtt.isNull() && !aTypeAtt.isNull() ) { + aNodeName = QString( "%1 ( %2 )" ).arg( aNameAtt.toAttr().value() ).arg( + getKindStr( aTypeAtt.toAttr().value() ) ); + } + } + // if NodeName attribute was not found or some error (NULL node), + // then an empty string is added for that index in the list + aNodesNames[i] = aNodeName.latin1(); + } + + return aNodesNames; +} + +/** + * returns status of library: false indicates that library file does not exist or can not be opened + */ +bool SUPERVGUI_Library::CanImport() const { + try { + QDomNodeList aNodes; + QDomDocument doc; + return getNodes( doc, aNodes ); + } + catch ( ... ) { + } + return false; +} + + + + + +/** + * Inline nodes library management dialog. constructor. + */ +SUPERVGUI_LibDlg::SUPERVGUI_LibDlg( QWidget* parent, int& theX, int& theY ) + :QDialog( parent, "SUPERVGUI_LibDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu), + myX( theX ), myY( theY ) +{ + setSizeGripEnabled( true ); + setCaption(tr("TIT_LIB_DLG")); + resize( 350, 400 ); + QGridLayout* aMainLayout = new QGridLayout( this, 4, 4, 11, 6 ); + + myLB = new QListBox( this ); + + QPushButton* anAddBtn = new QPushButton( tr("TIT_ADDFNODE"), this ); + connect( anAddBtn, SIGNAL( clicked() ), this, SLOT( add() ) ); + QPushButton* aRemBtn = new QPushButton( tr("BUT_REMOVE"), this ); + connect( aRemBtn, SIGNAL( clicked() ), this, SLOT( remove() ) ); + + aMainLayout->addMultiCellWidget( myLB, 0, 2, 0, 2 ); + aMainLayout->addWidget( anAddBtn, 0, 3 ); + aMainLayout->addWidget( aRemBtn, 1, 3 ); + + QGroupBox* aBtnBox = new QGroupBox( 0, Qt::Vertical, this ); + aBtnBox->layout()->setSpacing( 0 ); aBtnBox->layout()->setMargin( 0 ); + QHBoxLayout* aBtnLayout = new QHBoxLayout( aBtnBox->layout() ); + aBtnLayout->setAlignment( Qt::AlignTop ); + aBtnLayout->setSpacing( 6 ); aBtnLayout->setMargin( 11 ); + + QPushButton* aCloseBtn = new QPushButton( tr("BUT_CLOSE"), aBtnBox ); + connect( aCloseBtn, SIGNAL( clicked() ), this, SLOT( reject() ) ); + aBtnLayout->addStretch(); + aBtnLayout->addWidget( aCloseBtn ); + aBtnLayout->addStretch(); + + aMainLayout->addMultiCellWidget( aBtnBox, 3, 3, 0, 3 ); + aMainLayout->setRowStretch( 2, 1 ); + + initList(); +} + +/** + * Inline nodes library management dialog. destructor. + */ +SUPERVGUI_LibDlg::~SUPERVGUI_LibDlg() {} + +/** + * Called when user presses "Add" button. Add a selected node from library to graph + */ +void SUPERVGUI_LibDlg::add() { + const int i = myLB->currentItem(); + if ( i >= 0 && i < myLB->count() ) { + SUPERV::Graph_var aDataflow = Supervision.getMain()->getDataflow(); + SUPERV::INode_var aNode, aEndNode; + if ( SUPERVGUI_Library::getLibrary()->Import( aDataflow, aNode, aEndNode, i ) ) { + SUPERVGUI_Service::addNode( SUPERV::CNode::_narrow( aNode ), aEndNode, myX, myY ); + Supervision.getMain()->sync(); + } + else { // all errors must be reported to user in Import(), MB shown, etc.. + } // so we don't need to report errors if Import() returned false. + } +} + +/** + * Called when user presses "Remove" button. Remove a selected node from library + */ +void SUPERVGUI_LibDlg::remove() { + const int i = myLB->currentItem(); + if ( i >= 0 && i < myLB->count() ) { + SUPERVGUI_Library::getLibrary()->Remove( i ); + initList(); // re-initialize the list to reflect the changes + } +} + +/** + * Fills the list with names of nodes currently stored in the library. Indexes in the list + * can be used for calls to Library::Import() + */ +void SUPERVGUI_LibDlg::initList() { + myLB->clear(); + SUPERV::ListOfStrings aNodesNames = SUPERVGUI_Library::getLibrary()->GetLibraryNodesNames(); + for ( int i = 0, n = aNodesNames.length(); i < n; i++ ) + myLB->insertItem( (const char*)aNodesNames[i] ); +} + diff --git a/src/SUPERVGUI/SUPERVGUI_Library.h b/src/SUPERVGUI/SUPERVGUI_Library.h new file mode 100644 index 0000000..2991fae --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_Library.h @@ -0,0 +1,113 @@ +// SUPERV SUPERVGUI : GUI for Supervisor component +// +// 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 +// +// +// +// File : SUPERVGUI_Library.h +// Author : Alexander SLADKOV +// Module : SUPERV + +#ifndef SUPERVGUI_Library_H +#define SUPERVGUI_Library_H + +#include +#include + +#include "utilities.h" +#include "SALOME_LifeCycleCORBA.hxx" +#include CORBA_CLIENT_HEADER(SUPERV) + +class QListBox; + +/** + * SUPERVGUI_Library class is intended for management of InLine nodes library. + * InLine nodes library is an XML repository (currently it is a predefined user-dependant XML file) + * with InLine nodes stored in it. InLine node in a library contains its Python code and lists of + * input and output ports. + */ +class SUPERVGUI_Library : QObject { // extending QObject to enable slot/signals + + Q_OBJECT + +protected: + SUPERVGUI_Library(); // constructor is protected, use static function getLibrary() + +public: + static SUPERVGUI_Library* getLibrary() { + if ( !myLibrary ) + myLibrary = new SUPERVGUI_Library(); + return myLibrary; + } + + // Returns the XML file name used as InLine nodes repository + const char* GetLibraryFileName() const; + + // Export an InLine node to Library + bool Export( SUPERV::INode_var theNode ) const; + + // Import an InLine node from Library into the dataflow + bool Import( SUPERV::Graph_var theDataflow, SUPERV::INode_var& theNode, + SUPERV::INode_var& theEndNode, const int theLibIndex ) const; + + // Remove an InLine node with given index from Library + bool Remove( const int i ) const; + + // returns a list of node names currently stored in the library. Indexes of the nodes in + // this list can be used for futher calls to Import(.., index) + SUPERV::ListOfStrings GetLibraryNodesNames() const; + + // returns status of library: false indicates that library file does not exist or can not be opened + bool CanImport() const; + +private: + static SUPERVGUI_Library* myLibrary; + + bool createLibFile() const; // returns false on file creation error (also displays MB) + + // returns list of NODE_ELEMENT-s and error result (false) if failed (also displays MB) + bool getNodes( QDomDocument& theDoc, QDomNodeList& theNodes ) const; + +}; + +/** + * Dialog box for Add/Remove InLine nodes to Library, Add node to Graph from Library + */ +class SUPERVGUI_LibDlg: public QDialog { + + Q_OBJECT + +public: + SUPERVGUI_LibDlg( QWidget* parent, int& theX, int& theY ); + ~SUPERVGUI_LibDlg(); + +private slots: + void add(); // add selected node from library to graph + void remove(); // remove selected node from library + +private: + void initList(); // clear and fill list with nodes from Library + + QListBox* myLB; + int& myX; // comes from caller - SUPERVGUI_Service, used for calculating next node_s position + int& myY; // comes from caller - SUPERVGUI_Service +}; + +#endif diff --git a/src/SUPERVGUI/SUPERVGUI_Link.cxx b/src/SUPERVGUI/SUPERVGUI_Link.cxx deleted file mode 100644 index adaa31d..0000000 --- a/src/SUPERVGUI/SUPERVGUI_Link.cxx +++ /dev/null @@ -1,819 +0,0 @@ -// SUPERV SUPERVGUI : GUI for Supervisor component -// -// Copyright (C) 2003 CEA/DEN, EDF R&D -// -// -// -// File : SUPERVGUI_Link.cxx -// Author : Vitaly SMETANNIKOV -// Module : SUPERV - -using namespace std; -#include "SUPERVGUI_Graph.h" -#include "SUPERVGUI_Main.h" -#include "SUPERVGUI_Link.h" - - - -#define SKETCH_CLR Qt::green -#define DRAW_CLR Qt::black -#define HLT_CLR Qt::magenta -#define CTRL_CLR Qt::red - -#define LINE_WIDTH 2 -#define PNT_SIZE 6 - - -// Prevents moving of several links at once -bool SUPERVGUI_Link::LinkIsMoving=false; - -bool SUPERVGUI_Link::OrthoMode = false; - -SUPERVGUI_Link* SUPERVGUI_Link::SelectedLink=0; - -/** - * Consructor: - * If link is NULL - this must be defined later - */ -SUPERVGUI_Link::SUPERVGUI_Link(SUPERVGUI_Graph* theGraph, SUPERV_Link theLink) { - myGraph = theGraph; - myEngine = theLink; - myPortIn = 0; - myPortInES = 0; - myPortOut = 0; - myStartPort = 0; - myHltPnt = -1; - myPntMovingState = false; - myPainter = 0; - myIsVisible = true; - myTmpPen.setColor(SKETCH_CLR); - myTmpPen.setWidth(LINE_WIDTH); - myIsSelected = false; - myTmpPoints.clear(); - - if (!SUPERV_isNull(myEngine)) - connectToEvents(); -} - - -//********************************************************************** -SUPERVGUI_Link::~SUPERVGUI_Link() { - if (!SUPERV_isNull(myEngine)) { - disconnect(myGraph, 0, this, 0); - } - if (SelectedLink == this) SelectedLink=0; - emit linkDeleted(this); -} - - -//********************************************************************** -void SUPERVGUI_Link::setInputPort(SUPERVGUI_PortIn* thePortIn) { - myPortIn = thePortIn; - myPortIn->setLinkPrs(this); -} - - -//********************************************************************** -void SUPERVGUI_Link::setInputPortES(SUPERVGUI_PortInESNode* thePortInES) { - myPortInES = thePortInES; - myPortInES->setLinkPrs(this); -} - -//********************************************************************** -bool SUPERVGUI_Link::isESInputPort() { - if (myPortInES) - return true; - else - return false; -} - -//********************************************************************** -void SUPERVGUI_Link::destroyEngine() { - if (!SUPERV_isNull(myEngine)) { - myEngine->destroy(); - } -} - -//********************************************************************** -void SUPERVGUI_Link::setOutputPort(SUPERVGUI_PortOut* thePortOut){ - myPortOut = thePortOut; - myPortOut->addLinkPrs(this); -} - - -//********************************************************************** -void SUPERVGUI_Link::addPoint(long theX, long theY) { - if (SUPERV_isNull(myEngine)) return; - - if (myEngine->CoordsSize() <= 0) { - myEngine->AddCoord(1, theX, theY); - return; - } else { - QPoint aPnt(theX, theY); - long aX, aY; - myEngine->Coords(1, aX, aY); - if (!isESInputPort()) { - if (distance(aPnt, myGraph->viewportToContents(myPortIn->getConnectPnt()), - QPoint(aX, aY)) <= 0) { - myEngine->AddCoord(1, theX, theY); - return; - } - } - else { - if (distance(aPnt, myGraph->viewportToContents(myPortInES->getConnectPnt()), - QPoint(aX, aY)) <= 0) { - myEngine->AddCoord(1, theX, theY); - return; - } - } - - int i = 2; - long aNextX, aNextY; - for (i = 2; i <= myEngine->CoordsSize(); i++) { - myEngine->Coords(i, aNextX, aNextY); - if (distance(aPnt, QPoint(aX, aY), - QPoint(aNextX, aNextY)) <= 0) { - myEngine->AddCoord(i, theX, theY); - return; - } - aX = aNextX; - aY = aNextY; - } - if (distance(aPnt, QPoint(aX, aY), - myGraph->viewportToContents(myPortOut->getConnectPnt())) <= 0) { - myEngine->AddCoord(myEngine->CoordsSize()+1, theX, theY); - return; - } - } - repaint(); -} - - -//********************************************************************** -/** - * Can be used only in Sketching mode - */ -void SUPERVGUI_Link::addTmpPoint(QPoint thePnt) { - if (OrthoMode) { - int aSize = myTmpPoints.size(); - QPoint aPrevPnt; - // Previous point - if (aSize > 0) - aPrevPnt = myTmpPoints[aSize-1]; - else - aPrevPnt = myStartPort->getConnectPnt(); - - // Next point - QPoint aNewPoint; - if (Abs(thePnt.x() - aPrevPnt.x()) > - Abs(thePnt.y() - aPrevPnt.y())) { - aNewPoint = QPoint(thePnt.x(), aPrevPnt.y()); - } else { - aNewPoint = QPoint(aPrevPnt.x(), thePnt.y()); - } - // repaint last line - - myPainter->drawLine(aPrevPnt, thePnt); - myPainter->moveTo(aPrevPnt); - myPainter->lineTo(aNewPoint); - myPainter->lineTo(thePnt); - - myTmpPoints.push_back(aNewPoint); - } else - myTmpPoints.push_back(thePnt); -} - - -//********************************************************************** -/** - * Can be used only in Sketching mode - */ -void SUPERVGUI_Link::delLastTmpPoint() { - int aSize = myTmpPoints.size(); - if (aSize > 0) { - QPoint aRemPnt = myTmpPoints[aSize-1]; - - QPoint aLastPnt; - if (aSize > 1) - aLastPnt = myTmpPoints[aSize-2]; - else - aLastPnt = myStartPort->getConnectPnt(); - - myPainter->moveTo(aLastPnt); - myPainter->lineTo(aRemPnt); - myPainter->lineTo(myPrevPoint); - - myPainter->drawLine(aLastPnt, myPrevPoint); - - myTmpPoints.pop_back(); - } -} - - -//********************************************************************** -void SUPERVGUI_Link::removeLastPoint() { - if (myEngine && (!SUPERV_isNull(myEngine))) - myEngine->RemoveCoord(myEngine->CoordsSize()); -} - - -//********************************************************************** -void SUPERVGUI_Link::removePoint(int thePnt) { - if ((thePnt > -1) && (!SUPERV_isNull(myEngine))) { - paint(true); - myEngine->RemoveCoord(thePnt); - paint(false); - } -} - -//********************************************************************** -/** - * Repaints the link - */ -void SUPERVGUI_Link::repaint() { - paint(true); - paint(false); -} - - -//********************************************************************** -/** - * Paints or erases the link - * if toErase = true then it draws link by background color - */ -void SUPERVGUI_Link::paint(bool toErase) { - if ((!myGraph) || (!myIsVisible)) return; - if (!myEngine && SUPERV_isNull(myEngine)) return; - // if (!isCreationComplete()) return; - - QPainter aPainter(myGraph->viewport()); - QPen aDataPen; - aDataPen.setWidth(LINE_WIDTH); - - if (toErase) { - aDataPen.setColor(myGraph->viewport()->paletteBackgroundColor()); - } else { - if ((strcmp(myEngine->InPort()->Name(), "InVoid")==0) || - (myEngine->InPort()->Kind() == SUPERV::DataStreamParameter )) - aDataPen.setColor(CTRL_CLR); - else - aDataPen.setColor(DRAW_CLR); - } - aPainter.setPen(aDataPen); - drawLink(&aPainter); -} - - -//********************************************************************** -/** - * Defines a pen and draws link using given painter - */ -void SUPERVGUI_Link::paint(QPainter* thePainter, bool toErase) { - if ((!myGraph) || (!myIsVisible)) return; - if (!myEngine && SUPERV_isNull(myEngine)) return; - // if (!isCreationComplete()) return; - thePainter->save(); - - QPen aDataPen; - aDataPen.setWidth(LINE_WIDTH); - - if (toErase) { - aDataPen.setColor(myGraph->viewport()->paletteBackgroundColor()); - } else { - if ((strcmp(myEngine->InPort()->Name(), "InVoid")==0)|| - (myEngine->InPort()->Kind() == SUPERV::DataStreamParameter )) - aDataPen.setColor(CTRL_CLR); - else - aDataPen.setColor(DRAW_CLR); - } - thePainter->setPen(aDataPen); - drawLink(thePainter); - thePainter->restore(); -} - - -//********************************************************************** -/** - * Draws link using given painter - */ -void SUPERVGUI_Link::drawLink(QPainter* thePainter) { - if (!myIsVisible) return; - if (!isESInputPort()) - thePainter->moveTo(myPortIn->getConnectPnt()); - else - thePainter->moveTo(myPortInES->getConnectPnt()); - long aX, aY; - QPoint aPnt; - for (int i=0; i < myEngine->CoordsSize(); i++) { - myEngine->Coords(i+1, aX, aY); - aPnt = myGraph->contentsToViewport(QPoint(aX, aY)); - thePainter->lineTo(aPnt); - thePainter->drawEllipse(aPnt.x()-PNT_SIZE/2, aPnt.y()-PNT_SIZE/2, - PNT_SIZE, PNT_SIZE); - } - thePainter->lineTo(myPortOut->getConnectPnt()); -} - - -//********************************************************************** -/** - * Repaints whole link when it is sketching - */ -void SUPERVGUI_Link::repaintSketch() { - if (!myStartPort) return; - if (!myPainter) return; - - // myPainter->save(); - //myPainter->setRasterOp(Qt::CopyROP); - myPainter->moveTo(myStartPort->getConnectPnt()); - for (int i = 0; i< myTmpPoints.size(); i++) { - myPainter->lineTo(myGraph->contentsToViewport(myTmpPoints[i])); - } - myPainter->lineTo(myPrevPoint); - //myPainter->restore(); -} - - -//********************************************************************** -/** - * Drawing of non created link following to mouse pointer - */ -void SUPERVGUI_Link::drawTo(QPoint thePnt) { - if (!myStartPort) { - if (myPortIn) - myStartPort = myPortIn; - else if (myPortInES) - myStartPort = myPortInES; - else if (myPortOut) - myStartPort = myPortOut; - else - return; - } - if (!myPainter) { - myPainter = new QPainter(myGraph->viewport()); - myPainter->setPen(myTmpPen); - myPainter->setRasterOp(Qt::XorROP); - myPrevPoint = myStartPort->getConnectPnt(); - LinkIsMoving = true; - } - - long aX, aY; - - QPoint aStartPnt; - if (myTmpPoints.size() > 0) - aStartPnt = myGraph->contentsToViewport(myTmpPoints[myTmpPoints.size()-1]); - else - aStartPnt = myStartPort->getConnectPnt(); - - // erase old line - myPainter->drawLine(aStartPnt, myPrevPoint); - - // draw new line - QPoint aNewPoint = myGraph->contentsToViewport(thePnt); - myPainter->drawLine(aStartPnt, aNewPoint); - myPrevPoint = aNewPoint; - -} - - -//********************************************************************** -/** - * Set link non visible - */ -void SUPERVGUI_Link::setVisible(bool theVisible) { - myIsVisible = theVisible; - if (myIsVisible) { - connectToEvents(); - } else { - disconnect(myGraph, 0, this, 0); - } -} - - -//********************************************************************** -/** - * Checks full definition of the link - */ -bool SUPERVGUI_Link::isCreationComplete() { - bool aIsBoth = myPortIn && myPortOut; - if (myPortIn && myPortOut) { - // Check: is the same node? - SUPERV_Port aInPort = myPortIn->getPort(); - QString aInNodeName(aInPort->Node()->Name()); - SUPERV_Port aOutPort = myPortOut->getPort(); - QString aOutNodeName(aOutPort->Node()->Name()); - - bool aCanCreate = true; - // Stream port can be connected only with stream port - if (myPortIn->getPort()->Kind() == SUPERV::DataStreamParameter) - aCanCreate = (myPortOut->getPort()->Kind() == SUPERV::DataStreamParameter); - else if (myPortOut->getPort()->Kind() == SUPERV::DataStreamParameter) - aCanCreate = (myPortIn->getPort()->Kind() == SUPERV::DataStreamParameter); - - return aCanCreate && (aInNodeName != aOutNodeName); - } - else if (myPortInES && myPortOut) { - SUPERV_Port aInPortES = myPortInES->getPort(); - QString aInNodeName(aInPortES->Node()->Name()); - SUPERV_Port aOutPort = myPortOut->getPort(); - QString aOutNodeName(aOutPort->Node()->Name()); - - return (aInNodeName != aOutNodeName); - } - else - return false; -} - -//********************************************************************** -/** - * Abort creation of link - */ -void SUPERVGUI_Link::abortCreation() { - LinkIsMoving = false; -} - -//********************************************************************** -/** - * Final procedure of link creation - */ -bool SUPERVGUI_Link::createEngine() { - // clear temporary drawing - QPen aOldPen(myGraph->viewport()->paletteBackgroundColor(), LINE_WIDTH); - //check if myPainter not null - if (myPainter) { - myPainter->setPen(aOldPen); - myPainter->setRasterOp(Qt::CopyROP); - - QPoint aStartPnt; - if (myTmpPoints.size() > 0) - aStartPnt = myGraph->contentsToViewport(myTmpPoints[myTmpPoints.size()-1]); - else - aStartPnt = myStartPort->getConnectPnt(); - - myPainter->drawLine(aStartPnt, myPrevPoint); - - delete myPainter; - myPainter = 0; - } - - // Create engine - if (!isESInputPort()) { - if (myStartPort->getPort()->Kind() == SUPERV::DataStreamParameter) { - SUPERVGUI_StreamPortOut* aOut = dynamic_cast(myPortOut); - SUPERVGUI_StreamPortIn* aIn = dynamic_cast(myPortIn); - // myEngine = myGraph->getMain()->getDataflow()->StreamLink(aOut->getStreamPort(), aIn->getStreamPort()); - SUPERV_StreamGraph aSGraph = myGraph->getMain()->getDataflow()->ToStreamGraph(); - if (!SUPERV_isNull(aSGraph)) - myEngine = aSGraph->StreamLink(aOut->getStreamPort(), aIn->getStreamPort()); - } else - myEngine = myGraph->getMain()->getDataflow()-> - Link(myPortOut->getPort(), myPortIn->getPort()); - } else - myEngine = myGraph->getMain()->getDataflow()-> - Link(myPortOut->getPort(), myPortInES->getPort()); - - if (SUPERV_isNull(myEngine)) return false; - - // remember all points - QPoint aPnt; - if (myStartPort == myPortOut) { - int aSize = myTmpPoints.size(); - for (int i = aSize; i > 0; i--) { - aPnt = myTmpPoints[i-1]; - myEngine->AddCoord(aSize+1-i, aPnt.x(), aPnt.y()); - } - } else { - for (int i = 0; i < myTmpPoints.size(); i++) { - aPnt = myTmpPoints[i]; - myEngine->AddCoord(i+1, aPnt.x(), aPnt.y()); - } - } - LinkIsMoving = false; - - // empty temporary resources - myTmpPoints.clear(); - myStartPort = 0; - connectToEvents(); - paint(false); - return true; -} - - - -//********************************************************************** -void SUPERVGUI_Link::onMouseMove(QMouseEvent * theEvent) { - if (myPntMovingState) { - drawSegments(); - - QPoint aPos = myGraph->contentsToViewport(theEvent->pos()); - int aX = (aPos.x() > 0)? aPos.x(): 1; - int aY = (aPos.y() > 0)? aPos.y(): 1; - aX = (aX < myGraph->contentsWidth())? aX: myGraph->contentsWidth()-1; - aY = (aY < myGraph->contentsHeight())? aY: myGraph->contentsHeight()-1; - - myMovedPnt = QPoint(aX, aY); - drawSegments(); - return; - } - - if (LinkIsMoving) return; - - // Points highlighting - QPoint aPos = theEvent->pos(); - if (myEngine->CoordsSize() > 0 ) { - long aX, aY; - bool aIsFound = false; - for (int i=0; i < myEngine->CoordsSize(); i++) { - myEngine->Coords(i+1, aX, aY); - if (distance(aX, aY, - aPos.x(), - aPos.y()) < (PNT_SIZE+2)) { - myHltPnt = i+1; - aIsFound = true; - break; - } - } - if (!aIsFound) myHltPnt = -1; - } - - // Highlight line - if (isSelected(aPos)) { - if (SelectedLink==0) { - QPen aNewPen(HLT_CLR, LINE_WIDTH); - QPainter aPainter(myGraph->viewport()); - aPainter.setPen(aNewPen); - drawLink(&aPainter); - myIsSelected = true; - SelectedLink = this; - } - } else if (myIsSelected) { - myIsSelected = false; - if (SelectedLink == this) SelectedLink = 0; - paint(false); - } -} - - -//********************************************************************** -/** - * For internal using only - * Draws segments by current Pen when point is moving - */ -void SUPERVGUI_Link::drawSegments() { - myPainter->drawLine(myBeforePnt, myMovedPnt); - myPainter->drawLine(myMovedPnt, myAfterPnt); - myPainter->drawEllipse(myMovedPnt.x()-PNT_SIZE/2, - myMovedPnt.y()-PNT_SIZE/2, - PNT_SIZE, PNT_SIZE); -} - - -//********************************************************************** -void SUPERVGUI_Link::onMousePress(QMouseEvent * theEvent) { - if (LinkIsMoving) { - return; - } - if (theEvent->button() != Qt::LeftButton) { - SelectedLink = 0; - myHltPnt = -1; - return; - } - if (myHltPnt > -1) { // start point moving - if (myHltPnt == 1) { - if (!isESInputPort()) { - myBeforePnt = myPortIn->getConnectPnt(); - } - else { - myBeforePnt = myPortInES->getConnectPnt(); - } - } - else { - long aX, aY; - myEngine->Coords(myHltPnt-1, aX, aY); - myBeforePnt = myGraph->contentsToViewport(QPoint(aX, aY)); - } - if (myHltPnt == myEngine->CoordsSize()) - myAfterPnt = myPortOut->getConnectPnt(); - else { - long aX, aY; - myEngine->Coords(myHltPnt+1, aX, aY); - myAfterPnt = myGraph->contentsToViewport(QPoint(aX, aY)); - } - long aX, aY; - myEngine->Coords(myHltPnt, aX, aY); - myMovedPnt = myGraph->contentsToViewport(QPoint(aX, aY)); - - myPainter = new QPainter(myGraph->viewport()); - QPen aOldPen(myGraph->viewport()->paletteBackgroundColor(), LINE_WIDTH); - - myPainter->setPen(aOldPen); - drawSegments(); - - myPainter->setPen(myTmpPen); - myPainter->setRasterOp(Qt::XorROP); - drawSegments(); - - myPntMovingState = true; - LinkIsMoving = true; - } else if (myHltPnt > -1) - paint(false); -} - -//********************************************************************** -void SUPERVGUI_Link::onMouseRelease(QMouseEvent * theEvent){ - if (theEvent->button() != Qt::LeftButton) return; - - if (myPntMovingState) { - myPntMovingState = false; - LinkIsMoving = false; - drawSegments(); - delete myPainter; - myPainter = 0; - - int aX = (theEvent->pos().x() > 0)? theEvent->pos().x(): 1; - int aY = (theEvent->pos().y() > 0)? theEvent->pos().y(): 1; - aX = (aX < myGraph->contentsWidth())? aX: myGraph->contentsWidth()-1; - aY = (aY < myGraph->contentsHeight())? aY: myGraph->contentsHeight()-1; - myEngine->ChangeCoord(myHltPnt, aX, aY); - - paint(false); - } -} - -//********************************************************************** -/** - * Connects to the Graph mouse events - */ -void SUPERVGUI_Link::connectToEvents() { - connect(myGraph, SIGNAL(mouseMoved(QMouseEvent*)), - this, SLOT(onMouseMove(QMouseEvent*))); - - connect(myGraph, SIGNAL(mousePressed(QMouseEvent*)), - this, SLOT(onMousePress(QMouseEvent*))); - - connect(myGraph, SIGNAL(mouseReleased(QMouseEvent*)), - this, SLOT(onMouseRelease(QMouseEvent*))); -} - - -//********************************************************************** -bool SUPERVGUI_Link::isSelected(QPoint thePnt) { - if (myEngine->CoordsSize() == 0) { - if (!isESInputPort()) { - return (distance(thePnt, myGraph->viewportToContents(myPortOut->getConnectPnt()), - myGraph->viewportToContents(myPortIn->getConnectPnt())) <= 0); - } - else { - return (distance(thePnt, myGraph->viewportToContents(myPortOut->getConnectPnt()), - myGraph->viewportToContents(myPortInES->getConnectPnt())) <= 0); - } - } - else { - long aX, aY; - myEngine->Coords(1, aX, aY); - if (!isESInputPort()) { - if (distance(thePnt, myGraph->viewportToContents(myPortIn->getConnectPnt()), - QPoint(aX, aY)) <= 0) { - return true; - } - } - else { - if (distance(thePnt, myGraph->viewportToContents(myPortInES->getConnectPnt()), - QPoint(aX, aY)) <= 0) { - return true; - } - } - - int i = 2; - long aNextX, aNextY; - for (i = 2; i <= myEngine->CoordsSize(); i++) { - myEngine->Coords(i, aNextX, aNextY); - if (distance(thePnt, QPoint(aX, aY), - QPoint(aNextX, aNextY)) <= 0) { - return true; - } - aX = aNextX; - aY = aNextY; - } - if (distance(thePnt, QPoint(aX, aY), - myGraph->viewportToContents(myPortOut->getConnectPnt())) <= 0) { - return true; - } - } - return false; -} - - -//********************************************************************** -/** - * Returns true if at least one point is within the rect. - * Rect must be in contents coordinate space - */ -bool SUPERVGUI_Link::isInRect(int theX, int theY, int theW, int theH) { - QRect aRect(theX, theY, theW, theH); - if (aRect.contains(myGraph->viewportToContents(myPortOut->getConnectPnt()), true)) - return true; - - if (!isESInputPort()) { - if (aRect.contains(myGraph->viewportToContents(myPortIn->getConnectPnt()), true)) { - return true; - } - } - else { - if (aRect.contains(myGraph->viewportToContents(myPortInES->getConnectPnt()), true)) { - return true; - } - } - - long aX, aY; - QPoint aPrevPnt; - if (!isESInputPort()) - aPrevPnt = myGraph->viewportToContents(myPortIn->getConnectPnt()); - else - aPrevPnt = myGraph->viewportToContents(myPortInES->getConnectPnt()); - for (int i = 1; i <= myEngine->CoordsSize(); i++) { - myEngine->Coords(i, aX, aY); - if (aRect.contains(aX, aY, true)) - return true; - else { - QRect aTmpRect(QPoint(QMIN(aPrevPnt.x(), aX), - QMIN(aPrevPnt.y(), aY)), - QPoint(QMAX(aPrevPnt.x(), aX), - QMAX(aPrevPnt.y(), aY))); - if (aRect.intersects(aTmpRect)) - return true; - aPrevPnt = QPoint(aX, aY); - } - } - QPoint aLastPnt = myGraph->viewportToContents(myPortOut->getConnectPnt()); - QRect aLastRect(QPoint(QMIN(aPrevPnt.x(), aLastPnt.x()), - QMIN(aPrevPnt.y(), aLastPnt.y())), - QPoint(QMAX(aPrevPnt.x(), aLastPnt.x()), - QMAX(aPrevPnt.y(), aLastPnt.y()))); - if (aRect.intersects(aLastRect)) - return true; - - return false; -} - - -//********************************************************************** -/** - * Calculates distance between points - */ -int distance(int x1, int y1, int x2, int y2) { - int x = x2 - x1; - x = x * x; - int y = y2 - y1; - y = y * y; - return (int) sqrt((double)(x + y)); -} - - -//********************************************************************** -/** - * Finds distance between thePnt and line(thePntLn1, thePntLn2) - * Returned value is not an mathematical value - this is only estimation of - * of closing point to the line. 0 - means that point belongs to the line - */ -int distance(QPoint thePnt, QPoint thePntLn1, QPoint thePntLn2) { - int r, s; - int a, b, c; - - int px = thePnt.x(); - int py = thePnt.y(); - int lx = thePntLn1.x(); - int ly = thePntLn1.y(); - int nx = thePntLn2.x(); - int ny = thePntLn2.y(); - - r = px - lx; - r = r * r; - s = py - ly; - s = s * 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)); - - r = nx - lx; - r = r * r; - s = ny - ly; - s = s * s; - c = (int) sqrt((double)(r + s)); - - return (a+b-c); -} - -void SUPERVGUI_Link::setBeginPort(SUPERVGUI_Port* theBeginPort) { - myBeginPort = theBeginPort; -} - -SUPERVGUI_Port* SUPERVGUI_Link::getBeginPort() { - return myBeginPort; -} - - diff --git a/src/SUPERVGUI/SUPERVGUI_Link.h b/src/SUPERVGUI/SUPERVGUI_Link.h deleted file mode 100644 index 06d5ee2..0000000 --- a/src/SUPERVGUI/SUPERVGUI_Link.h +++ /dev/null @@ -1,148 +0,0 @@ -// SUPERV SUPERVGUI : GUI for Supervisor component -// -// Copyright (C) 2003 CEA/DEN, EDF R&D -// -// -// -// File : SUPERVGUI_Link.h -// Author : Vitaly SMETANNIKOV -// Module : SUPERV - -#ifndef SUPERVGUI_Link_H -#define SUPERVGUI_Link_H - -using namespace std; - -#include "SUPERVGUI_Def.h" -#include "SUPERVGUI_Port.h" -//_CS_PhB BUG QT erreur de compilation #include -#include - -class SUPERVGUI_Graph; - -int distance(int x1, int y1, int x2, int y2); -int distance(QPoint thePnt, QPoint thePntLn1, QPoint thePntLn2); - - -class SUPERVGUI_Link: public QObject { - Q_OBJECT - -public: - SUPERVGUI_Link(SUPERVGUI_Graph* theGraph, SUPERV_Link theLink=0); - - virtual ~SUPERVGUI_Link(); - - void setBeginPort(SUPERVGUI_Port* theBeginPort); - SUPERVGUI_Port* getBeginPort(); - - void setInputPort(SUPERVGUI_PortIn* thePortIn); - SUPERVGUI_PortIn* getInputPort() - { return myPortIn; }; - - void setInputPortES(SUPERVGUI_PortInESNode* thePortInES); - SUPERVGUI_PortInESNode* getInputPortES() - { return myPortInES; }; - - bool isESInputPort(); - - void destroyEngine(); - - void setOutputPort(SUPERVGUI_PortOut* thePortOut); - SUPERVGUI_PortOut* getOutputPort() - { return myPortOut; }; - - void addPoint(long theX, long theY); - void removeLastPoint(); - - void repaint(); - void paint(bool toErase); - void paint(QPainter* thePainter, bool toErase); - void drawLink(QPainter* thePainter); - - bool isInRect(int theX, int theY, int theW, int theH); - - SUPERV_Link getEngineLink() - { return myEngine; }; - - void drawTo(QPoint thePnt); - void abortCreation(); - - void repaintSketch(); - void addTmpPoint(QPoint thePnt); - void delLastTmpPoint(); - - bool isCreationComplete(); - bool createEngine(); - - bool isSelected() - { return myIsSelected; }; - - bool haveSelectedPoint() - { return (myHltPnt > -1); }; - - int getSelectedPoint() - { return myHltPnt; }; - - void removePoint(int thePnt); - - void setVisible(bool theVisible); - - static void setOrthoMode(bool theIsOrtho) - { OrthoMode = theIsOrtho; }; - - static bool isOrthoMode() - { return OrthoMode; }; - - static SUPERVGUI_Link* getSelectedLink() - { return SelectedLink; }; - -signals: - void linkDeleted(SUPERVGUI_Link*); - -public slots: - void onMouseMove(QMouseEvent* theEvent); - void onMousePress(QMouseEvent* theEvent); - void onMouseRelease(QMouseEvent* theEvent); - - -private: - void connectToEvents(); - bool isSelected(QPoint thePnt); - - - SUPERVGUI_Graph* myGraph; - SUPERVGUI_Port* myBeginPort; - SUPERVGUI_PortIn* myPortIn; - SUPERVGUI_PortInESNode* myPortInES; - SUPERVGUI_PortOut* myPortOut; - - SUPERV_Link myEngine; - - QPoint myPrevPoint; // used for sketching only - //_CS_PhB BUG QT erreur de compilation QValueVector myTmpPoints; - vector myTmpPoints; - - SUPERVGUI_Port* myStartPort; - - QPen myTmpPen; - - // Points highlighting management - int myHltPnt; // number of point or -1 - - // Points moving management - void drawSegments(); - bool myPntMovingState; - QPoint myBeforePnt, myMovedPnt, myAfterPnt; - QPainter* myPainter; - - // Selection of Link - bool myIsSelected; - - bool myIsVisible; - - static bool OrthoMode; - static bool LinkIsMoving; - static SUPERVGUI_Link* SelectedLink; -}; - -#endif diff --git a/src/SUPERVGUI/SUPERVGUI_Main.cxx b/src/SUPERVGUI/SUPERVGUI_Main.cxx index 93cfd42..0efe33a 100644 --- a/src/SUPERVGUI/SUPERVGUI_Main.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Main.cxx @@ -26,6 +26,7 @@ // Module : SUPERV using namespace std; + #include "QAD_Splitter.h" #include "QAD_LeftFrame.h" #include "QAD_ObjectBrowser.h" @@ -34,101 +35,27 @@ using namespace std; #include "QAD_Message.h" #include "QAD_FileDlg.h" #include "QAD_Application.h" -#include "SUPERVGUI_Def.h" #include "QAD_RightFrame.h" +#include "QAD_SpinBoxDbl.h" + +#include "NOTIFICATION.hxx" #include "SALOME_Event.hxx" +#include "SALOMEGUI_ImportOperation.h" #include "SUPERVGraph_ViewFrame.h" -#include -#include -#include "SUPERVGUI_Main.h" + #include "SUPERVGUI.h" -#include "SUPERVGUI_ComputeNode.h" -#include "SUPERVGUI_ControlNode.h" -#include "NOTIFICATION.hxx" +#include "SUPERVGUI_Def.h" +#include "SUPERVGUI_Main.h" #include "SUPERVGUI_Notification.h" -#include "SALOMEGUI_ImportOperation.h" #include "SUPERVGUI_Information.h" #include "SUPERVGUI_CanvasControlNode.h" -#include -/* -asv 20.10.04: removed 2 SUPERVGUI_Main constructors. there is only ONE way -to create a Main object now: with a non-null DataFlow as a 3d parameter -SUPERVGUI_Main::SUPERVGUI_Main(SUPERVGraph_ViewFrame* theParent, QAD_Desktop* theDesktop, bool fromIOR) - : SUPERVGraph_View(theParent), - myLogged( false ), - myFiltered( false ), - myLogFileName( QString::null ), - myLogFile( NULL ), - myWarning( false ), - myStep( false ), - myTrace( false ), - myVerbose( false ) -{ - Trace("SUPERVGUI_Main::SUPERVGUI_Main (new)"); - theParent->setViewWidget(this); - if (fromIOR) { - //SUPERVGUI_Main* am = Supervision.getMain(); - QAD_ObjectBrowser* ob = ((QAD_StudyFrame*)(theDesktop->getMainFrame()->activeWindow()))->getLeftFrame()->getObjectBrowser(); - // if (am == 0) { - // ob = ((QAD_StudyFrame*)(theDesktop->getMainFrame()->activeWindow()))->getLeftFrame()->getObjectBrowser(); - //} else { - //ob = am->objectBrowser; - //}; - QAD_ObjectBrowserItem* item = (QAD_ObjectBrowserItem*)(ob->getListView()->currentItem()); - SALOMEDS::SObject_var obj = theDesktop->getActiveStudy()->getStudyDocument()->FindObjectID(item->getEntry().latin1()); - SALOMEDS::GenericAttribute_var anAttr; - if (obj->FindAttribute(anAttr, "AttributeIOR")) { - SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - Standard_CString ior = anIOR->Value(); - dataflow = Supervision.getEngine()->getStreamGraph(ior); - if (SUPERV_isNull(dataflow)) { - QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_ACCESS_BAD_IOR")); - close(); - } else { - init(theDesktop); - } - } else { - QMessageBox::warning(0, tr("ERROR"), tr("MSG_NOACCESS_BY_IOR")); - close(); - } - } else { - dataflow = Supervision.getEngine()->StreamGraph(MAIN_NEW); - if (SUPERV_isNull(dataflow)) { - QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_CREATE_DF")); - close(); - } else { - init(theDesktop); - } - } -} +#include +#include +#include +#include +#include -SUPERVGUI_Main::SUPERVGUI_Main(SUPERVGraph_ViewFrame* theParent, QAD_Desktop* theDesktop, bool isModify, const char* f) - : SUPERVGraph_View(theParent), - myLogged( false ), - myFiltered( false ), - myLogFileName( QString::null ), - myLogFile( NULL ), - myWarning( false ), - myStep( false ), - myTrace( false ), - myVerbose( false ) -{ - Trace("SUPERVGUI_Main::SUPERVGUI_Main (file)") - theParent->setViewWidget(this); - if (isModify) { - dataflow = Supervision.getEngine()->StreamGraph(f); - } else { - dataflow = Supervision.getEngine()->StreamGraphE(f); - } - if (SUPERV_isNull(dataflow)) { - QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_BAD_FILE").arg(f)); - close(); - } else { - init(theDesktop); - } -} -*/ SUPERVGUI_Main::SUPERVGUI_Main(SUPERVGraph_ViewFrame* theParent, QAD_Desktop* theDesktop, SUPERV_Graph theDataFlow ) : SUPERVGraph_View(theParent), @@ -164,7 +91,6 @@ void SUPERVGUI_Main::init(QAD_Desktop* theDesktop) { myThread = new SUPERVGUI_Thread(); myThread->setMain(this); - myIsKilled = false; myCurrentView = CANVAS; myIsFromStudy = false; myLastGraph = 0; @@ -197,10 +123,8 @@ void SUPERVGUI_Main::init(QAD_Desktop* theDesktop) { objectBrowser = study->getActiveStudyFrame()->getLeftFrame()->getObjectBrowser(); - - graph = new SUPERVGUI_Graph(this); - graph->hide(); - array = new SUPERVGUI_Array(this); + myArray = new SUPERVGUI_CanvasArray(this); + myArrayView = new SUPERVGUI_ArrayView(myArray, this); myCanvas = new SUPERVGUI_Canvas(this); myCanvasView = new SUPERVGUI_CanvasView(myCanvas, this); @@ -211,13 +135,13 @@ void SUPERVGUI_Main::init(QAD_Desktop* theDesktop) { QBoxLayout * layout = new QVBoxLayout(this); layout->setMargin(0); layout->setSpacing(0); - layout->addWidget(graph); - layout->addWidget(array); layout->addWidget(myCanvasView); + layout->addWidget(myArrayView); if (myCurrentView == CANVAS || myCurrentView == CONTROLFLOW) { myCanvas->merge(); } + sync(); show(); if ( myLogged && !myLogFileName.isEmpty() && QFile::exists( myLogFileName ) ) { @@ -255,12 +179,12 @@ SUPERVGUI_Main::~SUPERVGUI_Main() { if ( myLogFile != NULL) { fclose( myLogFile ); } - graph->removeLinks(); - //delete myCanvas; + // delete notification; // kloss : nota bene : quand un datalow est detruit : verifier que les canaux de notification sont aussi detruit notification->_remove_ref(); // kloss : nota bene : quand un datalow est detruit : verifier que les canaux de notification sont aussi detruit delete myCanvas; + delete myArray; } void SUPERVGUI_Main::filterNotification() { @@ -295,104 +219,65 @@ void SUPERVGUI_Main::filterNotification() { } } -void SUPERVGUI_Main::changeDSGraphParameters() { - SUPERVGUI_DSGraphParameters* aDlg = new SUPERVGUI_DSGraphParameters(dataflow, dataflow->IsReadOnly()); - if (aDlg->exec() ) - sync(); - delete aDlg; -} - void SUPERVGUI_Main::syncAsync() { - Trace("SUPERVGUI_Main::syncAsync") + Trace("SUPERVGUI_Main::syncAsync"); QTimer::singleShot(1, this, SLOT(sync())); } -/** +/** * Called by thread when dataflow is executing */ void SUPERVGUI_Main::execute(char * theNodeName, SUPERV::GraphState theNodeState) { if (myCurrentView == CANVAS || myCurrentView == CONTROLFLOW) { SUPERVGUI_CanvasNode* aNode = (SUPERVGUI_CanvasNode*) myCanvas->child(theNodeName, "SUPERVGUI_CanvasNode"); - if (aNode) aNode->sync(); - } - else { - 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->syncOnEvent(theNodeState); + if ( aNode ) { + aNode->sync(); } } + else if (myCurrentView == CANVASTABLE) { + SUPERVGUI_CanvasCellNode* aNode = (SUPERVGUI_CanvasCellNode*) myArray->child(theNodeName, "SUPERVGUI_CanvasCellNode"); + if (aNode) aNode->sync(); + } } void SUPERVGUI_Main::sync() { - Trace("SUPERVGUI_Main::sync") - if ((SUPERV_isNull(dataflow))) return; - QString t = tr("GRAPH_TITLE"); - - t += dataflow->Name(); - setCaption(t); - - study->updateObjBrowser(); - if (myCurrentView == TABLE) { - array->sync(); - } else if (myCurrentView == GRAPH) { - graph->sync(); - } else { - myCanvas->sync(); - myCanvas->update(); - } -} - - -void SUPERVGUI_Main::showTable() { - if (myCurrentView == TABLE) return; + Trace("SUPERVGUI_Main::sync"); + if ((SUPERV_isNull(dataflow))) + return; + QString t = tr("GRAPH_TITLE"); + + t += dataflow->Name(); + setCaption(t); - if (array->create()) { - if (myCurrentView == GRAPH) - graph->hide(); - else - myCanvasView->hide(); - myCurrentView = TABLE; + study->updateObjBrowser(); + if (myCurrentView == CANVASTABLE) { + myArray->sync(); + myArray->update(); + } else { + myCanvas->sync(); + myCanvas->update(); } - sync(); } +void SUPERVGUI_Main::showCanvasTable() { + if (myCurrentView == CANVASTABLE) + return; -void SUPERVGUI_Main::showFullGraph() { - if (myCurrentView == TABLE) { - array->destroy(); - graph->show(); - } - else if (myCurrentView != GRAPH) { // (myCurrentView == CANVAS) { + if (myArray->create()) { myCanvasView->hide(); - graph->show(); + myArrayView->show(); + myCurrentView = CANVASTABLE; } - myCurrentView = GRAPH; - graph->sync(); - graph->setFullView(); + sync(); } - void SUPERVGUI_Main::showContolFlow() { bool merge = false; - if (myCurrentView == TABLE) { - array->destroy(); - merge = true; - } - else if (myCurrentView == GRAPH) { - graph->hide(); + if (myCurrentView == CANVASTABLE) { + myArrayView->hide(); + myArray->destroy(); merge = true; } myCurrentView = CONTROLFLOW; @@ -404,15 +289,13 @@ void SUPERVGUI_Main::showContolFlow() { } void SUPERVGUI_Main::showCanvas() { - if (myCurrentView == CANVAS) return; + if (myCurrentView == CANVAS) + return; bool merge = false; - if (myCurrentView == TABLE) { - array->destroy(); - merge = true; - } - else if (myCurrentView == GRAPH) { - graph->hide(); + if (myCurrentView == CANVASTABLE) { + myArrayView->hide(); + myArray->destroy(); merge = true; } myCurrentView = CANVAS; @@ -423,43 +306,31 @@ void SUPERVGUI_Main::showCanvas() { } } - -bool SUPERVGUI_Main::exportDataflow(QString theFile) { - Trace("SUPERVGUI_Main::exportDataflow"); - if ((SUPERV_isNull(dataflow))) return false; - - if (!theFile.isEmpty()) { - if (!dataflow->Export(theFile.latin1())) { - QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_BAD_WRITING")); - return false; - } - } - return true; -} - void SUPERVGUI_Main::insertFile() { - Trace("SUPERVGUI_Main::insertFile") + Trace("SUPERVGUI_Main::insertFile"); if ((SUPERV_isNull(dataflow))) return; + Editing(); // PAL6170: GUI->Engine: setting "Editing" flag + QString f = QAD_FileDlg::getFileName(QAD_Application::getDesktop(), "", "*.xml", tr("MSG_GRAPH_INSERT"), true); if (!f.isEmpty()) { - if (dataflow->Import(f.latin1())) { - if (myCurrentView == TABLE) { - array->destroy(); - array->create(); - } - else if (myCurrentView != GRAPH) { // (myCurrentView == CANVAS) { - myCanvas->merge(); - } - sync(); - } else { - QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_BAD_FILE").arg(f)); - }; - }; + if (dataflow->Import(f.latin1())) { + if (myCurrentView == CANVASTABLE) { + myArray->destroy(); + myArray->create(); + } + else { // (myCurrentView == CANVAS || myCurrentView == CONTROLFLOW) { + myCanvas->merge(); + } + sync(); + } else { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_BAD_FILE").arg(f)); + } + } } void SUPERVGUI_Main::copy() { @@ -594,42 +465,33 @@ void SUPERVGUI_Main::onSubGraphClosed(QAD_StudyFrame* theStudyFrame) } void SUPERVGUI_Main::run() { - Trace("SUPERVGUI_Main::run") + Trace("SUPERVGUI_Main::run"); if ((SUPERV_isNull(dataflow))) return; if (dataflow->IsEditing()) { if (!dataflow->IsValid()) { QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTVALID")); - } else if (!dataflow->IsExecutable()) { + } + else if (!dataflow->IsExecutable()) { QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTEXECUTABLE")); - } else if (graph->isAnyLinkCreating() || myCanvasView->isAnyLinkCreating()) { + } + else if (myCanvasView->isAnyLinkCreating()) { QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CRL_NOTCOMPLETE")); - } else { + } + else { myRunTime = QDateTime::currentDateTime(); - if (myIsKilled) { - //if (myIsRunned) { - if (!dataflow->ReRun()) { - QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE")); - if (dataflow->State() == SUPERV::ErrorState) { - kill(); - } - } else { - myThread->startThread(tr("MSG_GRAPH_STARTED")); - //sync(); - } - } else { - if (!dataflow->Run()) { - QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE")); - if (dataflow->State() == SUPERV::ErrorState) { - kill(); - } - } else { - myThread->startThread(tr("MSG_GRAPH_STARTED")); - //sync(); + if ( !dataflow->Run() ) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE")); + if ( dataflow->State() == SUPERV::ErrorState ) { + kill(); } + } + else { + myThread->startThread(tr("MSG_GRAPH_STARTED")); } } - } else { + } + else { QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_RUNNING")); } } @@ -637,57 +499,54 @@ void SUPERVGUI_Main::run() { void SUPERVGUI_Main::startExecute() { - Trace("SUPERVGUI_Main::startExecute") + Trace("SUPERVGUI_Main::startExecute"); if ((SUPERV_isNull(dataflow))) return; if (dataflow->IsEditing()) { if (!dataflow->IsValid()) { QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTVALID")); - } else if (!dataflow->IsExecutable()) { + } + else if (!dataflow->IsExecutable()) { QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTEXECUTABLE")); - } else if (graph->isAnyLinkCreating() || myCanvasView->isAnyLinkCreating()) { + } + else if (myCanvasView->isAnyLinkCreating()) { QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CRL_NOTCOMPLETE")); - } else { + } + else { myRunTime = QDateTime::currentDateTime(); - if (myIsKilled) { - //if (myIsRunned) { - if (!dataflow->ReStart()) { - QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE")); - } else { - myThread->startThread(tr("MSG_GRAPH_STARTED")); - } - } + if (!dataflow->Start()) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE")); + } else { - if (!dataflow->Start()) { - QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_BADEXECUTE")); - } else { - myThread->startThread(tr("MSG_GRAPH_STARTED")); - } + myThread->startThread(tr("MSG_GRAPH_STARTED")); } } - } else { + } + else { QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_RUNNING")); } } void SUPERVGUI_Main::kill() { - Trace("SUPERVGUI_Main::kill") - if ((SUPERV_isNull(dataflow))) return; + Trace("SUPERVGUI_Main::kill"); + if ((SUPERV_isNull(dataflow))) + return; - if (dataflow->IsEditing()) { - 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")); - } + if (dataflow->IsEditing()) { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_DF_NOTRUNNING")); + } + else if (dataflow->Kill()) { + myThread->stopThread(tr("MSG_GRAPH_KILLED")); + sync(); + } + else { + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANTKILL_DF")); + } } void SUPERVGUI_Main::suspendResume() { - Trace("SUPERVGUI_Main::suspendResume") + Trace("SUPERVGUI_Main::suspendResume"); if ((SUPERV_isNull(dataflow))) return; if (dataflow->IsEditing()) { @@ -707,9 +566,11 @@ void SUPERVGUI_Main::suspendResume() { } } } - +/* asv : 15.12.04 : commented out stopRestart() in Main and CanvasNode because it's not called from anywhere, + the comment from kloss below may be explaining it, but it's in French and I do not understand it.. + It also calls deprecated method of Engine: ReStart(). void SUPERVGUI_Main::stopRestart() { // kloss : a reviser et a connecter dans le popup du dataflow (pas de creation de bouton) - Trace("SUPERVGUI_Main::stopRestart") + Trace("SUPERVGUI_Main::stopRestart"); if ((SUPERV_isNull(dataflow))) return; if (dataflow->IsEditing()) { @@ -729,7 +590,7 @@ void SUPERVGUI_Main::stopRestart() { // kloss : a reviser et a connecter dans le }; }; } - +*/ void SUPERVGUI_Main::addNode() { Trace("SUPERVGUI_Main::addNode"); if (SUPERV_isNull(dataflow)) return; @@ -743,6 +604,9 @@ void SUPERVGUI_Main::addNode() { kill(); } } + + Editing(); // PAL6170: GUI->Engine: setting "Editing" flag + Supervision.getBrowser()->choose(); } @@ -750,20 +614,11 @@ void SUPERVGUI_Main::addNode() { * Add Computation node */ void SUPERVGUI_Main::addComputeNode(SUPERV_CNode theNode) { - //cout<<"### X="<X()<<" Y="<Y()<viewport(), this, theNode); - graph->ResizeGraph(aNode, theNode->X(), theNode->Y()); - graph->addChild(aNode, theNode->X(), theNode->Y()); - aNode->sync(); - } - break; - case TABLE: - array->destroy(); - array->create(); - break; + case CANVASTABLE: + myArray->destroy(); + myArray->create(); + break; case CANVAS: case CONTROLFLOW: { @@ -782,17 +637,9 @@ void SUPERVGUI_Main::addComputeNode(SUPERV_CNode theNode) { */ void SUPERVGUI_Main::addGOTONode(SUPERV_CNode theNode) { switch (myCurrentView) { - case GRAPH: - { - SUPERVGUI_Node* aNode = new SUPERVGUI_GotoNode(graph->viewport(), this, theNode); - graph->ResizeGraph(aNode, theNode->X(), theNode->Y()); - graph->addChild(aNode, theNode->X(), theNode->Y()); - aNode->sync(); - } - break; - case TABLE: - array->destroy(); - array->create(); + case CANVASTABLE: + myArray->destroy(); + myArray->create(); break; case CANVAS: case CONTROLFLOW: @@ -812,29 +659,9 @@ void SUPERVGUI_Main::addGOTONode(SUPERV_CNode theNode) { */ void SUPERVGUI_Main::addControlNode(SUPERV_CNode theStartNode, SUPERV_CNode theEndNode, bool Update) { switch (myCurrentView) { - case GRAPH: - { - SUPERVGUI_StartControlNode* aStartPrs = - new SUPERVGUI_StartControlNode(graph->viewport(), this, theStartNode); - SUPERVGUI_EndControlNode* aEndPrs = - new SUPERVGUI_EndControlNode(graph->viewport(), this, theEndNode, aStartPrs); - - graph->ResizeGraph(aStartPrs, theStartNode->X(), theStartNode->Y()); - graph->addChild(aStartPrs, theStartNode->X(), theStartNode->Y()); - graph->ResizeGraph(aEndPrs, theEndNode->X(), theEndNode->Y()); - graph->addChild(aEndPrs, theEndNode->X(), theEndNode->Y()); - if (Update) { - aStartPrs->updateLinksPrs(); - aEndPrs->updateLinksPrs(); - } - aStartPrs->sync(); - aEndPrs->sync(); - graph->repaintContents(); - } - break; - case TABLE: - array->destroy(); - array->create(); + case CANVASTABLE: + myArray->destroy(); + myArray->create(); break; case CANVAS: case CONTROLFLOW: @@ -860,19 +687,10 @@ void SUPERVGUI_Main::addControlNode(SUPERV_CNode theStartNode, SUPERV_CNode theE * Add Macro node */ void SUPERVGUI_Main::addMacroNode(SUPERV_CNode theNode) { - //cout<<"### X="<X()<<" Y="<Y()<viewport(), this, theNode); - graph->ResizeGraph(aNode, theNode->X(), theNode->Y()); - graph->addChild(aNode, theNode->X(), theNode->Y()); - aNode->sync(); - } - break; - case TABLE: - array->destroy(); - array->create(); + case CANVASTABLE: + myArray->destroy(); + myArray->create(); break; case CANVAS: case CONTROLFLOW: @@ -887,45 +705,44 @@ void SUPERVGUI_Main::addMacroNode(SUPERV_CNode theNode) { } } - -SUPERVGUI_Graph* SUPERVGUI_Main::getGraph() { - Trace("SUPERVGUI_Main::getGraph") - return(graph); +SUPERVGUI_CanvasArray* SUPERVGUI_Main::getCanvasArray() { + Trace("SUPERVGUI_Main::getCanvasArray"); + return(myArray); } -SUPERVGUI_Array* SUPERVGUI_Main::getArray() { - Trace("SUPERVGUI_Main::getArray") - return(array); +SUPERVGUI_ArrayView* SUPERVGUI_Main::getArrayView() { + Trace("SUPERVGUI_Main::getArrayView"); + return(myArrayView); } SUPERVGUI_Canvas* SUPERVGUI_Main::getCanvas() { - Trace("SUPERVGUI_Main::getCanvas") - return(myCanvas); + Trace("SUPERVGUI_Main::getCanvas"); + return(myCanvas); } SUPERVGUI_CanvasView* SUPERVGUI_Main::getCanvasView() { - Trace("SUPERVGUI_Main::getCanvasView") - return(myCanvasView); + Trace("SUPERVGUI_Main::getCanvasView"); + return(myCanvasView); } SUPERV_Graph SUPERVGUI_Main::getDataflow() { - Trace("SUPERVGUI_Main::getDataflow") - return(dataflow); + Trace("SUPERVGUI_Main::getDataflow"); + return(dataflow); } QAD_Message* SUPERVGUI_Main::getMessage() { - Trace("SUPERVGUI_Main::getMessage") - return(message); + Trace("SUPERVGUI_Main::getMessage"); + return(message); } QAD_Study* SUPERVGUI_Main::getStudy() { - Trace("SUPERVGUI_Main::getStudy") - return(study); + Trace("SUPERVGUI_Main::getStudy"); + return(study); } bool SUPERVGUI_Main::isArrayShown() { - Trace("SUPERVGUI_Main::isArrayShown") - return(myCurrentView == TABLE); + Trace("SUPERVGUI_Main::isArrayShown"); + return(myCurrentView == CANVASTABLE); } void SUPERVGUI_Main::showPopup(QPopupMenu* p, QMouseEvent* e) { @@ -950,10 +767,6 @@ void SUPERVGUI_Main::changeInformation() { if (aDlg->exec() ) sync(); delete aDlg; - /* Trace("SUPERVGUI_Main::changeInformation") - if (Supervision.information(SUPERV::CNode::_narrow(dataflow), dataflow->IsReadOnly())) { - sync(); - }*/ } // returns false, if can't add dataflow into the study @@ -983,6 +796,7 @@ bool SUPERVGUI_Main::addStudy() { if (aComponent->_is_nil()) { // is supervision component not found, then create it QAD_Operation* anOperation = new SALOMEGUI_ImportOperation( study ); anOperation->start(); + //if (aLocked) aStudy->GetProperties()->SetLocked(false); aComponent = aBuilder->NewComponent(STUDY_SUPERVISION); anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName"); aName = SALOMEDS::AttributeName::_narrow(anAttr); @@ -992,6 +806,7 @@ bool SUPERVGUI_Main::addStudy() { aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); aPixmap->SetPixMap( "ICON_OBJBROWSER_Supervision" ); aBuilder->DefineComponentInstance(aComponent, Supervision.getEngine()); + //if (aLocked) aStudy->GetProperties()->SetLocked(true); anOperation->finish(); } op->start(); @@ -1003,6 +818,7 @@ bool SUPERVGUI_Main::addStudy() { anIORAttr = SALOMEDS::AttributeIOR::_narrow(anAttr); anIORAttr->SetValue(dataflow->getIOR()); op->finish(); + //if (aLocked) return false; } sync(); @@ -1014,7 +830,7 @@ bool SUPERVGUI_Main::addStudy() { void SUPERVGUI_Main::chooseData(QListViewItem* item) { - Trace("SUPERVGUI_Main::chooseData") + Trace("SUPERVGUI_Main::chooseData"); if (choosing) { QString id = ((QAD_ObjectBrowserItem*)item)->getEntry(); if (!id.isEmpty()) { @@ -1025,7 +841,11 @@ void SUPERVGUI_Main::chooseData(QListViewItem* item) { if (object->FindAttribute(anAttr, "AttributeIOR")) { anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); ior = anIOR->Value(); - portIn->setValue(ior); + + // asv : 13.12.04 : commented out use of portIn field, but it seems that it + // should be replaced with some analogious code... selection of IOR was done - + // put its value into port. + //portIn->setValue(ior); // stop selection choosing = false; @@ -1037,15 +857,6 @@ void SUPERVGUI_Main::chooseData(QListViewItem* item) { } } -void SUPERVGUI_Main::setData(SUPERVGUI_PortIn* p) { - Trace("SUPERVGUI_Main::setData") - portIn = p; - choosing = true; - setCursor(forbiddenCursor); - objectBrowser->setCursor(pointingHandCursor); - Supervision.putInfo(tr("MSG_CHOOSE_DATA")); -} - SALOMEDS::SObject_var SearchOrCreateSOWithName(const SALOMEDS::Study_var theStudy, const SALOMEDS::SObject_var theSO, const char* theName, @@ -1113,6 +924,7 @@ bool SUPERVGUI_Main::putDataStudy(SUPERV_Port p, const char* inout) { SALOMEDS::SComponent_ptr aComponent = aStudy->FindComponent(STUDY_SUPERVISION); if (aComponent->_is_nil()) { // is supervision component not found, then create it aBuilder->NewCommand(); + //if (aLocked) aStudy->GetProperties()->SetLocked(false); aComponent = aBuilder->NewComponent(STUDY_SUPERVISION); anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName"); aName = SALOMEDS::AttributeName::_narrow(anAttr); @@ -1123,6 +935,7 @@ bool SUPERVGUI_Main::putDataStudy(SUPERV_Port p, const char* inout) { aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); aPixmap->SetPixMap( "ICON_OBJBROWSER_Supervision" ); aBuilder->DefineComponentInstance(aComponent, Supervision.getEngine()); + //if (aLocked) aStudy->GetProperties()->SetLocked(true); aBuilder->CommitCommand(); } aTransaction = true; @@ -1172,7 +985,7 @@ bool SUPERVGUI_Main::putDataStudy(SUPERV_Port p, const char* inout) { aTransaction = true; aBuilder->NewCommand(); } - aTmpSO = aDriver->PublishInStudy(aStudy, aTmpSO, anObject, ""); + aTmpSO = aDriver->PublishInStudy(aStudy, aTmpSO, anObject, /*anObject->Name()*/""); aBuilder->Addreference(aSO, aTmpSO); } else { // can't publish object: abort transaction if (aTransaction) aBuilder->AbortCommand(); @@ -1203,32 +1016,26 @@ bool SUPERVGUI_Main::putDataStudy(SUPERV_Port p, const char* inout) { void SUPERVGUI_Main::ActivatePanning() { - if (graph->isVisible()) { - graph->ActivatePanning(); - } else if (array->isVisible()) { - array->ActivatePanning(); - } else if (myCanvasView->isVisible()) { + if (myCanvasView->isVisible()) { myCanvasView->ActivatePanning(); + } else if (myArrayView->isVisible()) { + myArrayView->ActivatePanning(); } } void SUPERVGUI_Main::ResetView() { - if (graph->isVisible()) { - graph->ResetView(); - } else if (array->isVisible()) { - array->ResetView(); - } else if (myCanvasView->isVisible()) { + if (myCanvasView->isVisible()) { myCanvasView->ResetView(); + } else if (myArrayView->isVisible()) { + myArrayView->ResetView(); } } void SUPERVGUI_Main::setAsFromStudy(bool theToStudy) { myIsFromStudy = theToStudy; - graph->setAsFromStudy(theToStudy); - array->setAsFromStudy(theToStudy); myCanvas->setAsFromStudy(theToStudy); } @@ -1281,10 +1088,10 @@ bool SUPERVGUI_Main::isFiltered(char* graph, char* node, char* type, char* me Trace("SUPERVGUI_Main::isFiltered"); bool b = false; if (strcmp(getDataflow()->Name(), graph) == 0) { - SUPERVGUI_Node* n; - QObjectList* nodes = queryList("SUPERVGUI_Node"); + SUPERVGUI_CanvasNode* n; + QObjectList* nodes = queryList("SUPERVGUI_CanvasNode"); QObjectListIt i(*nodes); - while ((n=(SUPERVGUI_Node*)i.current()) != 0) { + while ((n=(SUPERVGUI_CanvasNode*)i.current()) != 0) { ++i; if (strcmp(n->name(), node) == 0) { if (strcmp(type, NOTIF_WARNING) == 0) { @@ -1315,10 +1122,10 @@ void SUPERVGUI_Main::closeEvent(QCloseEvent* e) { void SUPERVGUI_Main::setPaletteBackgroundColor(const QColor& color) { - array->setPaletteBackgroundColor(color); - graph->setPaletteBackgroundColor(color); myCanvas->setBackgroundColor(color); myCanvasView->setPaletteBackgroundColor(color.light()); + myArray->setBackgroundColor(color); + myArrayView->setPaletteBackgroundColor(color.light()); SUPERVGraph_View::setPaletteBackgroundColor(color); } @@ -1359,6 +1166,7 @@ void SUPERVGUI_Main::startTimer() { void SUPERVGUI_Main::executionFinished() { getStudy()->updateObjBrowser(); myCanvas->update(); + myArray->update(); } void SUPERVGUI_Main::checkExecution() { @@ -1368,6 +1176,41 @@ void SUPERVGUI_Main::checkExecution() { } } +/** + * Editing() is to be called by any operation in GUI before modification of a datamodel + * (add/remove ports or nodes, etc.). It is used to resolve inconsistancies between 2 data models + * in Engine: Editor and Executor. During and after execution, the values of ports and statuses of nodes + * are taken from Executor data model. But when user starts editing the graph - these changes must + * be applied to Editor data model. This function destroys Executor data model and moves to Editor. + */ +void SUPERVGUI_Main::Editing() { + if ( !SUPERV_isNull( dataflow ) ) + dataflow->Editing(); + + // updata GUI, Nodes' statuses and Ports' values could change. + sync(); +} + +void SUPERVGUI_Main::removeArrayChild(SUPERV::CNode_ptr theNode) +{ + // mkr: since the deletion of the node allow only in CANVAS view, + // it is necessary to remove the CanvasArray's children, which + // have the same CNode engine as deleting node. This CNode is given + // as argument + if (myArray) { + const QObjectList* aChList = myArray->children(); + QObjectListIt aItChList(*aChList); + SUPERVGUI_CanvasNode* anObjNode; + while ((anObjNode = (SUPERVGUI_CanvasNode*)aItChList.current()) != 0) { + ++aItChList; + if ((QString(anObjNode->getEngine()->Name())).compare(QString(theNode->Name())) == 0) { + myArray->removeChild(anObjNode); + delete anObjNode; + } + } + } +} + /******************************* SUPERVGUI_Thread class ****************************************/ SUPERVGUI_Thread::SUPERVGUI_Thread() :QThread() diff --git a/src/SUPERVGUI/SUPERVGUI_Main.h b/src/SUPERVGUI/SUPERVGUI_Main.h index b0f04c0..4009f82 100644 --- a/src/SUPERVGUI/SUPERVGUI_Main.h +++ b/src/SUPERVGUI/SUPERVGUI_Main.h @@ -28,14 +28,11 @@ #ifndef SUPERVGUI_Main_H #define SUPERVGUI_Main_H -//#include "SUPERVGUI.h" #include "SUPERVGraph_ViewFrame.h" -#include "SUPERVGUI_Array.h" -#include "SUPERVGUI_Graph.h" #include "QAD_Desktop.h" -#include "SUPERVGUI_Port.h" #include "SUPERVGUI_Canvas.h" #include "SUPERVGUI_CanvasView.h" +#include "SUPERVGUI_ArrayView.h" #include #include @@ -44,6 +41,9 @@ class QAD_Study; class QAD_ObjectBrowser; class QAD_Message; +class QAD_SpinBoxDbl; +class QLineEdit; +class QComboBox; class NOTIFICATION_Consumer; class SUPERVGUI_Thread; @@ -55,8 +55,6 @@ class SUPERVGUI_Main: public SUPERVGraph_View { friend class SUPERVGUI_Thread; public: - //SUPERVGUI_Main(SUPERVGraph_ViewFrame*, QAD_Desktop*, bool fromIOR); - //SUPERVGUI_Main(SUPERVGraph_ViewFrame*, QAD_Desktop*, bool isModify, const char* filename); SUPERVGUI_Main(SUPERVGraph_ViewFrame*, QAD_Desktop*, SUPERV_Graph); virtual ~SUPERVGUI_Main(); @@ -64,15 +62,13 @@ class SUPERVGUI_Main: public SUPERVGraph_View { void startExecute(); void kill(); void suspendResume(); - void stopRestart(); - bool exportDataflow(QString theFile); + //void stopRestart(); void openSubGraph(SUPERV_CNode theNode, bool correct = false); bool putDataStudy(SUPERV_Port port, const char* inout); - void setData(SUPERVGUI_PortIn* p); - SUPERVGUI_Graph* getGraph(); - SUPERVGUI_Array* getArray(); + SUPERVGUI_CanvasArray* getCanvasArray(); + SUPERVGUI_ArrayView* getArrayView(); SUPERVGUI_Canvas* getCanvas(); SUPERVGUI_CanvasView* getCanvasView(); SUPERV_Graph getDataflow(); @@ -108,7 +104,6 @@ class SUPERVGUI_Main: public SUPERVGraph_View { void lockedGraph(bool theLock) { myIsLocked = theLock; } bool isLocked() { return myIsLocked; } - bool isKilled() { return myIsKilled; } SUPERV::GraphState getNodeExecState(); void setNodeExecState(SUPERV::GraphState theNodeExecState); @@ -133,6 +128,11 @@ class SUPERVGUI_Main: public SUPERVGraph_View { bool IsGUIEventLoopFinished() const { return myGUIEventLoopFinished; } + void Editing(); // any Editing operation is to be performed -> + // activate Editors data model in Engine + + void removeArrayChild(SUPERV::CNode_ptr theNode); + signals: void KillMyThread(bool theValue); @@ -145,10 +145,11 @@ class SUPERVGUI_Main: public SUPERVGraph_View { void addNode(); void changeInformation(); void copy(); - void showTable(); - void showFullGraph(); + + void showCanvasTable(); void showContolFlow(); void showCanvas(); + void filterNotification(); void changeDSGraphParameters(); void onSubGraphClosed(QAD_StudyFrame* ); @@ -173,15 +174,14 @@ class SUPERVGUI_Main: public SUPERVGraph_View { QAD_Study* study; QAD_ObjectBrowser* objectBrowser; QAD_Message* message; - SUPERVGUI_Graph* graph; - + GraphViewType myCurrentView; - SUPERVGUI_Array* array; + SUPERVGUI_CanvasArray* myArray; + SUPERVGUI_ArrayView* myArrayView; SUPERVGUI_Canvas* myCanvas; SUPERVGUI_CanvasView* myCanvasView; bool choosing; - SUPERVGUI_PortIn* portIn; QString myHashCode; @@ -201,7 +201,6 @@ class SUPERVGUI_Main: public SUPERVGraph_View { bool myStep; bool myTrace; bool myVerbose; - bool myIsKilled; bool myIsLocked; SUPERVGUI_Thread* myThread; @@ -240,7 +239,9 @@ class SUPERVGUI_Thread : public QObject, public QThread { }; -//************************************************************** +/** + * A dialog for setting Graph execution parameters + */ class SUPERVGUI_DSGraphParameters: public QDialog { Q_OBJECT @@ -252,9 +253,9 @@ class SUPERVGUI_DSGraphParameters: public QDialog { void accept(); private: - + void setData(); - + QAD_SpinBoxDbl* myDeltaTime; QLineEdit* myTimeOut; QComboBox* myDataStreamTrace; diff --git a/src/SUPERVGUI/SUPERVGUI_ManagePortsDlg.cxx b/src/SUPERVGUI/SUPERVGUI_ManagePortsDlg.cxx new file mode 100644 index 0000000..eb8d83c --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_ManagePortsDlg.cxx @@ -0,0 +1,605 @@ +// SUPERV SUPERVGUI : GUI for Supervisor component +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : SUPERVGUI_ManagePortsDlg.cxx +// Author : Alexander SLADKOV +// Module : SUPERV + +using namespace std; + +#include "SUPERVGUI_ManagePortsDlg.h" +#include "SUPERVGUI_CanvasNode.h" +#include "SUPERVGUI_CanvasPort.h" +#include "SUPERVGUI_CanvasControlNode.h" +#include "SUPERVGUI.h" + +#include +#include +#include +#include +#include + +static const char* gTypes[] = + {"string", "boolean", "char", "short", "int", "long", "float", "double", "objref"}; + +static const char* const add_pix_data[] = { +"20 20 4 1", +". c None", +"b c #084818", +"a c #186929", +"# c #208541", +"....................", +"....................", +"....................", +"....................", +"........##a.........", +"........##b.........", +"........##b.........", +"........##b.........", +"........##b.........", +"...############a....", +"...############b....", +"...abbbb##bbbbbb....", +"........##b.........", +"........##b.........", +"........##b.........", +"........##b.........", +"........abb.........", +"....................", +"....................", +"...................."}; + +static const char* const del_pix_data[] = { +"16 16 3 1", +". c None", +"# c #800000", +"a c #ffffff", +"................", +"................", +".##a........##a.", +".####a.....##a..", +"..####a...##a...", +"....###a.#a.....", +".....#####a.....", +"......###a......", +".....#####a.....", +"....###a.##a....", +"...###a...##a...", +"..###a.....#a...", +"..###a......#a..", +"...#a........#a.", +"................", +"................"}; + +static const char* const up_pix_data[] = { +"16 16 5 1", +". c None", +"# c #000000", +"a c #838183", +"c c #c5c2c5", +"b c #ffffff", +"................", +"................", +"........#.......", +"......a#b#......", +".....a#bbb#.....", +"....a#bccbb#....", +"...a#bccccbb#...", +"..a####ccb####..", +".aaaaa#ccb#.....", +".....a#ccb#.....", +".....a#ccb#.....", +".....a#ccb#.....", +".....a#ccb#.....", +".....a#ccb#.....", +".....a#####.....", +"................"}; + +static const char* const down_pix_data[] = { +"16 16 5 1", +". c None", +"# c #000000", +"a c #838183", +"c c #c5c2c5", +"b c #ffffff", +"................", +".....#####a.....", +".....#bcc#a.....", +".....#bcc#a.....", +".....#bcc#a.....", +".....#bcc#a.....", +".....#bcc#a.....", +".....#bcc#aaaaa.", +"..####bcc####a..", +"...#bbccccb#a...", +"....#bbccb#a....", +".....#bbb#a.....", +"......#b#a......", +".......#........", +"................", +"................"}; + + +/** + * Constructor + */ +SUPERVGUI_ManagePortsDlg::SUPERVGUI_ManagePortsDlg( SUPERVGUI_CanvasNode* theNode ) + : QDialog( QAD_Application::getDesktop(), 0, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ) +{ + myNode = theNode; + myLastItem = 0; + init(); +} + +void SUPERVGUI_ManagePortsDlg::init() +{ + setName( "SUPERVGUI_ManagePortsDlg" ); + + SUPERV_CNode aCNode = myNode->getEngine(); + setCaption( tr( "TIT_MANAGE_PORTS" ) + aCNode->Name() ); + + QGridLayout* aBaseLayout = new QGridLayout( this ); + aBaseLayout->setMargin( 11 ); + aBaseLayout->setSpacing( 6 ); + + // -- name and type upper line widgets -- + QLabel* aNameLbl = new QLabel( tr( "NAME_LBL") , this ); + myNameEdt = new QLineEdit( this ); + QLabel* aTypeLbl = new QLabel( tr( "TYPE_LBL" ), this ); + myTypeCombo = new QComboBox( false, this ); // input field not editable + + aBaseLayout->addWidget( aNameLbl, 0, 0 ); + aBaseLayout->addWidget( myNameEdt, 0, 1 ); + aBaseLayout->addWidget( aTypeLbl, 0, 2 ); + aBaseLayout->addWidget( myTypeCombo, 0, 3 ); + aBaseLayout->setColStretch( 1, 1 ); + aBaseLayout->setColStretch( 3, 1 ); + + // -- common Input/Output variables -- + QPixmap adPix( (const char**) add_pix_data ); + QPixmap rmPix( (const char**) del_pix_data ); + QPixmap upPix( (const char**) up_pix_data ); + QPixmap dnPix( (const char**) down_pix_data ); + + // -- Input ports group box -- + QGroupBox* anInputGr = new QGroupBox( 1, Qt::Vertical, tr( "INPUT" ), this ); + anInputGr->layout()->setSpacing( 6 ); + anInputGr->layout()->setMargin( 11 ); + + myInList = new QListBox( anInputGr ); + myInList->setSelectionMode( QListBox::Single ); + + QGroupBox* anInputBtnGr = new QGroupBox( 0, Qt::Vertical, anInputGr ); + anInputBtnGr->setFrameStyle( QFrame::NoFrame ); + anInputBtnGr->layout()->setSpacing( 0 ); + anInputBtnGr->layout()->setMargin( 0 ); + + QVBoxLayout* anInputBtnLay = new QVBoxLayout( anInputBtnGr->layout() ); + anInputBtnLay->layout()->setSpacing( 6 ); + anInputBtnLay->layout()->setMargin( 0 ); + + QPushButton* anAddInputBtn = new QPushButton( anInputBtnGr ); + anAddInputBtn->setPixmap( adPix ); + QPushButton* aDeleteInputBtn = new QPushButton( anInputBtnGr ); + aDeleteInputBtn->setPixmap( rmPix ); + QPushButton* anUpInputBtn = new QPushButton( anInputBtnGr ); + anUpInputBtn->setPixmap( upPix ); + QPushButton* aDownInputBtn = new QPushButton( anInputBtnGr ); + aDownInputBtn->setPixmap( dnPix ); + + connect( anAddInputBtn, SIGNAL( clicked() ), this, SLOT( addInput() ) ); + connect( aDeleteInputBtn, SIGNAL( clicked() ), this, SLOT( removeInput() ) ); + connect( anUpInputBtn, SIGNAL( clicked() ), this, SLOT( upInput() ) ); + connect( aDownInputBtn, SIGNAL( clicked() ), this, SLOT( downInput() ) ); + + anInputBtnLay->addWidget( anAddInputBtn ); + anInputBtnLay->addWidget( aDeleteInputBtn ); + anInputBtnLay->addItem( new QSpacerItem( 1, 16, QSizePolicy::Maximum, QSizePolicy::MinimumExpanding ) ); + anInputBtnLay->addWidget( anUpInputBtn ); + anInputBtnLay->addWidget( aDownInputBtn ); + anInputBtnLay->addItem( new QSpacerItem( 1, 16, QSizePolicy::Maximum, QSizePolicy::MinimumExpanding ) ); + + aBaseLayout->addMultiCellWidget( anInputGr, 1, 1, 0, 1 ); + + // -- Output ports group box -- + QGroupBox* anOutputGr = new QGroupBox( 1, Qt::Vertical, tr( "OUTPUT" ), this ); + anOutputGr->layout()->setSpacing( 6 ); + anOutputGr->layout()->setMargin( 11 ); + + myOutList = new QListBox( anOutputGr ); + myOutList->setSelectionMode( QListBox::Single ); + + QGroupBox* anOutputBtnGr = new QGroupBox( 0, Qt::Vertical, anOutputGr ); + anOutputBtnGr->setFrameStyle( QFrame::NoFrame ); + anOutputBtnGr->layout()->setSpacing( 0 ); + anOutputBtnGr->layout()->setMargin( 0 ); + + QVBoxLayout* anOutputBtnLay = new QVBoxLayout( anOutputBtnGr->layout() ); + anOutputBtnLay->layout()->setSpacing( 6 ); + anOutputBtnLay->layout()->setMargin( 0 ); + + QPushButton* anAddOutputBtn = new QPushButton( anOutputBtnGr ); + anAddOutputBtn->setPixmap( adPix ); + QPushButton* aDeleteOutputBtn = new QPushButton( anOutputBtnGr ); + aDeleteOutputBtn->setPixmap( rmPix ); + QPushButton* anUpOutputBtn = new QPushButton( anOutputBtnGr ); + anUpOutputBtn->setPixmap( upPix ); + QPushButton* aDownOutputBtn = new QPushButton( anOutputBtnGr ); + aDownOutputBtn->setPixmap( dnPix ); + + connect( anAddOutputBtn, SIGNAL( clicked() ), this, SLOT( addOutput() ) ); + connect( aDeleteOutputBtn, SIGNAL( clicked() ), this, SLOT( removeOutput() ) ); + connect( anUpOutputBtn, SIGNAL( clicked() ), this, SLOT( upOutput() ) ); + connect( aDownOutputBtn, SIGNAL( clicked() ), this, SLOT( downOutput() ) ); + + anOutputBtnLay->addWidget( anAddOutputBtn ); + anOutputBtnLay->addWidget( aDeleteOutputBtn ); + anOutputBtnLay->addItem( new QSpacerItem( 1, 16, QSizePolicy::Maximum, QSizePolicy::MinimumExpanding ) ); + anOutputBtnLay->addWidget( anUpOutputBtn ); + anOutputBtnLay->addWidget( aDownOutputBtn ); + anOutputBtnLay->addItem( new QSpacerItem( 1, 16, QSizePolicy::Maximum, QSizePolicy::MinimumExpanding ) ); + + aBaseLayout->addMultiCellWidget( anOutputGr, 1, 1, 2, 3 ); + + // -- Ok / Cancel buttons line at the bottom of dialog -- + QGroupBox* aBtnBox = new QGroupBox( this ); + aBtnBox->setColumnLayout( 0, Qt::Vertical ); + aBtnBox->layout()->setSpacing( 0 ); + aBtnBox->layout()->setMargin( 0 ); + + QHBoxLayout* aBtnLayout = new QHBoxLayout( aBtnBox->layout() ); + aBtnLayout->setAlignment( Qt::AlignTop ); + aBtnLayout->setSpacing( 6 ); + aBtnLayout->setMargin( 11 ); + + QPushButton* aOkBtn = new QPushButton( tr( "BUT_OK" ), aBtnBox ); + QPushButton* aCancelBtn = new QPushButton( tr( "BUT_CANCEL" ), aBtnBox ); + connect( aOkBtn, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( aCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) ); + + aBtnLayout->addWidget( aOkBtn ); + aBtnLayout->addStretch(); + aBtnLayout->addWidget( aCancelBtn ); + + aBaseLayout->addMultiCellWidget( aBtnBox, 2, 2, 0, 3 ); + // ----------- + + connect( myInList,SIGNAL(currentChanged(QListBoxItem*)), this, SLOT(itemChanged(QListBoxItem*))); + connect( myOutList, SIGNAL(currentChanged(QListBoxItem*)), this, SLOT(itemChanged(QListBoxItem*))); + connect( myNameEdt, SIGNAL(textChanged(const QString&)), this, SLOT(nameChanged(const QString&))); + connect( myTypeCombo, SIGNAL(activated(const QString&)), this, SLOT(typeChanged(const QString&))); + + myNode->getMain()->lockedGraph( true ); + + // asv : 11.01.05 : if a node is a loop node, then only INPUT ports can be added/removed + if ( myNode->getNodeType() == SUPERV::LoopNode ) { + myOutList->setEnabled( false ); + anAddOutputBtn->setEnabled( false ); + aDeleteOutputBtn->setEnabled( false ); + anUpOutputBtn->setEnabled( false ); + aDownOutputBtn->setEnabled( false ); + } + +} + +/** + * Destructor + */ +SUPERVGUI_ManagePortsDlg::~SUPERVGUI_ManagePortsDlg() { +} + +/** + * Set the ports as entered by user (order, name/type, etc.) and close the dialog + */ +void SUPERVGUI_ManagePortsDlg::accept() { + // 1. set the ports to Engine's CNode + SUPERV_INode aINode = myNode->getInlineNode(); + if ( !SUPERV_isNull( aINode ) ) { + int i; + const bool isLoop = ( myNode->getNodeType() == SUPERV::LoopNode ); + + // 1.1 delete all ports (delete CanvasPorts, they delete SUPERV_Ports) + QObjectList* oldPorts = myNode->queryList("SUPERVGUI_CanvasPort"); + QObjectListIt it( *oldPorts ); // iterate over the old ports + QObject *obj; + + // asv : 11.01.05 : fix for a bug: for Loop node, removal of an Input Port + // automatically removes the corresponding Output Port. So for Loops the + // oldPorts list should be filtered to include only Input Ports. + // But I'll filter Gate-s as well.. + QObjectList portsToRemove; + while ( (obj = it.current()) != 0 ) { + ++it; + SUPERV::Port_var aPort = ((SUPERVGUI_CanvasPort*)obj)->getEngine(); + if ( !aPort->IsGate() && ( !isLoop || aPort->IsInput() ) ) + portsToRemove.append( obj ); + } + delete oldPorts; // delete the list, not the objects + + // portsToRemove list contains: + // for Loop node: all INPUT ports except Gates + // for other Inline: all INPUT and OUTPUT ports except Gates + it = QObjectListIt( portsToRemove ); + while ( (obj = it.current()) != 0 ) { + ++it; + ((SUPERVGUI_CanvasPort*)obj)->remove(); + } + + // 1.2 create new ports in INode and CanvasPort in myNode + PortListItem* item; + SUPERV_Port aPort; + for ( i = 0; i < myInList->count(); i++ ) { + item = (PortListItem*)myInList->item( i ); + aPort = aINode->InPort( item->PortName.latin1(), item->PortType.latin1() ); + myNode->createPort( aPort.in() ); + // asv : 11.01.05 : for Loop nodes do the same as in SUPERVGUI_CanvasStartNode::addInputPort() + if ( isLoop ) { + SUPERVGUI_CanvasStartNode* aStartLoopNode = (SUPERVGUI_CanvasStartNode*)myNode; + aStartLoopNode->merge(); + aStartLoopNode->getCoupled()->merge(); + } + } + // creating Out-ports, except LoopNode-s + for ( i = 0; i < myOutList->count() && !isLoop; i++ ) { + item = (PortListItem*)myOutList->item( i ); + aPort = aINode->OutPort( item->PortName.latin1(), item->PortType.latin1() ); + myNode->createPort( aPort.in() ); + } + + // 2. update the node's presentation + myNode->getMain()->getCanvas()->update(); + } + + // 3. close the dialog + myNode->getMain()->lockedGraph( false ); + QDialog::accept(); + close(); +} + +/** + * Simply close the dialog + */ +void SUPERVGUI_ManagePortsDlg::reject() { + myNode->getMain()->lockedGraph( false ); + QDialog::reject(); + close(); +} + +/** + * Update current values on show event + */ +void SUPERVGUI_ManagePortsDlg::showEvent( QShowEvent* theEvent ) { + init( myNode ); + QDialog::showEvent( theEvent ); +} + +/** + * Initialize In/Out tables with values from the given node + */ +void SUPERVGUI_ManagePortsDlg::init( const SUPERVGUI_CanvasNode* theNode ) { + if ( !theNode ) { + MESSAGE("ERROR: SUPERVGUI_ManagePortsDlg: the CanvasNode is nil!"); + return; + } + + SUPERV_INode aINode = myNode->getInlineNode(); + if ( SUPERV_isNull( aINode ) ) { + MESSAGE("ERROR: SUPERVGUI_ManagePortsDlg: the node of wrong type is found (not InLine node)!"); + return; + } + + // 1. fill myTypeCombo with all available types + myTypeCombo->insertStrList( gTypes ); + + // 2. fill Input and Output listboxes with Ports' names/types + QStringList aTypes; + SUPERV_Ports aPorts = aINode->Ports(); + for ( int i=0; i < aPorts->length(); i++ ) { + if ( aPorts[i]->IsGate() ) + continue; + if ( aPorts[i]->IsInput() ) + new PortListItem( myInList, aPorts[i]->Name(), aPorts[i]->Type() ); + else + new PortListItem( myOutList, aPorts[i]->Name(), aPorts[i]->Type() ); + } +} + +void SUPERVGUI_ManagePortsDlg::addPort( QListBox* theLB ) { + if ( !theLB ) + return; + QString name = myNameEdt->text(); + if ( !name.isNull() && name.length() ) { + bool found = false; // check if already exists -- and don't allow if yes + for ( int i = 0; i < theLB->count(); i++ ) { + if ( ((PortListItem*)theLB->item(i))->PortName == name ) { + found = true; + break; + } + } + if ( found ) + QMessageBox::warning( QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_PORT_EXIST") ); + else + new PortListItem( theLB, name, myTypeCombo->currentText() ); + } +} + +/** + * called on 'X' button press - remove selected port item + */ +void SUPERVGUI_ManagePortsDlg::removePort( QListBox* theLB ) { + if ( !theLB ) + return; + + const int i = theLB->currentItem(); + if ( i >=0 ) + delete theLB->item( i ); +} + +/** + * called on up/down key press - move the selected list box item from position 'from' to position 'to' + */ +void SUPERVGUI_ManagePortsDlg::moveItem( QListBox* theLB, const int from, const int to ) { + if ( !theLB ) + return; + + // disconnect itemChanged - it leads to crash if there was only 1 item left + disconnect( theLB, SIGNAL(currentChanged(QListBoxItem*)), this, SLOT(itemChanged(QListBoxItem*))); + + if ( from >= 0 && from < theLB->count() && to >=0 && to < theLB->count() ) { + QListBoxItem* item = theLB->item( from ); + theLB->takeItem( item ); + theLB->insertItem( item, to ); + theLB->setCurrentItem( item ); + theLB->setSelected( item, true ); + } + + // connect back.. + connect( theLB, SIGNAL(currentChanged(QListBoxItem*)), this, SLOT(itemChanged(QListBoxItem*))); +} + +/** + * move the selected item UP + */ +void SUPERVGUI_ManagePortsDlg::moveUp( QListBox* theLB ) { + if ( !theLB ) + return; + const int i = theLB->currentItem(); + moveItem( theLB, i, i-1 ); +} + +/** + * move the selected item DOWN + */ +void SUPERVGUI_ManagePortsDlg::moveDown( QListBox* theLB ) { + if ( !theLB ) + return; + const int i = theLB->currentItem(); + moveItem( theLB, i, i+1 ); +} + + +/** + * returns true if there is a current and selected item in the given listbox and it + * equals to the given item. + */ +bool isEditingItem( const QListBoxItem* item, const QListBox* theLB ) { + return item && item == theLB->item( theLB->currentItem() ) && theLB->isSelected( item ); +} + +/** + * called when name is changed. Tries to change name of the item, which was + * the last selected by user item in myInList or myOutList (myLastItem) + */ +void SUPERVGUI_ManagePortsDlg::nameChanged( const QString& name ) { + if ( isEditingItem( myLastItem, myInList ) || isEditingItem( myLastItem, myOutList ) ) { + ((PortListItem*)myLastItem)->PortName = name; + //myLastItem->listBox()->repaint( true ); + // it would be much better to change the item and repaint it -- but -- repaint() + // is done only after a while, which is not good.. so -- "cheating" around + const int i = myLastItem->listBox()->index( myLastItem ); + moveItem( myLastItem->listBox(), i, i ); + } +} + +/** + * called when type item in myTypeCombo is changed. Tries to change type + * of the last selected by user item in myInList or myOutList (myLastItem) + */ +void SUPERVGUI_ManagePortsDlg::typeChanged( const QString& type ) { + if ( isEditingItem( myLastItem, myInList ) || isEditingItem( myLastItem, myOutList ) ) { + ((PortListItem*)myLastItem)->PortType = type; + //myLastItem->listBox()->repaint( true ); + // it would be much better to change the item and repaint it -- but -- repaint() + // is done only after a while, which is not good.. so -- "cheating" around + const int i = myLastItem->listBox()->index( myLastItem ); + moveItem( myLastItem->listBox(), i, i ); + } +} + +/** + * called when new item became "currentItem" in any myInList or myOutList listboxes. + */ +void SUPERVGUI_ManagePortsDlg::itemChanged( QListBoxItem * item ) { + if ( !item ) // after remove, etc.. + return; + + // disable nameChanged, typeChanged callbacks + disconnect( myNameEdt, SIGNAL(textChanged(const QString&)), this, SLOT(nameChanged(const QString&))); + disconnect( myTypeCombo, SIGNAL(activated(const QString&)), this, SLOT(typeChanged(const QString&))); + + myLastItem = item; + myNameEdt->setText( ((PortListItem*)item)->PortName ); + for ( int i = 0; i < myTypeCombo->count(); i++ ) + if ( myTypeCombo->text( i ) == ((PortListItem*)item)->PortType ) { + myTypeCombo->setCurrentItem( i ); + break; + } + + // connect back nameChanged, typeChanged + connect( myNameEdt, SIGNAL(textChanged(const QString&)), this, SLOT(nameChanged(const QString&))); + connect( myTypeCombo, SIGNAL(activated(const QString&)), this, SLOT(typeChanged(const QString&))); +} + + + + +/*! + * Port parameters dialog definition (taken from SUPERVGUI_Node.cxx without change) + */ +SUPERVGUI_PortParamsDlg::SUPERVGUI_PortParamsDlg(const QStringList& thePortsNames) + : QDialog(QAD_Application::getDesktop(), 0, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ), + myPortsNames( thePortsNames ) +{ + setSizeGripEnabled( true ); + setCaption("Port parameters"); + + QGridLayout* aBaseLayout = new QGridLayout( this ); + aBaseLayout->setMargin( 11 ); aBaseLayout->setSpacing( 6 ); + + QLabel* aNameLbl = new QLabel("Port Name", this ); + aBaseLayout->addWidget(aNameLbl, 0, 0); + + myNameTxt = new QLineEdit( this ); + aNameLbl->setBuddy( myNameTxt ); + aBaseLayout->addWidget(myNameTxt, 0, 1); + + QLabel* aTypeLbl = new QLabel("Value Type", this ); + aBaseLayout->addWidget(aTypeLbl, 1, 0); + + myTypeTxt = new QComboBox( this ); + aTypeLbl->setBuddy( myTypeTxt ); + myTypeTxt->insertStrList( gTypes ); + aBaseLayout->addWidget(myTypeTxt, 1, 1); + + QGroupBox* aBtnBox = new QGroupBox( this ); + aBtnBox->setColumnLayout( 0, Qt::Vertical ); + aBtnBox->layout()->setSpacing( 0 ); aBtnBox->layout()->setMargin( 0 ); + QHBoxLayout* aBtnLayout = new QHBoxLayout( aBtnBox->layout() ); + aBtnLayout->setAlignment( Qt::AlignTop ); + aBtnLayout->setSpacing( 6 ); aBtnLayout->setMargin( 11 ); + + aBaseLayout->addMultiCellWidget( aBtnBox, 2, 2, 0, 1 ); + + QPushButton* aOKBtn = new QPushButton( tr( "BUT_OK" ), aBtnBox ); + connect( aOKBtn, SIGNAL( clicked() ), this, SLOT( clickOnOk() ) ); + aBtnLayout->addWidget( aOKBtn ); + + aBtnLayout->addStretch(); + + QPushButton* aCancelBtn = new QPushButton( tr("BUT_CANCEL"), aBtnBox ); + connect( aCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) ); + aBtnLayout->addWidget( aCancelBtn ); +} + +void SUPERVGUI_PortParamsDlg::clickOnOk() +{ + if (getName().isEmpty() || getType().isEmpty()) + QMessageBox::warning( QAD_Application::getDesktop(), tr( "ERROR" ), tr( "MSG_CANT_CREATE_PORT" ) ); + else if (myPortsNames.contains(getName())) + QMessageBox::warning( QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_PORT_EXIST") ); + else + accept(); +} diff --git a/src/SUPERVGUI/SUPERVGUI_ManagePortsDlg.h b/src/SUPERVGUI/SUPERVGUI_ManagePortsDlg.h new file mode 100644 index 0000000..345d1cb --- /dev/null +++ b/src/SUPERVGUI/SUPERVGUI_ManagePortsDlg.h @@ -0,0 +1,109 @@ +// SUPERV SUPERVGUI : GUI for Supervisor component +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : SUPERVGUI_ManagePortsDlg.h +// Author : Alexander SLADKOV +// Module : SUPERV + +#ifndef SUPERVGUI_ManagePortsDlg_H +#define SUPERVGUI_ManagePortsDlg_H + +#include +#include +#include +#include +#include + +class SUPERVGUI_CanvasNode; + +/** + * Simple redefinition of ListBoxItem for storing ports name and type without having to parce it + */ +class PortListItem : QListBoxText { +public: + PortListItem ( QListBox* lb, const QString& name, const QString& type ) + : QListBoxText( lb/*, QString( "%1 (%2)" ).arg( name ).arg( type )*/ ), + PortName( name ), + PortType( type ) {} + QString PortName; + QString PortType; + virtual QString text() const { return QString( "%1 (%2)" ).arg( PortName ).arg( PortType ); } +}; + +/** + * The dialog class + */ +class SUPERVGUI_ManagePortsDlg: public QDialog { + + Q_OBJECT + +public: + SUPERVGUI_ManagePortsDlg( SUPERVGUI_CanvasNode* theNode ); + virtual ~SUPERVGUI_ManagePortsDlg(); + +protected slots: + void accept(); + void reject(); + + void addInput() { addPort( myInList ); } + void addOutput() { addPort( myOutList );} + void removeInput() { removePort( myInList ); } + void removeOutput() { removePort( myOutList );} + void upInput() { moveUp( myInList ); } + void upOutput() { moveUp( myOutList );} + void downInput() { moveDown( myInList ); } + void downOutput() { moveDown( myOutList );} + + void nameChanged( const QString& name ); + void typeChanged( const QString& type ); + void itemChanged( QListBoxItem * item ); + +protected: + virtual void showEvent( QShowEvent* theEvent ); + void addPort( QListBox* ); + void removePort( QListBox* ); + void moveUp( QListBox* ); + void moveDown( QListBox* ); + void moveItem( QListBox* theLB, const int from, const int to ); + +private: + void init(); + void init( const SUPERVGUI_CanvasNode* theNode ); + + SUPERVGUI_CanvasNode* myNode; + + QLineEdit* myNameEdt; + QComboBox* myTypeCombo; + QListBox* myInList; + QListBox* myOutList; + QListBoxItem* myLastItem; +}; + +/*! + * Port parameters dialog definition (taken from SUPERVGUI_Node.h without change) + */ +class SUPERVGUI_PortParamsDlg: public QDialog { + Q_OBJECT + + public: + SUPERVGUI_PortParamsDlg(const QStringList& thePortsNames); + ~SUPERVGUI_PortParamsDlg() {}; + + QString getName() { return myNameTxt->text(); } + QString getType() { return myTypeTxt->currentText(); } + + public slots: + void clickOnOk(); + + + private: + QLineEdit* myNameTxt; + QComboBox* myTypeTxt; + QStringList myPortsNames; +}; + + +#endif diff --git a/src/SUPERVGUI/SUPERVGUI_Node.cxx b/src/SUPERVGUI/SUPERVGUI_Node.cxx deleted file mode 100644 index 6594235..0000000 --- a/src/SUPERVGUI/SUPERVGUI_Node.cxx +++ /dev/null @@ -1,581 +0,0 @@ -// SUPERV SUPERVGUI : GUI for Supervisor component -// -// 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 -// -// -// -// File : SUPERVGUI_Node.cxx -// Author : Francis KLOSS -// Module : SUPERV - -using namespace std; -#include "SUPERVGUI_Node.h" -#include "SUPERVGUI_Main.h" -#include "SUPERVGUI_Python.h" -#include "SUPERVGUI.h" -#include "SUPERVGUI_BrowseNodeDlg.h" -#include "SALOMEGUI_NameDlg.h" -#include "SUPERVGUI_Information.h" -#include "SUPERVGUI_ComputeNode.h" -#include "SUPERVGUI_ControlNode.h" - -#include -#include -#include -#include -#include -#include -#include - - - -SUPERVGUI_Node::SUPERVGUI_Node(QWidget* theParent, SUPERVGUI_Main* theMain, SUPERV_CNode theNode): - QFrame(theParent, "", WDestructiveClose), - myMain(theMain), - myNode(theNode), - warning(true), - step(true), - trace(true), - verbose(true), - aBrowseDlg(0) -{ - Trace("SUPERVGUI_Node::SUPERVGUI_Node"); - QPalette BackColor = QPalette(MAIN_BACK); - setPalette(BackColor); - - setName(myNode->Name()); - //myTitle = new SUPERVGUI_Label(0, LABEL_WIDTH, LABEL_HEIGHT, name(), QLabel::AlignLeft); - //connect(myTitle, SIGNAL(MousePress(QMouseEvent*)), this, SLOT(showPopup(QMouseEvent*))); - //myTitle->hide(); - - myStatus = new SUPERVGUI_Label(0, LABEL_WIDTH/2, LABEL_HEIGHT, "", QLabel::AlignHCenter); - myTime = new SUPERVGUI_Label(0, LABEL_WIDTH/2, LABEL_HEIGHT, "00:00:00", QLabel::AlignHCenter); - myStatus->hide(); - myTime->hide(); - - connect(myStatus, SIGNAL(MousePress(QMouseEvent*)), this, SLOT(showPopup(QMouseEvent*))); - connect(myTime, SIGNAL(MousePress(QMouseEvent*)), this, SLOT(showPopup(QMouseEvent*))); - - //create common popup - myPopup = new QPopupMenu(this); - if (myMain->isEditable() && getNodeType() != SUPERV::EndLoopNode - && getNodeType() != SUPERV::EndSwitchNode) { - myRenameItem = myPopup->insertItem(tr("MSG_RENAME"), this, SLOT(rename())); - myDeleteItem = myPopup->insertItem(tr("MSG_DELETE"), this, SLOT(remove())); - mySeparatorId = myPopup->insertSeparator(); - } - myPopup->insertItem(tr("MSG_BROWSE"), this, SLOT(browse())); - if ((getNodeType() != SUPERV::EndLoopNode) && (getNodeType() != SUPERV::EndSwitchNode)) - myPopup->insertItem(tr("MSG_CHANGE_INFO"), this, SLOT(changeInformation())); - //myPopup->insertItem(tr("MSG_CONFIGURE"), this, SLOT(configure())); - - if (myMain->isEditable() && (getNodeType() != SUPERV::FactoryNode) - && (getNodeType() != SUPERV::ComputingNode)) { - if ((getNodeType() != SUPERV::EndLoopNode)) { - QPopupMenu* aAddPortMnu = new QPopupMenu(this); - aAddPortMnu->insertItem("Input", this, SLOT(addInputPort())); - if (getNodeType() != SUPERV::LoopNode) - aAddPortMnu->insertItem("Output", this, SLOT(addOutputPort())); - - myPopup->insertSeparator(); - if ((getNodeType() != SUPERV::EndSwitchNode)) - myPopup->insertItem("Edit Function", this, SLOT(editFunction())); - myPopup->insertItem("Add Port", aAddPortMnu); - } - } - - // create execution popup - myRunPopup = new QPopupMenu(this); - 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()); -} - -SUPERVGUI_Node::~SUPERVGUI_Node() -{ - Trace("SUPERVGUI_Node::~SUPERVGUI_Node") -} - - -void SUPERVGUI_Node::sync() { - // asv : 18.11.04 : fix for 6170 : after execution is finished, nodes' status must be reset. - // this code here seems to be executed only in Table View (array). - SUPERV::GraphState aState = myNode->State(); - if ( !myMain->getDataflow()->IsExecuting() && myMain->IsGUIEventLoopFinished() && - (aState == SUPERV::DoneState || aState == SUPERV::KillState || aState == SUPERV::StopState ) ) - aState = SUPERV::EditingState; - - setState( aState ); -} - -void SUPERVGUI_Node::syncOnEvent(SUPERV::GraphState theStateFromEvent) { - setState(theStateFromEvent); -} - -void SUPERVGUI_Node::setState(SUPERV::GraphState theState) -{ - MESSAGE("NodeState="<changeItem(mySuspendItem, tr("MSG_SUSPEND")); - myRunPopup->setItemEnabled(mySuspendItem, true); - myRunPopup->setItemEnabled(myStopItem, false); - - switch (theState) { - case SUPERV_Waiting: - myStatus->setText("Waiting"); - myStatus->setPaletteBackgroundColor(QColor(35, 192, 255)); - break; - case SUPERV_Running: - case SUPERV::ReadyState: - myStatus->setText("Running"); - myStatus->setPaletteBackgroundColor(QColor(32,210,32)); - myRunPopup->changeItem(myStopItem, tr("MSG_STOP")); - myRunPopup->setItemEnabled(myStopItem, true); - break; - case SUPERV_Suspend: - case SUPERV::SuspendReadyState: - myStatus->setText("Suspended"); - myStatus->setPaletteBackgroundColor(QColor(255,180, 0)); - myRunPopup->changeItem(mySuspendItem, tr("MSG_RESUME")); - break; - case SUPERV_Done: - myStatus->setText("Finished"); - myStatus->setPaletteBackgroundColor(QColor(255, 158, 255)); - myRunPopup->setItemEnabled(mySuspendItem, false); - myRunPopup->changeItem(myStopItem, tr("MSG_RESTART")); - myRunPopup->setItemEnabled(myStopItem, true); - break; - case SUPERV_Error: - myStatus->setText("Aborted"); - myStatus->setPaletteBackgroundColor(red); - myRunPopup->setItemEnabled(mySuspendItem, false); - myRunPopup->changeItem(myStopItem, tr("MSG_RESTART")); - myRunPopup->setItemEnabled(myStopItem, true); - break; - case SUPERV_Kill: - myStatus->setText("Killed"); - myStatus->setPaletteBackgroundColor(red); - myRunPopup->setItemEnabled(mySuspendItem, false); - myRunPopup->changeItem(myStopItem, tr("MSG_RESTART")); - myRunPopup->setItemEnabled(myStopItem, true); - break; - default: - myStatus->setText("No Status"); - myStatus->setPaletteBackgroundColor(QColor(NODE_RED, NODE_GREEN, NODE_BLUE)); - myRunPopup->setItemEnabled(mySuspendItem, false); - break; - } - myTime->setPaletteBackgroundColor(myStatus->paletteBackgroundColor()); - long sec = myNode->CpuUsed(); - // sec++; - char hms[9]; - long s = sec/3600; - hms[0]=(char)(((s/10)%10)+48); - hms[1]=(char)((s%10)+48); - hms[2]=':'; - sec = sec%3600; - s = sec/60; - hms[3]=(char)((s/10)+48); - hms[4]=(char)((s%10)+48); - hms[5]=':'; - sec = sec%60; - hms[6]=(char)((sec/10)+48); - hms[7]=(char)((sec%10)+48); - hms[8]='\0'; - myTime->setText(hms); -} - -void SUPERVGUI_Node::rename() -{ - QString nm = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), myNode->Name() ); - if ( !nm.isEmpty() ) { - setNodeName(nm); - } -} - - -void SUPERVGUI_Node::remove() { - Trace("SUPERVGUI_Node::remove"); - deleteLinks(); - myNode->destroy(); - myMain->getGraph()->deleteNode(this); -} - -void SUPERVGUI_Node::suspendResume() { - Trace("SUPERVGUI_Node::suspendResume"); - int n = queryList("SUPERVGUI_Node")->count(); - if (myNode->IsSuspended()) { - 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")); - } - } -} - -void SUPERVGUI_Node::kill() { - Trace("SUPERVGUI_Node::kill"); - int n = queryList("SUPERVGUI_Node")->count(); - if (!((n==1)? myMain->getDataflow()->Kill() : myNode->Kill())) { - QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_KILLNODE")); - } else { - myStatus->setPaletteBackgroundColor(Qt::red); - myTime->setPaletteBackgroundColor(Qt::red); - myMain->getMyThread()->stopThread(tr("MSG_NODE_KILLED1")+myNode->Name()+tr("MSG_NODE_KILLED2")); - } -} - -void SUPERVGUI_Node::stopRestart() { - Trace("SUPERVGUI_Node::stopRestart"); - - int n = queryList("SUPERVGUI_Node")->count(); - if ((myNode->State() == SUPERV_Stop) || (myNode->State() == SUPERV_Kill)) { - if (!((n==1)? myMain->getDataflow()->Run() : myNode->ReStart())) { - QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_RESTARTNODE")); - } - } else { - if (!((n==1)? myMain->getDataflow()->Stop() : myNode->Stop())) { - QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_STOPNODE")); - } - } -} - -void SUPERVGUI_Node::changeInformation() { - SUPERVGUI_Information* aDlg = new SUPERVGUI_Information(myNode, !myMain->isEditable()); - if (aDlg->exec() ) - sync(); - delete aDlg; - if (myNode->IsGOTO()) { - QString nmGT = myNode->Name(); - if ( !nmGT.isEmpty() ) { - setNodeName(nmGT); - } - } - if (myMain->isEditable()) { - if (myMain->isArrayShown()) { //Table View - if (myNode->IsLoop() || myNode->IsSwitch()) { //for synchronic names changing - QString nmA = myNode->Name(); - if ( !nmA.isEmpty() ) { - setNodeName(nmA); - QString aStrA(tr("ENDNODE_PREFIX")); - aStrA+=nmA; - (dynamic_cast(this))->getPairCell()->getTitle()->setText(aStrA); - (dynamic_cast(this))->getPairCell()->setNodeName(aStrA); - // QToolTip::remove((dynamic_cast(this))->getPairCell()->getTitle()); - QToolTip::add((dynamic_cast(this))->getPairCell()->getTitle(), - (dynamic_cast(this))->getPairCell()->getTitle()->text()); - - } - } - // QToolTip::remove((dynamic_cast(this))->getTitle()); - QToolTip::add((dynamic_cast(this))->getTitle(), - (dynamic_cast(this))->getTitle()->text()); - QToolTip::add((dynamic_cast(this))->getComponent(), - (dynamic_cast(this))->getComponent()->text()); - } - else { //Graph View - if (myNode->IsLoop() || myNode->IsSwitch()) { //for synchronic names changing - QString nm = myNode->Name(); - if ( !nm.isEmpty() ) { - setNodeName(nm); - QString aStr(tr("ENDNODE_PREFIX")); - aStr+=nm; - (dynamic_cast(this))->getEndNode()->setNodeName(aStr); - } - } - else { - if (!(myNode->IsGOTO())) { - // QToolTip::remove((dynamic_cast(this))->getCommLabel()); - QToolTip::add((dynamic_cast(this))->getCommLabel(), - (dynamic_cast(this))->getCommLabel()->text()); - QToolTip::add((dynamic_cast(this))->getTitleLabel(), - (dynamic_cast(this))->getTitleLabel()->text()); - } - } - } - } - /* Trace("SUPERVGUI_Node::changeInformation") - if (Supervision.information(myNode, !myMain->isEditable())) { - myMain->syncAsync(); - };*/ -} - -void SUPERVGUI_Node::configure() { - Trace("SUPERVGUI_Node::configure") - QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_NOT_IMPLEMENTED")); // kloss : a faire : lancer l'ihm DATA -} - -void SUPERVGUI_Node::showPython() { - Trace("SUPERVGUI_Node::showPython") - SUPERVGUI_Python cp(myMain->getStudy()->get_PyInterp(), !myMain->isEditable()); - cp.exec(); -} - -void SUPERVGUI_Node::showPopup(QMouseEvent* e) { - Trace("SUPERVGUI_Node::showPopup"); - if (myMain->getDataflow()->IsExecuting()) - myMain->showPopup(myRunPopup, e); - else - myMain->showPopup(myPopup, e); -} - - -void SUPERVGUI_Node::mousePressEvent(QMouseEvent* e) { - if (!myMain->getDataflow()->IsExecuting()) - myMain->showPopup(myPopup, e); -} - - -bool SUPERVGUI_Node::isWarning() { - Trace("SUPERVGUI_Node::isWarning") - return(warning); -} - -bool SUPERVGUI_Node::isStep() { - Trace("SUPERVGUI_Node::isStep") - return(step); -} - -bool SUPERVGUI_Node::isTrace() { - Trace("SUPERVGUI_Node::isTrace") - return(trace); -} - -bool SUPERVGUI_Node::isVerbose() { - Trace("SUPERVGUI_Node::isVerbose") - return(verbose); -} - -void SUPERVGUI_Node::setWarning(bool b) { - Trace("SUPERVGUI_Node::setWarning") - warning = b; -} - -void SUPERVGUI_Node::setStep(bool b) { - Trace("SUPERVGUI_Node::setStep") - step = b; -} - -void SUPERVGUI_Node::setTrace(bool b) { - Trace("SUPERVGUI_Node::setTrace") - trace = b; -} - -void SUPERVGUI_Node::setVerbose(bool b) { - Trace("SUPERVGUI_Node::setVerbose") - verbose = b; -} - - -void SUPERVGUI_Node::browse() { - if ( !aBrowseDlg ) { - aBrowseDlg = new SUPERVGUI_BrowseNodeDlg(this); - aBrowseDlg->installEventFilter( this ); - } - if ( !aBrowseDlg->isVisible() ) - aBrowseDlg->show(); - else { - aBrowseDlg->raise(); - aBrowseDlg->setActiveWindow(); - aBrowseDlg->setFocus(); - } -} - -bool SUPERVGUI_Node::eventFilter( QObject* o, QEvent* e ) -{ - if ( o == aBrowseDlg && e->type() == QEvent::Close ) - aBrowseDlg = 0; - return QFrame::eventFilter( o, e ); -} - - -void SUPERVGUI_Node::setNodeName(QString aName) { - if ( myNode->SetName(aName.latin1())) { - setName(myNode->Name()); - //myTitle->setText(aName); - } else - QMessageBox::warning( QAD_Application::getDesktop(), tr( "ERROR" ), tr( "MSG_CANT_RENAMENODE" ) ); -} - -QStringList SUPERVGUI_Node::getPortsNamesIN(SUPERV_INode theNode, bool theInputPorts) -{ - QStringList aPNList; - if (!SUPERV_isNull(theNode)) { - SUPERV_Ports aPorts = theNode->Ports(); - for (int i=0; ilength(); i++) { - if (theInputPorts) { - if (aPorts[i]->IsInput()) aPNList.append(QString(aPorts[i]->Name())); - } - else - if (!aPorts[i]->IsInput()) aPNList.append(QString(aPorts[i]->Name())); - } - } - return aPNList; -} - -SUPERV_Port SUPERVGUI_Node::createInPort() { - SUPERV_INode aNode = getInlineNode(); - if (SUPERV_isNull(aNode)) { - MESSAGE("SUPERVGUI_Node::createInPort: Node is wrong type"); - return NULL; - } - - SUPERVGUI_PortParamsDlg* aDlg = new SUPERVGUI_PortParamsDlg(getPortsNamesIN(aNode,true)); - if (aDlg->exec()) { - SUPERV_Port aPort = aNode->InPort(aDlg->getName().latin1(), - aDlg->getType().latin1()); - delete aDlg; - return aPort; - } - delete aDlg; - return NULL; -} - - -SUPERV_Port SUPERVGUI_Node::createOutPort() { - SUPERV_INode aNode = getInlineNode(); - if (SUPERV_isNull(aNode)) { - MESSAGE("SUPERVGUI_Node::createInPort: Node is wrong type"); - return NULL; - } - - SUPERVGUI_PortParamsDlg* aDlg = new SUPERVGUI_PortParamsDlg(getPortsNamesIN(aNode,false)); - if (aDlg->exec()) { - SUPERV_Port aPort = aNode->OutPort(aDlg->getName().latin1(), - aDlg->getType().latin1()); - delete aDlg; - return aPort; - } - delete aDlg; - return NULL; -} - - - -void SUPERVGUI_Node::addInputPort() { - createInPort(); -} - - -void SUPERVGUI_Node::addOutputPort() { - createOutPort(); -} - - -void SUPERVGUI_Node::editFunction() { - if (getNodeType() == SUPERV::LoopNode) { - SUPERVGUI_EditPythonDlg* aDlg = new SUPERVGUI_EditPythonDlg(true); - SUPERV_LNode aLNode = getLoopNode(); - aDlg->setInitFunction(aLNode->PyInit()); - aDlg->setMoreFunction(aLNode->PyMore()); - aDlg->setNextFunction(aLNode->PyNext()); - if (aDlg->exec()) { - aLNode->SetPyInit(aDlg->getInitFuncName().latin1(), (aDlg->getInitFunction()).in()); - aLNode->SetPyMore(aDlg->getMoreFuncName().latin1(), (aDlg->getMoreFunction()).in()); - aLNode->SetPyNext(aDlg->getNextFuncName().latin1(), (aDlg->getNextFunction()).in()); - } - delete aDlg; - } else { - SUPERVGUI_EditPythonDlg* aDlg = new SUPERVGUI_EditPythonDlg(); - SUPERV_INode aINode = getInlineNode(); - aDlg->setFunction(aINode->PyFunction()); - if (aDlg->exec()) { - aINode->SetPyFunction(aDlg->getFuncName().latin1(), (aDlg->getFunction()).in()); - } - delete aDlg; - } -} - - - - - - -/*! - * Port parameters dialog definition - */ - -static const char* MyTypeStrings[] = - {"string", "boolean", "char", "short", "int", "long", "float", "double", "objref"}; - -SUPERVGUI_PortParamsDlg::SUPERVGUI_PortParamsDlg(const QStringList& thePortsNames) - : QDialog(QAD_Application::getDesktop(), 0, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ), - myPortsNames(thePortsNames) -{ - setSizeGripEnabled( true ); - setCaption("Port parameters"); - - QGridLayout* aBaseLayout = new QGridLayout( this ); - aBaseLayout->setMargin( 11 ); aBaseLayout->setSpacing( 6 ); - - QLabel* aNameLbl = new QLabel("Port Name", this ); - aBaseLayout->addWidget(aNameLbl, 0, 0); - - myNameTxt = new QLineEdit( this ); - aNameLbl->setBuddy( myNameTxt ); - aBaseLayout->addWidget(myNameTxt, 0, 1); - - QLabel* aTypeLbl = new QLabel("Value Type", this ); - aBaseLayout->addWidget(aTypeLbl, 1, 0); - - myTypeTxt = new QComboBox( this ); - aTypeLbl->setBuddy( myTypeTxt ); - myTypeTxt->insertStrList( MyTypeStrings ); - aBaseLayout->addWidget(myTypeTxt, 1, 1); - - QGroupBox* aBtnBox = new QGroupBox( this ); - aBtnBox->setColumnLayout( 0, Qt::Vertical ); - aBtnBox->layout()->setSpacing( 0 ); aBtnBox->layout()->setMargin( 0 ); - QHBoxLayout* aBtnLayout = new QHBoxLayout( aBtnBox->layout() ); - aBtnLayout->setAlignment( Qt::AlignTop ); - aBtnLayout->setSpacing( 6 ); aBtnLayout->setMargin( 11 ); - - aBaseLayout->addMultiCellWidget( aBtnBox, 2, 2, 0, 1 ); - - QPushButton* aOKBtn = new QPushButton( tr( "BUT_OK" ), aBtnBox ); - connect( aOKBtn, SIGNAL( clicked() ), this, SLOT( clickOnOk() ) ); - aBtnLayout->addWidget( aOKBtn ); - - aBtnLayout->addStretch(); - - QPushButton* aCancelBtn = new QPushButton( tr("BUT_CANCEL"), aBtnBox ); - connect( aCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) ); - aBtnLayout->addWidget( aCancelBtn ); -} - -void SUPERVGUI_PortParamsDlg::clickOnOk() -{ - if (getName().isEmpty() || getType().isEmpty()) - QMessageBox::warning( QAD_Application::getDesktop(), tr( "ERROR" ), tr( "MSG_CANT_CREATE_PORT" ) ); - else if (myPortsNames.contains(getName())) - QMessageBox::warning( QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_PORT_EXIST") ); - else - accept(); -} diff --git a/src/SUPERVGUI/SUPERVGUI_Node.h b/src/SUPERVGUI/SUPERVGUI_Node.h deleted file mode 100644 index 05ca410..0000000 --- a/src/SUPERVGUI/SUPERVGUI_Node.h +++ /dev/null @@ -1,183 +0,0 @@ -// SUPERV SUPERVGUI : GUI for Supervisor component -// -// 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 -// -// -// -// File : SUPERVGUI_Node.h -// Author : Francis KLOSS -// Module : SUPERV - -#ifndef SUPERVGUI_Node_H -#define SUPERVGUI_Node_H - -using namespace std; -#include "SUPERVGUI_Def.h" -#include "SUPERVGUI_Label.h" -#include -#include "SUPERVGUI_BrowseNodeDlg.h" -#include -#include "SUPERVGUI_Port.h" -#include - -class SUPERVGUI_Main; - -class SUPERVGUI_Node: public QFrame { - Q_OBJECT - - public: - SUPERVGUI_Node(QWidget* theParent, SUPERVGUI_Main* theMain, SUPERV_CNode theNode); - virtual ~SUPERVGUI_Node(); - - bool eventFilter( QObject* o, QEvent* e ); - virtual void sync(); - void syncOnEvent(SUPERV::GraphState theStateFromEvent); - - virtual void hideAll()=0; - virtual void showAll()=0; - virtual void deleteLinks() {}; - virtual void setNodeName(QString aName); - - SUPERV_CNode getEngine() - { return myNode; }; - - SUPERVGUI_Main* getMain() - { return myMain; }; - - bool isWarning(); - bool isStep(); - bool isTrace(); - bool isVerbose(); - - SUPERV::KindOfNode getNodeType() - { return myNode->Kind(); } - - SUPERV_CNode getComputingNode() - { return myNode; } - - SUPERV_FNode getFactoryNode() - { return SUPERV::FNode::_narrow(myNode); } - - SUPERV_INode getInlineNode() - { return SUPERV::INode::_narrow(myNode); } - - SUPERV_GNode getGotoNode() - { return SUPERV::GNode::_narrow(myNode); } - - SUPERV_LNode getLoopNode() - { return SUPERV::LNode::_narrow(myNode); } - - SUPERV_ELNode getEndLoopNode() - { return SUPERV::ELNode::_narrow(myNode); } - - SUPERV_SNode getSwitchNode() - { return SUPERV::SNode::_narrow(myNode); } - - SUPERV_ESNode getEndSwitchNode() - { return SUPERV::ESNode::_narrow(myNode); } - - - SUPERV_Port createInPort(); - SUPERV_Port createOutPort(); - QStringList getPortsNamesIN(SUPERV_INode theNode, bool theInputPorts); - - protected: - void mousePressEvent(QMouseEvent* e); - - public slots: - void suspendResume(); - void kill(); - void stopRestart(); - void configure(); - void showPython(); - - virtual void rename(); - virtual void remove(); - void changeInformation(); - void browse(); - - void setWarning(bool b); - void setStep(bool b); - void setTrace(bool b); - void setVerbose(bool b); - void showPopup(QMouseEvent* e); - - virtual void addInputPort(); - virtual void addOutputPort(); - virtual void editFunction(); - - protected: - virtual void setState(SUPERV::GraphState theState); - - SUPERV_CNode myNode; - SUPERVGUI_Main* myMain; - - //SUPERVGUI_Label* myTitle; - SUPERVGUI_Label* myTime; - SUPERVGUI_Label* myStatus; - - QPopupMenu* myPopup; - QPopupMenu* myRunPopup; - int myKillItem; - int mySuspendItem; - int myStopItem; - int myRenameItem; - int myDeleteItem; - int mySeparatorId; - - SUPERVGUI_BrowseNodeDlg* aBrowseDlg; - - private: - - bool warning; - bool step; - bool trace; - bool verbose; - -}; - - - -/*! - * Port parameters dialog definition - */ -class SUPERVGUI_PortParamsDlg: public QDialog { - Q_OBJECT - - public: - SUPERVGUI_PortParamsDlg(const QStringList& thePortsNames); - ~SUPERVGUI_PortParamsDlg() {}; - - QString getName() { return myNameTxt->text(); } - QString getType() { return myTypeTxt->currentText(); } - - public slots: - void clickOnOk(); - - - private: - QLineEdit* myNameTxt; - QComboBox* myTypeTxt; - QStringList myPortsNames; -}; - - - -#endif diff --git a/src/SUPERVGUI/SUPERVGUI_Notification.cxx b/src/SUPERVGUI/SUPERVGUI_Notification.cxx index 7515fb0..0121236 100644 --- a/src/SUPERVGUI/SUPERVGUI_Notification.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Notification.cxx @@ -26,12 +26,15 @@ // Module : SUPERV using namespace std; + #include "SUPERVGUI_Notification.h" -#include "QAD_Message.h" -#include "QAD_FileDlg.h" -#include "SUPERVGUI_Node.h" #include "SUPERVGUI_Main.h" +#include "SUPERVGUI_CanvasNode.h" + #include "NOTIFICATION.hxx" +#include "QAD_Message.h" +#include "QAD_FileDlg.h" + #include #include #include @@ -92,10 +95,10 @@ SUPERVGUI_Notification::SUPERVGUI_Notification( SUPERVGUI_Main* m ) myMainNotif->setVerbose( false ); /* nodes notification */ - QObjectList* ihmList = myMain->getGraph()->queryList( "SUPERVGUI_Node" ); + QObjectList* ihmList = myMain->/*getGraph()->*/queryList( "SUPERVGUI_CanvasNode" ); QObjectListIt i( *ihmList ); - SUPERVGUI_Node* theNode; - while ( ( theNode = ( ( SUPERVGUI_Node* )i.current() ) ) != 0) { + SUPERVGUI_CanvasNode* theNode; + while ( ( theNode = ( ( SUPERVGUI_CanvasNode* )i.current() ) ) != 0) { lin = new QFrame( myBox ); lin->setFrameStyle( QFrame::HLine | QFrame::Plain ); @@ -279,7 +282,7 @@ void SUPERVGUI_Notification::setVerbose( bool on ) /*! Constructor */ -SUPERVGUI_NotifWidget::SUPERVGUI_NotifWidget( QWidget* parent, SUPERVGUI_Node* n ) +SUPERVGUI_NotifWidget::SUPERVGUI_NotifWidget( QWidget* parent, SUPERVGUI_CanvasNode* n ) : QWidget( parent ), myNode ( n ) { init(); diff --git a/src/SUPERVGUI/SUPERVGUI_Notification.h b/src/SUPERVGUI/SUPERVGUI_Notification.h index add42ce..82ef1eb 100644 --- a/src/SUPERVGUI/SUPERVGUI_Notification.h +++ b/src/SUPERVGUI/SUPERVGUI_Notification.h @@ -38,7 +38,7 @@ using namespace std; #include class SUPERVGUI_Main; -class SUPERVGUI_Node; +class SUPERVGUI_CanvasNode; class SUPERVGUI_NotifWidget; class SUPERVGUI_Notification: public QDialog @@ -86,11 +86,11 @@ private: class SUPERVGUI_NotifWidget : public QWidget { public: - SUPERVGUI_NotifWidget( QWidget* parent, SUPERVGUI_Node* n ); + SUPERVGUI_NotifWidget( QWidget* parent, SUPERVGUI_CanvasNode* n ); SUPERVGUI_NotifWidget( QWidget* parent, QString title ); ~SUPERVGUI_NotifWidget(); - SUPERVGUI_Node* getNode() { return myNode; } + SUPERVGUI_CanvasNode* getNode() { return myNode; } bool getWarning() { return myWarningCheck->isChecked(); } bool getStep() { return myStepCheck->isChecked(); } @@ -107,7 +107,7 @@ private: private: QString myTitle; - SUPERVGUI_Node* myNode; + SUPERVGUI_CanvasNode* myNode; QCheckBox* myWarningCheck; QCheckBox* myStepCheck; QCheckBox* myTraceCheck; diff --git a/src/SUPERVGUI/SUPERVGUI_Port.cxx b/src/SUPERVGUI/SUPERVGUI_Port.cxx deleted file mode 100644 index 73a2422..0000000 --- a/src/SUPERVGUI/SUPERVGUI_Port.cxx +++ /dev/null @@ -1,620 +0,0 @@ -// SUPERV SUPERVGUI : GUI for Supervisor component -// -// 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 -// -// -// -// File : SUPERVGUI_Port.cxx -// Author : Francis KLOSS -// Module : SUPERV - -using namespace std; -#include "SUPERVGUI_Port.h" -#include "SUPERVGUI_Def.h" -#include "SUPERVGUI_Main.h" -#include "SUPERVGUI_Link.h" -#include "SUPERVGUI.h" -#include "SUPERVGUI_BrowseNodeDlg.h" -#include "QAD_LeftFrame.h" -#include "QAD_ObjectBrowser.h" -#include -#include "SUPERVGUI_GraphNode.h" - - -// Port en general -// --------------- - -SUPERVGUI_Port::SUPERVGUI_Port(QWidget* parent, SUPERVGUI_Main* m, SUPERV::Port_ptr p): - SUPERVGUI_Label(parent, PORT_WIDTH, PORT_HEIGHT, "", QLabel::AlignLeft | QLabel::AlignVCenter), - main(m) -{ - Trace("SUPERVGUI_Port::SUPERVGUI_Port"); - port = SUPERV::Port::_duplicate(p); - myName = port->Name(); - QString aName(port->Name()); - aName += (port->IsInput())? "Input":"Output"; - setName(aName); - - if (!port->IsInput() && port->IsGate()) - setAlignment(QLabel::AlignRight | QLabel::AlignVCenter); - - if (port->IsParam() || port->IsInLine()) - setText(myName + "=" + port->ToString()); - else - setText(myName); - - setLineWidth(1); - setMidLineWidth(2); - setFrameShape(QLabel::Box); - setFrameShadow(QLabel::Plain); - - popup = new QPopupMenu(this); - if (main->isEditable()) { - mySketchItem = popup->insertItem(tr("MSG_SKETCH_LINK"), this, SLOT(sketchLink())); - popup->insertSeparator(); - } - //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())); - } - browser = popup->insertItem(tr("MSG_BROWSE"),this, SLOT(browse())); - - connect(this, SIGNAL(MousePress(QMouseEvent*)), this, SLOT(showPopup(QMouseEvent*))); - connect(this, SIGNAL(MouseRelease(QMouseEvent*)), this, SLOT(endSketch())); -} - -SUPERVGUI_Port::~SUPERVGUI_Port() { - Trace("SUPERVGUI_Port::~SUPERVGUI_Port") -} - -SUPERV_Port SUPERVGUI_Port::getPort() { - Trace("SUPERVGUI_Port::getPort") - return(port); -} - -void SUPERVGUI_Port::showPopup(QMouseEvent* e) { - Trace("SUPERVGUI_Port::showPopup"); - if (e->button() != RightButton) return; - if (main->getDataflow()->IsExecuting()) - popup->setItemEnabled(mySketchItem, false); - /* else - if (!port->IsInput() //output port - || - port->IsInput() && (!port->IsLinked() //not linked input port - || - port->Kind() == SUPERV::EndSwitchParameter)) { //input port of EndSwitch node - popup->setItemEnabled(mySketchItem, true); - } - */ - main->showPopup(popup, e); -} - - -void SUPERVGUI_Port::browse() { - Trace("SUPERVGUI_Port::browse") - QString mess = (port->IsInput())? (tr("MSG_IPORT_VAL")) : (tr("MSG_OPORT_VAL")); - mess += port->ToString(); - QMessageBox::information(QAD_Application::getDesktop(), tr("MSG_INFO"), mess); -} - - -QPoint SUPERVGUI_Port::getConnectPnt() { - return QPoint(0,0); -} - - -void SUPERVGUI_Port::sync() { - if (port->IsParam() || port->IsInLine()) - setText(myName + "=" + port->ToString()); - else - setText(myName); - -} - - -void SUPERVGUI_Port::sketchLink() { - main->getGraph()->sketchBegin(this); - if (port->IsInput()) - setLineWidth(1); -} - -void SUPERVGUI_Port::endSketch() { - main->getGraph()->sketchEnd(this); - if (port->IsInput() && port->IsLinked()) - setLineWidth(1); -} - - -void SUPERVGUI_Port::deletePort() { - SUPERVGUI_GraphNode* aNode = (SUPERVGUI_GraphNode* )main->getGraph()->child(port->Node()->Name(), "SUPERVGUI_GraphNode"); - if (aNode) { - aNode->deletePort(this); - } -} - - - - -//*********************************************************** -// Port d'entree -// ------------- - -SUPERVGUI_PortIn::SUPERVGUI_PortIn(QWidget* parent, SUPERVGUI_Main* m, SUPERV::Port_ptr p) - : SUPERVGUI_Port(parent, m, p), myDlg( 0 ) -{ - Trace("SUPERVGUI_PortIn::SUPERVGUI_PortIn"); - myLinkPrs = 0; - // link->move(0, height()/2-POINT_SIZE_HALF); - - bool editing = port->IsInput() && ( !port->IsLinked() ); //main->isEditable(); -// bool linked = port->IsLinked(); -// bool b = (!linked) && editing; - if ((!port->IsGate()) && editing ) { - psc = popup->insertItem(tr("MSG_SETVALUE"), this, SLOT(setInput())); - } - // browser = popup->insertItem(tr("MSG_BROWSE"), this, SLOT(browse())); -} - -SUPERVGUI_PortIn::~SUPERVGUI_PortIn() { - Trace("SUPERVGUI_PortIn::~SUPERVGUI_PortIn"); -} - - -bool SUPERVGUI_PortIn::eventFilter( QObject* o, QEvent* e ) -{ - if ( o == myDlg && e->type() == QEvent::Close ) - myDlg = 0; - return SUPERVGUI_Port::eventFilter( o, e ); -} - -void SUPERVGUI_PortIn::showPopup(QMouseEvent* e){ - if (e->button() != RightButton) return; - if (main->getDataflow()->IsExecuting()) - popup->setItemEnabled(mySketchItem, false); - else { - popup->setItemEnabled(mySketchItem, !port->IsLinked()); - popup->setItemEnabled(psc, !port->IsLinked()); - } - main->showPopup(popup, e); -} - -void SUPERVGUI_PortIn::deleteLinks() { - if (myLinkPrs) { - disconnect(myLinkPrs, 0, this, 0); - main->getGraph()->deleteLink(myLinkPrs); - myLinkPrs = 0; - } -} - - -void SUPERVGUI_PortIn::sync() { - SUPERVGUI_Port::sync(); - // if (port->IsLinked()) { - // popup->setItemEnabled(browser, port->State() == SUPERV_Ready); - //} else { - if (!port->IsLinked()) { - if (port->HasInput()) { - // popup->setItemEnabled(browser, true); - setLineWidth(2); - } else { - //popup->setItemEnabled(browser, false); - setLineWidth(1); - } - } -} - -void SUPERVGUI_PortIn::setValue(const char* d) { - Trace("SUPERVGUI_PortIn::setValue") - if (port->Input(Supervision.getEngine()->StringValue(d))) { - sync(); - } else { - QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_SETVAL")); - }; -} - -void SUPERVGUI_PortIn::setInput() { - Trace("SUPERVGUI_PortIn::setInput"); - if ( !myDlg ) { - myDlg = new SUPERVGUI_GetValueDlg(this); - myDlg->installEventFilter( this ); - } - if ( !myDlg->isVisible() ) - myDlg->show(); - else { - myDlg->raise(); - myDlg->setActiveWindow(); - myDlg->setFocus(); - } -} - -/*void SUPERVGUI_PortIn::browse() { - Trace("SUPERVGUI_PortIn::browse") - QString mess(tr("MSG_IPORT_VAL")); - mess += port->ToString(); - QMessageBox::information(QAD_Application::getDesktop(), tr("MSG_INFO"), mess); - }*/ - - - -/** - * Returns coordinates of connection point in content coordinates - */ -QPoint SUPERVGUI_PortIn::getConnectPnt() { - // Parent widget is internal node frame - // parent of parent is node it self - QWidget* aNode = parentWidget()->parentWidget()->parentWidget(); - QPoint aPnt(aNode->pos()); // position of the node - - if (parentWidget()->isVisible()) { - aPnt += parentWidget()->parentWidget()->pos(); - aPnt += parentWidget()->pos(); - return QPoint(aPnt.x() + pos().x(), - aPnt.y() + (pos().y() + height()/2)); - } - return QPoint(aPnt.x(), - aPnt.y() + (aNode->height()/2)); -} - -void SUPERVGUI_PortIn::setLinkPrs(SUPERVGUI_Link* theLink) { - myLinkPrs = theLink; - connect(myLinkPrs, SIGNAL(linkDeleted(SUPERVGUI_Link*)), - this, SLOT(onDeleteLink(SUPERVGUI_Link*))); - popup->setItemEnabled(mySketchItem, false); -} - -void SUPERVGUI_PortIn::onDeleteLink(SUPERVGUI_Link*) { - disconnect(myLinkPrs, 0, this, 0); - myLinkPrs = 0; - popup->setItemEnabled(psc, true); - if (port->HasInput()) - setLineWidth(2); - if (main->isEditable()) { - popup->setItemEnabled(mySketchItem, true); - } else { - popup->setItemEnabled(mySketchItem, false); - } -} - - - -//*********************************************************** -// Port de sortie -// -------------- - -SUPERVGUI_PortOut::SUPERVGUI_PortOut(QWidget* parent, SUPERVGUI_Main* m, SUPERV::Port_ptr p): - SUPERVGUI_Port(parent, m, p), - study(false) -{ - Trace("SUPERVGUI_PortOut::SUPERVGUI_PortOut") - // link->move(width()-POINT_SIZE, height()/2-POINT_SIZE_HALF); - myLinksList.setAutoDelete(false); - - if (!port->IsGate()) { - pls = popup->insertItem(tr("MSG_PUT_INSTUDY"), this, SLOT(toStudy())); - } - //browser = popup->insertItem(tr("MSG_BROWSE"), this, SLOT(browse())); - - if (!main->getDataflow()->IsReadOnly()) { - popup->setItemEnabled(mySketchItem, true); - } else { - popup->setItemEnabled(mySketchItem, false); - } -} - -SUPERVGUI_PortOut::~SUPERVGUI_PortOut() { - Trace("SUPERVGUI_PortOut::~SUPERVGUI_PortOut"); -} - -void SUPERVGUI_PortOut::sync() { - Trace("SUPERVGUI_PortOut::sync") - SUPERVGUI_Port::sync(); - - bool ok = (port->State() == SUPERV_Ready); - // popup->setItemEnabled(browser, ok); - if (study && ok) { - study = main->putDataStudy(port, STUDY_PORT_OUT); - } - - if (study) { - setLineWidth(2); - popup->changeItem(pls, tr("MSG_NOT_INSTUDY")); - } else { - setLineWidth(1); - popup->changeItem(pls, tr("MSG_PUT_INSTUDY")); - } - -} - -void SUPERVGUI_PortOut::updateStudy() { - Trace("SUPERVGUI_PortOut::updateStudy") - SUPERVGUI_Node* aNode = (SUPERVGUI_Node* )main->getGraph()->child(port->Node()->Name(), "SUPERVGUI_Node"); - if (aNode) - ((SUPERVGUI_PortOut*)aNode->child(port->Name(), "SUPERVGUI_PortOut"))->study = study; - else - { - aNode = (SUPERVGUI_Node* )main->getArray()->child(port->Node()->Name(), "SUPERVGUI_Node"); - if (aNode) - ((SUPERVGUI_PortOut*)aNode->child(port->Name(), "SUPERVGUI_PortOut"))->study = study; - } -} - -void SUPERVGUI_PortOut::toStudy() { - Trace("SUPERVGUI_PortOut::toStudy") - - 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(); -} - -/*void SUPERVGUI_PortOut::browse() { - Trace("SUPERVGUI_PortOut::browse") - QString mess(tr("MSG_OPORT_VAL")); - mess += port->ToString(); - QMessageBox::information(QAD_Application::getDesktop(), tr("MSG_INFO"), mess); - }*/ - - -/** - * Returns coordinates of connection point in scroll view content coordinates - */ -QPoint SUPERVGUI_PortOut::getConnectPnt() { - // Parent widget is internal node frame - // parent of parent is node it self - QWidget* aNode = parentWidget()->parentWidget()->parentWidget(); - QPoint aPnt(aNode->pos()); // position of the node - if (parentWidget()->isVisible()) { - aPnt += parentWidget()->parentWidget()->pos(); - aPnt += parentWidget()->pos(); - return QPoint(aPnt.x() + pos().x() + width(), - aPnt.y() + (pos().y() + height()/2)); - } - return QPoint(aPnt.x() + aNode-> width(), - aPnt.y() + (aNode->height()/2)); -} - - -void SUPERVGUI_PortOut::addLinkPrs(SUPERVGUI_Link* theLink) { - myLinksList.append(theLink); - connect(theLink, SIGNAL(linkDeleted(SUPERVGUI_Link*)), - this, SLOT(onDeleteLink(SUPERVGUI_Link*))); -} - - -void SUPERVGUI_PortOut::onDeleteLink(SUPERVGUI_Link* theLink) { - disconnect(theLink, 0, this, 0); - myLinksList.remove(theLink); -} - - -void SUPERVGUI_PortOut::deleteLinks() { - if (myLinksList.count() > 0) { - while (SUPERVGUI_Link* aLink = myLinksList.last()) { - disconnect(aLink, 0, this, 0); - myLinksList.remove(aLink); - main->getGraph()->deleteLink(aLink); - } - } -} - - - -// ---------------------------- -// Input Port of EndSwitch Node -// ---------------------------- -SUPERVGUI_PortInESNode::SUPERVGUI_PortInESNode(QWidget* parent, SUPERVGUI_Main* m, SUPERV::Port_ptr p) - : SUPERVGUI_Port(parent, m, p), myDlg( 0 ) -{ - Trace("SUPERVGUI_PortInESNode::SUPERVGUI_PortInESNode"); - myLinksList.setAutoDelete(false); - - bool editing = port->IsInput() && ( !port->IsLinked() ); //main->isEditable(); - if ((!port->IsGate()) && editing ) { - psc = popup->insertItem(tr("MSG_SETVALUE"),this, SLOT(setInput())); - } - // browser = popup->insertItem(tr("MSG_BROWSE"),this, SLOT(browse())); -} - -SUPERVGUI_PortInESNode::~SUPERVGUI_PortInESNode() { - Trace("SUPERVGUI_PortInESNode::~SUPERVGUI_PortInESNode"); -} - -bool SUPERVGUI_PortInESNode::eventFilter( QObject* o, QEvent* e ) { - if ( o == myDlg && e->type() == QEvent::Close ) - myDlg = 0; - return SUPERVGUI_Port::eventFilter( o, e ); -} - -void SUPERVGUI_PortInESNode::sync() { - SUPERVGUI_Port::sync(); - /* if (port->IsLinked()) { - popup->setItemEnabled(browser, port->State() == SUPERV_Ready); - } else {*/ - if (!port->IsLinked()) { - if (port->HasInput()) { - // popup->setItemEnabled(browser, true); - setLineWidth(2); - } else { - // popup->setItemEnabled(browser, false); - setLineWidth(1); - } - } -} - -void SUPERVGUI_PortInESNode::setValue(const char* d) { - Trace("SUPERVGUI_PortIn::setValue") - if (port->Input(Supervision.getEngine()->StringValue(d))) { - sync(); - } else { - QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_SETVAL")); - }; -} - -/** - * Returns coordinates of connection point in content coordinates - */ -QPoint SUPERVGUI_PortInESNode::getConnectPnt() { - QWidget* aNode = parentWidget()->parentWidget()->parentWidget(); - QPoint aPnt(aNode->pos()); - - if (parentWidget()->isVisible()) { - aPnt += parentWidget()->parentWidget()->pos(); - aPnt += parentWidget()->pos(); - return QPoint(aPnt.x() + pos().x(), - aPnt.y() + (pos().y() + height()/2)); - } - return QPoint(aPnt.x(), - aPnt.y() + (aNode->height()/2)); -} - -void SUPERVGUI_PortInESNode::setLinkPrs(SUPERVGUI_Link* theLink) { - myLinksList.append(theLink); - connect(theLink, SIGNAL(linkDeleted(SUPERVGUI_Link*)), - this, SLOT(onDeleteLink(SUPERVGUI_Link*))); -} - -void SUPERVGUI_PortInESNode::deleteLinks() { - if (myLinksList.count() > 0) { - while (SUPERVGUI_Link* aLink = myLinksList.last()) { - disconnect(aLink, 0, this, 0); - myLinksList.remove(aLink); - main->getGraph()->deleteLink(aLink); - } - } -} - -void SUPERVGUI_PortInESNode::setInput() { - Trace("SUPERVGUI_PortInESNode::setInput"); - if ( !myDlg ) { - myDlg = new SUPERVGUI_GetValueDlg(this); - myDlg->installEventFilter( this ); - } - if ( !myDlg->isVisible() ) - myDlg->show(); - else { - myDlg->raise(); - myDlg->setActiveWindow(); - myDlg->setFocus(); - } -} - -/*void SUPERVGUI_PortInESNode::browse() { - Trace("SUPERVGUI_PortInESNode::browse") - QString mess(tr("MSG_IPORT_VAL")); - mess += port->ToString(); - QMessageBox::information(QAD_Application::getDesktop(), tr("MSG_INFO"), mess); - }*/ - - -void SUPERVGUI_PortInESNode::onDeleteLink(SUPERVGUI_Link* theLink) { - disconnect(theLink, 0, this, 0); - myLinksList.remove(theLink); - - if (myLinksList.count() == 0) { - popup->setItemEnabled(psc, true); - } else { - popup->setItemEnabled(psc, false); - } - - if (port->HasInput()) - setLineWidth(2); - - if (main->isEditable()) { - popup->setItemEnabled(mySketchItem, true); - } else { - popup->setItemEnabled(mySketchItem, false); - } -} - - - -// ---------------------------- -// Stream Ports -// ---------------------------- - -SUPERVGUI_StreamPortIn::SUPERVGUI_StreamPortIn(QWidget* parent, SUPERVGUI_Main* m, SUPERV::StreamPort_ptr p): - SUPERVGUI_PortIn(parent, m, p) -{ - myPort = SUPERV::StreamPort::_duplicate(p); - myParamItem = popup->insertItem(tr("MSG_STREAM_PARAM"),this, SLOT(setParams())); -} - -SUPERVGUI_StreamPortIn::~SUPERVGUI_StreamPortIn() -{ -} - - -void SUPERVGUI_StreamPortIn::setParams() -{ - SUPERVGUI_StreamInDlg* aDlg = new SUPERVGUI_StreamInDlg(this); - aDlg->exec(); - delete aDlg; -} - - -void SUPERVGUI_StreamPortIn::sync() -{ - SUPERVGUI_PortIn::sync(); - setText(myName + "=" + myPort->ToString()); -} - - -//------------------------------------------------------------------------------------------------ - -SUPERVGUI_StreamPortOut::SUPERVGUI_StreamPortOut(QWidget* parent, SUPERVGUI_Main* m, SUPERV::StreamPort_ptr p): - SUPERVGUI_PortOut(parent, m, p) -{ - myPort = SUPERV::StreamPort::_duplicate(p); - myParamItem = popup->insertItem(tr("MSG_STREAM_PARAM"),this, SLOT(setParams())); -} - -SUPERVGUI_StreamPortOut::~SUPERVGUI_StreamPortOut() -{ -} - -void SUPERVGUI_StreamPortOut::setParams() -{ - SUPERVGUI_StreamOutDlg* aDlg = new SUPERVGUI_StreamOutDlg(this); - aDlg->exec(); - delete aDlg; -} - - -void SUPERVGUI_StreamPortOut::sync() -{ - SUPERVGUI_PortOut::sync(); - setText(myName + "=" + myPort->ToString()); -} - - -//------------------------------------------------------------------------------------------------ diff --git a/src/SUPERVGUI/SUPERVGUI_Port.h b/src/SUPERVGUI/SUPERVGUI_Port.h deleted file mode 100644 index e54ef63..0000000 --- a/src/SUPERVGUI/SUPERVGUI_Port.h +++ /dev/null @@ -1,239 +0,0 @@ -// SUPERV SUPERVGUI : GUI for Supervisor component -// -// 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 -// -// -// -// File : SUPERVGUI_Port.h -// Author : Francis KLOSS -// Module : SUPERV - -#ifndef SUPERVGUI_Port_H -#define SUPERVGUI_Port_H - -//#include "SUPERVGUI_Point.h" -#include "SUPERVGUI_Label.h" -#include "SUPERVGUI_Def.h" -#include "SALOME_Selection.h" - -class SUPERVGUI_Main; -class SUPERVGUI_Link; - -class SUPERVGUI_Port: public SUPERVGUI_Label { - Q_OBJECT - - public: - SUPERVGUI_Port(QWidget* parent, SUPERVGUI_Main* m, SUPERV::Port_ptr p); - virtual ~SUPERVGUI_Port(); - - SUPERV_Port getPort(); - - virtual QPoint getConnectPnt(); - virtual void deleteLinks() = 0; - virtual void sync(); - - SUPERVGUI_Main* getMain() { return main;} - - private slots: - void sketchLink(); - void endSketch(); - - protected slots: - void browse(); - virtual void deletePort(); - - protected: - SUPERVGUI_Main* main; - SUPERV_Port port; - - QPopupMenu* popup; - int mySketchItem; - int myDelItem; - int browser; - - SALOME_Selection* mySelection; - - QString myName; - - private slots: - virtual void showPopup(QMouseEvent* e); -}; - - - - -class SUPERVGUI_GetValueDlg; -class SUPERVGUI_PortIn: public SUPERVGUI_Port { - Q_OBJECT - - public: - SUPERVGUI_PortIn(QWidget* parent, SUPERVGUI_Main* m, SUPERV::Port_ptr p); - virtual ~SUPERVGUI_PortIn(); - - bool eventFilter( QObject* o, QEvent* e ); - - void sync(); - void setValue(const char* id); - virtual QPoint getConnectPnt(); - - void setLinkPrs(SUPERVGUI_Link* theLink); - - SUPERVGUI_Link* getLinkPrs() - { return myLinkPrs; }; - - void deleteLinks(); - - private slots: - void setInput(); - // void browse(); - void onDeleteLink(SUPERVGUI_Link*); - virtual void showPopup(QMouseEvent* e); - - - private: - int psd; - int psc; - SUPERVGUI_Link* myLinkPrs; - SUPERVGUI_GetValueDlg* myDlg; -}; - - - - - -class SUPERVGUI_PortOut: public SUPERVGUI_Port { - Q_OBJECT - - public: - SUPERVGUI_PortOut(QWidget* parent, SUPERVGUI_Main* m, SUPERV::Port_ptr p); - virtual ~SUPERVGUI_PortOut(); - - void sync(); - void updateStudy(); - bool isInStudy() { return study; }; - void setStudyState(bool theIsInStudy) { study = theIsInStudy; }; - virtual QPoint getConnectPnt(); - - void addLinkPrs(SUPERVGUI_Link* theLink); - - SUPERVGUI_Link* getLinkPrs(int theNum) - { return myLinksList.at(theNum); }; - - int getLinkPrsCount() - { return myLinksList.count(); }; - - void deleteLinks(); - - private slots: - void toStudy(); - // void browse(); - - void sketch(QMouseEvent* e); - void onDeleteLink(SUPERVGUI_Link*); - - - private: - int pls; - bool study; - QPtrList myLinksList; -}; - - -class SUPERVGUI_PortInESNode: public SUPERVGUI_Port { - Q_OBJECT - - public: - SUPERVGUI_PortInESNode(QWidget* parent, SUPERVGUI_Main* m, SUPERV::Port_ptr p); - virtual ~SUPERVGUI_PortInESNode(); - - bool eventFilter( QObject* o, QEvent* e ); - - void sync(); - void setValue(const char* id); - virtual QPoint getConnectPnt(); - - void setLinkPrs(SUPERVGUI_Link* theLink); - - SUPERVGUI_Link* getLinkPrs(int theNum) - { return myLinksList.at(theNum); }; - - int getLinkPrsCount() - { return myLinksList.count(); }; - - void deleteLinks(); - - - private slots: - void setInput(); - // void browse(); - void onDeleteLink(SUPERVGUI_Link*); - - - private: -// int psd; - int psc; - QPtrList myLinksList; - SUPERVGUI_GetValueDlg* myDlg; - -}; - - - - -class SUPERVGUI_StreamPortIn: public SUPERVGUI_PortIn -{ - Q_OBJECT -public: - SUPERVGUI_StreamPortIn(QWidget* parent, SUPERVGUI_Main* m, SUPERV::StreamPort_ptr p); - virtual ~SUPERVGUI_StreamPortIn(); - - void sync(); - SUPERV_StreamPort getStreamPort() { return myPort;} - -private slots: - void setParams(); - -private: - SUPERV_StreamPort myPort; - - int myParamItem; -}; - - -class SUPERVGUI_StreamPortOut: public SUPERVGUI_PortOut -{ - Q_OBJECT -public: - SUPERVGUI_StreamPortOut(QWidget* parent, SUPERVGUI_Main* m, SUPERV::StreamPort_ptr p); - virtual ~SUPERVGUI_StreamPortOut(); - - void sync(); - SUPERV_StreamPort getStreamPort() { return myPort;} - -private slots: - void setParams(); - -private: - SUPERV_StreamPort myPort; - int myParamItem; -}; - - -#endif diff --git a/src/SUPERVGUI/SUPERVGUI_Python.cxx b/src/SUPERVGUI/SUPERVGUI_Python.cxx deleted file mode 100644 index f59a0f1..0000000 --- a/src/SUPERVGUI/SUPERVGUI_Python.cxx +++ /dev/null @@ -1,119 +0,0 @@ -// SUPERV SUPERVGUI : GUI for Supervisor component -// -// 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 -// -// -// -// File : SUPERVGUI_Python.cxx -// Author : Francis KLOSS -// Module : SUPERV - -using namespace std; -#include "SUPERVGUI_Def.h" -#include "QAD_PyEditor.h" -#include "QAD_PyInterp.h" -#include "QAD_Application.h" -#include "SUPERVGUI_Python.h" -#include -#include -#include - -#define MARGIN_SIZE 11 -#define SPACING_SIZE 6 -#define MIN_PYTHON_WIDTH 300 -#define MIN_PYTHON_HEIGHT 200 - -/*! - Constructor -*/ -SUPERVGUI_Python::SUPERVGUI_Python(QAD_PyInterp* pi, bool isReadOnly) - : QDialog( 0, "", TRUE, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ), - py_int( pi ) -{ - Trace("SUPERVGUI_Python::SUPERVGUI_Python"); - setCaption("Python Control Code"); - setSizeGripEnabled( TRUE ); - - QVBoxLayout* topLayout = new QVBoxLayout( this ); - topLayout->setMargin( MARGIN_SIZE ); topLayout->setSpacing( SPACING_SIZE ); - - edit = new QMultiLineEdit( this ); - edit->setPalette( QAD_Application::getPalette( true ) ); - edit->setReadOnly( isReadOnly ); - edit->setMinimumSize( MIN_PYTHON_WIDTH, MIN_PYTHON_HEIGHT ); - - QGroupBox* GroupButtons = new QGroupBox( this ); - GroupButtons->setColumnLayout(0, Qt::Vertical ); - GroupButtons->layout()->setSpacing( 0 ); GroupButtons->layout()->setMargin( 0 ); - QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons->layout() ); - GroupButtonsLayout->setAlignment( Qt::AlignTop ); - GroupButtonsLayout->setSpacing( SPACING_SIZE ); - GroupButtonsLayout->setMargin( MARGIN_SIZE ); - - if ( !isReadOnly ) { - ok = new QPushButton( tr( "BUT_OK" ), GroupButtons, "buttonOk" ); - ok->setAutoDefault( TRUE ); ok->setDefault( TRUE ); - GroupButtonsLayout->addWidget( ok ); - connect( ok, SIGNAL( clicked() ), this, SLOT( accept() ) ); - } - GroupButtonsLayout->addStretch(); - ko = new QPushButton( isReadOnly ? tr( "BUT_CLOSE" ) : tr( "BUT_CANCEL" ), GroupButtons, "buttonCancel" ); - ko->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( ko ); - connect( ko, SIGNAL( clicked() ), this, SLOT( reject() ) ); - if ( isReadOnly ) { - GroupButtonsLayout->addStretch(); - } - topLayout->addWidget( edit ); - topLayout->addWidget( GroupButtons ); -} - -/*! - Destructor -*/ -SUPERVGUI_Python::~SUPERVGUI_Python() { - Trace("SUPERVGUI_Python::~SUPERVGUI_Python") -} - -/*! - button slot -*/ -void SUPERVGUI_Python::accept() { - Trace("SUPERVGUI_Python::okButton"); - QDialog::accept(); - qApp->processEvents(); - int n = edit->numLines(); - for ( int li = 0; li < n; li++ ) { - QString ligne = edit->textLine( li ); - if ( !ligne.isEmpty() ) { - if ( py_int->run( ligne.latin1() ) ) { - QMessageBox::warning(0, "Supervision Error", "Can't Reload Python Code"); - } - } - } -} - -/*! - button slot -*/ -void SUPERVGUI_Python::reject() { - Trace("SUPERVGUI_Python::koButton"); - QDialog::reject(); -} diff --git a/src/SUPERVGUI/SUPERVGUI_Python.h b/src/SUPERVGUI/SUPERVGUI_Python.h deleted file mode 100644 index 8e31fe1..0000000 --- a/src/SUPERVGUI/SUPERVGUI_Python.h +++ /dev/null @@ -1,53 +0,0 @@ -// SUPERV SUPERVGUI : GUI for Supervisor component -// -// 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 -// -// -// -// File : SUPERVGUI_Python.h -// Author : Francis KLOSS -// Module : SUPERV - -#ifndef SUPERVGUI_Python_H -#define SUPERVGUI_Python_H - -using namespace std; -#include "SUPERVGUI_Def.h" -#include "QAD_PyInterp.h" - -class SUPERVGUI_Python: public QDialog { - Q_OBJECT - - public: - SUPERVGUI_Python(QAD_PyInterp* pi, bool isReadOnly); - virtual ~SUPERVGUI_Python(); - - private slots: - void accept(); - void reject(); - - private: - QAD_PyInterp* py_int; - QMultiLineEdit* edit; - QPushButton* ok; - QPushButton* ko; -}; - -#endif diff --git a/src/SUPERVGUI/SUPERVGUI_Service.cxx b/src/SUPERVGUI/SUPERVGUI_Service.cxx index e43928e..2bd8191 100644 --- a/src/SUPERVGUI/SUPERVGUI_Service.cxx +++ b/src/SUPERVGUI/SUPERVGUI_Service.cxx @@ -28,6 +28,7 @@ using namespace std; #include "SUPERVGUI_Service.h" #include "SUPERVGUI_Main.h" +#include "SUPERVGUI_Library.h" #include "SUPERVGUI.h" #include "QAD_Tools.h" #include "QAD_FileDlg.h" @@ -35,8 +36,9 @@ using namespace std; #include "SALOME_NamingService.hxx" #include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog) #include +#include #include - +#include static const char * ComponentIcon[] = { "20 20 2 1", @@ -155,11 +157,10 @@ SUPERVGUI_Service::SUPERVGUI_Service(SALOME_NamingService* ns): /*QLabel* aTypeLbl = */new QLabel(tr("LBL_NODETYPE"), aAddBox2); myTypeCombo = new QComboBox(aAddBox2); - myTypeCombo->insertItem("Computation"); - myTypeCombo->insertItem("Switch"); - myTypeCombo->insertItem("Loop"); - myTypeCombo->insertItem("GoTo"); - //myTypeCombo->insertItem("Label"); + myTypeCombo->insertItem( tr( "INLINE_COMP" ) ); + myTypeCombo->insertItem( tr( "INLINE_SWTC" ) ); + myTypeCombo->insertItem( tr( "INLINE_LOOP" ) ); + myTypeCombo->insertItem( tr( "INLINE_GOTO") ); connect(myTypeCombo, SIGNAL(activated(int)), this, SLOT(typeNodeSelected(int))); aPythonLayout->addWidget(aAddBox2); @@ -168,18 +169,18 @@ SUPERVGUI_Service::SUPERVGUI_Service(SALOME_NamingService* ns): myStackWidget = new QWidgetStack(aPythonPane); // other pane - myScriptPane = new SUPERVGUI_PythonEditPane(myStackWidget); + myScriptPane = new SUPERVGUI_PythonEditPane( myStackWidget, true, myX, myY ); myOtherId = myStackWidget->addWidget(myScriptPane); // loop pane QTabWidget* aLoopTabPane = new QTabWidget(myStackWidget); - myInitPane = new SUPERVGUI_PythonEditPane(myStackWidget); + myInitPane = new SUPERVGUI_PythonEditPane( myStackWidget, true, myX, myY ); aLoopTabPane->addTab(myInitPane, "Init"); - myMorePane = new SUPERVGUI_PythonEditPane(myStackWidget); + myMorePane = new SUPERVGUI_PythonEditPane( myStackWidget, true, myX, myY ); aLoopTabPane->addTab(myMorePane, "More"); - myNextPane = new SUPERVGUI_PythonEditPane(myStackWidget); + myNextPane = new SUPERVGUI_PythonEditPane( myStackWidget, true, myX, myY ); aLoopTabPane->addTab(myNextPane, "Next"); myLoopId = myStackWidget->addWidget(aLoopTabPane); @@ -195,43 +196,42 @@ SUPERVGUI_Service::SUPERVGUI_Service(SALOME_NamingService* ns): myTabPane->addTab(aPythonPane, tr("INLINE_PANE")); // Create Tab for Macro node only if environmental variable ENABLE_MACRO_NODE is set - if ( getenv( "ENABLE_MACRO_NODE" ) != NULL ) - { - QWidget* aMacroPane = new QWidget(myTabPane); - QVBoxLayout* aMacroLayout = new QVBoxLayout(aMacroPane, 0, 4); - aMacroLayout->setMargin(5); - aMacroLayout->setSpacing(10); - - QHBoxLayout* aLoadLayout = new QHBoxLayout(aMacroPane); //!! - aLoadLayout->addStretch(); - - QPushButton* aLoadBtn = new QPushButton(tr("BUT_LOAD"), aMacroPane); - connect(aLoadBtn, SIGNAL(clicked()), this, SLOT(loadGraph())); + if ( getenv( "ENABLE_MACRO_NODE" ) != NULL ) { + QWidget* aMacroPane = new QWidget(myTabPane); + QVBoxLayout* aMacroLayout = new QVBoxLayout(aMacroPane, 0, 4); + aMacroLayout->setMargin(5); + aMacroLayout->setSpacing(10); + + QHBoxLayout* aLoadLayout = new QHBoxLayout(aMacroPane); //!! + aLoadLayout->addStretch(); + + QPushButton* aLoadBtn = new QPushButton(tr("BUT_LOAD"), aMacroPane); + connect(aLoadBtn, SIGNAL(clicked()), this, SLOT(loadGraph())); - aLoadLayout->addWidget(aLoadBtn); + aLoadLayout->addWidget(aLoadBtn); - aMacroLayout->addLayout(aLoadLayout); + aMacroLayout->addLayout(aLoadLayout); - myMacroPane = new QListView(aMacroPane); - myMacroPane->addColumn(tr("COL_COMPONENTS")); - myMacroPane->addColumn(tr("COL_PORTTYPE")); - myMacroPane->addColumn(tr("COL_PORTWAY")); - myMacroPane->setColumnAlignment(1, AlignLeft); - myMacroPane->setColumnAlignment(2, AlignLeft); - myMacroPane->setColumnAlignment(3, AlignLeft); - myMacroPane->setSelectionMode(QListView::Extended); - myMacroPane->setRootIsDecorated(true); - aMacroLayout->addWidget(myMacroPane); //!! - - QPushButton* aAddBtn = new QPushButton(tr("TIT_ADDFNODE"), aMacroPane); - connect(aAddBtn, SIGNAL(clicked()), this, SLOT(addMacroNode())); - aAddBtn->setDefault(true); - - aMacroLayout->addWidget(aAddBtn); - - myTabPane->addTab(aMacroPane, tr("MACRO_PANE")); - } + myMacroPane = new QListView(aMacroPane); + myMacroPane->addColumn(tr("COL_COMPONENTS")); + myMacroPane->addColumn(tr("COL_PORTTYPE")); + myMacroPane->addColumn(tr("COL_PORTWAY")); + myMacroPane->setColumnAlignment(1, AlignLeft); + myMacroPane->setColumnAlignment(2, AlignLeft); + myMacroPane->setColumnAlignment(3, AlignLeft); + myMacroPane->setSelectionMode(QListView::Extended); + myMacroPane->setRootIsDecorated(true); + aMacroLayout->addWidget(myMacroPane); //!! + + QPushButton* aAddBtn = new QPushButton(tr("TIT_ADDFNODE"), aMacroPane); + connect(aAddBtn, SIGNAL(clicked()), this, SLOT(addMacroNode())); + aAddBtn->setDefault(true); + + aMacroLayout->addWidget(aAddBtn); + myTabPane->addTab(aMacroPane, tr("MACRO_PANE")); + } + aMainLayout->addWidget(myTabPane); // Close button @@ -384,28 +384,24 @@ void SUPERVGUI_Service::addComputeNode() { const char* interface = item->parent()->text(0).latin1(); const char* component = item->parent()->parent()->text(0).latin1(); SALOME_ModuleCatalog::Acomponent_ptr myComponent = (*aModuleCatalog)->GetComponent(aDesktop->getComponentName(component)); - if (myComponent==NULL) { + if ( myComponent == NULL ) { QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CHOOSE_SERVICE")); - } else { + } + else { const SALOME_ModuleCatalog::Service* myService = myComponent->GetService(interface, service); - b = true; - - SUPERV_CNode node = aMain->getDataflow()->CNode(*myService); - if (CORBA::is_nil(node)) { + SUPERV_CNode aNode = aMain->getDataflow()->CNode(*myService); + if ( CORBA::is_nil( aNode ) ) { QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CREATE_NODE")); return; } - //to appear a new node in the top-left corner of the current viewport - int cx, cy; - aMain->getCanvasView()->viewportToContents(myX, myY, cx, cy); - node->Coords(cx, cy); - myX += NODE_DX; - myY += NODE_DY; - aMain->addComputeNode(SUPERV::CNode::_narrow(node)); + + SUPERV::INode_var aDummyEndNode; + addNode( aNode, aDummyEndNode, myX, myY ); + b = true; // at least one node was added } } } - if (!b) { + if ( !b ) { QMessageBox::warning(aDesktop, tr("WARNING"), tr("MSG_NONODE_TOADD")); } } @@ -438,53 +434,31 @@ void SUPERVGUI_Service::addFactoryNode() { SALOME_ModuleCatalog::Acomponent_ptr myComponent = (*aModuleCatalog)->GetComponent(component); if (myComponent==NULL) { QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CHOOSE_SERVICE")); - } else { + } + else { const SALOME_ModuleCatalog::Service* myService = myComponent->GetService(interface, service); - b = true; - - MESSAGE ( " myService->TypeOfNode == " << myService->TypeOfNode ) - - int cx, cy; + SUPERV_CNode aNode; if ( myService->TypeOfNode == 0 ) { // ComputeNode - SUPERV_CNode node = aMain->getDataflow()->CNode(*myService); - if (CORBA::is_nil(node)) { + aNode = aMain->getDataflow()->CNode(*myService); + if (CORBA::is_nil( aNode ) ) { QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CREATE_NODE")); return; } - //to appear a new node in the top-left corner of the current viewport - aMain->getCanvasView()->viewportToContents(myX, myY, cx, cy); - node->Coords(cx, cy); - myX += NODE_DX; - myY += NODE_DY; - aMain->addComputeNode(SUPERV::CNode::_narrow(node)); - } else { // Factory Node - SUPERV_FNode node = aMain->getDataflow()->FNode(component, interface, *myService); - if (CORBA::is_nil(node)) { + } + else { // Factory Node + aNode = aMain->getDataflow()->FNode(component, interface, *myService); + if ( CORBA::is_nil( aNode ) ) { QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CREATE_NODE")); return; } - //to appear a new node in the top-left corner of the current viewport - aMain->getCanvasView()->viewportToContents(myX, myY, cx, cy); - node->Coords(cx, cy); - myX += NODE_DX; - myY += NODE_DY; - aMain->addComputeNode(SUPERV::CNode::_narrow(node)); - } - -// SUPERV_FNode node = aMain->getDataflow()->FNode(component, interface, *myService); -// if (CORBA::is_nil(node)) { -// QMessageBox::warning(0, tr("ERROR"), tr("MSG_CANT_CREATE_NODE")); -// return; -// } -// node->Coords(myX, myY); -// myX += NODE_DX; -// myY += NODE_DY; -// aMain->addComputeNode(SUPERV::CNode::_narrow(node)); + SUPERV::INode_var aDummyEndNode; + addNode( aNode, aDummyEndNode, myX, myY ); + b = true; } } } - if (!b) { + if ( !b ) { QMessageBox::warning(aDesktop, tr("WARNING"), tr("MSG_NONODE_TOADD")); } } @@ -496,53 +470,44 @@ void SUPERVGUI_Service::addInlineNode() { SUPERVGUI_Main* aMain = Supervision.getMain(); if (aMain==0) { QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NO_SUPERVISION_WINDOW")); - } else if (!aMain->isEditable()) { + } + else if (!aMain->isEditable()) { QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_CREATE_NODE")); - } else { + } + else { int aSel = myTypeCombo->currentItem(); - int cx, cy; switch (aSel) { case 0: // Computation - if (myScriptPane->isDefined()) { - SUPERV_INode aNode = aMain->getDataflow()->INode(myScriptPane->getFuncName().latin1(), + { + SUPERV_CNode aNode = aMain->getDataflow()->INode(myScriptPane->getFuncName().latin1(), (myScriptPane->getFunction()).in()); if (CORBA::is_nil(aNode)) { QMessageBox::warning(0, tr("ERROR"), tr("MSG_CANT_CREATE_NODE")); return; } - //to appear a new node in the top-left corner of the current viewport - aMain->getCanvasView()->viewportToContents(myX, myY, cx, cy); - aNode->Coords(cx, cy); - myX += NODE_DX; - myY += NODE_DY; - aMain->addComputeNode(SUPERV::CNode::_narrow(aNode)); + SUPERV::INode_var aDummyEndNode; + addNode( aNode, aDummyEndNode, myX, myY ); } break; case 1: // Switch - if (myScriptPane->isDefined()) { + { SUPERV_INode aEndNode; - SUPERV_SNode aStartNode = aMain->getDataflow()->SNode(myScriptPane->getFuncName().latin1(), + SUPERV_CNode aStartNode = aMain->getDataflow()->SNode(myScriptPane->getFuncName().latin1(), (myScriptPane->getFunction()).in(), aEndNode); if (CORBA::is_nil(aStartNode) || CORBA::is_nil(aEndNode)) { QMessageBox::warning(0, tr("ERROR"), tr("MSG_CANT_CREATE_NODE")); return; } - //to appear a new node in the top-left corner of the current viewport - aMain->getCanvasView()->viewportToContents(myX, myY, cx, cy); - aStartNode->Coords(cx, cy); - aEndNode->Coords(cx + LABEL_WIDTH*2, cy); - myX += NODE_DX; - myY += NODE_DY; - aMain->addControlNode(SUPERV::CNode::_narrow(aStartNode), SUPERV::CNode::_narrow(aEndNode), true); + addNode( aStartNode, aEndNode, myX, myY ); } break; case 2: // Loop { SUPERV_INode aEndNode; - SUPERV_LNode aStartNode = aMain->getDataflow()->LNode(myInitPane->getFuncName().latin1(), (myInitPane->getFunction()).in(), + SUPERV_CNode aStartNode = aMain->getDataflow()->LNode(myInitPane->getFuncName().latin1(), (myInitPane->getFunction()).in(), myMorePane->getFuncName().latin1(), (myMorePane->getFunction()).in(), myNextPane->getFuncName().latin1(), (myNextPane->getFunction()).in(), aEndNode); @@ -550,19 +515,13 @@ void SUPERVGUI_Service::addInlineNode() { QMessageBox::warning(0, tr("ERROR"), tr("MSG_CANT_CREATE_NODE")); return; } - //to appear a new node in the top-left corner of the current viewport - aMain->getCanvasView()->viewportToContents(myX, myY, cx, cy); - aStartNode->Coords(cx, cy); - aEndNode->Coords(cx + LABEL_WIDTH*2, cy); - myX += NODE_DX; - myY += NODE_DY; - aMain->addControlNode(SUPERV::CNode::_narrow(aStartNode), SUPERV::CNode::_narrow(aEndNode), true); + addNode( aStartNode, aEndNode, myX, myY ); } break; case 3: // GoTo { - SUPERV_GNode aGotoNode; + SUPERV_CNode aGotoNode; if (myScriptPane->isDefined()) aGotoNode = aMain->getDataflow()->GNode(myScriptPane->getFuncName().latin1(), (myScriptPane->getFunction()).in(), ""); @@ -572,12 +531,8 @@ void SUPERVGUI_Service::addInlineNode() { QMessageBox::warning(0, tr("ERROR"), tr("MSG_CANT_CREATE_NODE")); return; } - //to appear a new node in the top-left corner of the current viewport - aMain->getCanvasView()->viewportToContents(myX, myY, cx, cy); - aGotoNode->Coords(cx, cy); - myX += NODE_DX; - myY += NODE_DY; - aMain->addGOTONode(SUPERV::GNode::_narrow(aGotoNode)); + SUPERV::INode_var aDummyEndNode; + addNode( aGotoNode, aDummyEndNode, myX, myY ); } break; } @@ -588,11 +543,13 @@ void SUPERVGUI_Service::addMacroNode() { SUPERVGUI_Main* aMain = Supervision.getMain(); if (aMain==0) { QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NO_SUPERVISION_WINDOW")); - } else if (!aMain->isEditable()) { + } + else if (!aMain->isEditable()) { QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), tr("MSG_CANT_CREATE_NODE")); - } else { - if (myMFile) { - SUPERV_Graph aNode; + } + else { + if ( myMFile ) { + SUPERV_CNode aNode; if (aMain->getDataflow()->IsStreamGraph()) { SUPERV_StreamGraph aSGraph = aMain->getDataflow()->ToStreamGraph(); if (!SUPERV_isNull(aSGraph)) @@ -608,13 +565,9 @@ void SUPERVGUI_Service::addMacroNode() { QMessageBox::warning(0, tr("ERROR"), tr("MSG_CANT_CREATE_NODE")); return; } - //to appear a new node in the top-left corner of the current viewport - int cx, cy; - aMain->getCanvasView()->viewportToContents(myX, myY, cx, cy); - aNode->Coords(cx, cy); - myX += NODE_DX; - myY += NODE_DY; - aMain->addMacroNode(SUPERV::CNode::_narrow(aNode)); + + SUPERV::INode_var aDummyEndNode; + addNode( aNode, aDummyEndNode, myX, myY ); } else { QMessageBox::warning(QAD_Application::getDesktop(), tr("WARNING"), tr("MSG_NONODE_TOADD")); @@ -683,7 +636,8 @@ void SUPERVGUI_Service::choose() { void SUPERVGUI_Service::showEvent(QShowEvent* theEvent) { SUPERVGUI_Main* aMain = Supervision.getMain(); if (aMain && (!aMain->isArrayShown())) { - aMain->getGraph()->viewportToContents(0, 0, myX, myY); + aMain->getArrayView()->viewportToContents(0, 0, myX, myY); + //aMain->getGraph()->viewportToContents(0, 0, myX, myY); } QDialog::showEvent(theEvent); } @@ -698,29 +652,54 @@ void SUPERVGUI_Service::tabChanged(QWidget* theWidget) { //***************************************************** // Pane for Python script editing //***************************************************** -SUPERVGUI_PythonEditPane::SUPERVGUI_PythonEditPane(QWidget* theParent) - : QFrame(theParent) +SUPERVGUI_PythonEditPane::SUPERVGUI_PythonEditPane( QWidget* theParent, const bool isNodeCreation, int& theX, int& theY ) + : myIsWithLibrary( isNodeCreation ), + QFrame( theParent ), + myX( theX ), myY( theY ) { - QGridLayout* aEditLayout = new QGridLayout(this, 2, 4); + QGridLayout* aEditLayout = new QGridLayout( this, 2, 8, 0, 6 ); // First row + if ( myIsWithLibrary ) { + QPushButton* aLibBtn = new QPushButton(tr("BUT_LIBRARY"), this); + connect(aLibBtn, SIGNAL(clicked()), this, SLOT(library())); + aEditLayout->addMultiCellWidget( aLibBtn, 0, 0, 1, 2 ); + } + QPushButton* aLoadBtn = new QPushButton(tr("BUT_LOAD"), this); connect(aLoadBtn, SIGNAL(clicked()), this, SLOT(loadFile())); - aEditLayout->addWidget(aLoadBtn, 0, 2); + aEditLayout->addMultiCellWidget( aLoadBtn, 0, 0, 3, 4 ); - myNextBtn = new QPushButton(tr("BUT_NEXT"), this); - myNextBtn->setEnabled(false); - connect(myNextBtn, SIGNAL(clicked()), this, SLOT(readFunction())); + myFunctionsCombo = new QComboBox( this ); + connect( myFunctionsCombo, SIGNAL( activated( int ) ), this, SLOT( readFunction( int ) ) ); - aEditLayout->addWidget(myNextBtn, 0, 3); + aEditLayout->addMultiCellWidget( myFunctionsCombo, 0, 0, 5, 7 ); //Second row myText = new QTextEdit(this); - myText->setWordWrap(QTextEdit::FixedColumnWidth); - myText->setWrapColumnOrWidth(80); + myText->setTextFormat( Qt::PlainText ); // NOT rich text, so text() returns plain text + myText->setWordWrap( QTextEdit::FixedColumnWidth ); + myText->setWrapColumnOrWidth( 80 ); + connect( myText, SIGNAL( returnPressed() ), this, SLOT( autoIndentLine() ) ); - aEditLayout->addMultiCellWidget(myText, 1, 1, 0, 3); + aEditLayout->addMultiCellWidget( myText, 1, 1, 0, 7 ); + //aEditLayout->setColStretch( 3, 1 ); // to allow myFunctionsCombo be larger when needed +} + +/** + * Return a text between "def" and "(" + * "def" must begin with position 0, which means that only global function definitions are possible + */ +QString getFunctionName( const QString& aLine ) { + int aDefPos = aLine.find("def"); + if ( aDefPos == 0 ) { // only global function definitions! + int aStart = aLine.find(" ", aDefPos); + int aEnd = aLine.find("(", aStart); + QString aName = aLine.mid(aStart, (aEnd-aStart)); + return aName.stripWhiteSpace(); + } + return QString(); } /** @@ -744,6 +723,8 @@ void SUPERVGUI_PythonEditPane::initPyFunctions( QTextStream& theStream ) { aLine = theStream.readLine(); if ( !aLine.isNull() && aLine.find("def") == 0 ) { + myFunctionsCombo->insertItem( getFunctionName( aLine ) ); // aLine now == function name + aPyFunction += aLine; aPyFunction += '\n'; @@ -751,7 +732,9 @@ void SUPERVGUI_PythonEditPane::initPyFunctions( QTextStream& theStream ) { aLine = theStream.readLine(); // asv : 23.11.04 : added "|| aLine.isEmpty()" - fix for PAL6870. readLine() returns an empty // string for "\n" string, it trails \n caracter. but we accept such lines.. - while ( !aLine.isNull() && ( aLine.isEmpty() || aLine[0].isSpace() ) ) { + // asv : 22.12.04 : aLine[0].isSpace() || aLine[0]=='#' -> line must begin with space or tab + // (a normal code with indentation) or comment sign. + while ( !aLine.isNull() && ( aLine.isEmpty() || aLine[0].isSpace() || aLine[0] == '#' ) ) { aPyFunction += aLine; aPyFunction += '\n'; aLine = theStream.readLine(); @@ -782,8 +765,7 @@ void SUPERVGUI_PythonEditPane::loadFile() { } myPyFunctions.clear(); - myPyIndex = -1; - myNextBtn->setEnabled( false ); + myFunctionsCombo->clear(); myText->clear(); QTextStream aFileReader(&aFile); @@ -795,11 +777,8 @@ void SUPERVGUI_PythonEditPane::loadFile() { initPyFunctions( aFileReader ); - if ( myPyFunctions.size() ) { - myNextBtn->setEnabled( true ); - myPyIndex = 0; - readFunction(); - } + if ( myPyFunctions.size() ) + readFunction( 0 ); } /** @@ -807,30 +786,28 @@ void SUPERVGUI_PythonEditPane::loadFile() { * asv : Comment above is old! Present model: just take an already read string = PyFunction * from the list which is filled in loadFile(). */ -void SUPERVGUI_PythonEditPane::readFunction() { +void SUPERVGUI_PythonEditPane::readFunction( int i ) { myText->clear(); - if ( myPyIndex != -1 && myPyFunctions.size() && myPyFunctions.size() > myPyIndex ) - myText->append( myPyFunctions[ myPyIndex++ ] ); - if ( myPyFunctions.size() <= myPyIndex ) // last index was reached - myNextBtn->setEnabled( false ); + if ( i != -1 && myPyFunctions.size() && myPyFunctions.size() > i ) + myText->append( myPyFunctions[ i ] ); + + // asv : 30.11.04 : 2.7 - Inline node function editor improvement + // 2.7.1 - set focus to editor widget on editor window opening + // 2.7.2 - scroll to the beginning of function on editor window opening + myText->setFocus(); + myText->ensureVisible( 0,0 ); } /** * Returns the text after "def" and before "(" -- first defined function name */ QString SUPERVGUI_PythonEditPane::getFuncName() { - QString aName(""); for (int i=0; i < myText->paragraphs(); i++) { - QString aLine = myText->text(i); - int aDefPos = aLine.find("def"); - if (aDefPos == 0) { - int aStart = aLine.find(" ", aDefPos); - int aEnd = aLine.find("(", aStart); - QString aName = aLine.mid(aStart, (aEnd-aStart)); - return aName.stripWhiteSpace(); - } + QString aName = getFunctionName( myText->text(i) ); + if ( !aName.isEmpty() ) + return aName; } - return aName; + return QString(); } /** @@ -854,8 +831,8 @@ SUPERV_Strings SUPERVGUI_PythonEditPane::getFunction() { void SUPERVGUI_PythonEditPane::setFunction(SUPERV_Strings theStr) { - int aLen = theStr->length(); - for (int i=0; i < aLen; i++) + myText->clear(); + for ( int i=0, aLen = theStr->length(); i < aLen; i++ ) myText->append(QString(theStr[i])); // asv : 30.11.04 : 2.7 - Inline node function editor improvement @@ -865,32 +842,79 @@ void SUPERVGUI_PythonEditPane::setFunction(SUPERV_Strings theStr) { myText->ensureVisible( 0,0 ); } +/** + * Automatic indentation rule: if a previous line ended with + * ':', then add N additional spaces in the current line. If no ':' found, then + * the same amount of spaces as in the previous line is added. Connected to + * "returnPressed" signal of myText text edit. +*/ +void SUPERVGUI_PythonEditPane::autoIndentLine() { + const int N = 4; // width of indentation "tab" + if ( myText && myText->paragraphs() ) { + + // get current cursor position and previous line (the one to be analized) + int pos, para, i; + myText->getCursorPosition( ¶, &pos ); // pos==0, beginning of line + QString line = myText->text( para-1 ); // previous paragraph line + + // construct a string containing all leading space characters of previous line (tabs, etc.) + QString spacesStr; + i = -1; + while ( line[++i].isSpace() ) // append all isSpace() characters at beginning of line to spacesStr + spacesStr += line[i]; + + // if ':' was found -- add more spaces to spacesStr + line = line.stripWhiteSpace(); + if ( line[ line.length()-1 ] == ':' ) { + i = 0; + while ( i++ < N ) + spacesStr += ' '; + } + + // ok, append spacesStr at the beginning of the current line = make indentation + myText->insertAt( spacesStr, para, pos ); + myText->setCursorPosition( para, pos+spacesStr.length() ); + } +} +/** + * Create a node by loading it from an external XML library file + * This slot opens a dialog box which then "lives" by itself.. + */ +void SUPERVGUI_PythonEditPane::library() { + // if CanImport() returns false, it displays an error message box, so there is no need to + // display such message here ("library file not found", etc.). + if ( SUPERVGUI_Library::getLibrary()->CanImport() ) { + SUPERVGUI_LibDlg* aDlg = new SUPERVGUI_LibDlg( this, myX, myY ); + aDlg->exec(); + } +} /*! * Edit Python dialog */ -SUPERVGUI_EditPythonDlg::SUPERVGUI_EditPythonDlg(bool isLoop) - :QDialog(QAD_Application::getDesktop(), 0, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) +SUPERVGUI_EditPythonDlg::SUPERVGUI_EditPythonDlg( bool isLoop ) + :QDialog(QAD_Application::getDesktop(), 0, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) { setSizeGripEnabled( true ); setCaption(tr("TIT_FUNC_PYTHON")); resize( 500, 250 ); QVBoxLayout* aMainLayout = new QVBoxLayout(this, 7, 4); + int a,b; // dummies for PythonEditPane, not used, since library = false and myX, myY are not used in PythonEditPane if (isLoop) { QTabWidget* aLoopTabPane = new QTabWidget(this); - myInitPane = new SUPERVGUI_PythonEditPane(this); + myInitPane = new SUPERVGUI_PythonEditPane( this, false, a, b ); // library == false, since no creation of a node is needed here aLoopTabPane->addTab(myInitPane, "Init"); - myMorePane = new SUPERVGUI_PythonEditPane(this); + myMorePane = new SUPERVGUI_PythonEditPane( this, false, a, b ); aLoopTabPane->addTab(myMorePane, "More"); - myNextPane = new SUPERVGUI_PythonEditPane(this); + myNextPane = new SUPERVGUI_PythonEditPane( this, false, a, b ); aLoopTabPane->addTab(myNextPane, "Next"); aMainLayout->addWidget(aLoopTabPane); } else { - myEditPane = new SUPERVGUI_PythonEditPane(this); + myEditPane = new SUPERVGUI_PythonEditPane( this, false, a, b ); aMainLayout->addWidget(myEditPane); } QGroupBox* aBtnBox = new QGroupBox( this ); @@ -912,3 +936,40 @@ SUPERVGUI_EditPythonDlg::SUPERVGUI_EditPythonDlg(bool isLoop) aMainLayout->addWidget(aBtnBox); } + +/** + * Do the following actions for newly created Engine's CNode: + * 1. Create a presentation for it (CanvasNode) + * 2. Place the CanvasNode to the current top-left corner or the current viewport + * 3. Increment the coordinates of the next CanvasNode (new nodes are "cascaded" when several of them are created at once) + * PS theEndNode is passed only for Loop and Switch nodes (EndLoop and EndSwitch) + */ +void SUPERVGUI_Service::addNode( SUPERV::CNode_var theNode, SUPERV::INode_var theEndNode, int& theX, int& theY ) { + if ( !CORBA::is_nil( theNode ) ) { + int cx, cy; //to appear a new node in the top-left corner of the current viewport + SUPERVGUI_Main* aMain = Supervision.getMain(); + + //2.8 point of improvements: Adding node to graph window with taking into account zoom factor + QWMatrix aWM = aMain->getCanvasView()->worldMatrix(); + aMain->getCanvasView()->viewportToContents(theX, theY, cx, cy); + + //2.8 point of improvements: + cx = (int)((double)cx/aWM.m11()); + cy = (int)((double)cy/aWM.m22()); + theNode->Coords(cx, cy); + if ( !CORBA::is_nil( theEndNode ) ) + theEndNode->Coords(cx + LABEL_WIDTH*2, cy); + theX += (int)(NODE_DX*aWM.m11()); + theY += (int)(NODE_DY*aWM.m22()); + + if ( theNode->IsGOTO() ) + aMain->addGOTONode( theNode ); + else if ( theNode->IsMacro() ) + aMain->addMacroNode( theNode ); + else if ( theNode->IsLoop() || theNode->IsSwitch() ) + aMain->addControlNode( theNode, SUPERV::CNode::_narrow( theEndNode ), true ); + else + aMain->addComputeNode( theNode ); + } +} + diff --git a/src/SUPERVGUI/SUPERVGUI_Service.h b/src/SUPERVGUI/SUPERVGUI_Service.h index 9a2f161..1d9a557 100644 --- a/src/SUPERVGUI/SUPERVGUI_Service.h +++ b/src/SUPERVGUI/SUPERVGUI_Service.h @@ -34,15 +34,17 @@ using namespace std; #include #include +class QListBox; -//***************************************************** -// Pane for Python script editing -//***************************************************** +/*! + * Pane for Python script editing + */ class SUPERVGUI_PythonEditPane: public QFrame { + Q_OBJECT - public: - SUPERVGUI_PythonEditPane(QWidget* theParent); +public: + SUPERVGUI_PythonEditPane( QWidget* theParent, const bool isNodeCreation, int& theX, int& theY ); ~SUPERVGUI_PythonEditPane() {}; QString getFuncName(); @@ -53,13 +55,23 @@ class SUPERVGUI_PythonEditPane: public QFrame { SUPERV_Strings getFunction(); void setFunction(SUPERV_Strings theStr); - public slots: +public slots: + // load all functions from an XML file into internal structures void loadFile(); - void readFunction(); - private: + // when user presses "Enter" - automatically set indentation of next line + void autoIndentLine(); + + // when user select another function name in combo box - fill myText with its body + void readFunction( int i ); + + // when user presses "Library" button - open a "Create node from Library" dialog + void library(); + +private: + bool myIsWithLibrary; QTextEdit* myText; - QPushButton* myNextBtn; + QComboBox* myFunctionsCombo; // fills myPyFunctions list. called from loadFile() after user selects a file. void initPyFunctions( QTextStream& ); @@ -68,31 +80,40 @@ class SUPERVGUI_PythonEditPane: public QFrame { // in readFunction() QStringList myPyFunctions; - // index of currently displayed Python function - int myPyIndex; -}; - + int& myX; // comes from SUPERVGUI_Service + int& myY; // comes from SUPERVGUI_Service -//***************************************************** -// Dialog box for node creation -//***************************************************** +}; +/*! + * Dialog box for node creation + */ class SUPERVGUI_Service: public QDialog { + Q_OBJECT - public: +public: SUPERVGUI_Service(SALOME_NamingService* ns); ~SUPERVGUI_Service(); void choose(); - protected: + /*! + * Do the following actions for newly created Engine's CNode: + * 1. Create a presentation for it (CanvasNode) + * 2. Place the CanvasNode to the current top-left corner or the current viewport + * 3. Increment the coordinates of the next CanvasNode (new nodes are "cascaded" when several of them are created at once) + * PS theEndNode is passed only for Loop and Switch nodes (EndLoop and EndSwitch) + */ + static void addNode( SUPERV::CNode_var theNode, SUPERV::INode_var theEndNode, int& theX, int& theY ); + +protected: void showEvent(QShowEvent* theEvent); - private: +private: void initialise(); - private slots: +private slots: void tabChanged(QWidget *); void addComputeNode(); void addFactoryNode(); @@ -101,8 +122,8 @@ class SUPERVGUI_Service: public QDialog { void typeNodeSelected(int theRow); void loadGraph(); - private: - QListView* components; +private: + QListView* components; SALOME_NamingService* naming; int myX, myY; QWidgetStack* myStackWidget; @@ -128,9 +149,10 @@ class SUPERVGUI_Service: public QDialog { * Edit Python dialog */ class SUPERVGUI_EditPythonDlg: public QDialog { + Q_OBJECT - public: +public: SUPERVGUI_EditPythonDlg(bool isLoop = false); ~SUPERVGUI_EditPythonDlg() {}; @@ -177,7 +199,7 @@ class SUPERVGUI_EditPythonDlg: public QDialog { void setNextFunction(SUPERV_Strings theStr) { myNextPane->setFunction(theStr); } - private: +private: SUPERVGUI_PythonEditPane* myEditPane; SUPERVGUI_PythonEditPane* myInitPane; SUPERVGUI_PythonEditPane* myMorePane; diff --git a/src/SUPERVGUI/SUPERVGUI_View.cxx b/src/SUPERVGUI/SUPERVGUI_View.cxx deleted file mode 100644 index d47a98a..0000000 --- a/src/SUPERVGUI/SUPERVGUI_View.cxx +++ /dev/null @@ -1,256 +0,0 @@ -// SUPERV SUPERVGUI : GUI for Supervisor component -// -// Copyright (C) 2003 CEA/DEN, EDF R&D -// -// -// -// File : SUPERVGUI_View.cxx -// Author : Vitaly SMETANNIKOV -// Module : SUPERV - -using namespace std; -#include "SUPERVGUI_View.h" -#include "SUPERVGUI_Main.h" -#include "QAD_Config.h" -#include - - -#if QT_VERSION >= 0x030005 -QCursor panCursor(Qt::SizeAllCursor); -#else -QCursor panCursor(SizeAllCursor); -#endif - -SUPERVGUI_View::SUPERVGUI_View(SUPERVGUI_Main* theMain): - QScrollView(theMain, 0, Qt::WRepaintNoErase), - main(theMain) -{ - myIsPanActivated = false; - myAddStudyItem = 0; - myDx = 0; - myDx = 0; - myLastX = 0; - myLastY = 0; - myIsDragging = false; - myCursor = cursor(); - myDSItemID = -1; - -// myLastMinVisX = horizontalScrollBar()->value(); //viewport()->x(); -// myLastMinVisY = verticalScrollBar()->value(); //viewport()->y(); - - myPopup = new QPopupMenu(viewport()); - - if (main->isEditable()) { - myPopup->insertItem(tr("MSG_ADD_NODE"), main, SLOT(addNode())); - myPopup->insertItem(tr("MSG_INS_FILE"), main, SLOT(insertFile())); - myPopup->insertSeparator(); - } - - myViewPopup = new QPopupMenu(viewport()); - // myViewPopup->insertItem(tr("POP_FULLVIEW"), main, SLOT(showFullGraph())); - myViewPopup->insertItem(tr("POP_FULLVIEW"), main, SLOT(showCanvas())); - myViewPopup->insertItem(tr("POP_CONTROLVIEW"), main, SLOT(showContolFlow())); - myViewPopup->insertItem(tr("POP_TABLEVIEW"), main, SLOT(showTable())); - // myViewPopup->insertItem("Previous Full View", main, SLOT(showFullGraph())); - // myViewPopup->insertItem(tr("POP_CANVASVIEW"), main, SLOT(showCanvas())); - - myPopup->insertItem(tr("POP_VIEW"), myViewPopup); - myPopup->insertSeparator(); - - myAddStudyItem = myPopup->insertItem(tr("MSG_ADD_STUDY"), this, SLOT(addToStudy())); - myPopup->insertItem(tr("MSG_CHANGE_INFO"), main, SLOT(changeInformation())); - myPopup->insertSeparator(); - - myPopup->insertItem(tr("MSG_COPY_DATAFLOW"), main, SLOT(copy())); - myPopup->insertItem(tr("MSG_FILTER_NOTIFY"), main, SLOT(filterNotification())); - - myPopup->insertSeparator(); - myPopup->insertItem(tr("MSG_CHANGE_BACKGROUND"), this, SLOT(changeBackground())); - - QString aRed = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorRed"); - QString aGreen = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorGreen"); - QString aBlue = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorBlue"); - - if( (!aRed.isEmpty()) && (!aGreen.isEmpty()) && (!aBlue.isEmpty()) ) { - QColor aColor(aRed.toInt(), aGreen.toInt(), aBlue.toInt()); - setPaletteBackgroundColor(QColor(aRed.toInt(), aGreen.toInt(), aBlue.toInt())); - } else - setPaletteBackgroundColor(MAIN_COLOR); -} - - -SUPERVGUI_View::~SUPERVGUI_View() -{ -} - -bool SUPERVGUI_View::isHavingStreamPort() -{ - SUPERV::ListOfNodes* aNodesList = main->getDataflow()->Nodes(); - - //Computing Nodes - for ( int i = 0 ; i < (int) aNodesList->CNodes.length() ; i++ ) { - SUPERV::ListOfStreamPorts aStrPortsList = *( (aNodesList->CNodes)[i]->StreamPorts() ); - if ((int) aStrPortsList.length() > 0) { - return true; - } - } - - //FactoryNodes - for ( int i = 0 ; i < (int) aNodesList->FNodes.length() ; i++ ) { - SUPERV::ListOfStreamPorts aStrPortsList = *( (aNodesList->FNodes)[i]->StreamPorts() ); - if ((int) aStrPortsList.length() > 0) { - return true; - } - } - - //InLineNodes - for ( int i = 0 ; i < (int) aNodesList->INodes.length() ; i++ ) { - SUPERV::ListOfStreamPorts aStrPortsList = *( (aNodesList->INodes)[i]->StreamPorts() ); - if ((int) aStrPortsList.length() > 0) { - return true; - } - } - - //GOTONodes - for ( int i = 0 ; i < (int) aNodesList->GNodes.length() ; i++ ) { - SUPERV::ListOfStreamPorts aStrPortsList = *( (aNodesList->GNodes)[i]->StreamPorts() ); - if ((int) aStrPortsList.length() > 0) { - return true; - } - } - - //LoopNodes - for ( int i = 0 ; i < (int) aNodesList->LNodes.length() ; i++ ) { - SUPERV::ListOfStreamPorts aStrPortsList = *( (aNodesList->LNodes)[i]->StreamPorts() ); - if ((int) aStrPortsList.length() > 0) { - return true; - } - } - - //SwitchNodes - for ( int i = 0 ; i < (int) aNodesList->SNodes.length() ; i++ ) { - SUPERV::ListOfStreamPorts aStrPortsList = *( (aNodesList->SNodes)[i]->StreamPorts() ); - if ((int) aStrPortsList.length() > 0) { - return true; - } - } - - return false; -} - -void SUPERVGUI_View::addDSPopupItem() -{ - if (myDSItemID == -1) { - //Popupmenu items for user specification of parameters, if there are any DataStream ports in the graph - if (isHavingStreamPort()) { - myPopup->insertSeparator(); - myDSItemID = myPopup->insertItem(tr("MSG_SET_GRAPHPARAMS"), main, SLOT(changeDSGraphParameters())); - } - } -} - -void SUPERVGUI_View::viewportMousePressEvent(QMouseEvent* theEvent) -{ - myIsDragging = true; - myLastX = theEvent->globalX(); - myLastY = theEvent->globalY(); - - if (((theEvent->button() == Qt::MidButton)&&(theEvent->state() == Qt::ControlButton)) || myIsPanActivated) { - myCursor = cursor(); - setCursor(panCursor); - return; - } - QScrollView::viewportMousePressEvent(theEvent); -} - -void SUPERVGUI_View::viewportMouseMoveEvent(QMouseEvent* theEvent) -{ - if (myIsDragging && ((theEvent->state() == (Qt::ControlButton|Qt::MidButton)) || myIsPanActivated)) { - myDx = theEvent->globalX() - myLastX; - myDy = theEvent->globalY() - myLastY; - - myLastX = theEvent->globalX(); - myLastY = theEvent->globalY(); - - scrollBy(-myDx, -myDy); - return; - } - QScrollView::viewportMouseMoveEvent(theEvent); -} - - - -void SUPERVGUI_View::viewportMouseReleaseEvent(QMouseEvent* theEvent) -{ - myDx = 0; - myDx = 0; - myIsDragging = false; - myIsPanActivated = false; - setCursor(myCursor); - QScrollView::viewportMouseReleaseEvent(theEvent); -} - - -void SUPERVGUI_View::ActivatePanning() -{ - myIsPanActivated = true; -} - - -void SUPERVGUI_View::ResetView() -{ - setContentsPos(0,0); -} - - -void SUPERVGUI_View::setAsFromStudy(bool theToStudy) { - if (myAddStudyItem != 0) { - myPopup->setItemEnabled(myAddStudyItem, !theToStudy); - } -} - -void SUPERVGUI_View::addToStudy() { - if (main->addStudy()) main->setAsFromStudy(true); -} - -void SUPERVGUI_View::setPaletteBackgroundColor(const QColor& color) { - viewport()->setPaletteBackgroundColor(color); - QScrollView::setPaletteBackgroundColor(color.light()); - repaintContents(); -} - -void SUPERVGUI_View::ResizeGraph ( QWidget * theChild, int theX, int theY ) { - - int aGraphWidth = contentsWidth(); - int aGraphHeight = contentsHeight(); - if (theX > (contentsWidth() - theChild->width())) { - myLastX = theX; - myDx = theChild->width(); - aGraphWidth = theX + theChild->width(); - } - if (theY > (contentsHeight() - theChild->height())) { - myLastY = theY; - myDy = theChild->height(); - aGraphHeight = theY + theChild->height(); - } - - setMaximumWidth(aGraphWidth); - setMaximumHeight(aGraphHeight); - - resizeContents(aGraphWidth, aGraphHeight); -} - -int SUPERVGUI_View::getLastX() { - return myLastX; -} - -int SUPERVGUI_View::getLastY() { - return myLastY; -} -void SUPERVGUI_View::changeBackground() -{ - QColor selColor = QColorDialog::getColor(viewport()->paletteBackgroundColor(), this ); - if ( selColor.isValid() ) { - setPaletteBackgroundColor( selColor ); - } -} diff --git a/src/SUPERVGUI/SUPERVGUI_View.h b/src/SUPERVGUI/SUPERVGUI_View.h deleted file mode 100644 index 38b8814..0000000 --- a/src/SUPERVGUI/SUPERVGUI_View.h +++ /dev/null @@ -1,76 +0,0 @@ -// SUPERV SUPERVGUI : GUI for Supervisor component -// -// Copyright (C) 2003 CEA/DEN, EDF R&D -// -// -// -// File : SUPERVGUI_View.h -// Author : Vitaly SMETANNIKOV -// Module : SUPERV - -#ifndef SUPERVGUI_View_H -#define SUPERVGUI_View_H - -//#include "SUPERVGUI.h" -#include -#include - -//VRV: porting on Qt 3.0.5 -#if QT_VERSION >= 0x030005 -#include -#endif -//VRV: porting on Qt 3.0.5 - -class SUPERVGUI_Main; - -class SUPERVGUI_View: public QScrollView { - Q_OBJECT - - public: - SUPERVGUI_View(SUPERVGUI_Main* theMain); - virtual ~SUPERVGUI_View(); - - SUPERVGUI_Main* getMain() { return main; }; - - virtual void ActivatePanning(); - virtual void ResetView(); - virtual void setAsFromStudy(bool theToStudy); - - void setPaletteBackgroundColor(const QColor& color); - - void ResizeGraph( QWidget * theChild, int theX, int theY ); - - int getLastX(); - int getLastY(); - - void addDSPopupItem(); - - public slots: - void addToStudy(); - void changeBackground(); - - protected: - void viewportMouseMoveEvent(QMouseEvent* theEvent); - void viewportMouseReleaseEvent(QMouseEvent* theEvent); - void viewportMousePressEvent(QMouseEvent* theEvent); - bool isHavingStreamPort(); - - SUPERVGUI_Main* main; - QPopupMenu* myPopup; - QPopupMenu* myViewPopup; - bool myIsPanActivated; - int myAddStudyItem; - - private: - int myDSItemID; - int myDx; - int myDy; - int myLastX; - int myLastY; - bool myIsDragging; - QCursor myCursor; - - -}; - -#endif diff --git a/src/SUPERVGUI/SUPERV_msg_en.po b/src/SUPERVGUI/SUPERV_msg_en.po index caa00ee..59ce2d7 100644 --- a/src/SUPERVGUI/SUPERV_msg_en.po +++ b/src/SUPERVGUI/SUPERV_msg_en.po @@ -21,14 +21,14 @@ # # # -# File : SupervisorGUI_msg_en.po +# File : SUPERV_msg_en.po # Module : SUPERV msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "POT-Creation-Date: 2001-09-11 12:08:44 PM CEST\n" -"PO-Revision-Date: YYYY-MM-DD\n" +"PO-Revision-Date: 2005-01-20 19:47+0300\n" "Last-Translator: FULLNAME \n" "Content-Type: text/plain; charset=iso-8859-1\n" @@ -42,7 +42,7 @@ msgstr "File '%1' exists.\nReplace?" #:SUPERVGUI_Main.cxx:252 msgid "MSG_BAD_WRITING" -msgstr "Bad Writing File" +msgstr "Export failed. Backup copy of overwritten file is stored in '%1'" #:SUPERVGUI_Main.cxx:242 msgid "TTL_EXPORT_DATAFLOW" @@ -83,7 +83,7 @@ msgstr "Delete Link" msgid "MSG_ORTHO_LINE" msgstr "Ortho Mode" -#warnings - all of them must be Supervisor Warning.. +#:SUPERVGUI_Main.cxx:146 msgid "WARNING" msgstr "Supervisor Warning" @@ -549,9 +549,21 @@ msgstr "Control" msgid "POP_TABLEVIEW" msgstr "Table" +msgid "POP_TABLEVIEWCANVAS" +msgstr "Canvas Table" + msgid "POP_CANVASVIEW" msgstr "Canvas" +msgid "POP_FITALL" +msgstr "Fit All" + +msgid "POP_FITWITHINRECT" +msgstr "Fit Within Rectangle" + +msgid "POP_ZOOM" +msgstr "Zoom" + msgid "POP_SHOW" msgstr "Show" @@ -645,6 +657,9 @@ msgstr "EndOf" msgid "BUT_LOAD" msgstr "Load from file..." +msgid "BUT_LIBRARY" +msgstr "Library..." + msgid "BUT_NEXT" msgstr "Next Function" @@ -687,6 +702,18 @@ msgstr "Node type" msgid "ITM_DEL_PORT" msgstr "Delete" +msgid "ITM_COPY_PORT" +msgstr "Copy" + +msgid "ITM_PASTE_PORT" +msgstr "Paste Port" + +msgid "ITM_COPY_NODE" +msgstr "Copy Node" + +msgid "ITM_PASTE_NODE" +msgstr "Paste Node" + msgid "MSG_CANT_CREATE_NODE" msgstr "Can't create node" @@ -695,3 +722,102 @@ msgstr "Port with such name already exists" msgid "MSG_CANT_CREATE_PORT" msgstr "Port with empty Name and empty Type can not be created" + +msgid "TIT_MANAGE_PORTS" +msgstr "Edit Ports : " + +msgid "INPUT" +msgstr "Input" + +msgid "OUTPUT" +msgstr "Output" + +msgid "TYPE_LBL" +msgstr "Type:" + +msgid "MNU_INPUT" +msgstr "Input" + +msgid "MNU_OUTPUT" +msgstr "Output" + +msgid "MNU_EDIT_FUNC" +msgstr "Edit Function" + +msgid "MNU_ADD_PORT" +msgstr "Add Port" + +msgid "MNU_MANAGE_PORTS" +msgstr "Edit Ports" + +msgid "INLINE_COMP" +msgstr "Computation" + +msgid "INLINE_SWTC" +msgstr "Switch" + +msgid "INLINE_LOOP" +msgstr "Loop" + +msgid "INLINE_GOTO" +msgstr "GoTo" + +msgid "TLT_INVALID_LINK" +msgstr "Incompatible types" + +msgid "MSG_INVALID_LINK" +msgstr "Warning: the link connect ports of incompatible types.\nYou may keep it and edit types of ports before execution\nor you may remove it now." + +msgid "BUT_REMOVE" +msgstr "Remove" + +msgid "MNU_EXPORT" +msgstr "Export to Library" + +msgid "MSG_BAD_INODE" +msgstr "InLine node export error:\nThe selected node does not seem to be a valid InLine node." + +msgid "MSG_ERROR_LIB1" +msgstr "Error creating a library file and opening for writing." + +msgid "MSG_ERROR_LIB_IS_RECREATE" +msgstr "Library file is corrupt (bad XML structure). Remove it and create a new one?" + +msgid "MSG_ERROR_LIB_IO" +msgstr "Unknown I/O error occured creating new library file." + +msgid "MSG_ERROR_LIB_WRITE" +msgstr "Error writing library file!" + +msgid "MSG_ERROR_LIB_NIL_NODE" +msgstr "Error: the node to be exported is NULL" + +msgid "MSG_ERROR_LIB_NIL_COUPLED" +msgstr "Error: the coupled node of the exported node is NULL" + +msgid "MSG_ERROR_LIB_BAD_LOOP" +msgstr "Error: the Loop/EndLoop nodes pair is incorrect." + +msgid "MSG_ERROR_LIB_BAD_SWITCH" +msgstr "Error: the Switch/EndSwitch nodes pair is incorrect." + +msgid "MSG_ERROR_IMPORT_LIB_BAD_XML" +msgstr "Library file is corrupt (bad XML structure)." + +msgid "MSG_ERROR_IMPORT_LIB_NO_XML" +msgstr "Library file is not found. Export an InLine node to library to create the library file." + +msgid "MSG_ERROR_IMPORT_BAD_INDEX" +msgstr "Index of library node to be imported is out of bounds." + +msgid "MSG_ERROR_IMPORT_BAD_KIND_OF_NODE" +msgstr "Kind of node in the library is incorrect." + +msgid "MSG_ERROR_IMPORT_EXCEPTION" +msgstr "Unknown error occured during import operation." + +msgid "MSG_ERROR_EXPORT_EXCEPTION" +msgstr "Unknown error occured during export operation." + +msgid "TIT_LIB_DLG" +msgstr "Inline Library" diff --git a/src/SUPERVGUI/SUPERV_msg_fr.po b/src/SUPERVGUI/SUPERV_msg_fr.po index f1c2519..bebae47 100644 --- a/src/SUPERVGUI/SUPERV_msg_fr.po +++ b/src/SUPERVGUI/SUPERV_msg_fr.po @@ -28,7 +28,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "POT-Creation-Date: 2001-09-11 12:08:44 PM CEST\n" -"PO-Revision-Date: YYYY-MM-DD\n" +"PO-Revision-Date: 2004-12-02 16:17+0300\n" "Last-Translator: FULLNAME \n" "Content-Type: text/plain; charset=iso-8859-1\n" @@ -42,7 +42,7 @@ msgstr "File '%1' exists.\nReplace?" #:SUPERVGUI_Main.cxx:252 msgid "MSG_BAD_WRITING" -msgstr "Bad Writing File" +msgstr "Export failed. Backup copy of overwritten file is stored in '%1'" #:SUPERVGUI_Main.cxx:242 msgid "TTL_EXPORT_DATAFLOW" @@ -442,3 +442,49 @@ msgstr "Titles" msgid "POP_SHOWPORTS" msgstr "Ports" + +msgid "TIT_MANAGE_PORTS" +msgstr "Edit Ports : " + +msgid "INPUT" +msgstr "Input" + +msgid "OUTPUT" +msgstr "Output" + +msgid "TYPE_LBL" +msgstr "Type:" + +msgid "MNU_INPUT" +msgstr "Input" + +msgid "MNU_OUTPUT" +msgstr "Output" + +msgid "MNU_EDIT_FUNC" +msgstr "Edit Function" + +msgid "MNU_ADD_PORT" +msgstr "Add Port" + +msgid "MNU_MANAGE_PORTS" +msgstr "Edit Ports" + +msgid "INLINE_COMP" +msgstr "Computation" + +msgid "INLINE_SWTC" +msgstr "Switch" + +msgid "INLINE_LOOP" +msgstr "Loop" + +msgid "INLINE_GOTO" +msgstr "GoTo" + +msgid "TLT_INVALID_LINK" +msgstr "Incompatible types" + +msgid "MSG_INVALID_LINK" +msgstr "Warning: the link connect ports of incompatible types.\nYou may keep it and edit types of ports before execution\nor you may remove it now." + diff --git a/src/Supervision/CNode_Impl.cxx b/src/Supervision/CNode_Impl.cxx index 1813fcd..03bba44 100644 --- a/src/Supervision/CNode_Impl.cxx +++ b/src/Supervision/CNode_Impl.cxx @@ -183,6 +183,9 @@ void CNode_Impl::destroy() { delete(_id) ; _thisObj->_remove_ref(); } + else { + MESSAGE("CNode_Impl::destroy ERROR ") ; + } } // endService( "CNode_Impl::Destroy" ); } @@ -1806,100 +1809,6 @@ bool CNode_Impl::Resume() { return RetVal ; } -// Old method used in the past for initial study about GOTO and Loop -// Should not be used -bool CNode_Impl::Run() { - beginService( "CNode_Impl::Run" ); - bool RetVal = false ; - GraphExecutor::DataFlow * aDataFlowExecutor = DataFlowEditor()->Executor() ; - MESSAGE( "CNode_Impl::Run DataFlowExecutor " << aDataFlowExecutor << Name() << " _IsNode " << _IsNode ) ; - if ( aDataFlowExecutor ) { - DataFlowEditor()->EditedAfterExecution( false ) ; - if ( _IsNode ) { - RetVal = aDataFlowExecutor->Run( Name() , Name() , false ) ; - } - else { - RetVal = aDataFlowExecutor->Run( false ) ; - } - } - endService( "CNode_Impl::Run" ); - return RetVal ; -} - -bool CNode_Impl::ReRun() { - beginService( "CNode_Impl::ReRun" ); - bool RetVal = false ; - GraphExecutor::DataFlow * aDataFlowExecutor = DataFlowEditor()->Executor() ; - if ( aDataFlowExecutor ) { - DataFlowEditor()->EditedAfterExecution( false ) ; - if ( _IsNode ) { - RetVal = aDataFlowExecutor->Run( Name() , Name() , false ) ; - } -// The GUI calls directly that method instead of calling Graph_Impl::Run() : -// I redirect the call to Graph_Impl::Run() - else if ( DataFlowEditor()->IsEditing() ) { - RetVal = ((Graph_Impl::Graph_Impl *) this)->Graph_Impl::Run() ; - } - else { - RetVal = aDataFlowExecutor->Run( false ) ; - } - } - endService( "CNode_Impl::ReRun" ); - return RetVal ; -} - -// Old method used in the past for initial study about GOTO and Loop -// Should not be used -bool CNode_Impl::ReRunAt( const char * aNodeName ) { - beginService( "CNode_Impl::ReRunAt" ); - bool RetVal = false ; - GraphExecutor::DataFlow * aDataFlowExecutor = DataFlowEditor()->Executor() ; - if ( aDataFlowExecutor ) { - DataFlowEditor()->EditedAfterExecution( false ) ; - if ( _IsNode ) { - RetVal = aDataFlowExecutor->Run( Name() , aNodeName , false ) ; - } - } - endService( "CNode_Impl::ReRunAt" ); - return RetVal ; -} - -bool CNode_Impl::ReStart() { - beginService( "CNode_Impl::ReStart" ); - bool RetVal = false ; - GraphExecutor::DataFlow * aDataFlowExecutor = DataFlowEditor()->Executor() ; - if ( aDataFlowExecutor ) { - if ( _IsNode ) { - RetVal = aDataFlowExecutor->Run( Name() , Name() , true ) ; - } -// The GUI calls directly that method instead of calling Graph_Impl::Start() : -// I redirect the call to Graph_Impl::Start() - else if ( DataFlowEditor()->IsEditing() ) { - RetVal = ((Graph_Impl::Graph_Impl *) this)->Graph_Impl::Start() ; - } - else { - RetVal = aDataFlowExecutor->Run( true ) ; - } - } - endService( "CNode_Impl::ReStart" ); - return RetVal ; -} - -// Old method used in the past for initial study about GOTO and Loop -// Should not be used -bool CNode_Impl::ReStartAt( const char * aNodeName ) { - beginService( "CNode_Impl::ReStartAt" ); - bool RetVal = false ; - GraphExecutor::DataFlow * aDataFlowExecutor = DataFlowEditor()->Executor() ; - if ( aDataFlowExecutor ) { - if ( _IsNode ) { - RetVal = aDataFlowExecutor->Run( Name() , aNodeName , true ) ; - } - } - endService( "CNode_Impl::ReStartAt" ); - return RetVal ; -} - long CNode_Impl::CpuUsed() { long RetVal = 0 ; GraphExecutor::DataFlow * aDataFlowExecutor = DataFlowEditor()->Executor() ; @@ -1917,11 +1826,12 @@ long CNode_Impl::CpuUsed() { bool CNode_Impl::IsExecuting() { bool RetVal = false; if ( !IsMacro() && DataFlowEditor() && DataFlowEditor()->Executor() ) { - // asv : the statement below normally does not return true, Executor_OutNode + // asv : the statement below normally does not return true, Executor_OutNode // sets Editor->Editing() after finishing of execution (see Executor_OutNode.cxx) if ( DataFlowEditor()->IsExecuting() && DataFlowEditor()->Executor()->IsDone() ) { DataFlowEditor()->Editing(); } + RetVal = DataFlowEditor()->IsExecuting(); } return RetVal; diff --git a/src/Supervision/CNode_Impl.hxx b/src/Supervision/CNode_Impl.hxx index abe1edb..78c085c 100644 --- a/src/Supervision/CNode_Impl.hxx +++ b/src/Supervision/CNode_Impl.hxx @@ -249,12 +249,6 @@ class CNode_Impl : public POA_SUPERV::CNode , virtual bool SuspendDone() ; virtual bool Resume() ; - virtual bool Run() ; - virtual bool ReRun() ; - virtual bool ReRunAt( const char * aNodeName ) ; - virtual bool ReStart() ; - virtual bool ReStartAt( const char * aNodeName ) ; - virtual long CpuUsed() ; virtual bool IsExecuting(); diff --git a/src/Supervision/ELNode_Impl.cxx b/src/Supervision/ELNode_Impl.cxx index 04bc8da..bdb787b 100644 --- a/src/Supervision/ELNode_Impl.cxx +++ b/src/Supervision/ELNode_Impl.cxx @@ -74,17 +74,21 @@ ELNode_Impl::~ELNode_Impl() { void ELNode_Impl::destroy() { beginService( "ELNode_Impl::Destroy" ); if ( DataFlowEditor()->IsEditing() ) { - SUPERV::GNode_ptr aCoupled = SUPERV::GNode::_narrow( Coupled() ) ; +// 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() ; + else { + MESSAGE("ELNode_Impl::destroy ERROR ") ; } +// destroy have to be used for the LoopNode ==> destroy of the EndLoopNode +// if ( !CORBA::is_nil( aCoupled ) ) { +// aCoupled->SetCoupled( "" ) ; +// aCoupled->destroy() ; +// } } endService( "ELNode_Impl::Destroy" ); } @@ -95,9 +99,10 @@ bool ELNode_Impl::Delete() { if ( DataFlowEditor()->IsEditing() ) { DeletePorts() ; RetVal = DataFlowEditor()->RemoveNode( Name() ) ; - if ( RetVal ) { - RetVal = DataFlowEditor()->IsValid() ; - } +// IsValid is done in LNode_Impl::Delete +// if ( RetVal ) { +// RetVal = DataFlowEditor()->IsValid() ; +// } } endService( "ELNode_Impl::Delete" ); return RetVal ; diff --git a/src/Supervision/ESNode_Impl.cxx b/src/Supervision/ESNode_Impl.cxx index 18e8fcd..1cb438e 100644 --- a/src/Supervision/ESNode_Impl.cxx +++ b/src/Supervision/ESNode_Impl.cxx @@ -79,31 +79,37 @@ ESNode_Impl::~ESNode_Impl() { void ESNode_Impl::destroy() { beginService( "ESNode_Impl::Destroy" ); if ( DataFlowEditor()->IsEditing() ) { - SUPERV::GNode_ptr aCoupled = SUPERV::GNode::_narrow( Coupled() ) ; +// 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() ; + else { + MESSAGE("ESNode_Impl::destroy ERROR ") ; } +// destroy have to be used for the SwitchNode ==> destroy of the EndSwitchNode +// if ( !CORBA::is_nil( aCoupled ) ) { +// aCoupled->SetCoupled( "" ) ; +// aCoupled->destroy() ; +// } } -// endService( "ESNode_Impl::Destroy" ); + endService( "ESNode_Impl::Destroy" ); } bool ESNode_Impl::Delete() { -// beginService( "ESNode_Impl::Delete" ); + beginService( "ESNode_Impl::Delete" ); bool RetVal = false ; if ( DataFlowEditor()->IsEditing() ) { DeletePorts() ; RetVal = DataFlowEditor()->RemoveNode( Name() ) ; - if ( RetVal ) - RetVal = DataFlowEditor()->IsValid() ; +// IsValid is done in SNode_Impl::Delete +// if ( RetVal ) { +// RetVal = DataFlowEditor()->IsValid() ; +// } } -// endService( "ESNode_Impl::Delete" ); + endService( "ESNode_Impl::Delete" ); return RetVal ; } diff --git a/src/Supervision/FNode_Impl.cxx b/src/Supervision/FNode_Impl.cxx index 9fbd6d4..391f4c1 100644 --- a/src/Supervision/FNode_Impl.cxx +++ b/src/Supervision/FNode_Impl.cxx @@ -85,6 +85,9 @@ void FNode_Impl::destroy() { delete(_id) ; _thisObj->_remove_ref(); } + else { + MESSAGE("FNode_Impl::destroy ERROR ") ; + } } // endService( "FNode_Impl::Destroy" ); } diff --git a/src/Supervision/GNode_Impl.cxx b/src/Supervision/GNode_Impl.cxx index 9299a97..7c770df 100644 --- a/src/Supervision/GNode_Impl.cxx +++ b/src/Supervision/GNode_Impl.cxx @@ -144,6 +144,9 @@ void GNode_Impl::destroy() { delete(_id) ; _thisObj->_remove_ref(); } + else { + MESSAGE("GNode_Impl::destroy ERROR ") ; + } } // endService( "GNode_Impl::Destroy" ); } diff --git a/src/Supervision/Graph_Impl.cxx b/src/Supervision/Graph_Impl.cxx index 726e574..125b051 100644 --- a/src/Supervision/Graph_Impl.cxx +++ b/src/Supervision/Graph_Impl.cxx @@ -34,6 +34,8 @@ using namespace std; //#include "utilities.h" +#include "SALOME_Container_i.hxx" + #include "StreamGraph_Impl.hxx" #include "DataFlowEditor_DataFlow.hxx" @@ -142,6 +144,7 @@ static void CreateExecutor( CORBA::ORB_ptr orb , *aDataFlowExecutor = new GraphExecutor::DataFlow( orb , NamingService , theDataFlowInstanceName.c_str() , dbgfile.c_str() , aKindOfNode ) ; + MESSAGE( "CreateExecutor " << theDataFlowName << " " << theDataFlowInstanceName << " created with " << dbgfile.c_str() ) ; @@ -520,7 +523,8 @@ SUPERV::LNode_ptr Graph_Impl::LNode( const char * InitName , myNode->SetCoupled( myEndNode->BaseNode()->Name() ) ; myEndNode->SetCoupled( myNode->BaseNode()->Name() ) ; Link( myNode->Port( "DoLoop" ) , myEndNode->Port( "DoLoop" ) ) ; - Link( myEndNode->Port( "DoLoop" ) , myNode->Port( "InitLoop" ) ) ; +// Link( myEndNode->Port( "DoLoop" ) , myNode->Port( "InitLoop" ) ) ; + Link( myEndNode->Port( "DoLoop" ) , myNode->Port( "DoLoop" ) ) ; } } anEndOfLoop = SUPERV::ELNode::_duplicate( iendobject ) ; @@ -1760,11 +1764,7 @@ bool Graph_Impl::Begin() { } if ( DataFlowExecutor() ) { MESSAGE( "Graph_Impl::Begin " << DataFlowExecutor()->Threads() << " threads" ) -// if ( DataFlowExecutor()->Threads() ) { -// DataFlowExecutor()->JoinedWait() ; -// } - delete DataFlowExecutor() ; - DataFlowEditor()->Executor( NULL ) ; + Editing(); // just in case it was not called before by GUI.. } if ( DataFlowEditor()->IsExecutable() ) { DataFlowEditor()->EditedAfterExecution( false ) ; @@ -1790,70 +1790,59 @@ bool Graph_Impl::Begin() { } return RetVal ; } -bool Graph_Impl::Run() { - beginService( "Graph_Impl::Run" ); + +/** + * run() : was created in order to reduce code dublication, Run() and Start() do the same thing + * except for final call to Executor->Run( bool ) - Run() calls with AndSuspend=false + * and Start() calls with AndSuspend=true flag. The rest of the actions are the same: + * 1. if a MacroNode's coupled graph (MacroLevel>0) -> simply Run() it. + * 2. if a Supergraph -> create executor, load dataflow in it (done in Begin()), then - Run() it. + */ +bool Graph_Impl::run( const bool andSuspend ) { bool RetVal = false ; + + // if Editing or Finished state, and, naturally, 'this' is not a MacroNode. if ( ( DataFlowEditor()->IsEditing() || IsDone() ) && !IsMacro() ) { - MESSAGE( "Graph_Impl::Run " << DataFlowEditor()->Graph()->Name() << " " << DataFlowEditor() << " IsEditing" ); + if ( DataFlowEditor()->Graph()->GraphMacroLevel() ) { - MESSAGE( "Graph_Impl::Run " << DataFlowEditor()->Graph()->Name() << " GraphMacroLevel " - << DataFlowEditor()->Graph()->GraphMacroLevel() ) ; - RetVal = true ; + // MacroGraph's Executor was created in recursive function LoadDataflows(Executor), called from + // Begin() of Supergraph. See Begin() and LoadDataflows(Executor) for details. + RetVal = true ; } else { - MESSAGE( "Graph_Impl::Run " << DataFlowEditor()->Graph()->Name() << " GraphMacroLevel " - << DataFlowEditor()->Graph()->GraphMacroLevel() << " --> Begin()" ) ; + // Create Executor instance and its datamodel RetVal = Begin() ; } if ( RetVal ) { - MESSAGE( "Graph_Impl::Run " ); + // Set Executing flag to avoid edition operations during execution, EditedAfterExecution=false DataFlowEditor()->Executing() ; - RetVal = CNode_Impl::Run() ; + DataFlowEditor()->EditedAfterExecution( false ); + + // THE MAIN RUN METHOD + RetVal = DataFlowExecutor()->Run( andSuspend ); } } -// It is necessary to reload the dataflow because of ports with input initial values changed -// during execution to values of outport of EndLoopNode or GOTONode -// else if ( !IsMacro() && IsDone() ) { -// MESSAGE( "Graph_Impl::Run " << DataFlowEditor()->Graph()->Name() << " " << DataFlowEditor() -// << " IsNOTEditing --> CNode_Impl::ReRun" ); -// DataFlowEditor()->Executing() ; -// RetVal = CNode_Impl::ReRun() ; -// } + return RetVal ; + +} + +/** + * Run() - called on "Execute" command + */ +bool Graph_Impl::Run() { + beginService( "Graph_Impl::Run" ); + bool RetVal = run( /*andSuspend=*/false ) ; MESSAGE( "Graph_Impl::Run " << DataFlowEditor()->Graph()->Name() << " RetVal " << RetVal ) ; endService( "Graph_Impl::Run" ); return RetVal ; } + +/** + * Run() - called on "Execute step-by-step" command + */ bool Graph_Impl::Start() { beginService( "Graph_Impl::Start" ); - bool RetVal = false ; - if ( ( DataFlowEditor()->IsEditing() || IsDone() ) && !IsMacro() ) { - MESSAGE( "Graph_Impl::Start " << DataFlowEditor()->Graph()->Name() << " " << DataFlowEditor() << " IsEditing" ); - if ( DataFlowEditor()->Graph()->GraphMacroLevel() ) { - MESSAGE( "Graph_Impl::Start " << DataFlowEditor()->Graph()->Name() << " GraphMacroLevel " - << DataFlowEditor()->Graph()->GraphMacroLevel() ) ; - RetVal = true ; - } - else { - MESSAGE( "Graph_Impl::Start " << DataFlowEditor()->Graph()->Name() << " GraphMacroLevel " - << DataFlowEditor()->Graph()->GraphMacroLevel() << " --> Begin()" ) ; - RetVal = Begin() ; - } - if ( RetVal ) { - // Added by NKV to fix PAL6222 --> to be confirm by JR ; JR confirmed - DataFlowEditor()->Executing() ; - // End of NKV's correction - MESSAGE( "Graph_Impl::(Re)Start " ); - RetVal = ReStart() ; - } - } -// It is necessary to reload the dataflow because of ports with input initial values changed -// during execution to values of outport of EndLoopNode or GOTONode -// else if ( !IsMacro() && IsDone() ) { -// MESSAGE( "Graph_Impl::Start " << DataFlowEditor()->Graph()->Name() << " " << DataFlowEditor() -// << " IsNOTEditing --> CNode_Impl::ReStart" ); -// DataFlowEditor()->Executing() ; -// RetVal = CNode_Impl::ReStart() ; -// } + bool RetVal = run( /*andSuspend=*/true ) ; MESSAGE( "Graph_Impl::Start " << DataFlowEditor()->Graph()->Name() << " RetVal " << RetVal ) ; endService( "Graph_Impl::Start" ); return RetVal ; @@ -1937,6 +1926,7 @@ bool Graph_Impl::Event( SUPERV::CNode_out aNode , } anEvent = theEvent ; aState = theState ; + return RetVal ; } @@ -2492,5 +2482,13 @@ SUPERV::StreamGraph_ptr Graph_Impl::ToStreamGraph() { return SUPERV::StreamGraph::_duplicate( iobject ) ; } - +/** + * Destroy Executor and use only Editor and its data model + */ +void Graph_Impl::Editing() { + if ( DataFlowEditor() && DataFlowExecutor() ) { + delete DataFlowExecutor() ; + DataFlowEditor()->Executor( NULL ); + } +} diff --git a/src/Supervision/Graph_Impl.hxx b/src/Supervision/Graph_Impl.hxx index 5f1d8c0..3469f05 100644 --- a/src/Supervision/Graph_Impl.hxx +++ b/src/Supervision/Graph_Impl.hxx @@ -181,9 +181,10 @@ class Graph_Impl : public POA_SUPERV::Graph , virtual long Threads() ; virtual long SuspendedThreads() ; + virtual bool Run() ; // called on "Execute Graph" command + virtual bool Start() ; // called on "Execute Graph Step-by-Step" command + virtual bool Begin() ; - virtual bool Run() ; - virtual bool Start() ; virtual long LastLevelDone() ; virtual bool EventNoW( SUPERV::CNode_out aNode , @@ -205,6 +206,11 @@ class Graph_Impl : public POA_SUPERV::Graph , virtual SUPERV::StreamGraph_ptr ToStreamGraph() ; + virtual void Editing(); // Destroy Executor and use only Editor and its data model + +private: + bool run( const bool andSuspend = false ); // Run() calls run( false ), Start() calls run( true ); + }; diff --git a/src/Supervision/INode_Impl.cxx b/src/Supervision/INode_Impl.cxx index 64a355c..8797369 100644 --- a/src/Supervision/INode_Impl.cxx +++ b/src/Supervision/INode_Impl.cxx @@ -137,6 +137,9 @@ void INode_Impl::destroy() { delete(_id) ; _thisObj->_remove_ref(); } + else { + MESSAGE("INode_Impl::destroy ERROR ") ; + } } endService( "INode_Impl::Destroy" ); } diff --git a/src/Supervision/LNode_Impl.cxx b/src/Supervision/LNode_Impl.cxx index d258747..05907bd 100644 --- a/src/Supervision/LNode_Impl.cxx +++ b/src/Supervision/LNode_Impl.cxx @@ -86,10 +86,15 @@ void LNode_Impl::destroy() { delete(_id) ; _thisObj->_remove_ref(); } + else { + MESSAGE("LNode_Impl::destroy ERROR ") ; + } if ( !CORBA::is_nil( aCoupled ) ) { - aCoupled->SetCoupled( "" ) ; +// aCoupled->SetCoupled( "" ) ; : Used in GraphBase::Graph::RemoveNode( EndLoopNode ) : aCoupled->destroy() ; } +// Valid() only after deletion of the corresponding EndLoopNode : + DataFlowEditor()->IsValid() ; } endService( "LNode_Impl::Destroy" ); } @@ -100,9 +105,10 @@ bool LNode_Impl::Delete() { if ( DataFlowEditor()->IsEditing() ) { DeletePorts() ; RetVal = DataFlowEditor()->RemoveNode( Name() ) ; - if ( RetVal ) { - RetVal = DataFlowEditor()->IsValid() ; - } +// Valid() only after deletion of the corresponding EndLoopNode : +// if ( RetVal ) { +// RetVal = DataFlowEditor()->IsValid() ; +// } } endService( "LNode_Impl::Delete" ); return RetVal ; diff --git a/src/Supervision/Link_Impl.cxx b/src/Supervision/Link_Impl.cxx index 9f9cb48..1331b30 100644 --- a/src/Supervision/Link_Impl.cxx +++ b/src/Supervision/Link_Impl.cxx @@ -271,3 +271,26 @@ bool Link_Impl::Coords( const long index , long & X , long & Y ) { return RetVal ; } +/** + * Return true if InPort's and OutPort's types are compatible + * {"string", "boolean", "char", "short", "int", "long", "float", "double", "objref"}; + * Currently considered compatible ALL types except for objref - they must match exactly + * To make sure no other rule of compatibility is used - see Editor::OutNode::IsCompatible(). + */ +bool Link_Impl::IsValid() { + if ( InPort() && OutPort() ) { + return DataFlowEditor()->IsCompatible( OutPort()->Type(), InPort()->Type() ); + } + return false; +} + +/** + * Return true the ports of this link and theLink are equal. If you do on the GUI side - it does not + * return the correct value.. + */ +bool Link_Impl::IsEqual( SUPERV::Link_ptr theLink ) { + if ( InPort() && OutPort() && !CORBA::is_nil(theLink) ) { + return ( InPort() == theLink->InPort() && OutPort() == theLink->OutPort() ); + } + return false; +} diff --git a/src/Supervision/Link_Impl.hxx b/src/Supervision/Link_Impl.hxx index 0f0ef19..059cb6b 100644 --- a/src/Supervision/Link_Impl.hxx +++ b/src/Supervision/Link_Impl.hxx @@ -108,6 +108,10 @@ class Link_Impl : public POA_SUPERV::Link , virtual bool RemoveCoord( const long index ) ; virtual bool Coords( const long index , long & X , long & Y ) ; + virtual bool IsValid(); // returns true if inPort() and outPort() are type-compatible + + virtual bool IsEqual( SUPERV::Link_ptr theLink ); // returns true if GraphBase::InPort-s and OutPort-s of + // this Link and theLink are equal } ; diff --git a/src/Supervision/SNode_Impl.cxx b/src/Supervision/SNode_Impl.cxx index d1d0275..3b6e210 100644 --- a/src/Supervision/SNode_Impl.cxx +++ b/src/Supervision/SNode_Impl.cxx @@ -83,24 +83,31 @@ void SNode_Impl::destroy() { delete(_id) ; _thisObj->_remove_ref(); } + else { + MESSAGE("SNode_Impl::destroy ERROR ") ; + } if ( !CORBA::is_nil( aCoupled ) ) { - aCoupled->SetCoupled( "" ) ; +// aCoupled->SetCoupled( "" ) ; : Used in GraphBase::Graph::RemoveNode( EndSwitchNode ) : aCoupled->destroy() ; } +// Valid() only after deletion of the corresponding EndSwitchNode : + DataFlowEditor()->IsValid() ; } -// endService( "SNode_Impl::Destroy" ); + endService( "SNode_Impl::Destroy" ); } bool SNode_Impl::Delete() { -// beginService( "SNode_Impl::Delete" ); + beginService( "SNode_Impl::Delete" ); bool RetVal = false ; if ( DataFlowEditor()->IsEditing() ) { DeletePorts() ; RetVal = DataFlowEditor()->RemoveNode( Name() ) ; - if ( RetVal ) - RetVal = DataFlowEditor()->IsValid() ; +// Valid() only after deletion of the corresponding EndLoopNode : +// if ( RetVal ) { +// RetVal = DataFlowEditor()->IsValid() ; +// } } -// endService( "SNode_Impl::Delete" ); + endService( "SNode_Impl::Delete" ); return RetVal ; } diff --git a/src/Supervision/SuperV.py b/src/Supervision/SuperV.py index 613f6c6..7b7acbd 100644 --- a/src/Supervision/SuperV.py +++ b/src/Supervision/SuperV.py @@ -501,14 +501,14 @@ class CNode: return self.N.DoneW() def SuspendedW( self ): return self.N.SuspendedW() - def ReRun( self ): - return self.N.ReRun() - def ReStart( self ): - return self.N.ReStart() - def ReRunAt( self , aNodeName ): - return self.N.ReRunAt( aNodeName ) - def ReStartAt( self , aNodeName ): - return self.N.ReStartAt( aNodeName ) + #def ReRun( self ): + # return self.N.ReRun() + #def ReStart( self ): + # return self.N.ReStart() + #def ReRunAt( self , aNodeName ): + # return self.N.ReRunAt( aNodeName ) + #def ReStartAt( self , aNodeName ): + # return self.N.ReStartAt( aNodeName ) def Ping( self ): return self.N.ping() def Kill( self ): diff --git a/src/Supervision/Value_Impl.cxx b/src/Supervision/Value_Impl.cxx index d721730..9b948e6 100644 --- a/src/Supervision/Value_Impl.cxx +++ b/src/Supervision/Value_Impl.cxx @@ -170,35 +170,27 @@ CORBA::Any * Value_Impl::ToAny() { else { _InputValue = _DataFlowEditor->HasInput( _ParameterName ) ; } - if ( _InputValue && _DataFlowEditor->IsEditing() ) { + GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; + if ( _DataFlowExecutor ) { + anAny = new CORBA::Any( * _DataFlowExecutor->GetInData( name , + _ParameterName ) ) ; + } + else if ( _InputValue ) { anAny = new CORBA::Any( * _DataFlowEditor->GetInData( name , _ParameterName ) ) ; } else { - GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; - if ( _DataFlowExecutor ) { - anAny = new CORBA::Any( * _DataFlowExecutor->GetInData( name , - _ParameterName ) ) ; - } - else { - anAny = new CORBA::Any( *_Any ) ; - } + anAny = new CORBA::Any( *_Any ) ; } } else { - if ( _InputValue && _DataFlowEditor->IsEditing() ) { - anAny = new CORBA::Any( * _DataFlowEditor->GetOutData( name , - _ParameterName ) ) ; + GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; + if ( _DataFlowExecutor ) { + anAny = new CORBA::Any( * _DataFlowExecutor->GetOutData( name , + _ParameterName ) ) ; } else { - GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; - if ( _DataFlowExecutor ) { - anAny = new CORBA::Any( * _DataFlowExecutor->GetOutData( name , - _ParameterName ) ) ; - } - else { - anAny = new CORBA::Any( *_Any ) ; - } + anAny = new CORBA::Any( *_Any ) ; } } } @@ -211,8 +203,6 @@ CORBA::Any * Value_Impl::ToAny() { char * Value_Impl::ToString() { // beginService( "Value_Impl::ToString" ); CORBA::Any anAny = *ToAny() ; -// cout << "Value_Impl::ToString " << _DataFlowNode->Name() << " " -// << _ParameterName << " " ; if ( _DataFlowEditor ) { char * name ; if ( _DataFlowNode ) { @@ -221,6 +211,7 @@ char * Value_Impl::ToString() { else { name = _DataFlowEditor->Graph()->Name() ; } +// cout << "Value_Impl::ToString " << name << " " << _ParameterName << " " ; if ( _InputPort ) { if ( _DataFlowNode ) { _InputValue = _DataFlowNode->HasInput( _ParameterName ) ; @@ -228,29 +219,30 @@ char * Value_Impl::ToString() { else { _InputValue = _DataFlowEditor->HasInput( _ParameterName ) ; } - if ( _InputValue && _DataFlowEditor->IsEditing() ) { + GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; + if ( _DataFlowExecutor ) { +// cout << "_DataFlowExecutor->GetInData" << endl ; + anAny = * _DataFlowExecutor->GetInData( name , + _ParameterName ) ; + } + else if ( _InputValue ) { +// cout << "_DataFlowEditor->GetInData _DataFlowNode " << _DataFlowNode +// << " _InputValue " << _InputValue << endl ; anAny = * _DataFlowEditor->GetInData( name , _ParameterName ) ; } else { - GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; - if ( _DataFlowExecutor ) { - anAny = * _DataFlowExecutor->GetInData( name , - _ParameterName ) ; - } + anAny = *_Any ; } } else { - if ( _InputValue && _DataFlowEditor->IsEditing() ) { - anAny = * _DataFlowEditor->GetOutData( name , - _ParameterName ) ; + GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; + if ( _DataFlowExecutor ) { + anAny = * _DataFlowExecutor->GetOutData( name , + _ParameterName ) ; } else { - GraphExecutor::DataFlow * _DataFlowExecutor = _DataFlowEditor->Executor() ; - if ( _DataFlowExecutor ) { - anAny = * _DataFlowExecutor->GetOutData( name , - _ParameterName ) ; - } + anAny = *_Any ; } } } diff --git a/src/Supervision/batchmode_SuperV.py b/src/Supervision/batchmode_SuperV.py index bdc6441..6a70677 100644 --- a/src/Supervision/batchmode_SuperV.py +++ b/src/Supervision/batchmode_SuperV.py @@ -557,14 +557,14 @@ class CNode: return self.N.DoneW() def SuspendedW( self ): return self.N.SuspendedW() - def ReRun( self ): - return self.N.ReRun() - def ReStart( self ): - return self.N.ReStart() - def ReRunAt( self , aNodeName ): - return self.N.ReRunAt( aNodeName ) - def ReStartAt( self , aNodeName ): - return self.N.ReStartAt( aNodeName ) + #def ReRun( self ): + # return self.N.ReRun() + #def ReStart( self ): + # return self.N.ReStart() + #def ReRunAt( self , aNodeName ): + # return self.N.ReRunAt( aNodeName ) + #def ReStartAt( self , aNodeName ): + # return self.N.ReStartAt( aNodeName ) def Ping( self ): return self.N.ping() def Kill( self ): @@ -1257,11 +1257,26 @@ class Graph(GNode): class GraphE(Graph): ########################################################## def __init__( self , aName ): - graph = SuperVision.GraphE( aName ) - self.G = graph - self.G.Verbose = 1 - self.N = graph - self.N.Verbose = 1 + try: + graph = SuperVision.GraphE( aName ) + except: + try: + graph = aName.G.Copy() + except: + graph = aName + if graph != None : + if graph.IsStreamGraph() : + aGraph = graph.ToStreamGraph() + if aGraph != None : + graph = StreamGraphE( aGraph ) + else : + print "Graph creation failed" + self.G = graph + self.G.Verbose = 1 + self.N = graph + self.N.Verbose = 1 + else : + print "Graph creation failed" def ToStreamGraph( self ): aGraph = self.G.ToStreamGraph() if aGraph != None : -- 2.39.2