Пример #1
0
class Stimulus2(Stimulus):
    """Automates the execution of stimulus profiles."""
    def __init__(self, gatewayIPAddress=None):
        if (gatewayIPAddress is None):
            self.istim = Factory().GetIStimulus2("")
        else:
            self.istim = Factory().GetIStimulus2(gatewayIPAddress)

    def __del__(self):
        self.UnreserveStimulusProfileManager()

    def RunStimulusProfile(self,
                           testfile,
                           baselogpath,
                           timeout,
                           autostart,
                           stopondisconnect,
                           parameterfiles=()):
        """Starts the stimulus generation you defined in the test file."""
        tupleFiles = _ConvertListParamToTuple_(parameterfiles)
        _RaiseException_(
            self.istim.RunStimulusProfile(testfile, baselogpath, timeout,
                                          autostart, stopondisconnect,
                                          tupleFiles))
Пример #2
0
class Stimulus:
    def __init__(self):
        self.istim = Factory().GetIStimulus()

    def __del__(self):
        self.UnreserveStimulusProfileManager()

    def ReserveStimulusProfileManager(self):
        """
        Creates a task that reserves the stimulus generation server.

        This task prevents other clients from interrupting the stimulus generation process.
        """
        _RaiseException_(self.istim.ReserveStimulusProfileManager())

    def UnreserveStimulusProfileManager(self):
        """Destroys the task that reserves the stimulus generation server. Frees the server for other clients to use."""
        _RaiseException_(self.istim.UnreserveStimulusProfileManager())

    def GetStimulusProfileManagerState(self):
        """Returns the state of the stimulus generation component."""
        data = self.istim.GetStimulusProfileManagerState(StimulusState.Stopped)
        _RaiseException_(data[0])
        return self._NetStimulusStateToPy_(data[1])

    def RunStimulusProfile(self, testfile, baselogpath, timeout, autostart,
                           stopondisconnect):
        """Starts the stimulus generation you defined in the test file."""
        _RaiseException_(
            self.istim.RunStimulusProfile(str(testfile), str(baselogpath),
                                          System.UInt32(timeout),
                                          bool(autostart),
                                          bool(stopondisconnect)))

    def StopStimulusProfile(self):
        """Stops the stimulus generation."""
        _RaiseException_(self.istim.StopStimulusProfile())

    def GetStimulusProfileFile(self):
        """Acquires the current stimulus definition file."""
        data = self.istim.GetStimulusProfileFile("")
        _RaiseException_(data[0])
        return data[1]

    def GetStimulusProfileResult(self):
        """
        Acquires the result of stimulus generation test.

        Only the table test produces a test file of the result.
        """
        data = self.istim.GetStimulusProfileResult(StimulusResult.Failed, "")
        _RaiseException_(data[0])
        values = {
            'Result': self._NetStimulusResultToPy_(data[1]),
            'File': data[2]
        }
        return values

    def _NetStimulusStateToPy_(self, net):
        if (net == StimulusState.Stopped):
            return PyStimulusState.Stopped
        elif (net == StimulusState.Starting):
            return PyStimulusState.Starting
        elif (net == StimulusState.Running):
            return PyStimulusState.Running
        elif (net == StimulusState.Stopping):
            return PyStimulusState.Stopping
        else:
            raise ValueError

    def _NetStimulusResultToPy_(self, net):
        if (net == 0):
            return PyStimulusResult.NoResult
        elif (net == StimulusResult.Passed):
            return PyStimulusResult.Passed
        elif (net == StimulusResult.Failed):
            return PyStimulusResult.Failed
        elif (net == PyStimulusResult.Error):
            return PyStimulusResult.Error
        else:
            raise ValueError