@ECHO OFF
REM ATESYNCD.BAT - ATE Sync with diagnostic pauses (8.3 name)
REM Version: 1.1 - Debug version for recording boot process
REM Last modified: 2026-01-21
REM
REM This version pauses at each step for video recording
REM Usage: ATESYNCD TS-3R

IF NOT "%1"=="" SET MACHINE=%1
IF "%MACHINE%"=="" GOTO NO_MACHINE

ECHO.
ECHO ==============================================================
ECHO DEBUG MODE: ATESYNCD
ECHO ==============================================================
ECHO.
ECHO STEP 0: Machine name set
ECHO MACHINE = %MACHINE%
ECHO.
ECHO Press any key to continue to Step 1...
PAUSE

REM Verify T: drive
ECHO.
ECHO ==============================================================
ECHO STEP 1: Checking T: drive
ECHO ==============================================================
IF NOT EXIST T:\*.* GOTO NO_DRIVE
ECHO T: drive is accessible
ECHO.
ECHO Press any key to continue to Step 2...
PAUSE

REM Check machine folder
ECHO.
ECHO ==============================================================
ECHO STEP 2: Checking machine folder T:\%MACHINE%
ECHO ==============================================================
IF NOT EXIST T:\%MACHINE%\*.* GOTO CREATE_MACHINE
ECHO Machine folder exists
ECHO.
ECHO Press any key to continue to Step 3...
PAUSE
GOTO START_SYNC

:CREATE_MACHINE
ECHO Machine folder not found - creating...
MD T:\%MACHINE%
IF NOT EXIST T:\%MACHINE%\*.* GOTO MACHINE_ERROR
MD T:\%MACHINE%\LOGS
MD T:\%MACHINE%\LOGS\5BLOG
MD T:\%MACHINE%\LOGS\7BLOG
MD T:\%MACHINE%\LOGS\8BLOG
MD T:\%MACHINE%\LOGS\DSCLOG
MD T:\%MACHINE%\LOGS\HVLOG
MD T:\%MACHINE%\LOGS\PWRLOG
MD T:\%MACHINE%\LOGS\SCTLOG
MD T:\%MACHINE%\LOGS\VASLOG
MD T:\%MACHINE%\ProdSW
MD T:\%MACHINE%\Reports
ECHO Machine folder structure created
ECHO.
ECHO Press any key to continue to Step 3...
PAUSE

:START_SYNC
ECHO.
ECHO ==============================================================
ECHO STEP 3: Starting CTONWD (Upload test results)
ECHO ==============================================================
ECHO About to call: CTONWD.BAT
ECHO.
ECHO Press any key to run CTONWD...
PAUSE
CALL CTONWD.BAT
ECHO.
ECHO CTONWD completed
ECHO.
ECHO Press any key to continue to Step 4...
PAUSE

ECHO.
ECHO ==============================================================
ECHO STEP 4: Starting NWTOCD (Download updates)
ECHO ==============================================================
ECHO About to call: NWTOCD.BAT
ECHO.
ECHO Press any key to run NWTOCD...
PAUSE
CALL NWTOCD.BAT
ECHO.
ECHO NWTOCD completed
ECHO.
ECHO Press any key to finish...
PAUSE

ECHO.
ECHO ==============================================================
ECHO ATESYNCD Complete: %MACHINE%
ECHO ==============================================================
ECHO.
GOTO END

:NO_MACHINE
ECHO.
ECHO ==============================================================
ECHO ERROR at STEP 0: MACHINE not set
ECHO ==============================================================
ECHO.
ECHO Usage: ATESYNCD TS-3R
PAUSE
GOTO END

:NO_DRIVE
ECHO.
ECHO ==============================================================
ECHO ERROR at STEP 1: T: drive not available
ECHO ==============================================================
PAUSE
GOTO END

:MACHINE_ERROR
ECHO.
ECHO ==============================================================
ECHO ERROR at STEP 2: Could not create machine folder
ECHO ==============================================================
PAUSE
GOTO END

:END
