Home » Eclipse Projects » Papyrus for Real Time » Can't syncronize code to uml file
| |
Re: Can't syncronize code to uml file [message #1777479 is a reply to message #1777350] |
Wed, 29 November 2017 15:07 |
Ernesto Posse Messages: 438 Registered: March 2011 |
Senior Member |
|
|
After some tests, I found that the following works for me:
1. Let's say the original model is called "M". Put the capsule C you want to "separate", and all the elements it uses in a package P: if it has ports with protocols P1 and P2, then P1 and P2 must be in the package. If it has a part whose type is capsule A, then A (and all the elements it uses recursively) must be put in the package too.
2. Right-click the package -> Create Submodel; in the dialog, check the checkbox "Create an independent submodel resource" and select the location. Click [OK], and then Save All. This is critical. It looks like the new resource is not created or saved until you do Save All.
This creates the model separately, but it looks like it looses some attributes. In particular, the action language setting. This may be why you have problems synchronizing code. To check this, in the new model with the package, select the root element and in the Properties view select the "Language" tab. If it says "No Language", change it to "C++" and save. Then try to synchronize.
|
|
| |
Re: Can't syncronize code to uml file [message #1777702 is a reply to message #1777688] |
Fri, 01 December 2017 18:23 |
Ernesto Posse Messages: 438 Registered: March 2011 |
Senior Member |
|
|
That scenario would be very useful indeed, but it is not currently supported. You have correctly identified a key issue: the need to share protocols.
This could be potentially dealt with cross-model references. Cross-model references are technically possible in Papyrus (as in EMF models in general), so in theory you could define the protocols in the harness and the capsules to test in a separate model that referred to these protocols. But currently this is not (consciously) supported by the code generator.
I did another test, and this is what I found out.
The top level model contains a capsule Top with a part typed by Capsule1 and a protocol Protocol1. Top and Capsule1 have a port (of opposite conjugation) typed by Protocol1 and are connected. Capsule1 is in a package "Package1", but Top and Protocol1 are in the root element. Top could be considered the "harness" and Capsule1 the capsule under test.
Then I used the steps from my previous message, without putting Protocol1 in Package1. Simply right-click on the package and "Create Submodel". I put it in a separate project, but it doesn't seem to make much of a difference. Clicked on "Saved All" which created the separate model. When I opened the new submodel, at first it showed only Package1, but as soon as I unfolded it to see its contents, you could see in the model explorer the full harness consisting of the root of the original model, Top and Protocol1, but they are greyed out and unmodifiable.
So it looks like if the package that you export as a submodel refers to elements outside, you will get the full context that contains those elements, but the only part that is modifiable is the package that you exported as a sub-model.
In this scenario I was able to generate code in the detached model. But it generates code for the entire system (harness included) so it won't reuse code generated elsewhere.
BTW in the new submodel you can generate code by selecting the greyed out top-level "harness" root element, right-click and "(Re)Generate (all) code", or you can select the capsule of interest (say Capsule1 inside Package1), right-click and "Generate with this capsule as Top". In both cases code for all capsules and protocols will be generated, but in the later case, instead of having "TopMain.cc", "TopControllers.hh/.cc", you'll have "Capsule1Main.cc", "Capsule1Controllers.hh/.cc", and this last file will contain only the (static) structure of Capsule1.
You can try to experiment with this approach, and it may be useful for your use-case. But remember that this is a "use-at-your-own risk" case, as it is not officially supported.
[Updated on: Fri, 01 December 2017 18:27] Report message to a moderator
|
|
|
Re: Can't syncronize code to uml file [message #1777859 is a reply to message #1777702] |
Tue, 05 December 2017 12:22 |
Sekwon Jang Messages: 10 Registered: November 2017 |
Junior Member |
|
|
Thank you for reply.
I found an error as what you said (No Language) and fixed it.
I can open the model for new package in model explorer.
Then, I set the capsule of new package to top capsule and generate code.
Although I found an error about workspace, Papyrus shows code for transition when I click "Edit Code" on transition of model explorer.
But there is still the problem that can't syncronize code of edit view to uml file sometimes. I can't figure out when code is not syncronized to uml file and when code is syncronized.
But , I am glad that I can use submodel feature.
[Updated on: Tue, 05 December 2017 12:47] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Tue Apr 23 13:02:33 GMT 2024
Powered by FUDForum. Page generated in 0.03434 seconds
|