05-10-2010 03:35 PM
I have a need to move large amounts of test data from a Labwindows/CVI 8.5 application to a C# program to be bulk loaded into an Oracle database.
Since I'm not a Labwindows developer, I started learning about Network Variables by creating writer and reader apps in C#. By filling the arrays in the writer app and publishing using the Measurement Studio NetworkVariableBufferedWriter methods, I was able to use NetworkVariableSubscriber to read them, with no loss of data.
The data consists of a set of four arrays that generally hold 20,000 pieces of data. Two arrays are integer values and two hold double values. This set of data is collected repeatedly, usually generating multi-mega bytes of data before the test is complete.
The sample program in the 3DSim example appeared to be exactly what I need, but it uses a structure. I've been unable to find any reference to passing a CNV structure to a C#.net application.
My other thought was to place each of the 4 arrays into another 4x20000 array and pass that, but I'm not having any luck with this approach.
Can someone point me in the right direction! Preferably with some examples of how to pass structure-like data from LabWindows to C# using Network Variables.
Thanks
Bob
Solved! Go to Solution.
05-11-2010 10:27 AM
hey Bob,
The .NET API doesn't play nicely with C structures or LabVIEW clusters. Probably the easiest way to achieve what your looking for is to create a network variable for each array. The attached code (just remove the .txt extension) is a simple example of writing arrays to network variables from CVI to C#. Let me know if you have any questions.
NickB
National Instruments
PS - sorry if the C# example is a little obscure, I'm more comfortable in C and usually use these kind of opportunities as an excuse to try new things in C#... 🙂
05-12-2010 07:56 AM
Nickb,
Thanks for the examples. They would be a good addition to the Measurement Studio examples collection. I'm sure our site is not the only one that needs to share data quickly between Lab Windows and the .NET environment.
I was hoping to find a way to group all the arrays that belong together in some way to decrease any possibility of scrambling the data (this array doesn't belong with that array sort of thing).
Because throughput is a primary focus (cycle time, you know) I was hoping to use a completely asynchronous approach. I thought that using another NV to signal completion (as you show) would somehow impact the throughput of the system. I tested by filling each array with 20000 items (i.e. records) and writing the received array values to a text file. It took ~160mS which I'm hoping will be similar to writing to the Oracle database (bulk loading).
Thanks again for the help.
Regards
Bob