LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

array of structures across the datasocket?

I am restating this since I don't know if you guys look in the comments. How do I share an array of structures across the datasocket? I don't know before run time how many elements this array will be.
0 Kudos
Message 1 of 2
(2,918 Views)
It would be extremely difficult to try and do this with one DataSocket. DataSocket is not designed for nested structure or arrays of structure datatypes. You can't use DataSocket attributes to replicate simple structures (not composed of other structures). For example, a struct:

struct a
{
int id;
double data[100];
char description[100];
}

could be represented with a integer DataSocket that has a double array and string attribute. Attributes can't have attributes though, so nested structures would be difficult to send over DataSocket.

I would recommend one of three possible solutions:

1) Create a datasocket with attributes that represents one element of the structure array and create additional sockets for each other element incrementing the name
s of the URL's like item0, item1, etc.

2) Don't try and send structured data. Figure out the elements of the structure (native data types) that you need to send and pull them out and create regular arrays of doubles, strings, etc. and send them with a datasocket and attributes.

3) Don't use DataSocket. Use TCP and format everything to strings yourself and send TCP messages. This is what DataSocket is doing underneath anyway.

Remember DataSocket isn't designed for just C and was built in ActiveX. So, although arrays of structures may be relatively commonly used by C programmers, they aren't mappable to ActiveX datatypes and aren't exposed by DataSocket.

Best Regards,

Chris Matthews
Measurement Studio Support Manager
0 Kudos
Message 2 of 2
(2,918 Views)