LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Cluster to string

A challenge to all you wireheads out there:

Is there somebody amongst you who is LabVIEW-nerd enough to create a VI or
CIN to which you can wire any cluster and it will return a string containing
the elements of the cluster with their labels.
For instance a cluster containing the string "name", the U8 "Age"
and enumarated U8 "gender".
It returns:
"name: Harry
Age: 84
gender: male"

I use clusters a lot to input and output values to and from VI's.
Sometimes these results are very suitable to be saved in a file or output
in a status window. If there was only a way to access the type definition of
a cluster (after all Labview gets that information from somewhere if you
attach a wire to something). Number of elements and per element type
and label.

Persuing this a little further: Maybe a new function should be added to
LabVIEW which returns type information so you can build behavior like the
"add" function to which you can wire anything. Of course inside this VI you
're building you have to create different functionality for different types
(case structure).

But I would already be happy with the first thing I wanted.
The implementation I have in mind right now is a VI I wrote which request
the status of a serial device, the device returns a status byte, I turn this
byte into a boolean array and the array into a cluster. I use a cluster of
named booleans which represent the possible errors of the device. It looks
nice
on the screen and is easy to test using unbundle by name. Now I would like
to log the errors....., the definition of what bit represents which error is
already in the cluster, why go through it again?
Another example, a VI request info from the device and returns (in a
cluster) address of the device (U8), the name (string), the BIOS-date
(string) and version number (string). I would like to show this information
in a status-line after I've initialized the device.....
Another example: I try communicating with a device. In a statusline I would
like to show:"Connecting using: Port: COM1, Baudrate: 28800, Databits: 8,
Stopbits: 1 , Parity: no parity". Apart from "Connecting using: " the labels
and the values are already in the cluster.....
I can generate a lot of these example and I'm sure you can too.

I find myself wireing these things out and having to change them when I
change something to the cluster. A cluster cast to string would be nice.
Anybody any idea how to handle this (maybe using an ActiveX variant or
adaptation of flatten to string ???).

RB
0 Kudos
Message 1 of 22
(5,892 Views)
I know that such parsers have been written. Actually, I wrote one myself some
time ago. Later someone published (at info-labview AFAIK) a similar tool with
better functionality, but I can't remember who and when.

