Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Papyrus for Real Time » Deep copy of the passed message to the action code(Deep copy of the passed message to the action code)
Deep copy of the passed message to the action code [message #1765033] Mon, 05 June 2017 21:14 Go to next message
Mojtaba Bagherzadeh is currently offline Mojtaba BagherzadehFriend
Messages: 36
Registered: April 2016
Member
Hi,

As you know a pointer to a message is always passed to the action code (UMLRTMessage * msg). I need make a deep copy of this message and do some process when the next message arrives. Is there any built-in functionality in RTS to make a deep copy of passed message?

Thanks
Mojtaba
Re: Deep copy of the passed message to the action code [message #1765121 is a reply to message #1765033] Tue, 06 June 2017 20:38 Go to previous messageGo to next message
Ernesto Posse is currently offline Ernesto PosseFriend
Messages: 438
Registered: March 2011
Senior Member
There is no deep copy for the message (UMLRTMessage) itself. A message does contain a UMLRTSignal (which contains the payload), as well, which has a copy constructor, but this only increments the refcount for the signal, rather than a deep copy.

Keep in mind that these structures are very much internal. Yes, the action code gives you access to the UMLRTMessage, but the only functionality supported is defined by the UMLRTMessage public interface:

    bool defer ( ) const;
    void * getParam ( size_t index ) const;
    UMLRTPriority getPriority ( ) const { return signal.getPriority(); }
    int getSignalId ( ) const { return signal.getId(); }
    const char * getSignalName ( ) const { return signal.getName(); }
    const UMLRTObject_class * getType ( size_t index = 0 ) const { return signal.getType(index); }

    bool isValid ( ) const { return !signal.isInvalid(); }

    size_t sapIndex ( ) const { return sapIndex0_ + 1; }
    size_t sapIndex0 ( ) const { return sapIndex0_; }
    const UMLRTCommsPort * sap ( ) const { return destPort; }


It seems rather odd to want to deep-copy, or even shallow copy the message. What's your use case?

If you want to copy the actual message payload, that's another story.

By default there is support for copying data that comes with a message, but only a shallow copy. Originally deep-copy was supported, but requirements changed. When a message is received, the receiver gets a shallow copy of the payload. (Before it used to give you a deep copy).

If you want to do a deep copy of the data payload, it's up to you. You can send user-defined data-types in messages. If your data-type has a copy-constructor, that's going to be invoked when sending the data.

You can add the PassiveClassProperties stereotype on (data) classes, and set "generateCopyConstructor" to true (although that's the default). This will generate a default copy constructor which performs shallow copy on data. If you want a custom copy constructor, you can set" generateCopyConstructor to false, and set "publicDeclarations" to include a declaration of your copy constructor, and you can add the body of the copy constructor to "implementationEnding. See the attached model as an example. Class1 has the default copy constructor, while Class2 has a custom one.


Re: Deep copy of the passed message to the action code [message #1765137 is a reply to message #1765121] Tue, 06 June 2017 22:21 Go to previous message
Mojtaba Bagherzadeh is currently offline Mojtaba BagherzadehFriend
Messages: 36
Registered: April 2016
Member
Thanks, I was trying to deep copy the message params, I will try your suggestion and let you know if I face any issue.
Previous Topic:Is there any way to get the status of a timer?
Next Topic:Define a trigger which its signal is set to all incoming messages
Goto Forum:
  


Current Time: Thu Apr 25 02:07:25 GMT 2024

Powered by FUDForum. Page generated in 0.02617 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top