Certification

cancel
Showing results for 
Search instead for 
Did you mean: 

Query about CLD 16 solution

Hi,

 

 I'm just worked through the CLD Success Package exercises, and I have a query about CLD 16 - State Machine with Enables and Disables. Basically, I would like to understand better how and why the Data Cluster.ctl is used in the solution.

 

 When I attempted this, first of all I found that to increment/ decrement the Tons of Peanuts value was not possible with a local variable, so I then implemented my solution using the Value Property Nodes (in a QSM). I didn't need to use the Data Cluster.ctl. at all, and indeed I don't see how it works in terms of the basic principle of how it is used to read/ write values to the front panel. Perhaps there is just something about this approach that is radically different to my style of programming, however I would like to understand it better.

 

 I've looked around for literature that might shed some light on this, but can't find anything. So, I'm hoping someone here can help!

0 Kudos
Message 1 of 18
(4,822 Views)

Good question.

 

Let's see If I can shed a little light.  As an asside, I would not have coded it that way.

 

However, all of our UI elements exist in this control so if the requirements changed to Have 3 Control panels and a numeric to display the active peanut bin there is on place to make the data type changes and (looking at that data as if it were a class object)

 

There is one "Init" method. only 1 Use (Do) Method, and a few Update Display methods tossed all over the event structure (Which has a Timeout event to poll the stop boolean)  Like I said, Probably not the best way to do that.

 

It could be written many ways.  one of the reasons wee do code reviews! so someone can point out that the control looks like a "God Object" and we can learn better

 

 


"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 18
(4,787 Views)

Thanks for the reply. Ok, so the principle behind this specific solution isn't necessarily something I will need to become familiar with for the CPD exam, I take it. I found that my solution using Property Nodes to update values came much more naturally to me, and I think (although I am obviously biased in this) it was more readable.

0 Kudos
Message 3 of 18
(4,736 Views)

@DG76 wrote:

I found that my solution using Property Nodes to update values came much more naturally to me, and I think (although I am obviously biased in this) it was more readable.


You WILL have points marked off for using Property Nodes to set values.  Property Nodes are actually WORSE than using Local Variables (1000s times slower based on my last set of benchmarks and you still have the same issues as the Local Variables).  The solution is to store your values in a shift register and write to the terminals of your indicators.  These can be outside of the state case structure so they get updated every iteration.


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
0 Kudos
Message 4 of 18
(4,732 Views)

At first I marked the above post as a solution, however I have just gone back to this exercise in another attempt. In CLD 16, the clusters are not indicators, they are controls, and cannot be changed to indicators without rendering the control buttons within them non-functional. Therefore it is not possible to write to the clusters using shift registers, bearing in mind local variables are not an option.

 

I also note that the solution utilises Property Node Values to update these values. I think the only way to solve this exercise is using Property Node Values.


I'll keep the above post as a solution, however I'm not sure there really is a good solution to this one. Perhaps the exercise requirements could be updated, so that using Property Node Values is not the only way to solve it. This would mean tweaking the front panel clusters, perhaps taking the control buttons outside the clusters and making the Tons of Peanuts into an indicator.

0 Kudos
Message 5 of 18
(4,691 Views)

@DG76 wrote:

 

I also note that the solution utilises Property Node Values to update these values. I think the only way to solve this exercise is using Property Node Values.


You need property nodes for the enable/disable, but you can use local variables for the cluster.

Keep the data for each input cluster in a shift register, and whenever controls need to update, you can write the entire cluster data to a local variable of the cluster.

 

(Just looking at the provided "solution", I notice quite a few problems with it. Overly complicated and some potential race conditions. I probably could do it with 25% of the current code :D)

0 Kudos
Message 6 of 18
(4,679 Views)

Unfortunately, writing to local variables in this context is simply not possible for this CLD exercise as far as I can tell. Has anyone actually tried it? I get the attached errors when I do.

 

If someone has in fact implemented this, I would be interested as to exactly how they did it.

0 Kudos
Message 7 of 18
(4,663 Views)

After further consideration, I don't think I can accept crossrulz's suggestion as a solution (sorry crossrulz), just because I'm not sure if there is a solution for this with regards to programming the application without writing values to Property Nodes, in which case the exercise solution can be simplified as far as I am concerned. In the given exercise, indicators and controls are mixed in the cluster which significantly complicates matters and prevents successful implementation of the suggestions offered so far, unless I am missing something. I'd be happy to be proven wrong!

0 Kudos
Message 8 of 18
(4,642 Views)

@DG76 wrote:

In the given exercise, indicators and controls are mixed in the cluster which significantly complicates matters and prevents successful implementation of the suggestions offered so far, unless I am missing something. I'd be happy to be proven wrong!


No.  A cluster (and its contents) can only be a control or an indicator.  You cannot have both inside of the same cluster.  Now that I have looked at what the problem is, I see that what needs to happen is a single value inside of the cluster needs to be set when a certain button is pressed.  Personally, I don't think I would have used a cluster here.  But to update a single value in a cluster, you need to use a property node.


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
0 Kudos
Message 9 of 18
(4,630 Views)

The Tons of Peanuts control in the cluster is essentially being used as an indicator in this exercise, as it is showing the current Tons of Peanuts count, whereas the Fill and Use buttons are used to increment or decrement the count. Anyway, thanks for helping me get to the bottom of this, I think I have a much better understanding of what I need to know for the CLD exam now. I just hope that it won't involve a similar type of mixed-purpose cluster!

0 Kudos
Message 10 of 18
(4,628 Views)