BOSWatch 3
Python Script to receive and decode German BOS Information with rtl_fm and multimon-NG
 
Loading...
Searching...
No Matches
boswatch.router.router.Router Class Reference

Class for the Router. More...

Public Member Functions

def __init__ (self, name)
 Create a new router.
 
def addRoute (self, route)
 Adds a route point to the router.
 
def runRouter (self, bwPacket)
 Run the router.
 

Data Fields

 name
 
 routeList
 

Protected Member Functions

def _getStatistics (self)
 Returns statistical information's from last router run.
 

Protected Attributes

 _cumTime
 
 _routerTime
 
 _runCount
 

Detailed Description

Class for the Router.

Constructor & Destructor Documentation

◆ __init__()

def boswatch.router.router.Router.__init__ (   self,
  name 
)

Create a new router.

    @param name: name of the router
26 def __init__(self, name):
27 r"""!Create a new router
28
29 @param name: name of the router"""
30 self.name = name
31 self.routeList = []
32
33 # for time counting
34 self._cumTime = 0
35 self._routerTime = 0
36
37 # for statistics
38 self._runCount = 0
39
40 logging.debug("[%s] add new router", self.name)
41

Member Function Documentation

◆ addRoute()

def boswatch.router.router.Router.addRoute (   self,
  route 
)

Adds a route point to the router.

    @param route: instance of the Route class
42 def addRoute(self, route):
43 r"""!Adds a route point to the router
44
45 @param route: instance of the Route class
46 """
47 logging.debug("[%s] add route: %s", self.name, route.name)
48 self.routeList.append(route)
49

◆ runRouter()

def boswatch.router.router.Router.runRouter (   self,
  bwPacket 
)

Run the router.

    @param bwPacket: instance of Packet class
    @return a instance of Packet class
50 def runRouter(self, bwPacket):
51 r"""!Run the router
52
53 @param bwPacket: instance of Packet class
54 @return a instance of Packet class
55 """
56 self._runCount += 1
57 tmpTime = time.time()
58
59 logging.debug("[%s] started", self.name)
60
61 for routeObject in self.routeList:
62 logging.debug("[%s] -> run route: %s", self.name, routeObject.name)
63 bwPacket_tmp = routeObject.callback(copy.deepcopy(bwPacket)) # copy bwPacket to prevent edit the original
64
65 if bwPacket_tmp is None: # returning None doesnt change the bwPacket
66 continue
67
68 if bwPacket_tmp is False: # returning False stops the router immediately
69 logging.debug("[%s] stopped", self.name)
70 break
71
72 bwPacket = bwPacket_tmp
73 logging.debug("[%s] bwPacket returned", self.name)
74 logging.debug("[%s] finished", self.name)
75
76 self._routerTime = time.time() - tmpTime
77 self._cumTime += self._routerTime
78
79 return bwPacket
80

◆ _getStatistics()

def boswatch.router.router.Router._getStatistics (   self)
protected

Returns statistical information's from last router run.

    @return Statistics as pyton dict
81 def _getStatistics(self):
82 r"""!Returns statistical information's from last router run
83
84 @return Statistics as pyton dict"""
85 stats = {"type": "router",
86 "runCount": self._runCount,
87 "cumTime": self._cumTime,
88 "moduleTime": self._routerTime}
89 return stats

Field Documentation

◆ name

boswatch.router.router.Router.name

◆ routeList

boswatch.router.router.Router.routeList

◆ _cumTime

boswatch.router.router.Router._cumTime
protected

◆ _routerTime

boswatch.router.router.Router._routerTime
protected

◆ _runCount

boswatch.router.router.Router._runCount
protected