Commit 030d6ef3 authored by Philip ABBET's avatar Philip ABBET

Refactoring of the input groups data indexes

parent 0494e153
......@@ -92,10 +92,10 @@ class Input:
def isDataUnitDone(self):
"""Indicates if the current data unit will change at the next iteration"""
if (self.data_index_end >= 0) and (self.group.data_index_end == -1):
if (self.data_index_end >= 0) and (self.group.last_data_index == -1):
return True
return (self.data_index_end == self.group.data_index_end)
return (self.data_index_end == self.group.last_data_index)
def hasMoreData(self):
......@@ -369,8 +369,10 @@ class InputGroup:
restricted_access=True):
self._inputs = []
self.data_index = -1
self.data_index_end = -1
self.data_index = -1 # Lower index across all inputs
self.data_index_end = -1 # Bigger index across all inputs
self.first_data_index = -1 # Start index of the current data units
self.last_data_index = -1 # End index of the current data units
self.channel = str(channel)
self.synchronization_listener = synchronization_listener
self.restricted_access = restricted_access
......@@ -511,15 +513,20 @@ class InputGroup:
input.data_same_as_previous = True
# Compute the group's start and end indices
self.data_index = reduce(lambda x, y: max(x, y.data_index),
self.data_index = reduce(lambda x, y: min(x, y.data_index),
self._inputs[1:], self._inputs[0].data_index)
self.data_index_end = reduce(lambda x, y: min(x, y.data_index_end),
self.data_index_end = reduce(lambda x, y: max(x, y.data_index_end),
self._inputs[1:], self._inputs[0].data_index_end)
self.first_data_index = reduce(lambda x, y: max(x, y.data_index),
self._inputs[1:], self._inputs[0].data_index)
self.last_data_index = reduce(lambda x, y: min(x, y.data_index_end),
self._inputs[1:], self._inputs[0].data_index_end)
# Inform the synchronisation listener
if self.synchronization_listener is not None:
self.synchronization_listener.onIntervalChanged(self.data_index,
self.data_index_end)
self.synchronization_listener.onIntervalChanged(self.first_data_index,
self.last_data_index)
#----------------------------------------------------------
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment