LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

can I have the same front panel control in multiple events?

Solved!
Go to solution

I have tried to find this in the forums and know there must be a simple answer, but being an L plater still, this one is eluding me. So:

I am programming a small mission builder program which will allow a user to create mission files for a small underwater AUV. These mission files can be created in Wordpad or similar but I wanted to make an application where the user doesn't have to worry about the sometimes fussy syntax etc. The operating system of the AUV is linux based. Also it is a good opportunity to practice my LabVIEW file handling skills and state machine programming experience.

 

I have created a state machine, and one of the states is "Add Primitive". A primitive is a line of text that can be "go to xyz", "surface" "home" etc with coordinates or other parameters entered onto front panel controls when the appropriate primitive is called. I have there fore got 8 front panel controls that the user can choose primitives with and an event structure with a pane for each control. Each event then displays the write string controls for that primitive and property nodes hide all the rest on the front panel.

 

My problem is, I want a "Commit" button that will write the completed primitive to the file and display the file so far in a preview window. I can only put this commit button in one event though and I can't use local variables. I want the same front panel Commit control to do the same thing for every different event in my structure. Can this be done?

 

I am thinking that maybe the control and my preview pane should be outside (to the right of) my structure. Or maybe an event case isn't the right way to go at all. Any suggestions would be much appreciated.

Thanks

 

0 Kudos
Message 1 of 10
(2,841 Views)

Hi!

 

Its hard to understand exactly what you are trying to do without looking at the code. But, one control can only exist in one instance on the block diagram. You can however access the control value using a property node. You can also use the property  "Value (signaling)" to generate events when the value of a control is changed programatically.

 

best regards

 

Dan

0 Kudos
Message 2 of 10
(2,830 Views)

Hi Karlos,

 

why do you even need this button in several events?

You wrote you have just one event  to "Commit" (and your description also provides just one state to process) so you only need one instance…

 

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 10
(2,825 Views)

Hi again,

I have attached the main VI part of my project so far, please take into account it is a work in progress and I have been experimenting but you should be able to see what I am trying to do.

 

Each event in the event case is for a different primitive that will be added as a line to the mission file. After the user has finished adding the parts of their respective primitive in string controls which are shown as part of the event (and hidden for other events), I want the user to write this line to file with a commit button. I know I can only have one instance of this commit button on the block diagram, but how can I then have that one control action the things that were entered for each of my different events?

0 Kudos
Message 4 of 10
(2,816 Views)

Hi Karlos,

main problem: DON'T HIDE the event structure inside a case of your case structure!

It belongs in front of the case structure of your state machine!

 

Right now the event structure may block your UI and will even give RACE CONDITIONS due to waiting for events in parallel to reading button states…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 10
(2,810 Views)
Solution
Accepted by topic author KarlosAmigos

I recommend some rearchitecting of your state machine.  You should have one state just for handling user events (have the event structure in it).  The Start state should transition directly to this "idle" state.  You can then handle every button being pressed with the event structure instead of doing a polling of sorts.

 

Each case in the event structure can determine which state to go to next.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 6 of 10
(2,806 Views)

Hi Crossrulz,

I have one state called "Add Primitive" which handles all the primitive controls on the front panel via the event structure which is inside this case.

The "start" state transitions to a "create mission file" state, and then to this "Add Primitive" state. I have experimented with putting the commit control in its own event as part of this event structure but then how do I get my strings from all the other events into the "Commit" event.

I have tried adding a "Commit" state to my state machine too but then have to get my strings out of their event and into the "Commit" case.

Can you control state transitions from inside this event structure? I didn't know this was possible.

0 Kudos
Message 7 of 10
(2,800 Views)

@KarlosAmigos wrote:

Can you control state transitions from inside this event structure? I didn't know this was possible.


Why not?  You are just passing out which state to go to next.  It is just data, just like everything else.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 8 of 10
(2,783 Views)

Also try to avoid all these duplicate property nodes. Most seem to exist in every single case of the event structure. Place them after the event structure and only keep the boolean inside the event. . You only need to place the TRUEs, the tunnels will automatically default to false if unwired from within.

Message 9 of 10
(2,768 Views)

You're right of course Crossrulz, it is just data! This is my first ever event structure use so I am still getting used to it and its little differences.

 

Altenbach, thanks for the tip on my property nodes, so brilliant yet so obvious really!

 

I have a better understanding of the whole picture now and will make some changes accordingly. My Commit button will definitely be outside the event structure and its action will be fed by the strings within.

0 Kudos
Message 10 of 10
(2,729 Views)