Jump to content

[LVTN] Messenger Library


Recommended Posts

19 hours ago, Maksim Kuznetsov said:

That step also utilises the Messenger Library, but loads it from the folder next to the sequence (to make sure it runs on systems with LabVIEW Run-Time only).

BTW, I'm no expert in such plugins, but this statement seems very wrong to me.  Your plugins should find common dependencies in the EXE that is loading them, not making new copies.

Link to comment
5 hours ago, drjdpowell said:

BTW, I'm no expert in such plugins, but this statement seems very wrong to me.  Your plugins should find common dependencies in the EXE that is loading them, not making new copies.

Yes, you have a very good point here. Usually I follow this approach. However, TestStand Actor is allowed to load any sequence file through TestStand API.
The sequence file itself sometimes calls LabVIEW code, which in my case by a coincidence use the same library that is already loaded by a Run-Time engine.
For the sequence developer it is impossible to know that his steps will have a conflict in memory once deployed.

Thank you for a suggestion about putting Actors and Messenger library under the library. It sounds like a potential solution, I will give it a go.

Link to comment
On 12/17/2019 at 1:48 PM, drjdpowell said:

Another option is to put the entire of Messenger Library in a PPL (changing namespace) but then have ALL your code use this PPL instead of VI.lib (so everything uses the same namespace).

Unfortunately that didn't work.
The same behavior appears as described in the initial post: "Send Message (without reply)" and "Receive Notification" work, however "Send Message (with reply)" doesn't.

What I did was I created an .exe actor which receives and replies with a text message. Then I created a client actor that sends a message and waits for a reply.
Source and Build for the client work perfectly.

Then for a client actor I created a source distribution and included all dependencies in a library (that included Messenger Library).
I also tried putting the client actor itself into a library, but still with no luck.

Link to comment
1 hour ago, Maksim Kuznetsov said:

Then for a client actor I created a source distribution and included all dependencies in a library (that included Messenger Library).

But that wasn't the idea.  Your plugins can't pull in different copies of common dependancies; they must use the copy in the exe, be that source or a ppl.  You need to consult someone who is an expert in plugins.

Link to comment

I believe there is a misunderstanding and I am failing to explain correctly the issue that I am facing. Let me please try once again,
if you still have patience. I prepared the following diagram:

image.png.513fcef830c7520d3514da746c73d24a.png

1. TestStand Actor.exe is launched in LabVIEW Run-Time Server, hence the Messenger Library VIs will be loaded into memory.

2. TestStand Actor.exe runs the sequence file (with any kind of steps) using TestStand API.

3. Sequence File has some LabVIEW steps that are using Messenger Library VIs. LabVIEW Adapter in TestStand automatically
uses the same LabVIEW Run-Time Engine Server as in step 1. Hence there will be a name conflict.

Ideally I would build all of the LabVIEW steps into a packed library (as advised by NI). Doing that provides a namespace + puts all the
dependencies into one file. However, this brakes communication in Messenger Library and steps become useless.

Running steps without library produces a naming conflict in LabVIEW Run-Time Server.

Link to comment
  • 3 weeks later...

Hi everybody. After couple of more days of thinking and trying, I managed to narrow down
the issue to a very simple experiment. Making it work will solve the problem I've been facing for many days.

Experiment setup:

1. Create a simple Actor with a TCPEventMessenger (server). Make it reply with some text to the incoming message.
2. Create another Actor that connects to the actor from step 1 (through TCP). Make it send a message (with reply).
3. Add actor from step 2 to project library.
3. Test both actors in development environment, they should communicate perfectly.
4. Create a packed library build specification for project library from step 3.
5. Now open the actor from the freshly built .lvlibp and try to run it. It should fail with a timeout error while waiting for a reply.

This behavior doesn't make sense to me. Because when instead of building packed library I build an executable everything works
perfectly. Why can't I build a packed library and make it work the same way.

P.S. Packed library includes every dependency, same way as in executable.

Any advice will be highly appreciated! Thank you in advance and happy new year!

Kind Regards,
Max

Link to comment

Here is a link I found that I think might be the same issue, though with a Global Variable as the communication method between components: https://forums.ni.com/t5/LabVIEW/How-to-access-common-global-variable-between-different-Packed/td-p/3324410?profile.language=en

There, as I suggested above, the solution was to put the common dependancy in a common ppl, that all communicating components used.  

Link to comment

