Save Structured Messages into a Buffer "by value"

Moderator: Moderators

Save Structured Messages into a Buffer "by value"

Postby kfisher@strattechnologies.com » Tue Jul 13, 2021 12:25 pm

Hello!

I am working on a model in which I want to pass a structured message from one subsystem to another via a signal, and then save a local buffer of historic messages in the second subsystem.
I have tried many ways, mostly using ALH, however I have only been able to pass the messages to the buffer "by reference" as opposed to "by values" which is what I need to do in order to save the past values. I would prefer to not have to read down to every individual value and copy it, because the real work application of this would have messages with a large number of properties.

I have attached a few screen shots, as well as my sandbox model.

Thank you very much for your help!

First message sent, and saved to "msgBuffer". Note the position data is 0,0,0
first message.png


A new message is then formed in SS1 with position data 1,1,1, and sent via the "msg Signal Sent." In SS2, we again add the message to "msgBuffer" using the same ALH action as before
alh.png


However msgBuffer.msg references the same object/memory location as before, and therefore the first buffer message is now the same as the second
second message.png


CSM 19.0 SP3, default language javascript, using built in math. Simulation requires reference properties to be initialized.
You do not have the required permissions to view the files attached to this post.
kfisher@strattechnologies.com
Forum Newbie
Forum Newbie
 
Posts: 11
Posts Rating:0
Joined: Wed Mar 03, 2021 9:43 am

Re: Save Structured Messages into a Buffer "by value"

Postby saulius_p » Wed Jul 14, 2021 4:04 am

Hello,

Great to talk to you.

Have you used following samples (in video descriptions)?
https://youtu.be/wzzTWA_6wRw
https://youtu.be/pOyIKnI2Bvc
https://youtu.be/jk32emTYN4Y
https://youtu.be/4qRClTMsVxw
https://youtu.be/di7oJYtp1T8
https://youtu.be/zyMONpAjAwE

Let me know if this does not help.

Sincerely,
Saulius
Best regards,
Saulius Pavalkis
User avatar
saulius_p
No Magic
No Magic
 
Posts: 335
Posts Rating:13
Joined: Fri Dec 04, 2009 5:37 am
Full name: Saulius Pavalkis

Re: Save Structured Messages into a Buffer "by value"

Postby kfisher@strattechnologies.com » Thu Jul 15, 2021 2:32 pm

Saulius, thank you so much for your response. I had seen most of those videos (Brian Moberly is actually my colleague who is working on this model with me), but a few of them did give me ideas which ultimately led me to a solution. Your videos have taught me most everything I know, so thank you very much.

The problem was that I needed to create a runtime object for each new message, so that I had a new memory address to "save" in the buffer. I created a new object for the softwareMessageType block using ALH.createObject. But I was still hung up on getting the structured value type of "messageType" under that block instantiated. Apparently that is not possible during runtime, but I found a workaround in which I created an instance of the value type, and then used a Value Specification Action in the activity during runtime to get an object for the structured value type. I was then able to pass that object to a "Add Structural Value Action" to save the buffer.
one.png

two.png


Model attached for reference.
Thanks again
You do not have the required permissions to view the files attached to this post.
kfisher@strattechnologies.com
Forum Newbie
Forum Newbie
 
Posts: 11
Posts Rating:0
Joined: Wed Mar 03, 2021 9:43 am

Re: Save Structured Messages into a Buffer "by value"

Postby saulius_p » Fri Jul 16, 2021 2:03 am

Hello,

Thank you for the model and the solution. It is great that you found an issue. Some time it is not easy to suggest something quickly. We will try to leverage your model for the future material if this is ok.

Thank you!

Kind regards,
Saulius
Best regards,
Saulius Pavalkis
User avatar
saulius_p
No Magic
No Magic
 
Posts: 335
Posts Rating:13
Joined: Fri Dec 04, 2009 5:37 am
Full name: Saulius Pavalkis

Re: Save Structured Messages into a Buffer "by value"

Postby kfisher@strattechnologies.com » Fri Jul 16, 2021 6:02 am

Of course that is okay. Thank you again very much!
kfisher@strattechnologies.com
Forum Newbie
Forum Newbie
 
Posts: 11
Posts Rating:0
Joined: Wed Mar 03, 2021 9:43 am


Return to Cameo Simulation Toolkits

Who is online

Users browsing this forum: No registered users and 0 guests