Best approach for formatting result values?

What is the best way to control numeric format for TestStep results? Say I want the value to be shown with two fractional digits (0.62) and perhaps also with a unit (0.62dB). Should I add a FormattedResult property in addition to the Result property?

2 Likes

@GoranJohnsson have you looked at the Unit attribute? I believe that solves most of your problems. It will easily allow for units and engineering prefixes, but there is also a StringFormat setting that will allow you to define units of precision, hex, binary, etc.

The Units attribute example is here:

We leverage the standard .NET String Format syntax:

2 Likes

Great, seems to do the work! It is a challenge to find out all possibilities and capabilities…

2 Likes

Hi @GoranJohnsson, just curious, how did you get that result in the Step Settings panel, with what appears to be a radio button? Is that a custom IControlProvider, or does TAP have some built-in functionality I’m not aware of?

1 Like

@david-wsd Are you referring to the value format or the “radiobutton”?

The value format comes from the settings attribute:
[Output]
[Unit(“dB”,UseEngineeringPrefix:true,StringFormat:“F2”)]
public double Result { get; private set; }

The “radiobutton” is just the standard output icon

3 Likes

@GoranJohnsson Yes, the radio button. You answered my question, thanks! The Output attribute is what I was looking for.

2 Likes