|
|
Re: TimeEvent value setting [message #1708789 is a reply to message #1708757] |
Mon, 21 September 2015 08:58 |
Ed Willink Messages: 7655 Registered: July 2009 |
Senior Member |
|
|
Hi
It is VERY unusual to open a UML model with the "Sample Reflective Ecore
Model Editor"; use the UML Model Editor that understands UML.
By "interactive OCL", I presume you mean the interactive OCL console,
which is suitable for evaluating OCL on instances, not on the classes
normally present in UML diagrams.
Without any repro, it is very difficult to make sense of what you write:
See https://wiki.eclipse.org/OCL/ForumNetiquette.
Regards
Ed Willink
On 20/09/2015 12:26, Ali Khan wrote:
> Hello,
>
> I am working on profile diagram in papyrus. I have made a stereotype
> "S1" and added "a1" as its attribute. The attribute "a1" is typed by
> uml metaclass "TimeEvent".
>
> The stereotype "S1" is extended from UML metaclass "Class". Now when I
> apply that stereotype to a "block" in SysML BDD.. It then asks me to
> set the value of attribute "a1". What i am doing to set its value is
> just craeting a time event having "1second" in opaque expression.
> The problem i am facing is that when i open my uml model in "Sample
> Reflective Ecore Model Editor" and then check there the value of "a1"
> using "interactive OCL", but it keeps returning me "false" as a
> result, whereas it should return "true" when i write already assigned
> value. Actually the "TimeEvent" is not being assigned any value..
> I have tried all language in opaque expression.
>
> Can anyone help me Please..
> Thanks in advance
>
> Regards,
|
|
|
|
Re: TimeEvent value setting [message #1708808 is a reply to message #1708798] |
Mon, 21 September 2015 11:49 |
Camille Letavernier Messages: 952 Registered: February 2011 |
Senior Member |
|
|
Hi,
If S1.a1 is a TimeEvent, then it is not possible to assign "5" to it. You need an instance of TimeEvent (TE1), with a "When" condition containing a TimeExpression, and the "expr" value of this expression may be an opaque expression (Or any other expression). So "at least" your OCL should follow this path of properties.
Assuming that "self" is the instance of your stereotype (S1), and you used an OpaqueExpression for specifying the TimeExpression, this should look like:
self.a1.when.expr.bodies.at(1) = 5
With:
a1 : TimeEvent
when : TimeExpression
expr: OpaqueExpression
bodies: String[*]
(And you probably need to add a few oclAsType() in the middle)
In your OCL example, I'm not sure what "delay" is. S1 doesn't have a "delay" property, and neither does TimeEvent, nor TimeExpression.
HTH,
Camille
Camille Letavernier
[Updated on: Mon, 21 September 2015 11:50] Report message to a moderator
|
|
|
|
|
Re: TimeEvent value setting [message #1708824 is a reply to message #1708820] |
Mon, 21 September 2015 14:12 |
Camille Letavernier Messages: 952 Registered: February 2011 |
Senior Member |
|
|
Hi,
OpaqueExpression can already contain a Language/Body; you don't need to add an OpaqueBehavior in the OpaqueExpression. My OCL example was matching the case where you have an OpaqueExpression without an OpaqueBehavior. If you add an OpaqueBehavior, then it should look like:
self.a1.when.expr.behavior.bodies->at(1) = 5
Quote:But when I try to write OCL expression like "self.a1.when.expr.bodies.at(1)=5". It does not access bodies by a "dot" after "expr".
I did a few mistakes in my example. Since body is a multi-valued string, you need to use an arrow instead of a dot. Additionally, body seems to be a reserved keyword in OCL, so it needs to be escaped with "_". Finally, "body" is a String, so 5 needs to be put inside quotes. So it looks like:
self.a.when.expr.oclAsType(uml::OpaqueExpression)._body->at(1) = '5'
(Tested & verified, this time)
And if you use an intermediate OpaqueBehavior:
self.a.when.expr.oclAsType(uml::OpaqueExpression).behavior.oclAsType(uml::OpaqueBehavior)._body->at(1) = '4'
Quote:and if i write self.a1.when.expr=5 it gives me false whereas it should give true as a result if the value is assigned correctly..
No, it shouldn't. The value of "expr" is not an Integer, so it will never return true if compared to an integer. The only case you might expect this expression to return true, is when "expr" is a LiteralInteger with value = 5, but in this case you actually need to write the following:
self.a.when.expr.oclAsType(uml::LiteralInteger).value = 5
(But then you don't use OpaqueExpression and/or OpaqueBehavior; that's a different model)
Camille
Camille Letavernier
|
|
|
|
|
|
Re: TimeEvent value setting [message #1708883 is a reply to message #1708877] |
Tue, 22 September 2015 08:43 |
Camille Letavernier Messages: 952 Registered: February 2011 |
Senior Member |
|
|
Hi,
I don't think that UML goes that far in the semantics of expressions. AFAIK, it doesn't have a standard library for advanced types such as Dates or Times. So, the semantics of "OpaqueExpression", "Literal String", "Literal Integer" and others, in this case, are undefined.
Profiles dedicated to RealTime such as Marte, or System Engineering such as SysML, might be able to fill this gap. Marte has a lot of concepts related to Time specification, and SysML has a more general concept of Values and Units.
HTH,
Camille
Camille Letavernier
|
|
|
|
Powered by
FUDForum. Page generated in 0.04912 seconds