LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Need Info from a pre-8.0 CVI user (InstrumentDriverDotNetWizard)

I am building some code originally developed by a third party for our company.  There is a "funky" build tool called "InstrumentDriverDotNetWizard" that is a home-grown application.  The general MO of this third party was to rename sample programs, modify them very slightly, and proclaim it a tool.  I will paste the entire source code below, it is short.
 
It uses these DLL's that they zipped up and sent to me:
   NationalInstruments.InstrumentDriverDotNetWizard.Core.dll
   NationalInstruments.InstrumentDriverDotNetWizard.HeaderFileP.dll
   NationalInstruments.InstrumentDriverDotNetWizard.SubFilePars.dll
 
I use CVI 8.0.1.  I am downloading the Measurement Studio 8.1 eval to see if that is what I am missing (have an older copy on my desk, but it's older than VS.Net 2005 is). 
 
I could not Google "InstrumentDriverDotWizard" ... no results at all.  I'm wondering if this is a workaround for a problem that doesn't exist in current software?  Does anyone know?
 
---

using

System;

using NationalInstruments;

using

NationalInstruments.InstrumentDriverDotNetWizard;

namespace

InstrumentDriverDotNetWizard

{

/// <summary>

/// Console App wrapper for NI'ls InstrumentDriverDotNetWizard.

/// </summary>

class ConsoleApp

{

/// <summary>

/// The main entry point for the application.

/// </summary>

[

STAThread]

static void Main(string[] args)

{

if (args.Length != 1)

{

Console.WriteLine("Syntax: InstrumentDriverDotNetWizardConsoleApp fpfile");

}

else

{

String fppath = args[0];

String codepath = fppath.Replace(".fp",".cs");

System.IO.

FileStream fpfile = System.IO.File.OpenRead(fppath);

InstrumentDriver driver =

new InstrumentDriver(fpfile );

GeneratorOptions options =

new GeneratorOptions();

// //GUI App does this:

// //Is it the default? or is it the result of UpdateFromDriver()?

// options.Language = Language.CSharp;

// options.GenerateComments = true;

// options.Namespace = "InstrumentDriverInterop.Ivi";

// options.CallingConvention = CallingConvention.StdCall;

// options.ClassName = "KE622X";

// options.Dll = "KE622X_32.dll";

options.UpdateFromDriver(driver);

options.GenerateComments =

false;

// Console.WriteLine( driver.LooksLikeVxiPnpDriver );

// Console.WriteLine( driver.LooksLikeIviDriver );

 

System.IO.

StreamWriter codefile = new System.IO.StreamWriter(codepath);

codefile.Write( SimpleGenerator.Generate(driver,options));

codefile.Close();

// Console.WriteLine( driver.SubFile.Attributes.Length );

// Console.WriteLine( driver.SubFile.Values.Count );

// Console.WriteLine( driver.HeaderFile.SymbolExists("IVI_ATTR_SPECIFIC_DRIVER_PREFIX") );

}

}

}

}

Certified LabVIEW Developer
NI-VLM Administrator
0 Kudos
Message 1 of 4
(3,241 Views)
Hi JulieC,

You will need Measurement Studio because this code is .NET, and not ANSI C that works in CVI.  The .cs extension is for C#.NET source files.
The Instrument Driver .NET Wizard is a part of Measurment Studio.  While in a solution, add a new item, and Instrument Driver will be a choice, assuming Measurement Studio is installed.
 
Gavin Fox
Systems Software
National Instruments
0 Kudos
Message 2 of 4
(3,222 Views)

I think I need to re-explain:  I am developing an instrument driver, not using one.  The utility above did *SOMETHING* to the instrument driver as built from within CVI to make it useable from .NET.

The original author of the code was using much older software versions than I am.  I think they used CVI5.something.  The LabVIEW versions they used for other pieces of the same product were 5 and 6.  They used some strange combination of VC6++ and .Net 2003.

In contrast, I am using CVI8.0.1 (have 8.1, just haven't installed it for myself), LabVIEW 7.1, 8.0, 8.2, and I have converted everything C++ to .Net 2005 except this.

This, I get a compile error on this utility:

Error 1 The type or namespace name 'InstrumentDriverDotNetWizard' does not exist in the namespace 'NationalInstruments' (are you missing an assembly reference?) C:\PlatformESP\TSB\Tools\InstrumentDriverDotNetWizard\ConsoleApp.cs 3 27 InstrumentDriverDotNetWizardConsoleApp

I can't find the reference I need to add.  The DLL they sent me isn't a valid .COM component. 

So ...

1) Any idea if I still need to take this step or is a driver built with modern CVI capable of being called from .Net without using this kludgy conversion tool?

2) If I still need to do something kludgy, where can I find said reference?

 

