From: PASCALE NOYRET Date: Wed, 1 Jun 2022 09:25:48 +0000 (+0200) Subject: premiers devlpts pour sortie UQ en ligne de commande X-Git-Tag: merge_uncertainty_odysee_1210~69 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7f0e52e3a2d7b58000eac73f795d03b55046a1fd;p=tools%2Feficas.git premiers devlpts pour sortie UQ en ligne de commande --- diff --git a/Efi2Xsd/balisesXSD.py b/Efi2Xsd/balisesXSD.py index 32bd8779..4e059de6 100644 --- a/Efi2Xsd/balisesXSD.py +++ b/Efi2Xsd/balisesXSD.py @@ -125,11 +125,13 @@ finEltCataSimple = '\t\t \n\t\t\n' # TUPLE -tupleNonHomogeneSimpleType = '\t\n\t\t\n\t\t\n' -tupleNonHomogeneElt = '\t\t\t\n' -tupleDebutComplexeType = '\t\n\t\t' -tupleMilieuComplexeType = '\n\t\t\t' -tupleFinComplexeType = '\n\t\t\n\t\t\n\t\n' +tupleNonHomogeneSimpleType = '\t\n\t\t\n\t\t\n' +tupleNonHomogeneElt = '\t\t\t\n' +tupleDebutComplexeType = '\t\n\t\t' +tupleMilieuComplexeType = '\n\t\t\t' +tupleFinComplexeType = '\n\t\t\n\t\t\n\t\n' +tupleDebutComplexeTypeMinZero = '\t\n\t\t\n\t\t\n\t\t\n\t\t' +tupleFinComplexeTypeMinZero = '\n\t\t\n\t\t\n\t\t\n\t\n' # MATRICE eltMatrice = '\t\t\t \n' diff --git a/Ihm/I_MCSIMP.py b/Ihm/I_MCSIMP.py index 6d45ce9f..ac9dd0be 100644 --- a/Ihm/I_MCSIMP.py +++ b/Ihm/I_MCSIMP.py @@ -893,6 +893,45 @@ class MCSIMP(I_OBJECT.OBJECT): def isUQActivate(self): # valide uniquement pour les MCSIMP # a reflechir a la relecture du .comm - return False + return self.associeVariableUQ - + def lieVariableUQ(self): + self.associeVariableUQ=True + etapeIncertitude=self.jdc.getEtapesByName('ExpressionIncertitude') + if etapeIncertitude == [] : + self.jdc.editor.tree.racine.appendChild('ExpressionIncertitude', 'last') + etapeIncertitude=self.jdc.getEtapesByName('ExpressionIncertitude') + etapeIncertitude=etapeIncertitude[0] + incertitudeInput = etapeIncertitude.getChildOrChildInBloc('Input') + nodeVariableProbabiliste=incertitudeInput.node.appendChild('VariableProbabiliste', 'first') + # le buildChildren a une mcliste --> on est oblige de mettre first mais en fait c est last + if nodeVariableProbabiliste.item.object.nature=='MCFACT' : + newVariable=nodeVariableProbabiliste.item.object + else : + newVariable=nodeVariableProbabiliste.item.object[-1] + newVariable.variableDeterministe = self + + itemModelVariable=newVariable.getChild('ModelVariable') + itemModelVariable.setValeur(self.nom) + + itemConsigne=newVariable.getChild('Consigne') + itemConsigne.setValeur('la valeur entrée pour {} est {}'.format(self.nom, self.valeur)) + + itemXPath=newVariable.getChild('xPathVariable') + #itemXPath.reparent(newVariable) + itemXPath.setValeur(self.getGenealogiePrecise()) + #print (itemXPath) + + self.variableProbabiliste=nodeVariableProbabiliste.item + self.definition.siValide = self.changeValeursRefUQ + + def changeValeursRefUQ (self, motClef): + if not hasattr(motClef,'variableProbabiliste') : print ('pb ds changeValeursRefUQ'); return + itemConsigne=motClef.variableProbabiliste.getChild('Consigne') + itemConsigne.setValeur('la valeur entrée pour {} est {}'.format(motClef.nom, motClef.valeur)) + motClef.variableProbabiliste.valeurProbabiliste=motClef.valeur + + + def delieVariableUQ(self): + print ('pas encore programme') + diff --git a/Ihm/I_OBJECT.py b/Ihm/I_OBJECT.py index 6bdf4f5a..b4d58b84 100644 --- a/Ihm/I_OBJECT.py +++ b/Ihm/I_OBJECT.py @@ -192,44 +192,4 @@ class OBJECT: #print ('demandeRedessine pour', self.nom, self, tout) CONNECTOR.Emit(self,"redessine") - def ajouteAuxIncertains(self): - - etapeIncertitude=self.jdc.getEtapesByName('ExpressionIncertitude') - if etapeIncertitude == [] : - self.jdc.editor.tree.racine.appendChild('ExpressionIncertitude', 'last') - etapeIncertitude=self.jdc.getEtapesByName('ExpressionIncertitude') - etapeIncertitude=etapeIncertitude[0] - incertitudeInput = etapeIncertitude.getChildOrChildInBloc('Input') - nodeVariableProbabiliste=incertitudeInput.node.appendChild('VariableProbabiliste', 'first') - # le buildChildren a une mcliste --> on est oblige de mettre first mais en fait c est last - if nodeVariableProbabiliste.item.object.nature=='MCFACT' : - newVariable=nodeVariableProbabiliste.item.object - else : - newVariable=nodeVariableProbabiliste.item.object[-1] - newVariable.variableDeterministe = self - - itemModelVariable=newVariable.getChild('ModelVariable') - itemModelVariable.setValeur(self.nom) - - itemConsigne=newVariable.getChild('Consigne') - itemConsigne.setValeur('la valeur entrée pour {} est {}'.format(self.nom, self.valeur)) - - itemXPath=newVariable.getChild('xPathVariable') - #itemXPath.reparent(newVariable) - itemXPath.setValeur(self.getGenealogiePrecise()) - #print (itemXPath) - - self.variableProbabiliste=nodeVariableProbabiliste.item - self.definition.siValide = self.changeValeursRefUQ - - def changeValeursRefUQ (self, motClef): - if not hasattr(motClef,'variableProbabiliste') : print ('pb ds changeValeursRefUQ'); return - itemConsigne=motClef.variableProbabiliste.getChild('Consigne') - itemConsigne.setValeur('la valeur entrée pour {} est {}'.format(motClef.nom, motClef.valeur)) - motClef.variableProbabiliste.valeurProbabiliste=motClef.valeur - - - def enleveDesIncertains(self): - print ('pas encore programme') - class ErrorObj(OBJECT):pass diff --git a/InterfaceQT4/editorSsIhm.py b/InterfaceQT4/editorSsIhm.py index 033ac972..78763b57 100755 --- a/InterfaceQT4/editorSsIhm.py +++ b/InterfaceQT4/editorSsIhm.py @@ -142,12 +142,12 @@ class JDCEditorSsIhm : self.nouveau=0 if self.fichier is not None: # fichier jdc fourni if jdc==None : - #print ('PNPN : chgt try en if') - try : - #if 1 : + print ('PNPN : chgt try en if') + #try : + if 1 : self.jdc = self.readFile(self.fichier) - except : - print ("mauvaise lecture du fichier") + #except : + # print ("mauvaise lecture du fichier") if self.salome : try : self.appliEficas.addJdcInSalome( self.fichier) except : print ("mauvais enregistrement dans Salome") @@ -173,7 +173,9 @@ class JDCEditorSsIhm : if self.extensionFichier == '.xml' : if self.appliEficas.maConfiguration.withXSD: self.jdc.analyseXML() else : print ('run MDM with -x option (MDM for XML)'); exit() - else : self.jdc.analyse() + else : + self.jdc.analyse() + if hasattr(self.monConvert,'traitementApresLoad'): self.monConvert.traitementApresLoad(self.jdc) txt_exception = self.jdc.cr.getMessException() if txt_exception : self.jdc = None @@ -201,23 +203,23 @@ class JDCEditorSsIhm : if self.extensionFichier == '.xml' and self.appliEficas.maConfiguration.withXSD: formatIn='xml' if formatIn in convert.plugins: # Le convertisseur existe on l'utilise - p=convert.plugins[formatIn]() - p.readfile(fn) + monConvert=convert.plugins[formatIn]() + monConvert.readfile(fn) - if p.text=="" : self.nouveau=1 + if monConvert.text=="" : self.nouveau=1 #print ('PNPN --> CIST a faire') if formatIn != 'xml': - pareil,texteNew=self.verifieChecksum(p.text) + pareil,texteNew=self.verifieChecksum(monConvert.text) if not pareil : self.informe(("fichier modifie"),("Attention! fichier change hors EFICAS"),False) - p.text=texteNew - memeVersion,texteNew=self.verifieVersionCataDuJDC(p.text) + monConvert.text=texteNew + memeVersion,texteNew=self.verifieVersionCataDuJDC(monConvert.text) if memeVersion == 0 : texteNew=self.traduitCatalogue(texteNew) - p.text=texteNew - text=p.convert('exec',self.appliEficas) - if not p.cr.estvide(): self.afficheInfos("Erreur a la conversion",'red') + monConvert.text=texteNew + text=monConvert.convert('exec',self.appliEficas) + if not monConvert.cr.estvide(): self.afficheInfos("Erreur a la conversion",'red') else: - text=p.text + text=monConvert.text else : self.afficheInfos("Type de fichier non reconnu",'red') self.informe( "Type de fichier non reconnu", @@ -237,6 +239,7 @@ class JDCEditorSsIhm : rep_mat=self.maConfiguration.rep_mat ) self.modified = False + self.monConvert=monConvert return jdc diff --git a/InterfaceQT4/eficas_go.py b/InterfaceQT4/eficas_go.py index 092ee750..6238e90e 100755 --- a/InterfaceQT4/eficas_go.py +++ b/InterfaceQT4/eficas_go.py @@ -132,6 +132,31 @@ def genereXML(code=None): #print ('Fichier comm is not valid') monEditeur.XMLGenerator.gener(monEditeur.jdc) return monEditeur.XMLGenerator.writeDefault(fichierXMLOut) + + +def genereUQ(code=None): +#----------------------- + from Editeur import session + options=session.parse(sys.argv) + if code != None : options.code = code + if options.fichierCata == None : + print ('Use -c cata_name.py') + return 0 + try : fichier=options.comm[0] + except : fichier=None + if fichier==None : + print ('comm file is needed') + return 0 + + from .editorSsIhm import JDCEditorSsIhm + monEficasSsIhm = getEficasSsIhm(code=options.code) + monEditeur=JDCEditorSsIhm(monEficasSsIhm,fichier) + if not(monEditeur.readercata.cata) : return 0 + if monEditeur.jdc and not(monEditeur.jdc.isValid()): + print ('Fichier comm is not valid') + return 0 + return monEditeur.saveUQFile(fichier) + def genereComm(code=None): #----------------------- diff --git a/InterfaceQT4/feuille.py b/InterfaceQT4/feuille.py index 85259984..8923b2f1 100644 --- a/InterfaceQT4/feuille.py +++ b/InterfaceQT4/feuille.py @@ -105,8 +105,8 @@ class Feuille(QWidget,ContientIcones,SaisieValeur,FacultatifOuOptionnel): self.checkBoxUQ.setChecked(True) def setEnabledUQ(self) : - if self.checkBoxUQ.isChecked() : self.objSimp.ajouteAuxIncertains() - else : self.objSimp.enleveDesIncertains() + if self.checkBoxUQ.isChecked() : self.objSimp.lieVariableUQ() + else : self.objSimp.delieVariableUQ() def setNom(self): self.debutToolTip="" diff --git a/InterfaceQT4/qtEficas.py b/InterfaceQT4/qtEficas.py index 2975b309..cc0fd8e7 100755 --- a/InterfaceQT4/qtEficas.py +++ b/InterfaceQT4/qtEficas.py @@ -250,6 +250,7 @@ class Appli(AppliSsIhm,Ui_Eficas,QMainWindow): self.fileNew() def ajoutUQ(self): + AppliSsIhm.ajoutUQ(self) self.menuUQ = self.menubar.addMenu(tr("Incertitude")) self.actionUQ = QAction(self) self.actionUQ.setText(tr("Sauve Incertitude")) @@ -647,6 +648,7 @@ class Appli(AppliSsIhm,Ui_Eficas,QMainWindow): def getSource(self,file): # appele par Editeur/session.py + # non modifie par withUQ (normal) import convert p=convert.plugins['python']() p.readfile(file) diff --git a/InterfaceQT4/qtEficasSsIhm.py b/InterfaceQT4/qtEficasSsIhm.py index 56e2ba50..bc931b33 100755 --- a/InterfaceQT4/qtEficasSsIhm.py +++ b/InterfaceQT4/qtEficasSsIhm.py @@ -92,8 +92,12 @@ class AppliSsIhm: self.suiteTelemac=False self.viewmanager=MyViewManagerSsIhm(self) + self.withUQ=False - + def ajoutUQ(self): + self.withUQ=True + self.formatFichierIn = "pythonUQ" #par defaut + def definitCode(self,code,ssCode) : self.code=code self.ssCode=ssCode diff --git a/Noyau/N_MCSIMP.py b/Noyau/N_MCSIMP.py index 1409eab8..49a49fee 100644 --- a/Noyau/N_MCSIMP.py +++ b/Noyau/N_MCSIMP.py @@ -61,6 +61,7 @@ class MCSIMP(N_OBJECT.OBJECT): self.val = val self.parent = parent self.objPyxbDeConstruction = objPyxbDeConstruction + self.associeVariableUQ = False if parent: self.jdc = self.parent.jdc if self.jdc : self.cata = self.jdc.cata diff --git a/Tools/generateUQ.py b/Tools/generateUQ.py new file mode 100755 index 00000000..0370a4e7 --- /dev/null +++ b/Tools/generateUQ.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright (C) 2007-2013 EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +""" +"" + cree le .xml associe au .comm + generateXML.py -c leCatalogue le.comm + 23 avril + +""" +# Modules Python +# Modules Eficas + +import sys +import os +sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)),'../')) + +from InterfaceQT4 import eficas_go +if eficas_go.genereUQ(code='NonConnu'): + sys.exit(0) +else : + sys.exit(1) diff --git a/convert/convert_UQPython.py b/convert/convert_UQPython.py new file mode 100644 index 00000000..69237b55 --- /dev/null +++ b/convert/convert_UQPython.py @@ -0,0 +1,71 @@ +# Copyright (C) 2007-2022 EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# +from __future__ import absolute_import + + +import re +from Extensions.i18n import tr + +#import traceback +#traceback.print_stack() + +from convert.convert_python import Pythonparser + +def entryPoint(): + """ + Return a dictionary containing the description needed to load the plugin + """ + return { + 'name' : 'pythonUQ', + 'factory' : pythonUQParser + } + +class pythonUQParser(Pythonparser): + """ + This converter works like Pythonparser, except that it also initializes all + links between deterministic and probabilistic variables + """ + + def convert(self, outformat, appliEficas=None): + text=Pythonparser.convert(self, outformat, appliEficas) + return text + + def traitementApresLoad(self,jdc): + debug=1 + if debug : print ('traitementApresLoad') + etapeIncertitude=jdc.getEtapesByName('ExpressionIncertitude') + if etapeIncertitude==[] : return + + incertitudeInput = etapeIncertitude[0].getChildOrChildInBloc('Input') + self.lesVariablesInput = incertitudeInput[0].getChildOrChildInBloc('VariableProbabiliste') + for mc in self.lesVariablesInput : + mcVDXPath=mc.getChild('xPathVariable').valeur + if debug : print(mcVDXPath) + # a modifier lorsque le xPath comprendra le nom des OPERs + mcCherche=jdc.getEtapesByName(mcVDXPath[0])[0] + for mcFils in mcVDXPath[1:]: + if debug : print(mcCherche, mcFils) + mcCherche=mcCherche.getChildOrChildInBloc(mcFils) + if debug : print(mcCherche, mcFils) + mc.variableDeterministe=mcCherche + mcCherche.variableProbabiliste=mc + mcCherche.definition.siValide = mcCherche.changeValeursRefUQ + itemConsigne=mc.getChild('Consigne') + itemConsigne.setValeur('la valeur entrée pour {} est {}'.format(mcCherche.nom, mcCherche.valeur)) +