You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

199 lines
5.3 KiB
Markdown

# Config Reference
Ниже описана структура `config.json` для `service.py`.
Полный пример: [../config.template.json](../config.template.json)
## Корневые блоки
- `model` — параметры радиомодели RSSI -> distance.
- `solver` — параметры решателя пересечения сфер.
- `runtime` — HTTP-порт, polling, защита, выходные серверы.
- `input` — входные ресиверы, источники, фильтры, агрегация.
## model
```json
"model": {
"tx_power_dbm": 20.0,
"tx_gain_dbi": 0.0,
"rx_gain_dbi": 0.0,
"path_loss_exponent": 2.0,
"reference_distance_m": 1.0,
"min_distance_m": 0.001
}
```
- `tx_power_dbm` (float, required)
- `tx_gain_dbi` (float, optional)
- `rx_gain_dbi` (float, optional)
- `path_loss_exponent` (float, optional)
- `reference_distance_m` (float, optional)
- `min_distance_m` (float, optional)
## solver
```json
"solver": {
"tolerance": 0.001,
"z_preference": "positive"
}
```
- `tolerance` (float, optional)
- `z_preference` (`"positive"` | `"negative"`)
## runtime
```json
"runtime": {
"listen_host": "0.0.0.0",
"listen_port": 8081,
"poll_interval_s": 1.0,
"write_api_token": "",
"output_servers": []
}
```
- `listen_host` (string, optional)
- `listen_port` (int, optional)
- `poll_interval_s` (float, optional)
- `write_api_token` (string, optional)
### runtime.output_servers (рекомендуется)
Список выходных серверов. Можно задать несколько целей доставки.
```json
"output_servers": [
{
"name": "sink-main",
"ip": "192.168.1.100"
}
]
```
Поля:
- `name` (string)
- `ip` (string)
Автоматически:
- если `enabled` не задан, выход считается включенным при непустом `ip`;
- `port`, `path`, `timeout_s` берутся по умолчанию (`8080`, `/triangulation`, `3.0`).
Примечание:
- legacy-поля (`enabled`, `port`, `path`, `timeout_s`, `frequency_filter_*`) по-прежнему поддерживаются для обратной совместимости.
### runtime.output_server (legacy)
Одиночная цель. Поддерживается для обратной совместимости.
## input
```json
"input": {
"mode": "http_sources",
"aggregation": "median",
"source_timeout_s": 3.0,
"default_input_filter": {},
"receivers": []
}
```
- `mode` — для автосервиса только `"http_sources"`.
- `aggregation``"median"` или `"mean"`.
- `source_timeout_s` — timeout входных HTTP-запросов.
- `default_input_filter` — общий фильтр, автоматически применяемый ко всем ресиверам.
- `receivers` — массив ресиверов, минимум 3.
### input.default_input_filter
```json
"default_input_filter": {
"enabled": false,
"min_frequency_mhz": 0.0,
"max_frequency_mhz": 1000000000.0,
"min_rssi_dbm": -200.0,
"max_rssi_dbm": 50.0
}
```
Ограничения:
- `max_frequency_mhz >= min_frequency_mhz`
- `max_rssi_dbm >= min_rssi_dbm`
### input.receivers[]
```json
{
"receiver_id": "r0",
"center": { "x": 0.0, "y": 0.0, "z": 0.0 },
"frequencies_mhz": [433.92, 868.1],
"access": { "url": "http://host:9000/measurements", "api_token": "" },
"input_filter": {
"enabled": false,
"min_frequency_mhz": 0.0,
"max_frequency_mhz": 1000000000.0,
"min_rssi_dbm": -200.0,
"max_rssi_dbm": 50.0
}
}
```
Обязательные поля:
- `receiver_id`
- `center.x`, `center.y`, `center.z`
- URL источника:
- `access.url` (предпочтительно) или
- `source_url` (legacy)
Дополнительно:
- `access.api_token` или `source_api_token` — токен входного сервера (добавляется как `Authorization: Bearer ...`).
- `input_filter` — override фильтра для конкретного ресивера.
- `frequencies_mhz` — список разрешённых частот для ресивера; в расчёт попадут только они.
## Пример минимально рабочего конфига
```json
{
"model": { "tx_power_dbm": 20.0 },
"solver": { "tolerance": 0.001, "z_preference": "positive" },
"runtime": {
"listen_host": "0.0.0.0",
"listen_port": 8081,
"poll_interval_s": 1.0,
"output_servers": [
{
"name": "sink",
"ip": ""
}
]
},
"input": {
"mode": "http_sources",
"aggregation": "median",
"source_timeout_s": 3.0,
"receivers": [
{
"receiver_id": "r0",
"center": { "x": 0.0, "y": 0.0, "z": 0.0 },
"frequencies_mhz": [433.92, 868.1],
"access": { "url": "http://127.0.0.1:9001/measurements" }
},
{
"receiver_id": "r1",
"center": { "x": 10.0, "y": 0.0, "z": 0.0 },
"frequencies_mhz": [433.92, 868.1],
"access": { "url": "http://127.0.0.1:9002/measurements" }
},
{
"receiver_id": "r2",
"center": { "x": 0.0, "y": 8.0, "z": 0.0 },
"frequencies_mhz": [433.92, 868.1],
"access": { "url": "http://127.0.0.1:9003/measurements" }
}
]
}
}
```