Certified LabVIEW Developer
NI-VLM Administrator
0 Kudos
Message 3 of 4
(3,215 Views)
I am a CVI 8.1 user and I have Measurement Studio 8.0.1 installed on top of VS.NET 2005.
 
I checked the VS.NET 2005 help, and I got this: (let me know if you need more info, and perhaps also try the forum for Measurement Studio)
 
"Calling Instrument Drivers from .NET Languages"
 
Many IVI and VXI plug&play drivers include C DLLs, which provide functions that communicate with a particular instrument. To use an IVI or VXI plug&play driver with a C DLL in a Measurement Studio .NET application, use the .NET Instrument Driver wizard to create .NET entry points to the DLL functions you need to call from your application.
The .NET Instrument Driver wizard generates a .NET wrapper class for calling into IVI, VXIplug&play , and legacy instrument drivers based on the instrument driver function panel, header file, and an optional .sub file for IVI drivers. The wizard can generate both Visual C# and Visual Basic .NET source code.
Generating an instrument driver wrapper class with the .NET Instrument Driver wizard
Open the Visual Basic .NET or Visual C# project in which you want to generate an instrument driver wrapper class.
Select Project»Add New Item to launch the Add New Item dialog box.
In the Categories pane, select Measurement Studio.
In the Templates pane, select Instrument Driver.
Specify a name for the .NET instrument driver and click Open. The name you choose for the file becomes the name of the source file.
In the New .NET Instrument Driver dialog box, select which instrument driver you want to create by browsing to the .fp filename. Click Next.
Configure the code generation options. Default values are given based on information from the instrument driver .fp file.
Click Finish.
After you complete these steps, a new instrument driver wrapper class is added to the project and opened in the source code editor. Now you can edit and compile this file the same as any other source file in your project.
Inspecting an instrument driver wrapper class
After the .NET Instrument Driver wizard finishes, inspect the top of the file for any comments that begin with TODO. These comments indicate problems the wizard encountered while generating the instrument driver wrapper class, such as duplicate entries in the .fp or .sub file or missing constant values in the instrument driver header file.
If you chose to generate documentation comments, the comments precede each method in the instrument driver wrapper class. This help content also appears in Intellisense when you use the class. Because the wizard imports documentation comments directly from the function panel file, the documentation refers to elements in the driver's C API. For example, the documentation comments might refer to a function named niScope_init rather than to the class constructor, or the documentation might refer to an attribute named NISCOPE_ATTR_RANGE_CHECK rather than the NiScopeProperties.RangeCheck constant.
Calling an instrument driver wrapper class
The following example is a typical example of how you use an instrument driver wrapper class. Note that this example uses a pre-generated instrument driver wrapper class for the National Instruments NI-SCOPE instrument driver. The example code will not run unless NI-SCOPE is installed and an NI-SCOPE device is present in the system. You can download the NI-SCOPE instrument driver wrapper from Microsoft Visual C# and Visual Basic .NET Wrappers for National Instruments Modular Instruments Drivers at ni.com/kb.
[C#]
using (niScope scope = new niScope("myDAQmxDevice", true, true))
{
    double[] waveform = new double[1000];
    niScopeWfmInfo[] waveformInfo = new niScopeWfmInfo[1];
    scope.ConfigureChannel("0", 10.0, 0.0, niScopeConstants.Ac, 1.0, true);
    scope.SetString(niScopeProperties.TriggerSource, "0");
    scope.Read("0", 0.0, waveform.Length, waveform, waveformInfo);
}
[VB.NET]
Using scope = New niScope("myDAQmxDevice", True, True)
    Dim waveform(999) As Double
    Dim waveformInfo(0) As niScopeWfmInfo
    scope.ConfigureChannel("0", 10.0, 0.0, niScopeConstants.Ac, 1.0, True)
    scope.SetString(niScopeProperties.TriggerSource, "0")
    scope.Read("0", 0.0, waveform.Length, waveform, waveformInfo)
End Using
--
To whom it may concern: My alias is also my nickname, I've had it since I was a (very) skinny basketball-playing teen. OK, so I've got a 38 inch waist now, but my hometown friends haven't shaken that appellation for me. I trust that you will someday be OK with that alias, as I have been with that nickname.
0 Kudos
Message 4 of 4
(3,204 Views)