haniwers.v1.cli.mock#

Mock data acquisition command.

This module provides the ‘mock’ command for testing DAQ functionality without physical hardware. It supports CSV replay (Mocker) and random data generation (RandomMocker).

Examples: Replay from CSV file: $ haniwers-v1 mock --load-from data/recorded.csv --events 100

Generate random data:
    $ haniwers-v1 mock --random --events 500 --seed 42

Fast replay with custom output:
    $ haniwers-v1 mock --load-from data.csv --speed 10.0 --output-dir test/

Module Contents#

Functions#

validate_speed

Validate speed multiplier is within valid range.

validate_file_exists

Validate that file exists if path is provided.

validate_mutual_exclusivity

Validate that --load-from and --random are mutually exclusive.

mock

Run mock data acquisition for testing without hardware.

Data#

log

API#

haniwers.v1.cli.mock.log#

‘bind(…)’

haniwers.v1.cli.mock.validate_speed(speed: float) float#

Validate speed multiplier is within valid range.

Args: speed: Speed multiplier to validate

Returns: speed if valid

Raises: typer.BadParameter: If speed is outside valid range [0.1, 100.0]

haniwers.v1.cli.mock.validate_file_exists(path: Optional[pathlib.Path]) Optional[pathlib.Path]#

Validate that file exists if path is provided.

Args: path: File path to validate (None is valid)

Returns: path if valid or None

Raises: typer.BadParameter: If file does not exist

haniwers.v1.cli.mock.validate_mutual_exclusivity(load_from: Optional[pathlib.Path], random: bool) tuple[Optional[pathlib.Path], bool]#

Validate that --load-from and --random are mutually exclusive.

Args: load_from: CSV file path for replay mode random: Random generation mode flag

Returns: Tuple of validated (load_from, random)

Raises: typer.BadParameter: If both options are provided

haniwers.v1.cli.mock.mock(load_from: Optional[pathlib.Path] = TestingOptions.load_from, random: bool = TestingOptions.random, events: Optional[int] = TestingOptions.events, speed: float = TestingOptions.speed, shuffle: bool = TestingOptions.shuffle, seed: Optional[int] = TestingOptions.seed, workspace: Optional[pathlib.Path] = OutputOptions.workspace, filename_prefix: Optional[str] = OutputOptions.filename_prefix, verbose: bool = LoggerOptions.verbose, logfile: str = LoggerOptions.logfile) None#

Run mock data acquisition for testing without hardware.

This command allows developers to test DAQ functionality by either:

  1. Replaying events from a recorded CSV file (–load-from)

  2. Generating synthetic random events (–random)

The mock device (Mocker or RandomMocker) behaves like a real Device, allowing the Sampler to work identically in both mock and real modes.

Examples: Replay from CSV: $ haniwers-v1 mock --load-from data/run.csv --events 100

Generate random data:
    $ haniwers-v1 mock --random --events 500

Fast replay with shuffling:
    $ haniwers-v1 mock --load-from data.csv --speed 10.0 --shuffle

Reproducible random generation:
    $ haniwers-v1 mock --random --events 1000 --seed 42

Note: - Speed range: 0.1 (10x slower) to 100.0 (100x faster) - Output files go to sandbox/mock/ by default (clearly separated from real data) - Use Ctrl+C to stop acquisition early