1 of 1 people found this helpful
Thanks for posting your question here at PI DevClub. Your code confuses me and since I really don't know the return type from your custom GetAttributeDictionary, I am forced to ask that when you say "attribute" that you mean a PI point attribute and not an AFAttribute? I am going to proceed as if you mean PI point attribute.
Usually there is no need to convert the dictionary to a list since a dictionary is a specialized list, which may easily be enumerated over with a for each.
Point attributes are not the same thing as recorded values, so the UpdateValues method is the wrong thing to call. Since you are dealing with one PI point, you would use either of the 2 overloads at this link: PIPoint.SaveAttributes.
If you had more than one PI point, then you would want them bundled into a PIPointList, in which case you would use the method at this link: PIPointList.SaveAttributes. However, all tags in the PIPointList would have the same point attribute settings.
Even backing up a bit, you really should set a PIPoint object based upon the tag name. Once you have a PIPoint object, you can stop using the name. Even with that in mind, you should also have a PIServer object in code as well.
The snippet of code below is an example of usage. If you have more than one PIPoint, this may not be the most efficient and you would want to explore bulk methods with PIPointList.
PIServer pida = yourPIDataArchive; PIPoint tag = PIPoint.FindPIPoint(yourPIDataArchive, TagName); IDictionary<string, object> dict = tag.Name.GetAttributeDictionary(TagConfigDatabase); tag.SaveAttributes(dict);
I would encourage you to read the Live Library AF SDK Help to see more about available methods and syntax usage.
Thanks for your reply.
Indeed, these are PIPoint attributes.
The definition of GetAttributeDictionary is as follows:-
public IDictionary<string, object> GetAttributeDictionary(ITagConfigDatabase TagConfigDatabase)
I have more than one PI Point attributes to modify, hence I think I should be using PIPointList instead. Do you have a snippet for bulk modify?
If you are attempting to modify tags in bulk, you are mostly likely better suited doing that with PI Builder than attempting to do it in code.
I have already given you great links to read the help. If I am to write every line of code for you, then I would be depriving you of valuable learning opportunities.
I would also like to point out that you stated: "I have more than one PI Point attributes to modify, hence I think I should be using PIPointList instead." I would feel better if you stated: "I have more than one PI Point attributes to modify AND all the PI Points will have the same attribute settings, hence I think I should be using PIPointList instead." But you didn't say that and I have doubts about the efficiency of the many things I don't see in your application, given you have shared but a tiny snippet of code. The fact that your code shows interaction via a tag's name leaves me wondering how you intend to work with a list of tags, or if you must, a list of tag names.
Perhaps you should heed Vince's advice and use PI Builder. If you insist on using a code approach, I once again will provide help links for you to read and to learn from.
Finding more than one PI point would be require a suitable PIPoint.FindPIPoints overload (dependent upon your application).
Constructing a PIPointList from a FindPIPoints call should be the easiest thing you could do.
Other than that, I have little to offer without seeing more of your code.
Yes, and this morning I did make it to work with the readings. Thanks for your help.