Skip to content

tutorial_component_development

Kynneb edited this page Dec 22, 2017 · 24 revisions

Create a project

After installig ESROCOS, step into the esrocos workspace and source the environment script to provide access to the ESROCOS workflow tools . env.sh. Then call esrocos_create_project with the argument "tutorial_driver" to create your first esrocos component.

esrocos_create_project

Enter dependencies

The ESROCOS project creation workflow starts with an interactive dialogue questioning for some information about you and the project. Most important however is the information on other packages the new project should depend on. For this tutorial our project depends on two packages: types/base and types/core provide the most central ESROCOS data types.

enter dependencies

With that information, the ESROCOS tool will do some processing and will create a project folder together with the first artifacts and files.

esrocos_create_project

Artifacts in the new project

Step into the projects folder you just created and have a look around.

esrocos_create_project

Of all the files, the esrocos.yml is perhaps the most central: In it, you will find all the information you entered during project creation. Here you can add/edit the description of the project as well as the dependencies, the format of the yml structures correspond to the configuration files found in Autoproj, so don't let it confuse you.

esrocos.yml

Fetch dependencies

After every time you edit the esrocos.yml or just after creating a project (like now) you have to call esrocos_fetch_dependencies to let autoproj checkout and install the stated dependencies. Also all data types will be compiled by asn2aadlplus into one <projectname>_dv.aadl file, so the types will be provided to the taste GUI.

Edit project via TASTE-GUI

Next, call esrocos_edit_project to open your project in the TASTE GUI. On the left side under the bullet "dataview" you will find all the data types you imported to the project which are now usable within the TASTE GUI.

On the canvas to the right, create a TASTE function by using the context menu (right click) and choose new function or using the FU button in the toolbar on top. Various settings can be set for the function by right-clicking on it and selecting "edit properties". Rename it to driver and set the source language to C++ (cpp).

create a function

A taste project is made up of functions connected over Required Interfaces (RI) and Provided Interfaces (PI). We begin with adding an PI to our new driver function and editing its properties. A PI is an ingoing connection, in this case it is supposed to be called not from external modules but cyclic to drive our system. We set the period and the other settings to 100ms each.

create a function

  • An RI is an outgoing connection. It can be called from within the function and will call the code of the method it is connected to.

create a function

  • It can be set to expect a parameter to be passed to the receiving function

Create dummy functions

  • at the moment taste cannot generate skeletons for unconnected Interfaces

Generate Skeletons

esrocos_generate_skeletons

There will be a new folder driver with automatically generated driver.cc and driver.h. Also another one for the test function but we can ignore that at this point. The header file normally needs no manipulation.

We edit the code of driver.cc to call the RI method defined in the header:

#include "driver.h"

void driver_startup()
{
    /* Write your initialization code here,
       but do not make any call to a required interface. */
}

void driver_PI_trigger()
{
  driver_RI_trigger_out();    
}

Pack it for reuse

In this tutorial we will not build the project (as it would fulfill no purpose after all) but pack it to be reused later on.

  1. Step out of the fucnction directory into the project folder and pack the source folder: zip driver.zip driver/*

  2. Create a directory to export the function to: mkdir ~/tool-inst/share/components_library/tutorial_driver

Go back to edit mode via esrocos_edit_project:

  1. In the Interface view editor, double-click on the function to edit the properties, right click on Source Text and select the file named "driver.zip" that you just created.

  2. In the Interface View editor, right click on the function and select Export Functions -> Select the folder you just created. It will ask you for an export name: change the default "interfaceview" with "tutorial_driver"

go to your export folder cd ~/tool-inst/share/components_library/tutorial_driver remove the auto-generated dataview aadl file and generate a new one:

rm tutorial_driver_dv.aadl
taste-update-data-view tutorial_driver.asn

Congratulations, you developed a driver component and exported it on your system so it can be reused in future system integration.

Clone this wiki locally