/* Copyright (c) 20011 Hovanes Egiyan Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef _BaseIUVirtPar_HH_ #define _BaseIUVirtPar_HH_ extern "C" { #include #include #include #include } ; #include #include #include #include #include "BaseIUTimeoutable.hh" #include "BaseIUMessage.hh" #include "BaseIUModule.hh" using namespace std; //class BaseIUBoard; class BaseIUVirtPar: public BaseIUModule, public BaseIUTimeoutable { protected: string bvpType; string bvpName; uint32_t* bvpWriteBuffer; //! Prohibit default constructor BaseIUVirtPar(); public: //! Main constructor BaseIUVirtPar(string type, string name, BaseIUModule& board); //! Short constructor. There will be no associated device or address BaseIUVirtPar(string type, string name); //! Copy constructor BaseIUVirtPar(const BaseIUVirtPar& par); //! Destructor virtual ~BaseIUVirtPar(); //! Assignment operator, not virtual, needs overriding and careful use BaseIUVirtPar& operator=(const BaseIUVirtPar& par); //! Cloning function defined for polymorphism for copy constructor //! Invokes the copy constructor for this class and returns the //! the address of the resulting object virtual BaseIUVirtPar* CloneParameter() = 0; //! Purely virtual function for synch-ing modules with hardware virtual bool Sync(bool dir = 0) = 0; //! Purely virtual method to set the write value to the value based on another //! parameters write value. In principle both parameters are expected to be of //! the same class and type and name. virtual void SetWriteValueFrom( BaseIUVirtPar& fakePar ) = 0; // By default parameters are board dependent. For ones that have nothing // to do, false value should returned. virtual inline bool IsBoardDependent() { return true; } //! Virtual function for finding parameter values in the FIFO virtual bool FindMsgInFIFO(); //! Purely virtual method to process deque from CANbus virtual bool ProcessDeque( bool clearFlag = 0 ) = 0; //! Request read for all boards on the bus virtual void ReadRequest(BaseIUDevice* dev, string name ) = 0; // Override the BaseIUTimeoutable methods to be able to lock the object inline virtual double IncrementSilentTime( const double incTime ) { MtxLock objLock( bmMutex ); return BaseIUTimeoutable::IncrementSilentTime( incTime ); } inline virtual epicsAlarmCondition GetStatus() { MtxLock objLock( bmMutex ); return BaseIUTimeoutable::GetStatus(); } inline virtual epicsAlarmSeverity GetSeverity() { MtxLock objLock( bmMutex ); return BaseIUTimeoutable::GetSeverity(); } inline virtual void SetSilentTime( const double time ) { MtxLock objLock( bmMutex ); return BaseIUTimeoutable::SetSilentTime( time ); } virtual inline double GetDouble() { cerr << "Error: Using useless GetDouble()" << endl; return 0; } virtual inline double SetDouble(double val) { cerr << "Error: Using useless SetDouble()" << endl; return val; } virtual inline long GetLong() { cerr << "Error: Using useless GetLong()" << endl; return 0; } virtual inline long SetLong(long val) { cerr << "Error: Using useless SetLong()" << endl; return val; } virtual inline bool GetBit(const string name ) { cerr << "Error: Using useless GetBit()" << endl; return false; } virtual inline bool SetBit(const bool val, const string name ) { cerr << "Error: Using useless SetBit()" << endl; return val; } inline string GetType() { MtxLock localLock(bmMutex); return bvpType; } inline string GetName() { MtxLock localLock(bmMutex); return bvpName; } inline uint32_t* GetWriteBuffer() { return bvpWriteBuffer; } }; #endif // _BaseIUVirtPar_HH