The simulator plays a scenario against an agent instead of the plant. It loads the scenario’s starting data into Masterdata, moves its world forward every 10 seconds (readings drift, faults appear), and delivers the scenario’s trigger when it’s due, so you can watch the agent react in chat, in the action inbox and in its logs.
Every package has scenarios: 1,706 across the 145 packages, generated from each package’s acceptance cases. They are a generated starting set, not yet reviewed one by one.
What’s in simulator/
| Path | What it is |
|---|---|
runtime/ |
The bridge (xmsim_xmpro.py), the simulator engine it uses (xmsim/), the tick script, the SQL setup and a Dockerfile for a Stream Host with Python |
packs/<domain>/<package>/ |
Each package’s scenarios: scenarios.json (what happens and what should happen), inputs.json (starting data, world, faults) and deploy.json (the package scope and approvers a run sets up) |
datastreams/Agent Library Simulator.xuc |
The stream that runs it: an Event Simulator ticking every 10 seconds into the Python agent |
Install
-
A Stream Host with Python 3.11 and
pymssql. The XMPro Python agent loads Python in process, and the bridge talks to SQL Server withpymssql. For a Docker Stream Host, build the image inruntime/Dockerfilefrom the Stream Host image you run:docker build --build-arg STREAM_HOST_IMAGE=<your stream host image:tag> -t stream-host-python runtimeRun your Stream Host from that image. Tested on the Linux Docker Stream Host of XMPro 5.1; a Windows Stream Host needs Python 3.11 and
pymssqlinstalled and the same environment variables as theDockerfile, and has not been tested. -
Copy the files to the Stream Host so it sees
runtime/at/opt/xmsim/runtimeandpacks/at/opt/xmsim/packs(in Docker, mount them read-only).PYTHONPATHmust be/opt/xmsim/runtime(theDockerfilesets it). -
The simulator’s SQL login and run log. Run
runtime/xmsim-setup.sqlinMasterdataonce, as an administrator. It creates the loginxmsim_simand the tablesxmsim.Runandxmsim.Frame. Put the password you gave it in a file on the Stream Host, for example/run/xmsim/sql_password. -
The run settings. Copy
runtime/run.example.jsonto/opt/xmsim/run.jsonand set your SQL Server and the scenario to run. The password stays in its file, never inrun.json. -
The stream. In Data Stream Designer, upload the Event Simulator (2.00) and Python agents if you don’t have them, import
Agent Library Simulator.xuc(passwordDem0nstr@t1on), point it at the Stream Host with Python, and leave it unpublished until you want a run.
The package you’re testing must be imported and running first, with its domain’s SQL loaded (see the import guide).
Run a scenario
- Pick a scenario from the package’s
packs/<domain>/<package>/scenarios.json: itsscenario_id,titleandexpected_plainsay what it tests and what should happen. - Set
"scenario"in/opt/xmsim/run.jsonto that ID. - Publish the Agent Library Simulator stream. Each start begins a new run; it ends by itself after the scenario’s
duration_s. -
Watch the run:
SELECT TOP 5 * FROM xmsim.Run ORDER BY started_at DESC; -- setup: what it deployed, and any problems SELECT * FROM xmsim.Frame WHERE run_id = '<run_id>' ORDER BY frame; -- one row per tick: writes, errors, the trigger - When the trigger is a person asking the agent something (most supply chain scenarios), the frame shows
ask the agent: ...: type that question in the agent’s chat. - Compare what the agent did with the scenario’s
expected_plain. - Unpublish the stream when you’re done.
A scenario’s starting data replaces the demo rows it shares keys with, so the agent sees the scenario’s state. Run the domain’s demo data script again to put the demo back.