Actor Framework Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Persistent messages, saving and loading measages

Solved!
Go to solution

Hi all,

 

I'm working on an AF project where I need the ability to save and load a list of instructions (messages), along with some timing information on what iteration/when to send the message.

 

Some of thetmessages contain an arbitrary data type, others have no payload. 

 

These messages currently need to be sent to two different nested actors, depending on the instruction. 

 

Has anyone done something similar, or have thoughts on how to implement something like this?

 

Additionally it would be useful, but not critical, if the file were human readable for edits to the instructions without having to build a separate editor .

 

Apologies for formatting issues, on mobile. 

 

 

National Instruments
Staff Certification Engineer
0 Kudos
Message 1 of 12
(3,854 Views)

Not AF, but I have done objects saved as human-editable JSON.  It requires the objects having "To JSON" and "From JSON" methods.  The JSON needs to include the class name so the object can be recreated.  

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

This sounds a lot like Desktop Execution Trace Tool. You could use the trace output and parse out a list of commands sent to/received by a specific actor.

 

I guess you then want to go the other way and issue the messages based on a list of commands. This is a bit more interesting, but I guess you could get the parser to make an array of messages and timings and then recreate this messaging in your other situation. I am not sure how to handle the payloads though!

CLA - Kudos is how we show our appreciation for comments that helped us!
0 Kudos
Message 3 of 12
(3,795 Views)

Thanks for the replies!

 

I was curious if I could get around having saving/loading methods for each message of a different data type (re-assigning all the AF message objects manually isn't fun). Sadly I don't think that's possible, so I'm leaning towards something like a .ToString() method and .FromString() method for each message class. 

 

Nate

National Instruments
Staff Certification Engineer
0 Kudos
Message 4 of 12
(3,792 Views)

It won't give you editable data payloads, and it might be not helpful because it will require the application to already have the classes in memory, but you can reproduce instructions from the built-in Flatten to String or similar. Perhaps combined with some manual formatting to a text file for the intervals (allowing the intervals to be editable, and a fixed message with data to be copy-able) would be enough?

 

If you wanted to also edit the payload, and they had sensible string representations, you could do that too but then I guess you're basically almost all of the way to a toString(), fromString() setup...


GCentral
0 Kudos
Message 5 of 12
(3,788 Views)

@CertifiNATEtion wrote:

I was curious if I could get around having saving/loading methods for each message of a different data type (re-assigning all the AF message objects manually isn't fun). Sadly I don't think that's possible, so I'm leaning towards something like a .ToString() method and .FromString() method for each message class. 


What in the world are you talking about?  Except for a lack of human editability, Flatten/Unflatten does everything you want, effortlessly.

0 Kudos
Message 6 of 12
(3,784 Views)

Implementation isn't difficult flatten/unflatten is totally fine. It's manually changing the inheritance of each message class.

Nate

National Instruments
Staff Certification Engineer
0 Kudos
Message 7 of 12
(3,780 Views)

@CertifiNATEtion wrote:

It's manually changing the inheritance of each message class.


Why would you need to do that?

0 Kudos
Message 8 of 12
(3,775 Views)

Maybe I'm confused or mistaken.

The idea would be to make a new message class inherited from Actor Framework Message.lvcass that adds a virtual save/load method and then override it for each of the different message types I need to save or load. 

 

National Instruments
Staff Certification Engineer
0 Kudos
Message 9 of 12
(3,772 Views)

Don't make it a method.  Just straight up flatten the object.

Sam Taggart
CLA, CPI, CTD, LabVIEW Champion
DQMH Trusted Advisor
Read about my thoughts on Software Development at sasworkshops.com/blog
GCentral
Message 10 of 12
(3,770 Views)