Esempio n. 1
0
    def initialize(self):
        tb = self.config.testbed
        SCREEN_VERSION = 11
        self.SCREEN_VERSION = SCREEN_VERSION
        # sql databse
        # all dictionaries below are keyed by {uutid: {'j2g': {}, 'm2g': {}, 'g2m': {}}}
        self.widths_avg = {}   # dictionary to story the average width
        self.widths_min = {}   # minimum window width
        self.widths_dist = {}  # window width distribution
        #log file
        self.lf = self.config.logfile
        self.lvdsArgs = {}
        self.errorCount = {}
        # dictionary to store logger and diagnostic related resources.
        self.diag = {}
        self.diag_logger = {}
        self.uut_ser_dict = {}

        # Making uut list
        from copy import copy
        # copy from stratatestrunner.py
        self.uutDict = copy(self.config.uut_dict)
        self.uutSnList = self.uutDict.keys()
        self.info("Number of UUTS TO BE TESTED: %s\n" %len(self.uutSnList))
        self.lf.write("\n\nNumber of UUTS TO BE TESTED: %s\n" % len(self.uutSnList))
        self.info("######## SCREEN VERSION %s ###########" % SCREEN_VERSION) 
        for sn in self.uutSnList:
            self.info("UUT %s INFO: %s : %s\n" 
                %(sn, self.uutDict[sn]["id"], self.uutDict[sn]["slot"]))
            self.lvdsArgs[self.uutDict[sn]["id"]] = {}
            self.errorCount[sn] = 0
            slot = self.uutDict[sn]["slot"]
            uut_slot = int(slot)

            if (self.config.flags.VERBOSE and self.config.flags.DEBUG):
                # we log the mike-debug shell ONLY when -dv are both present
                self.info("Configuring diagnostic resources...")
                basepath = os.path.dirname(self.config.reportpath)
                self.info("Basepath: %s" % basepath)
                UUT_dbg = "UUT_slot%s_mike_debug" % slot
                self.uut_ser_dict[UUT_dbg] = self.uutDict[sn]['mike_debug']
                dbg_obj = self.uut_ser_dict[UUT_dbg]

                #----- dbg window logger --------------------- 
                # get a logger for the Mike-Debug shell
                sn_mike_debug = "%s_mike_debug" % sn
                dbg_logger, mike_debug_log_name = Diag.getLogger(basepath, sn_mike_debug, dbg=True)
                self.diag[sn_mike_debug] = Diag.DiagResponse()
                self.diag[sn_mike_debug].log = dbg_logger
                self.diag[sn_mike_debug].dsp = dbg_obj
                self.diag[sn_mike_debug].logname = mike_debug_log_name 
                self.info("Starting mike-debug shell logging...")
                t_id  = thread.start_new_thread(Diag.dbgLogger,
                        (self.diag[sn_mike_debug].log, dbg_obj))
                self.diag[sn_mike_debug].t_id = t_id
                self.info("Debug log started.....")
Esempio n. 2
0
    def initialize(self):
        # create aliases
        tb = self.config.testbed
        self.DiCon = tb['DiCon_SW']
        self.VOAREFTX = tb["VOA_Line_Ref_Tx"]
        self.PROGCD = tb["ProgCD"]
        self.dBox    = self.PROGCD.dBox
        self.OSA = tb["OSA"]
        self.VOAASE = tb["VOA_ASE"]
        self.VOAOUT = tb["VOA_Out"]
        self.REFRX = tb["ReferenceRx_Mike"]
        self.REFRX_ber = tb["ReferenceRx"]
        self.DAQ = tb["DAQ"]
        self.PWAV = tb['PWAV']
        self.PDIR = tb['PDIR']
        self.UUT_LINE_OUTPUT_SW = tb['UUT_LINE_OUTPUT_SW']
        self.UUT_CLIENT_OUTPUT_SW = tb['UUT_CLIENT_OUTPUT_SW']
        self.refsn = self.REFRX.SN
        refsn = self.refsn 

        #log file
        self.lf = self.config.logfile
         
        #sql database
        self.lineRxBerArgs = {}
        self.errorCount = {}
        # test type:
        self.UUT_TEST_TYPE = self.config.UUT_TEST_TYPE
        for voa in self.config.voaOutList:
            tb[voa].state = "ON"
        time.sleep(5)    # time to settle all instrument
        
        # initial OSNR setting to have a good eye
        self.init_osnr = self.config.init_osnr
        # step 1: set ProgCD SW6 to CNT to disable light from coming in.
        if self.PROGCD.__class__ == instruments.GP700:
            pass
        else:
            self.PROGCD.dBox.set_switch(6, 'cnt')

        # step 2. Disable VOAs
        self.info("Enabling VOA's ...")
        varAtt = self.config.varAtt
        for i in range(len(varAtt['voa'])):
            tb[varAtt['voa'][i]].state = "ON"
            tb[varAtt['voa'][i]].attenuation = varAtt['att'][i]
            tb[varAtt['voa'][i]].wavelength = varAtt['wl'][i]
        # Making uut list
        # copy from stratatestrunner.py
        self.uutDict = copy(self.config.uut_dict)
        self.uutSnList = self.uutDict.keys()
        self.info("Number of UUTS TO BE TESTED: %s\n" %len(self.uutSnList))
        self.lf.write("\n\nNumber of UUTS TO BE TESTED: %s\n" 
                                            %len(self.uutSnList))
        for sn in self.uutSnList:
            self.info("UUT INFO: slot%s : %s \n" 
                %(self.uutDict[sn]["slot"], sn))
            self.lineRxBerArgs[self.uutDict[sn]["id"]] = {}
            self.errorCount[sn] = 0
            
        refsn = self.REFRX.SN
        self.errorCount[refsn] = 0
        self.tdc_channel_dict = self.config.tdc_params
        self.dicon_sw_dict = self.config.dicon_sw_dict
        self.card_type_str = self.config.default_card_type        
        self.tdc_type = self.config.default_tdc_type
        tdc_type = self.tdc_type
        self.RxLOSThr = -24.0
        # make serial objects for UUTs
        index = 0
        self.uut_ser_dict = {}
        # dictionary to store logger and diagnostic related resources.
        self.diag = {}
        self.diag_logger = {}
        try:
            cd_list  = self.config.cdlist.split(',')
            self.cdTestList = []
            for cd in cd_list:
                self.cdTestList.append(int(cd))
            self.diagnostic("### CD list: %s" % self.cdTestList)
        except:
            self.cdTestList = self.config.cdTestList
            self.diagnostic("### CD list: %s" % self.cdTestList)
        try:
            tmp_list = self.config.osnrlist.split(',')
            self.osnrList = []
            for osnr in tmp_list:
                osnr_pq = PQ("%s dB" % osnr)
                self.osnrList.append(osnr_pq)
            self.diagnostic("### OSNR list: %s" % self.osnrList)
        except:
            self.osnrList = self.config.osnrList
            self.diagnostic("### OSNR list: %s" % self.osnrList)
        self.diagnostic("Setting RxLOSThr on REF to %s" % self.RxLOSThr)
        self.REFRX.RxLOSThr = self.RxLOSThr
        demod_settle_time = 14000
        self.diagnostic("Extending REFRX (%s) demod settle time to %s msec" % (self.REFRX.SN, demod_settle_time))
        
        self.REFRX.extend_demod_settle_time(demod_settle_time)

        #----- reference dbg window logger --------------------- 
        # get a logger for the reference Mike-Debug shell
        refsn_mike_debug = "ReferenceRx_mike_debug" 
        refsn_dbg_obj = self.config.testbed[refsn_mike_debug]
        self.info("Configuring diagnostic resources...")
        basepath = os.path.dirname(self.config.reportpath)

        refsn_dbg_logger, refsn_mike_debug_log_name = Diag.getLogger(basepath, refsn_mike_debug, dbg=True)
        self.diag[refsn_mike_debug] = Diag.DiagResponse()
        self.diag[refsn_mike_debug].log = refsn_dbg_logger
        self.diag[refsn_mike_debug].dsp = refsn_dbg_obj
        self.diag[refsn_mike_debug].logname = refsn_mike_debug_log_name 
        self.info("Starting Reference mike-debug shell logging...")
        refsn_t_id  = thread.start_new_thread(Diag.dbgLogger,
                (self.diag[refsn_mike_debug].log, refsn_dbg_obj))
        self.diag[refsn_mike_debug].t_id = refsn_t_id
        #self.diag[sn_mike_debug].thread = thread.start_new_thread(Diag.dbgLogger, (self.diag[sn_mike_debug].log, dbg_obj))
        self.info("Reference mike debug log started.....")
        self.info("Setting REF TDC to Auto-Cont mode...") 
        self.REFRX.set_tdc_auto_mode('Cont')
        if 1: #self.config.flags.DEBUG:
            self.info("Dumping out REF TDC setting...")
            raw_info = self.REFRX.show_tdc_state()
            self.info("%s" % raw_info)

        for sn, uut_dict in self.uutDict.items():
            slot = uut_dict['slot']
            UUT_ser = "UUT_slot%s_mike" % slot
            UUT_ber = "UUT_slot%s" % slot
            UUT_dbg = "UUT_slot%s_mike_debug" % slot

            obj = uut_dict['obj']
            self.uut_ser_dict[slot] = self.uutDict[sn]['mike']
            self.uut_ser_dict[UUT_ber] = self.uutDict[sn]['obj']
            self.uut_ser_dict[UUT_dbg] = self.uutDict[sn]['mike_debug'] #config.testbed[UUT_dbg]

            self.lineRxBerArgs[self.uutDict[sn]["id"]] = []
            ser_obj = self.uut_ser_dict[slot]
            ber_obj = self.uut_ser_dict[UUT_ber]
            dbg_obj = self.uut_ser_dict[UUT_dbg]
            self.info("Setting UUT TDC to Auto-Cont mode...")
            ser_obj.set_tdc_auto_mode('Cont')

            if 1:    # self.config.flags.DEBUG:
                self.info("Dumping out UUT TDC setting...")
                raw_info = ser_obj.show_tdc_state()
                self.info("%s" % raw_info)
 
            self.info("Configuring diagnostic resources...")
            basepath = os.path.dirname(self.config.reportpath)
            self.info("Basepath: %s" % basepath)
            #----- dbg window logger --------------------- 
            # get a logger for the Mike-Debug shell
            sn_mike_debug = "%s_mike_debug" % sn
            dbg_logger, mike_debug_log_name = Diag.getLogger(basepath, sn_mike_debug, dbg=True)
            self.diagnostic("Mike debug log located at '%s'" % os.path.dirname(mike_debug_log_name))
           
            self.diag[sn_mike_debug] = Diag.DiagResponse()
            self.diag[sn_mike_debug].log = dbg_logger
            self.diag[sn_mike_debug].dsp = dbg_obj
            self.diag[sn_mike_debug].logname = mike_debug_log_name 
            self.info("Starting mike-debug shell logging...")
            t_id  = thread.start_new_thread(Diag.dbgLogger,
                    (self.diag[sn_mike_debug].log, dbg_obj))
            self.diag[sn_mike_debug].t_id = t_id
            #self.diag[sn_mike_debug].thread = thread.start_new_thread(Diag.dbgLogger, (self.diag[sn_mike_debug].log, dbg_obj))
            self.info("Debug log started.....")
            self.uutDict[sn]['obj'] = ser_obj
            self.info("Setting UUT (slot%s:%s) for %s..." % (slot, sn,
                self.UUT_TEST_TYPE))
            self.info("Setting REFERENCE card (%s) for %s..." % (self.REFRX.SN, 'Tx'))
            uut_tx_channel = self.tdc_channel_dict[tdc_type][0]
            self.diagnostic("Setting TxChan to channel %s" % uut_tx_channel)
            ser_obj.ModChan = uut_tx_channel
            self.REFRX.ModChan = uut_tx_channel
            self.info("UUT TxChan: %s" % ser_obj.ModChan)
            self.info("REF TxChan: %s" % self.REFRX.ModChan)

            self.diagnostic("Setting RxLOSThr on UUT to %s" % self.RxLOSThr)
            ser_obj.RxLOSThr =  self.RxLOSThr
            # XXX: the following is experimental...
            self.diagnostic("Extending UUT(%s) demod settle time to %s msec" % (sn, demod_settle_time))
            ser_obj.extend_demod_settle_time(demod_settle_time)

            
            self.errorCount[sn] = 0
            if index == 0: # do the setting only once.
                # step3: set DiCon switch
                # SW3-SW5 are connected to P1 with the following mapping
                # SW1 & SW2 are UUT slot number dependent, so deal with them later.
                # P1:1 -> SW3, P1:2 -> SW4, P1:3 -> SW5
                # SW3-SW5 = ITU Channel H.  Assume H is connected to port 0, 1
                pdir_mod_name = "%s" % (self.PDIR.sw_mod)
                pdir_name = self.PDIR.name
                pdir_3_index = "%s:3" % pdir_name
                pdir_3_pos = self.dicon_sw_dict[tdc_type][pdir_3_index]
                self.info("Setting %s to position %d" % (pdir_3_index, pdir_3_pos))
                self.DiCon.set_switch(pdir_mod_name, pdir_3_pos, 3)

                pwav_name = self.PWAV.name
                pwav_mod_name = "%s" % (self.PWAV.sw_mod)
                pwav_pos = self.dicon_sw_dict[tdc_type][pwav_name]#self.config.pwav_pos
                self.info("Setting %s:1, %s:2, %s:3 to position %d" % \
                        (pwav_name, pwav_name, pwav_name, pwav_pos))
                self.DiCon.set_switch(pwav_mod_name, pwav_pos, 1)
                self.DiCon.set_switch(pwav_mod_name, pwav_pos, 2)
                self.DiCon.set_switch(pwav_mod_name, pwav_pos, 3)
               
                pdir_1_index = "%s:1" % pdir_name
                pdir_2_index = "%s:2" % pdir_name
                pdir_1_pos = self.dicon_sw_dict[tdc_type][pdir_1_index]
                pdir_2_pos = self.dicon_sw_dict[tdc_type][pdir_2_index] #self.config.pdir_2_pos
                self.info("Setting %s to %d and %s to %d" % (pdir_1_index,
                    pdir_1_pos, pdir_2_index, pdir_2_pos))
                self.DiCon.set_switch(pdir_mod_name, pdir_1_pos, 1)
                self.DiCon.set_switch(pdir_mod_name, pdir_2_pos, 2)
            
            index += 1

        #self.info("Configuring UUT and RefRx.....\n")
        #chn, pwr, losth, pminterval = self.config.refParams
        if (tdc_type == 1): # 1585.51
            self.chn = 51
        else:
            self.chn = 50
            
        self.info( "\nTime Stamp: %s" 
                  % (time.strftime( "%m-%d-%Y %H:%M:%S", time.localtime())))
