/*************************************************************************** tag: Peter Soetens Thu Oct 10 16:16:56 CEST 2002 DigitalInInterface.hpp DigitalInInterface.hpp - description ------------------- begin : Thu October 10 2002 copyright : (C) 2002 Peter Soetens email : peter.soetens@mech.kuleuven.ac.be *************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef DIGITALININTERFACE_HPP #define DIGITALININTERFACE_HPP #include "NameServer.hpp" #include "NameServerRegistrator.hpp" namespace StoneHead { /** * A class for reading digital inputs. */ class DigitalInInterface : public NameServerRegistrator { public: /** * Construct a nameserved DigitalInInterface instance. * The object can then be retrieved using DigitalInInterface::nameserver . * * @param name * The name which will refer to this instance. */ DigitalInInterface( const std::string& name ) : NameServerRegistrator( nameserver, name, this ) { } /** * Create a not nameserved DigitalInInterface instance. */ DigitalInInterface() { } virtual ~DigitalInInterface() { } /** * The NameServer of this interface. * @see NameServer */ static NameServer nameserver; /** * Inspect if a certain bit is on. * * @param bit The bit to check, starting from zero. * @return true if the bit is high (1), false otherwise. */ virtual bool isOn( unsigned int bit = 0) const = 0; /** * Inspect if a certain bit is on. * * @param bit The bit to check, starting from zero. * @return true if the bit is low (0), false otherwise. */ virtual bool isOff( unsigned int bit = 0) const = 0; /** * Inspect a bit. * * @param bit The bit to check, starting from zero. * @return true if the bit is high (1), false otherwise. */ virtual bool readBit( unsigned int bit = 0) const = 0; /** * Inspect a sequence of bits. * * @param start_bit The first bit to check. * @param stop_bit The last bit (inclusive) to check. * @return a bit pattern denoting the bit status from to * where bit zero equals the value of . */ virtual unsigned int readSequence(unsigned int start_bit, unsigned int stop_bit) const = 0; /** * Returns the number of bits that can be read for * digital input. */ virtual unsigned int nbOfInputs() const = 0; }; }; #endif