Commit b62a10c7 authored by Jussi Lindgren's avatar Jussi Lindgren

applications/tools/convert:

 + Added a new stream conversion tool from Loic Mahe (with minor code cleanup).
git:
 * Added .swp and ~ files to .gitignore
 * .sh-base and .cmd-base files will now have proper line endings
parent 7a83bece
# Auto detect text files and perform LF normalization
* text=auto
*.cmd text eol=crlf
*.nsi text eol=crlf
*.cmd text eol=crlf
*.cmd-base text eol=crlf
*.nsi text eol=crlf
*.m text eol=lf
*.sh text eol=lf
*.m text eol=lf
*.sh text eol=lf
*.sh-base text eol=lf
scripts/linux* text eol=lf
......@@ -2,4 +2,6 @@ local-tmp
dependencies
scripts/win32-dependencies.cmd
dist
*~
*.swp
# Add all the subdirs as projects of the named branch
OV_ADD_PROJECTS("APPLICATIONS_TOOLS")
PROJECT(openvibe-convert)
SET(PROJECT_VERSION_MAJOR ${OV_GLOBAL_VERSION_MAJOR})
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_TARGET(openvibe-convert SOURCES
CMakeLists.txt src/openvibe-convert-real.cmd-base src/openvibe-convert-real.sh-base)
ADD_DEPENDENCIES(openvibe-convert openvibe-designer openvibe-plugins-file-io)
# ----------------------
# Generate launch script
# ----------------------
IF(WIN32)
SET(OV_EXTENSION "cmd")
ENDIF(WIN32)
IF(UNIX)
SET(OV_EXTENSION "sh")
ENDIF(UNIX)
# Create the actual script thats run
CONFIGURE_FILE(src/openvibe-convert-real.${OV_EXTENSION}-base ${CMAKE_CURRENT_BINARY_DIR}/openvibe-convert-real.${OV_EXTENSION} @ONLY)
# Required for OV_INSTALL_LAUNCH_SCRIPT
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES LOCATION openvibe-convert-real.${OV_EXTENSION})
# -----------------------------
# Install files
# -----------------------------
# This will call the actual script
OV_INSTALL_LAUNCH_SCRIPT("openvibe-convert")
INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/openvibe-convert-real.${OV_EXTENSION} DESTINATION ${CMAKE_INSTALL_FULL_BINDIR})
INSTALL(DIRECTORY share/ DESTINATION ${CMAKE_INSTALL_FULL_DATADIR}/openvibe/applications/convert PATTERN ".svn" EXCLUDE)
......@@ -92,7 +92,7 @@
<TypeIdentifier>(0x330306dd, 0x74a95f98)</TypeIdentifier>
<Name>Filename</Name>
<DefaultValue></DefaultValue>
<Value>${SourceFile}</Value>
<Value>$ENV{OV_CONVERT_SRC}</Value>
</Setting>
</Settings>
<Attributes>
......@@ -208,7 +208,7 @@
<TypeIdentifier>(0x330306dd, 0x74a95f98)</TypeIdentifier>
<Name>Filename</Name>
<DefaultValue>record-[$core{date}-$core{time}].csv</DefaultValue>
<Value>${DestinationFile}</Value>
<Value>$ENV{OV_CONVERT_DEST}</Value>
</Setting>
<Setting>
<TypeIdentifier>(0x79a9edeb, 0x245d83fc)</TypeIdentifier>
......@@ -387,4 +387,4 @@
<NumChildren>0</NumChildren>
</VisualisationWidget>
</VisualisationTree>
</OpenViBE-Scenario>
\ No newline at end of file
</OpenViBE-Scenario>
......@@ -23,7 +23,7 @@
<TypeIdentifier>(0x330306dd, 0x74a95f98)</TypeIdentifier>
<Name>Filename</Name>
<DefaultValue>record-[$core{date}-$core{time}].edf</DefaultValue>
<Value>${DestinationFile}</Value>
<Value>$ENV{OV_CONVERT_DEST}</Value>
</Setting>
</Settings>
<Attributes>
......@@ -80,7 +80,7 @@
<TypeIdentifier>(0x330306dd, 0x74a95f98)</TypeIdentifier>
<Name>Filename (header)</Name>
<DefaultValue></DefaultValue>
<Value>${SourceFile}</Value>
<Value>$ENV{OV_CONVERT_SRC}</Value>
</Setting>
<Setting>
<TypeIdentifier>(0x512a166f, 0x5c3ef83f)</TypeIdentifier>
......@@ -398,4 +398,4 @@
<NumChildren>0</NumChildren>
</VisualisationWidget>
</VisualisationTree>
</OpenViBE-Scenario>
\ No newline at end of file
</OpenViBE-Scenario>
@ECHO OFF
REM This script is intended to be called via the launch script setting the environment properly
set Extension=%~x1
REM remove the dot before the extension
set Extension=%Extension:~1%
set DestinationExtension=%~x2
set DestinationExtension=%DestinationExtension:~1%
setlocal EnableDelayedExpansion
set FormatFrom=(dat vhdr csv gdf ov)
set FormatTo=(csv gdf edf ov)
rem count arguments
set argC=0
for %%x in (%*) do Set /A argC+=1
if not %argC% == 2 (
echo Usage: openvibe-convert [sourceFile] [destinationFile]
echo.
echo Converts stream files from source to dest.
echo Formats of the files are discovered from the file extensions.
echo.
echo Supported sources are "%FormatFrom%"
echo Supported destinations are "%FormatTo%"
echo.
pause
GOTO:EOF
)
if %Extension%==~1 (
echo File extension not found from source filename "%1".
pause
GOTO:EOF
)
if %DestinationExtension%==~1 (
echo File extension not found from destination filename "%2".
pause
GOTO:EOF
)
set From=false
set /a i=0
set From=false
for %%x in %FormatFrom% do (
if %%x==%Extension% (
set From=true
)
)
set To=false
for %%x in %FormatTo% do (
if %%x==%DestinationExtension% (
set To=true
)
)
if %From%==false (
echo 'There is no reader box for the .%Extension% format in openvibe'
goto:EOF
)
if %To%==false (
echo 'There is no writer box for the .%DestinationExtension% format in openvibe'
goto:EOF
)
set "ScenarioFolder=%OV_PATH_DATA%\applications\convert\"
set "ScenarioToOpen=%Extension%2%DestinationExtension%.xml"
set OV_CONVERT_SRC=%1
set OV_CONVERT_DEST=%2
REM launch designer
REM echo %OV_PATH_BIN%\openvibe-designer --no-gui --no-session-management --play-fast !ScenarioFolder!!ScenarioToOpen!
%OV_PATH_BIN%\openvibe-designer --no-gui --no-session-management --play-fast !ScenarioFolder!!ScenarioToOpen!
endlocal
#!/bin/bash
# This script is intended to be called via the launch script setting the environment properly
LOCAL_BIN_PATH="@CMAKE_INSTALL_FULL_BINDIR@"
if [ "$OV_PATH_BIN" != "" ]; then
LOCAL_BIN_PATH="$OV_PATH_BIN"
fi
LOCAL_LIB_PATH="@CMAKE_INSTALL_FULL_LIBDIR@"
if [ "$OV_PATH_LIB" != "" ]; then
LOCAL_LIB_PATH="$OV_PATH_LIB"
fi
LOCAL_DATA_PATH="@CMAKE_INSTALL_FULL_DATADIR@/openvibe"
if [ "$OV_PATH_DATA" != "" ]; then
LOCAL_DATA_PATH="$OV_PATH_DATA"
fi
FormatFrom=( "dat" "vhdr" "csv" "gdf" "ov" )
FormatTo=( "csv" "edf" "gdf" "ov" )
if [ $[$BASH_ARGC] != 2 ]; then
echo Usage: openvibe-convert [sourceFile] [destinationFile]
echo
echo Converts stream files from source to dest.
echo File formats are discovered from the file extensions.
echo
echo Supported sources: ${FormatFrom[@]}
echo Supported destinations: ${FormatTo[@]}
exit 1
fi
#get the extension
Extension="${1##*.}";
DestinationExtension="${2##*.}";
if [ $Extension == $1 ] ; then
echo No file extension found in filename "$1"
exit 1
fi
if [ $DestinationExtension == $2 ] ; then
echo No file extension found in filename "$2"
exit 1
fi
#check if the source format is valid
From=false
for x in "${FormatFrom[@]}"; do
if [ "$Extension" == "$x" ]; then
From=true
fi
done
if [ $From == false ]; then
echo "There is no reader box for the ."$Extension" format in openvibe"
exit 1
fi
#check if the destination format is valid
To=false
for x in "${FormatTo[@]}"; do
if [ "$DestinationExtension" == "$x" ]; then
To=true
fi
done
if [ $To == false ]; then
echo "There is no writer box for the ."$DestinationExtension" format in openvibe"
exit 1
fi
if [ $From ] && [ $To ]; then
ScenarioFolder="$LOCAL_DATA_PATH/applications/convert/"
ScenarioToOpen=$Extension"2"$DestinationExtension".xml"
#get the files path to the scenario
export OV_CONVERT_SRC=$1
export OV_CONVERT_DEST=$2
#launch designer
$LOCAL_BIN_PATH/openvibe-designer --no-gui --no-session-management --play-fast $ScenarioFolder$ScenarioToOpen
fi
This diff is collapsed.
SourceFile = \nDestinationFile = \nSourceFile = \nDestinationFile = \nSourceFile = \nDestinationFile = \n
\ No newline at end of file
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