Build own gui to run test plan, not workable with myTestPlan.execute(resultListeners)

I’m going to build a very simple user interface,click the “start” button to run a test plan automatically.

Then I copied code from “BuildTestPlan” example for run command. When the code goes to “myTestPlan.Execute(resultListeners);”, it will quit abnormally. But the code run successfully with no resultlistener like “myTestPlan.Execute()”.


The console application could be running without any issues. Could anyone tell me why the GUI couldn’t work? thanks

3 Likes

@hongbo.huo , did you inspect the SessoinLogs? They should contain additional details on why OpenTAP stops running.

Are you using the same Result Listener, when you’re running test plans using the CLI?

2 Likes

@witold.pietraszek Thanks for reply. It seems sessionlogs has a lot of information. But I couldn’t understand what was happening.

  1. The unsuccessful run generated a sessionlog named “console_log.txt”. It was not in “SessionLogs” folder
  2. The unsuccessful log is as below. I really have no idea what to do next.
    2021-03-20 10:47:56.389690 ; Session ; Debug ; Session log loaded as ‘F:\test only\openTap\openTapSDK\openTAPrun\bin\Debug\SessionLogs\openTAPrun 2021-03-20 10-47-52.txt’. [15.0 ms]

2021-03-20 10:47:56.416620 ; Session ; Debug ; Running '“F:\test only\openTap\openTapSDK\openTAPrun\bin\Debug\openTAPrun.exe” ’ in ‘F:\test only\openTap\openTapSDK\openTAPrun\bin\Debug’.

2021-03-20 10:47:56.447419 ; Session ; Debug ; Microsoft Windows 10.0.19042 X64

2021-03-20 10:47:56.447419 ; Session ; Debug ; .NET Framework 4.8.4341.0

2021-03-20 10:47:56.463534 ; Session ; Debug ; Session log loaded as ‘console_log.txt’. [9.51 ms]

2021-03-20 10:47:56.464642 ; Session ; Debug ; Running '“F:\test only\openTap\openTapSDK\openTAPrun\bin\Debug\openTAPrun.exe” ’ in ‘F:\test only\openTap\openTapSDK\openTAPrun\bin\Debug’.

2021-03-20 10:47:56.521426 ; Resolver ; Debug ; Found 8/26 assembly files. [31.6 ms]

2021-03-20 10:47:56.532205 ; Session ; Debug ; OpenTAP Engine 9.12.3+81c8e2eb X86

2021-03-20 10:47:56.621512 ; Resolver ; Debug ; Found match for System.Reflection.Metadata, Version=1.4.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a in F:\test only\openTap\openTapSDK\openTAPrun\bin\Debug\Dependencies\System.Reflection.Metadata.1.4.3.0\System.Reflection.Metadata.dll

2021-03-20 10:47:56.665933 ; Resolver ; Debug ; Found match for System.Collections.Immutable, Version=1.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a in F:\test only\openTap\openTapSDK\openTAPrun\bin\Debug\Dependencies\System.Collections.Immutable.1.2.3.0\System.Collections.Immutable.dll

2021-03-20 10:47:56.800393 ; Searcher ; Debug ; Ordered 7 assemblies according to references. [274 ms]

2021-03-20 10:47:56.854461 ; PluginManager ; Debug ; Found 4 plugin assemblies containing 147 plugin types. [328 ms]

2021-03-20 10:47:56.855463 ; PluginManager ; Debug ; Found version 9.12.3+81c8e2eb of OpenTap.dll

2021-03-20 10:47:56.855463 ; PluginManager ; Debug ; Found version 9.12.3+81c8e2eb of OpenTap.Package.dll

2021-03-20 10:47:56.855463 ; PluginManager ; Debug ; Found version 9.12.3+81c8e2eb of OpenTap.Plugins.BasicSteps.dll

2021-03-20 10:47:56.855463 ; PluginManager ; Debug ; Found version 0.0.0.0 of sdkrunCMD.exe

2021-03-20 10:47:56.855463 ; PluginManager ; Debug ; Searched 8 Assemblies. [329 ms]

