LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

State machine, controls, indicators

Solved!
Go to solution
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.
0 Kudos
Message 1 of 8
(3,182 Views)

@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.

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 8
(3,178 Views)

@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.

0 Kudos
Message 3 of 8
(3,171 Views)

@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.

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 4 of 8
(3,165 Views)

@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.

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 5 of 8
(3,159 Views)
For part I, I mean that the case selector requires the tunnels to be wired for every case, or to use the default value if unwired. I don't want to change the value at all in the other cases. For part II, I am reading a cluster, not writing to it. Would it be right to bundle the controls inside the loop but outside of the case structure? Does continuously bundling these controls have an effect on performance?
0 Kudos
Message 6 of 8
(3,149 Views)

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.

0 Kudos
Message 7 of 8
(3,128 Views)
Solution
Accepted by topic author JoshJosh117

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

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 8 of 8
(3,098 Views)