Esempio n. 3
0
    def initialize(self):
        # create aliases
        tb = self.config.testbed
        self.DiCon = tb['DiCon_SW']
        self.VOAREFTX = tb["VOA_Line_Ref_Tx"]
        self.PROGCD = tb["ProgCD"]
        self.dBox    = self.PROGCD.dBox
        self.OSA = tb["OSA"]
        self.VOAASE = tb["VOA_ASE"]
        self.VOAOUT = tb["VOA_Out"]
        self.REFRX = tb["ReferenceRx_Mike"]
        self.REFRX_ber = tb["ReferenceRx"]
        self.DAQ = tb["DAQ"]
        self.PWAV = tb['PWAV']
        self.PDIR = tb['PDIR']
        self.UUT_LINE_OUTPUT_SW = tb['UUT_LINE_OUTPUT_SW']
        self.UUT_CLIENT_OUTPUT_SW = tb['UUT_CLIENT_OUTPUT_SW']
        self.refsn = self.REFRX.SN
        refsn = self.refsn 

        #log file
        self.lf = self.config.logfile
        self.temperature = self.DAQ.temperature
         
        #sql database
        self.vadjArgs = {}
        self.errorCount = {}
        # test type:
        self.UUT_TEST_TYPE = self.config.UUT_TEST_TYPE
        for voa in self.config.voaOutList:
            tb[voa].state = "ON"
        time.sleep(5)    # time to settle all instrument
        
        # initial OSNR setting to have a good eye
        self.init_osnr = self.config.init_osnr
        # step 1: set ProgCD SW6 to CNT to disable light from coming in.
        if self.PROGCD.__class__ == instruments.GP700:
            pass
        else:
            self.PROGCD.dBox.set_switch(6, 'cnt')

        # step 2. Disable VOAs
        self.info("Enabling VOA's ...")
        varAtt = self.config.varAtt
        for i in range(len(varAtt['voa'])):
            tb[varAtt['voa'][i]].state = "ON"
            tb[varAtt['voa'][i]].attenuation = varAtt['att'][i]
            tb[varAtt['voa'][i]].wavelength = varAtt['wl'][i]
        # Making uut list
        # copy from stratatestrunner.py
        self.uutDict = copy(self.config.uut_dict)
        self.uutSnList = self.uutDict.keys()
        self.info("Number of UUTS TO BE TESTED: %s\n" %len(self.uutSnList))
        self.lf.write("\n\nNumber of UUTS TO BE TESTED: %s\n" 
                                            %len(self.uutSnList))
        for sn in self.uutSnList:
            self.info("UUT INFO: slot%s : %s \n" 
                %(self.uutDict[sn]["slot"], sn))
            self.vadjArgs[self.uutDict[sn]["id"]] = {}
            self.errorCount[sn] = 0
            
        refsn = self.REFRX.SN
        self.errorCount[refsn] = 0
        self.tdc_channel_dict = self.config.tdc_params
        self.dicon_sw_dict = self.config.dicon_sw_dict
        self.card_type_str = self.config.default_card_type        
        self.tdc_type = self.config.default_tdc_type
        tdc_type = self.tdc_type
        self.RxLOSThr = -24.0
        # make serial objects for UUTs
        index = 0
        self.uut_ser_dict = {}
        # dictionary to store logger and diagnostic related resources.
        self.diag = {}
        self.diag_logger = {}

        self.diagnostic("Setting RxLOSThr on REF to %s" % self.RxLOSThr)
        self.REFRX.RxLOSThr = self.RxLOSThr
        demod_settle_time = 14000
        self.diagnostic("Extending REFRX (%s) demod settle time to %s msec" % (self.REFRX.SN, demod_settle_time))
        self.REFRX.extend_demod_settle_time(demod_settle_time)
        
        for sn, uut_dict in self.uutDict.items():

            slot = uut_dict['slot']
            UUT_ser = "UUT_slot%s_mike" % slot
            UUT_ber = "UUT_slot%s" % slot
            obj = uut_dict['obj']
            self.uut_ser_dict[slot] = self.config.testbed[UUT_ser]
            self.uut_ser_dict[UUT_ber] = self.config.testbed[UUT_ber]
            self.vadjArgs[self.uutDict[sn]["id"]] = []
            ser_obj = self.uut_ser_dict[slot]
            ber_obj = self.uut_ser_dict[UUT_ber]
            self.info("Configuring diagnostic resources...")
            basepath = os.path.dirname(self.config.reportpath)
            self.info("Basepath: %s" % basepath)
            self.diag_logger[sn] = Diag.getLogger(basepath, sn)
            self.diag[sn] = Diag.DiagResponse()
            self.diag[sn].log = self.diag_logger[sn]
            self.diag[sn].dsp = ser_obj
            refsn_uut = "%s_%s" % (refsn, sn)
            self.diag_logger[refsn_uut] = Diag.getLogger(basepath, refsn_uut)
            self.diag[refsn_uut] = Diag.DiagResponse()
            self.diag[refsn_uut].log =  self.diag_logger[refsn_uut]
            self.diag[refsn_uut].dsp = self.REFRX


            self.uutDict[sn]['obj'] = ser_obj
            self.info("Setting UUT (slot%s:%s) for %s..." % (slot, sn,
                self.UUT_TEST_TYPE))
            self.info("Setting REFERENCE card (%s) for %s..." % (self.REFRX.SN, 'Tx'))
            uut_tx_channel = self.tdc_channel_dict[tdc_type][0]
            self.diagnostic("Setting TxChan to channel %s" % uut_tx_channel)
            ser_obj.ModChan = uut_tx_channel
            self.REFRX.ModChan = uut_tx_channel
            self.info("UUT TxChan: %s" % ser_obj.ModChan)
            self.info("REF TxChan: %s" % self.REFRX.ModChan)

            self.diagnostic("Setting RxLOSThr on UUT to %s" % self.RxLOSThr)
            ser_obj.RxLOSThr =  self.RxLOSThr
            # XXX: the following is experimental...
            self.diagnostic("Extending UUT(%s) demod settle time to %s msec" % (sn, demod_settle_time))
            ser_obj.extend_demod_settle_time(demod_settle_time)

            
            self.errorCount[sn] = 0
            if index == 0: # do the setting only once.
                # step3: set DiCon switch
                # SW3-SW5 are connected to P1 with the following mapping
                # SW1 & SW2 are UUT slot number dependent, so deal with them later.
                # P1:1 -> SW3, P1:2 -> SW4, P1:3 -> SW5
                # SW3-SW5 = ITU Channel H.  Assume H is connected to port 0, 1
                pdir_mod_name = "%s" % (self.PDIR.sw_mod)
                pdir_name = self.PDIR.name
                pdir_3_index = "%s:3" % pdir_name
                pdir_3_pos = self.dicon_sw_dict[tdc_type][pdir_3_index]
                self.info("Setting %s to position %d" % (pdir_3_index, pdir_3_pos))
                self.DiCon.set_switch(pdir_mod_name, pdir_3_pos, 3)

                pwav_name = self.PWAV.name
                pwav_mod_name = "%s" % (self.PWAV.sw_mod)
                pwav_pos = self.dicon_sw_dict[tdc_type][pwav_name]#self.config.pwav_pos
                self.info("Setting %s:1, %s:2, %s:3 to position %d" % \
                        (pwav_name, pwav_name, pwav_name, pwav_pos))
                self.DiCon.set_switch(pwav_mod_name, pwav_pos, 1)
                self.DiCon.set_switch(pwav_mod_name, pwav_pos, 2)
                self.DiCon.set_switch(pwav_mod_name, pwav_pos, 3)
               
                pdir_1_index = "%s:1" % pdir_name
                pdir_2_index = "%s:2" % pdir_name
                pdir_1_pos = self.dicon_sw_dict[tdc_type][pdir_1_index]
                pdir_2_pos = self.dicon_sw_dict[tdc_type][pdir_2_index] #self.config.pdir_2_pos
                self.info("Setting %s to %d and %s to %d" % (pdir_1_index,
                    pdir_1_pos, pdir_2_index, pdir_2_pos))
                self.DiCon.set_switch(pdir_mod_name, pdir_1_pos, 1)
                self.DiCon.set_switch(pdir_mod_name, pdir_2_pos, 2)
            
            index += 1

        #self.info("Configuring UUT and RefRx.....\n")
        #chn, pwr, losth, pminterval = self.config.refParams
        if (tdc_type == 1): # 1585.51
            self.chn = 51
        else:
            self.chn = 50
            
        self.info( "\nTime Stamp: %s" 
                  % (time.strftime( "%m-%d-%Y %H:%M:%S", time.localtime())))
