Subversion Repositories HomeAutomation

Rev

Rev 746 | Blame | Last modification | View Log | SVN | RSS feed

  1. ###########################################################
  2. #
  3. # The default implementation of the packet handler
  4. #
  5. ###########################################################
  6. from CanPktHandlerBase import CanPktHandlerBase
  7. from CanPkt import CanPkt
  8.  
  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.  
  25. class CanPktHandler1(CanPktHandlerBase):
  26.    
  27.     daemonCfg = None
  28.    
  29.     def __init__ (self, daemonCfg):
  30.         self.daemonCfg = daemonCfg
  31.        
  32.     def input(self, strdata):
  33.         """Make data buffer into CanPkt and do early discard check """
  34.         """Call all filters in chain """
  35.  
  36.         if len(strdata) < 2:
  37.             return
  38.         if strdata[0:3] != 'PKT':
  39.             return
  40.  
  41. #        print strdata
  42.         pkt = CanPkt.stringToCanPkt(self, strdata)
  43. #        print 'incoming: ' + pkt.toString()
  44.  
  45.         for filter in self.daemonCfg.filterChain:
  46.             fObj = self.daemonCfg.filterCfg.filterModules[filter]
  47.             sp = SpacePort(fObj.__ASSOCIATED_SPACES__)
  48.             fObj.filter('', pkt, sp) # FIXME: use if name
  49.  
  50.  
  51.     def output(self, data):
  52.         pass
  53.