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.

Actor Framework Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

AF Basics Article

I fully understand what I am trying to do, however as all of us, being new to something, we may make wrong perceptions about technique:

I have figured out a mistake - I was sending a message to a main actor in the callee's Pre Launch init vi, so I was killing the main Actor, and since the callee wasn't started serially - it was still staying active.  Just dragged a wrong class constant.

Just to repeat what I was doing:  I have a main actor which fires up a Timer Actor on a button press.

I have implemented a Timer Actor with the help of Time-Delayed Send Message in the Pre Launch Init.vi.  When the time out expires the Timer Actor sends itself a stop

Or if some other Main Actor activity happens - main actor sends a message to the TimerActor to stop.

Sorry, don't have the code right now, was updating to Windows 10 and that machine has no access to network temporarily.

P.S. If someone has a better way of executing a Timer in AF I would gladely learn.

0 Kudos
Message 11 of 19
(2,427 Views)

Thanks for these articles, Derek!


Regards,

Peter D

0 Kudos
Message 12 of 19
(2,427 Views)

Hi, assuming I want the logger in your basic walk-through become an interface.  how do I call methods on the interface class, using the object of it's child class?  When I try to use it in a command pattern style the priority queue becomes '0', when loading child class on parent's class wire.

 

How does mitigate that?

0 Kudos
Message 13 of 19
(1,930 Views)

@rsmrostov wrote:

Hi, assuming I want the logger in your basic walk-through become an interface.  how do I call methods on the interface class, using the object of it's child class?  When I try to use it in a command pattern style the priority queue becomes '0', when loading child class on parent's class wire.

 

How does mitigate that?


AF is much like other OOP code here - if you have a child class, and the message VIs (I.e. The VIs called by Do.vis) are dynamic dispatch, then you can create an interface/API in the parent class, call launch root/nested actor with the child class, then send the parent class messages. The messages which the parent understands how to receive become the interface.

 

If I've completely missed your point, perhaps you can clarify what you meant, or someone else can explain.


GCentral
0 Kudos
Message 14 of 19
(1,923 Views)

Hi cbutcher and thank you for replying: I am a bit confused by your answer at the following steps (by no means I am a pro of AF or OOP in Labview, so please correct me).

"message VIs (I.e. The VIs called by Do.vis)" in my understanding Do.vis call methods, not messages, while messages are passed into a Do.vi as an input, so are we talking about methods or messages here?

 

"call launch root/nested actor with the child class" - are you saying to launch a parent interface class from a child class????

 

p.s.  What I have done is created an interface class which sends messages to itself and is launched from the main Actor Core (ui)

