Salome HOME
PSEN
[tools/eficas.git] / PSEN_Eficas / opsPSEN.py
1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2013   EDF R&D
3 #
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
8 #
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 # Lesser General Public License for more details.
13 #
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20
21 #from ExtractGeneratorLoadLineandTransfoDico import ExtractGeneratorLoadLineandTransfoDico
22 from ExtractGeneratorLoadLineandTransfoDico import ExtractGeneratorLoadLineandTransfoDico2
23
24 def INCLUDE(self,PSSE_path,sav_file,**args):
25    """ 
26        Fonction sd_prod pour la macro INCLUDE
27    """
28    
29    if sav_file==None: return
30    reevalue=0
31    listeADeTruire=[]
32    listeNouveau=[]
33    toClean=False
34    if hasattr(self,'fichier_ini'):
35        reevalue=1
36        if self.fichier_ini == sav_file : return
37        self.fichier_ini=sav_file
38        if hasattr(self,'old_context_fichier_init' ):
39          toClean=True
40          for concept in self.old_context_fichier_init.values():
41              #self.jdc.delete_concept(concept)
42              listeADeTruire.append(concept)
43          self.jdc_aux=None
44          self.contexte_fichier_init={}
45          #self.reevalue_sd_jdc()
46          self.jdc.reset_context()
47
48    self.fichier_ini=sav_file
49    self.contexte_fichier_init = {}
50    self.fichier_unite = 999
51    self.fichier_err = None
52    self.fichier_text=""
53     
54    unite = 999
55
56    #try :
57    if 1:
58      MachineDico,LoadDico,LineDico,TransfoDico, MotorDico = ExtractGeneratorLoadLineandTransfoDico2(sav_file,PSSE_path)
59    else :
60    #except :
61      if self.jdc.appli is not None:
62         self.jdc.appli.affiche_alerte("Error", 'An error happened in ExtractGeneratorandLoadList execution ')
63         self.g_context = {}
64         self.etapes = []
65         self.jdc_aux = None
66         self.fichier_err = str(exc)
67         self.contexte_fichier_init = {}
68
69    
70    for nom in MachineDico.keys():
71       self.fichier_text += "%s=MONGENER(ID='%s',);\n" % (nom, 'a')
72       listeNouveau.append(nom)
73
74    for nom in LoadDico.keys():
75       self.fichier_text += "%s=MACHARGE(ID='%s',);\n" % (nom, 'a')
76       listeNouveau.append(nom)
77       
78    for nom in LineDico.keys():
79       self.fichier_text += "%s=MALIGNE(ID='%s',);\n" % (nom,'a')
80       listeNouveau.append(nom)
81
82    for nom in TransfoDico.keys():
83       self.fichier_text += "%s=MONTRANSFO(ID='%s',);\n" % (nom,'a')
84       listeNouveau.append(nom)
85
86    for nom in MotorDico.keys():
87       self.fichier_text += "%s=MONMOTEUR(ID='%s',);\n" % (nom,'a')
88       listeNouveau.append(nom)
89
90    import Extensions.jdc_include
91    self.JdC_aux = Extensions.jdc_include.JDC_CATA_INCLUDE(code='PSEN', execmodul=None)
92    self.make_contexte_include(None, self.fichier_text)
93    self.old_context_fichier_init = self.contexte_fichier_init
94    self.parent.record_unit(unite, self)
95
96    self.jdc.MachineDico=MachineDico
97    self.jdc.LoadDico=LoadDico
98    self.jdc.LineDico=LineDico
99    self.jdc.TransfoDico=TransfoDico
100    self.jdc.MotorDico = MotorDico
101
102    if toClean:
103     for concept in listeADeTruire :
104       if concept.nom not in listeNouveau: self.jdc.delete_concept(concept)
105     self.reevalue_sd_jdc()
106
107 def INCLUDE_context(self,d):
108    """ 
109        Fonction op_init pour macro INCLUDE
110    """
111    for k,v in self.g_context.items():
112       d[k]=v
113