Class RandomSequence

Class Documentation

class RandomSequence

Generates a sequence of randomly distributed unsigned 8-bit integer values. The configuration of the distribution is controlled by header supplied in the configure method, through the following parameters: UTC_START: sees the random number generator from which the sequence is generated OBS_OFFSET: byte offset into the random sequence.

Public Functions

RandomSequence() = default

Construct a new Random Sequence object.

~RandomSequence() = default

Destroy the Random Sequence object.

void configure(const ska::pst::common::AsciiHeader &header)

Configure the Random Sequence using the meta data present in the AsciiHeader.

Parameters

header – header containing a UTC_START and OBS_OFFSET key/val pair

void reset()

Reset the internal state of the Random Sequence. The next call to generate or validate will behave as per the first call to these functions.

void generate(uint8_t *buffer, uint64_t bufsz)

Generate a random sequence of uniformly distributed unsigned 8-bit integers. Each random number generated advances the sequence of random numbers.

Parameters
  • buffer – pointer to memory to which the random sequence should be written

  • bufsz – number of elements to write to the buffer

void generate_block(uint8_t *buffer, uint64_t bufsz, uint64_t block_offset, uint64_t block_size, uint64_t block_stride)

Generate a random data sequence written to the provided buffer in blocks.

Parameters
  • buffer – buffer to write the random sequence to

  • bufsz – size of the buffer in bytes

  • block_offset – offset from the start of the buffer for the first block

  • block_size – size of each block of random data to write in bytes

  • block_stride – separate between each block of random data in bytes

auto validate(uint8_t *buffer, uint64_t bufsz) -> bool

Compare contents of buffer to expected random sequence.

Parameters
  • buffer – pointer to buffer containing samples to be validated

  • bufsz – size of the buffer to be validated

Returns

true if all samples are valid

Returns

false if any samples are invalid

auto validate_block(uint8_t *buffer, uint64_t bufsz, uint64_t block_offset, uint64_t block_size, uint64_t block_stride) -> bool

Validate the n data sequence written to the provided buffer in blocks.

Parameters
  • buffer – pointer to buffer containing samples to be validated

  • bufsz – size of the buffer to be validated

  • block_offset – offset from the start of the buffer for the first block

  • block_size – size of each block of n data to write in bytes

  • block_stride – separate between each block of n data in bytes

Returns

true if all samples are valid

Returns

false if any samples are invalid

void seek(uint64_t nelements)

Seek forward through the random sequence.

Parameters

nelements – the number of elements in the sequence to skip over