RMCLink.Interop .NET Assembly

RMCLink.CreateUSBLink Method

Creates an RMCLink object for communicating with a controller (RMC70, RMC150, or RMC200) over a USB port.

Syntax

Visual Basic (Declaration)

Public Shared Function CreateUSBLink ( _

   devType As DeviceType, _

   deviceId As String _

) As RMCLink

 

Visual Basic (Usage)

Dim devType As DeviceType

Dim deviceId As String

Dim returnValue As RMCLink

 

returnValue = RMCLink.CreateUSBLink(devType, deviceId)

 

C#

public static RMCLink CreateUSBLink (

   DeviceType devType,

   string deviceId

)

 

Visual C++/CLI

public:

static RMCLink^ CreateUSBLink (

   DeviceType devType,

   String^ deviceId

)

Parameters

devType

Specifies which type of RMC will be linked to. It must be either DeviceType.RMC70, DeviceType.RMC150, or DeviceType.RMC200.

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

Returns a reference to a new RMCLink object created for communicating with the specified device type with the specified deviceId over a USB port.

Remarks

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

Exceptions

Exception Type

Condition

ArgumentNullException

The deviceId parameter refers to a null (Nothing in Visual Basic) object.

ArgumentOutOfRangeException

Either the devType parameter is set to neither DeviceType.RMC70, DeviceType.RMC150, nor DeviceType.RMC200, or the deviceId parameter is blank.

Example

The following code example illustrates the use of the CreateUSBLink method.

Visual Basic

Imports RMCLinkNET
 
Module Example
    Sub Main()
        ' Create the object itself.
        Dim rmc As RMCLink = RMCLink.CreateUSBLink(DeviceType.RMC70, "7573091001")
 
        ' 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.CreateUSBLink(DeviceType.RMC70, "7573091001");
 
            // 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::CreateUSBLink(DeviceType::RMC70, "7573091001");
 
    // 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


Send comments on this topic.

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