]> SALOME platform Git repositories - modules/adao.git/commitdiff
Salome HOME
Adding editable observer templates
authorJean-Philippe ARGAUD <jean-philippe.argaud@edf.fr>
Fri, 14 Jun 2013 12:20:01 +0000 (14:20 +0200)
committerJean-Philippe ARGAUD <jean-philippe.argaud@edf.fr>
Fri, 14 Jun 2013 12:20:01 +0000 (14:20 +0200)
bin/AdaoCatalogGenerator.py
resources/ADAOSchemaCatalog.xml
src/daEficas/generator_adao.py

index c6883653229bacf2f89fb695eede40dc01815cae..aec9be48abea9e83d5895fa05856aaaeb2668c28 100644 (file)
@@ -108,18 +108,30 @@ assim_data_choice = """
 
 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"),
-                                                             NodeType  = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "", into=("String", "Script")),
-                                                             PythonScript = BLOC (condition = " NodeType == 'String' ",
-                                                                                  Value = SIMP(statut = "o", typ = "TXM")
-                                                                                 ),
-                                                             UserFile = BLOC (condition = " NodeType == 'Script' ",
-                                                                              Value = SIMP(statut = "o", typ = "FichierNoAbs", validators=(OnlyStr()))
-                                                                             )
-                                                                      ),
-                                                          ),
+                                           ${var_name}_data = FACT(statut = "o",
+                                               Scheduler    = SIMP(statut = "f", typ = "TXM"),
+                                               Info         = SIMP(statut = "f", typ = "TXM"),
+                                               NodeType     = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "", into=("String", "Script", "Template")),
+                                               PythonScript = BLOC (condition = " NodeType == 'String' ",
+                                                   Value = SIMP(statut = "o", typ = "TXM")
+                                               ),
+                                               UserFile = BLOC (condition = " NodeType == 'Script' ",
+                                                   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", "ValueGnuPlotter", "ValueSerieGnuPlotter")),
+                                                   ValuePrinter = BLOC (condition = " Template == 'ValuePrinter' ",
+                                                       ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "print info,var[-1]" ),
+                                                   ),
+                                                   ValueGnuPlotter = BLOC (condition = " Template == 'ValueGnuPlotter' ",
+                                                       ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "import Gnuplot\\nglobal gp\\ntry:\\n    gp('set style data lines')\\nexcept:\\n    gp = Gnuplot.Gnuplot(persist=1)\\n    gp('set style data lines')\\ngp('set title  \\"'+str(info)+'\\"')\\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 gp\\ntry:\\n    gp('set style data lines')\\nexcept:\\n    gp = Gnuplot.Gnuplot(persist=1)\\n    gp('set style data lines')\\ngp('set title  \\"'+str(info)+'\\"')\\ngp.plot( Gnuplot.Data( var[:], with_='lines lw 2' ) )" ),
+                                                   ),
+                                               ),
+                                           ),
+                                       ),
 """
 
 observers_method = """
index 26a43934f04de7d375783d140cd8552144e3e4b2..b8e8ebd70fe20f229dd15c991101627e44a4aafe 100644 (file)
@@ -586,20 +586,13 @@ for param in data["specificParameters"]:
   </inline>
 
   <inline name="ObservationNodeString">
-    <script><code><![CDATA[
-#print "Entering in Observation"
-
-]]></code></script>
+    <script><code><![CDATA[]]></code></script>
     <inport name="var" type="pyobj"/>
     <inport name="info" type="pyobj"/>
   </inline>
 
   <inline name="ObservationNodeFile">
-    <script><code><![CDATA[
-#print "Entering in Observation"
-execfile(script)
-
-]]></code></script>
+    <script><code><![CDATA[execfile(script)]]></code></script>
     <inport name="var"    type="pyobj"/>
     <inport name="info"   type="pyobj"/>
     <inport name="script" type="string"/>
index 3e525681ccdb97ed8dcbca752491f2a3624582c4..d1bcd293a4581c46c67e9bce9072aa6d4ecda4b4 100644 (file)
@@ -349,6 +349,9 @@ class AdaoGenerator(PythonGenerator):
       self.text_da += "observers[\"" + observer + "\"][\"nodetype\"] = \"" + observers[observer]["nodetype"] + "\"\n"
       if observers[observer]["nodetype"] == "String":
         self.text_da += "observers[\"" + observer + "\"][\"String\"] = \"\"\"" + observers[observer]["script"] + "\"\"\"\n"
+      elif observers[observer]["nodetype"] == "Template":
+        self.text_da += "observers[\"" + observer + "\"][\"String\"] = \"\"\"" + observers[observer]["script"] + "\"\"\"\n"
+        self.text_da += "observers[\"" + observer + "\"][\"Template\"] = \"\"\"" + observers[observer]["template"] + "\"\"\"\n"
       else:
         self.text_da += "observers[\"" + observer + "\"][\"Script\"] = \"" + observers[observer]["file"] + "\"\n"
       if "scheduler" in observers[observer].keys():
@@ -371,6 +374,11 @@ class AdaoGenerator(PythonGenerator):
     # NodeType script/file
     if observers[observer]["nodetype"] == "String":
       observers[observer]["script"] = self.dictMCVal[observer_eficas_name + "PythonScript__Value"]
+    elif observers[observer]["nodetype"] == "Template":
+      observers[observer]["nodetype"] = "String"
+      observer_template_key = observer_eficas_name + "ObserverTemplate__"
+      observers[observer]["template"] = self.dictMCVal[observer_template_key + "Template"]
+      observers[observer]["script"]   = self.dictMCVal[observer_template_key + observers[observer]["template"] + "__ValueTemplate"]
     else:
       observers[observer]["file"] = self.dictMCVal[observer_eficas_name + "UserFile__Value"]