@echo off
setlocal


rem ### Edit ###
set OUTPUT_FOLDER=%~dp0

set E3DS_COMPONENT=XXX
set TIMEOUT=360


rem ### Do Not Edit ###
set INPUT_FILE_NAME=%1
set SCRIPT_FOLDER=%~dp0..\COMMON

set WORK_DIR=%OUTPUT_FOLDER%\work\%~n1
set RESULTS_DIR=%OUTPUT_FOLDER%\result\%~n1
set DAIMLER_SUPPLIER_SCRIPT=%SCRIPT_FOLDER%\apply_daimler_setting.rb


rem ### SW to PLMXML/JT ###
set OUTPUT_EXT=.jt
set PID=109841
if /i "%~x1" == ".sldasm" (
  set PID=109941
  set OUTPUT_EXT=.plmxml
)
set BASE_FILENAME=%~n1

rem ### elybatch
set ELYBATCH=%E3DS_COMPONENT%\tools\win\elybatch.exe
rem ### files
set CONFIG_FILE=%~dp0daimler_config.cfg
set SCENARIOFILE=%~dp0daimler_scenario.xml
set PARAMETER_FILE=%~dp0daimler_sw_to_plmxml_jt.prm

rem ### environment variables

rem ### mkdir
mkdir %WORK_DIR%
mkdir %RESULTS_DIR%

call :TRANSLATE %INPUT_FILE_NAME%

goto :END


rem *******************************************************
:TRANSLATE

set OUTPUT_FILE_NAME=%RESULTS_DIR%\%BASE_FILENAME%%OUTPUT_EXT%
set LOG_NAME=%WORK_DIR%\%BASE_FILENAME%.log
set XML_LOG_NAME=%BASE_FILENAME%.xml
set SCENARIOLOG=%BASE_FILENAME%_scenario_log.xml

"%ELYBATCH%" -f"%CONFIG_FILE%" -p%PID% -w"%WORK_DIR%" -i%INPUT_FILE_NAME% -o"%OUTPUT_FILE_NAME%" -u"%LOG_NAME%" -X"%XML_LOG_NAME%" -c"%PARAMETER_FILE%" -t%TIMEOUT% -S"%SCENARIOFILE%" -U"%SCENARIOLOG%"

goto :EOF
rem *******************************************************


:END
endlocal
