LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Which is the best way to share control value in front pane among threads?

Solved!
Go to solution

There are about five or six threads(that is, five or six while loops) in my diagram and all the threads are designed to get the ability to read the value of control in the front pane(partial or total) to finish calculation and configuration. 

Now I am using the local variables to achieve the goal and I feel that is an easy way but the way seemed not to be recommanded for some disavantages which I don't know very clearly. So I wonder is there a better way(s) to achieve?Thx!!

0 Kudos
Message 1 of 8
(2,821 Views)

Where is the front panel control located?  Is it inside the while loops, or read before the while loops.  If read before the while loops, then you split the wire.

 

I don't know what you mean by "front pane *partial or total)".

 

Using local variables if they are inside the while loops is probably okay, but it depends on what the rest of your code is doing.

 

 

0 Kudos
Message 2 of 8
(2,806 Views)

@RavensFan  已写:

Where is the front panel control located?  Is it inside the while loops, or read before the while loops.  If read before the while loops, then you split the wire.

 

I don't know what you mean by "front pane *partial or total)".

 

Using local variables if they are inside the while loops is probably okay, but it depends on what the rest of your code is doing.

 

 


Sorry for my poor English language, I mean front panel there. Suppose there are three while loops in my program, for example, and a state machine is realized inside each loop. All of three state machines have a state for initialization in common. When this state comes, each loop is expected to read values of some controls even all controls in the front panel and uses these values to finish configuration. At present, in diagram I put these controls in one of the three loops and introduce local variables in the other two loops and the program run OK. I just wonder is there a better way to do so?

 

Now my project is not in disk and nothing can be uploaded. Thanks for your attention.

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

Thanks this helped me.

0 Kudos
Message 4 of 8
(2,766 Views)
Solution
Accepted by Heartnode

Hi node,

 

Suppose there are three while loops in my program, for example, and a state machine is realized inside each loop. All of three state machines have a state for initialization in common. When this state comes, each loop is expected to read values of some controls even all controls in the front panel and uses these values to finish configuration.

Your current approach of using locals in tow of those loops might work nicely - but prevents modularization of your code! Your loops need to stay within your (as I guess) rather huge main VI…

When using a 4th loop to handle all UI actions you could introduce notifiers or FGVs (aka AEs) to handle your current input values. Your other state machines now can read those notifiers/FGVs when needed - and can be "outsourced" to their own VIs…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 8
(2,774 Views)

@GerdW  已写:

Hi node,

 

Suppose there are three while loops in my program, for example, and a state machine is realized inside each loop. All of three state machines have a state for initialization in common. When this state comes, each loop is expected to read values of some controls even all controls in the front panel and uses these values to finish configuration.

Your current approach of using locals in tow of those loops might work nicely - but prevents modularization of your code! Your loops need to stay within your (as I guess) rather huge main VI…

When using a 4th loop to handle all UI actions you could introduce notifiers or FGVs (aka AEs) to handle your current input values. Your other state machines now can read those notifiers/FGVs when needed - and can be "outsourced" to their own VIs…


Thanks for advice. I am considering a 4th loop and prefer notifiers than FGVs. But there are kinds of control value, such as string, boolean, int and double so on. So it seems that there should be many kinds of notifiers and  the output data type is difficult to design for FGVs. Maybe the variant could help?

 

Oh! I almost forget I can use a cluster and it actullay  turns to be  a large cluster.

0 Kudos
Message 6 of 8
(2,758 Views)

Hi node,

 

what about a (typedefined) cluster holding all relevant data?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 8
(2,756 Views)

Yeah, I think cluster is the final elegant solution!!!

0 Kudos
Message 8 of 8
(2,751 Views)