Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## AISCoT 7.3.2

- Add `SENSOR_BEACON=0` to disable the periodic receiver marker without
disabling vessel tracks.

## AISCoT 7.3.1

* Close the local AIS UDP listener before PyTAK rebuilds workers after a TAK
Expand Down
5 changes: 5 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ AISCOT has the following built-in configuration parameters:

CoT Stale period ("timeout"), in seconds.

* **`SENSOR_BEACON`**:
* Default: ``1``

Set to ``0`` to disable the periodic receiver marker. Vessel tracks remain enabled.

* **`COT_TYPE`**:
* Default: ``a-u-S-X-M``

Expand Down
5 changes: 4 additions & 1 deletion example-config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ COT_URL = udp://172.17.2.151:4242
; Optional. Override default CoT Stale period (in seconds).
; COT_STALE = 60

; Optional. Disable the periodic receiver marker without disabling vessel tracks.
; SENSOR_BEACON = 0

; Optional. Prepend conventional ship-type callsign prefixes (T/B, P/V, M/V, ...).
; VESSEL_NAME_PREFIX = True

Expand All @@ -29,4 +32,4 @@ COT_URL = udp://172.17.2.151:4242
; SHIPCLASS_ICONS = False

; Optional. Only forward vessels that are underway; drop parked (anchored/moored) hulls.
; UNDERWAY_ONLY = False
; UNDERWAY_ONLY = False
2 changes: 1 addition & 1 deletion src/aiscot/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.3.1
7.3.2
9 changes: 8 additions & 1 deletion src/aiscot/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ def cfg_bool(value, default: bool = False) -> bool:
return str(value).strip().lower() in pytak.BOOLEAN_TRUTH


def sensor_beacon_enabled(config: Union[dict, SectionProxy]) -> bool:
"""Return whether the periodic receiver beacon is enabled."""
value = config.get("SENSOR_BEACON", "1")
return str(value).strip().lower() not in {"0", "false", "no", "off"}


def create_tasks(
config: Union[dict, SectionProxy], clitool: pytak.CLITool
) -> Set[pytak.Worker,]:
Expand All @@ -73,7 +79,8 @@ def create_tasks(
Set of coroutine tasks.
"""
tasks = set([aiscot.AISWorker(clitool.tx_queue, config)])
tasks.add(aiscot.SensorWorker(clitool.tx_queue, config))
if sensor_beacon_enabled(config):
tasks.add(aiscot.SensorWorker(clitool.tx_queue, config))
return tasks


Expand Down
20 changes: 20 additions & 0 deletions tests/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,32 @@

import io
import xml.etree.ElementTree as ET
from types import SimpleNamespace
from unittest.mock import patch

import pytest

import aiscot


@pytest.mark.parametrize("value", ["0", "false", "False", "no", "off"])
def test_sensor_beacon_switch(value):
"""Receiver beacons default on and accept common false values."""
assert aiscot.functions.sensor_beacon_enabled({})
assert not aiscot.functions.sensor_beacon_enabled({"SENSOR_BEACON": value})


def test_create_tasks_can_omit_sensor_beacon():
"""Disabling the receiver beacon keeps vessel processing enabled."""
clitool = SimpleNamespace(tx_queue=object())
with patch.object(aiscot, "AISWorker", return_value="vessels"), patch.object(
aiscot, "SensorWorker", return_value="receiver"
) as sensor_worker:
tasks = aiscot.functions.create_tasks({"SENSOR_BEACON": "0"}, clitool)
assert tasks == {"vessels"}
sensor_worker.assert_not_called()


@pytest.fixture
def sample_data_libais():
return {
Expand Down
Loading