From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Certification

cancel
Showing results for 
Search instead for 
Did you mean: 

Event Based Queue Control Architecture plus other questions

Hi all,

 

Right, I've got my CLD exam in a couple of weeks and I've been going over the preparation material and web casts etc. For reference I have also attended the CLD preparation course.

 

Few issues/questions for you which I'm hoping you can help with. Any feedback, positive or negative is more than welcome, especially as my brand new Teflon coat arrived yesterday Smiley Very Happy

 

Now, my architecture style has always been to use the model view controller/event based queue controlled etc, call it what you want, however when attempting to use this design with the sample CLD exams provided in the NI e-kit I have run into what I see as a couple of issues, especially if you truly use the design as intended.

 

Oddly, and annoyingly, the CLD prep course tells you to use the EBQC pattern as it will satisfy any given CLD exam, great, however none of the solution examples have been solved using EBQC so it’s hard to understand exactly how to use the pattern for all situations. Yes, we used EBQC to solve the exam in the prep class, but it was easier to implement this pattern for that exam in my opinion.

 

The first mock exam I have tried is the boiler exam. Now, if you open up the solution and look at how it’s working, it’s actually very simple and neat. This neatness in part comes from the fact that all the controls are constantly polled from the front panel as well as all states being selected based on the condition of a single control state e.g. the first state is constantly polling the two front panel clusters but only moves onto the next state if two specific boolean controls are pressed; all other next state boolean controls have absolutely no effect when pressed which satisfies the sequence of operation but in my opinion is a crude way of disabling controls.

 

My issues/questions with this are as follows:

 

  1. It is bad practice and inefficient to constantly poll front panel objects, hence one of the biggest reasons for using event based structures. If I use the event structure to update a cluster constant in the consumer (pass the control states around in a shift register), how do I code it such that only each specific controls forces an action to happen? i.e. enable/disable controls without having to use property nodes/references. So to try and be a bit more clear as to what I mean, in the solution example only the specific control which is required has its valued assessed, regardless of if other controls have been pressed and registered without having to update any other data which is basically a crude way of blocking/disabling any other control button presses. With the EBQC you either update individual cluster elements or send the entire cluster contents as a whole. How would you code the EBQC to still only wait on specific control presses like the solution but update control states ensuring it goes back to the correct state after updating the cluster constants? Sorry if that all makes no sense whatsoever; feel free to call me a muppet and seek clarification.

 

  1. The exam papers all state that the program must respond to front panel controls within 100ms and not utilise 100% CPU. Fine, I'm using EBQC so definitely won’t use 100% CPU and the queue will wait indefinitely until the instant a command is sent (assuming no timeout has been set), however I did read somewhere that if the examiners see that no timing method has been implemented (i.e. wait ms or wait next ms multiple) to iterate the VI within 100ms it’s an instant fail, even though the program works as requested. Is this true? Obviously the queue needs some throttling if it’s constantly chucking the same command back on itself at lightning speed but other than that is it fine to use no timing control other than that set on the event structure and queue timeout?

 

  1. Most, if not all of the exams state that all the front panel controls/indicators etc must be initialised at start. Now, does this mean that its ok to simply use the ‘reinitialise to default values’ invoke node at the start of the code or does the initialisation have to specifically update all controls/indicators/cluster constants and shift registers etc? To me if the shift registers and cluster constants are initialised when the code starts and does not need re-setting when the code is running then using the invoke node is fine, however I would like to know if the examiners are looking for an ‘initialise’ case that targets everything, not just the FP controls/indicators.

 

Think that’s everything for now but I'm sure I’ll think of some more later.

 

Cheers for looking and cheers in advance.

 

Regards

 

Mitch

0 Kudos
Message 1 of 5
(5,621 Views)

I can't say on how NI will grade, but I can say that using an event structure, and not polling will not only reduce CPU usage, it will also simplify your code tremendously, and make the code more modular and scaleable.  This also meets the 100ms response criteria without any extra effort.  And if you get an exam that has a timeout requirement, like log out of the system after 10 seconds, then the event structure has that built in too.

 

Obviously there are many ways to solve the CLD, and many design patterns that will work.  But for me the simplest solution was a queued message handler based on an array of strings, with an event structure in the idle case.  That was the only loop needed.

 

As for initialization, my exam had me loading from a file as part of the software starting.  In this case I read from a file, and set the controls to the values in that file.  In my case it was a table.  So the table had to be initialized anyway so no extra code was needed to set control values at the start.  But I thinking haveing an Init UI case is probably a good idea, probably best to use locals set control values.

0 Kudos
Message 2 of 5
(5,614 Views)

Hi Hooovahh,

 

Cheers for your help, much appreciated.

 

Well that's the thing, the solution to the boiler exam is also very simple and whilst it works, it most certainly is not the most efficient way but easily satisfies the CLD requirements.

 

My concern over timing implementation is purely based on the fact that I read that if they see no hard coded timing control it's a fail. This was also eluded to in the prep class but surely it has to be wrong because it clearly satisfies the requirements. At the end of the day the exam is a set of requirements, it does not tell you how to design the code for obvious reasons . . . . Smiley Happy 

 

I think I understand how you have implemented your QMH so I'm going to give it a go and also modify mine to see which I prefer but I'm sure both will satisfy the exam requirements.

 

Initialisation wise I think for the sake of adding one more case and a couple of cluster constants its not worth leaving out. Belt and braces!

 

Ill let you know how the code mods go.

 

Thanks again.

 

Mitch

 

 

0 Kudos
Message 3 of 5
(5,608 Views)

One nice trick about the EDQMH is the control ref is right there on the left hand node cast it to generic and pass it right on down in the queue.  The method of the GIU controller handling the event should know what to cast it back to.


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 5
(5,565 Views)

Hi Jeff,

 

Apologies for the belated response but I've been on holiday.

 

I'm intrigued by your suggestion but I'm slight confused as to exactly what you mean (too much time in the sun) Smiley Happy

 

Would it be possible for you to post a very simple VI or pic so I can understand how this would a) work in practice and b) help this scenario.

 

I've modified my code and got it all working exactly as per the exam requirements via EBQMH but still had to resort to using the direct controls to ensure of correct operation. This is because the mechanical actions of the boiler controls are latched, not switched (or at least that's what I want) so want a way of doing this without toggling and update specific cluster constants. This is where your suggestion of using the control ref may help but without seeing it I cant say.

 

Cheers

 

Mitch   

0 Kudos
Message 5 of 5
(5,529 Views)