Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » How to write OCL in a file and use it in a state machine?
How to write OCL in a file and use it in a state machine? [message #1738180] Sun, 17 July 2016 17:27 Go to next message
Syed Samsul Arefin is currently offline Syed Samsul ArefinFriend
Messages: 17
Registered: May 2016
Junior Member
[Newbie]
Hello, I am quite new in papyrus modelling and OCL. In a state machine, I directly create guards and state invariants through the pop-up window. Now I want to write all the constraints in a file and use those constraints as guards/state invariants in the state machine. How can I do that? Thanks.
Re: How to write OCL in a file and use it in a state machine? [message #1738182 is a reply to message #1738180] Sun, 17 July 2016 17:43 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5969
Registered: July 2009
Senior Member
Hi

You can develop a *.ocl file that imports and complements your UML
models with additional Constraints, Operations, Properties.
Specification/modeling job done. (Use the Complete OCL Xtext editor.)

If you actually want to execute those constraints then you need an
instantiation of your statemachine. The default UML2Ecore2Java supports
only class structure. Perhaps Papyrus-RT provides a Java generator for
state machines too, in which case you are dependent on how that
generator supports OCL. Perhaps the constraints are correctly generated
as part of classes, but perhaps the statemechines are not extensions of
EClass and so the constraints get lost.

If you only want to animate those constraints you should be able to
create UML Instances of your States, manually Load->Resource for the
*.ocl and validate. Make sure you apply and set the
UMLforOCL::Validation::validate true. For a long time Papyrus validation
ignored loaded OCL, but I think that is now fixed, but it stopped me
progressing with OCL integration.

Overall, I see a problem that should just work and for which the
underlying code is all there but for which at least a couple of
integration bugs will probably scupper you.

Regards

Ed Willink


On 17/07/2016 18:27, Syed Samsul Arefin wrote:
> [Newbie]
> Hello, I am quite new in papyrus modelling and OCL. In a state
> machine, I directly create guards and state invariants through the
> pop-up window. Now I want to write all the constraints in a file and
> use those constraints as guards/state invariants in the state machine.
> How can I do that? Thanks.



---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
Re: How to write OCL in a file and use it in a state machine? [message #1738183 is a reply to message #1738182] Sun, 17 July 2016 18:26 Go to previous messageGo to next message
Syed Samsul Arefin is currently offline Syed Samsul ArefinFriend
Messages: 17
Registered: May 2016
Junior Member
Great! Thanks a lot. Now I can access model elements from the CompleteOCL file. But, how do I use newly created invariants back to the state machine? I am not quite sure how to complement the model. Am I missing something? I will not execute this but I want the model error free.

import 'platform:/resource/MPTestModel/model.uml'
package RootElement

context State
inv sampleInv: State.armed=1
endpackage

Re: How to write OCL in a file and use it in a state machine? [message #1738184 is a reply to message #1738183] Sun, 17 July 2016 18:36 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5969
Registered: July 2009
Senior Member
Hi

"But, how do I use newly created invariants back to the state machine?"

No sure what you mean If you mean import then Complete OCL document bck
into the UML model, there are a variety of tools used by OCL
auto-generation and tests, that can do this, but none of them has a UI,
or even a very useable API.

Regards

Ed Willink



On 17/07/2016 19:26, Syed Samsul Arefin wrote:
> Great! Thanks a lot. Now I can access model elements from the
> CompleteOCL file. But, how do I use newly created invariants back to
> the state machine? I am not quite sure how to complement the model. Am
> I missing something? I will not execute this but I want the model
> error free.
>
> import 'platform:/resource/MPTestModel/model.uml'
> package RootElement
>
> context State
> inv sampleInv: State.armed=1
> endpackage
>


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
Previous Topic:Evaluate OCL constraints in an UML model programmatically
Next Topic:[Announce] Deadline Extension: 16th International Workshop in OCL and Textual Modelling
Goto Forum:
  


Current Time: Mon Jul 16 19:59:57 GMT 2018

Powered by FUDForum. Page generated in 0.02011 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top