mirror of
https://github.com/BOSWatch/BW3-Core.git
synced 2025-12-06 07:12:04 +01:00
add descriptor module and docu
This commit is contained in:
parent
42209615ab
commit
157f6b5c10
65
docu/docs/modul/descriptor.md
Normal file
65
docu/docs/modul/descriptor.md
Normal file
|
|
@ -0,0 +1,65 @@
|
||||||
|
# <center>Descriptor</center>
|
||||||
|
---
|
||||||
|
|
||||||
|
## Beschreibung
|
||||||
|
Mit diesem Modul können einem Alarmpaket beliebige Beschreibung in Abhänigkeit der enthaltenen Informationen im Paket hinzugefügt werden.
|
||||||
|
|
||||||
|
## Resource
|
||||||
|
`descriptor`
|
||||||
|
|
||||||
|
## Konfiguration
|
||||||
|
|
||||||
|
Informationen zum Aufbau eines [BOSWatch Pakets](../develop/packet.md)
|
||||||
|
|
||||||
|
|Feld|Beschreibung|Default|
|
||||||
|
|----|------------|-------|
|
||||||
|
|scanField|Feld des BW Pakets welches geprüft werden soll||
|
||||||
|
|descrField|Name des Feldes im BW Paket in welchem die Beschreibung gespeichert werden soll||
|
||||||
|
|wildcard|Optional: Es kann für das angelegte `descrField` automatisch ein Wildcard registriert werden|None|
|
||||||
|
|descriptions|Liste der Beschreibungen||
|
||||||
|
|
||||||
|
#### `descriptions:`
|
||||||
|
|
||||||
|
|Feld|Beschreibung|Default|
|
||||||
|
|----|------------|-------|
|
||||||
|
|for|Inhalt im `scanField` auf welchem geprüft werden soll||
|
||||||
|
|add|Beschreibungstext welcher im `descrField` hinterlegt werden soll||
|
||||||
|
|
||||||
|
**Beispiel:**
|
||||||
|
```yaml
|
||||||
|
- type: module
|
||||||
|
res: descriptor
|
||||||
|
config:
|
||||||
|
- scanField: zvei
|
||||||
|
descrField: description
|
||||||
|
wildcard: "{DESCR}"
|
||||||
|
descriptions:
|
||||||
|
- for: 12345
|
||||||
|
add: FF DescriptorTest
|
||||||
|
- for: 45678
|
||||||
|
add: FF TestDescription
|
||||||
|
- scanField: status
|
||||||
|
descrField: fmsStatDescr
|
||||||
|
wildcard: "{STATUSTEXT}"
|
||||||
|
descriptions:
|
||||||
|
- for: 1
|
||||||
|
add: Frei (Funk)
|
||||||
|
- for: 2
|
||||||
|
add: Frei (Wache)
|
||||||
|
- ...
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
## Abhängigkeiten
|
||||||
|
|
||||||
|
- keine
|
||||||
|
|
||||||
|
---
|
||||||
|
## Paket Modifikationen
|
||||||
|
|
||||||
|
- Wenn im Paket das Feld `scanField` vorhanden ist, wird das Feld `descrField` dem Paket hinzugefügt
|
||||||
|
|
||||||
|
---
|
||||||
|
## Zusätzliche Wildcards
|
||||||
|
|
||||||
|
- Von der Konfiguration abhängig
|
||||||
|
|
@ -20,6 +20,7 @@ nav:
|
||||||
- Module:
|
- Module:
|
||||||
- Mode Filter: modul/mode_filter.md
|
- Mode Filter: modul/mode_filter.md
|
||||||
- Regex Filter: modul/regex_filter.md
|
- Regex Filter: modul/regex_filter.md
|
||||||
|
- Descriptor: modul/descriptor.md
|
||||||
- Plugins: tbd.md
|
- Plugins: tbd.md
|
||||||
- Entwickler:
|
- Entwickler:
|
||||||
- Eigenes Modul/Plugin schreiben: develop/ModulPlugin.md
|
- Eigenes Modul/Plugin schreiben: develop/ModulPlugin.md
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,10 @@
|
||||||
German BOS Information Script
|
German BOS Information Script
|
||||||
by Bastian Schroll
|
by Bastian Schroll
|
||||||
|
|
||||||
@file: template_module.py
|
@file: descriptor.py
|
||||||
@date: 01.03.2019
|
@date: 27.10.2019
|
||||||
@author: Bastian Schroll
|
@author: Bastian Schroll
|
||||||
@description: Template Module File
|
@description: Module to add descriptions to bwPackets
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
from module.module import Module
|
from module.module import Module
|
||||||
|
|
@ -26,28 +26,31 @@ logging.debug("- %s loaded", __name__)
|
||||||
|
|
||||||
|
|
||||||
class BoswatchModule(Module):
|
class BoswatchModule(Module):
|
||||||
"""!Description of the Module"""
|
"""!Adds descriptions to bwPackets"""
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
"""!Do not change anything here!"""
|
"""!Do not change anything here!"""
|
||||||
super().__init__(__name__, config) # you can access the config class on 'self.config'
|
super().__init__(__name__, config) # you can access the config class on 'self.config'
|
||||||
|
|
||||||
def onLoad(self):
|
def onLoad(self):
|
||||||
"""!Called by import of the plugin"""
|
"""!Called by import of the plugin"""
|
||||||
pass
|
for descriptor in self.config:
|
||||||
|
if descriptor.get("wildcard"):
|
||||||
|
self.registerWildcard(descriptor.get("wildcard"), descriptor.get("descrField"))
|
||||||
|
|
||||||
def doWork(self, bwPacket):
|
def doWork(self, bwPacket):
|
||||||
"""!start an run of the module.
|
"""!start an run of the module.
|
||||||
|
|
||||||
@param bwPacket: A BOSWatch packet instance"""
|
@param bwPacket: A BOSWatch packet instance"""
|
||||||
if bwPacket.get("mode") == "fms":
|
for descriptor in self.config:
|
||||||
pass
|
for description in descriptor.get("descriptions"):
|
||||||
elif bwPacket.get("mode") == "zvei":
|
if not bwPacket.get(descriptor.get("scanField")):
|
||||||
pass
|
break # scanField is not available in this packet
|
||||||
elif bwPacket.get("mode") == "pocsag":
|
bwPacket.set(descriptor.get("descrField"), description.get("for"))
|
||||||
pass
|
if str(description.get("for")) == str(bwPacket.get(descriptor.get("scanField"))):
|
||||||
elif bwPacket.get("mode") == "msg":
|
logging.debug("Description '%s' added in packet field '%s'", description.get("add"),
|
||||||
pass
|
descriptor.get("descrField"))
|
||||||
|
bwPacket.set(descriptor.get("descrField"), description.get("add"))
|
||||||
|
break # this descriptor has found a description - run next descriptor
|
||||||
return bwPacket
|
return bwPacket
|
||||||
|
|
||||||
def onUnload(self):
|
def onUnload(self):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue