Esempio n. 1
0
    def PingStatus(self, IpAddress):
        """
        #-------------------------------------------------------------------------------------------------------------------
        # Name: PingStatus
        # Input: IpAddress
        # Description:Pings the machine (with IpAddress provided as an argument)
        # Return: StatusResult() object
        #-------------------------------------------------------------------------------------------------------------------
        """
        result = CommandLine.RunCommand('ping ' + IpAddress, 30)
        if result.Status.HasError():
            logger.error("Error in pinging host {0} . {1}".format(
                IpAddress, result.CmdResult.Output))
            return StatusResult.Error("Error in pinging host {0} . {1}".format(
                IpAddress, result.CmdResult.Output))

        logger.info(result.CmdResult.Output)

        if ('unreachable.' in result.CmdResult.Output):
            #No route from the local system. Packets sent were never put on the wire.
            return StatusResult.Error('IpAddress is unreacheable. ' +
                                      result.CmdResult.Output)

        elif ('Ping request could not find host' in result.CmdResult.Output):
            return StatusResult.Error('host_not_found. ' +
                                      result.CmdResult.Output)

        elif ('Request timed out.' in result.CmdResult.Output):
            return StatusResult.Error('Connection time out' +
                                      result.CmdResult.Output)

        return StatusResult.Success()
Esempio n. 2
0
    def GetSinglePlotStatistics(self, statisticList):
        logger.info("Getting Single Plot Statistics ")
        methodString = "-m GetSinglePlotStatistics-1,1"
        result = self.SendCommandAndGetResponse(methodString)
        if result.Status.HasError():
            logger.error(
                "Error in Sending Command to get Single Point Statistics")
            return result

        current = "current : "
        voltage = "voltage : "
        match = re.findall(current + '(.*?);', result.CmdResult.Output,
                           re.DOTALL)
        if len(match) < 1:
            return StatusResult.Error("Could not read Current Value")

        # logger.info("Current : " + match[0])
        current = match[0]

        match = re.findall(voltage + '(.*?);', result.CmdResult.Output,
                           re.DOTALL)
        if len(match) < 1:
            return StatusResult.Error("Could not read Voltage Value")

        # logger.info("Voltage : " + match[0])
        voltage = match[0]

        statisticList[0] = current
        statisticList[1] = voltage

        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
Esempio n. 4
0
    def StartMeasurement(self):
        """
        #-------------------------------------------------------------------------------------------------------------------
        # Name: StartMeasurement
        # Input: Takes no argument
        # Description: Starts power measurement on ALPACA
        # Return: StatusResult() object
        #-------------------------------------------------------------------------------------------------------------------
        """
        if self.boardHasEpm:
            if self.epm.getData:
                logger.warning('ALPACA : Measurement already running. Stopping previous measurement')

                result = self.StopMeasurement()
                if result.HasError():
                    logger.error('ALPACA : Error stopping previous measurement')
                    return result

            logger.info('ALPACA : Starting measurement')

            try:
                self.epm.StartMeasurement()
            except Exception as e:
                logger.error(str(e))
                return StatusResult.Error('ALPACA : ', str(e))

        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()
Esempio n. 6
0
    def RebootDevice(self) :
        """
        #-------------------------------------------------------------------------------------------------------------------
        # Name: RebootDevice
        # Input: Takes no argument
        # Description: Reboots Device by switching Power & USB
        # Return: StatusResult() object
        #-------------------------------------------------------------------------------------------------------------------
        """

        logger.info("Turning Off Device")
        result = self.PowerOff()
        if result.HasError():
            return result
        result = self.UsbOff()
        if result.HasError():
            return result

        time.sleep(2)

        logger.info("Booting up Device")
        result = self.PowerOn()
        if result.HasError():
            return result
        result = self.UsbOn()
        if result.HasError():
            return result

        return result
Esempio n. 7
0
    def SetDataCollectionPath(self):
        """
        #-------------------------------------------------------------------------------------------------------------------
        # Name: SetDataCollectionPath
        # Input: Takes no argument
        # Description: Sets up path to save UDAS waveform on automation PC
        # Return: StatusResult() object
        #-------------------------------------------------------------------------------------------------------------------
        """
        logger.info("Setting Logs Location for saving UDAS")

        if self.boardHasEpm:
            if self.epm.getData:
                logger.warning('ALPACA : Measurement already running. Stopping previous measurement')

                result = self.StopMeasurement()
                if result.HasError():
                    logger.error('ALPACA : Error stopping previous measurement')
                    return result

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

        if self.boardHasEpm:
            try:
                logger.info('ALPACA : Log directory path : ' + self.logsPath)
                self.epm.SetLogDirectory(self.logsPath)
            except Exception as e:
                logger.error(str(e))
                return StatusResult.Error('ALPACA : ', str(e))

        return StatusResult.Success()
    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()
