Is it possible to use PiDataPipe for retrieving events on points changes like deletion or addition of points? Maybe the AFDataPipeType.TimeSeries can achieve that? Or only on updates of points, and for point changes to use only the FindCangedPiPoints method?
2 of 2 people found this helpful
The information you are seeking may be found with the links previously sent. Let's walk through it:
The PIDataPipe is used to subscribe for data change events on a list of PIPoint instances. The PIPoint instances do not have to be associated with the same PIServer. PIDataPipe instances can sign up for archive, snapshot or timeseries events. The pipe type is specified when the data pipe object is constructed.
Let me add my emphasis for you on the very first sentence.
The PIDataPipe is used to subscribe for data change events on a list of PIPoint instances.
The data pipe requires existing PIPoint instances and it therefore monitors data change events associated with those existing PIPoint instances. If you want to change something about the PIPoint definitions, that is really metadata. I thought it would have been self-evident by the name FindChangedPIPoints but let's once again walk through the help.
The PIPointChangeInfo structure is used when returning information about PI Points that have changed in the PIServer.
And halfway down the page
This method uses a pipe to track changes to PIPoint objects on a PIServer. If an AFTime is passed as the cookie, then a query is used to find changes since the given time. After the query completes, a new pipe is established to more efficiently track changes to subsequent calls via the nextCookie. The pipe is faster and more efficient than the query. Since the pipe is faster and more efficient users should only pass in an AFTime for the cookie on the first call. If the pipe loses connection, then a query is used to find changes that have occurred while the pipe was down. Queries will not reveal points that have been deleted; therefore, FindChangedPIPoints cannot report deleted points while the pipe is down unless filterPoints have been passed. If filterPoints have been provided, then their IDs will be validated after a query is used to backfill changes that occurred while the pipe was down. Any IDs that are not valid, will be reported as removed PI Points.
To me, this tells me there are 2 different things needed to monitor 2 different kinds of things: the PIDataPipe monitors data change events, and FindChangedPIPoints monitors changes in point definitions (meaning changing, adding, or deleting PI points). Regarding FindChangedPIPoints, as a developer I would be curious about what it returns: An IList<PIPointChangeInfo>. Once again, we click on PIPointChangeInfo to learn more about it:
The first line of help tells us nothing we didn't already know from the FindChangePIPoints help. But if you take a few seconds scanning down the page, there is some interesting properties that deserve exploring. There is an ID property telling us the ID of which PIPoint was changed (boring). But there is an Action property which is the AFChangeInfoAction that caused the object to be changed (interesting). If you click the link to learn more about AFChangeInfoAction, you would see:
Where you may see members of Unchanged, Added, Removed, Updated. Since you drilled down to this starting with FindChangedPIPoints, this becomes PIPoint Unchanged, PIPoint Added, PIPoint Removed, and PIPoint Updated.
So there you have it. All the information was within the help system and 2 links provided. There is one thing not yet within help because it's for PI AF 2018 (AF SDK 2.10) to be released within 10 days. That is a way to check if a tag has been renamed. Since this change applies to a PIPoint definition, it is now no mystery to you that you will use the FindChangedPIPoints method. Until the Live Library is updated for 2.10, there is this hidden nugget about tag renames:
Thank you Rick for this thorough answer
In case of AFChangeInfoAction Enumeration 'Updated', Is there a way for me to know what point property exactly was updated? (For instance: was it the point-type? point source? etc..)
1 of 1 people found this helpful
There is a way but the burden is placed 100% on your client. All you need to do is keep a cache of every PIPoint that you have subscribed to in your data pipe. This cache should be a dictionary keyed on PIPoint, and its Value payload should be an inner dictionary keyed on the name of the attribute and the inner dictionary Value would be the the last known value for the attribute setting. When you examine the PIPointChangeInfo to see that the Action is "Updated", you would then check the "ID" against your internal dictionary to see what has changed. You would scan the inner dictionary for what has changed, and then (1) act upon that information as your application requires, and (2) update the entry in your inner dictionary to reflect the new setting since it now becomes the last known value.
Helpful links for you to research:
These next 2 search on given text. Here "attributes" refers to PIPoint Attribute (meaning a definition setting) and not an AFAttribute. Ignore anything asset related (AFElement, AFEventFrame, AFAttribute, etc.) and focus on those that are PIServer related (PIPoint, PIPointList, PIPointClass, etc.)