[dataio/buffer] fixing bug in time buffer
This commit is contained in:
parent
ff2d8ebb50
commit
0f09c948ec
@ -8,9 +8,9 @@ class CircBuffer:
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
size: int,
|
size: int,
|
||||||
mutex: QMutex,
|
|
||||||
channels: int = 1,
|
channels: int = 1,
|
||||||
samplerate: int = 40_000,
|
samplerate: int = 40_000,
|
||||||
|
mutex: QMutex = QMutex(),
|
||||||
):
|
):
|
||||||
self.__size = size
|
self.__size = size
|
||||||
self.__channels = channels
|
self.__channels = channels
|
||||||
@ -123,7 +123,7 @@ class CircBuffer:
|
|||||||
# easy case first, we can spare the effort of further checking
|
# easy case first, we can spare the effort of further checking
|
||||||
if index >= 0 and index <= self.write_index(channel):
|
if index >= 0 and index <= self.write_index(channel):
|
||||||
if self.has_value(index, channel):
|
if self.has_value(index, channel):
|
||||||
return (self.__buffer[channel, index], self.__time[index])
|
return (self.__buffer[channel, index], self.__time[channel, index])
|
||||||
else:
|
else:
|
||||||
raise IndexError(
|
raise IndexError(
|
||||||
f"Invalid index {index} on ring buffer for channel{channel}"
|
f"Invalid index {index} on ring buffer for channel{channel}"
|
||||||
@ -132,7 +132,7 @@ class CircBuffer:
|
|||||||
if index < 0:
|
if index < 0:
|
||||||
index = self.write_index() - 1
|
index = self.write_index() - 1
|
||||||
if self.has_value(index, channel):
|
if self.has_value(index, channel):
|
||||||
return (self.__buffer[channel, index], self.__time[index])
|
return (self.__buffer[channel, index], self.__time[channel, index])
|
||||||
else:
|
else:
|
||||||
raise IndexError(
|
raise IndexError(
|
||||||
f"Invalid index {index} on ring buffer for channel{channel}"
|
f"Invalid index {index} on ring buffer for channel{channel}"
|
||||||
|
Loading…
Reference in New Issue
Block a user