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

oksImpl.h

00001 #ifndef SCTAPI_OKS_IMPL_CONFIGURATION
00002 #define SCTAPI_OKS_IMPL_CONFIGURATION
00003 
00004 #include <list>
00005 #include <string>
00006 #include <stdexcept>
00007 
00008 #include <oks/class.h>
00009 #include <oks/object.h>
00010 #include <oks/kernel.h>
00011 
00012 #include "RodDaq/CommonWithDsp/sctStructure.h"
00013 
00014 #include "../SctApi/log.h"
00015 
00016 #include "sctConf/configuration.h"
00017 
00021 /*  struct SlaveConfig { */
00022 /*    std::string emifFile; */
00023 /*    std::string ipramFile; */
00024 /*    std::string idramFile; */
00025 /*    std::string extFile; */
00026 /*  }; */
00027 
00031 /*  struct RodConfig { */
00032 /*    
00033 /*    bool bocPresent; */
00034 /*    
00035 /*    unsigned long baseAddress; */
00036 /*    
00037 /*    unsigned long mapSize; */
00038 /*    
00039 /*    long numSlaves; */
00040 /*    
00041 /*    SlaveConfig slaves[4]; */
00042 /*  }; */
00043 
00047 /*  struct TimConfig { */
00048 /*    
00049 /*    unsigned long baseAddress; */
00050 /*    
00051 /*    unsigned long mapSize; */
00052 /*  }; */
00053 
00061 /*  struct BOCChannelConfig { */
00062 /*    
00063 /*    int current; */
00064 /*    
00065 /*    int delay; */
00066 /*    
00067 /*    int markSpace; */
00068 /*    
00069 /*    int threshold0; */
00070 /*    
00071 /*    int delay0; */
00072 /*    
00073 /*    int threshold1; */
00074 /*    
00075 /*    int delay1; */
00076 
00077 /*    
00078 /*    int txFibre; */
00079 /*    
00080 /*    int rxFibre0; */
00081 /*    
00082 /*    int rxFibre1; */
00083 /*  }; */
00084 
00088 /*  class ConfigurationException : std::exception { */
00089 /*    std::string desc; */
00090 /*   public: */
00091 /*    
00092 /*    ConfigurationException(const std::string &str) : desc(str) {} */
00093 /*    
00094 /*    virtual const char* what () const { return desc.c_str(); } */
00095 /*  }; */
00096 
00124 class OksImpl : public Configuration {
00125   OksImpl(const OksImpl &);
00126   OksImpl &operator=(const OksImpl &);
00127 public:
00131   OksImpl(bool readOnly = true);
00135   ~OksImpl();
00136 
00137   /************* Get physical configuration ****************/
00138 
00143   std::list<unsigned int> listPartitions();
00144 
00149   std::list<unsigned int> listCratesInPartition(unsigned int partition);
00150 
00155   std::list<unsigned int> listRodsInCrate(unsigned int partition, unsigned int crate);
00156 
00163   std::list<unsigned int> listMURSInRod(unsigned int partition, unsigned int crate, unsigned int rod);
00164 
00171   std::list<std::string> listModulesInMUR(unsigned int partition, unsigned int MUR);
00172 
00179   std::list<std::string> listRModulesInMUR(unsigned int partition, unsigned int MUR);
00180 
00181   /************** Get configurations *****************/
00182 
00188   ABCDModule getModuleConfig(std::string module);
00189 
00195   RodConfig getRodConfig(unsigned int partition, unsigned int crate, unsigned int rod);
00196 
00202   BOCChannelConfig getBOCConfig(unsigned int partition, unsigned int crate, unsigned int rod, 
00203                                 unsigned int channel);
00204 
00210   char *getBOCMappings(unsigned int partition, unsigned int crate, unsigned int rod);
00211 
00217   TimConfig getTimConfig(unsigned int partition, unsigned int crate);
00218 
00224   void setBOCMapping(unsigned int partition, unsigned int crate, unsigned int rod, 
00225                      unsigned int channel, unsigned int tx, unsigned int rx0, unsigned int rx1);
00226 
00230   void printModuleConfig(const ABCDModule &conf);
00231 
00232   /************** Change indexing schemes ****************/
00233 
00237   void translateToROD(unsigned int MUR, unsigned int module,
00238               unsigned int &partition, unsigned int &crate, 
00239               unsigned int &rod, unsigned int &channel);
00240  
00244   void translateToRROD(unsigned int MUR, unsigned int module,
00245                unsigned int &partition, unsigned int &crate, 
00246                unsigned int &rod, unsigned int &channel);
00247  
00251   void translateToSN(unsigned int MUR, unsigned int module,
00252                      std::string &sn);
00253 
00257   void translateToBarrel(unsigned int MUR, unsigned int module,
00258                          unsigned int &barrel, unsigned int &row, int &number);
00259 
00263   void translateToEndcap(unsigned int MUR, unsigned int module,
00264                          unsigned int &disk, unsigned int &ring, unsigned int &number);
00268   void translateToPowerSupply(unsigned int MUR, unsigned int module,
00269                               unsigned int &partition, 
00270                               unsigned int &crate, unsigned int &channel);
00271 
00275   void translateFromROD(unsigned int partition, unsigned int crate, 
00276                         unsigned int rod, unsigned int channel,
00277                         unsigned int &MUR, unsigned int &module);
00278 
00282   void translateFromSN(std::string sn,
00283                        unsigned int &MUR, unsigned int &module);
00284 
00288   void translateFromBarrel(unsigned int barrel, unsigned int row, int number,
00289                          unsigned int &MUR, unsigned int &module);
00290 
00294   void translateFromEndcap(unsigned int disk, unsigned int ring, unsigned int number,
00295                            unsigned int &MUR, unsigned int &module);
00296 
00297 
00298   /************** Change configuration ******************/
00299 
00305   void updateModuleConfig(std::string module, ABCDModule conf);
00306 
00313   void updateRodConfig(unsigned int partition, unsigned int crate, unsigned int rod, RodConfig conf);
00314 
00319   void clearAll();
00320 
00334   void namePartition(int partition, string name);
00335 
00339   void createPartition(int partition);
00340 
00344   void createCrate(int partition, int crate);
00345 
00349   void createROD(int partition, int crate, int rod, RodConfig conf);
00350 
00354   void createMUR(int partition, int crate, int rod, int order, int number);
00355 
00359   void createModule(int MUR, int order, int RMUR, int rorder, string number, const ABCDModule &mConf);
00360 
00364   void createBOCConfig(int MUR, int order, const BOCChannelConfig &bConf);
00365 
00369   void setBOCConfig(int partition, int crate, int rod, int channel, const BOCChannelConfig &conf);
00370 
00374   void loadConfiguration(const std::string &filename);
00375 
00376   /************** Save configuration *********************/
00377 
00387   void saveConfiguration(std::string filename = "");
00388 
00389  private:
00393   xmlNodePtr getQueryNode(std::string query, std::string task);
00394 
00400   int getAttrAsInt(xmlNodePtr node, const char *attr);
00401 
00407   xmlNodePtr getChildNode(xmlNodePtr node, const char *name);
00408 
00414   xmlNodePtr getOrNewChildNode(xmlNodePtr node, const char *name);
00415 
00419   const ABCDModule parseModuleConfig(xmlNodePtr node);
00420 
00424   const RodConfig parseRodConfig(xmlNodePtr node);
00425 
00429   const TimConfig parseTimConfig(xmlNodePtr node);
00430 
00435   void replaceModuleConfig(xmlNodePtr node, ABCDModule conf, std::string name);
00436 
00437  private:
00438   OksObject *getPartition(unsigned int p);
00439   OksObject *getCrate(unsigned int p, unsigned int c);
00440   OksObject *getRod(unsigned int p, unsigned int c, unsigned int r);
00441   OksObject *getMUR(unsigned int m);
00442   OksObject *getModule(unsigned short mur, unsigned char position);
00443 
00444   OksObject *getObjectFromRelationship(const OksObject *obj, const std::string rel);
00445   unsigned long getULongData(const OksObject *obj, const std::string attr);
00446   unsigned short getUShortData(const OksObject *obj, const std::string attr);
00447   unsigned char getUCharData(const OksObject *obj, const std::string attr);
00448   std::string getStringData(const OksObject *obj, const std::string attr);
00449 
00450   OksClass *partClass;
00451   OksClass *crateClass;
00452   OksClass *rodClass;
00453   OksClass *murClass;
00454   OksClass *moduleClass;
00455 
00456 /*    ConfdbConfiguration configuration; */
00457 
00458   OksKernel kernel;
00459 };
00460 #endif

Generated on Tue Dec 9 10:07:44 2003 for SCT DAQ/DCS Software by doxygen1.3-rc3