This tutorial illustrates the migration of a server driver from the 0.15 codebase to the 0.16. For a larger overview of changes in 0.16.0 please look at our Migration guide.
Through the tutorial an OLD prefix indicates the 0.15.0 file structure, the NEW prefix is for 0.16.0.
Third party drivers should generally go into the /NEW/contrib
folder. If you want to keep it in the core distribution simply copy the files to /NEW/applications/platform/acquisition-server/src/drivers
and follow the guidelines to fix the header includes.
We are going to illustrate a migration to the /NEW/contrib
folder on the example of the gtec-gusbamp driver.
Copying the files
Currently the files inside the driver are these (do not forget the UI file and possibly other assets in /share):
/OLD/openvibe-applications/acquisition-server/trunc/src: ./gtec-gusbamp/ovasCConfigurationGTecGUSBamp.cpp ./gtec-gusbamp/ovasCConfigurationGTecGUSBamp.h ./gtec-gusbamp/ovasCDriverGTecGUSBamp.cpp ./gtec-gusbamp/ovasCDriverGTecGUSBamp.h /OLD/openvibe-applications/acquisition-server/trunc/share/openvibe-applications/acquisition-server: ./interface-GTec-GUSBamp.ui
We have to copy them to the /NEW/contrib/plugins/server-drivers directory so it looks like this:
/NEW/contrib/plugins/server-drivers: ./share: interface-GTec-GUSBamp.ui ./src: ovasCConfigurationGTecGUSBamp.cpp ovasCConfigurationGTecGUSBamp.h ovasCDriverGTecGUSBamp.cpp ovasCDriverGTecGUSBamp.h
Note that the /src
and /share
folders are now inside the driver. Also there is no substructure under the /share
folder.
Adding the driver to the project
In /NEW/contrib/common
you have to edit these three files:
- contribAcquisitionServer.cmake : This file is included as it is inside the Acquisition Server CMake file BEFORE declaring the executable.
- contribAcquisitionServerLinkLibs.cmake : This file is included as it is in the Acquisition Server CMake file AFTER the executable is declared (so you can add your own dependencies)
- contribAcquisitionServer.inl : This file is added to the header of the ovasCAcquisitionServerGUI.cpp file so you can include and push the drivers into it.
Somewhere at the end of contribAcquisitionServer.cmake add:
OV_ADD_CONTRIB_DRIVER("${CMAKE_SOURCE_DIR}/contrib/plugins/server-drivers/gtec-gusbamp")
Add this line to contribAcquisitionServerLinkLibs.cmake:
INCLUDE("FindThirdPartyGUSBampCAPI")
Add these lines to contribAcquisitionServer.inl:
#if defined TARGET_HAS_ThirdPartyGUSBampCAPI
vDriver->push_back(new OpenViBEAcquisitionServer::CDriverGTecGUSBamp(pAcquisitionServer->getDriverContext()));
#endif
Fix the headers
You can try to compile your code now and it will pick up the new driver. However several headers have moved in the 0.16.0 and you will have to fix the paths before.
The path to the ovasIDriver.h header has changed.
Modify all occurences of:
#include "../ovasIDriver.h"
to:
#include "ovasIDriver.h"
The toolkit has been moved
Modify all occurences of:
#include <openvibe-toolkit/ovtk_all.h>
to:
#include <toolkit/ovtk_all.h>
The /share folder has moved
In order to charge the .ui file correctly you have to use the new member functions of the OpenViBE::Directories
class.
Change the path to your UI file from:
"../share/openvibe-applications/acquisition-server/interface-GTec-GUSBamp.ui"
to:
OpenViBE::Directories::getDataDir() + "/applications/acquisition-server/interface-GTec-GUSBamp.ui"
That is it, now you can compile and your driver will work.