00001
00002
00003 #ifndef SCTROD_SCTAPI_H
00004 #define SCTROD_SCTAPI_H
00005
00006
00007 #include "config.h"
00008
00009 #include <list>
00010 #include <map>
00011 #include <string>
00012 #include <vector>
00013
00014 #include <boost/thread.hpp>
00015 #include <boost/shared_ptr.hpp>
00016 #include <boost/shared_array.hpp>
00017 #include <boost/date_time/posix_time/posix_time_types.hpp>
00018
00019 #include <mrs/message.h>
00020 #if USE_IS
00021 #include <is/isinfotmpl.h>
00022 #endif
00023
00024 class SCTDCSCommand;
00025 #include "log.h"
00026
00027 #include "DCSAccess.h"
00028
00029
00030 #include <CommonWithDsp/sctStructure.h>
00031
00032 #include <CommonWithDsp/processor.h>
00033
00034 struct scan_result_ptrs;
00035
00036 namespace SctConfiguration {
00037 class Configuration;
00038 struct BOCChannelConfig;
00039 struct BOCGlobalConfig;
00040 }
00041
00042 #include "SctApiFwd.h"
00043
00044 namespace SctApi {
00045
00046 class CrateException;
00047
00051 class SctApiException : public std::exception {
00052 std::string desc;
00053 public:
00055 SctApiException(const std::string &str) throw() : desc(str) {}
00056
00058 SctApiException(const CrateException &c) throw();
00059
00060 ~SctApiException() throw() {}
00061
00063 virtual const char* what () const throw() { return desc.c_str(); }
00064 };
00065
00066 class Crate;
00067
00068 class PrimListWrapper;
00069
00070 class ScanEx;
00071
00073 class Trigger {
00074 public:
00075 virtual ~Trigger();
00076
00078 typedef std::vector<std::pair<UINT16, UINT32> > RODTriggers;
00079
00081 virtual void singleL1A() = 0;
00083 virtual void doubleL1A(unsigned short delay) = 0;
00085 virtual void delayedL1A(unsigned short delay) = 0;
00087 virtual void calL1A(unsigned short delay) = 0;
00088 virtual void pulseL1A(unsigned short delay) = 0;
00089 virtual void softL1A(unsigned short delay) = 0;
00090 virtual void softCalL1A(unsigned short delay, unsigned short delay2) = 0;
00091 virtual void softPulseL1A(unsigned short delay, unsigned short delay2) = 0;
00092 virtual void bcL1A(unsigned short delay) = 0;
00093 virtual void bcCalL1A(unsigned short delay, unsigned short delay2) = 0;
00094 virtual void bcPulseL1A(unsigned short delay, unsigned short delay2) = 0;
00095
00096 virtual void setCommIncr(unsigned short command, unsigned short incr) = 0;
00097 virtual void getCommIncr(unsigned short &command, unsigned short &incr) const = 0;
00098
00100 virtual const RODTriggers getRODTriggers() const = 0;
00101
00102 virtual void print() const = 0;
00103 };
00104
00113 class Scan {
00114 public:
00115 virtual ~Scan();
00116
00118 typedef std::vector<FLOAT32> ScanPoints;
00119
00121 typedef std::vector<UINT32> TrigPoints;
00122
00124 enum ScanOptions {FULL, BITS32, LOOPCALLINE, DISTSLAVE, DEBUG, TIM};
00125
00126 virtual void configure(unsigned short type, float start, float stop, float step) = 0;
00127 virtual void configure2(unsigned short type, float start, float stop, float step) = 0;
00128
00129 virtual const boost::shared_ptr<Trigger> getTrigger1() const = 0;
00130 virtual const boost::shared_ptr<Trigger> getTrigger2() const = 0;
00131
00132 virtual boost::shared_ptr<Trigger> getTrigger1() = 0;
00133 virtual boost::shared_ptr<Trigger> getTrigger2() = 0;
00134
00135 virtual void setTrigger1(boost::shared_ptr<Trigger> trigger) = 0;
00136 virtual void setTrigger2(boost::shared_ptr<Trigger> trigger) = 0;
00137
00138 virtual void setScanVariable1(unsigned short var) = 0;
00139 virtual void setScanVariable2(unsigned short var) = 0;
00140
00141 virtual unsigned short getScanVariable1() const = 0;
00142 virtual unsigned short getScanVariable2() const = 0;
00143
00144 virtual void setNTrigs(unsigned long nTrigs) = 0;
00145 virtual unsigned long getNTrigs() const = 0;
00146
00147 virtual const TrigPoints getVariableTrigs() const = 0;
00148 virtual void setVariableTrigs(const TrigPoints &scans) = 0;
00149 virtual void setVariableTrigRange(unsigned short start, unsigned short end, unsigned long value) = 0;
00150
00151 virtual const ScanPoints getScanPoints1() const = 0;
00152 virtual const ScanPoints getScanPoints2() const = 0;
00153 virtual void setScanPoints1(const ScanPoints &scans) = 0;
00154 virtual void setScanPoints2(const ScanPoints &scans) = 0;
00155
00156 virtual int getOption(enum ScanOptions) const = 0;
00157 virtual void setOption(enum ScanOptions, int option) = 0;
00158
00160 virtual void print() const = 0;
00161
00162 virtual void setScanNumber(unsigned int scan) = 0;
00163 virtual unsigned int getScanNumber() const = 0;
00164 virtual void setRunNumber(unsigned int scan) = 0;
00165 virtual unsigned int getRunNumber() const = 0;
00166
00167 virtual std::list<std::string> getModuleList(unsigned int group) const = 0;
00168 virtual void setModuleList(unsigned int group, std::list<std::string> newList) = 0;
00169 virtual unsigned int getNGroups() const = 0;
00170 virtual void setNGroups(unsigned int val) = 0;
00171
00172 virtual boost::posix_time::ptime getStartTime() const = 0;
00173 virtual void setStartTime(boost::posix_time::ptime t) = 0;
00174
00175 virtual boost::posix_time::ptime getEndTime() const = 0;
00176 virtual void setEndTime(boost::posix_time::ptime t) = 0;
00177 };
00178
00236 class SctApi {
00237 SctApi(const SctApi &);
00238 SctApi &operator=(const SctApi&);
00239 public:
00240
00242 static const unsigned int BAD_MODULE;
00243
00247 SctApi();
00248
00252 SctApi(boost::shared_ptr<SctConfiguration::Configuration> newConf);
00253
00254 virtual ~SctApi();
00255
00256 private:
00262 void setup();
00263
00267 void dumpPrimList(boost::shared_ptr<PrimListWrapper> prim);
00268
00270 void dumpRawEvent(unsigned int partition, unsigned int crate, unsigned int rod, int units, unsigned long *bufferA, unsigned long *bufferB);
00271
00272 public:
00276 void setMrsStream(MRSStream *stream);
00277
00278 #if USE_IS
00279
00282 void setIsDictionary(ISInfoDictionary *dict);
00283 #endif
00284
00285
00286
00288
00301 void initialiseAll(int run);
00302
00304
00311 void shutdownAll();
00312
00314
00317 void setRunNumber(UINT32 newRun);
00318
00320
00323 void setScanNumber(UINT32 newScan);
00324
00326
00329 UINT32 getRunNumber();
00330
00332
00335 UINT32 getScanNumber();
00336
00338
00342 bool isRODPresent(unsigned int partition, unsigned int crate, unsigned int rod);
00343
00345
00352 void startupModules();
00353
00355 std::list<std::string> getModuleList();
00356
00357
00358
00360
00364 void loadConfiguration();
00365
00367
00371 void loadConfiguration(std::string filename);
00372
00374
00377 int loadModuleConfigurations();
00378
00380
00384 void storeModuleConfigurations();
00385
00387
00391 void configureBOC(unsigned int partition, unsigned int crate, unsigned int rod);
00392
00394
00398 int awaitResponse(unsigned int partition, unsigned int crate, unsigned int rod, int timeout);
00399
00401
00405 int awaitResponseAll(unsigned int partition, unsigned int crate, int timeout);
00406
00408
00413 unsigned long *getResponse(unsigned int partition, unsigned int crate, unsigned int rod,
00414 unsigned long &length);
00415
00421 bool getRodMessage(unsigned int partition, unsigned int crate, unsigned int rod,
00422 char *buffer, unsigned long &length);
00423
00424
00425
00427
00437 void flashLED(unsigned int partition, unsigned int crate, unsigned int rod,
00438 long slaveNumber, long period = 1000, long flashes = 10);
00439
00441
00445 void echo(unsigned int partition, unsigned int crate, unsigned int rod,
00446 unsigned int length, const unsigned long *data);
00447
00449
00453 void echoAll(unsigned int length, const unsigned long *data);
00454
00456
00460 void echoSlave(unsigned int partition, unsigned int crate, unsigned int rod,
00461 unsigned int slave, unsigned int length, const unsigned long *data);
00462
00463
00464
00465
00466
00468
00477 int dspBlockDump(unsigned int partition, unsigned int crate, unsigned int rod,
00478 long dspStart, long numWords, long dspNumber, bool usePrim = true);
00479
00481
00491 int dspBlockDumpFile(unsigned int partition, unsigned int crate, unsigned int rod,
00492 long dspStart, long numWords, long dspNumber, std::string filename, bool usePrim = true);
00493
00495
00500 void standardRegisterDump(RodLabel rl);
00501
00503
00506 void standardRegisterDump(unsigned int partition, unsigned int crate, unsigned int rod);
00507
00509
00513 void standardRegisterDumpAll();
00514
00516
00522 unsigned long *dspBlockRead(unsigned int partition, unsigned int crate, unsigned int rod,
00523 long dspStart, long numWords, long dspNumber, unsigned long &length, bool usePrim = true);
00524
00526
00532 int dspBlockWrite(unsigned int partition, unsigned int crate, unsigned int rod,
00533 unsigned long *buffer, unsigned long dspAddress, long numWords, long dspNumber, bool usePrim = true);
00534
00536
00544 unsigned long *primReadSlaveDsp(unsigned int partition, unsigned int crate, unsigned int rod,
00545 int s, int add, int words);
00546
00548
00554 void primWriteSlaveDsp(unsigned int partition, unsigned int crate, unsigned int rod,
00555 int s, int add, int numWords, unsigned long *data);
00556
00557 void writeSlaveFile(unsigned int partition, unsigned int crate, unsigned int rod, unsigned int slave,
00558 std::string fileName, unsigned long address, bool usePrim = true);
00559
00561 void startSlave(unsigned int partition, unsigned int crate, unsigned int rod, unsigned int slave);
00562
00564 boost::shared_array<unsigned long> loadFile(std::string filename, unsigned long & length);
00565
00567
00571 unsigned long readRodStatusReg(unsigned int partition, unsigned int crate, unsigned int rod,
00572 long regNumber);
00573
00575
00579 unsigned long readRodCommandReg(unsigned int partition, unsigned int crate, unsigned int rod,
00580 long regNumber);
00581
00583
00587 unsigned long dspSingleRead(unsigned int partition, unsigned int crate, unsigned int rod,
00588 const unsigned long dspAddr, long dspNumber);
00589
00591
00595 void dspSingleWrite(unsigned int partition, unsigned int crate, unsigned int rod,
00596 unsigned long dspAddr, unsigned long value, long dspNumber);
00597
00599
00605 ABCDModule *retrieveModule(UINT32 mid);
00606
00608
00612 void createDebugPrimList();
00613
00615
00619 void addDebugPrimList(unsigned long length, long index, long id, long version,
00620 unsigned long * body);
00621
00623
00627 void sendDebugPrimList(unsigned int partition, unsigned int crate, unsigned int rod);
00628
00630
00634 void sendDebugPrimListAll();
00635
00637
00645 void sendDebugSlavePrimList(unsigned int partition, unsigned int crate, unsigned int rod,
00646 unsigned int slave, bool await, bool response);
00647
00649
00652 void debugPrimListFromFile(std::string fileName);
00653
00655 void dumpDebugPrimList();
00656
00658 std::list<RodLabel> listRods();
00659
00660
00661
00663
00670 UINT32 findModule(std::string sn);
00671
00673
00677 std::string convertToString(UINT32 mid);
00678
00680
00684 UINT32 findModule(INT32 mur, INT32 module);
00685
00687
00691 std::pair<INT32, INT32> convertToMUR(UINT32 mid);
00692
00694
00698 UINT32 findBarrelModule(INT32 barrel, INT32 row, INT32 number);
00699
00701
00705 void convertToBarrelModule(UINT32 mid, UINT32 &barrel, UINT32 &row, int &number);
00706
00708
00712 UINT32 findEndcapModule(INT32 disk, INT32 quadrant, INT32 number);
00713
00715
00719 void convertToEndcapModule(UINT32 mid, INT32 &disk, UINT32 &quadrant, UINT32 &number);
00720
00722
00726 void getABCDModules(BankType bank);
00727
00729
00733 virtual void getABCDModule(UINT32 mid, BankType bank);
00734
00736
00740 virtual boost::shared_ptr<ABCDModule> getABCDModuleRaw(unsigned int partition, unsigned int crate, unsigned int rod,
00741 UINT32 slot, BankType bank);
00742
00744
00748 virtual void setABCDModules(BankType bank);
00749
00751
00755 virtual void setABCDModule(UINT32 mid, BankType bank);
00756
00758
00767 virtual void sendAllABCDModules(BankType bank, ConfigType type = SCTAPI_CONFIG_ALL);
00768
00770
00780 virtual void sendABCDModule(UINT32 mid, BankType bank, ConfigType type = SCTAPI_CONFIG_ALL);
00781
00783
00789 void modifyABCDMask(UINT32 mid, UINT32* mask);
00790
00794
00795
00802 void modifyABCDTrims(UINT32 mid, UINT8* trims);
00803
00807
00808
00810
00814 void modifyABCDVar(UINT32 typ, FLOAT32 var);
00815
00817
00821 void modifyABCDVar(UINT32 mid, UINT32 typ, FLOAT32 var);
00822
00824
00825
00827
00831 void modifyABCDVar(UINT32 mid, UINT32 chip, UINT32 typ, FLOAT32 var);
00832
00834
00838 void modifyABCDVarROD(UINT32 mid, UINT32 chip, UINT32 typ, FLOAT32 var, BankType bank);
00839
00841
00845 void modifyABCDVarROD(UINT32 mid, UINT32 typ, FLOAT32 var, BankType bank);
00846
00848
00852 void modifyABCDVarROD(UINT32 type, FLOAT32 value, BankType bank);
00853
00855
00856
00858
00862 void modifyABCDRC(UINT32 mid, UINT32 chip, UINT16 function, FLOAT32 p0, FLOAT32 p1, FLOAT32 p2);
00863
00865
00869 void modifyBOCParam(unsigned int partition, unsigned int crate, unsigned int rod,
00870 unsigned int channel, unsigned int type, unsigned int val);
00871
00873
00877 void modifyBOCParam(unsigned int type, unsigned int val);
00878
00880
00884 void printBOCSetup(unsigned int partition, unsigned int crate, unsigned int rod);
00885
00887
00891 std::vector<SctConfiguration::BOCChannelConfig> currentBOCSetup(unsigned int partition, unsigned int crate, unsigned int rod);
00892
00894
00898 void printBOCRegisters(unsigned int partition, unsigned int crate, unsigned int rod);
00899
00901
00905 SctConfiguration::BOCGlobalConfig currentBOCRegisters(unsigned int partition, unsigned int crate, unsigned int rod);
00906
00908 void saveBOCSetup(unsigned int partition, unsigned int crate, unsigned int rod);
00909
00911 void saveBOCRegisters(unsigned int partition, unsigned int crate, unsigned int rod);
00912
00914 void restoreBOCSetup(unsigned int partition, unsigned int crate, unsigned int rod);
00915
00917 void restoreBOCRegisters(unsigned int partition, unsigned int crate, unsigned int rod);
00918
00920
00924 void lasersOff();
00925
00926
00927
00929
00936 void timSetFrequency(unsigned int partition, unsigned int crate, double trigFreq, double rstFreq);
00937
00939
00944 void freeTriggers(unsigned int partition, unsigned int crate);
00945
00947
00951 void stopTriggers(unsigned int partition, unsigned int crate);
00952
00954
00958 void timL1A(unsigned int partition, unsigned int crate);
00959
00961
00965 void timCalL1A(unsigned int partition, unsigned int crate, int delay);
00966
00968
00972 void timSoftReset(unsigned int partition, unsigned int crate);
00973
00975
00979 void timBCReset(unsigned int partition, unsigned int crate);
00980
00982 void sendTimBurst(unsigned int partition, unsigned int crate, unsigned int count);
00983
00985 void timVerbose(unsigned int partition, unsigned int crate);
00986
00988
00991 void timWriteRegister(unsigned int partition, unsigned int crate, int reg, UINT16 val);
00992
00994
00997 UINT16 timReadRegister(unsigned int partition, unsigned int crate, int reg);
00998
01000
01004 void status();
01005
01007
01011 void defaultScan(int type);
01012
01014
01020 void doScan(boost::shared_ptr<Scan> scan);
01021
01025 void awaitScan();
01026
01036 void abortScan();
01037
01039
01043 void doRawScan(boost::shared_ptr<Scan> scan, int delay, int width,
01044 bool configureModules = false, bool clkBy2 = false);
01045
01047
01051 void sendTimTrigger(unsigned int partition, unsigned int crate, const Trigger *trig);
01052
01054
01058 void sendTrigger(unsigned int partition, unsigned int crate, unsigned int rod, const Trigger *trig);
01059
01061
01067 void printABCDModule(int mid);
01068
01070
01077 void printABCDRodModule(int mid, BankType bank);
01078
01080
01084 void decodeEvent(unsigned int partition, unsigned int crate, unsigned int rod,
01085 int sl, int index, bool extFlag = false, bool errorType = false);
01086
01088
01092 void scanEvents(unsigned int partition, unsigned int crate, unsigned int rod, int sl, bool extFlag, bool errorType);
01093
01097 void reportEventErrors();
01098
01102 void decodeConfig(unsigned int partition, unsigned int crate, unsigned int rod,
01103 bool skipTrim = false, bool bypass = false);
01104
01106
01110 void rawData(unsigned int partition, unsigned int crate, unsigned int rod, int delay, int units, bool setMask = true, const Trigger *trig = 0);
01111
01113
01119 void sendL1A(unsigned int partition, unsigned int crate, unsigned int rod, bool capture = false);
01120
01122
01139 std::vector<char> probe(unsigned int partition, unsigned int crate, unsigned int rod,
01140 signed int harness = -1);
01141
01143
01160 std::vector<char> probeWithTrigger(unsigned int partition, unsigned int crate, unsigned int rod,
01161 const Trigger *trigger, signed int harness = -1);
01162
01164 std::vector<std::vector<char> > SctApi::probeScan(unsigned int partition, unsigned int crate, unsigned int rod,
01165 boost::shared_ptr<Scan> scan, signed int harness = -1);
01166
01173 bool checkAllModulesProbe(std::string value);
01174
01180 void autoConfigure();
01181
01185 void bocHistogram(unsigned int partition, unsigned int crate, unsigned int rod,
01186 unsigned int samples, unsigned int numLoops);
01187
01188
01189
01197 void requestHardResetAll();
01198
01206 void requestHardReset(UINT32 mid);
01207
01215 void requestIVCurve(UINT32 mid, FLOAT32 start, FLOAT32 stop, FLOAT32 step, UINT16 delay, FLOAT32 currentLim);
01216
01224 void requestIVCurveAll(FLOAT32 start, FLOAT32 stop, FLOAT32 step, UINT16 delay, FLOAT32 currentLim);
01225
01236 void setSelectAllInCrate(int crate, bool value, int timeout = 5);
01237
01248
01249 void setSelect(UINT32 mid, bool value);
01250
01260 void changeRunState(int state);
01261
01262
01263
01264
01265
01266
01267
01269 void ddcChangeState (int crate, int channel, short state, int timeout = 2);
01271 void ddcChangeStateAll (int crate, short state, int timeout = 2);
01273 void ddcLoadConfiguration (int crate, short state, int timeout = 2);
01275 void ddcHardReset (int crate, int channel, int timeout = 2);
01277 void ddcHardResetAll (int crate, int timeout = 2);
01278
01280 int ddcGetChannelParameterInt (int crate, int channel, std::string name, int timeout = 2);
01282 float ddcGetChannelParameterFloat (int crate, int channel, std::string name, int timeout = 2);
01284 std::string ddcGetChannelParameterString (int crate, int channel, std::string name, int timeout = 2);
01286 int ddcGetCardParameterInt (int crate, int card, std::string name, int timeout = 2);
01288 float ddcGetCardParameterFloat (int crate, int card, std::string name, int timeout = 2);
01290 std::string ddcGetCardParameterString (int crate, int card, std::string name, int timeout = 2);
01292 int ddcGetCrateParameterInt (int crate, std::string name, int timeout = 2);
01294 float ddcGetCrateParameterFloat (int crate, std::string name, int timeout = 2);
01296 std::string ddcGetCrateParameterString (int crate, std::string name, int timeout = 2);
01297
01299
01304 void ddcGetCrateParameters(int crate, std::vector<std::string> names,
01305 std::map<std::string, float>& dpeValues, int timeout);
01306
01308 void ddcSetChannelParameter (int crate, int channel, std::string name, float value, int timeout = 2);
01310 void ddcSetCardParameter (int crate, int card, std::string name, float value, int timeout = 2);
01312 void ddcSetCrateParameter (int crate, std::string name, float value, int timeout = 2);
01313
01314
01315
01326 void tidyHistogramming();
01327
01331 long getRodSlot(unsigned int partition, unsigned int crate, unsigned int rod);
01332
01336 int getRodRevision(unsigned int partition, unsigned int crate, unsigned int rod);
01337
01341 int getRodRevision(const RodLabel &label);
01342
01346 void testLinkOutSelect(unsigned int partition, unsigned int crate, unsigned int rod,
01347 unsigned int link);
01348
01352 unsigned int testLinkOutRetrieve(unsigned int partition, unsigned int crate, unsigned int rod);
01353
01361 void unsetDebugOption(std::string opt);
01362
01370 void setDebugOption(std::string opt);
01371
01379 std::list<std::string> listEnabledDebugOptions();
01380
01388 std::vector<std::string> listDebugOptions();
01389
01393 void debugStepHistogram();
01394
01400 void debugContinueHistogram();
01401
01408 void debugAbortHistogram();
01409
01415 void eventTrapSetup(int slaveMask, int trapMatch, int trapMod, int trapRemain, bool tim, bool error,
01416 boost::shared_ptr<PrimListWrapper> primList);
01417
01419 void startEventTrap(int slave, boost::shared_ptr<PrimListWrapper> primList);
01420
01422 void stopEventTrap(int slave, boost::shared_ptr<PrimListWrapper> primList);
01423
01425 void rodMode(unsigned int partition, unsigned int crate, unsigned int rod,
01426 int mode, int flag, int fifoSetup, int nBins, int delay, int message);
01427
01429 void setupModuleMask(unsigned int partition, unsigned int crate, unsigned int rod,
01430 int port, int slvs);
01431
01433 void setupModuleMask(int port, int slvs, boost::shared_ptr<PrimListWrapper> list);
01434
01436 std::pair<UINT32, UINT32> sendData(unsigned int partition, unsigned int crate, unsigned int rod, int type, int dsp);
01437
01441 void resumePolling();
01442
01446 void stopPolling();
01447
01449 void print_calib(unsigned int partition, unsigned int crate, unsigned int rod);
01450
01452
01457 int synchSendPrimListAllCrates(boost::shared_ptr<PrimListWrapper> primList, int timeout = 10);
01458
01460 void stopHistogramming(const ScanEx &ex);
01461
01463 void setSlaveBlock(unsigned int partition, unsigned int crate, unsigned int rod,
01464 int s, long sAdd, int words, long value = 0, bool usePrim = true);
01465
01467 void writeRODRegister(unsigned int partition, unsigned int crate, unsigned int rod,
01468 int reg, int off, int width, int value);
01469
01471 unsigned int readRODRegister(unsigned int partition, unsigned int crate, unsigned int rod, int r);
01472
01474 int pollRegister(unsigned int partition, unsigned int crate, unsigned int rod, int r, int off, int width, int val, int timeout = 1000000);
01475
01476 virtual unsigned long *readFifo(unsigned int partition, unsigned int crate, unsigned int rod, int id, int bank, int elems);
01477
01479 void startHistogramTask(const Scan &scan, const ScanEx &ex, const RodLabel,
01480 unsigned int startBin, unsigned int nBins, unsigned int nTrigs,
01481 boost::shared_ptr<PrimListWrapper> list);
01482
01484
01489 void sendPrimList(unsigned int partition, unsigned int crate, unsigned int rod,
01490 boost::shared_ptr<PrimListWrapper> prim);
01491
01492 MRSStream *mrs;
01493 #if USE_IS
01494 ISInfoDictionary *m_isDict;
01495 #endif
01496 protected:
01497
01498
01499
01501
01506 virtual int initialiseRod(unsigned int partition, unsigned int crate, unsigned int rod);
01507
01509
01515 virtual int initialiseModule(std::string module);
01516
01518 ABCDModule *lookupConfig(UINT32 mid);
01519
01521
01525 virtual bool preScanHardwareCheck(Scan& scan, ScanEx& extra);
01526
01527 virtual void doHistogramSetup(const Scan &scan, const ScanEx &extra);
01528
01533 UINT32 *readEventBuffer(unsigned int partition, unsigned int crate, unsigned int rod,
01534 int sl, bool extFlag, bool errorType);
01535
01539 int getLastEventFrame(unsigned int partition, unsigned int crate, unsigned int rod, int slave);
01540
01542
01551 virtual int pollHistogramming(boost::shared_ptr<ScanControl> controller, int timeout = 5);
01552
01553 void scanLoop();
01554
01555 void scanPollingThread();
01556
01557 void addRodToList(RodLabel newRod);
01558
01559 RodInfo &SctApi::getRodInfo(const RodLabel &l);
01560
01562 std::list<RodLabel> rodList;
01563
01565 std::map<RodLabel, RodInfo> rodInfoList;
01566
01568 std::map<UINT32, ABCDModule> moduleMap;
01569
01570
01571 boost::shared_ptr<ScanControl> scanController;
01572
01573
01574 boost::shared_ptr<ScanControl> lastScanController;
01575
01576 private:
01577
01578
01579
01580
01581
01582
01584
01590 void sendSlavePrimList(unsigned int partition, unsigned int crate, unsigned int rod,
01591 boost::shared_ptr<PrimListWrapper> prim, unsigned int slave, bool await, bool response);
01592
01594
01599 void sendPrimListAll(unsigned int partition, unsigned int crate,
01600 boost::shared_ptr<PrimListWrapper> prim);
01601
01603 void setupEventTrapping(const Scan &scan, const ScanEx &ex, const RodLabel, boost::shared_ptr<PrimListWrapper> list);
01604
01606 void startEventTrapping(const Scan &scan, const ScanEx &ex, const RodLabel, boost::shared_ptr<PrimListWrapper> primList);
01607
01609 void setupEventDump(const Scan &scan, const ScanEx &ex, const RodLabel, boost::shared_ptr<PrimListWrapper> list);
01610
01612 void setupHistogramming(const Scan &scan, const ScanEx &ex, const RodLabel, bool tim,
01613 boost::shared_ptr<PrimListWrapper> list);
01614
01616 void calib_init();
01617
01619 void readRawData(unsigned int partition, unsigned int crate, unsigned int rod,
01620 int delay, bool setMask);
01621
01623 virtual int setupRawData(unsigned int partition, unsigned int crate, unsigned int rod,
01624 int delay, int units, bool setMask, const Trigger *trig = 0);
01625
01627
01631 Crate *getCrate(unsigned int partition, unsigned int crate) const;
01632
01634 void cacheModuleConfig(UINT32 mid);
01635
01637
01640 void getrpcrc(UINT32 mid, unsigned int &rpartition, unsigned int &rcrate, unsigned int &rrod, unsigned &rchannel);
01641
01643 void initDDC();
01644
01646 void setupScanMasks(ScanEx &extra, int distSlave, bool dual);
01647
01649 bool checkModuleListsForScan();
01650
01652
01655 void preScanModuleSetup(Scan &scan);
01656
01657 bool checkDebugOption(std::string opt);
01658
01659 bool checkDebugOption(int opt);
01660
01661
01662
01664 boost::shared_ptr<SctConfiguration::Configuration> config;
01665
01666 IPCPartition *ddcPartition;
01667 std::string *ddcCtrls[2];
01668 SCTDCSCommand *ddcCmd;
01669
01670 boost::shared_ptr<DCSAccess> dcsAccess;
01671
01673 boost::shared_ptr<PrimListWrapper> debugPrimList;
01674
01676 std::map<std::pair<unsigned int, unsigned int>, Crate* > crateMap;
01677
01679 Log log;
01680
01682 boost::shared_ptr<const Scan> lastDebugScan;
01683 boost::shared_ptr<const ScanEx> lastDebugScanEx;
01684
01686 UINT32 scanNumber;
01687
01689 UINT32 runNumber;
01690
01691 #if USE_SCAN_THREAD
01692 boost::condition scanQueue_notEmpty;
01693 boost::mutex scanQueue_mutex;
01694
01695
01696 std::auto_ptr<boost::thread> scanPollThread;
01697
01698 bool m_stopPolling;
01699 bool m_inScanLoop;
01700 #endif
01701
01702
01703 boost::mutex logMutex;
01704 };
01705 }
01706 #endif