コード例 #1
0
ファイル: kratos.py プロジェクト: Master-An/cpu_power_final
    def SetDataCollectionPath(self):
        """
        #-------------------------------------------------------------------------------------------------------------------
        # Name: SetDataCollectionPath
        # Input: Takes no argument
        # Description: Sets up path to save UDAS waveform
        # Return: StatusResult() object
        #-------------------------------------------------------------------------------------------------------------------
        """
        # SetOutputDirectory function is used to set the Automation logs output directory location
        logger.info("Setting Logs Location for saving UDAS")

        dateTimeStrPath = "Automation\\Logs\\" + str(datetime.now().strftime('%Y-%m-%d_%H-%M-%S'))
        kratosPcLocalPath = "C:\\" + dateTimeStrPath

        self.logsPath = "\\\\" + TestSuiteConfig.KratosIpAddress + "\\C$\\" + dateTimeStrPath

        logger.info('KRATOS : Log directory path : ' + self.logsPath)
        result =self.kratosHandler.SetOutputDirectory(kratosPcLocalPath)
        if result.HasError():
            logger.error("Error in setting up UDAS logs location :  " + result.ErrorMessage())
            recoveryResult = self.KratosErrorHandler()
            return recoveryResult

        return StatusResult.Success()
コード例 #2
0
ファイル: kratos.py プロジェクト: Master-An/cpu_power_final
    def GetPlotStatistics(self):
        """
        #-------------------------------------------------------------------------------------------------------------------
        # Name: GetPlotStatistics
        # Input: Takes no argument
        # Description: Prints measured power number
        # Return: StatusResult() object
        #-------------------------------------------------------------------------------------------------------------------
        """

        logger.info("Reading Measured Power Numbers")

        statisticsList = [1,2]

        result = self.kratosHandler.GetSinglePlotStatistics(statisticsList)
        if result.HasError():
            logger.error("Error in Reading Power Numbers :  " + result.CmdResult.Output)
            recoveryResult = self.KratosErrorHandler()
            return recoveryResult

        logger.info("Measured Current : " + statisticsList[0])
        logger.info("Measured Voltage : " + statisticsList[1])

        TestCasePowerMetrics.MeasuredCurrent = str(statisticsList[0])
        TestCasePowerMetrics.AverageVoltage = str(statisticsList[1])

        return StatusResult.Success()
コード例 #3
0
ファイル: kratos.py プロジェクト: Master-An/cpu_power_final
    def KratosErrorHandler(self):
        """
        -------------------------------------------------------------------------
        # Name: KratosErrorHandler
        # Input: Takes no argument
        # Description: Ping and restart Kratos Application for Recovery
        # Return: StatusResult.Error
        -------------------------------------------------------------------------
        """
        self.retryOnErrorCount = self.retryOnErrorCount + 1
        if self.retryOnErrorCount > 3 :
             return StatusResult.Error("Failled to Handle Error and Restart Kratos after Max Tries.")

        try:
            logger.info("Entered Kratos Error Handling")
            kratosRecovery  = KratosRecovery()
            result = kratosRecovery.PingKratos(TestSuiteConfig.KratosIpAddress, 3600)
            if result.HasError() :
                logger.error("Could Not Ping Kratos Machine in 60 Minutes.")
                return result
            result = kratosRecovery.RestartKratos(TestSuiteConfig.KratosIpAddress)
            logger.info("Rebooting Kratos Software and Test Device")
            if result.HasError():
                return result
            logger.info("Re-Configuring Kratos")
            result = self.KratosSetup()
            if result.HasError():
                return result

            # SetConfigurationFile function is used to recall the cfg file saved by user on Kratos
            configFile = TestCaseConfig.ChannelConfiguration if TestCaseConfig.ChannelConfiguration else TestSuiteConfig.ChannelConfiguration
            result = self.SetConfigurationFile(configFile)
            if result.HasError():
                raise Exception(result.ErrorMessage())

            # SetPowerConfiguration function is used to configure the Voltage, Current & OVP values on KRATOS
            result = self.SetPowerConfiguration()
            if result.HasError():
                raise Exception(result.ErrorMessage())

            # SetAcquisitionConfiguration function is used to set Acquisition parameters on KRATOS.
            result = self.SetAcquisitionConfiguration()
            if result.HasError():
                raise Exception(result.ErrorMessage())

            result = self.SetDefaultOptions()
            if result.HasError():
                raise Exception(result.ErrorMessage())

            logger.info("Booting up Device")
            result = self.PowerOn()
            if result.HasError():
                return result
            result = self.UsbOn()
            if result.HasError():
                return result
        except Exception as e:
            logger.error(str(e))
        return StatusResult.Error("Failing This Attempt To Retry Test After Kratos Restart")
