RMCLink.Interop .NET Assembly RMCLink.WriteLFile Method |
Writes to one or more integer (L) registers in the controller. Since all RMC100 registers are integer registers, this function should be used for all writes to RMC100 controllers. It should also be used when writing integer values to RMC70, RMC150, or RMC200 registers. Compare with WriteFFile.
Visual Basic (Declaration) |
Public Sub WriteLFile ( _ 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.WriteLFile(file, element, data, offset, count) |
C# |
public void WriteLFile ( int file, int element, int[] data, int offset, int count ) |
Visual C++/CLI |
public: void WriteLFile ( int file, int element, array<int>^ data, int offset, int count ) |
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.Int32 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 written from the data array into 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 WriteLFile method.
Visual Basic |
Imports RMCLinkNET
Module Example
Sub Main()
' Create the object itself.
Dim rmc As RMCLink = RMCLink.CreateEthernetLink(DeviceType.RMC100, "192.168.0.10")
' Connect to the controller.
rmc.Connect()
' Issue a Go (G) command to axis 0.
Dim cmd() As Integer = new Integer(5) {}
cmd(0) = &H81 ' Mode (S-Curves, Accel/Decel in pu/s/s)
cmd(1) = 100 ' Accel
cmd(2) = 100 ' Decel
cmd(3) = 1000 ' Speed
cmd(4) = 10000 ' Req. Position (10.000 inches)
cmd(5) = Asc("G") ' Command (Go)
rmc.WriteLFile(FileNumber100.fn100CommandAxis0,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.RMC100, "192.168.0.10");
// Connect to the controller.
rmc.Connect();
// Issue a Go (G) command to axis 0.
int[] cmd = new int[6];
cmd[0] = 0x0081; // Mode (S-Curves, Accel/Decel in pu/s/s)
cmd[1] = 100; // Accel
cmd[2] = 100; // Decel
cmd[3] = 1000; // Speed
cmd[4] = 10000; // Req. Position (10.000 inches)
cmd[5] = (int)'G'; // Command
rmc.WriteLFile(FileNumber100.fn100CommandAxis0,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 Go (G) command to axis 0.
array<int>^ cmd = gcnew array<int>(6);
cmd[0] = 0x0081; // Mode (S-Curves, Accel/Decel in pu/s/s)
cmd[1] = 100; // Accel
cmd[2] = 100; // Decel
cmd[3] = 1000; // Speed
cmd[4] = 10000; // Req. Position (10.000 inches)
cmd[5] = (int)'G'; // Command
rmc->WriteLFile(FileNumber100.fn100CommandAxis0,0,cmd,0,6);
// Disconnect from the controller.
rmc->Disconnect();
return 0;
}
|
See Also
RMCLink.Interop .NET Assembly | RMCLinkNET Namespace | RMCLink Class | WriteFFile
Copyright (c) 2024 Delta Computer Systems, Inc. dba Delta Motion