00001
00002
00003 #ifndef SCTAPI_TAPI_H
00004 #define SCTAPI_TAPI_H
00005
00006 #include <string>
00007 #include <TArrayD.h>
00008 #include <TArrayI.h>
00009 #include <TArrayL.h>
00010 #include <TArrayS.h>
00011
00012
00013 namespace SctApi {
00014 class SctApi;
00015 class Trigger;
00016 class Scan;
00017
00018 class TriggerImpl;
00019 class ScanDefImpl;
00020 }
00021
00022 #include "processor.h"
00023
00024 #include <TObject.h>
00025
00026 using std::string;
00027
00028
00029
00033 class TTrigger {
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 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
00056 SctApi::Trigger *getTrigger();
00057
00059 int incCmd;
00060
00062 int incData;
00063
00064 private:
00065 void update();
00066
00067 SctApi::TriggerImpl *worker;
00068
00069
00070 ClassDef(TTrigger,1)
00071 };
00072
00078 class TScanDef {
00079 TScanDef &operator=(const TScanDef &);
00080
00081 public:
00083 TScanDef();
00084
00085 TScanDef(const TScanDef &);
00086
00088 virtual ~TScanDef();
00089
00091 void print();
00092
00094 void configure(UINT16 type, FLOAT32 start, FLOAT32 stop, FLOAT32 step);
00095
00097 void configure2(UINT16 type, FLOAT32 start, FLOAT32 stop, FLOAT32 step);
00098
00099 SctApi::Scan *getScan();
00100
00102 long trigsPerBurst;
00103
00105 int scanVariable;
00106
00108 int scanVariable2;
00109
00111 TTrigger trigSequence;
00112
00114 TTrigger trigSequence2;
00115
00117 int format;
00118
00120 int full;
00121
00123 int bits32;
00124
00126 int loopCalLine;
00127
00129 int distSlave;
00130
00132 int debug;
00133 private:
00135 void update();
00136
00137 SctApi::ScanDefImpl *worker;
00138
00139
00140 ClassDef(TScanDef,1)
00141 };
00142
00158 class TApi : public TObject {
00159 public:
00161 TApi(int initDebug = 0);
00162
00164 ~TApi();
00165
00167
00170 void initialiseAll(int runNumber);
00171
00173 void shutdownAll();
00174
00176 void setRunNumber(int newRun);
00177
00179 void setScanNumber(int newScan);
00180
00181
00182
00184
00188 void echo(unsigned int partition, unsigned int crate, unsigned int rod,
00189 unsigned int length, long *data);
00190
00192 void loadConfiguration();
00193
00195 void configureBOC(unsigned int partition, unsigned int crate, unsigned int rod);
00196
00198 void awaitResponse(unsigned int partition, unsigned int crate, unsigned int rod, int timeout = 5);
00199
00201 unsigned long *getResponse(unsigned int partition, unsigned int crate, unsigned int rod);
00202
00204 unsigned long *getResponse(unsigned int partition, unsigned int crate, unsigned int rod,
00205 unsigned long *length);
00206
00208
00212 bool getRodMessage(unsigned int partition, unsigned int crate, unsigned int rod,
00213 char *buffer, int &length);
00214
00216
00222 void flashLED(unsigned int partition, unsigned int crate, unsigned int rod,
00223 unsigned long slaveNumber, long period = 1000, long flashes = 10);
00224
00225
00226 void status();
00227
00228
00231
00232
00235 Int_t dspBlockDump(unsigned int partition, unsigned int crate, unsigned int rod,
00236 long dspStart, long numWords, long dspNumber);
00237
00239
00242 Int_t dspBlockDumpFile(unsigned int partition, unsigned int crate, unsigned int rod,
00243 long dspStart, long numWords, long dspNumber, const char *filename);
00244
00246
00249 unsigned long *dspBlockRead(unsigned int partition, unsigned int crate, unsigned int rod,
00250 long dspStart, long numWords, long dspNumber, long *length);
00251
00253 int dspBlockWrite(unsigned int partition, unsigned int crate, unsigned int rod,
00254 unsigned long *buffer, unsigned long dspAddress, long numWords, long dspNumber);
00255
00257 unsigned long readRodStatusReg(unsigned int partition, unsigned int crate, unsigned int rod,
00258 long regNumber);
00259
00261 unsigned long readRodCommandReg(unsigned int partition, unsigned int crate, unsigned int rod,
00262 long regNumber);
00263
00265 unsigned long dspSingleRead(unsigned int partition, unsigned int crate, unsigned int rod,
00266 const unsigned long dspAddr, long dspNumber);
00267
00269 void dspSingleWrite(unsigned int partition, unsigned int crate, unsigned int rod,
00270 unsigned long dspAddr, unsigned long value, long dspNumber);
00271
00273 void createDebugPrimList();
00274
00276 void addDebugPrimList(unsigned long length, long index, long id, long version,
00277 unsigned long * body);
00279 void sendDebugPrimList(unsigned int partition, unsigned int crate, unsigned int rod);
00280
00282 void sendDebugSlavePrimList(unsigned int partition, unsigned int crate, unsigned int rod,
00283 unsigned int slave, bool await, bool response);
00284
00286 unsigned long *retrieveModule(UINT32 mid);
00287
00288
00289
00291
00295 UINT32 findModule(string sn);
00296
00298 UINT32 findModule(INT32 mur, INT32 module);
00299
00301 UINT32 findBarrelModule(INT32 barrel, INT32 row, INT32 number);
00302
00304 UINT32 findEndcapModule(INT32 disk, INT32 ring, INT32 number);
00305
00307 void getABCDModule(UINT32 bank);
00308
00310 void getABCDModule(UINT32 mid, UINT32 bank);
00311
00313 void setABCDModule(UINT32 mid, UINT32 bank);
00314
00316
00321 void sendABCDModule(UINT32 mid, UINT32 bank, UINT32 type=2);
00322
00324 void modifyABCDMask(UINT32 mid, UINT32* mask);
00325
00327 void modifyABCDTrims(UINT32 mid, UINT8* trims);
00328
00330 void modifyABCDVar(UINT32 typ, FLOAT32 var);
00331
00333 void modifyABCDVar(UINT32 mid, UINT32 typ, FLOAT32 var);
00334
00336 void modifyABCDVar(UINT32 mid, UINT32 c, UINT32 typ, FLOAT32 var);
00337
00339 void modifyBOCParam(unsigned int partition, unsigned int crate, unsigned int rod,
00340 unsigned int channel, unsigned int type, unsigned int val);
00341
00343 void defaultScan(int type);
00344
00346 void tidyHistogramming();
00347
00349 void doScan(TScanDef scan);
00350
00352 void doRawScan(TScanDef scan, int delay, bool configure = true, bool clkBy2 = false);
00353
00355 void sendTrigger(unsigned int partition, unsigned int crate, unsigned int rod, TTrigger trig);
00356
00358
00361 void printABCDModule(int mid);
00362
00364
00367 void printABCDRodModule(int mid, int bank);
00368
00370 void printBOCSetup(unsigned int partition, unsigned int crate, unsigned int rod);
00371
00373 void printBOCRegisters(unsigned int partition, unsigned int crate, unsigned int rod);
00374
00376 void rawData(unsigned int partition, unsigned int crate, unsigned int rod, int delay, int units, bool setMask = true, TTrigger trig = TTrigger());
00377
00379 char *probe(unsigned int partition, unsigned int crate, unsigned int rod, signed int harness = -1);
00380
00382 char *probeWithTrigger(unsigned int partition, unsigned int crate, unsigned int rod, TTrigger trig, signed int harness = -1);
00383
00385 void bocHistogram(unsigned int partition, unsigned int crate, unsigned int rod,
00386 unsigned int samples, unsigned int numLoops);
00387
00389 void rodMode(unsigned int partition, unsigned int crate, unsigned int rod,
00390 int mode, int flag, int fifoSetup, int nBins, int delay, int message);
00391
00392 void standardRegisterDump(unsigned int partition, unsigned int crate, unsigned int rod);
00393
00395
00398 void lasersOff();
00399
00401 void decodeEvent(unsigned int partition, unsigned int crate, unsigned int rod,
00402 int sl, int index, bool extFlag = false, bool errorType = false);
00403
00405
00408 void setDebugLevel(unsigned int level);
00409
00411 unsigned int getDebugLevel();
00412
00413 void debugStepHistogram();
00414
00415 void debugContinueHistogram();
00416
00417
00418
00420
00423 void freeTriggers(unsigned int partition, unsigned int crate,
00424 double freq);
00425
00427 void stopTriggers(unsigned int partition, unsigned int crate);
00428
00430 void timL1A(unsigned int partition, unsigned int crate);
00431
00433 void timCalL1A(unsigned int partition, unsigned int crate, int delay);
00434
00435 void requestHardReset(UINT32 mid);
00436
00438 void printHex(UINT32 num, int width);
00439 private:
00440
00441
00443
00448 int initialiseRod(unsigned int partition, unsigned int crate, unsigned int rod);
00449
00451
00457 int initialiseModule(string module);
00458
00459 private:
00461 SctApi::SctApi *worker;
00462
00463
00464 ClassDef(TApi,1)
00465 };
00466
00467
00468
00469 #endif