From 519df6e3f93dff3bb313c58156909c0a1b62daa3 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Fri, 23 Feb 2018 06:48:23 +0100 Subject: [PATCH] edit wildcard + add wildcards to packet.MD --- _info/packet.md | 535 +++++++++++++++++++---------------- boswatch/plugin/plugin.py | 12 +- boswatch/utils/wildcard.py | 8 +- plugins/template/template.py | 5 + 4 files changed, 303 insertions(+), 257 deletions(-) diff --git a/_info/packet.md b/_info/packet.md index ea5f8f7..f5d3c45 100644 --- a/_info/packet.md +++ b/_info/packet.md @@ -1,252 +1,289 @@ ## Format of the BOSWatch packets - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
fieldfmspocsagzveimsgdescription
serverNameXXXXname of the boswatch server instance
serverVersionXXXXin case of new version, server can notify
serverBuildDateXXXX
serverBranchXXXX
clientNameXXXXname of the boswatch client instance
clientIPXXXX
clientVersionXXXXin case of new version, server can notify
clientBuildDateXXXX
clientBranchXXXX
inputSourceXXXX(stick, audio)
timestampXXXX
frequencyXXXX
modeXXXX(fms, pocsag, zvei, msg)
descriptionShortXXXloaded from optional CSV file
descriptionLongXXXloaded from optional CSV file
bitrateX
ricX
subricX(1, 2, 3, 4)
subricTextX(a, b, c, d)
messageXX
toneX5-tone sequence
fmsX
serviceX
countryX
locationX
vehicleX
statusX
directionX
dirextionTextX(Fhz->Lst, Lst->Fhz)
tacticalInfoX(I, II, III, IV)
fieldfmspocsagzveimsgwildcarddescription
serverNameXXXX{SNAME}name of the boswatch server instance
serverVersionXXXX{SVERS}in case of new version, server can notify
serverBuildDateXXXX{SDATE}
serverBranchXXXX{SBRCH}
clientNameXXXX{CNAME}name of the boswatch client instance
clientIPXXXX{CIP}
clientVersionXXXX{CVERS}in case of new version, server can notify
clientBuildDateXXXX{CDATE}
clientBranchXXXX{CBRCH}
inputSourceXXXX{INSRC}(stick, audio)
timestampXXXX{TIMES}
frequencyXXXX{FREQ}
modeXXXX{MODE}(fms, pocsag, zvei, msg)
descriptionShortXXX{DESCS}loaded from optional CSV file
descriptionLongXXX{DESCL}loaded from optional CSV file
bitrateX{BIT}
ricX{RIC}
subricX{SRIC}(1, 2, 3, 4)
subricTextX{SRICT}(a, b, c, d)
messageXX{MSG}
toneX{TONE}5-tone sequence
fmsX{FMS}
serviceX{SERV}
countryX{COUNT}
locationX{LOC}
vehicleX{VEHC}
statusX{STAT}
directionX{DIR}
dirextionTextX{DIRT}(Fhz->Lst, Lst->Fhz)
tacticalInfoX{TACI}(I, II, III, IV)
+ +

+### Other possible wildcards: +- {BR} - Line break (\r\n) +- {LPAR} - Left parenthesis ( +- {RPAR} - Right parenthesis ) +- {TIME} - Actual timestamp diff --git a/boswatch/plugin/plugin.py b/boswatch/plugin/plugin.py index 89b3200..ce47a22 100644 --- a/boswatch/plugin/plugin.py +++ b/boswatch/plugin/plugin.py @@ -75,6 +75,8 @@ class Plugin: self._runCount += 1 logging.debug("[%s] run #%d", self._pluginName, self._runCount) + self._bwPacket = bwPacket + self._tmpTime = time.time() try: logging.debug("[%s] setup()", self._pluginName) @@ -117,6 +119,8 @@ class Plugin: self._cumTime += self._sumTime self._endTime = time.time() + self._bwPacket = None + logging.debug("[%s] took %0.3f seconds", self._pluginName, self._sumTime) # logging.debug("- setup: %0.2f sec.", self._setupTime) # logging.debug("- alarm: %0.2f sec.", self._alarmTime) @@ -186,8 +190,8 @@ class Plugin: pass def parseWildcards(self, msg): - """!Return the message with parsed wildcards - - todo self._bwPacket is set nowehere!!!! - """ + """!Return the message with parsed wildcards""" + if self._bwPacket is None: + logging.warning("wildcard replacing not allowed - no bwPacket set") + return msg return wildcard.replaceWildcards(self._bwPacket, msg) diff --git a/boswatch/utils/wildcard.py b/boswatch/utils/wildcard.py index 8a9b53b..a69cff5 100644 --- a/boswatch/utils/wildcard.py +++ b/boswatch/utils/wildcard.py @@ -31,6 +31,7 @@ def replaceWildcards(message, bwPacket): "{BR}": "\r\n", "{LPAR}": "(", "{RPAR}": ")", + "{TIME}": time.time(), # info wildcards "{SNAME}": bwPacket.getField("serverName"), @@ -44,13 +45,12 @@ def replaceWildcards(message, bwPacket): "{CBRCH}": bwPacket.getField("clientBranch"), # boswatch wildcards - "{MODE}": bwPacket.getField("mode"), + "{INSRC}": bwPacket.getField("mode"), + "{TIMES}": bwPacket.getField("mode"), "{FREQ}": bwPacket.getField("frequency"), + "{MODE}": bwPacket.getField("mode"), "{DESCS}": bwPacket.getField("descriptionShort"), "{DESCL}": bwPacket.getField("descriptionLong"), - "{INSRC}": bwPacket.getField("mode"), - "{TIME}": time.time(), - "{TIMES}": bwPacket.getField("mode"), # fms wildcards "{FMS}": bwPacket.getField("fms"), diff --git a/plugins/template/template.py b/plugins/template/template.py index bc57e3f..de1b78a 100644 --- a/plugins/template/template.py +++ b/plugins/template/template.py @@ -17,6 +17,11 @@ import logging from boswatch.plugin.plugin import Plugin +# ###################### # +# Custom plugin includes # + +# ###################### # + logging.debug("- %s loaded", __name__)