Skip to content
This repository was archived by the owner on Nov 15, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/acceptance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ jobs:
cp examples/model-source.yaml "$RUNNER_TEMP/catalog-acceptance/examples/"
cd "$RUNNER_TEMP/catalog-acceptance"
"$RUNNER_TEMP/modsim/bin/python" tools/fetch-models.py --output "$RUNNER_TEMP/catalog-acceptance/inputs"
"$RUNNER_TEMP/modsim/bin/python" tools/catalog-interop.py --scenario "$RUNNER_TEMP/catalog-acceptance/inputs/advantech/adam-5017uh/simulation/interop-inputs.sim.json" --modpoll-python "$RUNNER_TEMP/modpoll/bin/python" --node-reader "$GITHUB_WORKSPACE/.interop/modpoll/tools/wot-interop/read-write.cjs" --output "$RUNNER_TEMP/catalog-interop.json"
- name: Verify released runtime for product evidence
"$RUNNER_TEMP/modsim/bin/python" tools/catalog-interop.py --vectors "$RUNNER_TEMP/catalog-acceptance/inputs/devices/advantech/adam-5017uh/models/adam-5017uh.vectors.json" --modpoll-python "$RUNNER_TEMP/modpoll/bin/python" --node-reader "$GITHUB_WORKSPACE/.interop/modpoll/tools/wot-interop/read-write.cjs" --output "$RUNNER_TEMP/catalog-interop.json"
- name: Verify the released runtime against the catalog model
run: |
uv venv "$RUNNER_TEMP/released-modsim"
uv pip install --python "$RUNNER_TEMP/released-modsim/bin/python" 'modsim==2.0.0a2'
cd "$RUNNER_TEMP/catalog-acceptance"
"$RUNNER_TEMP/released-modsim/bin/python" tools/catalog-interop.py --scenario "$RUNNER_TEMP/catalog-acceptance/inputs/advantech/adam-5017uh/simulation/interop-inputs.sim.json" --modpoll-python "$RUNNER_TEMP/modpoll/bin/python" --node-reader "$GITHUB_WORKSPACE/.interop/modpoll/tools/wot-interop/read-write.cjs" --output "$RUNNER_TEMP/catalog-interop-released.json"
"$RUNNER_TEMP/released-modsim/bin/python" tools/catalog-interop.py --vectors "$RUNNER_TEMP/catalog-acceptance/inputs/devices/advantech/adam-5017uh/models/adam-5017uh.vectors.json" --modpoll-python "$RUNNER_TEMP/modpoll/bin/python" --node-reader "$GITHUB_WORKSPACE/.interop/modpoll/tools/wot-interop/read-write.cjs" --output "$RUNNER_TEMP/catalog-interop-released.json"
- uses: actions/upload-artifact@v4
with:
name: catalog-interop
Expand Down
13 changes: 6 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@ uv run python tools/generate-td.py --check
uv run --group docs mkdocs build -s
```

Device TMs, metadata, sources, evidence and product-specific scenarios belong in
[modbus-models](https://github.com/top-maker/modbus-models), targeting its `main`
through a PR and required catalog CI. Do not add editable device copies here.
A new model submission needs an executable TM and source/permission/known limits;
maintainers can help complete metadata. Photos and hardware evidence are optional.
Device TMs, metadata, sources and product-specific scenarios belong in
[Open Modbus Catalog](https://github.com/top-maker/open-modbus-catalog), targeting
its `main` through a PR and required catalog CI. Do not add editable device copies
here. A new model submission needs an executable TM and source/permission/known
limits; maintainers can help complete metadata.
Never include private endpoints, credentials or customer data in public inputs.

The model-source lock and downloader are consumers of immutable public data.
For a data update, resolve the release tag to its full SHA, review every file and
hash, update examples/model-source.yaml through a PR, run the downloader, then
For a data update, pin the full catalog commit, review every file and hash, update examples/model-source.yaml through a PR, run the downloader, then
run affected simulator/client tests. The tests/fixtures tree is a frozen runtime
regression fixture, not a contribution catalog. Generated TD fixtures are
regenerated by tools/generate-td.py, never hand edited.
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ RUN uv sync --locked --no-dev --no-install-project
# Copy Python app to the Docker image
COPY modsim /app/modsim/
COPY examples /app/examples
COPY tests/fixtures/io-module /app/tests/fixtures/io-module
COPY examples/deployment.yaml /app/deployment.yaml
COPY tools/fetch-models.py /app/tools/fetch-models.py
RUN .venv/bin/python tools/fetch-models.py
Expand Down
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ uv run modsim ps
The commands use `examples/deployment.yaml` by default. The example starts two
virtual ADAM devices: Unit 1 exposes ADAM-5017UH raw inputs; Unit 2 exposes
ADAM-6024 raw I/O with synthetic AO→AI and DO→DI loopback. These are simulation
values, not verified physical measurements. Models, scenarios and source
information are in [modbus-models](https://github.com/top-maker/modbus-models).
values, not verified physical measurements. The ADAM-5017UH model and scenario
come from [Open Modbus Catalog](https://github.com/top-maker/open-modbus-catalog);
the ADAM-6024 model is a frozen regression fixture in `tests/fixtures/io-module/`.

The deployment binds to all interfaces by default; set `server.bind` to
`127.0.0.1` in `examples/deployment.yaml` to restrict a direct local run.
Expand Down Expand Up @@ -174,9 +175,9 @@ For a single device without a managed deployment:

```bash
uv run python tools/fetch-models.py
uv run modsim --config examples/models/advantech/adam-5017uh/adam-5017uh.tm.json \
uv run modsim --config examples/models/devices/advantech/adam-5017uh/models/adam-5017uh.tm.json \
--unit-id 1 --port 5020 \
--scenario examples/models/advantech/adam-5017uh/simulation/adam-5017uh.sim.json
--scenario examples/models/devices/advantech/adam-5017uh/simulation/adam-5017uh.sim.json
```

The single-device model runtime currently supports TCP. The unconfigured demo
Expand All @@ -195,10 +196,10 @@ source change.

## Pinned public model inputs

Device data and optional scenarios are maintained only in
[modbus-models](https://github.com/top-maker/modbus-models).
`examples/model-source.yaml` pins data release `modbus-models-v2` to its full
commit and individual SHA-256 hashes. Prepare examples with
Device data and optional scenarios are maintained in
[Open Modbus Catalog](https://github.com/top-maker/open-modbus-catalog).
`examples/model-source.yaml` pins a full catalog commit and individual SHA-256
hashes. Prepare examples with
`uv run python tools/fetch-models.py`; this downloads verified local inputs to
ignored `examples/models/`, never executes downloaded Python, and does not copy
an interpreter. Re-run after updating the lock through a reviewed PR.
Expand Down
7 changes: 2 additions & 5 deletions contrib/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# Device data moved

The active model contribution source is
[modbus-models](https://github.com/top-maker/modbus-models).
Device models are maintained in
[Open Modbus Catalog](https://github.com/top-maker/open-modbus-catalog).
Use its contribution guide and target main. This directory no longer accepts
model edits. Historical commits and published releases are unchanged.

The initial curated data release contains two ADAM models; other former catalog
entries remain historical, pending source/redistribution review. See the
[fixed migration inventory](https://github.com/top-maker/modbus-models/blob/2493526acc6645393b3ebb3f32279167a88d6f41/schemas/migration.yaml).
Prepare current examples using tools/fetch-models.py and examples/model-source.yaml.
3 changes: 2 additions & 1 deletion docs/preview-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ selected read spans.
#### Modsim 2.0.0a2

This candidate uses published modpoll-wot 0.2.0a2 and immutable modbus-models-v1
inputs. Device mappings and contribution workflows now live in modbus-models;
inputs. Device mappings and contribution workflows moved to a data repository,
now [Open Modbus Catalog](https://github.com/top-maker/open-modbus-catalog);
examples pin a full data commit and individual content hashes. Vendor originals
are not copied. The tool and data releases remain independent.

Expand Down
8 changes: 4 additions & 4 deletions examples/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ server:
port: 5020
devices:
- id: adam-5017uh
model: examples/models/advantech/adam-5017uh/adam-5017uh.tm.json
model: examples/models/devices/advantech/adam-5017uh/models/adam-5017uh.tm.json
parameters:
THING_ID: urn:modsim:device:advantech:adam-5017uh
UNIT_ID: 1
HOST: 127.0.0.1
scenario: examples/models/advantech/adam-5017uh/simulation/adam-5017uh.sim.json
scenario: examples/models/devices/advantech/adam-5017uh/simulation/adam-5017uh.sim.json
- id: adam-6024
model: examples/models/advantech/adam-6024/adam-6024.tm.json
model: tests/fixtures/io-module/adam-6024.tm.json
parameters:
THING_ID: urn:modsim:device:advantech:adam-6024
UNIT_ID: 2
HOST: 127.0.0.1
scenario: examples/models/advantech/adam-6024/simulation/adam-6024.sim.json
scenario: tests/fixtures/io-module/simulation/adam-6024.sim.json
19 changes: 5 additions & 14 deletions examples/model-source.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
repository: top-maker/modbus-models
release: modbus-models-v2
revision: db8cf19a2b58bcfc3b45319caa2d386d5ab5cacd
profile: '0.2'
interpreter: 0.2.0a2
repository: top-maker/open-modbus-catalog
revision: f4e1f9cdb39d886e11e1f9aa5345828128b3aaca
files:
advantech/adam-5017uh/adam-5017uh.tm.json: 9e1d6e38dbb4e2db2f30f8dfd3d9df90a349b2e9aeb60a168ae4d60ee709ead7
advantech/adam-5017uh/simulation/adam-5017uh-behavior.py: b1ec8ff3d0fe6e32127f587d5049523584adef479509f90c004c010f3ceeb789
advantech/adam-5017uh/simulation/adam-5017uh-scripted-analog-input.sim.json: efbd727d253febdb8e816e70a07e2314f2110f47e705eca8e942e0948c80417e
advantech/adam-5017uh/simulation/adam-5017uh.sim.json: 246e0eaf9234aaec6c85c63497a27bbd89c132e436345636c9cdba8969fd3c9f
advantech/adam-6024/adam-6024.tm.json: 4c2aee3334faf6622f4ee34a23108fa0ec100a6b3110a78200eee79da8935596
advantech/adam-6024/simulation/adam-6024.sim.json: 2beb25195324919b10710d24dbdad93d9e3d4a37e857824faedf9246296c1cc0
advantech/adam-5017uh/simulation/interop-inputs.sim.json: dd10b90523317122ea8b70cf21b7417bd60b688ea5b12e36fb798d9e2a6d5a58
advantech/adam-5017uh/evidence/l2-check.yaml: a5f83e77acb60bf2cd5359523ad3fe76b0fae4adb90703b8f09a9dddad9a883b
schemas/evidence-schema.yaml: ecfbecbd89ab599f842357994239c67097e92983e0ffacfef2fa3615b27c5837
devices/advantech/adam-5017uh/models/adam-5017uh.tm.json: 9e1d6e38dbb4e2db2f30f8dfd3d9df90a349b2e9aeb60a168ae4d60ee709ead7
devices/advantech/adam-5017uh/models/adam-5017uh.vectors.json: a76f365ae333b78e8113227940e15cc52e527962d676d62754d6211b184e22eb
devices/advantech/adam-5017uh/simulation/adam-5017uh.sim.json: 246e0eaf9234aaec6c85c63497a27bbd89c132e436345636c9cdba8969fd3c9f
4 changes: 2 additions & 2 deletions tests/fixtures/io-module/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

Frozen MIT model/scenario/TD used only for protocol and codec regression.
Not a device contribution or independently maintained product mapping.
The canonical product lives in top-maker/modbus-models; generated TDs are checked
by tools/generate-td.py. Do not use this fixture as a model contribution target.
It also serves as the ADAM-6024 device in examples/deployment.yaml. Generated
TDs are checked by tools/generate-td.py. Do not use this fixture as a model contribution target.
2 changes: 1 addition & 1 deletion tests/test_catalog_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_remote_model_single_device_read_and_stop(tmp_path):
lock = yaml.safe_load(
(Path(__file__).resolve().parents[1] / "examples/model-source.yaml").read_text()
)
url = f"https://raw.githubusercontent.com/{lock['repository']}/{lock['revision']}/advantech/adam-5017uh/adam-5017uh.tm.json"
url = f"https://raw.githubusercontent.com/{lock['repository']}/{lock['revision']}/devices/advantech/adam-5017uh/models/adam-5017uh.tm.json"
scenario = tmp_path / "initial.sim.json"
values = [0x1234, 0x8001, 0xABCD, 0, 65535, 42, 0x0102, 0xFE01]
scenario.write_text(
Expand Down
32 changes: 16 additions & 16 deletions tools/catalog-interop.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import yaml

ROOT = Path(__file__).resolve().parents[1]
MODEL = "advantech/adam-5017uh/adam-5017uh.tm.json"
MODEL = "devices/advantech/adam-5017uh/models/adam-5017uh.tm.json"
VALUES = [0x1234, 0x8001, 0xABCD, 0, 65535, 42, 0x0102, 0xFE01]
EXPECTED = {f"AI{i}_RAW": value for i, value in enumerate(VALUES)}

Expand Down Expand Up @@ -76,17 +76,17 @@ def run(args):
port = reserve.getsockname()[1]
with TemporaryDirectory(prefix="modsim-catalog-interop-") as temporary:
work = Path(temporary)
if args.scenario:
scenario = args.scenario.resolve()
if json.loads(scenario.read_bytes()) != {
"version": "1",
"initial": EXPECTED,
}:
raise ValueError("Scenario differs from independent expected vector")
else:
scenario = work / "initial.sim.json"
scenario.write_text(json.dumps({"version": "1", "initial": EXPECTED}))
scenario_digest = hashlib.sha256(scenario.read_bytes()).hexdigest()
if args.vectors and json.loads(args.vectors.read_bytes()) != EXPECTED:
raise ValueError(
"Catalog vectors differ from the independent expected vector"
)
scenario = work / "initial.sim.json"
scenario.write_text(json.dumps({"version": "1", "initial": EXPECTED}))
vectors_digest = (
hashlib.sha256(args.vectors.read_bytes()).hexdigest()
if args.vectors
else None
)
env = dict(os.environ)
env.pop("PYTHONPATH", None)
with (work / "simulator.log").open("w+") as log:
Expand Down Expand Up @@ -206,7 +206,7 @@ def run(args):
report = {
"executed-at": datetime.now(timezone.utc).isoformat().replace("+00:00", "Z"),
"data-revision": revision,
"scenario-sha256": scenario_digest,
"vectors-sha256": vectors_digest,
"td-sha256": td_digest,
"td-endpoint": {
"host": "127.0.0.1",
Expand Down Expand Up @@ -241,7 +241,7 @@ def run(args):
args.output.parent.mkdir(parents=True, exist_ok=True)
args.output.write_text(json.dumps(report, indent=2) + "\n")
print(
"Catalog L2 subset passed: raw wire, published modpoll, node-wot, wrong-byte-order rejection, shutdown"
"Catalog interoperability passed: raw wire, published modpoll, node-wot, wrong-byte-order rejection, shutdown"
)


Expand All @@ -251,9 +251,9 @@ def run(args):
"--lock", type=Path, default=ROOT / "examples/model-source.yaml"
)
parser.add_argument(
"--scenario",
"--vectors",
type=Path,
help="Fixed local input with the independent known vector",
help="Catalog vectors file that must equal the independent known vector",
)
parser.add_argument("--modpoll-python", type=Path, required=True)
parser.add_argument("--node-reader", type=Path, required=True)
Expand Down
Loading