def startsystem(self): """ #------------------------------------------------------------------------------------------------------------------- # Name: startsystem # Description: Start the system with the previously deployed template # Input: Takes no argument # Examples: # startsystem() # It will start TBSLTE sytem with the previously deployed template # and check if system is running at end # Return: StatusResult() object #------------------------------------------------------------------------------------------------------------------- """ if not self._get_tbslteutil_handle(): return StatusResult.Error("TBSLTEUtil handle not initialized") try: output = self._tbslte_handle.start_system() except Exception as e: return StatusResult.Error( f"TBSLTEUtil threw an exception while starting the system: {e}" ) if output == 0: return StatusResult.Error("Failed to start the TBS system") elif output == 2: logger.debug( "TBSLTE system was already running before calling the 'startsystem' function" ) logger.info("TBSLTE system is up and running") return StatusResult.Success()
def stopsystem(self): """ #------------------------------------------------------------------------------------------------------------------- # Name: stopsystem # Description: Stop the TBSLTE system and check system is in stopped mode at end # Input: Takes no argument # Examples: # stopsystem() # It will stop TBSLTE sytem # Return: StatusResult() object #------------------------------------------------------------------------------------------------------------------- """ if not self._get_tbslteutil_handle(): return StatusResult.Error("TBSLTEUtil handle not initialized") try: output = self._tbslte_handle.stop_system() except Exception as e: return StatusResult.Error( f"TBSLTEUtil threw an exception while stopping the system: {e}" ) if output == 0: return StatusResult.Error("Failed to stop the TBS system") elif output == 2: logger.debug( "TBSLTE system was already stopped before calling the 'stopsystem' function" ) logger.info("TBSLTE system is stopped successfully") return StatusResult.Success()
def CheckTSens(self, thermalZone): """ #------------------------------------------------------------------------------------------------------------------- # Name: CheckTSens # Input: Takes 1 argument # argument1: thermalZone # Description: Checks temperature on device and reports when it's stable #--------------------------------------------------------------------------------------------------- """ logger.info("Calling CheckTSens function") methodString = "-m CheckTSens-" + str(thermalZone) result = self.SendCommandAndGetResponse(methodString) if result.Status.HasError(): logger.error("Error in running CheckTSens") return result.Status tSens5Temperature = "TSens5Temperature : " match = re.findall(tSens5Temperature + '(.*?);', result.CmdResult.Output, re.DOTALL) if len(match) < 1: return None tSens5Temperature = match[0] logger.debug("CheckTSens function working fine") return tSens5Temperature
def ControlTemperature(self, thermalZone, desiredTemperature, timeout, SVTemp=25): """ #------------------------------------------------------------------------------------------------------------------- # Name: ControlTemperature # Input: Takes 4 argument # argument1: thermalZone # argument2: desiredTemperature # argument3: timeout in seconds # argument4: SVTemp # Description: Controls temperature on device #--------------------------------------------------------------------------------------------------- """ logger.info("Calling ControlTemperature function") methodString = "-m ControlTemperature-" + str(thermalZone) + "," + str( desiredTemperature) + "," + str(timeout * 1000) + "," + str(SVTemp) #logger.debug(methodString) result = self.SendCommandAndGetResponse(methodString, timeout) logger.debug(result.CmdResult.Output) if result.Status.HasError(): logger.error("Error in running ControlTemperature") return result.Status logger.debug("ControlTemperature function working fine") return StatusResult.Success()
def PIDControl(self, thermalZone, desiredTemperature, timeout, SVTemp=25): """ #------------------------------------------------------------------------------------------------------------------- # Name: PIDControl # Input: Takes 4 arguments # argument1: thermal Zone # argument2: desiredTemperature in degree C # argument3: timeout in seconds. # argument4: SVTemp Temperature in degree C, default value is 25.0C # Description: Sets RV temperature, reports device temperature #------------------------------------------------------------------------------------------------------------------- """ msTimeout = timeout * 1000 logger.info("Inside PIDControl function") methodString = "-m PIDControl-" + str(thermalZone) + "," + str( desiredTemperature) + "," + str(msTimeout) + "," + str(SVTemp) logger.info(methodString) result = self.SendCommandAndGetResponse(methodString, timeout) logger.debug(result.CmdResult.Output) if result.Status.HasError(): logger.error("Error in running PIDControl") return result.Status logger.debug("PIDControl function working fine") return StatusResult.Success()
def __init__(self): """ #------------------------------------------------------------------------------------------------------------------- # Name: __init__ # Description: creates a Constructor #------------------------------------------------------------------------------------------------------------------- """ logger.debug("ThermalController Constructor called")
def initialize_handler(self): """ #------------------------------------------------------------------------------------------------------------------- # Name: initialize_handler # Description: Create TBSLTEUtility handle and connect to Qualcomm LTE(4G) Test Base Station based on key tbslte_host_id # Input: Takes no argument # Return: StatusResult() object #------------------------------------------------------------------------------------------------------------------- """ self._host_id = TestSuiteConfig.TbsLteHostId if self._host_id is None: return StatusResult.Error("TbsLteHostId is not provisioned") logger.debug( f"TBSLTE Host ID {self._host_id} obtained from input XML key TbsLteHostId" ) return StatusResult.Success()
def SetTemperature(self, temperature): """ #------------------------------------------------------------------------------------------------------------------- # Name: SetTemperature # Input: Takes one argument # argument1: Temperature in degree C # Description: Sets temperature on Thermal Controller #------------------------------------------------------------------------------------------------------------------- """ logger.info("Setting temperature to " + str(temperature)) methodString = "-m SetTemperature-" + str(temperature) result = self.SendCommandAndGetResponse(methodString) if result.Status.HasError(): logger.error("Error in setting Temperature" + result.CmdResult.Output) return result.Status logger.debug("SetTemperatue function working fine") return StatusResult.Success()
def SendCommandAndGetResponse(self, methodStrings, timeout=120): """ #------------------------------------------------------------------------------------------------------------------- # Name: SendCommandAndGetResponse # Input: Takes argument: # methodStrings: methods name followed by their parameters. # For example : -m methodName-param1,param2 # Description: check If it is Qualcomm Root Build # Return: StatusResult() object #------------------------------------------------------------------------------------------------------------------- """ cptfInterfaceExecutable = CommonApplicationUtilities._ResourcesProgramPath + "CPTF_LibraryInterface\\Qualcomm.CPTF.LibraryInterface.exe" dllPath = CommonApplicationUtilities._ResourcesProgramPath + "CPTF_LibraryInterface\\Qualcomm.CPT.Automation.Plugins.HW.Kratos.dll" className = 'Qualcomm.CPT.Automation.Plugins.HW.Kratos.KratosRecovery' executionString = cptfInterfaceExecutable + " -a " + dllPath + " -c " + className + methodStrings logger.debug("Executing Command :" + executionString) result = CommandLine.RunCommand(executionString, timeout) return result
def ReleaseTacPort(self): """ #------------------------------------------------------------------------------------------------------------------- # Name: ReleaseTacPort # Input: Takes no argument # Description: close TAC port # Return: StatusResult() object #------------------------------------------------------------------------------------------------------------------- """ if self.boardHasTac and hasattr(self.tac, 'ser'): try: logger.debug('Releasing TAC port') self.tac.ser.close() except Exception as e: logger.error('Failed to close TAC port') logger.error(str(e)) return StatusResult.Error('Failed to close TAC port : ', str(e)) return StatusResult.Success()
def CoolDevice(self, temperature, timeout): """ #------------------------------------------------------------------------------------------------------------------- # Name: CoolDevice # Input: Takes 2 arguments # argument1: Temperature # argument2: Timeout # Description: Cools down temperature on device #--------------------------------------------------------------------------------------------------- """ logger.info("Calling CoolDevice function") methodString = "-m CoolDevice-" + str(temperature) + "," + str( timeout * 1000) result = self.SendCommandAndGetResponse(methodString, timeout) if result.Status.HasError(): logger.error("Error in running CoolDevice") return result.Status logger.debug("CoolDevice function working fine") return StatusResult.Success()
def GetUeIpAddress(): """ #------------------------------------------------------------------------------------------------------------------- # Name: GetUeIpAddress # Input: Takes no arguments # Description: Function used to get UE IP Address # Return: UE IP Address #------------------------------------------------------------------------------------------------------------------- """ logger.info("Calling GetUeIpAddress function") logger.info("TBS: Detecting MME State") str1 = "/opt/lte/bin/appTestability.py -s localhost -p 15004 \\\"MME COMMAND GET MME_QUERY_STATE\\\"" command = TbsTestabilityActions.plinkstr + "\"" + str1 + "\"" logger.debug("Command is: " + str(command)) result = CommandLine.RunCommand(command, 15) matched = 0 OutputLines = str(result.CmdResult.OutputLines) OutputLines = OutputLines.split("\\n") logger.info("OutputLines: " + str(OutputLines) + "\n") for line in OutputLines: #logger.debug("Line contains: " + str(line)) if matched == 1: if "IPV4_ADDRESS" in line: match = re.search(r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}', line).group() if "10.1.1" in match: ipAddress = match logger.info("TBS: UE IP Address: " + str(ipAddress)) return ipAddress if ipAddress == "": logger.error("Failed to detect UE IP Address") return None else: match = re.search(r"\"IP_TYPE\" : \"IPV4\",", line) if match != None: matched = 1 logger.debug("Line contains: " + str(line))
def configuretemplateonltetbs(self, **kwargs): """ #------------------------------------------------------------------------------------------------------------------- # Name: configuretemplateonltetbs # Description: configure template for ltetbs # Input: Takes argument : # template_path (:class:`str`): : Required: The TBS server accessible # template file path. The template will be deployed to the system # regardless of its current state # Examples: # configuretemplateonltetbs({template_path: '/prj/qct/octopus/test/templates/Golden/LabOps/Wildcat_v27/BC01_EPN_4cell_20MHz_XOR_CAT11.xml'}) # It will configure and load /prj/qct/octopus/test/templates/Golden/LabOps/Wildcat_v27/BC01_EPN_4cell_20MHz_XOR_CAT11.xml # in tbslte station template and run system, make sure system running # Return: StatusResult() object #------------------------------------------------------------------------------------------------------------------- """ if not self._get_tbslteutil_handle(): return StatusResult.Error(f"TBSLTEUtil handle not initialized") try: template_path = kwargs.get('template_path') logger.debug( f"Deploying template {template_path} on TBSLTE station {self._host_id}" ) output = self._tbslte_handle.deploy_template(template_path) except Exception as e: return StatusResult.Error( f"TBSLTEUtil threw an exception while deploying the template: {e}" ) if not output: return StatusResult.Error( f"Failed to deploy template {template_path}") logger.info( f"Template {template_path} is deployed successful and LTETBS is running" ) return StatusResult.Success()
def ReadPVTemperature(self): """ #------------------------------------------------------------------------------------------------------------------- # Name: ReadPVTemperature # Description: Reads PV temperature on Thermal Controller #------------------------------------------------------------------------------------------------------------------- """ logger.info("Read PV temperature from Thermal Controller") methodString = "-m ReadPVTemperature-1" result = self.SendCommandAndGetResponse(methodString) if result.Status.HasError(): logger.error("Error in reading PV Temperature") return result.Status pvTemp = "PVTemp : " match = re.findall(pvTemp + '(.*?);', result.CmdResult.Output, re.DOTALL) if len(match) < 1: return None pvTemp = match[0] logger.debug("ReadPVTemperature function working fine") return pvTemp
def SendCommandAndGetResponse(self, methodStrings, timeout=30): """ #------------------------------------------------------------------------------------------------------------------- # Name: SendCommandAndGetResponse # Input: Takes 2 arguments # methodStrings: method names followed by their parameters # timeout: default value is 30 seconds # Description: Sends execution command to TEC dll # Return: StatusResult() object #------------------------------------------------------------------------------------------------------------------- """ cptfInterfaceExecutable = CommonApplicationUtilities._ResourcesProgramPath + "CPTF_LibraryInterface\\Qualcomm.CPTF.LibraryInterface.exe" dllPath = CommonApplicationUtilities._ResourcesProgramPath + "CPTF_LibraryInterface\\Qualcomm.CPT.Automation.TEC.dll" className = 'Qualcomm.CPT.Automation.TEC.ThermalController' executionString = cptfInterfaceExecutable + " -a " + dllPath + " -c " + className + " " + " -s " + " " + methodStrings logger.debug("Executing Command :" + executionString) result = CommandLine.RunCommand(executionString, timeout) logger.debug("Result contains: " + result.CmdResult.Output) if result.Status.HasError(): logger.error(result.CmdResult.Output) result.Status.AddError(result.CmdResult.Output) return result
def SendCommandAndGetResponse(self, methodStrings, timeout=120): """ #------------------------------------------------------------------------------------------------------------------- # Name: SendCommandAndGetResponse # Input: Takes argument : # methodStrings: methods name followed by their parameters. # For example : -m methodName-param1,param2 # Description: check If it is Qualcomm Root Build # Return: StatusResult() object #------------------------------------------------------------------------------------------------------------------- """ #cptfInterfaceExecutable = 'C:\\Automation\\PTAS_Engine\\CPTF_Lib_Interface\\CPTF_LibraryInterface.exe' cptfInterfaceExecutable = CommonApplicationUtilities._ResourcesProgramPath + "CPTF_LibraryInterface\\Qualcomm.CPTF.LibraryInterface.exe" dllPath = CommonApplicationUtilities._ResourcesProgramPath + "CPTF_LibraryInterface\\Qualcomm.CPT.Automation.Plugins.HW.Kratos.dll" className = 'Qualcomm.CPT.Automation.Plugins.HW.Kratos.KratosApi' executionString = cptfInterfaceExecutable + " -a " + dllPath + " -c " + className + " -m SetupKratos-" + self.kratosPcIpAddress + " " + methodStrings logger.debug("Executing Command :" + executionString) result = CommandLine.RunCommand(executionString, timeout) if result.Status.HasError() or 'Error' in result.CmdResult.Output: logger.error(result.CmdResult.Output) result.Status.AddError(result.CmdResult.Output) return result
def CheckCalibrationStatus(self, calibrationStatusList): """ #------------------------------------------------------------------------------------------------------------------- # Name: CheckCalibrationStatus # Description: Checks Status of Self Calibration, DMM Calibration & External Calibration #------------------------------------------------------------------------------------------------------------------- """ logger.info("Checking Calibration") commandToRun = "CheckCalibrationStatus()" result = self.SendCommandAndGetResponse(commandToRun) if result.HasError(): logger.error( "Kratos: Error in sending command to check the calibration status" ) return result response = self.LastApiResponse.split(',') if (response == None or len(response) != 3): return StatusResult.Error( f"Incorrect response from Kratos while checking calibration status. Response: {self.LastApiResponse}" ) logger.debug(f"External Calibration Status : {response[0]}") logger.debug(f"Self Calibration Status : {response[1]}") logger.debug(f"DMM Calibration Status : {response[2]}") if "PASS" not in response[0]: logger.warning( "External calibration is expired, please contact the IPS team to do the external calibration" ) selfCalibrationStatus = 'True' if ("PASS" in response[1]) else 'False' dmmCalibrationStatus = 'True' if ("PASS" in response[2]) else 'False' externalCalibrationStatus = 'True' if ("PASS" in response[0]) else 'False' calibrationStatusList.append(selfCalibrationStatus) calibrationStatusList.append(dmmCalibrationStatus) calibrationStatusList.append(externalCalibrationStatus) return result
def ExecuteCommand(self, command): """ ------------------------------------------------------------------------------------------------------------------- Name: ExecuteCommand Input: Takes one argument command : command or data to write on COM port Description: Handle the serial COM port connection to the Spiderboard, Writes data and read from COM port Return: StatusResult() object ------------------------------------------------------------------------------------------------------------------- """ logger.debug('Sending command : %s on spider board', command) #Make sure the COM port is up and running. result = self.HandleComPort() if result.HasError(): logger.error(result.ErrorMessage()) return result result, response = WindowsComPort.WriteReadOnComPort( self.serObj, command + '\r') if result.HasError(): logger.error(result.ErrorMessage()) return result if 'ok' not in response: return StatusResult.Error("Error in Spiderboard communication.") logger.debug('Recieved response from spider board') logger.debug(response) result = self.CloseSpiderboardComPort() if result.HasError(): logger.error(result.ErrorMessage()) return result return StatusResult.Success()
def StartAcquisition(self): logger.debug('ALPACA : No action required') return StatusResult.Success()