Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Papyrus for Real Time » strings as message parameters?
strings as message parameters? [message #1781711] Mon, 12 February 2018 13:48 Go to next message
Juergen Dingel is currently offline Juergen DingelFriend
Messages: 42
Registered: January 2015
Member
Hi,

what is the best/easiest way to use strings as message parameters, if any?

Thanks!

Juergen
Re: strings as message parameters? [message #1781728 is a reply to message #1781711] Mon, 12 February 2018 15:55 Go to previous messageGo to next message
Ernesto Posse is currently offline Ernesto PosseFriend
Messages: 359
Registered: March 2011
Senior Member
The easiest way is to declare the parameter with type String from the UML Primitive types: when choosing the type of a message parameter you get a list that begins with * (meaning "anything"), the list of Ansi C types, and at the bottom three options: "Select Existing Type...", "Create new Class..." or "Create new Enumeration...". Choose "Select Existing Type..." and under "Primitive Types" select "String". Do not choose "Ecore Primitive Types".

This will be represented in the generated C++ as "char *". But you can pass directly attributes of type UML String as well.

See the attached model for an example.

Unfortunately, the generated code doesn't support the C++ "string" type, because the generator was written to produce C++03 rather than more recent versions of C++. You can still use the "string" type in your action code, but you have to manually add an "#include <string>" to your capsules (in the CapsuleProperties stereotype/headerPreface), and do the wrapping on your own.
Re: strings as message parameters? [message #1781744 is a reply to message #1781728] Mon, 12 February 2018 21:47 Go to previous messageGo to next message
Juergen Dingel is currently offline Juergen DingelFriend
Messages: 42
Registered: January 2015
Member
Quote:
The easiest way is to declare the parameter with type String from the UML Primitive types: when choosing the type of a message parameter you get a list that begins with * (meaning "anything"), the list of Ansi C types, and at the bottom three options: "Select Existing Type...", "Create new Class..." or "Create new Enumeration...". Choose "Select Existing Type..." and under "Primitive Types" select "String". Do not choose "Ecore Primitive Types".


When I want add a parameter to a message and select the green '+', I get
- the list starting with '*',
- a submenu called 'Protocol Message Parameter with UI with existing Type...',
- a submenu called 'Protocol Message Parameter with UI with new Class...', and
- a submenu called 'Protocol Message Parameter with UI with new Enumeration...'.

Selecting '... with existing Type...', gets me
- a folder containing user-defined types in a folder named after my project,
- the UMLRT-RTS model library, and
- the AnsiCLibrary.

I cannot find 'Primitive Types' or 'String' in any of these...

Thanks

Juergen

Re: strings as message parameters? [message #1781846 is a reply to message #1781744] Tue, 13 February 2018 20:21 Go to previous message
Ernesto Posse is currently offline Ernesto PosseFriend
Messages: 359
Registered: March 2011
Senior Member
In a brand new model the UML Primitive Types are not automatically loaded. There are two things you can do:

1. In the model explorer, right-click the root-element
2. select "Import..." -> "Import Registered Package"
3. Select "UML Primitive Types".

Now you should see the package in the model explorer and in the "Existing Types..." dialog.

The second alternative is to add, for example, a log port in a capsule. This will automatically load the UML Primitive Types package.
Previous Topic:Protocol function (operation) input parameter type issue
Next Topic:Thread Assignment
Goto Forum:
  


Current Time: Mon Nov 12 18:42:12 GMT 2018

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

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

Back to the top