Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

how to use warpper class from IVI driver

assume that I have downloaded the instrument driver for my instrument which is AWG2041.
next, I follow the weblink
to generate an instrument driver wrapper class.
 
how do I make use of this wrapper class (say InstrumentDriverAWG2041.cs) in Visual Studio 2005?
My purpose is to capture the source of the waveform from the AWG 2041 from CH1.
 
thanks.
0 Kudos
Message 1 of 4
(4,064 Views)
Hey TTH,

As the document that you referenced states, after you've used the Measurement Studio Instrument Driver .NET Wizard, the newly generated wrapper class is added to your Visual Studio project and opened in your source code editor.  This wrapper class gives you access to the methods within the Instrument Driver so that you can call them from within your project.

In terms of how to architect your program, you'll need to consult the help document that was included as a part of your Instrument Driver download.  This is a very detailed *.doc file that describes each function, it's use, and parameters.

I hope this helps!


Derrick S.
Product Manager
NI DIAdem
National Instruments
0 Kudos
Message 2 of 4
(4,051 Views)
hi Derrick,
 
the architect part of the portion is exactly which I am not sure how to do about it.
assuming that I have a Form, with a Button and a TextBox, and when the user presses that Button, I wish to activate the Initialize function, and return the status of the Initialize function inside the TextBox.
how do I go about it?

private void button1_Click(object sender, EventArgs e)

{

// to add on Initialize function here. How to do about it?

}

I would like to return the status of the Initialize function in a textbox too.

Also, from the AWG2041 *.doc downloaded, it seems to say that it can only support GPIB interface. My instrument AWG 2041 does come with RS 232. Can I use the RS 232 to do the initialization test?

tkwg20xx_init

      ViStatus tkwg20xx_init (ViRsrc resourceName, ViBoolean IDQuery,
                              ViBoolean resetDevice, ViSession *instrumentHandle);

  Purpose

      This function performs the following initialization actions:
      
      - Opens a session to the Default Resource Manager resource and a session
      to the specified device using the interface and address specified in the
      Resource_Name control.
      
      - Performs an identification query on the Instrument.
      
      - Resets the instrument to a known state.
      
      - Sends initialization commands to the instrument that set any necessary
      programmatic variables such as Headers Off, Short Command form, and Data
      Transfer Binary to the state necessary for the operation of the
      instrument driver.
      
      - Returns an Instrument Handle which is used to differentiate between
      different sessions of this instrument driver.
      
      - Each time this function is invoked a Unique Session is opened.  It is
      possible to have more than one session open for the same resource.
      

  Parameter List

      resourceName

          Variable Type       ViRsrc

          This control specifies the interface and address of the device that
          is to be initialized (Instrument Descriptor). The exact grammar to be
          used in this control is shown in the note below.
          
          Default Value:  "GPIB::1"
          
          Notes:
          
          (1) Based on the Instrument Descriptor, this operation establishes a
          communication session with a device.  The grammar for the Instrument
          Descriptor is shown below.  Optional parameters are shown in square
          brackets ([]).
          
          Interface   Grammar
          ------------------------------------------------------
          GPIB        GPIB[board]::primary address[::secondary address]
                      [::INSTR]
          
          The GPIB keyword is used with GPIB instruments.
          
          The default value for optional parameters are shown below.
          
          Optional Parameter          Default Value
          -----------------------------------------
          board                       0
          secondary address           none - 31
          

      IDQuery

          Variable Type       ViBoolean

          This control specifies if an ID Query is sent to the instrument
          during the initialization procedure.
          
          Valid Range:
          VI_OFF (0) - Skip Query
          VI_ON  (1) - Do Query (Default Value)
          
          Notes:
          
          (1) Under normal circumstances the ID Query ensures that the
          instrument initialized is the type supported by this driver. However
          circumstances may arise where it is undesirable to send an ID Query
          to the instrument.  In those cases; set this control to "Skip Query"
          and this function will initialize the selected interface, without
          doing an ID Query.
          

      resetDevice

          Variable Type       ViBoolean

          This control specifies if the instrument is to be reset to its
          power-on settings during the initialization procedure.
          
          Valid Range:
          VI_OFF (0) - Don't Reset
          VI_ON  (1) - Reset Device (Default Value)
          
          Notes:
          
          (1) If you do not want the instrument reset. Set this control to
          "Don't Reset" while initializing the instrument.
          

      instrumentHandle

          Variable Type       ViSession (passed by reference)

          This control returns an Instrument Handle that is used in all
          subsequent function calls to differentiate between different sessions
          of this instrument driver.
          
          Notes:
          
          (1) Each time this function is invoked a Unique Session is opened.
          It is possible to have more than one session open for the same
          resource.
          

  Return Value

          This control contains the status code returned by the function call.
          
          Status Codes:
          
          Status    Description
          -------------------------------------------------
                 0  No error (the call was successful).
          
          3FFF0005  The specified termination character was read.
          3FFF0006  The specified number of bytes was read.
          
          BFFC0002  Parameter 2 (ID Query) out of range.
          BFFC0003  Parameter 3 (Reset Device) out of range.
          
          BFFC0803  Invalid Instrument Response.
          
          BFFF0000  Miscellaneous or system error occurred.
          BFFF000E  Invalid session handle.
          BFFF0015  Timeout occurred before operation could complete.
          BFFF0034  Violation of raw write protocol occurred.
          BFFF0035  Violation of raw read protocol occurred.
          BFFF0036  Device reported an output protocol error.
          BFFF0037  Device reported an input protocol error.
          BFFF0038  Bus error occurred during transfer.
          BFFF003A  Invalid setup (attributes are not consistent).
          BFFF005F  No listeners condition was detected.
          BFFF0060  This interface is not the controller in charge.
          BFFF0067  Operation is not supported on this session.
          

 

0 Kudos
Message 3 of 4
(4,043 Views)
TTH,

Any code that you want to execute upon the click of your button needs to go in the callback function for your button.  If you want to make a call to the initialize function, use the function prototype from the function reference document that downloaded with your driver to figure out the parameters and return value of the initialize method.

If you need some help getting started with your application, I highly recommend referencing some of our many examples that we ship with Measurement Studio.  You can find the examples installed by default to the <Measurement Studio>\DotNET\Examples directory

Many of our examples use button callbacks to execute various functionality.

I hope this helps!
Derrick S.
Product Manager
NI DIAdem
National Instruments
0 Kudos
Message 4 of 4
(4,023 Views)