Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Networkvariable + Cluster

Hello,

 

we have a lbview application and a C#-application (Visual studio 2010 with NI measurement studio 2010 professional). The communication with the labview application we have to do with the NI network variables (NationalInstruments.Networkvariable namespace,  NetworkVariableBufferedWriter class.....).

The labview programmer now wants to have clusters as networkvariables, e.g. a network variable with the name "Language" with the members Translate (boolean) and Current (string). And also he wants to have arrays of this types.

 

The NetworkVariableBufferedWriter class is a generic class with only few  possible datatypes. 

 

Now my question:  how can we work with clusters as networkvariables and how we can programm it in C# ?

 

In Labview there is also a datattype "file path",  how we have to do the communication with this networkvariabletypes in C# ?

Best regards

GeFi

Gerhard

0 Kudos
Message 1 of 2
(3,440 Views)

Hi

 

We interface LabVIEW shared variables to C# (Measurement Studio) just like you.

My understanding is that C# does not support LabVIEW clusters....so your LabVIEW developer will have do it slightly differently.

If the data inside the cluster is all the same type, then it is best to convert the cluster to an array and transfer the data as an array.....but I guess that is probably not the case, so...

 

What we do in LabVIEW is flatten clusters to strings (using the Flatten  to String VI) and then convert the string to a byte array.

The data can then be published to a Network Shared Variable that is fixed size byte array.

For your info, the flatten to String VI has a few options that relevant, to you:

 

1. Prepend array or string size can be set to false (you'll probably want this to be false as otherswise you will get the cluster size in the data).

2. You can set the byte order as Big Endian or Little Endian. (Big Endian is the LabVIEW default).

 

In C# you then read through the data by using the BitConverter class.

It will be easier to read the data if it is transferred in Little Endian format, but for Big Endian you can swap the bytes round manually in C# and it is no problem.

 

When we initially started using this method we used "Little Endian" format.....but  it's easy to forget the byte order in LabVIEW....and you'll probably see this problem over an over.

So in the end, we decided to use Big Endian (i.e. the LabVIEW default) ...and swap the bytes in C#....as you will get less bugs in the end.

 

Regards

Mark

Message 2 of 2
(3,433 Views)