Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Papyrus for Real Time » Can't syncronize code to uml file
Can't syncronize code to uml file [message #1777286] Tue, 28 November 2017 07:40 Go to next message
Sekwon Jang is currently offline Sekwon JangFriend
Messages: 10
Registered: November 2017
Junior Member
I made a package, put a capsule into a new package and perform "Create Submodel" in order to separate a capsule from uml file.
PapyrusRT made a new uml file for a new package.
I can open a new package from Project Explorer.
There is only a new model in the model explorer
But If I try to open a new model, Model explorer shows parent model not new model .
And there is another problem.
When I write code for separated capsule from Code view not Code Snippet,
PapyrusRT doesn't apply new code to separated uml file.
After code generation, there isn't new code in code generated

Are there addition step after "Create Submodel"?
Re: Can't syncronize code to uml file [message #1777350 is a reply to message #1777286] Tue, 28 November 2017 18:02 Go to previous messageGo to next message
Ernesto Posse is currently offline Ernesto PosseFriend
Messages: 438
Registered: March 2011
Senior Member
Submodels are not currently supported by Papyrus-RT. "Create Submodel" is inherited from base-Papyrus but it has not been tested on Papyrus-RT and it is quite possible that it wouldn't work properly in Papyrus-RT. You can try the instructions given in https://www.eclipse.org/forums/index.php?t=msg&th=1090014&goto=1776337&#msg_1776337. Those instructions suggests that you have to explicitly import the package into a new model or existing model with Right-Click->Import->Import Package From User Model.

As for code synchronization, it is hard to say with more information. It seems like you are trying to synchronize code generated from one model with a model that has been "separated". What are exactly the steps that you did? If you created a model M1 with say Capsule A, generated code (resulting in A.hh/.cc), then put A in a package, created submodel, imported it into another model and then modified A.hh or A.cc, then this would not update the "separated" model. This scenario is not supported by Papyrus-RT.
Code synchronization is done only between a model and code generated from that model directly, edited from the CDT editor (it won't work from other editors).

If you meant something different, could you clarify what exactly are you trying to do?
Re: Can't syncronize code to uml file [message #1777479 is a reply to message #1777350] Wed, 29 November 2017 15:07 Go to previous messageGo to next message
Ernesto Posse is currently offline Ernesto PosseFriend
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 #1777688 is a reply to message #1777479] Fri, 01 December 2017 15:09 Go to previous messageGo to next message
Juergen Dingel is currently offline Juergen DingelFriend
Messages: 42
Registered: January 2015
Member
Here is a related use case that I'm not sure currently is supported:
- students build a capsule A to solve an assignment and submit just that capsule,
- instructor imports A and connects it (ideally automatically) to a test harness to evaluate A.

Can the submodel concept be used for this? One problem seems to be that the submodel containing
A also needs to contain the protocols required to connect the harness to A, so
- if the harness also already contains them, you get duplicate declarations, and
- if the harness does not already contain them, then (it seems) you need to manually
create the triggers on transitions in the harness.

Juergen

Re: Can't syncronize code to uml file [message #1777702 is a reply to message #1777688] Fri, 01 December 2017 18:23 Go to previous messageGo to next message
Ernesto Posse is currently offline Ernesto PosseFriend
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 Go to previous message
Sekwon Jang is currently offline Sekwon JangFriend
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

Previous Topic:determine elapsed time since creation of timer?
Next Topic:IsQuery attribute adds const only to header, not to implemention
Goto Forum:
  


Current Time: Tue Apr 23 13:02:33 GMT 2024

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

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

Back to the top