Problem using LRegToFReg with C#

Hello,
I set up my Indirect Registers with 4 DWORDS followed by 4 REALS.

But I kept seeing invalid data when I used an array of ints and LRegToFReg.
So I reversed direction and used an array of floats with FRegToLReg for the
necessary registers. And then the data was correct.

So I put together both sets of code in the hope that someone will see what the
problem is. If you try the code just change the boolean ‘useInts’ to switch between
the method and generate the other file.

I’m sure it’s a simple mistake on my part but I just can’t find it. Hopefully
someone will see it.

BTW I’m using a RMC75E and Net 4.5

Thanks,

Skippy

[code] enum IndirectMemoryMapping /* element value /
{
StatusBitsAxis0 = 0, /
DWORD /
ErrorBitsAxis0 = 1, /
DWORD /
StatusBitsAxis1 = 2, /
DWORD /
ErrorBitsAxis1 = 3, /
DWORD */

        ActualPositionAxis0 = 4,  /* REAL */
        ActualVelocityAxis0 = 5,  /* REAL */
        ActualPositionAxis1 = 6,  /* REAL */
        ActualVelocityAxis1 = 7,  /* REAL */
        ControlOutputAxis0 = 8,   /* REAL */
    }

    private static int localCopyRmcDataLength = 8;

    private int[] localCopyRmcDataInts = new int[localCopyRmcDataLength];
    private float[] localCopyRmcDataFloats = new float[localCopyRmcDataLength];

    public static bool useInts = false;

    private void readRmcIndirectMemoryMap()
    {
        if (useInts)
        {
            rmc.ReadLFile((int)FileNumber70.fn70IndDataValues,
                (int)(IndirectMemoryMapping.StatusBitsAxis0),
                localCopyRmcDataInts,
                0,
                localCopyRmcDataLength);
        }
        else /* read floats */
        {
            rmc.ReadFFile((int)FileNumber70.fn70IndDataValues,
               (int)(IndirectMemoryMapping.StatusBitsAxis0),
               localCopyRmcDataFloats,
               0,
               localCopyRmcDataLength);
        }

        if (useInts)
        {
            using (FileStream fs = new FileStream("readingDataInts.txt", FileMode.Append, FileAccess.Write))
            using (StreamWriter sw = new StreamWriter(fs))
            {
                sw.WriteLine(String.Format("ar[0]: {0:D}",
                    localCopyRmcDataInts[0]));

                sw.WriteLine(String.Format("ar[1]: {0:D}",
                    localCopyRmcDataInts[1]));

                sw.WriteLine(String.Format("ar[2]: {0:D}",
                    localCopyRmcDataInts[2]));

                sw.WriteLine(String.Format("ar[3]: {0:D}",
                    localCopyRmcDataInts[3]));

                sw.WriteLine(String.Format("ar[4]: {0:F}",
                    RMCLink.LRegToFReg(localCopyRmcDataInts[4])));

                sw.WriteLine(String.Format("ar[5]: {0:F}",
                    RMCLink.LRegToFReg(localCopyRmcDataInts[5])));

                sw.WriteLine(String.Format("ar[6]: {0:F}",
                    RMCLink.LRegToFReg(localCopyRmcDataInts[6])));

                sw.WriteLine(String.Format("ar[7]: {0:F}",
                    RMCLink.LRegToFReg(localCopyRmcDataInts[7])));
                
                sw.WriteLine();
            }
        }
        else  /* read in floats */
        {
            using (FileStream fs = new FileStream("readingDataFloats.txt", FileMode.Append, FileAccess.Write))
            using (StreamWriter sw = new StreamWriter(fs))
            {
                sw.WriteLine(String.Format("ar[0]: {0:D}",
                    RMCLink.FRegToLReg(localCopyRmcDataFloats[0])));

                sw.WriteLine(String.Format("ar[1]: {0:D}",
                    RMCLink.FRegToLReg(localCopyRmcDataFloats[1])));

                sw.WriteLine(String.Format("ar[2]: {0:D}",                    
                    RMCLink.FRegToLReg(localCopyRmcDataFloats[2])));

                sw.WriteLine(String.Format("ar[3]: {0:D}",                    
                    RMCLink.FRegToLReg(localCopyRmcDataFloats[3])));

                sw.WriteLine(String.Format("ar[4]: {0:F4}",                    
                    localCopyRmcDataFloats[4]));

                sw.WriteLine(String.Format("ar[5]: {0:F4}",                    
                    localCopyRmcDataFloats[5]));

                sw.WriteLine(String.Format("ar[6]: {0:F4}",                    
                    localCopyRmcDataFloats[6]));

                sw.WriteLine(String.Format("ar[7]: {0:F4}",                    
                    localCopyRmcDataFloats[7]));

                sw.WriteLine();
            }
        }

[/code]