We are building an application that must capture every snapshot value for a given tag (or all tags) and mark them as questionable. To mark the values as questionable, the application captures the value (of type AF Value), and stores them in an AFValue List. Another thread will push the list to the PI Server every specified interval of time, let us call it x. Below is the code we are using to update the AFValues list to the PI Server.
- pisServer.UpdateValues(afValues, OSIsoft.AF.Data.AFUpdateOption.ReplaceOnly, bufferOption);
We are using “ReplaceOnly” mode because we don’t want to reintroduce values that didn’t make it to the archive due to compression. Our issue is here; when x (the refresh interval) is 2 seconds, then the application works fine, that is no values are marked as questionable other than those in the archive. So if we sent 10 identical values, then due to compression only one or two values at most should be archived, and with x = 2, then we will have one or two questionable values.
Now if x = 6, then the “ReplaceOnly” will not be valid anymore, so instead of 2 questionable values, we are having 5, 6 or 7 questionable values. Therefore, our constraint of not reintroducing compressed events to the archive is not true anymore. Note that we are sending one value to the PI Server every three seconds, and flushing the AFValuesList every 6 seconds.
I have created and attached a windows forms application that sends data to the PI Server every specified amount of time (3 seconds by default), and has a Data Pipe Observer capturing snapshot data, marking them as questionable and flushing them to the PI Server every x seconds.
To reproduce the issue, start the form; change the name of the PI Server to your PI server and the tag name to a tag of your choice to test, preferably the tag should only be fed from this application. Open PI SMT, Archive Editor and choose the given tag. Click the button “Send New Values”, keeping other controls to their default values, that is send 10 identical values, one each 3 seconds, and monitor PI SMT. With “AF Values Refresh Time” set to 2, then you should see in PI SMT a maximum of 1 or two questionable values, as the rest of the values will be removed due to compression (Of course the PI Tag should have compression enabled). Now set the “AF Values Refresh Time”to 6, and send another 10 identical values, this time you will notice that 6 or 7 questionable values made it to the Archive, which contradicts the operation of “ReplaceOnly” mode as we should only replace values that exist ( from the thread that is reintroducing values as questionable).
Any explanation for this weird behavior or a work around is highly appreciated.