Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Lost Facilities of CWArray

When using the National Instruments.Analysis tools in Measurement Studio.net 7.1 the functionality that was in the CWARRAY seems to be missing from the ArrayOperations.  In particular operations on 1D and 2D arrays such as IndexArray, setArray etc.  These are useful for abstracting data from larger analysis arrays containing multiple channels.
 
Is this correct? or am I missing something.
 
StevieB
0 Kudos
Message 1 of 7
(4,434 Views)

Hi StevieB,

I've found this knowledge base article which describes how to extract a channel of data from an array - thought it may be useful

http://digital.ni.com/public.nsf/websearch/6362FC1543AEDF4186256DD500647B68?OpenDocument

Also you should be able to find a full list of functionailty for the ArrayOperations in the documentation which Measurement Studio Installs, just by searching for ArrayOperations.

Is there anything in particular that you needed help with?

Hannah

NIUK & Ireland

0 Kudos
Message 2 of 7
(4,416 Views)

Hannah,

I was intrigued by your reply to stevieB.  I have also been battling converting a VB6 app to Meas Studio 7 in vb.net for over 2 months now and still have not figured out the following:

1. how can I perform a "search" on the Meas Studio Help? As far as I can tell there is no facility to do this and its like looking for a needle in a haystack to find anything in the NI-supplied Help documentation.

2. I have the same problem as stevieB regarding finding the equivalent of the VB6 CWArray functions.   I found an example somewhere that references a CWInstrumentControllib class, but I do not have this class in my installation and have no idea how to get it in there.  I have found ArrayOperations under the Analysis.Math namespace, but the capabilities are limited and do not include many Meas Studio 6 conveniences like AddArray, MulArray, IndexArray etc.

Any help you can provide would be greatly appreciated,

J R

 

 

 

 

0 Kudos
Message 3 of 7
(4,416 Views)
Greetings all

We reduced the functionality that was present in the CWArray library because alot of is now part of the part of the .NET framework Array class. Plus there have been significant changes in the way arrays used to work in VB 6.0 vs VB.NET. Alot of the changes between the languages have been covered in this free book here. This book is also a greate resource for someone who is upgrading from VB 6.0 to VB.NET.

Ofcourse this does not mean we do not intend to add additional functionality to the ArrayOperations class. If you feel there are certain critical array operations that are missing,please feel free to provide feedback by using this link.

vsaone- The CWInstrumentControllib library is an interop library that is generated if you use an activex component in VB.NET. If you are doing instrument control via GPIB or serial, you can use the native .NET APIs we provide for GPIB and VISA. These are available by downloading the approriate driver from the drivers page and installing .NET support. This will provide examples for how to use the APIs and documentation as well. This is alot better than using the  activex wrappers.

As for the help, the Measurement Studio help is fully integrated into Visual Studio 2003. To do a search, go to the Help menu in Visual Studio 2003 and select Search. If you want to filter by Measurement Studio libraries only, choose Measurement Studio in the Filter drop down box. You won't find any help about the CW controls in this help, since this is only for the .NET and C++ libraries. Was there something in particular you were trying to lookup that you were unable to find?

I hope this helps.

Bilal Durrani
NI
0 Kudos
Message 4 of 7
(4,408 Views)
Bilal,
 
Thanks for the help on Help - it helps a bit.  However, I find the VS2003 Help to be very frustrating because I usually have to sort thru either hundreds of unorganized hits or else get 0 hits when I perform a search on anything.  The Meas Studio Help in VB6 was most excellent and logical.  I cannot say the same for Meas Studio 7 Help.
 
The CWArray functions that I used all the time in VB6 were the math operations DivArray, AddArray, MulArray.  Its easy to duplicate these with loops, but not nearly as convenient and I fear a performance hit. I can find no equivalents in MS 7 or vb.net. I also used CopyArray, SetArray and IndexArray quite a bit, but there are vb.net alternatives to those, as you described.
 
J R
 
0 Kudos
Message 5 of 7
(4,406 Views)

Thank you all for replies.

