04-14-2014 10:26 PM
Hello, I am learning Actor framwork these days and try my best to utilize actor framework to develop testcase test program, generally speaking, the testcase is dynamic generated which is regarded as a testcase class, and testcase means a series of commands such as kinds of instruments',Datalog's, Delay's and etc. my problem is that these instruments and Datalog's actor should be launched and initialized only when the first testcase begins to start(instrument do not support open and close frequently),so far as I know, actor and only send message to itself and its caller. so I wonder know how should i can send message to instrument actor(DMM,PSU,OSC and etc) and Datalog actor since testcase should not launch the instrument once again(can't be their caller); or wonder if I can register a queue using running instrument and Datalog's Actor dynamically.
04-15-2014 05:17 AM
Actors can be sent messages from anywhere, not only from the "caller" and itself. Every module that knows the enqueuer can send messages to the actor. But the actor does not neccessarily know, where the messages comes from.
I did not completely understand, what you are trying to do. But from what I understood, you should start by making up a message architecure aka "which actor can send messages to which other actor".
I also think, you need to implement an "administator" actor, which invokes instrument actors and implements an interface to the instruments for the test case actors
Oli
04-15-2014 11:46 AM
Snipper wrote:
so far as I know, actor and only send message to itself and its caller. so I wonder know how should i can send message to instrument actor(DMM,PSU,OSC and etc) and Datalog actor
If I follow this correctly, you are asking how a calling actor can send messages to its nested actor. You launch actors usng Launch Actor.vi, which returns the new actor's enqueuer. The calling actor should store this enqueuer in its attributes. You can then use that enqueuer to send messages to the nested actor.
Remember to stop your nested actor in an override of the the calling actor's Stop Core.vi.
04-15-2014 09:21 PM
Thanks for your reply,Oli.your suggestion means a lot to me. following your suggestion(correct me if i am wrong), I can do testcase as following:when test start, UI actor(administor actor) will launch every instrument's actor and datalog actor first. after all instruments' actor and datalog actor is in running status, play testcase arrays(it may be a testcase class array)which is read from UI actor(administor actor); every testcase means a testcase actor( serial execution,and dynamically load), testcase actor should own Instruments' actor's and datalog actor's enqueueres and send commands of sequence to related actor. what I did not know yesterday is how should I get active actor's enqueuer,in other words, active actors is not launched by testcase actor, how do these actor's enqueueres get registered? I wonder If I can archive this goal by store active actor's enqueueres in a global varible(or LV2 varible),then overide preinit method to register them. I will try this idea today.
04-15-2014 09:50 PM
Thanks for your reply,niACS. I get some inspiration from it.
what I just wonder know is how nested instrument actor's and datalog actor's enqueueres get registered dynamically, yesterday my solution is that, a calling actor(the first testcase) launch a series of nested actors. but calling actor's lifetime is different form nested's lifetime. testcase will play sequencely, when the first testcase actor stops, a second actor will be executed, the second testcase actor should not launch HW and datalog actor any more, but send message to these actors directly. in other words, it means switch controll power(sound like switch controller in LabVIEW's Actor Framework sample,I will have to study the example once again).
04-16-2014 02:14 AM
One picture is worth tenthousand words
This would be my suggestion on how to launch actors.
Regarding communication between actors:
And as niACS mentioned: do not forget stopping the actors
04-16-2014 11:24 AM
Snipper wrote:
what I just wonder know is how nested instrument actor's and datalog actor's enqueueres get registered dynamically,
They don't. The AF does not provide any sort of dynamic registration. You can build such a system on your own, but that is highly discouraged.
Snipper wrote:
but calling actor's lifetime is different form nested's lifetime.
This is fine. The calling actor can quit and leave the nested actors running. But in a well-designed AF application, this means that those nested actors have no way to contact each other. If they need to communicate with each other then they need a common root to facilitate their communication. There are ways to get around this, but those ways are discouraged unless absolutely vital for performance reasons.
For more info, please read the HTML file that is generated in your AF sample project and my post here:
https://decibel.ni.com/content/message/71515#71515 (the one dated Apr 16, 2014 11:18 AM)
04-17-2014 06:50 AM
One picture is worth tenthousand words
This would be my suggestion on how to launch actors.
Regarding communication between actors:
Thanks Oli, your picture inspire me a lot. I will follow your suggestion 1;I think it is more general and easier to extend.Correct me if i am wrong, The built in AF sample project:Feedback Evaporative Cooler is similiar to my application. testcase can be regarded as controller of HW, play a testcase array serially is equal to switch to a new controller.Now I am confident to apply AF to my new project.It is not so hard as I imagine. Thanks for your help again.
04-17-2014 07:07 AM
Thanks AQ, your post help me understand AF more, Why I expected to launch Intr actor dynamically is that in my project, 85% of testcase may just use 30% of instr. so most of time, I do not need to launch all instr actor unless a specific instr is need, I hope I can query instr actor's status(check if it's enqueuer is available,then decide to launch). Now I decide to follow Oli's suggestion 1, Launch all my instr actors before I start to implyment a specific testcase, It seems less flexible, but more general and easy to do.
04-17-2014 02:39 PM
Snipper wrote:
Launch all my instr actors before I start to implyment a specific testcase, It seems less flexible, but more general and easy to do.
This is one of those times when the separation of actors really pays benefits.
Suppose you only launch your test case actors. They start running. When they need something to happen, they send a message up to Master. Here's the key: Master DOES know whether or not it has launched any Instr actors. If there's one available, use it. If there's not, Master can decide to launch another one. From TestCase's point of view, it is as if all the Instrs were launched at the start of the application... it doesn't know that you're doing lazy loading.