RMCLink.Interop .NET Assembly

RMCLink.CreateSerialLink Method

Creates an RMCLink object for communicating with a controller (either RMC70 or RMC100) over a serial port.

Syntax

Visual Basic (Declaration)

Public Shared Function CreateSerialLink ( _

   devType As DeviceType, _

   portName As String _

) As RMCLink

 

Visual Basic (Usage)

Dim devType As DeviceType

Dim portName As String

Dim returnValue As RMCLink

 

returnValue = RMCLink.CreateSerialLink(devType, portName)

 

C#

public static RMCLink CreateSerialLink (

   DeviceType devType,

   string portName

)

 

Visual C++/CLI

public:

static RMCLink^ CreateSerialLink (

   DeviceType devType,

   String^ portName

)

Parameters

devType

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

portName

Specifies the serial port to use for communicating with the device. Typical names include "COM1" and "COM2".

Return Value

Returns a reference to a new RMCLink object created for communicating with the specified device type on the specified serial 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. This method will support any com port on the PC.

Because the object is only created and the connection is not made, this method returns immediately.

Exceptions

Exception Type

Condition

ArgumentNullException

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

ArgumentOutOfRangeException

Either the devType parameter is set to neither DeviceType.RMC70 nor DeviceType.RMC100, or the portName parameter is blank.

Example

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

Visual Basic

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