AnsweredAssumed Answered

Why are my values not getting stored correctly

Question asked by schrecengost Champion on Jan 17, 2018
Latest reply on Jan 18, 2018 by rdavin

I am trying to write values to PI but am not getting the results I expected.  When I write 51.200001.  PI stores 51.20000076.  I write 51.200002. PI Stores 51.20000076 (same as before).  When I write 51.200003, PI stores 51.20000458.

 

Here is the C# code.  I am using the UpdateValue method.  The NewValue object is a C# decimal.  I have ran my program in debug and verifed the decimal value sent to PI.

 

class PI

    {

        static private PISDK.PISDK mSDK;

        static private PISDK.Server mServer;

        static private PISDK.PIPoints mPoints;

 

 

        public PI(String ServerName, String UserName, String PassWord="")

        {

            mSDK = new PISDK.PISDK();

            mServer = mSDK.Servers[ServerName];

            mPoints = mServer.PIPoints;

           

 

 

        }

 

 

        public static PISDK.PIValue GetSnapshotValue(String TagName)

        {

            PISDK.PIValue mValue;

            PISDK.PIPoint mPoint;            

           

            mPoint = mPoints[TagName];

            mValue = mPoint.Data.Snapshot;

 

 

            return mValue;

        }

 

 

        public static void UpdateValue(String TagName, String TimeStamp, Object NewValue )

        {

            mPoints[TagName].Data.UpdateValue(NewValue, TimeStamp);

        }

    }

Outcomes