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: 

CLA and Actor Framework

I was studying NI's CLA sample examples for the ATM problem.  I took NI's Actor Framework training and have started to use it in production code I'm writing.
 
It's pretty obvious to me that the ATM example is reinventing much of what the actor framework does and I wonder if the graders are fine with us just leveraging AF to do much of the work that the ATM example is laboriously re-creating.  E.g. Would it be fine to have Main launch a root actor which then launches nested actors?  I would not have the user event that represents a global stop the way the solution modules do, instead I would simply send stop core to the root actor and expect that to stop all nested actors.  Then I would define methods and corresponding messages for the actions (what are defined as Action Enums in the solution). Is that an acceptable approach that would score well?
 
For errors, I think I could just use the Handle Error (I believe that's the AF name for it) override in the root actor such that it gets errors from all of it's nested children.   That would eliminate the need to define a specific error handling module and send errors to said module (the way it's done in the example solutions).  Am I right?
 
I would need to have a way for all actors to access other actors enquers.  The easiest way would be to have a global variable for each modules enqueuer (or an action engine) but I'm wondering if I would be scored poorly for such a global based approach?  I believe a more correct method is to use the actor tree approach such that actors communicate to the root actor.  I think the controller might for instance send a message to parent (root actor) to "send this (Database specific) Message to the Database module"?  I have limited experience using multiple non-root Actors so I'm not sure if that's the right approach and I'm not sure if that's worth the trouble in terms of points on the exam (like would I score significantly better by doing that rather than just using the global(s) to access modules enqueuers)?
 
Finally, I have a rather broad question and I wonder if someone can point me to a white paper or something.  I don't entirely feel comfortable with the Asyncronous approach to programming.  For example, my imperative programmer mind thinks Widthdrawl should be defined as: "check balance, if > withdraw amount then balance = balance - withdraw amount, dispense cash, display new balance".  However, Actor Programming does not allow for straightforward function calls such as "get balance", instead I have to send a message to query the balance which then (maybe) results in a message to me containing account balance.  At that point I'm no longer in the withdraw function.  So instead I have to distribute around the logic for how to do a withdraw.  In looking at the ATM example it is not at all clear to me how the solution does this.  I see a "Controller:Withdraw Init" state which has a "Withdrawal" enum hovering in mid air (why?) and then Widthdraw Approved and Withdraw Failed states.  So, I'm asking for a pointer to knowledge about how to design these Actor/Messaged based architectures such that functions like Withdrawing can be done in a distributed but deterministic way.  Perhaps a fully working implementation of the ATM example would help if there is such a thing.
0 Kudos
Message 1 of 11
(5,462 Views)

I just realized that there's an Actor Framework solution provided for the car wash exam.  I made the erroneous assumptions that all the example solutions would be more or less the same.  Sorry for asking dumb questions.

0 Kudos
Message 2 of 11
(5,424 Views)

Hey Thomas,

 

Welcome to the CLA and Actor Framework.  Take a look at a few of my examples and then the discussion that followed for some of my journey. http://forums.ni.com/t5/Certification/Sample-Exam-Solutions-for-Review/m-p/3588940#M2879

 

Basically I just passed the CLA using the AF and I agree with some of your ideas, and you can see how I did things.  I can not guarantee that my examples would pass, but it should give you some ideas.

 

As far as the root versus nested solution.  I would suggest making the controller the root.  Then all the other modules are nested actors.  So there is no need for a global storage of the enqueuers, but you are correct each module talks through the controller.  Then yes you can utilize out of the box the error handler and the stop core.

 

I also just re-read your question about the withdrawal... Not sure this is the best advice but... The CLA didn't appear to me to require that level of thought.  I say this as a non NI grader, so buyer beware.  They are not looking for the in depth implementation that handles that level of detail.  They are looking at an architecture with some notes.  The developer should worry about the fine details.

 

So the UI can say controller I want to withdraw $X.  Then the control can ask the DB withdraw $100.  The DB can either reply success or failure.  The controller then can tell the UI etc, success or error.  It is up to you how many messages that is, and you could easily make a DB VI that takes an amount in and returns a true\false or an error.  Then in your comments say this is a message with reply.  Don't implement it, and don't try to script the messages or even the reply classes.  The developer gets to do that.

 

When you look at my examples you can see in some of my examples, you really are more saying I need a message "withdraw" and some DB query.  You do not need to every make those messages work, so logic in regards to race conditions etc are not really necessary to the CLA.  Though in general the architecture should protect against that and depending on the messages you make the AF will handle that for you.

 

Good luck

0 Kudos
Message 3 of 11
(5,404 Views)

Hi Thomas,

 

First off, I watched a youtube video of performing the CLA, so if that was you, thanks for publishing it!

 

Second, I will share a method to perform "synchronous" data operations with asynchronous modules that I took from the Delacor QMH. There are two main components, the API call to the module which other modules can use, and the handling of the call inside the module. First, here is an API call for "Get Status" that gets string data from the module, but the data can be anything. The data should be in a typedef'd cluster in case you change it at all, but I skipped that to save time. It creates a notifier, enqueues the "Get Status" state to the module, and waits for a notification to come back.

API.JPG

Next, here is what the module looks like. It converts the variant back to a notifier, and send a notification with the data. 

Main.JPG

Now when the API is called from another module, you get the data right there and can act on it how you please.

Message 4 of 11
(5,387 Views)

Hello Everyone,

 

I am preparing for LabVIEW CLA Exam and have been using QMH architecture for developing the architecture for sample project application as I am not familiar with Actor Framework. My question is, Shall I use QMH architecture for CLA exam? Will I lose any points as I am not using Actor Framework?

0 Kudos
Message 5 of 11
(4,815 Views)

You will only lose points if the architecture won't solve the problem.  So just use whatever you are used to.


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
Message 6 of 11
(4,811 Views)

Thanks for your reply. Do we need to recreate the UI on Front Panel with respect to question given on CLA Exam?

 

Thanks

Durai S

0 Kudos
Message 7 of 11
(4,804 Views)

Yes, you create any UI elements, which are usually the simulated hardware pieces. Keep it simple though, there is no extra credit for a nice UI.

0 Kudos
Message 8 of 11
(4,795 Views)

Durai, Make sure you download the sample exams along with the solution examples.  Study the solutions that others have given, I believe all of them have an example of a Queued Message Handler then practice re-creating them.  What I did the day before the CLA is I took the whole day off work and I solved each of the 3 CLA sample exams using the method I choose (Actor Framework in my case, QMH in your case).  

0 Kudos
Message 9 of 11
(4,788 Views)

Hello Everyone,

 

I have made attempt with CLA ATM sample exam. Kindly review and let us know your comments.

0 Kudos
Message 10 of 11
(4,596 Views)