LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic Events - multiple controls of the same type

Solved!
Go to solution

OK, so I'm trying to tweak my UI.
It's a simple dialog, it's got a few boolean controls on it and it's based on the Formula express VI.
I want to test it externally with some tests that invoke button pushes - and I'd like a technique which is scalable across all of my UIs in the project.

Currently I have grouped the boolean controls into 4 groups:
OK & Cancel
FP actions (home, end, backspace, delete)
standard operations
custom project variables...

Testing externally I can't close the VI as OK & Cancel are latch booleans. (and I'd like to be able to act on any latch boolean anyway)
I want to fire a value signalling / event to the buttons, maybe put the even registration in a subVI so it is testable.

unfortunately, from what I can see at the moment, instead of having 4 event cases, I now need a seperate dynamic case for each control as I can't see how to get the control/event name that fired the event from the event structure if I build an array or cluster of boolean events.

Any pointers as to how to make the events more testable from a scripted test that mimics a button push please?

James

CLD; LabVIEW since 8.0, Currently have LabVIEW 2015 SP1, 2018SP1 & 2020 installed
0 Kudos
Message 1 of 7
(2,013 Views)
Solution
Accepted by topic author James_W

@James_W wrote:

unfortunately, from what I can see at the moment, instead of having 4 event cases, I now need a seperate dynamic case for each control as I can't see how to get the control/event name that fired the event from the event structure if I build an array or cluster of boolean events.


You don't need separate cases, you can add all individual cluster controls to 1 even case.

 

You have quite a bit of options. Here are some ideas:

wiebeCARYA_0-1649076592195.png

 

EDIT: search for a True in that last example.

 

Message 2 of 7
(2,001 Views)

@James_W wrote:

Any pointers as to how to make the events more testable from a scripted test that mimics a button push please?


You can simulate the push of a latch button, but you need to use Windows APIs. Also, you need a coordinate to simulate the button press. This can be hard if your application uses (nested) subpanels and\or (nested) reentrant VIs.

0 Kudos
Message 3 of 7
(1,997 Views)

Thanks weibe,

I've given up with the latching action and gone for a switching action with locals to reset the OK and Cancel states because it's such a PITA to use the windows functions.
found I can fire Value signaling now to all my Booleans and scan the FP for the boolean by name to control in my tester function - so I'll just steer clear of switching actions for the sake of testability. 

Cheers

James

CLD; LabVIEW since 8.0, Currently have LabVIEW 2015 SP1, 2018SP1 & 2020 installed
0 Kudos
Message 4 of 7
(1,973 Views)

As another variation on ways to approach this:

 

We use a modified QMH scheme quite a bit.  There's generally one top-level "main brain" that coordinates a number of subservient QMH loops.  For the sake of unit testing the subservient loops, we'll often give them a simple GUI and an event-handling loop in parallel to the main QMH.  (The whole thing is typically in a conditional disable structure so it will be excluded in any executable build.)

 

All the working code belongs in message cases of the QMH loop.  The event loop merely catches GUI events and dispatches the corresponding message to the QMH loop.  This lets us easily do interactive unit testing for the various messages.

 

It's a little extra work upfront but it scales rather nicely. 

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 5 of 7
(1,969 Views)

@Kevin_Price wrote:

As another variation on ways to approach this:

 

We use a modified QMH scheme quite a bit.  There's generally one top-level "main brain" that coordinates a number of subservient QMH loops.  For the sake of unit testing the subservient loops, we'll often give them a simple GUI and an event-handling loop in parallel to the main QMH.  (The whole thing is typically in a conditional disable structure so it will be excluded in any executable build.)

 

All the working code belongs in message cases of the QMH loop.  The event loop merely catches GUI events and dispatches the corresponding message to the QMH loop.  This lets us easily do interactive unit testing for the various messages.

 

It's a little extra work upfront but it scales rather nicely. 

 

 

-Kevin P


I typed something similar about separating GUI and logic a few times and deleted it (the same number of times)..

 

It is a common and valuable technique to make testable code. Good practice in general to keep things clean and decoupled.

 

If you really want to automate the entire application, you still need to simulate (stimulate?) the GUI though.

0 Kudos
Message 6 of 7
(1,954 Views)

@James_W wrote:

Thanks weibe,

I've given up with the latching action and gone for a switching action with locals to reset the OK and Cancel states because it's such a PITA to use the windows functions.
found I can fire Value signaling now to all my Booleans and scan the FP for the boolean by name to control in my tester function - so I'll just steer clear of switching actions for the sake of testability. 

Cheers

James


This is pretty much the only way if you put your GUI in a subVI.  Well, not exactly like this, but you would pull in the reference to the control and set the value to FALSE with a property node because you won't have access to the local variable inside the subVI.

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 7 of 7
(1,941 Views)