LinWave#
- class waveline.linwave.LinWave(address)[source]#
Interface for linWave device.
The device is controlled via TCP/IP:
Control port: 5432
Streaming ports: 5433 for channel 1 and 5434 for channel 2
The interface is asynchronous and using
asyncio
for TCP/IP communication. This is especially beneficial for this kind of streaming applications, where most of the time the app is waiting for more data packets (read more). Please refer to the examples for implementation details.- __init__(address)[source]#
Initialize device.
- Parameters:
address (
str
) – IP address of device. Use the methoddiscover
to get IP addresses of available linWave devices.- Returns:
Instance of
LinWave
Example
There are two ways constructing and using the
LinWave
class:Without context manager, manually calling the
connect
andclose
method:>>> async def main(): >>> lw = waveline.LinWave("192.168.0.100") >>> await lw.connect() >>> print(await lw.get_info()) >>> ... >>> await lw.close() >>> asyncio.run(main())
Using the async context manager:
>>> async def main(): >>> async with waveline.LinWave("192.168.0.100") as lw: >>> print(await lw.get_info()) >>> ... >>> asyncio.run(main())
Methods
__init__
(address)Initialize device.
acquire
([raw, poll_interval_seconds])High-level method to continuously acquire data.
close
()Close connection.
connect
()Connect to device.
discover
([timeout])Discover linWave devices in network.
Get AE data records.
get_info
()Get device information.
get_setup
(channel)Get setup information.
Get status information.
get_tr_data
([raw])Get transient data records.
get_tr_snapshot
(channel, samples[, ...])Get snapshot of transient data.
identify
([channel])Blink LEDs to identify device or single channel.
set_channel
(channel, enabled)Enable/disable channel.
set_continuous_mode
(channel, enabled)Enable/disable continuous mode.
set_ddt
(channel, microseconds)Set duration discrimination time (DDT).
set_filter
(channel[, highpass, lowpass, order])Set IIR filter frequencies and order.
set_range
(channel, range_volts)Set input range.
set_range_index
(channel, range_index)Set input range by index.
set_status_interval
(channel, seconds)Set status interval.
set_threshold
(channel, microvolts)Set threshold for hit-based acquisition.
set_tr_decimation
(channel, factor)Set decimation factor of transient data and streaming data.
set_tr_enabled
(channel, enabled)Enable/disable recording of transient data.
set_tr_postduration
(channel, samples)Set post-duration samples for transient data.
set_tr_pretrigger
(channel, samples)Set pre-trigger samples for transient data.
Start data acquisition.
start_pulsing
(channel[, interval, count, cycles])Start pulsing.
Stop data acquisition.
Stop pulsing.
stream
(channel, blocksize, *[, raw, timeout])Async generator to stream channel data.
Attributes
Available channels
Maximum sampling rate in Hz
Control port number
RANGES
Check if connected to device.
- CHANNELS = (1, 2)#
Available channels
- MAX_SAMPLERATE = 10000000#
Maximum sampling rate in Hz
- PORT = 5432#
Control port number
- async identify(channel=0)[source]#
Blink LEDs to identify device or single channel.
- Parameters:
channel (
int
) – Channel number (0 for all to identify device)
Note
Available since firmware version 2.10.
- async set_range_index(channel, range_index)[source]#
Set input range by index.
Retrieve selectable ranges with the
get_info
method.
- async set_range(channel, range_volts)[source]#
Set input range.
Retrieve selectable ranges with the
get_info
method.- Parameters:
Deprecated: Please us the
set_range_index
method instead.
- async set_continuous_mode(channel, enabled)[source]#
Enable/disable continuous mode.
Threshold will be ignored in continous mode. The length of the records is determined by ddt with
set_ddt
.
- async set_tr_decimation(channel, factor)[source]#
Set decimation factor of transient data and streaming data.
The sampling rate will be 10 MHz / factor.
- async set_filter(channel, highpass=None, lowpass=None, order=8)[source]#
Set IIR filter frequencies and order.
- async start_pulsing(channel, interval=1, count=4, cycles=1)[source]#
Start pulsing.
The number of pulses should be even, because pulses are generated by a square-wave signal (between LOW and HIGH) and the pulse signal should end LOW.
- Parameters:
channel (
int
) – Channel number (0 for all channels)interval (
float
) – Interval between pulses in secondscount (
int
) – Number of pulses per channel (should be even), 0 for infinite pulsescycles (
int
) – Number of pulse cycles (automatically pulse through each channel in cycles). Only useful if all channels are chosen.
- async get_tr_snapshot(channel, samples, pretrigger_samples=0, *, raw=False)[source]#
Get snapshot of transient data.
The recording starts with the execution of the command. The total number of samples is the sum of samples and the pretrigger_samples. The trai and time of the returned records are always 0.
- Parameters:
- Return type:
- Returns:
List of transient data records
- async acquire(raw=False, poll_interval_seconds=0.05)[source]#
High-level method to continuously acquire data.
- Parameters:
- Yields:
AE and TR data records
- Return type:
Example
>>> async with waveline.LinWave("192.254.100.100") as lw: >>> # apply settings >>> await lw.set_channel(channel=1, enabled=True) >>> await lw.set_channel(channel=2, enabled=False) >>> await lw.set_range_index(channel=1, range_index=0) # 0: 50 mV >>> async for record in lw.acquire(): >>> # do something with the data depending on the type >>> if isinstance(record, waveline.AERecord): >>> ... >>> if isinstance(record, waveline.TRRecord): >>> ...
- stream(channel, blocksize, *, raw=False, timeout=5)[source]#
Async generator to stream channel data.
- Parameters:
- Yields:
Tuple of
relative time in seconds (first block: t = 0)
data as numpy array in volts (or ADC values if raw is True)
- Raises:
TimeoutError – If TCP socket read exceeds timeout, usually because of buffer overflows
- Return type:
Example
>>> async with waveline.LinWave("192.168.0.100") as lw: >>> # apply settings >>> await lw.set_range_index(channel=1, range_index=0) # 0: 50 mV >>> await lw.set_filter(channel=1, highpass=100e3, lowpass=500e3, order=8) >>> # open streaming port before start acq afterwards (order matters!) >>> stream = lw.stream(channel=1, blocksize=65536) >>> await lw.start_acquisition() >>> async for time, block in stream: >>> # do something with the data >>> ...