From 978752c11f001a9944bff427f6feebcc0a806b6a Mon Sep 17 00:00:00 2001 From: "pascale.noyret" Date: Fri, 21 Apr 2017 18:20:13 +0200 Subject: [PATCH] sauvegarde du 21 04 --- VirtualPolymer/VP_Cata_V1.py | 4 +- VirtualPolymer/VP_Cata_V2.py | 161 ++++++++++++++++++++++++ VirtualPolymer/lienDB.py | 229 +++++++++++++++++++++++++++++++++++ VirtualPolymer/listesDB.py | 62 ++++++++++ VirtualPolymer/prefs_VP.py | 2 +- 5 files changed, 455 insertions(+), 3 deletions(-) create mode 100644 VirtualPolymer/VP_Cata_V2.py create mode 100644 VirtualPolymer/lienDB.py create mode 100644 VirtualPolymer/listesDB.py diff --git a/VirtualPolymer/VP_Cata_V1.py b/VirtualPolymer/VP_Cata_V1.py index b51ef136..08f74e6c 100644 --- a/VirtualPolymer/VP_Cata_V1.py +++ b/VirtualPolymer/VP_Cata_V1.py @@ -328,11 +328,11 @@ Equation = PROC (nom="Equation", Constituants = FACT ( statut = 'o', ConstituantPOOH = SIMP (statut = 'f', typ = 'TXM', into = ('POOH',), defaut= 'POOH'), b_pooh = BLOC(condition = " ConstituantPOOH == 'POOH'" , - Differential_Equation = SIMP(statut= 'o',typ= 'TXM', defaut = '-ku1*POOH'), + Differential_Equation_POOH = SIMP(statut= 'o',typ= 'TXM', defaut = '-ku1*POOH'), ), # Fin b_pooh ConstituantP = SIMP (statut = 'f', typ = 'TXM', into = ('P',),defaut='P'), b_p = BLOC(condition = " ConstituantP == 'P'" , - Differential_Equation = SIMP(statut= 'o',typ= 'TXM', defaut = '2*ku1*POOH'), + Differential_Equation_P = SIMP(statut= 'o',typ= 'TXM', defaut = '2*ku1*POOH'), ), # Fin b_p OptionnelConstituant = FACT ( statut = 'f',max = '**', Constituant = SIMP (statut = 'o', typ = 'TXM'), diff --git a/VirtualPolymer/VP_Cata_V2.py b/VirtualPolymer/VP_Cata_V2.py new file mode 100644 index 00000000..91ad8d22 --- /dev/null +++ b/VirtualPolymer/VP_Cata_V2.py @@ -0,0 +1,161 @@ +# coding: utf-8 +import types +from Accas import * + +import lienDB +import listesDB + +monDico= { 'Equation_Liste' : ('initiation', 'propagation', 'termination', 'stabilization'), + 'Modele_TechnicalUse' : ('cable', 'coating', 'pipes'), + } + +monModele=listesDB.sModele().monModele + +JdC = JDC_CATA(code='VP', + execmodul=None, + ) + + + +#--------------------------------- +Equation = PROC (nom="Equation", + op=None, +#--------------------------------- + Equation_DB=SIMP(statut= 'o',typ= 'TXM', into=("Approved data base", "My data base") ), + Equation_Type = SIMP(statut= 'o',typ= 'TXM', into=("Show equation database", "Equation creation"),), + + +# --------------------------------------------------------------------------- + b_type_show = BLOC(condition = " Equation_Type == 'Show equation database'", +# --------------------------------------------------------------------------- + Equation_Liste=SIMP(statut= 'o',typ= 'TXM', into=('reaction_type','aging_type')), + + b_reaction_type = BLOC(condition = " Equation_Liste == 'reaction_type'", + Equation_reaction=SIMP(statut= 'o',typ= 'TXM', into=monDico['Equation_Liste'],siValide=lienDB.recupereDicoEquation), + ), # Fin b_reaction_type + + b_aging_type = BLOC(condition = " Equation_Liste == 'aging_type'", + Equation_reaction=SIMP(statut= 'o',typ= 'TXM', into=('All', 'thermo', 'radio'),siValide=lienDB.recupereDicoEquation), + ), # Fin b_reaction_type + + ListeEquation = SIMP(statut='o', typ='TXM', homo='SansOrdreNiDoublon',siValide=lienDB.afficheValeurEquation), + b_modification = BLOC(condition = " ListeEquation != None ", + modification = SIMP(typ = bool, statut = 'o',defaut = False, fr='toto', ang='toto en anglais', siValide=lienDB.instancieChemicalFormulation), + + b_modif = BLOC(condition = "modification == True", + Reaction_Type=SIMP(statut= 'o',typ= 'TXM', min=1,into=monDico['Equation_Liste'],), + Aging_Type=SIMP(statut= 'o',typ= 'TXM', min=1,max='**', homo='SansOrdreNiDoublon', into=('All', 'thermo', 'radio'),), + ChemicalFormulation = SIMP(statut='o', typ='TXM', defaut = 'POOH -> 2P'), + + OptionnelConstituant = FACT ( statut = 'f',max = '**', + Constituant = SIMP (statut = 'o', typ = 'TXM'), + Differential_Equation = SIMP(statut= 'o',typ= 'TXM'), + ), # fin Const_Equa + OptionnelleConstante = FACT (statut = 'f', max = '**', + ConstanteName= SIMP (statut = 'o', typ = 'TXM',), + ConstanteType = SIMP(statut= 'o',typ= 'TXM', min=1,into=('Arrhenius type','non Arrhenius type'),defaut='Arrhenius type'), + ),# fin ConstanteOptionnelle + Commentaire = SIMP (statut = 'f', typ = 'TXM', defaut = ' '), + + ),# fin b_modif + + ), # fin b_modification + ), # Fin b_type_show + + +# --------------------------------------------------------------------------- + b_type_creation = BLOC(condition = " Equation_Type == 'Equation creation'", +# --------------------------------------------------------------------------- + Equation_Modification = FACT ( statut = 'o', + + ChemicalFormulation = SIMP(statut='o', typ='TXM', defaut = 'POOH -> 2P'), + + Reaction_Type=SIMP(statut= 'o',typ= 'TXM', min=1,into=monDico['Equation_Liste'],), + Aging_Type=SIMP(statut= 'o',typ= 'TXM', min=1,max='**', homo='SansOrdreNiDoublon', into=('All', 'thermo', 'radio'),), + + Constituants = FACT ( statut = 'o', + ConstituantPOOH = SIMP (statut = 'f', typ = 'TXM', into = ('POOH',)), + b_pooh = BLOC(condition = " ConstituantPOOH == 'POOH'" , + Differential_Equation_POOH = SIMP(statut= 'o',typ= 'TXM', defaut = '-ku1*POOH'), + ), # Fin b_pooh + #ConstituantP = SIMP (statut = 'f', typ = 'TXM', into = ('P',)), + #b_p = BLOC(condition = " ConstituantP == 'P'" , + # Differential_Equation_P = SIMP(statut= 'o',typ= 'TXM', defaut = '2*ku1*POOH'), + #), # Fin b_p + ConstituantP = FACT ( statut = 'f', + ConstituantP = SIMP (statut = 'f', typ = 'TXM', into = ('P',)), + Differential_Equation_P = SIMP(statut= 'o',typ= 'TXM', defaut = '2*ku1*POOH'), + ), # Fin ConstituantP + + OptionnelConstituant = FACT ( statut = 'f',max = '**', + Constituant = SIMP (statut = 'o', typ = 'TXM'), + Differential_Equation = SIMP(statut= 'o',typ= 'TXM'), + ), # fin Const_Equa + ),# Fin Constituants + + Constante = FACT ( statut = 'o', + Constanteku1 = SIMP (statut = 'f', typ = 'TXM', into = ('ku1',), defaut= 'ku1'), + b_cku1 = BLOC(condition = "Constanteku1 == 'ku1'" , + ConstanteType = SIMP(statut= 'o',typ= 'TXM', into=('Arrhenius type','non Arrhenius type'),defaut='Arrhenius type'), + ), + OptionnelleConstante = FACT (statut = 'f', max = '**', + ConstanteName= SIMP (statut = 'o', typ = 'TXM',), + ConstanteType = SIMP(statut= 'o',typ= 'TXM', min=1,into=('Arrhenius type','non Arrhenius type'),defaut='Arrhenius type'), + ),# fin ConstanteOptionnelle + ), # fin constante + Commentaire = SIMP (statut = 'f', typ = 'TXM', defaut = ' '), + + ), # Fin Equation_Modification + ), # fin b_type_creation + + +) # Fin Equation + +#--------------------------------- +Modele = PROC (nom="Modele", + op=None, + Modele_DB=SIMP(statut= 'o',typ= 'TXM', into=("Approved data base", "My data base"),siValide=lienDB.recupereDicoModele ), + Modele_Type = SIMP(statut= 'o',typ= 'TXM', into=("Show modele database", "Modele creation"),siValide=lienDB.creeListeEquation), +# --------------------------------------------------------------------------- + b_type_creation = BLOC(condition = " Modele_Type == 'Modele creation'", +# --------------------------------------------------------------------------- + technicalUse= SIMP(statut= 'o',typ= 'TXM',into=monDico['Modele_TechnicalUse'],defaut=monModele.technical_use ), + modeleName=SIMP(statut='o',typ='TXM',defaut=monModele.nom,), + material=SIMP(statut='o',typ='TXM',defaut=monModele.materiaux[0],), + stabilizer = SIMP(typ = bool, statut = 'o',defaut = monModele.stabilise), + model_developed_by_for_EDF = SIMP(typ = bool, statut = 'o',defaut = monModele.dvt_EDF[0]), + documentation=SIMP(statut='o',typ='TXM',defaut=monModele.reference,), + + # ajouter la liste des equations et le remove (il faut garder ceux qu on a enlever) + + + AjoutEquation=SIMP(statut= 'o',typ= bool, defaut=False, siValide=lienDB.recupereModeleEquation), + b_ajout_equation = BLOC(condition = " AjoutEquation == True", + listeEquation_initiation=SIMP(statut='o', typ='TXM',homo='SansOrdreNiDoublon', max='**', min=0, defaut=[] ), + listeEquation_propagation=SIMP(statut='o', typ='TXM',homo='SansOrdreNiDoublon', max='**', min=0, defaut=[] ), + listeEquation_termination=SIMP(statut='o', typ='TXM',homo='SansOrdreNiDoublon', max='**', min=0, defaut=[] ), + listeEquation_stabilization=SIMP(statut='o',typ='TXM', homo='SansOrdreNiDoublon', max='**', min=0, defaut=[] ), + ),# fin b_ajout_equation + + # coefficients monModele.coef = liste de dictionnaire mais il faut prendre que le 0 + # on enleve ceux qui commence par D, S et B(casse imprtante) + # la clef est le coef, puis les valeurs + + Aging_Type=SIMP(statut= 'o',typ='TXM', min=1,max='**', homo='SansOrdreNiDoublon', into=('All', 'thermo', 'radio'), defaut=monModele.type_vieil), + Diffusion = SIMP(typ = bool, statut = 'o',defaut = monModele.diffusion,siValide = lienDB.prepareDiffusion), + + b_diffusion = BLOC(condition = " Diffusion == True", + #coefficients monModele.coef = liste de dictionnaire mais il faut prendre que le 0 + # on met ceux qui commence par D, S et pas les B ni les aitres( casse imprtante) + listeProduitPourLaDiffusion=SIMP(statut='o', typ='TXM', max='**', min=1,homo='SansOrdreNiDoublon', into = monModele.param_ini.keys(),siValide=lienDB.ajouteDiffusion), + ), # fin b_diffusion + + ), # fin b_type_creation + + + #AjoutEquation=Fact(statut='f', + # Reaction_Type=SIMP(statut= 'o',typ= 'TXM', min=1,into=monDico['Equation_Liste'],siValide=lienDB.recupereModeleEquation), + #), # fin AjoutEquation + + Commentaire = SIMP (statut = 'f', typ = 'TXM'), +) # Fin Modele diff --git a/VirtualPolymer/lienDB.py b/VirtualPolymer/lienDB.py new file mode 100644 index 00000000..ba2b1a71 --- /dev/null +++ b/VirtualPolymer/lienDB.py @@ -0,0 +1,229 @@ +# coding: utf-8 +import types +import sys,os + +import listesDB + + +maClasseDelistesDB = listesDB.classeListesDB() +monModele=listesDB.sModele().monModele + + +# -------------------------------------- +# Fonctions appellees depuis le catalogue +# -------------------------------------- + +# -------------------------------------- +# Dans Equation +# -------------------------------------- + +def recupereDicoEquation(monMC): + # Equation_reaction (ds 2 blocs) + # ou dans Equation b_type_show b_reaction_type + # ou dans Equation b_type_show b_aging_type + + if hasattr(monMC,'dsMaFunct') and monMC.dsMaFunct== True : return + editor=monMC.jdc.editor + + valeurDB=editor.getValeur('Equation','Equation_DB',()) + maClasseDelistesDB.metAJour(valeurDB) + listEquation=maClasseDelistesDB.getListEquation() + + valeurEquationListe=editor.getValeur('Equation','Equation_Liste',('b_type_show',)) + valeurAgingType=editor.getValeur('Equation','Equation_reaction',('b_type_show','b_reaction_type',)) + if valeurAgingType == None : + valeurAgingType=editor.getValeur('Equation','Equation_reaction',('b_type_show','b_aging_type',)) + if valeurAgingType == None : monMC.dsMaFunct = False; return + + listeEquationPourIhm = [] + listeReprEquationPourIhm = [] + dicoListAffiche = {} + + for equation in listEquation : + if valeurEquationListe == 'aging_type' : + if equation.type_vieil == valeurAgingType : + listeEquationPourIhm.append(equation) + listeReprEquationPourIhm.append(equation.representation) + dicoListAffiche[equation.representation]=equation + else: + if equation.type_react == valeurAgingType : + listeEquationPourIhm.append(equation) + listeReprEquationPourIhm.append(equation.representation) + dicoListAffiche[equation.representation]=equation + maClasseDelistesDB.dicoListAffiche = dicoListAffiche + + change=editor.changeIntoDefMC('Equation', ('b_type_show','ListeEquation'), listeReprEquationPourIhm ) + if change : + editor.reCalculeValiditeMCApresChgtInto('Equation', 'listeEquation', ('b_type_show',)) + if editor.fenetreCentraleAffichee : editor.fenetreCentraleAffichee.node.affichePanneau() + monMC.dsMaFunct = False + +def afficheValeurEquation(monMC): + # Equation b_modification modification + if hasattr(monMC,'dsMaFunct') and monMC.dsMaFunct== True : return + valeur=monMC.valeur + if valeur == None : return + maClasseDelistesDB.valeurEquationChoisie=str(valeur) + monEquation=maClasseDelistesDB.dicoListAffiche[str(valeur)] + + aAfficher='jkljkljk \n je ne sais plus \njfkqsljqfkl\nkfsjqklfjkl\n' + editor=monMC.jdc.editor + editor._viewText(aAfficher, "Rapport",largeur=30,hauteur=150) + + monMC.dsMaFunct = False + + +def instancieChemicalFormulation(monMC): + if hasattr(monMC,'dsMaFunct') and monMC.dsMaFunct== True : return + if monMC.valeur == False : return + + editor=monMC.jdc.editor + if hasattr(editor,'dsMaFunct') and editor.dsMaFunct== True : return + editor.dsMaFunct = True + + print ('ds instancie') + v=maClasseDelistesDB.valeurEquationChoisie + monEquation=maClasseDelistesDB.dicoListAffiche[v] + type_react=monEquation.type_react + type_vieil=monEquation.type_vieil + + editor.changeIntoMCandSet('Equation', ('b_type_show','b_modification','b_modif','ChemicalFormulation'),( v,),v ) + return + #change=editor.changeDefautDefMC('Equation', ('b_type_show','b_modification','b_modif','Reaction_Type'),type_react ) + change=editor.changeDefautDefMC('Equation', ('b_type_show','b_modification','b_modif','Aging_Type'), type_vieil ) + + for index,valeurConstituant in enumerate(monEquation.constituants): + valeurEquation=monEquation.equation[index] + editor.ajoutMC(monMC.etape,'OptionnelConstituant',None,('b_type_show','b_modification','b_modif',)) + print (index,valeurConstituant,valeurEquation) + + #OptionnelConstituant = FACT ( statut = 'f',max = '**', + # Constituant = SIMP (statut = 'o', typ = 'TXM'), + # Differential_Equation = SIMP(statut= 'o',typ= 'TXM'), + + for index,valeurConstituant in enumerate(monEquation.const_cine_nom): + valeurArrhe=monEquation.arrhenius[index] + if valeurArrhe : valeurConstanteType='Arrhenius type' + else : valeurConstanteType='non Arrhenius type' + print (index,valeurConstituant,valeurConstanteType) + #OptionnelleConstante = FACT (statut = 'f', max = '**', + # ConstanteName= SIMP (statut = 'o', typ = 'TXM',), + # ConstanteType = SIMP(statut= 'o',typ= 'TXM', min=1,into=('Arrhenius type','non Arrhenius type'),defaut='Arrhenius type'), + + change=editor.changeDefautDefMC('Equation', ('b_type_show','b_modification','b_modif','Commentaire'),monEquation.comment ) + print (monEquation.comment ) + if editor.fenetreCentraleAffichee : editor.fenetreCentraleAffichee.node.affichePanneau() + + monMC.dsMaFunct = False + editor.dsMaFunct = False + +# TEMPORAIRE +# TODO TODO TODO +# PNPNPNPNPN + + + +def recupereDicoModele(monMC): + if monMC.valeur == None: return + if hasattr(monMC,'dsMaFunct') and monMC.dsMaFunct== True : return + print ('je passe dans recupereDicoModele') + listEquation, listModele,listPostTraitement=recupereDicoGenerique(monMC) + editor=monMC.jdc.editor + editor.maClasseVisuEquation = classeVisuEquation({},listEquation, listModele,listPostTraitement) + monMC.dsMaFunct = False + + +def creeListeEquation(monMC): + if monMC.valeur == None: return + if hasattr(monMC,'dsMaFunct') and monMC.dsMaFunct== True : return + + editor=monMC.jdc.editor +# TEMPORAIRE +# TODO TODO TODO + listeEquationsAAfficher=[] + listeConstantesAAfficher=[] + for index,equation in enumerate( editor.maClasseVisuEquation.listEquation): + if index in monModele.equa: + listeEquationsAAfficher.append(equation.representation) + listeConstantesAAfficher.append(equation.const_cine_nom) + + monMC.dsMaFunct = False + + # listeEquation_stabilization=SIMP(statut='o', homo='SansOrdreNiDoublon', max='**', min=0 ), + +def recupereModeleEquation(monMC): + if hasattr(monMC,'dsMaFunct') and monMC.dsMaFunct== True : return + if monMC.valeur==False : return + editor=monMC.jdc.editor + if hasattr(editor,'dsMaFunct') and editor.dsMaFunct== True : return + + editor.dsMaFunct = True + dicoListeEquationAAfficher={} + + for valeurReactionType in monDico['Equation_Liste']: + dicoListeEquationAAfficher[valeurReactionType] = [] + for index,equation in enumerate( editor.maClasseVisuEquation.listEquation): + if equation.type_react==valeurReactionType : + dicoListeEquationAAfficher[valeurReactionType].append(equation.representation) + print (dicoListeEquationAAfficher) + + change=editor.changeIntoDefMC('Modele', ('b_type_creation','b_ajout_equation','listeEquation_initiation'),dicoListeEquationAAfficher['initiation'] ) + change=editor.changeIntoDefMC('Modele', ('b_type_creation','b_ajout_equation','listeEquation_propagation'),dicoListeEquationAAfficher['propagation'] ) + change=editor.changeIntoDefMC('Modele', ('b_type_creation','b_ajout_equation','listeEquation_termination'),dicoListeEquationAAfficher['termination'] ) + change=editor.changeIntoDefMC('Modele', ('b_type_creation','b_ajout_equation','listeEquation_stabilization'),dicoListeEquationAAfficher['stabilization'] ) + if editor.fenetreCentraleAffichee : editor.fenetreCentraleAffichee.node.affichePanneau() + editor.dsMaFunct = False + +def prepareDiffusion(monMC): + print ('je suis dans prepareDiffusion') + if monMC.valeur==False : return + if hasattr(monMC,'dsMaFunct') and monMC.dsMaFunct== True : return + monMC.dsMaFunct=True + editor=monMC.jdc.editor + if hasattr(editor,'dsMaFunct') and editor.dsMaFunct== True : return + editor.dsMaFunct = True + editor.dicoCoefS={} + editor.dicoCoefD={} + for c in monModele.coef[0].keys() : + if c[0]=='S': + clef=c[1:] + valeur= monModele.coef[0][c] + editor.dicoCoefS[clef]=valeur + if c[0]=='D': + clef=c[1:] + valeur= monModele.coef[0][c] + editor.dicoCoefD[clef]=valeur + print (editor.dicoCoefS,editor.dicoCoefD) + monMC.dsMaFunct=False + editor.dsMaFunct = False + + +def ajouteDiffusion(monMC): + print ('je suis dans ajouteDiffusion') + if monMC.valeur == None : return + print (monMC.valeur) + if hasattr(monMC,'dsMaFunct') and monMC.dsMaFunct== True : return + monMC.dsMaFunct=True + editor=monMC.jdc.editor + if hasattr(editor,'dsMaFunct') and editor.dsMaFunct== True : return + editor.dsMaFunct = True + + + for v in monMC.valeur : + print (v) + mesValeurs=editor.dicoCoefS[v] + print (editor.dicoCoefS) + print (mesValeurs) + MCFils='S'+v + for e in monMC.jdc.etapes: + if e.nom == Modele :break + + print (e) + editor.ajoutDefinitionMC(e,('b_type_creation','b_diffusion'),MCFils,typ='TXM',statut='o' ) + print ('ggggg') + editor.ajoutMC(e,MCFils,mesValeurs,('b_type_creation','b_diffusion',)) + print ('______') + if editor.fenetreCentraleAffichee : editor.fenetreCentraleAffichee.node.affichePanneau() + monMC.dsMaFunct=False + editor.dsMaFunct = False + diff --git a/VirtualPolymer/listesDB.py b/VirtualPolymer/listesDB.py new file mode 100644 index 00000000..fbef9b46 --- /dev/null +++ b/VirtualPolymer/listesDB.py @@ -0,0 +1,62 @@ +# coding: utf-8 +import types +import sys,os +sys.path.append('/home/A96028/opt/MAP/map-2016.1/lib/python2.7/site-packages/mapy/components/c_pre_polymer_data_management') +sys.path.append('/home/A96028/opt/MAP/map-2016.1/lib/python2.7/site-packages/mapy/virtual_polymer_common') +sys.path.append('/home/A96028/opt/MAP/map-2016.1/lib/python2.7/site-packages/') +import pckdb, class_data, instruction, equation_part, utils + +# -------------------------------------- +class sModele : +# -------------------------------------- + + _instance = None + + def __new__(cls, *args, **kwargs): + if not cls._instance: + cls._instance = super(sModele, cls).__new__( + cls, *args, **kwargs) + + return cls._instance + + def __init__ (self): + self.monModele=class_data.Modele() + + +# -------------------------------------- +class classeListesDB : +# -------------------------------------- + + _instance = None + + def __new__(cls, *args, **kwargs): + if not cls._instance: + cls._instance = super(listesDB, cls).__new__( + cls, *args, **kwargs) + + return cls._instance + + def __init__ (self): + self.listEquation = None + self.listModele = None + self.listPostTraitement = None + self.dicoListAffiche = {} + self.valeurEquationChoisie = None + + def metAJour(self,valeur): + if valeur == None : return + correspond=pckdb.DBRENAME + self.listEquation, self.listModele,self.listPostTraitement=pckdb.read_pckdb(correspond[valeur]) + + def getListEquation(self): + return self.listEquation + + def getListModele(self): + return self.listModele + + def getListPostTraitement(self): + return self.listPostTraitement + + def getdicoListAffiche(self): + return self.dicoListAffiche + diff --git a/VirtualPolymer/prefs_VP.py b/VirtualPolymer/prefs_VP.py index cec67343..2d50d821 100644 --- a/VirtualPolymer/prefs_VP.py +++ b/VirtualPolymer/prefs_VP.py @@ -35,7 +35,7 @@ encoding='iso-8859-1' # catalogues=( - ('VP','V1',os.path.join(repIni,'VP_Cata_V1.py'),'python','python'), + ('VP','V1',os.path.join(repIni,'VP_Cata_V2.py'),'python','python'), ) nombreDeBoutonParLigne=2 closeFrameRechercheCommande = True -- 2.39.2