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