コード例 #4
0
 def GetThermalValue(self,
                     para,
                     startRow=0,
                     endRow=0,
                     target="cpuss0-max-step"):
     logger.info("Calculating Average Thermal Value")
     FPSColumn = -1
     totalFPS = 0
     countFPS = 0
     rowNumber = 0
     averageThermalValue = -1
     TsensLog = ""
     files = os.listdir(os.path.join(para.TestCaseFolder, "logs"))
     if len(files) == 0:
         logger.warning("There is no tsens logger")
         return averageThermalValue
     for file in files:
         fileFullPath = os.path.join(
             os.path.join(para.TestCaseFolder, "logs"), file)
         if os.path.splitext(file)[1].lower() == ".csv":
             TsensLog = fileFullPath
     if TsensLog == "":
         logger.warning("There is no tsens logger csv file")
         return averageThermalValue
     try:
         with open(TsensLog, 'r') as f:
             reader = csv.reader(f)
             for row in reader:
                 if FPSColumn == -1:
                     i = 0
                     for item in row:
                         if item == target:
                             FPSColumn = i
                             break
                         i += 1
                 else:
                     if rowNumber >= startRow:
                         #logger.info(row)
                         if row == []:
                             break
                         if endRow == 0:
                             totalFPS += int(row[FPSColumn])
                             countFPS += 1
                         else:
                             if rowNumber <= endRow:
                                 totalFPS += int(row[FPSColumn])
                                 countFPS += 1
                             else:
                                 break
                     rowNumber += 1
             f.close()
         averageThermalValue = round(
             (float(totalFPS) / float(countFPS) / 1000.0), 2)
     except Exception as e:
         logger.error("Error in calculating average FPS: " + str(e))
         averageThermalValue = -1
     logger.info("Average FPS: " + str(averageThermalValue))
     return averageThermalValue
コード例 #5
0
    def SendCommandAndGetResponse(methodStrings, timeout=30):
        executionString = CommonApplicationUtilities._ToolsPath + "QcUSBSwitchTool\\QcUSBSwitchTool.exe " + methodStrings

        logger.debug("Executing Command :" + executionString)
        result = CommandLine.RunCommand(executionString, timeout)
        if (result.Status.HasError()
                or (not 'Success' in result.CmdResult.Output)):
            logger.error(result.CmdResult.Output)
            result.Status.AddError(result.CmdResult.Output)

        return result