Esempio n. 4
0
    def initialize(self):
        # create aliases
        tb = self.config.testbed
        self.tdc_channel_dict = self.config.tdc_params

        #log file
        self.lf = self.config.logfile

        #sql database
        self.errorCount = {}

        # Making uut list
        from copy import copy
        # copy from stratatestrunner.py
        self.uutDict = copy(self.config.uut_dict)
        self.uutSnList = self.uutDict.keys()
        self.info("Number of UUTS TO BE TESTED: %s\n" %len(self.uutSnList))
        self.lf.write("\n\nNumber of UUTS TO BE TESTED: %s\n" 
                                            %len(self.uutSnList))
        for sn in self.uutSnList:
            self.info("UUT INFO: %s : %s : %s\n" 
                %(sn, self.uutDict[sn]["id"], self.uutDict[sn]["slot"]))
            self.errorCount[sn] = 0
            
        self.uutRefSnList = self.uutSnList# + [refsn]
        # make serial objects for UUTs
        index = 0
        self.uut_ser_dict = {}
        # dictionary to store logger and diagnostic related resources.
        self.diag = {}
        self.diag_logger = {}

        #----- reference dbg window logger --------------------- 
        # get a logger for the reference Mike-Debug shell
        self.info("Configuring diagnostic resources...")
        basepath = os.path.dirname(self.config.reportpath)

        demod_settle_time = 14000
        reacq_settle_time = 180

        for sn, uut_dict in self.uutDict.items():
            slot = uut_dict['slot']
            UUT_ser = "UUT_slot%s_mike" % slot
            UUT_ber = "UUT_slot%s" % slot
            UUT_dbg = "UUT_slot%s_mike_debug" % slot
            obj = uut_dict['obj']
            self.uut_ser_dict[slot] = self.uutDict[sn]['mike']
            self.uut_ser_dict[UUT_ber] = self.uutDict[sn]['obj']
            self.uut_ser_dict[UUT_dbg] = self.uutDict[sn]['mike_debug'] #config.testbed[UUT_dbg]

            ser_obj = self.uut_ser_dict[slot]
            ber_obj = self.uut_ser_dict[UUT_ber]
            dbg_obj = self.uut_ser_dict[UUT_dbg]

            self.info("Configuring diagnostic resources...")
            basepath = os.path.dirname(self.config.reportpath)
            self.info("Basepath: %s" % basepath)
            #----- dbg window logger --------------------- 
            # get a logger for the Mike-Debug shell
            sn_mike_debug = "%s_mike_debug" % sn
            dbg_logger, mike_debug_log_name = Diag.getLogger(basepath, sn_mike_debug, dbg=True)
            self.diagnostic("UUT Mike debug log located at '%s'" % os.path.dirname(mike_debug_log_name))
            
            self.diag[sn_mike_debug] = Diag.DiagResponse()
            self.diag[sn_mike_debug].log = dbg_logger
            self.diag[sn_mike_debug].dsp = dbg_obj
            self.diag[sn_mike_debug].logname = mike_debug_log_name 
            self.info("Starting mike-debug shell logging...")
            t_id  = thread.start_new_thread(Diag.dbgLogger,
                    (self.diag[sn_mike_debug].log, dbg_obj))
            self.diag[sn_mike_debug].t_id = t_id
            #self.diag[sn_mike_debug].thread = thread.start_new_thread(Diag.dbgLogger, (self.diag[sn_mike_debug].log, dbg_obj))
            self.info("Debug log started.....")

            self.uutDict[sn]['obj'] = ser_obj
            self.errorCount[sn] = 0
            
            self.tdc_type = ser_obj.get_tdc_type()
            tdc_type = self.tdc_type
            uut_tx_channel = self.tdc_channel_dict[tdc_type][0]
            self.diagnostic("Setting TxChan to channel %s" % uut_tx_channel)
            ser_obj.ModChan = uut_tx_channel
            self.info("UUT TxChan: %s" % ser_obj.ModChan)
            # set TDC to manual dispersion of 0
            self.info("Setting TDC to manual dispersion of 0")
            ser_obj.set_tdc_fixed(0.0)
            self.info("Dumping out UUT TDC setting...")
            raw_info = ser_obj.show_tdc_state()
            self.info("%s" % raw_info)

            # do a demod acq and wait for 3 minutes..
            self.diagnostic("Extending UUT(%s)demod settle time to %s msec" % (sn,demod_settle_time))
            ser_obj.extend_demod_settle_time(demod_settle_time)
            self.info("Enabling LINE PRBS...")
            ber_obj.enable_line_prbs()
  
            self.diagnostic("Forcing demod reacquistion on UUT %s..." % sn)
            self.info("Wait for %s seconds for loops to settle..." % reacq_settle_time)
            ser_obj.force_demod_reacq()
            time.sleep(reacq_settle_time)

        ## initializing Ref and UUT
        if (self.tdc_type == 1): # 1585.51
            self.chn = 51
        else:
            self.chn = 50
 
        self.info( "\nTime Stamp: %s" 
                  % (time.strftime( "%m-%d-%Y %H:%M:%S", time.localtime())))
