[[PageOutline(1-10,Contents)]] = Pacpus tutorials = == Foreword == Before reading these tutorials, please have a look at the GettingStarted page in order to install the framework. '''Don't forget to check that the environment variable PACPUS_ROOT is well defined in your setup.''' The repository containing the tutorials is accessible through the URL in this command: {{{ cd ~ mkdir dev && mkdir pacpus cd dev/pacpus svn co https://devel.hds.utc.fr/svn/pacpustutorials }}} The repository contains several folders: - template: you will find here some source codes (CMakeLists.txt, .cpp and .h) useful for the exercises. - exercises: the wording of each tutorial. The wordings are available below too. - solutions: the solutions of the exercises (coming soon) == Basic Concepts == === Tutorial n°1: Creating your first PAPCUS project === ==== Exercise 1.1: your first component ==== The objective of this exercise is to understand the build process of a PACPUS project. The utility 'cmake' is used to create the Makefile of the project, and finally we use the GNU Compiler Collection to build the plugins. __'''Goal of this exercise:'''__ \\ Thanks to the different source codes (.cpp, .h and CMakeLists.txt) in the folder 'template', create a new PACPUS project containing just 1 component. \\ This component may generate a message in the terminal at a user selectable frequency. Once you have built your plugin, run it in /opt/pacpus/x.y.z/bin folder with the !PacpusSensor executable. __'''Indications:'''__ - You can use QTimer to generate the timer. - A component can be parametrized in a XML file, it might be useful to change the message display frequency. - The tree of your project may be something like that: {{{ pacpustutorials | |--> project_exercises | |--> plugin_exercise_1 | |--> CMakeLists.txt |--> MessageComponent.h |--> MessageComponent.cpp | |--> build | |--> build_linux.sh | |--> CMakeLists.txt }}} ==== Exercise 1.2: !FizzBuzz component ==== todo === Tutorial n°2: Managing the communication of components === ==== Exercise 2.1: communication between components ==== In this exercise we will develop a new component with one input and one output. The component should add a specific number defined as a parameter to the input value and provide the result as output. Before sending the result on the output it must wait for 1 second. The component will print to the terminal the result of the addition too. Write the code of this component in a new plugin but use the same pacpus project as the exercise 1. Build and install the plugin in the PACPUS_ROOT/bin folder and execute the plugin with the PacpusSensor application. Indication: - Now, the tree of your project may be something like that: {{{ pacpustutorials | |--> project_exercises | |--> plugin_exercise_1 | |--> CMakeLists.txt |--> MessageComponent.h |--> MessageComponent.cpp | |--> plugin_exercise_2 | |--> CMakeLists.txt |--> AdditionComponent.h |--> AdditionComponent.cpp | |--> build | |--> build_linux.sh | |--> CMakeLists.txt }}} ==== Exercise 2.2: communication of variable size data ==== Create a new component in the same plugin as the previous one (exercise 2.1). It will have the same functionnality with the difference that it can do an addition on a vector of input values. Build, install and run this new component. Indication : - you can use the QVector class as input/output type. ==== Exercise 2.3: Threaded component ==== From the component written in exercise 2.2 create a new component with the same interface. The addition must be done in a separate thread. Build, install and run this new component. Indication : - Your component must inherit from the QThread class. - Take care of the protection of the data to guarantee a thread safe execution. == Advanced concepts == Soon available...