Actor Framework Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Managing the life cycle of actors

Solved!
Go to solution

I'm building an application using the actor framework.  My architecture is such that I have a Main VI which is always running and from it, you can open various other windows for monitoring and transmitting messages in a digital bus.  My main question is how to manage which actors are running so that I know to send them a stop message when the application quits.  So far, I have an array of send queues, and each time an actor is created I add it's send queue to the array. However, if the actor is shut down by closing it's front panel window, I need the main VI to remove it from the array.  I can do this by listening to the receive queue but I was wondering if there was a better way to handle this type of architecture.

Thanks for your time.

0 Kudos
Message 1 of 6
(6,959 Views)

I make heavy use of variant attribute tables for this purpose. Give every actor a unique id and use that id to look them up. Also, instead of storing the actors in main.vi, consider making a controller actor that serves this purpose and tracks the state of your system. Mine does thing like manage which hardware resources are available and send data to the UI, an because it's an actor I can easily extend and override functionality.

Elijah Kerry

Senior Product Manager, LabVIEW

National Instruments

Sent from my iPhone

Elijah Kerry
Chief Product Manager, Software Platform
_______________________________________________
Follow my Software Engineering for LabVIEW Blog
0 Kudos
Message 2 of 6
(3,843 Views)

Elijah,

I remember seeing some example of this in NI Week but I'm not sure how to implement that exactly.  Do you have an example on how to use variant attribute tables, and how to make sure you get a unique ID?

Thanks, Jorge.

0 Kudos
Message 3 of 6
(3,843 Views)

Just create a variant, and then use 'Set Attribute.vi' and 'Get Attribute.vi' as lookup methods.  It's the most efficienct mapping algorithm in LabVIEW.  The unique ID is up to you... for me, I concatenate the name of the measurement task with the hardware in use and a timestamp into a single string, so I know it'll always be unique.

Elijah Kerry
Chief Product Manager, Software Platform
_______________________________________________
Follow my Software Engineering for LabVIEW Blog
0 Kudos
Message 4 of 6
(3,843 Views)

Elijah,

I created a framework in which I have a Main.vi which launches a couple of actors and from it you can launch multiple rx windows and one tx window, you can also start and stop the rx execution.  I was hoping you could look at my implementation, specially the part in which the life manager actor uses the variant to maintain a list of actors that are running.

How do I upload my code to this discussion.

Thanks, Jorge.

0 Kudos
Message 5 of 6
(3,843 Views)
Solution
Accepted by topic author JIV

JIV wrote:

I'm building an application using the actor framework.  My architecture is such that I have a Main VI which is always running and from it, you can open various other windows for monitoring and transmitting messages in a digital bus.  My main question is how to manage which actors are running so that I know to send them a stop message when the application quits.  So far, I have an array of send queues, and each time an actor is created I add it's send queue to the array. However, if the actor is shut down by closing it's front panel window, I need the main VI to remove it from the array.  I can do this by listening to the receive queue but I was wondering if there was a better way to handle this type of architecture.

Thanks for your time.

When an actor shuts down, it always sends a Last Ack message to its owner.  The message contains the final state of the actor (i.e. the actor as a regular by-value class).  When the owning VI receives a Last Ack, you can query the returned object to see which actor has terminated, and respond accordingly.

You can also choose to send an additional message before Last Ack, if you feel the need.

Also, I'm with Eli - anything complex enough to hold the queues of multiple nested actors should be an actor itself.

0 Kudos
Message 6 of 6
(3,843 Views)