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.

Syntax

C++

static CRMCLink* CreateEthernetLink(

   enumDEVICETYPE devType,

   LPCTSTR connectionString

);

Parameters

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.

Return Value

On success, a pointer to a newly allocated CRMCLink object is returned. On failure, NULL is returned.

Remarks

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.

Advanced Communication Options

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:

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:

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:

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:

Example

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


Send comments on this topic.

Copyright (c) 2024 Delta Computer Systems, Inc. dba Delta Motion