+# coding: utf-8\r
+import types\r
+from Accas import *\r
+import sys,os\r
+sys.path.append('/home/A96028/opt/MAP/map-2016.1/lib/python2.7/site-packages/mapy/components/c_pre_polymer_data_management')\r
+sys.path.append('/home/A96028/opt/MAP/map-2016.1/lib/python2.7/site-packages/mapy/virtual_polymer_common')\r
+sys.path.append('/home/A96028/opt/MAP/map-2016.1/lib/python2.7/site-packages/')\r
+import pckdb, class_data, instruction, equation_part, utils\r
+\r
+\r
+monDico= { 'Equation_Liste' : ('initiation', 'propagation', 'termination', 'stabilization'),\r
+ 'Modele_TechnicalUse' : ('cable', 'coating', 'pipes'),\r
+ }\r
+\r
+class Tuple:\r
+ def __init__(self,ntuple):\r
+ self.ntuple=ntuple\r
+\r
+ def __convert__(self,valeur):\r
+ if type(valeur) == types.StringType: return None\r
+ if len(valeur) != self.ntuple: return None\r
+ return valeur\r
+\r
+ def info(self):\r
+ return "Tuple de %s elements" % self.ntuple\r
+\r
+ __repr__=info\r
+ __str__=info\r
+\r
+#class ObjetUtilisateur(ASSD): pass\r
+\r
+class classeVisuEquation :\r
+ def __init__(self,dicoListeAffiche, listEquation, listModele,listPostTraitement):\r
+ self.dicoListeAffiche=dicoListeAffiche\r
+ self.listEquation=listEquation\r
+ self.listModele=listModele\r
+ self.listPostTraitement=listPostTraitement\r
+ \r
+\r
+def maFunc():\r
+ return ('a1','a2','a3')\r
+ \r
+def maFuncWithArg(monMC):\r
+ if hasattr(monMC,'dsMaFunct') and monMC.dsMaFunct== True : return\r
+ monMC.dsMaFunct = True\r
+\r
+ editor=monMC.jdc.editor\r
+ if monMC.valeur == 'POOH->P' : monInto=('a1','a2','a3')\r
+ else : monInto=('b1','b2','b3')\r
+\r
+ change=editor.changeIntoDefMC('AGING', ('Equation', 'b_approved','b_type_creation','Equation_Modification','Type2'), monInto )\r
+ if change :\r
+ print ('j ai change le into')\r
+ editor.reCalculeValiditeMCApresChgtInto('AGING', 'Type2', ('Equation', 'b_approved','b_type_creation','Equation_Modification')) \r
+ if editor.fenetreCentraleAffichee : editor.fenetreCentraleAffichee.node.affichePanneau()\r
+\r
+ monMC.dsMaFunct = False\r
+\r
+def recupereDicoGenerique(monMC):\r
+ if hasattr(monMC,'dsMaFunct') and monMC.dsMaFunct== True : return\r
+ print ('je passe dans la recuperation')\r
+ editor=monMC.jdc.editor\r
+ valeurDB=editor.getValeur('Equation','Equation_DB',())\r
+ if valeurDB == None : valeurDB=editor.getValeur('Modele','Modele_DB',())\r
+ correspond=pckdb.DBRENAME\r
+ if valeurDB != None :\r
+ listEquation, listModele,listPostTraitement=pckdb.read_pckdb(correspond[valeurDB])\r
+ monMC.dsMaFunct = False\r
+ return listEquation, listModele,listPostTraitement\r
+\r
+def recupereDicoEquation(monMC):\r
+ if hasattr(monMC,'dsMaFunct') and monMC.dsMaFunct== True : return\r
+ listEquation, listModele,listePostTraitement=recupereDicoGenerique(monMC)\r
+ editor=monMC.jdc.editor\r
+\r
+ valeurEquationListe=editor.getValeur('Equation','Equation_Liste',('b_type_show',))\r
+ valeurAgingType=editor.getValeur('Equation','Equation_reaction',('b_type_show','b_reaction_type',))\r
+ if valeurAgingType == None :\r
+ valeurAgingType=editor.getValeur('Equation','Equation_reaction',('b_type_show','b_aging_type',))\r
+ if valeurAgingType == None : monMC.dsMaFunct = False; return\r
+\r
+ listeEquationPourIhm = []\r
+ listeReprEquationPourIhm = []\r
+ dicoListeAffiche={}\r
+ for equation in listEquation :\r
+ if valeurEquationListe == 'aging_type' :\r
+ if equation.type_vieil == valeurAgingType : \r
+ listeEquationPourIhm.append(equation)\r
+ listeReprEquationPourIhm.append(equation.representation)\r
+ dicoListeAffiche[equation.representation]=equation\r
+ else:\r
+ if equation.type_react == valeurAgingType : \r
+ listeEquationPourIhm.append(equation)\r
+ listeReprEquationPourIhm.append(equation.representation)\r
+ dicoListeAffiche[equation.representation]=equation\r
+ change=editor.changeIntoDefMC('Equation', ('b_type_show','ListeEquation'), listeReprEquationPourIhm )\r
+ if change :\r
+ editor.reCalculeValiditeMCApresChgtInto('Equation', 'listeEquation', ('b_type_show',)) \r
+ if editor.fenetreCentraleAffichee : editor.fenetreCentraleAffichee.node.affichePanneau()\r
+ editor.maClasseVisuEquation = classeVisuEquation(dicoListeAffiche,listEquation, listModele,listPostTraitement)\r
+ monMC.dsMaFunct = False\r
+\r
+def afficheValeurEquation(monMC):\r
+ if hasattr(monMC,'dsMaFunct') and monMC.dsMaFunct== True : return\r
+ editor=monMC.jdc.editor\r
+ valeur=monMC.valeur\r
+ if valeur == None : \r
+ monMC.dsMaFunct = False\r
+ return\r
+ editor.maClasseVisuEquation.valeurEquationChoisie=valeur\r
+ monMC.dsMaFunct = False\r
+ \r
+\r
+def instancieChemicalFormulation(monMC):\r
+ if hasattr(monMC,'dsMaFunct') and monMC.dsMaFunct== True : return\r
+ if monMC.valeur == False : return\r
+\r
+ editor=monMC.jdc.editor\r
+ if hasattr(editor,'dsMaFunct') and editor.dsMaFunct== True : return\r
+ editor.dsMaFunct = True\r
+\r
+ print ('ds instancie')\r
+ v=editor.maClasseVisuEquation.valeurEquationChoisie\r
+ monEquation=editor.maClasseVisuEquation.dicoListeAffiche[v]\r
+ type_react=monEquation.type_react\r
+ type_vieil=monEquation.type_vieil\r
+ print (v, type_react, type_vieil)\r
+ #editor.changeIntoMCandSet('Equation', ('b_type_show','b_modification','b_modif','ChemicalFormulation'),( v,),v )\r
+ change=editor.changeDefautDefMC('Equation', ('b_type_show','b_modification','b_modif','Reaction_Type'),type_react )\r
+ change=editor.changeDefautDefMC('Equation', ('b_type_show','b_modification','b_modif','Aging_Type'), type_vieil )\r
+\r
+ for index,valeurConstituant in enumerate(monEquation.constituants):\r
+ valeurEquation=monEquation.equation[index] \r
+ editor.ajoutMC(monMC.etape,'OptionnelConstituant',None,('b_type_show','b_modification','b_modif',))\r
+ print (index,valeurConstituant,valeurEquation)\r
+\r
+ #OptionnelConstituant = FACT ( statut = 'f',max = '**',\r
+ # Constituant = SIMP (statut = 'o', typ = 'TXM'),\r
+ # Differential_Equation = SIMP(statut= 'o',typ= 'TXM'),\r
+ for index,valeurConstituant in enumerate(monEquation.const_cine_nom):\r
+ valeurArrhe=monEquation.arrhenius[index] \r
+ if valeurArrhe : valeurConstanteType='Arrhenius type'\r
+ else : valeurConstanteType='non Arrhenius type'\r
+\r
+ print (index,valeurConstituant,valeurConstanteType)\r
+ #OptionnelleConstante = FACT (statut = 'f', max = '**',\r
+ # ConstanteName= SIMP (statut = 'o', typ = 'TXM',),\r
+ # ConstanteType = SIMP(statut= 'o',typ= 'TXM', min=1,into=('Arrhenius type','non Arrhenius type'),defaut='Arrhenius type'),\r
+ change=editor.changeDefautDefMC('Equation', ('b_type_show','b_modification','b_modif','Commentaire'),monEquation.comment )\r
+ print (monEquation.comment )\r
+ #if change :\r
+ if editor.fenetreCentraleAffichee : editor.fenetreCentraleAffichee.node.affichePanneau()\r
+ monMC.dsMaFunct = False\r
+ editor.dsMaFunct = False\r
+ \r
+# TEMPORAIRE \r
+# TODO TODO TODO\r
+# PNPNPNPNPN\r
+\r
+\r
+maClasseDeModele=class_data.Modele()\r
+\r
+def recupereDicoModele(monMC):\r
+ if monMC.valeur == None: return\r
+ if hasattr(monMC,'dsMaFunct') and monMC.dsMaFunct== True : return\r
+ print ('je passe dans recupereDicoModele')\r
+ listEquation, listModele,listPostTraitement=recupereDicoGenerique(monMC)\r
+ editor=monMC.jdc.editor\r
+ editor.maClasseVisuEquation = classeVisuEquation({},listEquation, listModele,listPostTraitement)\r
+ monMC.dsMaFunct = False\r
+\r
+\r
+def creeListeEquation(monMC):\r
+ if monMC.valeur == None: return\r
+ if hasattr(monMC,'dsMaFunct') and monMC.dsMaFunct== True : return\r
+\r
+ editor=monMC.jdc.editor\r
+# TEMPORAIRE \r
+# TODO TODO TODO\r
+ listeEquationsAAfficher=[]\r
+ listeConstantesAAfficher=[]\r
+ for index,equation in enumerate( editor.maClasseVisuEquation.listEquation):\r
+ if index in maClasseDeModele.equa:\r
+ listeEquationsAAfficher.append(equation.representation)\r
+ listeConstantesAAfficher.append(equation.const_cine_nom)\r
+\r
+ monMC.dsMaFunct = False\r
+\r
+ # listeEquation_stabilization=SIMP(statut='o', homo='SansOrdreNiDoublon', max='**', min=0 ),\r
+\r
+def recupereModeleEquation(monMC):\r
+ if hasattr(monMC,'dsMaFunct') and monMC.dsMaFunct== True : return\r
+ if monMC.valeur==False : return\r
+ editor=monMC.jdc.editor\r
+ if hasattr(editor,'dsMaFunct') and editor.dsMaFunct== True : return\r
+\r
+ editor.dsMaFunct = True\r
+ dicoListeEquationAAfficher={}\r
+\r
+ for valeurReactionType in monDico['Equation_Liste']:\r
+ dicoListeEquationAAfficher[valeurReactionType] = [] \r
+ for index,equation in enumerate( editor.maClasseVisuEquation.listEquation):\r
+ if equation.type_react==valeurReactionType : \r
+ dicoListeEquationAAfficher[valeurReactionType].append(equation.representation)\r
+ print (dicoListeEquationAAfficher)\r
+ \r
+ change=editor.changeIntoDefMC('Modele', ('b_type_creation','b_ajout_equation','listeEquation_initiation'),dicoListeEquationAAfficher['initiation'] )\r
+ change=editor.changeIntoDefMC('Modele', ('b_type_creation','b_ajout_equation','listeEquation_propagation'),dicoListeEquationAAfficher['propagation'] )\r
+ change=editor.changeIntoDefMC('Modele', ('b_type_creation','b_ajout_equation','listeEquation_termination'),dicoListeEquationAAfficher['termination'] )\r
+ change=editor.changeIntoDefMC('Modele', ('b_type_creation','b_ajout_equation','listeEquation_stabilization'),dicoListeEquationAAfficher['stabilization'] )\r
+ if editor.fenetreCentraleAffichee : editor.fenetreCentraleAffichee.node.affichePanneau()\r
+ editor.dsMaFunct = False\r
+\r
+def prepareDiffusion(monMC):\r
+ print ('je suis dans prepareDiffusion')\r
+ if monMC.valeur==False : return\r
+ if hasattr(monMC,'dsMaFunct') and monMC.dsMaFunct== True : return\r
+ monMC.dsMaFunct=True\r
+ editor=monMC.jdc.editor\r
+ if hasattr(editor,'dsMaFunct') and editor.dsMaFunct== True : return\r
+ editor.dsMaFunct = True\r
+ editor.dicoCoefS={}\r
+ editor.dicoCoefD={}\r
+ for c in maClasseDeModele.coef[0].keys() :\r
+ if c[0]=='S':\r
+ clef=c[1:]\r
+ valeur= maClasseDeModele.coef[0][c]\r
+ editor.dicoCoefS[clef]=valeur\r
+ if c[0]=='D':\r
+ clef=c[1:]\r
+ valeur= maClasseDeModele.coef[0][c]\r
+ editor.dicoCoefD[clef]=valeur\r
+ print (editor.dicoCoefS,editor.dicoCoefD)\r
+ monMC.dsMaFunct=False\r
+ editor.dsMaFunct = False\r
+\r
+\r
+def ajouteDiffusion(monMC):\r
+ print ('je suis dans ajouteDiffusion')\r
+ if monMC.valeur == None : return\r
+ print (monMC.valeur)\r
+ if hasattr(monMC,'dsMaFunct') and monMC.dsMaFunct== True : return\r
+ monMC.dsMaFunct=True\r
+ editor=monMC.jdc.editor\r
+ if hasattr(editor,'dsMaFunct') and editor.dsMaFunct== True : return\r
+ editor.dsMaFunct = True\r
+\r
+\r
+ for v in monMC.valeur :\r
+ print (v)\r
+ mesValeurs=editor.dicoCoefS[v]\r
+ print (editor.dicoCoefS)\r
+ print (mesValeurs) \r
+ MCFils='S'+v\r
+ for e in monMC.jdc.etapes:\r
+ if e.nom == Modele :break\r
+\r
+ print (e)\r
+ editor.ajoutDefinitionMC(e,('b_type_creation','b_diffusion'),MCFils,typ='TXM',statut='o' )\r
+ print ('ggggg')\r
+ editor.ajoutMC(e,MCFils,mesValeurs,('b_type_creation','b_diffusion',))\r
+ print ('______')\r
+ if editor.fenetreCentraleAffichee : editor.fenetreCentraleAffichee.node.affichePanneau()\r
+ monMC.dsMaFunct=False\r
+ editor.dsMaFunct = False\r
+\r
+JdC = JDC_CATA(code='VP',\r
+ execmodul=None,\r
+ )\r
+\r
+\r
+ \r
+#---------------------------------\r
+Equation = PROC (nom="Equation",\r
+ op=None,\r
+#---------------------------------\r
+ Equation_DB=SIMP(statut= 'o',typ= 'TXM', into=("Approved data base", "My data base") ),\r
+ Equation_Type = SIMP(statut= 'o',typ= 'TXM', into=("Show equation database", "Equation creation"),),\r
+\r
+ \r
+# ---------------------------------------------------------------------------\r
+ b_type_show = BLOC(condition = " Equation_Type == 'Show equation database'",\r
+# ---------------------------------------------------------------------------\r
+ Equation_Liste=SIMP(statut= 'o',typ= 'TXM', into=('reaction_type','aging_type')),\r
+\r
+ b_reaction_type = BLOC(condition = " Equation_Liste == 'reaction_type'",\r
+ Equation_reaction=SIMP(statut= 'o',typ= 'TXM', into=monDico['Equation_Liste'],siValide=recupereDicoEquation),\r
+ ), # Fin b_reaction_type\r
+\r
+ b_aging_type = BLOC(condition = " Equation_Liste == 'aging_type'",\r
+ Equation_reaction=SIMP(statut= 'o',typ= 'TXM', into=('All', 'thermo', 'radio'),siValide=recupereDicoEquation),\r
+ ), # Fin b_reaction_type\r
+\r
+ ListeEquation = SIMP(statut='o', typ='TXM', homo='SansOrdreNiDoublon',siValide=afficheValeurEquation),\r
+ b_modification = BLOC(condition = " ListeEquation != None ",\r
+ modification = SIMP(typ = bool, statut = 'o',defaut = False, fr='toto', ang='toto en anglais', siValide=instancieChemicalFormulation),\r
+ \r
+ b_modif = BLOC(condition = "modification == True",\r
+ Reaction_Type=SIMP(statut= 'o',typ= 'TXM', min=1,into=monDico['Equation_Liste'],),\r
+ Aging_Type=SIMP(statut= 'o',typ= 'TXM', min=1,max='**', homo='SansOrdreNiDoublon', into=('All', 'thermo', 'radio'),),\r
+\r
+ OptionnelConstituant = FACT ( statut = 'f',max = '**',\r
+ Constituant = SIMP (statut = 'o', typ = 'TXM'),\r
+ Differential_Equation = SIMP(statut= 'o',typ= 'TXM'),\r
+ ), # fin Const_Equa\r
+ OptionnelleConstante = FACT (statut = 'f', max = '**',\r
+ ConstanteName= SIMP (statut = 'o', typ = 'TXM',),\r
+ ConstanteType = SIMP(statut= 'o',typ= 'TXM', min=1,into=('Arrhenius type','non Arrhenius type'),defaut='Arrhenius type'),\r
+ ),# fin ConstanteOptionnelle\r
+ Commentaire = SIMP (statut = 'f', typ = 'TXM', defaut = ' '),\r
+\r
+ ),# fin b_modif\r
+ \r
+ ), # fin b_modification\r
+ ), # Fin b_type_show\r
+\r
+\r
+# ---------------------------------------------------------------------------\r
+ b_type_creation = BLOC(condition = " Equation_Type == 'Equation creation'",\r
+# ---------------------------------------------------------------------------\r
+ Equation_Modification = FACT ( statut = 'o',\r
+ \r
+ ChemicalFormulation = SIMP(statut='o', typ='TXM', defaut = 'POOH -> 2P'),\r
+\r
+ Reaction_Type=SIMP(statut= 'o',typ= 'TXM', min=1,into=monDico['Equation_Liste'],),\r
+ Aging_Type=SIMP(statut= 'o',typ= 'TXM', min=1,max='**', homo='SansOrdreNiDoublon', into=('All', 'thermo', 'radio'),),\r
+\r
+ Constituants = FACT ( statut = 'o',\r
+ ConstituantPOOH = SIMP (statut = 'f', typ = 'TXM', into = ('POOH',), defaut= 'POOH'),\r
+ b_pooh = BLOC(condition = " ConstituantPOOH == 'POOH'" ,\r
+ Differential_Equation = SIMP(statut= 'o',typ= 'TXM', defaut = '-ku1*POOH'),\r
+ ), # Fin b_pooh\r
+ ConstituantP = SIMP (statut = 'f', typ = 'TXM', into = ('P',),defaut='P'),\r
+ b_p = BLOC(condition = " ConstituantP == 'P'" ,\r
+ Differential_Equation = SIMP(statut= 'o',typ= 'TXM', defaut = '2*ku1*POOH'),\r
+ ), # Fin b_p\r
+ OptionnelConstituant = FACT ( statut = 'f',max = '**',\r
+ Constituant = SIMP (statut = 'o', typ = 'TXM'),\r
+ Differential_Equation = SIMP(statut= 'o',typ= 'TXM'),\r
+ ), # fin Const_Equa\r
+ ),# Fin Constituants\r
+\r
+ Constante = FACT ( statut = 'o',\r
+ Constanteku1 = SIMP (statut = 'f', typ = 'TXM', into = ('ku1',), defaut= 'ku1'),\r
+ b_cku1 = BLOC(condition = "Constanteku1 == 'ku1'" ,\r
+ ConstanteType = SIMP(statut= 'o',typ= 'TXM', into=('Arrhenius type','non Arrhenius type'),defaut='Arrhenius type'),\r
+ ),\r
+ OptionnelleConstante = FACT (statut = 'f', max = '**',\r
+ ConstanteName= SIMP (statut = 'o', typ = 'TXM',),\r
+ ConstanteType = SIMP(statut= 'o',typ= 'TXM', min=1,into=('Arrhenius type','non Arrhenius type'),defaut='Arrhenius type'),\r
+ ),# fin ConstanteOptionnelle\r
+ ), # fin constante\r
+ Commentaire = SIMP (statut = 'f', typ = 'TXM', defaut = ' '),\r
+ \r
+ ), # Fin Equation_Modification\r
+\r
+ #Chemical_Formulation = SIMP(statut= 'o',typ= 'TXM', defaut = 'POOH->P',siValide=maFuncWithArg),\r
+ #Type1 = SIMP(statut='o', typ = 'TXM', into=maFunc),\r
+ #Type2 = SIMP(statut='o', typ = 'TXM'),\r
+\r
+ ), # fin b_type_creation\r
+ \r
+ \r
+) # Fin Equation\r
+\r
+#---------------------------------\r
+Modele = PROC (nom="Modele",\r
+ op=None,\r
+ Modele_DB=SIMP(statut= 'o',typ= 'TXM', into=("Approved data base", "My data base"),siValide=recupereDicoModele ),\r
+ Modele_Type = SIMP(statut= 'o',typ= 'TXM', into=("Show modele database", "Modele creation"),siValide=creeListeEquation),\r
+# ---------------------------------------------------------------------------\r
+ b_type_creation = BLOC(condition = " Modele_Type == 'Modele creation'",\r
+# ---------------------------------------------------------------------------\r
+ technicalUse= SIMP(statut= 'o',typ= 'TXM',into=monDico['Modele_TechnicalUse'],defaut=maClasseDeModele.technical_use ),\r
+ modeleName=SIMP(statut='o',typ='TXM',defaut=maClasseDeModele.nom,),\r
+ material=SIMP(statut='o',typ='TXM',defaut=maClasseDeModele.materiaux[0],),\r
+ stabilizer = SIMP(typ = bool, statut = 'o',defaut = maClasseDeModele.stabilise),\r
+ model_developed_by_for_EDF = SIMP(typ = bool, statut = 'o',defaut = maClasseDeModele.dvt_EDF[0]),\r
+ documentation=SIMP(statut='o',typ='TXM',defaut=maClasseDeModele.reference,),\r
+ \r
+ # ajouter la liste des equations et le remove (il faut garder ceux qu on a enlever)\r
+ \r
+\r
+ AjoutEquation=SIMP(statut= 'o',typ= bool, defaut=False, siValide=recupereModeleEquation),\r
+ b_ajout_equation = BLOC(condition = " AjoutEquation == True",\r
+ listeEquation_initiation=SIMP(statut='o', typ='TXM',homo='SansOrdreNiDoublon', max='**', min=0, defaut=[] ),\r
+ listeEquation_propagation=SIMP(statut='o', typ='TXM',homo='SansOrdreNiDoublon', max='**', min=0, defaut=[] ),\r
+ listeEquation_termination=SIMP(statut='o', typ='TXM',homo='SansOrdreNiDoublon', max='**', min=0, defaut=[] ),\r
+ listeEquation_stabilization=SIMP(statut='o',typ='TXM', homo='SansOrdreNiDoublon', max='**', min=0, defaut=[] ),\r
+ ),# fin b_ajout_equation\r
+ \r
+ # coefficients maClasseDeModele.coef = liste de dictionnaire mais il faut prendre que le 0\r
+ # on enleve ceux qui commence par D, S et B(casse imprtante)\r
+ # la clef est le coef, puis les valeurs\r
+\r
+ Aging_Type=SIMP(statut= 'o',typ='TXM', min=1,max='**', homo='SansOrdreNiDoublon', into=('All', 'thermo', 'radio'), defaut=maClasseDeModele.type_vieil),\r
+ Diffusion = SIMP(typ = bool, statut = 'o',defaut = maClasseDeModele.diffusion,siValide = prepareDiffusion),\r
+\r
+ b_diffusion = BLOC(condition = " Diffusion == True",\r
+ #coefficients maClasseDeModele.coef = liste de dictionnaire mais il faut prendre que le 0\r
+ # on met ceux qui commence par D, S et pas les B ni les aitres( casse imprtante)\r
+ listeProduitPourLaDiffusion=SIMP(statut='o', typ='TXM', max='**', min=1,homo='SansOrdreNiDoublon', into = maClasseDeModele.param_ini.keys(),siValide=ajouteDiffusion), \r
+ ), # fin b_diffusion\r
+ \r
+ ), # fin b_type_creation\r
+\r
+\r
+ #AjoutEquation=Fact(statut='f',\r
+ # Reaction_Type=SIMP(statut= 'o',typ= 'TXM', min=1,into=monDico['Equation_Liste'],siValide=recupereModeleEquation),\r
+ #), # fin AjoutEquation\r
+\r
+ Commentaire = SIMP (statut = 'f', typ = 'TXM'),\r
+) # Fin Modele\r