Add offline JSBSim dependencies

This commit is contained in:
moriy
2026-04-28 18:03:19 +08:00
parent 25297601d7
commit 9f8983ab48
6 changed files with 232 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
96159FCB523AE404B707186A75B4104EE23851E476A5E838E14584CF1E03F981 D:\Coding\AS_Test\offline-deps\installers\python-3.13.12-amd64.exe
CA685AE40B7435706A978EB62A619D3F922C502A3340DE5B7CB14363275A8DE4 D:\Coding\AS_Test\offline-deps\wheels\jsbsim-1.3.0-cp313-cp313-win_amd64.whl
5C70F1CC1C4EFBE316A572E2D8B9B9CC44E89B95F79CA3331553FBB63716E2BF D:\Coding\AS_Test\offline-deps\wheels\numpy-2.4.4-cp313-cp313-win_amd64.whl

Binary file not shown.

155
offline-deps/readme.md Normal file
View File

@@ -0,0 +1,155 @@
# Offline JSBSim Environment Setup
This folder contains the offline files needed to run the service JSBSim backend on a Windows x64 machine.
## Included Files
```text
offline-deps/
installers/
python-3.13.12-amd64.exe
wheels/
jsbsim-1.3.0-cp313-cp313-win_amd64.whl
numpy-2.4.4-cp313-cp313-win_amd64.whl
checksums/
SHA256SUMS.txt
python-runtime/
...
venv/
Scripts/
python.exe
```
`python-runtime/` is a project-local Python installation used to create `venv/`.
`venv/` is the runtime environment used by the Node service.
## Fresh Offline Install
Run these commands from the repository root:
```powershell
cd D:\Coding\AS_Test
powershell.exe -ExecutionPolicy Bypass -File .\offline-deps\setup-jsbsim-offline.ps1
```
The script will:
- install the bundled Python runtime into `offline-deps\python-runtime`
- create `venv`
- install JSBSim from `offline-deps\wheels`
- write `service\.env.local`
To force-create `venv` again:
```powershell
powershell.exe -ExecutionPolicy Bypass -File .\offline-deps\setup-jsbsim-offline.ps1 -Force
```
## Manual Install
Run these commands from the repository root:
```powershell
cd D:\Coding\AS_Test
offline-deps\installers\python-3.13.12-amd64.exe /quiet InstallAllUsers=0 TargetDir="%CD%\offline-deps\python-runtime" Include_launcher=0 PrependPath=0 Include_test=0 Include_doc=0 Include_tcltk=0 Include_pip=1
offline-deps\python-runtime\python.exe -m venv venv
.\venv\Scripts\python.exe -m pip install --no-index --find-links offline-deps\wheels jsbsim==1.3.0
```
## Verify Python Packages
```powershell
.\venv\Scripts\python.exe -c "import jsbsim, numpy; print('jsbsim', jsbsim.__version__); print('numpy', numpy.__version__)"
```
Expected versions:
```text
jsbsim 1.3.0
numpy 2.4.4
```
## Run Service With JSBSim Backend
If you used the one-click setup script, it already created `service\.env.local`.
You can start the service directly:
```powershell
cd D:\Coding\AS_Test\service
npm.cmd run start
```
Manual environment setup:
```powershell
cd D:\Coding\AS_Test\service
$env:SIM_BACKEND='jsbsim'
$env:JSBSIM_PYTHON='D:\Coding\AS_Test\venv\Scripts\python.exe'
npm.cmd run start
```
The service URL remains:
```text
http://127.0.0.1:4317
```
## Smoke Test
In a second PowerShell window:
```powershell
Invoke-RestMethod -Uri http://127.0.0.1:4317/health
```
Then test trim:
```powershell
$body = @{
aircraftId = 'c172p-jsbsim'
altitudeM = 1000
speedMps = 50
headingDeg = 0
flightPathAngleDeg = 0
} | ConvertTo-Json -Depth 8
Invoke-RestMethod -Uri http://127.0.0.1:4317/trim -Method Post -ContentType 'application/json' -Body $body
```
Then test straight simulation:
```powershell
$body = @{
aircraftId = 'c172p-jsbsim'
sampleRateHz = 5
durationSec = 1
initialState = @{
position = @(0, 1000, 0)
velocityMps = 50
headingDeg = 0
}
maneuver = @{
type = 'straight'
parameters = @{
flightPathAngleDeg = 0
}
}
} | ConvertTo-Json -Depth 8
Invoke-RestMethod -Uri http://127.0.0.1:4317/simulate -Method Post -ContentType 'application/json' -Body $body
```
## Notes
- The current JSBSim backend supports `straight`, `climb`, and `descent` only.
- `level-turn` is still handled by the mock backend until JSBSim control input scripting is added.
- The current smoke-test aircraft is `c172p-jsbsim`.
- If deploying to a different path, update `JSBSIM_PYTHON` to point at that machine's `venv\Scripts\python.exe`.
- If using custom JSBSim aircraft data instead of the data bundled with the Python wheel, set `JSBSIM_ROOT`.

