04-01-2013 04:59 PM
Solved! Go to Solution.
04-01-2013 05:13 PM
@JoshJosh117 wrote:
Hey everyone,
I'm working on converting a VI to use a state machine architecture. Put simply, there are several buttons that trigger states via an event structure in the idle state. Two of the states need to write values to the same set of indicators, but the rest need to leave them alone. Several states also contain a subVI which takes a cluster input. The cluster is composed of around 10 numeric/boolean controls. I'm wondering what the best way to handle these two issues is. I could use local variables or references, but that seems to be discouraged for most cases. I don't have access to the VI itself at the moment, but could post it later if needed.
Part II of your questiion invloves obtaining the control ref for whatever control inside the big cluster and writing to the value property. That way you avoid updating the entire cluster each time you write to it (I'm assuming you want to write to s signle control in the cluster instead of doing a wholesale update). Part I kind of confuses me. You stated exactly what you need to do. Some states write to the indicators, some don't.
04-01-2013 05:21 PM - edited 04-01-2013 05:22 PM
@billko wrote:
@JoshJosh117 wrote:
Hey everyone,
I'm working on converting a VI to use a state machine architecture. Put simply, there are several buttons that trigger states via an event structure in the idle state. Two of the states need to write values to the same set of indicators, but the rest need to leave them alone. Several states also contain a subVI which takes a cluster input. The cluster is composed of around 10 numeric/boolean controls. I'm wondering what the best way to handle these two issues is. I could use local variables or references, but that seems to be discouraged for most cases. I don't have access to the VI itself at the moment, but could post it later if needed.Part II of your questiion invloves obtaining the control ref for whatever control inside the big cluster and writing to the value property. That way you avoid updating the entire cluster each time you write to it (I'm assuming you want to write to s signle control in the cluster instead of doing a wholesale update). Part I kind of confuses me. You stated exactly what you need to do. Some states write to the indicators, some don't.
Or, you could use "bundle by name" allowing you to update only a particular value in the cluster. Then pass it out of the subVI and write the entire cluster indicator. Now you don't need any of those slow control refs. If it's a control you're writing to, then you can use a local variable, but I have to wonder why you are writing to a control in the first place and if there's a better way.
04-01-2013 05:30 PM - edited 04-01-2013 05:34 PM
@for(imstuck) wrote:
<snip>Or, you could use "bundle by name" allowing you to update only a particular value in the cluster. Then pass it out of the subVI and write the entire cluster indicator. Now you don't need any of those slow control refs. If it's a control you're writing to, then you can use a local variable, but I have to wonder why you are writing to a control in the first place and if there's a better way.
I tried that before and it updates all the controls anyway. Even though you only updated one value, all the controls get updated. It can be somewhat distracting if one control is updated at a rapid pace and all of them are updating.
[Edit] sorry the confusion about controls/indicators was set off by me. I confused controls with indicators. Duh. Sorry.
04-01-2013 05:39 PM - edited 04-01-2013 05:39 PM
@billko wrote:
@for(imstuck) wrote:
<snip>Or, you could use "bundle by name" allowing you to update only a particular value in the cluster. Then pass it out of the subVI and write the entire cluster indicator. Now you don't need any of those slow control refs. If it's a control you're writing to, then you can use a local variable, but I have to wonder why you are writing to a control in the first place and if there's a better way.
I tried that before and it updates all the controls anyway. Even though you only updated one value, all the controls get updated. It can be somewhat distracting if one control is updated at a rapid pace and all of them are updating.
[Edit] sorry the confusion about controls/indicators was set off by me. I confused controls with indicators. Duh. Sorry.
For "normal" (not rapid-fire) updates of one control in the cluster, of course, I would use for(imstuck)'s method. It's a lot cleaner.
04-01-2013 06:09 PM
04-01-2013 07:26 PM
Can we see what you're doing? A screenshot (or better, some code). It sounds like you may be doing something incorrectly, or at least, inefficiently.
04-02-2013 01:26 AM
You could go with locals, in this case it should be ok, or have an Update indicator-state.
I'd probably take the easy road and go with local in a simple state machine.
/Y