#include "PrimListItem.h" #include "ChipTest.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include PrlToolSubcfg::PrlToolSubcfg(DBInquire *, Config &cfg_in) : m_config(cfg_in){ } PrlToolSubFEGR::PrlToolSubFEGR(DBInquire *inq, Config &cfg_in) : PrlToolSubcfg(inq, cfg_in){ setupGenConfig(); if(inq!=0) m_config.read(inq); } PrlToolSubFEGR::~PrlToolSubFEGR(){} void PrlToolSubFEGR::setupGenConfig(){ std::map regmap; PixFeI4AConfig fecfga(0,0, "tmpfe", 0); PixFeI4BConfig fecfgb(0,0, "tmpfe", 0); ConfGroup &grgrpa = fecfga.config().subConfig("GlobalRegister_0/GlobalRegister")["GlobalRegister"]; for(int i=0;i regmap; PixFeI4AConfig fecfg(0,0, "tmpfe", 0); // pixel registers are identical in I4A and I4B, so doesn't matter which is used Config &cfg = fecfg.config(); ConfGroup &grgrp = cfg.subConfig("PixelRegister_0/PixelRegister")["PixelRegister"]; for(int i=0;i setmap; setmap["voltage"] = 0; setmap["currentlim"] = 1; m_config.addGroup("arguments"); m_config["arguments"].addString("dcsName", m_dcsName, "VDDD", "Full name of DCS channel", true); m_config["arguments"].addList("dcsSetType", m_dcsSetType, 0, setmap, "Type of setting to be done", true); m_config["arguments"].addFloat("setVal", m_setVal, 0., "Value to be set on channel/device", true); m_config["arguments"].reset(); } PrlToolSubGetDcs::PrlToolSubGetDcs(DBInquire *inq, Config &cfg_in) : PrlToolSubcfg(inq, cfg_in){ setupGenConfig(); if(inq!=0) m_config.read(inq); } PrlToolSubGetDcs::~PrlToolSubGetDcs(){} void PrlToolSubGetDcs::setupGenConfig(){ std::map setmap; setmap["voltage"] = 0; setmap["current"] = 1; m_config.addGroup("arguments"); m_config["arguments"].addString("dcsName", m_dcsName, "VDDD", "Full name of DCS channel", true); m_config["arguments"].addList("dcsGetType", m_dcsGetType, 0, setmap, "Type of reading to be done", true); m_config["arguments"].addString("storeName", m_storeName, "VDDD_READ 0", "Name of data field into which to write result", true); m_config["arguments"].addFloat("minCut", m_minCut, -9999999999.f, "If read value is below this, the \"skip rest of list\"-flag is raised", true); m_config["arguments"].addFloat("maxCut", m_maxCut, 9999999999.f, "If read value is above this, the \"skip rest of list\"-flag is raised", true); m_config["arguments"].reset(); } PrlToolSubSendDcsCmd::PrlToolSubSendDcsCmd(DBInquire *inq, Config &cfg_in) : PrlToolSubcfg(inq, cfg_in){ setupGenConfig(); if(inq!=0) m_config.read(inq); } PrlToolSubSendDcsCmd::~PrlToolSubSendDcsCmd(){ } void PrlToolSubSendDcsCmd::setupGenConfig(){ m_config.addGroup("arguments"); m_config["arguments"].addString("dcsName", m_dcsName, "none", "Full name of DCS device", true); m_config["arguments"].addString("dcsCmd", m_command, "*IDN?", "Command string to be sent to device", true); m_config["arguments"].addBool("readResponse", m_readResp, false, "Read response from DCS device after command was sent", true); m_config["arguments"].reset(); } PrlToolSubFitScan::PrlToolSubFitScan(DBInquire *inq, Config &cfg_in) : PrlToolSubcfg(inq, cfg_in){ setupGenConfig(); if(inq!=0) m_config.read(inq); } PrlToolSubFitScan::~PrlToolSubFitScan(){} void PrlToolSubFitScan::setupGenConfig(){ FitClass fc; std::map funcmap; for(int i=0;i<999;i++){ std::string fname = fc.getFuncTitle(i); if(fname=="") break; funcmap[fname] = i; } funcmap["FEI3 CapMeasure"]; PixLib::PixScan ps; //std::map histoMap = ps.getHistoTypes(); std::map storeMap; storeMap["not stored"] = 0; storeMap["VCAL parameters"] = 1; storeMap["FE-I3 injection capacitances"] = 2; storeMap["CAP0"] = 3; storeMap["CAP1"] = 4; storeMap["CAP0+CAP1"] = 5; storeMap["all CAPx"] = 6; m_fitParPreset.push_back(1.6f); m_fitParPreset.push_back(-0.0009f); m_config.addGroup("arguments"); m_config["arguments"].addString("scanName", m_scanName, "unknown", "Label of scan of which a hist/graph should be fitted", true); m_config["arguments"].addList("funcType", m_funcType, 0, funcmap, "Function to be fitted", true); m_config["arguments"].addList("histoType", m_histoType, 0, ps.getHistoTypes(), "Histogram/graph to be fitted", true); m_config["arguments"].addVector("fitParPreset", m_fitParPreset, m_fitParPreset, "Initial guesses of fit parameters", true); m_config["arguments"].addFloat("fitRangeMin", m_fitRgMin, 0., "Lower limit of fit rage; min=max=0. -> no limit", true); m_config["arguments"].addFloat("fitRangeMax", m_fitRgMax, 0., "Upper limit of fit rage; min=max=0. -> no limit", true); m_config["arguments"].addList("storeType", m_storeType, 0, storeMap, "Write the fit parameters to FE config?", true); m_config["arguments"].addFloat("offset", m_offset, 0., "Offset to add to stored val (only CAP0, CAP1)", true); m_config["arguments"].addFloat("conversion", m_conversion, 1., "Conversion of grad to stored val (only CAP0, CAP1)", true); m_config["arguments"].reset(); } PrlToolSubAnaGraph::PrlToolSubAnaGraph(DBInquire *inq, Config &cfg_in) : PrlToolSubcfg(inq, cfg_in){ setupGenConfig(); if(inq!=0) m_config.read(inq); } PrlToolSubAnaGraph::~PrlToolSubAnaGraph(){ } void PrlToolSubAnaGraph::setupGenConfig(){ // prepare lists/default arg's std::map storemap; storemap["scanned register"] = 1; storemap["file"] = 2; std::map anamap; anamap["Find best match"] = 1; m_anaArgs.push_back(0.); m_config.addGroup("arguments"); m_config["arguments"].addString("scanName", m_scanName, "unknown", "Label of scan of which a hist/graph should be fitted", true); m_config["arguments"].addList("anaAction", m_anaAction, 0, anamap, "Analysis action to be used", true); m_config["arguments"].addVector("anaArgs", m_anaArgs, m_anaArgs, "List of arguments (e.g. target values)", true); m_config["arguments"].addList("storeType", m_storeType, 0, storemap, "Write analysis result to ...", true); m_config["arguments"].reset(); } PrlToolSubWait::PrlToolSubWait(DBInquire *inq, Config &cfg_in) : PrlToolSubcfg(inq, cfg_in){ setupGenConfig(); if(inq!=0) m_config.read(inq); } PrlToolSubWait::~PrlToolSubWait(){} void PrlToolSubWait::setupGenConfig(){ int type = ((ConfInt&)m_config["specific"]["toolType"]).value(); m_config.addGroup("arguments"); m_config["arguments"].addInt("waitTime", m_waitTime, 1, (type==PrimListItem::GEN_WAIT)?"time in min. to wait":"time in msec. to wait", true); m_config["arguments"].reset(); } PrlToolSubWaitForSignal::PrlToolSubWaitForSignal(DBInquire *inq, Config &cfg_in) : PrlToolSubcfg(inq, cfg_in){ setupGenConfig(); if(inq!=0) m_config.read(inq); } PrlToolSubWaitForSignal::~PrlToolSubWaitForSignal(){} void PrlToolSubWaitForSignal::setupGenConfig(){ std::map channelMap, logicMap; channelMap["RX0"] = 0; channelMap["RX1"] = 1; channelMap["RX2"] = 2; channelMap["EXT_TRG"] = 3; logicMap["OR"] = 0; logicMap["AND"] = 1; m_config.addGroup("arguments"); m_config["arguments"].addList("channel", m_waitChannel, 0, channelMap, "USBPix-channel from which to read", true); m_config["arguments"].addList("combination", m_ctrlCombi, 0, logicMap, "Logical combination if more than 1 USBPix system", true); m_config["arguments"].addBool("waitOnOne", m_waitOnOne, true, "Wait if signal is high if true, low if false", true); m_config["arguments"].reset(); } PrlToolSubConfigureMods::PrlToolSubConfigureMods(DBInquire *inq, Config &cfg_in) : PrlToolSubcfg(inq, cfg_in){ setupGenConfig(); if(inq!=0) m_config.read(inq); } PrlToolSubConfigureMods::~PrlToolSubConfigureMods(){} void PrlToolSubConfigureMods::setupGenConfig(){ std::map cfgTypeList; cfgTypeList["ALL"] = 0; cfgTypeList["GR only"] = 1; cfgTypeList["PR only"] = 2; std::map typeMap; typeMap["current configuration"] = ChipTest::CURRENTCFG; typeMap["all 0's"] = ChipTest::ALLZERO; typeMap["all 1's"] = ChipTest::ALLONE; typeMap["odd rows 1"] = ChipTest::ALLODD; typeMap["even rows 1"] = ChipTest::ALLEVEN; typeMap["all 1's part A"] = ChipTest::ALLONE_A; typeMap["all 1's part B"] = ChipTest::ALLONE_B; typeMap["all 1's part C"] = ChipTest::ALLONE_C; typeMap["all 1's part D"] = ChipTest::ALLONE_D; typeMap["all 1's part E"] = ChipTest::ALLONE_E; typeMap["all 1's part F"] = ChipTest::ALLONE_F; typeMap["random"] = ChipTest::RANDOM; std::map pixNames; pixNames["ALL"] = 0; PixFeI4A fe(0,0,"DummyFE",0); // pixel registers are identical in I4A and I4B, so doesn't matter which is used Config &feconf = fe.config(); ConfGroup &trimgrp = feconf.subConfig("Trim_0/Trim")["Trim"]; ConfGroup &maskgrp = feconf.subConfig("PixelRegister_0/PixelRegister")["PixelRegister"]; for(int i=0;i<(int)maskgrp.size();i++){ std::string prname = maskgrp[i].name(); prname.erase(0,std::string("PixelRegister_").length()); pixNames[prname] = i+1; } // trim registers: >1 bit, must add bit index to name int maxval, nmask=pixNames.size()+1; for(int i=0;i<(int)trimgrp.size();i++){ std::string prname = trimgrp[i].name(); prname.erase(0,std::string("Trim_").length()); if(!fe.getTrimMax(prname,maxval)) maxval=0; maxval = (int)TMath::Log2((double)(maxval+1)); for(int j=0;j typeMap; typeMap["Conf. mode"] = 0; typeMap["Run mode"] = 1; m_config["arguments"].addList("mode", m_mode, 0, typeMap, "Set FE operation mode", true); m_config["arguments"].reset(); } PrlToolSubLoadCfg::PrlToolSubLoadCfg(DBInquire *inq, Config &cfg_in) : PrlToolSubcfg(inq, cfg_in){ setupGenConfig(); if(inq!=0) m_config.read(inq); } PrlToolSubLoadCfg::~PrlToolSubLoadCfg(){} void PrlToolSubLoadCfg::setupGenConfig(){ m_config.addGroup("arguments"); m_config["arguments"].addString("fileName", m_fname, "", "Path to config file to be loaded", true); m_config["arguments"].reset(); } PrlToolSubLoadModCfg::PrlToolSubLoadModCfg(DBInquire *inq, Config &cfg_in) : PrlToolSubcfg(inq, cfg_in){ setupGenConfig(); if(inq!=0) m_config.read(inq); } PrlToolSubLoadModCfg::~PrlToolSubLoadModCfg(){} void PrlToolSubLoadModCfg::setupGenConfig(){ m_config.addGroup("arguments"); m_config["arguments"].addBool("SetChipSN", m_setChipSN, true, "Set Chip SN from wafer probing info after reloading cfg.", true); m_config["arguments"].addInt("Chip_SN", m_chipSN, -1, "Chip Serial Number (to be set externally)", false); m_config["arguments"].reset(); } PrlToolSubResetMods::PrlToolSubResetMods(DBInquire *inq, Config &cfg_in) : PrlToolSubcfg(inq, cfg_in){ setupGenConfig(); if(inq!=0) m_config.read(inq); m_config["arguments"].reset(); } PrlToolSubResetMods::~PrlToolSubResetMods(){} void PrlToolSubResetMods::setupGenConfig(){ m_config.addGroup("arguments"); std::map typeMap; typeMap["soft global reset"] = 0; typeMap["hard reset (pulse)"] = 1; typeMap["hard reset (static ON)"] = 2; typeMap["hard reset (static OFF)"] = 3; typeMap["event counter reset"] = 4; typeMap["bunch counter reset"] = 5; m_config["arguments"].addList("resetType", m_resetType, 1, typeMap, "Type of reset to be sent", true); m_config["arguments"].reset(); } PrimListItem::PrimListItem(PrimListTypes type, int index, const char *label, PixScan *in_ps) : m_type((int)type), m_index(index) { m_label=label; m_subCfg = 0; m_scanLabel = ""; m_subType = -1; setupGenConfig(); setupSpecConfig(in_ps); m_scanLabel = m_label; setupSubcfg(0); } PrimListItem::PrimListItem(DBInquire *inq) { m_index = 0; m_type = (int)DEF_SCAN; m_label=""; m_scanLabel = ""; m_subType = -1; m_subCfg = 0; setupGenConfig(); m_config->read(inq); setupSpecConfig(); m_config->read(inq); setupSubcfg(inq); m_config->read(inq); } PrimListItem::PrimListItem(PrimListItem &inItem, int index) : m_type(inItem.m_type), m_index(index), m_label("Copy of "+inItem.m_label), m_scanLabel(inItem.m_scanLabel), m_subType(inItem.m_subType){ m_subCfg = 0; setupGenConfig(); *m_config = inItem.config(); setupSpecConfig(inItem.m_ps, false); *m_config = inItem.config(); setupSubcfg(0); *m_config = inItem.config(); m_label = "Copy of "+inItem.m_label; m_index = index; } PrimListItem::~PrimListItem() { delete m_config; delete m_ps; delete m_subCfg; } std::string PrimListItem::getTypeLabel(PrimListTypes type) { const std::string dummy="none"; for(std::map::iterator it=m_typeDef.begin(); it!=m_typeDef.end(); it++){ if(it->second==(int)type) return it->first; } return dummy; } std::string PrimListItem::getToolLabel(PrimListTools type) { const std::string dummy="none"; for(std::map::iterator it=m_prlTools.begin(); it!=m_prlTools.end(); it++){ if(it->second==(int)type) return it->first; } return dummy; } void PrimListItem::setupGenConfig(bool doreset) { m_typeDef["default PixScan"] = DEF_SCAN; m_typeDef["custom PixScan"] = CUST_SCAN; m_typeDef["chip test"] = CHIP_TEST; m_typeDef["tool"] = TOOL; // fill list of primlist tools m_prlTools["init. controller"] = INIT_ROD; m_prlTools["initialise DCS"] = INIT_DCS; m_prlTools["reset modules"] = RESET_MODS; m_prlTools["configure modules"] = CFG_MODS; m_prlTools["set VCAL from Q"] = SET_VCAL; m_prlTools["link test"] = LINK_CHECK; m_prlTools["disable failed"] = DISABLE_FAILED; m_prlTools["reload entire cfg."] = RELOAD_CFG; m_prlTools["load cfg. from file"] = LOAD_NEW_CFG; m_prlTools["set FE globreg"] = SET_FE_GR; m_prlTools["set FE pixreg"] = SET_FE_PR; m_prlTools["turn on/off supply"] = DCS_PWR; m_prlTools["set DCS value"] = DCS_SET; m_prlTools["get DCS value"] = DCS_GET; m_prlTools["get time stamp"] = GET_TIME; m_prlTools["fit scan result"] = FIT_SCAN; m_prlTools["analyse scan graph"] = ANA_GRAPH; m_prlTools["wait (minutes)"] = GEN_WAIT; m_prlTools["wait (msec)"] = GEN_WAIT_MSEC; m_prlTools["wait for ext. signal"] = SIG_WAIT; m_prlTools["request serv. rec's"] = GET_SRVREC; m_prlTools["save config to file"] = SAVE_CFG; m_prlTools["reload module cfg."] = LOAD_MOD_CFG; m_prlTools["set FE oper. mode"] = SET_FE_MODE; m_prlTools["send cmd. to DCS device"] = SEND_DCS_CMD; m_prlTools["send global pulse: Read EPROM"] = RD_EPROM; m_prlTools["burn GR values to EPROM"] = BURN_EPROM; m_abortIfError = false; m_config = new Config("prlcfg"); Config &conf = *m_config; conf.addGroup("general"); // conf["general"].addList("type", (int)m_type, (int)m_type, m_typeDef, "type of action of primlist item", false); conf["general"].addList("type", m_type, m_type, m_typeDef, "type of action of primlist item", false); conf["general"].addInt("index", m_index, m_index, "index of item in primlist", false); conf["general"].addBool("abortIfError", m_abortIfError, false, "abort execution of primlist if this item caused an error", true); conf["general"].addBool("executeIfSkip", m_executeIfSkip, false, "Still execute this item if a previous tool indicates to skip rest of list", true); conf["general"].addString("label", m_label, m_label, "label of action as shown in the list", true); if(doreset) conf.reset(); if(doreset) { m_subType = -1; m_ps = 0; m_ct = 0; } return; } void PrimListItem::setupSpecConfig(PixScan *in_ps, bool doreset) { Config &conf = *m_config; StdTestWin stdwin(0,"Load Std Files", TRUE, Qt::WType_TopLevel); stdwin.TestTypeSel->setCurrentItem(11); // set to "SYST" stdwin.TypeSet(); switch(m_type){ case DEF_SCAN:{ conf.addGroup("specific"); // create temporary PixScan object to get list of scan types m_ps = new PixScan(PixScan::DIGITAL_TEST); m_scanTypes = m_ps->getScanTypes(); delete m_ps; m_ps=0; conf["specific"].addList("scanType", m_subType, PixScan::DIGITAL_TEST, m_scanTypes, "PixScan default config type", true); conf["specific"].addString("scanLabel", m_scanLabel, "Primlist Scan 0", "Label used for storing scan result in file", true); // NB: must be identical to options in PixScanPanel - better use common def. via engine? std::map readDcsOpts; readDcsOpts["never"] = 0; readDcsOpts["after start"] = 1; conf["specific"].addList("readDCS", m_readDcs, 0, readDcsOpts, "Type of DCS readings during scan", true); if(doreset) conf["specific"].reset(); m_scanStdTypes.insert(std::make_pair("none",-1)); for(int j=0;jm_defname.latin1(); m_scanStdTypes.insert(std::make_pair(label, j)); } break;} case CUST_SCAN:{ conf.addGroup("specific"); conf["specific"].addString("scanLabel", m_scanLabel, "Primlist Scan 0", "Label used for storing scan result in file", true); // NB: must be identical to options in PixScanPanel - better use common def. via engine? std::map readDcsOpts; readDcsOpts["never"] = 0; readDcsOpts["after start"] = 1; conf["specific"].addList("readDCS", m_readDcs, 0, readDcsOpts, "Type of DCS readings during scan", true); if(doreset) conf["specific"].reset(); m_scanStdTypes.insert(std::make_pair("none",-1)); for(int j=0;jm_defname.latin1(); m_scanStdTypes.insert(std::make_pair(label, j)); } if(in_ps==0) m_ps = new PixScan(PixScan::DIGITAL_TEST); else m_ps = new PixScan(*in_ps); // needed to find this sub-config in a DB file later m_ps->config().m_confName = "ScanConfig/ScanConfig"; //m_ps->config().name("ScanConfig"); //m_ps->config().type("ScanConfig"); conf.addConfig(&(m_ps->config())); break;} case TOOL: conf.addGroup("specific"); conf["specific"].addList("toolType", m_subType, INIT_ROD, m_prlTools, "tool action type", true); if(doreset) conf["specific"].reset(); break; case CHIP_TEST:{ conf.addGroup("specific"); ChipTest ctdummy(ChipTest::CTDUMMY); std::map types = ctdummy.getTypeList(); conf["specific"].addList("chipTestType", m_subType, ChipTest::GLOBALREG, ctdummy.getTypeList(), "type of chip test", true); conf["specific"].addBool("raiseSkipIfFailed", m_raiseSkipIfFailed, true, "Raise flag to skip remaining primitive list items if test fails", true); if(doreset) conf["specific"].reset(); break;} default: break; } return; } void PrimListItem::setupSubcfg(DBInquire *inq){ if(m_type!=(int)TOOL && m_type!=(int)CHIP_TEST) return; // only valid for tools and chip tests Config *oldcfg = m_config; PixScan *oldps = m_ps; if(m_ct!=0) m_config->m_config.clear(); setupGenConfig(false); (*oldcfg)["general"].copy((*m_config)["general"]); setupSpecConfig(oldps, false); (*oldcfg)["specific"].copy((*m_config)["specific"]); delete m_subCfg; delete m_ct; m_ct=0; delete oldps; delete oldcfg; if(m_type==(int)TOOL){ switch(m_subType){ case SET_VCAL: m_subCfg = new PrlToolSubVcal(inq, *m_config); break; case SET_FE_GR: m_subCfg = new PrlToolSubFEGR(inq, *m_config); break; case SET_FE_PR: m_subCfg = new PrlToolSubFEPR(inq, *m_config); break; case DCS_PWR: m_subCfg = new PrlToolSubPwr(inq, *m_config); break; case DCS_SET: m_subCfg = new PrlToolSubSetDcs(inq, *m_config); break; case DCS_GET: m_subCfg = new PrlToolSubGetDcs(inq, *m_config); break; case FIT_SCAN: m_subCfg = new PrlToolSubFitScan(inq, *m_config); break; case ANA_GRAPH: m_subCfg = new PrlToolSubAnaGraph(inq, *m_config); break; case GEN_WAIT: case GEN_WAIT_MSEC: m_subCfg = new PrlToolSubWait(inq, *m_config); break; case SIG_WAIT: m_subCfg = new PrlToolSubWaitForSignal(inq, *m_config); break; case CFG_MODS: m_subCfg = new PrlToolSubConfigureMods(inq, *m_config); break; case SAVE_CFG: m_subCfg = new PrlToolSubSaveCfg(inq, *m_config); break; case SET_FE_MODE: m_subCfg = new PrlToolSubSetFeMode(inq, *m_config); break; case LOAD_NEW_CFG: m_subCfg = new PrlToolSubLoadCfg(inq, *m_config); break; case RESET_MODS: m_subCfg = new PrlToolSubResetMods(inq, *m_config); break; case SEND_DCS_CMD: m_subCfg = new PrlToolSubSendDcsCmd(inq, *m_config); break; case LOAD_MOD_CFG: m_subCfg = new PrlToolSubLoadModCfg(inq, *m_config); break; default: // any other type: no argument m_subCfg=0; } } else{ m_ct = ChipTest::make((ChipTest::chipTestType) m_subType); // needed to find this in a DB file later m_ct->config().m_confName = "ChipTest/ChipTest"; m_config->addConfig(&(m_ct->config())); } }