Skip to content
Embedded ADS Router

Embedded ADS Router

Adsify embeds an ADS TCP/IP router using the Beckhoff.TwinCAT.Ads.TcpRouter NuGet package. This eliminates the dependency on a locally installed TwinCAT AMS Router, enabling cross-platform operation on Linux, macOS, and Windows.

Startup Coordination

The router and connection pool use a two-phase startup:

  1. AdsRouterService (BackgroundService) starts the embedded AmsTcpIpRouter
  2. It signals readiness via AdsRouterReadySignal when RouterStatus.Started fires
  3. AdsConnectionPool waits for the signal before creating any connections

This prevents connection attempts before the router is ready.

Connection Pool

  • Creates one AdsConnection per configured PLC target
  • Maintains a background reconnection loop per connection
  • Exponential backoff: 1s, 2s, 4s, … capped at 30s
  • Write operations are serialized per-PLC via SemaphoreSlim
  • Read operations are concurrent (AdsClient is thread-safe for reads)

Graceful Degradation

If the router fails to start (e.g., missing AmsRouter:NetId), the connection pool runs without connections. API endpoints return 503 PLC_UNAVAILABLE instead of crashing.