[feat/multicast]: Add multi-instance multicast module with active trigger system#154
[feat/multicast]: Add multi-instance multicast module with active trigger system#154KoenigMjr wants to merge 6 commits into
Conversation
…gger system
Introduce a robust multicast processing module for POCSAG that correlates
empty tone-RICs (recipients) with subsequent text-RICs (content).
Key Features:
- Four Output Modes: Internally supports 'complete', 'incomplete', 'single',
and 'control'. Functional alarms are delivered as the first three, while
technical 'control' packets (Delimiters/NetIdent) are filtered by default.
- Active Trigger System: Implements a loss-free deferred delivery mechanism
using a loopback socket (TCP) to re-inject wakeup packets, flushing the
internal queue during auto-clear timeouts.
- Shared State & Multi-Instance: State is shared across instances but
separated by frequency to prevent crosstalk in multi-frequency setups.
- Data Aggregation: Automatically generates '{FIELD}_list' wildcards (e.g.,
RIC_LIST, DESCRIPTION_LIST) for all collected recipients, enabling
consolidated notifications in downstream plugins.
- Dynamic Filtering: Automatically blocks Delimiter and NetIdent RICs from
reaching subsequent plugins if they are defined in the configuration.
Infrastructural Changes:
- ModuleBase: Expanded return semantics to support:
* False: Explicitly blocks/drops a packet.
* List: Allows a module to expand one input into multiple output packets.
- PluginBase: Updated to handle lists of packets, ensuring a full
setup->alarm->teardown lifecycle for every individual element.
- Remove redundant list-handling block in doWork() - already handled by moduleBase._run()
- Fix bare except to except (ValueError, TypeError) in _copy_packet_dict_to_packet()
- Replace f-string logging with lazy %-style in _enrich_normal_alarm() and _set_mcast_metadata()
- Remove unused _trigger_ric_mode variable
- Simplify instance name from dynamic MCAST_{id} to static "Multicast" (no debug value)
- Update doWork() docstring to reflect single-packet-only parameter
- Add extension hook comment to _perform_instance_tick()
…tream Remove internal filtering of delimiter and netident packets from the multicast module. All packets are now passed through with multicastRole metadata set, allowing downstream filters (e.g. filter.regexFilter) to handle filtering as needed. Tone-RICs remain internally consumed as they carry no alarm-relevant information outside the module. Update documentation to reflect new behavior and add regexFilter example for filtering by multicastRole.
|
🇩🇪 DE 🇬🇧 EN |
|
Ich finde das mit den Listen in den Basis Klassen etwas "unschön", würde ich es wohl nennen :-D Bin mir nicht ganz sicher ob man das auch irgendwie besser lösen kann. Habe da aber leider gerade auch keine Zeit tiefer rein zu gehen. Kannst du mir nochmal kurz umreisen, wieso dies nötig ist? |
|
Du hast absolut recht! Vielen herzlichen Dank für deinen Input! Auf den ersten Blick macht mir der |
…ables to instance scope This commit refactors the internal state management to ensure true multi-instance capability. While previous commits shared state via class variables, this change encapsulates all buffers and flags within the individual instance. Key changes: - Migration of state: Moved `_tone_ric_packets`, `_last_tone_ric_time`, and processing flags from class variables to instance variables (`self`). - Thread Isolation: Shifted the cleanup logic to a per-instance `_cleanup_worker` thread, ensuring that timeouts are managed independently for each route/configuration. - Wildcard Safety: Isolated `_wildcards_registered` to prevent registration conflicts between multiple multicast instances. - Robust Hard-Timeout: Simplified `_cleanup_hard_timeout` to act strictly on the instance's own state. This refactoring resolves the "architectural dinosaur" of shared class state, making the module fully thread-safe and reliable for complex multi-route and multi-frequency deployments.
|
Sooo... Wesentliche Änderungen:
Dokumentation erweitert:
Bitte nochmal kritisch reviewen :) |
|
Verstehe das Listen Handling in den Base Klassen immer noch nicht so ganz. |
|
Guten Morgen! Gibts einen schöneren Weg (nativ?) den ich übersehen habe? |
|
Ehrlich gesagt verstehe ich das "Feature" nicht wirklich. |
|
Vielleicht liegt ein Missverständnis im Wording "liste" vor. Um alle abzuholen, fange ich weiter hinten mit dem Erklären an, ich vermute, du wirst jetzt die Basics nicht brauchen, aber um sicher zu gehen, How does it work: 1. Warum können wir die Pakete nicht vorher aufsplitten?
Wir können sie vorher nicht verarbeiten oder splitten, weil den ersten beiden RICs der Text fehlt. Das Multicast-Modul muss sie also im RAM sammeln (Buffer) und den Router blockieren (return False), bis die Text-RIC eintrifft. 2. Warum geben wir eine Python-Liste von Paketen zurück? Möglichkeit A (Ein einziges Paket mit einer Liste von RICs darin): Möglichkeit B (Eine Python-Liste aus einzelnen, vollwertigen Paketen) 3. Was hat es mit der ric_list (dem Feature) auf sich? Wer das nicht braucht, ignoriert es. Wer aber einen Alarmmonitor betreibt, kann über die Wildcard {RIC_LIST} auf einen Blick sehen: "Ah, meine RIC hat ausgelöst, und ich sehe im Monitor direkt, dass die Nachbarwehr auch alarmiert wurde." Das ist das eigentliche "Multicast-Feature" für den Endanwender. Ich hoffe, das macht den Ansatz verständlicher! |
🇩🇪 DE
Ich habe die Idee von thierry3000 aufgeschnappt und in den letzten Monaten ein Multicast-Modul geschrieben.
Sollte somit das Issue #87 und auch den PR #88 schließen.
Kurz und bündig
Dieses PR implementiert ein vollständiges Multicast-Modul für BOSWatch 3, das es ermöglicht, Alarmnachrichten automatisch an mehrere Empfänger (RICs) zu verteilen. Das Modul integriert sich nahtlos in das bestehende System und erweitert die Kernmodule um die Fähigkeit, Paketlisten zu verarbeiten.
Detaillierte Änderungen
1. Kernmodul module/multicast.py
2. Ergänzungen am bestehenden Programmcode
module/moduleBase.py
plugin/pluginBase.py
3. Dokumentation
Wichtige Punkte
🇬🇧 EN
I picked up the idea from thierry3000 and developed a multicast module over the past few months.
This should resolve Issue #87 as well as PR #88.
In a nutshell
This PR implements a complete multicast module for BOSWatch 3, enabling alarm messages to be automatically distributed to multiple recipients (RICs). The module integrates seamlessly into the existing system and extends the core modules with the ability to process packet lists.
Detailed Changes
1. Core Module module/multicast.py
Full multicast alarm processing with automatic distribution
Active Trigger System: Ensures lossless packet delivery via loopback socket
Multi-instance operation: Multiple module instances with shared thread-safe state
Frequency separation: Prevents mixing of alarms from different transmitters
Automatic filtering: Delimiter and network identifier RICs are intelligently filtered out
Configurable parameters:
2. Enhancements to Existing Codebase
module/moduleBase.py
plugin/pluginBase.py
3. Documentation
Key Points