Salome HOME
sauve du 10/06
[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    if hasattr(self,'fichier_ini'):
32        reevalue=1
33        if self.fichier_ini == sav_file : return
34        if hasattr(self,'old_context_fichier_init' ):
35          for concept in self.old_context_fichier_init.values():
36              self.jdc.delete_concept(concept)
37          self.jdc_aux=None
38          self.contexte_fichier_init={}
39          self.reevalue_sd_jdc()
40          self.jdc.reset_context()
41
42    self.fichier_ini=sav_file
43    self.contexte_fichier_init = {}
44    self.fichier_unite = 999
45    self.fichier_err = None
46    self.fichier_text=""
47     
48    unite = 999
49
50    try :
51    #if 1:
52      MachineDico,LoadDico,LineDico,TransfoDico = ExtractGeneratorLoadLineandTransfoDico2(sav_file,PSSE_path)
53    #else :
54    except :
55      if self.jdc.appli is not None:
56         self.jdc.appli.affiche_alerte("Error", 'An error happened in ExtractGeneratorandLoadList execution ')
57         self.g_context = {}
58         self.etapes = []
59         self.jdc_aux = None
60         self.fichier_err = str(exc)
61         self.contexte_fichier_init = {}
62
63    for nom in MachineDico.keys():
64       self.fichier_text += "%s=MONGENER(ID='%s',);\n" % (nom, 'a')
65
66    for nom in LoadDico.keys():
67       self.fichier_text += "%s=MACHARGE(ID='%s',);\n" % (nom, 'a')
68       
69    for nom in LineDico.keys():
70       self.fichier_text += "%s=MALIGNE(ID='%s',);\n" % (nom,'a')
71
72    for nom in TransfoDico.keys():
73       self.fichier_text += "%s=MONTRANSFO(ID='%s',);\n" % (nom,'a')
74
75    import Extensions.jdc_include
76    self.JdC_aux = Extensions.jdc_include.JDC_CATA_INCLUDE(code='PSEN', execmodul=None)
77    self.make_contexte_include(None, self.fichier_text)
78    self.old_context_fichier_init = self.contexte_fichier_init
79    self.parent.record_unit(unite, self)
80
81    self.jdc.MachineDico=MachineDico
82    self.jdc.LoadDico=LoadDico
83    self.jdc.LineDico=LineDico
84    self.jdc.TransfoDico=TransfoDico
85
86 def INCLUDE_context(self,d):
87    """ 
88        Fonction op_init pour macro INCLUDE
89    """
90    for k,v in self.g_context.items():
91       d[k]=v
92