Esempio n. 9
0
    def StartAcquisition(self):
        """
		#-------------------------------------------------------------------------------------------------------------------
		# Name: StartAcquisition
		# Description: Starts Acquisition on Kratos
		#-------------------------------------------------------------------------------------------------------------------
		"""
        logger.info("Starting Acquisition")
        commandToRun = "StartAcquisition()"
        result = self.SendCommandAndGetResponse(commandToRun, False)
        if (result.HasError()):
            return result

        status = KratosConstants.ExtAcquisitionStatus.UNKNOWN
        logger.info("Kratos: Waiting For Acquisition To Be Ready")
        # Wait for up to 60seconds for the waiting for trigger screen
        startTime = datetime.datetime.now()
        while (status !=
               KratosConstants.ExtAcquisitionStatus.WAITING_FOR_TRIGGER
               and (datetime.datetime.now() - startTime).seconds < 60):
            time.sleep(2)
            status = self.GetExtAcquisitionStatus()

        if (status !=
                KratosConstants.ExtAcquisitionStatus.WAITING_FOR_TRIGGER):
            return StatusResult.Error(
                "Kratos: Acquisition Is Not Ready. Check That A Measurement Can Be Performed Manually"
            )

        return StatusResult.Success()
Esempio n. 10
0
    def GetSinglePlotStatistics(self, statisticList):
        logger.info("Getting Single Plot Statistics ")

        for channel in ['CURRENT', 'VOLTAGE']:
            commandToRun = f"GetSinglePlotStatistics(0,{channel})"
            result = self.SendCommandAndGetResponse(commandToRun)
            if result.HasError():
                logger.error(f"Error in reading battery {channel}")
                return result

            dataFields = None
            if self.LastApiResponse:
                dataFields = self.LastApiResponse.split(",")

            if (dataFields == None or len(dataFields) < 3):
                return StatusResult.Error(
                    f"Kratos: Failed to parse response while reading battery {channel} value. Response: {self.LastApiResponse}"
                )

            if channel == 'CURRENT':
                statisticList[0] = dataFields[2]
            else:
                statisticList[1] = dataFields[2]

        return StatusResult.Success()
Esempio n. 11
0
    def GetAcquisitionError(self):
        """
		#-------------------------------------------------------------------------------------------------------------------
		# Name: GetAcquisitionError
		# Description: Get Acquisition Error if encountered
		#-------------------------------------------------------------------------------------------------------------------
		"""
        logger.info("Getting Acquisition Error")
        commandToRun = "GetAcquisitionError()"
        result = self.SendCommandAndGetResponse(commandToRun, False)
        if result.HasError():
            return result

        outputs = None
        if self.LastApiResponse:
            outputs = self.LastApiResponse.split(",")

        if (outputs == None or len(outputs) == 0):
            return StatusResult.Error(
                f"Incorrect response from Kratos while checking for Acquisition errors. Response: {self.LastApiResponse}"
            )

        if (outputs[0] != "NO ERROR"):
            return StatusResult.Error(
                f"Error response from Kratos while checking for Acquisition errors. Response: {self.LastApiResponse}"
            )

        return StatusResult.Success()
Esempio n. 12
0
    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()
Esempio n. 13
0
    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()
Esempio n. 14
0
    def SendSwTrigger(self):
        """
		#-------------------------------------------------------------------------------------------------------------------
		# Name: SendSwTrigger
		# Description: Send SW Trigger command to start measurement
		#-------------------------------------------------------------------------------------------------------------------
		"""
        logger.info("Sending Software Trigger")
        methodString = "-m SendSwTrigger"
        return self.SendCommandAndGetResponse(methodString)
Esempio n. 15
0
    def DmmMuxCalibration(self):
        """
		#-------------------------------------------------------------------------------------------------------------------
		# Name: DmmMuxCalibration
		# Description: Performs Dmm Mux Calibration on Kratos
		#-------------------------------------------------------------------------------------------------------------------
		"""
        logger.info("Performing Dmm Mux Calibration")
        methodString = "-m DmmMuxCalibration"
        return self.SendCommandAndGetResponse(methodString)