2021-03-20 10:47:56.867914 ; PluginManager ; Debug ; Loaded OpenTap. [419 us]

2021-03-20 10:47:56.868912 ; PluginManager ; Debug ; Loaded OpenTap.Plugins.BasicSteps. [200 us]

2021-03-20 10:47:56.919809 ; PluginManager ; Debug ; Loaded mscorlib. [700 ns]

2021-03-20 10:47:56.981613 ; PluginManager ; Debug ; Loaded OpenTap.Package. [15.4 ms]

2021-03-20 10:47:59.955807 ; TestPlan ; Information ; -----------------------------------------------------------------

2021-03-20 10:47:59.970796 ; TestPlan ; Information ; Starting TestPlan ‘Untitled’ on 2021/3/20 10:47:59, 4 of 4 TestSteps enabled.

2021-03-20 10:47:59.977783 ; Settings ; Debug ; No settings file exists for EngineSettings. A new instance with default values has been created. [2.84 ms]

2021-03-20 10:47:59.981771 ; Settings ; Debug ; No settings file exists for DutSettings. A new instance with default values has been created. [642 us]

2021-03-20 10:47:59.996698 ; Settings ; Debug ; No settings file exists for InstrumentSettings. A new instance with default values has been created. [220 us]

2021-03-20 10:47:59.998725 ; Settings ; Debug ; No settings file exists for ConnectionSettings. A new instance with default values has been created. [206 us]

2021-03-20 10:48:00.000897 ; Settings ; Debug ; No settings file exists for ResultSettings. A new instance with default values has been created. [162 us]

2021-03-20 10:48:00.003680 ; Settings ; Debug ; No settings file exists for PackageManagerSettings. A new instance with default values has been created. [977 us]

2021-03-20 10:48:00.012933 ; TestPlan ; Debug ; Saved Test Plan XML [4.80 ms]

2021-03-20 10:48:02.059357 ; TestPlan ; Information ; Waiting for resources to open:

2021-03-20 10:48:02.059357 ; TestPlan ; Information ; - Log

2021-03-20 11:04:30.431372 ; Session ; Debug ; Session log loaded as ‘F:\test only\openTap\openTapSDK\openTAPrun\bin\Debug\SessionLogs\openTAPrun 2021-03-20 11-04-25.txt’. [56.8 ms]

2021-03-20 11:04:30.458299 ; Session ; Debug ; Running '“F:\test only\openTap\openTapSDK\openTAPrun\bin\Debug\openTAPrun.exe” ’ in ‘F:\test only\openTap\openTapSDK\openTAPrun\bin\Debug’.

2021-03-20 11:04:30.521709 ; Session ; Debug ; Session log loaded as ‘console_log.txt’. [10.3 ms]

2021-03-20 11:04:30.526696 ; Session ; Debug ; Running '“F:\test only\openTap\openTapSDK\openTAPrun\bin\Debug\openTAPrun.exe” ’ in ‘F:\test only\openTap\openTapSDK\openTAPrun\bin\Debug’.

2021-03-20 11:04:30.587396 ; Resolver ; Debug ; Found 34/89 assembly files. [37.1 ms]

2021-03-20 11:04:30.621426 ; Resolver ; Debug ; Found match for System.Runtime.InteropServices.RuntimeInformation, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a in F:\test only\openTap\openTapSDK\openTAPrun\bin\Debug\Dependencies\System.Runtime.InteropServices.RuntimeInformation.4.0.2.0\System.Runtime.InteropServices.RuntimeInformation.dll

2021-03-20 11:04:30.630282 ; Session ; Debug ; Microsoft Windows 10.0.19042 X64

2021-03-20 11:04:30.630282 ; Session ; Debug ; .NET Framework 4.8.4341.0

2021-03-20 11:04:30.656212 ; Session ; Debug ; OpenTAP Engine 9.12.3+81c8e2eb X86

2021-03-20 11:04:30.687407 ; Resolver ; Debug ; Found match for System.Reflection.Metadata, Version=1.4.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a in F:\test only\openTap\openTapSDK\openTAPrun\bin\Debug\Dependencies\System.Reflection.Metadata.1.4.3.0\System.Reflection.Metadata.dll

