Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Papyrus for Real Time » Is there a way to to assign command line parameters to capsule attributes?
Is there a way to to assign command line parameters to capsule attributes? [message #1754265] Wed, 15 February 2017 22:19 Go to next message
Itamar Tzadok is currently offline Itamar TzadokFriend
Messages: 1
Registered: February 2017
Junior Member
I use a capsule attribute to store a delay value for timeouts used in transitions in the state machine. I want to run the application with different delays passed via the command line. Is there a way to do that? Smile
Re: Is there a way to to assign command line parameters to capsule attributes? [message #1754356 is a reply to message #1754265] Thu, 16 February 2017 17:13 Go to previous messageGo to next message
Ernesto Posse is currently offline Ernesto PosseFriend
Messages: 438
Registered: March 2011
Senior Member
Hi. There are a couple of utility functions in the API to access command-line arguments. They are defined in umlrtmain.hh, as static methods of the UMLRTMain class.

The useful ones are these:

    // Get the number of user command-line arguments.
    static int getArgCount ( );

    // Get the i-th command-line argument.
    static const char * getArg ( int index );

    static int argCount ( ) { return argc; }
    static const char * * argStrings ( ) { return argv; }


So in your capsule you should add, under the Properties View->Profile, the "CapsuleProperties" stereotype, and in the "headerPreface" add the following statement:

#include "umlrtmain.hh"


Then in your action code you can use them. For example, you can do:

const char *arg1 = UMLRTMain::getArg(1);

Re: Is there a way to to assign command line parameters to capsule attributes? [message #1777127 is a reply to message #1754356] Fri, 24 November 2017 18:37 Go to previous messageGo to next message
Juergen Dingel is currently offline Juergen DingelFriend
Messages: 42
Registered: January 2015
Member
One correction and one addition appear necessary:

const char *arg1 = UMLRTMain::getArg(1);

should be
const char *arg1 = UMLRTMain::getArg(0);


Also, on the command line invoke the executable using the '-u' command line option as in, e.g.,
$ ./TopMain.exe -u 3


Re: Is there a way to to assign command line parameters to capsule attributes? [message #1777137 is a reply to message #1777127] Fri, 24 November 2017 20:15 Go to previous message
Nicolas Hili is currently offline Nicolas HiliFriend
Messages: 40
Registered: March 2017
Member
Would that be a good addition to define a service port to do that rather than using C++ functions?

Nicolas

Previous Topic:What is the best way to add comments to model elements?
Next Topic:determine elapsed time since creation of timer?
Goto Forum:
  


Current Time: Fri Mar 29 06:23:48 GMT 2024

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

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

Back to the top