View File

@@ -0,0 +1,74 @@
param(
[switch]$Force
)
$ErrorActionPreference = "Stop"
$Root = Resolve-Path -LiteralPath (Join-Path $PSScriptRoot "..")
$OfflineDeps = Join-Path $Root "offline-deps"
$ServiceDir = Join-Path $Root "service"
$Installer = Join-Path $OfflineDeps "installers\python-3.13.12-amd64.exe"
$PythonRuntime = Join-Path $OfflineDeps "python-runtime"
$RuntimePython = Join-Path $PythonRuntime "python.exe"
$Venv = Join-Path $Root "venv"
$VenvPython = Join-Path $Venv "Scripts\python.exe"
$Wheels = Join-Path $OfflineDeps "wheels"
$ServiceEnv = Join-Path $ServiceDir ".env.local"
if (!(Test-Path -LiteralPath $ServiceDir)) {
throw "Could not find service directory. Run this script from the AS_Test project layout."
}
if (!(Test-Path -LiteralPath $Installer)) {
throw "Missing Python installer: $Installer"
}
if (!(Test-Path -LiteralPath $Wheels)) {
throw "Missing wheels directory: $Wheels"
}
if ($Force -and (Test-Path -LiteralPath $Venv)) {
Remove-Item -LiteralPath $Venv -Recurse -Force
}
if (!(Test-Path -LiteralPath $RuntimePython)) {
New-Item -ItemType Directory -Force -Path $PythonRuntime | Out-Null
$args = @(
"/quiet",
"InstallAllUsers=0",
"TargetDir=$PythonRuntime",
"Include_launcher=0",
"PrependPath=0",
"Include_test=0",
"Include_doc=0",
"Include_tcltk=0",
"Include_pip=1"
)
$process = Start-Process -FilePath $Installer -ArgumentList $args -Wait -PassThru -WindowStyle Hidden
if ($process.ExitCode -ne 0) {
throw "Python installer failed with exit code $($process.ExitCode)"
}
}
& $RuntimePython --version
if (!(Test-Path -LiteralPath $VenvPython)) {
& $RuntimePython -m venv $Venv
}
& $VenvPython -m pip install --no-index --find-links $Wheels jsbsim==1.3.0
& $VenvPython -c "import jsbsim, numpy; print('jsbsim', jsbsim.__version__); print('numpy', numpy.__version__)"
@"
SIM_BACKEND=jsbsim
JSBSIM_PYTHON=$VenvPython
"@ | Set-Content -LiteralPath $ServiceEnv -Encoding UTF8
Write-Host ""
Write-Host "JSBSim offline environment is ready."
Write-Host "Service env written to: $ServiceEnv"
Write-Host ""
Write-Host "Start service with:"
Write-Host " cd $Root\service"
Write-Host " npm.cmd run start"