02-20-2014 10:00 AM
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?
02-20-2014 10:06 AM
1000 clusters is better than 16,000 booleans!
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.)
02-20-2014 10:07 AM
good point!
thanks, I'll check it out.
thanks for the help.
02-20-2014 10:21 AM - edited 02-20-2014 10:30 AM
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.
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)
02-20-2014 11:44 AM
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?
02-20-2014 12:16 PM
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.
02-20-2014 12:33 PM
like this?
02-20-2014 12:34 PM
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.
02-20-2014 12:43 PM - edited 02-20-2014 12:51 PM
@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!
02-20-2014 01:07 PM - edited 02-20-2014 01:08 PM
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.