RMCLink C++ Wrapper Class

CRMCLink::CreateUSBLink Method

Creates an instance of the CRMCLink class for communicating with a controller (RMC70, RMC150, or RMC200) over a USB port.

Syntax

C++

static CRMCLink* CreateUSBLink(

   enumDEVICETYPE devType,

   LPCTSTR deviceID

);

Parameters

devType

Specifies which type of RMC will be linked to. It must be either dtRMC70, dtRMC150 or dtRMC200.

deviceID

Specifies which controller to connect to over the USB port:

RMC75E: The controller’s 10-digit serial number in the format ”7573xxyyzz”.

RMC150: The Ethernet (MAC) Address in the format ”00-50-A0-xx-yy-zz”.

RMC200: The CPU module's serial number in the format ”22Cyynnnn”.

Return Value

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

Remarks

Notice that this method does not in any way try to connect to the controller. This method simply creates the CRMCLink object. 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.

Example

The following code example illustrates the use of the CreateUSBLink 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::CreateUSBLink(CRMCLink::dtRMC70, _T("7573091001"));
    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