RouterConfig Class

Router Configuration class (AmsRouter configuration)

Inheritance Hierarchy

SystemObject
  TwinCAT.Ads.ConfigurationRouterConfig

Namespace: TwinCAT.Ads.Configuration
Assembly: TwinCAT.Ads.ConfigurationProviders (in TwinCAT.Ads.ConfigurationProviders.dll) Version: 7.0.0+e56d35ccc4675faac24789a4aab60071fc61d470

Syntax

C#

public class RouterConfig

The RouterConfig type exposes the following members.

Properties

 

Name

Description

ChannelPortType

Gets or sets the Ads/Ams infrastructure to use (Default: All)

ChannelProtocol

Gets or sets the used ADS Channel protocol (to force specific protocols, Default: All)

LoopbackExternalIPs

Gets or sets the loopback externals.

LoopbackExternalSubnet

Gets or sets the allowed Subnet for the Loopback communication.

LoopbackIP

Gets or sets the IPAddress used for local communication (Loopback ip).

LoopbackPort

Gets or sets the TCP Port that is used for the loopback.

Mqtt

Gets or sets the MQTT configurations.

Name

Gets or sets the name of the local System (Router)

NetId

Gets or sets the NetID of the local System.

RemoteConnections

Gets or sets the remote Routes/Connections.

TcpPort

Gets or sets the TCP port used for external communication (Default: 0xBF02)

UdpDiscoveryPort

Gets or sets the UDP discovery port that is used by the Broadcast.

Methods

 

Name

Description

Equals

Determines whether the specified object is equal to the current object.
(Inherited from Object)

Finalize

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object)

GetHashCode

Serves as the default hash function.
(Inherited from Object)

GetType

Gets the Type of the current instance.
(Inherited from Object)

MemberwiseClone

Creates a shallow copy of the current Object.
(Inherited from Object)

ToString

Returns a string that represents the current object.
(Inherited from Object)

Remarks

The content of the configuration is read by a so called configuration builder (https://learn.microsoft.com/en-us/dotnet/core/extensions/configuration). A set of environment variables for using 'AdsOverMqtt' looks like this:

Batch Script

# Basic ADS-Router config which has to match StaticRoutes on TwinCAT-Host systems
# Set the Router Name
AmsRouter__Name=MqttRouter
# Set the Local AmsNetId for this sample
AmsRouter__NetId = 42.42.42.42.1.1 

#Use All Channel protocols: 1st try standard AMS, 2nd fallback to Mqtt
AmsRouter__ChannelProtocol=All

AmsRouter__Mqtt__0__NORETAIN = false
AmsRouter__Mqtt__0__UNIDIRECTIONAL=false
AmsRouter__Mqtt__0__PORT=8883
AmsRouter__Mqtt__0__ADDRESS=ba-0f8cfe2680560cffb.eu-central-1.demo.beckhoff-cloud-instances.com
AmsRouter__Mqtt__0__TOPIC = VirtualAmsNetwork1
AmsRouter__Mqtt__0__TLS__IGNORECN=false
AmsRouter__Mqtt__0__TLS__CA__0=C:\Program Files(x86)\Beckhoff\TwinCAT\3.1\Target\Certificates\BA-0f8cfe2680560cffb\intermediateCA.pem
AmsRouter__Mqtt__0__TLS__CERT = C:\Program Files(x86)\Beckhoff\TwinCAT\3.1\Target\Certificates\BA-0f8cfe2680560cffb\MyDevice.pem
AmsRouter__Mqtt__0__TLS__KEY = C:\Program Files(x86)\Beckhoff\TwinCAT\3.1\Target\Certificates\BA-0f8cfe2680560cffb\MyDevice.key
AmsRouter__Mqtt__0__TLS__VERSION = tlsv1.2

Internally, in the IConfiguration section dictionary, thise key value associations look like this:

Batch Script

AmsRouter:Name=MqttRouter
AmsRouter:NetId = 42.42.42.42.1.1 
AmsRouter:ChannelProtocol=All
AmsRouter:Mqtt:0:NORETAIN = false
AmsRouter:Mqtt:0:UNIDIRECTIONAL=false
AmsRouter:Mqtt:0:PORT=8883
AmsRouter:Mqtt:0:ADDRESS=ba-0f8cfe2680560cffb.eu-central-1.demo.beckhoff-cloud-instances.com
AmsRouter:Mqtt:0:TOPIC = VirtualAmsNetwork1
AmsRouter:Mqtt:0:TLS:IGNORECN=false
AmsRouter:Mqtt:0:TLS:CA:0=C:\Program Files(x86)\Beckhoff\TwinCAT\3.1\Target\Certificates\BA-0f8cfe2680560cffb\intermediateCA.pem
AmsRouter:Mqtt:0:TLS:CERT = C:\Program Files(x86)\Beckhoff\TwinCAT\3.1\Target\Certificates\BA-0f8cfe2680560cffb\MyDevice.pem
AmsRouter:Mqtt:0:TLS:KEY = C:\Program Files(x86)\Beckhoff\TwinCAT\3.1\Target\Certificates\BA-0f8cfe2680560cffb\MyDevice.key
AmsRouter:Mqtt:0:TLS:VERSION = tlsv1.2

Reference

TwinCAT.Ads.Configuration Namespace

Other Resources

https://learn.microsoft.com/en-us/dotnet/core/extensions/configuration

Beckhoff Automation GmbH & Co. KG 2001-2026