LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Cluster To ASCII Text File

I need to find a way to output my cluster of indicators (string and
numeric) values (Over 100) that is stored in a global vi, to an ASCII
(not binary) text file. Ideally I'd like to be able to write the
cluster element name and value(s).

i.e.:

Indicator Labels, Indicator Values

Test 1 Upper Limit, 100 (Numeric)
File Path, c:\Test.txt (String)
Channels, 100, 200, 300, 400 (Array)

The flatten to string gives a binary output, as does the Write (data)
File vi. The Write Characters To File vi won't accept the cluster
format (unless I first flatten to string � which gives be a binary
output) , neither will the Write To Spreadsheet File vi.

I have gone through the laborious effort of connecting every cluster
element to a separate indicator in a
separate vi, labeling each
indicator to the same name as the cluster elements. I was surprised
that the indicator didn't take on the name of the cluster element, as
I created the indicator by left clicking to the option menu. If that
worked I was hoping that I could then create an attribute node that
would have the label text, unfortunately the attribute node will only
access the caption (which is not set), not the label.

Even if the attribute method worked, I'd end up with a massive amount
of wiring. There's got to be a better way.

I thought this was going to be trivial.

Bill
0 Kudos
Message 1 of 11
(4,578 Views)
It is easy in LabVIEW 7. Use the flatten to XML function.
The result is an XML respresentation of the cluster as follows


my cluster
3

Numeric
1.00000E-6


Numeric 2
1234.89543


String
the string data



The only drawback I see is that doubles are formatted with only 5 digits
precision, kind of useless for what I want to do.


Bill Watts wrote:
> I need to find a way to output my cluster of indicators (string and
> numeric) values (Over 100) that is stored in a global vi, to an ASCII
> (not binary) text file. Ideally I'd like to be able to write the
> cluster element name and value(s).
>
> i.e.:

>
> Indicator Labels, Indicator Values
>
> Test 1 Upper Limit, 100 (Numeric)
> File Path, c:\Test.txt (String)
> Channels, 100, 200, 300, 400 (Array)
>
> The flatten to string gives a binary output, as does the Write (data)
> File vi. The Write Characters To File vi won't accept the cluster
> format (unless I first flatten to string ? which gives be a binary
> output) , neither will the Write To Spreadsheet File vi.
>
> I have gone through the laborious effort of connecting every cluster
> element to a separate indicator in a separate vi, labeling each
> indicator to the same name as the cluster elements. I was surprised
> that the indicator didn't take on the name of the cluster element, as
> I created the indicator by left clicking to the option menu. If that
> worked I was hoping that I could then create an attribute node that
> would have the label text, unfortunately the attribute node will only
> access the caption (which is not set), not the label.
>
> Even if the attribu
te method worked, I'd end up with a massive amount
> of wiring. There's got to be a better way.
>
> I thought this was going to be trivial.
>
> Bill
0 Kudos
Message 2 of 11
(4,578 Views)
> The flatten to string gives a binary output, as does the Write (data)
> File vi. The Write Characters To File vi won't accept the cluster
> format (unless I first flatten to string ? which gives be a binary
> output) , neither will the Write To Spreadsheet File vi.
>

I think you will find that the string palette has a Number to String sub
palette and that has a Number to Decimal String. That and the other
numer to string functions will adapt to the input type and produce
strings in the same data shape.

If you don't manage to get that to work, remember that you can convert a
cluster to an array as long as it is a homogeneous cluster.

Greg McKaskle
0 Kudos
Message 3 of 11
(4,578 Views)
Jean-Pierre has cracked this nut!

His solution is available on the OpenG web-site.

Visit http://www.openg.org for more info

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 4 of 11
(4,578 Views)
Unfortunately I'm not using 7. Actaully the present program is in 5.1.

That aside, I'd still like to better understand your solution.

If I understand your example, I'd have to define each and every name
and value for each cluster element? IOW, I just can't wire/hook the
cluster and have the program know what the name and value(s) are
unless they are specifically declared? If so, that's not exactly what
I'm looking for. I can duplicate that effert without XML by
conditioning each element individually to an array.

Bill

>
> my cluster
> 3
>
> Numeric
> 1.00000E-6
>

>
> Numeric 2
> 1234.89543
>

>
> String
> the st
ring data

>

>

0 Kudos
Message 5 of 11
(4,578 Views)
Hi Greg,

Thanks for the reply.

Yes, I'm fully aware of the string conversion functions.

I was trying to avoid have to individually wire each and every cluster
element to a seperate conversion functons or an array -- if possible.
I wanted to simply send the cluster directly to a fle in ascii format.
So if I add or delete any cluster elemtes, I dont have to go and find
the format converter, and either have to add/modify/delete it.

Bill

Greg McKaskle wrote in message news:<3EF27AD4.5030104@austin.rr.com>...
> > The flatten to string gives a binary output, as does the Write (data)
> > File vi. The Write Characters To File vi won't accept the cluster
> > format (unless I first flatten to string ? which gives be a binary
> > outp
ut) , neither will the Write To Spreadsheet File vi.
> >
>
> I think you will find that the string palette has a Number to String sub
> palette and that has a Number to Decimal String. That and the other
> numer to string functions will adapt to the input type and produce
> strings in the same data shape.
>
> If you don't manage to get that to work, remember that you can convert a
> cluster to an array as long as it is a homogeneous cluster.
>
> Greg McKaskle
0 Kudos
Message 6 of 11
(4,578 Views)
Ben,

Can you please direct me to a more specific link at this site for the info?

Thanks!

Bill

Ben wrote in message news:<50650000000500000011000100-1042324653000@exchange.ni.com>...
> Jean-Pierre has cracked this nut!
>
> His solution is available on the OpenG web-site.
>
> Visit http://www.openg.org for more info
>
> Ben
0 Kudos
Message 7 of 11
(4,578 Views)
Hi Bill:
You can create a Reference to the cluster, then create Property, and select CONTROLS[] Property.

Then, you have an Array of References of every Control in the Cluster. You can get the string or numeric value of every control using Properties.

The order in the cluster is set as you get controls in the cluster. But that order can be changed anytime with "Reorder Controls in Cluster" in Cluster's pop-up menu. This way, if you insert or remove controls, you can define the order again.

I hope this helps you.

Aitortxo.
Aitortxo.
0 Kudos
Message 8 of 11
(4,287 Views)
In 6.1 and 7 there is a function that converts a cluster to XML. You
simply wire the cluster to the function (the function input is
polymorphic) and it spits out an XML text string. It does exactly what
you want it to do, if you can tolerate XML.

There is also a corresponding function that converts a text string input
a cluster.

Bill Watts wrote:
> Unfortunately I'm not using 7. Actaully the present program is in 5.1.
>
> That aside, I'd still like to better understand your solution.
>
> If I understand your example, I'd have to define each and every name
> and value for each cluster element? IOW, I just can't wire/hook the
> cluster and have the program know what the name and value(s) are
> unless they are specifically declared? If
so, that's not exactly what
> I'm looking for. I can duplicate that effert without XML by
> conditioning each element individually to an array.
>
> Bill
>
>
>>
>>my cluster
>>3
>>
>>Numeric
>>1.00000E-6
>>

>>
>>Numeric 2
>>1234.89543
>>

>>
>>String
>>the string data
>>

>>

>
0 Kudos
Message 9 of 11
(4,578 Views)
No I can not.

I only know of this solution by reading his posts.

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 10 of 11
(4,578 Views)