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 multiplier is within valid range. |
|
Validate that file exists if path is provided. |
|
Validate that --load-from and --random are mutually exclusive. |
|
Run mock data acquisition for testing without hardware. |
Data#
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] = typer.Option(None, '--load-from', help='CSV file to replay (mutually exclusive with --random)', exists=False), random: bool = typer.Option(False, '--random', help='Generate random synthetic data (mutually exclusive with --load-from)'), events: Optional[int] = typer.Option(None, '--events', help='Number of events to acquire (default: all events in CSV for replay)'), speed: float = typer.Option(1.0, '--speed', help='Speed multiplier for replay/generation (0.1 to 100.0, default: 1.0)'), shuffle: bool = typer.Option(False, '--shuffle', help='Shuffle event order (replay mode only)'), seed: Optional[int] = typer.Option(None, '--seed', help='Random seed for reproducibility (random mode only)'), output_dir: Optional[str] = typer.Option(None, '--output-dir', help='Output directory (default: sandbox/mock/)'), prefix: str = typer.Option('mock_data', '--prefix', help='Output filename prefix (default: mock_data)')) None#
Run mock data acquisition for testing without hardware.
This command allows developers to test DAQ functionality by either:
Replaying events from a recorded CSV file (–load-from)
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 42Note: - 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