///////////////////////////////////////////////////////////////////// // PixController.h // version 1.0 ///////////////////////////////////////////////////////////////////// // // 08/04/03 Version 1.0 (PM) // Initial release // //! Abstract class for the generic pixel module controller #ifndef _PIXLIB_PIXCONTROLLER #define _PIXLIB_PIXCONTROLLER #ifdef WIN32 #pragma warning(disable: 4786) #pragma warning(disable: 4800) #endif #include #include #include #include "primParams.h" #include "serialStreams.h" #include "PixModuleGroup/PixModuleGroup.h" #include "BaseException.h" namespace PixLib { class Bits; class Histo; class Config; //! Pix Controller Exception class; an object of this type is thrown in case of a controller error class PixControllerExc : public SctPixelRod::BaseException{ public: enum ErrorLevel{INFO, WARNING, ERROR, FATAL}; //! Constructor PixControllerExc(ErrorLevel el, std::string name) : BaseException(name), m_errorLevel(el), m_name(name) {}; //! Destructor virtual ~PixControllerExc() {}; //! Dump the error virtual void dump(std::ostream &out) { out << "Pixel Controller " << m_name << " -- Level : " << dumpLevel(); } std::string dumpLevel() { switch (m_errorLevel) { case INFO : return "INFO"; case WARNING : return "WARNING"; case ERROR : return "ERROR"; case FATAL : return "FATAL"; default : return "UNKNOWN"; } } //! m_errorLevel accessor ErrorLevel getErrorLevel() { return m_errorLevel; }; //! m_name accessor std::string getCtrlName() { return m_name; }; private: ErrorLevel m_errorLevel; std::string m_name; }; class PixScan; class PixScanConfig; class PixRunConfig; class PixController { public: enum HistoType{OCCUPANCY=0, LVL1, TOT, TOT_MEAN, TOT_SIGMA, SCURVES, SCURVE_MEAN, SCURVE_SIGMA, SCURVE_CHI2, HITOCC, TOTAVERAGE, TOTCAL_PARA, TOTCAL_PARB, TOTCAL_PARC, TOTCAL_CHI2, DSP_ERRORS, CLUSTER_TOT, CLUSTER_SIZE, CLSIZE_TOT, SEED_TOT, SEED_LVL1, NSEEDS, TOT0, TOT1, TOT2, TOT3, TOT4, TOT5, TOT6, TOT7, TOT8, TOT9, TOT10, TOT11, TOT12, TOT13, TOT14, TOT15}; static PixController *make(PixModuleGroup &grp, DBInquire *dbInquire, std::string type); //! Factory static PixController *make(PixModuleGroup &grp, std::string type); //! Factory PixController(PixModuleGroup &modGrp, DBInquire *dbInquire) : m_modGroup(modGrp), m_dbInquire(dbInquire) { //! Constructor m_name = m_modGroup.getRodName(); } PixController(PixModuleGroup &modGrp) : m_modGroup(modGrp), m_dbInquire(NULL) { //! Constructor m_name = m_modGroup.getRodName(); } virtual ~PixController() {}; //! Destructor virtual void initHW() = 0; //! Hardware (re)init virtual void testHW() = 0; //! Hardware test virtual void sendCommand(Bits commands, int moduleMask) = 0; //! Send command no out virtual void sendCommandOutSync(Bits commands, int moduleMask, std::vector& output) = 0; //! Send command sync virtual void sendCommandOutAsync(Bits commands, int moduleMask, int commandID) = 0; //! Send command async virtual bool checkOutReady(int commandID) = 0; //! Wait for command termination virtual void getOutput(int commandID, std::vector& output) = 0; //! Get command output virtual void writeModuleConfig(int moduleId, Module& config) = 0; //! Write module configuration virtual void readModuleConfig(int moduleId, Module& config) = 0; //! Read module configuration virtual void sendModuleConfig(unsigned int moduleMask) = 0; //! Send module configuration virtual void sendPixel(unsigned int moduleMask) = 0; //! send specif. pixel register cfg. virtual void sendGlobal(unsigned int moduleMask) = 0; //! send specif. gloabal register cfg. virtual void sendPixel(unsigned int moduleMask, std::string regName, bool allDcsIdentical=false) = 0; //! send pixel register cfg. virtual void sendPixel(unsigned int moduleMask, std::string regName, int DC)=0 ; //! send pixel register cfg. for specific DC virtual void sendGlobal(unsigned int moduleMask, std::string regName) = 0; //! send gloabal register cfg. virtual void setCalibrationMode() = 0; virtual void setConfigurationMode() = 0; virtual void setRunMode() = 0; virtual void writeScanConfig(PixScan &scn) = 0; //! Write scan parameters virtual void writeScanConfig(PixScanConfig &cfg) = 0; //! Write scan parameters virtual void startScan() = 0; //! Start a scan virtual bool fitHistos() = 0; //! fit histos virtual void getErrorHistos(unsigned int dsp, Histo* &his) = 0; //! get error arrays virtual void getHisto(HistoType type, unsigned int xmod, unsigned int slv, std::vector< std::vector >& his) = 0; //! Read an histogram virtual void getFitResults(HistoType type, unsigned int mod, unsigned int slv, std::vector< Histo * > &thr, std::vector< Histo * > &noise, std::vector< Histo * > &chi2) = 0; //! Read a Fit from Dsp virtual bool moduleActive(int nmod) = 0; //! true if a module is active during scan or datataking virtual void writeRunConfig(PixRunConfig &cfg) = 0; //! Get the run configuration parameters from PixModuleGroup virtual void startRun(int ntrig = 0) = 0; //! Start a run virtual void stopRun() = 0; //! Terminates a run virtual int runStatus() = 0; //! Check the status of the run virtual int nTrigger() = 0; //! Returns the number of trigger processed so far virtual void stopScan() = 0; //! Aborts a running scan virtual bool primitiveExists(std::string str) = 0; //! Ask if a given primitive is implemented // new function for MonLeak and HitBusScaler virtual void shiftPixMask(int mask, int steps=1) = 0; // Accessors PixModuleGroup &getModGroup() { return m_modGroup; }; //! Parent module group accessor std::string getCtrlName() { return m_name; }; //! Group name accessor Config &config() { return *m_conf; }; //! Configuration object accessor protected: Config *m_conf; //! Configuration object PixModuleGroup &m_modGroup; //! Pointer to the module group using this controller private: virtual void configInit() = 0; //! Init configuration structure std::string m_name; //! Name of the controller DBInquire *m_dbInquire; //! DBInquire }; } #endif