00001
00008 #ifndef SCTROD_SCTAPI_H
00009 #define SCTROD_SCTAPI_H
00010
00011
00012 #include "config.h"
00013
00014 #include <list>
00015 #include <map>
00016 #include <string>
00017 #include <vector>
00018
00019 #include <boost/thread.hpp>
00020 #include <boost/shared_ptr.hpp>
00021 #include <boost/shared_array.hpp>
00022 #include <boost/date_time/posix_time/posix_time_types.hpp>
00023
00024 #include <mrs/message.h>
00025 #if USE_IS
00026 #include <is/isinfotmpl.h>
00027 #endif
00028
00029 class SCTDCSCommand;
00030 #include "log.h"
00031
00032 #include "DCSAccess.h"
00033
00034
00035 #include <CommonWithDsp/sctStructure.h>
00036
00037 #include <CommonWithDsp/processor.h>
00038
00039 struct scan_result_ptrs;
00040
00041 namespace SctConfiguration {
00042 class Configuration;
00043 struct BOCChannelConfig;
00044 struct BOCGlobalConfig;
00045 }
00046
00047 #include "SctApiFwd.h"
00048
00049 namespace SctApi {
00050
00051 class CrateException;
00052
00056 class SctApiException : public std::exception {
00057 std::string desc;
00058 public:
00060 SctApiException(const std::string &str) throw() : desc(str) {}
00061
00063 SctApiException(const CrateException &c) throw();
00064
00065 ~SctApiException() throw() {}
00066
00068 virtual const char* what () const throw() { return desc.c_str(); }
00069 };
00070
00071 class Crate;
00072
00073 class PrimListWrapper;
00074
00075 class ScanEx;
00076
00078 class Trigger {
00079 public:
00080 virtual ~Trigger();
00081
00083 typedef std::vector<std::pair<UINT16, UINT32> > RODTriggers;
00084
00086 virtual void singleL1A() = 0;
00088 virtual void doubleL1A(unsigned short delay) = 0;
00090 virtual void delayedL1A(unsigned short delay) = 0;
00092 virtual void calL1A(unsigned short delay) = 0;
00093 virtual void pulseL1A(unsigned short delay) = 0;
00094 virtual void softL1A(unsigned short delay) = 0;
00095 virtual void softCalL1A(unsigned short delay, unsigned short delay2) = 0;
00096 virtual void softPulseL1A(unsigned short delay, unsigned short delay2) = 0;
00097 virtual void softBc(unsigned short delay) = 0;
00098 virtual void bcL1A(unsigned short delay) = 0;
00099 virtual void bcCalL1A(unsigned short delay, unsigned short delay2) = 0;
00100 virtual void bcPulseL1A(unsigned short delay, unsigned short delay2) = 0;
00101
00102 virtual void setCommIncr(unsigned short command, unsigned short incr) = 0;
00103 virtual void getCommIncr(unsigned short &command, unsigned short &incr) const = 0;
00104
00106 virtual const RODTriggers getRODTriggers() const = 0;
00107
00108 virtual void print() const = 0;
00109 };
00110
00119 class Scan {
00120 public:
00121 virtual ~Scan();
00122
00124 typedef std::vector<FLOAT32> ScanPoints;
00125
00127 typedef std::vector<UINT32> TrigPoints;
00128
00130
00150 enum ScanOptions {FULL, BITS32, LOOPCALLINE, DISTSLAVE, DEBUG, TIM, NTH, NTH_REM, ENABLE_DATA_MODE};
00151
00152 virtual void configure(unsigned short type, float start, float stop, float step) = 0;
00153 virtual void configure2(unsigned short type, float start, float stop, float step) = 0;
00154
00155 virtual const boost::shared_ptr<Trigger> getTrigger1() const = 0;
00156 virtual const boost::shared_ptr<Trigger> getTrigger2() const = 0;
00157
00158 virtual boost::shared_ptr<Trigger> getTrigger1() = 0;
00159 virtual boost::shared_ptr<Trigger> getTrigger2() = 0;
00160
00161 virtual void setTrigger1(boost::shared_ptr<Trigger> trigger) = 0;
00162 virtual void setTrigger2(boost::shared_ptr<Trigger> trigger) = 0;
00163
00164 virtual void setScanVariable1(unsigned short var) = 0;
00165 virtual void setScanVariable2(unsigned short var) = 0;
00166
00167 virtual unsigned short getScanVariable1() const = 0;
00168 virtual unsigned short getScanVariable2() const = 0;
00169
00170 virtual void setNTrigs(unsigned long nTrigs) = 0;
00171 virtual unsigned long getNTrigs() const = 0;
00172
00173 virtual const TrigPoints getVariableTrigs() const = 0;
00174 virtual void setVariableTrigs(const TrigPoints &scans) = 0;
00175 virtual void setVariableTrigRange(unsigned short start, unsigned short end, unsigned long value) = 0;
00176
00177 virtual const ScanPoints getScanPoints1() const = 0;
00178 virtual const ScanPoints getScanPoints2() const = 0;
00179 virtual void setScanPoints1(const ScanPoints &scans) = 0;
00180 virtual void setScanPoints2(const ScanPoints &scans) = 0;
00181
00182 virtual int getOption(enum ScanOptions) const = 0;
00183 virtual void setOption(enum ScanOptions, int option) = 0;
00184
00186 virtual void print() const = 0;
00187
00188 virtual void setScanNumber(unsigned int scan) = 0;
00189 virtual unsigned int getScanNumber() const = 0;
00190 virtual void setRunNumber(unsigned int scan) = 0;
00191 virtual unsigned int getRunNumber() const = 0;
00192
00193 virtual std::list<std::string> getModuleList(unsigned int group) const = 0;
00194 virtual void setModuleList(unsigned int group, std::list<std::string> newList) = 0;
00195 virtual unsigned int getNGroups() const = 0;
00196 virtual void setNGroups(unsigned int val) = 0;
00197
00198 virtual boost::posix_time::ptime getStartTime() const = 0;
00199 virtual void setStartTime(boost::posix_time::ptime t) = 0;
00200
00201 virtual boost::posix_time::ptime getEndTime() const = 0;
00202 virtual void setEndTime(boost::posix_time::ptime t) = 0;
00203 };
00204
00262 class SctApi {
00263 SctApi(const SctApi &);
00264 SctApi &operator=(const SctApi&);
00265 public:
00266
00268 static const unsigned int BAD_MODULE;
00269
00273 SctApi();
00274
00278 SctApi(boost::shared_ptr<SctConfiguration::Configuration> newConf);
00279
00280 virtual ~SctApi();
00281
00282 private:
00288 void setup();
00289
00293 void dumpPrimList(boost::shared_ptr<PrimListWrapper> prim);
00294
00296 void dumpRawEvent(unsigned int partition, unsigned int crate, unsigned int rod, int units, unsigned long *bufferA, unsigned long *bufferB);
00297
00298 public:
00302 void setMrsStream(MRSStream *stream);
00303
00304 #if USE_IS
00305
00308 void setIsDictionary(ISInfoDictionary *dict);
00309 #endif
00310
00311
00312
00314
00327 void initialiseAll(int run);
00328
00330
00337 void shutdownAll();
00338
00340
00343 void setRunNumber(UINT32 newRun);
00344
00346
00349 void setScanNumber(UINT32 newScan);
00350
00352
00355 UINT32 getRunNumber();
00356
00358
00361 UINT32 getScanNumber();
00362
00364
00368 bool isRODPresent(unsigned int partition, unsigned int crate, unsigned int rod);
00369
00371
00378 void startupModules();
00379
00381 std::list<std::string> getModuleList();
00382
00383
00384
00386
00390 void loadConfiguration();
00391
00393
00397 void loadConfiguration(std::string filename);
00398
00400
00403 int loadModuleConfigurations();
00404
00406
00410 void storeModuleConfigurations();
00411
00413
00417 void configureBOC(unsigned int partition, unsigned int crate, unsigned int rod);
00418
00420
00424 std::vector<double> getBOCMonitorArray(unsigned int partition, unsigned int crate, unsigned int rod);
00425
00427
00431 int awaitResponse(unsigned int partition, unsigned int crate, unsigned int rod, int timeout);
00432
00434
00438 int awaitResponseAll(unsigned int partition, unsigned int crate, int timeout);
00439
00441
00446 unsigned long *getResponse(unsigned int partition, unsigned int crate, unsigned int rod,
00447 unsigned long &length);
00448
00454 bool getRodMessage(unsigned int partition, unsigned int crate, unsigned int rod,
00455 char *buffer, unsigned long &length);
00456
00457
00458
00460
00470 void flashLED(unsigned int partition, unsigned int crate, unsigned int rod,
00471 long slaveNumber, long period = 1000, long flashes = 10);
00472
00474
00478 void echo(unsigned int partition, unsigned int crate, unsigned int rod,
00479 unsigned int length, const unsigned long *data);
00480
00482
00486 void echoAll(unsigned int length, const unsigned long *data);
00487
00489
00493 void echoSlave(unsigned int partition, unsigned int crate, unsigned int rod,
00494 unsigned int slave, unsigned int length, const unsigned long *data);
00495
00496
00497
00498
00499
00501
00510 int dspBlockDump(unsigned int partition, unsigned int crate, unsigned int rod,
00511 long dspStart, long numWords, long dspNumber, bool usePrim = true);
00512
00514
00524 int dspBlockDumpFile(unsigned int partition, unsigned int crate, unsigned int rod,
00525 long dspStart, long numWords, long dspNumber, std::string filename, bool usePrim = true);
00526
00528
00533 void standardRegisterDump(RodLabel rl);
00534
00536
00539 void standardRegisterDump(unsigned int partition, unsigned int crate, unsigned int rod);
00540
00542
00546 void standardRegisterDumpAll();
00547
00549
00555 unsigned long *dspBlockRead(unsigned int partition, unsigned int crate, unsigned int rod,
00556 long dspStart, long numWords, long dspNumber, unsigned long &length, bool usePrim = true);
00557
00559
00565 int dspBlockWrite(unsigned int partition, unsigned int crate, unsigned int rod,
00566 unsigned long *buffer, unsigned long dspAddress, long numWords, long dspNumber, bool usePrim = true);
00567
00569
00577 unsigned long *primReadSlaveDsp(unsigned int partition, unsigned int crate, unsigned int rod,
00578 int s, int add, int words);
00579
00581
00587 void primWriteSlaveDsp(unsigned int partition, unsigned int crate, unsigned int rod,
00588 int s, int add, int numWords, unsigned long *data);
00589
00590 void writeSlaveFile(unsigned int partition, unsigned int crate, unsigned int rod, unsigned int slave,
00591 std::string fileName, unsigned long address, bool usePrim = true);
00592
00594 void startSlave(unsigned int partition, unsigned int crate, unsigned int rod, unsigned int slave);
00595
00597 boost::shared_array<unsigned long> loadFile(std::string filename, unsigned long & length);
00598
00600
00604 unsigned long readRodStatusReg(unsigned int partition, unsigned int crate, unsigned int rod,
00605 long regNumber);
00606
00608
00612 unsigned long readRodCommandReg(unsigned int partition, unsigned int crate, unsigned int rod,
00613 long regNumber);
00614
00616
00620 unsigned long dspSingleRead(unsigned int partition, unsigned int crate, unsigned int rod,
00621 const unsigned long dspAddr, long dspNumber);
00622
00624
00628 void dspSingleWrite(unsigned int partition, unsigned int crate, unsigned int rod,
00629 unsigned long dspAddr, unsigned long value, long dspNumber);
00630
00632
00638 ABCDModule *retrieveModule(UINT32 mid);
00639
00641
00645 void createDebugPrimList();
00646
00648
00652 void addDebugPrimList(unsigned long length, long index, long id, long version,
00653 unsigned long * body);
00654
00656
00660 void sendDebugPrimList(unsigned int partition, unsigned int crate, unsigned int rod);
00661
00663
00667 void sendDebugPrimListAll();
00668
00670
00678 void sendDebugSlavePrimList(unsigned int partition, unsigned int crate, unsigned int rod,
00679 unsigned int slave, bool await, bool response);
00680
00682
00685 void debugPrimListFromFile(std::string fileName);
00686
00688 void dumpDebugPrimList();
00689
00691 const std::list<RodLabel> listRods() const;
00692
00694 const std::list<CrateLabel> listCrates() const;
00695
00696
00697
00699
00706 UINT32 findModule(std::string sn);
00707
00709
00713 std::string convertToString(UINT32 mid);
00714
00716
00720 UINT32 findModule(INT32 mur, INT32 module);
00721
00723
00727 std::pair<INT32, INT32> convertToMUR(UINT32 mid);
00728
00730
00734 UINT32 findBarrelModule(INT32 barrel, INT32 row, INT32 number);
00735
00737
00741 void convertToBarrelModule(UINT32 mid, UINT32 &barrel, UINT32 &row, int &number);
00742
00744
00748 UINT32 findEndcapModule(INT32 disk, INT32 quadrant, INT32 number);
00749
00751
00755 void convertToEndcapModule(UINT32 mid, INT32 &disk, UINT32 &quadrant, UINT32 &number);
00756
00758
00762 void getABCDModules(BankType bank);
00763
00765
00769 virtual void getABCDModule(UINT32 mid, BankType bank);
00770
00772
00776 virtual boost::shared_ptr<ABCDModule> getABCDModuleRaw(unsigned int partition, unsigned int crate, unsigned int rod,
00777 UINT32 slot, BankType bank);
00778
00780
00784 virtual void setABCDModules(BankType bank);
00785
00787
00791 virtual void setABCDModule(UINT32 mid, BankType bank);
00792
00794
00803 virtual void sendAllABCDModules(BankType bank,
00804 ConfigType type = SCTAPI_CONFIG_ALL,
00805 const bool enableDataMode=true );
00806
00808
00818 virtual void sendABCDModule(UINT32 mid,
00819 BankType bank,
00820 ConfigType type = SCTAPI_CONFIG_ALL,
00821 const bool enableDataMode=true );
00822
00824
00830 void modifyABCDMask(UINT32 mid, UINT32* mask);
00831
00835
00836
00843 void modifyABCDTrims(UINT32 mid, UINT8* trims);
00844
00848
00849
00851
00855 void modifyABCDVar(UINT32 typ, FLOAT32 var);
00856
00858
00862 void modifyABCDVar(UINT32 mid, UINT32 typ, FLOAT32 var);
00863
00865
00866
00868
00872 void modifyABCDVar(UINT32 mid, UINT32 chip, UINT32 typ, FLOAT32 var);
00873
00875
00879 void modifyABCDVarROD(UINT32 mid, UINT32 chip, UINT32 typ, FLOAT32 var, BankType bank);
00880
00882
00886 void modifyABCDVarROD(UINT32 mid, UINT32 typ, FLOAT32 var, BankType bank);
00887
00889
00893 void modifyABCDVarROD(UINT32 type, FLOAT32 value, BankType bank);
00894
00896
00897
00899
00903 void modifyABCDRC(UINT32 mid, UINT32 chip, UINT16 function, FLOAT32 p0, FLOAT32 p1, FLOAT32 p2);
00904
00906
00910 void modifyBOCParam(unsigned int partition, unsigned int crate, unsigned int rod,
00911 unsigned int channel, unsigned int type, unsigned int val);
00912
00914
00918 void modifyBOCParam(unsigned int type, unsigned int val);
00919
00921
00925 void printBOCSetup(unsigned int partition, unsigned int crate, unsigned int rod);
00926
00928
00932 std::vector<SctConfiguration::BOCChannelConfig> currentBOCSetup(unsigned int partition, unsigned int crate, unsigned int rod);
00933
00935
00939 void printBOCRegisters(unsigned int partition, unsigned int crate, unsigned int rod);
00940
00942
00946 SctConfiguration::BOCGlobalConfig currentBOCRegisters(unsigned int partition, unsigned int crate, unsigned int rod);
00947
00949 void saveBOCSetup(unsigned int partition, unsigned int crate, unsigned int rod, BankType bank);
00950
00952 void saveBOCRegisters(unsigned int partition, unsigned int crate, unsigned int rod, BankType bank);
00953
00955 void restoreBOCSetup(unsigned int partition, unsigned int crate, unsigned int rod, BankType bank);
00956
00958 void restoreBOCRegisters(unsigned int partition, unsigned int crate, unsigned int rod, BankType bank);
00959
00961
00965 void lasersOff();
00966
00967
00968
00970
00977 void timSetFrequency(unsigned int partition, unsigned int crate, double trigFreq, double rstFreq);
00978
00980
00985 void freeTriggers(unsigned int partition, unsigned int crate);
00986
00988
00992 void stopTriggers(unsigned int partition, unsigned int crate);
00993
00995
00999 void timL1A(unsigned int partition, unsigned int crate);
01000
01002
01006 void timCalL1A(unsigned int partition, unsigned int crate, int delay);
01007
01009
01013 void timSoftReset(unsigned int partition, unsigned int crate);
01014
01016
01020 void timBCReset(unsigned int partition, unsigned int crate);
01021
01023 void sendTimBurst(unsigned int partition, unsigned int crate, unsigned int count);
01024
01026 void timVerbose(unsigned int partition, unsigned int crate);
01027
01029
01032 void timWriteRegister(unsigned int partition, unsigned int crate, int reg, UINT16 val);
01033
01035
01038 UINT16 timReadRegister(unsigned int partition, unsigned int crate, int reg);
01039
01041
01045 void status();
01046
01048
01052 void defaultScan(int type);
01053
01055
01061 void doScan(boost::shared_ptr<Scan> scan);
01062
01066 void awaitScan();
01067
01077 void abortScan();
01078
01080
01084 void doRawScan(boost::shared_ptr<Scan> scan, int delay, int width,
01085 bool configureModules = false, bool clkBy2 = false);
01086
01088
01092 void sendTimTrigger(unsigned int partition, unsigned int crate, const Trigger *trig);
01093
01095
01099 void sendTrigger(unsigned int partition, unsigned int crate, unsigned int rod, const Trigger *trig);
01100
01102
01108 void printABCDModule(int mid);
01109
01111
01118 void printABCDRodModule(int mid, BankType bank);
01119
01121
01125 void decodeEvent(unsigned int partition, unsigned int crate, unsigned int rod,
01126 int sl, int index, bool extFlag = false, bool errorType = false);
01127
01129
01133 void scanEvents(unsigned int partition, unsigned int crate, unsigned int rod, int sl, bool extFlag, bool errorType);
01134
01138 void reportEventErrors();
01139
01143 void decodeConfig(unsigned int partition, unsigned int crate, unsigned int rod,
01144 bool skipTrim = false, bool bypass = false);
01145
01147
01151 void rawData(unsigned int partition, unsigned int crate, unsigned int rod, int delay, int units, bool setMask = true, const Trigger *trig = 0);
01152
01154
01160 void sendL1A(unsigned int partition, unsigned int crate, unsigned int rod, bool capture = false);
01161
01163
01180 std::vector<char> probe(unsigned int partition, unsigned int crate, unsigned int rod,
01181 signed int harness = -1);
01182
01184
01201 std::vector<char> probeWithTrigger(unsigned int partition, unsigned int crate, unsigned int rod,
01202 const Trigger *trigger, signed int harness = -1);
01203
01205 std::vector<std::vector<char> > SctApi::probeScan(unsigned int partition, unsigned int crate, unsigned int rod,
01206 boost::shared_ptr<Scan> scan, signed int harness = -1);
01207
01214 bool checkAllModulesProbe(std::string value);
01215
01221 void autoConfigure();
01222
01226 void bocHistogram(unsigned int partition, unsigned int crate, unsigned int rod,
01227 unsigned int samples, unsigned int numLoops);
01228
01229
01230
01238 void requestHardResetAll();
01239
01247 void requestHardReset(UINT32 mid);
01248
01256 void requestIVCurve(UINT32 mid, FLOAT32 start, FLOAT32 stop, FLOAT32 step, UINT16 delay, FLOAT32 currentLim);
01257
01265 void requestIVCurveAll(FLOAT32 start, FLOAT32 stop, FLOAT32 step, UINT16 delay, FLOAT32 currentLim);
01266
01277 void setSelectAllInCrate(int crate, bool value, int timeout = 5);
01278
01289
01290 void setSelect(UINT32 mid, bool value);
01291
01301 void changeRunState(int state);
01302
01303
01304
01306 void ddcChangeState (int crate, int channel, short state, int timeout = 2);
01308 void ddcChangeStateAll (int crate, short state, int timeout = 2);
01310 void ddcLoadConfiguration (int crate, short state, int timeout = 2);
01312 void ddcHardReset (int crate, int channel, int timeout = 2);
01314 void ddcHardResetAll (int crate, int timeout = 2);
01315
01317 int ddcGetChannelParameterInt (int crate, int channel, std::string name, int timeout = 2);
01319 float ddcGetChannelParameterFloat (int crate, int channel, std::string name, int timeout = 2);
01321 std::string ddcGetChannelParameterString (int crate, int channel, std::string name, int timeout = 2);
01323 int ddcGetCardParameterInt (int crate, int card, std::string name, int timeout = 2);
01325 float ddcGetCardParameterFloat (int crate, int card, std::string name, int timeout = 2);
01327 std::string ddcGetCardParameterString (int crate, int card, std::string name, int timeout = 2);
01329 int ddcGetCrateParameterInt (int crate, std::string name, int timeout = 2);
01331 float ddcGetCrateParameterFloat (int crate, std::string name, int timeout = 2);
01333 std::string ddcGetCrateParameterString (int crate, std::string name, int timeout = 2);
01334
01336
01341 void ddcGetCrateParameters(int crate, std::vector<std::string> names,
01342 std::map<std::string, float>& dpeValues, int timeout);
01343
01345 void ddcSetChannelParameter (int crate, int channel, std::string name, float value, int timeout = 2);
01347 void ddcSetCardParameter (int crate, int card, std::string name, float value, int timeout = 2);
01349 void ddcSetCrateParameter (int crate, std::string name, float value, int timeout = 2);
01350
01351
01352
01363 void tidyHistogramming();
01364
01368 long getRodSlot(unsigned int partition, unsigned int crate, unsigned int rod);
01369
01373 int getRodRevision(unsigned int partition, unsigned int crate, unsigned int rod);
01374
01378 int getRodRevision(const RodLabel &label);
01379
01383 void testLinkOutSelect(unsigned int partition, unsigned int crate, unsigned int rod,
01384 unsigned int link);
01385
01389 unsigned int testLinkOutRetrieve(unsigned int partition, unsigned int crate, unsigned int rod);
01390
01398 void unsetDebugOption(std::string opt);
01399
01407 void setDebugOption(std::string opt);
01408
01416 std::list<std::string> listEnabledDebugOptions();
01417
01425 std::vector<std::string> listDebugOptions();
01426
01430 void debugStepHistogram();
01431
01437 void debugContinueHistogram();
01438
01445 void debugAbortHistogram();
01446
01452 void eventTrapSetup(int slaveMask, int trapMatch, int trapMod, int trapRemain, bool tim, bool error,
01453 boost::shared_ptr<PrimListWrapper> primList);
01454
01456 void startEventTrap(int slave, boost::shared_ptr<PrimListWrapper> primList);
01457
01459 void stopEventTrap(int slave, boost::shared_ptr<PrimListWrapper> primList);
01460
01462 void rodMode(unsigned int partition, unsigned int crate, unsigned int rod,
01463 int mode, int flag, int fifoSetup, int nBins, int delay, int message);
01464
01466 void setupModuleMask(unsigned int partition, unsigned int crate, unsigned int rod,
01467 int port, int slvs);
01468
01470 void setupModuleMask(int port, int slvs, boost::shared_ptr<PrimListWrapper> list);
01471
01473 std::pair<UINT32, UINT32> sendData(unsigned int partition, unsigned int crate, unsigned int rod, int type, int dsp);
01474
01478 void resumePolling();
01479
01483 void stopPolling();
01484
01486 void print_calib(unsigned int partition, unsigned int crate, unsigned int rod);
01487
01489
01494 int synchSendPrimListAllCrates(boost::shared_ptr<PrimListWrapper> primList, int timeout = 10);
01495
01497 void stopHistogramming(const ScanEx &ex);
01498
01500 void setSlaveBlock(unsigned int partition, unsigned int crate, unsigned int rod,
01501 int s, long sAdd, int words, long value = 0, bool usePrim = true);
01502
01504 void writeRODRegister(unsigned int partition, unsigned int crate, unsigned int rod,
01505 int reg, int off, int width, int value);
01506
01508 unsigned int readRODRegister(unsigned int partition, unsigned int crate, unsigned int rod, int r);
01509
01511 int pollRegister(unsigned int partition, unsigned int crate, unsigned int rod, int r, int off, int width, int val, int timeout = 1000000);
01512
01513 virtual unsigned long *readFifo(unsigned int partition, unsigned int crate, unsigned int rod, int id, int bank, int elems);
01514
01516 void startHistogramTask(const Scan &scan, const ScanEx &ex, const RodLabel,
01517 unsigned int startBin, unsigned int nBins, unsigned int nTrigs,
01518 boost::shared_ptr<PrimListWrapper> list);
01519
01521
01526 void sendPrimList(unsigned int partition, unsigned int crate, unsigned int rod,
01527 boost::shared_ptr<PrimListWrapper> prim);
01528
01529 MRSStream *mrs;
01530 #if USE_IS
01531 ISInfoDictionary *m_isDict;
01532 #endif
01533 protected:
01534
01535
01536
01538
01543 virtual int initialiseRod(unsigned int partition, unsigned int crate, unsigned int rod);
01544
01546
01552 virtual int initialiseModule(std::string module);
01553
01555 ABCDModule *lookupConfig(UINT32 mid);
01556
01558
01562 virtual bool preScanHardwareCheck(Scan& scan, ScanEx& extra);
01563
01564 virtual void doHistogramSetup(const Scan &scan, const ScanEx &extra);
01565
01570 UINT32 *readEventBuffer(unsigned int partition, unsigned int crate, unsigned int rod,
01571 int sl, bool extFlag, bool errorType);
01572
01576 int getLastEventFrame(unsigned int partition, unsigned int crate, unsigned int rod, int slave);
01577
01579
01588 virtual int pollHistogramming(boost::shared_ptr<ScanControl> controller, int timeout = 5);
01589
01590 void scanLoop();
01591
01592 void scanPollingThread();
01593
01594 void addRodToList(RodLabel newRod);
01595
01596 RodInfo &SctApi::getRodInfo(const RodLabel &l);
01597
01599 std::list<RodLabel> rodList;
01600
01602 std::map<RodLabel, RodInfo> rodInfoList;
01603
01605 std::map<UINT32, ABCDModule> moduleMap;
01606
01607
01608 boost::shared_ptr<ScanControl> scanController;
01609
01610
01611 boost::shared_ptr<ScanControl> lastScanController;
01612
01613 private:
01614
01615
01616
01617
01618
01619
01621
01627 void sendSlavePrimList(unsigned int partition, unsigned int crate, unsigned int rod,
01628 boost::shared_ptr<PrimListWrapper> prim, unsigned int slave, bool await, bool response);
01629
01631
01636 void sendPrimListAll(unsigned int partition, unsigned int crate,
01637 boost::shared_ptr<PrimListWrapper> prim);
01638
01640 void setupEventTrapping(const Scan &scan, const ScanEx &ex, const RodLabel, boost::shared_ptr<PrimListWrapper> list);
01641
01643 void startEventTrapping(const Scan &scan, const ScanEx &ex, const RodLabel, boost::shared_ptr<PrimListWrapper> primList);
01644
01646 void setupEventDump(const Scan &scan, const ScanEx &ex, const RodLabel, boost::shared_ptr<PrimListWrapper> list);
01647
01649 void setupHistogramming(const Scan &scan, const ScanEx &ex, const RodLabel, bool tim,
01650 boost::shared_ptr<PrimListWrapper> list);
01651
01653 void calib_init();
01654
01656 void readRawData(unsigned int partition, unsigned int crate, unsigned int rod,
01657 int delay, bool setMask);
01658
01660 virtual int setupRawData(unsigned int partition, unsigned int crate, unsigned int rod,
01661 int delay, int units, bool setMask, const Trigger *trig = 0);
01662
01664
01668 Crate *getCrate(unsigned int partition, unsigned int crate) const;
01669
01671 void cacheModuleConfig(UINT32 mid);
01672
01674
01677 void getrpcrc(UINT32 mid, unsigned int &rpartition, unsigned int &rcrate, unsigned int &rrod, unsigned &rchannel);
01678
01680 void initDDC();
01681
01683 void setupScanMasks(ScanEx &extra, int distSlave, bool dual);
01684
01686 bool checkModuleListsForScan();
01687
01689
01692 void preScanModuleSetup(Scan &scan);
01693
01694 bool checkDebugOption(std::string opt);
01695
01696 bool checkDebugOption(int opt);
01697
01698
01699
01701 boost::shared_ptr<SctConfiguration::Configuration> config;
01702
01703 IPCPartition *ddcPartition;
01704 std::string *ddcCtrls[2];
01705 SCTDCSCommand *ddcCmd;
01706
01707 boost::shared_ptr<DCSAccess> dcsAccess;
01708
01710 boost::shared_ptr<PrimListWrapper> debugPrimList;
01711
01713 std::map<std::pair<unsigned int, unsigned int>, Crate* > crateMap;
01714
01716 Log log;
01717
01719 boost::shared_ptr<const Scan> lastDebugScan;
01720 boost::shared_ptr<const ScanEx> lastDebugScanEx;
01721
01723 UINT32 scanNumber;
01724
01726 UINT32 runNumber;
01727
01728 #if USE_SCAN_THREAD
01729 boost::condition scanQueue_notEmpty;
01730 boost::mutex scanQueue_mutex;
01731
01732
01733 std::auto_ptr<boost::thread> scanPollThread;
01734
01735 bool m_stopPolling;
01736 bool m_inScanLoop;
01737 #endif
01738
01739
01740 boost::mutex logMutex;
01741 };
01742 }
01743 #endif