1 | author: Gerald Dherbomez
|
---|
2 | copyright: Heudiasyc UMR UTC/CNRS 7253
|
---|
3 |
|
---|
4 | Exercise 2: Managing the communication of components together
|
---|
5 | -------------------------------------------------------------
|
---|
6 |
|
---|
7 |
|
---|
8 | Exercise 2.1: communication between components
|
---|
9 | ----------------------------------------------
|
---|
10 |
|
---|
11 | 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.
|
---|
12 |
|
---|
13 | 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.
|
---|
14 |
|
---|
15 | Indication:
|
---|
16 | - Now, the tree of your project may be something like that:
|
---|
17 |
|
---|
18 | pacpustutorials
|
---|
19 | |
|
---|
20 | |--> exercises
|
---|
21 | |
|
---|
22 | |--> exercise_1
|
---|
23 | |
|
---|
24 | |--> CMakeLists.txt
|
---|
25 | |--> MessageComponent.h
|
---|
26 | |--> MessageComponent.cpp
|
---|
27 | |
|
---|
28 | |--> exercise_2
|
---|
29 | |
|
---|
30 | |--> CMakeLists.txt
|
---|
31 | |--> AdditionComponent.h
|
---|
32 | |--> AdditionComponent.cpp
|
---|
33 | |
|
---|
34 | |--> build
|
---|
35 | |
|
---|
36 | |--> build_linux.sh
|
---|
37 | |
|
---|
38 | |--> CMakeLists.txt
|
---|
39 |
|
---|
40 |
|
---|
41 |
|
---|
42 | Exercise 2.2: communication of variable size data
|
---|
43 | -----------------------------------------------
|
---|
44 | 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.
|
---|
45 |
|
---|
46 | Build, install and run this new component.
|
---|
47 |
|
---|
48 | Indication :
|
---|
49 | - you can use the QVector class as input/output type.
|
---|
50 |
|
---|
51 |
|
---|
52 |
|
---|
53 | Exercise 2.3: Threaded component
|
---|
54 | --------------------------------
|
---|
55 | 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.
|
---|
56 |
|
---|
57 | Build, install and run this new component.
|
---|
58 |
|
---|
59 | Indication :
|
---|
60 | - Your component must inherit from the QThread class.
|
---|
61 | - Take care of the protection of the data to guarantee a thread safe execution.
|
---|
62 |
|
---|
63 |
|
---|
64 |
|
---|