00001 #ifndef IP_ENCODER_6_ENCINTERFACE_HPP 00002 #define IP_ENCODER_6_ENCINTERFACE_HPP 00003 00004 00005 #include <rtt/PeriodicActivity.hpp> 00006 #include <rtt/DataObjectInterfaces.hpp> 00007 #include <rtt/dev/EncoderInterface.hpp> 00008 #include <vector> 00009 00010 00011 class IP_Encoder_6_Task : public RTT::PeriodicActivity 00012 { 00013 public: 00014 IP_Encoder_6_Task( RTT::Seconds period ); 00015 virtual ~IP_Encoder_6_Task() {}; 00016 00017 virtual bool initialize(); 00018 virtual void step(); 00019 00020 virtual void positionSet(unsigned int encoderNr, int p); 00021 virtual void turnSet(unsigned int encoderNr, int t ); 00022 const int positionGet(unsigned int encoderNr) const; 00023 const int turnGet(unsigned int encoderNr) const; 00024 00025 private: 00026 long _virtualEncoder[6]; 00027 unsigned short _prevEncoderValue[6]; 00028 RTT::DataObjectLockFree<long> _virtual_encoder_1, _virtual_encoder_2, _virtual_encoder_3, 00029 _virtual_encoder_4, _virtual_encoder_5, _virtual_encoder_6; 00030 }; 00031 00032 00033 class IP_Encoder_6_EncInterface : public RTT::EncoderInterface 00034 { 00035 public: 00036 IP_Encoder_6_EncInterface( IP_Encoder_6_Task& IP_encoder_task, const unsigned int& encoder_nr, const std::string& name ); 00037 IP_Encoder_6_EncInterface( IP_Encoder_6_Task& IP_encoder_task, const unsigned int& encoder_nr ); 00038 virtual ~IP_Encoder_6_EncInterface() {}; 00039 00040 00041 virtual int positionGet() const { return _encoder_task->positionGet( _encoder_nr ); } 00042 virtual int turnGet() const { return _encoder_task->turnGet( _encoder_nr ); } 00043 virtual void positionSet( int p) { _encoder_task->positionSet( _encoder_nr, p ); } 00044 virtual void turnSet( int t ) { _encoder_task->turnSet( _encoder_nr, t ); } 00045 virtual int resolution() const { return 2000; } 00046 virtual bool upcounting() const { return true; } 00047 00048 private: 00049 unsigned int _encoder_nr; 00050 IP_Encoder_6_Task* _encoder_task; 00051 }; 00052 00053 #endif