Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsHow to write OCL in a file and use it in a state machine?
https://www.eclipse.org/forums/index.php/mv/msg/1079365/1738180/#msg_1738180
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. ]]>Syed Samsul Arefin2016-07-17T17:27:02-00:00Re: How to write OCL in a file and use it in a state machine?
https://www.eclipse.org/forums/index.php/mv/msg/1079365/1738182/#msg_1738182
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]]>Ed Willink2016-07-17T17:43:50-00:00Re: How to write OCL in a file and use it in a state machine?
https://www.eclipse.org/forums/index.php/mv/msg/1079365/1738183/#msg_1738183
import 'platform:/resource/MPTestModel/model.uml'
package RootElement
context State
inv sampleInv: State.armed=1
endpackage
]]>Syed Samsul Arefin2016-07-17T18:26:43-00:00Re: How to write OCL in a file and use it in a state machine?
https://www.eclipse.org/forums/index.php/mv/msg/1079365/1738184/#msg_1738184
"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]]>Ed Willink2016-07-17T18:36:03-00:00