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

TApi.cxx

00001 // File: TApi.cxx
00002 
00003 #include <iostream>
00004 #include <list>
00005 
00006 #include "TApi.h"
00007 #include "autoConfig.h"
00008 
00009 // For BOCChannelConfig
00010 #include "sctConf/configuration.h"
00011 #include "SctApiException.h"
00012 #include "TriggerImpl.h"
00013 #include "ScanDefImpl.h"
00014 
00015 #include <boost/bind.hpp>
00016 #include "SctApiDDC.h"
00017 #include "SctApi/Idiosyncrasy.h"
00018 
00019 // Template to check for exceptions 
00020 //  ::result_type is implemented by the boost bind stuff
00021 
00022 template <class Call> typename Call::result_type checkCall(const Call &call) {
00023   try {
00024     return call();
00025   } catch(SctApi::SctApiException &e) {
00026     std::cout << "SctApiException " << e.what() << " thrown\n";
00027   }
00028 }
00029 
00030 ClassImp(TApi)
00031 ClassImp(TScanDef)
00032 ClassImp(TTrigger)
00033 
00034 // TApi *tapi;
00035 
00036 // Constructor
00037 TApi::TApi(){
00038   SctApi::Idiosyncrasy id(0,0);
00039   worker = new SctApi::SctApi(id);
00040 }
00041 
00042 // Destructor
00043 /*
00044   The destructor.
00045 */
00046 TApi::~TApi(){
00047   delete worker;
00048 }
00049 
00050 // ROD Diagnostics
00051 
00052 void TApi::initialiseAll(int scanNumber) {
00053   worker->initialiseAll(scanNumber);
00054 }
00055 
00056 void TApi::shutdownAll() {
00057   worker->shutdownAll();
00058 }
00059 
00060 void TApi::setRunNumber(int newRun) {
00061   worker->setRunNumber(newRun);
00062 }
00063 
00064 void TApi::setScanNumber(int newScan) {
00065   worker->setScanNumber(newScan);
00066 }
00067 
00068 void TApi::flashLED(unsigned int partition, unsigned int crate, unsigned int rod,
00069                     long slaveNumber, long period, long flashes) {
00070   worker->flashLED(rod, slaveNumber, period, flashes);
00071 }
00072 
00073 void TApi::echo(unsigned int partition, unsigned int crate, unsigned int rod,
00074                 unsigned int length, unsigned long *data) {
00075   worker->echo(rod, length, data);
00076 }
00077 
00078 void TApi::echoAll(unsigned int length, unsigned long *data) {
00079   worker->echoAll(length, data);
00080 }
00081 
00082 void TApi::echoSlave(unsigned int partition, unsigned int crate, unsigned int rod,
00083                      unsigned int slave, unsigned int length, unsigned long *data) {
00084   worker->echoSlave(rod, slave, length, data);
00085 }
00086 
00087 void TApi::awaitResponse(unsigned int partition, unsigned int crate, unsigned int rod, int timeout) {
00088   worker->awaitResponse(rod, timeout);
00089 }
00090 
00091 unsigned long *TApi::getResponse(unsigned int partition, unsigned int crate, unsigned int rod) {
00092   unsigned long length;
00093   unsigned long *result = worker->getResponse(rod, length);
00094   if(length < 2) result = 0;
00095   else {
00096     if(result[0] != length) {
00097       std::cout << "Result length mismatch!\n";
00098     }
00099   }
00100   return result;
00101 }
00102 
00103 unsigned long *TApi::getResponse(unsigned int partition, unsigned int crate, unsigned int rod, 
00104                                  unsigned long *length) {
00105   unsigned long myLength;
00106   unsigned long *result = worker->getResponse(rod, myLength);
00107   *length = myLength;
00108   return result;
00109 }
00110 
00111 // Get a message from a ROD text buffer
00112 bool TApi::getRodMessage(unsigned int partition, unsigned int crate, unsigned int rod, 
00113                          char *buffer, unsigned long &length) {
00114   return worker->getRodMessage(rod, buffer, length);
00115 }
00116 
00117 UINT32 TApi::findModule(const char *sn) {
00118   return worker->findModule(sn);
00119 }
00120 
00121 UINT32 TApi::findModule(INT32 mur, INT32 module) {
00122   return worker->findModule(mur, module);
00123 }
00124 
00125 void TApi::sendABCDModules(UINT32 bank, UINT32 type) {
00126   try {
00127     worker->sendAllABCDModules(SctApi::BankType(bank), SctApi::ConfigType(type));
00128   } catch(SctApi::SctApiException &e) {
00129     std::cout << "Got exception: " << e.what() << std::endl;
00130   }
00131 }
00132 
00133 void TApi::sendABCDModule(UINT32 mid, UINT32 bank, UINT32 type) {
00134   try {
00135     worker->sendABCDModule(mid, SctApi::BankType(bank), SctApi::ConfigType(type));
00136   } catch(SctApi::SctApiException &e) {
00137     std::cout << "Got exception: " << e.what() << std::endl;
00138   }
00139 }
00140 
00141 void TApi::getABCDModules(UINT32 bank) {
00142   worker->getABCDModules(SctApi::BankType(bank));
00143 }
00144 
00145 void TApi::getABCDModule(UINT32 mid, UINT32 bank) {
00146   worker->getABCDModule(mid, SctApi::BankType(bank));
00147 }
00148 
00149 void TApi::modifyABCDMask(UINT32 mid, UINT32* mask) {
00150   worker->modifyABCDMask(mid, mask);
00151 }
00152 
00153 void TApi::modifyABCDTrims(UINT32 mid, UINT8* trims) {
00154   worker->modifyABCDTrims(mid, trims);
00155 }
00156 
00157 void TApi::modifyABCDVar(UINT32 typ, FLOAT32 var) {
00158   worker->modifyABCDVar(typ, var);
00159 }
00160 
00161 void TApi::modifyABCDVar(UINT32 mid, UINT32 typ, FLOAT32 var) {
00162   worker->modifyABCDVar(mid, typ, var);
00163 }
00164 
00165 void TApi::modifyABCDVar(UINT32 mid, UINT32 c, UINT32 typ, FLOAT32 var) {
00166   worker->modifyABCDVar(mid, c, typ, var);
00167 }
00168 
00169 void TApi::modifyABCDVarROD(UINT32 mid, UINT32 chip, UINT32 typ, FLOAT32 var, UINT32 bank) {
00170   worker->modifyABCDVarROD(mid, chip, typ, var, std::list<SctApi::BankType>(1,SctApi::BankType(bank)));
00171 }
00172 
00173 void TApi::modifyABCDVarROD(UINT32 typ, FLOAT32 var, UINT32 bank) {
00174   worker->modifyABCDVarROD(typ, var, std::list<SctApi::BankType>(1,SctApi::BankType(bank)));
00175 }
00176 
00177 void TApi::modifyBOCParam(unsigned int partition, unsigned int crate, unsigned int rod,
00178                             unsigned int channel, unsigned int type, unsigned int val) {
00179   checkCall(boost::bind(&SctApi::SctApi::modifyBOCParam, worker, 
00180                         rod, channel, type, val));
00181 }
00182 
00183 void TApi::modifyBOCParam(unsigned int type, unsigned int val) {
00184   checkCall(boost::bind(&SctApi::SctApi::modifyBOCParam, worker, type, val));
00185 }
00186 
00187 void TApi::loadConfiguration() {
00188   worker->loadConfiguration();
00189 }
00190 
00191 void TApi::loadModuleConfigurations() {
00192   worker->loadModuleConfigurations();
00193 }
00194 
00195 void TApi::configureBOC(unsigned int partition, unsigned int crate, unsigned int rod) {
00196   worker->configureBOC(rod);
00197 }
00198 
00199 UINT32 TApi::findBarrelModule(INT32 barrel, INT32 row, INT32 number) {
00200   return worker->findBarrelModule(barrel, row, number);
00201 }
00202 
00203 UINT32 TApi::findEndcapModule(INT32 disk, INT32 ring, INT32 number) {
00204   return worker->findEndcapModule(disk, ring, number);
00205 }
00206 
00207 void TApi::addDebugPrimList(unsigned long length, long index, long id, long version,
00208                             unsigned long * body) {
00209   worker->addDebugPrimList(length, index, id, version, body);
00210 }
00211 
00212 void TApi::sendDebugPrimList(unsigned int partition, unsigned int crate, unsigned int rod) {
00213   worker->sendDebugPrimList(rod);
00214 }
00215 
00216 void TApi::sendDebugPrimListAll() {
00217   worker->sendDebugPrimListAll();
00218 }
00219 
00220 void TApi::sendDebugSlavePrimList(unsigned int partition, unsigned int crate, unsigned int rod,
00221                                   unsigned int slave, bool await, bool response) {
00222   worker->sendDebugSlavePrimList(rod, slave, await, response);
00223 }
00224 
00225 void TApi::createDebugPrimList() {
00226   worker->createDebugPrimList();
00227 }
00228 
00229 void TApi::debugPrimListFromFile(const char *fileName) {
00230   worker->debugPrimListFromFile(fileName);
00231 }
00232 
00233 void TApi::dumpDebugPrimList() {
00234   worker->dumpDebugPrimList();
00235 }
00236 
00237 std::list<SctApi::RodLabel> TApi::listRods() {
00238   return worker->listRods();
00239 }
00240 
00241 /*
00242   Dump contents of a block of DSP memory to cout.
00243 */
00244 int TApi::dspBlockDump(unsigned int partition, unsigned int crate, unsigned int rod,
00245                        long dspStart, long numWords, long dspNumber, bool usePrimitive){
00246   return worker->dspBlockDump(rod, dspStart, numWords, dspNumber, usePrimitive);
00247 }
00248 
00249 int TApi::dspBlockDumpFile(unsigned int partition, unsigned int crate, unsigned int rod,
00250                            long dspStart, long numWords, long dspNumber, const char *filename, bool usePrimitive)
00251 {
00252   return worker->dspBlockDumpFile(rod, dspStart, numWords, dspNumber, filename, usePrimitive);
00253 }
00254 
00255 /*
00256   Read contents of a block of DSP memory.
00257 */
00258 unsigned long *TApi::dspBlockRead(unsigned int partition, unsigned int crate, unsigned int rod,
00259                                   long dspStart, long numWords, long dspNumber, 
00260                                   unsigned long *length, bool usePrimitive) {
00261   unsigned long thing;
00262   unsigned long *result = worker->dspBlockRead(rod, dspStart, numWords, 
00263                                                dspNumber, thing, usePrimitive);
00264   *length = thing;
00265   return result;
00266 }
00267 
00268 int TApi::dspBlockWrite(unsigned int partition, unsigned int crate, unsigned int rod,
00269                         unsigned long *buffer, unsigned long dspAddress, long numWords, 
00270                         long dspNumber, bool usePrimitive) {
00271   return worker->dspBlockWrite(rod, 
00272                                buffer, dspAddress, numWords, dspNumber, usePrimitive);
00273 }
00274 
00275 unsigned long TApi::dspSingleRead(unsigned int partition, unsigned int crate, unsigned int rod,
00276                                   const unsigned long dspAddr, long dspNumber) {
00277   return worker->dspSingleRead(rod, dspAddr, dspNumber);
00278 }
00279 
00281 void TApi::dspSingleWrite(unsigned int partition, unsigned int crate, unsigned int rod,
00282                    unsigned long dspAddr, unsigned long value, long dspNumber) {
00283   worker->dspSingleWrite(rod, dspAddr, value, dspNumber);
00284 }
00285 
00286 void TApi::defaultScan(int type) {
00287   worker->defaultScan(type);
00288 }
00289 
00290 void TApi::tidyHistogramming() {
00291   worker->tidyHistogramming();
00292 }
00293 
00294 
00295 void TApi::doScan(TScanDef tScan) {
00296   tScan.update();
00297   boost::shared_ptr<SctApi::Scan> scan = tScan.getScan();
00298 
00299   try {
00300     if(scan)
00301       worker->doScan(scan);
00302     else 
00303       std::cout << "Bad scan at Root interface level\n";
00304   } catch(SctApi::SctApiException &s) {
00305     std::cout << "Exception thrown by doScan:\n";
00306     std::cout << s.what() << std::endl;
00307   }
00308 }
00309 
00310 void TApi::awaitScan() {
00311   worker->awaitScan();
00312 }
00313 
00314 void TApi::doRawScan(TScanDef tScan, int delay, int width, bool configure, bool clkBy2) {
00315   tScan.update();
00316   boost::shared_ptr<SctApi::Scan> scan = tScan.getScan();
00317 
00318   try {
00319     if(scan)
00320       worker->doRawScan(scan, delay, width, configure, clkBy2);
00321     else 
00322       std::cout << "Bad scan at Root interface level\n";
00323   } catch(SctApi::SctApiException &s) {
00324     std::cout << "SctApi Exception thrown by doRawScan:\n";
00325     std::cout << s.what() << std::endl;
00326   } catch(...) {
00327     std::cout << "Unknown Exception thrown by doRawScan:\n";
00328   }
00329 }
00330 
00331 void TApi::sendTrigger(unsigned int partition, unsigned int crate, unsigned int rod, TTrigger tTrig) {
00332   tTrig.update();
00333 
00334   boost::shared_ptr<SctApi::Trigger> trig = tTrig.getTrigger();
00335 
00336   if(trig)
00337     worker->sendTrigger(rod, trig.get());
00338   else 
00339     std::cout << "Bad trigger at Root interface level\n";
00340 }
00341 
00342 void TApi::status() {
00343   worker->status();
00344 }
00345 
00346 unsigned long TApi::readRodCommandReg(unsigned int partition, unsigned int crate, unsigned int rod,
00347                                       long regNumber) {
00348   return worker->readRodCommandReg(rod, regNumber);
00349 }
00350 
00351 unsigned long TApi::readRodStatusReg(unsigned int partition, unsigned int crate, unsigned int rod,
00352                                      long regNumber) {
00353   return worker->readRodStatusReg(rod, regNumber);
00354 }
00355 
00356 void TApi::setABCDModule(UINT32 mid, UINT32 bank) {
00357   try {
00358     worker->setABCDModule(mid, std::list<SctApi::BankType>(1,SctApi::BankType(bank)));
00359   } catch(SctApi::SctApiException &s) {
00360     std::cout << "Exception thrown by setABCDModule:\n";
00361     std::cout << s.what() << std::endl;
00362   }
00363 }
00364 
00365 void TApi::setABCDModules(UINT32 bank) {
00366   try {
00367     worker->setABCDModules(std::list<SctApi::BankType>(1,SctApi::BankType(bank)));
00368   } catch(SctApi::SctApiException &s) {
00369     std::cout << "Exception thrown by setABCDModules:\n";
00370     std::cout << s.what() << std::endl;
00371   }
00372 }
00373 
00374 unsigned long *TApi::retrieveModule(UINT32 mid) {
00375   return (unsigned long*)worker->retrieveModule(mid);
00376 }
00377 
00378 void TApi::printABCDModule(int mid) {
00379   worker->printABCDModule(mid);
00380 }
00381 
00382 void TApi::printABCDRodModule(int mid, int bank) {
00383   checkCall(boost::bind(&SctApi::SctApi::printABCDRodModule, worker, 
00384                         mid, SctApi::BankType(bank)));
00385 }
00386 
00387 void TApi::printBOCSetup(unsigned int partition, unsigned int crate, unsigned int rod) {
00388   checkCall(boost::bind(&SctApi::SctApi::printBOCSetup, worker, 
00389                         rod));
00390 }
00391 
00392 void TApi::currentBOCSetup(unsigned int partition, unsigned int crate, unsigned int rod) {
00393   try {
00394     std::vector<SctConfiguration::BOCChannelConfig> setup = worker->currentBOCSetup(rod);
00395 
00396     std::cout << "Got setup length " << setup.size() << std::endl;
00397 
00398     for(unsigned int i=0; i<setup.size(); i++) {
00399       SctConfiguration::BOCChannelConfig conf = setup[i];
00400 
00401       std::cout << conf.current << " " << conf.delay << " " << conf.markSpace << std::endl;
00402       std::cout << conf.threshold0 << " " << conf.delay0 << std::endl;
00403       std::cout << conf.threshold1 << " " << conf.delay1 << std::endl;
00404     }
00405   } catch(SctApi::SctApiException &s) {
00406     std::cout << "Exception in currentBOCSetup " << s.what() << std::endl;
00407   }
00408 }
00409 
00410 void TApi::printBOCRegisters(unsigned int partition, unsigned int crate, unsigned int rod) {
00411   checkCall(boost::bind(&SctApi::SctApi::printBOCRegisters, worker, rod));
00412 }
00413 
00414 // void TApi::currentBOCRegisters(unsigned int partition, unsigned int crate, unsigned int rod) {
00415 //   checkCall(boost::bind(&SctApi::SctApi::currentBOCRegisters, worker, rod));
00416 // }
00417 
00418 void TApi::saveBOCSetup(unsigned int partition, unsigned int crate, unsigned int rod, UINT32 bank) {
00419   worker->saveBOCSetup(rod, SctApi::BankType(bank));
00420 }
00421 
00422 void TApi::saveBOCRegisters(unsigned int partition, unsigned int crate, unsigned int rod, UINT32 bank) {
00423   worker->saveBOCRegisters(rod, SctApi::BankType(bank));
00424 }
00425 
00426 void TApi::restoreBOCSetup(unsigned int partition, unsigned int crate, unsigned int rod, UINT32 bank) {
00427   worker->restoreBOCSetup(rod, SctApi::BankType(bank));
00428 }
00429 
00430 void TApi::restoreBOCRegisters(unsigned int partition, unsigned int crate, unsigned int rod, UINT32 bank) {
00431   worker->restoreBOCRegisters(rod, SctApi::BankType(bank));
00432 }
00433 
00434 void TApi::rawData(unsigned int partition, unsigned int crate, unsigned int rod, 
00435                    int delay, int units, bool setMask, TTrigger tTrig) {
00436   tTrig.update();
00437 
00438   boost::shared_ptr<SctApi::Trigger> trig = tTrig.getTrigger();
00439 
00440   if(trig)
00441     worker->rawData(rod, delay, units, setMask, trig.get());
00442   else 
00443     std::cout << "Bad trigger to raw data at Root interface level\n";
00444 }
00445 
00446 char *TApi::probe(unsigned int partition, unsigned int crate, unsigned int rod, signed int harness) {
00447   std::vector<char> result = worker->probe(rod, harness);
00448   int length = result.size();
00449   char *buffer = new char[length + 1];
00450 
00451   for (int i=0; i<length; i++) {
00452     buffer[i] = result[i];
00453   }
00454 
00455   buffer[length] = 0;
00456 
00457   return buffer;
00458 }
00459 
00460 char *TApi::probeWithTrigger(unsigned int partition, unsigned int crate, unsigned int rod, 
00461                              TTrigger tTrig, signed int harness) {
00462   tTrig.update();
00463 
00464   boost::shared_ptr<SctApi::Trigger> trig = tTrig.getTrigger();
00465 
00466   if(trig) {
00467     std::vector<char> result = worker->probeWithTrigger(rod, trig.get(), harness);
00468     int length = result.size();
00469     char *buffer = new char[length + 1];
00470 
00471     for (int i=0; i<length; i++) {
00472       buffer[i] = result[i];
00473     }
00474 
00475     buffer[length] = 0;
00476 
00477     return buffer;
00478   } else {
00479     std::cout << "Bad trigger to raw data at Root interface level\n";
00480     return 0;
00481   }
00482 }
00483 
00484 void TApi::probeScan(unsigned int partition, unsigned int crate, unsigned int rod, 
00485                      TScanDef tScan, signed int harness) {
00486   tScan.update();
00487   boost::shared_ptr<SctApi::Scan> scan = tScan.getScan();
00488 
00489   if(!scan) {
00490     std::cout << "Bad scan at Root interface level\n";
00491     return;
00492   }
00493 
00494   std::cout << "Summary\n";
00495   std::vector< std::vector <char> > result = worker->probeScan(rod, scan, harness);
00496   int outerLength = result.size();
00497   int innerLength = 0;
00498   if(outerLength > 0) {
00499     innerLength = result[0].size();
00500   }
00501   for(int i=0; i<innerLength; i++) {
00502     for(int j=0; j<outerLength; j++) {
00503       std::cout << result[j][i];
00504     }
00505     std::cout << std::endl;
00506   }
00507 }
00508 
00509 bool TApi::checkAllModulesProbe(const char *value) {
00510   return worker->checkAllModulesProbe(value);
00511 }
00512 
00513 void TApi::autoConfigure() {
00514   ::SctApi::AutoConf::AutoConfigurer configurer(*worker);
00515   configurer.run();
00516 
00517   std::list< ::SctApi::AutoConf::AutoResult> results = configurer.getResults();
00518 
00519   std::cout << results.size() << " auto-configure results:\n";
00520 
00521   for(std::list< ::SctApi::AutoConf::AutoResult>::const_iterator autoIter = results.begin();
00522       autoIter != results.end(); autoIter ++) {
00523     const ::SctApi::AutoConf::AutoResult &autoResult = *autoIter;
00524 
00525     std::cout << "r: " << autoResult.rod << " tx: " << autoResult.tx << " rx: " << autoResult.rx << std::endl;
00526   }
00527 }
00528 
00529 void TApi::rodMode(unsigned int partition, unsigned int crate, unsigned int rod,
00530                    int mode, int flag, int fifoSetup, int nBins, int delay, int message) {
00531   worker->rodMode(rod, 
00532                   mode, flag, fifoSetup, nBins, delay, message);
00533 }
00534 
00535 void TApi::bocHistogram(unsigned int partition, unsigned int crate, unsigned int rod, 
00536                         unsigned int samples, unsigned int numLoops)
00537 {
00538   worker->bocHistogram(rod, samples, numLoops);
00539 }
00540 
00541 void TApi::testLinkOutSelect(unsigned int partition, unsigned int crate, unsigned int rod,
00542                              unsigned int link) {
00543   worker->testLinkOutSelect(rod, link);
00544 }
00545 
00546 void TApi::setDebugOption(const char *opt) {
00547   worker->setDebugOption(opt);
00548 }
00549 
00550 void TApi::unsetDebugOption(const char *opt) {
00551   worker->unsetDebugOption(opt);
00552 }
00553 
00554 void TApi::listEnabledDebugOptions() {
00555   std::list<std::string> theList = worker->listEnabledDebugOptions();
00556   for(std::list<std::string>::const_iterator i = theList.begin();
00557       i != theList.end();
00558       i++) {
00559     std::cout << *i << std::endl;
00560   }
00561 }
00562 
00563 void TApi::listDebugOptions() {
00564   std::vector<std::string> theList = worker->listDebugOptions();
00565   for(std::vector<std::string>::const_iterator i = theList.begin();
00566       i != theList.end();
00567       i++) {
00568     std::cout << *i << std::endl;
00569   }
00570 }
00571 
00572 void TApi::debugStepHistogram() 
00573 {
00574   worker->debugStepHistogram();
00575 }
00576 
00577 void TApi::debugContinueHistogram()
00578 {
00579   worker->debugContinueHistogram();
00580 }
00581 
00582 void TApi::debugAbortHistogram()
00583 {
00584   worker->debugAbortHistogram();
00585 }
00586 
00587 void TApi::standardRegisterDump(unsigned int partition, unsigned int crate, unsigned int rod) 
00588 {
00589   worker->standardRegisterDump(rod);
00590 }
00591 
00592 void TApi::lasersOff() {
00593   worker->lasersOff();
00594 }
00595 
00596 void TApi::scanEvents(unsigned int partition, unsigned int crate, unsigned int rod, int sl, 
00597                       bool extFlag, bool errorType) {
00598   worker->scanEvents(rod, sl, extFlag, errorType);
00599 }
00600 
00601 void TApi::decodeEvent(unsigned int partition, unsigned int crate, unsigned int rod, 
00602                        int sl, int index, bool extFlag, bool errorType) {
00603   worker->decodeEvent(rod, sl, index, extFlag, errorType);
00604 }
00605 
00606 void TApi::decodeConfig(unsigned int partition, unsigned int crate, unsigned int rod, 
00607                         bool skipTrim, bool bypass) {
00608   worker->decodeConfig(rod, skipTrim, bypass);
00609 }
00610 
00611 void TApi::timSetFrequency(unsigned int partition, unsigned int crate, 
00612                            double trigFreq, double rstFreq) {
00613   worker->timSetFrequency(trigFreq, rstFreq);
00614 }
00615 
00616 void TApi::freeTriggers(unsigned int partition, unsigned int crate) {
00617   worker->freeTriggers();
00618 }
00619 
00620 void TApi::stopTriggers(unsigned int partition, unsigned int crate) {
00621   worker->stopTriggers();
00622 }
00623 
00624 void TApi::timL1A(unsigned int partition, unsigned int crate) {
00625   worker->timL1A();
00626 }
00627 
00628 void TApi::timCalL1A(unsigned int partition, unsigned int crate, int delay) {
00629   worker->timCalL1A(delay);
00630 }
00631 
00632 void TApi::timSoftReset(unsigned int partition, unsigned int crate) {
00633   worker->timSoftReset();
00634 }
00635 
00636 void TApi::timBCReset(unsigned int partition, unsigned int crate) {
00637   worker->timBCReset();
00638 }
00639 
00640 void TApi::sendTimBurst(unsigned int partition, unsigned int crate, int count) {
00641   checkCall(boost::bind(&SctApi::SctApi::sendTimBurst, worker, count));
00642 }
00643 
00644 void TApi::timVerbose(unsigned int partition, unsigned int crate) {
00645   worker->timVerbose();
00646 }
00647 
00648 void TApi::timRegLoad(unsigned int partition, unsigned int crate, int reg, UINT16 val) {
00649   worker->timWriteRegister(reg, val);
00650 }
00651 
00652 UINT16 TApi::timReadRegister(unsigned int partition, unsigned int crate, int reg) {
00653   return worker->timReadRegister(reg);
00654 }
00655 
00656 void TApi::requestHardReset(UINT32 mid) {
00657   worker->getSctApiDDC()->requestHardReset(mid);
00658 }
00659 
00660 void TApi::resumePolling() {
00661   worker->resumePolling();
00662 }
00663 
00664 void TApi::stopPolling() {
00665   worker->stopPolling();
00666 }
00667 
00668 
00669 TScanDef::TScanDef() :
00670   trigsPerBurst(200),
00671   scanVariable(1),  scanVariable2(1),
00672   full(0), bits32(0), loopCalLine(0),
00673   distSlave(0), debug(0), tim(0), nth(0), nth_rem(0),
00674   enableDataMode(true)
00675 {
00676   worker.reset(new SctApi::ScanDefImpl);
00677   // A large threshold scan
00678   configure(1, 0.0, 400.0, 5.0);
00679 
00680   // With a single L1A trigger
00681   trigSequence.singleL1A();
00682 
00683   // So the worker has pointers to the TriggerImpl's in the trigsequences
00684   update();
00685 }
00686 
00687 TScanDef::~TScanDef() {
00688 //   delete worker;
00689 }
00690 
00691 TScanDef::TScanDef(const TScanDef &other) :
00692   trigsPerBurst(other.trigsPerBurst),
00693 
00694   scanVariable(other.scanVariable),
00695   scanVariable2(other.scanVariable2),
00696 
00697   trigSequence(other.trigSequence),
00698   trigSequence2(other.trigSequence2),
00699 
00700   full(other.full), 
00701   bits32(other.bits32),
00702   loopCalLine(other.loopCalLine),
00703 
00704   distSlave(other.distSlave),
00705   debug(other.debug),
00706   tim(other.tim),
00707   nth(other.nth),
00708   nth_rem(other.nth_rem),
00709   enableDataMode(other.enableDataMode)
00710 {
00711   worker.reset(new SctApi::ScanDefImpl(*other.worker));
00712 }
00713 
00714 void TScanDef::update() {
00715   // Only copy the things which are defined as parameters
00716   // (ScanPoints are set up in worker by the configure method)
00717   if(trigsPerBurst != -1)
00718     worker->setNTrigs(trigsPerBurst);
00719 
00720   worker->setScanVariable1(scanVariable);
00721   worker->setScanVariable2(scanVariable2);
00722 
00723   // Copy triggers
00724   trigSequence.update();
00725   worker->setTrigger1(trigSequence.getTrigger());
00726   trigSequence2.update();
00727   worker->setTrigger2(trigSequence2.getTrigger());
00728 
00729   // Set options
00730   worker->setOption(SctApi::Scan::FULL, full);
00731   worker->setOption(SctApi::Scan::BITS32, bits32);
00732   worker->setOption(SctApi::Scan::LOOPCALLINE, loopCalLine);
00733   worker->setOption(SctApi::Scan::DISTSLAVE, distSlave);
00734   worker->setOption(SctApi::Scan::DEBUG, debug);
00735   worker->setOption(SctApi::Scan::TIM, tim);
00736   worker->setOption(SctApi::Scan::NTH, nth);
00737   worker->setOption(SctApi::Scan::NTH_REM, nth_rem);
00738   worker->setOption(SctApi::Scan::ENABLE_DATA_MODE, enableDataMode);
00739 }
00740 
00741 void TScanDef::print() {
00742   update();
00743   worker->print(); // copyScan(this).print();
00744 }
00745 
00746 void TScanDef::configure(UINT16 type, FLOAT32 start, FLOAT32 stop, FLOAT32 step) {
00747   scanVariable = type;
00748   worker->configure(type, start, stop, step);
00749 }
00750 
00751 void TScanDef::configure2(UINT16 type, FLOAT32 start, FLOAT32 stop, FLOAT32 step) {
00752   scanVariable2 = type;
00753   worker->configure2(type, start, stop, step);
00754 }
00755 
00756 void TScanDef::setScanPoint(int index, FLOAT32 value) {
00757   worker->scanPoints[index] = value;
00758 }
00759 
00760 void TScanDef::setScanPoint2(int index, FLOAT32 value) {
00761   worker->scanPoints2[index] = value;
00762 }
00763 
00764 void TScanDef::setTriggersPoint(int index, UINT32 nTrigs) {
00765   if(trigsPerBurst != -1) {
00766     worker->setNTrigs(trigsPerBurst);
00767   }
00768   trigsPerBurst = -1;
00769   worker->allTrigsSame = false;
00770   worker->trigPoints[index] = nTrigs;
00771 }
00772 
00773 // This is the default for both set 0 and set 1
00774 TTrigger::TTrigger() {
00775   worker.reset(new SctApi::TriggerImpl);
00776   incCmd = 0;
00777   incData = 0;
00778 
00779   update();
00780 }
00781 
00782 TTrigger::TTrigger(const TTrigger &other) {
00783   worker.reset(new SctApi::TriggerImpl(*other.worker));
00784   incCmd = other.incCmd;
00785   incData = other.incData;
00786 }
00787 
00788 TTrigger::~TTrigger() {
00789   // This is deleted by ScanDefImpl not via TScanDef
00790   //  delete worker;
00791 }
00792 
00793 void TTrigger::singleL1A() {
00794   worker->singleL1A();
00795 }
00796 
00797 void TTrigger::doubleL1A(int delay) {
00798   worker->doubleL1A(delay);
00799 }
00800 
00801 void TTrigger::delayedL1A(int delay) {
00802   worker->delayedL1A(delay);
00803 }
00804 
00805 void TTrigger::calL1A(int delay) {
00806   worker->calL1A(delay);
00807 }
00808 
00809 void TTrigger::pulseL1A(int delay) {
00810   worker->pulseL1A(delay);
00811 }
00812 
00813 void TTrigger::softL1A(int delay) {
00814   worker->softL1A(delay);
00815 }
00816 
00817 void TTrigger::softCalL1A(int delay, int delay2) {
00818   worker->softCalL1A(delay, delay2);
00819 }
00820 
00821 void TTrigger::softPulseL1A(int delay, int delay2) {
00822   worker->softPulseL1A(delay, delay2);
00823 }
00824 
00825 void TTrigger::bcL1A(int delay) {
00826   worker->bcL1A(delay);
00827 }
00828 
00829 void TTrigger::bcCalL1A(int delay, int delay2) {
00830   worker->bcCalL1A(delay, delay2);
00831 }
00832 
00833 void TTrigger::bcPulseL1A(int delay, int delay2) {
00834   worker->bcPulseL1A(delay, delay2);
00835 }
00836 
00837 void TTrigger::update() {
00838   worker->setCommIncr(incCmd, incData);
00839 }
00840 
00841 boost::shared_ptr<SctApi::Trigger> TriggerWrapper::getTrigger() {
00842   return worker;
00843 }
00844 
00845 // Copy TScanDef scan to implementation of Scan interface 
00846 //   update(); must be called on the scan first
00847 boost::shared_ptr<SctApi::Scan> ScanDefWrapper::getScan() {
00848 //   if((tScan.trigSequence.trigCommand.GetSize() != tScan.trigSequence.trigData.GetSize()) ||
00849 //      (tScan.trigSequence2.trigCommand.GetSize() != tScan.trigSequence2.trigData.GetSize()) ||
00850 //      ((tScan.trigSequence.trigCommand.GetSize() != tScan.trigSequence2.trigCommand.GetSize()) && 
00851 //       (tScan.trigSequence2.trigData.GetSize() != 0))) {
00852 //     cout << "Trigger arrays not compatible! Aborting scan...\n";
00853 //     return;
00854 //   }
00855 
00856   return worker;
00857 }

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