mpylab.env.eut.random module

Seedable EUT-monitor example for simulations and custom implementations.

class mpylab.env.eut.random.RandomEUTMonitor(*, seed=None, status_weights=None, recovery_weights=None, delay=0.0, source='random_simulation', operating_mode_changed=False, stored_data_lost=False)

Bases: EUTMonitor

Generate reproducible random EUT observations without hardware.

This class is both a simulation helper and a compact template for custom monitors. Its poll_event() method never blocks. Replace _make_exposure_event() with a camera, communication, or process-data check when adapting the class to real EUT monitoring.

Parameters:
  • seed – Seed used by an instance-local random-number generator. Equal seeds and configurations produce equal event sequences.

  • status_weights – Relative weights for passed, degraded, failed, and not_evaluated observations during exposure.

  • recovery_weights – Relative weights for automatic, operator, reset, and failed recovery after a degraded or failed observation.

  • delay – Non-negative delay in seconds before an event becomes available.

  • source – Source label stored in every generated event.

  • operating_mode_changed – Simulated observations needed for performance criterion B. Both default to False.

  • stored_data_lost – Simulated observations needed for performance criterion B. Both default to False.

Notes

This simulation must not be used as evidence of real EUT performance. The mandatory manual monitor remains active when this monitor is passed to Measure_Immunity as an automatic eut_monitor.

poll_event()

Return the scheduled random event after its configured delay.

Returns:

Scheduled event, or None while no event is due.

Return type:

dict or None

start_exposure(context)

Generate and schedule a random event for a new exposure.

Parameters:

context (mapping) – Measurement context describing the exposure.

start_phase(phase, context)

Generate a post-exposure event when that phase begins.

Parameters:
  • phase (str) – Phase from EUT_EVENT_PHASES.

  • context (mapping) – Measurement context for the phase.

stop_exposure()

Discard any random event still pending for the exposure.