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: 24
Posts Rating:3
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: 264
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: 24
Posts Rating:3
Joined: Thu Aug 10, 2017 2:44 pm
Full name: Joseph Cardwell

Re: OCL - Default Value limits check

Postby ryan.hill@gtri.gatech.edu » Tue Jul 14, 2020 10:26 am

I know this is an old post, but I want to bump this up again. I too would like to know if there is a way to see what "type" I'm getting out of "self.oclIsTypeOf(...)", and more broadly a debugging mechanism of some kind. The error "Can not evaluate OCL" doesn't help me fix it.
User avatar
ryan.hill@gtri.gatech.edu
Forum Newbie
Forum Newbie
 
Posts: 17
Posts Rating:0
Joined: Wed Jun 24, 2020 11:25 am
Full name: Ryan Hill

Re: OCL - Default Value limits check

Postby marlel » Mon Jul 27, 2020 2:17 am

Hello,

There is no real "debug", but you can do the expression evaluation "Tools->Expression Evaluation" and see the result
Best regards,
Martynas
marlel
No Magic
No Magic
 
Posts: 388
Posts Rating:27
Joined: Wed Jul 11, 2012 2:31 am


Return to Other

Who is online

Users browsing this forum: No registered users and 0 guests