Problem is that these things rely on the internal representation of variables in
LV. My own tool became useless (well, not completely) when this representation
was changed with a new LV version (don't know if it was 4.1 or 5.0). Right now
it's so badly documented (did I say badly? not at all documented!), I don't dare
to communicate it. (As the code is quite tricky, it's not self explaining
either).

Maybe you start a search at the info-labview archives, keyword something like
'parse type descriptor'

regards

Franz

Remco Breen schrieb:

> A chall
enge to all you wireheads out there:
>
> Is there somebody amongst you who is LabVIEW-nerd enough to create a VI or
> CIN to which you can wire any cluster and it will return a string containing
> the elements of the cluster with their labels.
> For instance a cluster containing the string "name", the U8 "Age"
> and enumarated U8 "gender".
> It returns:
> "name: Harry
> Age: 84
> gender: male"
>
> I use clusters a lot to input and output values to and from VI's.
> Sometimes these results are very suitable to be saved in a file or output
> in a status window. If there was only a way to access the type definition of
> a cluster (after all Labview gets that information from somewhere if you
> attach a wire to something). Number of elements and per element type
> and label.
>
> .....
0 Kudos
Message 2 of 22
(5,887 Views)
Thanks for the tip !

I've been looking at it this afternoon a couple of hours and could not find
a reference
to parsing type descriptors in the LabviewInfo search engine.
(By the way I get "access refused" when I try to reach
http://labview.pica.army.mil/,
anybody else experiencing this too?)

What I did find were references to polymorphic discussions and somebody
saying
that the type descriptor format was explained in the G Programming
reference, Apendix A.
I found that and have been playing with my own parser but when I got to the
cluster part
(of course did the numerical datatypes first :-{ ) I found that the label
is not stored in the
type descriptor. This is however crucial for my utility I wanted to
write....

Anybody else any ideas ?

RB.

Franz Josef Ahlers wrote in message <38E9E66C.D95B1DD3@ptb.de>...
>I know that such parsers have been written. Actually, I wrote one myself
some
>time ago. Later someone published (at info-labview AFAIK) a similar tool
with
>better functionality, but I can't remember who and when.
>
>Problem is that these things rely on the internal representation of
variables in
>LV. My own tool became useless (well, not completely) when this
representation
>was changed with a new LV version (don't know if it was 4.1 or 5.0). Right
now
>it's so badly documented (did I say badly? not at all documented!), I don't
dare
>to communicate it. (As the code is quite tricky, it's not self explaining
>either).
>
>Maybe you start a search at the info-labview archives, keyword something
like
>'parse type descriptor'
>
>regards
>
>Franz
>
>Remco Breen schrieb:
>
>> A challenge to all you wireheads out there:
>>
>> Is there somebody amongst you who is LabVIEW-nerd enough to create a VI
or
>> CIN to which you can wire any cluster and it will return a string
containing
>> the elements of the cluster with their labels.
>> For instance a cluster containing the string "name", the U8 "Age"
>> and enumarated U8 "gender".
>> It returns:
>> "name: Harry
>> Age: 84
>> gender: male"
>>
>> I use clusters a lot to input and output values to and from VI's.
>> Sometimes these results are very suitable to be saved in a file or output
>> in a status window. If there was only a way to access the type definition
of
>> a cluster (after all Labview gets that information from somewhere if you
>> attach a wire to something). Number of elements and per element type
>> and label.
>>
>> .....
>
0 Kudos
Message 3 of 22
(5,888 Views)
I happened to dig out my old own as well as the other solution I mentioned (It's
name was "LV_STRUCTURE_DCODER.LLB" and it was written by William van Drent.
"Parse_TypeDescriptor.llb" was the name of my old version. In it's best days it
could recursively parse any LV data type, regardless how deep it was nested). As
I expected, both of them now produce complete garbage when used under LV 5.1
since the internal representation of data in LV has changed. It's probably quite
simple to repair it (still needs some time though..) and then it should work
(until LV changes again 😞 ).

For now I will forward it to Remco with private mail, maybe it's still helpful.
Anybody else who is interested might drop me his request.


Franz
0 Kudos
Message 4 of 22
(5,888 Views)
Franz,

Can you please send me a copy of LV_STRUCTURE_DCODER.LLB as detailed on the Developers Exchange. I'm interested in converting any cluster and saving it to a data file. My Email is Ernst@MM-Tech.com

Thanks

Ernst
0 Kudos
Message 9 of 22
(5,885 Views)
Hello, I would be also interested to receive a copy of LV_STRUCTURE_DCODER.LLB.

Thanks RS e-mail is schubiger@lvv.iet.mavt.ethz.ch
0 Kudos
Message 10 of 22
(5,885 Views)
If possible could you send me a copy of your Parse_TypeDescriptor.llb and also LV_STRUCTURE_DCODER.LLB if you have it, I have not been able to get access to the site where it is supposedly posted. I am working with LV6 and would like to be able to read and write variants from clusters to Excel without having to hard-caode the data type (ie take a variant without knowing its type and dissect it so the data from each element ends up in a cell in Excel). I am working on a way to do this if the cluster is all simple data types, but it would be much more useful to me if I could embed clusters and arrays. My email is ekarplus@sciencewares.com.
0 Kudos
Message 11 of 22
(5,581 Views)
Hi

I think I wrote somthing like what you are looking for, some time ago. The
Vi was intended to take any type and write it to a configuration file and
read back to the variable. It also decode clusters inside clusters, and do a
lot more. A screen shot of the cluster Person, and how it is decoded as
string is attached. I also have some more complex examples of how it can be
used.

As someone pointed out the way of storing variables has changed in LV and
the decoding only has been tested with LV 5.1. It sure not work for LV 4 or
earlier.

IT SHOULD HAVE BEEN A NI JOB TO INCLUDE A VI TO DECODE THESE STRUCTURES.

Hans



Remco Breen wrote in message
news:954849346.228231@dibbs3.eur.cis.philips.com...
> A challenge to all you wireheads out there:
>
> Is there somebody amongst you who is LabVIEW-nerd enough to create a VI or
> CIN to which you can wire any cluster and it will return a string
containing
> the elements of the cluster with their labels.
> For instance a cluster containing the string "name", the U8 "Age"
> and enumarated U8 "gender".
> It returns:
> "name: Harry
> Age: 84
> gender: male"
>
> I use clusters a lot to input and output values to and from VI's.
> Sometimes these results are very suitable to be saved in a file or output
> in a status window. If there was only a way to access the type definition
of
> a cluster (after all Labview gets that information from somewhere if you
> attach a wire to something). Number of elements and per element type
> and label.
>
> Persuing this a little further: Maybe a new function should be added to
> LabVIEW which returns type information so you can build behavior like the
> "add" function to which you can wire anything. Of course inside this VI
you
> 're building you have to create different functionality for different
types
> (case structure).
>
> But I would already be happy with the first thing I wanted.
> The implementation I have in mind right now is a VI I wrote which request
> the status of a serial device, the device returns a status byte, I turn
this
> byte into a boolean array and the array into a cluster. I use a cluster of
> named booleans which represent the possible errors of the device. It looks
> nice
> on the screen and is easy to test using unbundle by name. Now I would like
> to log the errors....., the definition of what bit represents which error
is
> already in the cluster, why go through it again?
> Another example, a VI request info from the device and returns (in a
> cluster) address of the device (U8), the name (string), the BIOS-date
> (string) and version number (string). I would like to show this
information
> in a status-line after I've initialized the device.....
> Another example: I try communicating with a device. In a statusline I
would
> like to show:"Connecting using: Port: COM1, Baudrate: 28800, Databits: 8,
> Stopbits: 1 , Parity: no parity". Apart from "Connecting using: " the
labels
> and the values are already in the cluster.....
> I can generate a lot of these example and I'm sure you can too.
>
> I find myself wireing these things out and having to change them when I
> change something to the cluster. A cluster cast to string would be nice.
> Anybody any idea how to handle this (maybe using an ActiveX variant or
> adaptation of flatten to string ???).
>
> RB
>
>



[Attachment Test2.doc, see below]
0 Kudos
Message 5 of 22
(5,888 Views)
Hi

If attachment is opend in WORD; dobble clik on the picture to see everything

Hans


Hans �hra wrote in message
news:8cf5jo$69p$1@news.ffi.no...
> Hi
>
> I think I wrote somthing like what you are looking for, some time ago. The
> Vi was intended to take any type and write it to a configuration file and
> read back to the variable. It also decode clusters inside clusters, and do
a
> lot more. A screen shot of the cluster Person, and how it is decoded as
> string is attached. I also have some more complex examples of how it can
be
> used.
>
> As someone pointed out the way of storing variables has changed in LV and
> the decoding only has been tested with LV 5.1. It sure not work for LV 4
or
> earlier.
>
> IT SHOULD HAVE BEEN A NI JOB TO INCLUDE A VI TO DECODE THESE STRUCTURES.
>
> Hans
>
>
>
> Remco Breen wrote in message
> news:954849346.228231@dibbs3.eur.cis.philips.com...
> > A challenge to all you wireheads out there:
> >
> > Is there somebody amongst you who is LabVIEW-nerd enough to create a VI
or
> > CIN to which you can wire any cluster and it will return a string
> containing
> > the elements of the cluster with their labels.
> > For instance a cluster containing the string "name", the U8 "Age"
> > and enumarated U8 "gender".
> > It returns:
> > "name: Harry
> > Age: 84
> > gender: male"
> >
> > I use clusters a lot to input and output values to and from VI's.
> > Sometimes these results are very suitable to be saved in a file or
output
> > in a status window. If there was only a way to access the type
definition
> of
> > a cluster (after all Labview gets that information from somewhere if you
> > attach a wire to something). Number of elements and per element type
> > and label.
> >
> > Persuing this a little further: Maybe a new function should be added to
> > LabVIEW which returns type information so you can build behavior like
the
> > "add" function to which you can wire anything. Of course inside this VI
> you
> > 're building you have to create different functionality for different
> types
> > (case structure).
> >
> > But I would already be happy with the first thing I wanted.
> > The implementation I have in mind right now is a VI I wrote which
request
> > the status of a serial device, the device returns a status byte, I turn
> this
> > byte into a boolean array and the array into a cluster. I use a cluster
of
> > named booleans which represent the possible errors of the device. It
looks
> > nice
> > on the screen and is easy to test using unbundle by name. Now I would
like
> > to log the errors....., the definition of what bit represents which
error
> is
> > already in the cluster, why go through it again?
> > Another example, a VI request info from the device and returns (in a
> > cluster) address of the device (U8), the name (string), the BIOS-date
> > (string) and version number (string). I would like to show this
> information
> > in a status-line after I've initialized the device.....
> > Another example: I try communicating with a device. In a statusline I
> would
> > like to show:"Connecting using: Port: COM1, Baudrate: 28800, Databits:
8,
> > Stopbits: 1 , Parity: no parity". Apart from "Connecting using: " the
> labels
> > and the values are already in the cluster.....
> > I can generate a lot of these example and I'm sure you can too.
> >
> > I find myself wireing these things out and having to change them when I
> > change something to the cluster. A cluster cast to string would be nice.
> > Anybody any idea how to handle this (maybe using an ActiveX variant or
> > adaptation of flatten to string ???).
> >
> > RB
> >
> >
>
>
>
0 Kudos
Message 6 of 22
(5,889 Views)
The VI's that Franz Joseph send me looked very promissing, Especially the
LV_structure_decoder library
written by William van Drent. However they did not work anymore under LV
5.1.1 (That's what I use).
I looked at both programs for a while to find the difference between LV 4
and LV 5.1.1 (where does it go
wrong). But the example (top VI) has 36 subvi's. I could not find the reason
maybe I should take a user
manual form LV4 and compare it to the LV5.1 user manual.
I already spent more than one day in total on this which is way more than
solving my immediate problem
would take. So I am leaving it for now.
I did build my own decoder, and I found out that the label name ARE in there
(I thought they were not,
I read over it in the manual). If only I could call it recursively it would
be easier.
Then the decoding of the structure should be combined with the flattened
data and I'm there.
If I want a cluster into ASCII I think I have to flatten the data and feed
both the type descriptor and the flattened data to the VI which should
return a string (the flatten to string can not be inside the VI, if you
create a control from the input of the flatten to string you get a date/time
cluster which in itself reveals a little bit from the code underneath).

So.... do you have a working solution under LV5.1.1 ? Then I would be very
interested!

RB.


Hans �hra wrote in message <8cf5jo$69p$1@news.ffi.no>...
>Hi
>
>I think I wrote somthing like what you are looking for, some time ago. The
>Vi was intended to take any type and write it to a configuration file and
>read back to the variable. It also decode clusters inside clusters, and do
a
>lot more. A screen shot of the cluster Person, and how it is decoded as
>string is attached. I also have some more complex examples of how it can be
>used.
>
>As someone pointed out the way of storing variables has changed in LV and
>the decoding only has been tested with LV 5.1. It sure not work for LV 4 or
>earlier.
>
>IT SHOULD HAVE BEEN A NI JOB TO INCLUDE A VI TO DECODE THESE STRUCTURES.
>
>Hans
>
>
>
>Remco Breen wrote in message
>news:954849346.228231@dibbs3.eur.cis.philips.com...
>> A challenge to all you wireheads out there:
>>
>> Is there somebody amongst you who is LabVIEW-nerd enough to create a VI
or
>> CIN to which you can wire any cluster and it will return a string
>containing
>> the elements of the cluster with their labels.
>> For instance a cluster containing the string "name", the U8 "Age"
>> and enumarated U8 "gender".
>> It returns:
>> "name: Harry
>> Age: 84
>> gender: male"
>>
>> I use clusters a lot to input and output values to and from VI's.
>> Sometimes these results are very suitable to be saved in a file or output
>> in a status window. If there was only a way to access the type definition
>of
>> a cluster (after all Labview gets that information from somewhere if you
>> attach a wire to something). Number of elements and per element type
>> and label.
>>
>> Persuing this a little further: Maybe a new function should be added to
>> LabVIEW which returns type information so you can build behavior like the
>> "add" function to which you can wire anything. Of course inside this VI
>you
>> 're building you have to create different functionality for different
>types
>> (case structure).
>>
>> But I would already be happy with the first thing I wanted.
>> The implementation I have in mind right now is a VI I wrote which request
>> the status of a serial device, the device returns a status byte, I turn
>this
>> byte into a boolean array and the array into a cluster. I use a cluster
of
>> named booleans which represent the possible errors of the device. It
looks
>> nice
>> on the screen and is easy to test using unbundle by name. Now I would
like
>> to log the errors....., the definition of what bit represents which error
>is
>> already in the cluster, why go through it again?
>> Another example, a VI request info from the device and returns (in a
>> cluster) address of the device (U8), the name (string), the BIOS-date
>> (string) and version number (string). I would like to show this
>information
>> in a status-line after I've initialized the device.....
>> Another example: I try communicating with a device. In a statusline I
>would
>> like to show:"Connecting using: Port: COM1, Baudrate: 28800, Databits: 8,
>> Stopbits: 1 , Parity: no parity". Apart from "Connecting using: " the
>labels
>> and the values are already in the cluster.....
>> I can generate a lot of these example and I'm sure you can too.
>>
>> I find myself wireing these things out and having to change them when I
>> change something to the cluster. A cluster cast to string would be nice.
>> Anybody any idea how to handle this (maybe using an ActiveX variant or
>> adaptation of flatten to string ???).
>>
>> RB
>>
>>
>
>
>
0 Kudos
Message 7 of 22
(5,655 Views)