/***************************************************************
 * PrEncoderIntf.h
 *
 * This is an abstract class providing the interface
 * for derived encoder classes.
 *
 ****************************************************************/

/*
 * modification history
 *----------------------
 *
 * 10/26/97: K.C. Chang: created.
 */

#ifndef _PrEncoderIntf_h
#define _PrEncoderIntf_h

#include "PrDriverIntf.h"

// abstract class
class PrEncoderIntf : public PrDriverIntf
{
 public:
    PrEncoderIntf(int channelCount=0,int bitCount=0);

    // abstract class needs virtual destructor
    virtual ~PrEncoderIntf();

    // derived classes should implement valuesPreset() and channelValue()
    // and zero()
 
   // preset encoder values
    virtual int valuesPreset(const int *data)=0;

    // method to read an encoder channel
    virtual Float channelValue(int channel)=0;

    // hardware reset: calls valuesPreset() with zeros
    virtual int zero()=0;

    // read a channel value to 'num': calls channelValue()
    virtual int value(int channel,Float &num);

    // merge the hardware encoder counter with 32 bit software encoderer count
    // returns the merged 32 bit signed integer value
    int swCounterMerge(int channel,unsigned int bits);

    // 32 bit software encoder counter preset
    // returns the counter bit( < 32 bit) unsigned integer value
    unsigned int swCounterPreset(int channel,int value);

 private:
    const int highBitCount_;    //=2 
    const int highBitValue_;    //= 11b = 3

    int *wrapCount_;
    int *lastHighBitValue_;

    // copy is not allowed
    PrEncoderIntf(const PrEncoderIntf &) {}
};

#endif // _PrEncoderIntf_h

