def getCalDataFromDB(self, testbed): CalConfig.tempSqlObject = {} res = database.check_testbed(testbed) if(not res): self.info("Testbed:%s does not exist in database" % (testbed)) self.info("Creating testbed:%s and populating the testbed" " constants in the database"% testbed) result = self.createTestbed(testbed) if(not result): self.failed("Not able to create the testbed in database") return False else: self.info("Testbed:%s already exists in database" % (testbed)) #P1_1 Cal Constants EdfaOut Vs Tx CalConfig.outCal_switchModule = database.get_constant_value(testbed,"outCal_switchModule").ConstantValue CalConfig.outCal_switchSubMod = eval(database.get_constant_value(testbed,"outCal_switch_subModule").ConstantValue) CalConfig.outCal_switchPosition['edfaOut'] = eval(database.get_constant_value(testbed,"outCal_switchPos_edfaOut").ConstantValue) CalConfig.outCal_switchPosition['uutTx' ] = eval(database.get_constant_value(testbed,"outCal_switchPos_uutTx").ConstantValue) #P1_2 Cal Constants DemodOut1 Vs DemodOut2 #CalConfig.pdPad_switchModule = database.get_constant_value(testbed,"pdPad_switchModule").ConstantValue #CalConfig.pdPad_switchSubMod = eval(database.get_constant_value(testbed,"pdPad_switch_subModule").ConstantValue) #CalConfig.pdPad_switchPosition['dmodOut1'] = eval(database.get_constant_value(testbed,"pdPad_switchPos_dmodOut1").ConstantValue) #CalConfig.pdPad_switchPosition['dmodOut2'] = eval(database.get_constant_value(testbed,"pdPad_switchPos_dmodOut2").ConstantValue) for const in CalConfig.constLst: print "debug:", const CalConfig.tempSqlObject[const] = database.get_constant_value(testbed,const) CalConfig.voaAttn_zerodBm_for_pMeter_Prev = float(CalConfig.tempSqlObject['voaAttn_zerodBm_for_pMeter'].ConstantValue) CalConfig.dicon_sw1_pwrReading_Prev = float(CalConfig.tempSqlObject['dicon_sw1_pwrReading'].ConstantValue) CalConfig.dicon_sw2_pwrReading_Prev = float(CalConfig.tempSqlObject['dicon_sw2_pwrReading'].ConstantValue) CalConfig.dicon_sw3_pwrReading_Prev = float(CalConfig.tempSqlObject['dicon_sw3_pwrReading'].ConstantValue) CalConfig.dicon_sw4_pwrReading_Prev = float(CalConfig.tempSqlObject['dicon_sw4_pwrReading'].ConstantValue) CalConfig.outCal_inputPwr_forCalibration_Prev = float(CalConfig.tempSqlObject['outCal_inputPwr_forCalibration'].ConstantValue) CalConfig.outCal_sw1_pwrReading_Prev = float(CalConfig.tempSqlObject['outCal_sw1_pwrReading'].ConstantValue) CalConfig.outCal_sw2_pwrReading_Prev = float(CalConfig.tempSqlObject['outCal_sw2_pwrReading'].ConstantValue) #CalConfig.inputPwr_pdSwitchCal_Prev = float(CalConfig.tempSqlObject['inputPwr_pdSwitchCal'].ConstantValue) #CalConfig.pdCal_sw1_pwrReading_Prev = float(CalConfig.tempSqlObject['pdCal_sw1_pwrReading'].ConstantValue) #CalConfig.pdCal_sw2_pwrReading_Prev = float(CalConfig.tempSqlObject['pdCal_sw2_pwrReading'].ConstantValue) return True
def getCalDataFromDB(self, testbed): CalConfig.pdPad_switchModule = database.get_constant_value(testbed,"pdPad_switchModule").ConstantValue CalConfig.pdPad_switchSubMod = eval(database.get_constant_value(testbed,"pdPad_switch_subModule").ConstantValue) CalConfig.pdPad_switchPosition['dmodOut1'] = eval(database.get_constant_value(testbed,"pdPad_switchPos_dmodOut1").ConstantValue) CalConfig.pdPad_switchPosition['dmodOut2'] = eval(database.get_constant_value(testbed,"pdPad_switchPos_dmodOut2").ConstantValue) CalConfig.inPwr_pdSwitchLossCal = round(eval(database.get_constant_value(testbed, "inputPwr_pdSwitchCal").ConstantValue),2) CalConfig.pwrRead_sw1 = round(eval(database.get_constant_value(testbed, "pdCal_sw1_pwrReading").ConstantValue),2) CalConfig.pwrRead_sw2 = round(eval(database.get_constant_value(testbed, "pdCal_sw2_pwrReading").ConstantValue),2) CalConfig.pdCal_switchILoss['dmodOut1'] = CalConfig.inPwr_pdSwitchLossCal - CalConfig.pwrRead_sw1 CalConfig.pdCal_switchILoss['dmodOut2'] = CalConfig.inPwr_pdSwitchLossCal - CalConfig.pwrRead_sw2
def getCalDataFromDB(self, testbed): #4 # based on the pwr reading of uut_tx switch port and where # the pwr meter is connected, compute the pwr adjustment # for the uut_tx CalConfig.outCal_switchModule = database.get_constant_value(testbed,"outCal_switchModule").ConstantValue CalConfig.outCal_switchSubMod = eval(database.get_constant_value(testbed,"outCal_switch_subModule").ConstantValue) CalConfig.outCal_switchPosition['edfaOut'] = eval(database.get_constant_value(testbed,"outCal_switchPos_edfaOut").ConstantValue) CalConfig.outCal_switchPosition['uutTx'] = eval(database.get_constant_value(testbed,"outCal_switchPos_uutTx").ConstantValue) # sw1 - edfa # sw2 - uutTx CalConfig.inPwr_switchLossCal = round(eval(database.get_constant_value(testbed, "outCal_inputPwr_forCalibration").ConstantValue),2) CalConfig.pwrRead_sw1 = round(eval(database.get_constant_value(testbed, "outCal_sw1_pwrReading").ConstantValue),2) CalConfig.pwrRead_sw2 = round(eval(database.get_constant_value(testbed, "outCal_sw2_pwrReading").ConstantValue),2) CalConfig.outCal_switchILoss['edfaOut'] = CalConfig.inPwr_switchLossCal - CalConfig.pwrRead_sw1 CalConfig.outCal_switchILoss['uutTx'] = CalConfig.inPwr_switchLossCal - CalConfig.pwrRead_sw2
def getCalDataFromDB(self, testbed): CalConfig.switchModule = database.get_constant_value(testbed, "switchModule").ConstantValue CalConfig.org_attnForZerodBm = round(eval(database.get_constant_value(testbed, "voaAttn_zerodBm_for_pMeter").ConstantValue),2) dbSwitchPosLst = ["switchPos_pMeter","switchPos_edfaIn","switchPos_Pd1","switchPos_Pd2"] switchNameMappingLst = ['pMeter', 'edfaIn', 'Pd1', 'Pd2'] # 1 # set up CalConfig switchPosition dictionary for dbConst,scriptConst in zip(dbSwitchPosLst,switchNameMappingLst): res = eval(database.get_constant_value(testbed, dbConst).ConstantValue) CalConfig.switchPosition[scriptConst] = res #print "read back CalConfig.switchPosition[scriptConst]",CalConfig.switchPosition[scriptConst] CalConfig.switchPosition['default'] = CalConfig.switchPosition['pMeter'] #print "read back CalConfig.switchPosition['default'] ", CalConfig.switchPosition['default'] #print "read back CalConfig.switchPosition['Para']", CalConfig.switchPosition['Para'] # 2 # set up CalConfig switch_pwrReading dictionary dbPortPwrLst = ["dicon_sw1_pwrReading","dicon_sw2_pwrReading","dicon_sw3_pwrReading","dicon_sw4_pwrReading"] portLst = [1,2,3,4] for dbConst,port in zip(dbPortPwrLst, portLst): res = eval(database.get_constant_value(testbed, dbConst).ConstantValue) CalConfig.switch_pwrReading[port] = res #print "read back CalConfig.switch_pwrReading[port]" ,CalConfig.switch_pwrReading[port] # 3 # based on the pwr reading of each switch port and where # the pwr meter is connected, compute the pwr adjustment # for each switch port at the output. referencePort = CalConfig.switchPosition['pMeter'] referencePwr = CalConfig.switch_pwrReading[referencePort] for port in portLst: CalConfig.switch_OutAdj[port] = CalConfig.switch_pwrReading[port] - referencePwr #print "read back CalConfig.switch_OutAdj[port] ", CalConfig.switch_OutAdj[port] #4 newly added P1 switch to switch edfaOut or uutTx out to pwrMeter CalConfig.outCal_switchModule = database.get_constant_value(testbed,"outCal_switchModule").ConstantValue CalConfig.outCal_switchSubMod = eval(database.get_constant_value(testbed,"outCal_switch_subModule").ConstantValue) CalConfig.outCal_switchPosition['edfaOut'] = eval(database.get_constant_value(testbed,"outCal_switchPos_edfaOut").ConstantValue) CalConfig.outCal_switchPosition['uutTx'] = eval(database.get_constant_value(testbed,"outCal_switchPos_uutTx").ConstantValue) CalConfig.inPwr_switchLossCal = round(eval(database.get_constant_value(testbed, "outCal_inputPwr_forCalibration").ConstantValue),2) CalConfig.pwrRead_sw1 = round(eval(database.get_constant_value(testbed, "outCal_sw1_pwrReading").ConstantValue),2) CalConfig.pwrRead_sw2 = round(eval(database.get_constant_value(testbed, "outCal_sw2_pwrReading").ConstantValue),2) CalConfig.outCal_switchILoss['edfaOut'] = CalConfig.inPwr_switchLossCal - CalConfig.pwrRead_sw1 CalConfig.outCal_switchILoss['uutTx'] = CalConfig.inPwr_switchLossCal - CalConfig.pwrRead_sw2
if (str1.find('testbedname') > 0): l1 = str1.split('=') testbed = l1[1] #print "Testbed:", testbed res = database.check_testbed(testbed) if(not res): print ("\033[1;33m%s is not a valid testbed\033[m" % testbed) sys.exit(0) #Check the lastupdate date in one of the calibration parameters try: lc = str ( database.get_constant_value(testbed,"voaAttn_zerodBm_for_pMeter").LastUpdate ) except: print ("\033[1;33mUnable to retrieve testbed details from database\033[m") sys.exit(0) #print lc tmpDate = time.strptime(lc,"%Y-%m-%d") lastCalibrated = datetime(tmpDate.tm_year,tmpDate.tm_mon, tmpDate.tm_mday) CalibrationDue = lastCalibrated + timedelta(calibrationInterval) dayDue = CalibrationDue.weekday() if(dayDue == 6): CalibrationDue += timedelta(1) today = datetime.now() print "====================================================="