コード例 #6
0
ファイル: kratos.py プロジェクト: Master-An/cpu_power_final
    def KratosSetup(self):
        """
        #-------------------------------------------------------------------------------------------------------------------
        # Name: KratosSetup
        # Input: Takes no argument
        # Description: Sets up KRATOS calibration
        # Return: StatusResult() object
        #-------------------------------------------------------------------------------------------------------------------
        """
        result = self.SetKratosInIdleState()
        if result.HasError() :
            logger.error("Error in Setting Kratos to IDLE State. " + result.ErrorMessage())
            return StatusResult.Error("Error in Setting Kratos to IDLE State. " + result.ErrorMessage())

        #Checking calibration on KRATOS
        calStatusList = []
        result = self.GetCalibrationStatus(calStatusList)
        if result.HasError():
            return result

        if 'False' in calStatusList[0]:

            logger.warning("Starting self calibration")

            result = self.UsbOff()
            if result.HasError():
                return result

            result = self.PowerOff()
            if result.HasError():
                return result

            result = self.kratosHandler.SelfCalibration()
            if result.HasError():
                return result

            result = self.WaitForIdle()
            if result.HasError():
                return result

            calStatusList = []
            result = self.GetCalibrationStatus(calStatusList)
            if result.HasError():
                return result

            if 'False' in calStatusList[0]:
                return StatusResult.Error('Failed to complete KRATOS self calibration')
            '''
            result = self.PowerOn()
            if result.HasError():
                return result
            '''
        return StatusResult.Success()
コード例 #7
0
ファイル: kratos.py プロジェクト: Master-An/cpu_power_final
    def StartMeasurement(self):
        """
        #-------------------------------------------------------------------------------------------------------------------
        # Name: StartMeasurement
        # Input: Takes no argument
        # Description: Starts power measurement on KRATOS
        # Return: StatusResult() object
        #-------------------------------------------------------------------------------------------------------------------
        """
        logger.info('KRATOS : Starting measurement')

        # SendSwTrigger function is used to send Software trigger to DUT
        result = self.kratosHandler.SendSwTrigger()
        if result.HasError():
            logger.error("Error in Sending Software Trigger / Starting measurement :  " + result.ErrorMessage())
            recoveryResult = self.KratosErrorHandler()
            return recoveryResult

        return StatusResult.Success()
コード例 #8
0
    def UsbOff(self):
        """
        #-------------------------------------------------------------------------------------------------------------------
        # Name: UsbOff
        # Input: Takes no argument
        # Description: Disable USB on KRATOS
        # Return: StatusResult() object
        #-------------------------------------------------------------------------------------------------------------------
        """

        # Disconnecting the USB by passing argument - false
        logger.info('KRATOSLITE: USB OFF')

        result = QcUsbSwitch.SetUsbConnection('usb_off')
        if result.Status.HasError():
            logger.error("Error in Turning OFF USB :  " + result.CmdResult.Output)
            return result.Status

        return StatusResult.Success()
コード例 #9
0
    def UsbOn(self):
        """
        #-------------------------------------------------------------------------------------------------------------------
        # Name: UsbOn
        # Input: Takes no argument
        # Description: Enable USB on KRATOS
        # Return: StatusResult() object
        #-------------------------------------------------------------------------------------------------------------------
        """

        # Connecting the USB by passing argument - True
        logger.info('KRATOSLITE: USB ON')

        result = QcUsbSwitch.SetUsbConnection('usb_on')
        if result.Status.HasError():
            logger.error("Error in Turning ON USB :  " + result.CmdResult.Output)
            return result.Status
        logger.info('Waiting for 10 Seconds for USB to stabilise')
        time.sleep(10)
        return StatusResult.Success()
コード例 #10
0
ファイル: kratos.py プロジェクト: Master-An/cpu_power_final
    def UsbOff(self):
        """
        #-------------------------------------------------------------------------------------------------------------------
        # Name: UsbOff
        # Input: Takes no argument
        # Description: Disable USB on KRATOS
        # Return: StatusResult() object
        #-------------------------------------------------------------------------------------------------------------------
        """

        # Disconnecting the USB by passing argument - false
        logger.info('KRATOS: USB OFF')

        result = self.kratosHandler.SetUsbConnection('false')
        if result.HasError():
            logger.error("Error in Turning OFF USB :  " + result.ErrorMessage())
            recoveryResult = self.KratosErrorHandler()
            return recoveryResult

        return StatusResult.Success()
