07-18-2012 03:06 PM
I'm attempting to use MAX to set up some instruments (FGens) with generic names. I thought I had the logical names and driver sessions all configured correctly, but when I try to instantiate the specific driver via the IviFgen.Create, it runs the wrong construcor. When debugging it, the correct driver file is hit (a .NET driver wrapper created via Measurement Studio), but no matter which set of parameters I pass to IviFgen.Create, it always runs the following constructor:
public MyDriver(string Logical_Name, bool ID_Query, bool Reset_Device, string Option_String)
This wouldn't necessarily be a problem, but I get a "Function or Method not supported" Error when this runs. I need to know if there is some hidden configurations somewhere in MAX that allow me to set the default constructor, because apparently matching the parameters to call a different constructor is not enough =\
07-20-2012 10:52 AM
Hi Geoff V,
Can you provide more details on the hardware and software that you are using? Are you programming in Measurement Studio for Visual C# .NET? Which version? Do you have NI IVI Compliance Package installed? What is the instrument-specific driver that you are using? According to IviFgen Class Specification
----------
IIviFgen fgen = IviFgen.Create(“MyLogicalName”);
In this case, the ID of the instrument will not be verified, the instrument will not be reset, and options will be supplied from the configuration store and/or driver defaults.
-----------
Feel free to post your code for further troubleshooting. Also have a look at the following articles to learn how to configure your IVI device in MAX:
Using Measurement & Automation Explorer to Configure Your IVI System
Run-Time Configuration of IVI Instrument Drivers
07-23-2012 11:28 AM
Using Visual C# in VS 2010, I'm trying to instantiate one of the generic class drivers (FGEN) to use my .NET wrapper class for the "afg3k" driver, which makes PInvoke calls to the IviFgen_64.dll. This wrapper is for the Tektronix model AFG3101 function generator, and was generated via Measurement Studio. I am using NI-DAQmx 9.5.5 with IVI Compliance Pkg 4.4
I'm attempting to use the either of the following invokations:
Ivi.Fgen.IIviFgen fgenDriver = IviFgen.Create("FGEN");
Ivi.Fgen.IIviFgen fgenDriver = IviFgen.Create("FGEN", true, true);
I've attached 5 screen shots of my MAX window, where the FGEN logical name is configured. For some reason, when I make any call through the generic IviFgen.Create(...) it always calls the following constructor in my wrapper class:
MyDriver(string "LogicalName", bool query, bool reset, string "Options");
instead of the constructor matching the parameters I specify in the create. So it is finding my wrapper and calling it, just not the correct constructor for some reason. The problem is that when this specific constructor gets called, I get the following error:
IviSessionFactory: An instance of the specific driver referenced by the driver session name could not be created, or did not support the specified type.
Specific driver (software module): tkafg3k
Class name: InstrumentDriverLib.TektronixAFG3101Driver, InstrumentDriverLib
I can't find any documentation on this issue but I assume there are some settings to change in MAX that will allow me to force a different constructor to be instantiated.
Our preferred method would be setting up the Logical Name to directly call IviFgen_64.dll, that way we don't have to use the wrapper class. However I am unsure what to set as the as the assembly qualified class name when using the actual IviFgen_64.dll. I've guessed and checked at it with no prevail so far.
07-24-2012 12:16 PM
Hi Geoff V,
It seems that there is some sort of a mismatch in your IVI driver configuration. What I would do is create a .NET wrapper in VS 2010 for tkafg3k driver.
To do that open up C# project in VS 2010 and then go to Project-> Add New Item -> NI Instrument driver (refer to .net_wrapper.png)
You can then create a logical name in MAX (i.e. FGEN) and link it to tkafg2k driver session which would call tkafg3k_64.dll
Finally, if you want to use C# there is no way to address the DLL directly, you will need a .NET wrapper in any case.
07-26-2012 11:22 AM
So I mimicked the example code found in the "IVI-4.3: IviFgen Class Specification" document for instantiating a generic class driver and I'm getting some weird behavior, check out the first two screen shots...
In the first screenshot, I do not manually create my wrapper class (TektronixAFG3101Driver). When I run IviFgen.Create(...) I get the exception you see in the picture, with no inner exception. Furthermore, when I do this I cannot step into the TektronixAFG3101Driver class and it does not run any of the TektronixAFK3101Driver constructors.
In the second screenshot, I uncomment the TektronixAFK3101Driver variable, which should not be running any constructors on its own and does stay null the entire time. When I run the IviFgen.Create(...) I can step into my wrapper code to see the PInvoke does NOT error and I do see my instrument reset as it should. However, when the constructor returns I get the exception you see in the picture, with an inner exception of "Cannot cast TekfronixAFK3101 into IIviFgen". If it is attempting to return my wrapper type which only inherits from System.Object, how is this supposed to behave?
The third screenshot is of my MAX Driver Session settings incase anything there is not what it should be...
Thanks,
Geoff
07-29-2012 01:36 PM - edited 07-29-2012 01:39 PM
Hi Geoff,
The reason that you might be getting an error during compilation is that the Assembly Qualified Class Name is not configured correctly. Refer to IVI Configuration Server Specification :
--------
10.3.1 Assembly Qualified Class Name
Returns a string that is the assembly qualified class name of the default .NET class of the software module. This property may be an empty string.
---------
Also, I don't see a [IviFgen].Create method in the tkafg3k .NET wrapper, so that might also be what's causing the problem.
As you know, Tektronix tkafg3k IVI driver (TektronixAFG3101Driver) is based on the ivifgen driver and if you look at its .NET wrapper it is almost identical to .NET wrapper generated from iviFgen.fp. Now, I created a simple program in C# (WindowsFormApplication) and added the .NET wrapper generated from C:\Program Files\IVI Foundation\IVI\Drivers\tkafg3k\tkafg3k.fp to my C# project and I was able to successfully run it. Try it on your end. The code and MAX configuration are attached.
The code generates a sine wave on Channel 1 with A=1, freq=100Hz, DC offset=0, phase_delay=0.
07-30-2012 01:28 PM
Using the following chunk of code does control my FGEN correctly:
driver.ConfigureOperationMode("1", 1);
driver.ConfigureStandardWaveform("1", 1, 1, 0, 100, 0);
driver.InitiateGeneration();
However, I do need to be able to use the generic classes to instantiate them in order to keep the interchangability (as you know). That is why I was previously trying to use IviFgen.Create("FGEN"...). Maybe I misunderstood the documentation related to itnerchangability, but I thought it worked like this:
The generic IviFgen.Create("LogicalName", ...) basically looks up LogicalName, finds the Driver Session associated with this name, and uses the module path given in this Driver Session to find the correct driver for the actual instrument.
So this piece of code correctly controlls my Tektronics3101 FGEN, but I need to instantiate it generically so I can just use a different logical name to use a different instrument, etc etc. I'm sure it's a simple fix and I'm most likely missing something basic in the setup. I tried your MAX settings with the following piece of code:
_fgenDriver = IviFgen.Create(logicalName, query, reset);
_fgenDriver.Output.SetOperationMode("1", OperationMode.Continuous);
_fgenDriver.Output.SetEnabled("1", true);
and got this error: "The specific driver’s main class (assembly qualified class name) is not specified in the configuration store."
07-31-2012 02:53 PM
The reason why you are getting this error: "The specific driver’s main class (assembly qualified class name) is not specified in the configuration store." is as follows:
-------
This error is thrown after the driver session has been found, and the software module referenced by the driver session has been found. The cause of the error is either that the assembly qualified class name is blank, or that the program could not access the ISoftwareModule2 interface which contains the assembly qualified class name.
If the assembly qualified class name is blank, the driver referenced by the software module is not an IVI.NET driver, or the driver's software module entry is corrupt. If the driver is an IVI.NET driver, the problem may be fixed by repairing or reinstalling the driver.
If the assembly qualified class name is not blank, the program could not access the ISoftwareModule2 interface. This interface was added in version 1.5.0 of the IVI Shared Components. If a version of the IVI Shared Components older than version 1.5.0 is installed, the problem may be fixed by upgrading to a newer version.
-------
Reference: 1. Overview of the Inherent Capabilities Specification - IVI Foundation
You are correct in terms of how interchangability works. Just to reiterate, the logical name is what identifies the particular driver session to use. The driver session, in turn, identifies a specific driver and device and specifies the initial settings for the session. You configure the logical name, driver session, specific driver, and hardware asset with MAX. If you want to use your program with a different physical instrument, you change the configuration of the logical name to use the driver session for the new physical instrument. Now you should be able to create a new fgen IVI instrument driver session with the following function included in the .NET wrapper generated from ivifgen.fp:
public iviFgen(string Logical_Name, bool ID_Query, bool Reset_Device)
/// <param name="Logical_Name">
/// Pass the logical name that identifies the particular driver session to use. The driver session, in turn, identifies a specific driver and device and specifies the initial settings for the session. You configure the logical name, driver session, specific driver, and device with the IVI Configuration utility.
/// <param name="ID_Query">
/// Specify whether you want the instrument driver to perform an ID Query.
/// <param name="Reset_Device">
/// Specify whether you want the to reset the instrument during the initialization procedure.
08-13-2012 12:29 PM
Sorry for the late reply, had some account issues and got a new account but I do still have some questions/issues...
I reinstalled the following software on a fresh mashine:
NI-DAQMX 9.5.5
NI-VISA 5.1.2
IVI-Compliance pkg 4.5
IVI-SharedComponents (Latest)
IVI-NetSharedComponents (Latest)
NI-Device Drivers Aug 2012
The complete list can be seen in the first attached screenshot.
I'm still attempting to instantiate a FGEN driver instance which corresponds to my "FGEN" logical name. My Measurement Studio generated wrapper (TektronixAFG3101Driver.cs) is making calls to IviFgen.dll (C:\Program Files\IVI Foundation\IVI\Microsoft.NET\Framework32\v2.0.50727\IviFoundationSharedComponents 1.0\Ivi.Fgen.dll), which I assume is correct. Using this wrapper as my assembly qualified class name, the generic call (seen below) does hit this wrapper code and calls the DLL:
IIviFgen driver = IviFgen.Create("FGEN", bool, bool)
However the error I get makes it seem as though like I am missing some software download or ambiguous path somewhere. The error is: "Primary Error: (Hex 0xBFFF0011) Insufficient location information or the device or resource is not present in the system." The function generator is indeed connected via USB and I can use the VISA Test Panel to reset and query device by hand. Any ideas?
08-13-2012 01:19 PM
Make sure all the VISA Passports are checked in MAX -> Tools -> NI-VISA -> VISA Options -> Passports
Also, you might want to check the name of your Resource Descriptor under the Driver Sessions in MAX. Make sure the resource descriptor corresponds to your function generator. Refer to the following article for more details:
A resource descriptor is a string, such as a VISA resource descriptor, that specifies the interface and the address of the hardware to associate with the step. The following lists examples of valid resource descriptors.