AnsweredAssumed Answered

Send data to PI Point and specify Timestamp in AF SDK

Question asked by wling1 on Jun 13, 2016
Latest reply on Jun 13, 2016 by wling1



I am having some difficulty in writing data the the data archive through AF SDK. In my situation, I have an attribute that is pulling back a value from a linked SQL table query. This attribute is updated every day as the SQL query is set to run once a day. I have created a PI Point that I am attempting to update, but when it updates the value, it keeps using the same timestamp (which I assume is the element or attribute effective date). I would like to specify the timestamp so that I can keep archiving 1 data point each day that the code is run. I found what looked to be a way of doing it in the following thread ( Patrice's response at the end) but I can't get my code to work.

Writing data to a PI Point Array 


When I do it, I get the following error:


An unhandled exception of type 'System.InvalidOperationException' occurred in OSIsoft.AFSDK.dll

Additional information: Cannot convert value to a PI equivalent type for writing.


Here is what my code looks like:

public static void sendHistToPi(AFAttribute nonHistorizedTotalAlerts)
            PIServers myPIServers = new PIServers();
            PIServer myPIServer = myPIServers[0];
            PIPoint myPIPoint = PIPoint.FindPIPoint(myPIServer, "Total_Alerts_ByDay");
            myPIPoint.UpdateValue(new AFValue(nonHistorizedTotalAlerts.GetValue(), AFTime.Now),OSIsoft.AF.Data.AFUpdateOption.Insert);



Any help is greatly appreciated!