Salome HOME
Minor correction for Python 3
[modules/adao.git] / src / daComposant / daCore / BasicObjects.py
index e44ff41d3db758bca737ed57b26eacf809996e8e..7de386ea829ad0637e9b3deb9f1025c8033e0209 100644 (file)
@@ -22,8 +22,6 @@
 
 """
     Définit les outils généraux élémentaires.
-
-    Ce module est destiné à être appelée par AssimilationStudy.
 """
 __author__ = "Jean-Philippe ARGAUD"
 __all__ = []
@@ -824,6 +822,9 @@ class AlgorithmAndParameters(object):
         "Permet de lancer le calcul d'assimilation"
         if FileName is None or not os.path.exists(FileName):
             raise ValueError("a YACS file name has to be given for YACS execution.\n")
+        else:
+            __file    = os.path.abspath(FileName)
+            logging.debug("The YACS file name is \"%s\"."%__file)
         if not PlatformInfo.has_salome or \
             not PlatformInfo.has_yacs or \
             not PlatformInfo.has_adao:
@@ -840,13 +841,13 @@ class AlgorithmAndParameters(object):
         xmlLoader = loader.YACSLoader()
         xmlLoader.registerProcCataLoader()
         try:
-            catalogAd = r.loadCatalog("proc", os.path.abspath(FileName))
+            catalogAd = r.loadCatalog("proc", __file)
             r.addCatalog(catalogAd)
         except:
             pass
 
         try:
-            p = xmlLoader.load(os.path.abspath(FileName))
+            p = xmlLoader.load(__file)
         except IOError as ex:
             print("The YACS XML schema file can not be loaded: %s"%(ex,))
 
@@ -1095,6 +1096,45 @@ class AlgorithmAndParameters(object):
         #
         return 1
 
+# ==============================================================================
+class RegulationAndParameters(object):
+    """
+    Classe générale d'interface d'action pour la régulation et ses paramètres
+    """
+    def __init__(self,
+                 name               = "GenericRegulation",
+                 asAlgorithm        = None,
+                 asDict             = None,
+                 asScript           = None,
+                ):
+        """
+        """
+        self.__name       = str(name)
+        self.__P          = {}
+        #
+        if asAlgorithm is None and asScript is not None:
+            __Algo = ImportFromScript(asScript).getvalue( "Algorithm" )
+        else:
+            __Algo = asAlgorithm
+        #
+        if asDict is None and asScript is not None:
+            __Dict = ImportFromScript(asScript).getvalue( self.__name, "Parameters" )
+        else:
+            __Dict = asDict
+        #
+        if __Dict is not None:
+            self.__P.update( dict(__Dict) )
+        #
+        if __Algo is not None:
+            self.__P.update( {"Algorithm":self.__A} )
+
+    def get(self, key = None):
+        "Vérifie l'existence d'une clé de variable ou de paramètres"
+        if key in self.__P:
+            return self.__P[key]
+        else:
+            return self.__P
+
 # ==============================================================================
 class DataObserver(object):
     """
@@ -1595,16 +1635,13 @@ class CaseLogger(object):
         self.__logSerie = []
         self.__switchoff = False
         self.__viewers = {
-            "TUI":Interfaces._TUIViewer,
-            "DCT":Interfaces._DCTViewer,
-            "SCD":Interfaces._SCDViewer,
+            "TUI" :Interfaces._TUIViewer,
+            "SCD" :Interfaces._SCDViewer,
             "YACS":Interfaces._YACSViewer,
             }
         self.__loaders = {
-            "TUI":Interfaces._TUIViewer,
-            "DCT":Interfaces._DCTViewer,
-            "EPD":Interfaces._EPDViewer,
-            "COM":Interfaces._COMViewer,
+            "TUI" :Interfaces._TUIViewer,
+            "COM" :Interfaces._COMViewer,
             }
         if __addViewers is not None:
             self.__viewers.update(dict(__addViewers))