FB_AddRouteEntry

This function block adds a new AMS Router connection (remote route) to a TwinCAT System.
VAR_INPUT
VAR_INPUT
sNetID : T_AmsNetID;
stRoute : ST_AmsRouteEntry;
bExecute : BOOL;
tTimeout : TIME := DEFAULT_ADS_TIMEOUT;
END_VAR
sNetID: Here a string containing the network address of the TwinCAT Computer can be given, whose AMS Router connection list should be added by a new connection. The string can also be empty for the local computer.
stRoute: Structure element with parameters of the new connection.
bExecute: The function block is activated by a positive edge at this input.
tTimeout: States the length of the timeout that may not be exceeded by execution of the ADS command.
VAR_OUTPUT
VAR_OUTPUT
bBusy : BOOL;
bError : BOOL;
nErrId : UDINT;
END_VAR
bBusy: When the function block is activated this output is set. It remains set until and acknowledgement is received.
bError: If an ADS error should occur during the execution of the command, then this output is set, after the bBusy output has been reset.
nErrId: When the bError output is set, this variable supplies the ADS error code.
Example in FBD:
A new AMS Router connection should be added on the local TwinCAT System with the connection name: "TEST", TwinCAT network address: "172.16.6.111.1.1", IP address: "172.16.6.111" and the transport medium: "TCP/IP".
PROGRAM P_TEST3
VAR
fbAddRoute : FB_AddRouteEntry;
bExecute : BOOL;
bBusy : BOOL;
bError : BOOL;
nErrID : UDINT;
stRoute : ST_AmsRouteEntry := ( sName := 'TEST',
sNetID := '172.16.6.111.1.1',
sAddress := '172.16.6.111',
eTransport := eRouteTransport_TCP_IP );
END_VAR
The required connection parameters are initialised in the declaratoin part. The new connection is added by a positive edge a the bExecute variable.
Requirements
Development environment | Target system type | PLC libraries to include |
---|---|---|
TwinCAT v2.9.0 Build > 1033 TwinCAT v2.10.0 Build > 1257 | PC or CX (x86) | TcUtilities.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib are included automatically ) |
TwinCAT v2.10.0 Build >= 1301 | CX (ARM) |