SHDR Output

Serve SHDR from the Adapter application for an Agent's SHDR Adapter module to connect to.
MTConnect.NET Docs Menu
  • Module name — MTConnect SHDR adapter module (adapter-side)
  • Identifier — shdr
  • NuGet package — MTConnect.NET-AdapterModule-SHDR
  • Source path — adapter/Modules/MTConnect.NET-AdapterModule-SHDR/

Purpose

Hosts an SHDR-protocol TCP server on the adapter host. The adapter publishes observation values it has read from its data source (PLC, CNC, sensor, simulator, etc.) to this server; an MTConnect agent's shdr-adapter module connects to it and forwards the observations into the agent. This is the canonical adapter-to-agent transport in MTConnect deployments — line-oriented, pipe-delimited, low-latency.

Configuration Schema

The module's configuration class is ModuleConfiguration (under MTConnect.Configurations in the MTConnect.NET-AdapterModule-SHDR assembly). The keys below describe the YAML map under shdr:.

KeyTypeDefaultPermissible valuesNotes
hostnamestringlocalhosthostname or IP addressThe address the SHDR server binds to. localhost accepts loopback only; set to 0.0.0.0 to accept from any interface.
portint78781-65535The TCP port the SHDR server listens on. 7878 is the conventional MTConnect SHDR port.
heartbeatint10000millisecondsThe heartbeat interval advertised in the server's * PONG response.
connectionTimeoutint5000millisecondsSilence threshold (for legacy clients that do not heartbeat) before disconnecting the client. Ignored when the client heartbeats.
reconnectIntervalint10000millisecondsDelay between adapter-source reconnection attempts.
timeZoneOutputstringZIANA TZ identifier or fixed offset (Z, +05:30, etc.)The time-zone identifier appended to outbound timestamps. Z is UTC.
deviceKeystring(none)device name or UUIDIdentifies which Device the observations target. Required for the agent's shdr-adapter to bind incoming observations.

Adapter-host vs module config

The shdr module is loaded by the adapter host's adapter.config.yaml. Some adapter-host implementations expose a top-level deviceKey rather than a per-module one — check the adapter-host's documentation for whether the key sits on the module entry or on the surrounding adapter: block.

Wire Interaction

Data sourceA PLC, sensor, or file
shdr output moduleListens in the Adapter host
SHDR
Agentshdr-adapter module
  1. Connect
  2. Module ModuleTCP listen on <hostname>:<port>
  3. Agent ModuleTCP connect to <hostname>:<port>
  4. Module AgentConnection accepted
  5. Data update
  6. Data source Adapter hostA new value (avail = AVAILABLE)
  7. Adapter host Moduleavail|AVAILABLE
  8. Module Agent2024-05-13T12:00:00Z|avail|AVAILABLE, appended to the sequence buffer
  9. Heartbeat
  10. Agent Module* PING
  11. Module Agent* PONG 10000
  12. Data source reconnect
  13. Data source Adapter hostDisconnected
  14. Adapter host Data sourceReconnect every reconnectInterval ms
The Agent's shdr-adapter module connects to the Adapter, which answers its heartbeats.

Example Configuration

modules:
  - shdr:
      hostname: 0.0.0.0
      port: 7878
      heartbeat: 10000
      connectionTimeout: 5000
      reconnectInterval: 10000
      timeZoneOutput: Z

For multiple SHDR endpoints on a single adapter host, declare the module several times — each entry binds a different port:

modules:
  - shdr:
      port: 7878
      deviceKey: M12346
  - shdr:
      port: 7879
      deviceKey: M67890

Troubleshooting

  • Port already in use — pick a different port. The MTConnect SHDR spec does not mandate 7878; conventionally many CNC adapters use it.
  • Agent shows the device as UNAVAILABLE — the adapter-side module must be connected to a data source, and the data source must publish an avail observation (or set availableOnConnection: true on the agent's shdr-adapter to default to AVAILABLE whenever the TCP connection is up).
  • Time-zone offset mismatch — the timeZoneOutput of the adapter and the timestamp parsing in the agent must agree. Z (UTC) is the safest default.
  • Asset count emitted as scalar EVENT — see Asset count emitted as scalar; the adapter must emit asset counts as DATA_SET observations.

Classes

The main classes in the MTConnect.NET-AdapterModule-SHDR package:

  • ModuleConfiguration — the adapter-side SHDR module configuration class (under MTConnect.Configurations in the MTConnect.NET-AdapterModule-SHDR assembly).
  • MTConnectAdapterModule — the base class adapter modules derive from.