I want to get source UOM from PI point
"attribute.DataReference.UOM" gives me null value. Can anyone help me to solve this issue?
This is weird because if I have a similar configuration as yours, the AFAttribute.DataReference.UOM property actually gives me a reference to the UOM that I've configured. Can you share more about the part of the code that gives you the reference to the AFAttribute, and how your AF hierarchy looks like?
Anwar / Han,
The DataReference.UOM gets the AF UOM, and not the PIPoint UOM.
To use that (using the AF2012 SDK!), you should use the AFAttribute.PiPoint property. Using the PiPoint, you can then use the GetAttributes method:
Yes, actually that crossed my mind as well, and the 1st thing that I wanted to clarify with Anwar is whether he wants the engunit attribute in PIPoint. But If you look at the screenshot Anwar attached. He did configure a unit in his PIPoint Data Reference, and hence AFAttribute.DataReference.UOM should return a valid reference to a UOM object. You are right that this doesn't return what was configured for the PI tag in the PI Server, but in this case, what Anwar is doing is valid
Now you mention it, i see what you mean! Indeed my example gives the PI Point UOM, while the screenshot shows the source UOM set in the PI Point datareference.
But that is still different from the AF attribute UOM! This allows to do UOM conversion on the fly between the source UOM and the AF attribute UOM when reading/writing the value.
I expect that the UOM as circled in the screenshot needs to be taken from the configstring (attribute.AFDataReference.ConfigString), and parsing out the UOM= section.
I don't think the PIPoint DR exposes any properties or details, we can only get a PiPoint object if the DR is PIPoint.
This issue is proving more interesting then at first sight!
attribute.DataReference.UOM will return the UOM circled in the original post
attribute.UOM returns the UOM configured for the attribute
AF automatically converts values between these UOM's for you.
You should not need to parse the configuration string to read either of these UOMs.
The PI Point Attribute 'EngUnits' is used only for descriptive purposes - it does not actually have any affect on UOM conversions. Roger's example code for AF 2012 will retrieve this string.
As Han stated, you should not be receiving null in your example. More context may be helpful in tracking this down.
This is unfortunately a common point of confusion - so to expand on what Chris said,
Within the data reference configuration, you're specifying how the data comes from the source - in the case of a PI Point attribute, this field will agree with the point's Engineering Units.
At the attribute level, you're specifying how the data will be shown by default.
You might have PI tags measured in an inconvenient unit of measure - e.g. system uptime being measured in seconds or minutes, but humans would rather see that in days.
Or your "Pump casing temperature" PI tags could be a mix of °C and °F, but for dashboards, analytics, and notifications you'll want all of them in a common unit. Of course, end users (via PI client and data access suites) can always request the data in the unit of their choosing (e.g. in any of the "temperature" units)
So UOMs are a two-step process - "how is it in the source," then "how do I want to see it by default".
Retrieving data ...