]> SALOME platform Git repositories - samples/component.git/blob - src/SyrControlComponent/SyrControlComponent.py
Salome HOME
Fix compilation after changes in MED
[samples/component.git] / src / SyrControlComponent / SyrControlComponent.py
1 #! /usr/bin/env python
2 #
3 #  Copyright (C) 2003  CEA/DEN, EDF R&D
4 #
5 #
6 #
7 #  File   : SyrControlComponent.py
8 #  Author : Jean Rahuel
9 #  Module : SuperVisionTest
10 #  $Header:
11
12 import os
13 import sys
14 import time
15 import sys
16 from omniORB import CORBA, PortableServer
17 import CosNaming
18 import Engines, Engines__POA
19 import SuperVisionTest, SuperVisionTest__POA
20 from SALOME_ComponentPy import *
21
22 from LifeCycleCORBA import *
23 from SALOME_NamingServicePy import *
24
25 from SyrComponent_idl import *
26
27 from SyrControlComponent_idl import *
28
29 orb = CORBA.ORB_init([''], CORBA.ORB_ID)
30
31 lcc = LifeCycleCORBA(orb)
32
33 naming_service = SALOME_NamingServicePy_i(orb)
34
35 modulecatalog = naming_service.Resolve("/Kernel/ModulCatalog")
36
37 class SyrControlComponent( SuperVisionTest__POA.SyrControlComponent, SALOME_ComponentPy_i):
38
39     def L_OneEven( self , ValOne , ValEven ):
40         self.beginService( 'SyrControlComponent L_OneEven' )
41         self.sendMessage( NOTIF_STEP , "time.sleep( 1 )" )
42         time.sleep( 1 )
43         Finished = ValOne
44         if Finished == 0 :
45             Incr = 1
46             Even = ValEven
47             if Even == 0 :
48                 self.sendMessage( NOTIF_TRACE , "OddNumber" )
49                 Odd = 1
50             else :
51                 self.sendMessage( NOTIF_TRACE , "EvenNumber" )
52                 Odd = 0
53         else :
54             self.sendMessage( NOTIF_TRACE , "Syracuse is TRUE : NumberOne" )
55             Incr = 0
56             Even = 0
57             Odd = 0
58         Even = ValEven
59         self.endService( 'SyrControlComponent L_OneEven' )
60         return Finished,Incr,Even,Odd
61     
62     def C_NotOneIsEven( self ):
63         self.beginService( 'SyrControlComponent C_NotOneIsEven' )
64         self.sendMessage( NOTIF_TRACE , "EvenNumber" )
65         time.sleep( 1 )
66         self.endService( 'SyrControlComponent C_NotOneIsEven' )
67         return 0,1
68     
69     def LOOPN( self , InLoop , iN , iK , min , max ):
70         self.beginService( 'SyrControlComponent LOOPN' )
71         self.sendMessage( NOTIF_TRACE , "LOOPN" )
72         time.sleep( 1 )
73         OutLoop = 0
74         N = 0
75         if InLoop != 0 :
76             if min > 0 & min <= max :
77                 N = min
78                 OutLoop = 1
79         else :
80             if iN < max :
81                 N = iN + 1
82                 OutLoop = 1
83         print 'SyrControlComponent LOOPN InLoop iN OutLoop N',InLoop,iN,OutLoop,N
84         self.endService( 'SyrControlComponent LOOPN' )
85         return OutLoop,N,0
86
87     def WHILENOTONE( self , N ):
88         OutLoop = self.Syr.C_ISONE( N )
89         if OutLoop == 0 :
90             OutLoop = 1
91         else :
92             OutLoop = 0
93         print 'SyrControlComponent WHILENOTONE OutLoop N',OutLoop,N
94         return OutLoop
95
96     def IFNOTEVEN( self , N ) :
97         Even = self.Syr.C_ISEVEN( N )
98         Odd = 0
99         if Even == 0 :
100             Odd = 1
101         print 'SyrControlComponent IFNOTEVEN Odd Even N',Odd,Even,N
102         return Odd,Even
103
104     def LOOPi( self , InLoop , ii ):
105         OutLoop = 0
106         i = 0
107         if InLoop != 0 :
108             i = 0
109             OutLoop = 1
110         else :
111             if ii+1 < 2 :
112                 i = ii + 1
113                 OutLoop = 1
114         print 'SyrControlComponent LOOPi InLoop ii OutLoop i',InLoop,ii,OutLoop,i
115         return OutLoop,i
116
117     def WHILEEVEN( self , N ) :
118         OutLoop = self.Syr.C_ISEVEN( N )
119         print 'SyrControlComponent WHILEEVEN OutLoop N',OutLoop,N
120         return OutLoop 
121
122     def __init__(self, orb, poa, this, containerName, instanceName, interfaceName):
123         SALOME_ComponentPy_i.__init__(self, orb, poa, this, containerName,
124                                       instanceName, interfaceName, 1)
125         self.Syr = lcc.FindOrLoadComponent( 'FactoryServer' , 'SyrComponent' )
126         print "SyrControlComponent::__init__",dir(self.Syr)
127