取消
显示结果 
搜索替代 
您的意思是: 

Launcing nested actors - Actor framework

已解决!
转到解答

Hi everybody,

 

i have one question regarding launching nested actors.

There is two situations.

1.JPG

On first picture, nested actors are launched, and everything works just fine.

When i close root actor(program manager), all actors are closed, and in project explorer there is no locks.

 

In second situation, actor are launched, but after closing root actor, all actor remains locked.

2.JPG

And, i see that in some project that i saw, this situation also works just fine.

 

Can someone explain me why this doesn't work in my case?

 

Thanks

 

0 项奖励
1 条消息(共 7 条)
3,436 次查看

Do you know how your nested actors are stopped in the first case? By default, nested actors are launched with auto-stop enabled. Launch Nested Actor records the enqueuer and Stop Core sends a stop message to those actors.

 

In the second case that mechanism cannot work. Since LabVIEW classes are by value, you create three copies of your actor, store an enqueuer in each of them and then throw the copies away. That could work if you also stored the enqueuer of the device actor in the launching actor's private data. You would then have to send a stop message to each of the nested actors. I assume that is what happens in the other project you saw. It is still bad form and inefficient to do it that way.

0 项奖励
2 条消息(共 7 条)
3,418 次查看

Thanks for feedback.

Can you suggest what would be good practice?

What you recommend, how to launch nested actors in proper way?

 I understand that these are basic staff, but i'm new in actor, so any help is welcome.

 

Thanks

0 项奖励
3 条消息(共 7 条)
3,398 次查看
解答
接受人 milan87

@milan87 wrote:

Hi everybody,

 

i have one question regarding launching nested actors.

There is two situations.

1.JPG

On first picture, nested actors are launched, and everything works just fine.

When i close root actor(program manager), all actors are closed, and in project explorer there is no locks.

 

In second situation, actor are launched, but after closing root actor, all actor remains locked.

2.JPG

And, i see that in some project that i saw, this situation also works just fine.

 

Can someone explain me why this doesn't work in my case?

 

Thanks

 


The difference between the two cases is that in the first one, the 'send actor stop' command is handled by the parent actor since it 'knows' about the child actors. This is because of data flow. You pass the ref in sequence to launch each actor one after another so the parent is aware of the child, and can sed the stop actor message. 

 

In the second case, there is no 'data flow' as mentioned previously. You just make three copies of the actor and they do not know how to know which is the parent and which is the child since they are not connected in a horizontal data flow paradigm. 

 

One thing to note is that you can make the second case work just fine but you have to do more work. You need to make an event case that triggers when you stop the program then use the enqueuer for each 'child' actor to explicitly send the 'stop actor' message. So you will also need to store the third actors enqueuer as you have stored the first two. 

______________________________________________________________
Have a pleasant day and be sure to learn Python for success and prosperity.
4 条消息(共 7 条)
3,390 次查看

You mean like this.

milan87_0-1682070004345.png

 

Thanks a lot for both replays.It works fine.

0 项奖励
5 条消息(共 7 条)
3,374 次查看

I mostly reacted to you not collecting the Device ref, but then i've never used Actor Framework. 🙂

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 项奖励
6 条消息(共 7 条)
3,370 次查看

@milan87 wrote:

You mean like this.

milan87_0-1682070004345.png

 

Thanks a lot for both replays.It works fine.


Yes, like that. 

______________________________________________________________
Have a pleasant day and be sure to learn Python for success and prosperity.
0 项奖励
7 条消息(共 7 条)
3,350 次查看