Keysight Pathwave 89600 VSA .NET API
.NET 6+ Nuget Packages
Send Feedback

Glossary Item Box

This topic explains how to create a .NET 6+ application that connects to the 89600 VSA software.

Creating the Client Application

There are several ways you can create the client application.  The following sections provide brief guidance to help you get started.

Visual Studio

Start Visual Studio and create a new project.  Choose the Console App template that targets .NET (that doesn’t have “(.NET Framework)” in the template name) and configure access to the NuGet packages (see Add Package Source to Visual Studio).  Then you should be able to Manage NuGet Packages and install the desired VSA packages.  You can then skip to the Using the .NET 6+ Client API section for some example code to run.

Visual Studio Code

Follow the instructions for the Command Line (CLI) section below.  Install and start Visual Studio Code.  Open the folder where you created the .NET project.  Open Program.cs.  Install the Microsoft C# extension if prompted.  Click Run > Start Debugging and follow the prompts to choose C# and your debugging target (your console app). 

Command Line Interface (CLI)

Once you have the dotnet CLI tool installed on your system (see Microsoft’s .NET SDK installation instructions), you can follow these steps:

  1. Create directory and change to it
  2. Type dotnet new console
  3. Add Package Source using NuGet.exe Command Line
  4. Reference Packages using dotnet Command Line Tool
  5. Edit the Program.cs file to have the contents in the Using the .NET 6+ Client API section.
  6. Type dotnet run

Configure Package Source

There are several ways to configure your system to be able to access the NuGet packages.  This consists of creating or modifying a nuget.config file.  You can modify it manually, use the NuGet.exe command line tool (available from nuget.org), or use Visual Studio.

Add Package Source to Visual Studio

In Visual Studio, click Tools > Options and navigate to the NuGet Package Manager > Package Sources section.  Add a package source for the location you wish to use.  See Package Source Location for the possible source locations you can choose.  Below is an example of referencing the local file system location for the 89600 VSA NuGet packages.

 

Add Package Source using NuGet.exe Command Line

Run these commands to add the 89600 VSA package source to your global nuget.config file and list the available packages.  See Package Source Location for the value of [source].

nuget sources Add -Name "89600 VSA" -Source "[source]"

nuget list Keysight.Vsa

Add Package Source by Manually Editing nuget.config

You can manually edit the nuget.config file by adding the section in bold.  Make sure to change [source] to the correct value as described in Package Source Location.  If you are creating a new nuget.config, you can just use the text below.

<?xml version="1.0" encoding="utf-8"?>

<configuration>

     <packageSources>

          <add key="89600 VSA" value="[source]" />

     </packageSources>

</configuration>

 

Note: The local nuget.config location is the directory containing your .sln file (if you have one) or the directory containing your only .csproj file.  The global nuget.config location depends on your operating system.

Package Source Location

You can access the 89600 VSA NuGet packages from a local file system directory. When installing the Keysight PathWave 89600 VSA, the installer provides you with the option to install the required NuGet packages:

 

When this option is selected, the packages will be installed in this folder:

[source] = C:\Program Files\Common Files\Keysight\NuGet

Important: To use these packages on a Linux system, you will need to copy the C:\Program Files\Common Files\Keysight\NuGet folder to a folder on your Linux system.  The value of <source> then becomes the folder you choose.

Referencing .NET 6.0+ NuGet Packages

.NET 6.0+ client applications need to reference one or more NuGet packages that provide the interface to access the Keysight PathWave 89600 VSA functionality.

Once you follow the instructions in Configure Package Source, you will need to add a reference to the NuGet packages you need for your project.  Below is a list of packages you will need to reference.

  • Keysight.Vsa.All.Client – general VSA features, including Vector/PowerSuite mode 
  • Keysight.Vsa.<measurement extension>.Client – specific features for the measurement extension that you wish to use
  • Hardware-specific input extensions (extended functionality, not needed for hardware connectivity)
    • Keysight.Vsa.HardwareExtensions.Core.Client – input extensions for core hardware (including X-Series, Infiniium oscilloscopes, etc.). 
    • Keysight.Vsa.HardwareExtensions.<hardware>.Client – input extensions for a specific family of <hardware>

Reference Packages using Visual Studio

Right-click a project in the Solution Explorer panel and choose Manage NuGet Packages.  Choose the 89600 VSA package source from the dropdown and then install the desired packages from the Browse panel.

Reference Packages using dotnet Command Line Tool

Run the following commands to add the necessary packages for your usage:

dotnet add package Keysight.Vsa.All.Client

dotnet add package [other packages]

Reference Packages by Manually Editing Project File

You can manually edit the project file to add a PackageReference.  The bold text below shows an example of adding a reference to the Keysight.Vsa.Client package to a .csproj file.

<Project Sdk="Microsoft.NET.Sdk">

     <PropertyGroup>

      …

     </PropertyGroup>

     <ItemGroup>

           <PackageReference Include="Keysight.Vsa.All.Client" Version="28.60.179" />

     </ItemGroup>

</Project>

Using the .NET 6+ Client API

The following is a C# code snippet that provides a short example on how to use the .NET 6+ client API.

Important: if you are running from Linux, you will need to use the ApplicationFactory.Create override that provides the hostname and port of the Windows computer running 89600 VSA (since VSA does not run under Linux).

using Keysight.Vsa;
using CQ = Keysight.Vsa.ChannelQuality;
Application app;
// Connect to VSA (must have .NET Client Access Server enabled in VSA Startup Preferences)
// Here are some examples:
// (connect to already running VSA instance on this machine)
// app = ApplicationFactory.Create();
// (start latest installed VSA on this machine, choose port automatically)
app = ApplicationFactory.Create(true, null, null, -1);
// (connect to running VSA on remote machine)
// app = ApplicationFactory.Create(false, null, "remote.host.name.or.IP", 59189);
// (note, starting remote VSA is not currently supported)
if (app == null)
{     Console.WriteLine("Failed to connect to VSA");     return; }
app.IsVisible = true; // leave hidden for faster speed, show for debugging
app.Preset();
var meas = app.Measurements.SelectedItem;
// configure measurement settings (just an example, ignore actual results)
meas.SetMeasurementExtension<CQ.MeasurementExtension>();
var measExt = meas.GetMeasurementExtension<CQ.MeasurementExtension>();
measExt.MultitoneStimulus.Configure(1E6, 101);
// prepare to read data from trace
MeasurementData errSummary;
var currentTrace = app.Display.Traces.SelectedItem;
currentTrace.DataName = "Summary1";
errSummary = currentTrace.MeasurementData;
// run single measurement
meas.IsContinuous = false;
meas.Restart();
meas.WaitForMeasurementDone();
// read measurement result
var freqErr = errSummary.Summary("FrequencyError1");
Console.WriteLine($"frequency error = {freqErr}");
// or you can read measurement data directly without needing a Trace
// meas.IsCalculateMeasurementData("Summary1");
// errSummary = meas.MeasurementData("Summary1");
// meas.Restart();
// meas.WaitForMeasurementDone();
// freqErr = errSummary.Summary("FrequencyError1");
// Console.WriteLine($"frequency error = {freqErr}");
// errSummary.Dispose();
// meas.IsCalculateMeasurementDataClear();
app.Quit();