Esempio n. 5
0
    def initialize(self):
        # create aliases
        tb = self.config.testbed
        self.DiCon = tb['DiCon_SW']
        self.VOAREFTX = tb["VOA_Line_Ref_Tx"]
        self.PROGCD = tb["ProgCD"]
        self.dBox    = self.PROGCD.dBox
        self.OSA = tb["OSA"]
        self.VOAASE = tb["VOA_ASE"]
        self.VOAOUT = tb["VOA_Out"]
        self.REFRX = tb["ReferenceRx_Mike"]
        self.REFRX_ber = tb["ReferenceRx"]
        self.DAQ = tb["DAQ"]
        self.PWAV = tb['PWAV']
        self.PDIR = tb['PDIR']
        self.UUT_LINE_OUTPUT_SW = tb['UUT_LINE_OUTPUT_SW']
        self.UUT_CLIENT_OUTPUT_SW = tb['UUT_CLIENT_OUTPUT_SW']
        #self.TP = tb['InnoCor']
        self.refsn = self.REFRX.SN
        refsn = self.refsn 
        self.M1 = tb['M1']
        self.RxLOSThr = -24.0
        # ShelfController instance
        self.SC = tb['SC']
        
 
        #log file
        self.lf = self.config.logfile
        # dictionary to store logger and diagnostic related resources.
        self.diag = {}
        self.diag_logger = {}

        
        #sql database
        self.errorCount = {}
        self.clientChkArgs = {}
        
        # test type:
        self.UUT_TEST_TYPE = self.config.UUT_TEST_TYPE

        # step 1: set ProgCD SW6 to CNT to disable light from coming in.
        if self.PROGCD.__class__ == instruments.GP700:
            pass
        else:
            self.info("Disabling ProgCD output...")
            self.dBox.set_switch(6, 'cnt')

        # step 2. Disable VOAs
        self.info("Disabling VOA's ...")
        varAtt = self.config.varAtt
        for i in range(len(varAtt['voa'])):
            tb[varAtt['voa'][i]].state = "ON"
            tb[varAtt['voa'][i]].attenuation = varAtt['att'][i]
            tb[varAtt['voa'][i]].wavelength = varAtt['wl'][i]
        # Making uut list
        from copy import copy
        # copy from stratatestrunner.py
        self.uutDict = copy(self.config.uut_dict)
        self.uutSnList = self.uutDict.keys()
        self.info("Number of UUTS TO BE TESTED: %s\n" %len(self.uutSnList))
        self.lf.write("\n\nNumber of UUTS TO BE TESTED: %s\n" 
                                            %len(self.uutSnList))
        for sn in self.uutSnList:
            self.info("UUT INFO: slot%s : %s\n" %(self.uutDict[sn]["slot"], sn))
            self.clientChkArgs[self.uutDict[sn]["id"]] = {}
            self.errorCount[sn] = 0
            
        self.uutRefSnList = self.uutSnList# + [refsn]
        self.tdc_channel_dict = self.config.tdc_params
        self.dicon_sw_dict = self.config.dicon_sw_dict
        self.card_type_str = self.config.default_card_type
        # make serial objects for UUTs
        index = 0
        self.uut_ser_dict = {}
        #----- reference dbg window logger --------------------- 
        # get a logger for the reference Mike-Debug shell
        refsn_mike_debug = "ReferenceRx_mike_debug" 
        refsn_dbg_obj = self.config.testbed[refsn_mike_debug]
        self.info("Configuring diagnostic resources...")
        basepath = os.path.dirname(self.config.reportpath)

        refsn_dbg_logger, refsn_mike_debug_log_name = Diag.getLogger(basepath, refsn_mike_debug, dbg=True)
        self.diag[refsn_mike_debug] = Diag.DiagResponse()
        self.diag[refsn_mike_debug].log = refsn_dbg_logger
        self.diag[refsn_mike_debug].dsp = refsn_dbg_obj
        self.diag[refsn_mike_debug].logname = refsn_mike_debug_log_name 
        self.info("Starting Reference mike-debug shell logging...")
        refsn_t_id  = thread.start_new_thread(Diag.dbgLogger,
                (self.diag[refsn_mike_debug].log, refsn_dbg_obj))
        self.diag[refsn_mike_debug].t_id = refsn_t_id
        #self.diag[sn_mike_debug].thread = thread.start_new_thread(Diag.dbgLogger, (self.diag[sn_mike_debug].log, dbg_obj))
        self.info("Reference mike debug log started.....")
        self.rel_dict = {}
        for sn, uut_dict in self.uutDict.items():
            slot = uut_dict['slot']
            self.rel_dict[slot] = {}
            UUT_ser = "UUT_slot%s_mike" % slot
            UUT_ber = "UUT_slot%s" % slot
            UUT_dbg = "UUT_slot%s_mike_debug" % slot
            self.uut_ser_dict[slot] = self.uutDict[sn]['mike']
            self.uut_ser_dict[UUT_ber] = self.uutDict[sn]['obj']
            self.uut_ser_dict[UUT_dbg] = self.uutDict[sn]['mike_debug'] #config.testbed[UUT_dbg]

            ser_obj = self.uut_ser_dict[slot]
            ber_obj = self.uut_ser_dict[UUT_ber]
            dbg_obj = self.uut_ser_dict[UUT_dbg]
            
            self.rel_dict[slot]['is_2_1'], self.rel_dict[slot]['release'] = ber_obj.is_2_1_release()
            self.info("Configuring diagnostic resources...")
            basepath = os.path.dirname(self.config.reportpath)
            self.info("Basepath: %s" % basepath)
            sn_logger, sn_log_name = Diag.getLogger(basepath, sn)
            self.diag[sn] = Diag.DiagResponse()
            self.diag[sn].log = sn_logger 
            self.diag[sn].dsp = ser_obj
            self.diag[sn].logname = sn_log_name
            refsn_uut = "%s_%s" % (refsn, sn)
            refsn_logger, refsn_log_name = Diag.getLogger(basepath, refsn_uut)
            self.diag[refsn_uut] = Diag.DiagResponse()
            self.diag[refsn_uut].log = refsn_logger 
            self.diag[refsn_uut].dsp = self.REFRX
            self.diag[refsn_uut].logname = refsn_log_name
            #----- dbg window logger --------------------- 
            # get a logger for the Mike-Debug shell
            sn_mike_debug = "%s_mike_debug" % sn
            dbg_logger, mike_debug_log_name = Diag.getLogger(basepath, sn_mike_debug, dbg=True)
            self.diag[sn_mike_debug] = Diag.DiagResponse()
            self.diag[sn_mike_debug].log = dbg_logger
            self.diag[sn_mike_debug].dsp = dbg_obj
            self.diag[sn_mike_debug].logname = mike_debug_log_name 
            self.info("Starting mike-debug shell logging...")
            self.diagnostic("Mike debug log located at '%s'" % os.path.dirname(mike_debug_log_name))
            t_id  = thread.start_new_thread(Diag.dbgLogger,
                    (self.diag[sn_mike_debug].log, dbg_obj))
            self.diag[sn_mike_debug].t_id = t_id
            #self.diag[sn_mike_debug].thread = thread.start_new_thread(Diag.dbgLogger, (self.diag[sn_mike_debug].log, dbg_obj))
            self.info("Debug log started.....")

            obj = uut_dict['obj']
            self.clientChkArgs[self.uutDict[sn]["id"]] = []            
            ser_obj = self.uut_ser_dict[slot]
            self.uutDict[sn]['obj'] = ser_obj
            self.info("Setting UUT (slot%s:%s) for %s..." % (slot, sn,
                self.UUT_TEST_TYPE))
            self.info("Setting REFERENCE card (%s) for %s..." % (self.REFRX.SN, 'Rx'))
            tdc_lof_timeout = '3600.0'

            self.errorCount[sn] = 0
            self.tdc_type = self.config.default_tdc_type

            tdc_type = self.tdc_type
            uut_tx_channel = self.tdc_channel_dict[tdc_type][0]
            self.diagnostic("Setting TxChan to channel %s" % uut_tx_channel)
            ser_obj.ModChan = uut_tx_channel
            self.REFRX.ModChan = uut_tx_channel
            self.info("UUT TxChan: %s" % ser_obj.ModChan)
            self.info("REF TxChan: %s" % self.REFRX.ModChan)
            self.diagnostic("Setting RxLOSThr on UUT to %s" % self.RxLOSThr)
            ser_obj.RxLOSThr =  self.RxLOSThr

            if index == 0: # do the setting only once.
                # step3: set DiCon switch

                pdir_mod_name = "%s" % (self.PDIR.sw_mod)
                pdir_name = self.PDIR.name
                pdir_3_index = "%s:3" % pdir_name
                pdir_3_pos = self.dicon_sw_dict[tdc_type][pdir_3_index]
                self.info("Setting %s to position %d" % (pdir_3_index, pdir_3_pos))
                self.DiCon.set_switch(pdir_mod_name, pdir_3_pos, 3)

                pwav_name = self.PWAV.name
                pwav_mod_name = "%s" % (self.PWAV.sw_mod)
                pwav_pos = self.dicon_sw_dict[tdc_type][pwav_name]
                self.info("Setting %s:1, %s:2, %s:3 to position %d" % \
                        (pwav_name, pwav_name, pwav_name, pwav_pos))
                self.DiCon.set_switch(pwav_mod_name, pwav_pos, 1)
                self.DiCon.set_switch(pwav_mod_name, pwav_pos, 2)
                self.DiCon.set_switch(pwav_mod_name, pwav_pos, 3)
               
                pdir_1_index = "%s:1" % pdir_name
                pdir_2_index = "%s:2" % pdir_name
                pdir_1_pos = self.dicon_sw_dict[tdc_type][pdir_1_index]
                pdir_2_pos = self.dicon_sw_dict[tdc_type][pdir_2_index]
                self.info("Setting %s to %d and %s to %d" % (pdir_1_index,
                    pdir_1_pos, pdir_2_index, pdir_2_pos))
                self.DiCon.set_switch(pdir_mod_name, pdir_1_pos, 1)
                self.DiCon.set_switch(pdir_mod_name, pdir_2_pos, 2)
            
            index += 1


        # initializing Ref and UUT
        if (self.tdc_type == 1): # 1585.51
            self.chn = 51
        else:
            self.chn = 50
            
        self.info( "\nTime Stamp: %s" 
                  % (time.strftime( "%m-%d-%Y %H:%M:%S", time.localtime())))
