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:
AdsRouterService(BackgroundService) starts the embeddedAmsTcpIpRouter- It signals readiness via
AdsRouterReadySignalwhenRouterStatus.Startedfires AdsConnectionPoolwaits for the signal before creating any connections
This prevents connection attempts before the router is ready.
Connection Pool
- Creates one
AdsConnectionper 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.