RMCLink.Interop .NET Assembly RMCLink.ReadFFile Method |
Reads one or more floating-point (F) registers from the controller. ReadFFile is typically used to read floating-point registers from the RMC70, RMC150, or RMC200. Compare with ReadLFile.
Visual Basic (Declaration) |
Public Sub ReadFFile ( _ file As Integer, _ element As Integer, _ data() As Single, _ offsetAs Integer, _ count As Integer _ ) |
Visual Basic (Usage) |
Dim instance As RMCLink Dim file As Integer Dim element As Integer Dim data() as Single Dim offset As Integer Dim count As Integer
instance.ReadFFile(file, element, data, offset, count) |
C# |
public void ReadFFile ( int file, int element, float[] data, intoffset, int count ) |
Visual C++/CLI |
public: void ReadFFile ( int file, int element, array<float>^ data, int offset, intcount ) |
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.Single 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.
Notice that all RMC100 registers are integers. Therefore, using this method to read data from the RMC100 will simply convert the values to floating point. For example, reading a value of 25 will be stored as a Single in the output array as 25.0.
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.
Exception Type |
Condition |
The read overflows the maximum file size of 65536 elements. The sum of offset and count must be less than or equal to 65536. |
|
The data parameter refers to a null (Nothing in Visual Basic) object. |
|
One of the file and element parameters is out of range. Ensure that file and element are between 0 and 65535. |
|
This read was cancelled by a call on another thread to one of the Disconnect and CancelRequest methods. |
|
The link is not currently connected. The Connect method must be called before attempting to read from the controller. |
|
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. |
The following code example illustrates the use of the ReadFFile 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 | ReadLFile
Copyright (c) 2024 Delta Computer Systems, Inc. dba Delta Motion