Library¶
-
niveristand.library.
abstime
()¶ Returns the current date and time, in seconds, relative to the operating system’s epoc.
Note: Only available for RT sequences.
-
niveristand.library.
arraysize
(x)¶ Returns the number of elements in x, where x is an array.
Parameters: x – the array for which you want to get the number of elements. Returns: the size of the array. If x is not an array, this function returns 0. Return type: int
-
niveristand.library.
clearfault
(x)¶ Clears all faults set on channel x.
Parameters: x – the channel you want to clear faults on. Channel x must be a reference to a channel and should not be a reference to a local variable. If channel references a local variable,
clearfault()
performs no operation.Note: Only available for RT sequences.
-
niveristand.library.
clearlasterror
()¶ Clears the last error set by
generate_error()
.Note: Only available for RT sequences.
-
niveristand.library.
deltat
()¶ Returns the duration, in seconds, of the current system timestep.
To perform equality or comparison operations, use deltatus.
Note: In Python Mode, this function always returns 0.01 for a rate of 100Hz.
-
niveristand.library.
deltatus
()¶ Returns the duration, in microseconds, of the current system timestep.
Note: In Python Mode, this function always returns 10,000 for a rate of 100Hz.
-
niveristand.library.
fault
(channel, value)¶ Faults channel with value.
Parameters: - channel – channel to fault.
- value (float) – value to fault the channel.
channel must be a reference to a channel and should not be a reference to a local variable. If channel references a local variable,
fault()
performs no operation.Note: Only available for RT sequences.
-
niveristand.library.
fix
(x)¶ Rounds x to the nearest integer between x and zero.
Parameters: x (float) – value you want to round. Returns: floating-point representation of the rounded value. Return type: (float) Note: Only available for RT sequences.
-
niveristand.library.
generate_error
(code, message, action)¶ Generates an error to report test failure.
Parameters: - code (int) – error code to display.
- message (str) – error string to display.
- action (
niveristand.clientapi.ErrorAction
) – action to perform.
Returns: If action is Continue, returns the generated error.
-
niveristand.library.
getlasterror
()¶ Returns the numeric error code of the last error set by
generate_error()
.Note: Only available for RT sequences.
-
niveristand.library.
iteration
()¶ Returns the number of iterations since the current top-level sequence started.
Returns: iteration count. Return type: int
-
niveristand.library.
localhost_wait
(amount=0.1)¶ Waits for channel values to update.
Parameters: amount (float) – time, in seconds, this function waits for channel values to update. When running in the VeriStand Engine, this function is ignored as channels are always up to date.
-
niveristand.library.
multitask
()¶ Creates a multitask context for branching execution.
Refer to
niveristand.library.multitask()
for more details on branching execution.
-
niveristand.library.
nivs_yield
()¶ Yields execution from this task or block to the next.
Refer to
niveristand.library.multitask()
for more details on yielding to other tasks.
-
niveristand.library.
quotient
(x, y)¶ Returns floor(x/y), the number of times y evenly divides into x.
Parameters: - x – dividend.
- y – divisor.
Returns: integer quotient of x/y
Return type: int
-
niveristand.library.
recip
(x)¶ Returns 1/x.
Parameters: x – divisor. Note: Only available for RT sequences.
-
niveristand.library.
rand
(x)¶ Returns a random floating-point number between 0 and the maximum value.
Parameters: x (float) – maximum value. Returns: random number between 0 and x Return type: float
-
niveristand.library.
rem
(x, y)¶ Returns the remainder of x/y, when the quotient is rounded to the nearest integer.
Parameters: - x (float) – dividend.
- y (float) – divisor.
-
niveristand.library.
seqtime
()¶ Returns the number of elapsed seconds since the epoch.
Returns: time, in seconds, since the epoch. Return type: float To perform equality or comparison operations, use seqtimeus instead.
-
niveristand.library.
seqtimeus
()¶ Returns the elapsed time, in microseconds, since the epoch.
Returns: elapsed time, in microseconds, as reported by the system clock. Return type: int
-
niveristand.library.
stop_task
(task_function)¶ Stops the task you specify.
Parameters: task_function – task function you want to stop. You must have previously declared the task function inside a multitask()
context.Refer to
niveristand.library.multitask()
for more details on stopping tasks.
-
niveristand.library.
task
(mt)¶ Marks a nested function-definition as a task inside a
niveristand.library.multitask()
.Parameters: mt – the parent niveristand.library.multitask()
Use this function as a decorator. Refer to
niveristand.library.multitask()
for more details on using tasks.
-
niveristand.library.
tickcountms
()¶ Returns the current value of the milliseconds counter.
Returns: time, in milliseconds, as reported by the high-precision counter (if available). Return type: int
-
niveristand.library.
tickcountus
()¶ Returns the current value of the microseconds counter.
Returns: time, in microseconds, as reported by the high-precision counter (if available). Return type: int
-
niveristand.library.
wait
(duration)¶ Waits the duration, in seconds, you specify.
Parameters: duration ( DoubleValue
) – time, in seconds, this function waits. You may specify fractions of seconds.Returns: actual seconds waited. Return type: float This wait is non-blocking, so other tasks will run while this wait executes.
-
niveristand.library.
wait_until_next_ms_multiple
(ms_multiple)¶ Waits until the next millisecond multiple of the number you specify in ms_multiple.
Parameters: ms_multiple ( I64Value
) – the millisecond multiple to wait until.Returns: actual milliseconds waited. Return type: int This wait is non-blocking, so other tasks will run while this wait executes.
-
niveristand.library.
wait_until_next_us_multiple
(us_multiple)¶ Waits until the next microsecond multiple of the number you specify in us_multiple.
Parameters: us_multiple ( I64Value
) – the microsecond multiple to wait until.Returns: actual microseconds waited. Return type: int This wait is non-blocking, so other tasks will run while this wait executes.
-
niveristand.library.
wait_until_settled
(signal, upper_limit, lower_limit, settle_time, timeout)¶ Waits until signal settles for the amount of time you specify in settle_time.
Parameters: - signal (
DoubleValue
) – value to monitor. - upper_limit (
DoubleValue
) – maximum value of the settle range. - lower_limit (
DoubleValue
) – minimum value of the settle range. - settle_time (
DoubleValue
) – time, in seconds, signal must stay inside the settle range. - timeout (
DoubleValue
) – seconds to wait before the function times out.
Returns: True: The signal failed to settle before the operation timed out. False: The signal settled before the operation timed out.
Return type: bool
This wait is non-blocking, so other tasks will run while this wait executes.
- signal (
-
niveristand.library.
ramp
(ramp_out, init_value, final_value, duration)¶ Ramps a variable from an initial value to an ending value over the duration you specify.
Parameters: - ramp_out (
DoubleValue
) – variable you want to ramp. - init_value (
DoubleValue
) – starting value. - final_value (
DoubleValue
) – ending value. - duration (
DoubleValue
) – time, in seconds, you want the ramp to take.
- ramp_out (
-
niveristand.library.
sine_wave
(wave_out, amplitude, freq, phase, bias, duration)¶ Plays a sine wave with the parameters you specify.
Parameters: - wave_out (
DoubleValue
) – variable onto which the sine wave plays. - amplitude (
DoubleValue
) – amplitude of the sine wave. - freq (
DoubleValue
) – frequency, in Hz, of the sine wave. - phase (
DoubleValue
) – phase, in degrees, of the sine wave. - bias (
DoubleValue
) – offset to add to the sine wave. - duration (
DoubleValue
) – duration, in seconds, to play the sine wave.
- wave_out (
-
niveristand.library.
square_wave
(wave_out, amplitude, freq, phase, bias, duty_cycle, duration)¶ Plays a square wave with the parameters you specify.
Parameters: - wave_out (
DoubleValue
) – variable onto which the square wave plays. - amplitude (
DoubleValue
) – amplitude of the square wave. - freq (
DoubleValue
) – frequency, in Hz, of the square wave. - phase (
DoubleValue
) – phase, in degrees, of the square wave. - bias (
DoubleValue
) – offset to add to the square wave. - duty_cycle (
DoubleValue
) – percentage of time the square wave remains high versus low over one period. - duration (
DoubleValue
) – time, in seconds, to play the square wave.
- wave_out (
-
niveristand.library.
triangle_wave
(wave_out, amplitude, freq, phase, bias, duration)¶ Plays a triangle wave with the parameters you specify.
Parameters: - wave_out (
DoubleValue
) – variable onto which the triangle wave plays. - amplitude (
DoubleValue
) – amplitude of the triangle wave. - freq (
DoubleValue
) – frequency, in Hz, of the triangle wave. - phase (
DoubleValue
) – phase, in degrees, of the triangle wave. - bias (
DoubleValue
) – offset to add to the triangle wave. - duration (
DoubleValue
) – duration, in seconds, to play the triangle wave.
- wave_out (
-
niveristand.library.
uniform_white_noise_wave
(wave_out, amplitude, seed, duration)¶ Plays a uniform white noise wave with the parameters you specify.
Parameters: - wave_out (
DoubleValue
) – variable onto which the white noise wave plays. - amplitude (
DoubleValue
) – amplitude of the white noise wave. - seed (
I32Value
) – seed for random number generator. - duration (
DoubleValue
) – duration, in seconds, to play the white noise wave.
- wave_out (