Salome HOME
Updated copyright comment
[samples/component.git] / src / SyrControlComponent / SyrControlComponent.py
1 #! /usr/bin/env python3
2 # Copyright (C) 2007-2024  CEA, EDF, OPEN CASCADE
3 #
4 # Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 #
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License, or (at your option) any later version.
11 #
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 # Lesser General Public License for more details.
16 #
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this library; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
20 #
21 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #
23
24 #  File   : SyrControlComponent.py
25 #  Author : Jean Rahuel
26 #  Module : SuperVisionTest
27 #
28 import os
29 import sys
30 import time
31 import sys
32 from omniORB import CORBA, PortableServer
33 import CosNaming
34 import Engines, Engines__POA
35 import SuperVisionTest, SuperVisionTest__POA
36 from SALOME_ComponentPy import *
37
38 from LifeCycleCORBA import *
39 from SALOME_NamingServicePy import *
40
41 from SyrComponent_idl import *
42
43 from SyrControlComponent_idl import *
44
45 orb = CORBA.ORB_init([''], CORBA.ORB_ID)
46
47 lcc = LifeCycleCORBA(orb)
48
49 naming_service = SALOME_NamingServicePy_i(orb)
50
51 modulecatalog = naming_service.Resolve("/Kernel/ModulCatalog")
52
53 class SyrControlComponent( SuperVisionTest__POA.SyrControlComponent, SALOME_ComponentPy_i):
54
55     def L_OneEven( self , ValOne , ValEven ):
56         self.beginService( 'SyrControlComponent L_OneEven' )
57         self.sendMessage( NOTIF_STEP , "time.sleep( 1 )" )
58         time.sleep( 1 )
59         Finished = ValOne
60         if Finished == 0 :
61             Incr = 1
62             Even = ValEven
63             if Even == 0 :
64                 self.sendMessage( NOTIF_TRACE , "OddNumber" )
65                 Odd = 1
66             else :
67                 self.sendMessage( NOTIF_TRACE , "EvenNumber" )
68                 Odd = 0
69         else :
70             self.sendMessage( NOTIF_TRACE , "Syracuse is TRUE : NumberOne" )
71             Incr = 0
72             Even = 0
73             Odd = 0
74         Even = ValEven
75         self.endService( 'SyrControlComponent L_OneEven' )
76         return Finished,Incr,Even,Odd
77     
78     def C_NotOneIsEven( self ):
79         self.beginService( 'SyrControlComponent C_NotOneIsEven' )
80         self.sendMessage( NOTIF_TRACE , "EvenNumber" )
81         time.sleep( 1 )
82         self.endService( 'SyrControlComponent C_NotOneIsEven' )
83         return 0,1
84     
85     def LOOPN( self , InLoop , iN , iK , min , max ):
86         self.beginService( 'SyrControlComponent LOOPN' )
87         self.sendMessage( NOTIF_TRACE , "LOOPN" )
88         time.sleep( 1 )
89         OutLoop = 0
90         N = 0
91         if InLoop != 0 :
92             if min > 0 & min <= max :
93                 N = min
94                 OutLoop = 1
95         else :
96             if iN < max :
97                 N = iN + 1
98                 OutLoop = 1
99         print('SyrControlComponent LOOPN InLoop iN OutLoop N',InLoop,iN,OutLoop,N)
100         self.endService( 'SyrControlComponent LOOPN' )
101         return OutLoop,N,0
102
103     def WHILENOTONE( self , N ):
104         OutLoop = self.Syr.C_ISONE( N )
105         if OutLoop == 0 :
106             OutLoop = 1
107         else :
108             OutLoop = 0
109         print('SyrControlComponent WHILENOTONE OutLoop N',OutLoop,N)
110         return OutLoop
111
112     def IFNOTEVEN( self , N ) :
113         Even = self.Syr.C_ISEVEN( N )
114         Odd = 0
115         if Even == 0 :
116             Odd = 1
117         print('SyrControlComponent IFNOTEVEN Odd Even N',Odd,Even,N)
118         return Odd,Even
119
120     def LOOPi( self , InLoop , ii ):
121         OutLoop = 0
122         i = 0
123         if InLoop != 0 :
124             i = 0
125             OutLoop = 1
126         else :
127             if ii+1 < 2 :
128                 i = ii + 1
129                 OutLoop = 1
130         print('SyrControlComponent LOOPi InLoop ii OutLoop i',InLoop,ii,OutLoop,i)
131         return OutLoop,i
132
133     def WHILEEVEN( self , N ) :
134         OutLoop = self.Syr.C_ISEVEN( N )
135         print('SyrControlComponent WHILEEVEN OutLoop N',OutLoop,N)
136         return OutLoop 
137
138     def __init__(self, orb, poa, this, containerName, instanceName, interfaceName):
139         SALOME_ComponentPy_i.__init__(self, orb, poa, this, containerName,
140                                       instanceName, interfaceName, True)
141         self.Syr = lcc.FindOrLoadComponent( 'FactoryServer' , 'SyrComponent' )
142         print("SyrControlComponent::__init__",dir(self.Syr))
143
144     def getVersion( self ):
145         import salome_version
146         return salome_version.getVersion("COMPONENT", True)
147