Esempio n. 6
0
    def initialize(self):
        
        #test status and parameters
        self.resetState = True
        self.resetCount = 0
        self.maxResets = self.config.maxresets
        self.passing = True
        self.abort = False
        self.debugMode = self.config.debugmode
        
        # reading initial UUT params
        (min_chn, max_chn, odd_chn, even_chn, pwr, clpwr, cltxminpwr, cltxmaxpwr, losth, pminterval,
            rxpwr, rxmintol, rxmaxtol, clrxpwr, clrxmintol, clrxmaxtol, linetxmintol, linetxmaxtol) = self.config.uutParams
        tdcType = self.config.tdcType
        self.linemaxberr = self.config.lineberrlimit
        self.clientmaxberr = self.config.clientberrlimit
        self.uut_type = int(self.config.uuttype)        
        self.tagNameList = self.config.tagNameList
        
        #initialize testbed
        tb = self.config.testbed
        
        #sql database
        self.burnInTestArgs = {}
        self.modTemps = {} 
          
        #data file
        pathname = self.get_pathname(self.config.dataFileName)
        self.df = file(pathname, "w")
        
        #log file
        self.lf = self.config.logfile
        
        # Making uut list
        from copy import copy
        self.uutDict = copy(self.config.uut_dict) #dict from stratatestrunner
        self.uutSnList = self.uutDict.keys()
        self.info("Number of UUTS TO BE TESTED: %s\n"  %len(self.uutSnList))
        self.lf.write("\n\nNumber of UUTS TO BE TESTED: %s\n" 
                                            %len(self.uutSnList))
        
        #Setting up the UUT test info
        for sn in self.uutSnList:    #only one UUT
            self.burnInTestArgs[self.uutDict[sn]["id"]] = []
            uut_slot = self.uutDict[sn]['slot']
            self.SLOT = int(uut_slot)
            self.serialno = sn
            
        #Setting up the UUT
        self.uut_ser_dict = {}
        for sn, uut_dict in self.uutDict.items():
            slot = uut_dict['slot']
            UUT_ser = "UUT_slot%s" % slot
            UUT_ser_mike = "UUT_slot%s_mike" % slot
            UUT_dbg = "UUT_slot%s_mike_debug" % slot
            self.uut860 = self.uutDict[sn]['obj']
            self.uutdsp = self.uutDict[sn]['mike']
            self.dbg_obj =  self.uutDict[sn]['mike_debug'] 
            self.uut_ser_dict[UUT_ser] = self.uut860
            self.uut_ser_dict[UUT_ser_mike] = self.uutdsp
        #create logging 
        self.info("Configuring diagnostic resources...")
        basepath = os.path.dirname(self.config.reportpath)
        self.info("Basepath: %s" % basepath)
        self.diag = {}

        # get a logger for the Mike-Debug shell
        sn_mike_debug = "%s_mike_debug" % sn
        dbg_logger, mike_debug_log_name  = Diag.getLogger(basepath, sn_mike_debug)
        self.diagnostic("Mike debug log located at '%s'" % os.path.dirname(mike_debug_log_name))
        self.diag[sn_mike_debug] = Diag.DiagResponse()
        self.diag[sn_mike_debug].log = dbg_logger
        self.diag[sn_mike_debug].dsp = self.dbg_obj
        self.diag[sn_mike_debug].logname = mike_debug_log_name 
        self.info("Starting mike-debug shell logging...")
        t_id  = thread.start_new_thread(Diag.dbgLogger,
            (self.diag[sn_mike_debug].log, self.dbg_obj))
        self.diag[sn_mike_debug].t_id = t_id
        self.info("Debug log started.....")
        
        # cal tag checks
        for tag_name in self.tagNameList:
            xml_obj, upload_status = self.uutdsp.read_tag_from_mike(tag_name)
            if not upload_status:
                self.error("Upload failed for tag %s" % tag_name)
                self.passing = False
                uutid = self.uutDict[self.uutSnList[0]]["id"]
                return self.failed("Tags are missing.", uutid)
            else:
                self.info("Tag: %s" % tag_name)
                self.info("%s" % xml_obj.__str__())
                xml_file_name = "%s.xml" % tag_name
                self.save_object(xml_obj, xml_file_name)

        #verify the tdc type
        uut_tdc_type = self.uutdsp.get_tdc_type()
        self.info("UUT TDC Type: %s" % (int(uut_tdc_type),))
        if (int(tdcType) != int(uut_tdc_type)):
            self.info("Part number from the command line does not match the UUT TDC Type of %s." % (uut_tdc_type,))
            while(1):
                status = upper(self.user_input("\nDo you want to (c)ontinue or (a)bort the BurnIn[c/a]?:"))
                if status == "A":
                    raise TestSuiteAbort, "Suite aborted."
                    break
                elif status == "C":
                    self.info("Operator selected to continue the test.\n")
                    break

        # make the DB connection.
        card_conn_list = list(database.TitanBurnIn.select((database.TitanBurnIn.q.slot==self.SLOT)))
        i = 0
        while i < len(card_conn_list):
            if card_conn_list[i].tb == tb.name:
                card_conn = card_conn_list[i]
                self.db = card_conn
                break
            else:
                i += 1
        if (i >= len(card_conn_list)):
            #if environment variable IDTYPE == UUID, then use UUID for database entry id, else implicit auto-increment integer is used.
            if (("IDTYPE" in os.environ.keys()) and (os.environ["IDTYPE"]=="UUID")):
                database.TitanBurnIn(
                    id = (commands.getoutput('uuidgen -t')).strip(),
                    tb = str(tb.name), 
                    sn  = str(sn),
                    slot = int(self.SLOT), 
                    startTime = datetime.datetime(2000,1,1,0,0),
                    endTime = datetime.datetime(2000,1,1,0,0),
                    runs = int(0), 
                    currentRun = int(0), 
                    lastUpdate = datetime.datetime(2000,1,1,0,0), 
                    msg = str(''),
                    status = int(2)
                    )
            else:
                database.TitanBurnIn(
                    tb = str(tb.name), 
                    sn  = str(sn),
                    slot = int(self.SLOT), 
                    startTime = datetime.datetime(2000,1,1,0,0),
                    endTime = datetime.datetime(2000,1,1,0,0),
                    runs = int(0), 
                    currentRun = int(0), 
                    lastUpdate = datetime.datetime(2000,1,1,0,0), 
                    msg = str(''),
                    status = int(2)
                    )

            card_conn_list = list(database.TitanBurnIn.select((database.TitanBurnIn.q.slot==self.SLOT)))
            i = 0
            while i < len(card_conn_list):
                if card_conn_list[i].tb == tb.name:
                    card_conn = card_conn_list[i]
                    self.db = card_conn
                    break
                else:
                    i += 1    
        db_info = {}
        db_info['sn'] = sn
        db_info['startTime'] = datetime.datetime.fromtimestamp(timelib.now())
        db_info['endTime'] = None
        db_info['status'] = 2
        self._update_uut_db(db_info)        
       
        # keep looping until a valid response is given
        while (1):
            status = upper(self.user_input("\nDo you want to start or continue the BurnIn[s/c]?:"))
            if status == "S" or status == "C":
                break

        totalHrs, interval = self.config.totalhrs
        if status == "S":
            # if start a new burnin session, ask for how long to run range
            # (1-48) hours
            self.db.msg = ''  # clear the old meassages.
            self.db.msg += "Start Burn In Test for Line Card %s in Slot:%s ...\n" % (sn, self.SLOT)
            while (1):
                totalHrs = int(self.user_input("\nHow long do you want to run BurnIn test?[2-48]?:"))
                if totalHrs > 1 and totalHrs < 49:
                    if totalHrs != 48:
                        # prompt for password.
                        password_ok = self.check_password()
                        if not password_ok:
                            return self.abort("Test Engineering password not verified!")
                    totalHrsToRun = totalHrs
                    totalHrs = PQ(totalHrs, "h")
                    break
            self.numCheckIter = int(totalHrs/interval)
            self.info("Test to run for %s" %(totalHrs,))
            self.lf.write("Test to run for %s" %(totalHrs,))
            self.db.msg += "Test to run for %s\n" % (totalHrs,)
            self.db.currentRun = 0
            db_info['runs'] = totalHrsToRun
            self._update_uut_db(db_info)
        else:
            synctime = self.db.currentRun
            totalHrsToRun = self.db.runs
            totalHrs = PQ(totalHrsToRun, "h")
            syncTimeInHrs = PQ(synctime, "h")
            self.info("Test already ran for %s" %(syncTimeInHrs,))
            self.lf.write("\n\nTest already ran for %s" %(syncTimeInHrs,))
            previousData = self.db.msg
            for line in previousData.split("\n"):
                if line.find("Initial") >= 0:
                    self.info("Previous Run: %s" % line)
                    self.lf.write("\n\nPrevious Run: %s\n" % line)
                else:
                    if line.find("Iter") >= 0:
                        self.info("Previous Run: %s" % line)
                        self.lf.write("\n\nPrevious Run: %s\n" % line)
            
            if syncTimeInHrs > totalHrs:
                self.numCheckIter = 1
            else:
                timeLeftInHrs = PQ(round(totalHrs - syncTimeInHrs), "h")
                self.numCheckIter = int(timeLeftInHrs/interval)
                if round(totalHrs - syncTimeInHrs) <= 0:
                    self.numCheckIter = int(1)
                self.info("Test to run for %s more" %(timeLeftInHrs,))
                self.lf.write("\n\nTest to run for %s more" %(timeLeftInHrs,))
                self.db.msg += "\n\nTest to run for %s more \n" % (timeLeftInHrs,)
                db_info['runs'] = totalHrsToRun
                self._update_uut_db(db_info)
        
        #getting initial UUT state
        startTime = time.time()    
        while((self.resetState == True) and (self.resetCount <= self.maxResets)):  
            
            #set up uut
            self.setup_uut()
            # check uut initial state
            try:
                uut_client_sync = self.uut860.get_client_sync() 
                self.info("mr 0x3e802 = %s" % uut_client_sync)
                if uut_client_sync == '0':
                    uut_client_state = [0, 1, 0, 1, 0.0, 0, 0]
                    clientlostsync = 0
                    clientSecondsInSyncCurrent = int(time.time() - startTime)
                    clientSecondsOutOfSyncCurrent = 0
                    clientSecondsSinceReset = int(time.time() - startTime)
                    clientber = 0.0
                    clientPreFECBER = 0
                    clientberr = 0
                else:
                    uut_client_state = [1, 0, 0, 0, 0.0, 0, 0]
                    clientlostsync = int(uut_client_state[0])
                    clientSecondsInSyncCurrent = uut_client_state[1]
                    clientSecondsOutOfSyncCurrent = uut_client_state[2]
                    clientSecondsSinceReset = uut_client_state[3]
                    clientber = uut_client_state[4]
                    clientPreFECBER = uut_client_state[5]
                    clientberr = uut_client_state[6]
            except:
                self.info("Got exception!")
                uut_client_state = [1, 0, 0, 0, 0.0, 0, 0]
                clientlostsync = int(uut_client_state[0])
                clientSecondsInSyncCurrent = uut_client_state[1]
                clientSecondsOutOfSyncCurrent = uut_client_state[2]
                clientSecondsSinceReset = uut_client_state[3]
                clientber = uut_client_state[4]
                clientPreFECBER = uut_client_state[5]
                clientberr = uut_client_state[6]

            #lost sync determination
            if (clientlostsync == 1):
                self.resetState = self.uut860.get_4011_soft_reset_status()
                if self.resetState == True:
                    self.info("UUT was reset.\n")
                    self.lf.write("\n\nUUT was reset.\n")
                    self.df.write("\n\nUUT was reset.\n")
                    self.db.msg += ("\n\nUUT was reset.\n")
                    time.sleep(30)
                    self.resetCount +=1
            else:
                self.resetState = False
        
        #failure determination
        if (self.resetCount > self.maxResets):
            self.passing = False #uut was reset
            self.failed("UUT was reset more than %s times." % self.maxResets)
        if (clientlostsync == 1) and (self.resetState == False):
            self.passing = False #uut is out of sync
            self.failed("UUT was out of sync.")        
        
        #initial status output
        self.info("Initial: LostSync: %s SecondsInSync: %s ResetCount: %s" % (clientlostsync, clientSecondsInSyncCurrent, self.resetCount))
        self.lf.write("\n\nInitial: LostSync: %s SecondsInSync: %s ResetCount: %s\n" % (clientlostsync, clientSecondsInSyncCurrent, self.resetCount))
        self.df.write("\n\nInitial: LostSync: %s SecondsInSync: %s ResetCount: %s\n" % (clientlostsync, clientSecondsInSyncCurrent, self.resetCount))
        self.db.msg += ("\n\nInitial: LostSync: %s SecondsInSync: %s ResetCount: %s\n" % (clientlostsync, clientSecondsInSyncCurrent, self.resetCount))    
  
        #update database
        self._update_uut_db(db_info)
