Actor Framework Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Will this work for launching nested actors?

I want my application to be expandable, and not have to go in each time I add an actor to the project to have to manually add a nested actor launch VI and add that Queue to the Caller Class.


Will this piece of code work? I search for specific actors in my project (my core module actors), then I launch each of those nested actors, and add its Message Queue to an array of Queues that I keep in the caller class.

0 Kudos
Message 1 of 22
(8,510 Views)

If your top-level code treats all the actors the same, then there is no reason not to treat them as an array.   I’ve loaded arrays of actors (not AF ones, but similar) specified in configuration files.  It looks similar to your code:

0 Kudos
Message 2 of 22
(4,518 Views)

Thanks, I guess my next question is, is there an API already existing in the AF that allows you to search for a specific Queue to send a message to, that is in that array?

I wrote a piece of code to do it where I write the queue array, but I also write the Actor class array to the caller. Then I can search 1D array of Actor Class for a specific class, get the index to the class and it should be the same index of the queue, index the queue array to that index and voila....

Thats the hard way to do it, but I didnt know if there was something already prebuilt that does this?

0 Kudos
Message 3 of 22
(4,518 Views)

is there an API already existing in the AF that allows you to search for a specific Queue to send a message to, that is in that array?

I would only generally only use arrays when I treat everything in the array the the same, so it would never make sense to "search" an array.   Note that you can have all enqueuers in an array, for sending messages to all actors, and have the same enqueueres in a different structure that maintains separate identity for them, such as a cluster, where you can pick out specific actors.

0 Kudos
Message 4 of 22
(4,518 Views)

thanks for the update. although adding queues to a cluster, its a manual process. Each time you add a nested actor to that group, you will manually have to go in and that reference to the cluster. If it is an array, then you can add new nested actors dynamically, or plugin nested actors dynamically without having to alter the code, correct? Or am I missing something?

0 Kudos
Message 5 of 22
(4,518 Views)
Message 6 of 22
(4,518 Views)

exxonmobilLV wrote:

thanks for the update. although adding queues to a cluster, its a manual process. Each time you add a nested actor to that group, you will manually have to go in and that reference to the cluster. If it is an array, then you can add new nested actors dynamically, or plugin nested actors dynamically without having to alter the code, correct? Or am I missing something?

Sounds fine, till you get to the "search for a specific Queue to send a message to" part in your previous message. Plugin systems work because the calling code is designed to use the generic plugin, and doesn't depend on specific subtypes of plugin.   All plugins "fit" the plughole, and accept the same message set that the calling code will utilize. 

Message 7 of 22
(4,518 Views)

Thanks Jon,

I created a short project and used Variant Attributes to save the array of queues for the nested actors. Did I do this correctly?

Nested Queues Variant Attribute.png

0 Kudos
Message 8 of 22
(4,518 Views)

Variants are cool because they can have whole lists of attributes on the one variant, and the sort/search on the attribute lists is quick. So you only need one variant with a bunch of attributes, rather than a bunch of variants with one attribute (see belo).

I also put the actor wire through a shift register to preserve the Auto Quit data from the Launch Nested Actors.vi; YMMV.

Hope this helps!

NestedQueuesVariantAttribute2.png

Message 9 of 22
(4,518 Views)

thank you for the correction. that makes sense now. I havent used variant attributes before.

0 Kudos
Message 10 of 22
(4,518 Views)