RMCLink COM Component RMCLink.LRegToFReg Method |
Converts an L register value into an intermediate form used when writing mixed F and L registers with WriteFFile.
Visual Basic (Declaration) |
Function LRegToFReg ( _ regValue As Long _ ) As Single |
Visual Basic (Usage) |
Dim instance As RMCLink Dim regValue As Long Dim returnValue As Single
returnValue = instance.LRegToFReg(regValue) |
regValue
The value of the L register.
The same regValue L register value, but as a Single data type ready to write with WriteFFile. Notice that this value is not usable at this stage. That is, it will appear to be a garbage value.
This function is used when writing to L registers in an RMC70, RMC150, or RMC200 using the WriteFFile method. Notice that this should only be done when the write is writing a mixture of L and F registers. Otherwise the WriteLFile method should be used to write exclusively F 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 LRegToFReg 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 first two variables are defined as follows:
' L56:0 - LoopCount (DINT, L register)
' F56:1 - SetPoint (REAL, F register)
' We want to write to both is a single write, but because they
' are mixed L and F registers, we must use the special LRegToFReg
' function to place the L register values in the array.
Dim data(1) As Single
data(0) = rmc.LRegToFReg(4) ' LoopCount will be 4.
data(1) = 10.5 ' SetPoint will be 10.5.
' Write to these two registers.
rmc.WriteFFile fn70VarCurValues, 0, 2, data
' Close the connection.
rmc.Disconnect
End Sub
|
VBScript |
Option Explicit
Dim srv, rmc
' 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 first two variables are defined as follows:
' L56:0 - LoopCount (DINT, L register)
' F56:1 - SetPoint (REAL, F register)
' We want to write to both is a single write, but because they
' are mixed L and F registers, we must use the special LRegToFReg
' function to place the L register values in the array.
Dim data(1)
data(0) = rmc.LRegToFReg(4) ' LoopCount will be 4.
data(1) = 10.5 ' SetPoint will be 10.5.
' Write to these two registers.
rmc.WriteFFile 56,0,2,data
' 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 first two variables are defined as follows:
// L56:0 - LoopCount (DINT, L register)
// F56:1 - SetPoint (REAL, F register)
// We want to write to both is a single write, but because they
// are mixed L and F registers, we must use the special LRegToFReg
// function to place the L register values in the array.
var data = new Array(2);
data[0] = rmc.LRegToFReg(4); // LoopCount will be 4.
data[1] = 10.5; // SetPoint will be 10.5.
// Write to these two registers.
rmc.WriteFFile(56,0,2,data);
// Close the connection.
rmc.Disconnect();
|
See Also
RMCLink Class | RMCLink COM Component
Copyright (c) 2024 Delta Computer Systems, Inc. dba Delta Motion