The I was hoping, that by sending interface's child's object, I will be able to implement a child's methods on the interface (so now interface is sending messages to itself but with the child's object).  All this works, but the method for a child also implements method from a parent (all the parent's method is doing is updating status on the UI).  By implementing this, the private property of the 'Priority Queue' on the interfaces class is no longer valid, since I send a child object.

Child in my mind did not have to be AF here, but could be just a regular class with methods dynamically dispatched by the interface and overwritten by a child.

 

My guess is I am not getting some concept here....

 

 

0 Kudos
Message 15 of 19
(1,911 Views)

Hi, sorry - perhaps my usage of terminology was misleading or inaccurate (definitely not helpful if so).


@rsmrostov wrote:

Hi cbutcher and thank you for replying: I am a bit confused by your answer at the following steps (by no means I am a pro of AF or OOP in Labview, so please correct me).

"message VIs (I.e. The VIs called by Do.vis)" in my understanding Do.vis call methods, not messages, while messages are passed into a Do.vi as an input, so are we talking about methods or messages here?


Here, I'm describing the VIs (not messages) that you create a message from, i.e. the VI which is called inside the Do.vi. 

 


"call launch root/nested actor with the child class" - are you saying to launch a parent interface class from a child class????

 


Nope - I mean that you can create for example an 'interface' by creating a parent (Actor) class with some collection of VIs (for example, Measure Voltage, Log Data, whatever) which are dynamic dispatch, then in fact you launch an actor which is a child of that parent class, which implements those same Measure Voltage.vi, Log Data.vi, whatever.

 

Then, when you use "Send Measure Voltage Msg.vi", the actor is actually a child class, but if you had a different child, it would accept the same message, when you used the same "Send ... Msg.vi". This is what you want for an interface, right?

 


@rsmrostov wrote:

 What I have done is created an interface class which sends messages to itself and is launched from the main Actor Core (ui)

The I was hoping, that by sending interface's child's object, I will be able to implement a child's methods on the interface (so now interface is sending messages to itself but with the child's object).  All this works, but the method for a child also implements method from a parent (all the parent's method is doing is updating status on the UI).  By implementing this, the private property of the 'Priority Queue' on the interfaces class is no longer valid, since I send a child object.

Child in my mind did not have to be AF here, but could be just a regular class with methods dynamically dispatched by the interface and overwritten by a child.

 


I'm a bit confused as to what you mean here, so I'll rewrite what you wrote as I understand it, and you can correct me where I get it wrong...

 

You launch some root actor (A.lvclass), which in its own "Actor Core.vi", launches another (different class?) actor, say B.lvclass. B.lvclass is your "interface class". You want to have a child of B.lvclass, say Child.lvclass (or Ch.lvclass, from here on) which implements the dynamic dispatch methods of B.lvclass. This works as with normal, non-actor classes, as you describe.

 

I'm a bit confused when you describe the interface sending messages to the child's object. I'm reading it as, in B.lvclass:Actor Core.vi or similar, you have a loop which uses Read Self Enqueuer.vi, and sends messages. In that case, you are correct in understanding that if in A.lvclass:Actor Core.vi you call Lauch Nested Actor.vi with Ch.lvclass as the object passed to the Nested Actor input, it will be an object of type Ch.lvclass which receives the messages sent to the Self Enqueuer by the B.lvclass:Actor Core.vi (which is called by Ch.lvclass's "Call Parent Method.vi", which must be called for all Actor Core overrides).

 

When you say "the method for a child also implements method from a parent" I'm really a little lost as to the meaning of that section of your response.

 

It's worth noting you should be able to acquire the enqueuer for Ch.lvclass using Read Self Enqueuer, and A.lvclass using Read Caller Enqueuer.vi (from inside Ch.lvclass's methods). You can't get an enqueuer for B.lvclass, since no object of type B.lvclass exists here, however Ch.lvclass inherits from B.lvclass and so can call its methods. Messages sent to the Ch.lvclass will use whichever VI would be found for dynamic dispatch if the method is DD, as described at the beginning of this post (e.g B.lvclass:Measure Voltage.vi if Ch.lvclass does not provide an override, or Ch.lvclass:Measure Voltage if it does, and possibly both if Ch.lvclass:Measure Voltage.vi uses Call Parent Node).

 

Hopefully that's clearer, although I feel it might be a little verbose... Apologies if that isn't more helpful.


GCentral
0 Kudos
Message 16 of 19
(1,897 Views)
Now when my actor received the “Analyze” method it would just send the file to the helper loop, then go back to waiting for messages. The helper loop would then start working through he file. Now if my actor core received an “Abort” message it could again message up the helper loop and tell it to stop.

Hello Derek, 

 

I am user of AF for a while, but every time I start reading again about Actor Framework I stumble in something I've never realized before. I think it is part of the learning process where the use is tight coupled to it. 

One of the things I have noticed it is this statement of yours.

I was trying to understand how to do it, but I couldn't find a way of doing without modifying the main AF lvlib, as the MH loop is inside the Framework library. 

Is there an example for redirecting the message to the Helper Loop without modifying the AF Parent Actor Core.vi?

Thanks.

 

Felipe Pinheiro Silva


Follow my blog for LV content!

0 Kudos
Message 17 of 19
(1,710 Views)

One possibility is to create a User Event in Pre Launch Init and have your helper loop register for events, whilst your method VIs (those called by Do.vi) fire the user event stored in the Actor private data.


GCentral
Message 18 of 19
(1,700 Views)

Of course, also using queues, notifiers, rt fifos.

I was so focused on the MH issue that I couldn't see other alternatives. 

Thanks for the hint.

Felipe Pinheiro Silva


Follow my blog for LV content!

0 Kudos
Message 19 of 19
(1,690 Views)