Is there code samples to write data to PI Buffer using AF SDK?
Also are there any best practices when doing the same?
Yes, please see the example here:
AFData.UpdateValues Method (AFValues, AFUpdateOption, AFBufferOption)
You can also find the corresponding example in the AFSDK.chm guide in %pihome%\help\.
Generally, it's best to write data in bulk (i.e. use UpdateValues rather than looping through UpdateValue).
It's also good to store any possible errors in AFErrors collection:
public AFErrors<AFValue> UpdateValues(
Some general information regarding AF SDK buffering is here:
AF SDK Buffering
If you want to write data in bulk to different attributes at once, use AFListData.UpdateValues(IList<AFValue>, AFUpdateOption). Here, each AFValue in the IList can refer to a different attribute.
To write in bulk to a single attribute, you can use AFData.UpdateValues(AFValues, AFUpdateOption). Here, the AFValues.Attribute property must be set to the attribute you are writing to.
Are you using AF SDK 2.6?
To write to the buffer using the AF SDK you can set the value of AFBufferOption to either BufferIfPossible or Buffer. This really depends on what you want.
piPoint.UpdateValue(afVal, AFUpdateOption.Insert, AFBufferOption.BufferIfPossible); // write it to PI and buffer if possible
You need to configure PIBufSS with the correct PIServer/Collective. You use PI Buffering Manager to check that Buffering is setup correctly.
Thank you Barry and Dan!
Note that there are different levels of setting up buffering for AF SDK. You can set buffering at the system level, process level, or call level. The above mentioned methods set buffering at the call level. If you want buffering to be enabled for the all AF SDK applications, you can set up AF SDK buffering through buffering manager, which essentially writes to the AFSDK.config file. This enables buffering for all AF SDK application running on the machine, and you will then not need to add AFBufferOption to each data write call. (You can still override the global buffering configuration at the process or call level, if you need a more fine-grained control of buffering).
For more information, I encourage you to check out a similar discussion in this previous thread: https://pisquare.osisoft.com/message/44044#44044
Were you able to reach a resolution regarding your question above? If so, please let the community know by marking one of the answers as "Correct Answer". If not, please give us some more information on the current status of the project so we can further assist you. Thanks.
Retrieving data ...