OCL - Default Value limits check

Other topics that do not fit in any of categories.

Moderator: Moderators

OCL - Default Value limits check

Postby cardwellj » Tue Mar 13, 2018 5:42 pm

Hi,
I'm trying to figure out how to best apply an OCL constraint that checks to make sure the default value assigned to a constraint parameter input is within a valid lower and upper bound. I created a custom stereotype that is a generalization of a ConstraintParameter with two additional attributes called "Valid Lower Limit" and "Valid Upper Limit". The OCL expression "Valid_Upper_Limit > Valid_Upper_Limit" produces an expected Boolean response (true/false) based on the assigned values. However the OCL expression "defaultValue > Valid_Lower_Limit" does not evaluate.

I reviewed the comments from another post (see url below) and I believe the issue has to do with the UML primitive value types, but I'm not sure how to correct it. When I compare the custom attributes, which both are typed by a SysML "Real" type, the OCL expression evaluates. I tried to apply the solution in the post below to my own situation but was unsuccessful. I would like to understand the syntax of that solution and if/how I can apply it for my situation. I have provided a sample model.
ocl-comparing-integers-t3063-10.html
You do not have the required permissions to view the files attached to this post.
cardwellj
Forum Newbie
Forum Newbie
 
Posts: 23
Posts Rating:1
Joined: Thu Aug 10, 2017 2:44 pm
Full name: Joseph Cardwell

Re: OCL - Default Value limits check

Postby rimvydas.vaidelis » Thu Mar 15, 2018 8:25 am

You expression should be:

Code: Select all
defaultValue.oclAsType(LiteralInteger).value > Valid_Lower_Limit


Note: the constraint must have validationRule stereotype in order to work as a validation rule.
rimvydas.vaidelis
Customer Support
Customer Support
 
Posts: 261
Posts Rating:14
Joined: Fri May 28, 2010 4:45 am

Re: OCL - Default Value limits check

Postby cardwellj » Thu Mar 15, 2018 9:08 am

Thanks. That did it (using LiteralReal instead of LiteralInteger). I'm very new to OCL and was having a hard time navigating the syntax. From reading the OCL specification, I think this was a type conformance error. Is there a way to see what OCL types the expression is receiving? I typed the stereotype attributes as Real (SysML primitiveValueType), but I'm not sure how that translates in OCL. The Value specification for the default value is "Literal Real" so I'm not sure what the OCL expression is doing or why it's doing it. The No Magic Documentation for OCL is sparse at best and there aren't a lot of great tutorials online. Any additional insight you could provide would be beneficial.
cardwellj
Forum Newbie
Forum Newbie
 
Posts: 23
Posts Rating:1
Joined: Thu Aug 10, 2017 2:44 pm
Full name: Joseph Cardwell


Return to Other

Who is online

Users browsing this forum: No registered users and 0 guests

cron