示例#1
0
    def __init__(self, length):
        """
        Compute the moving-window average of the filter for length N.

        Since our architecture is primarially "pull", we don't do this
        until we've received a query from upstream.
        
        we know that if we want LENGTH packets then we will need
        to go back a certain amount of time in history.

        """

        self.sink = self.createSink("default")
        self.sink_timetree = timetree.default()
        
        self.src_timetree = timetree.default()
        self.source = self.createSource("default", self.get_data,
                                        self.get_source_tree)

        self.tmap_in = TMap()
        self.tmap_out = TMap()
        self.recent_request = None

        self.delay = length
示例#2
0
class FIRFilter(Filter):

    def __init__(self, length):
        """
        Compute the moving-window average of the filter for length N.

        Since our architecture is primarially "pull", we don't do this
        until we've received a query from upstream.
        
        we know that if we want LENGTH packets then we will need
        to go back a certain amount of time in history.

        """

        self.sink = self.createSink("default")
        self.sink_timetree = timetree.default()
        
        self.src_timetree = timetree.default()
        self.source = self.createSource("default", self.get_data,
                                        self.get_source_tree)

        self.tmap_in = TMap()
        self.tmap_out = TMap()
        self.recent_request = None

        self.delay = length
        
    def get_source_tree(self):
        return self.src_timetree

    def get_data(self, t1, t2):
        """
        Returns the available list of data
        between t1 and t2

        """
        self.recent_request = (t1, t2)
        return self.tmap_out(t1, t2)
    

    def process(self):
        """
        1. the input was a request for (t1, t2)
        
        2. do we have some existing subset of t1, t2 in our input queue ? 

        right now, we're just flying on heuristics

        
        """

        t1, t2 = self.recent_request
        t1 = t1 - self.delay
        
        req_data = self.source.get_data(t1, t2)

        for d in req_data:
            self.tmap_in[d.starttime] = d

        # now, compute over the input range

        for d in self.tmap_in.range(t1, t2):
            """