@echo off
setlocal
cd /d "%~dp0"

echo ==== 1. check GenServer running ====
tasklist /FI "IMAGENAME eq GenServer.exe" | find /I "GenServer.exe" >nul
if not %errorlevel%==0 echo WARNING GenServer NOT running. Run _restart_test.bat first.

echo ==== 2. check interactive NX ugraf ====
tasklist /FI "IMAGENAME eq ugraf.exe" | find /I "ugraf.exe" >nul
if %errorlevel%==0 goto nx_running

echo ==== 3. start NX worker ====
start "NXworker" /min "C:\Program Files\Siemens\NX2506\NXBIN\run_journal.exe" "%~dp0..\sample-data\tools\worker_journal.vb"
echo.
echo worker started in background. NX cold start 30-90s.
echo Then run _worker_check.bat to see generated STEP.
echo.
goto :eof

:nx_running
echo.
echo !!! interactive NX ugraf is RUNNING.
echo     worker competes for the NX license seat.
echo     Close NX, then re-run this script.
echo.
pause
endlocal
