2 issues with FlowDirection in OCL expression

Discussions about systems engineering product SysML functionalities

Moderator: Moderators

2 issues with FlowDirection in OCL expression

Postby CedricGava » Fri Oct 06, 2017 1:33 am

Hello

I need to create validation contraint for port based on their direction, but ocl interpreter fail, 1 to recognize FlowDirection type, and 2 'in' enumeration value.

Example:
Code: Select all
Context ProxyPort inv:
If self.direction = SysML::FlowDirection::out then ...


This Fail (I guess the interpreter cannot find SysML::FlowDirection::out) since FlowDirection enumeration is contained in a package named 'Ports&Flows'... Ok, let's change the expression

Code: Select all
Context ProxyPort inv:
If self.direction = SysML::Ports&Flows::FlowDirection::out then ...


This also fail, I guess because of the & symbol.

Workaround: moving the enumeration outside 'Ports&Flows' make it work... But I cannot share my models any longer.

Now this work:
Code: Select all
Context ProxyPort inv:
If self.direction = SysML::FlowDirection::out then ...


Another issue is when about the 'in' FlowDirection enumeration literal (SysML::FlowDirection::in). Since in is a keyword of OCL, the interpreter complains again.... IMPOSSIBLE to use this enumeration literal in an expression.


Code: Select all
Context ProxyPort inv:
If self.direction = SysML::FlowDirection::in then ...


Cannot manage to make this expression understood by the interpreter

Do I miss something ? Or should you fix this 1 in SysML library 2 OCL interpreter ?

Thank you
CedricGava
Forum Newbie
Forum Newbie
 
Posts: 5
Posts Rating:0
Joined: Thu Oct 13, 2016 8:04 am

Re: 2 issues with FlowDirection in OCL expression

Postby rimvydas.vaidelis » Tue Oct 10, 2017 9:06 am

You should specify qualified name of the enumeration value. Ports&Flows contains illegal character and because of that the name must be enclosed into quotes.
Code: Select all
SysML::"Ports&Flows"::FlowDirection::out


Enclosing into quotes should fix the problem with reserved word also:
Code: Select all
SysML::"Ports&Flows"::FlowDirection::"in"


If you have an older MD version then you have to replace the illegal character (&) with encoded26:
Code: Select all
SysML::Portsencoded26Flows::FlowDirection::out


The same can be used to avoid the reserved word problem:
Code: Select all
SysML::Portsencoded26Flows::FlowDirection::encoded69n


& - encoded26
i - encoded69

You can replace any character with encoded<HEX> where HEX is a hexadecimal code of the symbol.
rimvydas.vaidelis
Customer Support
Customer Support
 
Posts: 262
Posts Rating:14
Joined: Fri May 28, 2010 4:45 am

Re: 2 issues with FlowDirection in OCL expression

Postby CedricGava » Wed Oct 11, 2017 12:47 am

Thank you for the quick answer.
If I do not post answer it means that it works.
Thank you
CedricGava
Forum Newbie
Forum Newbie
 
Posts: 5
Posts Rating:0
Joined: Thu Oct 13, 2016 8:04 am


Return to SysML

Who is online

Users browsing this forum: No registered users and 0 guests

cron