Thank you for the link. But, the problem appear even if I just have a single Actor that uses dependencies from ppl.
Basically as soon as "Messenger Library" is put in ppl or a library the TCP Messenger brakes (I can send message without reply, but I can't receive replies).

Apparently PPL also creates a namespace for everything that is inside and that brings us back to your reply:

On 12/16/2019 at 6:16 PM, drjdpowell said:

On no condition would I recommend renamespacing the library, as TCP involves flattening the messages to strings, and that uses the class names, which you are changing.  The TCP Messengers override the usually LabVIEW flattening for some common messages for reasons of performance, replacing the class names with a much-shorter format using an enum for class type.  This is why some messages will still work.  But this is strictly limited.

Is there any easy fix that I can apply to make Messenger Library work from ppl and library?

Kind Regards.
Maksims

Link to comment
On 12/19/2019 at 12:39 PM, Maksim Kuznetsov said:

Unfortunately that didn't work.
The same behavior appears as described in the initial post: "Send Message (without reply)" and "Receive Notification" work, however "Send Message (with reply)" doesn't.

What I did was I created an .exe actor which receives and replies with a text message. Then I created a client actor that sends a message and waits for a reply.
Source and Build for the client work perfectly.

Then for a client actor I created a source distribution and included all dependencies in a library (that included Messenger Library).
I also tried putting the client actor itself into a library, but still with no luck.

I think there is a misunderstanding somewhere as what you describe here is almost the opposite of what I suggested here:

On 12/19/2019 at 12:39 PM, Maksim Kuznetsov said:

put the entire of Messenger Library in a PPL (changing namespace) but then have ALL your code use this PPL instead of VI.lib (so everything uses the same namespace).

 

Link to comment

To eliminate the misunderstanding. I have 2 applications:

  • One is a built executable, uses messenger library as is from VI package manager.
  • Second is a ppl with one actor inside (possible on a completely different PC).

I can't make these 2 applications communicate through a TCP messenger.

I understand that PPL changes the namespace of all classes. Hence when flattening/unflattening messenger addresses
the namespace is included. That is why communication doesn't work.

To solve this I think I need to somehow remove the namespace when flattening
and then add it when unflattening (in actor that runs from PPL).

What do you think?

Link to comment
11 hours ago, Maksim Kuznetsov said:

To eliminate the misunderstanding. I have 2 applications:

  • One is a built executable, uses messenger library as is from VI package manager.
  • Second is a ppl with one actor inside (possible on a completely different PC).

I can't make these 2 applications communicate through a TCP messenger.

I understand that PPL changes the namespace of all classes. Hence when flattening/unflattening messenger addresses
the namespace is included. That is why communication doesn't work.

To solve this I think I need to somehow remove the namespace when flattening
and then add it when unflattening (in actor that runs from PPL).

What do you think?

Here's a couple of diagrams.  You seem to be doing this:

V1.png.7cc01ca9642a4f7bc6515207f60373d5.png

Where the privately-namespaced copy of Messenger Library in your ppl cannot communicate.   But I'm suggesting this:

V2.png.0304cc03dcbe3f7b593144480073587a.png

Where every component uses a common ppl.

  • Thanks 1
Link to comment

Yes, Dr Powell, this is exactly what I was trying to do. Thank you for diagrams. I also realised it is not possible and shouldn't be possible based on this discussion:
https://forums.ni.com/t5/LabVIEW-Idea-Exchange/Allow-type-casting-between-classes-types-in-PPLs-lvlibp-s-or/idi-p/3136231?profile.language=en

Why it was necessary?

Due to how TestStand Interacts with LabVIEW application instances:
http://www.ni.com/product-documentation/14335/en/

TestStand steps tend to use the same application instance as LabVIEW executable (based on Messenger Library),
this is why steps that used Messenger Library from another location didn't work. I wanted
steps to be easily distributable, so had to keep dependencies (including Messenger Library) next to them.

NI suggests to keep LabVIEW steps in PPL, that didn't work for me because it changed the namespace of the library.
However, as you suggested, also changing namespace of the actor I communicate to, worked!

So now I have two PPLs with exactly same names, but with different contents. One with actor, second with steps. Additionally,
to make TestStand use a different application instance I specified a project path for each step (it forces it to use another application instance).
Then I continued my experiments and included steps directly into the Actor PPL and it also worked perfectly without having multiple
PPLs. Just one Actor PPL, that has API VIs that are called from TestStand.

So far so good, it works well. Thank you very much! It is a relief and I learnt valuable things.

P.S. Sharing PPL Messenger Library should also work, it will involve a little bit of extra work.

Link to comment

I am now thinking of creating PPL for a Messenger Library, that is the best solution. I remember 2 years ago you suggested:

On 1/25/2018 at 8:26 PM, drjdpowell said:

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.

Creating a PPL and relinking VIs in existing actors to that PPL should work. However how would you approach creating the PPL that will also appear in
LabVIEW palette for development (as it is now with Messenger Library)? I would like to distribute PPL to developers seamlessly without having them to dig
into the PPL and look for particular VIs.

Link to comment
On 9/13/2019 at 3:24 PM, drjdpowell said:

Your right, there is a reference leak here.  That Queue is a reference created in the actor's calling code, and is used to trigger the "Autoshutdown" message when the caller stops, thus invalidating the Queue.  There is an async component called the "ReferenceMonitor" which watches that Queue and sends the Autoshutdown message then closes.   ReferenceMonitor also polls the actor's address, so it can shut itself down if the actor dies.  However, I forgot to destroy the Queue in that case.   Here is an image where I have added the needed Close operation:

2146204797_FixReferenceLeak.png.3fb51efbe10eae86af6c78643cb176a8.png

Just a warning: this bug is the prime suspect in an application failing after 55 days continuous use.  LabVIEW has a limit of one million Queues alive at any time, after which "Obtain Queue" throws an Error 2: out of memory.  This happens after 55 days if one actor shuts down (without its Caller shutting down) every 5 or so seconds.  Unfortunately the application was built two days before this bug was reported.  Please upgrade to the latest Messenger Library version.

  • Thanks 1
Link to comment

Basic question: I've written actor templates with config and plugin features. Using those to write soundcard in and out actors. They have helper loops that use 'register' and 'notify' to transmit the waveforms around.

A standard labview notifier is set by the messaging loop to shut down the helper loop. How do you shut down your helper loops - is there a 'messenger library' feature you use?

When using queues I used to close the queue in the main loop and detect queue errors in the helper loops.

Link to comment

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.