Storage Controller

Handles all data aspects, from the storage, loading and saving of configuration data to the acquisition and creation of experimental data.

Whenever we open a new file, the GUI must be cleared and old file closed.

GUI file operations

Operation

H5 file

Video file

App data

Open file (video file selected)

Opens file next to video or creates a new one, if not open

Opens video file

Clears and loads data from file (if it existed)

Open file (h5 file selected)

Opens h5 file

Tries to open video file in same folder, if it’s found and matches.

Clears and loads data from file

Open h5 RO

Closes and opens the h5 file in RO mode

Tries to open video file in same folder, if it’s found and matches.

Cleared and loaded from file

Open video file with current h5

Opens the video file (error may occur later if the file doesn’t match)

Save

Saves unsaved data to current h5 file

Save as

Saves unsaved data to new h5 file

Reloads

Reloads all the data

Discard changes

Discards and opens last saved h5 file state

Reloads

Reloads all the data

Close and clear

Closes h5 file and creates new black autosave

Closed

Cleared

Import H5

Import the channels from the h5 file

Import YAML

Import the channels from the yaml file

class glitter2.storage.StorageController(app, channel_controller, player, ruler, **kwargs)

Bases: kivy._event.EventDispatcher

This class manages the nix file. It can import config from files and add it to the app. Or it can clear all the config and open/create an existing file.

close_file(force_remove_autosave=False)

Closes without saving the data. But if data was unsaved, it leaves the backup file unchanged.

config_changed

That the config changed and we need to read the config again before saving.

create_file(filename, overwrite=False)

All channels should have been cleared before opening.

cycle_file()

Closes and reopens the h5 file that was just closed, assuming no changes occurred to the file meanwhile.

has_unsaved

Data was written to the file and we need to save it.

import_file(filename, exclude_app_settings=False)

Loads the file’s config data.

open_file(filename, read_only=False)

Loads the file’s config and opens the file for usage.

read_only_file

Whether the last file opened, was opened as read only.

save(filename=None, force=False)

Saves the changes to the autosave and also saves the changes to the file in filename (if None saves to the current filename).

ui_close(app_close=False)

The UI asked for to close a file. We create a new one if the app doesn’t close.

If unsaved, will prompt if want to save

ui_open_file(filename, read_only=False)

GUI requested that the file be opened. Previously open file should have been closed.

Parameters
  • filename

  • read_only

write_changes_to_autosave(*largs, scheduled=False)

Writes unsaved changes to the current (autosave) file.