1 # -*- coding: utf-8 -*-
3 # Copyright (C) 2008-2024 EDF R&D
5 # This file is part of SALOME ADAO module
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License.
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this library; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 # Author: André Ribes, andre.ribes@edf.fr, EDF R&D
25 from generator.generator_python import PythonGenerator
30 Retourne les informations necessaires pour le chargeur de plugins
32 Ces informations sont retournees dans un dictionnaire
37 # La factory pour creer une instance du plugin
38 'factory' : AdaoGenerator,
41 class AdaoGenerator(PythonGenerator):
43 def __init__(self,cr=None):
44 PythonGenerator.__init__(self, cr)
48 self.text_da_status = False
49 self.logger = logging.getLogger('ADAO EFICAS GENERATOR')
50 self.logger.setLevel(logging.INFO)
51 ch = logging.StreamHandler()
52 ch.setLevel(logging.INFO)
53 formatter = logging.Formatter("%(name)s - %(levelname)s - %(message)s")
54 ch.setFormatter(formatter)
55 self.logger.addHandler(ch)
57 def gener(self,obj,format='brut',config=None,appliEficas=None):
58 self.logger.debug("method gener called")
59 self.text_comm = PythonGenerator.gener(self, obj, format, config, appliEficas)
60 for key, value in self.dictMCVal.items():
61 self.logger.debug("dictMCVAl %s %s" % (key,value))
64 self.text_da_status = False
66 self.text_da_status = True
68 self.logger.debug("EFICAS case is not valid, python command file for YACS schema generation cannot be created")
69 self.logger.debug(self.text_da)
71 # import traceback ; traceback.print_exc()
74 def writeDefault(self, fn):
75 if self.text_da_status:
76 self.logger.debug("write adao python command file")
77 filename = fn[:fn.rfind(".")] + '.py'
78 #~ f = open( str(filename), 'wb')
79 f = open( str(filename), 'w')
80 f.write( self.text_da )
83 def generMCSIMP(self,obj) :
85 Convertit un objet MCSIMP en texte python
88 for i in obj.getGenealogie() :
90 self.dictMCVal[clef]=obj.valeur
92 s=PythonGenerator.generMCSIMP(self,obj)
95 def generate_da(self):
97 self.text_da += "#-*- coding: utf-8 -*-\n"
98 self.text_da += "study_config = {}\n"
100 # Extraction de Study_type
101 if "__CHECKING_STUDY__StudyName" in self.dictMCVal.keys():
102 self.type_of_study = "CHECKING_STUDY"
103 self.text_da += "study_config['StudyType'] = '\"CHECKING_STUDY\"'\n"
104 elif "__OPTIMIZATION_STUDY__StudyName" in self.dictMCVal.keys():
105 self.type_of_study = "OPTIMIZATION_STUDY"
106 self.text_da += "study_config['StudyType'] = '\"ASSIMILATION_STUDY\"'\n"
107 elif "__REDUCTION_STUDY__StudyName" in self.dictMCVal.keys():
108 self.type_of_study = "REDUCTION_STUDY"
109 self.text_da += "study_config['StudyType'] = '\"ASSIMILATION_STUDY\"'\n"
111 self.type_of_study = "ASSIMILATION_STUDY"
112 self.text_da += "study_config['StudyType'] = '\"ASSIMILATION_STUDY\"'\n"
114 # Extraction de StudyName
115 self.text_da += "study_config['Name'] = '" + self.dictMCVal["__"+self.type_of_study+"__StudyName"] + "'\n"
116 # Extraction de Debug
117 if "__"+self.type_of_study+"__Debug" in self.dictMCVal.keys():
118 self.text_da += "study_config['Debug'] = '" + str(self.dictMCVal["__"+self.type_of_study+"__Debug"]) + "'\n"
120 self.text_da += "study_config['Debug'] = '0'\n"
122 # Extraction de Algorithm et de ses parametres
123 if "__"+self.type_of_study+"__AlgorithmParameters__Algorithm" in self.dictMCVal.keys():
124 self.text_da += "study_config['Algorithm'] = '" + self.dictMCVal["__"+self.type_of_study+"__AlgorithmParameters__Algorithm"] + "'\n"
125 self.add_AlgorithmParameters()
126 elif "__"+self.type_of_study+"__Algorithm" in self.dictMCVal.keys():
127 self.text_da += "study_config['Algorithm'] = '" + self.dictMCVal["__"+self.type_of_study+"__Algorithm"] + "'\n"
129 if "__"+self.type_of_study+"__Background__INPUT_TYPE" in self.dictMCVal.keys():
130 self.add_data("Background")
131 if "__"+self.type_of_study+"__BackgroundError__INPUT_TYPE" in self.dictMCVal.keys():
132 self.add_data("BackgroundError")
133 if "__"+self.type_of_study+"__Observation__INPUT_TYPE" in self.dictMCVal.keys():
134 self.add_data("Observation")
135 if "__"+self.type_of_study+"__ObservationError__INPUT_TYPE" in self.dictMCVal.keys():
136 self.add_data("ObservationError")
137 if "__"+self.type_of_study+"__CheckingPoint__INPUT_TYPE" in self.dictMCVal.keys():
138 self.add_data("CheckingPoint")
139 if "__"+self.type_of_study+"__ObservationOperator__INPUT_TYPE" in self.dictMCVal.keys():
140 self.add_data("ObservationOperator")
141 if "__"+self.type_of_study+"__EvolutionModel__INPUT_TYPE" in self.dictMCVal.keys():
142 self.add_data("EvolutionModel")
143 if "__"+self.type_of_study+"__EvolutionError__INPUT_TYPE" in self.dictMCVal.keys():
144 self.add_data("EvolutionError")
145 if "__"+self.type_of_study+"__ControlInput__INPUT_TYPE" in self.dictMCVal.keys():
146 self.add_data("ControlInput")
149 # Parametres optionnels
151 # Extraction du StudyRepertory
152 if "__"+self.type_of_study+"__StudyRepertory" in self.dictMCVal.keys():
153 self.text_da += "study_config['Repertory'] = '" + self.dictMCVal["__"+self.type_of_study+"__StudyRepertory"] + "'\n"
155 # Extraction du ExecuteInContainer
156 if "__"+self.type_of_study+"__ExecuteInContainer" in self.dictMCVal.keys():
157 self.text_da += "study_config['ExecuteInContainer'] = '" + str(self.dictMCVal["__"+self.type_of_study+"__ExecuteInContainer"]) + "'\n"
159 self.text_da += "study_config['ExecuteInContainer'] = 'No'\n"
161 # Extraction de UserPostAnalysis
162 if "__"+self.type_of_study+"__UserPostAnalysis__FROM" in self.dictMCVal.keys():
163 self.add_UserPostAnalysis()
164 if "__"+self.type_of_study+"__UserDataInit__INIT_FILE" in self.dictMCVal.keys():
166 if "__"+self.type_of_study+"__Observers__SELECTION" in self.dictMCVal.keys():
169 def add_data(self, data_name):
171 # Extraction des donnees
172 search_text = "__"+self.type_of_study+"__" + data_name + "__"
173 data_type = self.dictMCVal[search_text + "INPUT_TYPE"]
174 search_type = search_text + data_type + "__data__"
175 from_type = self.dictMCVal[search_type + "FROM"]
177 if from_type == "String":
178 data = self.dictMCVal[search_type + "STRING_DATA__STRING"]
179 elif from_type == "Script":
180 data = self.dictMCVal[search_type + "SCRIPT_DATA__SCRIPT_FILE"]
181 elif from_type == "DataFile":
182 data = self.dictMCVal[search_type + "DATA_DATA__DATA_FILE"]
183 elif from_type == "ScriptWithSwitch":
184 data = self.dictMCVal[search_type + "SCRIPTWITHSWITCH_DATA__SCRIPTWITHSWITCH_FILE"]
185 elif from_type == "ScriptWithFunctions":
186 data = self.dictMCVal[search_type + "SCRIPTWITHFUNCTIONS_DATA__SCRIPTWITHFUNCTIONS_FILE"]
187 elif from_type == "ScriptWithOneFunction":
188 data = self.dictMCVal[search_type + "SCRIPTWITHONEFUNCTION_DATA__SCRIPTWITHONEFUNCTION_FILE"]
189 elif from_type == "FunctionDict":
190 data = self.dictMCVal[search_type + "FUNCTIONDICT_DATA__FUNCTIONDICT_FILE"]
192 raise Exception('From Type unknown', from_type)
194 if from_type == "String" or from_type == "Script" or from_type == "DataFile":
195 self.text_da += data_name + "_config = {}\n"
196 self.text_da += data_name + "_config['Type'] = '" + data_type + "'\n"
197 self.text_da += data_name + "_config['From'] = '" + from_type + "'\n"
198 self.text_da += data_name + "_config['Data'] = '" + data + "'\n"
199 if search_text+"Stored" in self.dictMCVal.keys():
200 self.text_da += data_name + "_config['Stored'] = '" + str(self.dictMCVal[search_text+"Stored"]) + "'\n"
201 if search_type+"DATA_DATA__ColMajor" in self.dictMCVal.keys():
202 self.text_da += data_name + "_config['ColMajor'] = '" + str(self.dictMCVal[search_type+"DATA_DATA__ColMajor"]) + "'\n"
203 self.text_da += "study_config['" + data_name + "'] = " + data_name + "_config\n"
205 if from_type == "ScriptWithSwitch":
206 self.text_da += data_name + "_ScriptWithSwitch = {}\n"
207 self.text_da += data_name + "_ScriptWithSwitch['Function'] = ['Direct', 'Tangent', 'Adjoint']\n"
208 self.text_da += data_name + "_ScriptWithSwitch['Script'] = {}\n"
209 self.text_da += data_name + "_ScriptWithSwitch['Script']['Direct'] = '" + data + "'\n"
210 self.text_da += data_name + "_ScriptWithSwitch['Script']['Tangent'] = '" + data + "'\n"
211 self.text_da += data_name + "_ScriptWithSwitch['Script']['Adjoint'] = '" + data + "'\n"
212 self.text_da += data_name + "_config = {}\n"
213 self.text_da += data_name + "_config['Type'] = 'Function'\n"
214 self.text_da += data_name + "_config['From'] = 'ScriptWithSwitch'\n"
215 self.text_da += data_name + "_config['Data'] = " + data_name + "_ScriptWithSwitch\n"
216 self.text_da += "study_config['" + data_name + "'] = " + data_name + "_config\n"
218 if from_type == "ScriptWithFunctions":
219 self.text_da += data_name + "_ScriptWithFunctions = {}\n"
220 self.text_da += data_name + "_ScriptWithFunctions['Function'] = ['Direct', 'Tangent', 'Adjoint']\n"
221 self.text_da += data_name + "_ScriptWithFunctions['Script'] = {}\n"
222 self.text_da += data_name + "_ScriptWithFunctions['Script']['Direct'] = '" + data + "'\n"
223 self.text_da += data_name + "_ScriptWithFunctions['Script']['Tangent'] = '" + data + "'\n"
224 self.text_da += data_name + "_ScriptWithFunctions['Script']['Adjoint'] = '" + data + "'\n"
225 self.text_da += data_name + "_config = {}\n"
226 self.text_da += data_name + "_config['Type'] = 'Function'\n"
227 self.text_da += data_name + "_config['From'] = 'ScriptWithFunctions'\n"
228 self.text_da += data_name + "_config['Data'] = " + data_name + "_ScriptWithFunctions\n"
229 self.text_da += "study_config['" + data_name + "'] = " + data_name + "_config\n"
231 if from_type == "ScriptWithOneFunction":
232 self.text_da += data_name + "_ScriptWithOneFunction = {}\n"
233 self.text_da += data_name + "_ScriptWithOneFunction['Function'] = ['Direct', 'Tangent', 'Adjoint']\n"
234 self.text_da += data_name + "_ScriptWithOneFunction['Script'] = {}\n"
235 self.text_da += data_name + "_ScriptWithOneFunction['Script']['Direct'] = '" + data + "'\n"
236 self.text_da += data_name + "_ScriptWithOneFunction['Script']['Tangent'] = '" + data + "'\n"
237 self.text_da += data_name + "_ScriptWithOneFunction['Script']['Adjoint'] = '" + data + "'\n"
238 self.text_da += data_name + "_ScriptWithOneFunction['DifferentialIncrement'] = " + str(float(self.dictMCVal[search_type + "SCRIPTWITHONEFUNCTION_DATA__DifferentialIncrement"])) + "\n"
239 self.text_da += data_name + "_ScriptWithOneFunction['CenteredFiniteDifference'] = " + str(self.dictMCVal[search_type + "SCRIPTWITHONEFUNCTION_DATA__CenteredFiniteDifference"]) + "\n"
240 if search_type + "SCRIPTWITHONEFUNCTION_DATA__EnableMultiProcessing" in self.dictMCVal.keys():
241 self.text_da += data_name + "_ScriptWithOneFunction['EnableWiseParallelism'] = " + str(self.dictMCVal[search_type + "SCRIPTWITHONEFUNCTION_DATA__EnableMultiProcessing"]) + "\n"
242 if search_type + "SCRIPTWITHONEFUNCTION_DATA__EnableWiseParallelism" in self.dictMCVal.keys():
243 self.text_da += data_name + "_ScriptWithOneFunction['EnableWiseParallelism'] = " + str(self.dictMCVal[search_type + "SCRIPTWITHONEFUNCTION_DATA__EnableWiseParallelism"]) + "\n"
244 if search_type + "SCRIPTWITHONEFUNCTION_DATA__NumberOfProcesses" in self.dictMCVal.keys():
245 self.text_da += data_name + "_ScriptWithOneFunction['NumberOfProcesses'] = " + str(self.dictMCVal[search_type + "SCRIPTWITHONEFUNCTION_DATA__NumberOfProcesses"]) + "\n"
246 self.text_da += data_name + "_config = {}\n"
247 self.text_da += data_name + "_config['Type'] = 'Function'\n"
248 self.text_da += data_name + "_config['From'] = 'ScriptWithOneFunction'\n"
249 self.text_da += data_name + "_config['Data'] = " + data_name + "_ScriptWithOneFunction\n"
250 self.text_da += "study_config['" + data_name + "'] = " + data_name + "_config\n"
252 if from_type == "FunctionDict":
253 self.text_da += data_name + "_FunctionDict = {}\n"
254 self.text_da += data_name + "_FunctionDict['Function'] = ['Direct', 'Tangent', 'Adjoint']\n"
255 self.text_da += data_name + "_FunctionDict['Script'] = {}\n"
256 self.text_da += data_name + "_FunctionDict['Script']['Direct'] = '" + data + "'\n"
257 self.text_da += data_name + "_FunctionDict['Script']['Tangent'] = '" + data + "'\n"
258 self.text_da += data_name + "_FunctionDict['Script']['Adjoint'] = '" + data + "'\n"
259 self.text_da += data_name + "_config = {}\n"
260 self.text_da += data_name + "_config['Type'] = 'Function'\n"
261 self.text_da += data_name + "_config['From'] = 'FunctionDict'\n"
262 self.text_da += data_name + "_config['Data'] = " + data_name + "_FunctionDict\n"
263 self.text_da += "study_config['" + data_name + "'] = " + data_name + "_config\n"
267 init_file_data = self.dictMCVal["__"+self.type_of_study+"__UserDataInit__INIT_FILE"]
268 init_target_list = self.dictMCVal["__"+self.type_of_study+"__UserDataInit__TARGET_LIST"]
270 self.text_da += "Init_config = {}\n"
271 self.text_da += "Init_config['Type'] = 'Dict'\n"
272 self.text_da += "Init_config['From'] = 'Script'\n"
273 self.text_da += "Init_config['Data'] = '" + init_file_data + "'\n"
274 self.text_da += "Init_config['Target'] = ["
275 if isinstance(init_target_list, "str"):
276 self.text_da += "'" + init_target_list + "',"
278 for target in init_target_list:
279 self.text_da += "'" + target + "',"
280 self.text_da += "]\n"
281 self.text_da += "study_config['UserDataInit'] = Init_config\n"
283 def add_UserPostAnalysis(self):
285 from_type = self.dictMCVal["__"+self.type_of_study+"__UserPostAnalysis__FROM"]
287 if from_type == "String":
288 data = self.dictMCVal["__"+self.type_of_study+"__UserPostAnalysis__STRING_DATA__STRING"]
289 self.text_da += "Analysis_config = {}\n"
290 self.text_da += "Analysis_config['From'] = 'String'\n"
291 self.text_da += "Analysis_config['Data'] = \"\"\"" + data + "\"\"\"\n"
292 self.text_da += "study_config['UserPostAnalysis'] = Analysis_config\n"
293 elif from_type == "Script":
294 data = self.dictMCVal["__"+self.type_of_study+"__UserPostAnalysis__SCRIPT_DATA__SCRIPT_FILE"]
295 self.text_da += "Analysis_config = {}\n"
296 self.text_da += "Analysis_config['From'] = 'Script'\n"
297 self.text_da += "Analysis_config['Data'] = '" + data + "'\n"
298 self.text_da += "study_config['UserPostAnalysis'] = Analysis_config\n"
299 elif from_type == "Template":
300 tmpl = self.dictMCVal["__"+self.type_of_study+"__UserPostAnalysis__TEMPLATE_DATA__Template"]
301 data = self.dictMCVal["__"+self.type_of_study+"__UserPostAnalysis__TEMPLATE_DATA__%s__ValueTemplate"%tmpl]
302 self.text_da += "Analysis_config = {}\n"
303 self.text_da += "Analysis_config['From'] = 'String'\n"
304 self.text_da += "Analysis_config['Data'] = \"\"\"" + data + "\"\"\"\n"
305 self.text_da += "study_config['UserPostAnalysis'] = Analysis_config\n"
307 raise Exception('From Type unknown', from_type)
309 def add_AlgorithmParameters(self):
311 data_name = "AlgorithmParameters"
314 if "__"+self.type_of_study+"__AlgorithmParameters__Parameters" in self.dictMCVal:
315 para_type = self.dictMCVal["__"+self.type_of_study+"__AlgorithmParameters__Parameters"]
317 para_type = "Defaults"
319 if para_type == "Defaults":
320 from_type = para_type
321 elif para_type == "Dict":
322 from_type = self.dictMCVal["__"+self.type_of_study+"__AlgorithmParameters__Dict__data__FROM"]
326 if from_type == "Script":
327 data = self.dictMCVal["__"+self.type_of_study+"__AlgorithmParameters__Dict__data__SCRIPT_DATA__SCRIPT_FILE"]
328 self.text_da += data_name + "_config = {}\n"
329 self.text_da += data_name + "_config['Type'] = '" + data_type + "'\n"
330 self.text_da += data_name + "_config['From'] = '" + from_type + "'\n"
331 self.text_da += data_name + "_config['Data'] = '" + data + "'\n"
332 self.text_da += "study_config['" + data_name + "'] = " + data_name + "_config\n"
333 elif from_type == "String":
334 data = self.dictMCVal["__"+self.type_of_study+"__AlgorithmParameters__Dict__data__STRING_DATA__STRING"]
335 self.text_da += data_name + "_config = {}\n"
336 self.text_da += data_name + "_config['Type'] = '" + data_type + "'\n"
337 self.text_da += data_name + "_config['From'] = '" + from_type + "'\n"
338 self.text_da += data_name + "_config['Data'] = '" + data + "'\n"
339 self.text_da += "study_config['" + data_name + "'] = " + data_name + "_config\n"
340 elif from_type == "Defaults":
341 base = "__"+self.type_of_study+"__AlgorithmParameters__Parameters"
342 keys = [k for k in self.dictMCVal.keys() if base in k]
343 if base in keys: keys.remove(base)
344 keys = [k.replace(base,'') for k in keys]
347 key = k.split('__')[-1]
348 val = self.dictMCVal[base+k]
349 # print key," = ",val," ",type(val)
350 if isinstance(val, str) and key == "SetSeed":
351 data += '"%s":%s,'%(key,int(val))
352 elif isinstance(val, str) and not (val.count('[')>=2 or val.count('(')>=2):
353 data += '"%s":"%s",'%(key,val)
355 data += '"%s":%s,'%(key,val)
356 data = data.replace("'",'"')
359 self.text_da += data_name + "_config = {}\n"
360 self.text_da += data_name + "_config['Type'] = '" + data_type + "'\n"
361 self.text_da += data_name + "_config['From'] = 'String'\n"
362 self.text_da += data_name + "_config['Data'] = '" + data + "'\n"
363 self.text_da += "study_config['" + data_name + "'] = " + data_name + "_config\n"
365 def add_variables(self):
368 if "__"+self.type_of_study+"__InputVariables__NAMES" in self.dictMCVal.keys():
371 if isinstance(self.dictMCVal["__"+self.type_of_study+"__InputVariables__NAMES"], type("")):
372 names.append(self.dictMCVal["__"+self.type_of_study+"__InputVariables__NAMES"])
374 names = self.dictMCVal["__"+self.type_of_study+"__InputVariables__NAMES"]
375 if isinstance(self.dictMCVal["__"+self.type_of_study+"__InputVariables__SIZES"], type(1)):
376 sizes.append(self.dictMCVal["__"+self.type_of_study+"__InputVariables__SIZES"])
378 sizes = self.dictMCVal["__"+self.type_of_study+"__InputVariables__SIZES"]
380 self.text_da += "inputvariables_config = {}\n"
381 self.text_da += "inputvariables_config['Order'] = %s\n" % list(names)
382 for name, size in zip(names, sizes):
383 self.text_da += "inputvariables_config['%s'] = %s\n" % (name,size)
384 self.text_da += "study_config['InputVariables'] = inputvariables_config\n"
386 self.text_da += "inputvariables_config = {}\n"
387 self.text_da += "inputvariables_config['Order'] =['adao_default']\n"
388 self.text_da += "inputvariables_config['adao_default'] = -1\n"
389 self.text_da += "study_config['InputVariables'] = inputvariables_config\n"
392 if "__"+self.type_of_study+"__OutputVariables__NAMES" in self.dictMCVal.keys():
395 if isinstance(self.dictMCVal["__"+self.type_of_study+"__OutputVariables__NAMES"], type("")):
396 names.append(self.dictMCVal["__"+self.type_of_study+"__OutputVariables__NAMES"])
398 names = self.dictMCVal["__"+self.type_of_study+"__OutputVariables__NAMES"]
399 if isinstance(self.dictMCVal["__"+self.type_of_study+"__OutputVariables__SIZES"], type(1)):
400 sizes.append(self.dictMCVal["__"+self.type_of_study+"__OutputVariables__SIZES"])
402 sizes = self.dictMCVal["__"+self.type_of_study+"__OutputVariables__SIZES"]
404 self.text_da += "outputvariables_config = {}\n"
405 self.text_da += "outputvariables_config['Order'] = %s\n" % list(names)
406 for name, size in zip(names, sizes):
407 self.text_da += "outputvariables_config['%s'] = %s\n" % (name,size)
408 self.text_da += "study_config['OutputVariables'] = outputvariables_config\n"
410 self.text_da += "outputvariables_config = {}\n"
411 self.text_da += "outputvariables_config['Order'] = ['adao_default']\n"
412 self.text_da += "outputvariables_config['adao_default'] = -1\n"
413 self.text_da += "study_config['OutputVariables'] = outputvariables_config\n"
415 def add_observers(self):
417 observer = self.dictMCVal["__"+self.type_of_study+"__Observers__SELECTION"]
418 if isinstance(observer, type("")):
419 self.add_observer_in_dict(observer, observers)
421 for observer in self.dictMCVal["__"+self.type_of_study+"__Observers__SELECTION"]:
422 self.add_observer_in_dict(observer, observers)
424 # Write observers in the python command file
426 self.text_da += "observers = {}\n"
427 for observer in observers.keys():
429 self.text_da += "observers[\"" + observer + "\"] = {}\n"
430 self.text_da += "observers[\"" + observer + "\"][\"number\"] = " + str(number) + "\n"
431 self.text_da += "observers[\"" + observer + "\"][\"nodetype\"] = \"" + observers[observer]["nodetype"] + "\"\n"
432 if observers[observer]["nodetype"] == "String":
433 self.text_da += "observers[\"" + observer + "\"][\"String\"] = \"\"\"" + observers[observer]["script"] + "\"\"\"\n"
434 elif observers[observer]["nodetype"] == "Template":
435 self.text_da += "observers[\"" + observer + "\"][\"String\"] = \"\"\"" + observers[observer]["script"] + "\"\"\"\n"
436 self.text_da += "observers[\"" + observer + "\"][\"Template\"] = \"\"\"" + observers[observer]["template"] + "\"\"\"\n"
438 self.text_da += "observers[\"" + observer + "\"][\"Script\"] = \"" + observers[observer]["file"] + "\"\n"
439 if "scheduler" in observers[observer].keys():
440 self.text_da += "observers[\"" + observer + "\"][\"scheduler\"] = \"\"\"" + observers[observer]["scheduler"] + "\"\"\"\n"
441 if "info" in observers[observer].keys():
442 self.text_da += "observers[\"" + observer + "\"][\"info\"] = \"\"\"" + observers[observer]["info"] + "\"\"\"\n"
443 self.text_da += "study_config['Observers'] = observers\n"
445 def add_observer_in_dict(self, observer, observers):
447 Add observer in the observers dict.
449 observers[observer] = {}
450 observers[observer]["name"] = observer
451 observer_eficas_name = "__"+self.type_of_study+"__Observers__" + observer + "__" + observer + "_data__"
453 node_type_key_name = observer_eficas_name + "NodeType"
454 observers[observer]["nodetype"] = self.dictMCVal[node_type_key_name]
456 # NodeType script/file
457 if observers[observer]["nodetype"] == "String":
458 observers[observer]["script"] = self.dictMCVal[observer_eficas_name + "PythonScript__Value"]
459 elif observers[observer]["nodetype"] == "Template":
460 observers[observer]["nodetype"] = "String"
461 observer_template_key = observer_eficas_name + "ObserverTemplate__"
462 observers[observer]["template"] = self.dictMCVal[observer_template_key + "Template"]
463 observers[observer]["script"] = self.dictMCVal[observer_template_key + observers[observer]["template"] + "__ValueTemplate"]
465 observers[observer]["file"] = self.dictMCVal[observer_eficas_name + "UserFile__Value"]
468 scheduler_key_name = observer_eficas_name + "Scheduler"
469 if scheduler_key_name in self.dictMCVal.keys():
470 observers[observer]["scheduler"] = self.dictMCVal[scheduler_key_name]
473 info_key_name = observer_eficas_name + "Info"
474 if info_key_name in self.dictMCVal.keys():
475 observers[observer]["info"] = self.dictMCVal[info_key_name]