# eaxsim scenario

> eaxsim scenario: every key, its type and meaning, generated from the Go structs that decode it.

Product: Platform · Type: Reference · Editions: Cloud
Source: https://eaxware.com/docs/platform/reference/generated/config/sim-scenario/
Verified against commit 6a5fc9e.

<!-- GENERATED by tools/docgen (node tools/docgen/docgen.mjs). Do not edit by hand: change the source and regenerate. -->

An eaxsim scenario file (-scenario) and the model, link and I/O specifications of a simulated system.

Keys are the JSON keys. **Optional** marks keys that are omitted when empty, or that may be absent (pointers).

## Scenario

Scenario is a scenario file.

Source: `eaxPLC/pkg/sim/scenario/scenario.go`

| Key | Type | Optional | Description |
|---|---|---|---|
| `name` | string |  |  |
| `mode` | string |  | realtime (default) \| virtual |
| `speed` | number |  | virtual: 0 = as fast as possible |
| `until_s` | number | yes | virtual: stop after this simulated time |
| `base_tick_ms` | number | yes |  |
| `workers` | integer | yes |  |
| `seed` | integer |  |  |
| `nats` | [NATS](#nats) |  |  |
| `http` | [HTTP](#http) |  |  |
| `telemetry` | [Telemetry](#telemetry) |  | Telemetry: the PLCs' UNS telemetry on the broker (pkg/sim/host); absent: on whenever NATS is, automatic pacing, read-only. |
| `sites` | map of string to [Site](#site) | yes | Sites locate the plant on the map (templates name their site). |
| `library` | map of string to [Unit](#unit) | yes | Library: reusable units (a pump station, a reactor) that templates "use"; Include: files adding units ({"library": {...}}), relative to the scenario. |
| `include` | list of string | yes |  |
| `templates` | list of [Template](#template) |  |  |
| `expect` | list of [Expect](#expect) | yes | Expect: the run's pass/fail checks (checks.go), read-only; evaluated by eaxsimctl test in virtual time. |

## ModelSpec

ModelSpec is one model of an instance.

Source: `eaxPLC/pkg/sim/system.go`

| Key | Type | Optional | Description |
|---|---|---|---|
| `name` | string |  |  |
| `type` | string |  |  |
| `params` | [Params](#params) | yes |  |

## LinkSpec

LinkSpec copies a model output to a model input every step ("T1.level\_m").

Source: `eaxPLC/pkg/sim/system.go`

| Key | Type | Optional | Description |
|---|---|---|---|
| `from` | string |  |  |
| `to` | string |  |  |

## IOSpec

IOSpec wires a model port to the PLC's process image: %I addresses are
written from the port (sensors), %Q addresses are read into the port
(actuators). Scale [raw\_min, raw\_max, eng\_min, eng\_max] converts
engineering units to the raw value; Type picks the encoding of W/D/B
addresses (INT, UINT, WORD, DINT, UDINT, DWORD, REAL, SINT, USINT, BYTE).

Source: `eaxPLC/pkg/sim/system.go`

| Key | Type | Optional | Description |
|---|---|---|---|
| `plc` | string |  |  |
| `port` | string |  |  |
| `scale` | list of number | yes |  |
| `type` | string | yes |  |

## NATS

NATS: the broker the PLCs serve their API on (empty URL: no NATS).

Source: `eaxPLC/pkg/sim/scenario/scenario.go`

| Key | Type | Optional | Description |
|---|---|---|---|
| `url` | string | yes |  |
| `mode` | string | yes | Mode: mux (default: all PLCs on one connection and 4 wildcard subscriptions) \| per_plc (a controller and ~12 subscriptions each). |
| `pool` | integer | yes | Pool: shared connections (PLC i uses i % pool); default 4. |
| `nkey_dir` | string | yes | NKeyDir: &lt;dir&gt;/&lt;plc id&gt;.nk seeds give a PLC its own connection and identity (a secured eaxScada broker allows each identity plc.&lt;id&gt;.&gt;). |

## HTTP

HTTP is the host's API.

Source: `eaxPLC/pkg/sim/scenario/scenario.go`

| Key | Type | Optional | Description |
|---|---|---|---|
| `addr` | string | yes | default 127.0.0.1:8090 |

## Telemetry

Telemetry configures the hosted PLCs' UNS telemetry (host.Telemetry):

	"telemetry": {"interval\_ms": 200, "plcs": ["tank-00\*"], "prefix": "{site}/{area}/{id}",
	 "refresh\_s": 30, "writable": ["SetpointM", "Cmd\*"]}

eaxsim's -uns-\* flags override each field.

Source: `eaxPLC/pkg/sim/scenario/scenario.go`

| Key | Type | Optional | Description |
|---|---|---|---|
| `off` | boolean | yes | Off: no UNS telemetry or commands (alone: no other field with it). |
| `interval_ms` | number | yes | IntervalMs: the sampling period in wall time; 0: 50 ms, longer in proportion beyond 250 publishing PLCs. |
| `plcs` | list of string | yes | PLCs: the publishing PLCs by id (path.Match patterns); empty: all. |
| `prefix` | string | yes | Prefix: the UNS prefix pattern ({site}, {area}, {unit}, {id}, "/" between levels); empty: site/area/unit/id. |
| `refresh_s` | number | yes | RefreshS: every value republished this often; 0: 30 s, &lt; 0: never. |
| `writable` | list of string | yes | Writable: the variables UNS commands may write (path.Match patterns, case-insensitive, as a real runtime's `--uns-writable`); empty: read-only, a real runtime's default. |

## Site

Site is a place of the plant.

Source: `eaxPLC/pkg/sim/scenario/scenario.go`

| Key | Type | Optional | Description |
|---|---|---|---|
| `name` | string | yes |  |
| `lat` | number |  |  |
| `lon` | number |  |  |
| `info` | string | yes |  |

## Unit

Unit is a reusable template body: a PLC program with its process. A
template that uses it adds or overrides parameters, initial values and
faults, and may add models, links and I/O.

Source: `eaxPLC/pkg/sim/scenario/scenario.go`

| Key | Type | Optional | Description |
|---|---|---|---|
| `description` | string | yes |  |
| `program` | string |  |  |
| `scan_ms` | number |  |  |
| `params` | map of string to [Param](#param) | yes |  |
| `init` | map of string to [Value](#value) | yes |  |
| `models` | list of [ModelTemplate](#modeltemplate) | yes |  |
| `links` | list of [LinkSpec](#linkspec) | yes |  |
| `io` | list of [IOSpec](#iospec) | yes |  |
| `faults` | list of [FaultSpec](#faultspec) | yes |  |
| `kpi` | [KPI](#kpi) | yes | KPI is the signal that sums the unit up on overview maps ("T1.level_pct"), with its normal range. |

## Template

Template is replicated Count times.

Source: `eaxPLC/pkg/sim/scenario/scenario.go`

| Key | Type | Optional | Description |
|---|---|---|---|
| `use` | string | yes | a library unit |
| `kpi` | [KPI](#kpi) | yes |  |
| `id` | string |  | "tank-{i:04}"; {i} is 0-based |
| `count` | integer |  |  |
| `site` | string | yes |  |
| `area` | string | yes |  |
| `unit` | string | yes |  |
| `program` | string |  |  |
| `scan_ms` | number |  |  |
| `params` | map of string to [Param](#param) | yes |  |
| `init` | map of string to [Value](#value) | yes | "%MD100:REAL": number \| "${p}" |
| `models` | list of [ModelTemplate](#modeltemplate) | yes |  |
| `links` | list of [LinkSpec](#linkspec) | yes |  |
| `io` | list of [IOSpec](#iospec) | yes |  |
| `faults` | list of [FaultSpec](#faultspec) | yes |  |

## Expect

Expect is a pass/fail check of a virtual-time run (virtual
commissioning): a PLC variable or a plant signal compared with a value,
at a time, throughout a window, never in a window, or eventually in it.
Checks only read: no field writes a variable, forces a signal or
injects a fault, and an unknown key (a "write", "set", "force") is
refused like everywhere else in a scenario.

	"expect": [
	 {"id": "settled", "plc": "tank-00", "signal": "T1.level\_m", "check": "at", "at\_s": 90,
	 "cmp": "within", "value": 2.0, "tol": 0.05},
	 {"id": "no-spill", "plc": "tank-\*", "signal": "T1.level\_pct", "check": "never", "cmp": "&gt;", "value": 95},
	 {"id": "alarm", "plc": "tank-00", "var": "HighAlarm", "check": "eventually",
	 "after\_fault": "pump-on", "within\_s": 30, "cmp": "==", "value": true},
	 {"id": "pump-off", "plc": "tank-00", "var": "%QX0.0", "check": "always",
	 "from\_s": 200, "to\_s": 300, "cmp": "==", "value": false}]

Times are simulated seconds from the run's start (0), or from the start
of the fault after\_fault names (its at\_s on each PLC that has it).
eaxsimctl test runs a scenario in virtual time and reports the checks;
eaxsim itself does not evaluate them.

Source: `eaxPLC/pkg/sim/scenario/checks.go`

| Key | Type | Optional | Description |
|---|---|---|---|
| `id` | string |  |  |
| `description` | string | yes |  |
| `plc` | string | yes | PLC: the PLCs checked (path.Match on their ids); empty: every PLC. Each matching PLC must pass. |
| `signal` | string | yes | Signal: a model port ("T1.level_m"); Var: a PLC variable by name ("LevelM", "Line2.Valve1.Q") or a direct address with its type ("%MD104:REAL", "%QX0.1"; W: INT, D: DINT, B: BYTE without one). Exactly one of them. |
| `var` | string | yes |  |
| `check` | string |  | Check: at (the first sample at or after at_s), always (every sample in [from_s, to_s]), never (no sample in the window), eventually (a sample in [from_s, to_s] or [from_s, from_s + within_s]). A window without to_s runs to the run's end. |
| `cmp` | string |  | Cmp: ==, !=, &lt;, &lt;=, &gt;, &gt;=, or within (\|x - value\| &lt;= tol). |
| `value` | [Number](#number) | yes |  |
| `tol` | number | yes |  |
| `at_s` | number | yes | times, simulated seconds |
| `from_s` | number | yes |  |
| `to_s` | number | yes |  |
| `within_s` | number | yes |  |
| `after_fault` | string | yes | AfterFault: the id of a scenario fault; the times count from its start on each PLC that has it. |

## Params

Params are a model's numeric parameters.

Source: `eaxPLC/pkg/sim/model/model.go`

Underlying type: `map[string]float64`.

## Param

Param is a per-instance parameter: a number, {"uniform": [lo, hi]},
{"list": [a, b, ...]} (by instance, cycling) or {"step": [start, inc]}.

Source: `eaxPLC/pkg/sim/scenario/scenario.go`

This type has its own JSON decoding: it accepts more than its fields below (see its description).

| Key | Type | Optional | Description |
|---|---|---|---|
| `uniform` | list of number | yes |  |
| `list` | list of number | yes |  |
| `step` | list of number | yes |  |

## Value

Value is a number or a "${param}" reference.

Source: `eaxPLC/pkg/sim/scenario/scenario.go`

This type has its own JSON decoding: it accepts more than its fields below (see its description).

| Key | Type | Optional | Description |
|---|---|---|---|
| `Num` | number | yes |  |
| `Ref` | string |  |  |

## ModelTemplate

ModelTemplate is a model whose parameters may use ${param}.

Source: `eaxPLC/pkg/sim/scenario/scenario.go`

| Key | Type | Optional | Description |
|---|---|---|---|
| `name` | string |  |  |
| `type` | string |  |  |
| `params` | map of string to [Value](#value) | yes |  |

## FaultSpec

FaultSpec schedules a fault (sim.Fault) on the template's instances:
every one, or every Nth (i % every\_n == 0).

Source: `eaxPLC/pkg/sim/scenario/scenario.go`

| Key | Type | Optional | Description |
|---|---|---|---|
| `id` | string |  |  |
| `target` | string |  |  |
| `kind` | string |  |  |
| `value` | number | yes |  |
| `at_s` | number |  |  |
| `duration_s` | number | yes |  |
| `held` | number | yes | runtime (snapshot): the value a stuck sensor holds |
| `latched` | boolean | yes |  |
| `every_n` | integer | yes |  |

## KPI

KPI names a model signal and its range (for colouring).

Source: `eaxPLC/pkg/sim/scenario/scenario.go`

| Key | Type | Optional | Description |
|---|---|---|---|
| `signal` | string |  |  |
| `min` | number |  |  |
| `max` | number |  |  |
| `unit` | string | yes |  |

## Number

Number is a check's value: a number, or true (1) / false (0).

Source: `eaxPLC/pkg/sim/scenario/checks.go`

This type has its own JSON decoding: it accepts more than its fields below (see its description).
