]> SALOME platform Git repositories - modules/adao.git/commitdiff
Salome HOME
Adding editable UserPostAnalysis templates and improving observers ones
authorJean-Philippe ARGAUD <jean-philippe.argaud@edf.fr>
Mon, 17 Jun 2013 12:58:50 +0000 (14:58 +0200)
committerJean-Philippe ARGAUD <jean-philippe.argaud@edf.fr>
Mon, 17 Jun 2013 12:58:50 +0000 (14:58 +0200)
bin/AdaoCatalogGenerator.py
src/daEficas/generator_adao.py
src/daSalome/daYacsSchemaCreator/infos_daComposant.py

index d5425dfe3a4c7cd58293ec6d69a26b30295bca76..a619ec0a45509cbad5118dd3d984edf8edb46508 100644 (file)
@@ -71,6 +71,18 @@ def F_${data_name}(statut) : return FACT(statut = statut,
 
                                                       FUNCTIONDICT_FILE = SIMP(statut = "o", typ = "FichierNoAbs", validators=(OnlyStr()), fr="OBSOLETE : conservé pour compatibilité avec la version 6.5, sera supprimé dans le futur", ang="OBSOLETE: keeped for compatibility with the 6.5 version, will be removed in the future"),
                                                      ),
+                                         TEMPLATE_DATA =  BLOC (condition = " FROM in ( 'Template', ) ",
+                                             Template = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "AnalysisPrinter", into=("AnalysisPrinter", "AnalysisSaver", "AnalysisPrinterAndSaver")),
+                                             AnalysisPrinter = BLOC (condition = " Template == 'AnalysisPrinter' ",
+                                                 ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "import numpy\\nxa=numpy.ravel(ADD.get('Analysis')[-1])\\nprint 'Analysis:',xa" ),
+                                             ),
+                                             AnalysisSaver = BLOC (condition = " Template == 'AnalysisSaver' ",
+                                                 ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "import numpy\\nxa=numpy.ravel(ADD.get('Analysis')[-1])\\nf='/tmp/analysis.txt'\\nprint 'Analysis saved in \\"%s\\"'%f\\nnumpy.savetxt(f,xa)" ),
+                                             ),
+                                             AnalysisPrinterAndSaver = BLOC (condition = " Template == 'AnalysisPrinterAndSaver' ",
+                                                 ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "import numpy\\nxa=numpy.ravel(ADD.get('Analysis')[-1])\\nprint 'Analysis:',xa\\nf='/tmp/analysis.txt'\\nprint 'Analysis saved in \\"%s\\"'%f\\nnumpy.savetxt(f,xa)" ),
+                                             ),
+                                         ),
                                     )
 """
 
@@ -110,8 +122,8 @@ observers_choice = """
                                        ${var_name} = BLOC (condition=" '${var_name}' in set(SELECTION) ",
                                            ${var_name}_data = FACT(statut = "o",
                                                Scheduler    = SIMP(statut = "f", typ = "TXM"),
-                                               Info         = SIMP(statut = "f", typ = "TXM", defaut = "${var_name}"),
-                                               NodeType     = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "", into=("String", "Script", "Template")),
+                                               Info         = SIMP(statut = "o", typ = "TXM", defaut = "${var_name}"),
+                                               NodeType     = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "Template", into=("String", "Script", "Template")),
                                                PythonScript = BLOC (condition = " NodeType == 'String' ",
                                                    Value = SIMP(statut = "o", typ = "TXM")
                                                ),
