Actor Framework Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

About testcase Actor

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.

0 Kudos
Message 1 of 14
(9,371 Views)

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

0 Kudos
Message 2 of 14
(4,748 Views)

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.

0 Kudos
Message 3 of 14
(4,748 Views)

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.

0 Kudos
Message 4 of 14
(4,748 Views)

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).

0 Kudos
Message 5 of 14
(4,748 Views)

One picture is worth tenthousand words

This would be my suggestion on how to launch actors.

Regarding communication between actors:

  • to me the cleanest and most structured way would be to communicate from the TestCase actor via Master and Ressource Admin Actor to the Instr and Datalog actors. This involves a lot of communication (message forwarding) but it makes totally clear which actor cooperates with which others.
  • A less hierachical approach could be that the TestCase actor gets the enqueuers of Instr and Datalog actors from Master or Admin actor to establish a direct communication. But in this case, messages have to be defined including the enqueuer of TestCase actor in order to be able to receive data from Instr or Datalog.

LaunchActors.png

And as niACS mentioned: do not forget stopping the actors

0 Kudos
Message 6 of 14
(4,748 Views)

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)

0 Kudos
Message 7 of 14
(4,748 Views)

One picture is worth tenthousand words

This would be my suggestion on how to launch actors.

Regarding communication between actors:

  • to me the cleanest and most structured way would be to communicate from the TestCase actor via Master and Ressource Admin Actor to the Instr and Datalog actors. This involves a lot of communication (message forwarding) but it makes totally clear which actor cooperates with which others.
  • A less hierachical approach could be that the TestCase actor gets the enqueuers of Instr and Datalog actors from Master or Admin actor to establish a direct communication. But in this case, messages have to be defined including the enqueuer of TestCase actor in order to be able to receive data from Instr or Datalog.

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.

0 Kudos
Message 8 of 14
(4,748 Views)

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.

0 Kudos
Message 9 of 14
(4,748 Views)

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.

0 Kudos
Message 10 of 14
(4,748 Views)