Custom GUI & CSV results Listener?

I’ve started down the path of writing a custom GUI and using the example results listerner in the GUI example to parse data from steps for the purpose of displaying it in the GUI. I’ve also debugged my test sequence in the editor and verified the results setting of CSV publishes a table the way I want it. However, this same sequence when run in the custom GUI does not create the table.

— Updated —

When I use "tap run " the test plan executes and the appropriate result listeners are selected and function.

—>So the question becomes how do I enable a custom UI to read and load the listeners defined in the xml file? and pass that list to the tesplan run call.

The example GUI only statically loads two listeners and this appears to be the issue. I have started looking into the CLI cource(s) but have not figured out where it generates its list from the xml file and the object name of the CSV listener (or how to invoke it).

Well, I think I’ve figured out how to manually load the CSV results listener and I will test it on Monday when I have access to equipment. However the question still remains why does an OpenTap Custome GUI load the instruments using the settings folder but not the results listeners.

add csv assembly, to project
add namespace to TestPlanModel.cs
add resultListeners.Add(new CsvResultListener()); before calling testPlan.ExecuteAsync…

My guess (from a source file in another post) is that if resultslisteners is left empty the engine may load the resultslisteners dynamically from settings.

However, the custom GUI includes a resultslistener to harvest data from the test steps and display it on the GUI. As such this listener can not be compiled in the Development (test steps and instruments) environment and must be loaded as part of the GUI making it impossible to call the Execute function with an empty list.

Hi Craig,

Do you have the Results.xml file in the in the Settings directory? You may need to do something like:

var resultListeners = ResultSettings.Current.Concat(customResultListeners)
testPlan.Execute(resultListeners);

Otherwise, when you call Testplan.Execute(customResultListeners) it overrides the result listeners specified by the settings.

If you are building a custom GUI, the TUI is an excellent place to get inspiration, you can find the code here: OpenTAP / Plugins / Keysight Technologies / OpenTAP-TUI · GitLab

Thank you, that helped.

The concat required two objects and I still didn’t know how to address the one filled in by the settings xml files. Trying to figure out the correct syntax by browsing the resultsettings object was futile. What I came across was “var stores = ResultSettings.Current.OfType().ToList();”

While it didn’t address the issue I was facing it lead me to change the original code which statically defined the listeners:

            List<ResultListener> resultListeners = new List<ResultListener>();
            resultListeners.Add(new RugbyResultListener(this));
            resultListeners.Add(new CsvResultListener());
            // add more as needed  -->  resultListeners.Add(...);

to a dynamic version using the settings xml files.

            var resultListeners = ResultSettings.Current.OfType<IResultListener>().ToList();
            resultListeners.Add(new RugbyResultListener(this));

This also eliminated the need to for:
“using Keysight.OpenTap.Plugins.Csv;” and a reference to CSV is no longer required.

This may be long winded, but it may be useful to the next person looking for this solution since it is not obvious even in the TUI project.

1 Like

Ok, great, and you are right, I thought the TUI would use a custom result listener to monitor test plan events. I guess we should add something like that.

For future reference, this should work as well:

var customResultListener = new RugbyResultListener(this);
//T append your custom result listeners to the ones defined in XML 
plan.Execute(ResultSettings.Current.Concat(new []{customResultListener}));

The important part is to make sure to create a copy/derivative of ResultSettings.Current and not modify the original with these transient kinds of result listeners.

2 Likes