コード例 #11
0
ファイル: kratos.py プロジェクト: Master-An/cpu_power_final
    def SetAcquisitionConfiguration(self):
        """
        #-------------------------------------------------------------------------------------------------------------------
        # Name: SetAcquisitionConfiguration
        # Input: Takes no argument
        # Description: Sets up Acquisition configuration parameters AccuracyMode, SampleRate, MeasurementDuration, etc
        # Return: StatusResult() object
        #-------------------------------------------------------------------------------------------------------------------
        """
        samplingRate = TestCaseConfig.SampleRate if (TestCaseConfig.SampleRate != '') else TestSuiteConfig.SampleRate
        logger.info("Configuring Acquisition Parameters : " + TestSuiteConfig.AccuracyMode + ", " + samplingRate + ", " + str(TestCaseConfig.MeasurementDuration) + ", MANUAL")

        # SetAcquisitionParameters function is used to configure the parameters AccuracyMode, SampleRate, MeasurementDuration, etc on KRATOS
        result = self.kratosHandler.SetAcquisitionParameters(TestSuiteConfig.AccuracyMode, samplingRate, str(TestCaseConfig.MeasurementDuration), "MANUAL")
        if result.HasError():
            logger.error("Error in configuring Acquisition Parameters :  " + result.ErrorMessage())
            recoveryResult = self.KratosErrorHandler()
            return recoveryResult

        return StatusResult.Success()
コード例 #12
0
ファイル: kratos.py プロジェクト: Master-An/cpu_power_final
    def SetPowerConfiguration(self):
        """
        #-------------------------------------------------------------------------------------------------------------------
        # Name: SetPowerConfiguration
        # Input: Takes no argument
        # Description: Sets up power configuration parameters Voltage, Current, OVP
        # Return: StatusResult() object
        #-------------------------------------------------------------------------------------------------------------------
        """

        logger.info("Setting Voltage, Current & OVP : " + TestSuiteConfig.VoltageLevel + ", " + TestSuiteConfig.CurrentLimit + ", " + TestSuiteConfig.OVPLimit)

        # ConfigurePowerSupply function is used to configure the Voltage, Current & OVP values on KRATOS
        result =self.kratosHandler.ConfigurePowerSupply(TestSuiteConfig.VoltageLevel, TestSuiteConfig.CurrentLimit, TestSuiteConfig.OVPLimit)
        if result.HasError():
            logger.error("Error in Configuring Power Supply :  " + result.ErrorMessage())
            recoveryResult = self.KratosErrorHandler()
            return recoveryResult

        return StatusResult.Success()
コード例 #13
0
ファイル: kratos.py プロジェクト: Master-An/cpu_power_final
    def StopMeasurement(self):
        """
        #-------------------------------------------------------------------------------------------------------------------
        # Name: StopMeasurement
        # Input: Takes no argument
        # Description: Stops power measurement on KRATOS
        # Return: StatusResult() object
        #-------------------------------------------------------------------------------------------------------------------
        """

        # StopAcquisition function is used to stop capturing waveforms on KRATOS while the test case runs on DUT
        logger.info('KRATOS : Stopping measurement')

        result = self.kratosHandler.StopAcquisition()
        if result.HasError():
            logger.error("Error in Stopping Acquisition :  " + result.ErrorMessage())
            recoveryResult = self.KratosErrorHandler()
            return recoveryResult

        return self.WaitForIdle()
コード例 #14
0
ファイル: kratos.py プロジェクト: Master-An/cpu_power_final
    def StartAcquisition(self):
        """
        #-------------------------------------------------------------------------------------------------------------------
        # Name: StartAcquisition
        # Input: Takes no argument
        # Description: Makes KRATOS to start power measurement
        # Return: StatusResult() object
        #-------------------------------------------------------------------------------------------------------------------
        """

        # StartAcquisition function is used to start capturing waveforms on Kratos while the test case runs on DUT
        logger.info('KRATOS : Preparing to start measurement')

        result = self.kratosHandler.StartAcquisition()
        if result.HasError():
            logger.error("Error in Starting Acquisition :  " + result.ErrorMessage())
            recoveryResult = self.KratosErrorHandler()
            return recoveryResult

        return StatusResult.Success()
