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.
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.
05-25-2018 03:58 AM - edited 05-25-2018 04:00 AM
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:
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:
any help is appreciated.
thanks
05-25-2018 07:58 AM
@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.
05-25-2018 08:04 AM
@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_
- 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.