@@ -119,18 +131,30 @@ observers_choice = """
                                                    Value = SIMP(statut = "o", typ = "FichierNoAbs", validators=(OnlyStr()))
                                                ),
                                                ObserverTemplate =  BLOC (condition = " NodeType == 'Template' ",
-                                                   Template = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "", into=("ValuePrinter", "ValueSeriePrinter", "ValueGnuPlotter", "ValueSerieGnuPlotter")),
+                                                   Template = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "ValuePrinter", into=("ValuePrinter", "ValueSeriePrinter", "ValueSaver", "ValueSerieSaver", "ValuePrinterAndSaver", "ValueSeriePrinterAndSaver", "ValueGnuPlotter", "ValueSerieGnuPlotter")),
                                                    ValuePrinter = BLOC (condition = " Template == 'ValuePrinter' ",
                                                        ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "print info,var[-1]" ),
                                                    ),
                                                    ValueSeriePrinter = BLOC (condition = " Template == 'ValueSeriePrinter' ",
                                                        ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "print info,var[:]" ),
                                                    ),
+                                                   ValueSaver = BLOC (condition = " Template == 'ValueSaver' ",
+                                                       ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "import numpy,re\\nv=numpy.array((var[-1]))\\nglobal istep\\ntry:\\n    istep += 1\\nexcept:\\n    istep = 0\\nf='/tmp/value_%s_%05i.txt'%(info,istep)\\nf=re.sub('\\s','_',f)\\nprint 'Value saved in \\"%s\\"'%f\\nnumpy.savetxt(f,v)" ),
+                                                   ),
+                                                   ValueSerieSaver = BLOC (condition = " Template == 'ValueSerieSaver' ",
+                                                       ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "import numpy,re\\nv=numpy.array((var[:])) \\nglobal istep\\ntry:\\n    istep += 1\\nexcept:\\n    istep = 0\\nf='/tmp/value_%s_%05i.txt'%(info,istep)\\nf=re.sub('\\s','_',f)\\nprint 'Value saved in \\"%s\\"'%f\\nnumpy.savetxt(f,v)" ),
+                                                   ),
+                                                   ValuePrinterAndSaver = BLOC (condition = " Template == 'ValuePrinterAndSaver' ",
+                                                       ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "import numpy,re\\nv=numpy.array((var[-1]))\\nprint info,v\\nglobal istep\\ntry:\\n    istep += 1\\nexcept:\\n    istep = 0\\nf='/tmp/value_%s_%05i.txt'%(info,istep)\\nf=re.sub('\\s','_',f)\\nprint 'Value saved in \\"%s\\"'%f\\nnumpy.savetxt(f,v)" ),
+                                                   ),
+                                                   ValueSeriePrinterAndSaver = BLOC (condition = " Template == 'ValueSeriePrinterAndSaver' ",
+                                                       ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "import numpy,re\\nv=numpy.array((var[:])) \\nprint info,v\\nglobal istep\\ntry:\\n    istep += 1\\nexcept:\\n    istep = 0\\nf='/tmp/value_%s_%05i.txt'%(info,istep)\\nf=re.sub('\\s','_',f)\\nprint 'Value saved in \\"%s\\"'%f\\nnumpy.savetxt(f,v)" ),
+                                                   ),
                                                    ValueGnuPlotter = BLOC (condition = " Template == 'ValueGnuPlotter' ",
-                                                       ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "import Gnuplot\\nglobal nfig,gp\\ntry:\\n    nfig += 1\\n    gp('set style data lines')\\nexcept:\\n    nfig = 0\\n    gp = Gnuplot.Gnuplot(persist=1)\\n    gp('set style data lines')\\ngp('set title  \\"'+str(info)+' (Figure %i)\\"'%nfig)\\ngp.plot( Gnuplot.Data( var[-1], with_='lines lw 2' ) )" ),
+                                                       ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "import Gnuplot\\nglobal ifig,gp\\ntry:\\n    ifig += 1\\n    gp('set style data lines')\\nexcept:\\n    ifig = 0\\n    gp = Gnuplot.Gnuplot(persist=1)\\n    gp('set style data lines')\\ngp('set title  \\"%s (Figure %i)\\"'%(info,ifig))\\ngp.plot( Gnuplot.Data( var[-1], with_='lines lw 2' ) )" ),
                                                    ),
                                                    ValueSerieGnuPlotter = BLOC (condition = " Template == 'ValueSerieGnuPlotter' ",
-                                                       ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "import Gnuplot\\nglobal nfig,gp\\ntry:\\n    nfig += 1\\n    gp('set style data lines')\\nexcept:\\n    nfig = 0\\n    gp = Gnuplot.Gnuplot(persist=1)\\n    gp('set style data lines')\\ngp('set title  \\"'+str(info)+' (Figure %i)\\"'%nfig)\\ngp.plot( Gnuplot.Data( var[:], with_='lines lw 2' ) )" ),
+                                                       ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "import Gnuplot\\nglobal ifig,gp\\ntry:\\n    ifig += 1\\n    gp('set style data lines')\\nexcept:\\n    ifig = 0\\n    gp = Gnuplot.Gnuplot(persist=1)\\n    gp('set style data lines')\\ngp('set title  \\"%s (Figure %i)\\"'%(info,ifig))\\ngp.plot( Gnuplot.Data( var[:], with_='lines lw 2' ) )" ),
                                                    ),
                                                ),
                                            ),
index d1bcd293a4581c46c67e9bce9072aa6d4ecda4b4..3ce44bd155b74176ca550954a0a5189a4e80ff80 100644 (file)
@@ -277,6 +277,13 @@ class AdaoGenerator(PythonGenerator):
       self.text_da += "Analysis_config['From'] = 'Script'\n"
       self.text_da += "Analysis_config['Data'] = '" + data + "'\n"
       self.text_da += "study_config['UserPostAnalysis'] = Analysis_config\n"
+    elif from_type == "Template":
+      tmpl = self.dictMCVal["__"+self.type_of_study+"__UserPostAnalysis__TEMPLATE_DATA__Template"]
+      data = self.dictMCVal["__"+self.type_of_study+"__UserPostAnalysis__TEMPLATE_DATA__%s__ValueTemplate"%tmpl]
+      self.text_da += "Analysis_config = {}\n"
+      self.text_da += "Analysis_config['From'] = 'String'\n"
+      self.text_da += "Analysis_config['Data'] = \"\"\"" + data + "\"\"\"\n"
+      self.text_da += "study_config['UserPostAnalysis'] = Analysis_config\n"
     else:
       raise Exception('From Type unknown', from_type)
 
index c5207081be03122dcbaaa22139b41ce265d3865d..8b6d78792f3c8e05b042da17ac7c2052d16681e9 100644 (file)
@@ -208,9 +208,9 @@ StoredAssimData = ["Vector", "VectorSerie", "Matrix", "ScalarSparseMatrix", "Dia
 
 # Assimilation optional nodes
 OptDict = {}
-OptDict["UserPostAnalysis"]   = ["String", "Script"]
+OptDict["UserPostAnalysis"]   = ["String", "Script", "Template"]
 OptDefaultDict = {}
-OptDefaultDict["UserPostAnalysis"]   = "Script"
+OptDefaultDict["UserPostAnalysis"]   = "Template"
 
 # Observers
 ObserversList = [