|
RMCLink COM Component 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) |
|
Function FRegToLReg ( _ regValue As Single _ ) As Long |
|
Visual Basic (Usage) |
|
Dim instance As RMCLink Dim regValue As Single Dim returnValue As Long
returnValue = instance.FRegToLReg(regValue) |
regValue
The value corresponding to an L register from the array of 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 32-bit integer 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 6 / VBA |
Option Explicit Public Sub Sample() ' Declare and create the RMCLinkServer COM object. Dim srv As New RMCLinkServer ' Use our RMCLinkServer to create the correct type of RMCLink object. Dim rmc As RMCLink Set rmc = srv.CreateEthernetLink(dtRMC70, "192.168.0.22") ' Establish the connection. 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 from the Indirect Data Map. Dim data As Variant data = rmc.ReadFFile(fn70IndDataValues, 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. statusBitsValue.Text = rmc.FRegToLReg(data(0)) errorBitsValue.Text = rmc.FRegToLReg(data(1)) actPosValue.Text = data(2) tarPosValue.Text = data(3) ' Close the connection. rmc.Disconnect End Sub |
|
VBScript |
Option Explicit
Dim srv, rmc, data
' First we need to create the RMCLinkServer COM object.
Set srv = CreateObject("RMCLink.RMCLinkServer")
' Use our RMCLinkServer to create the correct type of RMCLink object.
' NOTE: VBScript does not support enumerations, so we use the literal value (dtRMC70=2).
Set rmc = srv.CreateEthernetLink(2, "192.168.0.22")
' Establish the connection.
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 from the Indirect Data Map.
data = rmc.ReadFFile_Script(18,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.
WScript.Echo "Status Bits = " & rmc.FRegToLReg(data(0))
WScript.Echo "Error Bits = " & rmc.FRegToLReg(data(1))
WScript.Echo "Actual Position = " & data(2)
WScript.Echo "Target Position = " & data(3)
' Close the connection.
rmc.Disconnect
|
|
JScript |
// First we need to create the RMCLinkServer COM object.
var srv = new ActiveXObject("RMCLink.RMCLinkServer");
// Use our RMCLinkServer to create the correct type of RMCLink object.
// NOTE: JScript does not support enumerations, so we use the literal value (dtRMC70=2).
var rmc = srv.CreateEthernetLink(2, "192.168.0.22");
// Establish the connection.
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 from the Indirect Data Map.
var data = rmc.ReadFFile_Script(18,0,4).toArray();
// 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.
WScript.echo("Status Bits = " + rmc.FRegToLReg(data[0]));
WScript.echo("Error Bits = " + rmc.FRegToLReg(data[1]));
WScript.echo("Actual Position = " + data[2]);
WScript.echo("Target Position = " + data[3]);
// Close the connection.
rmc.Disconnect();
|
See Also
RMCLink Class | RMCLink COM Component
Copyright (c) 2024 Delta Computer Systems, Inc. dba Delta Motion