| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
The following tutorial guides you through an example with the Vector Application Framework (VAF) that illustrates how interfaces from the COVESA Vehicle Signal Specification (VSS) can be derived and used.
Plan in this demo is to develop one executable with two application modules. The example does not use a platform for communication, the app-modules only communicate directly. That means, they share an internal communication channel, which is based on VSS. A high-level illustration of this setup is given below:
First step in this demo is the modeling of interfaces based on datatype and signal descriptions as imported from a catalogue in VSS format. Those interfaces are later used for data exchange between the application modules.
Create a new interface project for that purpose using the VAF command line tool:
vaf project init interface
Enter the name of the project: VssInterfaces
Enter the directory to store your project in: .Next, switch to the just created project directory.
cd VssInterfacesThen, import a VSS data catalogue to the project. The VSS catalogue as provided on GitHub is provided as JSON file and part of the container. It is located in: /opt/vaf/Demo/VssDemo/model/vss/vss.json.
vaf model import vss
Enter the path to the VSS catalogue file in JSON format /opt/vaf/Demo/VssDemo/model/vss/vss.jsonOpen the template file vss_interfaces.py within the newly created interface project. Import the VSS content from the previous step and define the interfaces for this demo using this input:
from .vss import *
acceleration_if = vafpy.ModuleInterface(name="Acceleration_If", namespace="demo")
acceleration_if.add_data_element(name="Lateral", datatype=Vss.Vehicle.Acceleration.lateral)
acceleration_if.add_data_element(name="Longitudinal", datatype=Vss.Vehicle.Acceleration.longitudinal)
acceleration_if.add_data_element(name="Vertical", datatype=Vss.Vehicle.Acceleration.vertical)
driver_if = vafpy.ModuleInterface(name="Driver_If", namespace="demo")
driver_if.add_data_element(name="Identifier", datatype=Vss.Vehicle.Driver.identifier)
driver_if.add_data_element(name="IsEyesOnRoad", datatype=Vss.Vehicle.Driver.is_eyes_on_road)Once complete, the configuration needs to be exported to JSON by using the following command:
vaf model generateThe exported JSON file gets stored to the subdirectory ./export by default, along with its CaC support file for later use in application module projects.
Before the next step, switch folders to the workspace again.
cd ..Create a new integration project using the VAF command line tool:
vaf project init integration
Enter your project name: DemoExecutableNext, switch folders:
cd DemoExecutableAdd two application modules to the project using:
vaf project create app-module
Enter the name of the app-module: VssProvider
Enter the namespace of the app-module: demo
vaf project create app-module
Enter the name of the app-module: VssConsumer
Enter the namespace of the app-module: demoNext, switch folders accordingly:
cd src/application_modules/vss_<consumer/provider>Then, import the outcome from the previously completed Interface project.
vaf project import
Please provide the path to the exported VAF model JSON file ../../../../VssInterfaces/export/VssInterfaces.jsonTwo new files are added to the project folder by this command. VssInterfaces.json is the VAF model file in JSON format. It contains all relevant information as imported from the VSS catalogue. vss_interfaces.py is the Configuration as Code (CaC) support, which is needed to access the model artifacts from the Python configuration.
Next step is the configuration of the app-module in ./model/vss_<consumer/provider>.py.
To import the interfaces from the previous step, write:
from .imported_models import *The app-module configuration template already contains the app-module object and a default task. On top, the interface definitions need to be added.
For the VssConsumer use:
vss_consumer = vafpy.ApplicationModule(name="VssConsumer", namespace="demo")
vss_consumer.add_consumed_interface("AccelerationConsumer", interface=Vss.Vehicle.acceleration_if)
vss_consumer.add_consumed_interface("DriverConsumer", interface=Vss.Vehicle.driver_if)
periodic_task = vafpy.Task(name="PeriodicTask", period=timedelta(milliseconds=200))
vss_consumer.add_task(task=periodic_task)For the VssProvider use:
vss_provider = vafpy.ApplicationModule(name="VssProvider", namespace="demo")
vss_provider.add_provided_interface("AccelerationProvider", interface=Vss.Vehicle.acceleration_if)
vss_provider.add_provided_interface("DriverProvider", interface=Vss.Vehicle.driver_if)
periodic_task = vafpy.Task(name="PeriodicTask", period=timedelta(milliseconds=200))
vss_provider.add_task(task=periodic_task)Continue from here with model and code generation:
vaf project generateSome sample code for the app-modules is provided for reference in: /opt/vaf/Demo/VssDemo/src/vss_<consumer/provider>/vss_<consumer/provider>.cpp. Feel free to copy it to the generated implementation stubs in: ./implementation/src/vss_<consumer/provider>.cpp
Finally, check if the app-module library compiles using:
vaf make buildWith this part completed for both, the VssProvider and the VssConsumer, the final integration on executable-level can be started.
Back in the integration project, plan is to define one executable with one instance of the above-created app-modules each.
Before we can start with the configuration, the changes from the application module projects need to be updated, such that the configuration is available in the integration project. To do so, use the following command and select both app-modules from the selection.
cd <path-to-integration-project>
vaf model updateContinuing with the configuration in ./model/vaf/demo_executable.py, we first define and configure one executable as follows:
executable = Executable("DemoExecutable", timedelta(milliseconds=10))Next, we can directly continue with the step of instantiating and adding app-modules as follows:
executable.add_application_module(VssProvider, [(Instances.VssProvider.Tasks.PeriodicTask, timedelta(milliseconds=1), 0)])
executable.add_application_module(VssConsumer, [(Instances.VssConsumer.Tasks.PeriodicTask, timedelta(milliseconds=1), 1)])The second parameter, allows the definition of an integration-specific task mapping. This includes the task period and execution order and allows the integrator to overrule the original settings from the application module project. In this example, we want the provider to be executed before the consumer.
The two app-modules instances now can be connected as follows:
executable.connect_interfaces(VssProvider, Instances.VssProvider.ProvidedInterfaces.AccelerationProvider,
VssConsumer, Instances.VssConsumer.ConsumedInterfaces.AccelerationConsumer)
executable.connect_interfaces(VssProvider, Instances.VssProvider.ProvidedInterfaces.DriverProvider,
VssConsumer, Instances.VssConsumer.ConsumedInterfaces.DriverConsumer)With this, the configuration part in the integration project is complete. Model and integration code can be generated in one step using:
vaf project generateTo complete the demo, compilation of the executable binary is missing.
vaf make build
vaf make installBefore the binary can be started, the setup.sh script as provided in the top-level folder of the integration project needs to be executed.
source setup.shAfterwards, the binary can be run from the ./build/Release/install/opt/DemoExecutable directory:
./bin/DemoExecutable| Back | FazBrowse Home | New Git URL |