/* * Copyright (C) 2007 ETH Zurich * * This file is part of Fosstrak (www.fosstrak.org). * * Fosstrak is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License version 2.1, as published by the Free Software Foundation. * * Fosstrak 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 Fosstrak; if not, write to the Free * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA */ package org.fosstrak.ale.server.readers; import java.util.Hashtable; import java.util.List; import org.fosstrak.ale.exception.ImplementationException; import org.fosstrak.ale.server.Tag; import org.fosstrak.ale.xsd.ale.epcglobal.CCOpSpec; import org.fosstrak.ale.xsd.ale.epcglobal.CCSpec; import org.fosstrak.ale.xsd.ale.epcglobal.LRSpec; import org.fosstrak.hal.HardwareException; import org.fosstrak.hal.Observation; /** * represents an abstract superclass for basereaders. * @author swieland * */ public abstract class BaseReader extends LogicalReader { /** * constructor for a BaseReader. */ public BaseReader() { super(); } /** * initializes a BaseReader. this method must be called befor the Reader can * be used. * @param name the name for the reader encapsulated by this reader. * @param spec the specification that describes the current reader. * @throws ImplementationException whenever an internal error occurs. */ public void initialize(String name, LRSpec spec) throws ImplementationException { super.initialize(name, spec); } /** * add a tag to a reader. * @param tag tag to be added to the reader */ public abstract void addTag(Tag tag); /** * add a List of tags to a reader. * @param tags a list of tags to be added to the reader */ public abstract void addTags(List<Tag> tags); /** * starts a basereader to read tags. * */ public abstract void start(); /** * stops a reader from reading tags. */ public abstract void stop(); /** * sets up a reader. * @throws ImplementationException whenever an internal error occured * */ public abstract void connectReader() throws ImplementationException; /** * destroys a reader. * @throws ImplementationException whenever an internal error occured * */ public abstract void disconnectReader() throws ImplementationException; /** * updates a reader according the specified LRSpec. * @param spec LRSpec for the reader * @throws ImplementationException whenever an internal error occurs */ public abstract void update(LRSpec spec) throws ImplementationException; /** * Triggers the identification of all tags that are currently available * on the reader. * @param readPointNames the readers/sources that have to be polled * @return a set of Observations * @throws HardwareException whenever an internal hardware error occurs (as reader not available...) */ public abstract Observation[] identify(String[] readPointNames) throws HardwareException; /** indicates whether the reader is connected or not. */ protected boolean connected = false; /** * flags the reader as connected. */ protected void setConnected() { connected = true; } /** * flags the reader as disconnected. */ protected void setDisconnected() { connected = false; } /** * tells whether the reader is connected or not. * @return boolean true or false */ protected boolean isConnected() { return connected; } /** * this method is called whenever a reader is undefined. a basereader * can override this method with its own cleanup routine. */ public void cleanup() { } /** * ADD_ACCESSSPEC from CCSpec. * */ public abstract void ADDACCESSSPECfromCCSpec(CCSpec ccspec, Hashtable<Integer, CCOpSpec> OpSpecTable); /** * DELETE_ACCESSSPEC. * */ public abstract void DELETEACCESSSPEC(); /** * recover_ACCESSSPEC3. * */ public abstract void recoveryACCESSSPEC3(); }