AnsweredAssumed Answered

C# AF SDK Retrieving Data

Question asked by GPaterson on Aug 4, 2015
Latest reply on Aug 5, 2015 by Marcos Vainer Loeff

Originally when I needed data from the AF Server,I would load a query into powerpivot/datalink and work with it from there. This approach is fine for small amounts of data, but excel is sluggish when I run the following query to do some regression analysis:

 

SELECT eh2.name, tc.Time, tc.Power_HAvg as Electricity 
FROM [PIDB-AF].[Asset].[ElementHierarchy] eh  
INNER JOIN [PIDB-AF].[DataT].[ft_TransposeInterpolateRange_EL Meter Template]  tc  
  ON tc.ElementID = eh.ElementID
INNER JOIN [PIDB-AF].[Asset].[ElementHierachy]eh1 on eh1.ElementID = eh.ParentElementID
INNER JOIN [PIDB-AF].[Asset].[ElementHierachy]eh2 on eh1.ElementID = eh1.ParentElementID
WHERE eh.Path like N'\Location\Campus\Buildings\%' AND tc.StartTime = DATE('t-1y') AND tc.EndTime = DATE('t') AND tc.TimeStep = '1h' --Location\Campus\Buildings\<Building Name>\Energy Meters\EL Meter
OPTION (FORCE ORDER, IGNORE ERRORS, EMBED ERRORS)  

 

The result has more than 800k rows and takes about 2 minutes to complete...

 

For faster performance, I want to use the AF SDK in C# and have made progress connecting to the AF server but the getting values seems to be more complex than traditional pi tags. How would I go about getting this data? I would rather not have to resort to making large csvs in excel and reading those in C#

Outcomes