02-01-2020 06:03 AM
Hi All,
I am preparing for CLA exam and practising to use actor framework. I really appreciate if you can help out with following grey areas in my understanding.
Scenario is, there is a machine accessing a keypad - I have to develop a soft keypad to simulate the hardware.
So, in my thought process there is a root actor called ATM Controller at the top level. Then Keypad API actor nested to ATM controller. One of the requirement is, user should be able to switch between simulated keypad and physical keypad easily. Therefore I have designed Keypad SIM (simulated keypad) and Keypad PHY (physical keypad) Actors nested to Keypad API. They are also INHERITED from Keypad API. Please see the Actor tree attached. Keypad SIM broadcasts an abstract message (a string) upon pressing the key "E".
Following are the list of issues I am having!
1. First, I was testing Keypad API & its nested actor - Keypad SIM (by launching Keypad API as the root actor). They did communicate i.e abstract message from keypad SIM was received at Keypad API. but when I closed the root's panel, it gave a fatal error by continuously poping in & out the Actor Core front panel on the screen. Soon as I changed inheritance to both inherit from Actor Core, (without being parent & child) it worked well. Any explanation?
2. Then I added the top layer, ATM Controller as the root actor and setup the Keypad API to send an abstract message (string). Now when I launch ATM controller, only that and Keypad SIM should popup and as I press the key "E" it should pass the string to the ATM controller via Keypad API (although it's front panel is not popeped out). But this abstract message is not received by the root actor. Could you please check the attached project and advise where the problem might be?
3. I am going to implement a method to control the "Simulation?" Boolean. so that ATM Controller can easily switch between software and hardware. Is this approach correct?
Many thanks in advance
Solved! Go to Solution.
02-01-2020 06:36 AM - edited 02-01-2020 06:53 AM
Hi London,
The code seemed to work ok following my changes in 2, but I suspect it may be more complicated than you really need to meet the requirements (or indeed, more complicated than required for a real application fulfilling these requirements). I didn't read closely through the Keypad API yet, but that's my feeling from a quick look.
As a side note, the New Value > Cluster to Array > Boolean Array to Number is really clever (I'll keep this in mind next time I want to find the value that changed in a cluster) but the handling code is pretty verbose. You could have done the following instead (I made C element 10 and left E as element 11, making 0 go from 10 to 9 in index):
I had to add a Quotient and Remainder to get rid of the "10" for 0, but otherwise it was fine. I suppose if I made the 0 the 0th element, and then removed the +1, that would be unnecessary (but I didn't think of that until I started typing this...)
02-02-2020 07:02 PM
Hi CButcher,
Many thanks for your response.
I revised LVOOP theory and now I understand your point - I can just call the child implementation from the root actor.
Thanks for your tip about the cluster handling code.