Esempio n. 7
0
    def initialize(self):
        # create aliases
        tb = self.config.testbed
        self.band_type = self.config.band_type
        self.dicon_band_sw_dict = self.config.dicon_band_sw_dict

        if 'P_FIBER_SPOOL_SEL' in self.config.testbed.keys():
            try:
                if self.band_type == 'L':
                    # the ProgCD for L-Band has a different address.
                    self.info("### Configurien for L-band configuration...")
                    self.PROGCD = tb["ProgCD_L"]
            except:
                self.info("### Configuring for C-band configuration...")
                
                self.PROGCD = tb["ProgCD"]

            self.DiCon_L           = tb['DiCon_SW_L']
            self.P_EDFA_SEL        = tb['P_EDFA_SEL']
            self.P_REF_SEL         = tb['P_REF_SEL']
            self.P_FILTER_SEL      = tb['P_FILTER_SEL']
            self.P_FIBER_SPOOL_SEL = tb['P_FIBER_SPOOL_SEL']

            p_edfa_sel_name = self.P_EDFA_SEL.name
            p_edfa_sel_mod_name = self.P_EDFA_SEL.sw_mod
            p_ref_sel_mod_name = self.P_REF_SEL.sw_mod
            p_filter_sel_mod_name = self.P_FILTER_SEL.sw_mod
            p_fiber_spool_sel_mod_name = self.P_FIBER_SPOOL_SEL.sw_mod
            # configuration is such that 1 is for L-band, 2 is for C-band
            p_band_sw_pos = self.dicon_band_sw_dict[self.band_type][p_edfa_sel_name]
            self.info("Setting all BAND_TYPE switches to position: %s" % p_band_sw_pos)
            self.info("Setting %s to %s" % (p_edfa_sel_mod_name, p_band_sw_pos))
            self.DiCon_L.set_switch(p_edfa_sel_mod_name, p_band_sw_pos, 1)
            self.DiCon_L.set_switch(p_edfa_sel_mod_name, p_band_sw_pos, 2)
            self.DiCon_L.set_switch(p_edfa_sel_mod_name, p_band_sw_pos, 3)

            self.info("Setting %s to %s" % (p_ref_sel_mod_name, p_band_sw_pos))
            self.DiCon_L.set_switch(p_ref_sel_mod_name, p_band_sw_pos, 1)
            self.DiCon_L.set_switch(p_ref_sel_mod_name, p_band_sw_pos, 2)
            self.DiCon_L.set_switch(p_ref_sel_mod_name, p_band_sw_pos, 3)

            self.info("Setting %s to %s" % (p_filter_sel_mod_name, p_band_sw_pos))
            self.DiCon_L.set_switch(p_filter_sel_mod_name, p_band_sw_pos, 1)
            self.DiCon_L.set_switch(p_filter_sel_mod_name, p_band_sw_pos, 2)
            self.DiCon_L.set_switch(p_filter_sel_mod_name, p_band_sw_pos, 3)

            self.info("Setting %s to %s" % (p_fiber_spool_sel_mod_name, p_band_sw_pos))
            self.DiCon_L.set_switch(p_fiber_spool_sel_mod_name, p_band_sw_pos, 1)
            self.DiCon_L.set_switch(p_fiber_spool_sel_mod_name, p_band_sw_pos, 2)
            self.DiCon_L.set_switch(p_fiber_spool_sel_mod_name, p_band_sw_pos, 3)
            self.REFRX = tb["ReferenceRx_L_Band_Mike"]
            self.REFRX_ber = tb["ReferenceRx_L_Band"]
        else:
            self.PROGCD = tb["ProgCD"]
            self.REFRX = tb["ReferenceRx_Mike"]
            self.REFRX_ber = tb["ReferenceRx"]

        self.dBox    = self.PROGCD.dBox
        
        self.DiCon = tb['DiCon_SW']
        self.VOAREFTX = tb["VOA_Line_Ref_Tx"]
        #self.PROGCD = tb["ProgCD"]
        self.OSA = tb["OSA"]
        self.VOAASE = tb["VOA_ASE"]
        self.VOAOUT = tb["VOA_Out"]
        self.DAQ = tb["DAQ"]
        self.PWAV = tb['PWAV']
        self.PDIR = tb['PDIR']
        self.UUT_LINE_OUTPUT_SW = tb['UUT_LINE_OUTPUT_SW']
        self.UUT_CLIENT_OUTPUT_SW = tb['UUT_CLIENT_OUTPUT_SW']
        self.refsn = self.REFRX.SN
        refsn = self.refsn 
        self.RxLOSThr = -24.0

        #log file
        self.lf = self.config.logfile

        #sql database
        self.lineTxBerArgs = {}
        self.errorCount = {}
        # test type:
        self.UUT_TEST_TYPE = self.config.UUT_TEST_TYPE

        self.init_osnr = self.config.init_osnr

        # step 1: set ProgCD SW6 to CNT to disable light from coming in.
        self.PROGCD.dBox.set_switch(6, 'cnt')

        # step 2. Disable VOAs
        self.info("Disabling VOA's ...")
        varAtt = self.config.varAtt
        for i in range(len(varAtt['voa'])):
            tb[varAtt['voa'][i]].state = "OFF"
            tb[varAtt['voa'][i]].attenuation = varAtt['att'][i]
            tb[varAtt['voa'][i]].wavelength = varAtt['wl'][i]

        # Making uut list
        from copy import copy
        # copy from stratatestrunner.py
        self.uutDict = copy(self.config.uut_dict)
        self.uutSnList = self.uutDict.keys()
        self.info("Number of UUTS TO BE TESTED: %s\n" %len(self.uutSnList))
        self.lf.write("\n\nNumber of UUTS TO BE TESTED: %s\n" 
                                            %len(self.uutSnList))
        for sn in self.uutSnList:
            self.info("UUT INFO: %s : %s : %s\n" 
                %(sn, self.uutDict[sn]["id"], self.uutDict[sn]["slot"]))
            self.lineTxBerArgs[self.uutDict[sn]["id"]] = {}
            self.errorCount[sn] = 0
            
        self.uutRefSnList = self.uutSnList# + [refsn]
        self.tdc_channel_dict = self.config.tdc_params
        self.dicon_sw_dict = self.config.dicon_sw_dict
        self.card_type_str = self.config.default_card_type
        
        # make serial objects for UUTs
        index = 0
        self.uut_ser_dict = {}
        # dictionary to store logger and diagnostic related resources.
        self.diag = {}
        self.diag_logger = {}

        self.diagnostic("Setting RxLOSThr on REF to %s" % self.RxLOSThr)
        self.REFRX.RxLOSThr = self.RxLOSThr
        demod_settle_time = 14000
        self.diagnostic("Extending REFRX (%s) demod settle time to %s msec" % (self.REFRX.SN, demod_settle_time))
        self.REFRX.extend_demod_settle_time(demod_settle_time)
        
        for sn, uut_dict in self.uutDict.items():

            slot = uut_dict['slot']
            if self.band_type == 'L':
                UUT_ser = "UUT_slot%s_L_mike" % slot
                UUT_ber = "UUT_slot%s_L" % slot
            else:
                UUT_ser = "UUT_slot%s_mike" % slot
                UUT_ber = "UUT_slot%s" % slot

            obj = uut_dict['obj']
            self.uut_ser_dict[slot] = self.config.testbed[UUT_ser]
            self.uut_ser_dict[UUT_ber] = self.config.testbed[UUT_ber]
            #self.uut_ser_dict[UUT_ber] = self.config.testbed[UUT_ber]
            self.lineTxBerArgs[self.uutDict[sn]["id"]] = []
            ser_obj = self.uut_ser_dict[slot]
            ber_obj = self.uut_ser_dict[UUT_ber]
            #self.diagnostic("Making 4400 to act like a 4040...")
            #ber_obj.set_4400_to_4040()

            self.info("Configuring diagnostic resources...")
            basepath = os.path.dirname(self.config.reportpath)
            self.info("Basepath: %s" % basepath)
            self.diag_logger[sn] = Diag.getLogger(basepath, sn)
            self.diag[sn] = Diag.DiagResponse()
            self.diag[sn].log = self.diag_logger[sn]
            self.diag[sn].dsp = ser_obj
            refsn_uut = "%s_%s" % (refsn, sn)
            self.diag_logger[refsn_uut] = Diag.getLogger(basepath, refsn_uut)
            self.diag[refsn_uut] = Diag.DiagResponse()
            self.diag[refsn_uut].log =  self.diag_logger[refsn_uut]
            self.diag[refsn_uut].dsp = self.REFRX


            self.uutDict[sn]['obj'] = ser_obj
            self.info("Setting UUT (slot%s:%s) for %s..." % (slot, sn,
                self.UUT_TEST_TYPE))
            self.info("Setting REFERENCE card (%s) for %s..." % (self.REFRX.SN, 'Rx'))

            #if self.UUT_TEST_TYPE == 'Tx':
            #    #ser_obj.set_uut_for_tx_tests()
            #    # 1. set LOF timeout
            #    tdc_lof_timeout = '6000.0'
            #    #tdc_lof_timeout = '1.0'
            #    self.info("Setting LOF timeout value %s for TDC..." % tdc_lof_timeout)
            #    ser_obj.set_tdc_lof_timeout(tdc_lof_timeout)
                 
                #if index == 0:  # we only set the reference once
                #    self.REFRX.set_ref_for_tx_tests(self.card_type_str)
            #else:
                #ser_obj.set_uut_for_rx_tests()
                #if index == 0: 
                    #self.REFRX.set_ref_for_rx_tests(self.card_type_str)
                
            self.errorCount[sn] = 0
            self.tdc_type = self.config.default_tdc_type

            tdc_type = self.tdc_type
            uut_tx_channel = self.tdc_channel_dict[tdc_type][0]
            self.diagnostic("Setting TxChan to channel %s" % uut_tx_channel)
            ser_obj.ModChan = uut_tx_channel
            self.REFRX.ModChan = uut_tx_channel
            self.info("UUT TxChan: %s" % ser_obj.ModChan)
            self.info("REF TxChan: %s" % self.REFRX.ModChan)
            self.diagnostic("Setting RxLOSThr on UUT(%s) to %s" % (sn,self.RxLOSThr))
            ser_obj.RxLOSThr =  self.RxLOSThr
            # XXX: the following is experimental...
            self.diagnostic("Extending UUT(%s)demod settle time to %s msec" % (sn,demod_settle_time))
            ser_obj.extend_demod_settle_time(demod_settle_time)

            if index == 0: # do the setting only once.
                # step3: set DiCon switch
                # SW3-SW5 are connected to P1 with the following mapping
                # SW1 & SW2 are UUT slot number dependent, so deal with them later.
                # P1:1 -> SW3, P1:2 -> SW4, P1:3 -> SW5
                # SW3-SW5 = ITU Channel H.  Assume H is connected to port 0, 1
                pdir_name = self.PDIR.name
                pdir_mod_name = "%s" % (self.PDIR.sw_mod)
                pdir_3_index = "%s:3" % pdir_name
                pdir_3_pos = self.dicon_sw_dict[tdc_type][pdir_3_index]
                self.info("Setting %s to position %d" % (pdir_3_index, pdir_3_pos))
                self.DiCon.set_switch(pdir_mod_name, pdir_3_pos, 3)
                    
                pwav_name = self.PWAV.name
                pwav_mod_name = "%s" % (self.PWAV.sw_mod)
                pwav_pos = self.dicon_sw_dict[tdc_type][pwav_name]#self.config.pwav_pos
                self.info("Setting %s:1, %s:2, %s:3 to position %d" % \
                        (pwav_name, pwav_name, pwav_name, pwav_pos))
                self.DiCon.set_switch(pwav_mod_name, pwav_pos, 1)
                self.DiCon.set_switch(pwav_mod_name, pwav_pos, 2)
                self.DiCon.set_switch(pwav_mod_name, pwav_pos, 3)
                pdir_1_index = "%s:1" % pdir_name
                pdir_2_index = "%s:2" % pdir_name
                pdir_1_pos = self.dicon_sw_dict[tdc_type][pdir_1_index]
                pdir_2_pos = self.dicon_sw_dict[tdc_type][pdir_2_index] #self.config.pdir_2_pos
                self.info("Setting %s to %d and %s to %d" % (pdir_1_index,
                    pdir_1_pos, pdir_2_index, pdir_2_pos))
                self.DiCon.set_switch(pdir_mod_name, pdir_1_pos, 1)
                self.DiCon.set_switch(pdir_mod_name, pdir_2_pos, 2)

            index += 1


        ## initializing Ref and UUT
        if (self.tdc_type == 1): # 1585.51
            self.chn = 51
        else:
            self.chn = 50
 
        self.info( "\nTime Stamp: %s" 
                  % (time.strftime( "%m-%d-%Y %H:%M:%S", time.localtime())))
