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

SctApi.h

00001 // File: SctApi.h
00002 // Library interface to SCTAPI
00003 #ifndef SCTROD_SCTAPI_H
00004 #define SCTROD_SCTAPI_H
00005 
00006 // Make sure all compilations have same SctApi structure!
00007 #include "config.h"
00008 
00009 #include <list>
00010 #include <map>
00011 #include <string>
00012 #include <vector>
00013 
00014 #include <boost/thread.hpp>
00015 #include <boost/shared_ptr.hpp>
00016 #include <boost/shared_array.hpp>
00017 #include <boost/date_time/posix_time/posix_time_types.hpp>
00018 
00019 #include <mrs/message.h>
00020 #if USE_IS
00021 #include <is/isinfotmpl.h>
00022 #endif
00023 
00024 class SCTDCSCommand;
00025 #include "log.h"
00026 
00027 #include "DCSAccess.h"
00028 
00029 // This defines ABCDModule (a typedef)
00030 #include <CommonWithDsp/sctStructure.h>
00031 // Unfortunately this is necessary
00032 #include <CommonWithDsp/processor.h>
00033 
00034 struct scan_result_ptrs;
00035 
00036 namespace SctConfiguration {
00037   class Configuration;
00038   struct BOCChannelConfig;
00039   struct BOCGlobalConfig;
00040 }
00041 
00042 #include "SctApiFwd.h"
00043 
00044 namespace SctApi {
00045 
00046 class CrateException;
00047 
00051 class SctApiException : public std::exception {
00052   std::string desc;
00053  public:
00055   SctApiException(const std::string &str) throw() : desc(str) {}
00056 
00058   SctApiException(const CrateException &c) throw();
00059 
00060   ~SctApiException() throw() {}
00061 
00063   virtual const char* what () const throw() { return desc.c_str(); }
00064 };
00065 
00066 class Crate;
00067 
00068 class PrimListWrapper;
00069 
00070 class ScanEx;
00071 
00073 class Trigger {
00074  public:
00075   virtual ~Trigger();
00076 
00078   typedef std::vector<std::pair<UINT16, UINT32> > RODTriggers;
00079 
00081   virtual void singleL1A() = 0;
00083   virtual void doubleL1A(unsigned short delay) = 0;
00085   virtual void delayedL1A(unsigned short delay) = 0;
00087   virtual void calL1A(unsigned short delay) = 0;
00088   virtual void pulseL1A(unsigned short delay) = 0;
00089   virtual void softL1A(unsigned short delay) = 0;
00090   virtual void softCalL1A(unsigned short delay, unsigned short delay2) = 0;
00091   virtual void softPulseL1A(unsigned short delay, unsigned short delay2) = 0;
00092   virtual void bcL1A(unsigned short delay) = 0;
00093   virtual void bcCalL1A(unsigned short delay, unsigned short delay2) = 0;
00094   virtual void bcPulseL1A(unsigned short delay, unsigned short delay2) = 0;
00095 
00096   virtual void setCommIncr(unsigned short command, unsigned short incr) = 0;
00097   virtual void getCommIncr(unsigned short &command, unsigned short &incr) const = 0;
00098 
00100   virtual const RODTriggers getRODTriggers() const = 0; 
00101 
00102   virtual void print() const = 0;
00103 };
00104 
00113 class Scan {
00114  public:
00115   virtual ~Scan();
00116 
00118   typedef std::vector<FLOAT32> ScanPoints;
00119 
00121   typedef std::vector<UINT32> TrigPoints;
00122 
00124 
00141   enum ScanOptions {FULL, BITS32, LOOPCALLINE, DISTSLAVE, DEBUG, TIM, NTH, NTH_REM};
00142 
00143   virtual void configure(unsigned short type, float start, float stop, float step) = 0;
00144   virtual void configure2(unsigned short type, float start, float stop, float step) = 0;
00145 
00146   virtual const boost::shared_ptr<Trigger> getTrigger1() const = 0;
00147   virtual const boost::shared_ptr<Trigger> getTrigger2() const = 0;
00148 
00149   virtual boost::shared_ptr<Trigger> getTrigger1() = 0;
00150   virtual boost::shared_ptr<Trigger> getTrigger2() = 0;
00151 
00152   virtual void setTrigger1(boost::shared_ptr<Trigger> trigger) = 0;
00153   virtual void setTrigger2(boost::shared_ptr<Trigger> trigger) = 0;
00154 
00155   virtual void setScanVariable1(unsigned short var) = 0;
00156   virtual void setScanVariable2(unsigned short var) = 0;
00157 
00158   virtual unsigned short getScanVariable1() const = 0;
00159   virtual unsigned short getScanVariable2() const = 0;
00160 
00161   virtual void setNTrigs(unsigned long nTrigs) = 0;
00162   virtual unsigned long getNTrigs() const = 0;
00163 
00164   virtual const TrigPoints getVariableTrigs() const = 0;
00165   virtual void setVariableTrigs(const TrigPoints &scans) = 0;
00166   virtual void setVariableTrigRange(unsigned short start, unsigned short end, unsigned long value) = 0;
00167 
00168   virtual const ScanPoints getScanPoints1() const = 0;
00169   virtual const ScanPoints getScanPoints2() const = 0;
00170   virtual void setScanPoints1(const ScanPoints &scans) = 0;
00171   virtual void setScanPoints2(const ScanPoints &scans) = 0;
00172 
00173   virtual int getOption(enum ScanOptions) const = 0;
00174   virtual void setOption(enum ScanOptions, int option) = 0;
00175 
00177   virtual void print() const = 0;
00178 
00179   virtual void setScanNumber(unsigned int scan) = 0;
00180   virtual unsigned int getScanNumber() const = 0;
00181   virtual void setRunNumber(unsigned int scan) = 0;
00182   virtual unsigned int getRunNumber() const = 0;
00183 
00184   virtual std::list<std::string> getModuleList(unsigned int group) const = 0;
00185   virtual void setModuleList(unsigned int group, std::list<std::string> newList) = 0;
00186   virtual unsigned int getNGroups() const = 0;
00187   virtual void setNGroups(unsigned int val) = 0;
00188   
00189   virtual boost::posix_time::ptime getStartTime() const = 0;
00190   virtual void setStartTime(boost::posix_time::ptime t) = 0;
00191   
00192   virtual boost::posix_time::ptime getEndTime() const = 0;
00193   virtual void setEndTime(boost::posix_time::ptime t) = 0;
00194 };
00195 
00253 class SctApi {
00254   SctApi(const SctApi &);
00255   SctApi &operator=(const SctApi&);
00256  public:
00257 
00259   static const unsigned int BAD_MODULE;
00260 
00264   SctApi();
00265 
00269   SctApi(boost::shared_ptr<SctConfiguration::Configuration> newConf);
00270 
00271   virtual ~SctApi();
00272 
00273  private:
00279   void setup();
00280 
00284   void dumpPrimList(boost::shared_ptr<PrimListWrapper> prim);
00285 
00287   void dumpRawEvent(unsigned int partition, unsigned int crate, unsigned int rod, int units, unsigned long *bufferA, unsigned long *bufferB);
00288 
00289 public:
00293   void setMrsStream(MRSStream *stream);
00294 
00295 #if USE_IS
00296 
00299   void setIsDictionary(ISInfoDictionary *dict);
00300 #endif
00301 
00302   /***************** Global configuration functions ***********************/
00303 
00305 
00318   void initialiseAll(int run);
00319 
00321 
00328   void shutdownAll();
00329 
00331 
00334   void setRunNumber(UINT32 newRun);
00335 
00337 
00340   void setScanNumber(UINT32 newScan);
00341 
00343 
00346   UINT32 getRunNumber();
00347 
00349 
00352   UINT32 getScanNumber();
00353 
00355 
00359   bool isRODPresent(unsigned int partition, unsigned int crate, unsigned int rod);
00360 
00362 
00369   void startupModules();
00370 
00372   std::list<std::string> getModuleList();
00373 
00374   /*********************** Module configuration **********************/
00375 
00377 
00381   void loadConfiguration();
00382 
00384 
00388   void loadConfiguration(std::string filename);
00389 
00391 
00394   int loadModuleConfigurations();
00395 
00397 
00401   void storeModuleConfigurations();
00402 
00404 
00408   void configureBOC(unsigned int partition, unsigned int crate, unsigned int rod);
00409 
00411 
00415   std::vector<double> getBOCMonitorArray(unsigned int partition, unsigned int crate, unsigned int rod);
00416 
00418 
00422   int awaitResponse(unsigned int partition, unsigned int crate, unsigned int rod, int timeout);
00423 
00425 
00429   int awaitResponseAll(unsigned int partition, unsigned int crate, int timeout);
00430 
00432 
00437   unsigned long *getResponse(unsigned int partition, unsigned int crate, unsigned int rod, 
00438                              unsigned long &length);
00439 
00445   bool getRodMessage(unsigned int partition, unsigned int crate, unsigned int rod,
00446                      char *buffer, unsigned long &length);
00447 
00448   /*************** ROD Diagnostics ********************/
00449 
00451 
00461   void flashLED(unsigned int partition, unsigned int crate, unsigned int rod,
00462                 long slaveNumber, long period = 1000, long flashes = 10);
00463 
00465 
00469   void echo(unsigned int partition, unsigned int crate, unsigned int rod,
00470             unsigned int length, const unsigned long *data);
00471 
00473 
00477   void echoAll(unsigned int length, const unsigned long *data);
00478 
00480 
00484   void echoSlave(unsigned int partition, unsigned int crate, unsigned int rod,
00485                  unsigned int slave, unsigned int length, const unsigned long *data);
00486 
00487 
00488   /***************** Direct ROD access (Debug only) ********************/
00489   /* Should be able to do anything with these commands */
00490 
00492 
00501   int dspBlockDump(unsigned int partition, unsigned int crate, unsigned int rod,
00502                    long dspStart, long numWords, long dspNumber, bool usePrim = true);
00503 
00505 
00515   int dspBlockDumpFile(unsigned int partition, unsigned int crate, unsigned int rod,
00516                        long dspStart, long numWords, long dspNumber, std::string filename, bool usePrim = true);
00517 
00519 
00524   void standardRegisterDump(RodLabel rl);
00525 
00527 
00530   void standardRegisterDump(unsigned int partition, unsigned int crate, unsigned int rod);
00531 
00533 
00537   void standardRegisterDumpAll();
00538 
00540 
00546   unsigned long *dspBlockRead(unsigned int partition, unsigned int crate, unsigned int rod,
00547                               long dspStart, long numWords, long dspNumber, unsigned long &length, bool usePrim = true);
00548 
00550 
00556   int dspBlockWrite(unsigned int partition, unsigned int crate, unsigned int rod,
00557                     unsigned long *buffer, unsigned long dspAddress, long numWords, long dspNumber, bool usePrim = true);
00558 
00560 
00568   unsigned long *primReadSlaveDsp(unsigned int partition, unsigned int crate, unsigned int rod,
00569                                   int s, int add, int words);
00570 
00572 
00578   void primWriteSlaveDsp(unsigned int partition, unsigned int crate, unsigned int rod,
00579                          int s, int add, int numWords, unsigned long *data);
00580 
00581   void writeSlaveFile(unsigned int partition, unsigned int crate, unsigned int rod, unsigned int slave, 
00582                       std::string fileName, unsigned long address, bool usePrim = true);
00583 
00585   void startSlave(unsigned int partition, unsigned int crate, unsigned int rod, unsigned int slave);
00586 
00588   boost::shared_array<unsigned long> loadFile(std::string filename, unsigned long & length);
00589 
00591 
00595   unsigned long readRodStatusReg(unsigned int partition, unsigned int crate, unsigned int rod,
00596                                  long regNumber);
00597 
00599 
00603   unsigned long readRodCommandReg(unsigned int partition, unsigned int crate, unsigned int rod,
00604                                   long regNumber);
00605 
00607 
00611   unsigned long dspSingleRead(unsigned int partition, unsigned int crate, unsigned int rod,
00612                               const unsigned long dspAddr, long dspNumber);
00613 
00615 
00619   void dspSingleWrite(unsigned int partition, unsigned int crate, unsigned int rod,
00620                       unsigned long dspAddr, unsigned long value, long dspNumber);
00621 
00623 
00629   ABCDModule *retrieveModule(UINT32 mid);
00630 
00632 
00636   void createDebugPrimList();
00637 
00639 
00643   void addDebugPrimList(unsigned long length, long index, long id, long version,
00644                         unsigned long * body);
00645 
00647 
00651   void sendDebugPrimList(unsigned int partition, unsigned int crate, unsigned int rod);
00652 
00654 
00658   void sendDebugPrimListAll();
00659 
00661 
00669   void sendDebugSlavePrimList(unsigned int partition, unsigned int crate, unsigned int rod,
00670                               unsigned int slave, bool await, bool response);
00671 
00673 
00676   void debugPrimListFromFile(std::string fileName);
00677 
00679   void dumpDebugPrimList();
00680 
00682   std::list<RodLabel> listRods();
00683 
00684   /**** Official SCTAPI bit ******/
00685 
00687 
00694   UINT32 findModule(std::string sn);
00695 
00697 
00701   std::string convertToString(UINT32 mid);
00702 
00704 
00708   UINT32 findModule(INT32 mur, INT32 module);
00709 
00711 
00715   std::pair<INT32, INT32> convertToMUR(UINT32 mid);
00716 
00718 
00722   UINT32 findBarrelModule(INT32 barrel, INT32 row, INT32 number);
00723 
00725 
00729   void convertToBarrelModule(UINT32 mid, UINT32 &barrel, UINT32 &row, int &number);
00730 
00732 
00736   UINT32 findEndcapModule(INT32 disk, INT32 quadrant, INT32 number);
00737 
00739 
00743   void convertToEndcapModule(UINT32 mid, INT32 &disk, UINT32 &quadrant, UINT32 &number);
00744 
00746 
00750   void getABCDModules(BankType bank);
00751 
00753 
00757   virtual void getABCDModule(UINT32 mid, BankType bank);
00758 
00760 
00764   virtual boost::shared_ptr<ABCDModule> getABCDModuleRaw(unsigned int partition, unsigned int crate, unsigned int rod, 
00765                                                          UINT32 slot, BankType bank);
00766   
00768 
00772   virtual void setABCDModules(BankType bank);
00773 
00775 
00779   virtual void setABCDModule(UINT32 mid, BankType bank);
00780 
00782 
00791   virtual void sendAllABCDModules(BankType bank, ConfigType type = SCTAPI_CONFIG_ALL);
00792 
00794 
00804   virtual void sendABCDModule(UINT32 mid, BankType bank, ConfigType type = SCTAPI_CONFIG_ALL);
00805 
00807 
00813   void modifyABCDMask(UINT32 mid, UINT32* mask);
00814 
00818 /*    void modifyABCDListMask(mList* mlist, UINT32* mask); */
00819 
00826   void modifyABCDTrims(UINT32 mid, UINT8* trims);
00827 
00831 /*    void modifyABCDTrims(mList* mlist, UINT8* trims); */
00832 
00834 
00838   void modifyABCDVar(UINT32 typ, FLOAT32 var);
00839 
00841 
00845   void modifyABCDVar(UINT32 mid, UINT32 typ, FLOAT32 var);
00846 
00848 /*    void modifyABCDVar(mList* mlist, UINT32 typ, FLOAT32 var); */
00849 
00851 
00855   void modifyABCDVar(UINT32 mid, UINT32 chip, UINT32 typ, FLOAT32 var);
00856 
00858 
00862   void modifyABCDVarROD(UINT32 mid, UINT32 chip, UINT32 typ, FLOAT32 var, BankType bank);
00863 
00865 
00869   void modifyABCDVarROD(UINT32 mid, UINT32 typ, FLOAT32 var, BankType bank);
00870 
00872 
00876   void modifyABCDVarROD(UINT32 type, FLOAT32 value, BankType bank);
00877 
00879 /*    void modifyABCDVar(mList* mlist, UINT32 chip, UINT32 typ, FLOAT32 var); */
00880 
00882 
00886   void modifyABCDRC(UINT32 mid, UINT32 chip, UINT16 function, FLOAT32 p0, FLOAT32 p1, FLOAT32 p2);
00887 
00889 
00893   void modifyBOCParam(unsigned int partition, unsigned int crate, unsigned int rod,
00894                       unsigned int channel, unsigned int type, unsigned int val);
00895 
00897 
00901   void modifyBOCParam(unsigned int type, unsigned int val);
00902 
00904 
00908   void printBOCSetup(unsigned int partition, unsigned int crate, unsigned int rod);
00909 
00911 
00915   std::vector<SctConfiguration::BOCChannelConfig> currentBOCSetup(unsigned int partition, unsigned int crate, unsigned int rod);
00916 
00918 
00922   void printBOCRegisters(unsigned int partition, unsigned int crate, unsigned int rod);
00923 
00925 
00929   SctConfiguration::BOCGlobalConfig currentBOCRegisters(unsigned int partition, unsigned int crate, unsigned int rod);
00930 
00932   void saveBOCSetup(unsigned int partition, unsigned int crate, unsigned int rod, BankType bank);
00933 
00935   void saveBOCRegisters(unsigned int partition, unsigned int crate, unsigned int rod, BankType bank);
00936 
00938   void restoreBOCSetup(unsigned int partition, unsigned int crate, unsigned int rod, BankType bank);
00939 
00941   void restoreBOCRegisters(unsigned int partition, unsigned int crate, unsigned int rod, BankType bank);
00942 
00944 
00948   void lasersOff();
00949 
00950   /* *************  TIM functs **************/
00951 
00953 
00960   void timSetFrequency(unsigned int partition, unsigned int crate, double trigFreq, double rstFreq);
00961 
00963 
00968   void freeTriggers(unsigned int partition, unsigned int crate);
00969 
00971 
00975   void stopTriggers(unsigned int partition, unsigned int crate);
00976 
00978 
00982   void timL1A(unsigned int partition, unsigned int crate);
00983 
00985 
00989   void timCalL1A(unsigned int partition, unsigned int crate, int delay);
00990 
00992 
00996   void timSoftReset(unsigned int partition, unsigned int crate);
00997 
00999 
01003   void timBCReset(unsigned int partition, unsigned int crate);
01004 
01006   void sendTimBurst(unsigned int partition, unsigned int crate, unsigned int count);
01007 
01009   void timVerbose(unsigned int partition, unsigned int crate);
01010 
01012 
01015   void timWriteRegister(unsigned int partition, unsigned int crate, int reg, UINT16 val);
01016 
01018 
01021   UINT16 timReadRegister(unsigned int partition, unsigned int crate, int reg);
01022 
01024 
01028   void status();
01029 
01031 
01035   void defaultScan(int type);
01036 
01038 
01044   void doScan(boost::shared_ptr<Scan> scan);
01045 
01049   void awaitScan();
01050 
01060   void abortScan();
01061 
01063 
01067   void doRawScan(boost::shared_ptr<Scan> scan, int delay, int width, 
01068                  bool configureModules = false, bool clkBy2 = false);
01069 
01071 
01075   void sendTimTrigger(unsigned int partition, unsigned int crate, const Trigger *trig);
01076 
01078 
01082   void sendTrigger(unsigned int partition, unsigned int crate, unsigned int rod, const Trigger *trig);
01083 
01085 
01091   void printABCDModule(int mid);
01092 
01094 
01101   void printABCDRodModule(int mid, BankType bank);
01102 
01104 
01108   void decodeEvent(unsigned int partition, unsigned int crate, unsigned int rod, 
01109                    int sl, int index, bool extFlag = false, bool errorType = false);
01110 
01112 
01116   void scanEvents(unsigned int partition, unsigned int crate, unsigned int rod, int sl, bool extFlag, bool errorType);
01117 
01121   void reportEventErrors();
01122 
01126   void decodeConfig(unsigned int partition, unsigned int crate, unsigned int rod, 
01127                     bool skipTrim = false, bool bypass = false);
01128 
01130 
01134   void rawData(unsigned int partition, unsigned int crate, unsigned int rod, int delay, int units, bool setMask = true, const Trigger *trig = 0);
01135 
01137 
01143   void sendL1A(unsigned int partition, unsigned int crate, unsigned int rod, bool capture = false);
01144 
01146 
01163   std::vector<char> probe(unsigned int partition, unsigned int crate, unsigned int rod, 
01164                           signed int harness = -1);
01165 
01167 
01184   std::vector<char> probeWithTrigger(unsigned int partition, unsigned int crate, unsigned int rod, 
01185                                      const Trigger *trigger, signed int harness = -1);
01186 
01188   std::vector<std::vector<char> > SctApi::probeScan(unsigned int partition, unsigned int crate, unsigned int rod, 
01189                                                     boost::shared_ptr<Scan> scan, signed int harness = -1);
01190 
01197   bool checkAllModulesProbe(std::string value);
01198 
01204   void autoConfigure();
01205 
01209   void bocHistogram(unsigned int partition, unsigned int crate, unsigned int rod, 
01210                     unsigned int samples, unsigned int numLoops);
01211 
01212   /*** DCS functionality */
01213 
01221   void requestHardResetAll();
01222 
01230   void requestHardReset(UINT32 mid);
01231 
01239   void requestIVCurve(UINT32 mid, FLOAT32 start, FLOAT32 stop, FLOAT32 step, UINT16 delay, FLOAT32 currentLim);
01240 
01248   void requestIVCurveAll(FLOAT32 start, FLOAT32 stop, FLOAT32 step, UINT16 delay, FLOAT32 currentLim);
01249 
01260   void setSelectAllInCrate(int crate, bool value, int timeout = 5);
01261 
01272   // #warning "Should this just change DCS?"
01273   void setSelect(UINT32 mid, bool value); 
01274 
01284   void changeRunState(int state);
01285 
01286   /************ Direct DDC (no translations) ****************/
01287 
01288 /*   /\** Get a channel parameter from DDC *\/ */
01289 /*   void ddcGetChannelParameter(int crate, int channel, std::string dpeName, */
01290 /*                               int& dpeValue, int timeout); */
01291 
01293   void ddcChangeState (int crate, int channel, short state, int timeout = 2);
01295   void ddcChangeStateAll (int crate, short state, int timeout = 2);
01297   void ddcLoadConfiguration (int crate, short state, int timeout = 2);
01299   void ddcHardReset (int crate, int channel, int timeout = 2);
01301   void ddcHardResetAll (int crate, int timeout = 2);
01302 
01304   int ddcGetChannelParameterInt (int crate, int channel, std::string name, int timeout = 2);
01306   float ddcGetChannelParameterFloat (int crate, int channel, std::string name, int timeout = 2);
01308   std::string ddcGetChannelParameterString (int crate, int channel, std::string name, int timeout = 2);
01310   int ddcGetCardParameterInt (int crate, int card, std::string name, int timeout = 2);
01312   float ddcGetCardParameterFloat (int crate, int card, std::string name, int timeout = 2);
01314   std::string ddcGetCardParameterString (int crate, int card, std::string name, int timeout = 2);
01316   int ddcGetCrateParameterInt (int crate, std::string name, int timeout = 2);
01318   float ddcGetCrateParameterFloat (int crate, std::string name, int timeout = 2);
01320   std::string ddcGetCrateParameterString (int crate, std::string name, int timeout = 2);
01321 
01323 
01328   void ddcGetCrateParameters(int crate, std::vector<std::string> names, 
01329                              std::map<std::string, float>& dpeValues, int timeout);
01330 
01332   void ddcSetChannelParameter (int crate, int channel, std::string name, float value, int timeout = 2);
01334   void ddcSetCardParameter (int crate, int card, std::string name, float value, int timeout = 2);
01336   void ddcSetCrateParameter (int crate, std::string name, float value, int timeout = 2);
01337 
01338 
01339 
01350   void tidyHistogramming();
01351 
01355   long getRodSlot(unsigned int partition, unsigned int crate, unsigned int rod);
01356 
01360   int getRodRevision(unsigned int partition, unsigned int crate, unsigned int rod);
01361 
01365   int getRodRevision(const RodLabel &label);
01366 
01370   void testLinkOutSelect(unsigned int partition, unsigned int crate, unsigned int rod,
01371                          unsigned int link);
01372 
01376   unsigned int testLinkOutRetrieve(unsigned int partition, unsigned int crate, unsigned int rod);
01377 
01385   void unsetDebugOption(std::string opt);
01386 
01394   void setDebugOption(std::string opt);
01395 
01403   std::list<std::string> listEnabledDebugOptions();
01404 
01412   std::vector<std::string> listDebugOptions();
01413 
01417   void debugStepHistogram();
01418 
01424   void debugContinueHistogram();
01425 
01432   void debugAbortHistogram();
01433 
01439   void eventTrapSetup(int slaveMask, int trapMatch, int trapMod, int trapRemain, bool tim, bool error, 
01440                       boost::shared_ptr<PrimListWrapper> primList);
01441 
01443   void startEventTrap(int slave, boost::shared_ptr<PrimListWrapper> primList);
01444 
01446   void stopEventTrap(int slave, boost::shared_ptr<PrimListWrapper> primList);
01447 
01449   void rodMode(unsigned int partition, unsigned int crate, unsigned int rod,
01450                int mode, int flag, int fifoSetup, int nBins, int delay, int message);
01451 
01453   void setupModuleMask(unsigned int partition, unsigned int crate, unsigned int rod,
01454                        int port, int slvs);
01455 
01457   void setupModuleMask(int port, int slvs, boost::shared_ptr<PrimListWrapper> list);
01458 
01460   std::pair<UINT32, UINT32> sendData(unsigned int partition, unsigned int crate, unsigned int rod, int type, int dsp);
01461 
01465   void resumePolling();
01466 
01470   void stopPolling();
01471 
01473   void print_calib(unsigned int partition, unsigned int crate, unsigned int rod);
01474 
01476 
01481   int synchSendPrimListAllCrates(boost::shared_ptr<PrimListWrapper> primList, int timeout = 10);
01482 
01484   void stopHistogramming(const ScanEx &ex);
01485 
01487   void setSlaveBlock(unsigned int partition, unsigned int crate, unsigned int rod, 
01488                      int s, long sAdd, int words, long value = 0, bool usePrim = true);
01489 
01491   void writeRODRegister(unsigned int partition, unsigned int crate, unsigned int rod,
01492                         int reg, int off, int width, int value);
01493 
01495   unsigned int readRODRegister(unsigned int partition, unsigned int crate, unsigned int rod, int r);
01496 
01498   int pollRegister(unsigned int partition, unsigned int crate, unsigned int rod, int r, int off, int width, int val, int timeout = 1000000);
01499 
01500   virtual unsigned long *readFifo(unsigned int partition, unsigned int crate, unsigned int rod, int id, int bank, int elems);
01501 
01503   void startHistogramTask(const Scan &scan, const ScanEx &ex, const RodLabel, 
01504                           unsigned int startBin, unsigned int nBins, unsigned int nTrigs,
01505                           boost::shared_ptr<PrimListWrapper> list);
01506 
01508 
01513   void sendPrimList(unsigned int partition, unsigned int crate, unsigned int rod,
01514                     boost::shared_ptr<PrimListWrapper> prim);
01515 
01516   MRSStream *mrs;
01517 #if USE_IS
01518   ISInfoDictionary *m_isDict;
01519 #endif
01520  protected:
01521   
01522   /********** Should these be part of the API? **************/
01523 
01525 
01530   virtual int initialiseRod(unsigned int partition, unsigned int crate, unsigned int rod);
01531 
01533 
01539   virtual int initialiseModule(std::string module);
01540 
01542   ABCDModule *lookupConfig(UINT32 mid);
01543 
01545 
01549   virtual bool preScanHardwareCheck(Scan& scan, ScanEx& extra);
01550   
01551   virtual void doHistogramSetup(const Scan &scan, const ScanEx &extra);
01552   
01557   UINT32 *readEventBuffer(unsigned int partition, unsigned int crate, unsigned int rod, 
01558                         int sl, bool extFlag, bool errorType);
01559 
01563   int getLastEventFrame(unsigned int partition, unsigned int crate, unsigned int rod, int slave);
01564 
01566 
01575   virtual int pollHistogramming(boost::shared_ptr<ScanControl> controller, int timeout = 5);
01576  
01577   void scanLoop();
01578 
01579   void scanPollingThread();
01580 
01581   void addRodToList(RodLabel newRod);
01582 
01583   RodInfo &SctApi::getRodInfo(const RodLabel &l);
01584 
01586   std::list<RodLabel> rodList;
01587 
01589   std::map<RodLabel, RodInfo> rodInfoList;
01590   
01592   std::map<UINT32, ABCDModule> moduleMap;
01593   
01594   // Controller for current scan
01595   boost::shared_ptr<ScanControl> scanController;
01596 
01597   // Possibly to be used for continuing a scan
01598   boost::shared_ptr<ScanControl> lastScanController;
01599 
01600  private:
01601 
01602   /*************************************************************
01603    *          Internal functions (shouldn't be exported,       *
01604    *              probably able to keep them private )         *
01605    *************************************************************/
01606 
01608 
01614   void sendSlavePrimList(unsigned int partition, unsigned int crate, unsigned int rod,
01615                          boost::shared_ptr<PrimListWrapper> prim, unsigned int slave, bool await, bool response);
01616 
01618 
01623   void sendPrimListAll(unsigned int partition, unsigned int crate,
01624                        boost::shared_ptr<PrimListWrapper> prim);
01625 
01627   void setupEventTrapping(const Scan &scan, const ScanEx &ex, const RodLabel, boost::shared_ptr<PrimListWrapper> list);
01628 
01630   void startEventTrapping(const Scan &scan, const ScanEx &ex, const RodLabel, boost::shared_ptr<PrimListWrapper> primList);
01631 
01633   void setupEventDump(const Scan &scan, const ScanEx &ex, const RodLabel, boost::shared_ptr<PrimListWrapper> list);
01634 
01636   void setupHistogramming(const Scan &scan, const ScanEx &ex, const RodLabel, bool tim, 
01637                           boost::shared_ptr<PrimListWrapper> list);
01638 
01640   void calib_init();
01641 
01643   void readRawData(unsigned int partition, unsigned int crate, unsigned int rod, 
01644                    int delay, bool setMask);
01645 
01647   virtual int setupRawData(unsigned int partition, unsigned int crate, unsigned int rod, 
01648                int delay, int units, bool setMask, const Trigger *trig = 0);
01649 
01651 
01655   Crate *getCrate(unsigned int partition, unsigned int crate) const;
01656 
01658   void cacheModuleConfig(UINT32 mid);
01659 
01661 
01664   void getrpcrc(UINT32 mid, unsigned int &rpartition, unsigned int &rcrate, unsigned int &rrod, unsigned &rchannel);
01665 
01667   void initDDC();
01668 
01670   void setupScanMasks(ScanEx &extra, int distSlave, bool dual);
01671 
01673   bool checkModuleListsForScan();
01674 
01676 
01679   void preScanModuleSetup(Scan &scan);
01680 
01681   bool checkDebugOption(std::string opt);
01682   // This should be DebugOptions but that would mean including SctApiDebug.h here
01683   bool checkDebugOption(int opt);
01684 
01685   /*********** Internal variables *************/
01686 
01688   boost::shared_ptr<SctConfiguration::Configuration> config;
01689 
01690   IPCPartition *ddcPartition;
01691   std::string *ddcCtrls[2];
01692   SCTDCSCommand *ddcCmd;
01693 
01694   boost::shared_ptr<DCSAccess> dcsAccess;
01695 
01697   boost::shared_ptr<PrimListWrapper> debugPrimList;
01698 
01700   std::map<std::pair<unsigned int, unsigned int>, Crate* > crateMap;
01701 
01703   Log log;
01704 
01706   boost::shared_ptr<const Scan> lastDebugScan;
01707   boost::shared_ptr<const ScanEx> lastDebugScanEx;
01708 
01710   UINT32 scanNumber;
01711 
01713   UINT32 runNumber;
01714 
01715 #if USE_SCAN_THREAD
01716   boost::condition scanQueue_notEmpty;
01717   boost::mutex scanQueue_mutex;
01718 
01719   /* ******* Threads ******/
01720   std::auto_ptr<boost::thread> scanPollThread;
01721 
01722   bool m_stopPolling;
01723   bool m_inScanLoop;
01724 #endif
01725 
01726   /* **********  Mutexes  ********** */
01727   boost::mutex logMutex;
01728 };
01729 }  // End of namespace SctApi
01730 #endif

Generated on Sat Jul 31 14:18:12 2004 for SCT DAQ/DCS Software - C++ by doxygen 1.3.5