I'm trying to end up with the following Structure Spectra(Channel,FreqRange).ydata whereby Channel can be upto 64,FreqRange upto 3 i.e. 10kHz, 1kHz and 200Hz ranges, ydata being the spectra for each channel and frequency range.The functions that I use frequently therefore are as follows: -

' read 64 Autopower Spectra data into array for one frequency range.

ydata=Eng.ydata(0) this fills ydata with (blocksize/2,number of channels) - Eng.ydata(0) is filled with format (Blocksize,Channels)

ydata=CWArray.SubsetArray(ydata,Array(Array(0,.Blocksize/2.56),Array(0,Number of Channels))) 

This returns the Spectrum data to the correct number of spectral lines.

form a channel count loop

I then use dblMag=CWArray.IndexArray(ydata,Array(null,iCount)) to Obtain A single Channel then use CWDSP.SpectrumUnitConversion for Converting the spectrum to dB.

I then use CWArray.CopyArray to copy the data out into the structure

Spectra(iCount,IFreqrange).ydata=CWArray.CopyArray(dblMag)

In an updategraph routine I use CWArray.CopyArray to strip out a single spectrum for a given freq range for plotting.

These routines are used for displaying Spectra from the device in realtime.

In .net this functionality is missing and some of them replaced, for me it would be better if they were still contained in ArrayOperations.

As regards help, ArrauOperation is buried in the Math operations whereas in VB6 they were all under CWArray.  Hopefully these routines will be included within Version 8 when it arrives.  By the way I haven't written a useful application in .Net thus far I'm testing things in 2005 Express.

0 Kudos
Message 6 of 7
(4,397 Views)

Thanks for the feedback. I file those as suggestions for further review.

Here is a small example of how you could implement ArraySubset in VB.NET

Public Shared Function ArraySubSet(ByVal inputArray(,) As Double, ByVal indexArray(,) As Integer) As Array
        If inputArray Is Nothing Then
            Throw New ArgumentNullException("inputarray")
        End If
        If indexArray Is Nothing Then
            Throw New ArgumentException("indexarray")
        End If

        Dim indexArrayRows As Integer = indexArray.GetLength(0)
        Dim indexArrayColumns As Integer = indexArray.GetLength(1)

        If indexArrayRows > 2 Or indexArrayColumns > 2 Then
            Throw New ArgumentException("invalid argument")
        End If

        Dim inputArrayRows As Integer = inputArray.GetLength(0)
        Dim inputArrayColumns As Integer = inputArray.GetLength(1)

        Dim newArrayDimensions(1) As Integer

        Dim i As Integer
        For i = 0 To indexArrayRows - 1
            newArrayDimensions(i) = indexArray(i, 1)
        Next i

        Dim rowStart As Integer = indexArray(0, 0)
        Dim colStart As Integer = indexArray(1, 0)

        Dim returnArray As Array = Array.CreateInstance(GetType(Double), newArrayDimensions)

        'get element size. In the case of a double, this is 8 bytes.
        Dim elementSize As Integer = 8

        For i = 0 To (newArrayDimensions(0)) - 1
            'Copy bytes from the array
            Buffer.BlockCopy(inputArray, (inputArrayColumns * rowStart + colStart) * elementSize, returnArray, i * elementSize * newArrayDimensions(1), elementSize * newArrayDimensions(1))
            rowStart = rowStart + 1
        Next i

        Return returnArray
    End Function 'ArraySubSet
-----------------------------------------------------------
Here is how you could use it

Dim data(5, 6) As Double
        Dim l As Integer = 0
        Dim i As Integer
        For i = 0 To 4
            Dim j As Integer
            For j = 0 To 5
                data(i, j) = l
                l = l + 1
            Next j
        Next
        Dim test As Array = ArrayExample.ArraySubSet(data, New Integer(,) {{1, 2}, {0, 3}})
   
-----------------------------------------------------------

I think I got it right, but this should get you up and running.

The Array class already has a Copy method.

We have the Measurements.SpectrumUnitConversion() method, which provides the same functionality as the one in CWDSP.

I hope this helps.
Bilal Durrani
NI
0 Kudos
Message 7 of 7
(4,377 Views)