Files
geutebruck/geutebruck-api/start-services.ps1
Administrator a92b909539 feat: GeViScope SDK integration with C# Bridge and Flutter app
- Add GeViScope Bridge (C# .NET 8.0) on port 7720
  - Full SDK wrapper for camera control, PTZ, actions/events
  - 17 REST API endpoints for GeViScope server interaction
  - Support for MCS (Media Channel Simulator) with 16 test channels
  - Real-time action/event streaming via PLC callbacks

- Add GeViServer Bridge (C# .NET 8.0) on port 7710
  - Integration with GeViSoft orchestration layer
  - Input/output control and event management

- Update Python API with new routers
  - /api/geviscope/* - Proxy to GeViScope Bridge
  - /api/geviserver/* - Proxy to GeViServer Bridge
  - /api/excel/* - Excel import functionality

- Add Flutter app GeViScope integration
  - GeViScopeRemoteDataSource with 17 API methods
  - GeViScopeBloc for state management
  - GeViScopeScreen with PTZ controls
  - App drawer navigation to GeViScope

- Add SDK documentation (extracted from PDFs)
  - GeViScope SDK docs (7 parts + action reference)
  - GeViSoft SDK docs (12 chunks)

- Add .mcp.json for Claude Code MCP server config

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-19 08:14:17 +01:00

208 lines
10 KiB
PowerShell

# Start Geutebruck API Services
# This script starts GeViServer, C# Bridge, GeViScope Bridge, SDK Bridge, Python API, and Flutter Web App
$ErrorActionPreference = "Stop"
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "Starting Geutebruck API Services" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
# Paths
$geviServerExe = "C:\GEVISOFT\GeViServer.exe"
$geviServerBridgePath = "C:\DEV\COPILOT\geviserver-bridge\GeViServerBridge\bin\Debug\net8.0"
$geviServerBridgeExe = "$geviServerBridgePath\GeViServerBridge.exe"
$geviScopeBridgePath = "C:\DEV\COPILOT\geviscope-bridge\GeViScopeBridge\bin\Debug\net8.0\win-x86"
$geviScopeBridgeExe = "$geviScopeBridgePath\GeViScopeBridge.exe"
$sdkBridgePath = "C:\DEV\COPILOT\geutebruck-api\src\sdk-bridge\GeViScopeBridge\bin\Release\net8.0"
$sdkBridgeExe = "$sdkBridgePath\GeViScopeBridge.exe"
$apiPath = "C:\DEV\COPILOT\geutebruck-api\src\api"
$venvPython = "C:\DEV\COPILOT\geutebruck-api\.venv\Scripts\python.exe"
$uvicorn = "C:\DEV\COPILOT\geutebruck-api\.venv\Scripts\uvicorn.exe"
$flutterWebPath = "C:\DEV\COPILOT\geutebruck_app\build\web"
# Function to wait for port to be listening
function Wait-ForPort {
param(
[int]$Port,
[int]$TimeoutSeconds = 60
)
$elapsed = 0
while ($elapsed -lt $TimeoutSeconds) {
$connection = Get-NetTCPConnection -LocalPort $Port -State Listen -ErrorAction SilentlyContinue
if ($connection) {
return $true
}
Start-Sleep -Seconds 2
$elapsed += 2
Write-Host "." -NoNewline -ForegroundColor Gray
}
return $false
}
# Check if already running
$geviServerRunning = Get-Process -Name "GeViServer" -ErrorAction SilentlyContinue
$geviServerBridgeRunning = Get-Process -Name "GeViServerBridge" -ErrorAction SilentlyContinue
$geviScopeBridgeRunning = Get-NetTCPConnection -LocalPort 7720 -State Listen -ErrorAction SilentlyContinue
$sdkBridgeRunning = Get-Process -Name "GeViScopeBridge" -ErrorAction SilentlyContinue
$uvicornRunning = Get-Process -Name "uvicorn" -ErrorAction SilentlyContinue
$flutterRunning = Get-NetTCPConnection -LocalPort 8081 -State Listen -ErrorAction SilentlyContinue
# Start GeViServer
if ($geviServerRunning) {
Write-Host "[SKIP] GeViServer is already running (PID: $($geviServerRunning.Id))" -ForegroundColor Yellow
} else {
Write-Host "[1/6] Starting GeViServer..." -ForegroundColor Green
Start-Process -FilePath $geviServerExe -ArgumentList "console" -WorkingDirectory "C:\GEVISOFT" -WindowStyle Hidden
# Wait for GeViServer to start listening on port 7700
Write-Host " Waiting for GeViServer to initialize" -NoNewline -ForegroundColor Gray
if (Wait-ForPort -Port 7700 -TimeoutSeconds 60) {
Write-Host ""
$process = Get-Process -Name "GeViServer" -ErrorAction SilentlyContinue
Write-Host " [OK] GeViServer started (PID: $($process.Id))" -ForegroundColor Green
} else {
Write-Host ""
Write-Host " [ERROR] GeViServer failed to start listening on port 7700" -ForegroundColor Red
exit 1
}
}
# Start C# GeViServer Bridge (handles 32-bit DLL communication)
if ($geviServerBridgeRunning) {
Write-Host "[SKIP] C# GeViServer Bridge is already running (PID: $($geviServerBridgeRunning.Id))" -ForegroundColor Yellow
} else {
Write-Host "[2/6] Starting C# GeViServer Bridge..." -ForegroundColor Green
Start-Process -FilePath $geviServerBridgeExe `
-ArgumentList "--urls", "http://localhost:7710" `
-WorkingDirectory $geviServerBridgePath `
-WindowStyle Hidden
# Wait for C# Bridge to start listening on port 7710
Write-Host " Waiting for C# Bridge to initialize" -NoNewline -ForegroundColor Gray
if (Wait-ForPort -Port 7710 -TimeoutSeconds 20) {
Write-Host ""
$process = Get-Process -Name "GeViServerBridge" -ErrorAction SilentlyContinue
Write-Host " [OK] C# Bridge started (PID: $($process.Id))" -ForegroundColor Green
} else {
Write-Host ""
Write-Host " [ERROR] C# Bridge failed to start listening on port 7710" -ForegroundColor Red
exit 1
}
}
# Start GeViScope Bridge (camera server SDK)
if ($geviScopeBridgeRunning) {
$geviScopeProcess = Get-NetTCPConnection -LocalPort 7720 -State Listen -ErrorAction SilentlyContinue |
Select-Object -First 1 -ExpandProperty OwningProcess
Write-Host "[SKIP] GeViScope Bridge is already running (PID: $geviScopeProcess)" -ForegroundColor Yellow
} else {
Write-Host "[3/6] Starting GeViScope Bridge..." -ForegroundColor Green
Start-Process -FilePath $geviScopeBridgeExe -WorkingDirectory $geviScopeBridgePath -WindowStyle Hidden
# Wait for GeViScope Bridge to start listening on port 7720
Write-Host " Waiting for GeViScope Bridge to initialize" -NoNewline -ForegroundColor Gray
if (Wait-ForPort -Port 7720 -TimeoutSeconds 20) {
Write-Host ""
$geviScopeProcess = Get-NetTCPConnection -LocalPort 7720 -State Listen -ErrorAction SilentlyContinue |
Select-Object -First 1 -ExpandProperty OwningProcess
Write-Host " [OK] GeViScope Bridge started (PID: $geviScopeProcess)" -ForegroundColor Green
} else {
Write-Host ""
Write-Host " [WARN] GeViScope Bridge failed to start on port 7720 (optional)" -ForegroundColor Yellow
}
}
# Start SDK Bridge (gRPC)
if ($sdkBridgeRunning) {
Write-Host "[SKIP] SDK Bridge is already running (PID: $($sdkBridgeRunning.Id))" -ForegroundColor Yellow
} else {
Write-Host "[4/6] Starting SDK Bridge..." -ForegroundColor Green
if (Test-Path $sdkBridgeExe) {
Start-Process -FilePath $sdkBridgeExe -WorkingDirectory $sdkBridgePath -WindowStyle Hidden
# Wait for SDK Bridge to start listening on port 50051
Write-Host " Waiting for SDK Bridge to connect" -NoNewline -ForegroundColor Gray
if (Wait-ForPort -Port 50051 -TimeoutSeconds 30) {
Write-Host ""
$process = Get-Process -Name "GeViScopeBridge" -ErrorAction SilentlyContinue
Write-Host " [OK] SDK Bridge started (PID: $($process.Id))" -ForegroundColor Green
} else {
Write-Host ""
Write-Host " [WARN] SDK Bridge failed to start on port 50051 (optional)" -ForegroundColor Yellow
}
} else {
Write-Host " [SKIP] SDK Bridge executable not found (optional)" -ForegroundColor Yellow
}
}
# Start Python API
if ($uvicornRunning) {
Write-Host "[SKIP] Python API is already running (PID: $($uvicornRunning.Id))" -ForegroundColor Yellow
} else {
Write-Host "[5/6] Starting Python API..." -ForegroundColor Green
# Clean Python cache to ensure fresh code load
Get-ChildItem -Path $apiPath -Recurse -Directory -Filter __pycache__ -ErrorAction SilentlyContinue | Remove-Item -Recurse -Force -ErrorAction SilentlyContinue
Start-Process -FilePath $uvicorn `
-ArgumentList "main:app", "--host", "0.0.0.0", "--port", "8000" `
-WorkingDirectory $apiPath `
-WindowStyle Hidden
# Wait for API to start listening on port 8000
Write-Host " Waiting for API to initialize" -NoNewline -ForegroundColor Gray
if (Wait-ForPort -Port 8000 -TimeoutSeconds 20) {
Write-Host ""
$process = Get-Process -Name "uvicorn" -ErrorAction SilentlyContinue
Write-Host " [OK] Python API started (PID: $($process.Id))" -ForegroundColor Green
} else {
Write-Host ""
Write-Host " [ERROR] Python API failed to start listening on port 8000" -ForegroundColor Red
exit 1
}
}
# Start Flutter Web Server
if ($flutterRunning) {
$flutterProcess = Get-NetTCPConnection -LocalPort 8081 -State Listen -ErrorAction SilentlyContinue |
Select-Object -First 1 -ExpandProperty OwningProcess
Write-Host "[SKIP] Flutter Web is already running (PID: $flutterProcess)" -ForegroundColor Yellow
} else {
Write-Host "[6/6] Starting Flutter Web Server..." -ForegroundColor Green
Start-Process -FilePath "python" `
-ArgumentList "-m", "http.server", "8081", "--bind", "0.0.0.0" `
-WorkingDirectory $flutterWebPath `
-WindowStyle Hidden
# Wait for Flutter Web to start listening on port 8081
Write-Host " Waiting for Flutter Web to initialize" -NoNewline -ForegroundColor Gray
if (Wait-ForPort -Port 8081 -TimeoutSeconds 10) {
Write-Host ""
$flutterProcess = Get-NetTCPConnection -LocalPort 8081 -State Listen -ErrorAction SilentlyContinue |
Select-Object -First 1 -ExpandProperty OwningProcess
Write-Host " [OK] Flutter Web started (PID: $flutterProcess)" -ForegroundColor Green
} else {
Write-Host ""
Write-Host " [ERROR] Flutter Web failed to start listening on port 8081" -ForegroundColor Red
exit 1
}
}
Write-Host ""
Write-Host "========================================" -ForegroundColor Green
Write-Host "Services Started Successfully!" -ForegroundColor Green
Write-Host "========================================" -ForegroundColor Green
Write-Host ""
Write-Host "GeViServer: Running on ports 7700-7703" -ForegroundColor Cyan
Write-Host "C# Bridge: http://localhost:7710 (GeViServer 32-bit adapter)" -ForegroundColor Cyan
Write-Host "GeViScope Bridge: http://localhost:7720 (Camera Server SDK)" -ForegroundColor Cyan
Write-Host "SDK Bridge: Running on port 50051 (gRPC)" -ForegroundColor Cyan
Write-Host "Python API: http://localhost:8000" -ForegroundColor Cyan
Write-Host "Swagger UI: http://localhost:8000/docs" -ForegroundColor Cyan
Write-Host "GeViServer API: http://localhost:8000/docs#/GeViServer" -ForegroundColor Green
Write-Host "GeViScope API: http://localhost:7720 (Direct access)" -ForegroundColor Green
Write-Host "Flutter Web: http://localhost:8081" -ForegroundColor Cyan
Write-Host ""
Write-Host "To check status, run: .\status-services.ps1" -ForegroundColor Yellow
Write-Host "To stop services, run: .\stop-services.ps1" -ForegroundColor Yellow