From: André Ribes Date: Wed, 7 Mar 2012 09:13:42 +0000 (+0100) Subject: Hook added X-Git-Tag: V6_5_0~25^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=32a803a44f902d2f0cedab6673788a1c278b303c;p=modules%2Fadao.git Hook added --- diff --git a/src/daSalome/daYacsIntegration/daOptimizerLoop.py b/src/daSalome/daYacsIntegration/daOptimizerLoop.py index 32a62d7..565cf4c 100644 --- a/src/daSalome/daYacsIntegration/daOptimizerLoop.py +++ b/src/daSalome/daYacsIntegration/daOptimizerLoop.py @@ -286,6 +286,12 @@ class AssimilationAlgorithm_asynch(SALOMERuntime.OptimizerAlgASync): # Set ObservationOperator self.ADD.setObservationOperator(asFunction = {"Direct":direct, "Tangent":tangent, "Adjoint":adjoint}) + # Set Observers + for observer_name in self.da_study.observers_dict.keys(): + if observers_dict[observer_name]["scheduler"] != "": + self.ADD.setDataObserver(observer_name, HookFunction=self.obs, Scheduler = observers_dict[observer_name]["scheduler"], HookParameters = observer_name) + else: + self.ADD.setDataObserver(observer_name, HookFunction=self.obs, HookParameters = observer_name) # Start Assimilation Study #print "ADD analyze" @@ -294,6 +300,11 @@ class AssimilationAlgorithm_asynch(SALOMERuntime.OptimizerAlgASync): # Assimilation Study is finished self.pool.destroyAll() + def obs(self, var, info): + print "Hook observer called with:" + print "var %s" % var + print "inof %s" % info + def getAlgoResult(self): #print "getAlgoResult" self.ADD.prepare_to_pickle() diff --git a/src/daSalome/daYacsIntegration/daStudy.py b/src/daSalome/daYacsIntegration/daStudy.py index e8feb00..8631e9b 100644 --- a/src/daSalome/daYacsIntegration/daStudy.py +++ b/src/daSalome/daYacsIntegration/daStudy.py @@ -152,9 +152,9 @@ class daStudy: self.FunctionObservationOperator[Name] = ObservationOperator def addObserver(self, name, scheduler, info): - observers_dict[name] = {} - observers_dict[name]["scheduler"] = scheduler - observers_dict[name]["info"] = info + self.observers_dict[name] = {} + self.observers_dict[name]["scheduler"] = scheduler + self.observers_dict[name]["info"] = info def getObservers(self): return self.observers_dict