master 046520b07e5b cached
142 files
1.0 MB
298.0k tokens
299 symbols
1 requests
Download .txt
Showing preview only (1,092K chars total). Download the full file or copy to clipboard to get everything.
Repository: picotech/picosdk-python-wrappers
Branch: master
Commit: 046520b07e5b
Files: 142
Total size: 1.0 MB

Directory structure:
gitextract_5m9lzjjf/

├── .github/
│   ├── CODE_OF_CONDUCT.md
│   ├── CONTRIBUTING.md
│   ├── PULL_REQUEST_TEMPLATE.md
│   └── issue_template.md
├── .gitignore
├── LICENSE.md
├── README.md
├── discontinuedExamples/
│   └── anyScopeExamples/
│       └── block.py
├── picohrdlExamples/
│   ├── picohrdlSingleModeExample.py
│   └── picohrdlStreamingModeExample.py
├── picosdk/
│   ├── PicoConnectProbes.py
│   ├── PicoDeviceEnums.py
│   ├── PicoDeviceStructs.py
│   ├── __init__.py
│   ├── constants.py
│   ├── ctypes_wrapper.py
│   ├── device.py
│   ├── discover.py
│   ├── errors.py
│   ├── functions.py
│   ├── functionsExhibitions.py
│   ├── library.py
│   ├── picoMeasurements.py
│   ├── picohrdl.py
│   ├── picosynth.py
│   ├── pl1000.py
│   ├── ps2000.py
│   ├── ps2000a.py
│   ├── ps3000.py
│   ├── ps3000a.py
│   ├── ps4000.py
│   ├── ps4000a.py
│   ├── ps5000.py
│   ├── ps5000a.py
│   ├── ps6000.py
│   ├── ps6000a.py
│   ├── psospa.py
│   ├── psospaBlockExample.py
│   ├── usbDrDaq.py
│   ├── usbPT104.py
│   └── usbtc08.py
├── picosynthExamples/
│   └── picosynthFrequencySweepExample.py
├── pl1000Examples/
│   ├── pl1000SingleModeExample.py
│   ├── pl1000StreamingModeExample.py
│   └── pl1000StreamingModeMultiChannelExample.py
├── ps2000Examples/
│   ├── advanced triggers/
│   │   ├── trigger_read_dropout.py
│   │   ├── trigger_read_interval.py
│   │   ├── trigger_read_pwq.py
│   │   ├── trigger_read_runt.py
│   │   ├── trigger_read_window.py
│   │   └── trigger_read_wpwq.py
│   ├── block_read.py
│   ├── device_info.py
│   ├── gen_sq_wave.py
│   ├── ps2000BlockExample.py
│   ├── ps2000ETSBlockExample.py
│   ├── ps2000SigGen.py
│   └── streaming_mode/
│       ├── streaming_mode.py
│       ├── streaming_mode_gathering.py
│       ├── streaming_mode_polling.py
│       └── streaming_mode_threaded.py
├── ps2000aExamples/
│   ├── ps2000aBlockAdvancedEdgeExample.py
│   ├── ps2000aBlockExample.py
│   ├── ps2000aBlockExampleCallbackMethod.py
│   ├── ps2000aMSOBlockExample.py
│   ├── ps2000aRapidBlockExample.py
│   ├── ps2000aSigGen.py
│   └── ps2000aStreamingExample.py
├── ps3000EExamples/
│   ├── ps3000EBlockExample.py
│   ├── ps3000ERapidBlockExample.py
│   └── ps3000EStreamingModeExample.py
├── ps3000aExamples/
│   ├── ps3000aBlockAdvancedTriggerExample.py
│   ├── ps3000aBlockExample.py
│   ├── ps3000aBlockMSOExample.py
│   ├── ps3000aRapidBlockExample.py
│   ├── ps3000aSigGen.py
│   └── ps3000aStreamingExample.py
├── ps4000Examples/
│   ├── ps4000BlockExample.py
│   └── ps4000StreamingExample.py
├── ps4000aExamples/
│   ├── ps4000 Ch4 AND logic triggering.py
│   ├── ps4000aBlockAdvancedEdgeTriggerExample.py
│   ├── ps4000aBlockDropoutTriggerExample.py
│   ├── ps4000aBlockFrequencyCounterExample.py
│   ├── ps4000aRapidBlockExample.py
│   ├── ps4000aRapidBlockWaveformAveragingExample.py
│   ├── ps4000aSigGen.py
│   ├── ps4000aStreamingExample.py
│   ├── ps4000a_Runt_trigger.py
│   ├── ps4444BlockExample.py
│   ├── ps4444BlockPicoConnectProbesExample.py
│   └── ps4824BlockExample.py
├── ps5000Examples/
│   ├── ps5000BlockExample.py
│   ├── ps5000RapidBlockExample.py
│   └── ps5000StreamingExample.py
├── ps5000aExamples/
│   ├── ps5000aBlockAdvancedTriggerExample.py
│   ├── ps5000aBlockCallbackExample.py
│   ├── ps5000aBlockExample.py
│   ├── ps5000aBlockLevelPulseWidthAdvancedTriggerExample.py
│   ├── ps5000aBlockMSOExample.py
│   ├── ps5000aBlockMSOTriggerExample.py
│   ├── ps5000aBlockWindowPulseWidthAdvancedTriggerExample.py
│   ├── ps5000aRapidBlockExample.py
│   ├── ps5000aSigGen.py
│   └── ps5000aStreamingExample.py
├── ps6000Examples/
│   ├── ps6000BlockAdvancedTriggerExample.py
│   ├── ps6000BlockExample.py
│   ├── ps6000GetInfoExample.py
│   ├── ps6000RapidBlockExample.py
│   ├── ps6000RapidBlockTriggerTimestampExample.py
│   ├── ps6000SigGen.py
│   └── ps6000StreamingExample.py
├── ps6000aExamples/
│   ├── ps6000aBlockAdvancedTriggerExample.py
│   ├── ps6000aBlockExample.py
│   ├── ps6000aBlockExampleExtClk.py
│   ├── ps6000aBlockExampleTrigTimes.py
│   ├── ps6000aBlockMSODigitalTriggerExample.py
│   ├── ps6000aBlockMSOExample.py
│   ├── ps6000aBlock_both_MSOExample.py
│   ├── ps6000aGetUnitInfo.py
│   ├── ps6000aRapidBlockExample.py
│   ├── ps6000aSigGenExample.py
│   └── ps6000aStreamingModeExample.py
├── pt104Examples/
│   ├── pt104DirectEthernet.py
│   ├── pt104EnumerateTestsExample.py
│   └── pt104Example.py
├── requirements-for-examples.txt
├── requirements.txt
├── setup.py
├── setupPicosynth.py
├── test/
│   ├── __init__.py
│   ├── run_examples.sh
│   ├── test_discover.py
│   ├── test_get_unit_info.py
│   ├── test_helpers.py
│   ├── test_open_close_unit.py
│   ├── test_set_channel.py
│   └── test_timebase.py
├── usbdrdaqExamples/
│   ├── usbdrdaqPhBlockExample.py
│   └── usbdrdaqScopeBlockExample.py
└── usbtc08Examples/
    ├── tc08SingleModeExample.py
    ├── tc08StreamingModeExample.py
    └── tc08StreamingModeMultiChExample.py

================================================
FILE CONTENTS
================================================

================================================
FILE: .github/CODE_OF_CONDUCT.md
================================================
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at support@picotech.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/


================================================
FILE: .github/CONTRIBUTING.md
================================================
# Contributing

We welcome contributions to the picosdk-python-examples repository. By contributing to this repository, you agree to abide by our [code of conduct](CODE_OF_CONDUCT.md).

## Steps to contribute

1. Fork, then clone the repository:

```
git clone https://github.com/YOUR-USERNAME/picosdk-python-wrappers.git
```

2. Create a new branch - specify a name in lowercase, using hyphens to link words e.g. `fft-example`

3. Push to the new branch on your fork, and then submit a pull request.

We will then review the pull request.

## Pull request guidelines

