/* Test of the RodStatus class * written by Fredrik Tegenfeldt * * $Id: GetRodStatus.cxx,v 1.3 2004/07/07 13:06:55 tegen Exp $ */ #include using namespace std; #include #include "RodModule.h" #include "RodStatus.h" #include "primParams.h" #include "RCCVmeInterface.h" #include "parameters.h" int main(int argc, char *argv[]) { using namespace SctPixelRod; std::string fileName(""), option; bool verbose = false; int slot = -1; unsigned long baseAddress; if (argc > 1) { for (int i=1; i 21)) { cout << "Slot number out or range [1:21] (input: " << slot << ")\n"; return 0; } break; } default: { break; } } } } // Prompt for slot number if (slot < 0 ) { cout << "Enter slot number (decimal):"; cin >> slot; while ((slot < 1) || (slot > 21)) { cout << "Slot number out or range [1:21], re-enter: "; cin >> slot; } } baseAddress = slot << 24; // Create VME interface RCCVmeInterface *vme; try { vme = new RCCVmeInterface(); } catch (...) { std::cout << "Caught an exception when creating a VME interface." << std::endl; } // Create RodModule RodModule *rod = NULL; RodStatus *rodStatus = NULL; try { rod = new RodModule(baseAddress, mapSize, *vme, numSlaves); rodStatus = new RodStatus(*rod); } catch (RodException &r) { std::cout << __FUNCTION__ << "ROD exception thrown when creating the RodModule/RodStatus objects" << std::endl << r; } catch (VmeException &v) { std::cout << __FUNCTION__ << ": VME exception thrown when creating the RodModule/RodStatus objects\n " << v << "RodModule not found on VME (wrong slot number or h/w error)!" << std::endl; } catch (...) { std::cout << __FUNCTION__ << ": Some whatever exception occured..." << std::endl; } /* If rodStatus couldn't been created, then we skip the attempt to * reset the module */ if (rodStatus) { if (!rodStatus->isSane()) { std::cout << "Looks like we have an insane ROD module on our hands..." << std::endl; std::cout << "With an initialize() it will be more happy." << std::endl; } try { std::cout << "First doing initialize()" << std::endl; rod->initialize(false); std::cout << "Secondly, make the snapshot of the status" << std::endl; rodStatus->snapShot(*rod); std::cout << "Done." << std::endl; } catch (BaseException &e) { std::cout << __FUNCTION__ << ": Exception when initializing RodModule:\n "; e.what(std::cout); std::cout << std::endl; } catch (...) { std::cout << "An exception was generated when initializing the RodModule." << std::endl; } if (!rodStatus->isSane()) { std::cout << "Still insane... check the slotnumber." << std::endl; } else { std::cout << "We've got a live one!" << std::endl; std::cout << "Print the status:" << std::endl; std::cout << *rodStatus; } } /* if(RodStatus) */ // Delete the ROD and VME objects before exiting delete rod; delete rodStatus; delete vme; return 0; }