Designing a Custom Playback Function in PI ProcessBook: Dynamic Trace Redrawing Explained
Explore how to create a custom animated playback feature in PI ProcessBook for dynamically redrawing traces within a fixed time window. Learn about PI Calculation Datasets, VBA scripting, challenges, and alternative approaches.
Roshan Soni
Designing a Custom Playback Function in PI ProcessBook: Dynamic Trace Redrawing Explained
Introduction
PI ProcessBook has long been a popular tool for visualizing and analyzing PI System data. However, users sometimes run into feature limitations—especially when attempting to go beyond the native playback functionality. One common request is for a playback feature that animates the redrawing of data traces within a fixed time window, rather than just shifting the displayed time range of a static plot. In this post, we’ll explore this advanced requirement, discuss possible approaches in ProcessBook using VBA and PI Calculation Datasets, and consider practical alternatives.
Understanding the Challenge
The default playback function in PI ProcessBook simply scrolls the time axis, revealing new sections of a pre-drawn data trace. This works for many use cases but falls short when an animated, dynamic build-up of the trend (similar to an animated GIF) is desired. In applications such as laboratory data review or process event investigation, this kind of animation can be invaluable for illustrating trends and transitions as they develop, all within a fixed time frame.
Standard ProcessBook Playback vs. Custom Requirements
ProcessBook’s standard playback:
- Moves the time range: The displayed window slides over the full historical trace.
- Shows static traces: All data within the window are shown at once, without incremental redrawing.
Custom requirements as described by users like Qinmiao Li:
- Fixed time window: The time axis is fixed; only data within that window is shown.
- Dynamic redrawing: The trace appears to be ‘drawn’ over time, building up as playback proceeds.
- User control: Both the playback range and speed are user-configurable.
Prototyping a Custom Solution
Since there’s no native ProcessBook control for this, users often resort to custom VBA scripting to manipulate datasets and plot updates. The typical approach involves:
- PI Calculation Datasets: Setting up datasets with time expressions that can be dynamically updated.
- VBA Timer: Using a timer loop in VBA to incrementally advance the dataset’s end time, forcing the trend to update with each tick.
- Redraw Logic: Continuously updating the dataset expression and refreshing the trend control in each timer event so the trace visually builds.
Key Implementation Details
- Dataset Configuration: Make sure to use a PI Calculation Dataset with a
.Valuesuffix to allow dynamic expression changes. - Timer Handling: Rely on a VBA timer instead of
Display_DataUpdatefor finer control over animation speed and periodic redraws. - Error Handling: Be mindful of server connections—sometimes dataset errors are resolved by refreshing the server in PI System Management Tools (SMT) or Known Servers Table (KST).
VBA Snippet Overview:
' Pseudocode outline for dynamic playback
Public Sub StartCustomPlayback()
' Initialize variables: start time, end time, playback interval
' Configure PI Calculation Dataset with expression limited to current interval
' Set a timer to incrementally expand the interval
' On each timer tick:
' Update dataset expression/end time
' Refresh the trend object
' Stop timer at desired playback end
End Sub
Practical Challenges and Limitations
- Responsiveness: ProcessBook trends may not update as smoothly as dedicated animation tools. Rapid, seamless redraws (as in high-quality GIFs) are hard to achieve.
- Code Maintenance: VBA scripting in ProcessBook can be complex to maintain, especially when handling multiple datasets or tags.
- Dataset Limitations: PI Calculation Datasets aren’t designed for high-performance animation, and their behavior can sometimes be unintuitive.
When to Look Beyond ProcessBook
Given these challenges, it's wise to pause and reconsider the use case:
- Is ProcessBook the right tool? For new projects, consider more modern platforms such as PI Vision, which offer richer extensibility and better animation capabilities via custom symbols and JavaScript.
- Is a GIF/animation needed for reports or presentations? External tools may integrate PI data for smoother visualizations.
Conclusion
Animating data traces within a fixed time window in PI ProcessBook is possible with clever use of VBA and PI Calculation Datasets, but it comes with real limitations in smoothness and maintainability. As PI ProcessBook approaches end-of-life in favor of PI Vision, consider migrating to newer platforms if such dynamic visualizations are business-critical. Nevertheless, with thoughtful coding and awareness of ProcessBook’s boundaries, basic animated playback features are achievable.
Further Reading
- PI Square: User Customizations and VBA Tips
- PI Developer Technologies: AFSDK, VBA, and PI Web API
- Upgrading to PI Vision: Key Considerations
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