AnsweredAssumed Answered

What is the best way to get hourly data using AFAttribute?

Question asked by eradwan on Apr 6, 2016
Latest reply on Apr 6, 2016 by pthivierge

Hi There,

 

I'm trying the following code where I need hourly data for a time range, however, I noticed that the returned values aren't stamped exactly at the beginning of the hour although the time range begins at mid-night! Is this the best way to navigate from AF attribute to its pi data?

 

AFDatabase eMDatabase = connection.GetDatabase();
AFCategory nOxWeeklyEmissions = eMDatabase.AttributeCategories["NOxWeeklyEmissions"];


AFAttributeList nOxAttribList = AFAttribute.FindElementAttributes(eMDatabase,null, "*",null, null, AFElementType.Any, "*", nOxWeeklyEmissions, TypeCode.Empty, true, AFSortField.Name, AFSortOrder.Ascending, 100);


                var strDate = fromDate.Substring(0, 24);
                DateTime startSearchDate = DateTime.ParseExact(strDate, "ddd MMM d yyyy HH:mm:ss", CultureInfo.InvariantCulture);
                string sDate = startSearchDate.ToString();
                string eDate = (startSearchDate.AddDays(7)).ToString();


                timeRange = new AFTimeRange(new AFTime(sDate), new AFTime(eDate));


                foreach (AFAttribute attribute in nOxAttribList)
                {
                    AFValues values = attribute.GetValues( timeRange, -186, null);
                }

Outcomes