RMCLink.Interop .NET Assembly RMCLink.WriteFFile Method |
Writes to one or more floating-point (F) registers in the controller. Notice that since all RMC100 registers are integers, WriteLFile should be used instead for that controller type. Use WriteFFile when writing to floating-point RMC70, RMC150, or RMC200 registers. Compare with WriteLFile.
Visual Basic (Declaration) |
Public Sub WriteFFile ( _ 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.WriteFFile(file, element, data, offset, count) |
C# |
public void WriteFFile ( int file, int element, float[] data, intoffset, int count ) |
Visual C++/CLI |
public: void WriteFFile ( int file, int element, array<float>^ data, int offset, intcount ) |
file
File number of the first register to write to. See the RMCLink Register Reference for details.
element
Element number of the first register to write to. See the RMCLink Register Reference for details.
data
The array of System.Single that holds the data to be written to the controller. Notice that the offset and count parameters control which portion of the array will be written.
offset
The element number in the source data array of the first write value. This offset only applies to the source array and will not affect the write location.
count
The number of registers to be written from the data array into the controller.
Notice that all RMC100 registers are integers. Therefore, using this method to write data to the RMC100 will simply round the values to integers before writing them to the controller.
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 write 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 |
Either the data being written to is read-only, or the write 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 write 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 write to the controller. |
|
The write 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 WriteFFile method.
Visual Basic |
Imports RMCLinkNET
Module Example
Sub Main()
' Create the object itself.
Dim rmc As RMCLink = RMCLink.CreateEthernetLink(DeviceType.RMC70, "192.168.0.10")
' Connect to the controller.
rmc.Connect()
' Issue a Move Absolute (20) command to axis 0.
Dim cmd() As Single = new Single(5) {}
cmd(0) = 20 ' Move Absolute (20)
cmd(1) = 10.0 ' Position (10 in)
cmd(2) = 10.0 ' Speed (10 in/s)
cmd(3) = 100.0 ' Accel (100 in/s/s)
cmd(4) = 100.0 ' Decel (100 in/s/s)
cmd(5) = 0 ' Direction (Nearest)
rmc.WriteFFile(FileNumber70.fn70CommandArea,0,cmd,0,6);
' 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.CreateEthernetLink(DeviceType.RMC70, "192.168.0.10");
// Connect to the controller.
rmc.Connect();
// Issue a Move Absolute (20) command to axis 0.
float[] cmd = new float[6];
cmd[0] = 20; // Move Absolute (20)
cmd[1] = 10.0; // Position (10 in)
cmd[2] = 10.0; // Speed (10 in/s)
cmd[3] = 100.0; // Accel (100 in/s/s)
cmd[4] = 100.0; // Decel (100 in/s/s)
cmd[5] = 0; // Direction (Nearest)
rmc.WriteFFile(FileNumber70.fn70CommandArea,0,cmd,0,6);
// Disconnect from the controller.
rmc.Disconnect();
}
}
}
|
Visual C++/CLI |
using namespace System;
using namespace RMCLinkNET;
int main()
{
// Create the object itself.
RMCLink^ rmc = RMCLink::CreateEthernetLink(DeviceType::RMC70, "192.168.0.10");
// Connect to the controller.
rmc->Connect();
// Issue a Move Absolute (20) command to axis 0.
array<float>^ cmd = gcnew array<float>(6);
cmd[0] = 20; // Move Absolute (20)
cmd[1] = 10.0; // Position (10 in)
cmd[2] = 10.0; // Speed (10 in/s)
cmd[3] = 100.0; // Accel (100 in/s/s)
cmd[4] = 100.0; // Decel (100 in/s/s)
cmd[5] = 0; // Direction (Nearest)
rmc.WriteFFile(FileNumber70::fn70CommandArea,0,cmd,0,6);
// Disconnect from the controller.
rmc->Disconnect();
return 0;
}
|
See Also
RMCLink.Interop .NET Assembly | RMCLinkNET Namespace | RMCLink Class | WriteLFile
Copyright (c) 2024 Delta Computer Systems, Inc. dba Delta Motion