author: Gerald Dherbomez copyright: Heudiasyc UMR UTC/CNRS 7253 Exercise 2: Managing the communication of components together ------------------------------------------------------------- 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 | |--> exercises | |--> exercise_1 | |--> CMakeLists.txt |--> MessageComponent.h |--> MessageComponent.cpp | |--> 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.