コード例 #15
0
ファイル: kratos.py プロジェクト: Master-An/cpu_power_final
    def PowerOff(self):
        """
        #-------------------------------------------------------------------------------------------------------------------
        # Name: PowerOff
        # Input: Takes no argument
        # Description: Power Off KRATOS card
        # Return: StatusResult() object
        #-------------------------------------------------------------------------------------------------------------------
        """

        # SetPowerSupplyOutput function is used to turn on/off the power supply on device under test. True to turn on, False to turn off the device.
        # Powering OFF the device by passing argument - false
        logger.info('KRATOS: POWER OFF')

        result =self.kratosHandler.SetPowerSupplyOutput('false')
        if result.HasError():
            logger.error("Error in Powering OFF Device :  " + result.ErrorMessage())
            recoveryResult = self.KratosErrorHandler()
            return recoveryResult

        return StatusResult.Success()
コード例 #16
0
ファイル: kratos.py プロジェクト: Master-An/cpu_power_final
    def GetCalibrationStatus(self, calStatusList):
        """
        #-------------------------------------------------------------------------------------------------------------------
        # Name: GetCalibrationStatus
        # Input: Takes one argument, calStatusList
        #        calStatusList : empty list, to return Calibration Status
        # Description: Stops power measurement on KRATOS
        # Return: StatusResult() object
        #-------------------------------------------------------------------------------------------------------------------
        """

        result = self.kratosHandler.CheckCalibrationStatus(calStatusList)
        if result.HasError() :
            logger.error("Error in checking KRATOS calibration status :  " + result.ErrorMessage())
            recoveryResult = self.KratosErrorHandler()
            return recoveryResult

        logger.info("Self Calibration : " + calStatusList[0])
        logger.info("DMM Calibration : " + calStatusList[1])
        logger.info("MUX Calibration : " + calStatusList[2])

        return StatusResult.Success()
コード例 #17
0
ファイル: kratos.py プロジェクト: Master-An/cpu_power_final
    def SetConfigurationFile(self, configFile):
        """
        #-------------------------------------------------------------------------------------------------------------------
        # Name: SetConfigurationFile
        # Input: Takes one argument
        #       configFile: UDAS configuration file path for KRATOS
        # Description: Sets up channel configuration for KRATOS
        # Return: StatusResult() object
        #-------------------------------------------------------------------------------------------------------------------
        """

        logger.info("Loading KRATOS Channel Configuration : " + configFile)

        if not configFile.endswith('.udas'):
            return StatusResult.Error('KRATOS : ', 'Incorrect Configuration file for KRATOS, UDAS file needed')

        result =self.kratosHandler.LoadChannelConfiguration("C:\\rcm\\cfg\\"+ configFile)
        if result.HasError():
            logger.error("Error in Loading Channel Configuration :  " + result.ErrorMessage())
            recoveryResult = self.KratosErrorHandler()
            return recoveryResult

        return StatusResult.Success()
コード例 #18
0
ファイル: kratos.py プロジェクト: Master-An/cpu_power_final
    def GetKratosIP(self, name):
        """
        #-------------------------------------------------------------------------------------------------------------------
        # Name: GetKratosIP
        # Input: Takes one argument
        #    name : KRATOS host name
        # Description: Gets KRATOS IP address from KRATOS host name
        # Return: StatusResult() object
        #-------------------------------------------------------------------------------------------------------------------
        """
        if (name is "") or ('kratos' not in name.lower()):
            return StatusResult.Error('KRATOS error: ', ' Incorrect KRATOS name')

        try:
            ipAddress = socket.gethostbyname(name)
        except Exception as e:
            logger.error('KRATOS : Failed to get KRATOS IP address')
            return StatusResult.Error(str(e))

        TestSuiteConfig.KratosIpAddress = str(ipAddress)
        logger.info('KRATOS : ' + 'Name - ' + name + ', IP address - ' + TestSuiteConfig.KratosIpAddress)

        return StatusResult.Success()