2021-03-20 11:04:31.160624 ; Searcher ; Debug ; Ordered 30 assemblies according to references. [570 ms]

2021-03-20 11:04:31.211488 ; PluginManager ; Debug ; Found 21 plugin assemblies containing 327 plugin types. [622 ms]

2021-03-20 11:04:31.212486 ; PluginManager ; Debug ; Found version 9.12.3+81c8e2eb of OpenTap.dll

2021-03-20 11:04:31.212486 ; PluginManager ; Debug ; Found version 9.12.3+81c8e2eb of OpenTap.Plugins.BasicSteps.dll

2021-03-20 11:04:31.212486 ; PluginManager ; Debug ; Found version 9.12.1+b350c60f of Keysight.OpenTap.Wpf.dll

2021-03-20 11:04:31.212486 ; PluginManager ; Debug ; Found version 9.12.3+81c8e2eb of OpenTap.Package.dll

2021-03-20 11:04:31.212486 ; PluginManager ; Debug ; Found version 9.12.1+b350c60f of PackageManager.exe

2021-03-20 11:04:31.212486 ; PluginManager ; Debug ; Found version 9.12.1+b350c60f of Editor.exe

2021-03-20 11:04:31.212486 ; PluginManager ; Debug ; Found version 0.0.0.0 of keboda_DUTs.dll

2021-03-20 11:04:31.212486 ; PluginManager ; Debug ; Found version 1.0.0.0 of OpenTap.Plugins.ExamplePlugin.dll

2021-03-20 11:04:31.212486 ; PluginManager ; Debug ; Found version 1.0.0.0 of OpenTap.Plugins.PluginDevelopment.dll

2021-03-20 11:04:31.212486 ; PluginManager ; Debug ; Found version 1.0.0.0 of PluginDevelopment.Gui.dll

2021-03-20 11:04:31.212486 ; PluginManager ; Debug ; Found version 9.10.1+cb7f7c7a of Csv.dll

2021-03-20 11:04:31.212486 ; PluginManager ; Debug ; Found version 9.12.1+b350c60f of ResultsViewer.exe

2021-03-20 11:04:31.212486 ; PluginManager ; Debug ; Found version 9.12.1+b350c60f of RunExplorer.exe

2021-03-20 11:04:31.212486 ; PluginManager ; Debug ; Found version 0.0.0.0 of sdkrunCMD.exe

2021-03-20 11:04:31.212486 ; PluginManager ; Debug ; Found version 9.12.1+b350c60f of Keysight.OpenTap.CommunityEditionPopup.dll

2021-03-20 11:04:31.212486 ; PluginManager ; Debug ; Found version 1.0.0 of OpenTap.OSIntegration.Windows.dll

2021-03-20 11:04:31.212486 ; PluginManager ; Debug ; Found version 9.12.3+81c8e2eb of OpenTap.Sdk.New.dll

2021-03-20 11:04:31.212486 ; PluginManager ; Debug ; Found version 9.4.2+3009aace of Keysight.OpenTap.Plugins.ResultListener.SqlDatabase.dll

2021-03-20 11:04:31.212486 ; PluginManager ; Debug ; Found version 9.4.2+3009aace of Keysight.OpenTap.Plugins.ResultListener.PostgreSQL.dll

2021-03-20 11:04:31.212486 ; PluginManager ; Debug ; Found version 9.4.2+3009aace of Keysight.OpenTap.Plugins.ResultListener.SQLite.dll

2021-03-20 11:04:31.212486 ; PluginManager ; Debug ; Found version 1.1.2+dda72af5 of OpenTap.VSSdk.Installer.dll

2021-03-20 11:04:31.212486 ; PluginManager ; Debug ; Searched 34 Assemblies. [623 ms]

2021-03-20 11:04:31.225162 ; PluginManager ; Debug ; Loaded OpenTap. [408 us]

2021-03-20 11:04:31.227158 ; PluginManager ; Debug ; Loaded OpenTap.Plugins.BasicSteps. [195 us]

