|
RMCLink.Interop .NET Assembly RMCLink.FRegToLReg Method |
Converts to an L register value from an intermediate form used when reading mixed F and L registers with ReadFFile.
|
Visual Basic (Declaration) |
|
Shared Public Function FRegToLReg ( _ registerValue As Single, _ ) As Integer |
|
Visual Basic (Usage) |
|
Dim registerValue As Single Dim returnValue As Float
returnValue = RMCLink.FRegToLReg(registerValue) |
|
C# |
|
static public int FRegToLReg ( float registerValue ) |
|
Visual C++/CLI |
|
public: static int FRegToLReg ( float registerValue ) |
registerValue
The value corresponding to an L register from the array of System.Single data types returned by ReadFFile. Notice that this value is not usable at this stage. That is, it will appear to be a garbage value, until converted by this method.
The L register value in a usable System.Int32 format.
This function is used when reading L registers from an RMC70, RMC150, or RMC200 using the ReadFFile method. Notice that this should only be done when the read is reading a mixture of L and F registers. Otherwise the ReadLFile method should be used to read exclusively L registers. Refer to the RMC70, RMC150 and RMC200 Register Data Types topic for details on L and F register types and on how to mix the two in a single read or write.
No exceptions are generated by this method.
The following code example illustrates the use of the FRegToLReg 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()
' Assume that the Indirect Data Map has been set up so that its
' first four registers correspond to the following:
' F18:0 = Axis 0 Status Bits (L register)
' F18:1 = Axis 0 Error Bits (L register)
' F18:2 = Axis 0 Actual Position (F register)
' F18:3 = Axis 0 Target Position (F register)
' Read up all four registers in a single read.
Dim data() as Single = New Single(3) {}
rmc.ReadFFile(FileNumber70.fn70IndDataValues, 0, data, 0, 4)
' At this point, data holds all four values. However, since
' the first two were strictly L registers, they cannot be used
' directly, since data(0) would return a bogus floating point
' value. Therefore, we use the FRegToLReg method. Notice that
' the F register values are used normally.
Console.WriteLine(String.Format("Status Bits = 0x{0:X8}", RMCLink.FRegToLReg(data(0))));
Console.WriteLine(String.Format("Error Bits = 0x{0:X8}", RMCLink.FRegToLReg(data(1))));
Console.WriteLine(String.Format("Actual Position = {0,-8:F3}", data(2)));
Console.WriteLine(String.Format("Target Position = {0,-8:F3}", data(3)));
' 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();
// Assume that the Indirect Data Map has been set up so that its
// first four registers correspond to the following:
// F18:0 = Axis 0 Status Bits (L register)
// F18:1 = Axis 0 Error Bits (L register)
// F18:2 = Axis 0 Actual Position (F register)
// F18:3 = Axis 0 Target Position (F register)
// Read up all four registers in a single read.
float[] data = new float[4];
rmc.ReadFFile(FileNumber70.fn70IndDataValues, 0, data, 0, 4);
// At this point, data holds all four values. However, since
// the first two were strictly L registers, they cannot be used
// directly, since data[0] would return a bogus floating point
// value, and even (long)data[0] would return a bogus long
// value. Therefore, we use the FRegToLReg method. Notice that
// the F register values are used normally.
Console.WriteLine(String.Format("Status Bits = 0x{0:X8}", RMCLink.FRegToLReg(data[0])));
Console.WriteLine(String.Format("Error Bits = 0x{0:X8}", RMCLink.FRegToLReg(data[1])));
Console.WriteLine(String.Format("Actual Position = {0,-8:F3}", data[2]));
Console.WriteLine(String.Format("Target Position = {0,-8:F3}", data[3]));
// 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();
// Assume that the Indirect Data Map has been set up so that its
// first four registers correspond to the following:
// F18:0 = Axis 0 Status Bits (L register)
// F18:1 = Axis 0 Error Bits (L register)
// F18:2 = Axis 0 Actual Position (F register)
// F18:3 = Axis 0 Target Position (F register)
// Read up all four registers in a single read.
array<float>^ data = gcnew array<float>(4);
rmc->ReadFFile(FileNumber70::fn70IndDataValues, 0, data, 0, 4);
// At this point, data holds all four values. However, since
// the first two were strictly L registers, they cannot be used
// directly, since data[0] would return a bogus floating point
// value, and even (long)data[0] would return a bogus long
// value. Therefore, we use the FRegToLReg method. Notice that
// the F register values are used normally.
Console::WriteLine(String::Format("Status Bits = 0x{0:X8}", RMCLink::FRegToLReg(data[0])));
Console::WriteLine(String::Format("Error Bits = 0x{0:X8}", RMCLink::FRegToLReg(data[1])));
Console::WriteLine(String::Format("Actual Position = {0,-8:F3}", data[2]));
Console::WriteLine(String::Format("Target Position = {0,-8:F3}", data[3]));
// Disconnect from the controller.
rmc->Disconnect();
return 0;
}
|
See Also
RMCLink.Interop .NET Assembly | RMCLinkNET Namespace | RMCLink Class
Copyright (c) 2024 Delta Computer Systems, Inc. dba Delta Motion