Skip to content

Commit

Permalink
bug fix on data saving
Browse files Browse the repository at this point in the history
  • Loading branch information
takuya-ulm committed Feb 11, 2025
1 parent 46a2056 commit fa83778
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/qudi/logic/qdyne/tools/custom_dataclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ def data_container(self):
"""
return self._data

@data_container.setter
def data_container(self, data_container):
self._data = data_container

@Slot(dict)
def update_values(self, new_dc_dict):
"""
Expand Down Expand Up @@ -125,7 +129,7 @@ def save(self):
def load(self):
try:
with open(self.save_path, 'rb') as f:
self._data_container = pickle.load(f)
return pickle.load(f)

except EOFError:
self.log.error(f"cannot load settings from {self.save_path}")
Expand Down Expand Up @@ -165,7 +169,7 @@ def initialize_data_container(self, *args):
Initialize the data container.
"""
if os.path.exists(self._data_storage.save_path):
self._data_storage.load()
self.mediator.data_container = self._data_storage.load()
self._log.debug(f"Saved settings loaded from {self._data_storage.save_path}")

else:
Expand Down
6 changes: 5 additions & 1 deletion src/qudi/logic/qdyne/tools/multi_settings_dataclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def current_data(self):
In MultiSettingsMediator, this is given by the currently selected method and mode.
"""

print(self.method_dict)
return self.method_dict[self.current_method][self.current_mode]

@property
Expand All @@ -67,6 +67,10 @@ def data_container(self):
"""
return self.method_dict

@data_container.setter
def data_container(self, data_container):
self.method_dict = data_container

@Slot(str)
def update_method(self, new_method: str):
self.current_method = new_method
Expand Down
4 changes: 4 additions & 0 deletions src/qudi/logic/qdyne/tools/settings_dataclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ def data_container(self):
"""
return self.mode_dict

@data_container.setter
def data_container(self, data_container):
self.mode_dict = data_container

@property
def default_data(self):
return self.mode_dict["default"]
Expand Down

0 comments on commit fa83778

Please sign in to comment.