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: 

Actor Message Log

For several reasons, I'd like to capture a log of the messages that are sent to an actor. Firstly for debug of my code, but then for later on in the application where I will have a complex state machine with several actors and lots of messages and I may need to debug the sequence. It seems like overriding "Receive Message.vi" would be a good place to capture a log. Some searching around this forum lead to using the "Get Class Name" to pull the class name, which gives the message name as a string that I can then store. But, how would I capture the data associated with that message class? Since every class has different data associated with it, I can see that it might be challenging. Suggestions welcome.

0 Kudos
Message 1 of 6
(5,959 Views)

Sounds like you would need to have some way of serializing/deserializing the message data.

You can look into converting it to a string. Ideas that come to mind is looking at the LAVAG Variant probe

https://lavag.org/topic/13748-cr-variant-probe/

or check out Aristos Queue Character Lineator https://decibel.ni.com/content/docs/DOC-24015

For an opportunity to learn from experienced developers / entrepeneurs (Steve, Joerg, and Brian amongst them):
Check out DSH Pragmatic Software Development Workshop!

DQMH Lead Architect * DQMH Trusted Advisor * Certified LabVIEW Architect * Certified LabVIEW Embedded Developer * Certified Professional Instructor * LabVIEW Champion * Code Janitor

Have you been nice to future you?
0 Kudos
Message 2 of 6
(4,736 Views)

First, what version of LabVIEW are you using?  If you are using 2013 or 2014, and have access to the Desktop Execution Trace Toolkit, you can get a version of AF that generates trace data for your message traffic.  Check ou the community source versio of AF here:

If you want to log attributes, you can override Receive Message as you've described.  As it turns out, the Flatten to XML primitive will give you a human-readable copy of your attributes, provided at least one attribute has a non-default value.  So you can flatten the XML and append it t some text file somewhere.

The down side, of course, is that you've introduced another layer to your class hierarchy, and dropping the logging layer *will* force a recompile.  That might matter, or it might not, depending on your process and regulatory requirements.

Message 3 of 6
(4,736 Views)

I think the XML trick will work. Thanks for the idea.

0 Kudos
Message 4 of 6
(4,736 Views)

You can also create a "Loggable Message.lvclass", give it a "Generate Log String.vi" dynamic dispatch method, and then make all your messages to that actor inherit from the Loggable Message class. Each one can override to create its own display message.

0 Kudos
Message 5 of 6
(4,736 Views)

Note that one can make the parent implementation of AQ’s “Generate Log String” return the class name and/or XML, and then have key message classes override with something more custom.   I use “Text Description” rather than “Generate Log String”, as such a function is valuable in custom probes in addition to logging.

0 Kudos
Message 6 of 6
(4,736 Views)