コード例 #19
0
ファイル: kratos.py プロジェクト: Master-An/cpu_power_final
    def UsbOn(self):
        """
        #-------------------------------------------------------------------------------------------------------------------
        # Name: UsbOn
        # Input: Takes no argument
        # Description: Enable USB on KRATOS
        # Return: StatusResult() object
        #-------------------------------------------------------------------------------------------------------------------
        """

        # Connecting the USB by passing argument - True
        logger.info('KRATOS: USB ON')

        result = self.kratosHandler.SetUsbConnection('true')
        if result.HasError():
            logger.error("Error in Turning ON USB :  " + result.ErrorMessage())
            recoveryResult = self.KratosErrorHandler()
            return recoveryResult

        logger.info('Waiting for 10 Seconds for USB to stabilise')
        time.sleep(10)

        return StatusResult.Success()
コード例 #20
0
    def AnalyzingPowerResult(self, para):
        cmdResult = CommandLine.RunCommand(
            CommonApplicationUtilities._ToolsPath +
            "UDASDataAnalysis\\UDASDataAnalysis.exe VBAT 1 " +
            str(int(13 * 10**9)) + "-" + str(int(15 * 10**9)) + " " +
            os.path.join(para.TestCaseFolder.replace('/', '\\'), "UDAS"), 600,
            True)
        logger.info(cmdResult.CmdResult.Output)
        if "Error" in cmdResult.CmdResult.Output:
            logger.error("Fail to analyze power data: " +
                         cmdResult.CmdResult.Output)
        else:
            cmdResult.CmdResult.OutputLines = [
                x for x in cmdResult.CmdResult.OutputLines if x != ''
            ]

            plane_current_avg = cmdResult.CmdResult.OutputLines[0].split(
                '-')[0].split(',')[0]
            # plane_current_min = cmdResult.CmdResult.OutputLines[0].split('-')[0].split(',')[1]
            # plane_current_max = cmdResult.CmdResult.OutputLines[0].split('-')[0].split(',')[2]

            logger.info("I_Avg, I_Min, I_Max, V_Avg, V_Min, V_Max")
            logger.info(plane_current_avg)
        return plane_current_avg
コード例 #21
0
ファイル: command.py プロジェクト: Master-An/cpu_power_final
    def RunCommandExe(command,
                      time_out_seconds=None,
                      wait_for_exit=True,
                      working_directory=None,
                      debug=False,
                      env=None,
                      passKeyword="",
                      failKeyword=""):
        """
		#-------------------------------------------------------------------------------------------------------------------
		# Name: RunCommandExe
		# Input: Takes max five argument
		# 	command : command to be executed
		#	time_out_seconds : if a time_out_seconds was specified and expires, returns an error
		#	wait_for_exit : if false, doesn't wait for command to exit, issues the command and returns
		#	working_directory : If not None, the current directory will be changed to working_directory before the child is executed
		#	debug : If False, write output in debug logs else info logs
		#	env : If not None, it defines the environment variables for the new process
		# Description: Executes the command
		# Return: Returns an Object of Status.Result() class, result. result have two attributes Status and CmdResult
		# 	storing objects of StatusResult and CommandLineResult respectively
		# Example : result = CommandLine.RunCommandExe('AtraceStartLogging.exe 1000 20 qtc', time_out_seconds = 20, wait_for_exit = True, working_directory = r'C:\Automation\PTAS\Plasma\Engine\Resources\Scripts\LoggingExecutables\Executables', debug = True)
		#           if result.Status.HasError():
		#               logger.error(result.CmdResult.Output)
		#-------------------------------------------------------------------------------------------------------------------
		"""
        CREATE_NO_WINDOW = 0x08000000  #To create a console application process that is being run without a console window.
        command = 'cmd.exe /C ' + command
        result = Result()
        out = None
        try:
            startTime = datetime.now()
            process = subprocess.Popen(command,
                                       cwd=working_directory,
                                       stdout=subprocess.PIPE,
                                       stderr=subprocess.STDOUT,
                                       env=env,
                                       universal_newlines=True,
                                       creationflags=CREATE_NO_WINDOW)
        except Exception as e:
            #If any error comes while executing command, add it to StatusResult() and return Result()
            result.CmdResult.AddResult('Exception Occurred @ ' + command +
                                       str(e))
            result.Status.AddError('Exception Occurred @ ' + command + str(e))
            return result

        while wait_for_exit:
            if time_out_seconds is not None:
                currTime = datetime.now()
                if (currTime - startTime).seconds > time_out_seconds:
                    result.Status.AddError('Command Timeout')
                    result.CmdResult.AddResult('Command Timeout')
                    return result

            out = process.stdout.readline().replace('\n', '')
            if (passKeyword in out) or (process.poll() is not None):
                result.CmdResult.AddResult('Success')
                return result

            if failKeyword and failKeyword in out:
                result.Status.AddError(out)
                result.CmdResult.AddResult("Failed")
                logger.error(out)
                return result

            if not debug:
                logger.info(out)
            else:
                logger.debug(out)

        return result
