From e9f972bc3fff75d576075d1fd6f92810f35d7f01 Mon Sep 17 00:00:00 2001 From: Jean-Philippe ARGAUD Date: Fri, 14 Jun 2013 14:20:01 +0200 Subject: [PATCH] Adding editable observer templates --- bin/AdaoCatalogGenerator.py | 36 ++++++++++++++++++++++----------- resources/ADAOSchemaCatalog.xml | 11 ++-------- src/daEficas/generator_adao.py | 8 ++++++++ 3 files changed, 34 insertions(+), 21 deletions(-) diff --git a/bin/AdaoCatalogGenerator.py b/bin/AdaoCatalogGenerator.py index c688365..aec9be4 100644 --- a/bin/AdaoCatalogGenerator.py +++ b/bin/AdaoCatalogGenerator.py @@ -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 = """ diff --git a/resources/ADAOSchemaCatalog.xml b/resources/ADAOSchemaCatalog.xml index 26a4393..b8e8ebd 100644 --- a/resources/ADAOSchemaCatalog.xml +++ b/resources/ADAOSchemaCatalog.xml @@ -586,20 +586,13 @@ for param in data["specificParameters"]: - + - + diff --git a/src/daEficas/generator_adao.py b/src/daEficas/generator_adao.py index 3e52568..d1bcd29 100644 --- a/src/daEficas/generator_adao.py +++ b/src/daEficas/generator_adao.py @@ -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"] -- 2.39.2