AnsweredAssumed Answered

How to retrieve data in datatable format

Question asked by ibuddler on Dec 1, 2019
Latest reply on Dec 3, 2019 by Rick_Davin_3.0
Right now I'm using AFValues.GetValueArrays. Wondering if there's a way to get the data and output as a datatable in a format of <Datetime>,<value>?
Thanks in advance.
        public bool TrySelect(out object[] pidata)
        {
            pidata = null;
            bool retVal = false;
            PIServers myPIServers = new PIServers();
            PIServer myPIServer = myPIServers.DefaultPIServer;
            try
            {
                myPIServer.Connect();
                PIPoint tagPIPoint = PIPoint.FindPIPoint(myPIServer, PiTag);
                if (tagPIPoint != null)
                {
                    AFValues tagInterpolated = tagPIPoint.InterpolatedValuesAtTimes(PiTimes, "", false);
                    tagInterpolated.GetValueArrays(out pidata, out _, out _);
                    retVal = true;
                }               
            }
            catch (Exception e)
            {               
                Console.WriteLine("Failed to get PI data: {0}. Error: {1}", PiTag, e.Message);                        
            }
            finally
            {
                myPIServer.Disconnect();           
            }
            return retVal;
        }

Outcomes