mpylab.env.eut.virtual module¶
Deterministic and randomized EUT monitors for tests and templates.
- class mpylab.env.eut.virtual.RandomEUTMonitor(*, seed=None, status_weights=None, recovery_weights=None, delay=0.0, source='random_simulation', operating_mode_changed=False, stored_data_lost=False)
Bases:
EUTMonitorGenerate 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, andnot_evaluatedobservations during exposure.recovery_weights – Relative weights for
automatic,operator,reset, andfailedrecovery 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_Immunityas an automaticeut_monitor.- poll_event()
Return the scheduled random event after its configured delay.
- Returns:
Scheduled event, or
Nonewhile 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.
- class mpylab.env.eut.virtual.VirtualEUTMonitor(events=())
Bases:
EUTMonitorEmit a configurable sequence of events without EUT hardware.
Each sequence item belongs to one exposure. A normal event dictionary is assigned to
during_exposurefor compatibility. A phase mapping may instead provide separateduring_exposure,post_exposure, andrecoveryevents.Noneemits no event in that phase. Event dictionaries accept the normalmake_eut_event()fields plus an optional non-negativedelayin seconds.- Parameters:
events (iterable of mapping or None, optional) – Per-exposure virtual event specifications.
- poll_event()
Return the active virtual event once its delay has elapsed.
- Returns:
Configured event, or
Nonewhile no event is due.- Return type:
dict or None
- start_exposure(context)
Activate the next configured virtual exposure specification.
- Parameters:
context (mapping) – Measurement context describing the exposure.
- start_phase(phase, context)
Activate the configured event for the requested exposure phase.
- Parameters:
phase (str) – Phase from
EUT_EVENT_PHASES.context (mapping) – Measurement context for the phase.
- stop_exposure()
Discard the active virtual exposure and any pending event.