Assign type to enumeration literal

Moderator: Moderators

Assign type to enumeration literal

Postby Franz » Wed Feb 21, 2018 11:47 am

Hi,

I have created an enumeration with several enumeration literals, which is connected to a GUI combo box. The purpose is that I want to be able to choose a material from a list and Matlab automatically looks up the material's properties in an excel sheet. I couldn't find a way how to assign the type String to the literal so Matlab can work with it... Is it possible somehow?

Sincerely
Franz
Franz
Forum Newbie
Forum Newbie
 
Posts: 10
Posts Rating:0
Joined: Thu Jan 04, 2018 10:04 am

Re: Assign type to enumeration literal

Postby donatas.mazeika@nomagic.com » Thu Mar 01, 2018 9:42 am

Hello,

Could you elaborate more on your question? Have you already integrated your model with Matlab? What is your wanted result/functionality from the MagicDraw side?

Have a nice day,
Donatas Mazeika
donatas.mazeika@nomagic.com
Forum Expert
Forum Expert
 
Posts: 121
Posts Rating:19
Joined: Tue Apr 21, 2015 12:30 am

Re: Assign type to enumeration literal

Postby Franz » Thu Mar 01, 2018 10:15 am

Hello,

Thank you for your reply.
So I have an enumeration with several enumeration literals as a block property. Then I created a property (in the German version it's Eigenschaft, I don't know if property is the right translation) typed as the enumeration. I dragged this property to a combo box in a GUI, so I can now choose one of the enumeration literals when the simulation is running. The chosen literal also is displayed in the variables pane, so until there it apparently works properly. However this chosen enumeration literal is supposed to be used in a parametric diagram. If I attach the property to a constraint parameter through a binding connector, the binding connector turns yellow and there is an error saying: "The two ends of a binding connector must have either the same type oder types that are compatible so that equality of their values can be defined" (see attachment). The enumeration literal should be of the type String. I cannot find out how to change the type of the enumeration so that the error disappears. The Matlab function is embedded in the constraint and needs to get handed over a String.

Sincerely
Franz
You do not have the required permissions to view the files attached to this post.
Franz
Forum Newbie
Forum Newbie
 
Posts: 10
Posts Rating:0
Joined: Thu Jan 04, 2018 10:04 am

Re: Assign type to enumeration literal

Postby donatas.mazeika@nomagic.com » Fri Mar 02, 2018 6:37 am

Hello,

Thanks for the explanation. The value property and the constraint parameter should have the same type (and in your situation, it would be value type with enumeration literals). Please take a look at this example:
Parametric.png


Best regards,
Donatas Mazeika
You do not have the required permissions to view the files attached to this post.
donatas.mazeika@nomagic.com
Forum Expert
Forum Expert
 
Posts: 121
Posts Rating:19
Joined: Tue Apr 21, 2015 12:30 am

Re: Assign type to enumeration literal

Postby donatas.mazeika@nomagic.com » Fri Mar 02, 2018 6:46 am

Also, I see, that you are using UML properties. In SysML Parametric Diagram, you should use Value Properties.

You could create SysML Enumeration Element from diagram palette in BDD, it would be created Value Type that is based on Enumeration. This would allow you to create Enumeration Literals for a Value Type. Please see image below:
Enumeration.png


Best regards,
Donatas Mazeika
You do not have the required permissions to view the files attached to this post.
donatas.mazeika@nomagic.com
Forum Expert
Forum Expert
 
Posts: 121
Posts Rating:19
Joined: Tue Apr 21, 2015 12:30 am

Re: Assign type to enumeration literal

Postby phillip.hermanto@uni-wuppertal.de » Wed Jun 30, 2021 3:54 am

Hey,
i think i have a similar problem with my project.
Is it possible to create an enumeration literal with a default value e.g. the density of the material? My idea is to create an Enumeration with several Enumeration Literals (Steel = 7750 kg/m3 or Wood = 650 kg/m3) and use those in my Simulation but i seems that there is no option for an default value when using Enumeration Literals. When i create a Property for my Enumeration it is not available in the drop down menu. Maybe you can help me with this.
You do not have the required permissions to view the files attached to this post.
phillip.hermanto@uni-wuppertal.de
Forum Newbie
Forum Newbie
 
Posts: 3
Posts Rating:1
Joined: Fri Jun 04, 2021 1:55 am

Re: Assign type to enumeration literal

Postby saulius_p » Wed Jun 30, 2021 5:18 am

Hello Franz,

Good to talk to you.

You can use enumeration literal as number, but if you want to do the math with it convert to real. e.g. https://www.w3schools.com/jsref/jsref_parsefloat.asp

Please find sample and screenshot below.

Kind regards,
Saulius

Capture.PNG
You do not have the required permissions to view the files attached to this post.
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


Return to Cameo Simulation Toolkits

Who is online

Users browsing this forum: No registered users and 0 guests

cron