Esempio n. 16
0
    def SelfCalibration(self):
        """
		#-------------------------------------------------------------------------------------------------------------------
		# Name: SelfCalibration
		# Description: Performs Self Calibration
		#-------------------------------------------------------------------------------------------------------------------
		"""
        logger.info("Performing Self Calibration")
        methodString = "-m SelfCalibration"
        return self.SendCommandAndGetResponse(methodString)
Esempio n. 17
0
    def GetAcquisitionError(self):
        """
		#-------------------------------------------------------------------------------------------------------------------
		# Name: GetAcquisitionError
		# Description: Get Acquisition Error if encountered
		#-------------------------------------------------------------------------------------------------------------------
		"""
        logger.info("Getting Acquisition Error")
        methodString = "-m GetAcquisitionError"
        return self.SendCommandAndGetResponse(methodString)
Esempio n. 18
0
    def StopAcquisition(self):
        """
		#-------------------------------------------------------------------------------------------------------------------
		# Name: StopAcquisition
		# Description: Stops Acquisition if in progress
		#-------------------------------------------------------------------------------------------------------------------
		"""
        logger.info("Stopping Acquisition")
        methodString = "-m StopAcquisition"
        return self.SendCommandAndGetResponse(methodString)
Esempio n. 19
0
    def StartAcquisition(self):
        """
		#-------------------------------------------------------------------------------------------------------------------
		# Name: StartAcquisition
		# Description: Starts Acquisition on Kratos
		#-------------------------------------------------------------------------------------------------------------------
		"""
        logger.info("Starting Acquisition")
        methodString = "-m StartAcquisition"
        return self.SendCommandAndGetResponse(methodString)
Esempio n. 20
0
    def DmmMuxCalibration(self):
        """
		#-------------------------------------------------------------------------------------------------------------------
		# Name: DmmMuxCalibration
		# Description: Performs Dmm Mux Calibration on Kratos
		#-------------------------------------------------------------------------------------------------------------------
		"""
        logger.info("Performing Dmm Mux Calibration")
        commandToRun = "DmmMuxCalibration()"
        return self.SendCommandAndGetResponse(commandToRun, False)
Esempio n. 21
0
    def SelfCalibration(self):
        """
		#-------------------------------------------------------------------------------------------------------------------
		# Name: SelfCalibration
		# Description: Performs Self Calibration
		#-------------------------------------------------------------------------------------------------------------------
		"""
        logger.info("Performing Self Calibration")
        commandToRun = "SelfCalibration()"
        return self.SendCommandAndGetResponse(commandToRun, False)
Esempio n. 22
0
    def LoadChannelConfiguration(self, configurationFile):
        """
		#-------------------------------------------------------------------------------------------------------------------
		# Name: LoadChannelConfiguration
		# Input: Takes argument :
		# 	configurationFile: Path of the cfg file to Load
		# Description: Loads the specified configuration file on Kratos
		#-------------------------------------------------------------------------------------------------------------------
		"""
        logger.info("Loading Channel Configuration : " + configurationFile)
        commandToRun = "LoadChannelConfiguration(" + configurationFile + ")"
        return self.SendCommandAndGetResponse(commandToRun)
Esempio n. 23
0
    def SetUsbConnection(self, enable):
        """
		#-------------------------------------------------------------------------------------------------------------------
		# Name: SetUsbConnection
		# Input: Takes argument :
		# 	enable: true / false
		# Description: Enables/Disables the USB Connection on Kratos
		#-------------------------------------------------------------------------------------------------------------------
		"""
        logger.info("Setting USB Connection to : " + enable)
        methodString = "-m SetUsbConnection-" + enable
        return self.SendCommandAndGetResponse(methodString)
Esempio n. 24
0
    def SetOutputDirectory(self, outputDirPath):
        """
		#-------------------------------------------------------------------------------------------------------------------
		# Name: SetOutputDirectory
		# Input: Takes argument :
		# 	outputDirPath: Absolute Logs Directory Path
		# Description: Sets Path on the Kratos PC to save UDAS Files
		#-------------------------------------------------------------------------------------------------------------------
		"""
        logger.info("Setting UDAS Output Directory to : " + outputDirPath)
        commandToRun = f"SetOutputDirectory({outputDirPath})"
        return self.SendCommandAndGetResponse(commandToRun)
