Smart Site
Home Docs Smart Data Industrial Protocol Management

Industrial Protocol Management

Smart SCADA speaks to field equipment through industrial protocols. Each protocol is implemented as a collector package that conforms to a common adapter contract, so the rest of the system (scheduling, pipeline, alarms) is protocol-agnostic.

Interface Screenshot

Industrial Protocol - Plugin Manager (English UI)

Captured from the live Smart Site system with the English UI. See the zh-CN counterpart for the Chinese-UI screenshot.

1. Supported Protocols

Protocol Library Package Default Port Typical Devices
Modbus TCP/RTU modbus-serial @ss-node/ss-collector-modbus 502 PLCs, RTUs, meters
OPC UA node-opcua @ss-node/ss-collector-opcua 4840 DCS, modern PLCs
MQTT mqtt @ss-node/ss-collector-mqtt 1883 IoT gateways, edge devices
S7 snap7 @ss-node/ss-collector-s7 102 Siemens S7-300/400/1200
Virtual (built-in) @ss-node/ss-collector-virtual — Testing, demos

2. Protocol Adapter Contract

Every collector implements IProtocolAdapter and extends BaseCollectorService. The contract uses two context interfaces:

2.1 IDeviceContext

Carries connection-level parameters for a device:

  • deviceId, protocol
  • host / port (or broker URL, endpoint URL)
  • slaveId (Modbus), rack/slot (S7), securityPolicy (OPC UA), qos (MQTT)
  • scanRate, timeout, retryCount

2.2 ITagContext

Carries tag-level addressing:

  • tagId, name
  • address (e.g. HR40001, ns=2;s=Temp, device/+/temp, DB1.DBX0.0)
  • dataType (bool, int16, uint16, int32, float32, float64, string)
  • access (ro / rw)
  • scale, offset, deadband

The base class calls connect(device), then doReadTag(client, tag) for each tag, and doDisconnect(client) on shutdown. Subclasses implement only these four abstract methods.

3. Protocol-Specific Notes

3.1 Modbus TCP/RTU

  • Supports both TCP (modbus.service.v2.ts) and RTU over serial (modbus-rtu.service.ts)
  • Addressing uses the Smart SCADA convention: Cxxxxx (coils), DIxxxxx (discrete inputs), HRxxxxx (holding registers), IRxxxxx (input registers)
  • Byte order and register order are configurable per tag for multi-register values

3.2 OPC UA

  • Uses subscription-based monitoring where supported; falls back to polling
  • Security policies: None, Basic128Rsa15, Basic256, Basic256Sha256
  • Addressing follows the OPC UA node ID format ns=<namespace>;s=<identifier> or i=<numeric>

3.3 MQTT

  • Subscribes to topic filters (wildcards + and # supported)
  • Extracts values from JSON payloads using JSONPath (jsonpath.util.ts)
  • Supports QoS 0/1/2 and Last Will messages
  • Topics can map to multiple tags via JSONPath rules

3.4 S7

  • Connects to Siemens S7 PLCs over ISO-on-TCP (port 102)
  • Addressing: DB<n>.DBX<offset>.<bit> (bit), DB<n>.DBW<offset> (word), DB<n>.DBD<offset> (dword)
  • Rack/slot must match the physical PLC configuration

3.5 Virtual

  • No network — generates values via simulators:
    • fixed-value.simulator.ts — constant
    • range-value.simulator.ts — ramp between min/max
    • bool.simulator.ts — toggling boolean
    • enum-value.simulator.ts — cycling enum
    • string.simulator.ts — random strings
  • Ideal for demos, training, and pipeline testing

4. Protocol Adapter Development

To add a new protocol:

  1. Create a new package under ss-services/ss-node/packages/ss-collector/ss-collector-<name>/
  2. Implement BaseCollectorService:
    @Injectable()
    export class MyProtocolService extends BaseCollectorService {
      async connect(device: IDeviceContext) { /* open connection */ }
      protected async doReadTag(client, tag: ITagContext) { /* read one tag */ }
      protected async doWriteTag(client, tag, value) { /* write one tag */ }
      protected async doDisconnect(client) { /* close connection */ }
    }
    
  3. Register the module in app.module.ts
  4. Add the protocol code to the device types dictionary (data/dicts/.../protocol-types.json)
  5. Write unit tests using plugin-test-harness.ts from the SDK

The ProtocolAdapterRegistry discovers adapters by protocol code and routes device reads to the correct collector.

5. FAQ

Q: Which protocol should I use for a new device? A: Use the protocol the device natively supports. For PLCs, Modbus TCP or OPC UA are most common. For IoT-style gateways publishing JSON, use MQTT. For Siemens S7 controllers, use S7.

Q: Can one device use two protocols? A: No. Create two device records, one per protocol, and group them logically. Each device binds to exactly one collector.

Q: My OPC UA connection fails with a security error. A: Confirm the security policy matches the server. Many field devices only support None or Basic128Rsa15. Also verify the certificate trust list and that the endpoint URL uses the server's hostname.

Q: Modbus reads return garbage for 32-bit floats. A: This is almost always a byte-order issue. Try swapping the word order (big-endian vs little-endian) in the tag's byte-order setting until the value is correct.

  • ../../05-collector/README.md
  • ../../05-collector/plugin-detail.md
  • ../../17-sdk/README.md
  • ../../04-template/README.md
  • Protocol Types Dictionary