///////////////////////////////////////////////////////////////////// // PixModule.cxx // version 1.0 ///////////////////////////////////////////////////////////////////// // // 11/04/03 Version 1.0 (CS) // Initial release // //! Class for the Pixel Module #include "PixDcs/SleepWrapped.h" #include "serialStreams.h" #include "pixelConfigStructures.h" #include "Bits/Bits.h" #include "PixModuleGroup/PixModuleGroup.h" #include "PixMcc/PixMcc.h" #include "PixMcc/PixMccData.h" #include "PixMcc/PixMccStructures.h" #include "PixMcc/PixMccI1.h" #include "PixMcc/PixMccI2.h" #include "PixFe/PixFe.h" #include "PixFe/PixFeData.h" #include "PixFe/PixFeStructures.h" #include "PixFe/PixFeI1.h" #include "PixFe/PixFeI2.h" #include "PixFe/PixFeI4A.h" #include "PixFe/PixFeI4B.h" #include "PixController/PixController.h" #include "PixController/RodPixController.h" #include "PixConfDBInterface/PixConfDBInterface.h" #include "Config/Config.h" #include "PixModule/PixModule.h" #include using namespace SctPixelRod; using namespace PixLib; PixModule::PixModule(DBInquire *dbInquire, PixModuleGroup *modGrp, std::string name) : m_name(name), m_group(modGrp), m_inputLink(0), m_outputLink1(1), m_outputLink2(1), m_outputLink3(1), m_outputLink4(1), m_delay(750), m_latency(200), m_outputBandwidth(0) { // Create the Config object stringstream configName; configName< tf; tf["FALSE"] = 0; tf["TRUE"] = 1; std::map mccfl; mccfl["MCC_I1"] = MCC_I1; mccfl["MCC_I2"] = MCC_I2; mccfl["NONE"] = NO_MCC; std::map fefl; fefl["FE_I1"] = FE_I1; fefl["FE_I2"] = FE_I2; fefl["FE_I4A"] = FE_I4A; fefl["FE_I4B"] = FE_I4B; // Group general conf.addGroup("general"); conf["general"].addInt("ModuleId", m_moduleId, 0, "Module Identifier", true); conf["general"].addInt("GroupId", m_groupId, 0, "Group Identifier", true); conf["general"].addList("Active", m_active, 1, tf, "Module active", true); conf["general"].addList("Present", m_present, 1,tf, "Module present", true); conf["general"].addInt("InputLink", m_inputLink, 0, "DCI link", true); conf["general"].addInt("OutputLink1", m_outputLink1, 0, "DTO link 1", true); conf["general"].addInt("OutputLink2", m_outputLink2, 0, "DTO link 2", true); conf["general"].addInt("OutputLink3", m_outputLink3, 0, "DTO link 3", true); conf["general"].addInt("OutputLink4", m_outputLink4, 0, "DTO link 4", true); conf["general"].addInt("BocInputLink", m_bocInputLink, -1, "BOC DCI link", true); conf["general"].addInt("BocOutputLink1", m_bocOutputLink1, -1, "BOC DTO link 1", true); conf["general"].addInt("BocOutputLink2", m_bocOutputLink2, -1, "DTO link 2", true); conf["general"].addList("MCC_Flavour", m_mccFlavour, NO_MCC, mccfl, "MCC Flavour", true); conf["general"].addList("FE_Flavour", m_feFlavour, FE_I4A, fefl, "FE Flavour", true); std::map geomTyp; geomTyp["unknown"] = NONE; geomTyp["Stave"] = STAVE; geomTyp["Sector"] = SECTOR; // Group general conf.addGroup("geometry"); conf["geometry"].addList("Type", (int &)m_geomType, NONE, geomTyp, "Geometry type", true); conf["geometry"].addInt("position", m_geomPosition, 0, "Module position in assembly", true); conf["geometry"].addInt("staveID", m_geomAssemblyId, 0, "Assembly identifier", true); std::map pp0Typ; pp0Typ["Optical"] = OPTICAL; pp0Typ["Optical_Test"] = OPTICAL_TEST; pp0Typ["Electrical"] = ELECTRICAL; pp0Typ["USB"] = USB; // Group general conf.addGroup("pp0"); conf["pp0"].addList("Type", (int &)m_pp0Type, OPTICAL, pp0Typ, "PP0 type", true); conf["pp0"].addInt("position", m_pp0Position, 1, "PP0 position", true); conf.reset(); conf.read(dbInquire); m_mcc = 0; for(recordIterator it = dbInquire->recordBegin(); it != dbInquire->recordEnd(); it++){ // Look for MCC inquire if((*it)->getName() == "PixMcc") { // Read MCC derived class fieldIterator f = (*it)->findField("ClassInfo_ClassName"); if(f!=(*it)->fieldEnd()) { std::string className; bool stat = dbInquire->getDB()->DBProcess(f, READ, className); if(stat) { // Switch between different MCC derived classes if(className == "PixMccI1") { m_mcc = new PixMccI1(*it, this, "MCC"); conf.addConfig(&(m_mcc->config())); } if(className == "PixMccI2") { m_mcc = new PixMccI2(*it, this, "MCC"); conf.addConfig(&(m_mcc->config())); } } } } // Look for FE inquires if((*it)->getName() == "PixFe"){ std::stringstream o((*it)->getDecName().substr((*it)->getDecName().rfind("_")+1,2)); int a; o >> a; // Read FE derived class fieldIterator f = (*it)->findField("ClassInfo_ClassName"); if(f!=(*it)->fieldEnd()) { std::string className; bool stat = dbInquire->getDB()->DBProcess(f, READ, className); if(stat) { // Switch between different FE derived classes if(className == "PixFeI1") { m_fe.push_back(new PixFeI1(*it, this,(*it)->getDecName(),a)); conf.addConfig(&(m_fe.back()->config())); } if(className == "PixFeI2") { m_fe.push_back(new PixFeI2(*it, this,(*it)->getDecName(),a)); conf.addConfig(&(m_fe.back()->config())); } if(className == "PixFeI4A" || className == "PixFeI4") { // keep PixFeI4 for backw. compat. m_fe.push_back(new PixFeI4A(*it, this,(*it)->getDecName(),a)); conf.addConfig(&(m_fe.back()->config())); if(className == "PixFeI4") m_feFlavour = FE_I4A; // needed for backw. compat. } if(className == "PixFeI4B") { m_fe.push_back(new PixFeI4B(*it, this,(*it)->getDecName(),a)); conf.addConfig(&(m_fe.back()->config())); } } } } } } PixModule::~PixModule() { // Delete MCC delete m_mcc; // Delete FEs for(std::vector::iterator fe = m_fe.begin(); fe != m_fe.end(); fe++) delete *fe; } void PixModule::loadConfig(std::string name) { // Load configuration data into child MCC if(m_mcc!=0) m_mcc->loadConfig(name); // Load configuration data into child FEs for(std::vector::iterator fe = m_fe.begin(); fe != m_fe.end(); fe++) (*fe)->loadConfig(name); } void PixModule::saveConfig(std::string name) { // Save configuration data from child MCC if(m_mcc!=0) m_mcc->saveConfig(name); // Save configuration data from child FEs for(std::vector::iterator fe = m_fe.begin(); fe != m_fe.end(); fe++) (*fe)->saveConfig(name); } void PixModule::storeConfig(std::string name) { // Store configuration data into child MCC if(m_mcc!=0) m_mcc->storeConfig(name); // Store configuration data into child FEs for(std::vector::iterator fe = m_fe.begin(); fe != m_fe.end(); fe++) (*fe)->storeConfig(name); } bool PixModule::restoreConfig(std::string name) { bool ret = true; // Restore configuration data into child MCC if (m_mcc!=0 && !m_mcc->restoreConfig(name)) ret = false; // Restore configuration data into child FEs for(std::vector::iterator fe = m_fe.begin(); fe != m_fe.end(); fe++) { if (!(*fe)->restoreConfig(name)) ret = false; } return ret; } void PixModule::deleteConfig(std::string name) { // Delete configuration data into child MCC if(m_mcc!=0) m_mcc->deleteConfig(name); // Delete configuration data into child FEs for(std::vector::iterator fe = m_fe.begin(); fe != m_fe.end(); fe++) (*fe)->deleteConfig(name); } void PixModule::writeConfig() { // Create a Module structure // PixelModule *modConfig = new PixelModule; static PixelModule modConfig; if(m_mcc!=0) m_mcc->fillConfig(&modConfig); for(int i=0;i::iterator fe = m_fe.begin(); fe != m_fe.end(); fe++) (*fe)->fillConfig(&modConfig); strncpy(modConfig.idStr, m_name.c_str(), 128); modConfig.active = m_active; modConfig.groupId = m_groupId; modConfig.pTTC = m_inputLink; modConfig.rx = m_outputLink1; modConfig.mccFlavour = m_mccFlavour; modConfig.feFlavour = m_feFlavour; // Write the configuration in the ROD structure m_group->getPixController()->writeModuleConfig(m_moduleId, modConfig); // delete modConfig; } void PixModule::setConfig(int structId, int moduleNum) { } PixFe* PixModule::pixFE(int nFE) { if(nFE>=0 && nFE<(int)m_fe.size()) return m_fe[nFE]; else return 0; } void PixModule::reset(int type){ if(pixMCC()!=0){ if(type!=0){ // not implemented } else{ pixMCC()->globalResetFE(31); pixMCC()->globalResetMCC(); } } else { Bits commandA(10, PIX_FE_SOFT_RESET); // calls FE global reset Bits commandB(10, PIX_MC_SYNC); // sets 3 hard reset lines ON Bits commandC(10, PIX_FE_REF_RESET); // sets 3 hard reset lines OFF Bits commandD(10, PIX_FE_EC_RESET); // calls fast command ECR Bits commandE(10, PIX_FE_BC_RESET); // calls fast command BCR int moduleMask = (0x1<getPixController()->sendCommand(commandA, moduleMask); break; case 1: m_group->getPixController()->sendCommand(commandB, moduleMask); sleep(100); // check length m_group->getPixController()->sendCommand(commandC, moduleMask); break; case 2: m_group->getPixController()->sendCommand(commandB, moduleMask); break; case 3: m_group->getPixController()->sendCommand(commandC, moduleMask); break; case 4: m_group->getPixController()->sendCommand(commandD, moduleMask); break; case 5: m_group->getPixController()->sendCommand(commandE, moduleMask); break; } } }