Salome HOME
Increment version: 7.3.1
[samples/randomizer.git] / src / Randomizer / RANDOMIZER.py
1 # Copyright (C) 2005-2013  OPEN CASCADE
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 ###############################################################
21 # File    : RANDOMIZER.py
22 # Author  : Vadim SANDLER (OCN)
23 # Created : 13/07/05
24 ###############################################################
25 #
26 import RANDOMIZER_ORB__POA
27 import SALOME_ComponentPy
28
29 class RANDOMIZER( RANDOMIZER_ORB__POA.RANDOMIZER,
30                   SALOME_ComponentPy.SALOME_ComponentPy_i ):
31     """
32     The implementation of the RANDOMIZER interface
33     """
34     def __init__ ( self, orb, poa, contID, containerName, instanceName, interfaceName ):
35         """
36         Constructor
37         """
38         SALOME_ComponentPy.SALOME_ComponentPy_i.__init__( self, orb, poa, contID, containerName,instanceName, interfaceName, 0 )
39
40     def getVersion( self ):
41         """
42         Get version information.
43         """
44         import salome_version
45         return salome_version.getVersion("RANDOMIZER", True)
46
47     def InitPoint( self ):
48         """
49         Generate random 2d-point:  x, y = [0,1)
50         """
51         self.beginService( "RANDOMIZER::InitPoint" )
52
53         import random
54         x = random.random()
55         y = random.random()
56
57         self.endService( "RANDOMIZER::InitPoint" )
58
59         return x, y
60     
61     def NextIteration( self ):
62         """
63         Get next random iteration step: ret = {1,2,3}
64         """
65         self.beginService( "RANDOMIZER::NextIteration" )
66
67         import random
68         iter = random.randint( 1,3 )
69
70         self.endService( "RANDOMIZER::NextIteration" )
71         
72         return iter