Skip to main content
Version: Next

Set it up by script and run it again

A plant with hundreds of tags is not set up by hand. This page is for the engineer who writes, or runs, an import for a whole project. It describes how the two importers built so far work, because the same shape suits any setup script: platform/tools/wincc-import for NIRO and tools/aw-import for AllWaves. For the WinCC tool's commands see Import a WinCC Unified project.

Plan first, apply second​

  1. plan reads the source and writes what it would make. It touches no gateway, so it runs anywhere, takes no key and can be read, diffed and checked into the project. The plan of a project is a file you can review before a single tag exists.
  2. apply makes it. It creates the provider and the connections when missing, then the types, then the instances, then the alarms, in that order, because each needs the one before.
  3. verify reads it back. After the PLC is online it reads every OPC UA tag once and lists the ones whose quality is not good.

The order matters on a gateway that already has the project's tags: make the new things first (--keep-old), check that the screens still resolve, then run again without it to remove the old ones.

Make a run safe to repeat​

  • What exists is left alone. A second apply makes only what is missing. The AllWaves importer and the WinCC importer both treat an existing connection, type or instance as done, and a rehearsal of the NIRO conversion showed the second run changing nothing.
  • Check names, not just count. The plan's tests assert that no path is made twice, that a name that would collide is refused (the importer stops with "Two structures got one type name" instead of choosing one), and that an item that is both a tag and a folder is an error.
  • Count before and after. The NIRO conversion went from imported motor tags to instances with 74 old tags removed and the same 643 alarms before and after, and every one of 537 tag paths in 89 screens still resolved. Those are two numbers to compare, not a judgement.
  • Leave out what you cannot map and say so. The AllWaves plan leaves out three whole arrays and the ESP32's 23 MQTT tags (no broker address was kept), and its README lists them.

Credentials​

The importers act as an API key with the engineer role, read from the environment (SCADEX_API_KEY) or a .env file that is not committed, not typed on a command line that shell history keeps. A key with that role can set up connections, tags, types and screens. Users, keys, sign-in providers and backup and restore need a person even for an admin key. See API keys. Revoke the key when the import is done.

Pace it​

A gateway that takes a large import drops out of its reverse proxy for about a minute while it works. The AllWaves importer paces its calls and waits for the gateway to report healthy before going on, and a script of your own should too: send in batches, check GET /api/v1/runtime/health between them, retry what failed after the wait and not at once.

Keep the source of truth in one place​

A script that is run again will put back what it made. If an engineer has since edited something in the dashboard, the next run either leaves it (what exists is kept) or replaces it. The WinCC importer's type-alarms works from the export and replaces alarm edits made in Scadex since convert; its views command keeps views that already have content unless --force. Decide, before the first run, which things are owned by the script and which by people, and say so in the project's README.

Types can also be exported and imported as JSON (GET /api/v1/udt/types/export, POST /api/v1/udt/types/import), which suits moving a catalog between gateways. See Tag types API.