Jump to content
drjdpowell

[LVTN] Messenger Library

Recommended Posts

On 06/01/2018 at 2:06 AM, burd said:

I got very confused because the VI Help for the Metronome Actor says that this actor accepts the Shutdown message (if I remember right)

I'll update the documentation.  Thanks.  

To be honest, I don't think I have written code to actually shutdown a Metronome actor in five years.  I just let them shut themselves down automatically.  Sometimes I don't even want to adjust the period at all and then I don't even bother wiring out the Metronome Address.  For example, here I need to limit the total size of debug log files and check them once an hour (3600000 ms).  It's "set and forget"; no shutdown code needed.

Self Message once and hour.png

Share this post


Link to post
Share on other sites

Hi James,

I really enjoy using your messenger library for several Labview pojects. I'm not complety sure if it is possible, but have you ever thought about using the actors in a kind of plugin in architecture way  (simunlar to this: https://forums.ni.com/t5/LabVIEW-Development-Best/Plug-in-Architecture-using-Packed-Project-Libraries-lvlibp/ta-p/3514395). 

So my questions is: Is it possible to save actors as packed libary and e.g. launch them from another actor? And if yes, what would I have to change (i'll guess your actor launcher would hav to be modified?)?

Best ragrds from Stuttgart,

Jan

Share this post


Link to post
Share on other sites

I have not done any PPL work, but the basic first step is to build Messenger Library into one or more PPLs.  This may involve changes in library membership to properly group things into PPLs (so it might be a bit of work to convert over existing projects).  Then (I think) one just has to make your code reference the new PPLs and build your own PPL.

If you want to try it, make a fork of Messenger Library, through all the extra bits of it into the main "SendMsg" library and see if you can make a PPL.

Share this post


Link to post
Share on other sites

I'm wondering if others see a similar behavior (described below) and if it's the Messenger Library, LabVIEW, or if it's related to a possibly slow PC (my IT department is extremely overly security cautious).

I have a project that has many Actors (currently about 80) and I want to change some of them to re-entrant.  When I change from NR to Shared clone reentrant execution (in VI Properties), afterwards it takes anywhere from 30 seconds to over a minute to save.  Is this expected? 

I've also noticed other slowdowns in the project (Find Project Items) that can take a long time to respond where the cursor blinks from a arrow cursor to a waiting cursor for about 30 seconds during which I can't select or do anything in LabVIEW.

 

Thanks,

Bruce

Share this post


Link to post
Share on other sites

For me changing reentrancy is instant.   You aren't accidentally saying "Yes" to changing all actors reentrancy are you?

Just say No.pngJust say no.

Share this post


Link to post
Share on other sites

Oh!  That was it!  I had been struggling with this for a while now.

Now it only takes a couple of seconds to save!

Thanks for the tip! 

Share this post


Link to post
Share on other sites

Make sure your VIs are the right reentrancy, as that dialog will happily change the parent methods in VI.lib.   All "Actor.vi" should be shared reentrant, and all "ActorNR.vi" should be non-reentrant.

Share this post


Link to post
Share on other sites
On 4/8/2017 at 3:15 PM, drjdpowell said:

Ah, so the issue is that an actor both replies with an error message, and publishes one.  One possible solution is to say that only one actor should “own" the error.  If actor_a asked actor_b to do something, and an error occurs, then actor_a is the one responsible for handling/reporting it.  You can do this by changing the error handling case to only publish the error message if their was no return address attached to the original request message.  Thus you Reply OR Notify, rather than Reply AND Notify, and there is only one error message.

Dr Powell,

How do I find out if  there is no return address attached to the original request message?

thanks

Edited by burd

Share this post


Link to post
Share on other sites
1 hour ago, burd said:

Dr Powell,

How do I find out if  there is no return address attached to the original request message?

thanks

Read the address and test it by one of these methods:

No Reply Address.png

The left one tests for a "Null" address (the standard parent "Send" object), while the right one tests that the reply address is still "valid" (meaning a message sent to it will go somewhere).   

Share this post


Link to post
Share on other sites
On 11/09/2017 at 9:51 PM, drjdpowell said:

Is the NI Service Locator not running on the remote machine?  When I run the example Clients with no Server running, they quickly return error 1510: "The requested service was not found as a registered service with the NI Service Locator.”  

Hi James, I am unable to replicate your Youtub example "Messenger TCP". I received error 1510 when run Client with NI Service Locator running. I am using Labview 2016 and planning to run server on RT cRIO. Please advice. Thanks

Share this post


Link to post
Share on other sites
On 05/03/2018 at 2:42 PM, Noriker said:

I received error 1510 when run Client with NI Service Locator running. I am using Labview 2016 and planning to run server on RT cRIO.

Error 1510 is "The requested service was not found as a registered service with the NI Service Locator.”   Does the LabVIEW Example "TCP Named Service" work on the two machines?  Did you use the right IP address?

  • Like 1

Share this post


Link to post
Share on other sites

Messenger TCP example works well on a cRIO. If network disconnected, can actor restart by sending initialisation message instead shutdown the actor?

Share this post


Link to post
Share on other sites
14 hours ago, Noriker said:

Messenger TCP example works well on a cRIO. If network disconnected, can actor restart by sending initialisation message instead shutdown the actor?

It's a Client-Server design, where the cRIO actor would be the Server.   A disconnect of the Client has no affect on the Server and it continues to run.   The Client (on the main computer or another RIO) needs to detect the disconnection and attempt to reconnect.   Nobody needs to shutdown, though the Client will need to go into a loop of trying to reconnect every few minutes until the network is back up.  See the conversation starting here, where bbean was dealing with the issue of the Client not being able to connect to the server.  

  • Like 1

Share this post


Link to post
Share on other sites

I'm returning to some Messenger work after a short break, which might explain why I can't see what's wrong with my Messenger Actor based project.

Right now I have a Main actor which is responsible for launching a number of sub-actors. One of these is the FPGA actor. Directly after the launcher I register for all notifications.

Within FPGA actor, the "Self: Initialize" message runs a number of states, the final one being to publish a notification event. This is to be received by the Main actor to known when it has initialised.

Unfortunately this event is not received by the Main actor. I believe this might be because the registration request has not yet been processed by the FPGA actor, and therefore the notification event has no listeners and is effectively unheard.

So my question is: what's the correct way to launch a sub-actor such that you can receive a message from it once it has completed initialisation steps?

 

Main Actor launches FPGA subactor and Registers for All Notifications

main_launches_fpga_subactor.JPG

 

FPGA Actor performs three initialisation steps, the third being to provide a Notification Event

FPGA_actor_notifies.JPG

Edited by Thoric

Share this post


Link to post
Share on other sites

I should add that this is in LabVIEW Real-Time 2017 SP1.

When launched from the IDE it works fine, but when compiled and deployed as an RTEXE that's when I see this issue.

 

Share this post


Link to post
Share on other sites

A coincidence.  I'd just committed to fixing the issue of missed events from the "Self:Initialize" case five days ago.  See Issue 13.  However, using a State Notification instead of an Event one should fix that; does it not on RT?  Note, BTW, that you shouldn't do both an Event and State Notification on the same label (I think this isn't the problem though).   If it is only an issue on RT, then I will look into the TCP communication actors, who treat the first Registration message specially (and thus a bug might be their).

Share this post


Link to post
Share on other sites

I tried avoiding the use of Self:Initialise by sending a message to the subactor immediately after registering for notifications. It still didn't work:

Messenger_avoid_selfinit_bug.JPG

Share this post


Link to post
Share on other sites

Are you sure you aren't passing an error in to the "Notify Event"?   No event is sent on error in.  I generally don't connect the error wire to notify unless I want to not Notify on error.

Also, are you passing the Notifications over TCP?

Share this post


Link to post
Share on other sites

Errors are captured in the final "" state, so if there was an error it would be sent to the caller (Main) where I log all errors. I don't see any such error. Also, no TCP usage.

In the meantime I just quickly created a new project with two actors, one calls the other, and proven:

1. The Self:Initialise state cannot send a notification to the caller - it won't receive it (you knew this, bug 13)

2. Sending a message to the subactor directly after registering for notifications, which gets the subactor to send a reply, does work. But it didn't in my actual project work, only in the test code. So there's either a race condition, timing error, or something else different.

I'll look into this more tomorrow.

Edited by Thoric

Share this post


Link to post
Share on other sites
11 minutes ago, Thoric said:

2. Sending a message to the subactor directly after registering for notifications, which gets the subactor to send a reply, does work. But it didn't in my actual project work, only in the test code. So there's either a race condition, timing error, or something else different.

When something works in the IDE but not in an exe (assuming nothing stupid e.g.e path differences) it very often is a race condition showing up. Never fun to do but can you chuck some delays into your launching code and/or the launched code to simulating running in the IDE which is usually slightly less responsive.

Share this post


Link to post
Share on other sites

Does the ObserverRegistry probe work on RT?  The probe included in the package will display all the registrations just before you make the Notification.  Another idea is to take one of the message loggers, make it a nonreentrant actor so you can open its FP on RT, then use it to see if the notification is getting though.

Share this post


Link to post
Share on other sites

So, the first thing I tried was a delay between registering for notifications, and sending the first message. This fixed it. So there's a race condition. Basically I can assume that the registration request is performed asynchronously and is not complete before the subactor sends back a message in response to the "Deploy_FPGA" message.

James - how can I ensure a regsitration request is complete before the subactor sends a notification?

 

messenger_message_delay.JPG

Share this post


Link to post
Share on other sites

I'm surprised as that shouldn't be possible.   Messages are handled in order sent, so the Registration must be handled before your "Deploy_FPGA" message.  Everything in this code is strictly ordered, so there should be no race condition.   Does the ObsReg custom probe work on RT?  If so can you place a probes just before the "FPGA_Initialized" Notification, on both the ObsReg and the Error in.   If it is a race condition preventing registration, you will see this in the ObsReg probe (do it both with and without the time delay).

Share this post


Link to post
Share on other sites

James, the code works in development mode, so using the probe (assuming it works on RT) will show no issues.
It's only once built into an executable and deployed that the problem occurs. Once built, I don't see how I can use probes :-(

Edited by Thoric

Share this post


Link to post
Share on other sites

Ah, sorry, so it works on RT, but not in an EXE on RT.  

Debugging the hard way, then: you’ll have to log to a file.  The method "vi.lib\drjdpowell\Messenging\ObserverRegister\ObsReg Core\ObsReg to Table.vi” may help in this.

Also, quickly try:

1) not running the error wire through the Notify

2) double check you didn’t accidentally run the wires under the Register-for-All call rather than through (this has happened to me once; one cannot tell by looking).

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.