Actor Framework Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Initializing a UI Actor

Solved!
Go to solution

I am planning to create a UI Actor which is a nested-actor to a UI Handler Actor. The UI Actor will have a VI reference in its private data. This VI reference is a reference to a dumb user interface VI with just front panel controls and indicators. The UI Actor will run this VI asynchronously when it is launched. 

 

The idea is that the UI Handler Actor will launch nested UI Actors each with a different user interface which the UI Handler Actor will specify in the UI Actor's private data. Also I want to add the control references value change event from the user interface VI to the UI Actor core's event structure.

 

The issue I am facing is I am not able to figure out how to initialize the UI Actor's private data and obtain the controls references before I launch the UI Actor. I have attached a picture of what I am trying to do.

 

Thank you!

0 Kudos
Message 1 of 5
(1,939 Views)
Solution
Accepted by topic author mkanand89

Create a method "Nested.lvclass:Initialize New Nested.vi". Make it public. Give it just one input: the VI refnum. Give it just one output: a Nested object. The block diagram will look something like shown below. Then call that VI before you call Launch Nested Actor, as shown.

ui2.png

 

Also, if you don't mind some advice, I suggest you clean up that block diagram that you shared a bit. I made the edits in MS Paint, so it's a bit choppy, but I think clear. You shouldn't be getting fields of an object only to pass into a subVI that also takes the object -- just access the fields inside. It'll make your refactoring easier later if you change your mind about design. As for output, you are passing out one output but you are unbundling the other output. Be consistent and do one or the other. I recommend unbundling both outside (as shown) because, again, it makes refactoring easier in the future.
uiact.jpg

 

0 Kudos
Message 2 of 5
(1,900 Views)
Solution
Accepted by topic author mkanand89

To give a more general answer to your query: if you have private fields of a nested actor that are set by the caller and you need to have those fields already set before the first message is sent, then you do this by making the caller call one or more methods of the nested class prior to launching. Naming that method "ClassName.lvclass:Initialize ClassName.vi" is a bright red flag to callers that they should do this.

 

You could instead create a method "ClassName.lvclass:Launch ClassName.vi" that encapsulates both the setting of the private data and the calling of Launch Nested Actor, but the conpane gets a bit tight because you end up replicating all the inputs of Launch Nested Actor on your own VI, so I generally don't advise that.

Message 3 of 5
(1,896 Views)

Thank you very much for the solution and replying so quickly. I can see that does fix my issue. And yes I will add the controls to the data of the nested class and unbundle it outside the sub VI. I was considering doing that previously. 

0 Kudos
Message 4 of 5
(1,893 Views)

Glad I could help. For details, see the "Configuring Actors" section of the Actor Framework Whitepaper that ships with LabVIEW (you can find a copy by creating a new project from either of the shipping Actor Framework project templates).

0 Kudos
Message 5 of 5
(1,881 Views)