Data manager
- class app.src.data_manager.DataManager
Bases:
objectDefines access points to the persistent data layer of the application.
- static delete_log(log_id=None)
Permanently deletes a log item. If no log_id is specified, ALL log items are deleted.
- Parameters
log_id – ID of the log item
- event_device_end(device_id)
Saves the information about a device end into persistent storage.
- Parameters
device_id – ID of the device to end
- event_device_start(config)
Saves the information about a device start into persistent storage.
Extra parameters:
‘device_id’: string - ID of the device,
‘device_class’: string - Class of the device,
‘device_type’: string - Type of the device,
‘address’: string - Address on which the connection to the device can be established,
- Parameters
config – A dictionary with the specified extra parameters
- event_task_end(device_id, task_id)
Saves the information about a task end into persistent storage.
- Parameters
device_id – ID of the device to which the task corresponds
task_id – ID of the task to end
- event_task_start(config: dict)
Saves the information about a task start into persistent storage.
Extra parameters:
‘task_id’: string - ID of the task,
‘task_class’: string - Class of the task,
‘task_type’: Type of the task
- Parameters
config – A dictionary with the specified extra parameters
- get_data(log_id: int, last_time: str, device_id: str, data_type: str = 'values') dict
Retrieves data from persistent storage for a specified device. Further filters may be applied through additional parameters.
- Parameters
log_id – ID of the log item to retrieve. Is ignored if the last_time parameter is not None.
last_time – The timestamp in format <YYYYmmddHHMMSSfff>. Data from before this time will be excluded from the response. If it’s not None, the log_id parameter is ignored.
device_id – device ID of the device
data_type – defines the type of data to retrieve, defaults to ‘values’
- Returns
a dictionary with the data from persistent storage
- get_latest_data(device_id, data_type: str = 'values') dict
Retrieves the data with the newest time for a specified device.
- Parameters
device_id – device ID of the device
data_type – defines the type of data to retrieve, defaults to ‘values’
- Returns
a dictionary with the data from persistent storage
- static insert(item, item_class)
Executes an INSERT query and commits the change.
- Parameters
item – Item to insert
item_class – Class reference of the Item type
- load_log()
Retrieves all log entries.
- load_variables()
Loads all variables from persistent storage.
- remove_all_logs()
Removes all log entries.
- remove_log(id)
Removes a log entry from persistent storage.
- Parameters
id – ID of the log entry to remove
- save_device(connector: app.models.Device)
Saves a Device object into persistent storage.
- Parameters
connector – device to save
- save_event(event: app.models.Event)
Saves an Event object into persistent storage.
- Parameters
event – event to save
- save_experiment(device_id, current_time=datetime.datetime(2022, 3, 20, 8, 34, 55, 826682))
Saves an Experiment object into persistent storage.
- Parameters
device_id – device ID of the related Device
current_time – time of the experiment, defaults to the current time.
- save_value(value: app.models.Value)
Saves a Value object into persistent storage.
- Parameters
value – value to save
- save_variable(variable: app.models.Variable)
Saves a Variable object into persistent storage.
- Parameters
variable – variable to save
- store_log(init_type, config)
Stores a log entry into persistent storage.
- Parameters
init_type – type of the log entry
config – config to log
- static update(item)
Executes an UPDATE query and commits the change.
- Parameters
item – Item to update
- update_experiment(device_id)
Updates an Experiment object in persistent storage.
- Parameters
device_id – device ID of the related Device