From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Adding time module column using c#

Hi All,I use NI GUI Example in c#

and I need to add time module column to the execution view by code.

I use: "axExecutionView.Columns.Insert("_MODULE_TIME",NationalInstruments.TestStand.Interop.UI.SeqViewColumnTypes.SeqViewColumnType_Expression,100,-1);"

 

but it doesn't work,

Tnx,

 

 

 

 

 

0 Kudos
Message 1 of 6
(4,545 Views)

Hello NewSCRUser,

 

What version of TestStand are you using and where did you find this example?  

 

Does the new column insert into the incorrect place, or does it just not appear?

 

Thanks,

 

-Jim B

-Jim B
Applications Engineer, National Instruments
CLD, CTD
0 Kudos
Message 2 of 6
(4,514 Views)

For tracing, using the following expression for the column will work:

 

(PropertyExists("Locals.ResultList") && PropertyExists("Step.TS.Id") && GetNumElements(Locals.ResultList) > 0 && PropertyExists("Locals.ResultList[" + Str(GetNumElements(Locals.ResultList) - 1) + "].TS.ModuleTime") && Locals.ResultList[GetNumElements(Locals.ResultList) - 1].TS.StepId == Step.TS.Id) ? Str(Locals.ResultList[GetNumElements(Locals.ResultList) - 1].TS.ModuleTime, "%f") : ""

 

Of if what you really want is TotalTime, change ModuleTime above to TotalTime.

 

The problem is when you hit a breakpoint and it refreshes the whole step list, you will then only get the time for the last step.

 

The reason why this is a harder problem than you might think is that the time results for a step are not stored on the step itself, they are only stored in Locals.ResultList and only if the step was actually set to record results. The expression above just looks at the last result in the result list and if it is for the current step, then it displays the module time for that step. This works while tracing because only the previous step at the tracepoint is refreshed. At a breakpoint, when it tries to refresh the entire view, only the last step matches the last result. If you wanted it to work in more cases you'd have to do somewhat of a search through the result list for each step, which would be slow and tricky to implement in an expression.

 

Another alternative you might want to consider is using the On-The-Fly report generation setting instead. That generates the report while the steps are still executing, and the report already includes the module times (or at least it can depending on what settings you use for the report).

 

Hope this helps,

-Doug

0 Kudos
Message 3 of 6
(4,503 Views)

Hi Doug,

 

I need to find the same time as it appear at report and show it on my GUI

Did you mean it by your example?

0 Kudos
Message 4 of 6
(4,468 Views)

Yes, I'm pretty sure the ModuleTime shown in the report is from the ModuleTime stored in the resultlist.

 

-Doug

0 Kudos
Message 5 of 6
(4,465 Views)

I've been made aware that there is a better way to match the step up with it's last result, there's actually a built-in API for this. Use the following expression instead of what I previously posted:

 

Step.CurrentLoopResult != Nothing ? (Step.CurrentLoopResult.Exists("TS.ModuleTime", 0) ? Str(Step.CurrentLoopResult.GetValNumber("TS.ModuleTime", 0), "%f") : "") : (Step.LastStepResult != Nothing ? (Step.LastStepResult.Exists("TS.ModuleTime", 0) ? Str(Step.LastStepResult.GetValNumber("TS.ModuleTime", 0), "%f") : "") : "")

 

This expression also does not have the problem the previous one had where you lose the value at a breakpoint. You will keep the values at all times with this expression.

 

Hope this helps,

-Doug

0 Kudos
Message 6 of 6
(4,460 Views)