/* * wiigee - accelerometerbased gesture recognition * Copyright (C) 2007, 2008 Benjamin Poppinga * * Developed at University of Oldenburg * Contact: benjamin.poppinga@informatik.uni-oldenburg.de * * This file is part of wiigee. * * wiigee is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ package device; import java.io.IOException; import java.util.Vector; import logic.*; import event.*; import filter.DirectionalEquivalenceFilter; import filter.Filter; import filter.IdleStateFilter; import filter.MotionDetectFilter; import util.Log; public class Device { // Fixed number values. public static final int MOTION = 0; // Buttons for action coordination protected int recognitionbutton; protected int trainbutton; protected int closegesturebutton; // Functional protected boolean accelerationenabled; // Filters, can filter the data stream protected Vector filters = new Vector(); // Listeners, receive generated events protected Vector devicelistener = new Vector(); protected ProcessingUnit processingunit = new ContinuousProcessingUnit();//new TriggeredProcessingUnit(); public Device() { this.addFilter(new IdleStateFilter()); this.addFilter(new MotionDetectFilter(this)); this.addFilter(new DirectionalEquivalenceFilter()); this.addDeviceListener(this.processingunit); } /** * Adds a Filter for processing the acceleration values. * @param filter The Filter instance. */ public void addFilter(Filter filter) { this.filters.add(filter); Log.write("Filter added..."); } /** * Resets all the filters, which are resetable. * Sometimes they have to be resettet if a new gesture starts. */ public void resetFilters() { for(int i=0; i