Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Related Pages

SctApi.h

00001 
00008 #ifndef SCTROD_SCTAPI_H
00009 #define SCTROD_SCTAPI_H
00010 
00011 // Make sure all compilations have same SctApi structure!
00012 #include "config.h"
00013 
00014 #include <list>
00015 #include <map>
00016 #include <string>
00017 #include <vector>
00018 
00019 #include <boost/thread.hpp>
00020 #include <boost/shared_ptr.hpp>
00021 #include <boost/shared_array.hpp>
00022 #include <boost/date_time/posix_time/posix_time_types.hpp>
00023 
00024 #include <mrs/message.h>
00025 #if USE_IS
00026 #include <is/isinfotmpl.h>
00027 #endif
00028 
00029 class SCTDCSCommand;
00030 #include "log.h"
00031 
00032 #include "DCSAccess.h"
00033 
00034 // This defines ABCDModule (a typedef)
00035 #include <CommonWithDsp/sctStructure.h>
00036 // Unfortunately this is necessary
00037 #include <CommonWithDsp/processor.h>
00038 
00039 struct scan_result_ptrs;
00040 
00041 namespace SctConfiguration {
00042   class Configuration;
00043   struct BOCChannelConfig;
00044   struct BOCGlobalConfig;
00045 }
00046 
00047 #include "SctApiFwd.h"
00048 
00049 namespace SctApi {
00050 
00051 class CrateException;
00052 
00056 class SctApiException : public std::exception {
00057   std::string desc;
00058  public:
00060   SctApiException(const std::string &str) throw() : desc(str) {}
00061 
00063   SctApiException(const CrateException &c) throw();
00064 
00065   ~SctApiException() throw() {}
00066 
00068   virtual const char* what () const throw() { return desc.c_str(); }
00069 };
00070 
00071 class Crate;
00072 
00073 class PrimListWrapper;
00074 
00075 class ScanEx;
00076 
00077 
00078 typedef std::list<std::string> ModuleList;
00079 
00081 class Trigger {
00082  public:
00083   virtual ~Trigger();
00084 
00086   typedef std::pair<UINT16, UINT32>  RODTrigger;
00087   typedef std::vector<RODTrigger>    RODTriggers;
00088 
00090   virtual void singleL1A() = 0;
00092   virtual void doubleL1A(unsigned short delay) = 0;
00094   virtual void delayedL1A(unsigned short delay) = 0;
00096   virtual void calL1A(unsigned short delay) = 0;
00097   virtual void pulseL1A(unsigned short delay) = 0;
00098   virtual void softL1A(unsigned short delay) = 0;
00099   virtual void softCalL1A(unsigned short delay, unsigned short delay2) = 0;
00100   virtual void softPulseL1A(unsigned short delay, unsigned short delay2) = 0;
00101   virtual void softBc(unsigned short delay) = 0;
00102   virtual void bcL1A(unsigned short delay) = 0;
00103   virtual void bcCalL1A(unsigned short delay, unsigned short delay2) = 0;
00104   virtual void bcPulseL1A(unsigned short delay, unsigned short delay2) = 0;
00105 
00106   virtual void setCommIncr(unsigned short command, unsigned short incr) = 0;
00107   virtual void getCommIncr(unsigned short &command, unsigned short &incr) const = 0;
00108 
00110   virtual const RODTriggers getRODTriggers() const = 0; 
00111 
00112   virtual void print() const = 0;
00113 };
00114 
00123 class Scan {
00124  public:
00125   virtual ~Scan();
00126 
00128   typedef std::vector<FLOAT32> ScanPoints;
00129 
00131   typedef std::vector<UINT32> TrigPoints;
00132 
00134 
00154   typedef enum ScanOptions {FULL, BITS32, LOOPCALLINE, DISTSLAVE, DEBUG, TIM, NTH, NTH_REM, ENABLE_DATA_MODE} ScanOptionsEnum;
00155 
00156   virtual void configure(unsigned short type, float start, float stop, float step) = 0;
00157   virtual void configure2(unsigned short type, float start, float stop, float step) = 0;
00158 
00159   virtual const boost::shared_ptr<Trigger> getTrigger1() const = 0;
00160   virtual const boost::shared_ptr<Trigger> getTrigger2() const = 0;
00161 
00162   virtual boost::shared_ptr<Trigger> getTrigger1() = 0;
00163   virtual boost::shared_ptr<Trigger> getTrigger2() = 0;
00164 
00165   virtual void setTrigger1(boost::shared_ptr<Trigger> trigger) = 0;
00166   virtual void setTrigger2(boost::shared_ptr<Trigger> trigger) = 0;
00167 
00168   virtual void setScanVariable1(unsigned short var) = 0;
00169   virtual void setScanVariable2(unsigned short var) = 0;
00170 
00171   virtual unsigned short getScanVariable1() const = 0;
00172   virtual unsigned short getScanVariable2() const = 0;
00173 
00174   virtual void setNTrigs(unsigned long nTrigs) = 0;
00175   virtual unsigned long getNTrigs() const = 0;
00176 
00177   virtual const TrigPoints getVariableTrigs() const = 0;
00178   virtual void setVariableTrigs(const TrigPoints &scans) = 0;
00179   virtual void setVariableTrigRange(unsigned short start, unsigned short end, unsigned long value) = 0;
00180 
00181   virtual const ScanPoints getScanPoints1() const = 0;
00182   virtual const ScanPoints getScanPoints2() const = 0;
00183   virtual void setScanPoints1(const ScanPoints &scans) = 0;
00184   virtual void setScanPoints2(const ScanPoints &scans) = 0;
00185 
00186   virtual int getOption(enum ScanOptions) const = 0;
00187   virtual void setOption(enum ScanOptions, int option) = 0;
00188 
00190   virtual void print() const = 0;
00191 
00192   virtual void setScanNumber(unsigned int scan) = 0;
00193   virtual unsigned int getScanNumber() const = 0;
00194   virtual void setRunNumber(unsigned int scan) = 0;
00195   virtual unsigned int getRunNumber() const = 0;
00196 
00197   virtual ModuleList getModuleList(unsigned int group) const = 0;
00198   virtual void setModuleList(unsigned int group, const ModuleList & newList) = 0;
00199   virtual unsigned int getNGroups() const = 0;
00200   virtual void setNGroups(unsigned int val) = 0;
00201   
00202   virtual boost::posix_time::ptime getStartTime() const = 0;
00203   virtual void setStartTime(boost::posix_time::ptime t) = 0;
00204   
00205   virtual boost::posix_time::ptime getEndTime() const = 0;
00206   virtual void setEndTime(boost::posix_time::ptime t) = 0;
00207 };
00208 
00266 class SctApi {
00267   SctApi(const SctApi &);
00268   SctApi &operator=(const SctApi&);
00269  public:
00270 
00272   static const unsigned int BAD_MODULE;
00273 
00277   SctApi();
00278 
00282   SctApi(boost::shared_ptr<SctConfiguration::Configuration> newConf);
00283 
00284   virtual ~SctApi();
00285 
00286  private:
00292   void setup();
00293 
00297   void dumpPrimList(boost::shared_ptr<PrimListWrapper> prim);
00298 
00300   void dumpRawEvent(unsigned int partition, unsigned int crate, unsigned int rod, int units, unsigned long *bufferA, unsigned long *bufferB);
00301 
00302 public:
00306   void setMrsStream(MRSStream *stream);
00307 
00308 #if USE_IS
00309 
00312   void setIsDictionary(ISInfoDictionary *dict);
00313 #endif
00314 
00315   /***************** Global configuration functions ***********************/
00316 
00318 
00331   void initialiseAll(int run);
00332 
00334 
00341   void shutdownAll();
00342 
00344 
00347   void setRunNumber(UINT32 newRun);
00348 
00350 
00353   void setScanNumber(UINT32 newScan);
00354 
00356 
00359   UINT32 getRunNumber();
00360 
00362 
00365   UINT32 getScanNumber();
00366 
00368 
00372   bool isRODPresent(unsigned int partition, unsigned int crate, unsigned int rod);
00373 
00375 
00382   void startupModules();
00383 
00385   ModuleList getModuleList();
00386 
00387   /*********************** Module configuration **********************/
00388 
00390 
00394   void loadConfiguration();
00395 
00397 
00401   void loadConfiguration(std::string filename);
00402 
00404 
00407   int loadModuleConfigurations();
00408 
00410 
00414   void storeModuleConfigurations();
00415 
00417 
00421   void configureBOC(unsigned int partition, unsigned int crate, unsigned int rod);
00422 
00424 
00428   std::vector<double> getBOCMonitorArray(unsigned int partition, unsigned int crate, unsigned int rod);
00429 
00431 
00435   int awaitResponse(unsigned int partition, unsigned int crate, unsigned int rod, int timeout);
00436 
00438 
00442   int awaitResponseAll(unsigned int partition, unsigned int crate, int timeout);
00443 
00445 
00450   unsigned long *getResponse(unsigned int partition, unsigned int crate, unsigned int rod, 
00451                              unsigned long &length);
00452 
00458   bool getRodMessage(unsigned int partition, unsigned int crate, unsigned int rod,
00459                      char *buffer, unsigned long &length);
00460 
00461   /*************** ROD Diagnostics ********************/
00462 
00464 
00474   void flashLED(unsigned int partition, unsigned int crate, unsigned int rod,
00475                 long slaveNumber, long period = 1000, long flashes = 10);
00476 
00478 
00482   void echo(unsigned int partition, unsigned int crate, unsigned int rod,
00483             unsigned int length, const unsigned long *data);
00484 
00486 
00490   void echoAll(unsigned int length, const unsigned long *data);
00491 
00493 
00497   void echoSlave(unsigned int partition, unsigned int crate, unsigned int rod,
00498                  unsigned int slave, unsigned int length, const unsigned long *data);
00499 
00500 
00501   /***************** Direct ROD access (Debug only) ********************/
00502   /* Should be able to do anything with these commands */
00503 
00505 
00514   int dspBlockDump(unsigned int partition, unsigned int crate, unsigned int rod,
00515                    long dspStart, long numWords, long dspNumber, bool usePrim = true);
00516 
00518 
00528   int dspBlockDumpFile(unsigned int partition, unsigned int crate, unsigned int rod,
00529                        long dspStart, long numWords, long dspNumber, std::string filename, bool usePrim = true);
00530 
00532 
00537   void standardRegisterDump(RodLabel rl);
00538 
00540 
00543   void standardRegisterDump(unsigned int partition, unsigned int crate, unsigned int rod);
00544 
00546 
00550   void standardRegisterDumpAll();
00551 
00553 
00559   unsigned long *dspBlockRead(unsigned int partition, unsigned int crate, unsigned int rod,
00560                               long dspStart, long numWords, long dspNumber, unsigned long &length, bool usePrim = true);
00561 
00563 
00569   int dspBlockWrite(unsigned int partition, unsigned int crate, unsigned int rod,
00570                     unsigned long *buffer, unsigned long dspAddress, long numWords, long dspNumber, bool usePrim = true);
00571 
00573 
00576   unsigned long dspSingleBlockRead(unsigned int partition, unsigned int crate, unsigned int rod,
00577                                    long dspStart, long dspNumber);
00578 
00580 
00583   void dspSingleBlockWrite(unsigned int partition, unsigned int crate, unsigned int rod,
00584                            unsigned long dspAddress, unsigned long val, long dspNumber);
00585 
00587 
00595   unsigned long *primReadSlaveDsp(unsigned int partition, unsigned int crate, unsigned int rod,
00596                                   int s, int add, int words);
00597 
00599 
00605   void primWriteSlaveDsp(unsigned int partition, unsigned int crate, unsigned int rod,
00606                          int s, int add, int numWords, unsigned long *data);
00607 
00608   void writeSlaveFile(unsigned int partition, unsigned int crate, unsigned int rod, unsigned int slave, 
00609                       std::string fileName, unsigned long address, bool usePrim = true);
00610 
00612   void startSlave(unsigned int partition, unsigned int crate, unsigned int rod, unsigned int slave);
00613 
00615   boost::shared_array<unsigned long> loadFile(std::string filename, unsigned long & length);
00616 
00618 
00622   unsigned long readRodStatusReg(unsigned int partition, unsigned int crate, unsigned int rod,
00623                                  long regNumber);
00624 
00626 
00630   unsigned long readRodCommandReg(unsigned int partition, unsigned int crate, unsigned int rod,
00631                                   long regNumber);
00632 
00634 
00638   unsigned long dspSingleRead(unsigned int partition, unsigned int crate, unsigned int rod,
00639                               const unsigned long dspAddr, long dspNumber);
00640 
00642 
00646   void dspSingleWrite(unsigned int partition, unsigned int crate, unsigned int rod,
00647                       unsigned long dspAddr, unsigned long value, long dspNumber);
00648 
00650 
00656   ABCDModule *retrieveModule(UINT32 mid);
00657 
00659 
00663   void createDebugPrimList();
00664 
00666 
00670   void addDebugPrimList(unsigned long length, long index, long id, long version,
00671                         unsigned long * body);
00672 
00674 
00678   void sendDebugPrimList(unsigned int partition, unsigned int crate, unsigned int rod);
00679 
00681 
00685   void sendDebugPrimListAll();
00686 
00688 
00696   void sendDebugSlavePrimList(unsigned int partition, unsigned int crate, unsigned int rod,
00697                               unsigned int slave, bool await, bool response);
00698 
00700 
00703   void debugPrimListFromFile(std::string fileName);
00704 
00706   void dumpDebugPrimList();
00707 
00709   const std::list<RodLabel> listRods() const;
00710 
00712   const std::list<CrateLabel> listCrates() const;
00713 
00714   /**** Official SCTAPI bit ******/
00715 
00717 
00724   UINT32 findModule(std::string sn);
00725 
00727 
00731   std::string convertToString(UINT32 mid);
00732 
00734 
00738   UINT32 findModule(INT32 mur, INT32 module);
00739 
00741 
00745   std::pair<INT32, INT32> convertToMUR(UINT32 mid);
00746 
00748 
00752   UINT32 findBarrelModule(INT32 barrel, INT32 row, INT32 number);
00753 
00755 
00759   void convertToBarrelModule(UINT32 mid, UINT32 &barrel, UINT32 &row, int &number);
00760 
00762 
00766   UINT32 findEndcapModule(INT32 disk, INT32 quadrant, INT32 number);
00767 
00769 
00773   void convertToEndcapModule(UINT32 mid, INT32 &disk, UINT32 &quadrant, UINT32 &number);
00774 
00776 
00780   void getABCDModules(BankType bank);
00781 
00783 
00787   virtual void getABCDModule(UINT32 mid, BankType bank);
00788 
00790 
00794   virtual boost::shared_ptr<ABCDModule> getABCDModuleRaw(unsigned int partition, unsigned int crate, unsigned int rod, 
00795                                                          UINT32 slot, BankType bank);
00796   
00798 
00802   virtual void setABCDModules(BankType bank);
00803 
00805 
00809   virtual void setABCDModule(UINT32 mid, BankType bank);
00810 
00812 
00821   virtual void sendAllABCDModules(BankType bank,
00822                                   ConfigType type = SCTAPI_CONFIG_ALL,
00823                                   const bool enableDataMode=true /* enableDataMode should have default value true to ensure compatibility with old code*/);
00824 
00826 
00836   virtual void sendABCDModule(UINT32 mid,
00837                               BankType bank,
00838                               ConfigType type = SCTAPI_CONFIG_ALL,
00839                               const bool enableDataMode=true /* enableDataMode should have default value true to ensure compatibility with old code*/);
00840 
00842 
00848   void modifyABCDMask(UINT32 mid, UINT32* mask);
00849 
00853 /*    void modifyABCDListMask(mList* mlist, UINT32* mask); */
00854 
00861   void modifyABCDTrims(UINT32 mid, UINT8* trims);
00862 
00866 /*    void modifyABCDTrims(mList* mlist, UINT8* trims); */
00867 
00869 
00873   void modifyABCDVar(UINT32 typ, FLOAT32 var);
00874 
00876 
00880   void modifyABCDVar(UINT32 mid, UINT32 typ, FLOAT32 var);
00881 
00883 /*    void modifyABCDVar(mList* mlist, UINT32 typ, FLOAT32 var); */
00884 
00886 
00890   void modifyABCDVar(UINT32 mid, UINT32 chip, UINT32 typ, FLOAT32 var);
00891 
00893 
00897   void modifyABCDVarROD(UINT32 mid, UINT32 chip, UINT32 typ, FLOAT32 var, BankType bank);
00898 
00900 
00904   void modifyABCDVarROD(UINT32 mid, UINT32 typ, FLOAT32 var, BankType bank);
00905 
00907 
00911   void modifyABCDVarROD(UINT32 type, FLOAT32 value, BankType bank);
00912 
00914 /*    void modifyABCDVar(mList* mlist, UINT32 chip, UINT32 typ, FLOAT32 var); */
00915 
00917 
00921   void modifyABCDRC(UINT32 mid, UINT32 chip, UINT16 function, FLOAT32 p0, FLOAT32 p1, FLOAT32 p2);
00922 
00924 
00928   void modifyBOCParam(unsigned int partition, unsigned int crate, unsigned int rod,
00929                       unsigned int channel, unsigned int type, unsigned int val);
00930 
00932 
00936   void modifyBOCParam(unsigned int type, unsigned int val);
00937 
00939 
00943   void printBOCSetup(unsigned int partition, unsigned int crate, unsigned int rod);
00944 
00946 
00950   std::vector<SctConfiguration::BOCChannelConfig> currentBOCSetup(unsigned int partition, unsigned int crate, unsigned int rod);
00951 
00953 
00957   void printBOCRegisters(unsigned int partition, unsigned int crate, unsigned int rod);
00958 
00960 
00964   SctConfiguration::BOCGlobalConfig currentBOCRegisters(unsigned int partition, unsigned int crate, unsigned int rod);
00965 
00967   void saveBOCSetup(unsigned int partition, unsigned int crate, unsigned int rod, BankType bank);
00968 
00970   void saveBOCRegisters(unsigned int partition, unsigned int crate, unsigned int rod, BankType bank);
00971 
00973   void restoreBOCSetup(unsigned int partition, unsigned int crate, unsigned int rod, BankType bank);
00974 
00976   void restoreBOCRegisters(unsigned int partition, unsigned int crate, unsigned int rod, BankType bank);
00977 
00979 
00983   void lasersOff();
00984 
00985   /* *************  TIM functs **************/
00986 
00988 
00995   void timSetFrequency(unsigned int partition, unsigned int crate, double trigFreq, double rstFreq);
00996 
00998 
01003   void freeTriggers(unsigned int partition, unsigned int crate);
01004 
01006 
01010   void stopTriggers(unsigned int partition, unsigned int crate);
01011 
01013 
01017   void timL1A(unsigned int partition, unsigned int crate);
01018 
01020 
01024   void timCalL1A(unsigned int partition, unsigned int crate, int delay);
01025 
01027 
01031   void timSoftReset(unsigned int partition, unsigned int crate);
01032 
01034 
01038   void timBCReset(unsigned int partition, unsigned int crate);
01039 
01041   void sendTimBurst(unsigned int partition, unsigned int crate, unsigned int count);
01042 
01044   void timVerbose(unsigned int partition, unsigned int crate);
01045 
01047 
01050   void timWriteRegister(unsigned int partition, unsigned int crate, int reg, UINT16 val);
01051 
01053 
01056   UINT16 timReadRegister(unsigned int partition, unsigned int crate, int reg);
01057 
01059 
01063   void status();
01064 
01066 
01070   void defaultScan(int type);
01071 
01073 
01079   void doScan(boost::shared_ptr<Scan> scan);
01080 
01084   void awaitScan();
01085 
01095   void abortScan();
01096 
01098 
01102   void doRawScan(boost::shared_ptr<Scan> scan, int delay, int width, 
01103                  bool configureModules = false, bool clkBy2 = false);
01104 
01106 
01110   void sendTimTrigger(unsigned int partition, unsigned int crate, const Trigger *trig);
01111 
01113 
01117   void sendTrigger(unsigned int partition, unsigned int crate, unsigned int rod, const Trigger *trig);
01118 
01120 
01126   void printABCDModule(int mid);
01127 
01129 
01136   void printABCDRodModule(int mid, BankType bank);
01137 
01139 
01143   void decodeEvent(unsigned int partition, unsigned int crate, unsigned int rod, 
01144                    int sl, int index, bool extFlag = false, bool errorType = false);
01145 
01147 
01151   void scanEvents(unsigned int partition, unsigned int crate, unsigned int rod, int sl, bool extFlag, bool errorType);
01152 
01156   void reportEventErrors();
01157 
01161   void decodeConfig(unsigned int partition, unsigned int crate, unsigned int rod, 
01162                     bool skipTrim = false, bool bypass = false);
01163 
01165 
01169   void rawData(unsigned int partition, unsigned int crate, unsigned int rod, int delay, int units, bool setMask = true, const Trigger *trig = 0);
01170 
01172 
01178   void sendL1A(unsigned int partition, unsigned int crate, unsigned int rod, bool capture = false);
01179 
01181 
01198   std::vector<char> probe(unsigned int partition, unsigned int crate, unsigned int rod, 
01199                           signed int harness = -1);
01200 
01202 
01219   std::vector<char> probeWithTrigger(unsigned int partition, unsigned int crate, unsigned int rod, 
01220                                      const Trigger *trigger, signed int harness = -1);
01221 
01223   std::vector<std::vector<char> > SctApi::probeScan(unsigned int partition, unsigned int crate, unsigned int rod, 
01224                                                     boost::shared_ptr<Scan> scan, signed int harness = -1);
01225 
01232   bool checkAllModulesProbe(std::string value);
01233 
01239   void autoConfigure();
01240 
01244   void bocHistogram(unsigned int partition, unsigned int crate, unsigned int rod, 
01245                     unsigned int samples, unsigned int numLoops);
01246 
01247   /*** DCS functionality */
01248 
01256   void requestHardResetAll();
01257 
01265   void requestHardReset(UINT32 mid);
01266 
01274   void requestIVCurve(UINT32 mid, FLOAT32 start, FLOAT32 stop, FLOAT32 step, UINT16 delay, FLOAT32 currentLim);
01275 
01283   void requestIVCurveAll(FLOAT32 start, FLOAT32 stop, FLOAT32 step, UINT16 delay, FLOAT32 currentLim);
01284 
01295   void setSelectAllInCrate(int crate, bool value, int timeout = 5);
01296 
01307   // #warning "Should this just change DCS?"
01308   void setSelect(UINT32 mid, bool value); 
01309 
01319   void changeRunState(int state);
01320 
01321   /************ Direct DDC (no translations) ****************/
01322 
01324   void ddcChangeState (int crate, int channel, short state, int timeout = 2);
01326   void ddcChangeStateAll (int crate, short state, int timeout = 2);
01328   void ddcLoadConfiguration (int crate, short state, int timeout = 2);
01330   void ddcHardReset (int crate, int channel, int timeout = 2);
01332   void ddcHardResetAll (int crate, int timeout = 2);
01333 
01335   int ddcGetChannelParameterInt (int crate, int channel, std::string name, int timeout = 2);
01337   float ddcGetChannelParameterFloat (int crate, int channel, std::string name, int timeout = 2);
01339   std::string ddcGetChannelParameterString (int crate, int channel, std::string name, int timeout = 2);
01341   int ddcGetCardParameterInt (int crate, int card, std::string name, int timeout = 2);
01343   float ddcGetCardParameterFloat (int crate, int card, std::string name, int timeout = 2);
01345   std::string ddcGetCardParameterString (int crate, int card, std::string name, int timeout = 2);
01347   int ddcGetCrateParameterInt (int crate, std::string name, int timeout = 2);
01349   float ddcGetCrateParameterFloat (int crate, std::string name, int timeout = 2);
01351   std::string ddcGetCrateParameterString (int crate, std::string name, int timeout = 2);
01352 
01354 
01359   void ddcGetCrateParameters(int crate, std::vector<std::string> names, 
01360                              std::map<std::string, float>& dpeValues, int timeout);
01361 
01363   void ddcSetChannelParameter (int crate, int channel, std::string name, float value, int timeout = 2);
01365   void ddcSetCardParameter (int crate, int card, std::string name, float value, int timeout = 2);
01367   void ddcSetCrateParameter (int crate, std::string name, float value, int timeout = 2);
01368 
01369 
01370 
01381   void tidyHistogramming();
01382 
01386   long getRodSlot(unsigned int partition, unsigned int crate, unsigned int rod);
01387 
01391   int getRodRevision(unsigned int partition, unsigned int crate, unsigned int rod);
01392 
01396   int getRodRevision(const RodLabel &label);
01397 
01401   void testLinkOutSelect(unsigned int partition, unsigned int crate, unsigned int rod,
01402                          unsigned int link);
01403 
01407   unsigned int testLinkOutRetrieve(unsigned int partition, unsigned int crate, unsigned int rod);
01408 
01416   void unsetDebugOption(std::string opt);
01417 
01425   void setDebugOption(std::string opt);
01426 
01434   std::list<std::string> listEnabledDebugOptions();
01435 
01443   std::vector<std::string> listDebugOptions();
01444 
01448   void debugStepHistogram();
01449 
01455   void debugContinueHistogram();
01456 
01463   void debugAbortHistogram();
01464 
01470   void eventTrapSetup(int slaveMask, int trapMatch, int trapMod, int trapRemain, bool tim, bool error, 
01471                       boost::shared_ptr<PrimListWrapper> primList);
01472 
01474   void startEventTrap(int slave, boost::shared_ptr<PrimListWrapper> primList);
01475 
01477   void stopEventTrap(int slave, boost::shared_ptr<PrimListWrapper> primList);
01478 
01480   void rodMode(unsigned int partition, unsigned int crate, unsigned int rod,
01481                int mode, int flag, int fifoSetup, int nBins, int delay, int message);
01482 
01484   void setupModuleMask(unsigned int partition, unsigned int crate, unsigned int rod,
01485                        int port, int slvs);
01486 
01488   void setupModuleMask(int port, int slvs, boost::shared_ptr<PrimListWrapper> list);
01489 
01491   std::pair<UINT32, UINT32> sendData(unsigned int partition, unsigned int crate, unsigned int rod, int type, int dsp);
01492 
01496   void resumePolling();
01497 
01501   void stopPolling();
01502 
01504   void print_calib(unsigned int partition, unsigned int crate, unsigned int rod);
01505 
01507 
01512   int synchSendPrimListAllCrates(boost::shared_ptr<PrimListWrapper> primList, int timeout = 10);
01513 
01515   void stopHistogramming(const ScanEx &ex);
01516 
01518   void setSlaveBlock(unsigned int partition, unsigned int crate, unsigned int rod, 
01519                      int s, long sAdd, int words, long value = 0, bool usePrim = true);
01520 
01522   void writeRODRegister(unsigned int partition, unsigned int crate, unsigned int rod,
01523                         int reg, int off, int width, int value);
01524 
01526   unsigned int readRODRegister(unsigned int partition, unsigned int crate, unsigned int rod, int r);
01527 
01529   int pollRegister(unsigned int partition, unsigned int crate, unsigned int rod, int r, int off, int width, int val, int timeout = 1000000);
01530 
01531   virtual unsigned long *readFifo(unsigned int partition, unsigned int crate, unsigned int rod, int id, int bank, int elems);
01532 
01534   void startHistogramTask(const Scan &scan, const ScanEx &ex, const RodLabel, 
01535                           unsigned int startBin, unsigned int nBins, unsigned int nTrigs,
01536                           boost::shared_ptr<PrimListWrapper> list);
01537 
01539 
01544   void sendPrimList(unsigned int partition, unsigned int crate, unsigned int rod,
01545                     boost::shared_ptr<PrimListWrapper> prim);
01546 
01547   MRSStream *mrs;
01548 #if USE_IS
01549   ISInfoDictionary *m_isDict;
01550 #endif
01551  protected:
01552   
01553   /********** Should these be part of the API? **************/
01554 
01556 
01561   virtual int initialiseRod(unsigned int partition, unsigned int crate, unsigned int rod);
01562 
01564 
01570   virtual int initialiseModule(std::string module);
01571 
01573   ABCDModule *lookupConfig(UINT32 mid);
01574 
01576 
01580   virtual bool preScanHardwareCheck(Scan& scan, ScanEx& extra);
01581   
01582   virtual void doHistogramSetup(const Scan &scan, const ScanEx &extra);
01583   
01588   UINT32 *readEventBuffer(unsigned int partition, unsigned int crate, unsigned int rod, 
01589                         int sl, bool extFlag, bool errorType);
01590 
01594   int getLastEventFrame(unsigned int partition, unsigned int crate, unsigned int rod, int slave);
01595 
01597 
01606   virtual int pollHistogramming(boost::shared_ptr<ScanControl> controller, int timeout = 5);
01607  
01608   void scanLoop();
01609 
01610   void scanPollingThread();
01611 
01612   void addRodToList(RodLabel newRod);
01613 
01614   RodInfo &SctApi::getRodInfo(const RodLabel &l);
01615 
01617   std::list<RodLabel> rodList;
01618 
01620   std::map<RodLabel, RodInfo> rodInfoList;
01621   
01623   std::map<UINT32, ABCDModule> moduleMap;
01624   
01625   // Controller for current scan
01626   boost::shared_ptr<ScanControl> scanController;
01627 
01628   // Possibly to be used for continuing a scan
01629   boost::shared_ptr<ScanControl> lastScanController;
01630 
01631  private:
01632 
01633   /*************************************************************
01634    *          Internal functions (shouldn't be exported,       *
01635    *              probably able to keep them private )         *
01636    *************************************************************/
01637 
01639 
01641   void doRawScanThreadInnards(boost::shared_ptr<Scan> scan, int delay, int width, 
01642                               bool configureModules, bool clkBy2);
01644 
01646   void doRawScanThread(boost::shared_ptr<Scan> scan, int delay, int width, 
01647                        bool configureModules, bool clkBy2);
01648 
01649   
01651 
01657   void sendSlavePrimList(unsigned int partition, unsigned int crate, unsigned int rod,
01658                          boost::shared_ptr<PrimListWrapper> prim, unsigned int slave, bool await, bool response);
01659 
01661 
01666   void sendPrimListAll(unsigned int partition, unsigned int crate,
01667                        boost::shared_ptr<PrimListWrapper> prim);
01668 
01670   void setupEventTrapping(const Scan &scan, const ScanEx &ex, const RodLabel, boost::shared_ptr<PrimListWrapper> list);
01671 
01673   void startEventTrapping(const Scan &scan, const ScanEx &ex, const RodLabel, boost::shared_ptr<PrimListWrapper> primList);
01674 
01676   void setupEventDump(const Scan &scan, const ScanEx &ex, const RodLabel, boost::shared_ptr<PrimListWrapper> list);
01677 
01679   void setupHistogramming(const Scan &scan, const ScanEx &ex, const RodLabel, bool tim, 
01680                           boost::shared_ptr<PrimListWrapper> list);
01681 
01683   void calib_init();
01684 
01686   void readRawData(unsigned int partition, unsigned int crate, unsigned int rod, 
01687                    int delay, bool setMask);
01688 
01690   virtual int setupRawData(unsigned int partition, unsigned int crate, unsigned int rod, 
01691                int delay, int units, bool setMask, const Trigger *trig = 0);
01692 
01694 
01698   Crate *getCrate(unsigned int partition, unsigned int crate) const;
01699 
01701   void cacheModuleConfig(UINT32 mid);
01702 
01704 
01707   void getrpcrc(UINT32 mid, unsigned int &rpartition, unsigned int &rcrate, unsigned int &rrod, unsigned &rchannel);
01708 
01710   void initDDC();
01711 
01713   void setupScanMasks(ScanEx &extra, int distSlave, bool dual);
01714 
01716   bool checkModuleListsForScan();
01717 
01719 
01722   void preScanModuleSetup(Scan &scan);
01723 
01724   bool checkDebugOption(std::string opt);
01725   // This should be DebugOptions but that would mean including SctApiDebug.h here
01726   bool checkDebugOption(int opt);
01727 
01728   /*********** Internal variables *************/
01729 
01731   boost::shared_ptr<SctConfiguration::Configuration> config;
01732 
01733   IPCPartition *ddcPartition;
01734   std::string *ddcCtrls[2];
01735   SCTDCSCommand *ddcCmd;
01736 
01737   boost::shared_ptr<DCSAccess> dcsAccess;
01738 
01740   boost::shared_ptr<PrimListWrapper> debugPrimList;
01741 
01743   std::map<std::pair<unsigned int, unsigned int>, Crate* > crateMap;
01744 
01746   Log log;
01747 
01749   boost::shared_ptr<const Scan> lastDebugScan;
01750   boost::shared_ptr<const ScanEx> lastDebugScanEx;
01751 
01753   UINT32 scanNumber;
01754 
01756   UINT32 runNumber;
01757 
01758 #if USE_SCAN_THREAD
01759   boost::condition scanQueue_notEmpty;
01760   boost::mutex scanQueue_mutex;
01761 
01762   /* ******* Threads ******/
01763   std::auto_ptr<boost::thread> scanPollThread;
01764 
01765   bool m_stopPolling;
01766   bool m_inScanLoop;
01767   bool m_inRawScanLoop;
01768 #endif
01769 
01770   /* **********  Mutexes  ********** */
01771   boost::mutex logMutex;
01772 };
01773 }  // End of namespace SctApi
01774 #endif

Generated on Mon Feb 21 11:43:47 2005 for SCT DAQ/DCS Software - C++ by doxygen 1.3.5