Subversion Repositories HomeAutomation

Rev

Details | Last modification | View Log | SVN | RSS feed

Rev Author Line No. Line
736 olof 1
###########################################################
2
#
3
# The default implementation of the packet handler
4
#
5
###########################################################
6
from CanPktHandlerBase import CanPktHandlerBase
738 olof 7
from CanPkt import CanPkt
736 olof 8
 
748 olof 9
class SpacePort():
10
 
11
    filterSpaces = {}
12
 
13
    def __init__ (self, filterSpaces):
14
        for fs in filterSpaces:
15
            self.filterSpaces[fs.name] = fs
16
 
17
    def runAll(self, args):
18
        for fs in filterSpaces.values():
19
            relatedSpaces = s.__RELATED_SPACES__
20
            fs.run(relatedSpaces, args)
21
 
22
    def run(self, spaceName, args):
23
        filtersSpaces[spaceName].run(args)
24
 
736 olof 25
class CanPktHandler1(CanPktHandlerBase):
26
 
27
    daemonCfg = None
28
 
29
    def __init__ (self, daemonCfg):
30
        self.daemonCfg = daemonCfg
738 olof 31
 
32
    def input(self, strdata):
736 olof 33
        """Make data buffer into CanPkt and do early discard check """
34
        """Call all filters in chain """
748 olof 35
 
738 olof 36
        if len(strdata) < 2:
736 olof 37
            return
738 olof 38
        if strdata[0:3] != 'PKT':
736 olof 39
            return
738 olof 40
 
746 olof 41
#        print strdata
738 olof 42
        pkt = CanPkt.stringToCanPkt(self, strdata)
746 olof 43
#        print 'incoming: ' + pkt.toString()
738 olof 44
 
737 olof 45
        for filter in self.daemonCfg.filterChain:
46
            fObj = self.daemonCfg.filterCfg.filterModules[filter]
748 olof 47
            sp = SpacePort(fObj.__ASSOCIATED_SPACES__)
48
            fObj.filter('', pkt, sp) # FIXME: use if name
49
 
50
 
736 olof 51
    def output(self, data):
52
        pass