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 = """
</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"/>
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():
# 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"]