Actor Framework Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Beginner at the Actor Framework - Need help in abstract messages - Attachment updated

Solved!
Go to solution

I tried to transfer TomMcQuilian's "Video 9 - Abstract Messages" to the small test program attached"

 

I deleted the previous project because it was too buggy.

 

The attached program (AF Test.zip) works fine, but without abstract messages.

Sending message (change palette) from the Main Actor to the Nested Actor (image processing) and back.

 

Here is the updated version with abstract messages (AF Test - AM.zip)
I actually did it 😉
Wow, a lot of work for two small messages to be sent back and forth.


I don't even know if I should even start up my existing project with AF under these circumstances!
Of course, when things go well, it's great and great to look after, but the way to get there is rocky and difficult.

 

I would be happy if an AF specialist could take a look at the code. 😊


Ciao Peter

Download All
0 Kudos
Message 1 of 12
(2,554 Views)

Not a direct answer to your question, but can you use LabVIEW 2020 (or later) and use interfaces instead of abstract messages? That would probably simplify things. 

CLA CLED AF Guild
0 Kudos
Message 2 of 12
(2,484 Views)

Yes, I know, but unfortunately I only have version 2019

😞

0 Kudos
Message 3 of 12
(2,472 Views)

I don't see abstract messages in Your class hierarchy.


The purpose of AM is to decouple actors. If you use message classes of the root actor  in
an nested actor (NA) (image acquisition, processing, error log) directly, then your have strong coupling to root actor and application becomes monolithic.  In this case You will not be able to reuse your NAs. To avoid this, the nested actors define an interface through abstracted message ( e.g. NewImageMsg.lvclass ) classes. The application class defines concrete messages through inheritance (e.g. NewImageMsg::ProceedNewImageMsg). So your application (may be root) actor knows about the modules used and linkt to their, but that is ok, at some point one have to get specific. But the NAs do not use classes from other actors, hence are modular and can be reused. You must define a member variable of type NewImageMsg in your NA and provide your concrete message ProseedNewImageMsg of root before launch NA. 

 

 

I remember well my first steps with AF and that I tried to solve the coupling problem by myself. The result was exactly what is written in the AF white paper about low and zero coupling...  So I recommend the famous RTFM  😉

0 Kudos
Message 4 of 12
(2,437 Views)

Hi p4keal,

 

I have attached the updated version with abstract messages (AF-Test -AM.zip)
I actually did it 😉 (Watching Toms video again more carefully).

 

Wow, a lot of work for two small messages to be sent back and forth.
I don't even know if I should even start up my existing project with AF under these circumstances!


Of course, when things go well, it's great and great to look after, but the way to get there is rocky and difficult.  😞

 

And yes I RTFM 🙂

Piet

0 Kudos
Message 5 of 12
(2,433 Views)

Hi PietH,

 

Sorry I'm late to the party, from your messages it looks like you've already sorted it out!

 

You mention that it's a lot of work for one message... and you're 100% right, it is. However, once you've mastered how the mechanism works and the process to make these messages, it becomes muscle memory. With a bit of practice, you will be able to make these messages in less than 2 minutes (I've not actually timed myself, but it's pretty quick!).

 

The messaging mechanism is like a joke, the more you have to explain it, the worse it is!

 

Ultimately, at some point, your code will mature to be compatible with interfaces (whether that's now or in a couple of years). With interfaces we define the API (i.e. messages in AF), and they make the whole thing much more straightforward. So, even though you may not be working with LV20 for this project, it's worth downloading to have a play around with them.

 

Cheers,

Tom

0 Kudos
Message 6 of 12
(2,420 Views)

Hello Tom,


Thank you for joining the party 🙂
In no case are you too late! I really appreciate your advice. And your videos are really great and a real asset. I have now at least understood the mechanism, and yes, the more you "play" with it, the more fun it is.

At the moment the software for evaluating medical image data, which I would like to set up again with AF, is running very traditionally as a producer-consumer architecture with the NI-AMC Reference Library. New functionalities are added relatively often, which is always a time-consuming thing.
This means that if the software is reprogrammed with AF, the maintenance and expansion of the software is also easier, I think.

So now it's time to train my muscles and get started 🙂

 

I would of course be very happy if you could take a quick look at the code before I start working on the big application. The "Go" from the specialist would be reassuring!

 

Ciao
Piet

0 Kudos
Message 7 of 12
(2,417 Views)

I agree with Tom.


In LV2020, the creation of abstract messages is quite comfortable. Among other things, the class variable and the write accessor are automatically created by the AF abstract message wizzard. I have added an abstract message to your project with a numerical input, which took less than a minute. 

 

ss abs msg.png

 

Message 8 of 12
(2,410 Views)
Solution
Accepted by topic author PietH

Hi Piet,

 

I've had a quick look at the project, the code itself looks clean and tidy - That's always a good start!

 

Looking through your code, I noticed you're storing just one enqueuer for your nested actor. If you're going to use AF I would recommend keeping an array/register of nested items, so you can launch more than one "Image Processor". It's worth the extra work now rather than in a couple of months time!

Also, watch out for your VI execution modes! I noticed that a lot of your VIs are non-reentrant, the whole idea of AF is that it's concurrent. So make sure you change the reentrancy to Shared Clone Reentrant Execution, you don't want to inadvertently create bottlenecks! I usually create a simple VI that changes the reentrancy of VIs in a library (and also turns off debugging).

 

McQuillan_0-1624371610796.png< I just created this, it worked on your actor. You should handle the references better, but I'm sure you get the idea!

edit: I'm opening the fp in this code so it gets brought into memory and changes are 'registered' for the save method

 

Other than this, your code looks good.  

 

Message 9 of 12
(2,409 Views)

Hi Tom,

 

Thanks a lot for your help and the good advices!

 

Ciao

Piet

0 Kudos
Message 10 of 12
(2,392 Views)