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
00140 private:
00142 void update();
00143
00144 friend class TApi;
00145
00146
00147 ClassDef(TScanDef,1)
00148 };
00149
00165 class TApi : public TObject {
00166 public:
00168 TApi();
00169
00171 ~TApi();
00172
00174
00177 void initialiseAll(int runNumber);
00178
00180 void shutdownAll();
00181
00183 void setRunNumber(int newRun);
00184
00186 void setScanNumber(int newScan);
00187
00188
00189
00191
00195 void echo(unsigned int partition, unsigned int crate, unsigned int rod,
00196 unsigned int length, unsigned long *data);
00197
00199
00203 void echoAll(unsigned int length, unsigned long *data);
00204
00206
00210 void echoSlave(unsigned int partition, unsigned int crate, unsigned int rod,
00211 unsigned int slave, unsigned int length, unsigned long *data);
00212
00214 void loadConfiguration();
00215
00217 void loadModuleConfigurations();
00218
00220 void configureBOC(unsigned int partition, unsigned int crate, unsigned int rod);
00221
00223 void awaitResponse(unsigned int partition, unsigned int crate, unsigned int rod, int timeout = 5);
00224
00226 unsigned long *getResponse(unsigned int partition, unsigned int crate, unsigned int rod);
00227
00229 unsigned long *getResponse(unsigned int partition, unsigned int crate, unsigned int rod,
00230 unsigned long *length);
00231
00233
00237 bool getRodMessage(unsigned int partition, unsigned int crate, unsigned int rod,
00238 char *buffer, unsigned long &length);
00239
00241
00247 void flashLED(unsigned int partition, unsigned int crate, unsigned int rod,
00248 long slaveNumber, long period = 1000, long flashes = 10);
00249
00250
00251 void status();
00252
00253
00256
00257
00260 Int_t dspBlockDump(unsigned int partition, unsigned int crate, unsigned int rod,
00261 long dspStart, long numWords, long dspNumber, bool usePrimitive = true);
00262
00264
00267 Int_t dspBlockDumpFile(unsigned int partition, unsigned int crate, unsigned int rod,
00268 long dspStart, long numWords, long dspNumber, const char *filename, bool usePrimitive = true);
00269
00271
00274 unsigned long *dspBlockRead(unsigned int partition, unsigned int crate, unsigned int rod,
00275 long dspStart, long numWords, long dspNumber,
00276 unsigned long *length, bool usePrimitive = true);
00277
00279 int dspBlockWrite(unsigned int partition, unsigned int crate, unsigned int rod,
00280 unsigned long *buffer, unsigned long dspAddress, long numWords,
00281 long dspNumber, bool usePrimitive = true);
00282
00284 unsigned long readRodStatusReg(unsigned int partition, unsigned int crate, unsigned int rod,
00285 long regNumber);
00286
00288 unsigned long readRodCommandReg(unsigned int partition, unsigned int crate, unsigned int rod,
00289 long regNumber);
00290
00292 unsigned long dspSingleRead(unsigned int partition, unsigned int crate, unsigned int rod,
00293 const unsigned long dspAddr, long dspNumber);
00294
00296 void dspSingleWrite(unsigned int partition, unsigned int crate, unsigned int rod,
00297 unsigned long dspAddr, unsigned long value, long dspNumber);
00298
00300 void createDebugPrimList();
00301
00303 void addDebugPrimList(unsigned long length, long index, long id, long version,
00304 unsigned long * body);
00305
00307 void sendDebugPrimList(unsigned int partition, unsigned int crate, unsigned int rod);
00308
00310 void sendDebugPrimListAll();
00311
00313 void sendDebugSlavePrimList(unsigned int partition, unsigned int crate, unsigned int rod,
00314 unsigned int slave, bool await, bool response);
00315
00316 void debugPrimListFromFile(const char *fileName);
00317
00318 void dumpDebugPrimList();
00319
00320 std::list<SctApi::RodLabel> listRods();
00321
00323 unsigned long *retrieveModule(UINT32 mid);
00324
00325
00326
00328
00332 UINT32 findModule(const char *sn);
00333
00335 UINT32 findModule(INT32 mur, INT32 module);
00336
00338 UINT32 findBarrelModule(INT32 barrel, INT32 row, INT32 number);
00339
00341 UINT32 findEndcapModule(INT32 disk, INT32 ring, INT32 number);
00342
00344 void getABCDModules(UINT32 bank);
00345
00347 void getABCDModule(UINT32 mid, UINT32 bank);
00348
00350 void setABCDModules(UINT32 bank);
00351
00353 void setABCDModule(UINT32 mid, UINT32 bank);
00354
00356
00361 void sendABCDModule(UINT32 mid, UINT32 bank, UINT32 type=2);
00362
00364
00368 void sendABCDModules(UINT32 bank, UINT32 type=2);
00369
00371 void modifyABCDMask(UINT32 mid, UINT32* mask);
00372
00374 void modifyABCDTrims(UINT32 mid, UINT8* trims);
00375
00377 void modifyABCDVar(UINT32 typ, FLOAT32 var);
00378
00380 void modifyABCDVar(UINT32 mid, UINT32 typ, FLOAT32 var);
00381
00383 void modifyABCDVar(UINT32 mid, UINT32 c, UINT32 typ, FLOAT32 var);
00384
00386 void modifyABCDVarROD(UINT32 mid, UINT32 chip, UINT32 typ, FLOAT32 var, UINT32 bank);
00387
00389 void modifyABCDVarROD(UINT32 typ, FLOAT32 var, UINT32 bank);
00390
00392 void modifyBOCParam(unsigned int partition, unsigned int crate, unsigned int rod,
00393 unsigned int channel, unsigned int type, unsigned int val);
00394
00396 void defaultScan(int type);
00397
00399 void tidyHistogramming();
00400
00402 void doScan(TScanDef scan);
00403
00404 void awaitScan();
00405
00407 void doRawScan(TScanDef scan, int delay, bool configure = true, bool clkBy2 = false);
00408
00410 void sendTrigger(unsigned int partition, unsigned int crate, unsigned int rod, TTrigger trig);
00411
00413
00416 void printABCDModule(int mid);
00417
00419
00422 void printABCDRodModule(int mid, int bank);
00423
00425 void printBOCSetup(unsigned int partition, unsigned int crate, unsigned int rod);
00426
00427 void currentBOCSetup(unsigned int partition, unsigned int crate, unsigned int rod);
00428
00430 void printBOCRegisters(unsigned int partition, unsigned int crate, unsigned int rod);
00431
00432 void currentBOCRegisters(unsigned int partition, unsigned int crate, unsigned int rod);
00433
00435 void saveBOCSetup(unsigned int partition, unsigned int crate, unsigned int rod);
00436
00438 void saveBOCRegisters(unsigned int partition, unsigned int crate, unsigned int rod);
00439
00441 void restoreBOCSetup(unsigned int partition, unsigned int crate, unsigned int rod);
00442
00444 void restoreBOCRegisters(unsigned int partition, unsigned int crate, unsigned int rod);
00445
00447 void rawData(unsigned int partition, unsigned int crate, unsigned int rod, int delay, int units, bool setMask = true, TTrigger trig = TTrigger());
00448
00450 char *probe(unsigned int partition, unsigned int crate, unsigned int rod, signed int harness = -1);
00451
00453 char *probeWithTrigger(unsigned int partition, unsigned int crate, unsigned int rod, TTrigger trig, signed int harness = -1);
00454
00456 void probeScan(unsigned int partition, unsigned int crate, unsigned int rod,
00457 TScanDef scan, signed int harness = -1);
00458
00460 bool checkAllModulesProbe(const char *value);
00461
00463 void autoConfigure();
00464
00466 void bocHistogram(unsigned int partition, unsigned int crate, unsigned int rod,
00467 unsigned int samples, unsigned int numLoops);
00468
00470 void rodMode(unsigned int partition, unsigned int crate, unsigned int rod,
00471 int mode, int flag, int fifoSetup, int nBins, int delay, int message);
00472
00473 void standardRegisterDump(unsigned int partition, unsigned int crate, unsigned int rod);
00474
00476
00479 void lasersOff();
00480
00482 void scanEvents(unsigned int partition, unsigned int crate, unsigned int rod, int sl = -1,
00483 bool extFlag = false, bool errorType = false);
00484
00486 void decodeEvent(unsigned int partition, unsigned int crate, unsigned int rod,
00487 int sl, int index, bool extFlag = false, bool errorType = false);
00488
00492 void decodeConfig(unsigned int partition, unsigned int crate, unsigned int rod,
00493 bool skipTrim = false, bool bypass = false);
00494
00495 void testLinkOutSelect(unsigned int partition, unsigned int crate, unsigned int rod,
00496 unsigned int link);
00497
00498 void setDebugOption(const char *opt);
00499
00500 void unsetDebugOption(const char *opt);
00501
00502 void listEnabledDebugOptions();
00503
00504 void listDebugOptions();
00505
00506 void debugStepHistogram();
00507
00508 void debugContinueHistogram();
00509
00510 void debugAbortHistogram();
00511
00512
00513
00515
00518 void timSetFrequency(unsigned int partition, unsigned int crate,
00519 double trigFreq, double rstFreq);
00520
00522
00525 void freeTriggers(unsigned int partition, unsigned int crate);
00526
00528 void stopTriggers(unsigned int partition, unsigned int crate);
00529
00531 void timL1A(unsigned int partition, unsigned int crate);
00532
00534 void timCalL1A(unsigned int partition, unsigned int crate, int delay);
00535
00537 void timSoftReset(unsigned int partition, unsigned int crate);
00538
00540 void timBCReset(unsigned int partition, unsigned int crate);
00541
00543 void sendTimBurst(unsigned int partition, unsigned int crate, int count);
00544
00546 void timVerbose(unsigned int partition, unsigned int crate);
00547
00548 void timRegLoad(unsigned int partition, unsigned int crate, int reg, UINT16 val);
00549
00550 UINT16 timReadRegister(unsigned int partition, unsigned int crate, int reg);
00551
00552 void requestHardReset(UINT32 mid);
00553
00554 void resumePolling();
00555
00556 void stopPolling();
00557 private:
00558 TApi(const TApi&);
00559 TApi &operator=(const TApi &);
00560
00562 SctApi::SctApi *worker;
00563
00564
00565 ClassDef(TApi,1)
00566 };
00567
00568
00569
00570 #endif