]> SALOME platform Git repositories - modules/adao.git/commitdiff
Salome HOME
Adding init node for observers
authorAndré Ribes <andre.ribes@edf.fr>
Wed, 7 Mar 2012 08:44:03 +0000 (09:44 +0100)
committerAndré Ribes <andre.ribes@edf.fr>
Wed, 7 Mar 2012 08:44:03 +0000 (09:44 +0100)
resources/ADAOSchemaCatalog.xml
src/daSalome/daYacsSchemaCreator/methods.py

index 7d645188bb9502fd5419010409c9d8bd4c9882c4..83187443e7b8edefd3af4fd5a092d941cdbefc59 100644 (file)
@@ -175,6 +175,8 @@ Study = assim_study
     <inport name="InputVariablesSizes" type="intvec"/>
     <inport name="OutputVariablesNames" type="stringvec"/>
     <inport name="OutputVariablesSizes" type="intvec"/>
+    <inport name="has_observers" type="bool"/>
+    <inport name="observers" type="pyobj"/>
     <outport name="Study" type="pyobj"/>
   </inline>
 
@@ -395,4 +397,12 @@ output["errorMessage"]        = ""
 ]]></code></script>
     <outport name="output" type="SALOME_TYPES/ParametricOutput"/>
   </inline>
+
+  <inline name="SetObserversNode">
+    <script><code><![CDATA[
+print "Setting observers"
+]]></code></script>
+    <outport name="has_observers" type="bool"/>
+    <outport name="observers" type="pyobj"/>
+  </inline>
 </proc>
index 4c672c75967b98810c88a8c41eb23a22395d49df..3750d59e8f17171d04080ba5dcb12a1e3c8d706f 100644 (file)
@@ -89,6 +89,27 @@ def create_yacs_proc(study_config):
 
   proc.edAddChild(CAS_node)
 
+
+  # Adding an observer init node if an user defines some
+  factory_init_observers_node = catalogAd.getNodeFromNodeMap("SetObserversNode")
+  init_observers_node = factory_init_observers_node.cloneNode("SetObservers")
+  if "Observers" in study_config.keys():
+    node_script = init_observers_node.getScript()
+    node_script += "has_observers = True\n"
+    node_script += "observers = " + str(study_config["Observers"]) + "\n"
+    init_observers_node.setScript(node_script)
+    proc.edAddChild(init_observers_node)
+    proc.edAddDFLink(init_observers_node.getOutputPort("has_observers"), CAS_node.getInputPort("has_observers"))
+    proc.edAddDFLink(init_observers_node.getOutputPort("observers"), CAS_node.getInputPort("observers"))
+  else:
+    node_script = init_observers_node.getScript()
+    node_script += "has_observers = False\n"
+    node_script += "observers = \"\"\n"
+    init_observers_node.setScript(node_script)
+    proc.edAddChild(init_observers_node)
+    proc.edAddDFLink(init_observers_node.getOutputPort("has_observers"), CAS_node.getInputPort("has_observers"))
+    proc.edAddDFLink(init_observers_node.getOutputPort("observers"), CAS_node.getInputPort("observers"))
+
   # Step 0.5: Find if there is a user init node
   init_config = {}
   init_config["Target"] = []