Commit 9128c120 authored by Serrière Guillaume's avatar Serrière Guillaume

Matlab stimulation File.

Signed-off-by: default avatarSerrière Guillaume <guillaume.serriere@inria.fr>
parent d4620ed9
......@@ -26,3 +26,10 @@ public:
virtual bool appendStimulation(SStimulation &rStim);
virtual bool closeFile(void);
};
class CMatlabGenerator: public CFileGeneratorBase{
public:
virtual bool openFile(const char* sFilename);
virtual bool appendStimulation(SStimulation &rStim);
virtual bool closeFile(void);
};
......@@ -32,13 +32,6 @@ generation_type parse_argument(string option)
}
}
string getBrutHexaCode(string l_oFormatedHexaCode)
{
string res = l_oFormatedHexaCode;
res.erase(res.begin(), res.begin()+2);
return res;
}
int generate_generator_list(vector<CFileGeneratorBase*> & rList, generation_type rType, int argc, char** argv)
{
switch(rType)
......@@ -65,6 +58,15 @@ int generate_generator_list(vector<CFileGeneratorBase*> & rList, generation_type
}
case MATLAB:
{
CFileGeneratorBase* gen = new CMatlabGenerator();
if(!gen->openFile(argv[3])){
cerr << "Unable to open " << argv[3] << endl;
return -1;
}
rList.push_back(gen);
return 0;
}
case PYTHON:
case LUA:
case UNKNOWN:
......
#include "ovbt_sg_defines.h"
#include "ovbt_sg_file_generator_base.h"
#include <fstream>
using namespace std;
string getBrutHexaCode(string l_oFormatedHexaCode)
{
string res = l_oFormatedHexaCode;
res.erase(res.begin(), res.begin()+2);
return res;
}
bool CMatlabGenerator::openFile(const char* sFilename)
{
m_oFile.open(sFilename, ios::out | ios::trunc);
if(!m_oFile.is_open())
return false;
m_oFile << "function OV_stimulations()" << endl << endl;
m_oFile << "global OVTK_StimulationId_LabelStart;"<< endl;
m_oFile << "OVTK_StimulationId_LabelStart = uint64(hex2dec('00008100'));"<< endl << endl;
m_oFile << "global OVTK_StimulationId_LabelEnd;"<< endl;
m_oFile << "OVTK_StimulationId_LabelEnd = uint64(hex2dec('000081ff'));"<< endl << endl;
return true;
}
bool CMatlabGenerator::appendStimulation(SStimulation &rStim)
{
m_oFile << "\tglobal " << rStim.m_sId << ";" << endl;
m_oFile << "\t" << rStim.m_sId << " = uint64(hex2dec('" << getBrutHexaCode(rStim.m_sHexaCode)<< "'));" << endl << endl;
return true;
}
bool CMatlabGenerator::closeFile(void)
{
m_oFile << "end" << endl;
m_oFile.close();
return true;
}
......@@ -5,8 +5,21 @@ SET(PROJECT_VERSION_MINOR ${OV_GLOBAL_VERSION_MINOR})
SET(PROJECT_VERSION_PATCH ${OV_GLOBAL_VERSION_PATCH})
SET(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/share/OV_stimulations.m
DEPENDS openvibe-stimulation-generator ${openvibe-toolkit_SOURCE_DIR}/share/stimulation_list.txt
COMMAND ${stim_generator_path}/openvibe-stimulation-generator
--matlab
${openvibe-toolkit_SOURCE_DIR}/share/stimulation_list.txt
${CMAKE_CURRENT_SOURCE_DIR}/share/OV_stimulations.m
COMMENT "Generating matlab stimulation sources..." )
add_custom_target(generate_matlab_stimulations_file DEPENDS share/OV_stimulations.m)
FILE(GLOB_RECURSE source_files src/*.cpp src/*.h src/*.inl)
ADD_LIBRARY(${PROJECT_NAME} SHARED ${source_files})
add_dependencies(openvibe-plugins-matlab generate_matlab_stimulations_file)
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
......
......@@ -10,7 +10,7 @@ SET(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_
#We need to generate the stimulation files
add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/include/toolkit/ovtk_stimulations.h ${CMAKE_CURRENT_SOURCE_DIR}/src/ovtk_stimulations.cpp
DEPENDS openvibe-stimulation-generator ${CMAKE_CURRENT_SOURCE_DIR}/share/stimulation_list.txt
COMMAND echo `pwd` & ${stim_generator_path}/openvibe-stimulation-generator
COMMAND ${stim_generator_path}/openvibe-stimulation-generator
--cpp
${CMAKE_CURRENT_SOURCE_DIR}/share/stimulation_list.txt
${CMAKE_CURRENT_SOURCE_DIR}/include/toolkit/ovtk_stimulations.h
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment