notice

Path: <BSW Package/Examples/amsr-vector-app-example-hello-world/app/hello_world/src

Files:

main.cpp

This is the entry point of the process. This method will return zero if the execution was successful.

  1. The first step of the main method is to block all signals for this thread and all child threads. It is necessary that only the signalhandler thread can react on signals.
  2. The next step is the initialization of logging. This step is basically reading the configuration files and is configuring the logging settings at runtime.
  3. Afterwards the initialization of the logging is supposed to be successfully done. This is checked by the if statement.
  4. The following step is to create the application object and call the run method of it.

application.h / application.cpp

application.h

The file application.h gives the definition of the application class. The application.cpp is providing the implementation of the class defined in the application.h file.

Constructor

The constructor of the application class is basically performing the initialization of the process. In this case the signalhandler thread is started. You could for example add the parsing of arguments, some configuration files or read some persistent data at this point.

Destructor

The destructor is setting the member variable exit_requested_ to true. This member variable can be used to identify that the destruction of this object was triggered. So, you could terminate the tasks you are currently performing.

SIGTERM or SIGINT

Afterwards the destructor is checking if exit was requested by sending SIGTERM or SIGINT. If not the termination of the signal handler thread is triggered to shut down the application. Finally, the destructor will wait till all threads have joined (Here just the signal handler thread). Here you can add the logic to persist some data before shutting down.

notice

Do not use this to store safety critical (ASIL related) information.

StartSignalHandlerThread

The method StartSignalHandlerThread is basically just starting the signal handler thread, setting its name, and returning an ara::core::Result object containing either the process id or the corresponding error.

Run

The Run method is the logic of the application.

  • If the application is reaching this point and the initialization went well it is reporting the application state kRunning to the Executionmanager.
  • Afterwards the example is printing a log message.
  • As a last step the application state kTerminating is reported to the Executionmanager.

SignalHandlerThread

The SignalHandlerThread method is describing the behavior of the signal handler thread.

This thread is basically just waiting for any signal. If the signal is either SIGINT or SIGTERM the application is supposed to shut down. This is triggered by setting the member variable exit_requested_ to true.

If another signal was received it will be ignored and the thread will wait for another arriving signal.

ReportApplicationState

The method ReportApplicationState is performing the report to the Executionmanager using the applicationstate API.

hello_world_error_domain.h / hello_world_error_domain.cpp

notice

Note: This is an example on how you can use the ErrorDomains in your project. If you do not need ErrorDomains just remove these files.

The hello_world_error_domain.h file is giving the definition of the HelloWorldErrorDomain class.

The hello_world_error_domain.cpp is providing the implementation of the class defined in hello_world_error_domain.h file.

This class is describing an ErrorDomain and is used to identify if an error occurred during the startup of the SignalHandlerThread.