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

utility.cxx

00001 #include <iostream>
00002 #include <string>
00003 #include <sstream>
00004 
00005 #include "utility.h"
00006 
00007 #include "primParams.h"
00008 
00009 #include "SctApiException.h"
00010 
00011 using namespace std;
00012 
00013 namespace SctApi {
00014   namespace Utility {
00015     void printMemoryBlock(ostream &os, unsigned long *mem, unsigned long words, int wordsPerLine, int level) 
00016     {
00017       unsigned int lines = words/wordsPerLine;
00018       int skipping = 0;
00019 
00020       os.fill('0');
00021 
00022       os << hex;
00023       for(unsigned int i=0; i<lines; i++) {
00024         int val = 0;
00025         for(int j=0; j<wordsPerLine; j++) {
00026           val+=mem[i*wordsPerLine+j];
00027         }
00028         if(val == 0) {
00029           if(!skipping) 
00030             os << string("        ", 0, level) << ".";
00031           skipping++;
00032         } else {
00033           if(skipping) os << " Skipped " << dec << skipping << hex << " blank lines\n";
00034           skipping = 0;
00035 
00036           os << string("        ", 0, level);
00037           for(int j=0; j<wordsPerLine; j++) {
00038             os.fill('0');
00039             os.width(8);
00040             os << mem[i*wordsPerLine+j] << " ";
00041           }
00042           os << endl;
00043         }
00044       }
00045       if(skipping) os << " Skipped " << dec << skipping << hex << " blank lines\n";
00046       if(lines*wordsPerLine < words) {
00047         os << string("        ", 0, level);
00048         for(unsigned int i=lines*wordsPerLine; i<words; i++) {
00049           os.fill('0');
00050           os.width(8);
00051           os << mem[i] << " ";
00052         }
00053         os << endl;
00054       }
00055       os.fill(' ');
00056 
00057       os << dec;
00058     }
00059 
00060     unsigned translateConfigType(ConfigType cfg){
00061       unsigned realtype;
00062       switch (cfg){
00063       case SCTAPI_CONFIG_NONE: {
00064     std::ostringstream oss;
00065     oss << "Invalid config specification : " << (int)cfg;
00066     throw SctApiException(oss.str());
00067       }
00068       case SCTAPI_CONFIG_CFG:
00069       case SCTAPI_CONFIG_BASIC:
00070     realtype=CONFIG_MODULE_BASIC;
00071     break;
00072       case SCTAPI_CONFIG_TRIM:
00073     realtype=CONFIG_MODULE_TRIM;
00074     break;
00075       case SCTAPI_CONFIG_MASK:
00076       case SCTAPI_CONFIG_OTHER:
00077       case SCTAPI_CONFIG_ALL:
00078     realtype=CONFIG_MODULE_ALL;
00079     break;
00080       default:
00081     std::cout << "translateConfigType: Invalid type specification " << cfg << endl;
00082     throw SctApiException("Invalid config specification");
00083     break;
00084       }
00085       return realtype;
00086     }
00087 
00088     int translateBank(BankType bank) {
00089       int realBank;
00090       switch(bank) {
00091 #ifdef PHYSICS_MODULE_CONFIG
00092       case SCTAPI_BANK_PHYSICS:
00093         realBank = PHYSICS_MODULE_CONFIG;
00094         break;
00095       case SCTAPI_BANK_SCAN:
00096         realBank = SCAN_MODULE_CONFIG;
00097         break;
00098       case SCTAPI_BANK_CALIBRATION:
00099         realBank = SPARE_MODULE_CONFIG;
00100         break;
00101 #else
00102       case SCTAPI_BANK_PHYSICS:
00103         realBank = INIT_MODULE_CONFIG;
00104         break;
00105       case SCTAPI_BANK_SCAN:
00106         realBank = WORK_MODULE_CONFIG;
00107         break;
00108       case SCTAPI_BANK_CALIBRATION:
00109         realBank = SPARE_MODULE_CONFIG;
00110         break;
00111 #endif
00112       default:
00113         std::cout << "translateBank: Invalid bank specification " << bank << endl;
00114         throw SctApiException("Invalid bank specification");
00115       }
00116       return realBank;
00117     }
00118   }
00119 }

Generated on Fri Sep 16 18:02:03 2005 for SCT DAQ/DCS Software - C++ by doxygen 1.3.5