# TUPLE
-tupleNonHomogeneSimpleType = '\t<xs:simpleType name="{}_n{}_tuple">\n\t\t<xs:restriction base="{}"/>\n\t\t</xs:simpleType>\n'
-tupleNonHomogeneElt = '\t\t\t<xs:element name="{}" type="{}:{}" minOccurs="{}" maxOccurs="{}"/>\n'
-tupleDebutComplexeType = '\t<xs:complexType name="{}">\n\t\t<xs:sequence>'
-tupleMilieuComplexeType = '\n\t\t\t<xs:element name="n{}" type="{}_n{}_tuple" minOccurs="1" maxOccurs="1"/>'
-tupleFinComplexeType = '\n\t\t</xs:sequence>\n\t\t<xs:attribute name="sdType" type="xs:string" fixed="Tuple"/>\n\t</xs:complexType>\n'
+tupleNonHomogeneSimpleType = '\t<xs:simpleType name="{}_n{}_tuple">\n\t\t<xs:restriction base="{}"/>\n\t\t</xs:simpleType>\n'
+tupleNonHomogeneElt = '\t\t\t<xs:element name="{}" type="{}:{}" minOccurs="{}" maxOccurs="{}"/>\n'
+tupleDebutComplexeType = '\t<xs:complexType name="{}">\n\t\t<xs:sequence>'
+tupleMilieuComplexeType = '\n\t\t\t<xs:element name="n{}" type="{}_n{}_tuple" minOccurs="1" maxOccurs="1"/>'
+tupleFinComplexeType = '\n\t\t</xs:sequence>\n\t\t<xs:attribute name="sdType" type="xs:string" fixed="Tuple"/>\n\t</xs:complexType>\n'
+tupleDebutComplexeTypeMinZero = '\t<xs:complexType name="{}">\n\t\t<xs:choice>\n\t\t<xs:sequence>\n\t\t</xs:sequence>\n\t\t<xs:sequence maxOccurs={}>'
+tupleFinComplexeTypeMinZero = '\n\t\t</xs:sequence>\n\t\t</xs:choice>\n\t\t<xs:attribute name="sdType" type="xs:string" fixed="Tuple"/>\n\t</xs:complexType>\n'
# MATRICE
eltMatrice = '\t\t\t <xs:element name="{}" type="{}:{}" minOccurs="{}" maxOccurs="{}"/>\n'
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')
+
#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
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")
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
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",
rep_mat=self.maConfiguration.rep_mat
)
self.modified = False
+ self.monConvert=monConvert
return jdc
#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):
#-----------------------
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=""
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"))
def getSource(self,file):
# appele par Editeur/session.py
+ # non modifie par withUQ (normal)
import convert
p=convert.plugins['python']()
p.readfile(file)
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
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
--- /dev/null
+#!/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)
--- /dev/null
+# 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))
+