While Calling PIPointList.PlotValues for two different attributes, mapped to same pi-point; it returns one result. But i want to map result back with both attributes respectively. Please suggest something??
Based on the AF SDK Reference, I feel that the PIPointList.PlotValues method will always strip out duplicate points in a single PIPointList.
An enumerable of AFValues for each PIPoint in the list. The results are not guaranteed to match the order of the PIPointList, and duplicate points in the list will not produce a duplicate result. The results can be mapped back to the corresponding PI Point using the PIPoint property on each result.
You mention that you want to map PIPoints back to the attributes.
If you are relying on the order of the PIPointList, then you might get incorrect results (see the bolded comment above).
You should note that each result has a PIPoint property. Have you considered using this to do the mapping?
Hi Duc Ta Hieu
In continuation to the original question, i would like to add " all PIPoint Property in our case are same as both attributes are mapped to same Pi Point. ".
So do we have anything in SDK which can accomplish this thing?
As mentioned twice already, yes there is. Instead of using PIPointList.PlotValues you want to use AFAttributeList.Data.PlotValues.
If you insist on using PIPointList, you must be willing to fully accept the limitation that a PIPoint will not be duplicated. The burden then is on you to make up for this limitation since it is your decision to use PIPointList instead of AFAttributeList.
All PIPoint Property in our case are same as both attributes are mapped to same Pi Point.
As Duc Ta Hieu explained, the help for PIPointList.PlotValues clearly states you won't get duplicates back. By duplicates, it means duplicate PIPoints. Keep in mind the returned object is based on a dictionary, and that key can only have a referenced to a given PIPoint once.
If you want an entry for each attribute, you should use the AFAttributeList.PlotValues method. Its returned object will have a dictionary that is keyed by attribute.
The AF SDK Reference provides an example at the bottom where a resultsMap is created using the PIPoint property. This is what I thought you were referring to when you said you require a mapping.
// Holds the results keyed on the associated point
Dictionary<PIPoint, AFValues> resultsMap = new Dictionary<PIPoint, AFValues>();
IEnumerable<AFValues> listResults = pointList.PlotValues(timeRange, 1000, config);
foreach (AFValues pointResults in listResults)
// Map the results back to the point
resultsMap[pointResults.PIPoint] = pointResults;
So let's say you have the following data references for your AF Attributes:
AFAttribute1 --> PIPointA
AFAttribute2 --> PIPointB
AFAttribute3 --> PIPointA
If you create a resultsMap then you will have the following dictionary:
PIPointA --> AFValuesA
PIPointB --> AFValuesB
If you need the AFValues for AFAttribute1, then you can look up the resultsMap dictionary on PIPointA to get AFValuesA.
If you need the AFValues for AFAttribute3, then you can look up the resultsMap dictionary on PIPointA to get AFValuesA.
The PIPoint is the key to your mapping. Using the resultsMap dictionary, you should be able to create your own data structures.
If you don't actually need anything from the PIPoints, and you just want plot values for each of your attributes, then check out Rick's recommendation about AFListData.PlotValues.
Retrieving data ...