QSlowBaseCommand.hh

Go to the documentation of this file.
00001 
00011 #ifndef _QSLOW_BASE_COMMAND_HH_
00012 #define _QSLOW_BASE_COMMAND_HH_
00013 
00014 // C/C++ Includes
00015 #include <map>
00016 #include <string>
00017 
00018 // Apollo Includes
00019 #include "QCuore.hh"
00020 #include "QCommand.hh"
00021 #include "QError.hh"
00022 #include "QSlowTypes.hh"
00023 
00024 
00025 class QError;
00026 
00027 class QSlowBaseCommand : public QCommand {
00028 public:    
00029   
00030 
00032    enum QSlowCmdType_t
00033       {
00034          QSLOW_GENERIC = 0xaa,
00035          QSLOW_SET,
00036          QSLOW_GET,
00037          QSLOW_START
00038       };
00039 
00041    enum QSlowKeyWords_t
00042       {
00043          QSLOW_KLG,
00044          QSLOW_KBASKET,
00045          QSLOW_KID,
00046          QSLOW_KCH,
00047          QSLOW_KDEV,
00048 
00049     
00050          // Front-End
00051          QSLOW_KFE_CRATE,
00052          QSLOW_KFE_BOARD,
00053          QSLOW_KFE_CHANNEL,
00054     
00055          // Bessel
00056          QSLOW_KBS_CRATE,
00057          QSLOW_KBS_BOARD,
00058          QSLOW_KBS_CHANNEL,
00059 
00060          // Pulser
00061          QSLOW_KPS_CRATE,
00062          QSLOW_KPS_BOARD,
00063          QSLOW_KPS_CHANNEL
00064 
00065       };
00066 
00067   
00068 
00070    enum QSlowTarget_t 
00071       {
00072          QSLOW_GE_TARGET,  
00073          QSLOW_FE_TARGET,  
00074          QSLOW_BS_TARGET,  
00075          QSLOW_PS_TARGET,  
00076          QSLOW_PO_TARGET   
00077       };
00078   
00079 
00081    enum QSlowEleCommand_t 
00082       {
00083     
00084          // General Parameters
00085          QSLOW_GE_MODE,
00086          QSLOW_GE_WRITE,
00087          QSLOW_GE_NUM,
00088          QSLOW_GE_LIVETIME,
00089          QSLOW_GE_BASKET,
00090          QSLOW_GE_IFACE,
00091          
00092     
00093          // Front-End Adressing
00094          QSLOW_FE_NAME,
00095          QSLOW_FE_ID,
00096          QSLOW_FE_LABEL,
00097          QSLOW_FE_CRATE,
00098          QSLOW_FE_SLOT,
00099          QSLOW_FE_BOARD,
00100          QSLOW_FE_CHANNEL,
00101          
00102          // Front-End Registers
00103          QSLOW_FE_MEMA,
00104          QSLOW_FE_MEMB,
00105          QSLOW_FE_MEMC,
00106          QSLOW_FE_MEMD,
00107          QSLOW_FE_DACH,
00108          QSLOW_FE_DACL,
00109 
00110          // Front-End Parameters
00111          QSLOW_FE_GAIN,
00112          QSLOW_FE_BIAS,
00113          QSLOW_FE_BIAS_POL,
00114          QSLOW_FE_ACYCLE,
00115          QSLOW_FE_ATIME,
00116          QSLOW_FE_RLOAD,
00117          QSLOW_FE_INPUT,
00118          QSLOW_FE_AUX,
00119          QSLOW_FE_THERM,
00120          QSLOW_FE_ODAC,
00121          QSLOW_FE_OMSB,
00122          QSLOW_FE_OSBIT,
00123          QSLOW_FE_OPOL,
00124          QSLOW_FE_TEST_POS,
00125          QSLOW_FE_TEST_NEG,
00126 
00127 
00128          // Bessel Adressing
00129          QSLOW_BS_NAME,
00130          QSLOW_BS_ID,
00131          QSLOW_BS_LABEL,
00132          QSLOW_BS_CRATE,
00133          QSLOW_BS_SLOT,
00134          QSLOW_BS_BOARD,
00135          QSLOW_BS_CHANNEL,
00136 
00137          // Bessel Register
00138          QSLOW_BS_MEM,
00139    
00140          // Bessel Parameters
00141          QSLOW_BS_TRGAIN,
00142          QSLOW_BS_DELETION,
00143          QSLOW_BS_ENABLE,
00144          QSLOW_BS_CUTFREQ,
00145 
00146 
00147          // Pulser Adressing
00148          QSLOW_PS_NAME,
00149          QSLOW_PS_ID,
00150          QSLOW_PS_LABEL,
00151          QSLOW_PS_CRATE,
00152          QSLOW_PS_SLOT,
00153          QSLOW_PS_BOARD,
00154          QSLOW_PS_CHANNEL,
00155 
00156          // Pulser Parameters
00157          QSLOW_PS_GROUP,
00158          QSLOW_PS_WIDTH,
00159          QSLOW_PS_AMPLI,
00160          QSLOW_PS_ATTEN,
00161          QSLOW_PS_FIRE,
00162 
00163          // Pulser Register
00164          QSLOW_PS_MEM0,
00165          QSLOW_PS_MEM1,
00166          QSLOW_PS_MEM2,
00167          QSLOW_PS_MEM3,
00168 
00169          // Power Supply
00170          QSLOW_PO_IDN,
00171          QSLOW_PO_VENDOR,       
00172          QSLOW_PO_NAME,
00173          QSLOW_PO_TYPE,       
00174          QSLOW_PO_VSET,
00175          QSLOW_PO_ISET,
00176          QSLOW_PO_VOUT,
00177          QSLOW_PO_IOUT,
00178          QSLOW_PO_VOUT_EN
00179 
00180       };
00181 
00182    // ctor
00183    QSlowBaseCommand(QSlowCmdType_t Type);
00184   
00185    // dtor
00186    virtual ~QSlowBaseCommand();
00187 
00188    // Execute Command
00189    virtual void Execute()=0;
00190   
00191    // Check Commands Parameters
00192    virtual void CheckParams()=0;
00193         
00194 protected:
00195   
00196    // Return true if adressing is by Logical Channel
00197    bool IsLg();
00198  
00199    // Return true if adressing is by Physical Channel
00200    bool IsPhysical();
00201 
00202    // Return true if adressing is by Id
00203    bool IsId();
00204         
00205    // Logical and Physical Addressig
00206    int fLg;      
00207    int fId;      
00208    int fCrate;   
00209    int fBoard;   
00210    int fChannel; 
00212    // Variables for to set/get parameters
00213    std::string  fStringVal;    
00214   
00215    QSlowEleCommand_t fCmdCode; 
00216    QSlowTarget_t      fTarget; 
00217    QSlowCmdType_t    fCmdType; 
00219    // Get Command Type
00220    inline const QSlowCmdType_t GetCmdType() const {return fCmdType;}
00221 
00222    static std::map<QSlowEleCommand_t,std::string> gGECommands; 
00223    static std::map<QSlowEleCommand_t,std::string> gBSCommands; 
00224    static std::map<QSlowEleCommand_t,std::string> gFECommands; 
00225    static std::map<QSlowEleCommand_t,std::string> gPSCommands; 
00226    static std::map<QSlowEleCommand_t,std::string> gPOCommands; 
00227    static std::map<QSlowTarget_t,QSlowTypes::QSlowDevice_t> gToDevice;  
00230    static std::map<QSlowKeyWords_t,  std::string> gKeyWords; 
00234    enum QSlowBoolType_t
00235       {
00236          QSLOW_NO_BOOL = 1000, 
00237          QSLOW_ONOFF,          
00238          QSLOW_POSNEG,         
00239          QSLOW_TESTBOLO,       
00240          QSLOW_RMAXRMIN        
00241       };
00242   
00243    // From unsigned int to std::string
00244    const std::string fuits(size_t IntVal);
00245 
00246    // From decimal unsigned interger to binary number
00247    std::string Binary(size_t Value);
00248 
00249    // Retunrs false if a invalid Parameters is passed
00250    bool CheckForNotValidParams(QError& ErrorRet);
00251   
00252    // If Setting (or Getting or Starting) in not defined
00253    void NotDefined(QError& ErrorRet, QSlowTarget_t Target, QSlowEleCommand_t CmdCode);
00254 
00255    // Return true if Slow Server is Locked
00256    bool IsLocked();
00257 
00258    // Return true if command is the "unlock" command
00259    bool IsUnlockCommand(QSlowEleCommand_t CmdCode);
00260    
00261    // Return true if the command il prensent only one time
00262    bool OnlyOne(const std::string& cmd);
00263 
00264    // get device type starting from the target
00265    inline const QSlowTypes::QSlowDevice_t GetDeviceType(QSlowTarget_t target) const {return gToDevice[target];} 
00266    
00267   
00268 private:
00269   
00270    bool fIsLg;       
00271    bool fIsPhysical; 
00272    bool fIsId;       
00274 };
00275 
00276 
00277 
00278 #endif // _QSLOW_BASE_COMMAND_HH_

Generated on Tue Nov 16 10:49:55 2010 for CUORE Software by  doxygen 1.5.6