Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Related Pages

VmePort.h

00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 // 25/03/2002  V 1.0 TM - Data types unsigned, addr_mod->AddrMod, 
00009 //                        namespace added            
00010 //  3/04/2002  V 1.1 PM - Few modifications in the block transfer
00011 //                        methods 
00012 // 18/04/2002  V 1.2 PM - Modification in the interrupt handling
00013 //                        and in the error reporting methods
00014 // 22/04/2002  V 1.3 PM - New methods for blocking and resuming 
00015 //                        interrupt notification and for reading
00016 //                        and setting an interrupt data word           
00017 // 19/02/2004  V 1.4 PM - Safe single word R/W methods added            
00018 //
00019 
00059 #ifndef SCTPIXELROD_VMEPORT_H
00060 #define SCTPIXELROD_VMEPORT_H
00061 
00062 #include <string>
00063 
00064 #include "VmeInterface.h"
00065 
00066 namespace SctPixelRod {
00067 
00068 class VmePort {
00069 public:
00070 
00072   VmePort(unsigned long base, unsigned long size, VmeInterface::AddrMod mod,
00073           VmeInterface &interf) : 
00074           m_baseAddress(base), m_mapSize(size), m_addrMod(mod),
00075           m_interface(interf) {
00076      m_handle = m_interface.registerPort(*this);
00077      m_exceptionTrapping = true;
00078    };
00080   ~VmePort() {
00081     m_interface.deletePort(*this);
00082   };                                                                  
00083 
00085   inline VmeInterface &getInterface() { return m_interface; };         
00087   inline unsigned long getHandle() { return m_handle; };         
00089   inline void *getMap() { return m_interface.getPortMap(m_handle); };         
00091   inline unsigned long getBaseAddress() { return m_baseAddress; };         
00093   inline unsigned long getMapSize() { return m_mapSize; };
00095   inline VmeInterface::AddrMod getAddrMod() { return m_addrMod; };
00097   inline void setExceptionTrapping(bool act) { m_exceptionTrapping = act; };         
00099   inline bool getExceptionTrapping() { return m_exceptionTrapping; };                
00101   inline long getLastErrcode() { return m_interface.getLastErrcode(); };
00103   inline std::string getErrorMessage(const long errcode) { return m_interface.getErrorMessage(errcode); };
00104 
00106   inline long getBusErrors() { return m_interface.getBusErrors(); };
00108   void busErrorReport() { m_interface.busErrorReport(*this); };
00109 
00111   inline unsigned char read8(const unsigned long offset) { 
00112     return m_interface.read8(m_handle, offset);
00113   };  
00114   inline unsigned char readS8(const unsigned long offset) { 
00115     return m_interface.readS8(m_handle, offset);
00116   };  
00117   
00118   // Word read (automatic mapping)
00119   inline unsigned short read16(const unsigned long offset){ 
00120     return m_interface.read16(m_handle, offset);
00121   };  
00122   inline unsigned short readS16(const unsigned long offset){ 
00123     return m_interface.readS16(m_handle, offset);
00124   };  
00125   
00127   inline unsigned long read32(const unsigned long offset){
00128     return m_interface.read32(m_handle, offset);
00129   };  
00130   inline unsigned long readS32(const unsigned long offset){
00131     return m_interface.readS32(m_handle, offset);
00132   };  
00133   
00135   inline void write8(const unsigned long offset, const unsigned char value) {
00136     m_interface.write8(m_handle, offset, value);
00137   };   
00138   inline void writeS8(const unsigned long offset, const unsigned char value) {
00139     m_interface.writeS8(m_handle, offset, value);
00140   };   
00141   
00143   inline void write16(const unsigned long offset, const unsigned short value) {
00144     m_interface.write16(m_handle, offset, value);
00145   };    
00146   inline void writeS16(const unsigned long offset, const unsigned short value) {
00147     m_interface.writeS16(m_handle, offset, value);
00148   };    
00149   
00151   inline void write32(const unsigned long offset, const unsigned long value) {
00152     m_interface.write32(m_handle, offset, value);
00153   };   
00154   inline void writeS32(const unsigned long offset, const unsigned long value) {
00155     m_interface.writeS32(m_handle, offset, value);
00156   };   
00157 
00159   inline void blockRead32(const unsigned long offset, unsigned long *buf, const long len) {
00160     m_interface.blockRead32(*this, offset, buf, len);
00161   };  
00163   inline void blockRead64(const unsigned long offset, unsigned long *buf, const long len) {
00164     m_interface.blockRead64(*this, offset, buf, len);
00165   };   
00167   inline void blockWrite32(const unsigned long offset, const unsigned long *buf, const long len) {
00168     m_interface.blockWrite32(*this, offset, buf, len);
00169   };  
00171   inline void blockWrite64(const unsigned long offset, const unsigned long *buf, const long len) {
00172     m_interface.blockWrite64(*this, offset, buf, len);
00173   };   
00174   
00175   // Interrupt handling
00176   inline void declareInterruptHandler(VmeInterruptHandler &ih) {
00177     m_interface.declareInterruptHandler(ih);
00178   };
00179   inline void cleanInterruptHandlers() {
00180     m_interface.cleanInterruptHandlers();
00181   };
00182   inline void removeInterruptHandler(VmeInterruptHandler &ih) {
00183     m_interface.removeInterruptHandler(ih);
00184   };
00186   inline void reEnableInterrupt() { 
00187     m_interface.reEnableInterrupt();
00188   }; 
00190   void blockInterruptNotification() {
00191     m_interface.blockInterruptNotification();
00192   };
00194   void resumeInterruptNotification() {
00195     m_interface.resumeInterruptNotification();
00196   };
00197   
00198 private:
00199   unsigned long m_handle;
00200   unsigned long m_baseAddress;
00201   unsigned long m_mapSize;
00202   VmeInterface::AddrMod m_addrMod;
00203   VmeInterface &m_interface;
00204   bool m_exceptionTrapping;
00205 };                                             // End of VmePort declaration
00206 
00208 class VmeInterruptHandler {
00209 public:
00211   VmeInterruptHandler(VmePort &port, char vect, int level) : 
00212       m_port(port), m_interruptLevel(level) {
00213     if (level == -1) {
00214       m_interruptVector = 0;
00215       m_interruptSoftVect = vect;
00216     } else {
00217       m_interruptVector = vect;
00218       m_interruptSoftVect = 0;
00219     } 
00220     m_port.declareInterruptHandler(*this); 
00221     m_active = true;
00222   };
00224   virtual ~VmeInterruptHandler() {
00225     m_active = false;
00226     m_port.removeInterruptHandler(*this);
00227   };
00229   virtual void interruptHandler(unsigned char vect, unsigned char softvect, int count) = 0;
00231   inline void activateSoftVector(unsigned char softvect) { 
00232     if (m_interruptSoftVect == 0) m_port.getInterface().activateSoftVector(m_interruptVector, softvect);
00233   };
00235   inline void setInterruptData(long data) {
00236     if (m_interruptSoftVect == 0) m_port.getInterface().setInterruptData(data);
00237   }
00239   inline long getInterruptData() {
00240     return m_port.getInterface().getInterruptData();
00241   }
00243   inline void reEnableInterrupt() { m_port.reEnableInterrupt(); }; 
00245   inline char getInterruptVector() { return m_interruptVector; }
00247   inline char getInterruptSoftVect() { return m_interruptSoftVect; }
00249   inline int getInterruptLevel() { return m_interruptLevel; }
00251   inline void setActive(bool active) { m_active = active; };
00252   inline bool getActive() { return m_active; };
00253   
00254 protected:
00255   VmePort &m_port;
00256   unsigned char m_interruptVector;
00257   unsigned char m_interruptSoftVect;
00258   unsigned int m_interruptLevel;
00259   bool m_active;
00260 };
00261 
00262 } // End namespace SctPixelRod
00263 
00264 #endif // SCTPIXELROD_VMEPORT_H

Generated on Thu Jul 15 09:51:02 2004 for SCT DAQ/DCS Software - C++ by doxygen 1.3.5