FakeIO IO Interface¶
A module for the FakeIO class.
-
class
larpix.io.fakeio.
FakeIO
[source]¶ An IO stand-in that sends output to stdout (i.e. print) and reads input from a data member that can be set in advance.
The queue is implemented as a
collections.deque
object. Data can be queued up in advance through repeated calls toqueue.append()
. The first element of the queue will be passed on to theController.read
method each time it is called. This is a true queue, i.e. first-in, first-out.The format for an element of the queue is a tuple:
([list_of_Packets], b'corresponding bytes')
.Although meaningless in terms of the internal implementation,
FakeIO
objects contain an internal state determining whether the object is currently “listening,” and will raise aRuntimeError
ifempty_queue
is called when the object is not listening.-
static
add_timestamps
(packets, positions, timestamps=0)[source]¶ Insert timestamp packets into a list of packets in the given positions.
Convenience method for modifying lists of packets to add to the FakeIO queue. Modifies the list in-place.
The positions are with respect to the indexes of the original list, so that the inserted element is just before the element that originally had that index. e.g.
>>> add_timestamps([a, b, c, d], [1, 3]) [a, TimestampPacket(...), b, c, TimestampPacket(...), d]
If timestamps is a list, those timestamps will be used for the TimestampPackets. If it is an int, it will be taken as the starting time, and each subsequent packet will be incremented by 1. A default starting time of 0 is assumed.
-
static