LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to merge event structures?

Solved!
Go to solution

Yes, that is what I need to do (write the current value of all the controls if any one of them change).

 

I see what you are saying...put all the booleans from a given register (i.e. discrete address I want to write) into a cluster.

 

The only thing is - and perhaps this is fine - I'd end up with probably 1000 clusters...would it work to have a single event case that was registered to execute if any one of 1000 different clusters had a new value?

0 Kudos
Message 11 of 20
(1,599 Views)
Solution
Accepted by topic author bmishoe

1000 clusters is better than 16,000 booleans!  Smiley Wink

 

With a number like 1000 clusters (or even 16,000 booleans), you can certainly create an event case to handle those value change events for 1000 controls.  (I would script that, and it would probably be easier than the scripting needed to merge 1000 event structure into 1 event structure.)  But it would still be far easier to use dynamic events.

 

Look in the exampel finder for Dynamic Event Registration.  The key with this is you use a For Loop to register for the 1000 events (by iterating over an array of references to your 1000 clusters.)

Message 12 of 20
(1,598 Views)

good point!

 

thanks, I'll check it out.

 

thanks for the help.

0 Kudos
Message 13 of 20
(1,595 Views)

If I'm reading that code picture right (and I'll bet a doughnut I am) there are a few things I would point out:  "Boolean array to number" is a very useful function.  you can find it on Numeric>Conversion AND Boolean palattes. this would put all your boolean to  U16 conversion code on BD space the size of a postage stamp and save you lots of scrolling.Smiley Wink

 

It looks like you are associating a constant address with each group of "Bit Controls"  WHY? A simple "Address" control (Think Combo Box even) would be a good start to refactor your code and allow your configuration file to simply hold key value pairs like

 

Register Name = #Bits, Base Address, Mask, default Value. 

 

Thousands of controls over 40 tabs is not the way to go to impress a user.  If on the other hand you need to display something like a "Page" at a time remember one of my favorite sayings.."I HATE TABS"

 

If you look at message 15 in this thread you will find where using radio buttons to load individual panes into a sub-panel can vastly improve code readability and helps to decouple the GUI from the worker code.

 

The image shows how one solution I worked on selected one of several UUT "Styles", populating the correct radio button captions (And number) from file and brought in the correct sub-panel to write/read pages of registers in a embeded uP system  (Actually a familly of precision guided bomb fuses- you know drop from plane, count how many floors it impacted through, blow up on the floor preprogrammed-  cool stuff)


"Should be" isn't "Is" -Jay
0 Kudos
Message 14 of 20
(1,588 Views)

RavensFan - can you give me a little more detail on the dynamic event registration?

 

here's what I gather...

 

1. Create a cluster for each register.  The cluster contains all the controls for said register (up to 16).

2. Use a loop to iterate through each cluster.  Within the loop, create a reference to each of the controls and register that reference for a value change event.

3. Pass this registered event reference to the Event Dynamic Registration input of an event structure.

4. Populate the event structure with 'genericized' code that performs the boolean math

 

Am I on the right track?

es.png

0 Kudos
Message 15 of 20
(1,558 Views)

I would recommend an array of 16 bits (bools) over a cluster of same- much easier to work with. You will then just get one change event for the array- inside the case of this event you can figure out which bit changed (by comparing with previous array value) or simply use the complete new array to recalculate your 16 bit value. 

0 Kudos
Message 16 of 20
(1,545 Views)

like this?

es.png

0 Kudos
Message 17 of 20
(1,539 Views)

by the way I know that example doesn't duplicate the boolean math from before, it's just meant to be a proof of concept to ensure we're on the same page.

0 Kudos
Message 18 of 20
(1,538 Views)

@bmishoe wrote:

by the way I know that example doesn't duplicate the boolean math from before, it's just meant to be a proof of concept to ensure we're on the same page.


Actually,  make those array indicators controls (You simply don't need the scalar booleans) Worse, since you write Value(Signaling) FOR each indicator EVERY itteration you managed to do something really really BAD  you generate multiple events each iteration and can only service ONE.  That will queue up more and more events that just can't be serviced and other events (Like STOP) will need a long long time to wait before they can be serviced.  (Yes Value Signalling ALWAYS creates a Value Change event- even if the value is unchanged):smileysurprised:  I'm assuming this is why you moved the P-Nodes outside the loop.

 

 

and why does that NOT duplicate the bool to number conversion?  It DOES!


"Should be" isn't "Is" -Jay
0 Kudos
Message 19 of 20
(1,530 Views)

I'm talking about making your front panel control an array of 16 bools- not having individual bool controls that you then package into an array in code.

 

No bool controls at all- just arrays of bools.

0 Kudos
Message 20 of 20
(1,522 Views)