00001
00002
00003 #ifndef SCTAPI_TAPI_H
00004 #define SCTAPI_TAPI_H
00005
00006 #include <list>
00007 #include <string>
00008 #include <TArrayD.h>
00009 #include <TArrayI.h>
00010 #include <TArrayL.h>
00011 #include <TArrayS.h>
00012
00013
00014 #include "SctApiFwd.h"
00015
00016 #ifndef __CINT__
00017 #include "TApiWrappers.h"
00018 #endif
00019
00020 #include "processor.h"
00021
00022 #include <TObject.h>
00023
00024
00025
00026 class TriggerWrapper;
00027 class ScanDefWrapper;
00028 class ScanMonitorWrapper;
00029
00033 class TTrigger : private TriggerWrapper {
00034 TTrigger &operator=(const TTrigger &);
00035
00036 public:
00038 TTrigger();
00039
00040 TTrigger(const TTrigger &);
00041
00043 virtual ~TTrigger();
00044
00045 void singleL1A();
00046 void doubleL1A(int delay);
00047 void delayedL1A(int delay);
00048 void calL1A(int delay);
00049 void pulseL1A(int delay);
00050 void softL1A(int delay);
00051 void softCalL1A(int delay, int delay2);
00052 void softPulseL1A(int delay, int delay2);
00053 void bcL1A(int delay);
00054 void bcCalL1A(int delay, int delay2);
00055 void bcPulseL1A(int delay, int delay2);
00056
00057 void print();
00058
00060 int incCmd;
00061
00063 int incData;
00064
00066 int source;
00067
00069 double frequency;
00070
00072 int random;
00073
00074 private:
00075 void update();
00076
00077 friend class TApi;
00078 friend class TScanDef;
00079
00080
00081 ClassDef(TTrigger,1)
00082 };
00083
00089 class TScanDef : private ScanDefWrapper {
00090 TScanDef &operator=(const TScanDef &);
00091
00092 public:
00094 TScanDef();
00095
00096 TScanDef(const TScanDef &);
00097
00099 virtual ~TScanDef();
00100
00102 void print();
00103
00105 void configure(UINT16 type, FLOAT32 start, FLOAT32 stop, FLOAT32 step);
00106
00108 void configure2(UINT16 type, FLOAT32 start, FLOAT32 stop, FLOAT32 step);
00109
00111 void setScanPoint(int index, FLOAT32 value);
00112
00114 void setScanPoint2(int index, FLOAT32 value);
00115
00117 void setTriggersPoint(int index, UINT32 ntrigs);
00118
00120 long trigsPerBurst;
00121
00123 int scanVariable;
00124
00126 int scanVariable2;
00127
00129 TTrigger trigSequence;
00130
00132 TTrigger trigSequence2;
00133
00135 int full;
00136
00138 int bits32;
00139
00141 int loopCalLine;
00142
00144 int distSlave;
00145
00147 int debug;
00148
00150 int tim;
00151
00153 int nth;
00154
00156 int nth_rem;
00157
00159 int enableDataMode;
00160
00162 int ccode;
00163
00165 int ope;
00166
00167 private:
00169 void update();
00170
00171 friend class TApi;
00172
00173
00174 ClassDef(TScanDef,1)
00175 };
00176
00182 class TScanMonitor : private ScanMonitorWrapper {
00183 TScanMonitor &operator=(const TScanMonitor &);
00184 TScanMonitor(const TScanMonitor &);
00185
00186 protected:
00188 TScanMonitor();
00189
00190 public:
00192 virtual ~TScanMonitor();
00193
00194 void newBin(int prevTriggers, int newBin);
00195 void finishScan();
00196
00197 private:
00198
00199 friend class ScanMonitorWrapper;
00200
00201
00202
00203 ClassDef(TScanMonitor,1)
00204 };
00205
00221 class TApi : public TObject {
00222 public:
00224 TApi(std::string plugin = "xml");
00225
00227 ~TApi();
00228
00230
00233 void initialiseAll(int runNumber);
00234
00235 bool isInitialised();
00236
00238 void shutdownAll();
00239
00241 void setRunNumber(int newRun);
00242
00244 void setScanNumber(int newScan);
00245
00247 void changeRunMode(enum SctApi::RunType mode);
00248
00249
00250
00252
00256 void echo(unsigned int rod,
00257 unsigned int length, unsigned long *data);
00258
00260
00264 void echoAll(unsigned int length, unsigned long *data);
00265
00267
00271 void echoSlave(unsigned int rod,
00272 unsigned int slave, unsigned int length, unsigned long *data);
00273
00275 void loadConfiguration();
00276
00278 void loadModuleConfigurations();
00279
00281 void configureBOC(unsigned int rod);
00282
00284 void awaitResponse(unsigned int rod, int timeout = 5);
00285
00287 unsigned long *getResponse(unsigned int rod);
00288
00290 unsigned long *getResponse(unsigned int rod,
00291 unsigned long *length);
00292
00294
00298 bool getRodMessage(unsigned int rod,
00299 char *buffer, unsigned long &length);
00300
00302
00308 void flashLED(unsigned int rod,
00309 long slaveNumber, long period = 1000, long flashes = 10);
00310
00311
00312 void status();
00313
00314
00317
00318
00321 Int_t dspBlockDump(unsigned int rod,
00322 long dspStart, long numWords, long dspNumber, bool usePrimitive = true);
00323
00325
00328 Int_t dspBlockDumpFile(unsigned int rod,
00329 long dspStart, long numWords, long dspNumber, const char *filename, bool usePrimitive = true);
00330
00332
00335 unsigned long *dspBlockRead(unsigned int rod,
00336 long dspStart, long numWords, long dspNumber,
00337 unsigned long *length, bool usePrimitive = true);
00338
00340 int dspBlockWrite(unsigned int rod,
00341 unsigned long *buffer, unsigned long dspAddress, long numWords,
00342 long dspNumber, bool usePrimitive = true);
00343
00345 unsigned long readRodStatusReg(unsigned int rod,
00346 long regNumber);
00347
00349 unsigned long readRodCommandReg(unsigned int rod,
00350 long regNumber);
00351
00353 unsigned long dspSingleRead(unsigned int rod,
00354 const unsigned long dspAddr, long dspNumber);
00355
00357 void dspSingleWrite(unsigned int rod,
00358 unsigned long dspAddr, unsigned long value, long dspNumber);
00359
00361 void createDebugPrimList();
00362
00364 void addDebugPrimList(unsigned long length, long index, long id, long version,
00365 unsigned long * body);
00366
00368 void sendDebugPrimList(unsigned int rod);
00369
00371 void sendDebugPrimListAll();
00372
00374 void sendDebugSlavePrimList(unsigned int rod,
00375 unsigned int slave, bool await, bool response);
00376
00377 void debugPrimListFromFile(const char *fileName);
00378
00379 void dumpDebugPrimList();
00380
00381 std::list<SctApi::RodLabel> listRods();
00382
00384 unsigned long *retrieveModule(UINT32 mid);
00385
00386
00387
00389
00393 UINT32 findModule(const char *sn);
00394
00396 UINT32 findModule(INT32 mur, INT32 module);
00397
00399 UINT32 findBarrelModule(INT32 barrel, INT32 row, INT32 number);
00400
00402 UINT32 findEndcapModule(INT32 disk, INT32 ring, INT32 number);
00403
00405 void getABCDModules(UINT32 bank);
00406
00408 void getABCDModule(UINT32 mid, UINT32 bank);
00409
00411 void setABCDModules(UINT32 bank);
00412
00414 void copyABCDModules(UINT32 source, std::list<UINT32> targets);
00415
00417 void copyABCDModules(UINT32 mid, UINT32 source, std::list<UINT32> targets);
00418
00419
00420 void TApi::setABCDModules(std::list<UINT32> banks);
00421
00423 void setABCDModule(UINT32 mid, UINT32 bank);
00424
00426
00431 void sendABCDModule(UINT32 mid, UINT32 bank, UINT32 type=SctApi::SCTAPI_CONFIG_ALL);
00432
00434
00438 void sendABCDModules(UINT32 bank, UINT32 type=SctApi::SCTAPI_CONFIG_ALL);
00439
00441 void modifyABCDMask(UINT32 mid, UINT32* mask);
00442
00444 void modifyABCDTrims(UINT32 mid, UINT8* trims);
00445
00447 void setAutoUpdateBanks(std::list<UINT32> banks);
00448
00450 void setAutoUpdateBank(UINT32 bank);
00451
00453 void modifyABCDVar(UINT32 typ, FLOAT32 var);
00454
00456 void modifyABCDVar(UINT32 mid, UINT32 typ, FLOAT32 var);
00457
00459 void modifyABCDVar(UINT32 mid, UINT32 c, UINT32 typ, FLOAT32 var);
00460
00462 void modifyABCDVarROD(UINT32 mid, UINT32 chip, UINT32 typ, FLOAT32 var, UINT32 bank);
00463
00465 void modifyABCDVarROD(UINT32 mid, UINT32 chip, UINT32 typ, FLOAT32 var, std::list<UINT32> banks);
00466
00468 void modifyABCDVarROD(UINT32 mid, UINT32 typ, FLOAT32 var, UINT32 bank);
00469
00471 void modifyABCDVarROD(UINT32 mid, UINT32 typ, FLOAT32 var, std::list<UINT32> banks);
00472
00474 void modifyABCDVarROD(UINT32 typ, FLOAT32 var, UINT32 bank);
00475
00477 void modifyABCDVarROD(UINT32 typ, FLOAT32 var, std::list<UINT32> banks);
00478
00480 void modifyBOCParam(unsigned int rod,
00481 unsigned int channel, unsigned int type, unsigned int val);
00482
00484 void modifyBOCParam(unsigned int type, unsigned int val);
00485
00487 void defaultScan(int type);
00488
00490 void tidyHistogramming();
00491
00493 TScanMonitor *startAsyncScan(TScanDef tscan);
00494
00496 void doScan(TScanDef scan);
00497
00498 void awaitScan();
00499
00501 void doRawScan(TScanDef scan, int delay, int width, bool configure = true, bool clkBy2 = false);
00502
00504 void sendRodTrigger(unsigned int rod, TTrigger trig, unsigned long count, int scan_point=0);
00505
00510 unsigned long sendTriggers(TTrigger trig, unsigned long count);
00511
00513
00516 void printABCDModule(int mid);
00517
00519
00522 void printABCDRodModule(int mid, int bank);
00523
00525 void printBOCSetup(unsigned int rod);
00526
00527 void currentBOCSetup(unsigned int rod);
00528
00530 void printBOCRegisters(unsigned int rod);
00531
00532
00533
00535 void saveBOCSetup(unsigned int rod, UINT32 bank);
00536
00538 void saveBOCRegisters(unsigned int rod, UINT32 bank);
00539
00541 void restoreBOCSetup(unsigned int rod, UINT32 bank);
00542
00544 void restoreBOCRegisters(unsigned int rod, UINT32 bank);
00545
00547 void rawData(unsigned int rod, int delay, int units, bool setMask = true, TTrigger trig = TTrigger());
00548
00550 char *probe(unsigned int rod, signed int harness = -1);
00551
00553 char *probeWithTrigger(unsigned int rod, TTrigger trig, signed int harness = -1);
00554
00556 void probeScan(unsigned int rod,
00557 TScanDef scan, signed int harness = -1);
00558
00560 bool checkAllModulesProbe(const char *value);
00561
00563 void autoConfigure();
00564
00566 void bocHistogram(unsigned int rod,
00567 unsigned int samples, unsigned int numLoops);
00568
00570 void rodMode(unsigned int rod,
00571 int mode, int flag, int fifoSetup, int nBins, int delay, int message);
00572
00573 void standardRegisterDump(unsigned int rod);
00574
00576
00579 void lasersOff();
00580
00582 void scanEvents(unsigned int rod, int sl = -1,
00583 bool extFlag = false, bool errorType = false);
00584
00586 void decodeEvent(unsigned int rod,
00587 int sl, int index, bool extFlag = false, bool errorType = false);
00588
00592 void decodeConfig(unsigned int rod,
00593 bool skipTrim = false, bool bypass = false);
00594
00595 void testLinkOutSelect(unsigned int rod,
00596 unsigned int link);
00597
00598 void setDebugOption(const char *opt);
00599
00600 void unsetDebugOption(const char *opt);
00601
00602 void listEnabledDebugOptions();
00603
00604 void listDebugOptions();
00605
00606 void debugStepHistogram();
00607
00608 void debugContinueHistogram();
00609
00610 void debugAbortHistogram();
00611
00612
00613
00615
00618 void timSetFrequency(double trigFreq, double rstFreq);
00619
00621 double timGetResetFrequency();
00622
00624 double timGetTriggerFrequency();
00625
00627
00630 void freeTriggers();
00631
00633 void stopTriggers();
00634
00636 void timL1A();
00637
00639 void timCalL1A(int delay);
00640
00642 void timSoftReset();
00643
00645 void timBCReset();
00646
00648 unsigned long sendTimBurst(unsigned long count, int random, bool external=false);
00649
00651 unsigned long runTimSequence(unsigned long count, int random, bool external=false);
00652
00654 void timVerbose();
00655
00656 void timRegLoad(int reg, UINT16 val);
00657
00658 UINT16 timReadRegister(int reg);
00659
00660 void requestHardReset(UINT32 mid);
00661
00662 void resumePolling();
00663
00664 void stopPolling();
00665 private:
00666 TApi(const TApi&);
00667 TApi &operator=(const TApi &);
00668
00670 SctApi::SctApi *worker;
00671
00672
00673 ClassDef(TApi,1)
00674 };
00675
00676
00677
00678 #endif