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
00032 class TTrigger : private TriggerWrapper {
00033 TTrigger &operator=(const TTrigger &);
00034
00035 public:
00037 TTrigger();
00038
00039 TTrigger(const TTrigger &);
00040
00042 virtual ~TTrigger();
00043
00044 void singleL1A();
00045 void doubleL1A(int delay);
00046 void delayedL1A(int delay);
00047 void calL1A(int delay);
00048 void pulseL1A(int delay);
00049 void softL1A(int delay);
00050 void softCalL1A(int delay, int delay2);
00051 void softPulseL1A(int delay, int delay2);
00052 void bcL1A(int delay);
00053 void bcCalL1A(int delay, int delay2);
00054 void bcPulseL1A(int delay, int delay2);
00055
00057 int incCmd;
00058
00060 int incData;
00061
00062 private:
00063 void update();
00064
00065 friend class TApi;
00066 friend class TScanDef;
00067
00068
00069 ClassDef(TTrigger,1)
00070 };
00071
00077 class TScanDef : private ScanDefWrapper {
00078 TScanDef &operator=(const TScanDef &);
00079
00080 public:
00082 TScanDef();
00083
00084 TScanDef(const TScanDef &);
00085
00087 virtual ~TScanDef();
00088
00090 void print();
00091
00093 void configure(UINT16 type, FLOAT32 start, FLOAT32 stop, FLOAT32 step);
00094
00096 void configure2(UINT16 type, FLOAT32 start, FLOAT32 stop, FLOAT32 step);
00097
00099 void setScanPoint(int index, FLOAT32 value);
00100
00102 void setScanPoint2(int index, FLOAT32 value);
00103
00105 void setTriggersPoint(int index, UINT32 ntrigs);
00106
00108 long trigsPerBurst;
00109
00111 int scanVariable;
00112
00114 int scanVariable2;
00115
00117 TTrigger trigSequence;
00118
00120 TTrigger trigSequence2;
00121
00123 int full;
00124
00126 int bits32;
00127
00129 int loopCalLine;
00130
00132 int distSlave;
00133
00135 int debug;
00136
00138 int tim;
00139
00141 int nth;
00142
00144 int nth_rem;
00145
00146 private:
00148 void update();
00149
00150 friend class TApi;
00151
00152
00153 ClassDef(TScanDef,1)
00154 };
00155
00171 class TApi : public TObject {
00172 public:
00174 TApi();
00175
00177 ~TApi();
00178
00180
00183 void initialiseAll(int runNumber);
00184
00186 void shutdownAll();
00187
00189 void setRunNumber(int newRun);
00190
00192 void setScanNumber(int newScan);
00193
00194
00195
00197
00201 void echo(unsigned int partition, unsigned int crate, unsigned int rod,
00202 unsigned int length, unsigned long *data);
00203
00205
00209 void echoAll(unsigned int length, unsigned long *data);
00210
00212
00216 void echoSlave(unsigned int partition, unsigned int crate, unsigned int rod,
00217 unsigned int slave, unsigned int length, unsigned long *data);
00218
00220 void loadConfiguration();
00221
00223 void loadModuleConfigurations();
00224
00226 void configureBOC(unsigned int partition, unsigned int crate, unsigned int rod);
00227
00229 void awaitResponse(unsigned int partition, unsigned int crate, unsigned int rod, int timeout = 5);
00230
00232 unsigned long *getResponse(unsigned int partition, unsigned int crate, unsigned int rod);
00233
00235 unsigned long *getResponse(unsigned int partition, unsigned int crate, unsigned int rod,
00236 unsigned long *length);
00237
00239
00243 bool getRodMessage(unsigned int partition, unsigned int crate, unsigned int rod,
00244 char *buffer, unsigned long &length);
00245
00247
00253 void flashLED(unsigned int partition, unsigned int crate, unsigned int rod,
00254 long slaveNumber, long period = 1000, long flashes = 10);
00255
00256
00257 void status();
00258
00259
00262
00263
00266 Int_t dspBlockDump(unsigned int partition, unsigned int crate, unsigned int rod,
00267 long dspStart, long numWords, long dspNumber, bool usePrimitive = true);
00268
00270
00273 Int_t dspBlockDumpFile(unsigned int partition, unsigned int crate, unsigned int rod,
00274 long dspStart, long numWords, long dspNumber, const char *filename, bool usePrimitive = true);
00275
00277
00280 unsigned long *dspBlockRead(unsigned int partition, unsigned int crate, unsigned int rod,
00281 long dspStart, long numWords, long dspNumber,
00282 unsigned long *length, bool usePrimitive = true);
00283
00285 int dspBlockWrite(unsigned int partition, unsigned int crate, unsigned int rod,
00286 unsigned long *buffer, unsigned long dspAddress, long numWords,
00287 long dspNumber, bool usePrimitive = true);
00288
00290 unsigned long readRodStatusReg(unsigned int partition, unsigned int crate, unsigned int rod,
00291 long regNumber);
00292
00294 unsigned long readRodCommandReg(unsigned int partition, unsigned int crate, unsigned int rod,
00295 long regNumber);
00296
00298 unsigned long dspSingleRead(unsigned int partition, unsigned int crate, unsigned int rod,
00299 const unsigned long dspAddr, long dspNumber);
00300
00302 void dspSingleWrite(unsigned int partition, unsigned int crate, unsigned int rod,
00303 unsigned long dspAddr, unsigned long value, long dspNumber);
00304
00306 void createDebugPrimList();
00307
00309 void addDebugPrimList(unsigned long length, long index, long id, long version,
00310 unsigned long * body);
00311
00313 void sendDebugPrimList(unsigned int partition, unsigned int crate, unsigned int rod);
00314
00316 void sendDebugPrimListAll();
00317
00319 void sendDebugSlavePrimList(unsigned int partition, unsigned int crate, unsigned int rod,
00320 unsigned int slave, bool await, bool response);
00321
00322 void debugPrimListFromFile(const char *fileName);
00323
00324 void dumpDebugPrimList();
00325
00326 std::list<SctApi::RodLabel> listRods();
00327
00329 unsigned long *retrieveModule(UINT32 mid);
00330
00331
00332
00334
00338 UINT32 findModule(const char *sn);
00339
00341 UINT32 findModule(INT32 mur, INT32 module);
00342
00344 UINT32 findBarrelModule(INT32 barrel, INT32 row, INT32 number);
00345
00347 UINT32 findEndcapModule(INT32 disk, INT32 ring, INT32 number);
00348
00350 void getABCDModules(UINT32 bank);
00351
00353 void getABCDModule(UINT32 mid, UINT32 bank);
00354
00356 void setABCDModules(UINT32 bank);
00357
00359 void setABCDModule(UINT32 mid, UINT32 bank);
00360
00362
00367 void sendABCDModule(UINT32 mid, UINT32 bank, UINT32 type=2);
00368
00370
00374 void sendABCDModules(UINT32 bank, UINT32 type=2);
00375
00377 void modifyABCDMask(UINT32 mid, UINT32* mask);
00378
00380 void modifyABCDTrims(UINT32 mid, UINT8* trims);
00381
00383 void modifyABCDVar(UINT32 typ, FLOAT32 var);
00384
00386 void modifyABCDVar(UINT32 mid, UINT32 typ, FLOAT32 var);
00387
00389 void modifyABCDVar(UINT32 mid, UINT32 c, UINT32 typ, FLOAT32 var);
00390
00392 void modifyABCDVarROD(UINT32 mid, UINT32 chip, UINT32 typ, FLOAT32 var, UINT32 bank);
00393
00395 void modifyABCDVarROD(UINT32 typ, FLOAT32 var, UINT32 bank);
00396
00398 void modifyBOCParam(unsigned int partition, unsigned int crate, unsigned int rod,
00399 unsigned int channel, unsigned int type, unsigned int val);
00400
00402 void defaultScan(int type);
00403
00405 void tidyHistogramming();
00406
00408 void doScan(TScanDef scan);
00409
00410 void awaitScan();
00411
00413 void doRawScan(TScanDef scan, int delay, bool configure = true, bool clkBy2 = false);
00414
00416 void sendTrigger(unsigned int partition, unsigned int crate, unsigned int rod, TTrigger trig);
00417
00419
00422 void printABCDModule(int mid);
00423
00425
00428 void printABCDRodModule(int mid, int bank);
00429
00431 void printBOCSetup(unsigned int partition, unsigned int crate, unsigned int rod);
00432
00433 void currentBOCSetup(unsigned int partition, unsigned int crate, unsigned int rod);
00434
00436 void printBOCRegisters(unsigned int partition, unsigned int crate, unsigned int rod);
00437
00438 void currentBOCRegisters(unsigned int partition, unsigned int crate, unsigned int rod);
00439
00441 void saveBOCSetup(unsigned int partition, unsigned int crate, unsigned int rod, UINT32 bank);
00442
00444 void saveBOCRegisters(unsigned int partition, unsigned int crate, unsigned int rod, UINT32 bank);
00445
00447 void restoreBOCSetup(unsigned int partition, unsigned int crate, unsigned int rod, UINT32 bank);
00448
00450 void restoreBOCRegisters(unsigned int partition, unsigned int crate, unsigned int rod, UINT32 bank);
00451
00453 void rawData(unsigned int partition, unsigned int crate, unsigned int rod, int delay, int units, bool setMask = true, TTrigger trig = TTrigger());
00454
00456 char *probe(unsigned int partition, unsigned int crate, unsigned int rod, signed int harness = -1);
00457
00459 char *probeWithTrigger(unsigned int partition, unsigned int crate, unsigned int rod, TTrigger trig, signed int harness = -1);
00460
00462 void probeScan(unsigned int partition, unsigned int crate, unsigned int rod,
00463 TScanDef scan, signed int harness = -1);
00464
00466 bool checkAllModulesProbe(const char *value);
00467
00469 void autoConfigure();
00470
00472 void bocHistogram(unsigned int partition, unsigned int crate, unsigned int rod,
00473 unsigned int samples, unsigned int numLoops);
00474
00476 void rodMode(unsigned int partition, unsigned int crate, unsigned int rod,
00477 int mode, int flag, int fifoSetup, int nBins, int delay, int message);
00478
00479 void standardRegisterDump(unsigned int partition, unsigned int crate, unsigned int rod);
00480
00482
00485 void lasersOff();
00486
00488 void scanEvents(unsigned int partition, unsigned int crate, unsigned int rod, int sl = -1,
00489 bool extFlag = false, bool errorType = false);
00490
00492 void decodeEvent(unsigned int partition, unsigned int crate, unsigned int rod,
00493 int sl, int index, bool extFlag = false, bool errorType = false);
00494
00498 void decodeConfig(unsigned int partition, unsigned int crate, unsigned int rod,
00499 bool skipTrim = false, bool bypass = false);
00500
00501 void testLinkOutSelect(unsigned int partition, unsigned int crate, unsigned int rod,
00502 unsigned int link);
00503
00504 void setDebugOption(const char *opt);
00505
00506 void unsetDebugOption(const char *opt);
00507
00508 void listEnabledDebugOptions();
00509
00510 void listDebugOptions();
00511
00512 void debugStepHistogram();
00513
00514 void debugContinueHistogram();
00515
00516 void debugAbortHistogram();
00517
00518
00519
00521
00524 void timSetFrequency(unsigned int partition, unsigned int crate,
00525 double trigFreq, double rstFreq);
00526
00528
00531 void freeTriggers(unsigned int partition, unsigned int crate);
00532
00534 void stopTriggers(unsigned int partition, unsigned int crate);
00535
00537 void timL1A(unsigned int partition, unsigned int crate);
00538
00540 void timCalL1A(unsigned int partition, unsigned int crate, int delay);
00541
00543 void timSoftReset(unsigned int partition, unsigned int crate);
00544
00546 void timBCReset(unsigned int partition, unsigned int crate);
00547
00549 void sendTimBurst(unsigned int partition, unsigned int crate, int count);
00550
00552 void timVerbose(unsigned int partition, unsigned int crate);
00553
00554 void timRegLoad(unsigned int partition, unsigned int crate, int reg, UINT16 val);
00555
00556 UINT16 timReadRegister(unsigned int partition, unsigned int crate, int reg);
00557
00558 void requestHardReset(UINT32 mid);
00559
00560 void resumePolling();
00561
00562 void stopPolling();
00563 private:
00564 TApi(const TApi&);
00565 TApi &operator=(const TApi &);
00566
00568 SctApi::SctApi *worker;
00569
00570
00571 ClassDef(TApi,1)
00572 };
00573
00574
00575
00576 #endif