* Follow the conventions in the other file headers if adding a new file, or changing an existing file
* If contributing a new file, ensure that it is in the appropriate location in the repository directory structure
* [Commit messages](https://chris.beams.io/posts/git-commit/#seven-rules) should clearly communicate the reason for the change

================================================
FILE: .github/PULL_REQUEST_TEMPLATE.md
================================================
Fixes #.

Changes proposed in this pull request:

*
*
*


================================================
FILE: .github/issue_template.md
================================================
### Setup

* Example filename:
* Version of Python:
* Pico Technology device model:
* Driver name, version number and platform (32- or 64-bit):
* Operating system:
* USB port type	(e.g. 2.0):

### Description

#### Steps to reproduce the issue

Use one of two methods to describe the issue:

1. A list of steps to reproduce the issue. 
1. A natural language description of what you were doing when the issue occurred if you are unable to work out what the steps are. 

#### Actual Result



#### Expected Result



### Notes

Include any other information here.

================================================
FILE: .gitignore
================================================
# .gitignore file for picosdk-ps6000a-matlab-instrument-driver
# Untracked files/folders to ignore.

# Windows platforms

**/*.obj
**/*.lib
**/*.exp
**/*.bak

# All platforms

**/*.h

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]

# Distribution / packaging
build/
dist/
*.egg-info/
*.egg

================================================
FILE: LICENSE.md
================================================
Copyright © 2019 Pico Technology Ltd.

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

================================================
FILE: README.md
================================================
# picosdk-python-wrappers

Welcome to the PicoSDK for Python. It allows you to control PicoScope devices in your own Python programs.

## Getting started

To use this code you will need to install the PicoSDK C libraries.

### Microsoft Windows

Please visit [our Downloads page](https://www.picotech.com/downloads) to download the 32-bit or 64-bit PicoSDK C Libraries for Windows. 
Please take care to match the "bitness" of your python to the PicoSDK.

### Linux

Follow the instructions from our [Linux Software & Drivers for Oscilloscopes and Data Loggers page](https://www.picotech.com/downloads/linux) 
to install the required driver packages for your product.

### macOS

Please visit [our Downloads page](https://www.picotech.com/downloads) to download the PicoSDK C Libraries for MacOS.

## Installing the python driver bindings

A `distutils` installer is provided. After you have installed the PicoSDK
driver package (see above), the Python package can be installed using the
following command in the top-level directory:

    pip install .

If you are not using a virtualenv or are not elevated, use:

    python setup.py install
	
=======
For using the AS108 you will need to use the following as well:

	python setupPicosynth.py install
	

On macOS and Linux you will either need to use `sudo` with this command, to
install into the system folders, or to install for the current user only you
can use:

    pip install . --user

Within python, the library for `import` is called `picosdk`.

## Compatibility

This code is written to be compatible with both Python 2.7 and Python 3 (any version).

If you find a compatibility problem please raise an [Issue](https://www.picotech.com/tech-support), listing all the versions you can find (python, numpy, 
picosdk commit hash, etc.) and your error message(s).

## C interface

You can access C driver functions directly (ctypes calls) by their original C name, following the [Programmer's
Guides](https://github.com/picotech/picosdk-python-wrappers#programmers-guides) exactly. Examples are provided in the folders like `psX000[a]Examples/`.

### Programmer's Guides

You can download Programmer's Guides providing a description of the API functions for the relevant PicoScope or 
PicoLog driver from our [Documentation page](https://www.picotech.com/library/documentation).

## Python interface

We are in the process of adding Pythonic wrappers around the C functions. If we haven't got to your feature yet or your device is listed as one of the [unsupported models](https://github.com/picotech/picosdk-python-wrappers#unsupported-models),
let us know that you're waiting in an [Issue](https://www.picotech.com/tech-support)

### Unsupported models

The following drivers and devices are not yet supported:

* `plcm3` - PicoLog CM3 Current Data Logger
* `ps3000` - PicoScope 3204, 3205, 3206, 3223, 3224, 3423 & 3423

### Dependencies

As well as depending on the C libraries, the Python wrappers use some Python libraries like `numpy`. Many of the
examples scripts also use the `matplotlib` plotting library. You can install these dependencies with pip as follows:

    pip install -r requirements.txt
    pip install -r requirements-for-examples.txt

### Driver-agnostic examples

The `anyScopeExamples` folder contains examples in pure python which do the same thing as the C-style examples, but
in a driver-generic way.  These examples are currently not being developed further but are still avaliable to use 
and develop futher yourself.

### Python Classes

#### Library

`picosdk.library.Library` contains a base class for each of the driver classes. It does the job of translating python
types into C ones, and back again, and some unit conversions to get rid of nano, micro and milli-style prefixes. It also
handles any differences in programming API between PicoScope driver versions.

#### Device

`picosdk.device.Device` contains the concrete class which represents a PicoScope with a valid handle. It caches some
information about the device state, like the currently selected voltage ranges of the channels.

It is implemented in terms of the Library class' public interface, and deals almost entirely with python types. The
main exception is its handling of numpy arrays - it (knowing the voltage ranges) is responsible for converting the raw
ADC counts that the driver uses for amplitude into physical units.

## Testing this code

Check which device driver your device uses, and check the constants at the top of test/test_helpers.py to enable the 
relevant drivers for connected-device tests. (most tests use this).

To check which driver your device uses, you can use `picosdk.discover`:

    from picosdk.discover import find_all_units
    
    scopes = find_all_units()
    
    for scope in scopes:
        print(scope.info)
        scope.close()

You should then configure test/test_helpers.py's list of connected devices, so it can run all the tests we have
on your device.

To run the unit tests, you will need to install nose (e.g. `pip install nose`.) Then, run `nosetests` in the root of 
the repo. 

## Obtaining support

Please visit our [Support page](https://www.picotech.com/tech-support) to contact us directly or visit our [Test and Measurement Forum](https://www.picotech.com/support/forum17.html) to post questions.

## Copyright and licensing

See [LICENSE.md](LICENSE.md) for license terms. 

*PicoScope*, *PicoLog* and *PicoSDK* are registered trademarks of Pico Technology Ltd. 

*Windows* is a registered trademark of Microsoft Corporation. 

*macOS* is a registered trademark of Apple Inc. 

*Linux* is the registered trademark of Linus Torvalds in the U.S. and other countries.

Copyright © 2018-2019 Pico Technology Ltd. All rights reserved. 


================================================
FILE: discontinuedExamples/anyScopeExamples/block.py
================================================
#
# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.
#
from __future__ import print_function
from picosdk.discover import find_unit
from picosdk.device import ChannelConfig, TimebaseOptions
import matplotlib.pyplot as plt

with find_unit() as device:

    print("found PicoScope: %s" % (device.info,))

    channel_configs = [ChannelConfig('A', True, 'DC', 5.)]
    microsecond = 1.e-6
    # the entry-level scopes only have about 8k-samples of memory onboard for block mode, so only ask for 6k samples.
    timebase_options = TimebaseOptions(microsecond, None, 6000 * microsecond)

    times, voltages, overflow_warnings = device.capture_block(timebase_options, channel_configs)

    for channel, data in voltages.items():
        label = "Channel %s" % channel
        if channel in overflow_warnings:
            label += " (over range)"
        plt.plot(times, data, label=label)

    plt.xlabel('Time / s')
    plt.ylabel('Amplitude / V')
    plt.legend()
    plt.show()



================================================
FILE: picohrdlExamples/picohrdlSingleModeExample.py
================================================
#
# Copyright (C) 2019 Pico Technology Ltd. See LICENSE file for terms.
#
# PICOLOG HIGH RESOLUTION DATA LOGGER SINGLE MODE EXAMPLE
#
# This example demonstrates how to capture a single value from an ADC-20 or ADC-24 Precision Data Logger.


import ctypes
import numpy as np
from picosdk.picohrdl import picohrdl as hrdl
from picosdk.functions import assert_pico2000_ok

# Create chandle and status ready for use
chandle = ctypes.c_int16()
status = {}

# Open unit
status["openUnit"] = hrdl.HRDLOpenUnit()
assert_pico2000_ok(status["openUnit"])
chandle=status["openUnit"]

# Set mains noise rejection
# Reject 50 Hz mains noise
status["mainsRejection"] = hrdl.HRDLSetMains(chandle, 0)
assert_pico2000_ok(status["mainsRejection"])

# Set single reading
range = hrdl.HRDL_VOLTAGERANGE["HRDL_2500_MV"]
conversionTime = hrdl.HRDL_CONVERSIONTIME["HRDL_100MS"]
overflow = ctypes.c_int16(0)
value = ctypes.c_int32()
status["getSingleValue"] = hrdl.HRDLGetSingleValue(chandle, 5, range, conversionTime, 1, ctypes.byref(overflow), ctypes.byref(value))
assert_pico2000_ok(status["getSingleValue"])

# Display value
print(value.value)

# Close unit
status["closeUnit"] = hrdl.HRDLCloseUnit(chandle)
assert_pico2000_ok(status["closeUnit"])

# Print status
print(status)

================================================
FILE: picohrdlExamples/picohrdlStreamingModeExample.py
================================================
#
# Copyright (C) 2025 Pico Technology Ltd. See LICENSE file for terms.
#
# PICOLOG HIGH RESOLUTION DATA LOGGER STREAMING MODE EXAMPLE
#
# This example demonstrates how to capture data streaming from an ADC-20 or ADC-24 Precision Data Logger.

import ctypes
import numpy as np
from picosdk.picohrdl import picohrdl as hrdl
from picosdk.functions import assert_pico2000_ok
import matplotlib.pyplot as plt
import time

# Create chandle and status ready for use
chandle = ctypes.c_int16(16384)
status = {}
maxSamples = 200 #1_000

status["closeUnit"] = hrdl.HRDLCloseUnit(chandle)

# Open unit
status["openUnit"] = hrdl.HRDLOpenUnit()
assert_pico2000_ok(status["openUnit"])
chandle = status["openUnit"]

# Set mains noise rejection
# Reject 50 Hz mains noise
status["mainsRejection"] = hrdl.HRDLSetMains(chandle, 0)
assert_pico2000_ok(status["mainsRejection"])

# Setup Channel(s)
range = ctypes.c_int16(0)
range = hrdl.HRDL_VOLTAGERANGE["HRDL_2500_MV"]
overflow = ctypes.c_int16(0)
value = ctypes.c_int32()

channel = ctypes.c_int16(1) # (Ch number) ADC-20: Ch1 to Ch8 , ADC-24: Ch1 to Ch16
enabled = ctypes.c_int16(1)
singleEnded = ctypes.c_int16(1) # 0: differential, Not 0: for single ended

status["SetAnalogInChannel"] = hrdl.HRDLSetAnalogInChannel(chandle, channel, enabled, range, singleEnded)
assert_pico2000_ok(status["SetAnalogInChannel"])

# Streaming
# sampleInterval_ms = conversionTime x NumberOfChannels + 20ms
# 20ms = 1/3 of the fastest sample time for one channel
sampleInterval_ms = ctypes.c_int32(100 * 1 + 20)
conversionTime = hrdl.HRDL_CONVERSIONTIME["HRDL_100MS"]
status["SetInterval"] = hrdl.HRDLSetInterval(chandle, sampleInterval_ms, conversionTime)
assert_pico2000_ok(status["SetInterval"])

nValues = ctypes.c_int32(20)
method = ctypes.c_int16(2) # BM_STREAM (2)
status["Run"] = hrdl.HRDLRun(chandle, nValues, method)
assert_pico2000_ok(status["Run"])

TotalValues = 0
# Buffers
TempBuffer = (ctypes.c_int32 * 100)()
BufValues = []

myready = ctypes.c_int16(0)
check = ctypes.c_int16(0)
# Check for data collection
while TotalValues < maxSamples:
    while myready.value == check.value:
        myready.value = hrdl.HRDLReady(chandle)
        time.sleep(0.02) # 20ms = 1/3 of the fastest sample time for one channel
        # print("ready = ", myready) # DEBUG
    noOfValues = ctypes.c_int32(20) # Ask for 20 samples
    noOfValues = hrdl.HRDLGetValues(chandle, ctypes.byref(TempBuffer), ctypes.byref(overflow), noOfValues)  
    TotalValues = TotalValues + int(noOfValues)
    print("TotalValues = ",TotalValues ,", noOfValues = ", int(noOfValues) ) # DEBUG
    #sleep (sampleInterval_ms - 20ms /1000)
    time.sleep( ((100 * 1 + 20) - 20) /1000)

    #for i in range(noOfValues):
        ####TempBuffer[i] =  adc2mV(TempBuffer[i], channelRange, maxADC)
        #BufValues.append(float(TempBuffer[i]))
    #if(noOfValues != 0):
    #    BufValues.append(float(TempBuffer[0]))

    # Convert to mV and Append values App Buffer
    loop = noOfValues
    while (loop != 0):
        loop = loop -1
        # TempBuffer[loop] =  adc2mVpl1000(TempBuffer[loop], 2500, 8388607) # adc2mVpl1000(value, Max range in mV, Max ADC count)
        #TempBuffer[loop] = (TempBuffer[loop] * 2500) / 8388607
        BufValues.append(float((TempBuffer[loop] * 2500) / 8388607))

# Stop data collection
hrdl.HRDLStop(chandle)

# Create time data
timeMs = np.linspace(0, (len(BufValues) -1) * 0.1, len(BufValues))

# plot data
plt.plot(timeMs, BufValues[:])
plt.xlabel('Time (s)')
plt.ylabel('Voltage (mV)')
plt.show()

# Close unit
status["closeUnit"] = hrdl.HRDLCloseUnit(chandle)
assert_pico2000_ok(status["closeUnit"])

# Print status
print(status)

================================================
FILE: picosdk/PicoConnectProbes.py
================================================
#
# Copyright (C) 2024 Pico Technology Ltd. See LICENSE file for terms.
#
"""
This is a Python module defining the enumerations from the PicoConnectProbes.h C header
file for use with various PicoScope oscilloscopes driver API functions.
"""

from ctypes import *
from picosdk.constants import make_enum
from picosdk.library import Library

class PicoConnectProbeslib(Library):
    def __init__(self):
        super(PicoConnectProbeslib, self).__init__("picoConnectProbes")


picoConnectProbes  = PicoConnectProbeslib()

def _define_pico_probe_range_info():
    PICO_PROBE_NONE_NV = 0
    PICO_X1_PROBE_NV = 1
    PICO_X10_PROBE_NV = 10
    
    return {k.upper(): v for k, v in locals().items() if k.startswith("PICO")}
    
picoConnectProbes.PICO_PROBE_RANGE_INFO = _define_pico_probe_range_info

================================================
FILE: picosdk/PicoDeviceEnums.py
================================================
#
# Copyright (C) 2020 Pico Technology Ltd. See LICENSE file for terms.
#
"""
This is a Python module defining the enumerations from the PicoDeviceEnums.h C header
file for use with PicoScope 6000 A Series oscilloscopes using the ps6000a driver API
functions.
"""

from ctypes import *
from picosdk.constants import make_enum
from picosdk.library import Library

class PicoEnumlib(Library):
    def __init__(self):
        super(PicoEnumlib, self).__init__("ps6000a")


picoEnum  = PicoEnumlib()

def _define_ratio_mode():
    PICO_RATIO_MODE_AGGREGATE = 1
    PICO_RATIO_MODE_DECIMATE = 2
    PICO_RATIO_MODE_AVERAGE = 4
    PICO_RATIO_MODE_DISTRIBUTION = 8
    PICO_RATIO_MODE_SUM = 16
    PICO_RATIO_MODE_TRIGGER_DATA_FOR_TIME_CALCUATION = 0x10000000
    PICO_RATIO_MODE_SEGMENT_HEADER = 0x20000000
    PICO_RATIO_MODE_TRIGGER = 0x40000000
    PICO_RATIO_MODE_RAW = 0x80000000
    
    return {k.upper(): v for k, v in locals().items() if k.startswith("PICO")}
    
picoEnum.PICO_RATIO_MODE = _define_ratio_mode()

def _define_channel():
    PICO_CHANNEL_A = 0
    PICO_CHANNEL_B = 1
    PICO_CHANNEL_C = 2
    PICO_CHANNEL_D = 3
    PICO_CHANNEL_E = 4
    PICO_CHANNEL_F = 5
    PICO_CHANNEL_G = 6
    PICO_CHANNEL_H = 7
    PICO_PORT0 = 128
    PICO_PORT1 = 129
    PICO_PORT2 = 130
    PICO_PORT3 = 131
    PICO_EXTERNAL = 1000
    PICO_TRIGGER_AUX = 1001
    PICO_PULSE_WIDTH_SOURCE = 0x10000000
    PICO_DIGITAL_SOURCE = 0x10000001
    
    return {k.upper(): v for k, v in locals().items() if k.startswith("PICO")}
    
picoEnum.PICO_CHANNEL = _define_channel()

def _define_channel_flags():
    PICO_CHANNEL_A_FLAGS = 1
    PICO_CHANNEL_B_FLAGS = 2
    PICO_CHANNEL_C_FLAGS = 4
    PICO_CHANNEL_D_FLAGS = 8
    PICO_CHANNEL_E_FLAGS = 16
    PICO_CHANNEL_F_FLAGS = 32
    PICO_CHANNEL_G_FLAGS = 64
    PICO_CHANNEL_H_FLAGS = 128
    PICO_PORT0_FLAGS = 65536
    PICO_PORT1_FLAGS = 131072
    PICO_PORT2_FLAGS = 262144
    PICO_PORT3_FLAGS = 524288
    
    return {k.upper(): v for k, v in locals().items() if k.startswith("PICO")}

picoEnum.PICO_CHANNEL_FLAGS = _define_channel_flags()

picoEnum.PICO_PORT_DIGITAL_CHANNEL = make_enum([
    "PICO_PORT_DIGITAL_CHANNEL0",
    "PICO_PORT_DIGITAL_CHANNEL1",
    "PICO_PORT_DIGITAL_CHANNEL2",
    "PICO_PORT_DIGITAL_CHANNEL3",
    "PICO_PORT_DIGITAL_CHANNEL4",
    "PICO_PORT_DIGITAL_CHANNEL5",
    "PICO_PORT_DIGITAL_CHANNEL6",
    "PICO_PORT_DIGITAL_CHANNEL7",
    ])
    
picoEnum.PICO_DATA_TYPE = make_enum([
    "PICO_INT8_T",
    "PICO_INT16_T",
    "PICO_INT32_T",
    "PICO_UINT32_T",
    "PICO_INT64_T",
    ])

def _define_coupling():
    PICO_AC = 0
    PICO_DC = 1
    PICO_DC_50OHM = 50
    
    return {k.upper(): v for k, v in locals().items() if k.startswith("PICO")}

picoEnum.PICO_COUPLING = _define_coupling()

# PicoBandwitdthLimiterFlags
# needs implementing still

def _define_bandwidth_limiter():
    PICO_BW_FULL = 0
    PICO_BW_100KHZ = 100000
    PICO_BW_20KHZ = 20000
    PICO_BW_1MHZ = 1000000
    PICO_BW_20MHZ = 20000000
    PICO_BW_25MHZ = 25000000
    PICO_BW_50MHZ = 50000000
    PICO_BW_200HMZ = 200000000
    PICO_BW_250MHZ = 250000000
    PICO_BW_500MHZ = 500000000
    
    return {k.upper(): v for k, v in locals().items() if k.startswith("PICO")}
    
picoEnum.PICO_BANDWIDTH_LIMITER = _define_bandwidth_limiter()

picoEnum.PICO_PULSE_WIDTH_TYPE = make_enum([
    "PICO_PW_TYPE_NONE",
    "PICO_PW_TYPE_LESS_THAN",
    "PICO_PW_TYPE_GREATER_THAN",
    "PICO_PW_IN_RANGE",
    "PICO_PW_TYPE_OUT_OF_RANGE"
    ])
    
picoEnum.PICO_SWEEP_TYPE = make_enum([
    "PICO_UP",
    "PICO_DOWN",
    "PICO_UPDOWN",
    "PICO_DOWNUP"
    ])
    
def _define_wave_type():
    PICO_SINE = 0x00000011
    PICO_SQUARE = 0x00000012
    PICO_TRIANGLE = 0x00000013
    PICO_RAMP_UP = 0x00000014
    PICO_RAMP_DOWN = 0x00000015
    PICO_SINC = 0x00000016
    PICO_GAUSSIAN = 0x00000017
    PICO_HALF_SINE = 0x00000018
    PICO_DC_VOLTAGE = 0x00000400
    PICO_PWM = 0x00001000
    PICO_WHITENOISE = 0x00002001
    PICO_PRBS = 0x00002002
    PICO_ARBITRARY = 0x10000000
    
    return {k.upper(): v for k, v in locals().items() if k.startswith("PICO")}

picoEnum.PICO_WAVE_TYPE = _define_wave_type()

picoEnum.PICO_SIGGEN_TRIG_TYPE = make_enum([
    "PICO_SIGGEN_RISING",
    "PICO_SIGGEN_FALLING",
    "PICO_SIGGEN_GATE_HIGH",
    "PICO_SIGGEN_GATE_LOW"
    ])
    
picoEnum.PICO_SIGGEN_TRIG_SOURCE = make_enum([
    "PICO_SIGGEN_NONE",
    "PICO_SIGGEN_SCOPE_TRIG",
    "PICO_SGGEN_AUX_IN",
    "PICO_SIGGEN_EXT_IN",
    "PICO_SIGGEN_SOFT_TRIG",
    "PICO_SIGGEN_TRIGGER_RAW"
    ])
    
picoEnum.PICO_SIGGEN_FILTER_STATE = make_enum([
    "PICO_SIGGEN_FILTER_AUTO",
    "PICO_SIGGEN_FILTER_OFF",
    "PICO_SIGGEN_FILTER_ON"
    ])
    
picoEnum.PICO_SIGGEN_PARAMETER = make_enum([
    "PICO_SIGGEN_PARAM_OUTPUT_VOLTS",
    "PICO_SIGGEN_PARAM_SAMPLE",
    "PICO_SIGGEN_BUFFER_LENGTH"
    ])
    
picoEnum.PICO_TIME_UNITS = make_enum([
    "PICO_FS",
    "PICO_PS",
    "PICO_NS",
    "PICO_US",
    "PICO_MS",
    "PICO_S"
    ])

def _define_threshold_direction():
    PICO_ABOVE = PICO_INSIDE = 0
    PICO_BELOW = PICO_OUTSIDE = 1
    PICO_RISING = PICO_ENTER = PICO_NONE = 2 
    PICO_FALLING = PICO_EXIT = 3
    PICO_RISING_OR_FALLING = PICO_ENTER_OR_EXIT = 4
    PICO_ABOVE_LOWER = 5
    PICO_BELOW_LOWER = 6
    PICO_RISING_LOWER = 7
    PICO_FALLING_LOWER = 8
    PICO_POSITIVE_RUNT = 9
    PICO_NEGATIVE_RUNT = 10
    PICO_LOGIC_LOWER = 1000
    PICO_LOGIC_UPPER = 1001
    
    return {k.upper(): v for k, v in locals().items() if k.startswith("PICO")}
    
picoEnum.PICO_THRESHOLD_DIRECTION = _define_threshold_direction()

picoEnum.PICO_THRESHOLD_MODE = make_enum([
    "PICO_LEVEL",
    "PICO_WINDOW"
    ])
    
picoEnum.PICO_ETS_MODE = make_enum([
    "PICO_ETS_OFF",
    "PICO_ETS_FAST",
    "PICO_ETS_SLOW"
    ])
    
picoEnum.PICO_INDEX_MODE = make_enum([
    "PICO_SINGLE",
    "PICO_DUAL",
    "PICO_QUAD"
    ])
    
def _define_action():
    PICO_CLEAR_ALL = 0x00000001
    PICO_ADD = 0x00000002
    PICO_CLEAR_THIS_DATA_BUFFER = 0x00001000
    PICO_CLEAR_WAVEFORM_DATA_BUFFERS = 0x00002000
    PICO_CLEAR_WAVEFORM_READ_DATA_BUFFERS = 0x00004000
    
    return {k.upper(): v for k, v in locals().items() if k.startswith("PICO")}
    
picoEnum.PICO_ACTION = _define_action()

picoEnum.PICO_TRIGGER_STATE = make_enum([
    "PICO_CONDITION_DONT_CARE",
    "PICO_CONDITION_TRUE",
    "PICO_CONDITION_FALSE"
    ])
    
def _define_resolution():
    PICO_DR_8BIT = 0
    PICO_DR_12BIT = 1
    PICO_DR_14BIT = 2
    PICO_DR_15BIT = 3
    PICO_DR_16BIT = 4
    PICO_DR_10BIT = 10
    PICO_DR_10BIT_TURBO = 0x1A
    
    return {k.upper(): v for k, v in locals().items() if k.startswith("PICO")}
    
picoEnum.PICO_DEVICE_RESOLUTION = _define_resolution()

picoEnum.PICO_READ_SELECTION = make_enum([
    "PICO_READSELECTION_NONE",
    "PICO_TRIGGER_READ",
    "PICO_DATA_READ1",
    "PICO_DATA_READ2",
    "PICO_DATA_READ3"
    ])

picoEnum.PICO_TRIM_ACTION = make_enum([
    "PICO_OLDEST",
    "PICO_RECENT"
    ])

picoEnum.PICO_DIGITAL_PORT_HYSTERESIS = make_enum([
    "PICO_VERY_HIGH_400MV",
    "PICO_HIGH_200MV",
    "PICO_NORMAL_100MV",
    "PICO_LOW_50MV"
    ])
    
picoEnum.PICO_DIGITAL_DIRECTION = make_enum([
    "PICO_DIGITAL_DONT_CARE",
    "PICO_DIGITAL_DIRECTION_LOW",
    "PICO_DIGITAL_DIRECTION_HIGH",
    "PICO_DIGITAL_DIRECTION_RISING",
    "PICO_DIGITAL_DIRECTION_FALLING",
    "PICO_DIGITAL_DIRECTION_RISING_OR_FALLING",
    "PICO_DIGITAL_DIRECTION_MAX_DIRECTION"
    ])
    
def _define_conditions_info():
    PICO_CLEAR_CONDITIONS = 0x00000001
    PICO_ADD_CONDITIONS = 0x00000002
    
    return {k.upper(): v for k, v in locals().items() if k.startswith("PICO")}
    
picoEnum.PICO_CONDITIONS_INFO = _define_conditions_info()

picoEnum.PICO_CLOCK_REFERENCE = make_enum([
    "PICO_INTERNAL_REF",
    "PICO_EXTERNAL_REF"
    ])
    
picoEnum.PICO_TRIGGER_WITHIN_PRE_TRIGGER = make_enum([
    "PICO_DISABLE",
    "PICO_ARM"
    ])
    
picoEnum.PICO_TEMPERATURE_REFERENCE = make_enum([
    "PICO_TEMPERATURE_UNINITIALISED",
    "PICO_TEMPERATURE_NORMAL",
    "PICO_TEMPERATURE_WARNING",
    "PICO_TEMPERATURE_CRITICAL",
    "PICO_TEMPERATURE_REFERENCE"
    ])
    
def _define_digital_port():
    PICO_DIGITAL_PORT_NONE = 0
    PICO_DIGITAL_PORT_MSO_POD = 1000
    PICO_DIGITAL_PORT_UNKNOWN_DEVICE = -2
    
    return {k.upper(): v for k, v in locals().items() if k.startswith("PICO")}
    
picoEnum.PICO_DIGITAL_PORT = _define_digital_port

picoEnum.PICO_EXTERNAL_FREQUENCY = make_enum([
    "PICO_FREQUENCY_OFF",
    "PICO_FREQUENCY_5MHZ",
    "PICO_FREQUENCY_10MHZ",
    "PICO_FREQUENCY_20MHZ",
    "PICO_FREQUENCY_25MHZ"
    ])
    
def _define_power_delivery_device_type():
    PICO_USB_POWER_DELIEVRY_DEVICE_TYPE_NOTHING = 0
    PICO_USB_POWER_DELIEVRY_DEVICE_TYPE_SOURCE = 2
    PICO_USB_POWER_DELIEVRY_DEVICE_TYPE_DEBUG = 3
    
    return {k.upper(): v for k, v in locals().items() if k.startswith("PICO")}
    
picoEnum.PICO_USB_POWER_DELIEVRY_DEVICE_TYPE = _define_power_delivery_device_type

picoEnum.PICO_AUXIO_MODE = make_enum([
    "PICO_AUXIO_INPUT",
    "PICO_AUXIO_HIGH_OUT",
    "PICO_AUXIO_LOW_OUT",
    "PICO_AUXIO_TRIGGER_OUT"
    ])

================================================
FILE: picosdk/PicoDeviceStructs.py
================================================
#
# Copyright (C) 2020 Pico Technology Ltd. See LICENSE file for terms.
#
"""
This is a Python module defining the structures from the PicoDeviceStructs.h C header
file for use with PicoScope 6000 A Series oscilloscopes using the ps6000a driver API
functions.
"""

from ctypes import *
from picosdk.library import Library

class PicoStructlib(Library):
    def __init__(self):
        super(PicoStructlib, self).__init__("ps6000a")


picoStruct = PicoStructlib()

class PICO_TRIGGER_INFO(Structure):
    _pack_ = 1
    _fields_ = [("status", c_uint32),
                ("segmentIndex", c_uint64),
                ("triggerIndex", c_uint64),
                ("triggerTime", c_double),
                ("timeUnits", c_uint32),
                ("missedTriggers", c_uint64),
                ("timeStampCounter", c_uint64)]
                
picoStruct.PICO_TRIGGER_INFO = PICO_TRIGGER_INFO

class PICO_TRIGGER_CHANNEL_PROPERTIES(Structure):
    _pack_ = 1
    _fields_ = [("thresholdUpper", c_int16),
                ("thresholdUpperHysteresis", c_uint16),
                ("thresholdLower", c_int16),
                ("thresholdLowerHysteresis", c_uint16),
                ("channel", c_uint32)]
                
picoStruct.PICO_TRIGGER_CHANNEL_PROPERTIES = PICO_TRIGGER_CHANNEL_PROPERTIES

class PICO_CONDITION(Structure):
    _pack_ = 1
    _fields_ = [("source", c_uint32),
                ("condition", c_uint32)]
                
picoStruct.PICO_CONDITION = PICO_CONDITION

class PICO_DIRECTION(Structure):
    _pack_ = 1
    _fields_ = [("channel", c_uint32),
                ("direction", c_uint32),
                ("thresholdMode", c_uint32)]
                
picoStruct.PICO_DIRECTION = PICO_DIRECTION

class PICO_USER_PROBE_INTERACTIONS(Structure):
    _pack_ = 1
    _fields_ = [("connected", c_uint16),
                ("channel", c_uint32),
                ("enabled", c_uint16),
                ("probeName", c_uint32),
                ("requiresPower", c_uint8),
                ("isPowered", c_uint8),
                ("status", c_uint32),
                ("probeOff", c_uint32),
                ("rangeFirst", c_uint32),
                ("rangeLast", c_uint32),
                ("rangeCurrent", c_uint32),
                ("couplingFirst", c_uint32),
                ("couplingLast", c_uint32),
                ("couplingCurrent", c_uint32),
                ("filterFlags", c_uint32),
                ("filterCurrent", c_uint32)]
                
picoStruct.PICO_USER_PROBE_INTERACTIONS = PICO_USER_PROBE_INTERACTIONS

class PICO_DATA_BUFFERS(Structure):
    _pack_ = 1
    _fields_ = [("channel", c_uint32),
                ("waveform", c_uint64),
                ("downSampleRatioMode", c_uint32),
                ("read", c_uint32),
                ("bufferMax", c_void_p),
                ("bufferMin", c_void_p),
                ("dataType", c_uint32),
                ("nDistributionPoints", c_uint32)]
                
picoStruct.PICO_DATA_BUFFERS = PICO_DATA_BUFFERS

class PICO_STREAMING_DATA_INFO(Structure):
    _pack_ = 1
    _fields_ = [("channel", c_uint32),
                ("mode", c_uint32),
                ("type", c_uint32),
                ("noOfSamples", c_int32),
                ("bufferIndex", c_uint64),
                ("startIndex", c_int32),
                ("overflow", c_int16)]
                
picoStruct.PICO_STREAMING_DATA_INFO = PICO_STREAMING_DATA_INFO

class PICO_STREAMING_DATA_TRIGGER_INFO(Structure):
    _pack_ = 1
    _fields_ = [("triggerAt", c_uint64),
                ("triggered", c_int16),
                ("autoStop", c_int16)]
                
picoStruct.PICO_STREAMING_DATA_TRIGGER_INFO = PICO_STREAMING_DATA_TRIGGER_INFO

class PICO_SCALING_FACTORS(Structure):
    _pack_ = 1
    _fields_ = [("channel", c_uint32),
                ("range", c_uint32),
                ("offset", c_int16),
                ("scalingFactor", c_double)]
                
picoStruct.PICO_SCALING_FACTORS = PICO_SCALING_FACTORS

class PICO_SCALING_FACTORS_FOR_RANGE_TYPES(Structure):
    _pack_ = 1
    _fields_ = [("channel", c_uint32),
                ("rangeMin", c_int64),
                ("rangeMax", c_int64),
                ("rangeType", c_uint32),
                ("offset", c_int16),
                ("scalingFactor", c_double)]
                
picoStruct.PICO_SCALING_FACTORS_FOR_RANGE_TYPES = PICO_SCALING_FACTORS_FOR_RANGE_TYPES

class PROBE_APP(Structure):
    _pack_ = 1
    _fields_ = [("id", c_int32),
                ("appMajorVersion", c_int32),
                ("appMinorVersion", c_int32)]
               
picoStruct.PROBE_APP = PROBE_APP

class DIGITAL_CHANNEL_DIRECTIONS(Structure):
    _pack_ = 1
    _fields_ = [("channel", c_uint32),
                ("direction", c_uint32)]
                
picoStruct.DIGITAL_CHANNEL_DIRECTIONS = DIGITAL_CHANNEL_DIRECTIONS

class PICO_DIGITAL_PORT_INTERACTIONS(Structure):
    _pack_ = 1
    _fields_ = [("connected", c_uint16),
                ("channel", c_uint32),
                ("digitalPortName", c_uint32),
                ("status", c_uint32),
                ("serial", c_int8),
                ("calibrationDate", c_int8)]
                
picoStruct.PICO_DIGITAL_PORT_INTERACTIONS = PICO_DIGITAL_PORT_INTERACTIONS

class PICO_CHANNEL_OVERVOLTAGE_TRIPPED(Structure):
    _pack_ = 1
    _fields_ = [("channel", c_uint32),
                ("tripped", c_uint8)]
                
picoStruct.PICO_CHANNEL_OVERVOLTAGE_TRIPPED = PICO_CHANNEL_OVERVOLTAGE_TRIPPED

class PICO_USB_POWER_DELIVERY(Structure):
    _pack_ = 1
    _fields_ = [("valid", c_uint8),
                ("busVoltagemV", c_uint32),
                ("rpCurrentLimitmA", c_uint32),
                ("partnerConnected", c_uint8),
                ("ccPolarity", c_uint8),
                ("attachedDevice", c_uint32),
                ("contractExists", c_uint8),
                ("currentPdo", c_uint32),
                ("currentRdo", c_uint32)]
                
picoStruct.PICO_USB_POWER_DELIVERY = PICO_USB_POWER_DELIVERY

class PICO_USB_POWER_DETAILS(Structure):
    _pack_ = 1
    _fields_ = [("dataPort", c_uint32),
                ("powerPort", c_uint32)]
                
picoStruct.PICO_USB_POWER_DETAILS = PICO_USB_POWER_DETAILS

================================================
FILE: picosdk/__init__.py
================================================
#
# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.
#


================================================
FILE: picosdk/constants.py
================================================
#
# Copyright (C) 2014-2018 Pico Technology Ltd. See LICENSE file for terms.
#
"""
Defines python-visible versions of preprocessor-macros from Pico SDK C header files.
All constants in this file are exposed directly on the Library class specific to each driver. That
(rather than importing this file directly) is the supported way of accessing them, since some
older drivers have different names/values for some of the macros.
"""
from picosdk.errors import UnknownConstantError


# convenience functions provided in the old python SDK:
def pico_tag(number):
    """Get the macro name for a given PICO_STATUS value."""
    try:
        return PICO_STATUS_LOOKUP[number]
    except KeyError:
        raise UnknownConstantError("%s is not a known PICO_STATUS value." % number)


def pico_num(tag):
    """Resolve the numerical constant associated with a PICO_STATUS macro."""
    try:
        return PICO_STATUS[tag]
    except KeyError:
        raise UnknownConstantError("%s is not a known PICO_STATUS macro." % tag)


def make_enum(members):
    """All C enums with no specific values follow the pattern 0, 1, 2... in the order they are in source."""
    enum = {}
    for i, member in enumerate(members):
        keys = [member]
        if isinstance(member, tuple):
            # this member has multiple names!
            keys = member
        for key in keys:
            enum[key] = i
    return enum


PICO_STATUS = {
    "PICO_OK": 0x00000000,
    "PICO_MAX_UNITS_OPENED": 0x00000001,
    "PICO_MEMORY_FAIL": 0x00000002,
    "PICO_NOT_FOUND": 0x00000003,
    "PICO_FW_FAIL": 0x00000004,
    "PICO_OPEN_OPERATION_IN_PROGRESS": 0x00000005,
    "PICO_OPERATION_FAILED": 0x00000006,
    "PICO_NOT_RESPONDING": 0x00000007,
    "PICO_CONFIG_FAIL": 0x00000008,
    "PICO_KERNEL_DRIVER_TOO_OLD": 0x00000009,
    "PICO_EEPROM_CORRUPT": 0x0000000A,
    "PICO_OS_NOT_SUPPORTED": 0x0000000B,
    "PICO_INVALID_HANDLE": 0x0000000C,
    "PICO_INVALID_PARAMETER": 0x0000000D,
    "PICO_INVALID_TIMEBASE": 0x0000000E,
    "PICO_INVALID_VOLTAGE_RANGE": 0x0000000F,
    "PICO_INVALID_CHANNEL": 0x00000010,
    "PICO_INVALID_TRIGGER_CHANNEL": 0x00000011,
    "PICO_INVALID_CONDITION_CHANNEL": 0x00000012,
    "PICO_NO_SIGNAL_GENERATOR": 0x00000013,
    "PICO_STREAMING_FAILED": 0x00000014,
    "PICO_BLOCK_MODE_FAILED": 0x00000015,
    "PICO_NULL_PARAMETER": 0x00000016,
    "PICO_ETS_MODE_SET": 0x00000017,
    "PICO_DATA_NOT_AVAILABLE": 0x00000018,
    "PICO_STRING_BUFFER_TO_SMALL": 0x00000019,
    "PICO_ETS_NOT_SUPPORTED": 0x0000001A,
    "PICO_AUTO_TRIGGER_TIME_TO_SHORT": 0x0000001B,
    "PICO_BUFFER_STALL": 0x0000001C,
    "PICO_TOO_MANY_SAMPLES": 0x0000001D,
    "PICO_TOO_MANY_SEGMENTS": 0x0000001E,
    "PICO_PULSE_WIDTH_QUALIFIER": 0x0000001F,
    "PICO_DELAY": 0x00000020,
    "PICO_SOURCE_DETAILS": 0x00000021,
    "PICO_CONDITIONS": 0x00000022,
    "PICO_USER_CALLBACK": 0x00000023,
    "PICO_DEVICE_SAMPLING": 0x00000024,
    "PICO_NO_SAMPLES_AVAILABLE": 0x00000025,
    "PICO_SEGMENT_OUT_OF_RANGE": 0x00000026,
    "PICO_BUSY": 0x00000027,
    "PICO_STARTINDEX_INVALID": 0x00000028,
    "PICO_INVALID_INFO": 0x00000029,
    "PICO_INFO_UNAVAILABLE": 0x0000002A,
    "PICO_INVALID_SAMPLE_INTERVAL": 0x0000002B,
    "PICO_TRIGGER_ERROR": 0x0000002C,
    "PICO_MEMORY": 0x0000002D,
    "PICO_SIG_GEN_PARAM": 0x0000002E,
    "PICO_SHOTS_SWEEPS_WARNING": 0x0000002F,
    "PICO_SIGGEN_TRIGGER_SOURCE": 0x00000030,
    "PICO_AUX_OUTPUT_CONFLICT": 0x00000031,
    "PICO_AUX_OUTPUT_ETS_CONFLICT": 0x00000032,
    "PICO_WARNING_EXT_THRESHOLD_CONFLICT": 0x00000033,
    "PICO_WARNING_AUX_OUTPUT_CONFLICT": 0x00000034,
    "PICO_SIGGEN_OUTPUT_OVER_VOLTAGE": 0x00000035,
    "PICO_DELAY_NULL": 0x00000036,
    "PICO_INVALID_BUFFER": 0x00000037,
    "PICO_SIGGEN_OFFSET_VOLTAGE": 0x00000038,
    "PICO_SIGGEN_PK_TO_PK": 0x00000039,
    "PICO_CANCELLED": 0x0000003A,
    "PICO_SEGMENT_NOT_USED": 0x0000003B,
    "PICO_INVALID_CALL": 0x0000003C,
    "PICO_GET_VALUES_INTERRUPTED": 0x0000003D,
    "PICO_NOT_USED": 0x0000003F,
    "PICO_INVALID_SAMPLERATIO": 0x00000040,
    "PICO_INVALID_STATE": 0x00000041,
    "PICO_NOT_ENOUGH_SEGMENTS": 0x00000042,
    "PICO_DRIVER_FUNCTION": 0x00000043,
    "PICO_RESERVED": 0x00000044,
    "PICO_INVALID_COUPLING": 0x00000045,
    "PICO_BUFFERS_NOT_SET": 0x00000046,
    "PICO_RATIO_MODE_NOT_SUPPORTED": 0x00000047,
    "PICO_RAPID_NOT_SUPPORT_AGGREGATION": 0x00000048,
    "PICO_INVALID_TRIGGER_PROPERTY": 0x00000049,
    "PICO_INTERFACE_NOT_CONNECTED": 0x0000004A,
    "PICO_RESISTANCE_AND_PROBE_NOT_ALLOWED": 0x0000004B,
    "PICO_POWER_FAILED": 0x0000004C,
    "PICO_SIGGEN_WAVEFORM_SETUP_FAILED": 0x0000004D,
    "PICO_FPGA_FAIL": 0x0000004E,
    "PICO_POWER_MANAGER": 0x0000004F,
    "PICO_INVALID_ANALOGUE_OFFSET": 0x00000050,
    "PICO_PLL_LOCK_FAILED": 0x00000051,
    "PICO_ANALOG_BOARD": 0x00000052,
    "PICO_CONFIG_FAIL_AWG": 0x00000053,
    "PICO_INITIALISE_FPGA": 0x00000054,
    "PICO_EXTERNAL_FREQUENCY_INVALID": 0x00000056,
    "PICO_CLOCK_CHANGE_ERROR": 0x00000057,
    "PICO_TRIGGER_AND_EXTERNAL_CLOCK_CLASH": 0x00000058,
    "PICO_PWQ_AND_EXTERNAL_CLOCK_CLASH": 0x00000059,
    "PICO_UNABLE_TO_OPEN_SCALING_FILE": 0x0000005A,
    "PICO_MEMORY_CLOCK_FREQUENCY": 0x0000005B,
    "PICO_I2C_NOT_RESPONDING": 0x0000005C,
    "PICO_NO_CAPTURES_AVAILABLE": 0x0000005D,
    "PICO_NOT_USED_IN_THIS_CAPTURE_MODE": 0x0000005E,
    "PICO_TOO_MANY_TRIGGER_CHANNELS_IN_USE": 0x0000005F,
    "PICO_INVALID_TRIGGER_DIRECTION": 0x00000060,
    "PICO_INVALID_TRIGGER_STATES": 0x00000061,
    "PICO_GET_DATA_ACTIVE": 0x00000103,
    "PICO_IP_NETWORKED": 0x00000104,
    "PICO_INVALID_IP_ADDRESS": 0x00000105,
    "PICO_IPSOCKET_FAILED": 0x00000106,
    "PICO_IPSOCKET_TIMEDOUT": 0x00000107,
    "PICO_SETTINGS_FAILED": 0x00000108,
    "PICO_NETWORK_FAILED": 0x00000109,
    "PICO_WS2_32_DLL_NOT_LOADED": 0x0000010A,
    "PICO_INVALID_IP_PORT": 0x0000010B,
    "PICO_COUPLING_NOT_SUPPORTED": 0x0000010C,
    "PICO_BANDWIDTH_NOT_SUPPORTED": 0x0000010D,
    "PICO_INVALID_BANDWIDTH": 0x0000010E,
    "PICO_AWG_NOT_SUPPORTED": 0x0000010F,
    "PICO_ETS_NOT_RUNNING": 0x00000110,
    "PICO_SIG_GEN_WHITENOISE_NOT_SUPPORTED": 0x00000111,
    "PICO_SIG_GEN_WAVETYPE_NOT_SUPPORTED": 0x00000112,
    "PICO_INVALID_DIGITAL_PORT": 0x00000113,
    "PICO_INVALID_DIGITAL_CHANNEL": 0x00000114,
    "PICO_INVALID_DIGITAL_TRIGGER_DIRECTION": 0x00000115,
    "PICO_SIG_GEN_PRBS_NOT_SUPPORTED": 0x00000116,
    "PICO_ETS_NOT_AVAILABLE_WITH_LOGIC_CHANNELS": 0x00000117,
    "PICO_WARNING_REPEAT_VALUE": 0x00000118,
    "PICO_POWER_SUPPLY_CONNECTED": 0x00000119,
    "PICO_POWER_SUPPLY_NOT_CONNECTED": 0x0000011A,
    "PICO_POWER_SUPPLY_REQUEST_INVALID": 0x0000011B,
    "PICO_POWER_SUPPLY_UNDERVOLTAGE": 0x0000011C,
    "PICO_CAPTURING_DATA": 0x0000011D,
    "PICO_USB3_0_DEVICE_NON_USB3_0_PORT": 0x0000011E,
    "PICO_NOT_SUPPORTED_BY_THIS_DEVICE": 0x0000011F,
    "PICO_INVALID_DEVICE_RESOLUTION": 0x00000120,
    "PICO_INVALID_NUMBER_CHANNELS_FOR_RESOLUTION": 0x00000121,
    "PICO_CHANNEL_DISABLED_DUE_TO_USB_POWERED": 0x00000122,
    "PICO_SIGGEN_DC_VOLTAGE_NOT_CONFIGURABLE": 0x00000123,
    "PICO_NO_TRIGGER_ENABLED_FOR_TRIGGER_IN_PRE_TRIG": 0x00000124,
    "PICO_TRIGGER_WITHIN_PRE_TRIG_NOT_ARMED": 0x00000125,
    "PICO_TRIGGER_WITHIN_PRE_NOT_ALLOWED_WITH_DELAY": 0x00000126,
    "PICO_TRIGGER_INDEX_UNAVAILABLE": 0x00000127,
    "PICO_AWG_CLOCK_FREQUENCY": 0x00000128,
    "PICO_TOO_MANY_CHANNELS_IN_USE": 0x00000129,
    "PICO_NULL_CONDITIONS": 0x0000012A,
    "PICO_DUPLICATE_CONDITION_SOURCE": 0x0000012B,
    "PICO_INVALID_CONDITION_INFO": 0x0000012C,
    "PICO_SETTINGS_READ_FAILED": 0x0000012D,
    "PICO_SETTINGS_WRITE_FAILED": 0x0000012E,
    "PICO_ARGUMENT_OUT_OF_RANGE": 0x0000012F,
    "PICO_HARDWARE_VERSION_NOT_SUPPORTED": 0x00000130,
    "PICO_DIGITAL_HARDWARE_VERSION_NOT_SUPPORTED": 0x00000131,
    "PICO_ANALOGUE_HARDWARE_VERSION_NOT_SUPPORTED": 0x00000132,
    "PICO_UNABLE_TO_CONVERT_TO_RESISTANCE": 0x00000133,
    "PICO_DUPLICATED_CHANNEL": 0x00000134,
    "PICO_INVALID_RESISTANCE_CONVERSION": 0x00000135,
    "PICO_INVALID_VALUE_IN_MAX_BUFFER": 0x00000136,
    "PICO_INVALID_VALUE_IN_MIN_BUFFER": 0x00000137,
    "PICO_SIGGEN_FREQUENCY_OUT_OF_RANGE": 0x00000138,
    "PICO_EEPROM2_CORRUPT": 0x00000139,
    "PICO_EEPROM2_FAIL": 0x0000013A,
    "PICO_SERIAL_BUFFER_TOO_SMALL": 0x0000013B,
    "PICO_SIGGEN_TRIGGER_AND_EXTERNAL_CLOCK_CLASH": 0x0000013C,
    "PICO_WARNING_SIGGEN_AUXIO_TRIGGER_DISABLED": 0x0000013D,
    "PICO_SIGGEN_GATING_AUXIO_NOT_AVAILABLE": 0x00000013E,
    "PICO_SIGGEN_GATING_AUXIO_ENABLED": 0x00000013F,
    "PICO_RESOURCE_ERROR": 0x00000140,
    "PICO_TEMPERATURE_TYPE_INVALID": 0x00000141,
    "PICO_TEMPERATURE_TYPE_NOT_SUPPORTED": 0x00000142,
    "PICO_TIMEOUT": 0x00000143,
    "PICO_DEVICE_NOT_FUNCTIONING": 0x00000144,
    "PICO_INTERNAL_ERROR": 0x00000145,
    "PICO_MULTIPLE_DEVICES_FOUND": 0x00000146,
    "PICO_WARNING_NUMBER_OF_SEGMENTS_REDUCED": 0x00000147,
    "PICO_CAL_PINS_STATES": 0x00000148,
    "PICO_CAL_PINS_FREQUENCY": 0x00000149,
    "PICO_CAL_PINS_AMPLITUDE": 0x0000014A,
    "PICO_CAL_PINS_WAVETYPE": 0x0000014B,
    "PICO_CAL_PINS_OFFSET": 0x0000014C,
    "PICO_PROBE_FAULT": 0x0000014D,
    "PICO_PROBE_IDENTITY_UNKNOWN": 0x0000014E,
    "PICO_PROBE_POWER_DC_POWER_SUPPLE_REQUIRED": 0x0000014F,
    "PICO_PROBE_NOT_POWERED_THROUGH_DC_POWER_SUPPLY": 0x00000150,
    "PICO_PROBE_CONFIG_FAILURE": 0x00000151,
    "PICO_PROBE_INTERACTION_CALLBACK": 0x00000152,
    "PICO_UNKNOWN_INTELLIGENT_PROBE": 0x00000153,
    "PICO_INTELLIGENT_PROBE_CORRUPT": 0x00000154,
    "PICO_PROBE_COLLECTION_NOT_STARTED": 0x00000155,
    "PICO_PROBE_POWER_CONSUMPTION_EXCEEDED": 0x00000156,
    "PICO_WARNING_PROBE_CHANNEL_OUT_OF_SYNC": 0x00000157,
    "PICO_ENDPOINT_MISSING": 0x00000158,
    "PICO_UNKNOWN_ENDPOINT_REQUEST": 0x00000159,
    "PICO_ADC_TYPE_ERROR": 0x0000015A,
    "PICO_FPGA2_FAILED": 0x0000015B,
    "PICO_FPGA2_DEVICE_STATUS": 0x0000015C,
    "PICO_ENABLED_PROGRAM_FPGA2_FAILED": 0x0000015D,
    "PICO_NO_CANNELS_OR_PORTS_ENABLED": 0x0000015E,
    "PICO_INVALID_RATIO_MODE": 0x0000015F,
    "PICO_READS_NOT_SUPPORTED_IN_CURRENT_CAPTURE_MODE": 0x00000160,
    "PICO_TRIGGER_READ_SELECTION_CHECK_FAILED": 0x00000161,
    "PICO_DATA_READ1_SELECTION_CHECK_FAILED": 0x00000162,
    "PICO_DATA_READ2_SELECTION_CHECK_FAILED": 0x00000164,
    "PICO_DATA_READ3_SELECTION_CHECK_FAILED": 0x00000168,
    "PICO_READ_SELECTION_OUT_OF_RANGE": 0x00000170,
    "PICO_MULTIPLE_RATIO_MODES": 0x00000171,
    "PICO_NO_SAMPLES_READ": 0x00000172,
    "PICO_RATIO_MODE_NOT_REQUESTED": 0x00000173,
    "PICO_NO_USER_READ_REQUESTS": 0x00000174,
    "PICO_ZERO_SAMPLES_INVALID": 0x00000175,
    "PICO_ANALOGUE_HARDWARE_MISSING": 0x00000176,
    "PICO_ANALOGUE_HARDWARE_PINS": 0x00000177,
    "PICO_ANALOGUE_SMPS_FAULT": 0x00000178,
    "PICO_DIGITAL_ANALOGUE_HARDWARE_CONFLICT": 0x00000179,
    "PICO_RATIO_MODE_BUFFER_NOT_SET": 0x0000017A,
    "PICO_RESOLUTION_NOT_SUPPORTED_BY_VARIENT": 0x0000017B,
    "PICO_THRESHOLD_OUT_OF_RANGE": 0x0000017C,
    "PICO_INVALID_SIMPLE_TRIGGER_DIRECTION": 0x0000017D,
    "PICO_AUX_NOT_SUPPORTED": 0x0000017E,
    "PICO_NULL_DIRECTIONS": 0x0000017F,
    "PICO_NULL_CHANNEL_PROPERTIES": 0x00000180,
    "PICO_TRIGGER_CHANNEL_NOT_ENABLED": 0x00000181,
    "PICO_CONDITION_HAS_NO_TRIGGER_PROPERTY": 0x00000182,
    "PICO_RATIO_MODE_TRIGGER_MASKING_INVALID": 0x00000183,
    "PICO_TRIGGER_DATA_REQUIRES_MIN_BUFFER_SIZE_OF_40_SAMPLES": 0x00000184,
    "PICO_NO_OF_CAPTURES_OUT_OF_RANGE": 0x00000185,
    "PICO_RATIO_MODE_SEGMENT_HEADER_DOES_NOT_REQUIRE_BUFFERS": 0x00000186,
    "PICO_FOR_SEGMENT_HEADER_USE_GETTRIGGERINFO": 0x00000187,
    "PICO_READ_NOT_SET": 0x00000188,
    "PICO_ADC_SETTING_MISMATCH": 0x00000189,
    "PICO_DATATYPE_INVALID": 0x0000018A,
    "PICO_RATIO_MODE_DOES_NOT_SUPPORT_DATATYPE": 0x0000018B,
    "PICO_CHANNEL_COMBINATION_NOT_VALID_IN_THIS_RESOLUTION": 0x0000018C,
    "PICO_USE_8BIT_RESOLUTION": 0x0000018D,
    "PICO_AGGREGATE_BUFFERS_SAME_POINTER": 0x0000018E,
    "PICO_OVERLAPPED_READ_VALUES_OUT_OF_RANGE": 0x0000018F,
    "PICO_OVERLAPPED_READ_SEGMENTS_OUT_OF_RANGE": 0x00000190,
    "PICO_CHANNELFLAGSCOMBINATIONS_ARRAY_SIZE_TOO_SMALL": 0x00000191,
    "PICO_CAPTURES_EXCEEDS_NO_OF_SUPPORTED_SEGMENTS": 0x00000192,
    "PICO_TIME_UNITS_OUT_OF_RANGE": 0x00000193,
    "PICO_NO_SAMPLES_REQUESTED": 0x00000194,
    "PICO_INVALID_ACTION": 0x00000195,
    "PICO_NO_OF_SAMPLES_NEED_TO_BE_EQUAL_WHEN_ADDING_BUFFERS": 0x00000196,
    "PICO_WAITING_FOR_DATA_BUFFERS": 0x00000197,
    "PICO_STREAMING_ONLY_SUPPORTS_ONE_READ": 0x00000198,
    "PICO_CLEAR_DATA_BUFFER_INVALID": 0x00000199,
    "PICO_INVALID_ACTION_FLAGS_COMBINATION": 0x0000019A,
    "PICO_PICO_MOTH_MIN_AND_MAX_NULL_BUFFERS_CANNOT_BE_ADDED": 0x0000019B,
    "PICO_CONFLICT_IN_SET_DATA_BUFFERS_CALL_REMOVE_DATA_BUFFER_TO_RESET": 0x0000019C,
    "PICO_REMOVING_DATA_BUFFER_ENTRIES_NOT_ALLOWED_WHILE_DATA_PROCESSING": 0x0000019D,
    "PICO_CYUSB_REQUEST_FAILED": 0x00000200,
    "PICO_STREAMING_DATA_REQUIRED": 0x00000201,
    "PICO_INVALID_NUMBER_OF_SAMPLES": 0x00000202,
    "PICO_INALID_DISTRIBUTION": 0x00000203,
    "PICO_BUFFER_LENGTH_GREATER_THAN_INT32_T": 0x00000204,
    "PICO_PLL_MUX_OUT_FAILED": 0x00000209,
    "PICO_ONE_PULSE_WIDTH_DIRECTION_ALLOWED": 0x0000020A,
    "PICO_EXTERNAL_TRIGGER_NOT_SUPPORTED": 0x0000020B,
    "PICO_NO_TRIGGER_CONDITIONS_SET": 0x0000020C,
    "PICO_NO_OF_CHANNEL_TRIGGER_PROPERTIES_OUT_OF_RANGE": 0x0000020D,
    "PICO_PROBE_COMPNENT_ERROR": 0x0000020E,
    "PICO_INVALID_TRIGGER_CHANNELS_FOR_ETS": 0x00000210,
    "PICO_NOT_AVALIABLE_WHEN_STREAMING_IS_RUNNING": 0x00000211,
    "PICO_INVALID_TRIGGER_WITHIN_PRE_TRIGGER_STATE": 0x00000212,
    "PICO_ZERO_NUMBER_OF_CAPTURES_INVALID": 0x00000213,
    "PICO_TRIGGER_DELAY_OUT_OF_RANGE": 0x00000300,
    "PICO_INVALID_THRESHOLD_DIRECTION": 0x00000301,
    "PICO_INVALID_THRESGOLD_MODE": 0x00000302,
    "PICO_DEVICE_TIME_STAMP_RESET": 0x01000000,
    "PICO_WATCHDOGTIMER": 0x10000000,
    "PICO_IPP_NOT_FOUND": 0x10000001,
    "PICO_IPP_NO_FUNCTION": 0x10000002,
    "PICO_IPP_ERROR": 0x10000003,
    "PICO_SHADOW_CAL_NOT_AVAILABLE": 0x10000004,
    "PICO_SHADOW_CAL_DISABLED": 0x10000005,
    "PICO_SHADOW_CAL_ERROR": 0x10000006,
    "PICO_SHADOW_CAL_CORRUPT": 0x10000007,
}

PICO_STATUS_LOOKUP = {v: k for k, v in PICO_STATUS.items()}

PICO_INFO = {
    "PICO_DRIVER_VERSION": 0x00000000,
    "PICO_USB_VERSION": 0x00000001,
    "PICO_HARDWARE_VERSION": 0x00000002,
    "PICO_VARIANT_INFO": 0x00000003,
    "PICO_BATCH_AND_SERIAL": 0x00000004,
    "PICO_CAL_DATE": 0x00000005,
    "PICO_KERNEL_VERSION": 0x00000006,
    "PICO_DIGITAL_HARDWARE_VERSION": 0x00000007,
    "PICO_ANALOGUE_HARDWARE_VERSION": 0x00000008,
    "PICO_FIRMWARE_VERSION_1": 0x00000009,
    "PICO_FIRMWARE_VERSION_2": 0x0000000A,
    "PICO_MAC_ADDRESS": 0x0000000B,
    "PICO_SHADOW_CAL": 0x0000000C,
    "PICO_IPP_VERSION": 0x0000000D,
}


================================================
FILE: picosdk/ctypes_wrapper.py
================================================
# coding=utf-8
#
# Copyright (C) 2018-2019 Pico Technology Ltd. See LICENSE file for terms.
#
import ctypes
import sys

if sys.platform == 'win32':
    C_CALLBACK_FUNCTION_FACTORY = ctypes.WINFUNCTYPE
else:
    C_CALLBACK_FUNCTION_FACTORY = ctypes.CFUNCTYPE


================================================
FILE: picosdk/device.py
================================================
# coding=utf-8
#
# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.
#
"""
Definition of the Device class, which provides access to SDK functions which require a device handle, including
capturing data and configuring the AWG.
"""
from __future__ import print_function
import collections
import numpy
import math
import time
from picosdk.errors import DeviceCannotSegmentMemoryError, InvalidTimebaseError, ClosedDeviceError, \
    NoChannelsEnabledError, NoValidTimebaseForOptionsError


def requires_open(error_message="This operation requires a device to be connected."):
    def check_open_decorator(method):
        def check_open_impl(self, *args, **kwargs):
            if not self.is_open:
                raise ClosedDeviceError(error_message)
            return method(self, *args, **kwargs)
        return check_open_impl
    return check_open_decorator


"""ChannelConfig: A type for specifying channel setup for capture (pass into Device.set_channel, or Device.capture_*)
name = The channel name as a string (e.g. 'A'.)
enabled = bool indicating whether the channel should be enabled or disabled.
coupling (optional) = 'AC' or 'DC', default is 'DC'.
range_peak (optional) = +/- max volts, the highest precision range which includes your value will be selected.
analog_offset (optional) = the meaning of 0 for this channel."""
ChannelConfig = collections.namedtuple('ChannelConfig', ['name', 'enabled', 'coupling', 'range_peak', 'analog_offset'])
ChannelConfig.__new__.__defaults__ = (None, None, None)


"""TimebaseOptions: A type for specifying timebase constraints (pass to Device.find_timebase or Device.capture_*)
All are optional. Please specify the options which matter to you: 
  - the maximum time interval (if you want the fastest/most precise timebase you can get),
  - the number of samples in one buffer,
  - the minimum total collection time (if you want at least x.y seconds of uninterrupted capture data)
  - the oversample (if you want to sacrifice time precision for amplitude precision - see the programming guides.)"""
TimebaseOptions = collections.namedtuple('TimebaseOptions', ['max_time_interval',
                                                             'no_of_samples',
                                                             'min_collection_time',
                                                             'oversample'])
_TIMEBASE_OPTIONS_DEFAULTS = (None, None, None, 1)
TimebaseOptions.__new__.__defaults__ = _TIMEBASE_OPTIONS_DEFAULTS


class Device(object):
    """This object caches some information about the device state which cannot be queried from the driver. Please don't
    mix and match calls to this object with calls directly to the driver (or the ctypes wrapper), as this may cause
    unwanted behaviour (e.g. throwing an exception because no channels are enabled, when you enabled them yourself
    on the driver object.)"""
    def __init__(self, driver, handle):
        self.driver = driver
        self.handle = handle
        self.is_open = handle > 0

        # if a channel is missing from here, it is disabled (or in an undefined state).
        self._channel_ranges = {}
        self._channel_offsets = {}

    @requires_open("The device either did not initialise correctly or has already been closed.")
    def close(self):
        self.driver.close_unit(self)
        self.handle = None
        self.is_open = False

    @property
    @requires_open()
    def info(self):
        return self.driver.get_unit_info(self)

    def __enter__(self):
        return self

    def __exit__(self, *args):
        self.close()
        if all(i is None for i in args):
            return True
        return False

    @requires_open()
    def set_channel(self, channel_config):
        name = channel_config.name
        if not channel_config.enabled:
            self.driver.set_channel(self,
                                    channel_name=name,
                                    enabled=channel_config.enabled)
            try:
                del self._channel_ranges[name]
                del self._channel_offsets[name]
            except KeyError:
                pass
            return
        # if enabled, we pass through the values from the channel config:
        self._channel_ranges[name] = self.driver.set_channel(self,
                                                             channel_name=name,
                                                             enabled=channel_config.enabled,
                                                             coupling=channel_config.coupling,
                                                             range_peak=channel_config.range_peak,
                                                             analog_offset=channel_config.analog_offset)
        self._channel_offsets[name] = channel_config.analog_offset
        return self._channel_ranges[name]

    @requires_open()
    def set_channels(self, *channel_configs):
        """ set_channels(self, *channel_configs)
        An alternative to calling set_channel for each one, you can call this method with some channel configs.
        This method will also disable any missing channels from the passed configs, and disable ALL channels if the
        collection is empty. """
        # Add channels which are missing as "disabled".
        if len(channel_configs) < len(self.driver.PICO_CHANNEL):
            channel_configs = list(channel_configs)
            present_channels = set(c.name for c in channel_configs)
            missing_channels = [cn for cn in self.driver.PICO_CHANNEL.keys() if cn not in present_channels]
            for channel_name in missing_channels:
                channel_configs.append(ChannelConfig(channel_name, False))

        for channel_config in channel_configs:
            self.set_channel(channel_config)

    def _timebase_options_are_impossible(self, options):
        device_max_samples_possible = self.driver.MAX_MEMORY
        if options.no_of_samples is not None:
            if options.no_of_samples > device_max_samples_possible:
                return True
        elif options.max_time_interval is not None and options.min_collection_time is not None:
            effective_min_no_samples = math.ceil(options.min_collection_time / options.max_time_interval)
            if effective_min_no_samples > device_max_samples_possible:
                return True
        if None not in (options.no_of_samples, options.max_time_interval, options.min_collection_time):
            # if all 3 are requested, the result can be impossible.
            effective_min_no_samples = int(math.ceil(options.min_collection_time / options.max_time_interval))
            if effective_min_no_samples > options.no_of_samples:
                return True
        # Is it still possible that this device cannot handle this request, but we don't know without making calls to
        # get_timebase.
        return False

    @staticmethod
    def _validate_timebase(timebase_options, timebase_info):
        """validate whether a timebase result matches the options requested."""
        if timebase_options.max_time_interval is not None:
            if timebase_info.time_interval > timebase_options.max_time_interval:
                return False
        if timebase_options.no_of_samples is not None:
            if timebase_options.no_of_samples > timebase_info.max_samples:
                return False
        if timebase_options.min_collection_time is not None:
            if timebase_options.min_collection_time > timebase_info.max_samples * timebase_info.time_interval:
                return False
        return True

    @requires_open()
    def find_timebase(self, timebase_options):
        timebase_id = 0
        # quickly validate that the request is not impossible.
        if self._timebase_options_are_impossible(timebase_options):
            raise NoValidTimebaseForOptionsError()
        # TODO binary search?
        last_error = None
        found_one_good = False
        while True:
            try:
                timebase_info = self.driver.get_timebase(self, timebase_id, 0, timebase_options.oversample)
                found_one_good = True
                if self._validate_timebase(timebase_options, timebase_info):
                    return timebase_info
            except InvalidTimebaseError as e:
                if found_one_good:
                    # we won't find a valid timebase.
                    last_error = e
                    break
            timebase_id += 1
        args = ()
        if last_error is not None:
            args = (last_error.args[0],)
        raise NoValidTimebaseForOptionsError(*args)

    @requires_open()
    def capture_block(self, timebase_options, channel_configs=()):
        """device.capture_block(timebase_options, channel_configs)
        timebase_options: TimebaseOptions object, specifying at least 1 constraint, and optionally oversample.
        channel_configs: a collection of ChannelConfig objects. If present, will be passed to set_channels.
        """
        # set_channel:

        if channel_configs:
            self.set_channels(*channel_configs)

        if len(self._channel_ranges) == 0:
            raise NoChannelsEnabledError("We cannot capture any data if no channels are enabled.")

        # memory_segments:
        USE_SEGMENT_ID=0
        try:
            # always force the number of memory segments on the device to 1 before computing timebases for a one-off
            # block capture.
            max_samples_possible = self.driver.memory_segments(self, USE_SEGMENT_ID+1)
            if timebase_options.no_of_samples is not None and timebase_options.no_of_samples > max_samples_possible.value:
                raise NoValidTimebaseForOptionsError()
        except DeviceCannotSegmentMemoryError:
            pass

        # get_timebase
        timebase_info = self.find_timebase(timebase_options)

        post_trigger_samples = timebase_options.no_of_samples
        pre_trigger_samples = 0

        if post_trigger_samples is None:
            post_trigger_samples = int(math.ceil(timebase_options.min_collection_time / timebase_info.time_interval))

        self.driver.set_null_trigger(self)

        # tell the device to capture something:
        approx_time_busy = self.driver.run_block(self,
                                                 pre_trigger_samples,
                                                 post_trigger_samples,
                                                 timebase_info.timebase_id,
                                                 timebase_options.oversample,
                                                 USE_SEGMENT_ID)

        is_ready = self.driver.is_ready(self)
        while not is_ready:
            time.sleep(approx_time_busy / 5)
            is_ready = self.driver.is_ready(self)

        raw_data, overflow_warnings = self.driver.get_values(self,
                                                             self._channel_ranges.keys(),
                                                             post_trigger_samples,
                                                             USE_SEGMENT_ID)

        self.driver.stop(self)

        times = numpy.linspace(0.,
                               post_trigger_samples * timebase_info.time_interval,
                               post_trigger_samples,
                               dtype=numpy.dtype('float32'))

        voltages = {}

        max_adc = self.driver.maximum_value(self)
        for channel, raw_array in raw_data.items():
            array = raw_array.astype(numpy.dtype('float32'), casting='safe')
            factor = self._channel_ranges[channel] / max_adc
            array = array * factor
            voltages[channel] = array

        return times, voltages, overflow_warnings


================================================
FILE: picosdk/discover.py
================================================
#
# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.
#
from picosdk.errors import DeviceNotFoundError
from picosdk.ps2000 import ps2000
from picosdk.ps2000a import ps2000a
from picosdk.ps3000 import ps3000
from picosdk.ps3000a import ps3000a
from picosdk.ps4000 import ps4000
from picosdk.ps4000a import ps4000a
from picosdk.ps5000a import ps5000a
from picosdk.ps6000 import ps6000
from picosdk.ps6000a import ps6000a


# the A drivers are faster to enumerate devices, so search them first.
drivers = [
    ps2000a,
    ps3000a,
    ps4000a,
    ps5000a,
    ps6000a,
    ps6000,
    ps2000,
    ps3000,
    ps4000,
]


def find_unit():
    """Search for, open and return the first device connected, on any driver."""
    for driver in drivers:
        try:
            device = driver.open_unit()
        except DeviceNotFoundError:
            continue
        return device
    raise DeviceNotFoundError("Could not find any devices on any drivers.")


def find_all_units():
    """Search for, open and return ALL devices on ALL pico drivers (supported in this SDK wrapper)."""
    devices = []
    for driver in drivers:
        try:
            device = driver.open_unit()
        except DeviceNotFoundError:
            continue
        devices.append(device)
    if not devices:
        raise DeviceNotFoundError("Could not find any devices on any drivers.")
    return devices

================================================
FILE: picosdk/errors.py
================================================
#
# Copyright (C) 2019 Pico Technology Ltd. See LICENSE file for terms.
#


class PicoError(Exception):
    """All errors thrown explicitly by this package will be PicoError's."""
    pass


class FeatureNotSupportedError(PicoError):
    """raised when a feature is not supported on the connected device."""
    pass


class CannotFindPicoSDKError(PicoError, IOError):
    pass


class CannotOpenPicoSDKError(PicoError, IOError):
    pass


class DeviceNotFoundError(PicoError, IOError):
    pass


class ArgumentOutOfRangeError(PicoError, ValueError):
    pass


class ValidRangeEnumValueNotValidForThisDevice(FeatureNotSupportedError, ValueError):
    pass


class DeviceCannotSegmentMemoryError(FeatureNotSupportedError, TypeError):
    pass


class InvalidMemorySegmentsError(PicoError, ValueError):
    pass


class InvalidTimebaseError(PicoError, ValueError):
    pass


class InvalidTriggerParameters(PicoError, ValueError):
    pass


class InvalidCaptureParameters(PicoError, ValueError):
    pass


class PicoSDKCtypesError(PicoError, IOError):
    pass


class ClosedDeviceError(PicoError, IOError):
    pass


class NoChannelsEnabledError(PicoError, ValueError):
    pass


class NoValidTimebaseForOptionsError(PicoError, ValueError):
    pass


class UnknownConstantError(PicoError, TypeError):
    pass


================================================
FILE: picosdk/functions.py
================================================
#
# Copyright (C) 2018-2024 Pico Technology Ltd. See LICENSE file for terms.
#
from __future__ import division
import numpy as np
from picosdk.constants import PICO_STATUS, PICO_STATUS_LOOKUP
from picosdk.errors import PicoSDKCtypesError


def adc2mV(bufferADC, range, maxADC):
    """ 
        adc2mc(
                c_short_Array           bufferADC
                int                     range
                c_int32                 maxADC
                )
               
        Takes a buffer of raw adc count values and converts it into millivolts
    """

    channelInputRanges = [10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000]
    vRange = channelInputRanges[range]
    bufferV = [(np.int64(x) * vRange) / maxADC.value for x in bufferADC]
    
    return bufferV
	
def adc2mVpl1000(bufferADC, range, maxADC):
	"""
		adc2mVpl1000(
						c_short_Array		bufferADC,
						int 				range,
						c_int32				maxADC
						)
		
		Takes a buffer of raw adc count values and converts it into millvolts
	"""
	
	bufferV = [(x * range) / maxADC.value for x in bufferADC]
	
	return bufferV

def mV2adc(millivolts, range, maxADC):
    """
        mV2adc(
                float                   millivolts
				int                     range
                c_int32                 maxADC
                )
        Takes a voltage value and converts it into adc counts
    """
    channelInputRanges = [10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000]
    vRange = channelInputRanges[range]
    adcValue = round((millivolts * maxADC.value)/vRange)

    return adcValue

def mV2adcpl1000(millivolts, range, maxADC):
	"""
		mV2adc(
				float				millivolts,
				int					range,
				c_int32				maxADC
				)
		Takes a voltage value and converts it to adc counts
	"""
	adcValue = round((millivolts * maxADC.value)/range)
	
	return adcValue


def splitMSOData(dataLength, data):
    """
    This method converts an array of values for a ditial port into the binary equivalent, splitting the bits by
    digital channel.

    Returns a set of 8 variables, each of which corresponds to the binary data values over time of the different
    digital channels from the lowest significant bit to the most significant bit. For PORT0 this will be in the order
    (D0, D1, D2, ... D7) and for PORT1 this will be (D8, D9, D10, ... D15).

        splitMSOData(
                        c_int32         dataLength
                        c_int16 array   data
                        )
    """
    # Makes an array for each digital channel
    binaryBufferD0 = np.chararray((dataLength.value, 1))
    binaryBufferD1 = np.chararray((dataLength.value, 1))
    binaryBufferD2 = np.chararray((dataLength.value, 1))
    binaryBufferD3 = np.chararray((dataLength.value, 1))
    binaryBufferD4 = np.chararray((dataLength.value, 1))
    binaryBufferD7 = np.chararray((dataLength.value, 1))
    binaryBufferD5 = np.chararray((dataLength.value, 1))
    binaryBufferD6 = np.chararray((dataLength.value, 1))
    
    # Changes the data from int type to a binary type and then separates the data for each digital channel
    for i in range(0, dataLength.value):
        MSOData = data[i]
        binaryMSOData = bin(MSOData)
        binaryMSOData = binaryMSOData[2:]
        binaryMSOData = binaryMSOData.zfill(8)
        binaryBufferD0[i] = binaryMSOData[7]
        binaryBufferD1[i] = binaryMSOData[6]
        binaryBufferD2[i] = binaryMSOData[5]
        binaryBufferD3[i] = binaryMSOData[4]
        binaryBufferD4[i] = binaryMSOData[3]
        binaryBufferD5[i] = binaryMSOData[2]
        binaryBufferD6[i] = binaryMSOData[1]
        binaryBufferD7[i] = binaryMSOData[0]

    return binaryBufferD0, \
           binaryBufferD1, \
           binaryBufferD2, \
           binaryBufferD3, \
           binaryBufferD4, \
           binaryBufferD5, \
           binaryBufferD6, \
           binaryBufferD7


def splitMSODataFast(dataLength, data):
    """
    # This implementation will work on either channel in the same way as the splitMSOData method above, albeit in a
    more efficient manner.

    Returns a tuple of 8 arrays, each of which is the values over time of a different digital channel.
    The tuple contains the channels in order (D7, D6, D5, ... D0) or equivalently (D15, D14, D13, ... D8).

        splitMSODataFast(
                        c_int32         dataLength
                        c_int16 array   data
                        )
    """
    # Makes an array for each digital channel
    bufferBinaryDj = (
        np.chararray(dataLength.value),
        np.chararray(dataLength.value),
        np.chararray(dataLength.value),
        np.chararray(dataLength.value),
        np.chararray(dataLength.value),
        np.chararray(dataLength.value),
        np.chararray(dataLength.value),
        np.chararray(dataLength.value),
    )
    # Splits out the individual bits from the port into the binary values for each digital channel/pin.
    for i in range(dataLength.value):
        for j in range(8):
            bufferBinaryDj[j][i] = 1 if (data[i] & (1 << (7-j))) else 0

    return bufferBinaryDj


def assert_pico_ok(status):
    """
        assert_pico_ok(
                        status
                       )
    """
    # checks for PICO_OK status return
    if status != PICO_STATUS['PICO_OK']:
        raise PicoSDKCtypesError("PicoSDK returned '{}'".format(PICO_STATUS_LOOKUP[status]))


def assert_pico2000_ok(status):
    """
        assert_pico_ok(
                        status
                       )
    """
    # checks for PICO_OK status return
    if status > 0:
        errorCheck = True
    else:
        errorCheck = False
        raise PicoSDKCtypesError("Unsuccessful API call")
        
def mV2adcV2(millivolts, rangeMax, maxADC):
    """
        mV2adcV2(
                float                   millivolts
				int                     rangeMax
                c_int32                 maxADC
                )
        Takes a voltage value and converts it into adc counts for psospa driver scopes
    """
    adcValue = round((millivolts * maxADC.value)/(rangeMax/1000000))

    return adcValue
    
def adc2mVV2(bufferADC, rangeMax, maxADC):
    """ 
        adc2mVV2(
                c_short_Array           bufferADC
                int                     rangeMax
                c_int32                 maxADC
                )
               
        Takes a buffer of raw adc count values and converts it into millivolts for psospa driver scopes
    """
    buffermV = [(x * (rangeMax/1000000)) / maxADC.value for x in bufferADC]
    
    return buffermV

================================================
FILE: picosdk/functionsExhibitions.py
================================================
#
# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.
#

import numpy as np
import openpyxl
from math import floor, log2, log10
import shutil
import os
import toml

def dataImporter(name):

    workbook = openpyxl.load_workbook(name, data_only = True)
    
    sheet = workbook['filterParameters']
    
    noOfChannels = sheet.cell(row = 2, column = 1).value
    bits = sheet.cell(row = 2, column = 2).value
    samplingRate = sheet.cell(row = 2, column = 3).value
    sampleLength = sheet.cell(row = 2, column = 4).value
    
    return noOfChannels, bits, samplingRate, sampleLength
    
    
def ps6000aTimebase(samplingRate):
    
    sampleInterval = (1/samplingRate)/1000000 #s
    
    breakPoint = 6.4/1000000000
    
    if sampleInterval >= breakPoint:
        timebase = floor((sampleInterval * 156250000)+5)
    else:
        timebase = floor(log2(sampleInterval * 5000000000))
    
    return timebase
    
def ps5000aTimebase(samplingRate):
    
    sampleInterval = (1/samplingRate)/1000000 #s
    
    breakPoint = 8/1000000000
    
    if sampleInterval >= breakPoint:
        timebase = floor((sampleInterval * 125000000)+2)
    else:
        timebase = floor(log2(sampleInterval * 1000000000))
    
    return timebase
    
def ps3000aTimebase(samplingRate):
    
    sampleInterval = (1/samplingRate)/1000000 #s
    
    breakPoint = 8/1000000000
    
    if sampleInterval >= breakPoint:
        timebase = floor((sampleInterval * 125000000)+2)
    else:
        timebase = floor(log2(sampleInterval * 1000000000))
    
    return timebase
  
def ps4000aTimebase(samplingRate):
    
    timebase = floor((80/samplingRate)-1)
    
    return timebase
    
def ps2000aTimebase(samplingRate):
    
    sampleInterval = (1/samplingRate)/1000000 #s
    
    breakPoint = 4/1000000000
    
    if sampleInterval>= breakPoint:
        timebase = floor((sampleInterval*125000000)+2)
    else:
        timebase = floor(log2(sampleInterval * 1000000000))
        
    return timebase
    
def ps2000Timebase(sampleRate):
    #assumes sample rate is in Hz
    #assumes sample interval in s
    
    sampleInterval = (1/sampleRate)
    
    timebase = floor(log10(sampleInterval*1000000000))
    
    return timebase
    
    
def BitEnumSelector(bits):

    if bits <= 8:
        enum = 0
    elif bits <= 10:
        enum = 10
    else:
        enum = 1
        
    return enum
    
def saveConfigFile(channels, bits, sampleRate,captureLength, segments):
    
    # configValues = [channels, bits, sampleRate, captureLength, segments]
    data = {
        "Active Channels" : int(channels),
        "Scope Bit Resolution" : int(bits),
        "Sampling Rate (MHz)" : float(sampleRate),
        "Capture Length (Samples)" : int(captureLength),
        "Number of Capture Segments for Rapid Block" : int(segments),
        }
    # # Save the list to a text file
    with open('configValues.toml', 'w') as file:
        toml.dump(data,file)  
    
        
    return
    
def loadConfigValues():
    
    with open('configValues.toml', 'r') as file:
        restored_configValues = toml.load(file)
            
    channels = int(restored_configValues["Active Channels"])
    bits = int(restored_configValues["Scope Bit Resolution"])
    sampleRate = float(restored_configValues["Sampling Rate (MHz)"])
    captureLength = int(float(restored_configValues["Capture Length (Samples)"]))
    segments = int(restored_configValues["Number of Capture Segments for Rapid Block"])
    
    return channels, bits, sampleRate, captureLength, segments
    
def copyFile(source_directory, filename):
    
    destination_directory = 'D:/'

    # Define the destination file path
    source_file = os.path.join(source_directory, filename)
    destination_file = os.path.join(destination_directory, filename)

    # Copy the file to the new location
    shutil.copy(source_file, destination_file)
    
    return 

================================================
FILE: picosdk/library.py
================================================
#
# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.
#
"""
Definition of the Library class, which is the abstract representation of a picotech device driver.
Note: Many of the functions in this class are missing: these are populated by the psN000(a).py modules, which subclass
this type and attach the missing methods.
"""

from __future__ import print_function

import sys
from ctypes import c_int16, c_int32, c_uint32, c_float, create_string_buffer, byref
from ctypes.util import find_library
import collections
import picosdk.constants as constants
import numpy

from picosdk.errors import CannotFindPicoSDKError, CannotOpenPicoSDKError, DeviceNotFoundError, \
    ArgumentOutOfRangeError, ValidRangeEnumValueNotValidForThisDevice, DeviceCannotSegmentMemoryError, \
    InvalidMemorySegmentsError, InvalidTimebaseError, InvalidTriggerParameters, InvalidCaptureParameters


from picosdk.device import Device


"""TimebaseInfo: A type for holding the particulars of a timebase configuration.
"""
TimebaseInfo = collections.namedtuple('TimebaseInfo', ['timebase_id',
                                                       'time_interval',
                                                       'time_units',
                                                       'max_samples',
                                                       'segment_id'])


def requires_device(error_message="This method requires a Device instance registered to this Library instance."):
    def check_device_decorator(method):
        def check_device_impl(self, device, *args, **kwargs):
            if not isinstance(device, Device) or device.driver != self:
                raise TypeError(error_message)
            return method(self, device, *args, **kwargs)
        return check_device_impl
    return check_device_decorator


class Library(object):
    def __init__(self, name):
        self.name = name
        self._clib = self._load()
        # ! some drivers will replace these dicts at import time, where they have different constants (notably ps2000).
        self.PICO_INFO = constants.PICO_INFO
        self.PICO_STATUS = constants.PICO_STATUS
        self.PICO_STATUS_LOOKUP = constants.PICO_STATUS_LOOKUP
        # these must be set in each driver file.
        self.PICO_CHANNEL = {}
        self.PICO_COUPLING = {}
        self.PICO_VOLTAGE_RANGE = {}

        # most series of scopes top out at 512MS.
        self.MAX_MEMORY = 2**29

        # These are set in some driver files, but not all.
        self.PICO_RATIO_MODE = {}
        self.PICO_THRESHOLD_DIRECTION = {}

    def _load(self):
        library_path = find_library(self.name)

        # 'find_library' fails in Cygwin.
        if not sys.platform == 'cygwin':
            if library_path is None:
                env_var_name = "PATH" if sys.platform == 'win32' else "LD_LIBRARY_PATH"
                raise CannotFindPicoSDKError("PicoSDK (%s) not found, check %s" % (self.name, env_var_name))

        try:
            if sys.platform == 'win32':
                from ctypes import WinDLL
                result = WinDLL(library_path)
            elif sys.platform == 'cygwin':
                from ctypes import CDLL
                library_path = self.name
                result = CDLL(library_path + ".dll")
            else:
                from ctypes import cdll
                result = cdll.LoadLibrary(library_path)
        except OSError as e:
            raise CannotOpenPicoSDKError("PicoSDK (%s) not compatible (check 32 vs 64-bit): %s" % (self.name, e))
        return result

    def __str__(self):
        return "picosdk %s library" % self.name

    def make_symbol(self, python_name, c_name, return_type, argument_types, docstring=None):
        """Used by python wrappers for particular drivers to register C functions on the class."""
        c_function = getattr(self._clib, c_name)
        c_function.restype = return_type
        c_function.argtypes = argument_types
        if docstring is not None:
            c_function.__doc__ = docstring
        # make the functions available under *both* their original and generic names
        setattr(self, python_name, c_function)
        setattr(self, c_name, c_function)
        # AND if the function is camel case, add an "underscore-ized" version:
        if python_name.lower() != python_name:
            acc = []
            for c in python_name[1:]:
                # Be careful to exclude both digits (lower index) and lower case (higher index).
                if ord('A') <= ord(c) <= ord('Z'):
                    c = "_" + c.lower()
                acc.append(c)
            if acc[:2] == ['_', '_']:
                acc = acc[1:]
            setattr(self, "".join(acc), c_function)

    def list_units(self):
        """Returns: a list of dictionaries which identify connected devices which use this driver."""
        handles = []
        device_infos = []
        try:
            while True:
                handle = self._python_open_unit()
                device_infos.append(self._python_get_unit_info_wrapper(handle, []))
                handles.append(handle)
        except DeviceNotFoundError:
            pass

        for handle in handles:
            self._python_close_unit(handle)

        return device_infos

    def open_unit(self, serial=None, resolution=None):
        """optional arguments:
        serial: If no serial number is provided, this function opens the first device discovered.
        resolution: for some devices, you may specify a resolution as you open the device. You should retrieve this
            numeric constant from the relevant driver module.
        returns: a Device instance, which has functions on it for collecting data and using the waveform generator (if
            present).
        Note: Either use this object in a context manager, or manually call .close() on it when you are finished."""
        return Device(self, self._python_open_unit(serial=serial, resolution=resolution))

    @requires_device("close_unit requires a picosdk.device.Device instance, passed to the correct owning driver.")
    def close_unit(self, device):
        self._python_close_unit(device.handle)

    @requires_device("get_unit_info requires a picosdk.device.Device instance, passed to the correct owning driver.")
    def get_unit_info(self, device, *args):
        return self._python_get_unit_info_wrapper(device.handle, args)

    def _python_open_unit(self, serial=None, resolution=None):
        if serial is None:
            handle, status = self._python_open_any_unit(resolution)
        else:
            handle, status = self._python_open_specific_unit(serial, resolution)

        if handle < 1:
            message = ("Driver %s could find no device" % self.name) + ("s" if serial is None else
                                                                        (" matching %s" % serial))
            if status is not None:
                message += " (%s)" % constants.pico_tag(status)
            raise DeviceNotFoundError(message)

        return handle

    def _python_open_any_unit(self, resolution):
        status = None
        if len(self._open_unit.argtypes) == 3:
            if resolution is None:
                resolution = self.DEFAULT_RESOLUTION
            chandle = c_int16()
            cresolution = c_int32()
            cresolution.value = resolution
            status = self._open_unit(byref(chandle), None, cresolution)
            handle = chandle.value
        elif len(self._open_unit.argtypes) == 2:
            chandle = c_int16()
            status = self._open_unit(byref(chandle), None)
            handle = chandle.value
        else:
            handle = self._open_unit()

        return handle, status

    def _python_open_specific_unit(self, serial, resolution):
        handle = -1
        status = None
        if len(self._open_unit.argtypes) == 3:
            if resolution is None:
                resolution = self.DEFAULT_RESOLUTION
            chandle = c_int16()
            cresolution = c_int32()
            cresolution.value = resolution
            cserial = create_string_buffer(serial)
            status = self._open_unit(byref(chandle), cserial, cresolution)
            handle = chandle.value
        elif len(self._open_unit.argtypes) == 2:
            chandle = c_int16()
            cserial = create_string_buffer(serial)
            status = self._open_unit(byref(chandle), cserial)
            handle = chandle.value
        else:
            open_handles = []
            temp_handle = self._open_unit()

            while temp_handle > 0:
                this_serial = self._python_get_unit_info(temp_handle, self.PICO_INFO["PICO_BATCH_AND_SERIAL"])
                if this_serial == serial:
                    handle = temp_handle
                    break
                open_handles.append(temp_handle)
                temp_handle = self._open_unit()

            for temp_handle in open_handles:
                self._python_close_unit(temp_handle)

        return handle, status

    def _python_close_unit(self, handle):
        return self._close_unit(c_int16(handle))

    @staticmethod
    def _create_empty_string_buffer():
        try:
            return create_string_buffer("\0", 255)
        except TypeError:
            return create_string_buffer("\0".encode('utf8'), 255)

    def _python_get_unit_info(self, handle, info_type):
        string_size = 255
        info = self._create_empty_string_buffer()
        if len(self._get_unit_info.argtypes) == 4:
            info_len = self._get_unit_info(c_int16(handle), info, c_int16(string_size), c_int16(info_type))
            if info_len > 0:
                return info.value[:info_len]
        elif len(self._get_unit_info.argtypes) == 5:
            required_size = c_int16(0)
            status = self._get_unit_info(c_int16(handle),
                                         info,
                                         c_int16(string_size),
                                         byref(required_size),
                                         c_uint32(info_type))
            if status == self.PICO_STATUS['PICO_OK']:
                if required_size.value < string_size:
                    return info.value[:required_size.value]
        return ""

    def _python_get_unit_info_wrapper(self, handle, keys):
        # verify that the requested keys are valid for this driver:
        invalid_info_lines = list(set(keys) - set(self.PICO_INFO.keys()))
        if invalid_info_lines:
            raise ArgumentOutOfRangeError("%s not available for %s devices" % (",".join(invalid_info_lines), self.name))

        if not keys:
            # backwards compatible behaviour from first release of this wrapper, which works on all drivers.
            UnitInfo = collections.namedtuple('UnitInfo', ['driver', 'variant', 'serial'])
            return UnitInfo(
                driver=self,
                variant=self._python_get_unit_info(handle, self.PICO_INFO["PICO_VARIANT_INFO"]),
                serial=self._python_get_unit_info(handle, self.PICO_INFO["PICO_BATCH_AND_SERIAL"])
            )

        # make a new type here, with the relevant keys.
        UnitInfo = collections.namedtuple('UnitInfo', list(keys))

        info_lines = {}

        for line in keys:
            info_lines[line] = self._python_get_unit_info(handle, self.PICO_INFO[line])

        return UnitInfo(**info_lines)

    @requires_device("set_channel requires a picosdk.device.Device instance, passed to the correct owning driver.")
    def set_channel(self, device, channel_name='A', enabled=True, coupling='DC', range_peak=float('inf'),
                    analog_offset=None):
        """optional arguments:
        channel_name: a single channel (e.g. 'A')
        enabled: whether to enable the channel (boolean)
        coupling: string of the relevant enum member for your driver less the driver name prefix. e.g. 'DC' or 'AC'.
        range_peak: float which is the largest value you expect in the input signal. We will throw an exception if no
                    range on the device is large enough for that value.
        analog_offset: the meaning of 0 for this channel.
        return value: Max voltage of new range. Raises an exception in error cases."""

        excluded = ()
        reliably_resolved = False

        max_voltage = None

        while not reliably_resolved:
            if enabled:
                range_id, max_voltage = self._resolve_range(range_peak, excluded)
            else:
                range_id = 0
                max_voltage = None

            try:
                self._python_set_channel(device.handle,
                                         self.PICO_CHANNEL[channel_name],
                                         1 if enabled else 0,
                                         self.PICO_COUPLING[coupling],
                                         range_id,
                                         analog_offset)

                reliably_resolved = True
            except ValidRangeEnumValueNotValidForThisDevice:
                excluded += (range_id,)

        return max_voltage

    def _resolve_range(self, signal_peak, exclude=()):
        # we use >= so that someone can specify the range they want precisely.
        # we allow exclude so that if the smallest range in the header file isn't available on this device (or in this
        # configuration) we can exclude it from the collection. It should be the numerical enum constant (the key in
        # PICO_VOLTAGE_RANGE).
        possibilities = list(filter(lambda tup: tup[1] >= signal_peak and tup[0] not in exclude,
                                    self.PICO_VOLTAGE_RANGE.items()))

        if not possibilities:
            raise ArgumentOutOfRangeError("%s device doesn't support a range as wide as %sV" % (self.name, signal_peak))

        return min(possibilities, key=lambda i: i[1])

    def _python_set_channel(self, handle, channel_id, enabled, coupling_id, range_id, analog_offset):
        if len(self._set_channel.argtypes) == 5 and self._set_channel.argtypes[1] == c_int16:
            if analog_offset is not None:
                raise ArgumentOutOfRangeError("This device doesn't support analog offset")
            return_code = self._set_channel(c_int16(handle),
                                            c_int16(channel_id),
                                            c_int16(enabled),
                                            c_int16(coupling_id),
                                            c_int16(range_id))
            if return_code == 0:
                raise ValidRangeEnumValueNotValidForThisDevice("%sV is out of range for this device." % (
                    self.PICO_VOLTAGE_RANGE[range_id]))
        elif len(self._set_channel.argtypes) == 5 and self._set_channel.argtypes[1] == c_int32 or (
             len(self._set_channel.argtypes) == 6):
            status = self.PICO_STATUS['PICO_OK']
            if len(self._set_channel.argtypes) == 6:
                if analog_offset is None:
                    analog_offset = 0.0
                status = self._set_channel(c_int16(handle),
                                           c_int32(channel_id),
                                           c_int16(enabled),
                                           c_int32(coupling_id),
                                           c_int32(range_id),
                                           c_float(analog_offset))
            elif len(self._set_channel.argtypes) == 5 and self._set_channel.argtypes[1] == c_int32:
                if analog_offset is not None:
                    raise ArgumentOutOfRangeError("This device doesn't support analog offset")
                status = self._set_channel(c_int16(handle),
                                           c_int32(channel_id),
                                           c_int16(enabled),
                                           c_int16(coupling_id),
                                           c_int32(range_id))
            if status != self.PICO_STATUS['PICO_OK']:
                if status == self.PICO_STATUS['PICO_INVALID_VOLTAGE_RANGE']:
                    raise ValidRangeEnumValueNotValidForThisDevice("%sV is out of range for this device." % (
                        self.PICO_VOLTAGE_RANGE[range_id]))
                if status == self.PICO_STATUS['PICO_INVALID_CHANNEL'] and not enabled:
                    # don't throw errors if the user tried to disable a missing channel.
                    return
                raise ArgumentOutOfRangeError("problem configuring channel (%s)" % constants.pico_tag(status))

        else:
            raise NotImplementedError("not done other driver types yet")

    @requires_device("memory_segments requires a picosdk.device.Device instance, passed to the correct owning driver.")
    def memory_segments(self, device, number_segments):
        if not hasattr(self, '_memory_segments'):
            raise DeviceCannotSegmentMemoryError()
        max_samples = c_int32(0)
        status = self._memory_segments(c_int16(device.handle), c_uint32(number_segments), byref(max_samples))
        if status != self.PICO_STATUS['PICO_OK']:
            raise InvalidMemorySegmentsError("could not segment the device memory into (%s) segments (%s)" % (
                                              number_segments, constants.pico_tag(status)))
        return max_samples

    @requires_device("get_timebase requires a picosdk.device.Device instance, passed to the correct owning driver.")
    def get_timebase(self, device, timebase_id, no_of_samples, oversample=1, segment_index=0):
        """query the device about what time precision modes it can handle.
        note: the driver returns the timebase in nanoseconds, this function converts that into SI units (seconds)"""
        nanoseconds_result = self._python_get_timebase(device.handle,
                                                       timebase_id,
                                                       no_of_samples,
                                                       oversample,
                                                       segment_index)

        return TimebaseInfo(nanoseconds_result.timebase_id,
                            nanoseconds_result.time_interval * 1.e-9,
                            nanoseconds_result.time_units,
                            nanoseconds_result.max_samples,
                            nanoseconds_result.segment_id)

    def _python_get_timebase(self, handle, timebase_id, no_of_samples, oversample, segment_index):
        # We use get_timebase on ps2000 and ps3000 and parse the nanoseconds-int into a float.
        # on other drivers, we use get_timebase2, which gives us a float in the first place.
        if len(self._get_timebase.argtypes) == 7 and self._get_timebase.argtypes[1] == c_int16:
            time_interval = c_int32(0)
            time_units = c_int16(0)
            max_samples = c_int32(0)
            return_code = self._get_timebase(c_int16(handle),
                                             c_int16(timebase_id),
                                             c_int32(no_of_samples),
                                             byref(time_interval),
                                             byref(time_units),
                                             c_int16(oversample),
                                             byref(max_samples))
            if return_code == 0:
                raise InvalidTimebaseError()

            return TimebaseInfo(timebase_id, float(time_interval.value), time_units.value, max_samples.value, None)
        elif hasattr(self, '_get_timebase2') and (
                     len(self._get_timebase2.argtypes) == 7 and self._get_timebase2.argtypes[1] == c_uint32):
            time_interval = c_float(0.0)
            max_samples = c_int32(0)
            status = self._get_timebase2(c_int16(handle),
                                         c_uint32(timebase_id),
                                         c_int32(no_of_samples),
                                         byref(time_interval),
                                         c_int16(oversample),
                                         byref(max_samples),
                                         c_uint32(segment_index))
            if status != self.PICO_STATUS['PICO_OK']:
                raise InvalidTimebaseError("get_timebase2 failed (%s)" % constants.pico_tag(status))

            return TimebaseInfo(timebase_id, time_interval.value, None, max_samples.value, segment_index)
        else:
            raise NotImplementedError("not done other driver types yet")

    @requires_device()
    def set_null_trigger(self, device):
        auto_trigger_after_millis = 1
        if hasattr(self, '_set_trigger') and len(self._set_trigger.argtypes) == 6:
            PS2000_NONE = 5
            return_code = self._set_trigger(c_int16(device.handle),
                                            c_int16(PS2000_NONE),
                                            c_int16(0),
                                            c_int16(0),
                                            c_int16(0),
                                            c_int16(auto_trigger_after_millis))
            if return_code == 0:
                raise InvalidTriggerParameters()
        elif hasattr(self, '_set_simple_trigger') and len(self._set_simple_trigger.argtypes) == 7:
            enabled = False
            status = self._set_simple_trigger(c_int16(device.handle),
                                              c_int16(int(enabled)),
                                              c_int32(self.PICO_CHANNEL['A']),
                                              c_int16(0),
                                              c_int32(self.PICO_THRESHOLD_DIRECTION['NONE']),
                                              c_uint32(0),
                                              c_int16(auto_trigger_after_millis))
            if status != self.PICO_STATUS['PICO_OK']:
                raise InvalidTriggerParameters("set_simple_trigger failed (%s)" % constants.pico_tag(status))
        else:
            raise NotImplementedError("not done other driver types yet")

    @requires_device()
    def run_block(self, device, pre_trigger_samples, post_trigger_samples, timebase_id, oversample=1, segment_index=0):
        """tell the device to arm any triggers and start capturing in block mode now.
        returns: the approximate time (in seconds) which the device will take to capture with these settings."""
        return self._python_run_block(device.handle,
                                      pre_trigger_samples,
                                      post_trigger_samples,
                                      timebase_id,
                                      oversample,
                                      segment_index)

    def _python_run_block(self, handle, pre_samples, post_samples, timebase_id, oversample, segment_index):
        time_indisposed = c_int32(0)
        if len(self._run_block.argtypes) == 5:
            return_code = self._run_block(c_int16(handle),
                                          c_int32(pre_samples + post_samples),
                                          c_int16(timebase_id),
                                          c_int16(oversample),
                                          byref(time_indisposed))
            if return_code == 0:
                raise InvalidCaptureParameters()
        elif len(self._run_block.argtypes) == 9:
            status = self._run_block(c_int16(handle),
                                     c_int32(pre_samples),
                                     c_int32(post_samples),
                                     c_uint32(timebase_id),
                                     c_int16(oversample),
                                     byref(time_indisposed),
                                     c_uint32(segment_index),
                                     None,
                                     None)
            if status != self.PICO_STATUS['PICO_OK']:
                raise InvalidCaptureParameters("run_block failed (%s)" % constants.pico_tag(status))
        else:
            raise NotImplementedError("not done other driver types yet")

        return float(time_indisposed.value) * 0.001

    @requires_device()
    def is_ready(self, device):
        """poll this function to find out when block mode is ready or has triggered.
        returns: True if data is ready, False otherwise."""
        if hasattr(self, '_ready') and len(self._ready.argtypes) == 1:
            return_code = self._ready(c_int16(device.handle))
            return bool(return_code)
        elif hasattr(self, '_is_ready') and len(self._is_ready.argtypes) == 2:
            is_ready = c_int16(0)
            status = self._is_ready(c_int16(device.handle), byref(is_ready))
            if status != self.PICO_STATUS['PICO_OK']:
                raise InvalidCaptureParameters("is_ready failed (%s)" % constants.pico_tag(status))
            return bool(is_ready.value)
        else:
            raise NotImplementedError("not done other driver types yet")

    @requires_device()
    def maximum_value(self, device):
        if not hasattr(self, '_maximum_value'):
            return (2**15)-1
        max_adc = c_int16(0)
        self._maximum_value(c_int16(device.handle), byref(max_adc))
        return max_adc.value

    @requires_device()
    def get_values(self, device, active_channels, num_samples, segment_index=0):
        # Initialise buffers to hold the data:
        results = {channel: numpy.empty(num_samples, numpy.dtype('int16')) for channel in active_channels}

        overflow = c_int16(0)

        if len(self._get_values.argtypes) == 7 and self._get_timebase.argtypes[1] == c_int16:
            inputs = {k: None for k in 'ABCD'}
            for k, arr in results.items():
                inputs[k] = arr.ctypes.data
            return_code = self._get_values(c_int16(device.handle),
                                           inputs['A'],
                                           inputs['B'],
                                           inputs['C'],
                                           inputs['D'],
                                           byref(overflow),
                                           c_int32(num_samples))
            if return_code == 0:
                raise InvalidCaptureParameters()
        elif len(self._get_values.argtypes) == 7 and self._get_timebase.argtypes[1] == c_uint32:
            # For this function pattern, we first call a function (self._set_data_buffer) to register each buffer. Then,
            # we can call self._get_values to actually populate them.
            for channel, array in results.items():
                status = self._set_data_buffer(c_int16(device.handle),
                                               c_int32(self.PICO_CHANNEL[channel]),
                                               array.ctypes.data,
                                               c_int32(num_samples),
                                               c_uint32(segment_index),
                                               c_int32(self.PICO_RATIO_MODE['NONE']))
                if status != self.PICO_STATUS['PICO_OK']:
                    raise InvalidCaptureParameters("set_data_buffer failed (%s)" % constants.pico_tag(status))

            samples_collected = c_uint32(num_samples)
            status = self._get_values(c_int16(device.handle),
                                      c_uint32(0),
                                      byref(samples_collected),
                                      c_uint32(1),
                                      c_int32(self.PICO_RATIO_MODE['NONE']),
                                      c_uint32(segment_index),
                                      byref(overflow))
            if status != self.PICO_STATUS['PICO_OK']:
                raise InvalidCaptureParameters("get_values failed (%s)" % constants.pico_tag(status))

        overflow_warning = {}
        if overflow.value:
            for channel in results.keys():
                if overflow.value & (1 >> self.PICO_CHANNEL[channel]):
                    overflow_warning[channel] = True

        return results, overflow_warning

    @requires_device()
    def stop(self, device):
        if self._stop.restype == c_int16:
            return_code = self._stop(c_int16(device.handle))
            if isinstance(return_code, c_int16):
                if return_code == 0:
                    raise InvalidCaptureParameters()
        else:
            status = self._stop(c_int16(device.handle))
            if status != self.PICO_STATUS['PICO_OK']:
                raise InvalidCaptureParameters("stop failed (%s)" % constants.pico_tag(status))


================================================
FILE: picosdk/picoMeasurements.py
================================================
#
# Copyright (C) 2025 Pico Technology Ltd. See LICENSE file for terms.
#

import numpy as np


================================================
FILE: picosdk/picohrdl.py
================================================
#
# Copyright (C) 2019 Pico Technology Ltd. See LICENSE file for terms.
#
"""
This is a Python module defining the functions from the picohrdl.h C header file
for ADC-20/24 Data Loggers using the picohrdl driver API functions.
"""

from ctypes import *
from picosdk.library import Library
from picosdk.errors import ArgumentOutOfRangeError
from picosdk.constants import make_enum

class picohrdllib(Library):
    def __init__(self):
        super(picohrdllib, self).__init__("picohrdl")
		
picohrdl = picohrdllib()

picohrdl.HRDL_VOLTAGERANGE = make_enum([
    "HRDL_2500_MV",
	"HRDL_1250_MV",
	"HRDL_625_MV",
	"HRDL_313_MV",
	"HRDL_156_MV",
	"HRDL_78_MV",
	"HRDL_39_MV",
])

picohrdl.HRDL_CONVERSIONTIME = make_enum([
    "HRDL_60MS",
	"HRDL_100MS",
	"HRDL_180MS",
	"HRDL_340MS",
	"HRDL_660MS",
])

doc = """ int16_t HRDLCloseUnit
    (
	    int16_t    handle
	); """
picohrdl.make_symbol("_closeUnit_", "HRDLCloseUnit", c_int16, [c_int16], doc)

doc = """ int16_t HRDLCollectSingleValueAsync
    (
	    int16_t    handle,
		int16_t    channel,
		int16_t    range,
		int16_t    conversionTime,
		int16_t    singleEnded
	); """
picohrdl.make_symbol("_collectSingleValue_Async_", "HRDLCollectSingleValueAsync", c_int16, [c_int16, c_int16, c_int16, c_int16, c_int16], doc)

doc = """ int16_t HRDLGetMinMaxAdcCounts
    (
	    int16_t    handle,
		int32_t    *minAdc,
		int32_t    *maxAdc,
		int16_t    channel
	); """
picohrdl.make_symbol("_getMinMaxAdcCounts_", "HRDLGetMinMaxAdcCounts", c_int16, [c_int16, c_void_p, c_void_p, c_int16], doc)

doc = """ int16_t HRDLGetNumberOfEnabledChannels
    (
	    int16_t    handle,
		int16_t    *nEnabledChannels
	); """
picohrdl.make_symbol("_getNumberOfEnabledChannels_", "HRDLGetNumberOfEnabledChannels", c_int16, [c_int16, c_void_p], doc)

doc = """ int16_t HRDLGetSingleValue
    (
	    int16_t    handle,
		int16_t    channel,
		int16_t    range,
		int16_t    conversionTime,
		int16_t    singleEnded,
		int16_t    *overflow,
		int32_t    *value
	); """
picohrdl.make_symbol("_getSingleValue_", "HRDLGetSingleValue", c_int16, [c_int16, c_int16, c_int16, c_int16, c_int16, c_void_p, c_void_p], doc)

doc = """ int16_t HRDLGetSingleValueAsync
    (
	    int16_t    handle,
		int32_t    *value,
		int16_t    *overflow
	); """
picohrdl.make_symbol("_getSingleValueAsync_", "HRDLGetSingleValueAsync", c_int16, [c_int16, c_void_p, c_void_p], doc)

doc = """ int32_t HRDLGetTimesAndVAlues
    (
	    int16_t    handle,
		int32_t    *times,
		int32_t    *values,
		int16_t    *overflow,
		int32_t    noOfValues
	); """
picohrdl.make_symbol("_getTimesAndValues_", "HRDLGetTimesAndValues", c_int16, [c_int16, c_void_p, c_void_p, c_void_p, c_int32], doc)

doc = """ int16_t HRDLGetUnitInfo
    (
	    int16_t    handle,
		int8_t     *string,
		int16_t    stringLength,
		int16_t    info
	); """
picohrdl.make_symbol("_getUnitInfo_", "HRDLGetUnitInfo", c_int16, [c_int16, c_void_p, c_int16, c_int16], doc)

doc = """ int32_t HRDLGetValues
    (
	    int16_t    handle,
		int32_t    *values,
		int16_t    *overflow,
		int32_t    noOfValues
	); """
picohrdl.make_symbol("_getValues_", "HRDLGetValues", c_int16, [c_int16, c_void_p, c_void_p, c_int32], doc)

doc = """ int16_t HRDLOpenUnit
    (
	    void
	); """
picohrdl.make_symbol("_openUnit_", "HRDLOpenUnit", c_int16, [], doc)

doc = """ int16_t HRDLOpenUnitAsync
    (
	    void
	); """
picohrdl.make_symbol("_openUnitAsync_", "HRDLOpenUnitAsync", c_int16, [], doc)

doc = """ int16_t HRDLOpenUnitProgress
    (
	    int16_t    *handle,
		int16_t    *progress
	); """
picohrdl.make_symbol("_openUnitProgress_", "HRDLOpenUnitProgress", c_int16, [c_void_p, c_void_p], doc)

doc = """ int16_t HRDLReady
    (
	    int16_t    handle
	); """
picohrdl.make_symbol("_ready_", "HRDLReady", c_int16, [c_int16], doc)

doc = """ int16_t HRDLRun
    (
	    int16_t    handle,
		int32_t    nValues,
		int16_t    method
	); """
picohrdl.make_symbol("_run_", "HRDLRun", c_int16, [c_int16, c_int32, c_int16], doc)

doc = """ int16_t HRDLSetAnalogInChannel
    (
	    int16_t    handle,
		int16_t    channel,
		int16_t    enabled,
		int16_t    range,
		int16_t    singleEnded
	); """
picohrdl.make_symbol("_setAnalogInChannel_", "HRDLSetAnalogInChannel", c_int16, [c_int16, c_int16, c_int16, c_int16, c_int16], doc)

doc = """ int16_t HRDLSetDigitalIOChannel
    (
	    int16_t    handle,
		int16_t    directionOut,
		int16_t    digitalOutPinState,
		int16_t    enabledDigitalIn
	); """
picohrdl.make_symbol("_setDigitalIOChannel_", "HRDLSetDigitalIOChannel", c_int16, [c_int16, c_int16, c_int16, c_int16], doc)

doc = """ int16_t HRDLSetInterval
    (
	    int16_t    handle,
		int32_t    samplesInterval_ms,
		int16_t    conversionTime
	); """
picohrdl.make_symbol("_setInterval_", "HRDLSetInterval", c_int16, [c_int16, c_int32, c_int16], doc)

doc = """ int16_t HRDLSetMains
    (
	    int16_t    handle,
		int16_t    sixtyHertz
	); """
picohrdl.make_symbol("_setMains_", "HRDLSetMains", c_int16, [c_int16, c_int16], doc)

doc = """ void HRDLStop
    (
	    int16_t    handle
	); """
picohrdl.make_symbol("_stop_", "HRDLStop", c_int16, [c_int16], doc)

================================================
FILE: picosdk/picosynth.py
================================================
#
# Copyright (C) 2022 Pico Technology Ltd. See LICENSE file for terms.
#
"""
This is a Python module defining the functions from the picosynth.h C header file
for the PicoSource AS108 Agile Synthesizer using the picosynth driver API functions.
"""

from ctypes import *
from picosdk.library import Library
from picosdk.errors import ArgumentOutOfRangeError
from picosdk.constants import make_enum

class Picosynthlib(Library):
    def __init__(self):
        super(Picosynthlib, self).__init__("picosynth")
        
picosynth = Picosynthlib()

picosynth.PICO_SOURCE_MODEL = make_enum([
    "PICO_NONE_SPECIFIED",
    "PICO_SYNTH",
])

doc = """ PICO_STATUS picosynthOpenUnit
    (
        PICO_SOURCE_MODEL  model,
        uint32_t  *handle,
        unit8_t  *serialNumber
    );"""
picosynth.make_symbol("_OpenUnit","picosynthOpenUnit",c_uint32,[c_uint32, c_void_p, c_void_p],doc)

doc = """ PICO_STATUS picosynthEnumerateUnits
    (
        PICO_SOURCE_MODEL  model,
        uint8_t  *serials,
        unit16_t  *serialLth
    );"""
picosynth.make_symbol("_EnumerateUnits","picosynthEnumerateUnits",c_uint32,[c_uint32, c_void_p, c_void_p],doc)

doc = """ PICO_STATUS picosynthGetUnitInfo
    (
        int8_t  *string,
        unit16_t  stringLength,
        uint16_t  *requiredSize,
        PICO_INFO  deviceInfo
    );"""
picosynth.make_symbol("_GetUnitInfo","picosynthGetUnitInfo",c_uint32,[c_uint32, c_void_p, c_uint16, c_void_p, c_uint32],doc)

doc = """ PICO_STATUS picosynthPingUnit
    (
        uint32_t  *handle,
    );"""
picosynth.make_symbol("_PingUnit","picosynthPingUnit",c_uint32,[c_uint32],doc)

doc = """ PICO_STATUS picosynthCloseUnit
    (
        uint32_t  *handle,
    );"""
picosynth.make_symbol("_CloseUnit","picosynthCloseUnit",c_uint32,[c_uint32],doc)

doc = """ PICO_STATUS picosynthSetOutputOff
    (
        uint32_t  *handle,
    );"""
picosynth.make_symbol("_SetOutputOff","picosynthSetOutputOff",c_uint32,[c_uint32],doc)

doc = """ PICO_STATUS picosynthSetFrequency
    (
        uint32_t  *handle,
        double  frequencyHz,
        double  powerLeveldBm
    );"""
picosynth.make_symbol("_SetFrequency","picosynthSetFrequency",c_uint32,[c_uint32, c_double, c_double],doc)

doc = """ PICO_STATUS picosynthSetPhase
    (
        uint32_t  handle,
        double  phaseDeg
    );"""
picosynth.make_symbol("_SetPhase", "picosynthSetPhase", c_uint32,[c_uint32, c_double], doc)

doc = """ PICO_STATUS picosynthSetAmplitudeModulation
    (
        uint32_t  handle,
        double  frequencyHz,
        double  powerLeveldBm,
        double  modulationDepthPercent,
        double  modulationRateHz,
        MODULATION_SOURCE  modulationSource,
        int16_t  enabled
    );"""
picosynth.make_symbol("_SetAmplitudeModulation","picosynthSetAmplitudeModulation", c_uint32,[c_uint32,c_double,c_double,c_double,c_double,c_uint32,c_int16],doc)

doc = """ PICO_STATUS picosynthSetFrequencyModulation
    (
        uint32_t  handle,
        double  frequencyHz,
        double  powerLeveldBm,
        double  modulationDeviationHz,
        double  modulationRateHz,
        MODULATION_SOURCE  modulationSource,
        int16_t  enabled
    );"""
picosynth.make_symbol("_SetFrequencyModulation","picosynthSetFrequencyModulation",c_uint32,[c_uint32,c_double,c_double,c_double,c_double,c_uint32,c_int16],doc)

doc = """ PICO_STATUS picosynthSetPhaseModulation
    (
        uint32_t  handle,
        double  frequencyHz,
        double  powerLeveldBm,
        double  modulationDeviationHz,
        double  modulationRateHz,
        MODULATION_SOURCE  modulationSource,
        int16_t  enabled
    );"""
picosynth.make_symbol("_SetPhaseModulation","picosynthSetPhaseModulation",c_uint32,[c_uint32,c_double,c_double,c_double,c_double,c_uint32,c_int16],doc)

doc = """ PICO_STATUS picosynthSetFrequencyAndLevelSweep
    (
        uint32_t  handle,
        double  startFrequencyHz,
        double  stopFrequencyHz,
        double  startLevel,
        double  stopLevel,
        LEVEL_UNIT  levelUnit,
        double  dwellTimeUs,
        int32_t  pointsInSweep,
        SWEEP_HOP_MODE  mode,
        TRIGGER_MODE  triggerMode
    );"""
picosynth.make_symbol("_SetFrequencyAndLevelSweep","picosynthSetFrequencyAndLevelSweep", c_uint32,[c_uint32,c_double,c_double,c_double,c_double,c_uint32,c_double,c_int32,c_uint32,c_uint32],doc)

doc = """ PICO_STATUS picosynthSetPhaseAndLevelSweep
    (
        uint32_t  handle,
        double  frequencyHz,
        double  startPhaseDeg,
        double  stopPhaseDeg,
        double  startLevel,
        double  stopLevel,
        LEVEL_UNIT levelUnit,
        double  dwellTimeUs,
        int32_t  pointsInSweep,
        SWEEP_HOP_MODE  mode,
        TRIGGER_MODE  triggerMode
    );"""
picosynth.make_symbol("_SetPhaseAndLevelSweep","picosynthSetPhaseAndLevelSweep", c_uint32,[c_uint32,c_double,c_double,c_double,c_double,c_double,c_uint32,c_double,c_int32,c_uint32,c_uint32],doc)

doc = """ PICO_STATUS picosynthSetArbitraryPhaseAndLevel
    (
        uint32_t  handle,
        double  frequencyHz,
        double  *arbitraryPhaseDeg,
        double  *arbitraryPowerLeveldBm,
        int32_t  numberOfPoints,
        double  dwellTimeUs,
        TRIGGER_MODE  triggerMode
    );"""
picosynth.make_symbol("_SetArbitraryPhaseAndLevel","picosynthSetArbitraryPhaseAndLevel",c_uint32,[c_uint32,c_double,c_double,c_double,c_int32,c_double,c_uint32],doc)

doc = """ PICO_STATUS picosynthSetArbitraryFrequencyAndLevel
    (
        uint32_t  handle,
        double  *arbitraryFrequencyHz,
        double  *arbitraryPowerLeveldBm,
        int32_t  numberOfPoints,
        double  dwellTimeUs,
        TRIGGER_MODE  triggerMode
    );"""
picosynth.make_symbol("_SetArbitraryFrequencyAndLevel","picosynthSetArbitraryFrequencyAndLevel",c_uint32,[c_uint32,c_double,c_double,c_int32,c_double,c_uint32],doc)


================================================
FILE: picosdk/pl1000.py
================================================
#
# Copyright (C) 2019 Pico Technology Ltd. See LICENSE file for terms.
#
"""
This is a Python module defining the functions from the pl1000.h C header
file for PicoLog 1000 Series datalogger using the pl1000 driver API functions.
"""

from ctypes import *
from picosdk.ctypes_wrapper import C_CALLBACK_FUNCTION_FACTORY
from picosdk.library import Library
from picosdk.constants import make_enum

class Pl1000lib(Library):
    def __init__(self):
        super(Pl1000lib, self).__init__("pl1000")
		
pl1000 = Pl1000lib()

def _pl1000Inputs():
    PL1000_CHANNEL_1 = 1
    PL1000_CHANNEL_2 = 2
    PL1000_CHANNEL_3 = 3
    PL1000_CHANNEL_4 = 4
    PL1000_CHANNEL_5 = 5
    PL1000_CHANNEL_6 = 6
    PL1000_CHANNEL_7 = 7
    PL1000_CHANNEL_8 = 8
    PL1000_CHANNEL_9 = 9
    PL1000_CHANNEL_10 = 10
    PL1000_CHANNEL_11 = 11
    PL1000_CHANNEL_12 = 12
    PL1000_CHANNEL_13 = 13
    PL1000_CHANNEL_14 = 14
    PL1000_CHANNEL_15 = 15
    PL1000_CHANNEL_16 = 16
    PL1000_MAX_CHANNEL = PL1000_CHANNEL_16
	
    return {k.upper(): v for k, v in locals().items() if k.startswith("PL1000")}
	
pl1000.PL1000Inputs = _pl1000Inputs()

pl1000.PL1000DO_Channel = make_enum([
    'PL1000_DO_CHANNEL_0',
	'PL1000_DO_CHANNEL_1',
	'PL1000_DO_CHANNEL_2',
	'PL1000_DO_CHANNEL_3',
	'PL1000_DO_CHANNEL_MAX',
])

pl1000.PL1000OpenProgress = {
    'PL1000_OPEN_PROGRESS_FAIL' : -1,
	'PL1000_OPEN_PROGRESS_PENDING': 0,
	'PL1000_OPEN_PROGRESS_COMPLETE' : 1,
}

pl1000.PL1000_BLOCK_METHOD = make_enum([
	"BM_SINGLE",
	"BM_WINDOW",
	"BM_STREAM",
])

doc = """ PICO_STATUS pl1000CloseUnit
    (
	    int16_t  handle
	); """
pl1000.make_symbol("_CloseUnit_", "pl1000CloseUnit", c_uint32, [c_int16], doc)

doc = """ PICO_STATUS pl1000GetSingle
    (
	    int16_t  handle,
		PL1000_INPUTS  channel,
		unit16_t  *value
	); """
pl1000.make_symbol("_GetSingle_", "pl1000GetSingle", c_uint32, [c_int16, c_int32, c_void_p], doc)

doc = """ PICO_STATUS pl1000GetUnitInfo
    (
	    int16_t  handle,
		int8_t  *string,
		int16_t  stringLength,
		int16_t  *requiredSize,
		PICO_INFO  info
	); """
pl1000.make_symbol("_GetUnitInfo_", "pl1000GetUnitInfo", c_uint32, [c_int16, c_void_p, c_int16, c_void_p, c_int32], doc)

doc = """ PICO_STATUS pl1000GetValues
    (
	    int16_t  handle,
		uint16_t  *values,
		uint32_t  *noOfValues,
		unit16_t  *overflow,
		uint32_t  *triggerIndex
	); """
pl1000.make_symbol("_GetValues_", "pl1000GetValues", c_uint32, [c_int16, c_void_p, c_void_p, c_void_p, c_void_p], doc)

doc = """ PICO_STATUS pl1000MaxValue
    (
	    int16_t  handle,
		uint16_t  *maxValue
	); """
pl1000.make_symbol("_MaxValue_", "pl1000MaxValue", c_uint32, [c_int16, c_void_p], doc)

doc = """ PICO_STATUS pl1000OpenUnit
    (
	    int16_t  *handle
	); """
pl1000.make_symbol("_OpenUnit_", "pl1000OpenUnit", c_uint32, [c_void_p], doc)

doc = """ PICO_STATUS pl1000OpenUnitAsync
    (
	    int16_t  *status
	); """
pl1000.make_symbol("_OpenUnitAsync_", "pl1000OpenUnitAsync", c_uint32, [c_void_p], doc)

doc = """ PICO_STATUS pl1000OpenUnitProgress
    (
	    int16_t  *handle,
		int16_t  *progress,
		int16_t  *complete
	); """
pl1000.make_symbol("_OpenUnitProgress_", "pl1000OpenUnitProgress", c_uint32, [c_void_p, c_void_p, c_void_p], doc)

doc = """ PICO_STATUS pl1000PingUnit
    (
	    int16_t  handle
	); """
pl1000.make_symbol("_PingUnit_", "pl1000PingUnit", c_uint32, [c_int16], doc)

doc = """ PICO_STATUS pl1000Ready
    (
	    int16_t  handle,
		int16_t  *ready
	); """
pl1000.make_symbol("_Ready_", "pl1000Ready", c_uint32, [c_int16, c_void_p], doc)

doc = """ PICO_STATUS pl1000Run
    (
	    int16_t  handle,
		uint32_t  no_of_values,
		BLOCK_METHOD  method
	); """
pl1000.make_symbol("_Run_", "pl1000Run", c_uint32, [c_int16, c_uint32, c_int32], doc)

doc = """ PICO_STATUS pl1000SetDo
    (
	    int16_t  handle,
		int16_t  do_value,
		int16_t  doNo
	); """
pl1000.make_symbol("_SetDo_", "pl1000SetDo", c_uint32, [c_int16, c_int16, c_int16], doc)

doc = """ PICO_STATUS pl1000SetInterval
    (
	    int16_t  handle,
		uint32_t  *us_for_block,
		uint32_t  ideal_no_of_samples,
		int16_t  *channels,
		int16_t  no_of_channels
	); """
pl1000.make_symbol("_SetInterval_", "pl1000SetInterval", c_uint32, [c_int16, c_void_p, c_uint32, c_void_p, c_int16], doc)

doc = """ PICO_STATUS pl1000SetPulseWidth
    (
	    int16_t  handle,
		uint16_t  period,
		uint8_t  cycle
	); """
pl1000.make_symbol("_SetPulseWidth_", "pl1000SetPulseWidth", c_uint32, [c_int16, c_int16, c_int8], doc)

doc = """ PICO_STATUS pl1000SetTrigger
    (
	    int16_t  handle,
		uint16_t  enabled,
		uint16_t  auto_trigger,
		uint16_t  auto_ms,
		uint16_t  channel,
		uint16_t  dir,
		uint16_t  threshold,
		uint16_t  hysteresis,
		float  delay
	); """
pl1000.make_symbol("_SetTrigger_", "pl1000SetTrigger", c_uint32, [c_int16, c_uint16, c_uint16, c_uint16, c_uint16, c_uint16, c_uint16, c_uint16, c_float], doc)

doc = """ PICO_STATUS pl1000Stop
    (
	    int16_t  handle
	); """
pl1000.make_symbol("_Stop_", "pl1000Stop", c_uint32, [c_int16], doc)



================================================
FILE: picosdk/ps2000.py
================================================
#
# Copyright (C) 2015-2018 Pico Technology Ltd. See LICENSE file for terms.
#
"""
This is a Python module defining the functions from the ps2000.h C header file
for PicoScope 2000 Series oscilloscopes using the ps2000 driver API functions.
"""

from ctypes import *
from picosdk.library import Library
from picosdk.errors import ArgumentOutOfRangeError
from picosdk.constants import make_enum
from picosdk.ctypes_wrapper import C_CALLBACK_FUNCTION_FACTORY


class Ps2000lib(Library):
    def __init__(self):
        super(Ps2000lib, self).__init__("ps2000")


ps2000 = Ps2000lib()

ps2000.PS2000_CHANNEL = make_enum([
    "PS2000_CHANNEL_A",
    "PS2000_CHANNEL_B",
])

# use the last character, i.e. the channel name:
ps2000.PICO_CHANNEL = {k[-1]: v for k, v in ps2000.PS2000_CHANNEL.items()}

# This field is passed to the driver as a boolean, not an enum.
ps2000.PICO_COUPLING = {
    'AC': 0,
    'DC': 1
}

ps2000.PS2000_WAVE_TYPE = make_enum([
    "PS2000_SINE",
    "PS2000_SQUARE",
    "PS2000_TRIANGLE",
    "PS2000_RAMPUP",
    "PS2000_RAMPDOWN",
    "PS2000_DC_VOLTAGE",
    "PS2000_GAUSSIAN",
    "PS2000_SINC",
    "PS2000_HALF_SINE",
])

ps2000.PS2000_SWEEP_TYPE = make_enum([
    "PS2000_UP",
    "PS2000_DOWN",
    "PS2000_UPDOWN",
    "PS2000_DOWNUP",
])


ps2000.PS2000_VOLTAGE_RANGE = {
    'PS2000_20MV':  1,
    'PS2000_50MV':  2,
    'PS2000_100MV': 3,
    'PS2000_200MV': 4,
    'PS2000_500MV': 5,
    'PS2000_1V':    6,
    'PS2000_2V':    7,
    'PS2000_5V':    8,
    'PS2000_10V':   9,
    'PS2000_20V':   10,
}

# float voltage value max (multiplier for output voltages). Parse the value in the constant name.
ps2000.PICO_VOLTAGE_RANGE = {
    v: float(k.split('_')[1][:-1]) if k[-2] != 'M' else (0.001 * float(k.split('_')[1][:-2]))
    for k, v in ps2000.PS2000_VOLTAGE_RANGE.items()
}

ps2000.MAX_MEMORY = 32e3

ps2000.PS2000_TIME_UNITS = make_enum([
    'PS2000_FS',
    'PS2000_PS',
    'PS2000_NS',
    'PS2000_US',
    'PS2000_MS',
    'PS2000_S',
    'PS2000_MAX_TIME_UNITS',
])

doc = """ int16_t ps2000_open_unit
    (
        void
    ); """
ps2000.make_symbol("_open_unit", "ps2000_open_unit", c_int16, [], doc)

doc = """ int16_t ps2000_get_unit_info
    (
        int16_t  handle,
        int8_t  *string,
        int16_t  string_length,
        int16_t  line
    ); """
ps2000.make_symbol("_get_unit_info", "ps2000_get_unit_info", c_int16, [c_int16, c_char_p, c_int16, c_int16], doc)

doc = """ int16_t ps2000_flash_led
    (
        int16_t handle
    ); """
ps2000.make_symbol("_flash_led", "ps2000_flash_led", c_int16, [c_int16, ], doc)

doc = """ int16_t ps2000_close_unit
    (
        int16_t handle
    ); """
ps2000.make_symbol("_close_unit", "ps2000_close_unit", c_int16, [c_int16, ], doc)

doc = """ int16_t ps2000_set_channel
    (
        int16_t  handle,
        int16_t  channel,
        int16_t  enabled,
        int16_t  dc,
        int16_t  range
    ); """
ps2000.make_symbol("_set_channel", "ps2000_set_channel", c_int16, [c_int16, c_int16, c_int16, c_int16, c_int16], doc)

doc = """ int16_t ps2000_get_timebase
    (
        int16_t  handle,
        int16_t  timebase,
        int32_t  no_of_samples,
        int32_t *time_interval,
        int16_t *time_units,
        int16_t  oversample,
        int32_t *max_samples
    ); """
ps2000.make_symbol("_get_timebase", "ps2000_get_timebase", c_int16,
                   [c_int16, c_int16, c_int32, c_void_p, c_void_p, c_int16, c_void_p], doc)

doc = """ int16_t ps2000_set_trigger
    (
        int16_t  handle,
        int16_t  source,
        int16_t  threshold,
        int16_t  direction,
        int16_t  delay,
        int16_t  auto_trigger_ms
    ); """
ps2000.make_symbol("_set_trigger", "ps2000_set_trigger", c_int16,
                   [c_int16, c_int16, c_int16, c_int16, c_int16, c_int16], doc)

doc = """ int16_t ps2000_set_trigger2
    (
        int16_t  handle,
        int16_t  source,
        int16_t  threshold,
        int16_t  direction,
        float    delay,
        int16_t  auto_trigger_ms
    ); """
ps2000.make_symbol("_set_trigger2", "ps2000_set_trigger2", c_int16,
                   [c_int16, c_int16, c_int16, c_int16, c_float, c_int16], doc)

doc = """ int16_t ps2000_run_block
    (
        int16_t handle,
        int32_t  no_of_values,
        int16_t  timebase,
        int16_t  oversample,
        int32_t * time_indisposed_ms
    ); """
ps2000.make_symbol("_run_block", "ps2000_run_block", c_int16, [c_int16, c_int32, c_int16, c_int16, c_void_p], doc)

doc = """ int16_t ps2000_run_streaming
    (
        int16_t  handle,
        int16_t  sample_interval_ms,
        int32_t  max_samples,
        int16_t  windowed
    ); """
ps2000.make_symbol("_run_streaming", "ps2000_run_streaming", c_int16, [c_int16, c_int16, c_int32, c_int16], doc)

doc = """ int16_t ps2000_run_streaming_ns
    (
        int16_t            handle,
        uint32_t           sample_interval,
        PS2000_TIME_UNITS  time_units,
        uint32_t           max_samples,
        int16_t            auto_stop,
        uint32_t           noOfSamplesPerAggregate,
        uint32_t           overview_buffer_size
    ); """
ps2000.make_symbol("_run_streaming_ns", "ps2000_run_streaming_ns", c_int16,
                   [c_int16, c_uint32, c_int32, c_uint32, c_int16, c_uint32, c_uint32], doc)

doc = """ int16_t ps2000_ready
    (
        int16_t  handle
    ); """
ps2000.make_symbol("_ready", "ps2000_ready", c_int16, [c_int16, ], doc)

doc = """ int16_t ps2000_stop
    (
        int16_t  handle
    ); """
ps2000.make_symbol("_stop", "ps2000_stop", c_int16, [c_int16, ], doc)

doc = """ int32_t ps2000_get_values
    (
        int16_t  handle,
        int16_t *buffer_a,
        int16_t *buffer_b,
        int16_t *buffer_c,
        int16_t *buffer_d,
        int16_t *overflow,
        int32_t  no_of_values
    ); """
ps2000.make_symbol("_get_values", "ps2000_get_values", c_int32,
                   [c_int16, c_void_p, c_void_p, c_void_p, c_void_p, c_void_p, c_int32], doc)

doc = """ int32_t ps2000_get_times_and_values
    (
        int16_t  handle,
        int32_t *times,
        int16_t *buffer_a,
        int16_t *buffer_b,
        int16_t *buffer_c,
        int16_t *buffer_d,
        int16_t *overflow,
        int16_t  time_units,
        int32_t  no_of_values
    ); """
ps2000.make_symbol("_get_times_and_values", "ps2000_get_times_and_values", c_int32,
                   [c_int16, c_void_p, c_void_p, c_void_p, c_void_p, c_void_p, c_void_p, c_int16, c_int32], doc)

doc = """ int16_t ps2000_last_button_press
    (
        int16_t  handle
    ); """
ps2000.make_symbol("_last_button_press", "ps2000_last_button_press", c_int16, [c_int16, ], doc)

doc = """ int32_t ps2000_set_ets
    (
        int16_t  handle,
        int16_t  mode,
        int16_t  ets_cycles,
        int16_t  ets_interleave
    ); """
ps2000.make_symbol("_set_ets", "ps2000_set_ets", c_int32, [c_int16, c_int16, c_int16, c_int16], doc)

doc = """ int16_t ps2000_set_led
    (
        int16_t  handle,
        int16_t  state
    ); """
ps2000.make_symbol("_set_led", "ps2000_set_led", c_int16, [c_int16, c_int16], doc)

doc = """ int16_t ps2000_open_unit_async
    (
        void
    ); """
ps2000.make_symbol("_open_unit_async", "ps2000_open_unit_async", c_int16, [], doc)

doc = """ int16_t ps2000_open_unit_progress
    (
        int16_t *handle,
        int16_t *progress_percent
    ); """
ps2000.make_symbol("_open_unit_progress", "ps2000_open_unit_progress", c_int16, [c_void_p, c_void_p], doc)

doc = """ int16_t ps2000_get_streaming_last_values
    (
        int16_t  handle,
        GetOverviewBuffersMaxMin
    ); """
ps2000.make_symbol("_get_streaming_last_values", "ps2000_get_streaming_last_values", c_int16, [c_int16, c_void_p], doc)

doc = """ int16_t ps2000_overview_buffer_status
    (
        int16_t  handle,
        int16_t *previous_buffer_overrun
    ); """
ps2000.make_symbol("_overview_buffer_status", "ps2000_overview_buffer_status", c_int16, [c_int16, c_void_p], doc)

doc = """ uint32_t ps2000_get_streaming_values
    (
        int16_t  handle,
        double   *start_time,
        int16_t  *pbuffer_a_max,
        int16_t  *pbuffer_a_min,
        int16_t  *pbuffer_b_max,
        int16_t  *pbuffer_b_min,
        int16_t  *pbuffer_c_max,
        int16_t  *pbuffer_c_min,
        int16_t  *pbuffer_d_max,
        int16_t  *pbuffer_d_min,
        int16_t  *overflow,
        uint32_t *triggerAt,
        int16_t  *triggered,
        uint32_t  no_of_values,
        uint32_t  noOfSamplesPerAggregate
    ); """
ps2000.make_symbol("_get_streaming_values", "ps2000_get_streaming_values", c_uint32,
                   [c_int16, c_void_p,
                    c_void_p, c_void_p, c_void_p, c_void_p, c_void_p, c_void_p, c_void_p, c_void_p,
                    c_void_p, c_void_p, c_void_p, c_uint32, c_uint32], doc)

doc = """ uint32_t ps2000_get_streaming_values_no_aggregation
    (
        int16_t handle,
        double *start_time,
        int16_t * pbuffer_a,
        int16_t * pbuffer_b,
        int16_t * pbuffer_c,
        int16_t * pbuffer_d,
        int16_t * overflow,
        uint32_t * triggerAt,
        int16_t * trigger,
        uint32_t no_of_values
    ); """
ps2000.make_symbol("_get_streaming_values_no_aggregation", "ps2000_get_streaming_values_no_aggregation", c_uint32,
                   [c_int16, c_void_p,
                    c_void_p, c_void_p, c_void_p, c_void_p,
                    c_void_p, c_void_p, c_void_p, c_uint32], doc)

doc = """ int16_t ps2000_set_light
    (
        int16_t  handle,
        int16_t  state
    ); """
ps2000.make_symbol("_set_light", "ps2000_set_light", c_int16, [c_int16, c_int16], doc)

doc = """ int16_t ps2000_set_sig_gen_arbitrary
    (
        int16_t            handle,
        int32_t            offsetVoltage,
        uint32_t           pkToPk,
        uint32_t           startDeltaPhase,
        uint32_t           stopDeltaPhase,
        uint32_t           deltaPhaseIncrement,
        uint32_t           dwellCount,
        uint8_t           *arbitraryWaveform,
        int32_t            arbitraryWaveformSize,
        PS2000_SWEEP_TYPE  sweepType,
        uint32_t           sweeps
    ); """
ps2000.make_symbol("_set_sig_gen_arbitrary", "ps2000_set_sig_gen_arbitrary", c_int16,
                   [c_int16, c_int32, c_uint32, c_uint32, c_uint32, c_uint32, c_uint32, c_void_p, c_int32, c_int32,
                    c_uint32], doc)

doc = """ int16_t ps2000_set_sig_gen_built_in
    (
        int16_t            handle,
        int32_t            offsetVoltage,
        uint32_t           pkToPk,
        PS2000_WAVE_TYPE   waveType,
        float              startFrequency,
        float              stopFrequency,
        float              increment,
        float              dwellTime,
        PS2000_SWEEP_TYPE  sweepType,
        uint32_t           sweeps
    ); """
ps2000.make_symbol("_set_sig_gen_built_in", "ps2000_set_sig_gen_built_in", c_int16,
                   [c_int16, c_int32, c_uint32, c_int32, c_float, c_float, c_float, c_float, c_int32, c_uint32], doc)

doc = """ int16_t ps2000SetAdvTriggerChannelProperties
    (
        int16_t                            handle,
        PS2000_TRIGGER_CHANNEL_PROPERTIES *channelProperties,
        int16_t                            nChannelProperties,
        int32_t                            autoTriggerMilliseconds
    ); """
ps2000.make_symbol("_SetAdvTriggerChannelProperties", "ps2000SetAdvTriggerChannelProperties", c_int16,
                   [c_int16, c_void_p, c_int16, c_int32], doc)

doc = """ int16_t ps2000SetAdvTriggerChannelConditions
    (
        int16_t                    handle,
        PS2000_TRIGGER_CONDITIONS *conditions,
        int16_t                    nConditions
    ); """
ps2000.make_symbol("_SetAdvTriggerChannelConditions", "ps2000SetAdvTriggerChannelConditions", c_int16,
                   [c_int16, c_void_p, c_int16], doc)

doc = """ int16_t ps2000SetAdvTriggerChannelDirections
    (
        int16_t                     handle,
        PS2000_THRESHOLD_DIRECTION  channelA,
        PS2000_THRESHOLD_DIRECTION  channelB,
        PS2000_THRESHOLD_DIRECTION  channelC,
        PS2000_THRESHOLD_DIRECTION  channelD,
        PS2000_THRESHOLD_DIRECTION  ext
    ); """
ps2000.make_symbol("_SetAdvTriggerChannelDirections", "ps2000SetAdvTriggerChannelDirections", c_int16,
                   [c_int16, c_int32, c_int32, c_int32, c_int32, c_int32], doc)

doc = """ int16_t ps2000SetPulseWidthQualifier
    (
        int16_t                     handle,
        PS2000_PWQ_CONDITIONS      *conditions,
        int16_t                     nConditions,
        PS2000_THRESHOLD_DIRECTION  direction,
        uint32_t                    lower,
        uint32_t                    upper,
        PS2000_PULSE_WIDTH_TYPE     type
    ); """
ps2000.make_symbol("_SetPulseWidthQualifier", "ps2000SetPulseWidthQualifier", c_int16,
                   [c_int16, c_void_p, c_int16, c_int32, c_uint32, c_uint32, c_int32], doc)

doc = """ int16_t ps2000SetAdvTriggerDelay
    (
        int16_t   handle,
        uint32_t  delay,
        float     preTriggerDelay
    ); """
ps2000.make_symbol("_SetAdvTriggerDelay", "ps2000SetAdvTriggerDelay", c_int16, [c_int16, c_uint32, c_float], doc)

doc = """ int16_t ps2000PingUnit
    (
        int16_t  handle
    ); """
ps2000.make_symbol("_PingUnit", "ps2000PingUnit", c_int16, [c_int16, ], doc)

ps2000.PICO_INFO = {k: v for k, v in ps2000.PICO_INFO.items() if v <= 0x00000005}
ps2000.PICO_INFO["PICO_ERROR_CODE"] = 0x00000006
ps2000.PICO_INFO["PICO_KERNEL_DRIVER_VERSION"] = 0x00000007


doc = """ void *my_get_overview_buffers
    (
        int16_t    **overviewBuffers
        int16_t   overflow,
        uint32_t  triggerAt,
        int16_t   triggered,
        int16_t   autoStop,
        uint32_t    nValues
    );
    define a python function which accepts the correct arguments, and pass it to the constructor of this type.
    """

ps2000.GetOverviewBuffersType = C_CALLBACK_FUNCTION_FACTORY(None,
                                                         POINTER(POINTER(c_int16)),
                                                         c_int16,
                                                         c_uint32,
                                                         c_int16,
                                                         c_int16,
                                                         c_uint32)

ps2000.GetOverviewBuffersType.__doc__ = doc

================================================
FILE: picosdk/ps2000a.py
================================================
#
# Copyright (C) 2014-2018 Pico Technology Ltd. See LICENSE file for terms.
#
"""
This is a Python module defining the functions from the ps2000aApi.h C header
file for PicoScope 2000 Series oscilloscopes using the ps2000a driver API functions.
"""

from ctypes import *
from picosdk.ctypes_wrapper import C_CALLBACK_FUNCTION_FACTORY
from picosdk.library import Library
from picosdk.constants import make_enum


class Ps2000alib(Library):
    def __init__(self):
        super(Ps2000alib, self).__init__("ps2000a")


ps2000a = Ps2000alib()

# A tuple in an enum like this is 2 names for the same value.
ps2000a.PS2000A_CHANNEL = make_enum([
    "PS2000A_CHANNEL_A",
    "PS2000A_CHANNEL_B",
    "PS2000A_CHANNEL_C",
    "PS2000A_CHANNEL_D",
    ("PS2000A_EXTERNAL", "PS2000A_MAX_CHANNELS"),
    "PS2000A_TRIGGER_AUX",
    "PS2000A_MAX_TRIGGER_SOURCE",
])

# only include the normal analog channels for now:
ps2000a.PICO_CHANNEL = {k[-1]: v for k, v in ps2000a.PS2000A_CHANNEL.items() if "PS2000A_CHANNEL_" in k}


ps2000a.PS2000A_COUPLING = make_enum([
    'PS2000A_AC',
    'PS2000A_DC',
])

# Just use AC and DC.
ps2000a.PICO_COUPLING = {k[-2:]: v for k, v in ps2000a.PS2000A_COUPLING.items()}

ps2000a.PS2000A_RANGE = make_enum([
    "PS2000A_10MV",
    "PS2000A_20MV",
    "PS2000A_50MV",
    "PS2000A_100MV",
    "PS2000A_200MV",
    "PS2000A_500MV",
    "PS2000A_1V",
    "PS2000A_2V",
    "PS2000A_5V",
    "PS2000A_10V",
    "PS2000A_20V",
    "PS2000A_50V",
    "PS2000A_MAX_RANGES",
])

ps2000a.PICO_VOLTAGE_RANGE = {
    v: float(k.split('_')[1][:-1]) if k[-2] != 'M' else (0.001 * float(k.split('_')[1][:-2]))
    for k, v in ps2000a.PS2000A_RANGE.items() if k != "PS2000A_MAX_RANGES"
}

ps2000a.MAX_MEMORY = 128e6

ps2000a.PS2000A_RATIO_MODE = {
    'PS2000A_RATIO_MODE_NONE': 0,
    'PS2000A_RATIO_MODE_AGGREGATE': 1,
    'PS2000A_RATIO_MODE_DECIMATE': 2,
    'PS2000A_RATIO_MODE_AVERAGE': 4,
}

ps2000a.PS2000A_TIME_UNITS = make_enum([
    'PS2000A_FS',
    'PS2000A_PS',
    'PS2000A_NS',
    'PS2000A_US',
    'PS2000A_MS',
    'PS2000A_S',
    'PS2000A_MAX_TIME_UNITS',
])

ps2000a.PICO_RATIO_MODE = {k[19:]: v for k, v in ps2000a.PS2000A_RATIO_MODE.items()}


def _define_threshold_direction():
    ps2000a_above = 0
    ps2000a_below = 1
    ps2000a_rising = 2
    ps2000a_falling = 3
    ps2000a_rising_or_falling = 4
    ps2000a_above_lower = 5
    ps2000a_below_lower = 6
    ps2000a_rising_lower = 7
    ps2000a_falling_lower = 8

    ps2000a_inside = ps2000a_above
    ps2000a_outside = ps2000a_below
    ps2000a_enter = ps2000a_rising
    ps2000a_exit = ps2000a_falling
    ps2000a_enter_or_exit = ps2000a_rising_or_falling
    ps2000a_positive_runt = 9
    ps2000a_negative_runt = 10

    ps2000a_none = ps2000a_rising

    return {k.upper(): v for k, v in locals().items() if k.startswith("ps2000a")}


ps2000a.PS2000A_THRESHOLD_DIRECTION = _define_threshold_direction()

ps2000a.PICO_THRESHOLD_DIRECTION = {
    k[8:]: v for k, v in ps2000a.PS2000A_THRESHOLD_DIRECTION.items()
}

ps2000a.PS2000A_THRESHOLD_MODE = make_enum([
    "PS2000A_LEVEL",
    "PS2000A_WINDOW",
])

ps2000a.PS2000A_TRIGGER_STATE = make_enum([
    "PS2000A_CONDITION_DONT_CARE",
    "PS2000A_CONDITION_TRUE",
    "PS2000A_CONDITION_FALSE",
    "PS2000A_CONDITION_MAX",
])


def _define_digital_port():
    ps2000a_digital_port0 = 0x80
    ps2000a_digital_port1 = ps2000a_digital_port0 + 1
    ps2000a_digital_port2 = ps2000a_digital_port0 + 2
    ps2000a_digital_port3 = ps2000a_digital_port0 + 3
    ps2000a_max_digital_ports = ps2000a_digital_port3 - ps2000a_digital_port0 + 1
    
    return {k.upper(): v for k, v in locals().items() if k.startswith("ps2000a")}

ps2000a.PS2000A_DIGITAL_PORT = _define_digital_port()

ps2000a.PS2000A_DIGITAL_CHANNEL = make_enum([
    "PS2000A_DIGITAL_CHANNEL_0",
    "PS2000A_DIGITAL_CHANNEL_1",
    "PS2000A_DIGITAL_CHANNEL_2",
    "PS2000A_DIGITAL_CHANNEL_3",
    "PS2000A_DIGITAL_CHANNEL_4",
    "PS2000A_DIGITAL_CHANNEL_5",
    "PS2000A_DIGITAL_CHANNEL_6",
    "PS2000A_DIGITAL_CHANNEL_7",
    "PS2000A_DIGITAL_CHANNEL_8",
    "PS2000A_DIGITAL_CHANNEL_9",
    "PS2000A_DIGITAL_CHANNEL_10",
    "PS2000A_DIGITAL_CHANNEL_11",
    "PS2000A_DIGITAL_CHANNEL_12",
    "PS2000A_DIGITAL_CHANNEL_13",
    "PS2000A_DIGITAL_CHANNEL_14",
    "PS2000A_DIGITAL_CHANNEL_15",
    "PS2000A_DIGITAL_CHANNEL_16",
    "PS2000A_DIGITAL_CHANNEL_17",
    "PS2000A_DIGITAL_CHANNEL_18",
    "PS2000A_DIGITAL_CHANNEL_19",
    "PS2000A_DIGITAL_CHANNEL_20",
    "PS2000A_DIGITAL_CHANNEL_21",
    "PS2000A_DIGITAL_CHANNEL_22",
    "PS2000A_DIGITAL_CHANNEL_23",
    "PS2000A_DIGITAL_CHANNEL_24",
    "PS2000A_DIGITAL_CHANNEL_25",
    "PS2000A_DIGITAL_CHANNEL_26",
    "PS2000A_DIGITAL_CHANNEL_27",
    "PS2000A_DIGITAL_CHANNEL_28",
    "PS2000A_DIGITAL_CHANNEL_29",
    "PS2000A_DIGITAL_CHANNEL_30",
    "PS2000A_DIGITAL_CHANNEL_31",
    "PS2000A_MAX_DIGITAL_CHANNELS",
])

ps2000a.PS2000A_DIGITAL_DIRECTION = make_enum([
    "PS2000A_DIGITAL_DONT_CARE",
    "PS2000A_DIGITAL_DIRECTION_LOW",
    "PS2000A_DIGITAL_DIRECTION_HIGH",
    "PS2000A_DIGITAL_DIRECTION_RISING",
    "PS2000A_DIGITAL_DIRECTION_FALLING",
    "PS2000A_DIGITAL_DIRECTION_RISING_OR_FALLING",
    "PS2000A_DIGITAL_MAX_DIRECTION",
])

ps2000a.PS2000A_PULSE_WIDTH_TYPE = make_enum([
    "PS2000A_PW_TYPE_NONE",
    "PS2000A_PW_TYPE_LESS_THAN",
    "PS2000A_PW_TYPE_GREATER_THAN",
    "PS2000A_PW_TYPE_IN_RANGE",
    "PS2000A_PW_TYPE_OUT_OF_RANGE"
])


class PS2000A_TRIGGER_CONDITIONS(Structure):
    _pack_ = 1
    _fields_ = [("channelA", c_int32),
                ("channelB", c_int32),
                ("channelC", c_int32),
                ("channelD", c_int32),
                ("external", c_int32),
                ("aux", c_int32),
                ("pulseWidthQualifier", c_int32),
                ("digital", c_int32)]
               
ps2000a.PS2000A_TRIGGER_CONDITIONS = PS2000A_TRIGGER_CONDITIONS


class PS2000A_PWQ_CONDITIONS(Structure):
    _pack_ = 1
    _fields_ = [("channelA", c_int32),
                ("channelB", c_int32),
                ("channelC", c_int32),
                ("channelD", c_int32),
                ("external", c_int32),
                ("aux", c_int32),
                ("digital", c_int32)]
                
ps2000a.PS2000A_PWQ_CONDITIONS = PS2000A_PWQ_CONDITIONS


class PS2000A_DIGITAL_CHANNEL_DIRECTIONS(Structure):
    _pack_ = 1
    _fields_ = [("channel", c_int32),
                ("direction", c_int32)]
               
ps2000a.PS2000A_DIGITAL_CHANNEL_DIRECTIONS = PS2000A_DIGITAL_CHANNEL_DIRECTIONS


class PS2000A_TRIGGER_CHANNEL_PROPERTIES(Structure):
    _pack_ = 1
    _fields_ = [("thresholdUpper", c_int16),
                ("thresholdHysteresis", c_uint16),
                ("thresholdLower", c_int16),
                ("thresholdLowerHysteresis", c_uint16),
                ("channel", c_int32),
                ("thresholdMode", c_int32)]

ps2000a.PS2000A_TRIGGER_CHANNEL_PROPERTIES = PS2000A_TRIGGER_CHANNEL_PROPERTIES

doc = """ PICO_STATUS ps2000aOpenUnit
    (
        int16_t *status,
        int8_t  *serial
    ); """
ps2000a.make_symbol("_OpenUnit", "ps2000aOpenUnit", c_uint32, [c_void_p, c_char_p], doc)

doc = """ PICO_STATUS ps2000aOpenUnitAsync
    (
        int16_t *status,
        int8_t    *serial
    ); """
ps2000a.make_symbol("_OpenUnitAsync", "ps2000aOpenUnitAsync", c_uint32, [c_void_p, c_char_p], doc)

doc = """ PICO_STATUS ps2000aOpenUnitProgress
    (
        int16_t *handle,
        int16_t *progressPercent,
        int16_t *complete
    ); """
ps2000a.make_symbol("_OpenUnitProgress", "ps2000aOpenUnitProgress", c_uint32, [c_void_p, c_void_p, c_void_p], doc)

doc = """ PICO_STATUS ps2000aGetUnitInfo
    (
        int16_t   handle,
        int8_t   *string,
        int16_t   stringLength,
        int16_t  *requiredSize,
        PICO_INFO info
    ); """
ps2000a.make_symbol("_GetUnitInfo", "ps2000aGetUnitInfo", c_uint32, [c_int16, c_char_p, c_int16, c_void_p, c_uint32],
                    doc)

doc = """ PICO_STATUS ps2000aFlashLed
    (
        int16_t handle,
        int16_t start
    ); """
ps2000a.make_symbol("_FlashLed", "ps2000aFlashLed", c_uint32, [c_int16, c_int16], doc)

doc = """ PICO_STATUS ps2000aCloseUnit
    (
        int16_t handle
    ); """
ps2000a.make_symbol("_CloseUnit", "ps2000aCloseUnit", c_uint32, [c_int16, ], doc)

doc = """ PICO_STATUS ps2000aMemorySegments
    (
        int16_t   handle,
        uint32_t  nSegments,
        int32_t  *nMaxSamples
    ); """
ps2000a.make_symbol("_MemorySegments", "ps2000aMemorySegments", c_uint32, [c_int16, c_uint32, c_void_p], doc)

doc = """ PICO_STATUS ps2000aSetChannel
    (
        int16_t          handle,
        PS2000A_CHANNEL  channel,
        int16_t          enabled,
        PS2000A_COUPLING type,
        PS2000A_RANGE    range,
        float            analogOffset
    ); """
ps2000a.make_symbol("_SetChannel", "ps2000aSetChannel", c_uint32,
                    [c_int16, c_int32, c_int16, c_int32, c_int32, c_float], doc)

doc = """ PICO_STATUS ps2000aSetDigitalPort
    (
        int16_t              handle,
        PS2000A_DIGITAL_PORT port,
        int16_t              enabled,
        int16_t              logicLevel
    ); """
ps2000a.make_symbol("_SetDigitalPort", "ps2000aSetDigitalPort", c_uint32, [c_int16, c_int32, c_int16, c_int16], doc)

doc = """ PICO_STATUS ps2000aSetNoOfCaptures
    (
        int16_t  handle,
        uint32_t nCaptures
    ); """
ps2000a.make_symbol("_SetNoOfCaptures", "ps2000aSetNoOfCaptures", c_uint32, [c_int16, c_uint32], doc)

doc = """ PICO_STATUS ps2000aGetTimebase
    (
        int16_t  handle,
        uint32_t timebase,
        int32_t  noSamples,
        int32_t *timeIntervalNanoseconds,
        int16_t  oversample,
        int32_t *totalSamples,
        uint32_t segmentIndex
    ); """
ps2000a.make_symbol("_GetTimebase", "ps2000aGetTimebase", c_uint32,
                    [c_int16, c_uint32, c_int32, c_void_p, c_int16, c_void_p, c_uint32], doc)

doc = """ PICO_STATUS ps2000aGetTimebase2
    (
        int16_t  handle,
        uint32_t timebase,
        int32_t  noSamples,
        float   *timeIntervalNanoseconds,
        int16_t  oversample,
        int32_t *totalSamples,
        uint32_t segmentIndex
    ); """
ps2000a.make_symbol("_GetTimebase2", "ps2000aGetTimebase2", c_uint32,
                    [c_int16, c_uint32, c_int32, c_void_p, c_int16, c_void_p, c_uint32], doc)

doc = """ PICO_STATUS ps2000aSetSigGenArbitrary
    (
        int16_t                     handle,
        int32_t                     offsetVoltage,
        uint32_t                    pkToPk,
        uint32_t                    startDeltaPhase,
        uint32_t                    stopDeltaPhase,
        uint32_t                    deltaPhaseIncrement,
        uint32_t                    dwellCount,
        int16_t                    *arbitraryWaveform,
        int32_t                     arbitraryWaveformSize,
        PS2000A_SWEEP_TYPE          sweepType,
        PS2000A_EXTRA_OPERATIONS    operation,
        PS2000A_INDEX_MODE          indexMode,
        uint32_t                    shots,
        uint32_t                    sweeps,
        PS2000A_SIGGEN_TRIG_TYPE    triggerType,
        PS2000A_SIGGEN_TRIG_SOURCE  triggerSource,
        int16_t                     extInThreshold
    ); """
ps2000a.make_symbol("_SetSigGenArbitrary", "ps2000aSetSigGenArbitrary", c_uint32,
                    [c_int16, c_int32, c_uint32, c_uint32, c_uint32, c_uint32, c_uint32, c_void_p, c_int32, c_int32,
                     c_int32,
                     c_int32, c_uint32, c_uint32, c_int32, c_int32, c_int16], doc)

doc = """ PICO_STATUS ps2000aSetSigGenBuiltIn
    (
        int16_t                     handle,
        int32_t                     offsetVoltage,
        uint32_t                    pkToPk,
        int16_t                     waveType,
        float                       startFrequency,
        float                       stopFrequency,
        float                       increment,
        float                       dwellTime,
        PS2000A_SWEEP_TYPE          sweepType,
        PS2000A_EXTRA_OPERATIONS    operation,
        uint32_t                    shots,
        uint32_t                    sweeps,
        PS2000A_SIGGEN_TRIG_TYPE    triggerType,
        PS2000A_SIGGEN_TRIG_SOURCE  triggerSource,
        int16_t                     extInThreshold
    ); """
ps2000a.make_symbol("_SetSigGenBuiltIn", "ps2000aSetSigGenBuiltIn", c_uint32,
                    [c_int16, c_int32, c_uint32, c_int16, c_float, c_float, c_float, c_float, c_int32, c_int32,
                     c_uint32,
                     c_uint32, c_int32, c_int32, c_int16], doc)

doc = """ PICO_STATUS ps2000aSetSigGenPropertiesArbitrary
    (
        int16_t                     handle,
        uint32_t                    startDeltaPhase,
        uint32_t                    stopDeltaPhase,
        uint32_t                    deltaPhaseIncrement,
        uint32_t                    dwellCount,
        PS2000A_SWEEP_TYPE          sweepType,
        uint32_t                    shots,
        uint32_t                    sweeps,
        PS2000A_SIGGEN_TRIG_TYPE    triggerType,
        PS2000A_SIGGEN_TRIG_SOURCE  triggerSource,
        int16_t                     extInThreshold
    ); """
ps2000a.make_symbol("_SetSigGenPropertiesArbitrary", "ps2000aSetSigGenPropertiesArbitrary", c_uint32,
                    [c_int16, c_uint32, c_uint32, c_uint32, c_uint32, c_int32, c_uint32, c_uint32, c_int32, c_int32,
                     c_int16], doc)

doc = """ PICO_STATUS ps2000aSetSigGenPropertiesBuiltIn
    (
        int16_t                     handle,
        double                      startFrequency,
        double                      stopFrequency,
        double                      increment,
        double                      dwellTime,
        PS2000A_SWEEP_TYPE          sweepType,
        uint32_t                    shots,
        uint32_t                    sweeps,
        PS2000A_SIGGEN_TRIG_TYPE    triggerType,
        PS2000A_SIGGEN_TRIG_SOURCE  triggerSource,
        int16_t                     extInThreshold
    ); """
ps2000a.make_symbol("_SetSigGenPropertiesBuiltIn", "ps2000aSetSigGenPropertiesBuiltIn", c_uint32,
                    [c_int16, c_double, c_double, c_double, c_double, c_int32, c_uint32, c_uint32, c_int32, c_int32,
                     c_int16], doc)

doc = """ PICO_STATUS ps2000aSigGenFrequencyToPhase
    (
        int16_t             handle,
        double              frequency,
        PS2000A_INDEX_MODE  indexMode,
        uint32_t            bufferLength,
        uint32_t           *phase
    ); """
ps2000a.make_symbol("_SigGenFrequencyToPhase", "ps2000aSigGenFrequencyToPhase", c_uint32,
                    [c_int16, c_double, c_int32, c_uint32, c_void_p], doc)

doc = """ PICO_STATUS ps2000aSigGenArbitraryMinMaxValues
    (
        int16_t   handle,
        int16_t  *minArbitraryWaveformValue,
        int16_t  *maxArbitraryWaveformValue,
        uint32_t *minArbitraryWaveformSize,
        uint32_t *maxArbitraryWaveformSize
    ); """
ps2000a.make_symbol("_SigGenArbitraryMinMaxValues", "ps2000aSigGenArbitraryMinMaxValues", c_uint32,
                    [c_int16, c_void_p, c_void_p, c_void_p, c_void_p], doc)

doc = """ PICO_STATUS ps2000aSigGenSoftwareControl
    (
        int16_t  handle,
        int16_t  state
    ); """
ps2000a.make_symbol("_SigGenSoftwareControl", "ps2000aSigGenSoftwareControl", c_uint32, [c_int16, c_int16], doc)

doc = """ PICO_STATUS ps2000aSetEts
    (
        int16_t           handle,
        PS2000A_ETS_MODE  mode,
        int16_t           etsCycles,
        int16_t           etsInterleave,
        int32_t          *sampleTimePicoseconds
    ); """
ps2000a.make_symbol("_SetEts", "ps2000aSetEts", c_uint32, [c_int16, c_int32, c_int16, c_int16, c_void_p], doc)

doc = """ PICO_STATUS ps2000aSetSimpleTrigger
    (
        int16_t                      handle,
        int16_t                      enable,
        PS2000A_CHANNEL              source,
        int16_t                      threshold,
        PS2000A_THRESHOLD_DIRECTION  direction,
        uint32_t                     delay,
        int16_t                      autoTrigger_ms
    ); """
ps2000a.make_symbol("_SetSimpleTrigger", "ps2000aSetSimpleTrigger", c_uint32,
                    [c_int16, c_int16, c_int32, c_int16, c_int32, c_uint32, c_int16], doc)

doc = """ PICO_STATUS ps2000aSetTriggerDigitalPortProperties
    (
        int16_t                             handle,
        PS2000A_DIGITAL_CHANNEL_DIRECTIONS *directions,
        int16_t                             nDirections
    ); """
ps2000a.make_symbol("_SetTriggerDigitalPortProperties", "ps2000aSetTriggerDigitalPortProperties", c_uint32,
                    [c_int16, c_void_p, c_int16], doc)

doc = """ PICO_STATUS ps2000aSetDigitalAnalogTriggerOperand
    (
        int16_t handle,
        PS2000A_TRIGGER_OPERAND operand
    ); """
ps2000a.make_symbol("_SetDigitalAnalogTriggerOperand", "ps2000aSetDigitalAnalogTriggerOperand", c_uint32,
                    [c_int16, c_int32], doc)

doc = """ PICO_STATUS ps2000aSetTriggerChannelProperties
    (
        int16_t                             handle,
        PS2000A_TRIGGER_CHANNEL_PROPERTIES *channelProperties,
        int16_t                             nChannelProperties,
        int16_t                             auxOutputEnable,
        int32_t                             autoTriggerMilliseconds
    ); """
ps2000a.make_symbol("_SetTriggerChannelProperties", "ps2000aSetTriggerChannelProperties", c_uint32,
                    [c_int16, c_void_p, c_int16, c_int16, c_int32], doc)

doc = """ PICO_STATUS ps2000aSetTriggerChannelConditions
    (
        int16_t                     handle,
        PS2000A_TRIGGER_CONDITIONS *conditions,
        int16_t                     nConditions
    ); """
ps2000a.make_symbol("_SetTriggerChannelConditions", "ps2000aSetTriggerChannelConditions", c_uint32,
                    [c_int16, c_void_p, c_int16], doc)

doc = """ PICO_STATUS ps2000aSetTriggerChannelDirections
    (
        int16_t                      handle,
        PS2000A_THRESHOLD_DIRECTION  channelA,
        PS2000A_THRESHOLD_DIRECTION  channelB,
        PS2000A_THRESHOLD_DIRECTION  channelC,
        PS2000A_THRESHOLD_DIRECTION  channelD,
        PS2000A_THRESHOLD_DIRECTION  ext,
        PS2000A_THRESHOLD_DIRECTION  aux
    ); """
ps2000a.make_symbol("_SetTriggerChannelDirections", "ps2000aSetTriggerChannelDirections", c_uint32,
                    [c_int16, c_int32, c_int32, c_int32, c_int32, c_int32, c_int32], doc)

doc = """ PICO_STATUS ps2000aSetTriggerDelay
    (
        int16_t   handle,
        uint32_t  delay
    ); """
ps2000a.make_symbol("_SetTriggerDelay", "ps2000aSetTriggerDelay", c_uint32, [c_int16, c_uint32], doc)

doc = """ PICO_STATUS ps2000aSetPulseWidthQualifier
    (
        int16_t                      handle,
        PS2000A_PWQ_CONDITIONS      *conditions,
        int16_t                      nConditions,
        PS2000A_THRESHOLD_DIRECTION  direction,
        uint32_t                     lower,
        uint32_t                     upper,
        PS2000A_PULSE_WIDTH_TYPE     type
    ); """
ps2000a.make_symbol("_SetPulseWidthQualifier", "ps2000aSetPulseWidthQualifier", c_uint32,
                    [c_int16, c_void_p, c_int16, c_int32, c_uint32, c_uint32, c_int32], doc)

doc = """ PICO_STATUS ps2000aIsTriggerOrPulseWidthQualifierEnabled
    (
        int16_t  handle,
        int16_t *triggerEnabled,
        int16_t *pulseWidthQualifierEnabled
    ); """
ps2000a.make_symbol("_IsTriggerOrPulseWidthQualifierEnabled", "ps2000aIsTriggerOrPulseWidthQualifierEnabled", c_uint32,
                    [c_int16, c_void_p, c_void_p], doc)

doc = """ PICO_STATUS ps2000aGetTriggerTimeOffset64
    (
        int16_t             handle,
        int64_t            *time,
        PS2000A_TIME_UNITS *timeUnits,
        uint32_t            segmentIndex
    ); """
ps2000a.make_symbol("_GetTriggerTimeOffset", "ps2000aGetTriggerTimeOffset64", c_uint32,
                    [c_int16, c_void_p, c_void_p, c_uint32], doc)

doc = """ PICO_STATUS PREF2 PREF3 (ps2000aGetValuesTriggerTimeOffsetBulk64)
    (
        int16_t             handle,
        int64_t            *times,
        PS2000A_TIME_UNITS *timeUnits,
        uint32_t            fromSegmentIndex,
        uint32_t            toSegmentIndex
    ); """
ps2000a.make_symbol("_GetValuesTriggerTimeOffsetBulk", "ps2000aGetValuesTriggerTimeOffsetBulk64", c_uint32,
                    [c_int16, c_void_p, c_void_p, c_uint32, c_uint32], doc)

doc = """ PICO_STATUS ps2000aGetNoOfCaptures
    (
        int16_t   handle,
        uint32_t *nCaptures
    ); """
ps2000a.make_symbol("_GetNoOfCaptures", "ps2000aGetNoOfCaptures", c_uint32, [c_int16, c_void_p], doc)

doc = """ PICO_STATUS ps2000aGetNoOfProcessedCaptures
    (
        int16_t   handle,
        uint32_t *nProcessedCaptures
    ); """
ps2000a.make_symbol("_GetNoOfProcessedCaptures", "ps2000aGetNoOfProcessedCaptures", c_uint32, [c_int16, c_void_p], doc)

doc = """ PICO_STATUS ps2000aSetDataBuffer
    (
        int16_t            handle,
        int32_t            channelOrPort,
        int16_t           *buffer,
        int32_t            bufferLth,
        uint32_t           segmentIndex,
        PS2000A_RATIO_MODE mode
    ); """
ps2000a.make_symbol("_SetDataBuffer", "ps2000aSetDataBuffer", c_uint32,
                    [c_int16, c_int32, c_void_p, c_int32, c_uint32, c_int32], doc)

doc = """ PICO_STATUS ps2000aSetDataBuffers
    (
        int16_t            handle,
        int32_t            channelOrPort,
        int16_t           *bufferMax,
        int16_t           *bufferMin,
        int32_t            bufferLth,
        uint32_t           segmentIndex,
        PS2000A_RATIO_MODE mode
    ); """
ps2000a.make_symbol("_SetDataBuffers", "ps2000aSetDataBuffers", c_uint32,
                    [c_int16, c_int32, c_void_p, c_void_p, c_int32, c_uint32, c_int32], doc)

doc = """ PICO_STATUS ps2000aSetEtsTimeBuffer
    (
        int16_t  handle,
        int64_t *buffer,
        int32_t  bufferLth
    ); """
ps2000a.make_symbol("_SetEtsTimeBuffer", "ps2000aSetEtsTimeBuffer", c_uint32, [c_int16, c_void_p, c_int32], doc)

doc = """ PICO_STATUS ps2000aIsReady
    (
        int16_t  handle,
        int16_t *ready
    ); """
ps2000a.make_symbol("_IsReady", "ps2000aIsReady", c_uint32, [c_int16, c_void_p], doc)

doc = """ PICO_STATUS ps2000aRunBlock
    (
        int16_t            handle,
        int32_t            noOfPreTriggerSamples,
        int32_t            noOfPostTriggerSamples,
        uint32_t           timebase,
        int16_t            oversample,
        int32_t           *timeIndisposedMs,
        uint32_t           segmentIndex,
        ps2000aBlockReady  lpReady,
        void              *pParameter
    ); """
ps2000a.make_symbol("_RunBlock", "ps2000aRunBlock", c_uint32,
                    [c_int16, c_int32, c_int32, c_uint32, c_int16, c_void_p, c_uint32, c_void_p, c_void_p], doc)

doc = """ PICO_STATUS ps2000aRunStreaming
    (
        int16_t             handle,
        uint32_t            *sampleInterval,
        PS2000A_TIME_UNITS  sampleIntervalTimeUnits,
        uint32_t            maxPreTriggerSamples,
        uint32_t            maxPostPreTriggerSamples,
        int16_t             autoStop,
        uint32_t            downSampleRatio,
        PS2000A_RATIO_MODE  downSampleRatioMode,
        uint32_t            overviewBufferSize
    ); """
ps2000a.make_symbol("_RunStreaming", "ps2000aRunStreaming", c_uint32,
                    [c_int16, c_void_p, c_int32, c_uint32, c_uint32, c_int16, c_uint32, c_int32, c_uint32], doc)

doc = """ PICO_STATUS ps2000aGetStreamingLatestValues
    (
        int16_t                handle,
        ps2000aStreamingReady  lpPs2000aReady,
        void                   *pParameter
    ); """
ps2000a.make_symbol("_GetStreamingLatestValues", "ps2000aGetStreamingLatestValues", c_uint32,
                    [c_int16, c_void_p, c_void_p], doc)

doc = """ void *ps2000aStreamingReady
    (
        int16_t   handle,
        int32_t   noOfSamples,
        uint32_t  startIndex,
        int16_t   overflow,
        uint32_t  triggerAt,
        int16_t   triggered,
        int16_t   autoStop,
        void     *pParameter
    );
    define a python function which accepts the correct arguments, and pass it to the constructor of this type.
    """

ps2000a.StreamingReadyType = C_CALLBACK_FUNCTION_FACTORY(None,
                                                         c_int16,
                                                         c_int32,
                                                         c_uint32,
                                                         c_int16,
                                                         c_uint32,
                                                         c_int16,
                                                         c_int16,
                                                         c_void_p)

ps2000a.StreamingReadyType.__doc__ = doc

doc = """ PICO_STATUS ps2000aNoOfStreamingValues
    (
        int16_t   handle,
        uint32_t *noOfValues
    ); """
ps2000a.make_symbol("_NoOfStreamingValues", "ps2000aNoOfStreamingValues", c_uint32, [c_int16, c_void_p], doc)

doc = """ PICO_STATUS ps2000aGetMaxDownSampleRatio
    (
        int16_t             handle,
        uint32_t            noOfUnaggreatedSamples,
        uint32_t           *maxDownSampleRatio,
        PS2000A_RATIO_MODE  downSampleRatioMode,
        uint32_t            segmentIndex
    ); """
ps2000a.make_symbol("_GetMaxDownSampleRatio", "ps2000aGetMaxDownSampleRatio", c_uint32,
                    [c_int16, c_uint32, c_void_p, c_int32, c_uint32], doc)

doc = """ PICO_STATUS ps2000aGetValues
    (
        int16_t             handle,
        uint32_t            startIndex,
        uint32_t           *noOfSamples,
        uint32_t            downSampleRatio,
        PS2000A_RATIO_MODE  downSampleRatioMode,
        uint32_t            segmentIndex,
        int16_t            *overflow
    ); """
ps2000a.make_symbol("_GetValues", "ps2000aGetValues", c_uint32,
                    [c_int16, c_uint32, c_void_p, c_uint32, c_int32, c_uint32, c_void_p], doc)

doc = """ PICO_STATUS ps2000aGetValuesBulk
    (
        int16_t             handle,
        uint32_t           *noOfSamples,
        uint32_t            fromSegmentIndex,
        uint32_t            toSegmentIndex,
        uint32_t            downSampleRatio,
        PS2000A_RATIO_MODE  downSampleRatioMode,
        int16_t            *overflow
    ); """
ps2000a.make_symbol("_GetValuesBulk", "ps2000aGetValuesBulk", c_uint32,
                    [c_int16, c_void_p, c_uint32, c_uint32, c_uint32, c_int32, c_void_p], doc)

doc = """ PICO_STATUS ps2000aGetValuesAsync
    (
        int16_t             handle,
        uint32_t            startIndex,
        uint32_t            noOfSamples,
        uint32_t            downSampleRatio,
        PS2000A_RATIO_MODE  downSampleRatioMode,
        uint32_t            segmentIndex,
        void               *lpDataReady,
        void               *pParameter
    ); """
ps2000a.make_symbol("_GetValuesAsync", "ps2000aGetValuesAsync", c_uint32,
                    [c_int16, c_uint32, c_uint32, c_uint32, c_int32, c_uint32, c_void_p, c_void_p], doc)

doc = """ PICO_STATUS ps2000aGetValuesOverlapped
    (
        int16_t             handle,
        uint32_t            startIndex,
        uint32_t           *noOfSamples,
        uint32_t            downSampleRatio,
        PS2000A_RATIO_MODE  downSampleRatioMode,
        uint32_t            segmentIndex,
        int16_t            *overflow
    ); """
ps2000a.make_symbol("_GetValuesOverlapped", "ps2000aGetValuesOverlapped", c_uint32,
                    [c_int16, c_uint32, c_void_p, c_uint32, c_int32, c_uint32, c_void_p], doc)

doc = """ PICO_STATUS ps2000aGetValuesOverlappedBulk
    (
        int16_t             handle,
        uint32_t            startIndex,
        uint32_t           *noOfSamples,
        uint32_t            downSampleRatio,
        PS2000A_RATIO_MODE  downSampleRatioMode,
        uint32_t            fromSegmentIndex,
        uint32_t            toSegmentIndex,
        int16_t            *overflow
    ); """
ps2000a.make_symbol("_GetValuesOverlappedBulk", "ps2000aGetValuesOverlappedBulk", c_uint32,
                    [c_int16, c_uint32, c_void_p, c_uint32, c_int32, c_uint32, c_int32, c_void_p], doc)

doc = """ PICO_STATUS ps2000aStop
    (
        int16_t  handle
    ); """
ps2000a.make_symbol("_Stop", "ps2000aStop", c_uint32, [c_int16, ], doc)

doc = """ PICO_STATUS ps2000aHoldOff
    (
        int16_t               handle,
        uint64_t              holdoff,
        PS2000A_HOLDOFF_TYPE  type
    ); """
ps2000a.make_symbol("_HoldOff", "ps2000aHoldOff", c_uint32, [c_int16, c_uint64, c_int32], doc)

doc = """ PICO_STATUS ps2000aGetChannelInformation
    (
        int16_t               handle,
        PS2000A_CHANNEL_INFO  info,
        int32_t               probe,
        int32_t              *ranges,
        int32_t              *length,
        int32_t               channels
    ); """
ps2000a.make_symbol("_GetChannelInformation", "ps2000aGetChannelInformation", c_uint32,
                    [c_int16, c_int32, c_int32, c_int32, c_int32, c_int32], doc)

doc = """ PICO_STATUS ps2000aEnumerateUnits
    (
        int16_t *count,
        int8_t  *serials,
        int16_t *serialLth
    ); """
ps2000a.make_symbol("_EnumerateUnits", "ps2000aEnumerateUnits", c_uint32, [c_void_p, c_char_p, c_void_p], doc)

doc = """ PICO_STATUS ps2000aPingUnit
    (
        int16_t  handle
    ); """
ps2000a.make_symbol("_PingUnit", "ps2000aPingUnit", c_uint32, [c_int16, ], doc)

doc = """ PICO_STATUS ps2000aMaximumValue
    (
        int16_t  handle,
        int16_t *value
    ); """
ps2000a.make_symbol("_MaximumValue", "ps2000aMaximumValue", c_uint32, [c_int16, c_void_p], doc)

doc = """ PICO_STATUS ps2000aMinimumValue
    (
        int16_t  handle,
        int16_t *value
    ); """
ps2000a.make_symbol("_MinimumValue", "ps2000aMinimumValue", c_uint32, [c_int16, c_void_p], doc)

doc = """ PICO_STATUS ps2000aGetAnalogueOffset
    (
        int16_t           handle,
        PS2000A_RANGE     range,
        PS2000A_COUPLING  coupling,
        float            *maximumVoltage,
        float            *minimumVoltage
    ); """
ps2000a.make_symbol("_GetAnalogueOffset", "ps2000aGetAnalogueOffset", c_uint32,
                    [c_int16, c_int32, c_int32, c_void_p, c_void_p], doc)

doc = """ PICO_STATUS ps2000aGetMaxSegments
    (
        int16_t   handle,
        uint32_t *maxSegments
    ); """
ps2000a.make_symbol("_GetMaxSegments", "ps2000aGetMaxSegments", c_uint32, [c_int16, c_void_p], doc)

ps2000a.INI_LOGIC_VOLTS = 1.5

doc = """ void *ps2000aBlockReady
    (
        int16_t    handle,
        PICO_STATUS    status,
        void    *pParameter
    );
    define a python function which accepts the correct arguments, and pass it to the constructor of this type.
    """
    
ps2000a.BlockReadyType = C_CALLBACK_FUNCTION_FACTORY(None,
                                                     c_int16,
                                                     c_uint32,
                                                     c_void_p)

ps2000a.BlockReadyType.__doc__ = doc

================================================
FILE: picosdk/ps3000.py
================================================
#
# Copyright (C) 2015-2018 Pico Technology Ltd. See LICENSE file for terms.
#
"""
This is a Python module defining the functions from the ps3000.h C header file
for PicoScope 3000 Series oscilloscopes using the ps3000 driver API functions.
"""

from ctypes import *
from picosdk.library import Library
from picosdk.constants import make_enum


class Ps3000lib(Library):
    def __init__(self):
        super(Ps3000lib, self).__init__("ps3000")


ps3000 = Ps3000lib()

ps3000.PS3000_CHANNEL = make_enum([
    "PS3000_CHANNEL_A",
    "PS3000_CHANNEL_B",
    "PS3000_CHANNEL_C",
    "PS3000_CHANNEL_D",
])

# use the last character, i.e. the channel name:
ps3000.PICO_CHANNEL = {k[-1]: v for k, v in ps3000.PS3000_CHANNEL.items()}

# This field is passed to the driver as a boolean, not an enum.
ps3000.PICO_COUPLING = {
    'AC': 0,
    'DC': 1
}

ps3000.PS3000_VOLTAGE_RANGE = {
    'PS3000_20MV':  1,
    'PS3000_50MV':  2,
    'PS3000_100MV': 3,
    'PS3000_200MV': 4,
    'PS3000_500MV': 5,
    'PS3000_1V':    6,
    'PS3000_2V':    7,
    'PS3000_5V':    8,
    'PS3000_10V':   9,
    'PS3000_20V':   10,
    'PS3000_50V':   11,
    'PS3000_100V':  12,
    'PS3000_200V':  13,
    'PS3000_400V':  14,
}

# float voltage value max (multiplier for output voltages). Parse the value in the constant name.
ps3000.PICO_VOLTAGE_RANGE = {
    v: float(k.split('_')[1][:-1]) if k[-2] != 'M' else (0.001 * float(k.split('_')[1][:-2]))
    for k, v in ps3000.PS3000_VOLTAGE_RANGE.items()
}

doc = """ int16_t ps3000_open_unit
    (
        void
    ); """
ps3000.make_symbol("_open_unit", "ps3000_open_unit", c_int16, [], doc)

doc = """ int16_t ps3000_get_unit_info
    (
        int16_t  handle,
        int8_t  *string,
        int16_t  string_length,
        int16_t  line
    ); """
ps3000.make_symbol("_get_unit_info", "ps3000_get_unit_info", c_int16, [c_int16, c_char_p, c_int16, c_int16], doc)

doc = """ int16_t ps3000_flash_led
    (
        int16_t handle
    ); """
ps3000.make_symbol("_flash_led", "ps3000_flash_led", c_int16, [c_int16, ], doc)

doc = """ int16_t ps3000_close_unit
    (
        int16_t handle
    ); """
ps3000.make_symbol("_close_unit", "ps3000_close_unit", c_int16, [c_int16, ], doc)

doc = """ int16_t ps3000_set_channel
    (
        int16_t  handle,
        int16_t  channel,
        int16_t  enabled,
        int16_t  dc,
        int16_t  range
    ); """
ps3000.make_symbol("_set_channel", "ps3000_set_channel", c_int16, [c_int16, c_int16, c_int16, c_int16, c_int16], doc)

doc = """ int16_t ps3000_get_timebase
    (
        int16_t  handle,
        int16_t  timebase,
        int32_t  no_of_samples,
        int32_t *time_interval,
        int16_t *time_units,
        int16_t  oversample,
        int32_t *max_samples
    ); """
ps3000.make_symbol("_get_timebase", "ps3000_get_timebase", c_int16,
                   [c_int16, c_int16, c_int32, c_void_p, c_void_p, c_int16, c_void_p], doc)

doc = """ int32_t ps3000_set_siggen
    (
        int16_t  handle,
        int16_t  wave_type,
        int32_t  start_frequency,
        int32_t  stop_frequency,
        float    increment,
        int16_t  dwell_time,
        int16_t  repeat,
        int16_t  dual_slope
    ); """
ps3000.make_symbol("_set_siggen", "ps3000_set_siggen", c_int32,
                   [c_int16, c_int16, c_int32, c_int32, c_float, c_int16, c_int16, c_int16], doc)

doc = """ int32_t ps3000_set_ets
    (
        int16_t  handle,
        int16_t  mode,
        int16_t  ets_cycles,
        int16_t  ets_interleave
    ); """
ps3000.make_symbol("_set_ets", "ps3000_set_ets", c_int32, [c_int16, c_int16, c_int16, c_int16], doc)

doc = """ int16_t ps3000_set_trigger
    (
        int16_t  handle,
        int16_t  source,
        int16_t  threshold,
        int16_t  direction,
        int16_t  delay,
        int16_t  auto_trigger_ms
    ); """
ps3000.make_symbol("_set_trigger", "ps3000_set_trigger", c_int16,
                   [c_int16, c_int16, c_int16, c_int16, c_int16, c_int16], doc)

doc = """ int16_t ps3000_set_trigger2
    (
        int16_t  handle,
        int16_t  source,
        int16_t  threshold,
        int16_t  direction,
        float    delay,
        int16_t  auto_trigger_ms
    ); """
ps3000.make_symbol("_set_trigger2", "ps3000_set_trigger2", c_int16,
                   [c_int16, c_int16, c_int16, c_int16, c_float, c_int16], doc)

doc = """ int16_t ps3000_run_block
    (
        int16_t handle,
        int32_t  no_of_values,
        int16_t  timebase,
        int16_t  oversample,
        int32_t * time_indisposed_ms
    ); """
ps3000.make_symbol("_run_block", "ps3000_run_block", c_int16, [c_int16, c_int32, c_int16, c_int16, c_void_p], doc)

doc = """ int16_t ps3000_run_streaming
    (
        int16_t  handle,
        int16_t  sample_interval_ms,
        int32_t  max_samples,
        int16_t  windowed
    ); """
ps3000.make_symbol("_run_streaming", "ps3000_run_streaming", c_int16, [c_int16, c_int16, c_int32, c_int16], doc)

doc = """ int16_t ps3000_run_streaming_ns
    (
        int16_t            handle,
        uint32_t           sample_interval,
        PS3000_TIME_UNITS  time_units,
        uint32_t           max_samples,
        int16_t            auto_stop,
        uint32_t           noOfSamplesPerAggregate,
        uint32_t           overview_buffer_size
    ); """
ps3000.make_symbol("_run_streaming_ns", "ps3000_run_streaming_ns", c_int16,
                   [c_int16, c_uint32, c_int32, c_uint32, c_int16, c_uint32, c_uint32], doc)

doc = """ int16_t ps3000_ready
    (
        int16_t  handle
    ); """
ps3000.make_symbol("_ready", "ps3000_ready", c_int16, [c_int16, ], doc)

doc = """ int16_t ps3000_stop
    (
        int16_t  handle
    ); """
ps3000.make_symbol("_stop", "ps3000_stop", c_int16, [c_int16, ], doc)

doc = """ int32_t ps3000_get_values
    (
        int16_t  handle,
        int16_t *buffer_a,
        int16_t *buffer_b,
        int16_t *buffer_c,
        int16_t *buffer_d,
        int16_t *overflow,
        int32_t  no_of_values
    ); """
ps3000.make_symbol("_get_values", "ps3000_get_values", c_int32,
                   [c_int16, c_void_p, c_void_p, c_void_p, c_void_p, c_void_p, c_int32], doc)

doc = """ void ps3000_release_stream_buffer
    (
        int16_t  handle
    ); """
ps3000.make_symbol("_release_stream_buffer", "ps3000_release_stream_buffer", None, [c_int16, ], doc)

doc = """ int32_t ps3000_get_times_and_values
    (
        int16_t  handle,
        int32_t *times,
        int16_t *buffer_a,
        int16_t *buffer_b,
        int16_t *buffer_c,
        int16_t *buffer_d,
        int16_t *overflow,
        int16_t  time_units,
        int32_t  no_of_values
    ); """
ps3000.make_symbol("_get_times_and_values", "ps3000_get_times_and_values", c_int32,
                   [c_int16, c_void_p, c_void_p, c_void_p, c_void_p, c_void_p, c_void_p, c_int16, c_int32], doc)

doc = """ int16_t ps3000_open_unit_async
    (
        void
    ); """
ps3000.make_symbol("_open_unit_async", "ps3000_open_unit_async", c_int16, [], doc)

doc = """ int16_t ps3000_open_unit_progress
    (
        int16_t *handle,
        int16_t *progress_percent
    ); """
ps3000.make_symbol("_open_unit_progress", "ps3000_open_unit_progress", c_int16, [c_void_p, c_void_p], doc)

doc = """ int16_t ps3000_streaming_ns_get_interval_stateless
    (
        int16_t   handle,
        int16_t   nChannels,
        uint32_t *sample_interval
    ); """
ps3000.make_symbol("_streaming_ns_get_interval_stateless", "ps3000_streaming_ns_get_interval_stateless", c_int16,
                   [c_int16, c_int16, c_void_p], doc)

doc = """ int16_t ps3000_get_streaming_last_values
    (
        int16_t  handle,
        GetOverviewBuffersMaxMin
    ); """
ps3000.make_symbol("_get_streaming_last_values", "ps3000_get_streaming_last_values", c_int16, [c_int16, c_void_p], doc)

doc = """ int16_t ps3000_overview_buffer_status
    (
        int16_t  handle,
        int16_t *previous_buffer_overrun
    ); """
ps3000.make_symbol("_overview_buffer_status", "ps3000_overview_buffer_status", c_int16, [c_int16, c_void_p], doc)

doc = """ uint32_t ps3000_get_streaming_values
    (
        int16_t  handle,
        double   *start_time,
        int16_t  *pbuffer_a_max,
        int16_t  *pbuffer_a_min,
        int16_t  *pbuffer_b_max,
        int16_t  *pbuffer_b_min,
        int16_t  *pbuffer_c_max,
        int16_t  *pbuffer_c_min,
        int16_t  *pbuffer_d_max,
        int16_t  *pbuffer_d_min,
        int16_t  *overflow,
        uint32_t *triggerAt,
        int16_t  *triggered,
        uint32_t  no_of_values,
        uint32_t  noOfSamplesPerAggregate
    ); """
ps3000.make_symbol("_get_streaming_values", "ps3000_get_streaming_values", c_uint32,
                   [c_int16, c_void_p,
                    c_void_p, c_void_p, c_void_p, c_void_p, c_void_p, c_void_p, c_void_p, c_void_p,
                    c_void_p, c_void_p, c_void_p, c_uint32, c_uint32], doc)

doc = """ uint32_t ps3000_get_streaming_values_no_aggregation
    (
        int16_t handle,
        double *start_time,
        int16_t * pbuffer_a,
        int16_t * pbuffer_b,
        int16_t * pbuffer_c,
        int16_t * pbuffer_d,
        int16_t * overflow,
        uint32_t * triggerAt,
        int16_t * trigger,
        uint32_t no_of_values
    ); """
ps3000.make_symbol("_get_streaming_values_no_aggregation", "ps3000_get_streaming_values_no_aggregation", c_uint32,
                   [c_int16, c_void_p,
                    c_void_p, c_void_p, c_void_p, c_void_p,
                    c_void_p, c_void_p, c_void_p, c_uint32], doc)

doc = """ int16_t ps3000_save_streaming_data
    (
        int16_t               handle,
        PS3000_CALLBACK_FUNC  lpCallbackFunc,
        int16_t              *dataBuffers,
        int16_t               dataBufferSize
    ); """
ps3000.make_symbol("_save_streaming_data", "ps3000_save_streaming_data", c_int16,
                   [c_int16, c_void_p, c_void_p, c_int16], doc)

doc = """ int16_t ps3000SetAdvTriggerChannelProperties
    (
        int16_t                            handle,
        PS3000_TRIGGER_CHANNEL_PROPERTIES *channelProperties,
        int16_t                            nChannelProperties,
        int32_t                            autoTriggerMilliseconds
    ); """
ps3000.make_symbol("_SetAdvTriggerChannelProperties", "ps3000SetAdvTriggerChannelProperties", c_int16,
                   [c_int16, c_void_p, c_int16, c_int32], doc)

doc = """ int16_t ps3000SetAdvTriggerChannelConditions
    (
        int16_t                    handle,
        PS3000_TRIGGER_CONDITIONS *conditions,
        int16_t                    nConditions
    ); """
ps3000.make_symbol("_SetAdvTriggerChannelConditions", "ps3000SetAdvTriggerChannelConditions", c_int16,
                   [c_int16, c_void_p, c_int16], doc)

doc = """ int16_t ps3000SetAdvTriggerChannelDirections
    (
        int16_t                     handle,
        PS3000_THRESHOLD_DIRECTION  channelA,
        PS3000_THRESHOLD_DIRECTION  channelB,
        PS3000_THRESHOLD_DIRECTION  channelC,
        PS3000_THRESHOLD_DIRECTION  channelD,
        PS3000_THRESHOLD_DIRECTION  ext
    ); """
ps3000.make_symbol("_SetAdvTriggerChannelDirections", "ps3000SetAdvTriggerChannelDirections", c_int16,
                   [c_int16, c_int32, c_int32, c_int32, c_int32, c_int32], doc)

doc = """ int16_t ps3000SetPulseWidthQualifier
    (
        int16_t                     handle,
        PS3000_PWQ_CONDITIONS      *conditions,
        int16_t                     nConditions,
        PS3000_THRESHOLD_DIRECTION  direction,
        uint32_t                    lower,
        uint32_t                    upper,
        PS3000_PULSE_WIDTH_TYPE     type
    ); """
ps3000.make_symbol("_SetPulseWidthQualifier", "ps3000SetPulseWidthQualifier", c_int16,
                   [c_int16, c_void_p, c_int16, c_int32, c_uint32, c_uint32, c_int32], doc)

doc = """ int16_t ps3000SetAdvTriggerDelay
    (
        int16_t   handle,
        uint32_t  delay,
        float     preTriggerDelay
    ); """
ps3000.make_symbol("_SetAdvTriggerDelay", "ps3000SetAdvTriggerDelay", c_int16, [c_int16, c_uint32, c_float], doc)

doc = """ int16_t ps3000PingUnit
    (
        int16_t  handle
    ); """
ps3000.make_symbol("_PingUnit", "ps3000PingUnit", c_int16, [c_int16, ], doc)

ps3000.PICO_INFO = {k: v for k, v in ps3000.PICO_INFO.items() if v <= 0x00000005}
ps3000.PICO_INFO["PICO_ERROR_CODE"] = 0x00000006


================================================
FILE: picosdk/ps3000a.py
================================================
#
# Copyright (C) 2014-2018 Pico Technology Ltd. See LICENSE file for terms.
#
"""
This is a Python module defining the functions from the ps3000aApi.h C header
file for PicoScope 3000 Series oscilloscopes using the ps3000a driver API
functions.
"""

from ctypes import *
from picosdk.ctypes_wrapper import C_CALLBACK_FUNCTION_FACTORY
from picosdk.library import Library
from picosdk.constants import make_enum


class Ps3000alib(Library):
    def __init__(self):
        super(Ps3000alib, self).__init__("ps3000a")


ps3000a = Ps3000alib()

ps3000a.PS3000A_COUPLING = make_enum([
    'PS3000A_AC',
    'PS3000A_DC',
])

# Just use AC and DC.
ps3000a.PICO_COUPLING = {k[-2:]: v for k, v in ps3000a.PS3000A_COUPLING.items()}

# A tuple in an enum like this is 2 names for the same value.
ps3000a.PS3000A_CHANNEL = make_enum([
    "PS3000A_CHANNEL_A",
    "PS3000A_CHANNEL_B",
    "PS3000A_CHANNEL_C",
    "PS3000A_CHANNEL_D",
    ("PS3000A_EXTERNAL", "PS3000A_MAX_CHANNELS"),
    "PS3000A_TRIGGER_AUX",
    "PS3000A_MAX_TRIGGER_SOURCE",
])

# only include the normal analog channels for now:
ps3000a.PICO_CHANNEL = {k[-1]: v for k, v in ps3000a.PS3000A_CHANNEL.items() if "PS3000A_CHANNEL_" in k}

ps3000a.PS3000A_RANGE = make_enum([
    "PS3000A_10MV",
    "PS3000A_20MV",
    "PS3000A_50MV",
    "PS3000A_100MV",
    "PS3000A_200MV",
    "PS3000A_500MV",
    "PS3000A_1V",
    "PS3000A_2V",
    "PS3000A_5V",
    "PS3000A_10V",
    "PS3000A_20V",
    "PS3000A_50V",
    "PS3000A_MAX_RANGES",
])

ps3000a.PICO_VOLTAGE_RANGE = {
    v: float(k.split('_')[1][:-1]) if k[-2] != 'M' else (0.001 * float(k.split('_')[1][:-2]))
    for k, v in ps3000a.PS3000A_RANGE.items() if k != "PS3000A_MAX_RANGES"
}

ps3000a.PS3000A_RATIO_MODE = {
    'PS3000A_RATIO_MODE_NONE': 0,
    'PS3000A_RATIO_MODE_AGGREGATE': 1,
    'PS3000A_RATIO_MODE_DECIMATE': 2,
    'PS3000A_RATIO_MODE_AVERAGE': 4,
}

ps3000a.PS3000A_TIME_UNITS = make_enum([
    'PS3000A_FS',
    'PS3000A_PS',
    'PS3000A_NS',
    'PS3000A_US',
    'PS3000A_MS',
    'PS3000A_S',
    'PS3000A_MAX_TIME_UNITS',
])

ps3000a.PS3000A_DIGITAL_CHANNEL = make_enum([
    "PS3000A_DIGITAL_CHANNEL_0",
    "PS3000A_DIGITAL_CHANNEL_1",
    "PS3000A_DIGITAL_CHANNEL_2",
    "PS3000A_DIGITAL_CHANNEL_3",
    "PS3000A_DIGITAL_CHANNEL_4",
    "PS3000A_DIGITAL_CHANNEL_5",
    "PS3000A_DIGITAL_CHANNEL_6",
    "PS3000A_DIGITAL_CHANNEL_7",
    "PS3000A_DIGITAL_CHANNEL_8",
    "PS3000A_DIGITAL_CHANNEL_9",
    "PS3000A_DIGITAL_CHANNEL_10",
    "PS3000A_DIGITAL_CHANNEL_11",
    "PS3000A_DIGITAL_CHANNEL_12",
    "PS3000A_DIGITAL_CHANNEL_13",
    "PS3000A_DIGITAL_CHANNEL_14",
    "PS3000A_DIGITAL_CHANNEL_15",
    "PS3000A_DIGITAL_CHANNEL_16",
    "PS3000A_DIGITAL_CHANNEL_17",
    "PS3000A_DIGITAL_CHANNEL_18",
    "PS3000A_DIGITAL_CHANNEL_19",
    "PS3000A_DIGITAL_CHANNEL_20",
    "PS3000A_DIGITAL_CHANNEL_21",
    "PS3000A_DIGITAL_CHANNEL_22",
    "PS3000A_DIGITAL_CHANNEL_23",
    "PS3000A_DIGITAL_CHANNEL_24",
    "PS3000A_DIGITAL_CHANNEL_25",
    "PS3000A_DIGITAL_CHANNEL_26",
    "PS3000A_DIGITAL_CHANNEL_27",
    "PS3000A_DIGITAL_CHANNEL_28",
    "PS3000A_DIGITAL_CHANNEL_29",
    "PS3000A_DIGITAL_CHANNEL_30",
    "PS3000A_DIGITAL_CHANNEL_31",
    "PS3000A_MAX_DIGITAL_CHANNELS"
])

ps3000a.PS3000A_DIGITAL_DIRECTION = make_enum([
    "PS3000A_DIGITAL_DONT_CARE",
    "PS3000A_DIGITAL_DIRECTION_LOW",
    "PS3000A_DIGITAL_DIRECTION_HIGH",
    "PS3000A_DIGITAL_DIRECTION_RISING",
    "PS3000A_DIGITAL_DIRECTION_FALLING",
    "PS3000A_DIGITAL_DIRECTION_RISING_OR_FALLING",
    "PS3000A_DIGITAL_MAX_DIRECTION"
])

def _define_digital_port():
    PS3000A_DIGITAL_PORT0 = 0x80
    PS3000A_DIGITAL_PORT1 = PS3000A_DIGITAL_PORT0 + 1
    PS3000A_DIGITAL_PORT2 = PS3000A_DIGITAL_PORT0 + 2
    PS3000A_DIGITAL_PORT3 = PS3000A_DIGITAL_PORT0 + 3
    PS3000A_MAX_DIGITAL_PORTS = (PS3000A_DIGITAL_PORT3 - PS3000A_DIGITAL_PORT0) + 1

    return {k.upper(): v for k, v in locals().items() if k.startswith("PS3000A")}

ps3000a.PS3000A_DIGITAL_PORT = _define_digital_port()

ps3000a.PS3000A_TRIGGER_STATE = make_enum([
    "PS3000A_CONDITION_DONT_CARE",
    "PS3000A_CONDITION_TRUE",
    "PS3000A_CONDITION_FALSE",
    "PS3000A_CONDITION_MAX"
    ])
    
ps3000a.PS3000A_THRESHOLD_DIRECTION = make_enum([
    ("PS3000A_ABOVE", "PS3000A_INSIDE"),
    ("PS3000A_BELOW", "PS3000A_OUTSIDE","PS3000A_NONE"),
    ("PS3000A_RISING", "PS3000A_ENTER"),
    ("PS3000A_FALLING", "PS3000A_EXIT"),
    ("PS3000A_RISING_OR_FALLING", "PS3000A_ENTER_OR_EXIT"),
    "PS3000A_ABOVE_LOWER",
    "PS3000A_BELOW_LOWER",
    "PS3000A_RISING_LOWER",
    "PS3000A_FALLING_LOWER",
    "PS3000A_POSITIVE_RUNT",
    "PS3000A_NEGATIVE_RUNT"
    ])
    
ps3000a.PS3000A_THRESHOLD_MODE = make_enum([
    "PS3000A_LEVEL",
    "PS3000A_WINDOW"
    ])

class PS3000A_DIGITAL_CHANNEL_DIRECTIONS(Structure):
    _pack_ = 1
    _fields_ = [("channel", c_int32),
                ("direction", c_int32)]
                
ps3000a.PS3000A_DIGITAL_CHANNEL_DIRECTIONS = PS3000A_DIGITAL_CHANNEL_DIRECTIONS
                
class PS3000A_TRIGGER_CONDITIONS(Structure):
    _pack_ = 1
    _fields_ = [("channelA", c_uint32),
                ("channelB", c_uint32),
                ("channelC", c_uint32),
                ("channelD", c_uint32),
                ("external", c_uint32),
                ("aux", c_uint32),
                ("pulseWidthQualifier", c_uint32)]

ps3000a.PS3000A_TRIGGER_CONDITIONS = PS3000A_TRIGGER_CONDITIONS
                
class PS3000A_TRIGGER_CONDITIONS_V2(Structure):
    _pack_ = 1
    _fields_ = [("channelA", c_uint32),
                ("channelB", c_uint32),
                ("channelC", c_uint32),
                ("channelD", c_uint32),
                ("external", c_uint32),
                ("aux", c_uint32),
                ("pulseWidthQualifier", c_uint32),
                ("digital", c_uint32)]
ps3000a.PS3000A_TRIGGER_CONDITIONS_V2 = PS3000A_TRIGGER_CONDITIONS_V2
                
class PS3000A_TRIGGER_CHANNEL_PROPERTIES(Structure):
    _pack_ = 1
    _fields_ = [("thresholdUpper", c_int16),
                ("thresholdUpperHysteresis", c_uint16),
                ("thresholdLower", c_int16),
                ("thresholdLowerHysteresis", c_uint16),
                ("channel", c_uint32),
                ("thresholdMode", c_uint32)]
ps3000a.PS3000A_TRIGGER_CHANNEL_PROPERTIES = PS3000A_TRIGGER_CHANNEL_PROPERTIES
                
doc = """ PICO_STATUS ps3000aOpenUnit
    (
        int16_t *handle,
        int8_t  *serial
    ); """
ps3000a.make_symbol("_OpenUnit", "ps3000aOpenUnit", c_uint32, [c_void_p, c_char_p], doc)

doc = """ PICO_STATUS ps3000aOpenUnitAsync
    (
        int16_t *status,
        int8_t  *serial
    ); """
ps3000a.make_symbol("_OpenUnitAsync", "ps3000aOpenUnitAsync", c_uint32, [c_void_p, c_char_p], doc)

doc = """ PICO_STATUS ps3000aOpenUnitProgress
    (
        int16_t *handle,
        int16_t *progressPercent,
        int16_t *complete
    ); """
ps3000a.make_symbol("_OpenUnitProgress", "ps3000aOpenUnitProgress", c_uint32, [c_void_p, c_void_p, c_void_p], doc)

doc = """ PICO_STATUS ps3000aGetUnitInfo
    (
        int16_t    handle,
        int8_t    *string,
        int16_t    stringLength,
        int16_t   *requiredSize,
        PICO_INFO  info
    ); """
ps3000a.make_symbol("_GetUnitInfo", "ps3000aGetUnitInfo", c_uint32, [c_int16, c_char_p, c_int16, c_void_p, c_uint32],
                    doc)

doc = """ PICO_STATUS ps3000aFlashLed
    (
        int16_t  handle,
        int16_t  start
    ); """
ps3000a.make_symbol("_FlashLed", "ps3000aFlashLed", c_uint32, [c_int16, c_int16], doc)

doc = """ PICO_STATUS ps3000aCloseUnit
    (
        int16_t  handle
    ); """
ps3000a.make_symbol("_CloseUnit", "ps3000aCloseUnit", c_uint32, [c_int16, ], doc)

doc = """ PICO_STATUS ps3000aMemorySegments
    (
        int16_t   handle,
        uint32_t  nSegments,
        int32_t  *nMaxSamples
    ); """
ps3000a.make_symbol("_MemorySegments", "ps3000aMemorySegments", c_uint32, [c_int16, c_uint32, c_void_p], doc)

doc = """ PICO_STATUS ps3000aSetChannel
    (
        int16_t          handle,
        PS3000a_CHANNEL  channel,
        int16_t          enabled,
        PS3000a_COUPLING type,
        PS3000a_RANGE    range,
        float            analogOffset
    ); """
ps3000a.make_symbol("_SetChannel", "ps3000aSetChannel", c_uint32,
                    [c_int16, c_int32, c_int16, c_int32, c_int32, c_float], doc)

doc = """ PICO_STATUS ps3000aSetDigitalPort
    (
        int16_t              handle,
        PS3000a_DIGITAL_PORT port,
        int16_t              enabled,
        int16_t              logicLevel
    ); """
ps3000a.make_symbol("_SetDigitalPort", "ps3000aSetDigitalPort", c_uint32, [c_int16, c_int32, c_int16, c_int16], doc)

doc = """ PICO_STATUS ps3000aSetBandwidthFilter
    (
        int16_t                    handle,
        PS3000A_CHANNEL            channel,
        PS3000A_BANDWIDTH_LIMITER  bandwidth
    ); """
ps3000a.make_symbol("_SetBandwidthFilter", "ps3000aSetBandwidthFilter", c_uint32, [c_int16, c_int32, c_int32], doc)

doc = """ PICO_STATUS ps3000aSetNoOfCaptures
    (
        int16_t   handle,
        uint32_t  nCaptures
    ); """
ps3000a.make_symbol("_SetNoOfCaptures", "ps3000aSetNoOfCaptures", c_uint32, [c_int16, c_uint32], doc)

doc = """ PICO_STATUS ps3000aGetTimebase
    (
        int16_t   handle,
        uint32_t  timebase,
        int32_t   noSamples,
        int32_t  *timeIntervalNanoseconds,
        int16_t   oversample,
        int32_t  *maxSamples,
        uint32_t  segmentIndex
    ); """
ps3000a.make_symbol("_GetTimebase", "ps3000aGetTimebase", c_uint32,
                    [c_int16, c_uint32, c_int32, c_void_p, c_int16, c_void_p, c_uint32], doc)


doc = """ PICO_STATUS ps3000aGetTimebase2
    (
        int16_t  handle,
        uint32_t timebase,
        int32_t  noSamples,
        float   *timeIntervalNanoseconds,
        int16_t  oversample,
        int32_t *maxSamples,
        uint32_t segmentIndex
    ); """
ps3000a.make_symbol("_GetTimebase2", "ps3000aGetTimebase2", c_uint32,
                    [c_int16, c_uint32, c_int32, c_void_p, c_int16, c_void_p, c_uint32], doc)

doc = """ PICO_STATUS ps3000aSetSigGenArbitrary
    (
        int16_t                     handle,
        int32_t                     offsetVoltage,
        uint32_t                    pkToPk,
        uint32_t                    startDeltaPhase,
        uint32_t                    stopDeltaPhase,
        uint32_t                    deltaPhaseIncrement,
        uint32_t                    dwellCount,
        int16_t                    *arbitraryWaveform,
        int32_t                     arbitraryWaveformSize,
        PS3000A_SWEEP_TYPE          sweepType,
        PS3000A_EXTRA_OPERATIONS    operation,
        PS3000A_INDEX_MODE          indexMode,
        uint32_t                    shots,
        uint32_t                    sweeps,
        PS3000A_SIGGEN_TRIG_TYPE    triggerType,
        PS3000A_SIGGEN_TRIG_SOURCE  triggerSource,
        int16_t                     extInThreshold
    ); """
ps3000a.make_symbol("_SetSigGenArbitrary", "ps3000aSetSigGenArbitrary", c_uint32,
                    [c_int16, c_int32, c_uint32, c_uint32, c_uint32, c_uint32, c_uint32, c_void_p, c_int32, c_int32,
                     c_int32,
                     c_int32, c_uint32, c_uint32, c_int32, c_int32, c_int16], doc)

doc = """ PICO_STATUS ps3000aSetSigGenBuiltIn
    (
        int16_t                     handle,
        int32_t                     offsetVoltage,
        uint32_t                    pkToPk,
        int16_t                     waveType,
        float                       startFrequency,
        float                       stopFrequency,
        float                       increment,
        float                       dwellTime,
        PS3000A_SWEEP_TYPE          sweepType,
        PS3000A_EXTRA_OPERATIONS    operation,
        uint32_t                    shots,
        uint32_t                    sweeps,
        PS3000A_SIGGEN_TRIG_TYPE    triggerType,
        PS3000A_SIGGEN_TRIG_SOURCE  triggerSource,
        int16_t                     extInThreshold
    ); """
ps3000a.make_symbol("_SetSigGenBuiltIn", "ps3000aSetSigGenBuiltIn", c_uint32,
                    [c_int16, c_int32, c_uint32, c_int16, c_float, c_float, c_float, c_float, c_int32, c_int32,
                     c_uint32,
                     c_uint32, c_int32, c_int32, c_int16], doc)

doc = """ PICO_STATUS ps3000aSetSigGenPropertiesArbitrary
    (
        int16_t                     handle,
        uint32_t                    startDeltaPhase,
        uint32_t                    stopDeltaPhase,
        uint32_t                    deltaPhaseIncrement,
        uint32_t                    dwellCount,
        PS3000A_SWEEP_TYPE          sweepType,
        uint32_t                    shots,
        uint32_t                    sweeps,
        PS3000A_SIGGEN_TRIG_TYPE    triggerType,
        PS3000A_SIGGEN_TRIG_SOURCE  triggerSource,
        int16_t                     extInThreshold
    ); """
ps3000a.make_symbol("_SetSigGenPropertiesArbitrary", "ps3000aSetSigGenPropertiesArbitrary", c_uint32,
                    [c_int16, c_uint32, c_uint32, c_uint32, c_uint32, c_int32, c_uint32, c_uint32, c_int32, c_int32,
                     c_int16], doc)

doc = """ PICO_STATUS ps3000aSetSigGenPropertiesBuiltIn
    (
        int16_t                     handle,
        double                      startFrequency,
        double                      stopFrequency,
        double                      increment,
        double                      dwellTime,
        PS3000A_SWEEP_TYPE          sweepType,
        uint32_t                    shots,
        uint32_t                    sweeps,
        PS3000A_SIGGEN_TRIG_TYPE    triggerType,
        PS3000A_SIGGEN_TRIG_SOURCE  triggerSource,
        int16_t                     extInThreshold
    ); """
ps3000a.make_symbol("_SetSigGenPropertiesBuiltIn", "ps3000aSetSigGenPropertiesBuiltIn", c_uint32,
                    [c_int16, c_double, c_double, c_double, c_double, c_int32, c_uint32, c_uint32, c_int32, c_int32,
                     c_int16], doc)

doc = """ PICO_STATUS ps3000aSigGenFrequencyToPhase
    (
        int16_t             handle,
        double              frequency,
        PS3000A_INDEX_MODE  indexMode,
        uint32_t            bufferLength,
        uint32_t           *phase
    ); """
ps3000a.make_symbol("_SigGenFrequencyToPhase", "ps3000aSigGenFrequencyToPhase", c_uint32,
                    [c_int16, c_double, c_int32, c_uint32, c_void_p], doc)

doc = """ PICO_STATUS ps3000aSigGenArbitraryMinMaxValues
    (
        int16_t   handle,
        int16_t  *minArbitraryWaveformValue,
        int16_t  *maxArbitraryWaveformValue,
        uint32_t *minArbitraryWaveformSize,
        uint32_t *maxArbitraryWaveformSize
    ); """
ps3000a.make_symbol("_SigGenArbitraryMinMaxValues", "ps3000aSigGenArbitraryMinMaxValues", c_uint32,
                    [c_int16, c_void_p, c_void_p, c_void_p, c_void_p], doc)

doc = """ PICO_STATUS ps3000aGetMaxEtsValues
    (
        int16_t  handle,
        int16_t *etsCycles,
        int16_t *etsInterleave
    ); """
ps3000a.make_symbol("_GetMaxEtsValues", "ps3000aGetMaxEtsValues", c_uint32, [c_int16, c_void_p, c_void_p], doc)

doc = """ PICO_STATUS ps3000aSigGenSoftwareControl
    (
        int16_t  handle,
        int16_t  state
    ); """
ps3000a.make_symbol("_SigGenSoftwareControl", "ps3000aSigGenSoftwareControl", c_uint32, [c_int16, c_int16], doc)

doc = """ PICO_STATUS ps3000aSetEts
    (
        int16_t           handle,
        PS3000A_ETS_MODE  mode,
        int16_t           etsCycles,
        int16_t           etsInterleave,
        int32_t          *sampleTimePicoseconds
    ); """
ps3000a.make_symbol("_SetEts", "ps3000aSetEts", c_uint32, [c_int16, c_int32, c_int16, c_int16, c_void_p], doc)

doc = """ PICO_STATUS ps3000aSetSimpleTrigger
    (
        int16_t                      handle,
        int16_t                      enable,
        PS3000A_CHANNEL              source,
        int16_t                      threshold,
        PS3000A_THRESHOLD_DIRECTION  direction,
        uint32_t                     delay,
        int16_t                      autoTrigger_ms
    ); """
ps3000a.make_symbol("_SetSimpleTrigger", "ps3000aSetSimpleTrigger", c_uint32,
                    [c_int16, c_int16, c_int32, c_int16, c_int32, c_uint32, c_int16], doc)

doc = """ PICO_STATUS ps3000aSetTriggerDigitalPortProperties
    (
        int16_t                             handle,
        PS3000A_DIGITAL_CHANNEL_DIRECTIONS *directions,
        int16_t                             nDirections
    ); """
ps3000a.make_symbol("_SetTriggerDigitalPortProperties", "ps3000aSetTriggerDigitalPortProperties", c_uint32,
                    [c_int16, c_void_p, c_int16], doc)

doc = """ PICO_STATUS ps3000aSetPulseWidthDigitalPortProperties
    (
        int16_t                             handle,
        P
Download .txt
gitextract_5m9lzjjf/

├── .github/
│   ├── CODE_OF_CONDUCT.md
│   ├── CONTRIBUTING.md
│   ├── PULL_REQUEST_TEMPLATE.md
│   └── issue_template.md
├── .gitignore
├── LICENSE.md
├── README.md
├── discontinuedExamples/
│   └── anyScopeExamples/
│       └── block.py
├── picohrdlExamples/
│   ├── picohrdlSingleModeExample.py
│   └── picohrdlStreamingModeExample.py
├── picosdk/
│   ├── PicoConnectProbes.py
│   ├── PicoDeviceEnums.py
│   ├── PicoDeviceStructs.py
│   ├── __init__.py
│   ├── constants.py
│   ├── ctypes_wrapper.py
│   ├── device.py
│   ├── discover.py
│   ├── errors.py
│   ├── functions.py
│   ├── functionsExhibitions.py
│   ├── library.py
│   ├── picoMeasurements.py
│   ├── picohrdl.py
│   ├── picosynth.py
│   ├── pl1000.py
│   ├── ps2000.py
│   ├── ps2000a.py
│   ├── ps3000.py
│   ├── ps3000a.py
│   ├── ps4000.py
│   ├── ps4000a.py
│   ├── ps5000.py
│   ├── ps5000a.py
│   ├── ps6000.py
│   ├── ps6000a.py
│   ├── psospa.py
│   ├── psospaBlockExample.py
│   ├── usbDrDaq.py
│   ├── usbPT104.py
│   └── usbtc08.py
├── picosynthExamples/
│   └── picosynthFrequencySweepExample.py
├── pl1000Examples/
│   ├── pl1000SingleModeExample.py
│   ├── pl1000StreamingModeExample.py
│   └── pl1000StreamingModeMultiChannelExample.py
├── ps2000Examples/
│   ├── advanced triggers/
│   │   ├── trigger_read_dropout.py
│   │   ├── trigger_read_interval.py
│   │   ├── trigger_read_pwq.py
│   │   ├── trigger_read_runt.py
│   │   ├── trigger_read_window.py
│   │   └── trigger_read_wpwq.py
│   ├── block_read.py
│   ├── device_info.py
│   ├── gen_sq_wave.py
│   ├── ps2000BlockExample.py
│   ├── ps2000ETSBlockExample.py
│   ├── ps2000SigGen.py
│   └── streaming_mode/
│       ├── streaming_mode.py
│       ├── streaming_mode_gathering.py
│       ├── streaming_mode_polling.py
│       └── streaming_mode_threaded.py
├── ps2000aExamples/
│   ├── ps2000aBlockAdvancedEdgeExample.py
│   ├── ps2000aBlockExample.py
│   ├── ps2000aBlockExampleCallbackMethod.py
│   ├── ps2000aMSOBlockExample.py
│   ├── ps2000aRapidBlockExample.py
│   ├── ps2000aSigGen.py
│   └── ps2000aStreamingExample.py
├── ps3000EExamples/
│   ├── ps3000EBlockExample.py
│   ├── ps3000ERapidBlockExample.py
│   └── ps3000EStreamingModeExample.py
├── ps3000aExamples/
│   ├── ps3000aBlockAdvancedTriggerExample.py
│   ├── ps3000aBlockExample.py
│   ├── ps3000aBlockMSOExample.py
│   ├── ps3000aRapidBlockExample.py
│   ├── ps3000aSigGen.py
│   └── ps3000aStreamingExample.py
├── ps4000Examples/
│   ├── ps4000BlockExample.py
│   └── ps4000StreamingExample.py
├── ps4000aExamples/
│   ├── ps4000 Ch4 AND logic triggering.py
│   ├── ps4000aBlockAdvancedEdgeTriggerExample.py
│   ├── ps4000aBlockDropoutTriggerExample.py
│   ├── ps4000aBlockFrequencyCounterExample.py
│   ├── ps4000aRapidBlockExample.py
│   ├── ps4000aRapidBlockWaveformAveragingExample.py
│   ├── ps4000aSigGen.py
│   ├── ps4000aStreamingExample.py
│   ├── ps4000a_Runt_trigger.py
│   ├── ps4444BlockExample.py
│   ├── ps4444BlockPicoConnectProbesExample.py
│   └── ps4824BlockExample.py
├── ps5000Examples/
│   ├── ps5000BlockExample.py
│   ├── ps5000RapidBlockExample.py
│   └── ps5000StreamingExample.py
├── ps5000aExamples/
│   ├── ps5000aBlockAdvancedTriggerExample.py
│   ├── ps5000aBlockCallbackExample.py
│   ├── ps5000aBlockExample.py
│   ├── ps5000aBlockLevelPulseWidthAdvancedTriggerExample.py
│   ├── ps5000aBlockMSOExample.py
│   ├── ps5000aBlockMSOTriggerExample.py
│   ├── ps5000aBlockWindowPulseWidthAdvancedTriggerExample.py
│   ├── ps5000aRapidBlockExample.py
│   ├── ps5000aSigGen.py
│   └── ps5000aStreamingExample.py
├── ps6000Examples/
│   ├── ps6000BlockAdvancedTriggerExample.py
│   ├── ps6000BlockExample.py
│   ├── ps6000GetInfoExample.py
│   ├── ps6000RapidBlockExample.py
│   ├── ps6000RapidBlockTriggerTimestampExample.py
│   ├── ps6000SigGen.py
│   └── ps6000StreamingExample.py
├── ps6000aExamples/
│   ├── ps6000aBlockAdvancedTriggerExample.py
│   ├── ps6000aBlockExample.py
│   ├── ps6000aBlockExampleExtClk.py
│   ├── ps6000aBlockExampleTrigTimes.py
│   ├── ps6000aBlockMSODigitalTriggerExample.py
│   ├── ps6000aBlockMSOExample.py
│   ├── ps6000aBlock_both_MSOExample.py
│   ├── ps6000aGetUnitInfo.py
│   ├── ps6000aRapidBlockExample.py
│   ├── ps6000aSigGenExample.py
│   └── ps6000aStreamingModeExample.py
├── pt104Examples/
│   ├── pt104DirectEthernet.py
│   ├── pt104EnumerateTestsExample.py
│   └── pt104Example.py
├── requirements-for-examples.txt
├── requirements.txt
├── setup.py
├── setupPicosynth.py
├── test/
│   ├── __init__.py
│   ├── run_examples.sh
│   ├── test_discover.py
│   ├── test_get_unit_info.py
│   ├── test_helpers.py
│   ├── test_open_close_unit.py
│   ├── test_set_channel.py
│   └── test_timebase.py
├── usbdrdaqExamples/
│   ├── usbdrdaqPhBlockExample.py
│   └── usbdrdaqScopeBlockExample.py
└── usbtc08Examples/
    ├── tc08SingleModeExample.py
    ├── tc08StreamingModeExample.py
    └── tc08StreamingModeMultiChExample.py
Download .txt
SYMBOL INDEX (299 symbols across 59 files)

FILE: picosdk/PicoConnectProbes.py
  class PicoConnectProbeslib (line 13) | class PicoConnectProbeslib(Library):
    method __init__ (line 14) | def __init__(self):
  function _define_pico_probe_range_info (line 20) | def _define_pico_probe_range_info():

FILE: picosdk/PicoDeviceEnums.py
  class PicoEnumlib (line 14) | class PicoEnumlib(Library):
    method __init__ (line 15) | def __init__(self):
  function _define_ratio_mode (line 21) | def _define_ratio_mode():
  function _define_channel (line 36) | def _define_channel():
  function _define_channel_flags (line 58) | def _define_channel_flags():
  function _define_coupling (line 95) | def _define_coupling():
  function _define_bandwidth_limiter (line 107) | def _define_bandwidth_limiter():
  function _define_wave_type (line 138) | def _define_wave_type():
  function _define_threshold_direction (line 194) | def _define_threshold_direction():
  function _define_action (line 230) | def _define_action():
  function _define_resolution (line 247) | def _define_resolution():
  function _define_conditions_info (line 290) | def _define_conditions_info():
  function _define_digital_port (line 316) | def _define_digital_port():
  function _define_power_delivery_device_type (line 333) | def _define_power_delivery_device_type():

FILE: picosdk/PicoDeviceStructs.py
  class PicoStructlib (line 13) | class PicoStructlib(Library):
    method __init__ (line 14) | def __init__(self):
  class PICO_TRIGGER_INFO (line 20) | class PICO_TRIGGER_INFO(Structure):
  class PICO_TRIGGER_CHANNEL_PROPERTIES (line 32) | class PICO_TRIGGER_CHANNEL_PROPERTIES(Structure):
  class PICO_CONDITION (line 42) | class PICO_CONDITION(Structure):
  class PICO_DIRECTION (line 49) | class PICO_DIRECTION(Structure):
  class PICO_USER_PROBE_INTERACTIONS (line 57) | class PICO_USER_PROBE_INTERACTIONS(Structure):
  class PICO_DATA_BUFFERS (line 78) | class PICO_DATA_BUFFERS(Structure):
  class PICO_STREAMING_DATA_INFO (line 91) | class PICO_STREAMING_DATA_INFO(Structure):
  class PICO_STREAMING_DATA_TRIGGER_INFO (line 103) | class PICO_STREAMING_DATA_TRIGGER_INFO(Structure):
  class PICO_SCALING_FACTORS (line 111) | class PICO_SCALING_FACTORS(Structure):
  class PICO_SCALING_FACTORS_FOR_RANGE_TYPES (line 120) | class PICO_SCALING_FACTORS_FOR_RANGE_TYPES(Structure):
  class PROBE_APP (line 131) | class PROBE_APP(Structure):
  class DIGITAL_CHANNEL_DIRECTIONS (line 139) | class DIGITAL_CHANNEL_DIRECTIONS(Structure):
  class PICO_DIGITAL_PORT_INTERACTIONS (line 146) | class PICO_DIGITAL_PORT_INTERACTIONS(Structure):
  class PICO_CHANNEL_OVERVOLTAGE_TRIPPED (line 157) | class PICO_CHANNEL_OVERVOLTAGE_TRIPPED(Structure):
  class PICO_USB_POWER_DELIVERY (line 164) | class PICO_USB_POWER_DELIVERY(Structure):
  class PICO_USB_POWER_DETAILS (line 178) | class PICO_USB_POWER_DETAILS(Structure):

FILE: picosdk/constants.py
  function pico_tag (line 14) | def pico_tag(number):
  function pico_num (line 22) | def pico_num(tag):
  function make_enum (line 30) | def make_enum(members):

FILE: picosdk/device.py
  function requires_open (line 18) | def requires_open(error_message="This operation requires a device to be ...
  class Device (line 52) | class Device(object):
    method __init__ (line 57) | def __init__(self, driver, handle):
    method close (line 67) | def close(self):
    method info (line 74) | def info(self):
    method __enter__ (line 77) | def __enter__(self):
    method __exit__ (line 80) | def __exit__(self, *args):
    method set_channel (line 87) | def set_channel(self, channel_config):
    method set_channels (line 110) | def set_channels(self, *channel_configs):
    method _timebase_options_are_impossible (line 126) | def _timebase_options_are_impossible(self, options):
    method _validate_timebase (line 145) | def _validate_timebase(timebase_options, timebase_info):
    method find_timebase (line 159) | def find_timebase(self, timebase_options):
    method capture_block (line 185) | def capture_block(self, timebase_options, channel_configs=()):

FILE: picosdk/discover.py
  function find_unit (line 30) | def find_unit():
  function find_all_units (line 41) | def find_all_units():

FILE: picosdk/errors.py
  class PicoError (line 6) | class PicoError(Exception):
  class FeatureNotSupportedError (line 11) | class FeatureNotSupportedError(PicoError):
  class CannotFindPicoSDKError (line 16) | class CannotFindPicoSDKError(PicoError, IOError):
  class CannotOpenPicoSDKError (line 20) | class CannotOpenPicoSDKError(PicoError, IOError):
  class DeviceNotFoundError (line 24) | class DeviceNotFoundError(PicoError, IOError):
  class ArgumentOutOfRangeError (line 28) | class ArgumentOutOfRangeError(PicoError, ValueError):
  class ValidRangeEnumValueNotValidForThisDevice (line 32) | class ValidRangeEnumValueNotValidForThisDevice(FeatureNotSupportedError,...
  class DeviceCannotSegmentMemoryError (line 36) | class DeviceCannotSegmentMemoryError(FeatureNotSupportedError, TypeError):
  class InvalidMemorySegmentsError (line 40) | class InvalidMemorySegmentsError(PicoError, ValueError):
  class InvalidTimebaseError (line 44) | class InvalidTimebaseError(PicoError, ValueError):
  class InvalidTriggerParameters (line 48) | class InvalidTriggerParameters(PicoError, ValueError):
  class InvalidCaptureParameters (line 52) | class InvalidCaptureParameters(PicoError, ValueError):
  class PicoSDKCtypesError (line 56) | class PicoSDKCtypesError(PicoError, IOError):
  class ClosedDeviceError (line 60) | class ClosedDeviceError(PicoError, IOError):
  class NoChannelsEnabledError (line 64) | class NoChannelsEnabledError(PicoError, ValueError):
  class NoValidTimebaseForOptionsError (line 68) | class NoValidTimebaseForOptionsError(PicoError, ValueError):
  class UnknownConstantError (line 72) | class UnknownConstantError(PicoError, TypeError):

FILE: picosdk/functions.py
  function adc2mV (line 10) | def adc2mV(bufferADC, range, maxADC):
  function adc2mVpl1000 (line 27) | def adc2mVpl1000(bufferADC, range, maxADC):
  function mV2adc (line 42) | def mV2adc(millivolts, range, maxADC):
  function mV2adcpl1000 (line 57) | def mV2adcpl1000(millivolts, range, maxADC):
  function splitMSOData (line 71) | def splitMSOData(dataLength, data):
  function splitMSODataFast (line 120) | def splitMSODataFast(dataLength, data):
  function assert_pico_ok (line 152) | def assert_pico_ok(status):
  function assert_pico2000_ok (line 163) | def assert_pico2000_ok(status):
  function mV2adcV2 (line 176) | def mV2adcV2(millivolts, rangeMax, maxADC):
  function adc2mVV2 (line 189) | def adc2mVV2(bufferADC, rangeMax, maxADC):

FILE: picosdk/functionsExhibitions.py
  function dataImporter (line 12) | def dataImporter(name):
  function ps6000aTimebase (line 26) | def ps6000aTimebase(samplingRate):
  function ps5000aTimebase (line 39) | def ps5000aTimebase(samplingRate):
  function ps3000aTimebase (line 52) | def ps3000aTimebase(samplingRate):
  function ps4000aTimebase (line 65) | def ps4000aTimebase(samplingRate):
  function ps2000aTimebase (line 71) | def ps2000aTimebase(samplingRate):
  function ps2000Timebase (line 84) | def ps2000Timebase(sampleRate):
  function BitEnumSelector (line 95) | def BitEnumSelector(bits):
  function saveConfigFile (line 106) | def saveConfigFile(channels, bits, sampleRate,captureLength, segments):
  function loadConfigValues (line 123) | def loadConfigValues():
  function copyFile (line 136) | def copyFile(source_directory, filename):

FILE: picosdk/library.py
  function requires_device (line 36) | def requires_device(error_message="This method requires a Device instanc...
  class Library (line 46) | class Library(object):
    method __init__ (line 47) | def __init__(self, name):
    method _load (line 66) | def _load(self):
    method __str__ (line 90) | def __str__(self):
    method make_symbol (line 93) | def make_symbol(self, python_name, c_name, return_type, argument_types...
    method list_units (line 115) | def list_units(self):
    method open_unit (line 132) | def open_unit(self, serial=None, resolution=None):
    method close_unit (line 143) | def close_unit(self, device):
    method get_unit_info (line 147) | def get_unit_info(self, device, *args):
    method _python_open_unit (line 150) | def _python_open_unit(self, serial=None, resolution=None):
    method _python_open_any_unit (line 165) | def _python_open_any_unit(self, resolution):
    method _python_open_specific_unit (line 184) | def _python_open_specific_unit(self, serial, resolution):
    method _python_close_unit (line 218) | def _python_close_unit(self, handle):
    method _create_empty_string_buffer (line 222) | def _create_empty_string_buffer():
    method _python_get_unit_info (line 228) | def _python_get_unit_info(self, handle, info_type):
    method _python_get_unit_info_wrapper (line 247) | def _python_get_unit_info_wrapper(self, handle, keys):
    method set_channel (line 273) | def set_channel(self, device, channel_name='A', enabled=True, coupling...
    method _resolve_range (line 310) | def _resolve_range(self, signal_peak, exclude=()):
    method _python_set_channel (line 323) | def _python_set_channel(self, handle, channel_id, enabled, coupling_id...
    method memory_segments (line 368) | def memory_segments(self, device, number_segments):
    method get_timebase (line 379) | def get_timebase(self, device, timebase_id, no_of_samples, oversample=...
    method _python_get_timebase (line 394) | def _python_get_timebase(self, handle, timebase_id, no_of_samples, ove...
    method set_null_trigger (line 431) | def set_null_trigger(self, device):
    method run_block (line 458) | def run_block(self, device, pre_trigger_samples, post_trigger_samples,...
    method _python_run_block (line 468) | def _python_run_block(self, handle, pre_samples, post_samples, timebas...
    method is_ready (line 496) | def is_ready(self, device):
    method maximum_value (line 512) | def maximum_value(self, device):
    method get_values (line 520) | def get_values(self, device, active_channels, num_samples, segment_ind...
    method stop (line 572) | def stop(self, device):

FILE: picosdk/picohrdl.py
  class picohrdllib (line 14) | class picohrdllib(Library):
    method __init__ (line 15) | def __init__(self):

FILE: picosdk/picosynth.py
  class Picosynthlib (line 14) | class Picosynthlib(Library):
    method __init__ (line 15) | def __init__(self):

FILE: picosdk/pl1000.py
  class Pl1000lib (line 14) | class Pl1000lib(Library):
    method __init__ (line 15) | def __init__(self):
  function _pl1000Inputs (line 20) | def _pl1000Inputs():

FILE: picosdk/ps2000.py
  class Ps2000lib (line 16) | class Ps2000lib(Library):
    method __init__ (line 17) | def __init__(self):

FILE: picosdk/ps2000a.py
  class Ps2000alib (line 15) | class Ps2000alib(Library):
    method __init__ (line 16) | def __init__(self):
  function _define_threshold_direction (line 88) | def _define_threshold_direction():
  function _define_digital_port (line 131) | def _define_digital_port():
  class PS2000A_TRIGGER_CONDITIONS (line 197) | class PS2000A_TRIGGER_CONDITIONS(Structure):
  class PS2000A_PWQ_CONDITIONS (line 211) | class PS2000A_PWQ_CONDITIONS(Structure):
  class PS2000A_DIGITAL_CHANNEL_DIRECTIONS (line 224) | class PS2000A_DIGITAL_CHANNEL_DIRECTIONS(Structure):
  class PS2000A_TRIGGER_CHANNEL_PROPERTIES (line 232) | class PS2000A_TRIGGER_CHANNEL_PROPERTIES(Structure):

FILE: picosdk/ps3000.py
  class Ps3000lib (line 14) | class Ps3000lib(Library):
    method __init__ (line 15) | def __init__(self):

FILE: picosdk/ps3000a.py
  class Ps3000alib (line 16) | class Ps3000alib(Library):
    method __init__ (line 17) | def __init__(self):
  function _define_digital_port (line 129) | def _define_digital_port():
  class PS3000A_DIGITAL_CHANNEL_DIRECTIONS (line 166) | class PS3000A_DIGITAL_CHANNEL_DIRECTIONS(Structure):
  class PS3000A_TRIGGER_CONDITIONS (line 173) | class PS3000A_TRIGGER_CONDITIONS(Structure):
  class PS3000A_TRIGGER_CONDITIONS_V2 (line 185) | class PS3000A_TRIGGER_CONDITIONS_V2(Structure):
  class PS3000A_TRIGGER_CHANNEL_PROPERTIES (line 197) | class PS3000A_TRIGGER_CHANNEL_PROPERTIES(Structure):

FILE: picosdk/ps4000.py
  class Ps4000lib (line 16) | class Ps4000lib(Library):
    method __init__ (line 17) | def __init__(self):
  function process_enum (line 86) | def process_enum(enum):

FILE: picosdk/ps4000a.py
  class Ps4000alib (line 15) | class Ps4000alib(Library):
    method __init__ (line 16) | def __init__(self):
  function _define_ranges (line 60) | def _define_ranges():
  function process_enum (line 176) | def process_enum(enum):
  class PS4000A_USER_PROBE_INTERACTIONS (line 197) | class PS4000A_USER_PROBE_INTERACTIONS(Structure):
  class PS4000A_CONDITION (line 332) | class PS4000A_CONDITION (Structure):
  class PS4000A_DIRECTION (line 339) | class PS4000A_DIRECTION(Structure):
  class PS4000A_TRIGGER_CHANNEL_PROPERTIES (line 346) | class PS4000A_TRIGGER_CHANNEL_PROPERTIES(Structure):

FILE: picosdk/ps5000.py
  class Ps5000lib (line 15) | class Ps5000lib(Library):
    method __init__ (line 16) | def __init__(self):
  class PWQ_CONDITIONS (line 59) | class PWQ_CONDITIONS (Structure):
  class TRIGGER_CONDITIONS (line 70) | class TRIGGER_CONDITIONS (Structure):
  class TRIGGER_CHANNEL_PROPERTIES (line 82) | class TRIGGER_CHANNEL_PROPERTIES (Structure):

FILE: picosdk/ps5000a.py
  class Ps5000alib (line 16) | class Ps5000alib(Library):
    method __init__ (line 17) | def __init__(self):
  function _define_channel (line 46) | def _define_channel():
  function _define_conditionsInfo (line 150) | def _define_conditionsInfo():
  class PS5000A_TRIGGER_INFO (line 199) | class PS5000A_TRIGGER_INFO(Structure):
  class PS5000A_DIGITAL_CHANNEL_DIRECTIONS (line 211) | class PS5000A_DIGITAL_CHANNEL_DIRECTIONS(Structure):
  class PS5000A_DIRECTION (line 218) | class PS5000A_DIRECTION(Structure):
  class PS5000A_TRIGGER_CHANNEL_PROPERTIES_V2 (line 227) | class PS5000A_TRIGGER_CHANNEL_PROPERTIES_V2(Structure):
  class PS5000A_CONDITION (line 238) | class PS5000A_CONDITION (Structure):
  class PS5000A_PWQ_CONDITIONS (line 245) | class PS5000A_PWQ_CONDITIONS (Structure):

FILE: picosdk/ps6000.py
  class Ps6000lib (line 16) | class Ps6000lib(Library):
    method __init__ (line 17) | def __init__(self):
  class PS6000_TRIGGER_CONDITIONS (line 128) | class PS6000_TRIGGER_CONDITIONS (Structure):
  class PS6000_TRIGGER_CHANNEL_PROPERTIES (line 140) | class PS6000_TRIGGER_CHANNEL_PROPERTIES (Structure):
  class PS6000_PWQ_CONDITIONS (line 151) | class PS6000_PWQ_CONDITIONS (Structure):
  class PS6000_TRIGGER_INFO (line 162) | class PS6000_TRIGGER_INFO (Structure):

FILE: picosdk/ps6000a.py
  class Ps6000alib (line 17) | class Ps6000alib(Library):
    method __init__ (line 18) | def __init__(self):

FILE: picosdk/psospa.py
  class Psospalib (line 16) | class Psospalib(Library):
    method __init__ (line 17) | def __init__(self):

FILE: picosdk/usbDrDaq.py
  class UsbDrDaqlib (line 15) | class UsbDrDaqlib(Library):
    method __init__ (line 16) | def __init__(self):

FILE: picosdk/usbPT104.py
  class usbpt104lib (line 14) | class usbpt104lib(Library):
    method __init__ (line 15) | def __init__(self):
  function _define_communication_type (line 51) | def _define_communication_type():

FILE: picosdk/usbtc08.py
  class usbtc08lib (line 14) | class usbtc08lib(Library):
    method __init__ (line 15) | def __init__(self):
  class USBTC08_INFO (line 28) | class USBTC08_INFO(Structure):

FILE: ps2000Examples/advanced triggers/trigger_read_dropout.py
  class TriggerConditions (line 31) | class TriggerConditions(Structure):
  class PwqConditions (line 42) | class PwqConditions(Structure):
  class TriggerChannelProperties (line 52) | class TriggerChannelProperties(Structure):
  function get_timebase (line 62) | def get_timebase(device, wanted_time_interval):

FILE: ps2000Examples/advanced triggers/trigger_read_interval.py
  class TriggerConditions (line 30) | class TriggerConditions(Structure):
  class PwqConditions (line 41) | class PwqConditions(Structure):
  class TriggerChannelProperties (line 51) | class TriggerChannelProperties(Structure):
  function get_timebase (line 61) | def get_timebase(device, wanted_time_interval):

FILE: ps2000Examples/advanced triggers/trigger_read_pwq.py
  class TriggerConditions (line 31) | class TriggerConditions(Structure):
  class PwqConditions (line 42) | class PwqConditions(Structure):
  class TriggerChannelProperties (line 52) | class TriggerChannelProperties(Structure):
  function get_timebase (line 62) | def get_timebase(device, wanted_time_interval):

FILE: ps2000Examples/advanced triggers/trigger_read_runt.py
  class TriggerConditions (line 31) | class TriggerConditions(Structure):
  class PwqConditions (line 42) | class PwqConditions(Structure):
  class TriggerChannelProperties (line 52) | class TriggerChannelProperties(Structure):
  function get_timebase (line 62) | def get_timebase(device, wanted_time_interval):

FILE: ps2000Examples/advanced triggers/trigger_read_window.py
  class TriggerConditions (line 31) | class TriggerConditions(Structure):
  class PwqConditions (line 42) | class PwqConditions(Structure):
  class TriggerChannelProperties (line 52) | class TriggerChannelProperties(Structure):
  function get_timebase (line 62) | def get_timebase(device, wanted_time_interval):

FILE: ps2000Examples/advanced triggers/trigger_read_wpwq.py
  class TriggerConditions (line 31) | class TriggerConditions(Structure):
  class PwqConditions (line 42) | class PwqConditions(Structure):
  class TriggerChannelProperties (line 52) | class TriggerChannelProperties(Structure):
  function get_timebase (line 62) | def get_timebase(device, wanted_time_interval):

FILE: ps2000Examples/block_read.py
  function get_timebase (line 15) | def get_timebase(device, wanted_time_interval):

FILE: ps2000Examples/gen_sq_wave.py
  function gen_square (line 4) | def gen_square(t, duty, low_thres):

FILE: ps2000Examples/streaming_mode/streaming_mode.py
  function get_overview_buffers (line 26) | def get_overview_buffers(buffers, _overflow, _triggered_at, _triggered, ...
  function adc_to_mv (line 33) | def adc_to_mv(values, range_, bitness=16):

FILE: ps2000Examples/streaming_mode/streaming_mode_gathering.py
  class Channel (line 14) | class Channel(IntEnum):
  class PotentialRange (line 19) | class PotentialRange(IntEnum):
  class TimeUnit (line 33) | class TimeUnit(IntEnum):
  function adc_to_mv (line 46) | def adc_to_mv(values, range_, bitness=16):
  function determine_time_unit (line 52) | def determine_time_unit(interval_ns):
  class StreamingDevice (line 63) | class StreamingDevice:
    method __init__ (line 64) | def __init__(self, gather_values, potential_range=PotentialRange.PS200...
    method close (line 88) | def close(self):
    method gather (line 92) | def gather(self):

FILE: ps2000Examples/streaming_mode/streaming_mode_polling.py
  class Channel (line 14) | class Channel(IntEnum):
  class PotentialRange (line 19) | class PotentialRange(IntEnum):
  function adc_to_mv (line 36) | def adc_to_mv(values, range_, bitness=16):
  class StreamingDevice (line 42) | class StreamingDevice:
    method __init__ (line 43) | def __init__(self, potential_range=PotentialRange.PS2000_50MV):
    method process_value (line 68) | async def process_value(self, mv_value):
    method get_streamed_values (line 72) | def get_streamed_values(self, block_id):
    method start (line 88) | def start(self):

FILE: ps2000Examples/streaming_mode/streaming_mode_threaded.py
  function process_values (line 23) | def process_values(adc_values):
  function get_overview_buffers (line 33) | def get_overview_buffers(buffers, _overflow, _triggered_at, _triggered, ...
  function adc_to_mv (line 42) | def adc_to_mv(values, range_, bitness=16):
  class Channel (line 48) | class Channel(IntEnum):
  class PotentialRange (line 53) | class PotentialRange(IntEnum):

FILE: ps2000aExamples/ps2000aBlockExampleCallbackMethod.py
  function blockready_callback (line 86) | def blockready_callback(handle, statusCode, param):

FILE: ps2000aExamples/ps2000aStreamingExample.py
  function streaming_callback (line 138) | def streaming_callback(handle, noOfSamples, startIndex, overflow, trigge...

FILE: ps3000aExamples/ps3000aStreamingExample.py
  function streaming_callback (line 151) | def streaming_callback(handle, noOfSamples, startIndex, overflow, trigge...

FILE: ps4000Examples/ps4000StreamingExample.py
  function streaming_callback (line 129) | def streaming_callback(handle, noOfSamples, startIndex, overflow, trigge...

FILE: ps4000aExamples/ps4000aBlockDropoutTriggerExample.py
  class RECT (line 60) | class RECT(ctypes.Structure):

FILE: ps4000aExamples/ps4000aStreamingExample.py
  function streaming_callback (line 150) | def streaming_callback(handle, noOfSamples, startIndex, overflow, trigge...

FILE: ps4000aExamples/ps4000a_Runt_trigger.py
  function setup_runt_trigger (line 9) | def setup_runt_trigger(chandle, trigger_ch, channel_range_mv):

FILE: ps4000aExamples/ps4444BlockPicoConnectProbesExample.py
  function PicoConnectProbe_callback (line 22) | def PicoConnectProbe_callback(handle, pico_status, probes_ptr, nProbes):

FILE: ps5000Examples/ps5000StreamingExample.py
  function streaming_callback (line 136) | def streaming_callback(handle, noOfSamples, startIndex, overflow, trigge...

FILE: ps5000aExamples/ps5000aBlockCallbackExample.py
  function block_callback (line 101) | def block_callback(handle, statusCallback, param):

FILE: ps5000aExamples/ps5000aStreamingExample.py
  function streaming_callback (line 154) | def streaming_callback(handle, noOfSamples, startIndex, overflow, trigge...

FILE: ps6000Examples/ps6000StreamingExample.py
  function streaming_callback (line 137) | def streaming_callback(handle, noOfSamples, startIndex, overflow, trigge...

FILE: ps6000aExamples/ps6000aBlockExampleExtClk.py
  function ExternalReferenceInteractions_callback (line 32) | def ExternalReferenceInteractions_callback(handle, statusCallback, refer...

FILE: pt104Examples/pt104DirectEthernet.py
  function interpolate_temperature (line 110) | def interpolate_temperature(resistance):
  function get_channel_temperatures (line 142) | def get_channel_temperatures(resistances):
  function calculate_resistances (line 151) | def calculate_resistances(eeprom_vars, measurements):
  function parse_pkt_data (line 192) | def parse_pkt_data(pkt, storage):
  function parse_and_store_data (line 223) | def parse_and_store_data(raw_input, data_store):
  function udp_send (line 309) | def udp_send(sock: socket.socket, payload: bytes, addr):
  function udp_recv (line 314) | def udp_recv(sock: socket.socket, timeout: float = 2.0) -> bytes:
  function start_keep_alive (line 326) | def start_keep_alive(sock: socket.socket, dest):
  function lock_device (line 339) | def lock_device(sock: socket.socket, dest) -> bool:
  function read_EEPROM (line 362) | def read_EEPROM(sock: socket.socket, dest):
  function mains_rejection (line 392) | def mains_rejection(sock: socket.socket, dest):
  function start_converting (line 414) | def start_converting(sock: socket.socket, dest):
  function main (line 437) | def main():

FILE: test/test_discover.py
  class OpenCloseTest (line 16) | class OpenCloseTest(DriverTest):
    method test_find_unit_success (line 17) | def test_find_unit_success(self):
    method test_find_all_units_success (line 30) | def test_find_all_units_success(self):
    method test_find_unit_failure (line 47) | def test_find_unit_failure(self):
    method test_find_all_units_failure (line 61) | def test_find_all_units_failure(self):

FILE: test/test_get_unit_info.py
  class GetInfoTest (line 19) | class GetInfoTest(DriverTest):
    method test_get_info_success (line 20) | def test_get_info_success(self):
    method test_get_info_advanced_success (line 44) | def test_get_info_advanced_success(self):
    method test_get_info_with_invalid_key_fails (line 73) | def test_get_info_with_invalid_key_fails(self):

FILE: test/test_helpers.py
  class TestFailAndError (line 41) | class TestFailAndError(Exception):
  class TestError (line 45) | class TestError(Exception):
  class DriverTest (line 49) | class DriverTest(_unittest.TestCase):
    method _find_driver (line 51) | def _find_driver(name):
    method run_snippet_and_count_problems (line 56) | def run_snippet_and_count_problems(self, drivers_to_use, fn):

FILE: test/test_open_close_unit.py
  class OpenCloseTest (line 14) | class OpenCloseTest(DriverTest):
    method test_open_unit_failure (line 15) | def test_open_unit_failure(self):
    method test_open_unit_success (line 35) | def test_open_unit_success(self):
    method test_close_unit_success (line 57) | def test_close_unit_success(self):
    method test_with_statement_open_close (line 85) | def test_with_statement_open_close(self):

FILE: test/test_set_channel.py
  class SetChannelTest (line 15) | class SetChannelTest(DriverTest):
    method test_set_channel_success (line 28) | def test_set_channel_success(self):
    method test_set_channel_very_small_peak (line 45) | def test_set_channel_very_small_peak(self):
    method test_set_channel_range_too_large (line 63) | def test_set_channel_range_too_large(self):

FILE: test/test_timebase.py
  class FindTimebaseTest (line 18) | class FindTimebaseTest(DriverTest):
    method assertValidTimebases (line 19) | def assertValidTimebases(self, input_config, output_info):
    method test_find_timebase_success (line 28) | def test_find_timebase_success(self):
    method test_find_timebase_terrasample (line 49) | def test_find_timebase_terrasample(self):
    method test_find_timebase_impossible (line 75) | def test_find_timebase_impossible(self):
    method test_get_timebase_throws_on_bad_params (line 103) | def test_get_timebase_throws_on_bad_params(self):
  class TimebaseValidationTest (line 132) | class TimebaseValidationTest(unittest.TestCase):
    method test_valid_config (line 133) | def test_valid_config(self):
    method test_invalid_config (line 147) | def test_invalid_config(self):
Condensed preview — 142 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (1,131K chars).
[
  {
    "path": ".github/CODE_OF_CONDUCT.md",
    "chars": 3217,
    "preview": "# Contributor Covenant Code of Conduct\n\n## Our Pledge\n\nIn the interest of fostering an open and welcoming environment, w"
  },
  {
    "path": ".github/CONTRIBUTING.md",
    "chars": 911,
    "preview": "# Contributing\n\nWe welcome contributions to the picosdk-python-examples repository. By contributing to this repository, "
  },
  {
    "path": ".github/PULL_REQUEST_TEMPLATE.md",
    "chars": 56,
    "preview": "Fixes #.\n\nChanges proposed in this pull request:\n\n*\n*\n*\n"
  },
  {
    "path": ".github/issue_template.md",
    "chars": 561,
    "preview": "### Setup\n\n* Example filename:\n* Version of Python:\n* Pico Technology device model:\n* Driver name, version number and pl"
  },
  {
    "path": ".gitignore",
    "chars": 327,
    "preview": "# .gitignore file for picosdk-ps6000a-matlab-instrument-driver\r\n# Untracked files/folders to ignore.\r\n\r\n# Windows platfo"
  },
  {
    "path": "LICENSE.md",
    "chars": 739,
    "preview": "Copyright © 2019 Pico Technology Ltd.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any purpos"
  },
  {
    "path": "README.md",
    "chars": 5750,
    "preview": "# picosdk-python-wrappers\n\nWelcome to the PicoSDK for Python. It allows you to control PicoScope devices in your own Pyt"
  },
  {
    "path": "discontinuedExamples/anyScopeExamples/block.py",
    "chars": 996,
    "preview": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\nfrom __future__ import print_function\nfrom pic"
  },
  {
    "path": "picohrdlExamples/picohrdlSingleModeExample.py",
    "chars": 1300,
    "preview": "#\r\n# Copyright (C) 2019 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PICOLOG HIGH RESOLUTION DATA LOGGER SINGL"
  },
  {
    "path": "picohrdlExamples/picohrdlStreamingModeExample.py",
    "chars": 3657,
    "preview": "#\n# Copyright (C) 2025 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PICOLOG HIGH RESOLUTION DATA LOGGER STREAMIN"
  },
  {
    "path": "picosdk/PicoConnectProbes.py",
    "chars": 823,
    "preview": "#\r\n# Copyright (C) 2024 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n\"\"\"\r\nThis is a Python module defining the e"
  },
  {
    "path": "picosdk/PicoDeviceEnums.py",
    "chars": 9521,
    "preview": "#\r\n# Copyright (C) 2020 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n\"\"\"\r\nThis is a Python module defining the e"
  },
  {
    "path": "picosdk/PicoDeviceStructs.py",
    "chars": 6395,
    "preview": "#\r\n# Copyright (C) 2020 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n\"\"\"\r\nThis is a Python module defining the s"
  },
  {
    "path": "picosdk/__init__.py",
    "chars": 77,
    "preview": "#\r\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n"
  },
  {
    "path": "picosdk/constants.py",
    "chars": 14890,
    "preview": "#\n# Copyright (C) 2014-2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n\"\"\"\nDefines python-visible versions of pr"
  },
  {
    "path": "picosdk/ctypes_wrapper.py",
    "chars": 258,
    "preview": "# coding=utf-8\n#\n# Copyright (C) 2018-2019 Pico Technology Ltd. See LICENSE file for terms.\n#\nimport ctypes\nimport sys\n\n"
  },
  {
    "path": "picosdk/device.py",
    "chars": 11856,
    "preview": "# coding=utf-8\n#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n\"\"\"\nDefinition of the Device cl"
  },
  {
    "path": "picosdk/discover.py",
    "chars": 1402,
    "preview": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\nfrom picosdk.errors import DeviceNotFoundError"
  },
  {
    "path": "picosdk/errors.py",
    "chars": 1317,
    "preview": "#\n# Copyright (C) 2019 Pico Technology Ltd. See LICENSE file for terms.\n#\n\n\nclass PicoError(Exception):\n    \"\"\"All error"
  },
  {
    "path": "picosdk/functions.py",
    "chars": 6649,
    "preview": "#\n# Copyright (C) 2018-2024 Pico Technology Ltd. See LICENSE file for terms.\n#\nfrom __future__ import division\nimport nu"
  },
  {
    "path": "picosdk/functionsExhibitions.py",
    "chars": 4074,
    "preview": "#\r\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n\r\nimport numpy as np\r\nimport openpyxl\r\nfrom"
  },
  {
    "path": "picosdk/library.py",
    "chars": 28893,
    "preview": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n\"\"\"\nDefinition of the Library class, which is "
  },
  {
    "path": "picosdk/picoMeasurements.py",
    "chars": 99,
    "preview": "#\r\n# Copyright (C) 2025 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n\r\nimport numpy as np\r\n"
  },
  {
    "path": "picosdk/picohrdl.py",
    "chars": 5311,
    "preview": "#\r\n# Copyright (C) 2019 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n\"\"\"\r\nThis is a Python module defining the f"
  },
  {
    "path": "picosdk/picosynth.py",
    "chars": 6027,
    "preview": "#\r\n# Copyright (C) 2022 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n\"\"\"\r\nThis is a Python module defining the f"
  },
  {
    "path": "picosdk/pl1000.py",
    "chars": 5191,
    "preview": "#\r\n# Copyright (C) 2019 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n\"\"\"\r\nThis is a Python module defining the f"
  },
  {
    "path": "picosdk/ps2000.py",
    "chars": 14952,
    "preview": "#\r\n# Copyright (C) 2015-2018 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n\"\"\"\r\nThis is a Python module defining "
  },
  {
    "path": "picosdk/ps2000a.py",
    "chars": 31468,
    "preview": "#\n# Copyright (C) 2014-2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n\"\"\"\nThis is a Python module defining the "
  },
  {
    "path": "picosdk/ps3000.py",
    "chars": 12428,
    "preview": "#\n# Copyright (C) 2015-2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n\"\"\"\nThis is a Python module defining the "
  },
  {
    "path": "picosdk/ps3000a.py",
    "chars": 32754,
    "preview": "#\n# Copyright (C) 2014-2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n\"\"\"\nThis is a Python module defining the "
  },
  {
    "path": "picosdk/ps4000.py",
    "chars": 27910,
    "preview": "#\n# Copyright (C) 2015-2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n\"\"\"\nThis is a Python module defining the "
  },
  {
    "path": "picosdk/ps4000a.py",
    "chars": 40651,
    "preview": "#\n# Copyright (C) 2015-2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n\"\"\"\nThis is a Python module defining the "
  },
  {
    "path": "picosdk/ps5000.py",
    "chars": 16768,
    "preview": "#\r\n# Copyright (C) 2019 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n\"\"\"\r\nThis is a Python module defining the f"
  },
  {
    "path": "picosdk/ps5000a.py",
    "chars": 37257,
    "preview": "#\n# Copyright (C) 2014-2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n\"\"\"\nThis is a Python module defining the "
  },
  {
    "path": "picosdk/ps6000.py",
    "chars": 31042,
    "preview": "#\n# Copyright (C) 2014-2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n\"\"\"\nThis is a Python module defining the "
  },
  {
    "path": "picosdk/ps6000a.py",
    "chars": 32263,
    "preview": "#\r\n# Copyright (C) 2020 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n\"\"\"\r\nThis is a Python module defining the f"
  },
  {
    "path": "picosdk/psospa.py",
    "chars": 26598,
    "preview": "#\r\n# Copyright (C) 2024 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n\"\"\"\r\nThis is a Python module defining the f"
  },
  {
    "path": "picosdk/psospaBlockExample.py",
    "chars": 5271,
    "preview": "#\r\n# Copyright (C) 2024 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PSOSPA BLOCK MODE EXAMPLE\r\n# This example"
  },
  {
    "path": "picosdk/usbDrDaq.py",
    "chars": 9649,
    "preview": "#\r\n# Copyright (C) 2014-2020 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n\"\"\"\r\nThis is a Python module defining "
  },
  {
    "path": "picosdk/usbPT104.py",
    "chars": 4038,
    "preview": "#\r\n# Copyright (C) 2020 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n\"\"\"\r\nThis is a Python module defining the f"
  },
  {
    "path": "picosdk/usbtc08.py",
    "chars": 4633,
    "preview": "#\r\n# Copyright (C) 2015-2018 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n\"\"\"\r\nThis is a Python module defining "
  },
  {
    "path": "picosynthExamples/picosynthFrequencySweepExample.py",
    "chars": 1692,
    "preview": "#\r\n# Copyright (C) 2022 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PicoSource AS108 Agile Synthesizer Exampl"
  },
  {
    "path": "pl1000Examples/pl1000SingleModeExample.py",
    "chars": 1068,
    "preview": "#\r\n# Copyright (C) 2019 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PL1000 SINGLE MODE EXAMPLE\r\n# This exampl"
  },
  {
    "path": "pl1000Examples/pl1000StreamingModeExample.py",
    "chars": 2125,
    "preview": "#\r\n# Copyright (C) 2019 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PL1000 STREAMING MODE EXAMPLE\r\n# This exa"
  },
  {
    "path": "pl1000Examples/pl1000StreamingModeMultiChannelExample.py",
    "chars": 5586,
    "preview": "#\n# Copyright (C) 2025 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PL1000 STREAMING MODE MULTICHANNEL EXAMPLE\n#"
  },
  {
    "path": "ps2000Examples/advanced triggers/trigger_read_dropout.py",
    "chars": 4949,
    "preview": "from ctypes import byref, c_int16, c_int32, sizeof, Structure, c_uint16\nfrom time import sleep\n\nimport numpy as np\nfrom "
  },
  {
    "path": "ps2000Examples/advanced triggers/trigger_read_interval.py",
    "chars": 4836,
    "preview": "from ctypes import byref, c_int16, c_int32, sizeof, Structure, c_uint16\nfrom time import sleep\n\nimport numpy as np\nfrom "
  },
  {
    "path": "ps2000Examples/advanced triggers/trigger_read_pwq.py",
    "chars": 4983,
    "preview": "from ctypes import byref, c_int16, c_int32, sizeof, Structure, c_uint16\nfrom time import sleep\n\nimport numpy as np\nfrom "
  },
  {
    "path": "ps2000Examples/advanced triggers/trigger_read_runt.py",
    "chars": 5010,
    "preview": "from ctypes import byref, c_int16, c_int32, sizeof, Structure, c_uint16\nfrom time import sleep\n\nimport numpy as np\nfrom "
  },
  {
    "path": "ps2000Examples/advanced triggers/trigger_read_window.py",
    "chars": 4716,
    "preview": "from ctypes import byref, c_int16, c_int32, sizeof, Structure, c_uint16\nfrom time import sleep\n\nimport numpy as np\nfrom "
  },
  {
    "path": "ps2000Examples/advanced triggers/trigger_read_wpwq.py",
    "chars": 5011,
    "preview": "from ctypes import byref, c_int16, c_int32, sizeof, Structure, c_uint16\nfrom time import sleep\n\nimport numpy as np\nfrom "
  },
  {
    "path": "ps2000Examples/block_read.py",
    "chars": 2989,
    "preview": "from ctypes import byref, c_byte, c_int16, c_int32, sizeof\nfrom time import sleep\n\nfrom picosdk.ps2000 import ps2000\nfro"
  },
  {
    "path": "ps2000Examples/device_info.py",
    "chars": 119,
    "preview": "from picosdk.ps2000 import ps2000\n\nwith ps2000.open_unit() as device:\n    print('Device info: {}'.format(device.info))\n"
  },
  {
    "path": "ps2000Examples/gen_sq_wave.py",
    "chars": 828,
    "preview": "import ctypes\nimport numpy as np\n\ndef gen_square(t, duty, low_thres):\n    t, w = np.asarray(t), np.asarray(duty)\n    w ="
  },
  {
    "path": "ps2000Examples/ps2000BlockExample.py",
    "chars": 4517,
    "preview": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS2000 BLOCK MODE EXAMPLE\n# This example ope"
  },
  {
    "path": "ps2000Examples/ps2000ETSBlockExample.py",
    "chars": 4973,
    "preview": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS2000 ETS BLOCK MODE EXAMPLE\n# This example"
  },
  {
    "path": "ps2000Examples/ps2000SigGen.py",
    "chars": 3368,
    "preview": "import ctypes\nimport numpy as np\nfrom time import sleep\nimport math\n\nfrom picosdk.ps2000 import ps2000 as ps\nfrom picosd"
  },
  {
    "path": "ps2000Examples/streaming_mode/streaming_mode.py",
    "chars": 1922,
    "preview": "from ctypes import POINTER, c_int16, c_uint32\n\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nfrom picosdk.ps2000 i"
  },
  {
    "path": "ps2000Examples/streaming_mode/streaming_mode_gathering.py",
    "chars": 3083,
    "preview": "from time import time_ns\nfrom ctypes import POINTER, c_int16, c_uint32\n\nimport matplotlib.pyplot as plt\nimport numpy as "
  },
  {
    "path": "ps2000Examples/streaming_mode/streaming_mode_polling.py",
    "chars": 3305,
    "preview": "import asyncio\nimport concurrent.futures\nimport functools\n\nfrom ctypes import POINTER, c_int16, c_uint32\n\nfrom picosdk.p"
  },
  {
    "path": "ps2000Examples/streaming_mode/streaming_mode_threaded.py",
    "chars": 2080,
    "preview": "from ctypes import POINTER, c_int16, c_uint32\n\nfrom picosdk.ps2000 import ps2000\nfrom picosdk.functions import assert_pi"
  },
  {
    "path": "ps2000aExamples/ps2000aBlockAdvancedEdgeExample.py",
    "chars": 9639,
    "preview": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS2000A BLOCK MODE EXAMPLE\n# This example op"
  },
  {
    "path": "ps2000aExamples/ps2000aBlockExample.py",
    "chars": 7461,
    "preview": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS2000A BLOCK MODE EXAMPLE\n# This example op"
  },
  {
    "path": "ps2000aExamples/ps2000aBlockExampleCallbackMethod.py",
    "chars": 7543,
    "preview": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS2000A BLOCK MODE EXAMPLE\n# This example op"
  },
  {
    "path": "ps2000aExamples/ps2000aMSOBlockExample.py",
    "chars": 12923,
    "preview": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PicoScope 2000 Series (A API) MSO Block Mode"
  },
  {
    "path": "ps2000aExamples/ps2000aRapidBlockExample.py",
    "chars": 12818,
    "preview": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n# ps2000a RAPID BLOCK MODE EXAMPLE\n# This exam"
  },
  {
    "path": "ps2000aExamples/ps2000aSigGen.py",
    "chars": 7443,
    "preview": "#\r\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PicoScope 2000 (A API) Series Signal Gene"
  },
  {
    "path": "ps2000aExamples/ps2000aStreamingExample.py",
    "chars": 7544,
    "preview": "#\n# Copyright (C) 2018-2019 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS2000 Series (A API) STREAMING MODE EX"
  },
  {
    "path": "ps3000EExamples/ps3000EBlockExample.py",
    "chars": 5271,
    "preview": "#\r\n# Copyright (C) 2024 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PSOSPA BLOCK MODE EXAMPLE\r\n# This example"
  },
  {
    "path": "ps3000EExamples/ps3000ERapidBlockExample.py",
    "chars": 9832,
    "preview": "#\n# Copyright (C) 2024 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PSOSPA RAPID BLOCK MODE EXAMPLE\n# This examp"
  },
  {
    "path": "ps3000EExamples/ps3000EStreamingModeExample.py",
    "chars": 6972,
    "preview": "#\r\n# Copyright (C) 2024 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PSOSPA STREAMING MODE EXAMPLE\r\n# This exa"
  },
  {
    "path": "ps3000aExamples/ps3000aBlockAdvancedTriggerExample.py",
    "chars": 7884,
    "preview": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS3000A BLOCK MODE EXAMPLE\n# This example op"
  },
  {
    "path": "ps3000aExamples/ps3000aBlockExample.py",
    "chars": 5625,
    "preview": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS3000A BLOCK MODE EXAMPLE\n# This example op"
  },
  {
    "path": "ps3000aExamples/ps3000aBlockMSOExample.py",
    "chars": 6847,
    "preview": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PicoScope 3000 Series (A API) MSO Block Mode"
  },
  {
    "path": "ps3000aExamples/ps3000aRapidBlockExample.py",
    "chars": 13968,
    "preview": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS3000A RAPID BLOCK MODE EXAMPLE\n# This exam"
  },
  {
    "path": "ps3000aExamples/ps3000aSigGen.py",
    "chars": 4322,
    "preview": "#\r\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PicoScope 3000 (A API) Series Signal Gene"
  },
  {
    "path": "ps3000aExamples/ps3000aStreamingExample.py",
    "chars": 7866,
    "preview": "#\n# Copyright (C) 2018-2020 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS3000 Series (A API) STREAMING MODE EX"
  },
  {
    "path": "ps4000Examples/ps4000BlockExample.py",
    "chars": 5878,
    "preview": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS4000 BLOCK MODE EXAMPLE\n# This example ope"
  },
  {
    "path": "ps4000Examples/ps4000StreamingExample.py",
    "chars": 6725,
    "preview": "#\n# Copyright (C) 2018-2022 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS4000 Series (A API) STREAMING MODE EX"
  },
  {
    "path": "ps4000aExamples/ps4000 Ch4 AND logic triggering.py",
    "chars": 10929,
    "preview": "import ctypes\nfrom ctypes import byref, c_int16, c_int32, sizeof, Structure, c_uint16\nimport numpy as np\nfrom picosdk.ps"
  },
  {
    "path": "ps4000aExamples/ps4000aBlockAdvancedEdgeTriggerExample.py",
    "chars": 8219,
    "preview": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS4824 BLOCK MODE EXAMPLE\n# This example ope"
  },
  {
    "path": "ps4000aExamples/ps4000aBlockDropoutTriggerExample.py",
    "chars": 8524,
    "preview": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS4824 BLOCK MODE EXAMPLE\n# This example ope"
  },
  {
    "path": "ps4000aExamples/ps4000aBlockFrequencyCounterExample.py",
    "chars": 6270,
    "preview": "#\n# Copyright (C) 2025 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS4000 BLOCK MODE FREQUENCY COUNTER EXAMPLE\n"
  },
  {
    "path": "ps4000aExamples/ps4000aRapidBlockExample.py",
    "chars": 9875,
    "preview": "#\r\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PS4000A RAPID BLOCK MODE EXAMPLE\r\n# This "
  },
  {
    "path": "ps4000aExamples/ps4000aRapidBlockWaveformAveragingExample.py",
    "chars": 7904,
    "preview": "#\r\n# Copyright (C) 2020-2024 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PS4000 A BLOCK MODE WAVEFORM AVERAGI"
  },
  {
    "path": "ps4000aExamples/ps4000aSigGen.py",
    "chars": 4877,
    "preview": "#\r\n# Copyright (C) 2019 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PicoScope 4000 (A API) Series Signal Gene"
  },
  {
    "path": "ps4000aExamples/ps4000aStreamingExample.py",
    "chars": 7769,
    "preview": "#\n# Copyright (C) 2018-2019 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS2000 Series (A API) STREAMING MODE EX"
  },
  {
    "path": "ps4000aExamples/ps4000a_Runt_trigger.py",
    "chars": 10008,
    "preview": "import ctypes\nfrom picosdk.ps4000a import ps4000a as ps\nfrom picosdk.functions import assert_pico_ok\nimport numpy as np\n"
  },
  {
    "path": "ps4000aExamples/ps4444BlockExample.py",
    "chars": 6931,
    "preview": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS4824 BLOCK MODE EXAMPLE\n# This example ope"
  },
  {
    "path": "ps4000aExamples/ps4444BlockPicoConnectProbesExample.py",
    "chars": 10505,
    "preview": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS4444 PICOCONNECT PROBE, BLOCK MODE EXAMPLE"
  },
  {
    "path": "ps4000aExamples/ps4824BlockExample.py",
    "chars": 7927,
    "preview": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS4824 BLOCK MODE EXAMPLE\n# This example ope"
  },
  {
    "path": "ps5000Examples/ps5000BlockExample.py",
    "chars": 6046,
    "preview": "#\n# Copyright (C) 2018-2022 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS5000 BLOCK MODE EXAMPLE\n# This exampl"
  },
  {
    "path": "ps5000Examples/ps5000RapidBlockExample.py",
    "chars": 11072,
    "preview": "#\n# Copyright (C) 2018-2022 Pico Technology Ltd. See LICENSE file for terms.\n#\n# ps5000 RAPID BLOCK MODE EXAMPLE\n# This "
  },
  {
    "path": "ps5000Examples/ps5000StreamingExample.py",
    "chars": 7006,
    "preview": "#\n# Copyright (C) 2018-2024 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS5000 Series STREAMING MODE EXAMPLE\n# "
  },
  {
    "path": "ps5000aExamples/ps5000aBlockAdvancedTriggerExample.py",
    "chars": 10941,
    "preview": "#\n# Copyright (C) 2018-2022 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS5000A BLOCK MODE EXAMPLE\n# This examp"
  },
  {
    "path": "ps5000aExamples/ps5000aBlockCallbackExample.py",
    "chars": 7020,
    "preview": "#\n# Copyright (C) 2018-2022 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS5000A BLOCK MODE EXAMPLE\n# This examp"
  },
  {
    "path": "ps5000aExamples/ps5000aBlockExample.py",
    "chars": 6739,
    "preview": "#\n# Copyright (C) 2018-2022 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS5000A BLOCK MODE EXAMPLE\n# This examp"
  },
  {
    "path": "ps5000aExamples/ps5000aBlockLevelPulseWidthAdvancedTriggerExample.py",
    "chars": 9148,
    "preview": "#\n# Copyright (C) 2018-2022 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS5000A BLOCK MODE EXAMPLE\n# This examp"
  },
  {
    "path": "ps5000aExamples/ps5000aBlockMSOExample.py",
    "chars": 6660,
    "preview": "#\n# Copyright (C) 2018-2022 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PicoScope 5000 Series (A API) MSO Block"
  },
  {
    "path": "ps5000aExamples/ps5000aBlockMSOTriggerExample.py",
    "chars": 8304,
    "preview": "#\n# Copyright (C) 2018-2022 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PicoScope 5000 Series (A API) MSO Block"
  },
  {
    "path": "ps5000aExamples/ps5000aBlockWindowPulseWidthAdvancedTriggerExample.py",
    "chars": 9194,
    "preview": "#\n# Copyright (C) 2018-2023 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS5000A BLOCK MODE WINDOW PULSE WIDTH A"
  },
  {
    "path": "ps5000aExamples/ps5000aRapidBlockExample.py",
    "chars": 14150,
    "preview": "#\n# Copyright (C) 2018-2022 Pico Technology Ltd. See LICENSE file for terms.\n#\n# ps5000a RAPID BLOCK MODE EXAMPLE\n# This"
  },
  {
    "path": "ps5000aExamples/ps5000aSigGen.py",
    "chars": 5692,
    "preview": "#\r\n# Copyright (C) 2018-2024 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PicoScope 5000 (A API) Signal Genera"
  },
  {
    "path": "ps5000aExamples/ps5000aStreamingExample.py",
    "chars": 8026,
    "preview": "#\n# Copyright (C) 2018-2019 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS5000 Series (A API) STREAMING MODE EX"
  },
  {
    "path": "ps6000Examples/ps6000BlockAdvancedTriggerExample.py",
    "chars": 7570,
    "preview": "#\n# Copyright (C) 2018-2022 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS6000 BLOCK MODE ADVANCED TRIGGER EXAM"
  },
  {
    "path": "ps6000Examples/ps6000BlockExample.py",
    "chars": 5861,
    "preview": "#\n# Copyright (C) 2018-2022 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS6000 BLOCK MODE EXAMPLE\n# This exampl"
  },
  {
    "path": "ps6000Examples/ps6000GetInfoExample.py",
    "chars": 1115,
    "preview": "#\r\n# Copyright (C) 2020 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PS6000 GET INFO EXAMPLE\r\n# This example o"
  },
  {
    "path": "ps6000Examples/ps6000RapidBlockExample.py",
    "chars": 12805,
    "preview": "#\n# Copyright (C) 2018-2022 Pico Technology Ltd. See LICENSE file for terms.\n#\n# ps6000 RAPID BLOCK MODE EXAMPLE\n# This "
  },
  {
    "path": "ps6000Examples/ps6000RapidBlockTriggerTimestampExample.py",
    "chars": 13367,
    "preview": "#\n# Copyright (C) 2018-2022 Pico Technology Ltd. See LICENSE file for terms.\n#\n# ps6000 RAPID BLOCK MODE EXAMPLE\n# This "
  },
  {
    "path": "ps6000Examples/ps6000SigGen.py",
    "chars": 3579,
    "preview": "#\r\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PicoScope 6000 Series Signal Generator Ex"
  },
  {
    "path": "ps6000Examples/ps6000StreamingExample.py",
    "chars": 7338,
    "preview": "#\n# Copyright (C) 2019 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS6000 Series STREAMING MODE EXAMPLE\n# This "
  },
  {
    "path": "ps6000aExamples/ps6000aBlockAdvancedTriggerExample.py",
    "chars": 7118,
    "preview": "#\r\n# Copyright (C) 2020-2024 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PS6000 A BLOCK MODE EXAMPLE\r\n# This "
  },
  {
    "path": "ps6000aExamples/ps6000aBlockExample.py",
    "chars": 5039,
    "preview": "#\r\n# Copyright (C) 2020-2024 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PS6000 A BLOCK MODE EXAMPLE\r\n# This "
  },
  {
    "path": "ps6000aExamples/ps6000aBlockExampleExtClk.py",
    "chars": 6223,
    "preview": "#\n# Copyright (C) 2020-2024 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS6000A Demonstrates external clock cal"
  },
  {
    "path": "ps6000aExamples/ps6000aBlockExampleTrigTimes.py",
    "chars": 8272,
    "preview": "#\n# Copyright (C) 2020-2024 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PS6000 A BLOCK MODE EXAMPLE WITH ALL TR"
  },
  {
    "path": "ps6000aExamples/ps6000aBlockMSODigitalTriggerExample.py",
    "chars": 7702,
    "preview": "#\r\n# Copyright (C) 2020-2024 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PS6000 A MSO BLOCK MODE DIGITAL TRIG"
  },
  {
    "path": "ps6000aExamples/ps6000aBlockMSOExample.py",
    "chars": 7021,
    "preview": "#\r\n# Copyright (C) 2020-2024 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PS6000 A BLOCK MODE EXAMPLE\r\n# This "
  },
  {
    "path": "ps6000aExamples/ps6000aBlock_both_MSOExample.py",
    "chars": 11302,
    "preview": "#\r\n# Copyright (C) 2020-2024 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PS6000 A BLOCK MODE EXAMPLE\r\n# This "
  },
  {
    "path": "ps6000aExamples/ps6000aGetUnitInfo.py",
    "chars": 1659,
    "preview": "#\r\n# Copyright (C) 2024 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PS6000 A GET UNIT INFO EXAMPLE\r\n# This ex"
  },
  {
    "path": "ps6000aExamples/ps6000aRapidBlockExample.py",
    "chars": 10902,
    "preview": "#\r\n# Copyright (C) 2020-2024 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PS6000 A BLOCK MODE EXAMPLE\r\n# This "
  },
  {
    "path": "ps6000aExamples/ps6000aSigGenExample.py",
    "chars": 3448,
    "preview": "#\r\n# Copyright (C) 2020 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PS6000 A SIGNAL GENERATOR EXAMPLE\r\n# This"
  },
  {
    "path": "ps6000aExamples/ps6000aStreamingModeExample.py",
    "chars": 6851,
    "preview": "#\r\n# Copyright (C) 2020-2024 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PS6000 A STREAMING MODE EXAMPLE\r\n# T"
  },
  {
    "path": "pt104Examples/pt104DirectEthernet.py",
    "chars": 22638,
    "preview": "#\n# Copyright (C) 2026 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PT-104 DIRECT ETHERNET EXAMPLE (NO SDK)\n# ##"
  },
  {
    "path": "pt104Examples/pt104EnumerateTestsExample.py",
    "chars": 2328,
    "preview": "#\n# Copyright (C) 2025 Pico Technology Ltd. See LICENSE file for terms.\n#\n# PT104 Example\n# This example opens a pt104, "
  },
  {
    "path": "pt104Examples/pt104Example.py",
    "chars": 1799,
    "preview": "#\r\n# Copyright (C) 2022 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# PT104 Example\r\n# This example opens a pt1"
  },
  {
    "path": "requirements-for-examples.txt",
    "chars": 31,
    "preview": "matplotlib>=1.5.3\r\ntoml>=0.10.2"
  },
  {
    "path": "requirements.txt",
    "chars": 13,
    "preview": "numpy>=1.12.1"
  },
  {
    "path": "setup.py",
    "chars": 1885,
    "preview": "#\n# Copyright (C) 2017-2018 Pico Technology Ltd.\n#\nfrom __future__ import print_function\nfrom setuptools import setup\n\ni"
  },
  {
    "path": "setupPicosynth.py",
    "chars": 948,
    "preview": "#\n# Copyright (C) 2017-2018 Pico Technology Ltd.\n#\nfrom __future__ import print_function\nfrom distutils.core import setu"
  },
  {
    "path": "test/__init__.py",
    "chars": 74,
    "preview": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n"
  },
  {
    "path": "test/run_examples.sh",
    "chars": 373,
    "preview": "#! /bin/bash\n\ncd \"${BASH_SOURCE%/*}\" || exit\n\nFILE_ERRORS=\"\"\nNEWLINE=$'\\n'\n\nfor file in ../ps*Examples/*\ndo\n    if [[ -f"
  },
  {
    "path": "test/test_discover.py",
    "chars": 2310,
    "preview": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n\"\"\"\nUnit tests for the wrapper functions for d"
  },
  {
    "path": "test/test_get_unit_info.py",
    "chars": 3692,
    "preview": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n\"\"\"\nUnit tests for the wrapper function for re"
  },
  {
    "path": "test/test_helpers.py",
    "chars": 1872,
    "preview": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n\"\"\"\nHelper methods for tests, and test configu"
  },
  {
    "path": "test/test_open_close_unit.py",
    "chars": 4220,
    "preview": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n\"\"\"\nUnit tests for the wrapper functions for o"
  },
  {
    "path": "test/test_set_channel.py",
    "chars": 3012,
    "preview": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n\"\"\"\nUnit tests for the wrapper functions for c"
  },
  {
    "path": "test/test_timebase.py",
    "chars": 7175,
    "preview": "#\n# Copyright (C) 2018 Pico Technology Ltd. See LICENSE file for terms.\n#\n\"\"\"\nUnit tests for the wrapper functions for c"
  },
  {
    "path": "usbdrdaqExamples/usbdrdaqPhBlockExample.py",
    "chars": 3010,
    "preview": "#\r\n# Copyright (C) 2020 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# USBDRDAQ SCOPE BLOCK MODE EXAMPLE\r\n# This"
  },
  {
    "path": "usbdrdaqExamples/usbdrdaqScopeBlockExample.py",
    "chars": 3226,
    "preview": "#\r\n# Copyright (C) 2020 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# USBDRDAQ SCOPE BLOCK MODE EXAMPLE\r\n# This"
  },
  {
    "path": "usbtc08Examples/tc08SingleModeExample.py",
    "chars": 1586,
    "preview": "#\r\n# Copyright (C) 2019 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# TC-08 SINGLE MODE EXAMPLE\r\n\r\n\r\nimport cty"
  },
  {
    "path": "usbtc08Examples/tc08StreamingModeExample.py",
    "chars": 1964,
    "preview": "#\r\n# Copyright (C) 2019 Pico Technology Ltd. See LICENSE file for terms.\r\n#\r\n# TC-08 STREAMING MODE EXAMPLE\r\n\r\n\r\nimport "
  },
  {
    "path": "usbtc08Examples/tc08StreamingModeMultiChExample.py",
    "chars": 4314,
    "preview": "#\n# Copyright (C) 2026 Pico Technology Ltd. See LICENSE file for terms.\n#\n# TC-08 STREAMING MODE EXAMPLE\n\nimport ctypes\n"
  }
]

About this extraction

This page contains the full source code of the picotech/picosdk-python-wrappers GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 142 files (1.0 MB), approximately 298.0k tokens, and a symbol index with 299 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!