temfield_mpylab.EUT

temfield_mpylab.EUT re-exports the shared mpylab monitor API for existing TEMField integrations. New code should import these objects from mpylab.env.eut directly.

Shared monitor classes

class mpylab.env.eut.EUTMonitor[source]

Bases: object

Minimal interface for monitoring an EUT during one RF exposure.

Implementations must not access the measurement’s MGraph. Polling should be non-blocking unless the monitor is wrapped in ThreadedEUTMonitor.

start_exposure(context)[source]

Prepare monitoring for one exposure.

Parameters:

context (mapping) – Measurement context describing the exposure.

start_phase(phase, context)[source]

Notify the monitor that an exposure phase has started.

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

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

poll_event()[source]

Return one structured EUT event or None when nothing changed.

stop_exposure()[source]

Stop monitoring the current exposure.

close()[source]

Release monitor resources.

class mpylab.env.eut.ManualEUTMonitor(poll_key=None, keylist='sS', stop_keys='qQ')[source]

Bases: EUTMonitor

Always-available manual EUT status input.

Events may be submitted from a GUI thread or generated from a configured keyboard callback. State after exposure and recovery method are accepted as separate values so that the performance criterion remains evaluable.

Parameters:
  • poll_key (callable, optional) – Non-blocking callback returning an integer key code or None.

  • keylist (str, optional) – Keys that record an operator-observed EUT failure.

  • stop_keys (str, optional) – Keys that request measurement termination.

__init__(poll_key=None, keylist='sS', stop_keys='qQ')[source]
start_exposure(context)[source]

Enable manual input for a new exposure and discard stale events.

Parameters:

context (mapping) – Measurement context describing the exposure.

property is_active

Whether manual observations are currently accepted.

property current_phase

Current exposure phase for newly submitted observations.

start_phase(phase, context)[source]

Select the phase assigned to subsequent manual observations.

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

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

submit_event(event, *, source='manual_gui')[source]

Queue a manually supplied event for the active exposure.

Parameters:
  • event (mapping) – EUT event fields accepted by validate_eut_event().

  • source (str, optional) – Operator interface that supplied the event.

Returns:

Normalized event placed in the queue.

Return type:

dict

submit_status(status, reason='operator_observation', details=None, *, source='manual_gui', **event_fields)[source]

Queue a manual functional status in the current exposure phase.

Parameters:
  • status (str) – Observation status from EUT_EVENT_STATUSES.

  • reason (str, optional) – Machine-readable reason for the observation.

  • details (object, optional) – Supplemental operator information.

  • source (str, optional) – Operator interface that supplied the status.

  • **event_fields (object) – Additional fields accepted by make_eut_event().

Returns:

Normalized event placed in the queue.

Return type:

dict

submit_post_exposure_state(after_exposure_state, *, recovery, reason='operator_post_exposure_observation', details=None, source='manual_gui', operating_mode_changed=None, stored_data_lost=None)[source]

Queue post-exposure state and recovery information.

Parameters:
  • after_exposure_state (str) – Functional state observed after RF exposure.

  • recovery (str) – Recovery mechanism consistent with the observed state.

  • reason (str, optional) – Machine-readable reason for the observation.

  • details (object, optional) – Supplemental operator information.

  • source (str, optional) – Operator interface that supplied the observation.

  • operating_mode_changed (bool, optional) – Whether the EUT operating mode changed unexpectedly.

  • stored_data_lost (bool, optional) – Whether stored EUT data was lost.

Returns:

Normalized post-exposure event placed in the queue.

Return type:

dict

poll_event()[source]

Return the next queued or keyboard-generated operator event.

Returns:

Next event, or None when no operator input is available.

Return type:

dict or None

stop_exposure()[source]

Disable manual input for the completed exposure.

class mpylab.env.eut.ThreadedEUTMonitor(monitor, *, poll_interval=0.01, join_timeout=1.0)[source]

Bases: EUTMonitor

Poll another EUT monitor in a dedicated background thread.

The wrapped monitor’s poll_event may block only for a bounded time so that stop_exposure can join the worker. start_exposure and stop_exposure themselves are called outside the worker and should therefore return promptly.

Parameters:
  • monitor (EUTMonitor) – Monitor polled by the background worker.

  • poll_interval (float, optional) – Delay in seconds between polling calls.

  • join_timeout (float, optional) – Maximum time in seconds allowed for worker shutdown.

__init__(monitor, *, poll_interval=0.01, join_timeout=1.0)[source]
property is_running

Whether the background polling worker is currently running.

start_exposure(context)[source]

Start the wrapped monitor and its background polling worker.

Parameters:

context (mapping) – Measurement context describing the exposure.

