4 from batchmode_salome import orb
5 from batchmode_salome import lcc
6 from batchmode_salome import naming_service
7 from batchmode_salome import CORBA
8 from batchmode_salome import myStudy
11 from LifeCycleCORBA import *
12 from SALOME_NamingServicePy import *
15 from batchmode_salome import *
17 # from libSuperVision_Swig import SuperV_Swig
18 # print 'SuperV_Swig imported'
21 orb = CORBA.ORB_init([''], CORBA.ORB_ID)
22 lcc = LifeCycleCORBA(orb)
23 naming_service = SALOME_NamingServicePy_i(orb)
30 # SuperVision = SuperV_Swig( len(sys.argv) , sys.argv )
31 # SuperVision.Swig = 1
32 # print 'SuperV_Swig created'
34 # SuperVision = lcc.FindOrLoadComponent("SuperVisionContainer","SUPERV")
35 # SuperVision.Swig = 0
36 # print 'Supervision Component loaded'
38 SuperVision = lcc.FindOrLoadComponent("SuperVisionContainer","SUPERV")
41 modulecatalog = naming_service.Resolve("/Kernel/ModulCatalog")
43 myBuilder = myStudy.NewBuilder()
44 father = myStudy.FindComponent("SUPERV")
46 father = myBuilder.NewComponent("SUPERV")
47 A1 = myBuilder.FindOrCreateAttribute(father, "AttributeName");
48 FName = A1._narrow(SALOMEDS.AttributeName)
50 # FName.SetValue("Supervision")
51 Comp = modulecatalog.GetComponent( "SUPERV" )
52 FName.SetValue( Comp._get_componentusername() )
54 A2 = myBuilder.FindOrCreateAttribute(father, "AttributePixMap");
55 aPixmap = A2._narrow(SALOMEDS.AttributePixMap);
56 aPixmap.SetPixMap( "ICON_OBJBROWSER_Supervision" );
57 myBuilder.DefineComponentInstance(father,SuperVision)
60 def PortInputFloat(obj, x):
61 return obj.Input( SuperVision.AnyValue( CORBA.Any(CORBA.TC_double, x)))
63 def PortInputLong(obj, x):
64 return obj.Input( SuperVision.AnyValue( CORBA.Any(CORBA.TC_long, x)))
66 def PortInputObject(obj, x):
68 return obj.Input( SuperVision.AnyValue( CORBA.Any(CORBA.TC_Object, x)))
70 return obj.Input( SuperVision.AnyValue( x ) )
72 def PortInputString(obj, x):
73 return obj.Input( SuperVision.AnyValue( CORBA.Any(CORBA.TC_string, x)))
75 def InputFloat(obj, nodein_port, x):
76 return obj.Input(nodein_port, SuperVision.AnyValue( CORBA.Any(CORBA.TC_double, x)))
78 def InputLong(obj, nodein_port, x):
79 return obj.Input(nodein_port, SuperVision.AnyValue( CORBA.Any(CORBA.TC_long, x)))
81 def InputObject(obj, nodein_port, x):
83 return obj.Input(nodein_port, SuperVision.AnyValue( CORBA.Any(CORBA.TC_Object, x)))
85 return obj.Input(nodein_port, SuperVision.AnyValue( x ) )
87 def InputString(obj, nodein_port, x):
88 return obj.Input(nodein_port, SuperVision.AnyValue( CORBA.Any(CORBA.TC_string, x)))
92 dataflow = SuperVision.getGraph(ior)
94 itr = myStudy.NewChildIterator(father)
97 res,A=item.FindAttribute("AttributeName")
99 aName = A._narrow(SALOMEDS.AttributeName)
100 if aName.Value() == name :
101 res, A = myBuilder.FindOrCreateAttribute(item, "AttributeIOR")
102 anIOR = A._narrow(SALOMEDS.AttributeIOR);
103 anIOR.SetValue(dataflow.getIOR())
106 obj = myBuilder.NewObject(father)
107 A=myBuilder.FindOrCreateAttribute(obj, "AttributeName")
108 aName=A._narrow(SALOMEDS.AttributeName)
110 A=myBuilder.FindOrCreateAttribute(obj, "AttributeIOR")
111 anIOR = A._narrow(SALOMEDS.AttributeIOR)
112 anIOR.SetValue(dataflow.getIOR())
114 typestring = re.compile(r"_[^_]+_([^_]+)_.*")
116 def getRealArgs(self,args):
122 types.append(typestring.match(self).group(1))
125 types.append(type(self))
126 realargs.append(self)
130 types.append(typestring.match(a).group(1))
133 types.append(type(a))
136 return tuple(types), tuple(realargs)
138 bs_AddInput_valuedict = {
139 (InstanceType, FloatType) : PortInputFloat,
140 (InstanceType, IntType) : PortInputLong,
141 (InstanceType, StringType) : PortInputString,
142 (InstanceType, InstanceType) : PortInputObject,
143 (InstanceType, StringType, FloatType) : InputFloat,
144 (InstanceType, StringType, IntType) : InputLong,
145 (InstanceType, StringType, StringType) : InputString,
146 (InstanceType, StringType, InstanceType) : InputObject,
147 (InstanceType, StringType, ListType) : InputObject,
151 def Args( aService , aNodeName , verbose ):
152 lenin = len( aService.ServiceinParameter )
153 infos = aNodeName + 'info = "'
154 infos = infos + 'NodeName : ' + aNodeName + '\\n'
155 infos = infos + 'ServiceName : ' + aService.ServiceName + '\\n'
156 infos = infos + 'PortNames : \\n'
157 defnames = aNodeName + " = " + "'" + aNodeName + "' ; "
160 argname = aNodeName + aService.ServiceinParameter[ i ].Parametername
161 valname = aNodeName + "\\\\"
162 valname = valname + aService.ServiceinParameter[ i ].Parametername
163 defnames = defnames + argname + " = " + "'" + valname + "' ; "
164 infos = infos + str(i) + '. ' + argname + ' : Input'
165 infos = infos + str(i) + ' '
166 infos = infos + aService.ServiceinParameter[ i ].Parametername + ' '
167 infos = infos + aService.ServiceinParameter[ i ].Parametertype + '\\n'
169 lenout = len( aService.ServiceoutParameter )
172 argname = aNodeName + aService.ServiceoutParameter[ i ].Parametername
173 valname = aNodeName + "\\\\"
174 valname = valname + aService.ServiceoutParameter[ i ].Parametername
175 defnames = defnames + argname + " = " + "'" + valname + "' ; "
176 infos = infos + str(lenin+i) + '. ' + argname + ' : Output'
177 infos = infos + str(i) + ' '
178 infos = infos + aService.ServiceoutParameter[ i ].Parametername + ' '
179 infos = infos + aService.ServiceoutParameter[ i ].Parametertype + '\\n'
182 defnames = defnames + infos
184 defnames = defnames + " ; print " + aNodeName + "info"
187 def Service_Swig( aCatalogService ) :
188 aService = SuperVision.Service()
189 aService.ServiceName = aCatalogService.ServiceName
191 while i < len( aCatalogService.ServiceinParameter ) :
192 p = SuperVision.ServicesParameter( aCatalogService.ServiceinParameter[i].Parametertype , aCatalogService.ServiceinParameter[i].Parametername )
193 SuperVision.AddInParameter( aService , p )
196 while i < len( aCatalogService.ServiceoutParameter ) :
197 p = SuperVision.ServicesParameter( aCatalogService.ServiceoutParameter[i].Parametertype , aCatalogService.ServiceoutParameter[i].Parametername )
198 SuperVision.AddOutParameter( aService , p )
202 ##########################################################
204 ##########################################################
205 def __init__( self , aNode , Verbose ):
207 self.N.Verbose = Verbose
211 return self.N.Service()
214 def CreationDate( self ):
215 return self.N.CreationDate()
216 def LastUpdateDate( self ):
217 return self.N.LastUpdateDate()
219 return self.N.Version()
221 return self.N.Author()
223 return self.N.Comment()
225 def SetName( self , aNewName ):
226 return self.N.SetName( aNewName )
227 def SetAuthor( self , anAuthor ):
228 return self.N.SetAuthor( anAuthor )
229 def SetComment( self , aComment ):
230 return self.N.SetComment( aComment )
233 print "Name ",self.N.Name()
234 if self.N.IsFactory() :
235 print "ComponentName ",self.N.GetComponentName()
236 print "InterfaceName ",self.N.GetInterfaceName()
237 aService = self.N.Service()
238 print "Service Name ",aService.ServiceName
239 lenin = len( aService.ServiceinParameter )
240 print " ",lenin," input argument(s) :"
243 print " ",i,". ",aService.ServiceinParameter[ i ].Parametername," ",aService.ServiceinParameter[ i ].Parametertype
245 lenout = len( aService.ServiceoutParameter )
246 print " ",lenout," output argument(s) :"
249 print " ",i,". ",aService.ServiceoutParameter[ i ].Parametername," ",aService.ServiceoutParameter[ i ].Parametertype
251 aKind = self.N.Kind()
252 print "KindOfNode",aKind
253 aFirstCreation = self.N.CreationDate()
254 print "Creation Date ",aFirstCreation.Day,"-",aFirstCreation.Month,"-",aFirstCreation.Year," ",aFirstCreation.Hour,":",aFirstCreation.Minute,":",aFirstCreation.Second
255 aLastModification = self.N.LastUpdateDate()
256 print "Update Date ",aLastModification.Day,"-",aLastModification.Month,"-",aLastModification.Year," ",aLastModification.Hour,":",aLastModification.Minute,":",aLastModification.Second
257 print "Version ",self.N.Version()
258 print "Author ",self.N.Author()
259 if self.N.IsFactory() :
260 print "Container ",self.N.GetContainer()
261 print "Comment ",self.N.Comment()
262 print "Coords ",self.N.X()," ",self.N.Y()
263 def Port( self , aPortName ):
264 aPort = self.N.Port( aPortName )
266 myPort = Port( aPort , self.N.Verbose )
269 print "Error while creating the Port : ",aPortName
271 def Input( self , *args ):
272 types, realargs = getRealArgs(self.N,args)
273 fn = bs_AddInput_valuedict[types]
274 anInput = apply( fn, realargs)
276 myInput = Port( anInput , self.N.Verbose )
278 ErrMsg = "Failed to create the Input"
282 # def BusPort( self , InOutParameterName , InOutParameterType ):
283 # sts,inp,outp = self.N.BusPort( InOutParameterName ,
284 # InOutParameterType )
285 # inp = Port( inp , self.N.Verbose )
286 # outp = Port( outp , self.N.Verbose )
287 # return sts,inp,outp
288 # def BusPorts( self , InputParameterName , InputParameterType ,
289 # OutputParameterName , OutputParameterType ):
290 # sts,inp,outp = self.N.BusPorts( InputParameterName ,
291 # InputParameterType ,
292 # OutputParameterName ,
293 # OutputParameterType )
294 # inp = Port( inp , self.N.Verbose )
295 # outp = Port( outp , self.N.Verbose )
296 # return sts,inp,outp
298 ports = self.N.Ports()
300 while i < len( ports ) :
301 ports[ i ] = Port( ports[i] , self.N.Verbose )
304 def ListPorts( self , *args ):
305 if len( args ) == 0 :
306 aName = self.N.Name()
309 ports = self.N.Ports()
312 portsname = ports[ 0 ].Name()
313 bs = portsname.find('\\')
315 portsname1,portsname2 = portsname.split('\\')
316 portsname = portsname1 + portsname2
317 listofports = aName + portsname
319 while i < len( ports ) :
320 portsname = ports[ i ].Name()
321 bs = portsname.find('\\')
323 portsname1,portsname2 = portsname.split('\\')
324 portsname = portsname1 + portsname2
325 listofports = listofports + ',' + aName + portsname
328 if len( ports ) == 1 :
329 listofports = "[" + listofports + "] = " + aName + ".Ports()"
331 listofports = listofports + " = " + aName + ".Ports()"
333 def PrintPorts( self ):
334 ports = self.N.Ports()
336 while i < len( ports ) :
338 if ports[ i ].IsInput() :
340 print Direction,self.N.Name(),'(',ports[ i ].Name(),ports[ i ].Kind(),ports[ i ].Type(),') = ',ports[ i ].ToString()
343 links = self.N.Links()
345 while i < len( links ) :
346 links[ i ] = Link( links[i] , self.N.Verbose )
349 def PrintLinks( self ):
352 while i < len( links ) :
356 return self.N.IsGraph()
357 def IsComputing( self ):
358 return self.N.IsComputing()
359 def IsFactory( self ):
360 return self.N.IsFactory()
361 def IsInLine( self ):
362 return self.N.IsInLine()
364 return self.N.IsGOTO()
366 return self.N.IsLoop()
367 def IsEndLoop( self ):
368 return self.N.IsEndLoop()
369 def IsSwitch( self ):
370 return self.N.IsSwitch()
371 def IsEndSwitch( self ):
372 return self.N.IsEndSwitch()
373 def SubGraph( self ):
374 return self.N.SubGraph()
376 return self.N.Thread()
377 def IsWaiting( self ):
378 return self.N.IsWaiting()
379 def IsRunning( self ):
380 return self.N.IsRunning()
382 return self.N.IsDone()
383 def IsSuspended( self ):
384 return self.N.IsSuspended()
386 return self.N.State()
388 return self.N.Control()
389 def ControlClear( self ):
390 return self.N.ControlClear()
391 def AutoState( self ):
392 return self.N.AutoState()
394 return self.N.ReadyW()
395 def RunningW( self ):
396 return self.N.RunningW()
398 return self.N.DoneW()
399 def SuspendedW( self ):
400 return self.N.SuspendedW()
402 return self.N.ReRun()
404 return self.N.ReStart()
405 def ReRunAt( self , aNodeName ):
406 return self.N.ReRunAt( aNodeName )
407 def ReStartAt( self , aNodeName ):
408 return self.N.ReStartAt( aNodeName )
413 def KillDone( self ):
414 return self.N.KillDone()
416 return self.N.Suspend()
417 def SuspendDone( self ):
418 return self.N.SuspendDone()
420 return self.N.Resume()
423 def Coords( self , X , Y ):
424 return self.N.Coords( X , Y )
432 ##########################################################
434 ##########################################################
435 def __init__( self , aNode , Verbose ):
437 self.N.Verbose = Verbose
438 def GetComponentName( self ):
439 return self.N.ComponentName()
440 def GetInterfaceName( self ):
441 return self.N._get_interfaceName()
442 def GetContainer( self ):
443 return self.N.Container()
444 def SetComponentName( self , aComponentName ):
445 return self.N.SetComponentName( aComponentName )
446 def SetInterfaceName( self , anInterfaceName ):
447 return self.N.SetInterfaceName( anInterfaceName )
448 def SetContainer( self , aComputer ):
449 return self.N.SetContainer( aComputer )
451 ##########################################################
453 ##########################################################
454 def __init__( self , aNode , Verbose ):
456 self.N.Verbose = Verbose
457 def Edit( self , FuncName , PyFunc ) :
458 file = '/tmp/' + FuncName + '.py'
460 fd = os.open( file , os.O_CREAT | os.O_WRONLY | os.O_TRUNC )
461 while ( i < len( PyFunc ) ) :
462 os.write( fd , PyFunc[ i ] + '\n' )
464 edit = '${EDITOR} ' + file
466 fd = os.open( file , os.O_RDONLY )
467 line = os.read( fd , 132 )
471 line = os.read( fd , 132 )
472 PyFunc = res.splitlines()
474 while i < len( PyFunc ) :
478 def SetPyFunction( self , FuncName , aPyFunction ):
479 return self.N.SetPyFunction( FuncName , aPyFunction )
480 def PyFunction( self ):
481 return self.N.PyFunction()
482 def PyFuncName( self ):
483 return self.N.PyFuncName()
485 PyFunc = self.N.PyFunction()
486 PyFunc = self.Edit( self.N.PyFuncName() , PyFunc )
487 self.N.SetPyFunction( self.N.PyFuncName() , PyFunc )
488 def InPort( self , aParameterName , aParameterType ):
489 aPort = self.N.InPort( aParameterName ,
492 myPort = Port( aPort , self.N.Verbose )
495 print "Error while creating the Port : ",aParameterName
497 def OutPort( self , aParameterName , aParameterType ):
498 aPort = self.N.OutPort( aParameterName ,
501 myPort = Port( aPort , self.N.Verbose )
504 print "Error while creating the Port : ",aParameterName
507 ##########################################################
509 ##########################################################
510 def __init__( self , aNode , Verbose ):
512 self.N.Verbose = Verbose
513 def SetCoupled( self , anInLineNode ):
515 node = self.N.SetCoupled( anInLineNode )
520 node = self.N.Coupled()
523 node = INode( node , self.N.Verbose )
525 node = LNode( node , self.N.Verbose )
526 elif node.IsEndLoop() :
527 node = ELNode( node , self.N.Verbose )
528 elif node.IsSwitch() :
529 node = SNode( node , self.N.Verbose )
530 elif node.IsEndSwitch() :
531 node = ESNode( node , self.N.Verbose )
534 ##########################################################
536 ##########################################################
537 def __init__( self , aNode , Verbose ):
539 self.N.Verbose = Verbose
540 def SetPyInit( self , InitName , aPyFunction ):
541 return self.N.SetPyInit( InitName , aPyFunction )
543 return self.N.PyInit()
544 def PyInitName( self ) :
545 return self.N.PyInitName()
547 PyFunc = self.N.PyFunction()
548 PyFunc = self.Edit( self.N.PyFuncName() , PyFunc )
549 self.N.SetPyFunction( self.N.PyFuncName() , PyFunc )
550 def SetPyMore( self , MoreName , aPyFunction ):
551 return self.N.SetPyMore( MoreName , aPyFunction )
553 return self.N.PyMore()
554 def PyMoreName( self ) :
555 return self.N.PyMoreName()
557 PyMore = self.N.PyMore()
558 PyMore = self.Edit( self.N.PyMoreName() , PyMore )
559 self.N.SetPyMore( self.N.PyMoreName() , PyMore )
560 def SetPyNext( self , NextName , aPyFunction ):
561 return self.N.SetPyNext( NextName , aPyFunction )
563 return self.N.PyNext()
564 def PyNextName( self ) :
565 return self.N.PyNextName()
567 PyNext = self.N.PyNext()
568 PyNext = self.Edit( self.N.PyNextName() , PyNext )
569 self.N.SetPyNext( self.N.PyNextName() , PyNext )
571 ##########################################################
573 ##########################################################
574 def __init__( self , aNode , Verbose ):
576 self.N.Verbose = Verbose
578 ##########################################################
580 ##########################################################
581 def __init__( self , aNode , Verbose ):
583 self.N.Verbose = Verbose
585 ##########################################################
587 ##########################################################
588 def __init__( self , aNode , Verbose ):
590 self.N.Verbose = Verbose
592 ##########################################################
593 #class ServicesParameter_Swig :
594 ##########################################################
595 # def __init__( self , aServicesParameter ):
596 # self.Parametertype = aServicesParameter.Parametertype
597 # self.Parametername = aServicesParameter.Parametername
599 ##########################################################
601 ##########################################################
602 def __init__( self , aName ):
604 graph = SuperVision.Graph( aName )
607 graph = aName.G.Copy()
616 print "Graph creation failed"
617 def CNode( self , *args ):
618 if len( args ) == 1 :
621 aComponent = args[ 0 ]
622 anInterface = args[ 1 ]
624 NodeComponent = modulecatalog.GetComponent( aComponent )
625 aService = NodeComponent.GetService( anInterface , aService )
626 aNode = self.G.CNode( aService )
628 myNode = CNode( aNode , self.G.Verbose )
630 ErrMsg = "Failed to create a Node with Service " + aService.ServiceName
634 def Node( self , aComponent , anInterface , aService ):
635 if SuperVision.Swig :
636 aService = Service_Swig( aService )
637 return self.FNode( aComponent , anInterface , aService )
638 def FNode( self , aComponent , anInterface , aService ):
639 NodeComponent = modulecatalog.GetComponent( aComponent )
640 aService = NodeComponent.GetService( anInterface , aService )
641 if SuperVision.Swig :
642 aService = Service_Swig( aService )
643 aNode = self.G.FNode( aComponent , anInterface , aService )
645 myNode = FNode( aNode , self.G.Verbose )
647 ErrMsg = "Failed to create a Node with Service " + aService.ServiceName
651 def INode( self , FuncName , aPythonFunction ):
652 aNode = self.G.INode( FuncName , aPythonFunction )
654 myNode = INode( aNode , self.G.Verbose )
656 ErrMsg = "Failed to create a Node"
660 def GNode( self , FuncName , aPythonFunction , anINode ):
661 aNode = self.G.GNode( FuncName , aPythonFunction , anINode )
663 myNode = GNode( aNode , self.G.Verbose )
665 ErrMsg = "Failed to create a Node"
669 def LNode( self , InitName , InitFunction , MoreName , MoreFunction , NextName , NextFunction ):
670 aNode,anEndOfLoop = self.G.LNode( InitName , InitFunction , MoreName , MoreFunction , NextName , NextFunction )
672 myNode = LNode( aNode , self.G.Verbose )
673 myEndOfLoop = INode( anEndOfLoop , self.G.Verbose )
674 return myNode,myEndOfLoop
675 ErrMsg = "Failed to create a Node with Service " + aService.ServiceName
679 def SNode( self , FuncName , aPythonFunction ):
680 aNode,anEndOfSwitch = self.G.SNode( FuncName , aPythonFunction )
682 myNode = SNode( aNode , self.G.Verbose )
683 myEndOfSwitch = INode( anEndOfSwitch , self.G.Verbose )
684 return myNode,myEndOfSwitch
685 ErrMsg = "Failed to create a Node"
689 # def LoopNode( self , aComponent , anInterface , aService , aNodeName ):
690 # NodeComponent = modulecatalog.GetComponent( aComponent )
691 # aService = NodeComponent.GetService( anInterface , aService )
692 # aNode,anEndNode = self.G.LoopNode( aComponent , anInterface , aService , aNodeName )
694 # myEndNode = anEndNode
696 # myNode = Node( aNode , self.G.Verbose )
697 # if anEndNode != None :
698 # myEndNode = Node( anEndNode , self.G.Verbose )
699 # if ( aNode != None ) & ( anEndNode != None ) :
700 # return myNode,myEndNode
701 # ErrMsg = "Failed to create a Node with Service " + aService.ServiceName
702 # if self.G.Verbose :
704 # return aNode,anEndNode
705 # def SwitchNode( self , aComponent , anInterface , aService , aNodeName ):
706 # NodeComponent = modulecatalog.GetComponent( aComponent )
707 # aService = NodeComponent.GetService( anInterface , aService )
708 # aNode,anEndNode = self.G.SwitchNode( aComponent , anInterface , aService , aNodeName )
710 # myEndNode = anEndNode
712 # myNode = Node( aNode , self.G.Verbose )
713 # if anEndNode != None :
714 # myEndNode = Node( anEndNode , self.G.Verbose )
715 # if ( aNode != None ) & ( anEndNode != None ) :
716 # return myNode,myEndNode
717 # ErrMsg = "Failed to create a Node with Service " + aService.ServiceName
718 # if self.G.Verbose :
720 # return aNode,anEndNode
721 # def LNode( self , aNodeName ):
722 # aNode = self.G.LNode( aNodeName )
724 # myNode = Node( aNode , self.G.Verbose )
726 # ErrMsg = "Failed to create a Node with Service " + aService.ServiceName
727 # if self.G.Verbose :
730 # def LService( self , aComponent , anInterface , aService ):
731 # NodeComponent = modulecatalog.GetComponent( aComponent )
732 # aService = NodeComponent.GetService( anInterface , aService )
733 # aNode = self.G.LService( aComponent , anInterface , aService )
735 # myNode = Node( aNode , self.G.Verbose )
737 # ErrMsg = "Failed to create a Node with Service " + aService.ServiceName
738 # if self.G.Verbose :
741 # def CNode( self , aNodeName ):
742 # aNode = self.G.CNode( aNodeName )
744 # myNode = Node( aNode , self.G.Verbose )
746 # ErrMsg = "Failed to create a Node with Service " + aService.ServiceName
747 # if self.G.Verbose :
750 # def CService( self , aComponent , anInterface , aService ):
751 # NodeComponent = modulecatalog.GetComponent( aComponent )
752 # aService = NodeComponent.GetService( anInterface , aService )
753 # aNode = self.G.CService( aComponent , anInterface , aService )
755 # myNode = Node( aNode , self.G.Verbose )
757 # ErrMsg = "Failed to create a Node with Service " + aService.ServiceName
758 # if self.G.Verbose :
761 def PrintService( self , aComponent , anInterface , aService ):
762 NodeComponent = modulecatalog.GetComponent( aComponent )
763 aService = NodeComponent.GetService( anInterface , aService )
764 print "ServiceName ",aService.ServiceName," :"
765 lenin = len( aService.ServiceinParameter )
766 print " ",lenin," input argument(s) :"
769 print " ",i,". ",aService.ServiceinParameter[ i ].Parametername," ",aService.ServiceinParameter[ i ].Parametertype
771 lenout = len( aService.ServiceoutParameter )
772 print " ",lenout," output argument(s) :"
775 print " ",i,". ",aService.ServiceoutParameter[ i ].Parametername," ",aService.ServiceoutParameter[ i ].Parametertype
777 def Link( self , aFromNodePort , aToNodePort ):
778 aLink = self.G.Link( aFromNodePort.P , aToNodePort.P )
780 myLink = Link( aLink , self.G.Verbose )
782 ErrMsg = "Failed to create a Link from " + aFromNodePort.Node().Name() + "(" + aFromNodePort.Name() + ") to " + aToNodePort.Node().Name() + "(" + aToNodePort.Name() + ")"
786 def Import( self , anXmlFileName ):
787 return self.G.Import( anXmlFileName )
788 def Export( self , anXmlFileName ):
789 return self.G.Export( anXmlFileName )
790 def IsReadOnly( self ) :
791 return self.G.IsReadOnly()
792 def ComponentRef( self , aFactoryServer , aComponent ) :
793 return self.G.ComponentRef( aFactoryServer , aComponent )
795 return self.G.IsValid()
796 def IsExecutable( self ):
797 return self.G.IsExecutable()
798 def IsEditing( self ):
799 return self.G.IsEditing()
800 def IsExecuting( self ):
801 return self.G.IsExecuting()
802 def LevelMax( self ):
803 return self.G.LevelMax()
804 def ThreadsMax( self ):
805 return self.G.ThreadsMax()
806 def GraphsNumber( self ):
807 return self.G.GraphsNumber()
808 def LevelNodes( self , aLevel ):
809 nodes = self.G.LevelNodes( aLevel )
810 return self.nodesTuple( nodes )
811 def Run( self , *args ):
813 aService = self.Service()
817 print aService.ServiceinParameter[ i ].Parametername," = ",args[i]
818 self.Input( aService.ServiceinParameter[ i ].Parametername , args[i] )
822 def Start( self , *args ):
824 aService = self.Service()
828 print aService.ServiceinParameter[ i ].Parametername," = ",args[i]
829 self.Input( aService.ServiceinParameter[ i ].Parametername , args[i] )
832 return self.G.Start()
834 sts,aNode,anEvent,aState = self.G.Event()
836 return sts,aNode,anEvent,aState
838 sts,aNode,anEvent,aState = self.G.EventW()
840 return sts,aNode,anEvent,aState
843 sts,aNode,anEvent,aState = self.G.EventW()
845 print sts,aNode.Thread(),aNode.SubGraph(),aNode.Name(),anEvent,aState
848 return self.G.Threads()
849 def SuspendedThreads( self ):
850 return self.G.SuspendedThreads()
851 def LastLevelDone( self ):
852 return self.G.LastLevelDone()
853 def Verbose( self , verbose ):
854 preverbose = self.G.Verbose
855 self.G.Verbose = verbose
858 nodes = self.G.Nodes()
859 return self.nodesTuple( nodes )
860 def nodesTuple( self , nodes ) :
861 n = len( nodes.CNodes )
866 pynodes.append( CNode( nodes.CNodes[i] , self.G.Verbose ) )
869 n = len( nodes.FNodes )
872 pynodes.append( FNode( nodes.FNodes[i] , self.G.Verbose ) )
875 n = len( nodes.INodes )
878 pynodes.append( INode( nodes.INodes[i] , self.G.Verbose ) )
881 n = len( nodes.GNodes )
884 pynodes.append( GNode( nodes.GNodes[i] , self.G.Verbose ) )
887 n = len( nodes.LNodes )
890 pynodes.append( LNode( nodes.LNodes[i] , self.G.Verbose ) )
893 n = len( nodes.ELNodes )
896 pynodes.append( GNode( nodes.ELNodes[i] , self.G.Verbose ) )
899 n = len( nodes.SNodes )
902 pynodes.append( SNode( nodes.SNodes[i] , self.G.Verbose ) )
905 n = len( nodes.ESNodes )
908 pynodes.append( GNode( nodes.ESNodes[i] , self.G.Verbose ) )
912 def ListNodes( self , *args ):
916 listofnodes = nodes[ 0 ].Name()
918 while i < len( nodes ) :
919 listofnodes = listofnodes + ',' + nodes[ i ].Name()
922 if len( args ) == 0 :
923 aName = self.N.Name()
926 if len( nodes ) == 1 :
927 listofnodes = "[" + listofnodes + "] = " + aName + ".Nodes()"
929 listofnodes = listofnodes + " = " + aName + ".Nodes()"
931 def PrintNodes( self ):
939 def PrintThreads( self ):
942 while i < len( nodes ) :
943 print nodes[i].Name(),nodes[i].Thread(),nodes[i].State(),nodes[i].Control(),nodes[i].AutoState()
946 links = self.G.GLinks()
948 while i < len( links ) :
949 links[ i ] = Link( links[i] , self.G.Verbose )
952 def ListLinks( self , *args ):
953 links = self.G.GLinks()
955 listoflinks = links[ 0 ].InPort().Node().Name()
956 listoflinks = listoflinks + links[ 0 ].InPort().Name()
958 while i < len( links ) :
959 listoflinks = listoflinks + ',' + links[ i ].InPort().Node().Name()
960 listoflinks = listoflinks + links[ i ].InPort().Name()
963 if len( args ) == 0 :
964 aName = self.N.Name()
967 if len( links ) == 1 :
968 listoflinks = "[" + listoflinks + "] = " + aName + ".GLinks()"
970 listoflinks = listoflinks + " = " + aName + ".GLinks()"
972 def PrintLinks( self ):
973 links = self.G.GLinks()
975 while i < len( links ) :
976 Link( links[ i ] , self.G.Verbose ).Print()
979 graphs = self.G.Graphs()
982 while i < len( graphs ) :
983 outgraphs[ i ] = Graph( graphs[i].Name() , self.G.Verbose )
984 outgraphs[ i ].Merge( graphs[i] )
988 aCopy = self.G.Copy()
990 myCopy = Graph( aCopy )
992 ErrMsg = "Failed to get a Copy of " + self.G.Name()
996 def Merge( self , aGraph ):
997 return self.G.Merge( aGraph.G )
1001 ##########################################################
1002 class GraphE(Graph):
1003 ##########################################################
1004 def __init__( self , aName ):
1005 graph = SuperVision.GraphE( aName )
1011 ##########################################################
1013 ##########################################################
1014 def __init__( self , aValue , Verbose ):
1016 self.V.Verbose = Verbose
1017 def ToString( self ):
1018 return self.V.ToString()
1020 return self.V.ToAny()
1021 def Destroy( self ):
1024 ##########################################################
1026 ##########################################################
1027 def __init__( self , aPort , Verbose ):
1029 self.P.Verbose = Verbose
1030 def Input( self , *args ):
1031 types, realargs = getRealArgs(self.P,args)
1032 fn = bs_AddInput_valuedict[types]
1033 anInput = apply( fn, realargs)
1036 aNode = self.P.Node()
1038 if aNode.IsComputing() :
1039 myNode = CNode( aNode , self.P.Verbose )
1040 elif aNode.IsFactory() :
1041 myNode = FNode( aNode , self.P.Verbose )
1042 elif aNode.IsInLine() :
1043 myNode = INode( aNode , self.P.Verbose )
1044 elif aNode.IsGOTO() :
1045 myNode = GNode( aNode , self.P.Verbose )
1046 elif aNode.IsLoop() :
1047 myNode = LNode( aNode , self.P.Verbose )
1048 elif aNode.IsEndLoop() :
1049 myNode = ELNode( aNode , self.P.Verbose )
1050 elif aNode.IsSwitch() :
1051 myNode = SNode( aNode , self.P.Verbose )
1052 elif aNode.IsEndSwitch() :
1053 myNode = ESNode( aNode , self.P.Verbose )
1059 return self.P.Name()
1061 return self.P.Type()
1063 aLink = self.P.Link()
1065 myLink = Link( aLink , self.P.Verbose )
1067 ErrMsg = "Failed to get a Link to " + self.P.Node().Name() + "(" + self.P.Name() + ")"
1072 links = self.P.Links()
1074 while i < len( links ) :
1075 links[ i ] = Link( links[i] , self.P.Verbose )
1078 def PrintLinks( self ):
1079 links = self.P.Links()
1081 while i < len( links ) :
1082 Link( links[ i ] , self.P.Verbose ).Print()
1084 def IsInput( self ):
1085 return self.P.IsInput()
1086 def IsLinked( self ):
1087 return self.P.IsLinked()
1088 def HasInput( self ):
1089 return self.P.HasInput()
1091 return self.P.Kind()
1092 def IsParam( self ):
1093 return self.P.IsParam()
1095 return self.P.IsGate()
1097 return self.P.IsLoop()
1098 def IsInLine( self ):
1099 return self.P.IsInLine()
1100 def IsSwitch( self ):
1101 return self.P.IsSwitch()
1102 def IsEndSwitch( self ):
1103 return self.P.IsEndSwitch()
1104 # def IsBus( self ):
1105 # return self.P.IsBus()
1107 return self.P.Done()
1109 return self.P.State()
1110 def ToString( self ):
1111 return self.P.ToString()
1113 return self.P.ToAny()
1115 if self.P.IsInput() :
1116 if self.P.IsLinked() :
1117 print "In",self.P.Node().Name(),'(',self.P.Name(),self.P.Kind(),self.P.Type(),') = ',self.P.ToString(),' from ',self.Link().OutPort().Print()
1119 print "In",self.P.Node().Name(),'(',self.P.Name(),self.P.Kind(),self.P.Type(),') = ',self.P.ToString()
1121 print "Out",self.P.Node().Name(),'(',self.P.Name(),self.P.Kind(),self.P.Type(),') = ',self.P.ToString()
1122 def Destroy( self ):
1125 ##########################################################
1127 ##########################################################
1128 def __init__( self , aLink , Verbose ):
1130 self.L.Verbose = Verbose
1131 def OutPort( self ):
1132 aPort = self.L.OutPort()
1134 myPort = Port( aPort , self.L.Verbose )
1137 print "Error while getting the Port : "
1140 aPort = self.L.InPort()
1142 myPort = Port( aPort , self.L.Verbose )
1145 print "Error while getting the Port : "
1148 anOutPort = self.L.OutPort()
1149 anInPort = self.L.InPort()
1150 print anOutPort.Node().Name(),'(',anOutPort.Name(),' ',anOutPort.Kind(),') =',anOutPort.ToString(),' --> ',anInPort.Node().Name(),'(',anInPort.Name(),')',' ',anInPort.Kind()
1151 def CoordsSize( self ):
1152 return self.L.CoordsSize()
1153 def AddCoord( self , index , X , Y ):
1154 return self.L.AddCoord( index , X , Y )
1155 def ChangeCoord( self , index , X , Y ):
1156 return self.L.ChangeCoord( index , X , Y )
1157 def RemoveCoord( self , index ):
1158 return self.L.RemoveCoord( index )
1159 def Coords( self , index ):
1160 return self.L.Coords( index )
1161 def destroy( self ):