LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Cluster as a carrier of parameters. Bad?

My application use a cluster to store parameters, countervalues and paths. 

When my application starts I populate my "system-cluster" with parameters from an INI-file. This cluster is led sometimes through loops (slow, 1-5 sec or something) where some member are getting updated. The cluster also contains references to tables and path to folders. The cluster have around 15 members, strings, numerics, and some small arrays.

I don't lead the cluster through a highspeed loop. 

 

I want to know if this is bad programming. 

 

Thanx

 

0 Kudos
Message 1 of 20
(4,665 Views)

@TakeANap wrote:

My application use a cluster to store parameters, countervalues and paths. 

When my application starts I populate my "system-cluster" with parameters from an INI-file. This cluster is led sometimes through loops (slow, 1-5 sec or something) where some member are getting updated. The cluster also contains references to tables and path to folders. The cluster have around 15 members, strings, numerics, and some small arrays.

I don't lead the cluster through a highspeed loop. 

 

I want to know if this is bad programming. 

 

Thanx

 


The only drawback I can see is that the clusters can get unwieldly.  I'm sure other people here have more detailed pros and cons lists.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 20
(4,630 Views)

@TakeANap wrote:

I want to know if this is bad programming. 


That's Excellent!

Edit: With some caveats. Control and Indicator references shouldn't be needed as you generally shouldn't update them from a 'lower' level. Either have some timeout event that update indicator with data from the cluster, or generate some queue/event for updates.

But the general idea of having all data in a cluster going through loops in a shift register is very good.

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 3 of 20
(4,627 Views)

I have references to tables and big arrays for the whole application in the cluster. 

Why cluster?

 

I have so many times made the mistake to draw threads from const into a shiftregister/whileloop and then to a statemachine (case structure).. It always ends up with dussins of threads going from left to right to each shiftregister. I learned to put all of them in a cluster..Then I needed to only draw ONE thread (line?) through the whileloop with the statemachine.

 

 

0 Kudos
Message 4 of 20
(4,618 Views)

@TakeANap wrote:

I have references to tables and big arrays for the whole application in the cluster. 

Why cluster?

 

I have so many times made the mistake to draw threads from const into a shiftregister/whileloop and then to a statemachine (case structure).. It always ends up with dussins of threads going from left to right to each shiftregister. I learned to put all of them in a cluster..Then I needed to only draw ONE thread (line?) through the whileloop with the statemachine.


The question isn't about having cluster, but about having table and array references in the cluster. That indicates you're using Indicators on the front panel as data containers, right? That part is bad design. Put the array in the cluster. So whenever data needs to be updated it's updated in the cluster, and whenever it needs to be presented it's read from the cluster.

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 5 of 20
(4,613 Views)

I would like to piggyback off of this, not trying to hijack your thread.... I also use a data cluster for my main VI state machine, I put references to my main VI graph/chart and data containers in that cluster. I do this because I feed those references into sub VIs that are essentially just while loops that are doing data acquisition until readings are stable. I like to feed the data out to the main VI graph/charts as the data is collected and can do this if I have the main VI graph/chart references and use some property nodes.

 

You say this is bad practice, but what other options would I have to actively update my main VI graphs and data containers while the program is in a subVI while loop? Getting to stability for some of the measurements I take can take up to 10-15 minutes and being able to see the graphs as data is collected can a) help make a an early decision if something isn't working as it should be, b) can be used to troubleshoot problems while the program is running if any arise, and c) is pleasing to be able to see that the program is actually doing something, making is way towards stability, and not just sitting there.

0 Kudos
Message 6 of 20
(4,600 Views)

You are correct. I placed tables and/or arrays on FP as an allocation of memory. You mean it's better to have in a cluster? I thought all clusterdata are pushed/popped in and out of stack when it enters different parts of code. 

 

 

0 Kudos
Message 7 of 20
(4,598 Views)

I'd use a class. Group parts of the cluster into other classes. Put the stuff using the data in methods...

 

Thinking about a class as a glorified cluster is a reasonably good way to get started with OO.

 

A little knowledge can be dangerous though. OO gives great power, but doing it wrong can do some serious damage.

Message 8 of 20
(4,572 Views)

I'll chime in.

 

So, your application takes some time during launch to configure itself.  Is this "Bad"?

 

Have you started up any Microsoft product lately?  Hell, I have been tempted to add an artificial delay into some of my delivered software during launch just to appear like the executive is "A Real Application!"

 

Bad, probably... but Normal and expected behavior!  

 

In other words,  "Yup, that's what everyone else does and nobody has better plans"

 

THAT BEING SAID!  The world wide web consortium (W3C) has some affect on Document Object Models.   DOMUserdefref.dll.  this hunk of code is currently not threadsafe and accounts for a significant portion of application launch time.  You have to solve that problem first to quickly launch your own application. 


"Should be" isn't "Is" -Jay
0 Kudos
Message 9 of 20
(4,559 Views)

I put my references in a cluster, but that cluster is in a global, so I can have "lazy" access to them.  I do update the front panel from SubVIs all the time - caveat here, though.  On applications where performance is a must, I will go with the more conventional route of updating the controls and indicators directly.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 10 of 20
(4,549 Views)