LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

With multiple events in a single event case, how to associate value with the correct object?

I am playing with the template where an event structure takes note of user inputs and a main state machine is then used to respond to these inputs. When I only monitor one control I use the 'NewVal' output to read out the changed value. But when I monitor multiple objects with a single case I also have to associate the readout with the correct owner. After some tinkering I was able to extract the label property and use a case to assign them. Are there better ways of doing this? For example maybe there is a way to connect the label text directly to the 'bundle by name'?

Also this should be easy to accomplish by simply creating local variables of the objects and read from them, but I got the impression that the use of global and local variables is now strongly discouraged?

Thanks for any suggestions!

0 Kudos
Message 1 of 8
(3,786 Views)

Often you can just place all the control terminals inside the event case and just re-bundle all of them (in your case), changed or not. Since a user interaction is always the time limiting step, this won't cause any performance issues. It also keeps the code much simpler and easier to maintain.

0 Kudos
Message 2 of 8
(3,762 Views)

Let me rephrase my question: say I have placed a group of distinguishable but otherwise identical controls (e.g. 8 switches) in a single case of a event structure and monitor 'Value Change', when a value change does occur, what's the right/easiest way for me to single out the 1 out of all controls being monitored for further manipulation?

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

Christian,

 

You suggest the terminals be place inside the event case, however they are parameters that need to be initialized in the Initialization process and a user sets the initial values there and later are allowd to make realtime adjustments, so the terminals have to be put in the Initializations step I think...

 

Jay

0 Kudos
Message 4 of 8
(3,734 Views)

@jplaserguy wrote:

... so the terminals have to be put in the Initializations step I think...


why?

0 Kudos
Message 5 of 8
(3,722 Views)

The reason is for me to imitate this standard state machine frame work. I suppose if I put the terminals outside of the event structure, or even outside of the while loop out of the event structure then I can read and write them anywhere I want. But the example seems to suggest all parameters be passed around with the cluster ribbon and nothing else.

0 Kudos
Message 6 of 8
(3,699 Views)

Well, I don't really like these theroretical discussions. Can you attach a simplified version of some of your code?

 

There are many other ways to identify the particular control. You could for example search an array of references for the value of the "ctlref" event data node. This would make the code much more robust (your code will fail for example if you (or some other programmer updating your code in a few years!) notices a mispelling and edits the label without also changing the case structure cases).

0 Kudos
Message 7 of 8
(3,687 Views)

Thanks for the advice! I will post some snippets soon.

 

Jay

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