@@ -0,0 +1,3056 @@
+/*%0A * To change this template, choose Tools %7C Templates%0A * and open the template in the editor.%0A */%0Apackage net.sf.jaer.eventprocessing.filter;%0A%0Aimport net.sf.jaer.chip.AEChip;%0Aimport net.sf.jaer.event.BasicEvent;%0Aimport net.sf.jaer.event.EventPacket;%0Aimport net.sf.jaer.event.OutputEventIterator;%0Aimport net.sf.jaer.eventprocessing.EventFilter2D;%0Aimport net.sf.jaer.util.filter.LowpassFilter;%0A%0A/**%0A * Filters out events from a saturated readout.%0A *%0A * @author tobi%0A */%0Apublic class BusSaturationFilter extends EventFilter2D %7B%0A%0A    private float saturationPeriodUs = getPrefs().getFloat(%22BusSaturationFilter.saturationPeriodUs%22, .5f);%0A%0A%0A    %7B%0A        setPropertyTooltip(%22dsaturationPeriodUst%22, %22If event interspike period drops below this for tauMs ms, events are filtered out%22);%0A    %7D%0A    private float tauMs = getPrefs().getFloat(%22BusSaturationFilter.tauMs%22, 1);%0A%0A%0A    %7B%0A        setPropertyTooltip(%22tauMs%22, %22If event interspike period drops below this for tauMs ms, events are filtered out%22);%0A    %7D%0A    private LowpassFilter lowpass = new LowpassFilter();%0A    int lastts = 0;%0A%0A    public BusSaturationFilter(AEChip chip) %7B%0A        super(chip);%0A        lowpass.setTauMs(tauMs);%0A%0A    %7D%0A%0A    /**%0A     * Get the value of saturationPeriodUs%0A     *%0A     * @return the value of saturationPeriodUs%0A     */%0A    public float getSaturationPeriodUs() %7B%0A        return saturationPeriodUs;%0A    %7D%0A%0A    /**%0A     * Set the value of saturationPeriodUs%0A     *%0A     * @param saturationPeriodUs new value of saturationPeriodUs%0A     */%0A    public void setSaturationPeriodUs(float saturationPeriodUs) %7B%0A        support.firePropertyChange(%22saturationPeriodUs%22, this.saturationPeriodUs, saturationPeriodUs);%0A        this.saturationPeriodUs = saturationPeriodUs;%0A        getPrefs().putFloat(%22BusSaturationFilter.saturationPeriodUs%22, saturationPeriodUs);%0A    %7D%0A%0A    @Override%0A    public Object getFilterState() %7B%0A        return null;%0A    %7D%0A%0A    @Override%0A    public void resetFilter() %7B%0A    %7D%0A%0A    @Override%0A    public void initFilter() %7B%0A    %7D%0A%0A    @Override%0A    public EventPacket%3C?%3E filterPacket(EventPacket%3C?%3E in) %7B%0A        if (!isFilterEnabled()) %7B%0A            return in;%0A        %7D%0A        if (in == null) %7B%0A            return null;%0A        %7D%0A        checkOutputPacketEventType(in.getEventClass());%0A        OutputEventIterator outItr = out.outputIterator();%0A        for (BasicEvent e : in) %7B%0A            int dt = e.timestamp - lastts;%0A            lastts=e.timestamp;%0A            lowpass.filter(dt, e.timestamp);%0A            if (lowpass.getValue() %3E saturationPeriodUs) %7B%0A                BasicEvent o = (BasicEvent) outItr.nextOutput();%0A                o.copyFrom(e);%0A            %7D%0A        %7D%0A        return out;%0A    %7D%0A%0A    /**%0A     * @return the tauMs%0A     */%0A    public float getTauMs() %7B%0A        return tauMs;%0A    %7D%0A%0A    /**%0A     * @param tauMs the tauMs to set%0A     */%0A    public void setTauMs(float tauMs) %7B%0A        support.firePropertyChange(%22tauMs%22, this.tauMs, tauMs);%0A        this.tauMs = tauMs;%0A        getPrefs().putFloat(%22BusSaturationFilter.tauMs%22, tauMs);%0A    %7D%0A%7D%0A

prototype of a filter that filters out events completely if the event rate is too high, indicating bus saturation. needs evolving to make it more useful.