Esempio n. 25
0
    def SetUsbConnection(self, enable):
        """
		#-------------------------------------------------------------------------------------------------------------------
		# Name: SetUsbConnection
		# Input: Takes argument :
		# 	enable: true / false
		# Description: Enables/Disables the USB Connection on Kratos
		#-------------------------------------------------------------------------------------------------------------------
		"""
        logger.info("Setting USB Connection to : " + enable)
        setOut = "ON" if (enable == 'true') else "OFF"
        commandToRun = "SetUsbConnection(1," + setOut + ")"
        return self.SendCommandAndGetResponse(commandToRun, False)
Esempio n. 26
0
    def SetPowerSupplyOutput(self, enable):
        """
		#-------------------------------------------------------------------------------------------------------------------
		# Name: SetPowerSupplyOutput
		# Input: Takes argument :
		# 	enable: true/false to enable or disable Power
		# Description: Power ON/OFF Device by turning on Kratos Power ON/OFF
		#-------------------------------------------------------------------------------------------------------------------
		"""
        logger.info("Setting PowerSupply Output to " + enable)
        setOut = "ON" if (enable == 'true') else "OFF"
        commandToRun = "SetPowerSupplyOutput(1," + setOut + ")"
        return self.SendCommandAndGetResponse(commandToRun)
Esempio n. 27
0
    def SetPowerSupplyOutput(self, enable):
        """
		#-------------------------------------------------------------------------------------------------------------------
		# Name: SetPowerSupplyOutput
		# Input: Takes argument :
		# 	enable: true/false to enable or disable Power
		# Description: Power ON/OFF Device by turning on Kratos Power ON/OFF
		#-------------------------------------------------------------------------------------------------------------------
		"""
        logger.info("Setting PowerSupply Output to " + enable)
        methodString = "-m SetPowerSupplyOutput-" + enable
        result = self.SendCommandAndGetResponse(methodString)
        return result
Esempio n. 28
0
    def ConfigurePowerSupply(self, voltage, currentLimit, ovp):
        """
		#-------------------------------------------------------------------------------------------------------------------
		# Name: ConfigurePowerSupply
		# Input: Takes argument :
		# 	voltage: Voltage to be set on Kratos
		#	currentLimit: Current Limit to be set on Kratos
		#	ovp: OVP to be set
		# Description: Sets Voltage, Current & OVP on Kratos
		#-------------------------------------------------------------------------------------------------------------------
		"""
        logger.info("Configuring Power Supply ")
        commandToRun = f"ConfigurePowerSupply(1,{voltage},{currentLimit},{ovp})"
        return self.SendCommandAndGetResponse(commandToRun)
Esempio n. 29
0
    def SetDefaultOptions(self):
        """
		#-------------------------------------------------------------------------------------------------------------------
		# Name: SetDefaultOption
		# Input: Takes No Arguments
		# Description: Sets default of parameters :
		# checkCal : False, ignoreSelfCal : false, ignoreExtCal : True, enforceMaxVBat : False, checkConnectors : True, autoSaveData : True
		#-------------------------------------------------------------------------------------------------------------------
		"""
        logger.info(
            "Setting Default Options - checkCal : False, ignoreSelfCal : false, ignoreExtCal : True, enforceMaxVBat : False, checkConnectors : True, autoSaveData : True"
        )
        commandToRun = "SetOptions(CHK_CAL=OFF,IGNORE_SELF_CAL=OFF,IGNORE_EXT_CAL=ON,ENFORCE_MAX_VBAT=OFF,CHK_CONNECTORS=ON,AUTOSAVE=ON)"
        return self.SendCommandAndGetResponse(commandToRun)
Esempio n. 30
0
    def ConfigurePowerSupply(self, voltage, currentLimit, ovp):
        """
		#-------------------------------------------------------------------------------------------------------------------
		# Name: ConfigurePowerSupply
		# Input: Takes argument :
		# 	voltage: Voltage to be set on Kratos
		#	currentLimit: Current Limit to be set on Kratos
		#	ovp: OVP to be set
		# Description: Sets Voltage, Current & OVP on Kratos
		#-------------------------------------------------------------------------------------------------------------------
		"""
        logger.info("Configuring Power Supply ")
        methodString = "-m ConfigurePowerSupply-" + voltage + "," + currentLimit + "," + ovp
        return self.SendCommandAndGetResponse(methodString)