RMCLink.Interop .NET Assembly RMCLink.CreateEthernetLink Method |
Creates an RMCLink object for communicating with a controller (RMC70, RMC150, RMC200, or RMC100) over Ethernet.
Visual Basic (Declaration) |
Public Shared Function CreateEthernetLink ( _ devType As DeviceType, _ connectionString As String, _ ) As RMCLink |
Visual Basic (Usage) |
Dim devType As DeviceType Dim connectionString As String Dim returnValue As RMCLink
returnValue = RMCLink.CreateEthernetLink(devType,connectionString) |
C# |
public static RMCLink CreateEthernetLink ( DeviceType devType, string connectionString ) |
Visual C++/CLI |
public: static RMCLink^ CreateEthernetLink ( DeviceType devType, String^ connectionString ) |
devType
Specifies which type of RMC will be linked to. It must be DeviceType.RMC70, DeviceType.RMC150, DeviceType.RMC200, or DeviceType.RMC100.
connectionString
Specifies the TCP/IP host name for the controller to connect to. This can be an IP address string, such as "192.168.0.10" or a textual host name, such as "rmc.deltamotion.com". Additional options can also be specified as described under Advanced Communication Options.
Returns a reference to a new RMCLink object created for communicating with the specified device type over TCP/IP using the specified host name.
Notice that this method only creates the RMCLink object and does not connect to the controller. To connect to the device, you will need to call the Connect instance method. Because the object is only created and the connection is not made, this method returns immediately.
The connectionString parameter can optionally specify the following communication options if needed by the application.
Port Number (<hostName>:<portNum>)
This option specifies the TCP port number for RMCLink to use. The default port number is 44818 for the RMC75/150/200 and 1324 for the RMC100. This option should only be used to change the port number if there is a firewall or Network Address Translation (NAT) gateway that will translate to the correct port number (44818 or 1324) before RMCLink application traffic reaches the RMC controller.
To use a different port number, add ":<portNum>" immediately after the host name portion of the connectionString, where <portNum> is the port number to use.
Example:
192.168.0.10:2468
Connect to the RMC at 192.168.0.10 using TCP port 2468. Note that a firewall or NAT gateway must translate this to port 44818 (RMC75/150/200) or 1324 (RMC100) at the RMC controller.
Connection Size (connSize=<value>)
This option specifies the maximum EtherNet/IP messaging connection size to be used or may be used to select unconnected messaging. Larger connection sizes can greatly increase the data throughput for large transfers. This option is only supported when devType is DeviceType.RMC200.
To specify the connection size to use, add ";connSize=<value>" to the end of the connectionString parameter, where <value> is one of the following values:
0: Use EtherNet/IP unconnected messaging, which will limit each transaction to 504 bytes. Use this to match the behavior of RMCLink 4.1 and earlier.
512-17476: Use EtherNet/IP connected messaging with the specified connection size (in bytes). This method consumes a messaging connection resource in the RMC but allows for much larger transactions than unconnected messaging.
Note: RMCTools 4.25.0 and later provides 1416, 4336, 8716, 13096, and 17476 as options. Consider picking one of those values.
Values greater than 17476 will be truncated. Values of 1-511 will be rejected. If not specified, the default value of 8716 is used.
Note that this parameter controls the maximum size that RMCLink may use, and the connection size may be further limited by the controller firmware. Specifically, RMC200 firmware prior to 1.19.0 will limit the connection size to 1416 bytes.
Examples:
192.168.0.10;connSize=17476
Connect to the RMC at 192.168.0.10 using EtherNet/IP connected messaging with a connection size of up to 17476 bytes.
192.168.0.10;connSize=0
Connect to the RMC at 192.168.0.10 using EtherNet/IP unconnected messaging, which limits transactions to 504 bytes.
Timeout (timeout=<value>)
This option specifies the Ethernet timeout for each transaction. To set the timeout, add “;timeout=<value>” to the end of the connectionString parameter, where <value> is the timeout in milliseconds. The range is 500 to 10000 (0.5 to 10 seconds). Out-of-range values will be clamped to the range. If not specified, the default of 2000 (2 seconds) is used.
Examples:
192.168.0.10;timeout=6000
Connect to the RMC at 192.168.0.10 using an Ethernet timeout of 6 seconds.
192.168.0.10;timeout=1000
Connect to the RMC at 192.168.0.10 using an Ethernet timeout of 1 second.
Exception Type |
Condition |
The connectionString parameter refers to a null (Nothing in Visual Basic) object. |
|
Either the devType parameter is not set to DeviceType.RMC70, DeviceType.RMC150, DeviceType.RMC200, or DeviceType.RMC200, or the connectionString parameter is blank. |
The following code example illustrates the use of the CreateEthernetLink method.
Visual Basic |
Imports RMCLinkNET
Module Example
Sub Main()
' Create the object itself.
Dim rmc As RMCLink = RMCLink.CreateEthernetLink(DeviceType.RMC70, "192.168.0.10")
' Connect to the controller.
rmc.Connect()
' Read and display Axis 0's Actual Position (F8:8).
Dim data() As Single = New Single(0) {}
rmc.ReadFFile(FileNumber70.fn70StatusAxis0,8,data,0,1)
Console.WriteLine("Axis0 Actual Position = " & data(0) & " inches")
' Disconnect from the controller.
rmc.Disconnect()
End Sub
End Module
|
C# |
using System;
using RMCLinkNET;
namespace Example
{
public class Program
{
static void Main()
{
// Create the object itself.
RMCLink rmc = RMCLink.CreateEthernetLink(DeviceType.RMC70, "192.168.0.10");
// Connect to the controller.
rmc.Connect();
// Read and display Axis 0's Actual Position.
float[] data = new float[1];
rmc.ReadFFile(FileNumber70.fn70StatusAxis0,8,data,0,1);
Console.WriteLine("Axis0 Actual Position = " + data[0] + " inches");
// Disconnect from the controller.
rmc.Disconnect();
}
}
}
|
Visual C++/CLI |
using namespace System;
using namespace RMCLinkNET;
int main()
{
// Create the object itself.
RMCLink^ rmc = RMCLink::CreateEthernetLink(DeviceType::RMC70, "192.168.0.10");
// Connect to the controller.
rmc->Connect();
// Read and display Axis 0's Actual Position.
array<float>^ data = gcnew array<float>(1);
rmc->ReadFFile(FileNumber70::fn70StatusAxis0,8,data,0,1);
Console::WriteLine("Axis0 Actual Position = " + data[0] + " inches");
// Disconnect from the controller.
rmc->Disconnect();
return 0;
}
|
See Also
RMCLink.Interop .NET Assembly | RMCLinkNET Namespace | RMCLink Class | DeviceType
Copyright (c) 2024 Delta Computer Systems, Inc. dba Delta Motion