2021-03-20 11:04:31.258109 ; Resolver ; Debug ; Found match for System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 in F:\test only\openTap\openTapSDK\openTAPrun\bin\Debug\Dependencies\System.ValueTuple.4.0.3.0\System.ValueTuple.dll

2021-03-20 11:04:31.295975 ; PluginManager ; Debug ; Loaded mscorlib. [600 ns]

2021-03-20 11:04:31.365786 ; PluginManager ; Debug ; Loaded Keysight.OpenTap.Wpf. [32.5 ms]

2021-03-20 11:04:31.376953 ; PluginManager ; Debug ; Loaded PackageManager. [46.3 ms]

2021-03-20 11:04:31.391717 ; PluginManager ; Debug ; Loaded OpenTap.Plugins.PluginDevelopment. [49.9 ms]

2021-03-20 11:04:31.401702 ; PluginManager ; Debug ; Loaded ResultsViewer. [65.9 ms]

2021-03-20 11:04:31.405681 ; PluginManager ; Debug ; Loaded OpenTap.Package. [71.6 ms]

2021-03-20 11:04:31.412060 ; PluginManager ; Debug ; Loaded RunExplorer. [70.3 ms]

2021-03-20 11:04:31.417648 ; PluginManager ; Debug ; Loaded Editor. [86.5 ms]

2021-03-20 11:04:31.464614 ; PluginManager ; Debug ; Loaded OpenTap.OSIntegration.Windows. [6.41 ms]

2021-03-20 11:04:35.760367 ; TestPlan ; Information ; -----------------------------------------------------------------

2021-03-20 11:04:35.776340 ; TestPlan ; Information ; Starting TestPlan ‘Untitled’ on 2021/3/20 11:04:35, 4 of 4 TestSteps enabled.

2021-03-20 11:04:35.783283 ; Settings ; Debug ; No settings file exists for EngineSettings. A new instance with default values has been created. [2.56 ms]

2021-03-20 11:04:35.787304 ; Settings ; Debug ; No settings file exists for DutSettings. A new instance with default values has been created. [662 us]

2021-03-20 11:04:35.803261 ; Settings ; Debug ; No settings file exists for InstrumentSettings. A new instance with default values has been created. [225 us]

2021-03-20 11:04:35.805222 ; Settings ; Debug ; No settings file exists for ConnectionSettings. A new instance with default values has been created. [216 us]

2021-03-20 11:04:35.807244 ; Settings ; Debug ; No settings file exists for ResultSettings. A new instance with default values has been created. [154 us]

2021-03-20 11:04:35.835305 ; PluginManager ; Debug ; Loaded PresentationFramework. [400 ns]

2021-03-20 11:04:35.894019 ; Settings ; Debug ; GuiControlsSettings loaded from F:\test only\openTap\openTapSDK\openTAPrun\bin\Debug\Settings\GUI Controls.xml [85.7 ms]

2021-03-20 11:04:35.921943 ; Settings ; Debug ; EditorSettings loaded from F:\test only\openTap\openTapSDK\openTAPrun\bin\Debug\Settings\Editor.xml [27.4 ms]

2021-03-20 11:04:35.922940 ; Settings ; Debug ; No settings file exists for PackageManagerSettings. A new instance with default values has been created. [925 us]

2021-03-20 11:04:35.923940 ; Settings ; Debug ; No settings file exists for PackageManagerGuiSettings. A new instance with default values has been created. [359 us]

2021-03-20 11:04:35.932914 ; Settings ; Debug ; PanelSettings loaded from F:\test only\openTap\openTapSDK\openTAPrun\bin\Debug\Settings\GUI Panels.xml [8.98 ms]

2021-03-20 11:04:35.933912 ; Settings ; Debug ; No settings file exists for CustomBenchSettingsList. A new instance with default values has been created. [244 us]

2021-03-20 11:04:35.935904 ; Settings ; Debug ; No settings file exists for ExampleSettings. A new instance with default values has been created. [346 us]

2021-03-20 11:04:35.936904 ; Settings ; Debug ; No settings file exists for ViewerSettings. A new instance with default values has been created. [340 us]

