This is the last part of a 3-part series on creating a Duration attribute on an event frame.
Part 3 - Variations on a Theme
Reading from the Primary Element
The performance tests in Part 2 made mention of a mysterious Part 3 method. This is just a variation on using StringBuilder DR to create a start and end time that may be used in a formula, except the start and end times will be read from the Primary Element rather than the event frame itself. This technique performs the same as what was presented in Part 1. So why include it?
- To show that it was not just considered but also evaluated.
- You really don't know if it performs the same, better, or worse until after its evaluated so you may as well post the results.
- Part 1 requires Start and End Time attributes on each event frame and some may be upset that these attributes are redundant to the properties that already exist. This variation is for those people who shake their fist angrily in the sky screaming "Why? WHY? WHY?!!!"
Setting up the Element Template
Here's all the the attribute templates defined on the Element.
To distinguish this from Part 1, I have named my attributes Event Start Time and Event End Time. Given they are defined on the primary referenced element but only make sense within context of an event frame, I have chose to make these attributes hidden.
Event Start Time
Event End Time
Setting up the Event Frame Template
The event frame template has a lone attribute. Just like Part 1, we want to dot the i's and cross the t's with little touches like specifying the UOM.
Taking some formatting liberties with the formula config string, here's what it looks like:
A=.\Elements[.]|Event Start Time;
B=.\Elements[.]|Event End Time;
[B - A];stepped=True;UOM=s
This is an option to you if you insist on not seeing the start and end time on the event frame. Personally, many people that I've worked with who wanted to see a Duration also wanted to see the start and end time on the event frame, i.e. what was shown in Part 1. But, hey, you've got choices.
The PISquare forums show a steady trickle of requests for a Duration attribute on event frames. You have choices on how you can achieve this:
- Using the original Sinusoid PIPoint technique.
- Using StringBuilder DR to create the start and end times on the event frame.
- Using StringBuilder DR to create the start and end times on the primary referenced element.
- You may create a custom data reference tailored to your specific requirements.