コード例 #22
0
    def InitEnvironmnet(self):
        if 'KratosLite' in TestSuiteConfig.HardwareType:
            try:
                #self.PowerHandler = KratosLite()
                self.PowerHandler = PTTKratoslite()

                result = self.PowerHandler.SetConfigurationFile(
                    TestSuiteConfig.ChannelConfiguration)
                #                 if result.HasError():
                #                     return result
                result = self.PowerHandler.PowerOn()
                result = self.PowerHandler.UsbOn()
                result = Adb.IsDeviceDetected()
                if result.HasError():
                    logger.info("set usb on again")
                    QcUsbSwitch.SetUsbConnection('usb_on')
                    result = Adb.IsDeviceDetected()
                    logger.info("second time: " + str(result.IsSuccess()))
                else:
                    logger.info("first time: " + str(result.IsSuccess()))
                result = Adb.SetAdbRoot()
                if result.HasError():
                    return result
                result = Adb.SetAdbRemount()
                if result.HasError():
                    return result

            except Exception as e:
                return StatusResult.Error('Failed to initialize KRATOSLITE: ',
                                          str(e))
        elif 'Kratos' in TestSuiteConfig.HardwareType:
            logger.info("----------supply with Kratos--------------")
            try:
                #self.PowerHandler = Kratos()
                self.PowerHandler = PTTKratos()
                result = self.PowerHandler.SetConfigurationFile(
                    TestSuiteConfig.ChannelConfiguration)
                #                 if result.HasError():
                #                     return result
                result = self.PowerHandler.PowerOn()
                result = self.PowerHandler.UsbOn()
            except Exception as e:
                logger.info(str(e))
                return StatusResult.Error('Failed to initialize KRATOS: ',
                                          str(e))
        elif 'Monitor' in TestSuiteConfig.HardwareType:
            try:
                self.PowerHandler = PTTPowerMonitor()
            except Exception as e:
                logger.info(str(e))
                return StatusResult.Error(
                    'Failed to initialize PowerMonitor: ', str(e))
        else:
            logger.error(
                "Can't support hardware type, please check TestSuiteConfig.HardwareType"
            )
            return
        logger.info(TestSuiteConfig.HardwareType +
                    " : initialization successful.")
        logger.info("Waiting for device ...")
        result = Adb.WaitForDevice(30)
        logger.info("wait for device ready...")
        result = AdbSettings.ReMountDevice()
        if result.HasError():
            logger.error("Unable to set root & remount privileges")
        self.Wakelock()
        self.Discharging()
        logger.info("Disable charging & Enable wakelock")