start_phase(phase, context)[source]

Forward a phase transition while serializing monitor access.

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

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

poll_event()[source]

Return one event queued by the worker without blocking.

Returns:

Next queued event, or None when the queue is empty.

Return type:

dict or None

stop_exposure()[source]

Stop and join the worker, then stop the wrapped monitor.

close()[source]

Stop an active worker and release the wrapped monitor.

class mpylab.env.eut.CompositeEUTMonitor(manual_monitor, automatic_monitors=())[source]

Bases: EUTMonitor

Combine mandatory manual input with optional automatic monitors.

Parameters:
  • manual_monitor (ManualEUTMonitor) – Always-available operator interaction layer.

  • automatic_monitors (EUTMonitor or iterable of EUTMonitor, optional) – Additional automatic observation sources.

__init__(manual_monitor, automatic_monitors=())[source]
start_exposure(context)[source]

Start manual and automatic monitors for one exposure.

Parameters:

context (mapping) – Measurement context describing the exposure.

start_phase(phase, context)[source]

Forward an exposure phase transition to all active monitors.

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

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

poll_event()[source]

Return the next manual, diagnostic, or automatic monitor event.

Returns:

Next available event, or None when no monitor has an event.

Return type:

dict or None

stop_exposure()[source]

Stop every monitor while containing automatic-monitor failures.

close()[source]

Release resources held by all component monitors.

class mpylab.env.eut.EUTMonitoringSession(monitor: EUTMonitor)[source]

Bases: object

Manage monitors and classify their events for one EUT exposure.

The session deliberately has no access to RF hardware and does not apply retry or stop policies. Measurement kernels remain responsible for those safety and workflow decisions.

Parameters:

monitor (EUTMonitor) – Monitor, commonly a CompositeEUTMonitor, whose lifecycle is managed by the session.

monitor

Managed monitor instance.

Type:

EUTMonitor

active

Whether an exposure is active.

Type:

bool

phase

Current exposure phase, or None outside an exposure.

Type:

str or None

__init__(monitor: EUTMonitor) None[source]
classmethod from_monitors(manual_monitor: ManualEUTMonitor, automatic_monitors: EUTMonitor | Iterable[EUTMonitor] = ()) EUTMonitoringSession[source]

Build a session with mandatory manual operator intervention.

Parameters:
  • manual_monitor (ManualEUTMonitor) – Always-available manual observation and intervention source.

  • automatic_monitors (EUTMonitor or iterable of EUTMonitor, optional) – Additional automatic observation sources.

Returns:

Session managing the combined monitor.

Return type:

EUTMonitoringSession

property events: tuple[dict, ...]

Return status events collected during the current exposure.

property diagnostics: tuple[dict, ...]

Return monitor diagnostics collected during the current exposure.

start_exposure(context: Mapping) None[source]

Start a new exposure and clear records from the previous one.

Parameters:

context (mapping) – Measurement-specific exposure context forwarded to every monitor.

Raises:

RuntimeError – If another exposure is already active.

start_phase(phase: str, context: Mapping) None[source]

Switch all monitors to another phase of the active exposure.

Parameters:
  • phase (str) – Exposure phase accepted by the EUT event schema.

  • context (mapping) – Measurement-specific phase context forwarded to every monitor.

Raises:

RuntimeError – If no exposure is active.

poll_event(diagnostic_context: Mapping | None = None)[source]

Return the next status event and retain diagnostics separately.

Parameters:

diagnostic_context (mapping, optional) – Metadata added with setdefault to monitor diagnostics, for example the current frequency, position, or attempt number.

Returns:

Next validated status event. Diagnostics and an empty monitor queue both return None; diagnostics are available through diagnostics and pop_diagnostics().

Return type:

dict or None

pop_diagnostics() list[dict][source]

Remove and return all diagnostics collected since the last call.

Returns:

Collected monitor diagnostics in arrival order.

Return type:

list of dict

stop_exposure() None[source]

Stop the active exposure; repeated calls are harmless.

close() None[source]

Stop an active exposure and release all monitor resources.

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

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.

__init__(*, seed=None, status_weights=None, recovery_weights=None, delay=0.0, source='random_simulation', operating_mode_changed=False, stored_data_lost=False)[source]
start_exposure(context)[source]

Generate and schedule a random event for a new exposure.

Parameters:

context (mapping) – Measurement context describing the exposure.

start_phase(phase, context)[source]

Generate a post-exposure event when that phase begins.

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

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

poll_event()[source]

Return the scheduled random event after its configured delay.

Returns:

Scheduled event, or None while no event is due.

Return type:

dict or None

stop_exposure()[source]

Discard any random event still pending for the exposure.