]> SALOME platform Git repositories - samples/calculator.git/blob - src/CALCULATOR/CALCULATOR_TEST.py
Salome HOME
994e24a2f5246dc35d16c1f2ff53ccc37a18379f
[samples/calculator.git] / src / CALCULATOR / CALCULATOR_TEST.py
1 from omniORB import CORBA
2
3 import salome
4 import SALOME
5 import SALOME_MED
6
7 #CCRT :
8 import os
9 import Engines
10 import LifeCycleCORBA
11
12 host = os.getenv( 'HOST' )
13
14 orb = CORBA.ORB_init([''], CORBA.ORB_ID)
15
16 lcc = LifeCycleCORBA.LifeCycleCORBA(orb)
17 #endCCRT
18
19 ################   GET A MED FIELD FROM FILE pointe.med   ###################
20 #
21 # This test program is based on the field named fieldcelldoublevector in 
22 # med file $MED_ROOT_DIR/share/salome/resources/pointe.med
23 from os import environ
24 filePath=environ["MED_ROOT_DIR"]
25 filePath=filePath+"/share/salome/resources/"
26 medFile=filePath+"pointe.med"
27 fieldname = "fieldcelldoublescalar"
28
29 # Launch the Med Component and use it to load into memory the test field 
30 print "Launch the Med Component: "
31 #CCRTmed_comp = salome.lcc.FindOrLoadComponent("FactoryServer", "MED")
32 med_comp = lcc.FindOrLoadComponent("FactoryServer", "MED")
33
34 # Get a Corba field proxy on the distant field (located in the med_comp server).
35 try:
36     studyname = salome.myStudyName
37     studynameId = salome.myStudyId
38     print "We are working in the study ",studyname," with the ID ",studynameId
39     print "Read field ",fieldname
40     fieldcell  = med_comp.readFieldInFile(medFile,studyname,fieldname,-1,-1)
41     fieldcelldouble = fieldcell._narrow(SALOME_MED.FIELDDOUBLE)
42 except SALOME.SALOME_Exception, ex:
43     print ex.details
44     print ex.details.type
45     print ex.details.text
46     print ex.details.sourceFile
47     print ex.details.lineNumber
48     raise
49
50 print "Description of Field : "
51 print fieldcelldouble
52 print fieldcelldouble.getName()
53 print fieldcelldouble.getDescription()
54 print fieldcelldouble.getNumberOfComponents()
55 #
56 #
57 ##############  Load Calculator Component and test it   ###################
58 #
59 #
60 print "Load Calculator Component "
61 # we need to import CALCULATOR_ORB to get a typed object (to perform narrowing)
62 import CALCULATOR_ORB
63 calculator = salome.lcc.FindOrLoadComponent("FactoryServer", "CALCULATOR")
64 #
65 print "Appel cloneField : fieldcelldouble -> f1,f2,f3,f4"
66 (f1,f2,f3,f4)=calculator.cloneField(fieldcelldouble)  # fieldcelldouble is consumed
67 #
68 calculator.printField(f1)
69 print "Add fields f2+f3"
70 f_add=calculator.add(f2, f3)
71 calculator.printField(f_add)
72
73 #
74 print "Apply linear function"
75 f_lin=calculator.applyLin(f4,2.0,1.0)
76 #
77 print "Appel Norme Max "
78 norme=calculator.normMax(f_lin)
79 print " -> norme = ",norme
80 #
81 print "End of Calculator Test!"