Esempio n. 8
0
    def initialize(self):
        
        #test status and parameters
        self.resetState = True
        self.resetCount = 0
        self.maxResets = self.config.maxresets
        self.passing = True
        self.abort = False
        self.debugMode = self.config.debugmode
        
        # reading initial UUT params
        (min_chn, max_chn, odd_chn, even_chn, pwr, clpwr, cltxminpwr, cltxmaxpwr, losth, pminterval,
            rxpwr, rxmintol, rxmaxtol, clrxpwr, clrxmintol, clrxmaxtol, linetxmintol, linetxmaxtol) = self.config.uutParams
        tdcType = self.config.tdcType
        self.linemaxberr = self.config.lineberrlimit
        self.clientmaxberr = self.config.clientberrlimit
        self.uut_type = int(self.config.uuttype)        
        
        #initialize testbed
        tb = self.config.testbed
        
        #sql database
        self.burnInTestArgs = {}
        self.modTemps = {} 
          
        #data file
        pathname = self.get_pathname(self.config.dataFileName)
        self.df = file(pathname, "w")
        
        #log file
        self.lf = self.config.logfile
        
        # Making uut list
        from copy import copy
        self.uutDict = copy(self.config.uut_dict) #dict from stratatestrunner
        self.uutSnList = self.uutDict.keys()
        self.info("Number of UUTS TO BE TESTED: %s\n"  %len(self.uutSnList))
        self.lf.write("\n\nNumber of UUTS TO BE TESTED: %s\n" 
                                            %len(self.uutSnList))
        
        #Setting up the UUT test info
        for sn in self.uutSnList:    #only one UUT
            self.burnInTestArgs[self.uutDict[sn]["id"]] = []
            uut_slot = self.uutDict[sn]['slot']
            self.SLOT = int(uut_slot)
            self.serialno = sn
            
        #Setting up the UUT
        self.uut_ser_dict = {}
        for sn, uut_dict in self.uutDict.items():
            slot = uut_dict['slot']
            UUT_ser = "UUT_slot%s" % slot
            UUT_ser_mike = "UUT_slot%s_mike" % slot
            UUT_dbg = "UUT_slot%s_mike_debug" % slot
            self.uut860 = self.uutDict[sn]['obj']
            self.uutdsp = self.uutDict[sn]['mike']
            self.dbg_obj =  self.uutDict[sn]['mike_debug'] 
            self.uut_ser_dict[UUT_ser] = self.uut860
            self.uut_ser_dict[UUT_ser_mike] = self.uutdsp
        #create logging 
        self.info("Configuring diagnostic resources...")
        basepath = os.path.dirname(self.config.reportpath)
        self.info("Basepath: %s" % basepath)
        self.diag = {}

        # get a logger for the Mike-Debug shell
        sn_mike_debug = "%s_mike_debug" % sn
        dbg_logger, mike_debug_log_name  = Diag.getLogger(basepath, sn_mike_debug)
        self.diagnostic("Mike debug log located at '%s'" % os.path.dirname(mike_debug_log_name))
        self.diag[sn_mike_debug] = Diag.DiagResponse()
        self.diag[sn_mike_debug].log = dbg_logger
        self.diag[sn_mike_debug].dsp = self.dbg_obj
        self.diag[sn_mike_debug].logname = mike_debug_log_name 
        self.info("Starting mike-debug shell logging...")
        t_id  = thread.start_new_thread(Diag.dbgLogger,
            (self.diag[sn_mike_debug].log, self.dbg_obj))
        self.diag[sn_mike_debug].t_id = t_id
        self.info("Debug log started.....")
        
        #verify the tdc type
        uut_tdc_type = self.uutdsp.get_tdc_type()
        self.info("UUT TDC Type: %s" % (int(uut_tdc_type),))
        if (int(tdcType) != int(uut_tdc_type)):
            self.info("Part number from the command line does not match the UUT TDC Type of %s." % (uut_tdc_type,))
            while(1):
                status = upper(self.user_input("\nDo you want to (c)ontinue or (a)bort the BurnIn[c/a]?:"))
                if status == "A":
                    raise TestSuiteAbort, "Suite aborted."
                    break
                elif status == "C":
                    self.info("Operator selected to continue the test.\n")
                    break

        #getting initial UUT state
        startTime = time.time()    
        while((self.resetState == True) and (self.resetCount <= self.maxResets)):  
            
            #set up uut
            self.setup_uut()
            # check uut initial state
            try:
                uut_client_sync = self.uut860.get_client_sync() 
                self.info("mr 0x3e802 = %s" % uut_client_sync)
                if uut_client_sync == '0':
                    uut_client_state = [0, 1, 0, 1, 0.0, 0, 0]
                    clientlostsync = 0
                    clientSecondsInSyncCurrent = int(time.time() - startTime)
                    clientSecondsOutOfSyncCurrent = 0
                    clientSecondsSinceReset = int(time.time() - startTime)
                    clientber = 0.0
                    clientPreFECBER = 0
                    clientberr = 0
                else:
                    uut_client_state = [1, 0, 0, 0, 0.0, 0, 0]
                    clientlostsync = int(uut_client_state[0])
                    clientSecondsInSyncCurrent = uut_client_state[1]
                    clientSecondsOutOfSyncCurrent = uut_client_state[2]
                    clientSecondsSinceReset = uut_client_state[3]
                    clientber = uut_client_state[4]
                    clientPreFECBER = uut_client_state[5]
                    clientberr = uut_client_state[6]
            except:
                self.info("Got exception!")
                uut_client_state = [1, 0, 0, 0, 0.0, 0, 0]
                clientlostsync = int(uut_client_state[0])
                clientSecondsInSyncCurrent = uut_client_state[1]
                clientSecondsOutOfSyncCurrent = uut_client_state[2]
                clientSecondsSinceReset = uut_client_state[3]
                clientber = uut_client_state[4]
                clientPreFECBER = uut_client_state[5]
                clientberr = uut_client_state[6]

            #lost sync determination
            if (clientlostsync == 1):
                self.resetState = self.uut860.get_4011_soft_reset_status()
                if self.resetState == True:
                    self.info("UUT was reset.\n")
                    self.lf.write("\n\nUUT was reset.\n")
                    self.df.write("\n\nUUT was reset.\n")
                    time.sleep(30)
                    self.resetCount +=1
            else:
                self.resetState = False
        
        #failure determination
        if (self.resetCount > self.maxResets):
            self.passing = False #uut was reset
            self.failed("UUT was reset more than %s times." % self.maxResets)
        if (clientlostsync == 1) and (self.resetState == False):
            self.passing = False #uut is out of sync
            self.failed("UUT was out of sync.")        
        
        #initial status output
        self.info("Initial: LostSync: %s SecondsInSync: %s ResetCount: %s" % (clientlostsync, clientSecondsInSyncCurrent, self.resetCount))
        self.lf.write("\n\nInitial: LostSync: %s SecondsInSync: %s ResetCount: %s\n" % (clientlostsync, clientSecondsInSyncCurrent, self.resetCount))
        self.df.write("\n\nInitial: LostSync: %s SecondsInSync: %s ResetCount: %s\n" % (clientlostsync, clientSecondsInSyncCurrent, self.resetCount))
Esempio n. 9
0
    def initialize(self):
        # create aliases
        tb = self.config.testbed
        self.tdc_channel_dict = self.config.tdc_params

        #log file
        self.lf = self.config.logfile

        #sql database
        self.errorCount = {}

        # Making uut list
        from copy import copy
        # copy from stratatestrunner.py
        self.uutDict = copy(self.config.uut_dict)
        self.uutSnList = self.uutDict.keys()
        self.info("Number of UUTS TO BE TESTED: %s\n" %len(self.uutSnList))
        self.lf.write("\n\nNumber of UUTS TO BE TESTED: %s\n" 
                                            %len(self.uutSnList))
        for sn in self.uutSnList:
            self.info("UUT INFO: %s : %s : %s\n" 
                %(sn, self.uutDict[sn]["id"], self.uutDict[sn]["slot"]))
            self.errorCount[sn] = 0
            
        self.uutRefSnList = self.uutSnList# + [refsn]
        # make serial objects for UUTs
        index = 0
        self.uut_ser_dict = {}
        # dictionary to store logger and diagnostic related resources.
        self.diag = {}
        self.diag_logger = {}

        #----- reference dbg window logger --------------------- 
        # get a logger for the reference Mike-Debug shell
        self.info("Configuring diagnostic resources...")
        basepath = os.path.dirname(self.config.reportpath)


        for sn, uut_dict in self.uutDict.items():
            slot = uut_dict['slot']
            UUT_ser = "UUT_slot%s_mike" % slot
            UUT_ber = "UUT_slot%s" % slot
            UUT_dbg = "UUT_slot%s_mike_debug" % slot
            obj = uut_dict['obj']

            self.uut_ser_dict[slot] = self.config.testbed[UUT_ser]
            self.uut_ser_dict[UUT_ber] = self.config.testbed[UUT_ber]
            self.uut_ser_dict[UUT_dbg] = self.config.testbed[UUT_dbg]
            
            ser_obj = self.uut_ser_dict[slot]
            ber_obj = self.uut_ser_dict[UUT_ber]
            dbg_obj = self.uut_ser_dict[UUT_dbg]
            self.info("Setting UUT TDC to Auto-Cont mode...")
            ser_obj.set_tdc_auto_mode('Cont')

            if self.config.flags.DEBUG:
                self.info("Dumping out UUT TDC setting...")
                raw_info = ser_obj.show_tdc_state()
                self.info("%s" % raw_info)

            self.info("Configuring diagnostic resources...")
            basepath = os.path.dirname(self.config.reportpath)
            self.info("Basepath: %s" % basepath)
            #----- dbg window logger --------------------- 
            # get a logger for the Mike-Debug shell
            sn_mike_debug = "%s_mike_debug" % sn
            dbg_logger, mike_debug_log_name = Diag.getLogger(basepath, sn_mike_debug, dbg=True)
            self.diagnostic("UUT Mike debug log located at '%s'" % os.path.dirname(mike_debug_log_name))
            
            self.diag[sn_mike_debug] = Diag.DiagResponse()
            self.diag[sn_mike_debug].log = dbg_logger
            self.diag[sn_mike_debug].dsp = dbg_obj
            self.diag[sn_mike_debug].logname = mike_debug_log_name 
            self.info("Starting mike-debug shell logging...")
            t_id  = thread.start_new_thread(Diag.dbgLogger,
                    (self.diag[sn_mike_debug].log, dbg_obj))
            self.diag[sn_mike_debug].t_id = t_id
            #self.diag[sn_mike_debug].thread = thread.start_new_thread(Diag.dbgLogger, (self.diag[sn_mike_debug].log, dbg_obj))
            self.info("Debug log started.....")

            self.uutDict[sn]['obj'] = ser_obj
            self.errorCount[sn] = 0
            
            self.tdc_type = ser_obj.get_tdc_type()
            tdc_type = self.tdc_type
            uut_tx_channel = self.tdc_channel_dict[tdc_type][0]
            self.diagnostic("Setting TxChan to channel %s" % uut_tx_channel)
            ser_obj.ModChan = uut_tx_channel
            self.info("UUT TxChan: %s" % ser_obj.ModChan)

        ## initializing Ref and UUT
        if (self.tdc_type == 1): # 1585.51
            self.chn = 51
        else:
            self.chn = 50
 
        self.info( "\nTime Stamp: %s" 
                  % (time.strftime( "%m-%d-%Y %H:%M:%S", time.localtime())))
