Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_error_message():
try:
# We pass in an invalid model name to force going to error_message
with niscope.Session('FakeDevice', False, True, 'Simulate=1, DriverSetup=Model:invalid_model; BoardType:PXIe'):
assert False
except niscope.Error as e:
assert e.code == -1074118609
assert e.description.find('Simulation does not support the selected model and board type.') != -1
def multiple_niscope_sessions():
with niscope.Session('', False, False, 'Simulate=1, DriverSetup=Model:5164;BoardType:PXIe') as simulated_session_1, niscope.Session('', False, False, 'Simulate=1, DriverSetup=Model:5164;BoardType:PXIe') as simulated_session_2:
yield [simulated_session_1, simulated_session_2]
def example(resource_name, options, total_acquisition_time_in_seconds, voltage, sample_rate_in_hz, samples_per_fetch):
total_samples = int(total_acquisition_time_in_seconds * sample_rate_in_hz)
# 1. Opening session
with niscope.Session(resource_name=resource_name, options=options) as session:
# We will acquire on all channels of the device
channel_list = [c for c in range(session.channel_count)] # Need an actual list and not a range
# 2. Creating numpy arrays
waveforms = [np.ndarray(total_samples, dtype=np.float64) for c in channel_list]
# 3. Configuring
session.configure_horizontal_timing(min_sample_rate=sample_rate_in_hz, min_num_pts=1, ref_position=0.0, num_records=1, enforce_realtime=True)
session.channels[channel_list].configure_vertical(voltage, coupling=niscope.VerticalCoupling.DC, enabled=True)
# Configure software trigger, but never send the trigger.
# This starts an infinite acquisition, until you call session.abort() or session.close()
session.configure_trigger_software()
current_pos = 0
# 4. initiating
with session.initiate():
while current_pos < total_samples:
def example(resource_name, channels, options, length, voltage):
with niscope.Session(resource_name=resource_name, options=options) as session:
session.configure_vertical(range=voltage, coupling=niscope.VerticalCoupling.AC)
session.configure_horizontal_timing(min_sample_rate=50000000, min_num_pts=length, ref_position=50.0, num_records=1, enforce_realtime=True)
with session.initiate():
waveforms = session.channels[channels].fetch(num_samples=length)
for i in range(len(waveforms)):
print('Waveform {0} information:'.format(i))
print(str(waveforms[i]) + '\n\n')
def example(resource_name, channels, options, length, voltage):
with niscope.Session(resource_name=resource_name, options=options) as session:
session.configure_vertical(range=voltage, coupling=niscope.VerticalCoupling.AC)
session.configure_horizontal_timing(min_sample_rate=50000000, min_num_pts=length, ref_position=50.0, num_records=1, enforce_realtime=True)
waveforms = session.channels[channels].read(num_samples=length)
for i in range(len(waveforms)):
print('Waveform {0} information:'.format(i))
print(str(waveforms[i]) + '\n\n')