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

SctApiMConf.cxx

00001 
00013 #include "primListWrapper.h"
00014 #include "PrimBuilder.h"
00015 #include "SctApi.h"
00016 #include "SctApiRodInfo.h"
00017 #include "crate.h"
00018 #include "utility.h"
00019 
00020 #include "CommonWithDsp/primParams.h"
00021 #include "CommonWithDsp/registerIndices.h"
00022 
00023 #include "Sct/FibreNumberConverters.h"
00024 
00025 using namespace std;
00026 using namespace SctPixelRod;
00027 
00028 namespace SctApi {
00029 
00030 void SctApi::getABCDModules(BankType bank) {
00031   {
00032     boost::mutex::scoped_lock lock(logMutex);
00033     log << "getABCDModule (all). Bank: " << bank << endl;
00034   }
00035   for(map<UINT32, ABCDModule> ::const_iterator iter = moduleMap.begin();
00036       iter != moduleMap.end();
00037       iter ++) {
00038     getABCDModule(iter->first, bank);
00039   }
00040 }
00041 
00042 void SctApi::getABCDModule(UINT32 mid, BankType bank) {
00043   {
00044     boost::mutex::scoped_lock lock(logMutex);
00045     log << "getABCDModule " << mid << " Bank: " << bank << endl;
00046   }
00047 
00048   // Find module channel in ROD
00049   unsigned int partition, crate, rod, channel;
00050   Utility::getpcrc(mid, partition, crate, rod, channel);
00051 
00052   // Which bank id to use
00053   int realBank = Utility::translateBank(bank);
00054 
00055   boost::shared_ptr<PrimListWrapper> primList(new PrimListWrapper(1));
00056   PrimBuilder::instance().readModuleData(primList, realBank, channel);
00057 
00058   sendPrimList(partition, crate, rod, primList);
00059 
00060   int responseCode = awaitResponse(partition, crate, rod, 5);
00061 
00062   unsigned long length;
00063   unsigned long *outBody = 0;
00064   if(responseCode == 0) {
00065     outBody = getResponse(partition, crate, rod, length);
00066   }
00067 
00068   if(outBody) {
00069 //      unsigned long outLength = outBody[0];
00070 //      unsigned long outIndex = outBody[1];
00071     unsigned long outNumPrims = outBody[2];
00072 //      unsigned long outPrimVersion = outBody[3];
00073 
00074     if(outNumPrims == 1) {
00075       unsigned long primLength = outBody[4];
00076 //        unsigned long primIndex = outBody[5];
00077       unsigned long primID = outBody[6];
00078 //        unsigned long primVersion = outBody[7];
00079 
00080       if(primID == RW_MODULE_DATA) {
00081         if(primLength != (sizeof(ABCDModule)/sizeof(UINT32) + 4)) { // Prim length includes header
00082           cout << "Output primitive was " << primLength << " not " << sizeof(ABCDModule)/sizeof(UINT32) << endl;
00083         }
00084 
00085         // Data is at outBody[8]
00086         ABCDModule result;
00087 
00088         // Copy data
00089         for(unsigned int i=0; i<sizeof(ABCDModule)/sizeof(UINT32); i++) {
00090           ((unsigned long *)&result)[i] = outBody[8 + i];
00091         }
00092 
00093         ABCDModule *previous = lookupConfig(mid);
00094 
00095         if(previous) {
00096           cout << "Replacing previous module config\n";
00097 
00098           *previous = result;
00099         } else {
00100           cout << "New module config inserted\n";
00101           moduleMap.insert(make_pair(mid, result));
00102         }
00103       } else {
00104         cout << "Returned primitive was not RW_MODULE_DATA\n";
00105       }
00106     } else {
00107       cout << "Too many primitives in output list\n";
00108     }
00109 
00110     delete [] outBody;
00111   } else {
00112     cout << "No response to primitive list!\n";
00113   }
00114 }
00115 
00116 boost::shared_ptr<ABCDModule> SctApi::getABCDModuleRaw(unsigned int partition, unsigned int crate, unsigned int rod, 
00117                                                        UINT32 slot, BankType bank) {
00118   {
00119     boost::mutex::scoped_lock lock(logMutex);
00120     log << "getABCDModuleRaw Slot: " << slot << " Bank: " << bank << endl;
00121   }
00122 
00123   boost::shared_ptr<ABCDModule> result;
00124 
00125   // Which bank id to use
00126   int realBank = Utility::translateBank(bank);
00127 
00128   boost::shared_ptr<PrimListWrapper> primList(new PrimListWrapper(1));
00129   PrimBuilder::instance().readModuleData(primList, realBank, slot);
00130   sendPrimList(partition, crate, rod, primList);
00131 
00132   int responseCode = awaitResponse(partition, crate, rod, 5);
00133 
00134   unsigned long length;
00135   unsigned long *outBody = 0;
00136   if(responseCode == 0) {
00137     outBody = getResponse(partition, crate, rod, length);
00138   }
00139 
00140   if(outBody) {
00141     unsigned long outNumPrims = outBody[2];
00142 
00143     if(outNumPrims == 1) {
00144       unsigned long primLength = outBody[4];
00145       unsigned long primID = outBody[6];
00146 
00147       if(primID == RW_MODULE_DATA) {
00148         unsigned int expectedSize = (sizeof(ABCDModule)/sizeof(UINT32) + 4);
00149         if(primLength != expectedSize) { // Prim length includes header
00150           cout << "Output primitive was " << primLength << " not " << expectedSize << endl;
00151         }
00152 
00153         result.reset(new ABCDModule);
00154 
00155         // Data is at outBody[8]
00156         // Copy data
00157         for(unsigned int i=0; i<sizeof(ABCDModule)/sizeof(UINT32); i++) {
00158           ((unsigned long *)result.get())[i] = outBody[8 + i];
00159         }
00160       } else {
00161         cout << "Returned primitive was not RW_MODULE_DATA\n";
00162       }
00163     } else {
00164       cout << "Too many primitives in output list\n";
00165     }
00166 
00167     delete [] outBody;
00168   } else {
00169     cout << "No response to primitive list!\n";
00170   }
00171 
00172   return result;
00173 }
00174 
00175 /* Store config in ROD */
00176 void SctApi::setABCDModules(BankType bank) {
00177   {
00178     boost::mutex::scoped_lock lock(logMutex);
00179     log << "setABCDModule called for all modules. Bank " << bank << endl;
00180   }
00181   for(map<UINT32, ABCDModule>::const_iterator iter = moduleMap.begin();
00182       iter != moduleMap.end();
00183       iter ++) {
00184     cout << "Set Config " << iter->first << endl;
00185     setABCDModule(iter->first, bank);
00186   }
00187 
00188   // Off-ROD modules need to be sent from the "wrong" ROD
00189   for(list<RodLabel>::const_iterator rl = rodList.begin();
00190       rl!=rodList.end();
00191       rl++){
00192     RodInfo info = getRodInfo(*rl);
00193 
00194     for(std::map<unsigned long, unsigned long>::const_iterator iter = info.offRODRX.begin();
00195         iter != info.offRODRX.end(); iter++) {
00196       cout << "Set config " << hex << iter->first << " (off ROD pair of " << iter->second << ")" << dec << endl;
00197       setABCDModule(iter->first, bank);
00198     }
00199   }
00200 
00201   return;
00202 }
00203 
00204 /* Store config in ROD */
00205 void SctApi::setABCDModule(UINT32 mid, BankType bank) {
00206   if(mid==0xffffffff){
00207     cout << "setABCDModule with 0xffffffff\n";
00208     throw SctApiException("mid out of range");
00209   }
00210 
00211   {
00212     boost::mutex::scoped_lock lock(logMutex);
00213     log << "setABCDModule " << mid << " Bank: " << bank << endl;
00214   }
00215 
00216   unsigned int partition, crate, rod, channel;
00217   Utility::getpcrc(mid, partition, crate, rod, channel);
00218 
00219   int realBank = Utility::translateBank(bank);
00220 
00221   std::string moduleName;
00222   ABCDModule *moduleConfig;
00223 
00224   moduleConfig = lookupConfig(mid);
00225 
00226   if(!moduleConfig) {
00227     cout << "*** NO module configuration for mid = " << mid << " in set module" << endl;
00228     return;
00229   }
00230 
00231   cout << "\nModule config\n";
00232   cout << " primary channel " << (int)moduleConfig->pTTC 
00233        << " red channel " << (int)moduleConfig->rTTC 
00234        << " group " << (int)moduleConfig->groupId
00235        << " select " << (int)moduleConfig->select << endl;
00236   cout << " target (chip 0) " << (int)moduleConfig->chip[0].target << endl;
00237 
00238   boost::shared_ptr<PrimListWrapper> primList(new PrimListWrapper(1));
00239   PrimBuilder::instance().writeModuleData(primList, moduleConfig, realBank, channel);
00240 
00241   RodLabel rl(partition, crate, rod);
00242 
00243   for(int l=0; l<2; l++) {
00244     const unsigned int zeroTo123Pos = moduleConfig->rx[l];
00245     // We check the values before using it, doing this here makes the next bit less confusing
00246     const unsigned int zeroTo95Pos = Sct::FibreNumberConverters::from124FormatTo96Format(zeroTo123Pos);
00247     if (zeroTo123Pos==DATA_LINK_OFF) {
00248       // Don't try to get non-existant value!
00249       //  but otherwise this is valid ... no problem
00250     } else if(zeroTo123Pos <= 123 && zeroTo95Pos < 96) {
00251       // This is already cached in cacheModuleConfig
00252       const unsigned int val = getRodInfo(rl).linkErrorMasks[zeroTo95Pos];
00253       PrimBuilder::instance().writeRegister(primList, ERROR_MASK(zeroTo95Pos/48, zeroTo95Pos%48), 0, 13, val);
00254     } else {
00255       std::ostringstream os;
00256       os << "Bad fibre number for error mask values! Line " << __LINE__ << " of " << __FILE__ << " when 123pos = " << zeroTo123Pos <<" and 95pos = " << zeroTo95Pos;
00257       if (mrs) {
00258         *mrs << "SctApi" << MRS_ERROR << MRS_TEXT(os.str()) << ENDM;
00259       } else {
00260         std::cout << "SctApi: ERROR " << os.str() << std::endl;
00261       }
00262     }
00263   }
00264 
00265   // This will be a null op if it doesn't exist
00266 #ifdef CMD_BUFFER_0
00267   setupModuleMask(CMD_BUFFER_0, 0xf, primList);
00268 #else
00269   setupModuleMask(SP0, 0xf, primList);
00270 #endif
00271   sendPrimList(partition, crate, rod, primList);
00272 
00273   int responseCode = awaitResponse(partition, crate, rod, 10);
00274 
00275   if(responseCode!=0) {
00276     cout << "Set module unsuccessful!\n";
00277   }
00278 }
00279 
00280 void SctApi::sendAllABCDModules(BankType bank,
00281                                 ConfigType type,
00282                                 const bool enableDataMode /* enableDataMode should have default value true to ensure compatibility with old code*/) {
00283   {
00284     boost::mutex::scoped_lock lock(logMutex);
00285     log << "sendABCDModule called for all modules. Bank: " << bank << endl;
00286   }
00287 
00288   /*
00289     This method is far too long...
00290 
00291     1) Change to ROD mode that allows configuration to be sent to the modules
00292     2) Check the BOC isn't interlocked
00293     3) Build and send a primitive list
00294      a) Disable trigger decoder
00295      b) Disable formatters
00296      c) Send configuration
00297      d) Reenable trigger decoder
00298     4) Change "back" to CALIBRATION_MODE
00299 
00300     option 2 (for early versions of the DSP code, probably not every stage necessary)
00301     1) Disable formatters
00302     2) Send configuration for each module in turn using sendABCDModule
00303     3) Setup module masks
00304     4) Reset some FIFOs...
00305 
00306 */
00307 
00308   cout << "Send config to all modules\n";
00309 
00310   PrimBuilder &builder = PrimBuilder::instance();
00311 
00312   // Set ROD mode to something appropriate (may be in TIM mode!)
00313   boost::shared_ptr<PrimListWrapper> rodModeList1(new PrimListWrapper(1));
00314   // Should CALIBRATION_SLINK_OVERRIDE_MODE be added to this (it works without!)
00315   builder.rodMode(rodModeList1, CALIBRATION_MODE, 0, 1, 1, 1, 1);
00316 
00317   synchSendPrimListAllCrates(rodModeList1);
00318 
00319 
00320   // If new primitive use it instead of doing a loop
00321 #if (R_SEND_CONFIG == 104) || (R_SEND_CONFIG == 105)
00322   {
00323     boost::mutex::scoped_lock lock(logMutex);
00324     log << "\tUsing one SEND_CONFIG primitive\n";
00325   }
00326 
00327   {
00328     for(list<RodLabel>::const_iterator rl = rodList.begin();
00329         rl!=rodList.end();
00330         rl++){
00331 
00332       if(!getCrate(rl->partition, rl->crate)->checkBOCLasersOn(rl->rod)) {
00333         cout << "Trying to send module configuration using BOC that has its lasers cut out\n";
00334         if(mrs) {
00335           *mrs << "BOC_INTERLOCKED" << MRS_ERROR << MRS_QUALIF("SCTAPI") 
00336                << MRS_PARAM<int>("crate", rl->crate) 
00337                << MRS_PARAM<int>("rod", rl->rod)
00338                << MRS_TEXT("Can't send all module config (BOC interlocked)") << ENDM;
00339         }
00340 
00341         throw SctApiException("Send modules aborted due to interlock status");
00342       }
00343     }
00344   }
00345 
00346   boost::shared_ptr<PrimListWrapper> sendConfigList(new PrimListWrapper(1));
00347 
00348   // Write "Disable trigger decoder" to primList
00349 #ifdef RRIF_CMND_1
00350   builder.writeRegister(sendConfigList, RRIF_CMND_1, 18, 1, 0);
00351 #else
00352 #error "Unsupported no registers"
00353 #endif   // RRIF_CMND_1
00354 
00355   // Disable all formatters
00356 #ifdef FMT_LINK_EN
00357   for(int i=0; i<8; i++) {
00358     builder.writeRegister(sendConfigList, FMT_LINK_EN(i), 0, 32, 0);
00359   }
00360 #else
00361 #warning "Probably don't need to turn off formatters!?"
00362 #endif // FMT_LINK_EN
00363 
00364   int realBank = Utility::translateBank(bank);
00365 
00366   //@todo SP_BOTH doesn't work with current DSP code
00367 //  builder.sendConfig(sendConfigList, SP_BOTH, 0, ALL_MODULES, ALL_MODULES, ALL_CHIPS, 1, 1,
00368 //                                     realBank, MODULE_GROUP_ALL, type, 0, enableDataMode);
00369   builder.sendConfig(sendConfigList, SP0, 0, ALL_MODULES, ALL_MODULES, ALL_CHIPS, 1, 1,
00370                      realBank, MODULE_GROUP_ALL, type, 0, enableDataMode);
00371 
00372   // Write "Re-enable trigger decoder" to primList
00373 #ifdef RRIF_CMND_1
00374   builder.writeRegister(sendConfigList, RRIF_CMND_1, 18, 1, 1);
00375 #else
00376 #error "Unsupported no registers"
00377 #endif  // RRIF_CMND_1
00378 
00379   // setupModuleMask to reenable appropriate formatters??
00380 
00381   for(map<pair<unsigned int, unsigned int>, Crate* >::const_iterator ci = crateMap.begin();
00382       ci != crateMap.end();
00383       ci++) {
00384     sendPrimListAll(ci->first.first, ci->first.second, sendConfigList);
00385   }
00386 
00387   for(map<pair<unsigned int, unsigned int>, Crate* >::const_iterator ci = crateMap.begin();
00388       ci != crateMap.end();
00389       ci++) {
00390     int responseCode = awaitResponseAll(ci->first.first, ci->first.second, 10);
00391 
00392     if(responseCode != 0) {
00393       cout << "Send modules unsuccessful\n";
00394     }
00395   }
00396 
00397   boost::shared_ptr<PrimListWrapper> rodModeList(new PrimListWrapper(1));
00398   // Should CALIBRATION_SLINK_OVERRIDE_MODE be added to this (it works without!)
00399   builder.rodMode(rodModeList, CALIBRATION_MODE, 0, 1, 1, 1, 1);
00400 
00401   for(map<pair<unsigned int, unsigned int>, Crate* >::const_iterator ci = crateMap.begin();
00402       ci != crateMap.end();
00403       ci++) {
00404     sendPrimListAll(ci->first.first, ci->first.second, rodModeList);
00405   }
00406 
00407   for(map<pair<unsigned int, unsigned int>, Crate* >::const_iterator ci = crateMap.begin();
00408       ci != crateMap.end();
00409       ci++) {
00410     int responseCode = awaitResponseAll(ci->first.first, ci->first.second, 10);
00411 
00412     if(responseCode != 0) {
00413       cout << "Send modules rod mode unsuccessful\n";
00414     }
00415   }
00416 #else   // Use slow config (loop over modules)
00417   {
00418     boost::mutex::scoped_lock lock(logMutex);
00419     log << "\tUsing multiple SEND_CONFIG primitives\n";
00420   }
00421 
00422 #warning "Slow module sending"
00423 
00424   // Disable all formatters to avoid bus error!
00425 #ifdef FMT_LINK_EN
00426   boost::shared_ptr<PrimListWrapper> clearFormatList(new PrimListWrapper(1));
00427 
00428   for(int i=0; i<8; i++) {
00429     builder.writeRegister(clearFormatList, FMT_LINK_EN(i), 0, 32, 0);
00430   }
00431 
00432   for(map<pair<unsigned int, unsigned int>, Crate* >::const_iterator ci = crateMap.begin();
00433       ci != crateMap.end();
00434       ci++) {
00435     sendPrimListAll(ci->first.first, ci->first.second, clearFormatList);
00436 
00437     int responseCode = awaitResponseAll(ci->first.first, ci->first.second, 10);
00438 
00439     if(responseCode != 0) {
00440       cout << "Clear formatters unsuccessful\n";
00441     }
00442   }
00443 #else
00444 #warning "Probably don't need to turn off formatters! (old version)"
00445 #endif   // FMT_LINK_EN
00446 
00447   for(map<UINT32, ABCDModule>::const_iterator iter = moduleMap.begin();
00448       iter != moduleMap.end();
00449       iter ++) {
00450     cout << "SendConfig " << iter->first << endl;
00451     sendABCDModule(iter->first, bank, type, enableDataMode);
00452   }
00453 #endif   // End of slow config sending
00454 
00455   // Restore link masks etc
00456   boost::shared_ptr<PrimListWrapper> setupMasks(new PrimListWrapper(1));
00457 
00458 #ifdef CMD_BUFFER_0
00459   setupModuleMask(CMD_BUFFER_0, 0xf, setupMasks);
00460 #else
00461   setupModuleMask(SP0, 0xf, setupMasks);
00462 #endif   // CMD_BUFFER_0
00463 
00464   for(map<pair<unsigned int, unsigned int>, Crate* >::const_iterator ci = crateMap.begin();
00465       ci != crateMap.end();
00466       ci++) {
00467     sendPrimListAll(ci->first.first, ci->first.second, setupMasks);
00468 
00469     int responseCode = awaitResponseAll(ci->first.first, ci->first.second, 10);
00470 
00471     if(responseCode != 0) {
00472       cout << "Setup masks unsuccessful\n";
00473     }
00474   }
00475 
00476   // Reset everything so its not confused by the clk/2
00477   boost::shared_ptr<PrimListWrapper> resetList(new PrimListWrapper(1));
00478 
00479   cout << "Resetting front end interface\n";
00480 #ifdef RRIF_CMND_0
00481   builder.writeRegister(resetList, RRIF_CMND_0, 0, 8, 0xff);  // Reset everything
00482   builder.writeRegister(resetList, RRIF_CMND_0, 0, 8, 0x78);  // Leave debug FIFO in reset
00483 #else
00484 #error "Unsupported no registers"
00485 #endif   // RRIF_CMND_0
00486 
00487   for(map<pair<unsigned int, unsigned int>, Crate* >::const_iterator ci = crateMap.begin();
00488       ci != crateMap.end();
00489       ci++) {
00490     sendPrimListAll(ci->first.first, ci->first.second, resetList);
00491 
00492     int responseCode = awaitResponseAll(ci->first.first, ci->first.second, 10);
00493 
00494     if(responseCode != 0) {
00495       cout << "ROD front end reset unsuccessful\n";
00496     }
00497   }
00498 
00499   return;
00500 }
00501 
00502   void SctApi::sendABCDModule(UINT32 mid,
00503                               BankType bank, 
00504                               ConfigType type, 
00505                               const bool enableDataMode /* enableDataMode should have default value true to ensure compatibility with old code*/ ) {
00506   if(mid==0xffffffff){
00507     cout << "sendABCDModule with 0xffffffff\n";
00508     throw SctApiException("mid out of range");
00509   }
00510 
00511   cout << "Send config to module " << mid << endl;
00512 
00513   {
00514     boost::mutex::scoped_lock lock(logMutex);
00515     log << "sendABCDModule: Mid: " << mid << " Bank: " << bank << " Type: " << type << endl;
00516   }
00517 
00518   unsigned int partition, crate, rod, channel;
00519   Utility::getpcrc(mid, partition, crate, rod, channel);
00520 
00521   if(!getCrate(partition, crate)) {
00522     cout << "Send module for non-existent crate " << partition << " " << crate << endl;
00523     return;
00524   }
00525 
00526   int realBank = Utility::translateBank(bank);
00527 
00528   if(realBank > SPARE_MODULE_CONFIG) {
00529     cout << "sendABCDModule with illegal bank (translated) " << realBank << endl;
00530     throw SctApiException("Illegal Bank");
00531   }
00532 
00533   if(!getCrate(partition, crate)->checkBOCLasersOn(rod)) {
00534     cout << "Trying to send module configuration using BOC that has its lasers cut out\n";
00535     if(mrs) {
00536       *mrs << "BOC_INTERLOCKED" << MRS_ERROR << MRS_QUALIF("SCTAPI") 
00537            << MRS_PARAM<int>("module", mid) << MRS_PARAM<int>("crate", crate) 
00538            << MRS_PARAM<int>("rod", rod)
00539            << MRS_TEXT("Can't send module config (BOC interlocked)") << ENDM;
00540     }
00541 
00542     return;
00543   }
00544 
00545   boost::shared_ptr<PrimListWrapper> primList(new PrimListWrapper(1));
00546   PrimBuilder &builder = PrimBuilder::instance();
00547 
00548   // Write "Disable trigger decoder" to primList
00549 #ifdef RRIF_CMND_1
00550   builder.writeRegister(primList, RRIF_CMND_1, 18, 1, 0);
00551 #else
00552 #error "Unsupported no registers"
00553 #endif
00554 
00555   builder.sendConfig(primList, SP0, 0, channel, NO_MODULE, ALL_CHIPS, 1, 1,
00556                      realBank, MODULE_GROUP_ALL, type, 0, enableDataMode);
00557 
00558   // Write "Re-enable trigger decoder" to primList
00559 #ifdef RRIF_CMND_1
00560   builder.writeRegister(primList, RRIF_CMND_1, 18, 1, 1);
00561 #else
00562 #error "Unsupported no registers"
00563 #endif
00564 
00565   sendPrimList(partition, crate, rod, primList);
00566 
00567   int responseCode = awaitResponse(partition, crate, rod, 10);
00568 
00569   if(responseCode != 0) {
00570     cout << "Send module unsuccessful\n";
00571   }
00572 }
00573 
00574 void SctApi::modifyABCDVarROD(UINT32 mid, UINT32 chip, UINT32 type, FLOAT32 value, BankType bank) {
00575   {
00576     boost::mutex::scoped_lock lock(logMutex);
00577     log << "modifyABCDVarROD (module " << mid << ": chip " << chip  << ") " << type << " " << value << "\n";
00578   }
00579 
00580   cout << "Change variable macro\n";
00581 
00582   unsigned int partition, crate, rod, channel;
00583   Utility::getpcrc(mid, partition, crate, rod, channel);
00584 
00585   if(!isRODPresent(partition, crate, rod)) {
00586     cout << "Trying to change module configuration on a non existant ROD\n";
00587     if(mrs) {
00588       *mrs << "ROD_UNCONFIGURED" << MRS_ERROR << MRS_QUALIF("SCTAPI") 
00589            << MRS_PARAM<int>("module", mid) << MRS_PARAM<int>("crate", crate) 
00590            << MRS_PARAM<int>("rod", rod)
00591            << MRS_TEXT("Can't modify module config (ROD non-existant)") << ENDM;
00592     }
00593 
00594     return;
00595   }
00596 
00597   boost::shared_ptr<PrimListWrapper> primList(new PrimListWrapper(1));
00598 
00599   int realBank = Utility::translateBank(bank);
00600 
00601   PrimBuilder::instance().writeModuleVariable(primList, realBank, MODULE_GROUP_ALL, channel, chip, type, value);
00602 
00603   sendPrimList(partition, crate, rod, primList);
00604   awaitResponse(partition, crate, rod, 5);
00605 }
00606 
00607 void SctApi::modifyABCDVarROD(UINT32 mid, UINT32 type, FLOAT32 value, BankType bank) {
00608   {
00609     boost::mutex::scoped_lock lock(logMutex);
00610     log << "modifyABCDVarROD (module " << mid << ") " << type << " " << value << "\n";
00611   }
00612 
00613   cout << "Change variable macro\n";
00614 
00615   unsigned int partition, crate, rod, channel;
00616   Utility::getpcrc(mid, partition, crate, rod, channel);
00617 
00618   if(!isRODPresent(partition, crate, rod)) {
00619     cout << "Trying to change module configuration on a non existant ROD\n";
00620     if(mrs) {
00621       *mrs << "ROD_UNCONFIGURED" << MRS_ERROR << MRS_QUALIF("SCTAPI") 
00622            << MRS_PARAM<int>("module", mid) << MRS_PARAM<int>("crate", crate) 
00623            << MRS_PARAM<int>("rod", rod)
00624            << MRS_TEXT("Can't modify module config (ROD non-existant)") << ENDM;
00625     }
00626 
00627     return;
00628   }
00629 
00630   boost::shared_ptr<PrimListWrapper> primList(new PrimListWrapper(1));
00631 
00632   int realBank = Utility::translateBank(bank);
00633 
00634   PrimBuilder::instance().writeModuleVariable(primList, realBank, MODULE_GROUP_ALL, channel, ALL_CHIPS, type, value);
00635 
00636   sendPrimList(partition, crate, rod, primList);
00637   awaitResponse(partition, crate, rod, 5);
00638 }
00639 
00640 void SctApi::modifyABCDVarROD(UINT32 type, FLOAT32 value, BankType bank) {
00641   {
00642     boost::mutex::scoped_lock lock(logMutex);
00643     log << "modifyABCDVarROD (all modules, all chips) " << type << " " << value << " Bank: " << bank << "\n";
00644   }
00645 
00646   cout << "Change variable macro\n";
00647 
00648   boost::shared_ptr<PrimListWrapper> primList(new PrimListWrapper(1));
00649 
00650   int realBank = Utility::translateBank(bank);
00651 
00652   PrimBuilder::instance().writeModuleVariable(primList, realBank, MODULE_GROUP_ALL, ALL_MODULES, ALL_CHIPS, type, value);
00653 
00654   for(list<RodLabel>::const_iterator rl = rodList.begin();
00655       rl!=rodList.end();
00656       rl++){
00657 
00658     unsigned int partition = rl->partition, crate = rl->crate, rod = rl->rod;
00659 
00660     if(!isRODPresent(partition, crate, rod)) {
00661       cout << "Trying to change module configuration on a non existant ROD\n";
00662       if(mrs) {
00663         *mrs << "ROD_UNCONFIGURED" << MRS_ERROR << MRS_QUALIF("SCTAPI") 
00664              << MRS_PARAM<int>("crate", crate) 
00665              << MRS_PARAM<int>("rod", rod)
00666              << MRS_TEXT("Can't modify module config (ROD non-existant)") << ENDM;
00667       }
00668 
00669       return;
00670     }
00671 
00672     sendPrimList(partition, crate, rod, primList);
00673     awaitResponse(partition, crate, rod, 2);
00674   }
00675 }
00676 
00677 } // Close namespace

Generated on Thu Feb 3 17:37:42 2005 for SCT DAQ/DCS Software - C++ by doxygen 1.3.5