03-20-2014 04:10 AM
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,
03-21-2014 04:41 PM
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
03-23-2014 12:11 PM - edited 03-23-2014 12:12 PM
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
03-27-2014 09:56 AM
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?
03-27-2014 10:39 AM
Yes, I'm pretty sure the ModuleTime shown in the report is from the ModuleTime stored in the resultlist.
-Doug
03-27-2014 10:54 AM
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