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
00236 void shutdownAll();
00237
00239 void setRunNumber(int newRun);
00240
00242 void setScanNumber(int newScan);
00243
00245 void changeRunMode(enum SctApi::RunType mode);
00246
00247
00248
00250
00254 void echo(unsigned int rod,
00255 unsigned int length, unsigned long *data);
00256
00258
00262 void echoAll(unsigned int length, unsigned long *data);
00263
00265
00269 void echoSlave(unsigned int rod,
00270 unsigned int slave, unsigned int length, unsigned long *data);
00271
00273 void loadConfiguration();
00274
00276 void loadModuleConfigurations();
00277
00279 void configureBOC(unsigned int rod);
00280
00282 void awaitResponse(unsigned int rod, int timeout = 5);
00283
00285 unsigned long *getResponse(unsigned int rod);
00286
00288 unsigned long *getResponse(unsigned int rod,
00289 unsigned long *length);
00290
00292
00296 bool getRodMessage(unsigned int rod,
00297 char *buffer, unsigned long &length);
00298
00300
00306 void flashLED(unsigned int rod,
00307 long slaveNumber, long period = 1000, long flashes = 10);
00308
00309
00310 void status();
00311
00312
00315
00316
00319 Int_t dspBlockDump(unsigned int rod,
00320 long dspStart, long numWords, long dspNumber, bool usePrimitive = true);
00321
00323
00326 Int_t dspBlockDumpFile(unsigned int rod,
00327 long dspStart, long numWords, long dspNumber, const char *filename, bool usePrimitive = true);
00328
00330
00333 unsigned long *dspBlockRead(unsigned int rod,
00334 long dspStart, long numWords, long dspNumber,
00335 unsigned long *length, bool usePrimitive = true);
00336
00338 int dspBlockWrite(unsigned int rod,
00339 unsigned long *buffer, unsigned long dspAddress, long numWords,
00340 long dspNumber, bool usePrimitive = true);
00341
00343 unsigned long readRodStatusReg(unsigned int rod,
00344 long regNumber);
00345
00347 unsigned long readRodCommandReg(unsigned int rod,
00348 long regNumber);
00349
00351 unsigned long dspSingleRead(unsigned int rod,
00352 const unsigned long dspAddr, long dspNumber);
00353
00355 void dspSingleWrite(unsigned int rod,
00356 unsigned long dspAddr, unsigned long value, long dspNumber);
00357
00359 void createDebugPrimList();
00360
00362 void addDebugPrimList(unsigned long length, long index, long id, long version,
00363 unsigned long * body);
00364
00366 void sendDebugPrimList(unsigned int rod);
00367
00369 void sendDebugPrimListAll();
00370
00372 void sendDebugSlavePrimList(unsigned int rod,
00373 unsigned int slave, bool await, bool response);
00374
00375 void debugPrimListFromFile(const char *fileName);
00376
00377 void dumpDebugPrimList();
00378
00379 std::list<SctApi::RodLabel> listRods();
00380
00382 unsigned long *retrieveModule(UINT32 mid);
00383
00384
00385
00387
00391 UINT32 findModule(const char *sn);
00392
00394 UINT32 findModule(INT32 mur, INT32 module);
00395
00397 UINT32 findBarrelModule(INT32 barrel, INT32 row, INT32 number);
00398
00400 UINT32 findEndcapModule(INT32 disk, INT32 ring, INT32 number);
00401
00403 void getABCDModules(UINT32 bank);
00404
00406 void getABCDModule(UINT32 mid, UINT32 bank);
00407
00409 void setABCDModules(UINT32 bank);
00410
00412 void copyABCDModules(UINT32 source, std::list<UINT32> targets);
00413
00415 void copyABCDModules(UINT32 mid, UINT32 source, std::list<UINT32> targets);
00416
00417
00418 void TApi::setABCDModules(std::list<UINT32> banks);
00419
00421 void setABCDModule(UINT32 mid, UINT32 bank);
00422
00424
00429 void sendABCDModule(UINT32 mid, UINT32 bank, UINT32 type=SctApi::SCTAPI_CONFIG_ALL);
00430
00432
00436 void sendABCDModules(UINT32 bank, UINT32 type=SctApi::SCTAPI_CONFIG_ALL);
00437
00439 void modifyABCDMask(UINT32 mid, UINT32* mask);
00440
00442 void modifyABCDTrims(UINT32 mid, UINT8* trims);
00443
00445 void setAutoUpdateBanks(std::list<UINT32> banks);
00446
00448 void setAutoUpdateBank(UINT32 bank);
00449
00451 void modifyABCDVar(UINT32 typ, FLOAT32 var);
00452
00454 void modifyABCDVar(UINT32 mid, UINT32 typ, FLOAT32 var);
00455
00457 void modifyABCDVar(UINT32 mid, UINT32 c, UINT32 typ, FLOAT32 var);
00458
00460 void modifyABCDVarROD(UINT32 mid, UINT32 chip, UINT32 typ, FLOAT32 var, UINT32 bank);
00461
00463 void modifyABCDVarROD(UINT32 mid, UINT32 chip, UINT32 typ, FLOAT32 var, std::list<UINT32> banks);
00464
00466 void modifyABCDVarROD(UINT32 mid, UINT32 typ, FLOAT32 var, UINT32 bank);
00467
00469 void modifyABCDVarROD(UINT32 mid, UINT32 typ, FLOAT32 var, std::list<UINT32> banks);
00470
00472 void modifyABCDVarROD(UINT32 typ, FLOAT32 var, UINT32 bank);
00473
00475 void modifyABCDVarROD(UINT32 typ, FLOAT32 var, std::list<UINT32> banks);
00476
00478 void modifyBOCParam(unsigned int rod,
00479 unsigned int channel, unsigned int type, unsigned int val);
00480
00482 void modifyBOCParam(unsigned int type, unsigned int val);
00483
00485 void defaultScan(int type);
00486
00488 void tidyHistogramming();
00489
00491 TScanMonitor *startAsyncScan(TScanDef tscan);
00492
00494 void doScan(TScanDef scan);
00495
00496 void awaitScan();
00497
00499 void doRawScan(TScanDef scan, int delay, int width, bool configure = true, bool clkBy2 = false);
00500
00502 void sendRodTrigger(unsigned int rod, TTrigger trig, unsigned long count, int scan_point=0);
00503
00508 unsigned long sendTriggers(TTrigger trig, unsigned long count);
00509
00511
00514 void printABCDModule(int mid);
00515
00517
00520 void printABCDRodModule(int mid, int bank);
00521
00523 void printBOCSetup(unsigned int rod);
00524
00525 void currentBOCSetup(unsigned int rod);
00526
00528 void printBOCRegisters(unsigned int rod);
00529
00530
00531
00533 void saveBOCSetup(unsigned int rod, UINT32 bank);
00534
00536 void saveBOCRegisters(unsigned int rod, UINT32 bank);
00537
00539 void restoreBOCSetup(unsigned int rod, UINT32 bank);
00540
00542 void restoreBOCRegisters(unsigned int rod, UINT32 bank);
00543
00545 void rawData(unsigned int rod, int delay, int units, bool setMask = true, TTrigger trig = TTrigger());
00546
00548 char *probe(unsigned int rod, signed int harness = -1);
00549
00551 char *probeWithTrigger(unsigned int rod, TTrigger trig, signed int harness = -1);
00552
00554 void probeScan(unsigned int rod,
00555 TScanDef scan, signed int harness = -1);
00556
00558 bool checkAllModulesProbe(const char *value);
00559
00561 void autoConfigure();
00562
00564 void bocHistogram(unsigned int rod,
00565 unsigned int samples, unsigned int numLoops);
00566
00568 void rodMode(unsigned int rod,
00569 int mode, int flag, int fifoSetup, int nBins, int delay, int message);
00570
00571 void standardRegisterDump(unsigned int rod);
00572
00574
00577 void lasersOff();
00578
00580 void scanEvents(unsigned int rod, int sl = -1,
00581 bool extFlag = false, bool errorType = false);
00582
00584 void decodeEvent(unsigned int rod,
00585 int sl, int index, bool extFlag = false, bool errorType = false);
00586
00590 void decodeConfig(unsigned int rod,
00591 bool skipTrim = false, bool bypass = false);
00592
00593 void testLinkOutSelect(unsigned int rod,
00594 unsigned int link);
00595
00596 void setDebugOption(const char *opt);
00597
00598 void unsetDebugOption(const char *opt);
00599
00600 void listEnabledDebugOptions();
00601
00602 void listDebugOptions();
00603
00604 void debugStepHistogram();
00605
00606 void debugContinueHistogram();
00607
00608 void debugAbortHistogram();
00609
00610
00611
00613
00616 void timSetFrequency(double trigFreq, double rstFreq);
00617
00619 double timGetResetFrequency();
00620
00622 double timGetTriggerFrequency();
00623
00625
00628 void freeTriggers();
00629
00631 void stopTriggers();
00632
00634 void timL1A();
00635
00637 void timCalL1A(int delay);
00638
00640 void timSoftReset();
00641
00643 void timBCReset();
00644
00646 unsigned long sendTimBurst(unsigned long count, int random, bool external=false);
00647
00649 unsigned long runTimSequence(unsigned long count, int random, bool external=false);
00650
00652 void timVerbose();
00653
00654 void timRegLoad(int reg, UINT16 val);
00655
00656 UINT16 timReadRegister(int reg);
00657
00658 void requestHardReset(UINT32 mid);
00659
00660 void resumePolling();
00661
00662 void stopPolling();
00663 private:
00664 TApi(const TApi&);
00665 TApi &operator=(const TApi &);
00666
00668 SctApi::SctApi *worker;
00669
00670
00671 ClassDef(TApi,1)
00672 };
00673
00674
00675
00676 #endif