Skip to content

Buffer

mosca.control.buffer.CircularBuffer

CircularBuffer(
    n_items=DEFAULT_N_ITEMS,
    buffer_size=DEFAULT_BUFFER_SIZE,
    data_size=DEFAULT_DATA_SIZE,
    dtype=DEFAULT_DTYPE,
)

Class managing a circular buffer.

buffer_size class-attribute instance-attribute

buffer_size = property(lambda self: shape[1])

Maximum number of points that can be stored in the buffer at any given time (2nd dimension). Once the limit is reached the older points will be overwritten.

data_size class-attribute instance-attribute

data_size = property(lambda self: shape[2])

Data size (3d dimension of the buffer).

dtype class-attribute instance-attribute

dtype = property(lambda self: dtype)

first_point_time class-attribute instance-attribute

first_point_time = property(
    lambda self: _metadata["first_point_time"]
)

Timestamp of the first added point.

latest_point_num property

latest_point_num

Latest stored point number.

latest_point_time class-attribute instance-attribute

latest_point_time = property(
    lambda self: _metadata["latest_point_time"]
)

Timestamp of the latest added point.

locked class-attribute instance-attribute

locked = property(lambda self: _locked)

n_items class-attribute instance-attribute

n_items = property(lambda self: shape[0])

Number of detector modules. (1st dim of the buffer)

n_points class-attribute instance-attribute

n_points = property(lambda self: _n_points_set)

Total number of points that have been added to this buffer, including ones that may have been overwritten (i.e: NOT the number of points currently stored, which can't be greater than buffer_size)

oldest_point_num property

oldest_point_num

Oldest stored point number.

__getitem__

__getitem__(index)

add_data

add_data(data)

Add data to the buffers. point_nums: 1D array containing the point numbers (0 being the first point of the SCAN) data: array (see below)

Returns: the number of new points

IMPORTANT! Arrays shape: it is the CALLER's resposability to provide correctly aligned data. -> data will be reshaped to (n_items, n_points, data_size)

clear

clear()

Resets the point counters. (sets stored points list to -1 and last_point_num to -1)

get_data

get_data(
    first=None,
    last=None,
    strip_first_axis=False,
    raise_ex=True,
    clip_idx=False,
    flatten=False,
)

WARNING!! like any python array indexing, the last point returned will be the one found at index last-1. e.g: get_data(0, 34) will return points 0 to 33 included.

Returns data from a range of points first: point number stored in the buffer. If None, the older point is selected. last: point number stored in the buffer. If None, the latest point is selected. strip_first_axis: if the first axis (nb points) size is 1, the arrays will be reshaped to 2D (points, data) clip_idx: if true the given point range will be clipped to the available points. flatten: reshape the arrays to 1D. raise_ex: if set to True, the function will raise an exception instead of returning empty arrays.

get_point

get_point(pix_num)

Returns the given point. pix_num: point number (0 is the first point of the SCAN)

lock

lock()

prepare

prepare(
    n_items=None,
    buffer_size=None,
    data_size=None,
    dtype=None,
)

TODO: hide counter size Allocate the buffers. n_items: number of items (1st dim of the buffer) buffer_size: max number of points to store (2nd dim of the buffer) data_size: size of data (3rd dim of the buffer)

unlock

unlock()