@ECHO OFF
REM ===============================================================================
REM GRIFO_M_PBIT - Simulation Mode Launcher (Simple Version)
REM ===============================================================================
REM 
REM This script uses the Python wrapper to execute the test in simulation mode.
REM It can use any available Python 3.7+ interpreter (system or embedded).
REM 
REM Usage:
REM   run_simulate_simple.bat
REM 
REM ===============================================================================

SETLOCAL

SET SCRIPT_DIR=%~dp0
SET WRAPPER=%SCRIPT_DIR%python_simulate_wrapper.py

ECHO ===============================================================================
ECHO GRIFO M-PBIT Test - Simulation Mode (Simple Launcher)
ECHO ===============================================================================
ECHO.

REM Check if wrapper exists
IF NOT EXIST "%WRAPPER%" (
    ECHO [ERROR] Python wrapper not found: %WRAPPER%
    GOTO ERROR_EXIT
)

ECHO [OK] Found wrapper: python_simulate_wrapper.py
ECHO.
ECHO Detecting Python interpreter...
ECHO.

REM Try to use Python
python --version >NUL 2>&1
IF %ERRORLEVEL% EQU 0 (
    ECHO [OK] Using system Python
    python "%WRAPPER%"
    SET EXIT_CODE=%ERRORLEVEL%
) ELSE (
    REM Try python3
    python3 --version >NUL 2>&1
    IF %ERRORLEVEL% EQU 0 (
        ECHO [OK] Using python3
        python3 "%WRAPPER%"
        SET EXIT_CODE=%ERRORLEVEL%
    ) ELSE (
        ECHO [ERROR] No Python interpreter found in PATH
        ECHO [ERROR] Please install Python 3.7+ or add it to PATH
        GOTO ERROR_EXIT
    )
)

ECHO.
ECHO ===============================================================================
IF %EXIT_CODE% EQU 0 (
    ECHO [OK] Test completed successfully
    COLOR 2F
) ELSE (
    ECHO [ERROR] Test failed with exit code: %EXIT_CODE%
    COLOR 4F
)
ECHO ===============================================================================
ECHO.

ECHO Press any key to exit...
PAUSE >NUL
COLOR
ENDLOCAL
EXIT /B %EXIT_CODE%

:ERROR_EXIT
ECHO.
ECHO ===============================================================================
ECHO [ERROR] Cannot execute test - see messages above
ECHO ===============================================================================
ECHO.
COLOR 4F
ECHO Press any key to exit...
PAUSE >NUL
COLOR
ENDLOCAL
EXIT /B 1