2021-03-20 11:04:35.937899 ; Settings ; Debug ; No settings file exists for RunExplorerSettings. A new instance with default values has been created. [835 us]

2021-03-20 11:04:35.947350 ; TestPlan ; Debug ; Saved Test Plan XML [4.93 ms]

2021-03-20 11:04:37.996318 ; TestPlan ; Information ; Waiting for resources to open:

2021-03-20 11:04:37.996318 ; TestPlan ; Information ; - Log

I use the following method to run the tap plan using result listeners, it is running successfully for me.

public void Test()
        {
            Task.Run(() =>
            {
                while (true)
                {
                    if (isTapPlanReadyForRun)
                    {
                        Dispatcher.CurrentDispatcher.Invoke(() =>
                        {                     
                            cancellationToken = new CancellationTokenSource();
                            myTestPlan.ExecuteAsync(resultListeners, null, null, cancellationToken.Token);
                        });

                        break;
                    }
                }
            });

        }
3 Likes

I’m so happy this works! Thanks a lot :smile:
It seems myTestPlan.ExecuteAsync() is the key to run. Below is my finally running code:
> // Execute the TestPlan. This is the equivalent of the Run button in the TAP GUI.

        //myTestPlan.Execute();
        CancellationToken cancellationToken = new CancellationToken();
        //myTestPlan.Execute(resultListeners,null);
        myTestPlan.ExecuteAsync(resultListeners, null, null, cancellationToken);
3 Likes

Hi @hongbo.huo, I’m glad to see this topic. I’ve been considering making a simple custom UI. Some of our operators feel that the Keysight Editor is overkill for them. But I’m not sure how to go about firing up the OpenTAP engine outside of the comfort of the Editor. I have a bunch of questions like these:

  • From a c# application, how do you get the OpenTAP engine “running” ?
  • Does OpenTAP automatically load all the plugins, like it does in the Editor?
  • Do I have to point OpenTAP to a Settings directory, etc?
  • How do I register Log listeners?

Does anyone know of a good reference for starting a custom OpenTAP UI? Would the TUI be a good place to look?

1 Like

@david-wsd great questions! I believe you are already familiar with dockable panels (for those that aren’t , an example is here: sdk/Examples/PluginDevelopment.Gui/GUI/DockablePanel.cs · master · OpenTAP / OpenTAP · GitLab)
This is one possibility for customizing a UI without doing too much UI work. We have even recently enabled something we initially called “Focus Mode” which allows you to hide certain aspects of the UI for simplicity (press Alt+Shift+Enter in 9.12+).

For integrating with C# API (including starting OpenTAP, loading plugins, settings, and Result Listeners) you can look at this example. It doesn’t go into details of how to create a UI, but it shows the OpenTAP APIs you would need:

If you are looking for more of a web interface there is also the REST API Plugin. This is built on OpenAPI/Swagger and provides a really nice interface for web UIs.

1 Like

@brennen_direnzo Focus mode = mind blown :exploding_head:

LOL I learn something new every time I visit this forum!

I had not even thought of using a dockable panel within the Editor, as an alternative to creating completely standalone custom UI. Combined with the focus mode, that could fly. But while in focus mode, how is the user supposed to load a test plan?

For a completely separate UI, the example you shared looks like the perfect starting point, nice and succinct. Thank you!

To manually connect resources prior to running a test plan, is it as simple as calling myTestPlan.Open() ?

1 Like

You are always good for some positive quotes that can be shared :grinning:. We are glad you find it useful. Maybe you can convince more of your team to join :wink:

For Focus Mode. What we have seen it that 1 of 2 things would be done:

  1. Buttons would be created to allow for loading/running specific Test Plans (restricting the user to what can be selected, or providing no selection)
  2. Slightly more flexible, but having a FilePath in the custom panel that allowed for select.

For manual connection to resources, you got it. Calling TestPlan.Open() is the equivalent of clicking the Connect button in the Editor UI:
image

1 Like

@brennen_direnzo :open_mouth: Have I missed something, was the Focus mode announced somewhere?

1 Like

It was part of a release highlight for 9.12, but we did not do major communication. There are a few notes in the Editor.chm file:

1 Like