Skip to content
This repository has been archived by the owner on Aug 5, 2022. It is now read-only.

GettingStarted

gdenneul edited this page Nov 25, 2014 · 3 revisions

Getting started with the Parameter-framework

In this tutorial of 10 minutes, we will build all the required sources needed to run a simple example.

Get the sources

First of all, let's get the sources:

git clone https://github.com/01org/parameter-framework.git

For this example, we also need the filesystem plugin:

git clone https://github.com/01org/parameter-framework-plugins-filesystem.git

Building the sources and installing

Parameter framework core

As written in the README, you have to build the parameter framework core. During this tutorial, we assume you want to install it in /home/user/pfw_installed/

So, let's run cmake:

cmake -DCMAKE_INSTALL_PREFIX=/home/user/pfw_installed

Now lets build and install:

make && make install

Filesystem plugin

Now that we have built the core, we can build the filesystem plugin needed for our example:

cmake -DCMAKE_PREFIX_PATH=/home/user/pfw_installed -DCMAKE_INSTALL_PREFIX=/home/user/pfw_installed .

Now lets build and install:

make && make install

Add the install directory to your PATH

In order to be able to run the commands you have just installed, add the following to your PATH variable.

PATH="${PATH}:/home/user/pfw_installed/bin/"

It is required that the different commands know the library path as well. Give that information to your system via the LD_LIBRARY_PATH variable.

LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/home/user/pfw_installed/lib/"

Run the test-platform

Now that you have built everything you need, you should be able to run our example. Clone the example configuration:

git clone https://github.com/01org/parameter-framework-samples.git

Now that you have the example files, install them using cmake:

cd parameter-framework-samples
cmake -DCMAKE_PREFIX_PATH=/home/user/pfw_installed -DCMAKE_INSTALL_PREFIX=/home/user/pfw_example .
make && make install

Those sample .xml files contain the configuration required to run the example. Note that we are not going to take a look at the .xml files in this tutorial. This will be the topic of the second tutorial

After that, you should be able to run your virtual platform:

test-platform ~/pfw_example/ParameterFrameworkConfiguration.xml

It is now listening on a socket to receive some commands, giving no initial output. Note that you must give a path to the test-platform program.

Run the remote-process

Since the test-platform is started, we can now attempt to communicate with it thanks to the remote-process program. Run remote process with the following arguments:

remote-process localhost 5001 createExclusiveSelectionCriterionFromStateList Mood mad sad glad
# Done
remote-process localhost 5001 start
# Done

You just created a criterion via the command line! The parameter-framework is configured to behave in certain ways based on criteria such as the Mood we specified.

Note that you can list all available commands by passing help to the remote-process program.

The system in short

The example is just for illustrating a simple set of rules we can handle with the parameter framework. It handles the current playlist based on the user's mood. Here is the structure of our example system:

  • My library
    • artists
      • Beethoven
      • Black Sabbath
      • Explosions in the Sky
      • Iron Maiden

We want the system to include / exclude artists from the current playlist based on the user's mood:

  • If the user is sad, he wants to listen to Post-rock music (Explosions in the Sky)
  • If the user is mad, he wants to listen to Heavy-metal music (Iron Maiden or Black Sabbath)
  • If the user is glad, he wants to listen to Classical music (Beethoven)

For the sake of simplicity, each artist is represented by a file which contains his state regarding the current playlist.

Here is an overview of the system:

The files are re-written each time we change the user's mood.

View the state of our system

So, everything is launched. Let's have a look at our system and it current state.

remote-process localhost 5000 listCriteria
# Mood:
# =====
# Possible states (Exclusive): {glad, mad, sad, sleepy}
# Current state = mad

So our mood is mad What impact does it haves on the music genre?

remote-process localhost 5000 dumpDomains
# - ConfigurableDomains: MusicLibrary
#     - ConfigurableDomain: Genre = {Sequence aware: no, Last applied configuration: Heavy-metal}
#         - Configuration: Heavy-metal
#             - CompoundRule = All
#                 - SelectionCriterionRule = Mood Is mad
#         - Configuration: Classical
#             - CompoundRule = All
#                 - SelectionCriterionRule = Mood Is glad
#         - Configuration: Post-rock
#             - CompoundRule = All
#                 - SelectionCriterionRule = Mood Is sad

For example, if our mood is glad (specified by the test-platform), we want to listen to the Classical genre.

We can check which artists are included from the playlist and which are included with the following command:

grep '.' ~/pfw_example/libraries/*
# /home/user/pfw_example/libraries/beethoven:Included
# /home/user/pfw_example/libraries/blackSabbath:Excluded
# /home/user/pfw_example/libraries/explosionInTheSky:Excluded
# /home/user/pfw_example/libraries/ironMaiden:Excluded

Change a criterion

Now what happens if we change the Mood criterion?

remote-process localhost 5001 setCriterionState Mood glad
# Done
remote-process localhost 5001 applyConfigurations
# Done

Lets have a look:

grep '.' ~/pfw_example/libraries/*
# /home/user/pfw_example/libraries/beethoven:Included
# /home/user/pfw_example/libraries/blackSabbath:Excluded
# /home/user/pfw_example/libraries/explosionInTheSky:Excluded
# /home/user/pfw_example/libraries/ironMaiden:Excluded

As expected, Beethoven is now included into the playlist.