This contains everything you need to run your app locally.
View your app in AI Studio: https://ai.studio/apps/drive/1FGKhfb1UFkvOTOgKKChUNYs3YyUmbhZN
Prerequisites: Node.js
- Install dependencies:
npm install - Set the
GEMINI_API_KEYin .env.local to your Gemini API key - Run the app:
npm run dev
The browser app cannot open raw TCP servers directly. To accept external Modbus and IEC 61850 clients, run the local relay service:
- Install deps (includes
ws):npm install - Start relay (needs permission for low ports like
502and102):npm run relay - In the app, open Modbus panel:
- Physical Network Bridge URL:
ws://127.0.0.1:34001 - Click Connect
- Select the NIC/IP used by your LAN
- Physical Network Bridge URL:
- Configure device endpoints:
- Modbus servers use each device
IP + modbusPort. - IEC 61850 servers (SCL/Demo devices with Server role) use each device
IP + iecMmsPort(default102).
- Modbus servers use each device
- Verify the Bound Endpoints list in the app shows each device endpoint as
ACTIVE.
IEC bridge mode:
- IEC endpoints now run as TCP proxy listeners in relay mode.
- Each external endpoint (
deviceIp:iecMmsPort) is bridged to a backend MMS server (iecBackendHost:iecBackendPort). - Configure per-device backend in Device Configurator (SCL/Demo Server role).
- For bulk creation, backend ports auto-increment from base backend port.
You can run one or more real MMS servers (e.g. using mz-automation/libiec61850) and point each simulated IED endpoint to the corresponding backend host/port.
For the bundled standard backend launcher, you can dynamically choose the SCD file:
- Default:
npm run iec:std:start(usesDUBGG.scd) - Custom SCD (relative path):
SCD_FILE="MyStation.scd" npm run iec:std:start - Custom SCD (absolute path):
SCD_FILE="/path/to/MyStation.scd" npm run iec:std:start - Optional IED/AP targeting from multi-IED SCD:
SCD_IED_NAME="IED_A" SCD_AP_NAME="AP1" SCD_FILE="MyStation.scd" npm run iec:std:start
- Endpoint ownership default: startup no longer pushes a hardcoded
TestIEDendpoint; the app publishes imported IED endpoints (name/IP/port) via Network Binding → Connect IEC. - Backend routing default in std mode:
RELAY_FORCE_BACKEND=1is enabled by default so imported endpoints are always proxied to the local libiec backend (prevents simulation fallback). - Ghost-discovery prevention in std mode:
RELAY_IEC_DEFAULT_LISTENER=0andRELAY_CLEAR_IEC_ON_UI_DISCONNECT=1are enabled so relay does not expose IEC endpoints unless the app publishes them, and clears IEC endpoints when app bridge disconnects. - Control-channel hardening: relay now accepts endpoint-publish sessions only from trusted browser origins (the app UI). Headless test clients are rejected by default.
- Temporary override for diagnostics only:
RELAY_ALLOW_HEADLESS_WS=1 npm run relay - Optional override to allow simulation routing:
RELAY_FORCE_BACKEND=0 npm run iec:std:start - Optional legacy auto-endpoint injection (not recommended):
RELAY_AUTOCONFIG_ENDPOINT=1 npm run iec:std:start
UI helper:
- In Network Binding → IEC Device Configuration → Advanced: Backend Proxy, set SCD File for each IED.
- Click Copy Start Cmd to copy a ready command using that SCD path.
- Run the copied command in terminal, then reconnect IEDScout.
Typical mapping example:
- External endpoint:
172.16.21.12:102-> Backend:127.0.0.1:8102 - External endpoint:
172.16.21.13:102-> Backend:127.0.0.1:8103
Relay will show this mapping in the IEC 61850 Endpoints panel and track live IEC client counts.
If binding to 502 fails on Linux, run with elevated privileges, for example:
sudo npm run relay
Optional environment overrides:
RELAY_WS_PORT(default34001)RELAY_MODBUS_PORT/RELAY_MODBUS_HOST(fallback Modbus bind)RELAY_IEC_MMS_PORT/RELAY_IEC_MMS_HOST(fallback IEC bind)RELAY_IEC_BACKEND_HOST/RELAY_IEC_BACKEND_PORT(default IEC backend fallback when per-device backend is not set)
