RMCLink C++ Wrapper Class CRMCLink::CreateEthernetLink Method |
Creates an instance of the CRMCLink class for communicating with a controller (RMC70, RMC150, RMC200, or RMC100) over Ethernet.
C++ |
static CRMCLink* CreateEthernetLink( enumDEVICETYPE devType, LPCTSTR connectionString ); |
devType
Specifies which type of RMC will be linked to. It must be dtRMC70, dtRMC150, dtRMC200, or dtRMC100.
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.
On success, a pointer to a newly allocated CRMCLink object is returned. On failure, NULL is returned.
Notice that this method only creates the CRMCLink object and does not connect to the controller. To connect to the device, you will need to call the CRMCLink::Connect instance method. Because the object is only created and the connection is not made, this method returns immediately.
Free the CRMCLink class instance with the C++ delete keyword when you are done with it.
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 dtRMC200.
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.
The following code example illustrates the use of the CreateEthernetLink method.
C++ |
#include <windows.h>
#include <stdio.h>
#include "RMCLink.h"
void main()
{
// In order to create COM objects, we must initialize the COM sub-system.
::CoInitialize(0);
// Create a new RMCLink object.
CRMCLink* pRMC = CRMCLink::CreateEthernetLink(CRMCLink::dtRMC70, _T("192.168.0.22"));
if ( pRMC != NULL )
{
// Establish the connection.
HRESULT hr = pRMC->Connect();
if ( SUCCEEDED(hr) )
{
// Read F8:8 and F8:9 (Axis 0 Actual Position and Velocity)
float afData[2];
hr = pRMC->ReadFFile(CRMCLink::fn70StatusAxis0, 8, 2, afData);
if ( SUCCEEDED(hr) )
{
printf("Actual Position = %.3f, Actual Velocity = %.3f\n",
afData[0], afData[1]);
}
// Close the connection.
pRMC->Disconnect();
}
// Free the RMCLink object we created.
delete pRMC;
}
// Release the COM sub-system.
::CoUninitialize();
}
|
See Also
CRMCLink Class | RMCLink C++ Wrapper Class | CRMCLink::enumDEVICETYPE
Copyright (c) 2024 Delta Computer Systems, Inc. dba Delta Motion