From 67a965c6d8e540e2c16390a6235567304cefae5f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20Ribes?= Date: Tue, 27 Mar 2012 15:35:49 +0200 Subject: [PATCH] String et Script pour les observers --- bin/AdaoCatalogGenerator.py | 8 +++---- examples/daSalome/test006_Observers.comm.in | 4 ++-- src/daEficas/generator_adao.py | 8 +++---- .../daGUI/daGuiImpl/adaoStudyEditor.py | 2 +- .../daYacsSchemaCreator/help_methods.py | 24 +++++++++---------- src/daSalome/daYacsSchemaCreator/methods.py | 8 +++---- 6 files changed, 27 insertions(+), 27 deletions(-) diff --git a/bin/AdaoCatalogGenerator.py b/bin/AdaoCatalogGenerator.py index 4e5675d..941d1dd 100644 --- a/bin/AdaoCatalogGenerator.py +++ b/bin/AdaoCatalogGenerator.py @@ -96,11 +96,11 @@ observers_choice = """ ${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=("pyscript", "userfile")), - PythonScript = BLOC (condition = " NodeType == 'pyscript' ", + 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 == 'userfile' ", + UserFile = BLOC (condition = " NodeType == 'Script' ", Value = SIMP(statut = "o", typ = "FichierNoAbs", validators=(OnlyStr())) ) ), @@ -109,7 +109,7 @@ observers_choice = """ observers_method = """ def F_Observers(statut) : return FACT(statut=statut, - SELECTION = SIMP(statut="o", defaut=[], typ="TXM", max="**", validators=NoRepeat(), into=(${choices})), + SELECTION = SIMP(statut="o", defaut=[], typ="TXM", min=0, max="**", validators=NoRepeat(), into=(${choices})), ${decl_choices} ) """ diff --git a/examples/daSalome/test006_Observers.comm.in b/examples/daSalome/test006_Observers.comm.in index f1b323c..1efe8e4 100644 --- a/examples/daSalome/test006_Observers.comm.in +++ b/examples/daSalome/test006_Observers.comm.in @@ -26,7 +26,7 @@ ASSIMILATION_STUDY(Study_name='test_observers', ('Background','BackgroundError','Observation', 'ObservationError','AlgorithmParameters',),), Observers=_F(SELECTION=('CurrentState','CostFunctionJ',), - CostFunctionJ_data=_F(NodeType='pyscript', + CostFunctionJ_data=_F(NodeType='String', Value= """print " ---> observerCost" print " var =",var.valueserie() @@ -47,5 +47,5 @@ print " imageCost %s"%filename gp.hardcopy(filename=filename, color=1) numero += 1 """,), - CurrentState_data=_F(NodeType='userfile', + CurrentState_data=_F(NodeType='Script', Value='test006_Observers_observer_with_file.py',),),); diff --git a/src/daEficas/generator_adao.py b/src/daEficas/generator_adao.py index 6ec3fe5..9673b80 100644 --- a/src/daEficas/generator_adao.py +++ b/src/daEficas/generator_adao.py @@ -275,10 +275,10 @@ class AdaoGenerator(PythonGenerator): self.text_da += "observers[\"" + observer + "\"] = {}\n" self.text_da += "observers[\"" + observer + "\"][\"number\"] = " + str(number) + "\n" self.text_da += "observers[\"" + observer + "\"][\"nodetype\"] = \"" + observers[observer]["nodetype"] + "\"\n" - if observers[observer]["nodetype"] == "pyscript": - self.text_da += "observers[\"" + observer + "\"][\"pyscript\"] = \"\"\"" + observers[observer]["script"] + "\"\"\"\n" + if observers[observer]["nodetype"] == "String": + self.text_da += "observers[\"" + observer + "\"][\"String\"] = \"\"\"" + observers[observer]["script"] + "\"\"\"\n" else: - self.text_da += "observers[\"" + observer + "\"][\"userfile\"] = \"" + observers[observer]["file"] + "\"\n" + self.text_da += "observers[\"" + observer + "\"][\"Script\"] = \"" + observers[observer]["file"] + "\"\n" if "scheduler" in observers[observer].keys(): self.text_da += "observers[\"" + observer + "\"][\"scheduler\"] = \"\"\"" + observers[observer]["scheduler"] + "\"\"\"\n" self.text_da += "study_config['Observers'] = observers\n" @@ -295,7 +295,7 @@ class AdaoGenerator(PythonGenerator): observers[observer]["nodetype"] = self.dictMCVal[node_type_key_name] # NodeType script/file - if observers[observer]["nodetype"] == "pyscript": + if observers[observer]["nodetype"] == "String": observers[observer]["script"] = self.dictMCVal[observer_eficas_name + "PythonScript__Value"] else: observers[observer]["file"] = self.dictMCVal[observer_eficas_name + "UserFile__Value"] diff --git a/src/daSalome/daGUI/daGuiImpl/adaoStudyEditor.py b/src/daSalome/daGUI/daGuiImpl/adaoStudyEditor.py index 454ce6e..ef7b8b1 100644 --- a/src/daSalome/daGUI/daGuiImpl/adaoStudyEditor.py +++ b/src/daSalome/daGUI/daGuiImpl/adaoStudyEditor.py @@ -86,7 +86,7 @@ def updateItem(salomeStudyId, salomeStudyItem, adaoCase): itemValue = adaoCase.filename else: itemName = salomeStudyItem.GetName() - itemValue = adaoCase.get_filename() + itemValue = adaoCase.filename icon = adaoModuleHelper.studyItemPixmapNOk() if adaoCase.isOk(): diff --git a/src/daSalome/daYacsSchemaCreator/help_methods.py b/src/daSalome/daYacsSchemaCreator/help_methods.py index 9879ca6..018a20d 100644 --- a/src/daSalome/daYacsSchemaCreator/help_methods.py +++ b/src/daSalome/daYacsSchemaCreator/help_methods.py @@ -136,26 +136,26 @@ def check_study(study_config): logging.fatal("An observer nodetype description must be a string") logging.fatal("Observer is %s" % obs_var) sys.exit(1) - if nodetype != "pyscript" and nodetype != "userfile": - logging.fatal("An observer nodetype must be equal to 'pyscript' or 'userfile'") + if nodetype != "String" and nodetype != "Script": + logging.fatal("An observer nodetype must be equal to 'String' or 'Script'") logging.fatal("Observer is %s" % obs_var) sys.exit(1) - if nodetype == "pyscript": - if "pyscript" not in study_config["Observers"][obs_var].keys(): - logging.fatal("An observer with nodetype pyscript must provide a pyscript") + if nodetype == "String": + if "String" not in study_config["Observers"][obs_var].keys(): + logging.fatal("An observer with nodetype String must provide a String") logging.fatal("Observer is %s" % obs_var) sys.exit(1) - if not isinstance(study_config["Observers"][obs_var]["pyscript"], type("")): - logging.fatal("An observer pyscript description must be a string") + if not isinstance(study_config["Observers"][obs_var]["String"], type("")): + logging.fatal("An observer String description must be a string") logging.fatal("Observer is %s" % obs_var) sys.exit(1) - if nodetype == "userfile": - if "userfile" not in study_config["Observers"][obs_var].keys(): - logging.fatal("An observer with nodetype userfileuserfilemust provide a pyscript") + if nodetype == "Script": + if "Script" not in study_config["Observers"][obs_var].keys(): + logging.fatal("An observer with nodetype Script provide a Script") logging.fatal("Observer is %s" % obs_var) sys.exit(1) - if not isinstance(study_config["Observers"][obs_var]["userfile"], type("")): - logging.fatal("An observer userfile description must be a string") + if not isinstance(study_config["Observers"][obs_var]["Script"], type("")): + logging.fatal("An observer Script description must be a string") logging.fatal("Observer is %s" % obs_var) sys.exit(1) if "scheduler" in study_config["Observers"][obs_var].keys(): diff --git a/src/daSalome/daYacsSchemaCreator/methods.py b/src/daSalome/daYacsSchemaCreator/methods.py index 3750d59..08c468b 100644 --- a/src/daSalome/daYacsSchemaCreator/methods.py +++ b/src/daSalome/daYacsSchemaCreator/methods.py @@ -346,19 +346,19 @@ def create_yacs_proc(study_config): proc.edAddDFLink(read_for_switch_node.getOutputPort("data"), extract_data_node.getInputPort("data")) observation_node = None - if observer_cfg["nodetype"] == "pyscript": + if observer_cfg["nodetype"] == "String": factory_observation_node = catalogAd.getNodeFromNodeMap("ObservationNodeString") observation_node = factory_observation_node.cloneNode("Observation") node_script = observation_node.getScript() - node_script += observer_cfg["pyscript"] + node_script += observer_cfg["String"] observation_node.setScript(node_script) else: factory_observation_node = catalogAd.getNodeFromNodeMap("ObservationNodeFile") observation_node = factory_observation_node.cloneNode("Observation") if repertory: - observation_node.getInputPort("script").edInitPy(os.path.join(base_repertory, os.path.basename(observer_cfg["userfile"]))) + observation_node.getInputPort("script").edInitPy(os.path.join(base_repertory, os.path.basename(observer_cfg["Script"]))) else: - observation_node.getInputPort("script").edInitPy(observer_cfg["userfile"]) + observation_node.getInputPort("script").edInitPy(observer_cfg["Script"]) observer_bloc.edAddChild(observation_node) proc.edAddDFLink(extract_data_node.getOutputPort("var"), observation_node.getInputPort("var")) proc.edAddDFLink(extract_data_node.getOutputPort("info"), observation_node.getInputPort("info")) -- 2.39.2