RMCLink C++ Wrapper Class

CRMCLink::LRegToFReg Method

Converts an L register value into an intermediate form used when writing mixed F and L registers with WriteFFile.

Syntax

C++

static float LRegToFReg(

   long regValue

);

Parameters

regValue

The value of the L register.

Return Value

The same regValue L register value, but as a float 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.

Remarks

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.

Example

The following code example illustrates the use of the LRegToFReg method.

C++

#include <windows.h>
#include <stdio.h>
#include "RMCLink.h"
 
void main()
{
    // In order to create COM objects, we must initialize the COM sub-system.
    ::CoInitialize(0);
 
    // Create a new RMCLink object.
    CRMCLink* pRMC = CRMCLink::CreateEthernetLink(CRMCLink::dtRMC70, _T("192.168.0.22"));
    if ( pRMC != NULL )
    {
        // Establish the connection.
        HRESULT hr = pRMC->Connect();
        if ( SUCCEEDED(hr) )
        {
            // 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.
            float afData[2];
            afData[0] = CRMCLink::LRegToFReg(4); // LoopCount will be 4.
            afData[1] = 10.5;                    // SetPoint will be 10.5.
 
            // Write to these two registers.
            pRMC->WriteFFile(CRMCLink::fn70VarCurValues, 0, 2, afData);
 
            // Close the connection.
            pRMC->Disconnect();
        }
 
        // Free the RMCLink object we created.
        delete pRMC;
    }
 
    // Release the COM sub-system.
    ::CoUninitialize();
}

 

See Also

CRMCLink Class | RMCLink C++ Wrapper Class


Send comments on this topic.

Copyright (c) 2024 Delta Computer Systems, Inc. dba Delta Motion