Guided Use Cases & Scenarios
This page focuses on scenario-driven engineering workflows (integrators/dev/QA), grounded in the runnable reference repo: spx-examples.
Common Use Cases
1. Validate a device driver against virtual hardware
Pick a template model from
spx-examples/library/domains/...(Modbus, SCPI/ASCII, MQTT, BLE).Start SPX Server via Docker Compose and expose the required protocol ports.
Load the model, create an Instance, and drive deterministic time from tests (MiL).
Use Scenarios to cover happy-path and fault modes (disconnects, delays, spikes).
Debug with API state + server logs; keep the workflow repeatable in CI.
2. Run QA smoke tests in CI (MiL)
docker compose up -d→ wait forGET /health→ runpytest→docker compose down.Store
SPX_PRODUCT_KEYin the CI secret store; inject it into the job environment.Pin versions explicitly (server image tag + Python dependencies) so tests stay reproducible.
3. Onboard engineers with a safe sandbox
Start from one model + one scenario.
Make one change (attribute, mapping, scenario override) and re-run the same tests.
See: Use in Unit Tests (MiL), Snapshots — Getting Started, Communication Adapters.
Step-by-Step Walkthroughs
End-to-end: SCPI multimeter smoke test (spx-examples)
Files used:
This flow is a good baseline for “driver vs virtual hardware” integration testing:
Start SPX Server and verify it’s healthy.
Register the model + create an instance.
Discover the effective ASCII/SCPI port from the instance (the model auto-assigns starting at 5025).
Run protocol-level assertions and scenario-driven faults.
Run locally
Scenarios covered by this example (see the model YAML):
voltage_staticascii_disconnectascii_response_delay_spikedischarge_spike
Debug checklist
Scenario Blueprint Template
Use this checklist when creating scenarios for other models:
Define intent
What user story are we simulating?
e.g. "Operator reads voltage while unplugging sensor."
Select assets
Which YAML model and scenarios support it?
Start with spx-examples/library/domains/....
Identify actors
Which services or scripts will interact with the model?
REST client, SCPI CLI, Modbus master.
Script stimuli
Which API/protocol calls drive the scenario?
Document command sequences.
Expected results
What readings/logs confirm success?
Use attribute wrappers or protocol responses.
Fault coverage
How do we simulate edge cases?
Add scenario overrides or temporary detachments.
Cleanup
How do we reset the model?
Call stop() on scenarios or reload the model.
Tips for Junior Engineers / QA
Start with one scenario and make the happy-path pass before layering faults.
Use the
spx-examplesrepo as a library; copy models into your project as needed.When results look odd, inspect live instance state via
spx-pythonand server logs.Commit updates to scenarios alongside test scripts so the team reviews both.
Last updated

