### Data Streaming Example (Python) Source: https://github.com/vallen-systems/waveline/blob/master/docs/_generated/waveline.linwave.LinWave.md Illustrates how to set up and use the data streaming functionality. This example configures channel settings, applies filters, opens a stream, starts acquisition, and then iterates through the streamed data blocks. ```python 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 ... ``` -------------------------------- ### WaveLine Development Setup and Tools Source: https://github.com/vallen-systems/waveline/blob/master/README.md Sets up the development environment for the WaveLine project, including cloning the repository, creating and activating a virtual environment, and installing development tools like pylint, mypy, pytest, and tox. It also includes commands for formatting and checking code. ```shell git clone https://github.com/vallen-systems/waveline.git cd waveline # Create virtual environment in directory .venv python -m venv .venv # Activate virtual environment source .venv/bin/activate # Linux .venv\Scripts\activate # Windows # Install package (editable) and all development tools pip install -e .[dev] # Run formatter ruff format . # Run linter ruff check . # Run the test suite in the current environment pytest # Run the CI pipeline (checks and tests) for all targeted (and installed) Python versions with tox tox # Build the documentation cd docs make html # Linux .\make.bat html # Windows ``` -------------------------------- ### Run WaveLine Examples Source: https://github.com/vallen-systems/waveline/blob/master/README.md Executes example scripts for interacting with linWave and spotWave devices. These examples demonstrate basic usage and functionality. ```shell python examples/linwave_ae.py # if you have a linWave device python examples/spotwave_ae.py # if you have a spotWave device ``` -------------------------------- ### Install WaveLine Python Package Source: https://github.com/vallen-systems/waveline/blob/master/README.md Installs the latest version of the WaveLine Python library from PyPI. This is the primary step to begin using the library. ```shell pip install waveline ``` -------------------------------- ### Continuous Data Acquisition Example (Python) Source: https://github.com/vallen-systems/waveline/blob/master/docs/_generated/waveline.linwave.LinWave.md Demonstrates how to continuously acquire data using the 'acquire' method. This example shows how to apply settings, iterate through acquired records (AERecord or TRRecord), and process them based on their type. ```python 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): ... ``` -------------------------------- ### Device Information and Status Source: https://github.com/vallen-systems/waveline/blob/master/docs/_generated/waveline.spotwave.SpotWave.md Methods for retrieving general information, setup details, and the current status of the SpotWave device. ```APIDOC ## Device Information and Status ### Description Retrieve essential information about the SpotWave device, including its general information, current setup configuration, and operational status. ### Methods #### `get_info()` * **Description**: Get device information. * **Method**: GET * **Endpoint**: Not applicable (method call) #### `get_setup()` * **Description**: Get setup. * **Method**: GET * **Endpoint**: Not applicable (method call) #### `get_status()` * **Description**: Get status. * **Method**: GET * **Endpoint**: Not applicable (method call) ``` -------------------------------- ### Python: Use Integrated Pulser for Coupling Check Source: https://context7.com/vallen-systems/waveline/llms.txt Utilizes the integrated pulser for coupling checks and sensor verification. This example configures channel settings, decimation, and filter, then sets up streaming for two channels. It starts pulsing, captures waveforms, and prints peak values to verify sensor response. ```python import asyncio from waveline import LinWave async def main(): async with LinWave("192.168.0.100") as lw: decimation = 5 block_duration = 0.1 # seconds blocksize = int(block_duration * LinWave.MAX_SAMPLERATE / decimation) await lw.set_channel(channel=0, enabled=False) await lw.set_range_index(channel=0, range_index=0) await lw.set_filter(channel=0, highpass=None, lowpass=None, order=0) await lw.set_tr_decimation(channel=0, factor=decimation) # Setup streaming for both channels stream_ch1 = lw.stream(channel=1, blocksize=blocksize) stream_ch2 = lw.stream(channel=2, blocksize=blocksize) await lw.start_acquisition() # Start pulsing: 4 pulses per channel, 10ms interval, 1 cycle await lw.start_pulsing(channel=0, interval=0.01, count=4, cycles=1) # Capture waveforms from both channels _, y_ch1 = await anext(stream_ch1) _, y_ch2 = await anext(stream_ch2) await lw.stop_pulsing() await lw.stop_acquisition() print(f"Channel 1 peak: {y_ch1.max():.4f} V") print(f"Channel 2 peak: {y_ch2.max():.4f} V") asyncio.run(main()) ``` -------------------------------- ### Configure LinWave Channel Settings (Python) Source: https://context7.com/vallen-systems/waveline/llms.txt Configures various channel settings for a linWave device, including input range, filters, threshold, duration discrimination time (DDT), and transient data recording parameters. It also demonstrates how to retrieve and verify the setup for a specific channel. ```python import asyncio from waveline import LinWave async def main(): async with LinWave("192.168.0.100") as lw: # Configure all channels (channel=0) await lw.set_channel(channel=0, enabled=True) await lw.set_range_index(channel=0, range_index=0) # 0: 50 mV, 1: 5 V await lw.set_filter(channel=0, highpass=100e3, lowpass=450e3, order=8) await lw.set_threshold(channel=0, microvolts=1000) # 1000 µV = 60 dB(AE) await lw.set_ddt(channel=0, microseconds=400) # Duration discrimination time await lw.set_status_interval(channel=0, seconds=2) # Configure transient data recording await lw.set_tr_enabled(channel=0, enabled=True) await lw.set_tr_decimation(channel=0, factor=10) # 10 MHz / 10 = 1 MHz await lw.set_tr_pretrigger(channel=0, samples=200) await lw.set_tr_postduration(channel=0, samples=200) # Verify setup for channel 1 setup = await lw.get_setup(channel=1) print(f"Threshold: {setup.threshold_volts * 1e6:.0f} µV") print(f"Filter: {setup.filter_highpass_hz/1e3:.0f}-{setup.filter_lowpass_hz/1e3:.0f} kHz") print(f"DDT: {setup.ddt_seconds * 1e6:.0f} µs") print(f"TR enabled: {setup.tr_enabled}") print(f"TR decimation: {setup.tr_decimation}") asyncio.run(main()) ``` -------------------------------- ### Acquisition Control Source: https://github.com/vallen-systems/waveline/blob/master/docs/_generated/waveline.linwave.LinWave.md Functions to start and stop the overall data acquisition process. ```APIDOC ## POST /vallen-systems/waveline/acquisition/start ### Description Start the data acquisition process. ### Method POST ### Endpoint /vallen-systems/waveline/acquisition/start ### Parameters None ### Request Example ```json {} ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example ```json { "status": "success" } ``` ## POST /vallen-systems/waveline/acquisition/stop ### Description Stop the data acquisition process. ### Method POST ### Endpoint /vallen-systems/waveline/acquisition/stop ### Parameters None ### Request Example ```json {} ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### Connect to SpotWave and Get Device Info Source: https://context7.com/vallen-systems/waveline/llms.txt Connects to a SpotWave device using its serial port and retrieves essential device information such as firmware version, input ranges, and ADC to volts conversion factor. It also fetches the device status, including temperature and recording status, and provides a method to identify the device by blinking its LED. Requires the waveline library. ```python from waveline import SpotWave # Using context manager (recommended) with SpotWave("COM6") as sw: info = sw.get_info() print(f"Firmware: {info.firmware_version}") print(f"Input ranges: {info.input_range}") print(f"ADC to volts: {info.adc_to_volts}") status = sw.get_status() print(f"Temperature: {status.temperature}°C") print(f"Recording: {status.recording}") # Blink LED to identify device sw.identify() # Output: # Firmware: 00.2D # Input ranges: ['34 mV'] # ADC to volts: [1.041e-06] # Temperature: 28.5°C # Recording: False ``` -------------------------------- ### SpotWave Continuous Mode Acquisition Source: https://context7.com/vallen-systems/waveline/llms.txt Streams continuous transient data from a SpotWave device. This example configures the device for continuous acquisition, setting parameters like decimation, DDT for record length, and filter settings. It then iterates through acquired records, calculating and printing RMS and peak values for each. Dependencies include numpy and the waveline library. ```python import numpy as np from waveline import SpotWave, AERecord, TRRecord def main(): port = SpotWave.discover()[0] with SpotWave(port) as sw: # Configure continuous mode sw.set_continuous_mode(True) sw.set_status_interval(0) # Disable status messages sw.set_tr_enabled(True) sw.set_tr_decimation(4) # 2 MHz / 4 = 500 kHz # DDT determines record length: 100ms * 500kHz = 50,000 samples sw.set_ddt(100000) # 100 ms sw.set_filter(50e3, 200e3, 4) record_count = 0 for record in sw.acquire(): if isinstance(record, TRRecord): record_count += 1 rms = np.sqrt(np.mean(record.data**2)) peak = np.max(np.abs(record.data)) print(f"Record {record_count}: {record.samples} samples, " f"RMS={rms*1e3:.3f}mV, Peak={peak*1e3:.3f}mV") if record_count >= 10: break if __name__ == "__main__": main() ``` -------------------------------- ### Connect to LinWave Device and Get Info (Python) Source: https://context7.com/vallen-systems/waveline/llms.txt Connects to a linWave device and retrieves its information, including firmware version, channel count, input ranges, and hardware ID. It also fetches the device status, such as temperature and recording status. This uses Python's asyncio for asynchronous operations. ```python import asyncio from waveline import LinWave async def main(): # Using async context manager (recommended) async with LinWave("192.168.0.100") as lw: info = await lw.get_info() print(f"Firmware: {info.firmware_version}") print(f"Channels: {info.channel_count}") print(f"Input ranges: {info.input_range}") print(f"Hardware ID: {info.hardware_id}") status = await lw.get_status() print(f"Temperature: {status.temperature}°C") print(f"Recording: {status.recording}") asyncio.run(main()) ``` -------------------------------- ### Device Control Source: https://github.com/vallen-systems/waveline/blob/master/docs/_generated/waveline.spotwave.SpotWave.md Control the operational state of the SpotWave device, including starting and stopping pulsing and acquisition processes. ```APIDOC ## POST /start_pulsing ### Description Starts the pulsing operation on the SpotWave device. ### Method POST ### Endpoint /start_pulsing ### Parameters #### Query Parameters - **interval** (int) - Optional - The interval for pulsing in microseconds. - **count** (int) - Optional - The number of pulses to perform. ### Request Example ```json { "interval": 1000, "count": 10 } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example ```json { "status": "Pulsing started successfully." } ``` ## POST /stop_pulsing ### Description Stops the pulsing operation on the SpotWave device. ### Method POST ### Endpoint /stop_pulsing ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example ```json { "status": "Pulsing stopped successfully." } ``` ## POST /stop_acquisition ### Description Stops the data acquisition process on the SpotWave device. ### Method POST ### Endpoint /stop_acquisition ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example ```json { "status": "Acquisition stopped successfully." } ``` ## POST /stream ### Description Alias for the `acquire` method. Initiates or continues the data streaming from the SpotWave device. ### Method POST ### Endpoint /stream ### Parameters #### Request Body - **args** (list) - Optional - Positional arguments for the acquire method. - **kwargs** (object) - Optional - Keyword arguments for the acquire method. ### Request Example ```json { "args": [], "kwargs": { "duration": 10 } } ``` ### Response #### Success Response (200) - **data** (list) - The acquired data stream. #### Response Example ```json { "data": [ 10.5, 11.2, 10.9 ] } ``` ``` -------------------------------- ### Python: Stream Continuous Waveform Data Source: https://context7.com/vallen-systems/waveline/llms.txt Streams continuous waveform data from a LinWave channel at high sample rates. This example configures the samplerate, blocksize, and filter settings before opening a stream and processing incoming data blocks. It's useful for real-time monitoring and analysis. ```python import asyncio import numpy as np from waveline import LinWave async def main(): async with LinWave("192.168.0.100") as lw: samplerate = 1_000_000 # 1 MHz blocksize = 100_000 # 100k samples per block await lw.set_range_index(channel=0, range_index=0) await lw.set_tr_decimation(channel=0, factor=int(lw.MAX_SAMPLERATE / samplerate)) await lw.set_filter(channel=0, highpass=100e3, lowpass=500e3, order=8) # Open streaming port before starting acquisition stream = lw.stream(channel=1, blocksize=blocksize, timeout=5.0) await lw.start_acquisition() try: block_count = 0 async for time_seconds, data in stream: block_count += 1 rms = np.sqrt(np.mean(data**2)) peak = np.max(np.abs(data)) print(f"Block {block_count}: t={time_seconds:.3f}s, RMS={rms*1e3:.2f}mV, Peak={peak*1e3:.2f}mV") if block_count >= 10: # Stop after 10 blocks break finally: await lw.stop_acquisition() asyncio.run(main()) ``` -------------------------------- ### Initialize SpotWave Device (Python) Source: https://github.com/vallen-systems/waveline/blob/master/docs/_generated/waveline.spotwave.SpotWave.md Initializes the SpotWave device, accepting either a serial port string (e.g., 'COM6') or a pre-configured serial.Serial object. The discover method can be used to find available ports. ```python import waveline # Example 1: Without context manager sw = waveline.SpotWave("COM6") print(sw.get_setup()) # ... perform operations ... sw.close() # Example 2: Using context manager with waveline.SpotWave("COM6") as sw: print(sw.get_setup()) # ... perform operations ... ``` -------------------------------- ### Device Initialization and Connection Source: https://github.com/vallen-systems/waveline/blob/master/docs/_generated/waveline.spotwave.SpotWave.md Methods for initializing, connecting to, and closing the serial connection with the SpotWave device. ```APIDOC ## Device Initialization and Connection ### Description These methods handle the initialization of the SpotWave device, establishing a serial connection, and closing it when no longer needed. ### Methods #### `__init__(port)` * **Description**: Initialize device. * **Parameters**: * `port` (string) - The serial port to connect to. #### `connect()` * **Description**: Open serial connection to the device. * **Method**: GET * **Endpoint**: Not applicable (method call) #### `close()` * **Description**: Close serial connection to the device. * **Method**: GET * **Endpoint**: Not applicable (method call) ``` -------------------------------- ### Pulsing Control Source: https://github.com/vallen-systems/waveline/blob/master/docs/_generated/waveline.linwave.LinWave.md Methods for starting and stopping pulsing operations on a channel. ```APIDOC ## Pulsing Control ### Description Methods for starting and stopping pulsing operations on a channel. ### Methods * **`start_pulsing(channel[, interval, count, cycles])`** * Description: Start pulsing on a specified channel. * Parameters: * `channel` (int): The channel number. * `interval` (float, optional): The interval between pulses in seconds. * `count` (int, optional): The number of pulses to generate. * `cycles` (int, optional): The number of cycles per pulse. * **`stop_pulsing()`** * Description: Stop any active pulsing operations. * Method: N/A (Assumed to be called on an initialized and connected device) ``` -------------------------------- ### Initialize and Use LinWave (Manual Connection) - Python Source: https://github.com/vallen-systems/waveline/blob/master/docs/_generated/waveline.linwave.LinWave.md Demonstrates manual initialization, connection, information retrieval, and disconnection of the LinWave device. This method requires explicit calls to connect() and close(). ```python import asyncio import waveline async def main(): lw = waveline.LinWave("192.168.0.100") await lw.connect() print(await lw.get_info()) # ... other operations ... await lw.close() asyncio.run(main()) ``` -------------------------------- ### Initialization and Connection Source: https://github.com/vallen-systems/waveline/blob/master/docs/_generated/waveline.linwave.LinWave.md Methods for initializing, connecting to, and closing the connection with a LinWave device. ```APIDOC ## Initialization and Connection ### Description Methods for initializing, connecting to, and closing the connection with a LinWave device. ### Methods * **`__init__(address)`** * Description: Initialize device. * Parameters: * `address` (str): The network address of the device. * **`connect()`** * Description: Connect to the device. * Method: N/A (Assumed to be called after initialization) * **`close()`** * Description: Close the connection to the device. * Method: N/A (Assumed to be called to terminate the connection) ``` -------------------------------- ### Pulsing Control Source: https://github.com/vallen-systems/waveline/blob/master/docs/_generated/waveline.linwave.LinWave.md Functions to start and stop pulsing, with parameters to control interval, count, and cycles. ```APIDOC ## POST /vallen-systems/waveline/pulsing/start ### Description Start pulsing for a specified channel with configurable interval, count, and cycles. ### Method POST ### Endpoint /vallen-systems/waveline/pulsing/start ### Parameters #### Request Body - **channel** (int) - Required - Channel number (0 for all channels). - **interval** (float) - Optional - Interval between pulses in seconds. Default is 1. - **count** (int) - Optional - Number of pulses per channel, 0 for infinite pulses. Default is 4. - **cycles** (int) - Optional - Number of pulse cycles (automatically pulse through each channel in cycles). Only useful if all channels are chosen. Default is 1. ### Request Example ```json { "channel": 0, "interval": 0.5, "count": 10, "cycles": 2 } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example ```json { "status": "success" } ``` ## POST /vallen-systems/waveline/pulsing/stop ### Description Stop the pulsing process. ### Method POST ### Endpoint /vallen-systems/waveline/pulsing/stop ### Parameters None ### Request Example ```json {} ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### Initialize and Use LinWave (Async Context Manager) - Python Source: https://github.com/vallen-systems/waveline/blob/master/docs/_generated/waveline.linwave.LinWave.md Illustrates using the LinWave class with an asynchronous context manager. This approach automatically handles connection and disconnection, simplifying resource management. ```python import asyncio import waveline async def main(): async with waveline.LinWave("192.168.0.100") as lw: print(await lw.get_info()) # ... other operations ... asyncio.run(main()) ``` -------------------------------- ### Device Configuration Source: https://github.com/vallen-systems/waveline/blob/master/docs/_generated/waveline.spotwave.SpotWave.md Methods for configuring various settings of the SpotWave device, including thresholds, filters, logging, and timing parameters. ```APIDOC ## Device Configuration ### Description Configure various operational parameters of the SpotWave device, such as data acquisition settings, logging modes, and timing intervals. ### Methods #### `set_cct(interval_seconds)` * **Description**: Set coupling check transmitter (CCT) / pulser interval. * **Parameters**: * `interval_seconds` (float) - The interval in seconds for the CCT. #### `set_continuous_mode(enabled)` * **Description**: Enable/disable continuous mode. * **Parameters**: * `enabled` (boolean) - True to enable, False to disable. #### `set_datetime([timestamp])` * **Description**: Set current date and time. * **Parameters**: * `timestamp` (int/float) - Optional. Unix timestamp to set the device time. #### `set_ddt(microseconds)` * **Description**: Set duration discrimination time (DDT). * **Parameters**: * `microseconds` (int) - The DDT value in microseconds. #### `set_filter([highpass, lowpass, order])` * **Description**: Set IIR filter frequencies and order. * **Parameters**: * `highpass` (float) - High-pass filter cutoff frequency. * `lowpass` (float) - Low-pass filter cutoff frequency. * `order` (int) - The order of the IIR filter. #### `set_logging_mode(enabled)` * **Description**: Enable/disable data log mode. * **Parameters**: * `enabled` (boolean) - True to enable, False to disable. #### `set_status_interval(seconds)` * **Description**: Set status interval. * **Parameters**: * `seconds` (float) - The interval in seconds for status updates. #### `set_threshold(microvolts)` * **Description**: Set threshold for hit-based acquisition. * **Parameters**: * `microvolts` (int) - The threshold value in microvolts. #### `set_tr_decimation(factor)` * **Description**: Set decimation factor of transient data. * **Parameters**: * `factor` (int) - The decimation factor. #### `set_tr_enabled(enabled)` * **Description**: Enable/disable recording of transient data. * **Parameters**: * `enabled` (boolean) - True to enable, False to disable. #### `set_tr_postduration(samples)` * **Description**: Set post-duration samples for transient data. * **Parameters**: * `samples` (int) - The number of post-duration samples. #### `set_tr_pretrigger(samples)` * **Description**: Set pre-trigger samples for transient data. * **Parameters**: * `samples` (int) - The number of pre-trigger samples. ``` -------------------------------- ### Get AE Data Source: https://github.com/vallen-systems/waveline/blob/master/docs/_generated/waveline.linwave.LinWave.md Retrieve Acoustic Emission (AE) data records, which can include status or hit data. ```APIDOC ## GET /vallen-systems/waveline/ae_data ### Description Retrieve Acoustic Emission (AE) data records. These records can be either status data or hit data. ### Method GET ### Endpoint /vallen-systems/waveline/ae_data ### Parameters None ### Request Example ```json {} ``` ### Response #### Success Response (200) - **data** (list) - A list of AE data records. Each record is of type AERecord. #### Response Example ```json { "data": [ { "timestamp": 1678886400, "amplitude": 100, "duration": 50, "channel": 1 }, { "timestamp": 1678886401, "status": "OK", "channel": 0 } ] } ``` ``` -------------------------------- ### Device Configuration Source: https://github.com/vallen-systems/waveline/blob/master/docs/_generated/waveline.spotwave.SpotWave.md Configure various settings of the SpotWave device, including continuous mode, DDT, status intervals, and transient recording parameters. ```APIDOC ## POST /set_continuous_mode ### Description Enables or disables the continuous mode of the SpotWave device. When enabled, the threshold setting is ignored. ### Method POST ### Endpoint /set_continuous_mode ### Parameters #### Request Body - **enabled** (bool) - Required - Set to `True` to enable continuous mode. ### Request Example ```json { "enabled": true } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example ```json { "status": "Continuous mode set successfully." } ``` ## POST /set_ddt ### Description Sets the Duration Discrimination Time (DDT) for the SpotWave device. ### Method POST ### Endpoint /set_ddt ### Parameters #### Request Body - **microseconds** (int) - Required - The DDT value in microseconds. ### Request Example ```json { "microseconds": 50000 } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example ```json { "status": "DDT set successfully." } ``` ## POST /set_status_interval ### Description Sets the interval at which status information is reported by the SpotWave device. ### Method POST ### Endpoint /set_status_interval ### Parameters #### Request Body - **seconds** (int) - Required - The status reporting interval in seconds. ### Request Example ```json { "seconds": 5 } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example ```json { "status": "Status interval set successfully." } ``` ## POST /set_tr_enabled ### Description Enables or disables the recording of transient data on the SpotWave device. ### Method POST ### Endpoint /set_tr_enabled ### Parameters #### Request Body - **enabled** (bool) - Required - Set to `True` to enable transient data recording. ### Request Example ```json { "enabled": true } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example ```json { "status": "Transient recording enabled successfully." } ``` ## POST /set_tr_decimation ### Description Sets the decimation factor for transient data recording on the SpotWave device. The sampling rate for transient data will be 2 MHz / factor. ### Method POST ### Endpoint /set_tr_decimation ### Parameters #### Request Body - **factor** (int) - Required - The decimation factor. ### Request Example ```json { "factor": 10 } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example ```json { "status": "Transient data decimation factor set successfully." } ``` ``` -------------------------------- ### Get Transient Data Records Source: https://github.com/vallen-systems/waveline/blob/master/docs/_generated/waveline.linwave.LinWave.md Retrieves all available transient data records. Optionally returns raw ADC values instead of converted volts. ```APIDOC ## GET /vallen-systems/waveline/get_tr_data ### Description Get transient data records. Optionally returns raw ADC values instead of converted volts. ### Method GET ### Endpoint /vallen-systems/waveline/get_tr_data ### Parameters #### Query Parameters - **raw** (bool) - Optional - Return TR amplitudes as ADC values if True, skip conversion to volts ### Response #### Success Response (200) - **records** (list[TRRecord]) - List of transient data records #### Response Example { "records": [ { "timestamp": 1678886400.123456, "amplitude": 0.12345 } ] } ``` -------------------------------- ### Get Transient Data Snapshot Source: https://github.com/vallen-systems/waveline/blob/master/docs/_generated/waveline.linwave.LinWave.md Captures a snapshot of transient data from a specified channel. Allows configuration of sample count and pre-trigger samples. Optionally returns raw ADC values. ```APIDOC ## GET /vallen-systems/waveline/get_tr_snapshot ### Description Get a snapshot of transient data from a specified channel. 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. Optionally returns raw ADC values instead of converted volts. ### Method GET ### Endpoint /vallen-systems/waveline/get_tr_snapshot ### Parameters #### Query Parameters - **channel** (int) - Required - Channel number (0 for all channels) - **samples** (int) - Required - Number of samples to read - **pretrigger_samples** (int) - Optional - Number of samples to read before the execution of the command (default: 0) - **raw** (bool) - Optional - Return TR amplitudes as ADC values if True, skip conversion to volts (default: False) ### Response #### Success Response (200) - **records** (list[TRRecord]) - List of transient data records #### Response Example { "records": [ { "timestamp": 0, "amplitude": 0.56789 } ] } ``` -------------------------------- ### Buffer and Data Log Management Source: https://github.com/vallen-systems/waveline/blob/master/docs/_generated/waveline.spotwave.SpotWave.md Methods for clearing the device's internal buffers and data logs. ```APIDOC ## Buffer and Data Log Management ### Description Manage the data buffers and logs within the SpotWave device. These methods allow you to clear the input/output buffers and erase any stored data logs. ### Methods #### `clear_buffer()` * **Description**: Clear input and output buffer. * **Method**: GET * **Endpoint**: Not applicable (method call) #### `clear_data_log()` * **Description**: Clear logged data from internal memory. * **Method**: GET * **Endpoint**: Not applicable (method call) ``` -------------------------------- ### Get Transient Data Snapshot (Python) Source: https://github.com/vallen-systems/waveline/blob/master/docs/_generated/waveline.linwave.LinWave.md Captures a snapshot of transient data for a specified channel. The recording duration is determined by 'samples' and 'pretrigger_samples'. The 'raw' parameter dictates the data format (ADC values or volts). ```python async def get_tr_snapshot(channel, samples, pretrigger_samples=0, raw=False): """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:** * **channel** ([`int`](https://docs.python.org/3/library/functions.html#int)) – Channel number (0 for all channels) * **samples** ([`int`](https://docs.python.org/3/library/functions.html#int)) – Number of samples to read * **pretrigger_samples** ([`int`](https://docs.python.org/3/library/functions.html#int)) – Number of samples to read before the execution of the command * **raw** ([`bool`](https://docs.python.org/3/library/functions.html#bool)) – Return TR amplitudes as ADC values if *True*, skip conversion to volts * **Return type:** [`list`](https://docs.python.org/3/library/stdtypes.html#list)[[`TRRecord`](waveline.datatypes.TRRecord.md#waveline.datatypes.TRRecord)] * **Returns:** List of transient data records """ pass ``` -------------------------------- ### Configure Waveline Acquisition Settings Source: https://github.com/vallen-systems/waveline/blob/master/docs/_generated/waveline.datatypes.Setup.md This endpoint allows you to configure various acquisition parameters for the Waveline system, including voltage thresholds, timing intervals, and transient recording settings. ```APIDOC ## PUT /vallen-systems/waveline/config ### Description Configure acquisition and transient recording settings for the Waveline system. ### Method PUT ### Endpoint /vallen-systems/waveline/config ### Parameters #### Request Body - **threshold_volts** (float) - Required - Threshold for hit-based acquisition in volts - **ddt_seconds** (float) - Required - Duration discrimination time (DDT) in seconds - **status_interval_seconds** (float) - Required - Status interval in seconds - **tr_enabled** (bool) - Required - Flag if transient data recording is enabled - **tr_decimation** (int) - Optional - Decimation factor for transient data - **tr_pretrigger_samples** (int) - Optional - Pre-trigger samples for transient data - **tr_postduration_samples** (int) - Optional - Post-duration samples for transient data - **extra** (dict[str, str]) - Optional - Extra setup information (specific to device and firmware version) ### Request Example ```json { "threshold_volts": 0.5, "ddt_seconds": 0.001, "status_interval_seconds": 10.0, "tr_enabled": true, "tr_decimation": 10, "tr_pretrigger_samples": 100, "tr_postduration_samples": 500, "extra": { "firmware_version": "1.2.3" } } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message indicating successful configuration. #### Response Example ```json { "message": "Waveline configuration updated successfully." } ``` ``` -------------------------------- ### Convert Waveline Units (Volts to dB(AE)) Source: https://context7.com/vallen-systems/waveline/llms.txt Provides utility functions for converting between volts and dB(AE) units within the Waveline system. It includes examples of converting a dB(AE) threshold value to its equivalent in microvolts. ```python import numpy as np from waveline.utils import decibel_to_volts, volts_to_decibel # Convert dB(AE) to volts threshold_db = 60 # 60 dB(AE) threshold_volts = decibel_to_volts(threshold_db) print(f"{threshold_db} dB(AE) = {threshold_volts*1e6:.0f} µV") # Output: 60 dB(AE) = 1000 µV ``` -------------------------------- ### Get Transient Data Records (Python) Source: https://github.com/vallen-systems/waveline/blob/master/docs/_generated/waveline.linwave.LinWave.md Retrieves transient data records from the Waveline system. The 'raw' parameter controls whether data is returned as ADC values or converted to volts. This function returns a list of TRRecord objects. ```python async def get_tr_data(raw=False): """Get transient data records. * **Parameters:** **raw** ([`bool`](https://docs.python.org/3/library/functions.html#bool)) – Return TR amplitudes as ADC values if *True*, skip conversion to volts * **Return type:** [`list`](https://docs.python.org/3/library/stdtypes.html#list)[[`TRRecord`](waveline.datatypes.TRRecord.md#waveline.datatypes.TRRecord)] * **Returns:** List of transient data records """ pass ``` -------------------------------- ### Channel and Device Configuration Source: https://github.com/vallen-systems/waveline/blob/master/docs/_generated/waveline.linwave.LinWave.md Methods for configuring individual channels and device settings. ```APIDOC ## Channel and Device Configuration ### Description Methods for configuring individual channels and device settings. ### Methods * **`get_setup(channel)`** * Description: Get setup information for a specific channel. * Parameters: * `channel` (int): The channel number. * **`get_status()`** * Description: Get the current status information of the device. * Method: N/A (Assumed to be called on an initialized and connected device) * **`identify([channel])`** * Description: Blink LEDs to identify the device or a single channel. * Parameters: * `channel` (int, optional): The channel number to identify. If not specified, the device is identified. * **`set_channel(channel, enabled)`** * Description: Enable or disable a specific channel. * Parameters: * `channel` (int): The channel number. * `enabled` (bool): True to enable, False to disable. * **`set_continuous_mode(channel, enabled)`** * Description: Enable or disable continuous data acquisition mode for a channel. * Parameters: * `channel` (int): The channel number. * `enabled` (bool): True to enable, False to disable. * **`set_ddt(channel, microseconds)`** * Description: Set the Duration Discrimination Time (DDT) for a channel. * Parameters: * `channel` (int): The channel number. * `microseconds` (int): The DDT value in microseconds. * **`set_filter(channel[, highpass, lowpass, order])`** * Description: Set the IIR filter frequencies and order for a channel. * Parameters: * `channel` (int): The channel number. * `highpass` (float, optional): The high-pass cutoff frequency. * `lowpass` (float, optional): The low-pass cutoff frequency. * `order` (int, optional): The filter order. * **`set_range(channel, range_volts)`** * Description: Set the input voltage range for a channel. * Parameters: * `channel` (int): The channel number. * `range_volts` (float): The desired input range in Volts. * **`set_range_index(channel, range_index)`** * Description: Set the input voltage range for a channel using a range index. * Parameters: * `channel` (int): The channel number. * `range_index` (int): The index corresponding to the desired range. * **`set_status_interval(channel, seconds)`** * Description: Set the interval for status updates for a channel. * Parameters: * `channel` (int): The channel number. * `seconds` (float): The interval in seconds. * **`set_threshold(channel, microvolts)`** * Description: Set the threshold for hit-based acquisition for a channel. * Parameters: * `channel` (int): The channel number. * `microvolts` (float): The threshold value in microvolts. * **`set_tr_decimation(channel, factor)`** * Description: Set the decimation factor for transient data and streaming data for a channel. * Parameters: * `channel` (int): The channel number. * `factor` (int): The decimation factor. * **`set_tr_enabled(channel, enabled)`** * Description: Enable or disable the recording of transient data for a channel. * Parameters: * `channel` (int): The channel number. * `enabled` (bool): True to enable, False to disable. * **`set_tr_postduration(channel, samples)`** * Description: Set the post-duration samples for transient data acquisition for a channel. * Parameters: * `channel` (int): The channel number. * `samples` (int): The number of post-duration samples. * **`set_tr_pretrigger(channel, samples)`** * Description: Set the pre-trigger samples for transient data acquisition for a channel. * Parameters: * `channel` (int): The channel number. * `samples` (int): The number of pre-trigger samples. * **`set_tr_samples(channel[, min_samples, ...])`** * Description: Set the number of samples (limits) for transient data acquisition for a channel. * Parameters: * `channel` (int): The channel number. * `min_samples` (int, optional): The minimum number of samples. * `...`: Additional parameters may be accepted. ``` -------------------------------- ### Device Discovery and Information Source: https://github.com/vallen-systems/waveline/blob/master/docs/_generated/waveline.linwave.LinWave.md Methods for discovering LinWave devices on the network and retrieving device information. ```APIDOC ## Device Discovery and Information ### Description Methods for discovering LinWave devices on the network and retrieving device information. ### Methods * **`discover([timeout])`** * Description: Discover LinWave devices in the network. * Parameters: * `timeout` (float, optional): The timeout in seconds for the discovery process. * **`get_info()`** * Description: Get general information about the connected device. * Method: N/A (Assumed to be called on an initialized and connected device) ``` -------------------------------- ### Clear Waveline Internal Data Log Source: https://github.com/vallen-systems/waveline/blob/master/docs/_generated/waveline.spotwave.SpotWave.md The `clear_data_log` method erases all previously logged data from the Waveline device's internal memory. This is typically used to free up space or to start a fresh data logging session. Ensure that any required data has been retrieved before calling this method. ```python sw.clear_data_log() ``` -------------------------------- ### Enable SpotWave Data Logging Source: https://context7.com/vallen-systems/waveline/llms.txt Enables internal data logging to the SpotWave device's memory. This involves configuring acquisition parameters like continuous mode, threshold, and DDT, then enabling logging mode. Data is retrieved from the device's log and can be cleared afterward. ```python from waveline import SpotWave def main(): port = SpotWave.discover()[0] with SpotWave(port) as sw: # Configure acquisition sw.set_continuous_mode(False) sw.set_threshold(1000) sw.set_ddt(400) # Enable logging mode sw.set_logging_mode(True) # Start acquisition (data stored internally) sw.start_acquisition() # ... acquisition runs, data logged to internal memory ... sw.stop_acquisition() # Retrieve logged data logged_records = sw.get_data_log() print(f"Retrieved {len(logged_records)} logged records") for record in logged_records: print(f"Time: {record.time:.6f}s, Amplitude: {record.amplitude*1e6:.1f}µV") # Clear log sw.clear_data_log() sw.set_logging_mode(False) if __name__ == "__main__": main() ``` -------------------------------- ### Device Information and Status Source: https://github.com/vallen-systems/waveline/blob/master/docs/_generated/waveline.spotwave.SpotWave.md Retrieve information, status, and configuration details from the SpotWave device. ```APIDOC ## GET /get_info ### Description Retrieves detailed information about the SpotWave device. ### Method GET ### Endpoint /get_info ### Response #### Success Response (200) - **device_info** (object) - Dataclass containing device information (e.g., firmware version, serial number). #### Response Example ```json { "device_info": { "firmware_version": "00.2D", "serial_number": "SN12345" } } ``` ## GET /get_setup ### Description Retrieves the current setup configuration of the SpotWave device. ### Method GET ### Endpoint /get_setup ### Response #### Success Response (200) - **setup_config** (object) - Dataclass containing the device's setup configuration. #### Response Example ```json { "setup_config": { "continuous_mode": false, "ddt": 50000 } } ``` ## GET /get_status ### Description Retrieves the current operational status of the SpotWave device. ### Method GET ### Endpoint /get_status ### Response #### Success Response (200) - **device_status** (object) - Dataclass containing the device's status information (e.g., battery level, operational state). #### Response Example ```json { "device_status": { "battery_level": 85, "operational_state": "idle" } } ``` ```