Accessing Short-Hand Units in PI AF: Using the Abbreviation Property of UOM
Learn how to access concise unit of measure (UOM) abbreviations in PI AF by leveraging the Abbreviation property, ideal for streamlined data representation.
Roshan Soni
Understanding PI AF UOM Properties and Accessing the Abbreviation
When working with PI AF (Asset Framework), you will often encounter situations where you need to retrieve the units of measure (UOM) for various attributes. Attributes in PI AF can have associated UOMs, aiding in consistency and standardization across different datasets. But what if you need the abbreviated version of a UOM instead of its full name? This post will guide you on how to access the short-hand versions of UOMs, like gpm for "gallons per minute," rather than the verbose descriptions.
The UOM Properties
In PI AF, an attribute might have different UOM properties, namely SourceUOM, DisplayUOM, and DefaultUOM.
- SourceUOM: The UOM in which the source data is provided.
- DisplayUOM: The UOM used for displaying the value.
- DefaultUOM: The UOM considered as the default for the attribute.
These properties are designed to provide flexibility in displaying and managing UOMs but calling .ToString() on these properties will return the full name of the UOM. For example, for a flow rate, it might return "gallons per minute".
Accessing the Abbreviation
If you're interested in retrieving the abbreviated form, you should utilize the Abbreviation property from the UOM class. This property holds the short-hand notation that is often more concise and suitable for graphical and report-based representations.
Example Usage:
Here’s how you can obtain the abbreviation:
Console.WriteLine(selectedAttribute.DisplayUOM?.Abbreviation);
This code snippet utilizes the null-conditional operator ?. to safely access the Abbreviation property. This is important because it avoids NullReferenceExceptions in scenarios where the DisplayUOM or DefaultUOM might be null.
Remember, you do not need to append .ToString() after .Abbreviation because the Abbreviation property inherently returns a string value.
Why Use the Abbreviation?
- Readability: Abbreviations are often easier to read and fit better within UI constraints.
- Standardization: They provide a standardized symbol for units which is understandable to industry professionals.
- Efficiency: In data visualization and reporting, space is often limited – abbreviations help save space without losing meaning.
Conclusion
By understanding and effectively utilizing the UOM properties within PI AF, you can ensure data is consistently represented and accessible in a format that’s appropriate for your users. Keep in mind the scenario where the UOM might not be set, and utilize the null-conditional operator to safeguard against unexpected runtime errors. With these tips, you're well-equipped to manage UOMs in a PI environment efficiently.
Tags
About Roshan Soni
Expert in PI System implementation, industrial automation, and data management. Passionate about helping organizations maximize the value of their process data through innovative solutions and best practices.
No comments yet
Be the first to share your thoughts on this article.
Related Articles
Enhancing PI ProcessBook Trends with Banding and Zones: User Needs, Workarounds, and the Road Ahead
A look at the user demand for trend banding/zoning in OSIsoft PI ProcessBook, current VBA workarounds, UI challenges, and how future PI Vision releases aim to address these visualization needs.
Roshan Soni
Migrating PIAdvCalcFilVal Uptime Calculations from PI DataLink to PI OLEDB
Learn how to translate PI DataLink's PIAdvCalcFilVal advanced calculations—like counting uptime based on conditions—into efficient PI OLEDB SQL queries. Explore three practical approaches using PIAVG, PIINTERP, and PICOunt tables, and get tips for validation and accuracy.
Roshan Soni
Understanding PI Web API WebID Encoding: Can You Generate WebIDs Client-Side?
Curious about how PI Web API generates WebIDs and whether you can encode them client-side using GUIDs or paths? This article explores the encoding mechanisms, current documentation, and best practices for handling WebIDs in your applications.
Roshan Soni