Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion fdsreader/devc/device.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Tuple, Union
from typing import Tuple, Union, List

from fdsreader.utils import Quantity

Expand All @@ -19,6 +19,7 @@ def __init__(self, device_id: str, quantity: Quantity, position: Tuple[float, fl
self.position = position
self.orientation = orientation
self._data_callback = lambda: None
self._activation_times: List[Tuple[float, bool]]= []

@property
def data(self):
Expand Down Expand Up @@ -47,6 +48,21 @@ def xyz(self):
"""Alias for :class:`Device`.position.
"""
return self.position

@property
def activation_times(self):
"""Alias for :class:`Device`._activation_times.
"""
return self._activation_times

def add_activation_time(self, activation: Tuple[float, bool]):
"""Adds an activation time to the list of activation times

Args:
activation (Tuple[float, bool]): The activation time to track. Tuple should contain the time of activation (float) and the activation state (bool)
"""
self._activation_times.append(activation)
self._activation_times.sort(key=lambda activation: activation[0]) # Sort the list of times by time

def clear_cache(self):
"""Remove all data from the internal cache that has been loaded so far to free memory.
Expand Down
12 changes: 11 additions & 1 deletion fdsreader/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from fdsreader import settings
from fdsreader._version import __version__


class Simulation:
"""Master class managing all data for a given simulation.

Expand Down Expand Up @@ -249,6 +248,17 @@ def parse_smv_file(self):
self._devices[device_id] = [self._devices[device_id], device]
else:
self._devices[device_id] = device
elif keyword.startswith("DEVICE_ACT"):
device_id = line.replace("DEVICE_ACT", "").strip()
# Device should always be defined, as DEVICE_ACT appears after all DEVICE lines in smv
device = self._devices[device_id]

data_line = smv_file.readline().strip()
data = list(filter(None, data_line.split(" ")))

_, time, value = data
value = bool(int(value))
device.add_activation_time((time, value))
elif keyword.startswith("SLC"):
self._load_slice(smv_file, keyword)
elif keyword.startswith("BNDS"):
Expand Down