@echo off setlocal & pushd :: StartKLVBroadcast.cmd, 07 April 2003 :: For use with the Predator KLV Situational Awareness Server (KLVBroadcast.exe) :: by Justin Mercier (justin.f.mercier@boeing.com) :: Boeing Autometric :: This script will call klvbroadcast with appropriate command line args and will :: also create an archive telemetry file. :: USAGE :: CLA 1 is the COM port, i.e. COM1 :: CLA 2 is the network port, i.e. 5002 :: CLA 3 is an optional name for the feed which will be used in naming the archive file :: check for CLAs if {%1} EQU {} ( echo No arguments passed! Using defaults! set DRDCOMPORT=COM1 ) ELSE ( set DRDCOMPORT=%1 ) if {%2} EQU {} ( echo No port specified, using default value of 5002 set PORT=5002 ) ELSE ( set PORT=%2 ) if {%3} EQU {} ( set FEED=%DRDCOMPORT% ) ELSE ( set FEED=%3 ) :: Set nice looking window title title Predator Situational Awareness Server - %FEED% on %COMPUTERNAME% - Do not Close! :: Grab date and time and set respective vars FOR /f "tokens=2-4 delims=/ " %%a in ('DATE/T') do SET DATE=%%c-%%a-%%b FOR /f "tokens=1-2 delims=: " %%a in ('TIME/T') do SET time=%%a%%b if %time% LEQ 999 set time=0%time% set datetime=%date%-%time% :: Set the Predator capture directory for the telemetry archive file if not defined EDEN_ROOT set EDEN_ROOT=%DBC_ROOT% if not defined EDEN_ROOT set EDEN_ROOT=. set capdir=%EDEN_ROOT%\etc\Predator if NOT EXIST "%capdir%" MKDIR "%capdir%" :: set archive file name and avoid clobber :makefilename set capfile=%capdir%\Predator_%datetime%_%FEED%.txt if exist "%capfile%" ( if not defined APPEND set APPEND=0 call :APPEND goto :makefilename ) :: clean up zero length files from previous sessions for /f "tokens=1-4" %%a in ('dir /-C "%capdir%" ^| findstr /i Predator_') do call :zerohandle %%c %%d :: Call the app with CLAs. Check that the working directory be properly set :: in the shortcut that calls this script or set here. Type 'klvbroadcast' for usage details. if not exist klvbroadcast.exe ( cd /d "%EDEN_ROOT%"\bin if not exist klvbroadcast.exe ( echo Cannot find klvbroadcast.exe, please set in calling app or in this script. Exitting... endlocal & popd & exit 1 ) ) klvbroadcast -u tcp %PORT% drd %DRDCOMPORT% datastream "%capfile%" :: Insert pause to readout any output if klvbroadcast terminates and exit pause endlocal & popd & exit 0 :: the zero handle call function that deletes zero length files :zerohandle if {%1} EQU {0} del /Q "%capdir%\"%2 >nul goto :EOF :: the append call function that increments the file name, used to break the loop and force variable expansion :APPEND set APPEND+=1 set FEED=%FEED%_%APPEND% goto :EOF :: if we get this far, something is really wrong as we should have exitted through a branch by this point. echo Reached end of script.... ???? pause endlocal & popd & exit 1