Generic hardware access library
/home/cschwick/hal/generic/classtester/src/common/VME64xDummyBusAdapterTester.cc
Go to the documentation of this file.
00001 #include "VME64xDummyBusAdapterTester.hh"
00002 
00003 HAL::VME64xDummyBusAdapterTester::VME64xDummyBusAdapterTester( string configSpaceDefinitionFile,
00004                                                                string moduleMapperFile,
00005                                                                string addressTableContainerFile )
00006   throw( HAL::IllegalValueException,
00007          HAL::NoSuchFileException,
00008          HAL::XMLProcessingException,
00009          HAL::HardwareAccessException )
00010   : busAdapter_( configSpaceDefinitionFile, 
00011                  HAL::VME64xDummyBusAdapter::VERBOSE_ON, 
00012                  HAL::VME64xDummyBusAdapter::MEMORY_MAP_ON ),
00013     moduleMapper_(moduleMapperFile),
00014     addressTableContainer_(moduleMapper_,
00015                            addressTableContainerFile) {
00016 
00017 }
00018 
00019 bool HAL::VME64xDummyBusAdapterTester::execute() {
00020   bool result = true;
00021   try {
00022     HAL::VME64xCrate vmeCrate( busAdapter_,
00023                           addressTableContainer_,
00024                           moduleMapper_ );
00025     //vmeCrate.printAddressMap( std::cout );
00026     uint32_t slotId = 6;
00027     std::cout << "try to get the device in slot 6 (tests boundary checking)" << std::endl;
00028     HAL::VMEDevice* devicePtr = vmeCrate.getVMEDevice( slotId );
00029 
00030     std::cout << "accessing HAL::VMEDevice via address read and write commands" << std::endl;
00031 
00032     devicePtr->write( "testBase", 0x12345678 );
00033     devicePtr->write( "testHigh", 0x9abcdef0 );
00034     
00035     std::cout << "reading back" << std::endl;
00036     
00037     uint32_t result1, result2;
00038     devicePtr->read("testBase", &result1);
00039     std::cout << "read from testBase " << std::hex << result1 << std::endl;
00040     devicePtr->read("testHigh", &result2 );
00041     std::cout << "read from testHigh " << std::hex << result2 << std::endl;
00042 
00043     if ( result1 != 0x12345678 ||
00044          result2 != 0x9abcdef0 ) {
00045       result = false;
00046       std::cout << "read back wrong values ! test failed!" << std::endl;
00047     }
00048 
00049   } catch( HAL::HardwareAccessException& e) {
00050     std::cout << "unexpected exception: test failed:" << std::endl;
00051     std::cout << e.what();
00052     result = false;
00053   }
00054   return result;
00055 }
00056 
00057 string HAL::VME64xDummyBusAdapterTester::getName() const {
00058   return "VME64xDummyBusAdapterTester";
00059 }
00060 
00061 string HAL::VME64xDummyBusAdapterTester::getDescription() const {
00062   return "Performs a test of the HAL::VME64xDummyBusAdapter";
00063 }