| | 1 | = Pacpus tutorials = |
| | 2 | |
| | 3 | == Foreword == |
| | 4 | |
| | 5 | Before reading these tutorials, please have a look at the GettingStarted page in order to install the framework. |
| | 6 | |
| | 7 | The repository containing the tutorials is accessible through the URL in this command: |
| | 8 | |
| | 9 | {{{ |
| | 10 | cd ~ |
| | 11 | cd dev/pacpus/ |
| | 12 | svn co https://devel.hds.utc.fr/svn/pacpustutorials |
| | 13 | }}} |
| | 14 | |
| | 15 | The repository contains several folders: |
| | 16 | - template: you will find here some source codes (CMakeLists.txt, .cpp and .h) useful for the exercises. |
| | 17 | - exercises: the wording of each tutorial. |
| | 18 | - solutions: the solutions of the exercises (coming soon) |
| | 19 | |
| | 20 | == Basic Concepts == |
| | 21 | |
| | 22 | === Tutorial n°1: Creating your first PAPCUS project === |
| | 23 | |
| | 24 | 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. |
| | 25 | |
| | 26 | 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. |
| | 27 | |
| | 28 | Once you have built your plugin, run it in /opt/pacpus/x.y.z/bin folder with the PacpusSensor executable. |
| | 29 | |
| | 30 | Indications: |
| | 31 | - You can use QTimer to generate the timer. |
| | 32 | - A component can be parametrized in a XML file, it might be useful to change the message display frequency. |
| | 33 | - The tree of your project may be something like that: |
| | 34 | |
| | 35 | {{{ |
| | 36 | |
| | 37 | pacpustutorials |
| | 38 | | |
| | 39 | |--> exercises |
| | 40 | | |
| | 41 | |--> exercise_1 |
| | 42 | | |
| | 43 | |--> CMakeLists.txt |
| | 44 | |--> MessageComponent.h |
| | 45 | |--> MessageComponent.cpp |
| | 46 | | |
| | 47 | |--> build |
| | 48 | | |
| | 49 | |--> build_linux.sh |
| | 50 | | |
| | 51 | |--> CMakeLists.txt |
| | 52 | |
| | 53 | }}} |
| | 54 | |
| | 55 | |
| | 56 | === Tutorial n°2: Managing the communication of components === |
| | 57 | |
| | 58 | |
| | 59 | |
| | 60 | |
| | 61 | ==== Exercise 2.1: communication between components ==== |
| | 62 | |
| | 63 | |
| | 64 | 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. |
| | 65 | |
| | 66 | 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. |
| | 67 | |
| | 68 | Indication: |
| | 69 | - Now, the tree of your project may be something like that: |
| | 70 | |
| | 71 | {{{ |
| | 72 | pacpustutorials |
| | 73 | | |
| | 74 | |--> exercises |
| | 75 | | |
| | 76 | |--> exercise_1 |
| | 77 | | |
| | 78 | |--> CMakeLists.txt |
| | 79 | |--> MessageComponent.h |
| | 80 | |--> MessageComponent.cpp |
| | 81 | | |
| | 82 | |--> exercise_2 |
| | 83 | | |
| | 84 | |--> CMakeLists.txt |
| | 85 | |--> AdditionComponent.h |
| | 86 | |--> AdditionComponent.cpp |
| | 87 | | |
| | 88 | |--> build |
| | 89 | | |
| | 90 | |--> build_linux.sh |
| | 91 | | |
| | 92 | |--> CMakeLists.txt |
| | 93 | }}} |
| | 94 | |
| | 95 | |
| | 96 | ==== Exercise 2.2: communication of variable size data ==== |
| | 97 | |
| | 98 | 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. |
| | 99 | |
| | 100 | Build, install and run this new component. |
| | 101 | |
| | 102 | Indication : |
| | 103 | - you can use the QVector class as input/output type. |
| | 104 | |
| | 105 | |
| | 106 | |
| | 107 | ==== Exercise 2.3: Threaded component ==== |
| | 108 | |
| | 109 | 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. |
| | 110 | |
| | 111 | Build, install and run this new component. |
| | 112 | |
| | 113 | Indication : |
| | 114 | - Your component must inherit from the QThread class. |
| | 115 | - Take care of the protection of the data to guarantee a thread safe execution. |
| | 116 | |
| | 117 | |
| | 118 | |
| | 119 | |
| | 120 | == Advanced concepts == |
| | 121 | |
| | 122 | Soon available... |