Skip to content
Snippets Groups Projects
Commit 51f2ee6f authored by David Hammer's avatar David Hammer
Browse files

Merge branch 'add-fs-load-time' into 'master'

Use stopwatch when reading constant files

See merge request karaboDevices/calng!19
parents 4178b8de bc505605
No related branches found
No related tags found
1 merge request!19Use stopwatch when reading constant files
......@@ -23,6 +23,7 @@ from karabo.bound import (
STRING_ELEMENT,
UINT32_ELEMENT,
VECTOR_UINT32_ELEMENT,
Unit,
)
from . import utils
......@@ -185,6 +186,15 @@ def add_status_schema_from_enum(schema, enum_class):
.reconfigurable()
.commit(),
DOUBLE_ELEMENT(schema)
.key(f"{constant_node}.constantLoadingTime")
.displayedName("FS load time")
.unit(Unit.SECOND)
.description("How long it took loading this constant from the file system")
.readOnly()
.initialValue(0)
.commit(),
SLOT_ELEMENT(schema)
.key(f"{constant_node}.overrideConstantFromFile")
.displayedName("Override from file")
......@@ -567,9 +577,11 @@ class BaseCalcatFriend:
self._set_status(constant, "dataFilePath", str(file_path))
self._set_status(constant, "dataSetName", resp["data"]["data_set_name"])
constant_data = _read_dataset_externally(
file_path, resp["data"]["data_set_name"]
)
with utils.Stopwatch() as stopwatch:
constant_data = _read_dataset_externally(
file_path, resp["data"]["data_set_name"]
)
self._set_status(constant, "constantLoadingTime", stopwatch.elapsed)
with self.cached_constants_lock:
self.cached_constants[constant] = constant_data
......@@ -594,9 +606,13 @@ class BaseCalcatFriend:
)
self._set_status(constant, "dataFilePath", str(file_path))
self._set_status(constant, "dataSetName", resp["data"]["data_set_name"])
constant_data = _read_dataset_externally(
file_path, resp["data"]["data_set_name"]
)
with utils.Stopwatch() as stopwatch:
constant_data = _read_dataset_externally(
file_path, resp["data"]["data_set_name"]
)
self._set_status(constant, "constantLoadingTime", stopwatch.elapsed)
with self.cached_constants_lock:
self.cached_constants[constant] = constant_data
self._set_status(constant, "beginValidityAt", resp["data"]["begin_at"])
......@@ -608,10 +624,13 @@ class BaseCalcatFriend:
return constant_data
def get_constant_from_file(self, constant):
constant_data = _read_dataset_externally(
self.device.get(f"foundConstants.{constant.name}.dataFilePath"),
self.device.get(f"foundConstants.{constant.name}.dataSetName"),
)
with utils.Stopwatch() as stopwatch:
constant_data = _read_dataset_externally(
self.device.get(f"foundConstants.{constant.name}.dataFilePath"),
self.device.get(f"foundConstants.{constant.name}.dataSetName"),
)
self._set_status(constant, "constantLoadingTime", stopwatch.elapsed)
with self.cached_constants_lock:
self.cached_constants[constant] = constant_data
self._set_status(constant, "beginValidityAt", "manual override")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment