Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Comprehensive Documentation for .NET Libraries?

 

Background: I'm very new to PXI and NI ecosystem, but have significant experience with .NET programmed and embedded development.  I'm trying to create an automated hardware / firmware test system for our embedded devices, that can be run automatically (with our nightly builds, for example).

 

I've been floundering around for the past few days trying to get a good understanding of the .NET libraries provided by NI.  The biggest problem I keep running into is I cannot find any sort of comprehensive documentation on the libraries.  For example, I would like to be able to find all of the instruments attached to a system.  In this case, my system with a PXI backplane with 5 instrument modules installed.

 

Visa looked like a good place to start.  I opened up the FindResources example, and immediately wanted to know what the syntax is for ResourceManager.Find(string).  I've been searching for days and haven't found anything that will me what the Find method expects in a string.

 

A significant number of classes and functions in the NationalInstruments namespace (.net dlls) expect a resource string to be passed in.  What is a resource string?  How is it formatted?  How can I get a list of resources attached to my system?  

 

For example, if I want to take readings from the DMM that's in the PXI chassis, what do I need to pass to the resourceName parameter?  How can I programmically get a list of resources?

 

Where's the documentation for the .NET Libraries?

0 Kudos
Message 1 of 5
(4,688 Views)

For finding out what NI modules you have in your chassis use NationalInstruments.ModularInstruments.ModularInstrumentsSystem (Assembly NationalInstruments.ModularInstruments.ModularInstrumentsSystem
C:\Program Files (x86)\National Instruments\MeasurementStudioVS2008\DotNET\Assemblies\Current\NationalInstruments.ModularInstruments.ModularInstrumentsSystem.dll)

 

From your project, set a reference to NationalInstruments.ModularInstruments.ModularInstrumentsSystem.

 

I have used C# so here’s a code snippet:

 

Snippet

        /// <summary>
        /// Gets the names of all the devices connected to the system (NI chassis/ PC).
        /// </summary>
        /// <returns>List of device names</returns>
        public IEnumerable<string> GetNIDevicesNames(string driverName) // Driver name e.g. niHSDIO, niDCPower, etc.
        {
            ModularInstrumentsSystem myModularInstrumentsSystem = string.IsNullOrEmpty(driverName) ? new ModularInstrumentsSystem() : new ModularInstrumentsSystem(driverName);
            foreach (DeviceInfo item in myModularInstrumentsSystem.DeviceCollection)
            {
                yield return item.Name;
            }
        }

 

You can then use the returned names as resource names.

 

As for the comprehensive documentation for .NET Libraries, I suggest using Visual Studio object browser as resource once a particular driver is installed to your system. Hope this helps.

0 Kudos
Message 2 of 5
(4,684 Views)

I've tried using the ModularInstrumentsSystem class, and it gets all but 1 of the modules installed in my chassis.  I have

   PXI-2566

   PXI-2527

   PXI-4065

   PXI-4130

   PXIe-6535

 

The ModularInstrumensSystem.DeviceCollection will return all of the devices EXCEPT for the PXIe-6535.  The PXIe-6535 does show up under the DaqSystem.Local.Devices collection, and I cannot figure out why.  

 

I've been crashing around the Visual Studio object browser, but that doesn't give a whole lot of information.  For example in the Visa namespace, creating PxiSession requires a "string that describes a unique VISA resource", but doesn't give any sort of hint as to where that resource string comes from, or its format, or anything.  Is "Bob" a valid resource?  It's a string, and I can pass it in, but I highly doubt that it would work....

 

public PxiSession(string resourceName)
    Member of NationalInstruments.Visa.PxiSession

Summary:
Initializes a new instance of the NationalInstruments.Visa.PxiSession object from the specified resource name.

Parameters:
resourceName: String that describes a unique VISA resource.

Remarks:
This constructor ensures that the resource string represents a PXI INSTR resource and throws a NationalInstruments.Visa.ResourceTypeMismatchException if the resource string represents an incorrect resource.

Information of what a resource string is, how one goes about getting them dynamically, etc, is one of the many pieces of information that I'm after.  The NI-VISA Interactive Control software can show resources.  How can I get those resource strings in my code?  Basic, fundamental documenation of how these APIs function would just be fantastic.

0 Kudos
Message 3 of 5
(4,679 Views)

Hi CurtisHx,

 

For NI-VISA, please refer to http://www.ni.com/product-documentation/52841/en/ to get a brief overview of the API and a link to download the CHM that might be useful to see what API functions are available.

 

The NI-VISA .NET API is a wrapper on the NI-VISA C API, and a lot of the VISA concepts can be gathered from the NI-VISA C documentation (which is typically installed in <DOCUMENTS>\National Instruments\NI-VISA\Documentation.)

 

For your specific question about getting the PXI Resource names programmatically, you would create a NationalInstruments.Visa.ResourceManager object and use its Find() method to find all VISA resources. In addition, you can pass it a pattern such as "PXI?*" to restrict the list to PXI resources. These patterns are described in the NI-VISA C Documentation.

 

I hope this helps a bit.

 

EDIT: Search the NI-VISA C API Help for viFindRsrc page which has examples of patterns you can use.

Message 4 of 5
(4,677 Views)

That at least helps me to get going.  Thanks.

0 Kudos
Message 5 of 5
(4,639 Views)