From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Actor Framework Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with a simple "polling" Actor

I need to add a task/thread to my software (that doesnt use AF), that will poll periodically (1sec) a device (via serial port modbus) and keep a led indicator TRUE if the device responds (FALSE otherwise).

 

So I thought to use AF! Nice! GG! 😄

Instead of manually develop all the messages/queues/etc.... all is built in. Framework for the win! Reuse software for the win!

 

SO I created an Actor (KeepAlive), it has 2 state variable:

  • refnum to bool indicator
  • VISA serial port.

it has one method: Check, that will poll the device (via serial port), and set the indicator value (via the refnum).

Then I create the message for this method.

 

 

then on my software, I create & spawn the actor (place it on block diagram, set instance variables via property , and launch root actor), and call the TimeDelayedSendMsg, with 1sec input, and my Check Msg object.

 

When I want to stop it , I send SendNormalStop to is enqueuer.

 

It works.

 

BUT

 

I want to use this actor many times. The actor should spawn at the end of a test (if test is OK, I spawn the Keepalive), but when the user starts a new test, this actor should be stopped or not in memory (whatever)

 

I am not able to create a DVR of actor inside lvlib (it doesn't work, don't know why).

I can't create a singleton of this actor because I can't check the object ref (I can't use the "first call" to implement singleton, I need the version with notAPath/ref, but it doesn't work with classes).

 

My questions:

 

  1. How to change actor state? via properties or via messages? If I want to change com port to actor for example. Is it ok to initialise an actor via properties directly on the actor object? via PreLaunch init???
  2. In order to minimize wires around, I thought to use a "global architecture", and just Spawn/start the actor, and Stop it, without placing many blocks around or having much wires around. I am not able to do that, bc I can't create a singleton/DVR/Buffer around it.

any help is appreciated.

thanks

0 Kudos
Message 1 of 3
(2,501 Views)

@Ironman_ wrote:

 

I am not able to create a DVR of actor inside lvlib (it doesn't work, don't know why).

 


Try a DVR of a cluster, containing an Actor object.  DVR of a bare Object (of any kind) is a special features and restrictions.  Putting it in a cluster prevents those feature and restrictions.

0 Kudos
Message 2 of 3
(2,461 Views)

@Ironman_ wrote:

 

I can't create a singleton of this actor because I can't check the object ref (I can't use the "first call" to implement singleton, I need the version with notAPath/ref, but it doesn't work with classes).

 


Send it a message.   If that produces an error, then your singleton isn't running and can be (re)started.

 


@Ironman_ 
  1. In order to minimize wires around, I thought to use a "global architecture"...

This is a "code smell", BTW.   Use a "singleton" or any global feature only with good reason, and hiding wires is not a good reason.

0 Kudos
Message 3 of 3
(2,459 Views)