Esempio n. 10
0
    def initialize(self):
        # create aliases
        tb = self.config.testbed
        self.SC = tb['SC']
        self.DiCon = tb['DiCon_SW']
        self.VOAREFTX = tb["VOA_Line_Ref_Tx"]
        self.PROGCD = tb["ProgCD"]
        self.dBox    = self.PROGCD.dBox
        self.OSA = tb["OSA"]
        self.VOAASE = tb["VOA_ASE"]
        self.VOAOUT = tb["VOA_Out"]
        self.REFRX = tb["ReferenceRx_Mike"]
        self.REFRX_ber = tb["ReferenceRx"]
        self.DAQ = tb["DAQ"]
        self.PWAV = tb['PWAV']
        self.PDIR = tb['PDIR']
        self.UUT_LINE_OUTPUT_SW = tb['UUT_LINE_OUTPUT_SW']
        self.UUT_CLIENT_OUTPUT_SW = tb['UUT_CLIENT_OUTPUT_SW']
        self.refsn = self.REFRX.SN
        refsn = self.refsn 
        try:
            cd_list  = self.config.cdlist.split(',')
            self.cdTestList = []
            for cd in cd_list:
                self.cdTestList.append(int(cd))
            self.diagnostic("### CD list: %s" % self.cdTestList)
        except:
            self.cdTestList = self.config.cdTestList
            self.diagnostic("### CD list: %s" % self.cdTestList)
        try:
            tmp_list = self.config.osnrlist.split(',')
            self.osnrList = []
            for osnr in tmp_list:
                osnr_pq = PQ("%s dB" % osnr)
                self.osnrList.append(osnr_pq)
            self.diagnostic("### OSNR list: %s" % self.osnrList)
        except:
            self.osnrList = self.config.osnrList
            self.diagnostic("### OSNR list: %s" % self.osnrList)


        self.RxLOSThr = -24.0

        #log file
        self.lf = self.config.logfile

        #sql database
        self.lineTxBerArgs = {}
        self.errorCount = {}
        # test type:
        self.UUT_TEST_TYPE = self.config.UUT_TEST_TYPE

        self.init_osnr = self.config.init_osnr

        # step 1: set ProgCD SW6 to CNT to disable light from coming in.
        self.PROGCD.dBox.set_switch(6, 'cnt')

        # step 2. Disable VOAs
        self.info("Disabling VOA's ...")
        varAtt = self.config.varAtt
        for i in range(len(varAtt['voa'])):
            tb[varAtt['voa'][i]].state = "OFF"
            tb[varAtt['voa'][i]].attenuation = varAtt['att'][i]
            tb[varAtt['voa'][i]].wavelength = varAtt['wl'][i]

        # Making uut list
        from copy import copy
        # copy from stratatestrunner.py
        self.uutDict = copy(self.config.uut_dict)
        self.uutSnList = self.uutDict.keys()
        self.info("Number of UUTS TO BE TESTED: %s\n" %len(self.uutSnList))
        self.lf.write("\n\nNumber of UUTS TO BE TESTED: %s\n" 
                                            %len(self.uutSnList))
        for sn in self.uutSnList:
            self.info("UUT INFO: %s : %s : %s\n" 
                %(sn, self.uutDict[sn]["id"], self.uutDict[sn]["slot"]))
            self.lineTxBerArgs[self.uutDict[sn]["id"]] = {}
            self.errorCount[sn] = 0
            
        self.uutRefSnList = self.uutSnList# + [refsn]
        self.tdc_channel_dict = self.config.tdc_params
        self.dicon_sw_dict = self.config.dicon_sw_dict
        # get the rx dicon switch configuration for testing Reference
        self.dicon_sw_dict_rx = self.config.dicon_sw_dict_rx
        self.card_type_str = self.config.default_card_type
        
        # make serial objects for UUTs
        index = 0
        self.uut_ser_dict = {}
        # dictionary to store logger and diagnostic related resources.
        self.diag = {}
        self.diag_logger = {}

        self.diagnostic("Setting RxLOSThr on REF to %s" % self.RxLOSThr)
        self.REFRX.RxLOSThr = self.RxLOSThr
        demod_settle_time = 14000
        self.diagnostic("Extending REFRX (%s) demod settle time to %s msec" % (self.REFRX.SN, demod_settle_time))
        self.REFRX.extend_demod_settle_time(demod_settle_time)
        #----- reference dbg window logger --------------------- 
        # get a logger for the reference Mike-Debug shell
        refsn_mike_debug = "ReferenceRx_mike_debug" 
        refsn_dbg_obj = self.config.testbed[refsn_mike_debug]
        self.info("Configuring diagnostic resources...")
        basepath = os.path.dirname(self.config.reportpath)

        refsn_dbg_logger, refsn_mike_debug_log_name = Diag.getLogger(basepath, refsn_mike_debug, dbg=True)
        self.diagnostic("Reference Mike debug log located at '%s'" % os.path.dirname(refsn_mike_debug_log_name))

        self.diag[refsn_mike_debug] = Diag.DiagResponse()
        self.diag[refsn_mike_debug].log = refsn_dbg_logger
        self.diag[refsn_mike_debug].dsp = refsn_dbg_obj
        self.diag[refsn_mike_debug].logname = refsn_mike_debug_log_name 
        self.info("Starting Reference mike-debug shell logging...")
        refsn_t_id  = thread.start_new_thread(Diag.dbgLogger,
                (self.diag[refsn_mike_debug].log, refsn_dbg_obj))
        self.diag[refsn_mike_debug].t_id = refsn_t_id
        #self.diag[sn_mike_debug].thread = thread.start_new_thread(Diag.dbgLogger, (self.diag[sn_mike_debug].log, dbg_obj))
        self.info("Reference mike debug log started.....")
        self.info("Setting REF TDC to Auto-Cont mode...") 
        self.REFRX.set_tdc_auto_mode('Cont')
        if self.config.flags.DEBUG:
            self.info("Dumping out REF TDC setting...")
            raw_info = self.REFRX.show_tdc_state()
            self.info("%s" % raw_info)

        for sn, uut_dict in self.uutDict.items():

            slot = uut_dict['slot']
            UUT_ser = "UUT_slot%s_mike" % slot
            UUT_ber = "UUT_slot%s" % slot
            UUT_dbg = "UUT_slot%s_mike_debug" % slot
            obj = uut_dict['obj']

            self.uut_ser_dict[slot] = self.uutDict[sn]['mike']
            self.uut_ser_dict[UUT_ber] = self.uutDict[sn]['obj']
            self.uut_ser_dict[UUT_dbg] = self.uutDict[sn]['mike_debug'] #config.testbed[UUT_dbg]

            
            self.lineTxBerArgs[self.uutDict[sn]["id"]] = []
            ser_obj = self.uut_ser_dict[slot]
            ber_obj = self.uut_ser_dict[UUT_ber]
            dbg_obj = self.uut_ser_dict[UUT_dbg]
            self.info("Setting UUT TDC to Auto-Cont mode...")
            ser_obj.set_tdc_auto_mode('Cont')

            if self.config.flags.DEBUG:
                self.info("Dumping out UUT TDC setting...")
                raw_info = ser_obj.show_tdc_state()
                self.info("%s" % raw_info)

            self.info("Configuring diagnostic resources...")
            basepath = os.path.dirname(self.config.reportpath)
            self.info("Basepath: %s" % basepath)
            #----- dbg window logger --------------------- 
            # get a logger for the Mike-Debug shell
            sn_mike_debug = "%s_mike_debug" % sn
            dbg_logger, mike_debug_log_name = Diag.getLogger(basepath, sn_mike_debug, dbg=True)
            self.diagnostic("UUT Mike debug log located at '%s'" % os.path.dirname(mike_debug_log_name))
            
            self.diag[sn_mike_debug] = Diag.DiagResponse()
            self.diag[sn_mike_debug].log = dbg_logger
            self.diag[sn_mike_debug].dsp = dbg_obj
            self.diag[sn_mike_debug].logname = mike_debug_log_name 
            self.info("Starting mike-debug shell logging...")
            t_id  = thread.start_new_thread(Diag.dbgLogger,
                    (self.diag[sn_mike_debug].log, dbg_obj))
            self.diag[sn_mike_debug].t_id = t_id
            #self.diag[sn_mike_debug].thread = thread.start_new_thread(Diag.dbgLogger, (self.diag[sn_mike_debug].log, dbg_obj))
            self.info("Debug log started.....")

            self.uutDict[sn]['obj'] = ser_obj
            self.info("Setting UUT (slot%s:%s) for %s..." % (slot, sn,
                self.UUT_TEST_TYPE))
            self.info("Setting REFERENCE card (%s) for %s..." % (self.REFRX.SN, 'Rx'))

            #if self.UUT_TEST_TYPE == 'Tx':
            #    #ser_obj.set_uut_for_tx_tests()
            #    # 1. set LOF timeout
            #    tdc_lof_timeout = '6000.0'
            #    #tdc_lof_timeout = '1.0'
            #    self.info("Setting LOF timeout value %s for TDC..." % tdc_lof_timeout)
            #    ser_obj.set_tdc_lof_timeout(tdc_lof_timeout)
                 
                #if index == 0:  # we only set the reference once
                #    self.REFRX.set_ref_for_tx_tests(self.card_type_str)
            #else:
                #ser_obj.set_uut_for_rx_tests()
                #if index == 0: 
                    #self.REFRX.set_ref_for_rx_tests(self.card_type_str)
                
            self.errorCount[sn] = 0
            self.tdc_type = self.config.default_tdc_type

            tdc_type = self.tdc_type
            uut_tx_channel = self.tdc_channel_dict[tdc_type][0]
            self.diagnostic("Setting TxChan to channel %s" % uut_tx_channel)
            ser_obj.ModChan = uut_tx_channel
            self.REFRX.ModChan = uut_tx_channel
            self.info("UUT TxChan: %s" % ser_obj.ModChan)
            self.info("REF TxChan: %s" % self.REFRX.ModChan)
            self.diagnostic("Setting RxLOSThr on UUT(%s) to %s" % (sn,self.RxLOSThr))
            ser_obj.RxLOSThr =  self.RxLOSThr
            # XXX: the following is experimental...
            self.diagnostic("Extending UUT(%s)demod settle time to %s msec" % (sn,demod_settle_time))
            ser_obj.extend_demod_settle_time(demod_settle_time)


        self.info("Turning on Input VOAs and Stabilizing.....\n" )
        for voa in self.config.voaInList:
            tb[voa].state = "ON"
        self.VOAOUT.state = "ON"
        time.sleep(10)    # time to settle all instrument


        ## initializing Ref and UUT
        if (self.tdc_type == 1): # 1585.51
            self.chn = 51
        else:
            self.chn = 50
 
        self.info( "\nTime Stamp: %s" 
                  % (time.strftime( "%m-%d-%Y %H:%M:%S", time.localtime())))