LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Use case for functional global in Actor Framework

Solved!
Go to solution

I am learning actor framework in labview, I've gotten to the point where I can decouple child actors using abstract messages for child to parent. I've put some time into understanding proper implementation and I'm trying to make a logging library that I can drop into other projects.

 

My real question is, would it be kosher to use a global variable to set a logging level... 0 being basic logging (app started, measurement started, etc) and 4 being low level (Instrument actor sent request to instrument, SBR polling set to 100ms interval).

 

I can pass messages up and down the actor tree but it seems like there's no better way to have every level check the current log level to see what gets recorded. I know I'm probably re-inventing the wheel but this is partly just to learn proper use of AF.

 

Thanks!

0 Kudos
Message 1 of 2
(1,426 Views)
Solution
Accepted by topic author bghagar

I believe that a common/possible method to deal with this kind of thing (see also error loggers, but not error handlers) is to create a (second) root actor (because you can have multiple root actors) and then pass its enqueuer to things that should log a message.

 

Your message/error logger can have a message to "Set Log Level" or similar, and a separate message with a "Send Log Entry.vi" that takes a message/error/whatever and an enum with a "level" input.

On receiving the message, the logger can check its private data "log level" property and if message.loglevel > logger.minloglevel, log the message/error/whatever.

You could also use this with a GUI and a separate display level, such that all messages are "logged" but only a (changeable) subset are displayed and can be filtered using controls on the GUI.

 

A key point here is that the logger is sharing its enqueuer widely (or rather, having its enqueuer shared widely).

This violates the idea of the tree for message passing - one discussion of this can be found at https://forums.ni.com/t5/Actor-Framework-Discussions/Actor-Tree-vs-Network-Routing-Branch-of-quot-Cl...


GCentral
0 Kudos
Message 2 of 2
(1,386 Views)