00001
00002
00025 #include <iostream>
00026
00027 #include <vector>
00028
00029 #include "ScanDefImpl.h"
00030 #include "TriggerImpl.h"
00031 #include "SctApiException.h"
00032 #include "SctApiHisto.h"
00033 #include "ConfigurationUtility.h"
00034 #include "Sct/AbcdChip.h"
00035
00036 using namespace SctApi;
00037 using namespace boost;
00038 using namespace boost::posix_time;
00039
00040 #include "crate.h"
00041 #include "RodCrate/TimDefine.h"
00042
00043 SctApiException::SctApiException(const CrateException &c) throw() : desc(c.what()) {}
00044
00045 TriggerImpl::TriggerImpl()
00046 {
00047 incCmd = incData = 0;
00048 m_source = SOURCE_UNKNOWN;
00049 m_freq=40.;
00050 m_random=0;
00051 }
00052
00053 TriggerImpl::TriggerImpl(const TriggerImpl &other) :
00054 trigSequence(other.trigSequence), incCmd(other.incCmd), incData(other.incData),
00055 m_source(other.m_source), m_freq(other.m_freq), m_random(other.m_random)
00056 {
00057 }
00058
00059 boost::shared_ptr<TriggerImpl> TriggerImpl::clone(const boost::shared_ptr< ::SctApi::Trigger> other) {
00060 boost::shared_ptr<TriggerImpl> result(new TriggerImpl());
00061
00062 result->trigSequence = other->getRODTriggers();
00063
00064 unsigned short command;
00065 unsigned short incr;
00066 other->getCommIncr(command, incr);
00067
00068 result->incCmd = command;
00069 result->incData = incr;
00070 result->m_source = other->getSource();
00071 result->m_freq= other->getFrequency();
00072 result->m_random = other->getRandom();
00073
00074 return result;
00075 }
00076
00077 TriggerImpl::~TriggerImpl()
00078 {
00079 }
00080
00081 void TriggerImpl::clear() {
00082 trigSequence.clear();
00083 }
00084
00085 void TriggerImpl::addCommand(UINT16 first, UINT32 second) {
00086 trigSequence.push_back(std::make_pair(first, second));
00087 }
00088
00089 void TriggerImpl::singleL1A()
00090 {
00091 trigSequence.clear();
00092
00093 trigSequence.push_back(std::make_pair(L1_TRIGGER, 0));
00094
00095 incCmd = incData = 0;
00096 }
00097
00098 void TriggerImpl::doubleL1A(unsigned short delay)
00099 {
00100 trigSequence.clear();
00101
00102 trigSequence.push_back(std::make_pair(L1_TRIGGER, 0));
00103 trigSequence.push_back(std::make_pair(DELAY, delay));
00104 trigSequence.push_back(std::make_pair(L1_TRIGGER, 0));
00105
00106 incCmd = incData = 0;
00107 }
00108
00109 void TriggerImpl::delayedL1A(unsigned short delay)
00110 {
00111 trigSequence.clear();
00112
00113 trigSequence.push_back(std::make_pair(DELAY, delay));
00114 trigSequence.push_back(std::make_pair(L1_TRIGGER, 0));
00115
00116 incCmd = incData = 0;
00117 }
00118
00119 void TriggerImpl::calL1A(unsigned short delay)
00120 {
00121 trigSequence.clear();
00122
00123 trigSequence.push_back(std::make_pair(CALIBRATION_PULSE, 0));
00124 trigSequence.push_back(std::make_pair(DELAY, delay));
00125 trigSequence.push_back(std::make_pair(L1_TRIGGER, 0));
00126
00127 incCmd = incData = 0;
00128 }
00129
00130 void TriggerImpl::pulseL1A(unsigned short delay)
00131 {
00132 trigSequence.clear();
00133
00134 trigSequence.push_back(std::make_pair(PULSE_INPUT_REG, 0));
00135 trigSequence.push_back(std::make_pair(DELAY, delay));
00136 trigSequence.push_back(std::make_pair(L1_TRIGGER, 0));
00137
00138 incCmd = incData = 0;
00139 }
00140
00141 void TriggerImpl::softL1A(unsigned short delay)
00142 {
00143 trigSequence.clear();
00144
00145 trigSequence.push_back(std::make_pair(SOFT_RESET, 0));
00146 trigSequence.push_back(std::make_pair(DELAY, delay));
00147 trigSequence.push_back(std::make_pair(L1_TRIGGER, 0));
00148
00149 incCmd = incData = 0;
00150 }
00151
00152 void TriggerImpl::softCalL1A(unsigned short delay, unsigned short delay2)
00153 {
00154 trigSequence.clear();
00155
00156 trigSequence.push_back(std::make_pair(SOFT_RESET, 0));
00157 trigSequence.push_back(std::make_pair(DELAY, delay));
00158 trigSequence.push_back(std::make_pair(CALIBRATION_PULSE, 0));
00159 trigSequence.push_back(std::make_pair(DELAY, delay2));
00160 trigSequence.push_back(std::make_pair(L1_TRIGGER, 0));
00161
00162 incCmd = incData = 0;
00163 }
00164
00165 void TriggerImpl::softPulseL1A(unsigned short delay, unsigned short delay2)
00166 {
00167 trigSequence.clear();
00168
00169 trigSequence.push_back(std::make_pair(SOFT_RESET, 0));
00170 trigSequence.push_back(std::make_pair(DELAY, delay));
00171 trigSequence.push_back(std::make_pair(PULSE_INPUT_REG, 0));
00172 trigSequence.push_back(std::make_pair(DELAY, delay2));
00173 trigSequence.push_back(std::make_pair(L1_TRIGGER, 0));
00174
00175 incCmd = incData = 0;
00176 }
00177
00178 void TriggerImpl::softBc(unsigned short delay)
00179 {
00180 trigSequence.clear();
00181
00182 trigSequence.push_back(std::make_pair(SOFT_RESET, 0));
00183 trigSequence.push_back(std::make_pair(DELAY, delay));
00184 trigSequence.push_back(std::make_pair(BC_RESET, 0));
00185
00186 incCmd = incData = 0;
00187 }
00188
00189 void TriggerImpl::soft()
00190 {
00191 trigSequence.clear();
00192
00193 trigSequence.push_back(std::make_pair(SOFT_RESET, 0));
00194
00195 incCmd = incData = 0;
00196 }
00197
00198 void TriggerImpl::bc()
00199 {
00200 trigSequence.clear();
00201
00202 trigSequence.push_back(std::make_pair(BC_RESET, 0));
00203
00204 incCmd = incData = 0;
00205 }
00206
00207 void TriggerImpl::bcL1A(unsigned short delay)
00208 {
00209 trigSequence.clear();
00210
00211 trigSequence.push_back(std::make_pair(BC_RESET, 0));
00212 trigSequence.push_back(std::make_pair(DELAY, delay));
00213 trigSequence.push_back(std::make_pair(L1_TRIGGER, 0));
00214
00215 incCmd = incData = 0;
00216 }
00217
00218 void TriggerImpl::bcCalL1A(unsigned short delay, unsigned short delay2)
00219 {
00220 trigSequence.clear();
00221
00222 trigSequence.push_back(std::make_pair(BC_RESET, 0));
00223 trigSequence.push_back(std::make_pair(DELAY, delay));
00224 trigSequence.push_back(std::make_pair(CALIBRATION_PULSE, 0));
00225 trigSequence.push_back(std::make_pair(DELAY, delay2));
00226 trigSequence.push_back(std::make_pair(L1_TRIGGER, 0));
00227
00228 incCmd = incData = 0;
00229 }
00230
00231 void TriggerImpl::bcPulseL1A(unsigned short delay, unsigned short delay2)
00232 {
00233 trigSequence.clear();
00234
00235 trigSequence.push_back(std::make_pair(BC_RESET, 0));
00236 trigSequence.push_back(std::make_pair(DELAY, delay));
00237 trigSequence.push_back(std::make_pair(PULSE_INPUT_REG, 0));
00238 trigSequence.push_back(std::make_pair(DELAY, delay2));
00239 trigSequence.push_back(std::make_pair(L1_TRIGGER, 0));
00240
00241 incCmd = incData = 0;
00242 }
00243
00244 void TriggerImpl::setCommIncr(unsigned short command, unsigned short incr)
00245 {
00246 incCmd = command;
00247 incData = incr;
00248 }
00249
00250 void TriggerImpl::getCommIncr(unsigned short &command, unsigned short &incr) const
00251 {
00252 command = incCmd;
00253 incr = incData;
00254 }
00255
00256 const ::SctApi::Trigger::RODTriggers TriggerImpl::getRODTriggers(int scan_point) const
00257 {
00258 ::SctApi::Trigger::RODTriggers out_trigs = trigSequence;
00259 if (incCmd<out_trigs.size() && incCmd>=0){
00260 out_trigs[incCmd].second+=incData*scan_point;
00261 }
00262 return out_trigs;
00263 }
00264
00265 const ::SctApi::Trigger::TIMTriggers TriggerImpl::getTIMTriggers(int scan_point) const {
00266 return convertToTIMTriggers(getRODTriggers(scan_point));
00267 }
00268
00269
00270 bool TriggerImpl::isValidRODTrigger() const{
00271 return trigSequence.size()<=6;
00272 }
00273
00274
00275 bool TriggerImpl::isValidTIMTrigger() const{
00276 for (::SctApi::Trigger::RODTriggers::const_iterator i=trigSequence.begin(); i!=trigSequence.end(); ++i){
00277 switch (i->first) {
00278
00279 case L1_TRIGGER : case BC_RESET :
00280 case SOFT_RESET : case DELAY:
00281 case CALIBRATION_PULSE : continue;
00282
00283 default: return false;
00284 }
00285 }
00286 return true;
00287 }
00288
00289 bool TriggerImpl::timNeedsSequencer() const{
00290 if (trigSequence.empty()) return false;
00291 if (trigSequence.size()==1 && trigSequence[0].first==L1_TRIGGER) return false;
00292 return true;
00293 }
00294
00295 void TriggerImpl::setFrequency(double freq){
00296 m_freq=freq;
00297 }
00298
00299 double TriggerImpl::getFrequency() const{
00300 return m_freq;
00301 }
00302
00303 Trigger::Source TriggerImpl::getSource() const{
00304 return m_source;
00305 }
00306
00307 void TriggerImpl::setSource(Trigger::Source s){
00308 m_source=s;
00309 }
00310
00311 int TriggerImpl::getRandom() const{
00312 return m_random;
00313 }
00314
00315 void TriggerImpl::setRandom(int r){
00316 m_random=r;
00317 }
00318
00319 #if 0
00320 void TriggerImpl::copy(const ::SctApi::Trigger &trig)
00321 {
00322 short unsigned cmd, data;
00323
00324 trig.getCommIncr(cmd, data);
00325
00326 incCmd = cmd;
00327 incData = data;
00328 m_source = trig.getSource();
00329 m_freq = trig.getFrequency();
00330 m_random = trig.getRandom();
00331
00332 trigSequence = trig.getRODTriggers();
00333 }
00334 #endif
00335
00336 ScanDefImpl::ScanDefImpl()
00337 : allTrigsSame(true),
00338 scanVariable(0), scanVariable2(0),
00339 trigSequence(new TriggerImpl), trigSequence2(new TriggerImpl),
00340 full(0),
00341 bits32(1),
00342 loopCalLine(0),
00343 distSlave(1),
00344 debug(0),
00345 tim(0),
00346 nth(0), nth_rem(0),
00347 enableDataMode(true),
00348 ccode(0),
00349 ope(0),
00350 scanNumber(0),
00351 runNumber(0),
00352 m_maxGroup(0),
00353 startTime(second_clock::universal_time()),
00354 endTime(second_clock::universal_time())
00355 {
00356 trigPoints.clear();
00357 scanPoints.clear();
00358 scanPoints2.clear();
00359 }
00360
00361 ScanDefImpl::~ScanDefImpl()
00362 {
00363
00364
00365 }
00366
00367 ScanDefImpl::ScanDefImpl(const ScanDefImpl &other) :
00368
00369 scanPoints(other.scanPoints),
00370 scanPoints2(other.scanPoints2),
00371 trigPoints(other.trigPoints),
00372 allTrigsSame(other.allTrigsSame),
00373 scanVariable(other.scanVariable),
00374 scanVariable2(other.scanVariable2),
00375
00376 trigSequence(TriggerImpl::clone(other.trigSequence)),
00377 trigSequence2(TriggerImpl::clone(other.trigSequence2)),
00378
00379 full(other.full),
00380 bits32(other.bits32),
00381 loopCalLine(other.loopCalLine),
00382
00383 distSlave(other.distSlave),
00384 debug(other.debug),
00385 tim(other.tim),
00386 nth(other.nth),
00387 nth_rem(other.nth_rem),
00388 enableDataMode(other.enableDataMode),
00389 ccode(other.ccode),
00390 ope(other.ope),
00391
00392 scanNumber(other.scanNumber),
00393 runNumber(other.runNumber),
00394 groupLists(other.groupLists),
00395 m_maxGroup(other.m_maxGroup),
00396
00397 startTime(other.startTime),
00398 endTime(other.endTime)
00399 {
00400 }
00401
00402 boost::shared_ptr<ScanDefImpl> ScanDefImpl::clone(const boost::shared_ptr<const ::SctApi::Scan> other) {
00403 std::cout << "Starting ScanDefImpl::clone ... " << std::endl;
00404 boost::shared_ptr<ScanDefImpl> result(new ScanDefImpl);
00405
00406 result->scanPoints = other->getScanPoints1();
00407 result->scanPoints2 = other->getScanPoints2();
00408
00409 result->trigPoints = other->getVariableTrigs();
00410 result->scanVariable = other->getScanVariable1();
00411 result->scanVariable2 = other->getScanVariable2();
00412
00413 result->trigSequence = TriggerImpl::clone(other->getTrigger1());
00414 result->trigSequence2 = TriggerImpl::clone(other->getTrigger2());
00415
00416 result->full = other->getOption(Scan::FULL);
00417 result->bits32 = other->getOption(Scan::BITS32);
00418 result->loopCalLine = other->getOption(Scan::LOOPCALLINE);
00419 result->distSlave = other->getOption(Scan::DISTSLAVE);
00420 result->debug = other->getOption(Scan::DEBUG);
00421 result->tim = other->getOption(Scan::TIM);
00422 result->nth = other->getOption(Scan::NTH);
00423 result->nth_rem = other->getOption(Scan::NTH_REM);
00424 result->enableDataMode = other->getOption(Scan::ENABLE_DATA_MODE);
00425 result->ccode = other->getOption(Scan::USE_CCODE);
00426 result->ope = other->getOption(Scan::OPE);
00427
00428
00429
00430
00431
00432
00433 #if !USE_CONST_SCAN
00434 result->startTime = other->getStartTime();
00435 result->endTime = other->getEndTime();
00436 #endif
00437
00438 std::cout << "Finishing ScanDefImpl::clone ... " << std::endl;
00439 return result;
00440 }
00441
00442 void ScanDefImpl::configure(unsigned short type, float start, float stop, float step)
00443 {
00444 scanVariable = type;
00445
00446
00447 int npoints = int(((stop - start) / step) + 1.001);
00448
00449 scanPoints.resize(npoints);
00450
00451 for(int i=0; i<npoints; i++) {
00452 FLOAT32 point = start + i * step;
00453 scanPoints[i] = point;
00454 }
00455
00456 if(allTrigsSame) {
00457
00458 int newNTrig = trigPoints.size() > 0?trigPoints[0]:0;
00459 trigPoints.resize(std::max(1U, scanPoints.size()), newNTrig);
00460 }
00461 }
00462
00463 void ScanDefImpl::configure2(unsigned short type, float start, float stop, float step)
00464 {
00465 scanVariable2 = type;
00466
00467 int npoints = int(((stop - start) / step) + 1.001);
00468
00469 scanPoints2.resize(npoints);
00470
00471 for(int i=0; i<npoints; i++) {
00472 FLOAT32 point = start + i * step;
00473 scanPoints2[i] = point;
00474 }
00475 }
00476
00477 const boost::shared_ptr< ::SctApi::Trigger> ScanDefImpl::getTrigger1() const
00478 {
00479 return trigSequence;
00480 }
00481
00482 const boost::shared_ptr< ::SctApi::Trigger> ScanDefImpl::getTrigger2() const
00483 {
00484 return trigSequence2;
00485 }
00486
00487 boost::shared_ptr< ::SctApi::Trigger> ScanDefImpl::getTrigger1()
00488 {
00489 return trigSequence;
00490 }
00491
00492 boost::shared_ptr< ::SctApi::Trigger> ScanDefImpl::getTrigger2()
00493 {
00494 return trigSequence2;
00495 }
00496
00497 void ScanDefImpl::setTrigger1(boost::shared_ptr< ::SctApi::Trigger> trigger)
00498 {
00499 trigSequence = trigger;
00500
00501
00502
00503 }
00504
00505 void ScanDefImpl::setTrigger2(boost::shared_ptr< ::SctApi::Trigger> trigger)
00506 {
00507 trigSequence2 = trigger;
00508
00509
00510
00511 }
00512
00513 void ScanDefImpl::setScanVariable1(unsigned short var)
00514 {
00515 scanVariable = var;
00516 }
00517
00518 void ScanDefImpl::setScanVariable2(unsigned short var)
00519 {
00520 scanVariable2 = var;
00521 }
00522
00523 unsigned short ScanDefImpl::getScanVariable1() const
00524 {
00525 return scanVariable;
00526 }
00527
00528 unsigned short ScanDefImpl::getScanVariable2() const
00529 {
00530 return scanVariable2;
00531 }
00532
00533 void ScanDefImpl::setNTrigs(unsigned long nTrigs)
00534 {
00535 trigPoints.resize(std::max(1U, scanPoints.size()));
00536
00537 for(unsigned int i=0; i<trigPoints.size(); i++) {
00538 trigPoints[i] = nTrigs;
00539 }
00540
00541 allTrigsSame = true;
00542 }
00543
00544 unsigned long ScanDefImpl::getNTrigs() const
00545 {
00546 if(trigPoints.size() > 0) {
00547 return trigPoints[0];
00548 } else {
00549 return 0;
00550 }
00551 }
00552
00553 const ::SctApi::Scan::TrigPoints ScanDefImpl::getVariableTrigs() const
00554 {
00555 return trigPoints;
00556 }
00557
00558 void ScanDefImpl::setVariableTrigs(const TrigPoints &trigs)
00559 {
00560 allTrigsSame = false;
00561 trigPoints = trigs;
00562 }
00563
00564 void ScanDefImpl::setVariableTrigRange(unsigned short start, unsigned short end, unsigned long value)
00565 {
00566 allTrigsSame = false;
00567 for(int i=start; i<=end; i++)
00568 trigPoints[i] = value;
00569 }
00570
00571 const ::SctApi::Scan::ScanPoints ScanDefImpl::getScanPoints1() const
00572 {
00573 return scanPoints;
00574 }
00575
00576 const ::SctApi::Scan::ScanPoints ScanDefImpl::getScanPoints2() const
00577 {
00578 return scanPoints2;
00579 }
00580
00581 void ScanDefImpl::setScanPoints1(const ScanPoints &scans)
00582 {
00583 scanPoints = scans;
00584
00585 if(allTrigsSame) {
00586
00587 int newNTrig = trigPoints.size() > 0?trigPoints[0]:0;
00588 trigPoints.resize(std::max(1U, scanPoints.size()), newNTrig);
00589 }
00590 }
00591
00592 void ScanDefImpl::setScanPoints2(const ScanPoints &scans)
00593 {
00594 scanPoints2 = scans;
00595 }
00596
00597 int ScanDefImpl::getOption(enum ScanOptions opt) const
00598 {
00599 switch(opt) {
00600 case FULL:
00601 return full;
00602 case BITS32:
00603 return bits32;
00604 case LOOPCALLINE:
00605 return loopCalLine;
00606 case DISTSLAVE:
00607 return distSlave;
00608 case DEBUG:
00609 return debug;
00610 case TIM:
00611 return tim;
00612 case NTH:
00613 return nth;
00614 case NTH_REM:
00615 return nth_rem;
00616 case ENABLE_DATA_MODE:
00617 return enableDataMode;
00618 case USE_CCODE:
00619 return ccode;
00620 case OPE:
00621 return ope;
00622 default:
00623 return 0;
00624 }
00625 }
00626
00627 void ScanDefImpl::setOption(enum ScanOptions opt, int option)
00628 {
00629 switch(opt) {
00630 case FULL:
00631 full = option;
00632 break;
00633 case BITS32:
00634 bits32 = option;
00635 break;
00636 case LOOPCALLINE:
00637 loopCalLine = option;
00638 break;
00639 case DISTSLAVE:
00640 distSlave = option;
00641 break;
00642 case DEBUG:
00643 debug = option;
00644 break;
00645 case TIM:
00646 tim = option;
00647 break;
00648 case NTH:
00649 nth = option;
00650 break;
00651 case NTH_REM:
00652 nth_rem = option;
00653 break;
00654 case ENABLE_DATA_MODE:
00655 enableDataMode = option;
00656 break;
00657 case USE_CCODE:
00658 ccode = option;
00659 break;
00660 case OPE:
00661 ope = option;
00662 break;
00663 }
00664 }
00665
00666 std::string ScanDefImpl::print() const {
00667 std::ostringstream oss;
00668 oss << "Scan\n";
00669 oss << "Run: " << getRunNumber() << " Scan: " << getScanNumber() << "\n";
00670
00671 if(allTrigsSame) {
00672 oss << getNTrigs() << " triggers per scan point\n";
00673
00674 TrigPoints points = getVariableTrigs();
00675
00676
00677 if (points.empty()){
00678 oss << "Trigger count array empty\n";
00679 }else{
00680 unsigned int initVal = points[0];
00681
00682 for(TrigPoints::const_iterator iter = points.begin();
00683 iter != points.end();
00684 iter++) {
00685 if(*iter != initVal) oss << " Trigger count array not constant\n";
00686 }
00687 }
00688
00689 if(points.size() != getScanPoints1().size()) {
00690 oss << " Trigger count array not the same size as scan point array!!!\n";
00691 }
00692
00693 } else {
00694 oss << "Triggers per scan point:\n";
00695
00696 TrigPoints points = getVariableTrigs();
00697
00698 int i=0;
00699 for(TrigPoints::const_iterator iter = points.begin();
00700 iter != points.end();
00701 i++, iter++) {
00702 if(i && (i%20 == 0)) oss << "\n";
00703 oss.width(4);
00704
00705 oss << *iter << " ";
00706 }
00707 oss << "\n";
00708 }
00709
00710 oss << "Binning mode " << (getOption(Scan::FULL)?"full":"condensed") << "\n";
00711 oss << "Bin size " << (getOption(Scan::BITS32)?"32bit":"16bit") << "\n";
00712 oss << "Cal line loop " << (getOption(Scan::LOOPCALLINE)?"yes":"no") << "\n";
00713 oss << "Use TIM for triggers (synchronous) " << (getOption(Scan::TIM)?"yes":"no") << "\n";
00714 oss << "Put module into dataTakingMode during configure (usually yes): " << (getOption(Scan::ENABLE_DATA_MODE)?"yes":"no") << "\n";
00715 oss << "Histogramming task=" << (getOption(Scan::USE_CCODE)?"ccode":"assembly") << "\n";
00716 oss << "OPE=" << (getOption(Scan::OPE)?"yes":"no") << "\n";
00717 oss << "Slave DSPs: ";
00718 switch(getOption(Scan::DISTSLAVE)) {
00719 case 0:
00720 {
00721 oss << "All to Slave 0";
00722 if(getOption(Scan::NTH) > 1) {
00723 oss << ": Capture trigger%" << getOption(Scan::NTH) << "==" << getOption(Scan::NTH_REM);
00724 }
00725 break;
00726 }
00727 case 1: oss << "According to groups"; break;
00728 case 2:
00729 {
00730 oss << "Router distribution";
00731 if(getOption(Scan::NTH) > 1) {
00732 oss << ": Capture trigger%" << getOption(Scan::NTH) << "==" << getOption(Scan::NTH_REM);
00733 }
00734 break;
00735 }
00736 default: oss << "Invalid type!"; break;
00737 }
00738 oss << "\n";
00739
00740 if(getOption(Scan::DEBUG)) {
00741 oss << "In debug mode\n";
00742 }
00743
00744 if(getScanPoints2().size() > 0) {
00745 oss << "Module set 0\n";
00746 } else {
00747 oss << "Scan parameters\n";
00748 }
00749
00750 oss << "Scan over variable number " << getScanVariable1() << "\n";
00751
00752 oss << getScanPoints1().size() << " scan points:\n";
00753 int i=0;
00754
00755 std::vector<FLOAT32> points = getScanPoints1();
00756
00757 for(std::vector<FLOAT32>::const_iterator iter=points.begin();
00758 iter != points.end();
00759 i++, iter++) {
00760 if(i && (i%20 == 0)) oss << "\n";
00761 oss.width(4);
00762
00763 oss << *iter << " ";
00764 }
00765 oss << "\n";
00766
00767 oss << "Trigger:\n";
00768
00769 oss << getTrigger1()->print();
00770
00771 if(getScanPoints2().size() > 0) {
00772 oss << "Module set 1\n";
00773
00774 oss << "Scan over variable number " << getScanVariable2() << "\n";
00775
00776 oss << getScanPoints2().size() << " scan points:\n";
00777 int i=0;
00778
00779 std::vector<FLOAT32> points2 = getScanPoints2();
00780
00781 for(std::vector<FLOAT32>::const_iterator iter=points2.begin();
00782 iter != points2.end();
00783 i++, iter++) {
00784 if(i && (i%20 == 0)) oss << "\n";
00785 oss.width(4);
00786
00787 oss << *iter << " ";
00788 }
00789 oss << "\n";
00790
00791 oss << "Trigger2:\n";
00792
00793 oss << getTrigger2()->print();
00794 } else {
00795 oss << "Second trigger not defined\n";
00796 }
00797
00798 #if !USE_CONST_SCAN
00799 for(int i=0; i<4; i++) {
00800 oss << "Modules in group " << i << "\n";
00801
00802 ModuleList groupList = getModuleList(i);
00803
00804 for(ModuleList::const_iterator iter = groupList.begin();
00805 iter != groupList.end();
00806 iter++) {
00807 oss << " [" << *iter << "]\n";
00808 }
00809 }
00810 #endif
00811 return oss.str();
00812 }
00813
00814
00815 void ScanDefImpl::setScanNumber(unsigned int scan)
00816 {
00817 scanNumber = scan;
00818 }
00819
00820 unsigned int ScanDefImpl::getScanNumber() const
00821 {
00822 return scanNumber;
00823 }
00824
00825 void ScanDefImpl::setRunNumber(unsigned int run)
00826 {
00827 runNumber = run;
00828 }
00829
00830 unsigned int ScanDefImpl::getRunNumber() const
00831 {
00832 return runNumber;
00833 }
00834
00835 #if USE_CONST_SCAN
00836 #define ScanDefImpl ScanEx
00837 #endif
00838
00839 std::list<std::string> ScanDefImpl::getModuleList(unsigned int group) const
00840 {
00841 std::list<std::string> result;
00842
00843 if(group<groupLists.size()) {
00844 result = groupLists[group];
00845 }
00846
00847 return result;
00848 }
00849
00850 void ScanDefImpl::setModuleList(unsigned int group, const ::SctApi::ModuleList & newList)
00851 {
00852 if(group+1 > groupLists.size()) {
00853 groupLists.resize(group + 1);
00854 }
00855 groupLists[group] = newList;
00856 }
00857
00858 unsigned int ScanDefImpl::getNGroups() const
00859 {
00860 return m_maxGroup;
00861 }
00862
00863 void ScanDefImpl::setNGroups(unsigned int val)
00864 {
00865 m_maxGroup = val;
00866 }
00867
00868 #if USE_CONST_SCAN
00869 #undef ScanDefImpl
00870 #endif
00871
00872 std::string TriggerImpl::print() const
00873 {
00874 std::ostringstream oss;
00875 Trigger::RODTriggers trigs = getRODTriggers(0);
00876
00877 oss << "Printing trigger: length " << trigs.size() << "\n";
00878
00879 unsigned short trigData, trigCmd;
00880 getCommIncr(trigData, trigCmd);
00881
00882 for(unsigned int i = 0; i < trigs.size(); i++) {
00883 oss.width(4);
00884 oss << getNameOfRODTrigger(trigs[i]);
00885 if(trigData != 0 && trigCmd == i) {
00886 oss << "+" << trigData;
00887 }
00888 oss << "\n";
00889 }
00890 oss << "Trigger OK for ROD:" << (isValidRODTrigger()?"Y":"N")
00891 << "\tOK for TIM:" << (isValidTIMTrigger()?"Y":"N") << "\n";
00892 oss << "Trigger Frequency:" << getFrequency() << " kHz, Source:" << getSource();
00893 oss << " Random:" << getRandom();
00894 oss << "\n";
00895 oss << "Trigger: TIM needs sequencer? " << (timNeedsSequencer()?"Y":"N") << "\n";
00896 return oss.str();
00897 }
00898
00899 #if USE_CONST_SCAN
00900 #define ScanDefImpl ScanEx
00901 #endif
00902
00903 ptime ScanDefImpl::getStartTime() const {
00904 return startTime;
00905 }
00906
00907 void ScanDefImpl::setStartTime(ptime t) {
00908 startTime = t;
00909 }
00910
00911 ptime ScanDefImpl::getEndTime() const {
00912 return endTime;
00913 }
00914
00915 void ScanDefImpl::setEndTime(ptime t) {
00916 endTime = t;
00917 }
00918
00919 #if USE_CONST_SCAN
00920 #undef ScanDefImpl
00921 #endif
00922
00923 bool RodLabel::operator==(const RodLabel &rhs) const {
00924 return partition == rhs.partition && crate == rhs.crate && rod == rhs.rod;
00925 }
00926
00927 bool RodLabel::operator!=(const RodLabel &rhs) const {
00928 return !(*this == rhs);
00929 }
00930
00931 bool RodLabel::operator<(const RodLabel &rhs) const {
00932 if(partition < rhs.partition) return true;
00933 if(partition > rhs.partition) return false;
00934 if(crate < rhs.crate) return true;
00935 if(crate > rhs.crate) return false;
00936 if(rod < rhs.rod) return true;
00937
00938 return false;
00939 }
00940
00941
00942 bool CrateLabel::operator==(const CrateLabel &rhs) const {
00943 return partition == rhs.partition && crate == rhs.crate;
00944 }
00945
00946 bool CrateLabel::operator<(const CrateLabel &rhs) const {
00947 if(partition < rhs.partition) return true;
00948 if(partition > rhs.partition) return false;
00949 if(crate < rhs.crate) return true;
00950
00951 return false;
00952 }