/***************************************************************
 * PrForceSensorIntf.h
 *
 * This is an abstract class providing the interface
 * for derived force sensor classes.
 *
 ****************************************************************/

/*
 * modification history
 *----------------------
 *
 * 12/19/97: K.C. Chang: created.
 */

#ifndef _PrForceSensorIntf_h
#define _PrForceSensorIntf_h

#include "PrDriverIntf.h"

// abstract class
class PrForceSensorIntf : public PrDriverIntf
{
 public:
    PrForceSensorIntf(int channelCount=0,int bitCount=0);
    // abstract class needs virtual destructor
    virtual ~PrForceSensorIntf();

    Float *bias() { return bias_; }

    // derived classes should implement forceMax(),torqueMax(),values()

    virtual Float forceMax()=0;   // implement!
    virtual Float torqueMax()=0;   // implement!

    // read force sensor values
    virtual int values(Float *data) = 0;  // implement!
 
    // hardware reset
    virtual int zero();

    // read a force sensor value from a channel
    virtual int value(int channel,Float &data); 

 private:
    Float *bias_;

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

inline PrForceSensorIntf::PrForceSensorIntf(int channelCount,int bitCount)
: PrDriverIntf(channelCount,bitCount)
{
    bias_ = new Float[channelCount];
    for(int i=0;i<channelCount;i++)
      bias_[i] = 0.0;
    flag( PR_DRIVER_OK );
}

inline PrForceSensorIntf::~PrForceSensorIntf()
{
    delete[] bias_;
}

inline int PrForceSensorIntf::zero()
{
    for(int i=0;i<channelCount();i++)
      bias_[i]=0.0;
	  
    return values(bias_);
}
 
inline int PrForceSensorIntf::value(int channel,Float &data) 
{ 
    channel=0;
    data=0.0;
    return PR_DRIVER_ERROR; 
}

#endif // _PrForceSensorIntf_h

