Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [papyrus-rt-dev] Code generation questions (Papyrus-RT used in lecture)

A couple more comments in-line below:

On Wed, Nov 8, 2017 at 9:22 AM charles+zeligsoft.com <charles@xxxxxxxxxxxxx> wrote:
Some answers inline below.

I hope this helps.


Regards,

Charles Rivet
Senior Product Manager, Papyrus-RT product leader

On 2017-11-08, at 04:38 , Ansgar Radermacher <ansgar.radermacher@xxxxxx> wrote:

Dear all,

the university of Darmstadt plans to use Papyrus-RT instead of a commercial tool in a lecture about real-time systems.

They asked me the following questions that they could not figure out in the documentation

- How to specify synchronous (blocking) invocations ?
<cr>
As a general note, one must be careful in the use of synchronous signals in real-time embedded systems because of their blocking behavior.

That being said, there are “invoke” methods defined in UML-RT, but they are not implemented in the Papyrus-RT Runtime Services Library (RTS).

Check out: 

  • int invoke ( UMLRTMessage * replyMsgs );
  • int invokeAt ( int index, UMLRTMessage * replyMsg );

In RTS files:


The stubs are there, but they are not implemented. If you want to write code these operations, we would be happy to incorporate it in the Papyrus-RT code base!

A workaround does exist in that you can boost the priority of the signals sent and received to simulate this functionality.

A “send” operation does have a field for the priority of the message:

  • bool send ( UMLRTPriority priority = PRIORITY_NORMAL ) const;

Where priority can be any of:

  • PRIORITY_SYNCHRONOUS = 0,
  • PRIORITY_SYSTEM,
  • PRIORITY_PANIC,
  • PRIORITY_HIGH,
  • PRIORITY_NORMAL,
  • PRIORITY_LOW,
  • PRIORITY_BACKGROUND,
  • PRIORITY_MAXPLUS1
By setting the priority at a high level, e.g., SYNCHRONOUS, the message will be one of the first processed as message queues as first processed in order of priority.


</cr>

[epp] Indeed, you can use the PRIORITY_SYNCHRONOUS approach but you have to be aware that it isn't really synchronous. It just means that it is the highest possible priority. 

[epp] Since 'invoke' is not yet implemented, the user has to manually do a send/acknowledgment protocol, e.g.: Capsule Sender sends a message in state S1 to capsule Receiver and waits for an acknowledgement reply with a transition from S1 triggered by the reply message. The Receiver will have a transition for that message, and in the action of that transition, it sends back the acknowledgement.

 
- Is it possible to add additional #include to certain files?
<cr>
Yes there is. There are stereotype properties that allow you to do this. If you add the “CapsuleProperties” stereotype, you will find the ability to specify include files (header/implementation preface/ending).
</cr>

[epp] This assumes that the RtCppProperties profile is applied to the model. If the model was created with the wizard, selecting "UML-RT for C++" as the template in the "Initialization Information" dialog, will automatically apply this stereotype.

[epp] I'm not sure if we have documentation on applying stereotypes, but just in case, the user needs to select a capsule in the Model Explorer, and go to the "Profile" tab in the "Properties" view, then click the [+] button and double-click the stereotype to apply (e.g. CapsuleProperties) and click [OK]. Then the stereotype will appear under "Applied stereotypes". Unfold the stereotype and you will see all the properties that could be customized. Typically, additional #include statements are added under "headerPreface".

[epp] If you are using some class A in some capsule or class B, both defined in the same model, there is no need to manually add the inclusion of A.hh into the definition of B. This is done automatically. However, if you want to include files defined as UML Artifacts, you can create a class diagram, drag-and-drop the client class and the artifact into the diagram and draw a Dependency between them. The include will be generated. Furthermore, there is a "DependencyProperties" stereotype which can be used to control whether you want an #include or a forward reference. 

- Is it possible to add additional code that is executed at the beginning of the generated main method?
<cr>
If you mean before the main method is started, I don’t think so.

However, you can run code as part of the top capsule’s initial transition. At that point, the runtime system has been initialized and you would have access to all its services, but no other execution would have started.

This is the typical approach, for example, to read in command line parameters that could affect the system’s running configuration. There should be an example available on how to do this - let me know if this is of interest and I’ll find it for you.
</cr>


[epp] Indeed, modifying the main.cc is not supported, and I wouldn't recommend doing this, as the code in the main initializes the runtime system. Having said that, Papyrus-RT is open source, so you can always modify the main generator (see org.eclipse.papyrusrt.codegen.cpp.structure.CppMainGenerator). Otherwise, you can write action code in the Top Capsule's state-machine's initial transition as Charles suggests.

[epp] And one more thing, these sort of questions are great to ask in the Papyrus-RT forum [1]. I would encourage the prof at Darmstadt and his students to post their questions there. 

 
Best regards

Ansgar
_______________________________________________
papyrus-rt-dev mailing list
papyrus-rt-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/papyrus-rt-dev
_______________________________________________
papyrus-rt-dev mailing list
papyrus-rt-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/papyrus-rt-dev
--
Ernesto Posse
Zeligsoft

Back to the top