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)
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
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)
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)
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")
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)
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)
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")
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
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")
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
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))
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))
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]
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
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
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
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")
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)
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]
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))