Exemplo n.º 1
0
def _reconstruct_args(f, args, new_param):
    real_func = getattr(f, rt_seq_mode_id, f)
    new_args = list(args)
    arg_spec = inspect.signature(real_func).parameters

    if new_param is not None:
        if new_param.param_name in arg_spec.keys():
            idx = list(arg_spec.keys()).index(new_param.param_name)
            datatype_name = new_param.default_elem.__class__.__name__
            datatype = rtprimitives.get_class_by_name(datatype_name)
            if new_param.by_value:
                if isinstance(args[idx], DataType):
                    value = args[idx].value
                else:
                    value = args[idx]
                new_args[idx] = datatype(value)
            else:
                if not isinstance(args[idx], DataType):
                    value = args[idx]
                    new_args[idx] = datatype(value)
        else:
            raise errors.VeristandError(
                _errormessages.param_description_no_param)

    return tuple(new_args)
Exemplo n.º 2
0
 def __pow__(self, power, modulo=None):
     if isinstance(power, DataType):
         return self.value ** power.value
     elif isinstance(power, (int, float)):
         return self.value ** power
     else:
         raise nivsexceptions.VeristandError(_errormessages.invalid_type_for_operator)
def get_channel_value(name):
    value = 0.0
    err, value = _get_workspace().GetSingleChannelValue(name, value)
    if err.ErrorCode:
        raise errors.VeristandError(_errormessages.csharp_call_failed %
                                    (err.ErrorCode, err.ResolvedErrorMessage))
    return value
Exemplo n.º 4
0
 def __add__(self, other):
     if isinstance(other, DataType):
         return self.value + other.value
     elif isinstance(other, (int, float)):
         return self.value + other
     else:
         raise nivsexceptions.VeristandError(_errormessages.invalid_type_for_operator)
Exemplo n.º 5
0
 def __le__(self, other):
     if isinstance(other, DataType):
         return self.value <= other.value
     elif self._is_compatible_with_datatype(other):
         return self.value <= other
     else:
         raise nivsexceptions.VeristandError(_errormessages.invalid_type_for_operator)
Exemplo n.º 6
0
 def __init__(self, dot_net_instance):
     if isinstance(dot_net_instance, IWorkspace2DotNet):
         super(_Workspace2, self).__init__(dot_net_instance)
     else:
         raise errors.VeristandError(
             _errormessages.unexpected_dot_net_data_type %
             "NationalInstruments.VeriStand.ClientAPI.IWorkspace2")
Exemplo n.º 7
0
 def __invert__(self):
     if isinstance(self, (I32Value, I64Value, U32Value, U64Value)):
         return ~self.value
     elif isinstance(self, (BooleanValue, DoubleValue)):
         return 0
     else:
         raise nivsexceptions.VeristandError(_errormessages.invalid_type_for_operator)
Exemplo n.º 8
0
 def __rshift__(self, other):
     if isinstance(other, (I32Value, I64Value)):
         return self.value >> other.value
     elif self._is_integer_type(other):
         return self.value >> other
     else:
         raise nivsexceptions.VeristandError(_errormessages.invalid_type_for_operator)
Exemplo n.º 9
0
 def __init__(self, dot_net_instance):
     if isinstance(dot_net_instance, IStimulusProfileSessionDotNet):
         super(_StimulusProfileSession, self).__init__(dot_net_instance)
     else:
         raise errors.VeristandError(
             _errormessages.unexpected_dot_net_data_type %
             "NationalInstruments.VeriStand.ClientAPI."
             "IStimulusProfileSession")
Exemplo n.º 10
0
 def __init__(self, dot_net_instance):
     if isinstance(dot_net_instance, ISequenceControlDotNet):
         super(_SequenceControl, self).__init__(dot_net_instance)
     else:
         raise errors.VeristandError(
             _errormessages.unexpected_dot_net_data_type %
             "NationalInstruments.VeriStand.ClientAPI."
             "ISequenceControl")
 def __init__(self, dot_net_instance):
     if isinstance(dot_net_instance, SystemDefinitionChannelResourceDotNet):
         super(_SystemDefinitionChannelResource,
               self).__init__(dot_net_instance)
     else:
         raise errors.VeristandError(
             _errormessages.unexpected_dot_net_data_type %
             "NationalInstruments.VeriStand.Data."
             "SystemDefinitionChannelResource")
def get_vector_channel_value(name):
    value = []
    row_dim = col_dim = 0
    err, row_dim, col_dim, value = _get_workspace().GetChannelVectorValues(
        name, row_dim, col_dim, value)
    if err.ErrorCode:
        raise errors.VeristandError(_errormessages.csharp_call_failed %
                                    (err.ErrorCode, err.ResolvedErrorMessage))
    return value
def get_channel_size(name):
    node_info_list = None
    err, node_info_list = _get_workspace().GetSystemNodeChannelList(
        "", node_info_list)
    if err.ErrorCode:
        raise errors.VeristandError(_errormessages.csharp_call_failed %
                                    (err.ErrorCode, err.ResolvedErrorMessage))
    channel_node_info = _get_channel_node_info(name, node_info_list)
    return channel_node_info.ChannelRowDimension * channel_node_info.ChannelColumnDimension
