]> SALOME platform Git repositories - tools/eficas.git/blob - VirtualPolymer/VP_Cata_V1.py.equation
Salome HOME
VirtualPolymer
[tools/eficas.git] / VirtualPolymer / VP_Cata_V1.py.equation
1 # coding: utf-8\r
2 import types\r
3 from Accas import *\r
4 import sys,os\r
5 sys.path.append('/home/A96028/opt/MAP/map-2016.1/lib/python2.7/site-packages/mapy/components/c_pre_polymer_data_management')\r
6 sys.path.append('/home/A96028/opt/MAP/map-2016.1/lib/python2.7/site-packages/mapy/virtual_polymer_common')\r
7 sys.path.append('/home/A96028/opt/MAP/map-2016.1/lib/python2.7/site-packages/')\r
8 import pckdb, class_data, instruction, equation_part, utils\r
9 \r
10 \r
11 class Tuple:\r
12   def __init__(self,ntuple):\r
13     self.ntuple=ntuple\r
14 \r
15   def __convert__(self,valeur):\r
16     if type(valeur) == types.StringType: return None\r
17     if len(valeur) != self.ntuple: return None\r
18     return valeur\r
19 \r
20   def info(self):\r
21     return "Tuple de %s elements" % self.ntuple\r
22 \r
23   __repr__=info\r
24   __str__=info\r
25 \r
26 #class ObjetUtilisateur(ASSD): pass\r
27 \r
28 class classeVisuEquation :\r
29    def __init__(self,dicoListeAffiche):\r
30       self.dicoListeAffiche=dicoListeAffiche\r
31    \r
32 \r
33 def maFunc():\r
34     return ('a1','a2','a3')\r
35      \r
36 def maFuncWithArg(monMC):\r
37     if hasattr(monMC,'dsMaFunct') and monMC.dsMaFunct== True : return\r
38     monMC.dsMaFunct = True\r
39 \r
40     editor=monMC.jdc.editor\r
41     if monMC.valeur == 'POOH->P' : monInto=('a1','a2','a3')\r
42     else : monInto=('b1','b2','b3')\r
43 \r
44     change=editor.changeIntoDefMC('AGING', ('Equation', 'b_approved','b_type_creation','Equation_Modification','Type2'), monInto )\r
45     if change :\r
46        print ('j ai change le into')\r
47        editor.reCalculeValiditeMCApresChgtInto('AGING', 'Type2', ('Equation', 'b_approved','b_type_creation','Equation_Modification')) \r
48        if editor.fenetreCentraleAffichee : editor.fenetreCentraleAffichee.node.affichePanneau()\r
49 \r
50     monMC.dsMaFunct = False\r
51 \r
52 def recupereDicoGenerique(monMC):\r
53     if hasattr(monMC,'dsMaFunct') and monMC.dsMaFunct== True : return\r
54     print ('je passe dans la recuperation')\r
55     editor=monMC.jdc.editor\r
56     valeurDB=editor.getValeur('Equation','Equation_DB',())\r
57     print ('valeurDB',valeurDB)\r
58     correspond=pckdb.DBRENAME\r
59     if valeurDB != None :\r
60        listEquation, listModele,listePostTraitement=pckdb.read_pckdb(correspond[valeurDB])\r
61        print (listEquation, listModele,listePostTraitement)\r
62     monMC.dsMaFunct = False\r
63     return listEquation, listModele,listePostTraitement\r
64 \r
65 def recupereDicoEquation(monMC):\r
66     if hasattr(monMC,'dsMaFunct') and monMC.dsMaFunct== True : return\r
67     listEquation, listModele,listePostTraitement=recupereDicoGenerique(monMC)\r
68     editor=monMC.jdc.editor\r
69 \r
70     valeurEquationListe=editor.getValeur('Equation','Equation_Liste',('b_type_show',))\r
71     valeurAgingType=editor.getValeur('Equation','Equation_reaction',('b_type_show','b_reaction_type',))\r
72     if valeurAgingType == None :\r
73        print ('dans reaction-type')\r
74        valeurAgingType=editor.getValeur('Equation','Equation_reaction',('b_type_show','b_aging_type',))\r
75     if valeurAgingType == None : monMC.dsMaFunct = False; return\r
76 \r
77     print ('valeurType',valeurAgingType)\r
78     listeEquationPourIhm = []\r
79     listeReprEquationPourIhm = []\r
80     dicoListeAffiche={}\r
81     for equation in listEquation :\r
82         if valeurEquationListe == 'aging_type' :\r
83            if equation.type_vieil == valeurAgingType : \r
84               listeEquationPourIhm.append(equation)\r
85               listeReprEquationPourIhm.append(equation.representation)\r
86               dicoListeAffiche[equation.representation]=equation\r
87         else:\r
88            if equation.type_react == valeurAgingType : \r
89               listeEquationPourIhm.append(equation)\r
90               listeReprEquationPourIhm.append(equation.representation)\r
91               dicoListeAffiche[equation.representation]=equation\r
92     change=editor.changeIntoDefMC('Equation', ('b_type_show','ListeEquation'), listeReprEquationPourIhm )\r
93     if change :\r
94        editor.reCalculeValiditeMCApresChgtInto('Equation', 'listeEquation', ('b_type_show',)) \r
95        if editor.fenetreCentraleAffichee : editor.fenetreCentraleAffichee.node.affichePanneau()\r
96     editor.maClasseVisuEquation = classeVisuEquation(dicoListeAffiche)\r
97     monMC.dsMaFunct = False\r
98 \r
99 def afficheValeurEquation(monMC):\r
100     if hasattr(monMC,'dsMaFunct') and monMC.dsMaFunct== True : return\r
101     editor=monMC.jdc.editor\r
102     valeur=monMC.valeur\r
103     if valeur == None : \r
104        monMC.dsMaFunct = False\r
105        return\r
106     print (editor.maClasseVisuEquation.dicoListeAffiche[valeur])\r
107     print(str (editor.maClasseVisuEquation.dicoListeAffiche[valeur]))\r
108     editor.maClasseVisuEquation.valeurEquationChoisie=valeur\r
109     monMC.dsMaFunct = False\r
110               \r
111 \r
112 def instancieChemicalFormulation(monMC):\r
113     if hasattr(monMC,'dsMaFunct') and monMC.dsMaFunct== True : return\r
114     if monMC.valeur == False : return\r
115 \r
116     editor=monMC.jdc.editor\r
117     if hasattr(editor,'dsMaFunct') and editor.dsMaFunct== True : return\r
118     editor.dsMaFunct = True\r
119 \r
120     print ('ds instancie')\r
121     v=editor.maClasseVisuEquation.valeurEquationChoisie\r
122     monEquation=editor.maClasseVisuEquation.dicoListeAffiche[v]\r
123     type_react=monEquation.type_react\r
124     type_vieil=monEquation.type_vieil\r
125     print (v, type_react, type_vieil)\r
126     #editor.changeIntoMCandSet('Equation', ('b_type_show','b_modification','b_modif','ChemicalFormulation'),( v,),v )\r
127     change=editor.changeDefautDefMC('Equation', ('b_type_show','b_modification','b_modif','Reaction_Type'),type_react )\r
128     change=editor.changeDefautDefMC('Equation', ('b_type_show','b_modification','b_modif','Aging_Type'), type_vieil )\r
129 \r
130     for index,valeurConstituant in enumerate(monEquation.constituants):\r
131         valeurEquation=monEquation.equation[index] \r
132         editor.ajoutMC(monMC.etape,'OptionnelConstituant',None,('b_type_show','b_modification','b_modif',))\r
133         print (index,valeurConstituant,valeurEquation)\r
134 \r
135             #OptionnelConstituant =  FACT ( statut = 'f',max = '**',\r
136             #    Constituant = SIMP (statut = 'o', typ = 'TXM'),\r
137             #    Differential_Equation =  SIMP(statut= 'o',typ= 'TXM'),\r
138     for index,valeurConstituant in enumerate(monEquation.const_cine_nom):\r
139          valeurArrhe=monEquation.arrhenius[index] \r
140          if valeurArrhe : valeurConstanteType='Arrhenius type'\r
141          else           : valeurConstanteType='non Arrhenius type'\r
142 \r
143          print (index,valeurConstituant,valeurConstanteType)\r
144             #OptionnelleConstante  = FACT (statut = 'f', max = '**',\r
145             #     ConstanteName= SIMP (statut = 'o', typ = 'TXM',),\r
146             #    ConstanteType =  SIMP(statut= 'o',typ= 'TXM', min=1,into=('Arrhenius type','non Arrhenius type'),defaut='Arrhenius type'),\r
147     change=editor.changeDefautDefMC('Equation', ('b_type_show','b_modification','b_modif','Commentaire'),monEquation.comment )\r
148     print (monEquation.comment )\r
149     #if change :\r
150     if editor.fenetreCentraleAffichee : editor.fenetreCentraleAffichee.node.affichePanneau()\r
151     monMC.dsMaFunct = False\r
152     editor.dsMaFunct = False\r
153  \r
154 \r
155 \r
156 monDico= { 'Equation_Liste' : ('initiation', 'propagation', 'termination', 'stabilization')}\r
157 \r
158 JdC = JDC_CATA(code='VP',\r
159                execmodul=None,\r
160                 )\r
161 \r
162 \r
163   \r
164 #---------------------------------\r
165 Equation = PROC (nom="Equation",\r
166       op=None,\r
167 #---------------------------------\r
168       Equation_DB=SIMP(statut= 'o',typ= 'TXM', into=("Approved data base", "My data base") ),\r
169       Equation_Type = SIMP(statut= 'o',typ= 'TXM', into=("Show equation database", "Equation creation"),),\r
170 \r
171       \r
172 #     ---------------------------------------------------------------------------\r
173        b_type_show = BLOC(condition = " Equation_Type == 'Show equation database'",\r
174 #      ---------------------------------------------------------------------------\r
175         Equation_Liste=SIMP(statut= 'o',typ= 'TXM', into=('reaction_type','aging_type')),\r
176 \r
177          b_reaction_type =  BLOC(condition = " Equation_Liste  == 'reaction_type'",\r
178            Equation_reaction=SIMP(statut= 'o',typ= 'TXM', into=monDico['Equation_Liste'],siValide=recupereDicoEquation),\r
179          ), # Fin b_reaction_type\r
180 \r
181          b_aging_type =  BLOC(condition = " Equation_Liste  == 'aging_type'",\r
182               Equation_reaction=SIMP(statut= 'o',typ= 'TXM', into=('All', 'thermo', 'radio'),siValide=recupereDicoEquation),\r
183          ), # Fin b_reaction_type\r
184 \r
185          ListeEquation = SIMP(statut='o', typ='TXM',  homo='SansOrdreNiDoublon',siValide=afficheValeurEquation),\r
186          b_modification = BLOC(condition = " ListeEquation != None ",\r
187            modification = SIMP(typ = bool, statut = 'o',defaut = False, fr='toto', ang='toto en anglais', siValide=instancieChemicalFormulation),\r
188            \r
189            b_modif = BLOC(condition = "modification == True",\r
190             Reaction_Type=SIMP(statut= 'o',typ= 'TXM', min=1,into=monDico['Equation_Liste'],),\r
191             Aging_Type=SIMP(statut= 'o',typ= 'TXM', min=1,max='**', homo='SansOrdreNiDoublon', into=('All', 'thermo', 'radio'),),\r
192 \r
193             OptionnelConstituant =  FACT ( statut = 'f',max = '**',\r
194                 Constituant = SIMP (statut = 'o', typ = 'TXM'),\r
195                 Differential_Equation =  SIMP(statut= 'o',typ= 'TXM'),\r
196                ), # fin Const_Equa\r
197             OptionnelleConstante  = FACT (statut = 'f', max = '**',\r
198                   ConstanteName= SIMP (statut = 'o', typ = 'TXM',),\r
199                   ConstanteType =  SIMP(statut= 'o',typ= 'TXM', min=1,into=('Arrhenius type','non Arrhenius type'),defaut='Arrhenius type'),\r
200                   ),# fin ConstanteOptionnelle\r
201             Commentaire =  SIMP (statut = 'f', typ = 'TXM', defaut = ' '),\r
202 \r
203            ),# fin b_modif\r
204          \r
205          ), # fin b_modification\r
206        ), # Fin b_type_show\r
207 \r
208 \r
209 #     ---------------------------------------------------------------------------\r
210       b_type_creation = BLOC(condition = " Equation_Type == 'Equation creation'",\r
211 #         ---------------------------------------------------------------------------\r
212          Equation_Modification = FACT ( statut = 'o',\r
213  \r
214             ChemicalFormulation = SIMP(statut='o', typ='TXM', defaut = 'POOH -> 2P'),\r
215 \r
216             Reaction_Type=SIMP(statut= 'o',typ= 'TXM', min=1,into=monDico['Equation_Liste'],),\r
217             Aging_Type=SIMP(statut= 'o',typ= 'TXM', min=1,max='**', homo='SansOrdreNiDoublon', into=('All', 'thermo', 'radio'),),\r
218 \r
219             Constituants = FACT ( statut = 'o',\r
220                ConstituantPOOH = SIMP (statut = 'f', typ = 'TXM', into = ('POOH',), defaut= 'POOH'),\r
221                b_pooh =  BLOC(condition = " ConstituantPOOH == 'POOH'" ,\r
222                   Differential_Equation =  SIMP(statut= 'o',typ= 'TXM', defaut = '-ku1*POOH'),\r
223                ), # Fin b_pooh\r
224                ConstituantP = SIMP (statut = 'f', typ = 'TXM', into = ('P',),defaut='P'),\r
225                b_p =  BLOC(condition = " ConstituantP == 'P'" ,\r
226                  Differential_Equation =  SIMP(statut= 'o',typ= 'TXM', defaut = '2*ku1*POOH'),\r
227                ), # Fin b_p\r
228             OptionnelConstituant =  FACT ( statut = 'f',max = '**',\r
229                 Constituant = SIMP (statut = 'o', typ = 'TXM'),\r
230                 Differential_Equation =  SIMP(statut= 'o',typ= 'TXM'),\r
231                ), # fin Const_Equa\r
232             ),# Fin Constituants\r
233 \r
234             Constante = FACT ( statut = 'o',\r
235                Constanteku1 = SIMP (statut = 'f', typ = 'TXM', into = ('ku1',), defaut= 'ku1'),\r
236                b_cku1 =  BLOC(condition = "Constanteku1 == 'ku1'" ,\r
237                   ConstanteType =  SIMP(statut= 'o',typ= 'TXM', into=('Arrhenius type','non Arrhenius type'),defaut='Arrhenius type'),\r
238                   ),\r
239                OptionnelleConstante  = FACT (statut = 'f', max = '**',\r
240                   ConstanteName= SIMP (statut = 'o', typ = 'TXM',),\r
241                   ConstanteType =  SIMP(statut= 'o',typ= 'TXM', min=1,into=('Arrhenius type','non Arrhenius type'),defaut='Arrhenius type'),\r
242                   ),# fin ConstanteOptionnelle\r
243             ), # fin constante\r
244             Commentaire =  SIMP (statut = 'f', typ = 'TXM', defaut = ' '),\r
245                   \r
246          ), # Fin Equation_Modification\r
247 \r
248                  #Chemical_Formulation =  SIMP(statut= 'o',typ= 'TXM', defaut = 'POOH->P',siValide=maFuncWithArg),\r
249                  #Type1 = SIMP(statut='o', typ = 'TXM', into=maFunc),\r
250                  #Type2 = SIMP(statut='o', typ = 'TXM'),\r
251 \r
252         ),  # fin b_type_creation\r
253                  \r
254       \r
255 ) # Fin Equation\r
256 \r
257 Modele = PROC (nom="Modele",\r
258       op=None,\r
259       Commentaire =  SIMP (statut = 'f', typ = 'TXM'),\r
260 ) # Fin Modele\r