Generic hardware access library
/home/cschwick/hal/generic/src/common/VMEHardwareAddress.cc
Go to the documentation of this file.
00001 #include "hal/VMEHardwareAddress.hh"
00002 
00003 #include <sstream>
00004 #include <iomanip>
00005 
00006 HAL::VMEHardwareAddress::VMEHardwareAddress (uint32_t address, 
00007                                              uint32_t addressModifier,
00008                                              uint32_t dataWidth ) 
00009   throw (HAL::IllegalValueException)
00010   : HAL::GeneralHardwareAddress( address, dataWidth ) {
00011   
00012   mapId_ = 0;
00013   if ( addressModifier == 0x2f ) {
00014     addressSpace_ = (AddressSpace)CONFIGURATION;
00015   } else {
00016     addressSpace_ = (AddressSpace)MEMORY;
00017   }
00018   if (addressModifier > 255 ) {
00019     std::stringstream text;
00020     text << "AddressModifier of "
00021          << std::hex << addressModifier
00022          << " is illegal in this implementation.\n    (HAL::VMEHardwareAddress::VMEHardwareAddress)"
00023          << std::ends;
00024     throw( HAL::IllegalValueException( text.str(), __FILE__, __LINE__, __FUNCTION__ ) );
00025   }
00026   addressModifier_ = addressModifier;
00027 }
00028 
00029 uint32_t HAL::VMEHardwareAddress::getAddressModifier() const 
00030   throw () {
00031   return addressModifier_;
00032 }
00033 
00034 bool HAL::VMEHardwareAddress::isIOSpace() const
00035   throw( HAL::IllegalOperationException ) {
00036   std::string text = "There is no IO space in VME.\n    (HAL::VMEHardwareAddress::isIOSpace)";
00037   throw( HAL::IllegalOperationException( text, __FILE__, __LINE__, __FUNCTION__ ) );
00038 }
00039 
00040 std::string HAL::VMEHardwareAddress::getAddressSpaceString() const {
00041   std::string resultString = "UNDEFINED";
00042   if (addressSpace_ == (AddressSpace)MEMORY) {
00043     resultString =  "memory";
00044   } else if (addressSpace_ == (AddressSpace)CONFIGURATION) {
00045     resultString = "configuration";
00046   }
00047   return resultString;
00048 }
00049 
00050 void HAL::VMEHardwareAddress::print( std::ostream& os ) const {
00051   std::string vmeSpaceString = getAddressSpaceString();
00052   os << std::setw(13) <<"  " << "   ";
00053   os << "   ";
00054   os << std::setw(2) << std::hex << std::setfill('0') << addressModifier_ << "      "
00055      << std::setw(1) << std::dec << dataWidth_ << "  "
00056      << std::setfill('0') << std::setw(8) << std::hex << address_ << "  ";
00057 }
00058 
00059 HAL::GeneralHardwareAddress* HAL::VMEHardwareAddress::clone() const {
00060   return new VMEHardwareAddress( *this );
00061 }