Exemplo n.º 14
0
 def __init__(self, dot_net_instance):
     if isinstance(dot_net_instance, SequenceParameterAssignmentInfoDotNet):
         super(_SequenceParameterAssignmentInfo,
               self).__init__(dot_net_instance)
     else:
         raise errors.VeristandError(
             _errormessages.unexpected_dot_net_data_type %
             "NationalInstruments.VeriStand.ClientAPI."
             "SequenceParameterAssignmentInfo")
Exemplo n.º 15
0
 def create_and_register_task_for_top_level(self):
     thread = current_thread()
     if thread in self._task_dict:
         raise errors.VeristandError(_errormessages.reregister_thread)
     task = _Task(thread.getName())
     # queue the task
     self.register_task(task)
     # queue an iteration counter for this top-level task
     self._task_queue.append(task.iteration_counter)
     return task
Exemplo n.º 16
0
    def undeploy(self):
        """
        Undeploys the Stimulus Profile Session.

        Returns:
            None:

        """
        err = self._dot_net_instance.Undeploy(None)
        err = _Error(err)
        if err.is_error:
            raise \
                errors.VeristandError(_errormessages.csharp_call_failed % (err.error_code, err.resolved_error_message))
Exemplo n.º 17
0
    def set_channel_vector_values(self, channel, new_values):
        """
        Sets the vector values of a channel on the target.

        Args:
            channel (str): The name of the channel. You must enter the full path to the channel as specified in the
             system definition file.
            new_values (List[float]): The vector values. This parameter expects a 1D array. If the channel expects
             two-dimensional data, convert the 2D channel data into a 1D array before passing it to this method.

        """
        err = self._dot_net_instance.SetChannelVectorValues(channel, new_values)
        err = _Error(err)
        if err.is_error:
            raise \
                errors.VeristandError(_errormessages.csharp_call_failed % (err.error_code, err.resolved_error_message))
Exemplo n.º 18
0
    def get_multiple_system_nodes_data(self, names):
        """
        Gets information about multiple nodes in the system definition file.

        Args:
            names ([str]): The names of the nodes. You must enter the full path to each node as specified in the system
             definition file.

        Returns:
            niveristand.clientapi._nodeinfo._NodeInfo: Information about the nodes.

        """
        err, node_infos = self._dot_net_instance.GetMultipleSystemNodesData(names, None)
        err = _Error(err)
        if err.is_error:
            raise \
                errors.VeristandError(_errormessages.csharp_call_failed % (err.error_code, err.resolved_error_message))
        return [_NodeInfo(node_info) for node_info in node_infos]
Exemplo n.º 19
0
    def get_single_channel_value(self, name):
        """
        Gets the value of a single channel on the target.

        Args:
            name (str): The name of the channel. You must enter the full path to the channel as specified in the system
             definition file.

        Returns:
            float: The value of the specified channel.

        """
        err, value = self._dot_net_instance.GetSingleChannelValue(name, 0)
        err = _Error(err)
        if err.is_error:
            raise \
                errors.VeristandError(_errormessages.csharp_call_failed % (err.error_code, err.resolved_error_message))
        return value
Exemplo n.º 20
0
    def deploy(self, auto_start):
        """
        Deploys the Stimulus Profile Session.

        Args:
            auto_start (bool): If True, starts sequences immediately upon deploy. If False, waits for an external Run
             command.

        Returns:
            str: The ID of the Stimulus profile session.

        """
        ret_val, session_id, err = self._dot_net_instance.Deploy(
            auto_start, None, None)
        err = _Error(err)
        if err.is_error:
            raise \
                errors.VeristandError(_errormessages.csharp_call_failed % (err.error_code, err.resolved_error_message))
        return session_id
Exemplo n.º 21
0
    def get_channel_vector_values(self, channel):
        """
        Gets the vector values of a channel on the target.

        Args:
            channel (): The name of the channel. You must enter the full path to the channel as specified in the system
             definition file.

        Returns:
            int: The number of rows in the vector array.
            int: The number of columns in the vector array.
            [float]: The vector values.

        """
        err, row_dim, col_dim, value = self._dot_net_instance.GetChannelVectorValues(channel)
        err = _Error(err)
        if err.is_error:
            raise \
                errors.VeristandError(_errormessages.csharp_call_failed % (err.error_code, err.resolved_error_message))
        return row_dim, col_dim, value
Exemplo n.º 22
0
 def __init__(self, dot_net_instance):
     if isinstance(dot_net_instance, ErrorDotNet):
         super(_Error, self).__init__(dot_net_instance)
     else:
         raise errors.VeristandError(
             _errormessages.unexpected_dot_net_data_type % "NationalInstruments.VeriStand.Error")
Exemplo n.º 23
0
def _get_channel_node_info(name, node_info_list):
    for channel in node_info_list:
        if channel.FullPath == name:
            return channel
    raise errors.VeristandError(_errormessages.channel_not_found % name)
Exemplo n.º 24
0
    def get_task_for_curr_thread(self):
        thread = current_thread()

        if thread not in self._task_dict:
            raise errors.VeristandError(_errormessages.unregistered_thread)
        return self._task_dict[thread]
Exemplo n.º 25
0
 def __setitem__(self, key, value):
     return nivsexceptions.VeristandError(_errormessages.cannot_change_array_elements)
def set_vector_channel_value(name, value):
    err = _get_workspace().SetChannelVectorValues(name, value)
    if err.ErrorCode:
        raise errors.VeristandError(_errormessages.csharp_call_failed %
                                    (err.ErrorCode, err.ResolvedErrorMessage))