Ejemplo n.º 1
0
    def save(self, path=None):
        """
        Saves this sequence to disk.

        Args:
            path(Optional[str]): path to the location you want to save the sequence file.

        Returns:
            path you specify in **path**.

        All dependencies required for deployment of this sequence save to the same path.
        If you do not specify a path in **path**, this sequence saves to the location where you last saved the object.
        If you did not previously save the object, it saves to a temporary folder.

        For a simpler use case, refer to :func:`niveristand.realtimesequencetools.save_py_as_rtseq`

        """
        if self._rtseq is None:
            raise VeristandError(_errormessages.save_without_valid_sequence)
        if path is not None:
            self._path = os.path.abspath(path)
        elif not os.path.isdir(self._path):
            self._path = tempfile.mkdtemp()

        name = self._build_file_name()
        self._rtseqpkg.save_referenced(self._path, self)
        self._update_references()
        rtseqapi.save_real_time_sequence(self._rtseq, name)
        return name
Ejemplo n.º 2
0
def compile_rtseq(rtseq):
    success, _, compilation_events = \
        CompilerUtilities.TryGetCompiledInstance(rtseq, False, [], [])
    if not success:
        errormsg = " ".join([
            x.Message for x in compilation_events
            if x.EventType == CompilationEventType.Error
        ])
        raise VeristandError(errormsg)
Ejemplo n.º 3
0
    def run(self, rtseq_params={}):
        """
        Runs the sequence on the globally configured VeriStand Engine.

        Args:
            rtseq_params (Dict[str, niveristand.clientapi._datatypes.rtprimitives.DoubleValue]):  the parameters to be
             passed to the RT sequence.

        Returns:
            niveristand.clientapi.stimulusprofileapi.StimulusProfileState: Stimulus profile session state.

        Deploys and runs the sequence without waiting for the sequence to finish. Use the returned
        :class:`StimulusProfileState` to wait for the sequence to complete and obtain the return value.

        For a simpler use case, refer to :func:`niveristand.realtimesequencetools.run_py_as_rtseq`

        """
        if self._rtseq is None:
            raise VeristandError(_errormessages.run_without_valid_sequence)
        if self._path is None:
            raise VeristandError(_errormessages.invalid_path_for_sequence)

        name = self._build_file_name()
        return rtseqapi.run_rt_sequence(name, rtseq_params)
Ejemplo n.º 4
0
    def run(self, timeout_within_each_step=100000):
        """
        Runs the sequence on the globally configured VeriStand Engine.

        Args:
            timeout_within_each_step (Optional[int]): Time, in milliseconds,
                each step waits before execution is aborted.

        Returns:
            :class:`niveristand.clientapi.StimulusProfileState`: Stimulus profile session state.

        Deploys and runs the sequence without waiting for the sequence to finish. Use the returned
        :class:`StimulusProfileState` to wait for the sequence to complete and obtain the return value.

        For a simpler use case, refer to :func:`niveristand.realtimesequencetools.run_py_as_rtseq`

        """
        if self._rtseq is None:
            raise VeristandError(_errormessages.run_without_valid_sequence)
        if self._path is None:
            raise VeristandError(_errormessages.invalid_path_for_sequence)

        name = self._build_file_name()
        return rtseqapi.run_rt_sequence(name, timeout_within_each_step)
Ejemplo n.º 5
0
 def append(self, new):
     funcs_to_add = list()
     if inspect.isfunction(new) or isinstance(new, RealTimeSequence):
         funcs_to_add.append(new)
     elif inspect.ismodule(new):
         for func_name, func in inspect.getmembers(new, inspect.isfunction):
             if getattr(func, rt_seq_mode_id, None) is not None:
                 funcs_to_add.append(func)
     else:
         raise VeristandError()
     for func in [
             f for f in funcs_to_add
             if self._obj_to_key(f) not in self._rtseqs
     ]:
         name = func.__name__
         self._rtseqs[name] = func
         if name not in self._dep_graph:
             self._dep_graph[name] = list()
 def _sequence_complete_event_handler(self, source, args):
     from niveristand.clientapi import ErrorAction
     data_value = args.ReturnValue
     if data_value.Type == DataType.Void:
         self._ret_val = None
     elif data_value.Type in [DataType.Boolean, DataType.Double, DataType.Int32, DataType.Int64, DataType.UInt32,
                              DataType.UInt64]:
         self._ret_val = data_value.Value
     else:
         raise VeristandError(_errormessages.invalid_return_type)
     aborted = args.Aborted
     error = args.Error
     if aborted:
         self._completion_state = StimulusProfileState.CompletionState.Aborted
         self._last_error = SequenceError(error.Code, error.Message, ErrorAction.AbortSequence)
     else:
         if error.Code != 0:
             self._completion_state = StimulusProfileState.CompletionState.Failed
             self._last_error = SequenceError(error.Code, error.Message, ErrorAction.ContinueSequenceExecution)
         else:
             self._completion_state = StimulusProfileState.CompletionState.Success
     self._rt_sequence_completed = True
Ejemplo n.º 7
0
 def __delitem__(self, key):
     raise VeristandError()
Ejemplo n.º 8
0
 def __setitem__(self, key, value):
     raise VeristandError()