Dynamically Detecting and Resolving New Aliases in PI ProcessBook Displays
Learn how to use PI SDK Event Pipes and ContextHandlers to automatically detect and resolve new aliases or tags added in PI ProcessBook module contexts, ensuring real-time updates without polling.
Roshan Soni
Dynamically Detecting and Resolving New Aliases in PI ProcessBook Displays
In the world of real-time process data visualization, PI ProcessBook remains a staple tool for engineers and operators relying on accurate and timely data representation. Occasionally, you may need your ProcessBook display to automatically adapt when a new PI Point alias is added to the current module context—eliminating the need for manual refreshes or disruptive polling mechanisms.
In this post, I’ll walk through best practices for detecting and resolving new aliases or tags in PI ProcessBook using the PI SDK and event-driven techniques.
The Challenge: Real-Time Tag Resolution
Imagine you add a new alias to a module in the PI Module Database (MDB) or Asset Framework (AF), and you want your ProcessBook display to immediately resolve and show data for that alias, without waiting for a manual refresh or a timer-based poll. Polling can be resource-intensive and introduce unwanted lag for users.
The Event-Driven Approach
The answer lies with PI SDK Event Pipes—a robust way to monitor the Module Database (MDB) for changes. Event Pipes allow you to respond to events such as "add," "remove," or "edit" on PI Modules (including changes to aliases) in near-real-time. Here’s how you can leverage this:
-
Declare an EventPipe on PIModuleDB: In your VBA (or VB6) environment, declare a
PISDK.EventPipeobject and assign it toServer.PIModuleDB.EventPipe. This sets up event monitoring on the module database. -
Consume the Events: Use the EventPipe's
TakeorTakeAllmethods to pull event objects as they occur. Each event object contains properties to help you identify which module or alias was changed. -
Trigger Context Re-Resolution: Upon detecting an alias addition or edit event for the current module context, refresh the PI ProcessBook display's context so it resolves the new alias and fetches the newly available data.
Refreshing the Display Context Properly
A key nuance is ensuring the display context is correctly re-evaluated. In ProcessBook VBA, this involves iterating over the ContextHandlers (which manage context linkage for Aliases, Properties, and ModuleContext) and invoking their ContextUpdated method. Here’s an example:
Dim ch As ContextHandler
For Each ch In Application.ContextHandlers
ch.ContextUpdated ThisDisplay
Next
Pro Tip: Always reference context handlers by name (
"Alias","Property","ModuleContext") rather than index. This best practice ensures your code adapts gracefully if the set or order of context handlers differs across computers.
Application.ContextHandlers("Alias").ContextUpdated ThisDisplay
Application.ContextHandlers("Property").ContextUpdated ThisDisplay
Application.ContextHandlers("ModuleContext").ContextUpdated ThisDisplay
Troubleshooting Tips
- Using
Application.Refreshalone typically does not force the display to resolve new aliases; explicit calls toContextUpdatedare needed. - After invoking context updates, verify context data before and after the change to confirm successful alias resolution.
- When programming in VBA, remember the differences in method call syntax compared to VB.NET (avoiding extraneous parentheses can make or break your code!).
Additional Resources
- PI SDK Programming Reference (
PISDK.CHM), installed with PI SDK or available from your OSIsoft support portal. - PI Square Community Forums, a trove of practical examples and expert Q&A.
Conclusion
By harnessing PI SDK Event Pipes and programmatically refreshing ProcessBook's context handlers, you can achieve dynamic, event-driven updates when new aliases or tags emerge in your PI Asset Model. This not only improves user experience but also reduces unnecessary system load compared to polling solutions.
Have you built event-driven solutions in PI ProcessBook or migrated similar logic to PI Vision or other visualization tools? Share your tips in the comments below!
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