Actor Framework Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

how to create free running actor core

Solved!
Go to solution

Hi AF funs,

I am beginner with AF but understand idea those mechanismus. But i still need help with create actor core for my actor "air distribution". My actor checking every 500ms pressure in pneumatic systems (digital input).  If is pressure OK toggle valve (digital output) to On but If is NG toggle valve to Off and send message to upper actor " Error air distribution! "


Thank you.

0 Kudos
Message 1 of 8
(7,750 Views)

Awesome!   I will start by saying there is a significant learning curve, but that shouldn’t stop you from using it.  One key thing to keep in mind, is that the Actor Framework is really a messaging framework (it’s a queued message handler, more on that in another post). And it’s object-oriented. So, if you know how to think in object oriented then it will be a little easier. IF not, no problem. Just be ready to accept a few things. Have you checked out the actor Framework page on Ni.com?

[1] http://www.ni.com/webcast/2551/en/
[2] https://decibel.ni.com/content/docs/DOC-23893
[3] https://decibel.ni.com/content/docs/DOC-17109

Awesum_Actor

Message 2 of 8
(4,405 Views)

reteP,

If I understand your question, you need your air distribution actor to periodically do something, namely check the pressure.  As you probably know, AF ActorCore is always waiting for a new message.  So, that loop will not do anything until it gets a message.  So, you need something that sends it a message that causes it to poll the required analog and digital IO.

Built in to AF is a VI called 'Time-Delayed Send Message.vi" (I'll call it TSDM.vi).  Check the Actor Framework->Advanced palette.  Add this to either your air distribution's Pre-Launch Init.vi or its Actor Core.vi.  Supply the TSDM.vi with the Enqueuer from Read Self Enqueuer, the Message that will cause your actor to check the IO and the time (in your case 500 ms) and count (0 for infintie) parameters.

And, this is important, Retain the 'Delivery Notifier' output from the TSDM.vi so that you can stop it when your actor stops.  It is a LV Notifier so you will need to wire it up to a Release Notifier node AFTER the call to the parent's Actor Core.  This can be done in your Actor Core, or in your override of Stop Core.vi.

Alternately, you can create an independent loop in your override of Actor Core.vi that is timed and sends a message to itself or you could (don't recommend) checking the IO in that loop and send the message to the parent directly.

No matter how you do it, you will have to come up with a way to stop the independent loop. TDSM,vi has the notifier, but you can implement alternate approaches in an independent loop.  Personally though, I would use the TDSM mechanism.  Just remember if you are debugging, the time delayed message will queue up if you are at a break point in that actor.

Hope this helps!

Kurt

Message 3 of 8
(4,405 Views)

Here is my test projekt. Check Actor core air distribution and tell me what you mean about this and how to send message from Air distribution to parent actor APP.

0 Kudos
Message 4 of 8
(4,405 Views)

reteP,

So, it looks like you have a 250ms loop in Air Distribution:Actor Core.vi with a way to stop the loop.  All good so far.  Let's leave that approach for now, since it works, and look at how to get a message to the parent actor APP.

In AF, every actor (except the topmost actor) has a some other actor that launched it.  App launches Air Distribution in App.Actor Core by calling Launch Actor.vi and you supply App's enqueuer.  Air Distribution actor always remembers who launched it.  This is taken care of by the framework.  You can get the launcher's enqueuer by using the Read Caller Enqueuer.vi (it is in the Actor Framework palette).  When you see the words 'Caller Enqueuer' it is talking about the enqueuer of the actor that launched 'this' actor.  For Air Distribution, Caller Enqueuer returns the enqueuer for App.

To send a message to parent actor App, you might think about adding it it Air Dirstirbution's Check pressure.vi.  In the same 'True' case that Send Toggle is called.  EXCEPT, you are going to use Read Caller Enqueuer and send a different message - one that you will need to create.  One that says "Error air distribution!".

You might need to keep track of the fact that you sent the Caller a message unless you want to constantly message about an error while the error is active.  Also, you might want to send a message saying that the error no longer exists.

Another thing to think about.  In the Check pressure.vi, you could call Toggle.vi directly instead of using a message.  There is absolutely nothing wrong with how you implemented it, just that not everything has to be a message as long as you can keep your message handling responsive.

Kurt

0 Kudos
Message 5 of 8
(4,405 Views)

Hi Kurt,

yesterday i check example from hands-on what sent wegunterjrNGC and there was same problem. There is idea create abstract actor "Timed loop" this is parent class for dual fan actor. Timed loop is generator message "periodicaly". I think this is what i need. I must do abstract actor which will generate message to my actor air dis every 250ms. Now i don't know whether can i send message to air dis actor from others system  actors.

What do you mean about this way ???

0 Kudos
Message 6 of 8
(4,405 Views)
Solution
Accepted by topic author reteP

Problem is solved. I am created actor Timed loop this actor is parent actor and air dis is child. Timed loop periodically send update message and air dis is state machine ( check pressure -> power On or Off). This program working well. Check projekt 😉

Next step will create  message for other actor UI "pressure is OK or NG".

0 Kudos
Message 7 of 8
(4,405 Views)

reteP,

Good work!

One thing I noted is that your root ('App') actor (currently called Test air.lvclass) also derives from Timed loop.lvclass.  As such there is an Update message being sent to it every 500 ms (the default interval).  This is not necessarily bad if you have plans for the root actor to handle the Update message, but in your current implementation, it could just as well inherit from the AF Actor.lvclass.

Keep us posted on your progress.

Kurt

0 Kudos
Message 8 of 8
(4,405 Views)