RMCLink.Interop .NET Assembly

RMCLink.ReadLFile Method

Reads one or more integer (L) registers from the controller. ReadLFile is typically used to read RMC100 registers (which are all integer registers), or to read RMC70, RMC150, or RMC200 registers in integer format. Compare with ReadFFile.

Syntax

Visual Basic (Declaration)

Public Sub ReadLFile ( _

   file As Integer, _

   element As Integer, _

   data() As Integer, _

   offsetAs Integer, _

   count As Integer _

)

 

Visual Basic (Usage)

Dim instance As RMCLink

Dim file As Integer

Dim element As Integer

Dim data() as Integer

Dim offset As Integer

Dim count As Integer

 

instance.ReadLFile(file, element, data, offset, count)

 

C#

public void ReadLFile (

   int file,

   int element,

   int[] data,

   int offset,

   int count

)

 

Visual C++/CLI

public:

void ReadLFile (

   int file,

   int element,

   array<int>^ data,

   int offset,

   int count

)

Parameters

file

File number of the first register to be read. See the RMCLink Register Reference for details.

element

Element number of the first register to be read. See the RMCLink Register Reference for details.

data

The array of System.Int32 into which the read data is to be placed. The offset and count parameters determine the actual location in the array.

offset

The element number in the destination data array where the first read value will be placed. This offset only applies to the destination array and will not affect the read location.

count

The number of registers to read and placed in data.

Remarks

For details on integer (L) and floating-point (F) registers and how to read from and write to both, see RMC100 Register Data Types or RMC70, RMC150, and RMC200 Register Data Types.

This method is synchronous, which means that it will not return until the read is completed, which may take several seconds. If this method is called on the main thread, then the application will likely be unresponsive until this method completes. For applications where this is not acceptable, this and other synchronous methods should be called from a worker thread, and may use the CancelRequest method to cancel an in progress request.

Exceptions

Exception Type

Condition

ArgumentException

The read overflows the maximum file size of 65536 elements. The sum of offset and count must be less than or equal to 65536.

ArgumentNullException

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

ArgumentOutOfRangeException

One of the file and element parameters is out of range. Ensure that file and element are between 0 and 65535.

CancelledException

This read was cancelled by a call on another thread to one of the Disconnect and CancelRequest methods.

InvalidOperationException

The link is not currently connected. The Connect method must be called before attempting to read from the controller.

ReadWriteFailedException

The read failed due to a communication failure. Check that the remote device is powered up, check the communication wiring, and check the communication configuration of both the local and remote devices. Check the Message property of the exception for a description of the communication failure.

Example

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

Visual Basic

Imports RMCLinkNET
 
Module Example
    Sub Main()
        ' Create the object itself.
        Dim rmc As RMCLink = RMCLink.CreateSerialLink(DeviceType.RMC100, "COM1")
 
        ' Connect to the controller.
        rmc.Connect()
 
        ' Read and display Axis 0's Command, Target, and Actual Positions (L0:0-2).
        Dim data() As Integer = New Integer(2) {}
        rmc.ReadLFile(FileNumber100.fn100StatusAxis0,0,data,0,3)
 
        Console.WriteLine("Axis 0:")
        Console.WriteLine(" Command Position: " & data(0) & " inches")
        Console.WriteLine("  Target Position: " & data(1) & " inches")
        Console.WriteLine("  Actual Position: " & data(2) & " 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.RMC100, "COM1");
 
            // Connect to the controller.
            rmc.Connect();
 
            // Read and display Axis 0's Command, Target, and Actual Positions (L0:0-2).
            float[] data = new float[3];
            rmc.ReadLFile(FileNumber100.fn100StatusAxis0,0,data,0,3);
 
            Console.WriteLine("Axis 0:");
            Console.WriteLine(" Command Position: " + data[0] + " inches");
            Console.WriteLine("  Target Position: " + data[1] + " inches");
            Console.WriteLine("  Actual Position: " + data[2] + " 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::RMC100, "COM1");
 
    // Connect to the controller.
    rmc->Connect();
 
    // Read and display Axis 0's Command, Target, and Actual Positions (L0:0-2).
    array<float>^ data = gcnew array<float>(3);
    rmc->ReadLFile(FileNumber100::fn100StatusAxis0,0,data,0,3);
 
    Console::WriteLine("Axis 0:");
    Console::WriteLine(" Command Position: " + data[0] + " inches");
    Console::WriteLine("  Target Position: " + data[1] + " inches");
    Console::WriteLine("  Actual Position: " + data[2] + " inches");
 
    // Disconnect from the controller.
    rmc->Disconnect();
 
    return 0;
}

 

See Also

RMCLink.Interop .NET Assembly | RMCLinkNET Namespace | RMCLink Class | ReadFFile


Send comments on this topic.

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