Commit 8ce85c33 authored by GUILLOU Perceval's avatar GUILLOU Perceval Committed by Perceval Guillou
Browse files

fixing regulator init_obj for lazy init

parent 888cf4b4
......@@ -88,7 +88,7 @@ class Controller:
self._objects[new_obj.name] = new_obj
# --- For custom attributes and commands.
# set_custom_members(self, new_obj, self.init_obj ) # really needed ???????
set_custom_members(self, new_obj, self.init_obj) # really needed ???????
return new_obj
......@@ -97,50 +97,61 @@ class Controller:
with self.__lock:
if self.__hw_controller_initialized:
return
else:
self.__hw_controller_initialized = True
# ========= INIT HW, DEVICE AND CHILD DEVICE IF ANY =======================
if not self.__hw_controller_initialized:
self.initialize_controller()
print("============= controller_hw INITIALIZED")
self.__hw_controller_initialized = True
for obj in self._objects.values():
if self.__initialized_obj.get(obj):
return
# --- initialize the object
obj.load_base_config()
if isinstance(obj, Input):
self.initialize_input(obj)
elif isinstance(obj, Output):
self.initialize_output(obj)
elif isinstance(obj, Loop):
self.initialize_loop(obj)
if isinstance(obj, Loop):
print(f"============= {obj.name} INITIALIZED")
self.__initialized_obj[obj] = True
# if self.__initialized_obj.get(obj):
# return
if not self.__initialized_obj.get(obj.input):
self.__initialized_obj[obj.input] = True
obj.input.load_base_config()
self.initialize_input(obj.input)
# else:
# self.__initialized_obj[obj] = True
if not self.__initialized_obj.get(obj.output):
self.__initialized_obj[obj.output] = True
obj.output.load_base_config()
self.initialize_output(obj.output)
# print("controller:init_obj",obj)
obj.load_base_config()
self.initialize_loop(obj)
# if not self.__hw_controller_initialized:
# self.initialize_controller()
else:
self.__initialized_obj[obj] = True
obj.load_base_config()
if isinstance(obj, Input):
self.initialize_input(obj)
elif isinstance(obj, Output):
self.initialize_output(obj)
# ========= INIT ALL DEVICES ATTACHED TO THE CONTROLLER ==================
# if self.__hw_controller_initialized:
# return
# else:
# self.__hw_controller_initialized = True
# print("controller:init_controller_hw")
# # --- initialize the object
# obj.load_base_config()
# if isinstance(obj, Input):
# self.initialize_input(obj)
# elif isinstance(obj, Output):
# self.initialize_output(obj)
# elif isinstance(obj, Loop):
# self.initialize_loop(obj)
# print("controller:obj_INITIALIZED",obj)
# self.initialize_controller()
# print("============= controller_hw INITIALIZED")
# for obj in self._objects.values():
# # --- initialize the object
# obj.load_base_config()
# if isinstance(obj, Input):
# self.initialize_input(obj)
# elif isinstance(obj, Output):
# self.initialize_output(obj)
# elif isinstance(obj, Loop):
# self.initialize_loop(obj)
# print(f"============= {obj.name} INITIALIZED")
@property
def name(self):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment