-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
1,441 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Configuration | ||
|
||
pybench instruments can be configured in two main ways. The first by providing the instrument address to the constructor of the instrument class, and the second by using a configuration file. The configuration file is a YAML file that defines the instruments available to pybench and their addresses. Using configuration files is useful when you have multiple instruments that you want to use in your tests, or if you want to keep the instrument addresses separate from your test code. pybench looks for local and global configuration files, which can be handy when you want to have multiple test code bases that use the same instruments. | ||
|
||
## Configuration file format | ||
|
||
The configuration file is a YAML file that defines the instruments available to pybench and their addresses. The configuration file is structured as follows: | ||
|
||
```yaml | ||
|
||
instrument1: | ||
address: "address1" | ||
type: "instrument_type" | ||
instrument2: | ||
address: "address2" | ||
type: "instrument_type2" | ||
``` | ||
|
||
Example configuration file: | ||
|
||
```yaml | ||
powersupply: | ||
address: "TCPIP0::192.168.10.31::inst0::INSTR" | ||
type: E36233A | ||
specan: | ||
address: "TCPIP::192.168.10.21::inst0::INSTR" | ||
type: N9040B | ||
siggen: | ||
address: "TCPIP::192.168.10.41::inst0::INSTR" | ||
type: SMA100A | ||
``` | ||
|
||
The "type" field must match an instrument class in pybench. The address field is the address of the instrument, which is used to connect to the instrument. Note that the address field does not need to be TCP/IP addresses, but can be any address that the instrument class can use to connect to the instrument. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Usage Model | ||
|
||
All supported instruments within pybench have a similar API and usage model. This allows for a consistent experience when using different instruments in your tests. This page describes the usage model for pybench instruments through examples. | ||
|
||
## Basic usage | ||
|
||
The following example demonstrates how to use a power supply instrument to set the output voltage and current, and then enable the output. | ||
|
||
```python | ||
from bench.keysight import E36233A | ||
|
||
# Create an instance of the power supply | ||
ps = E36233A("TCPIP0::192.168.1.1::inst0::INSTR") | ||
|
||
# Set the output voltage to 5V for channel 1 | ||
ps.ch1.voltage = 5 | ||
|
||
# Set the output current to 1A for channel 2 | ||
ps.ch2.current = 1 | ||
|
||
# Enable the output for channel 1 | ||
ps.ch1.output_enabled = True | ||
|
||
# Check output operational mode | ||
print(ps.ch1.operational_mode) | ||
``` | ||
|
||
## Using configuration files | ||
|
||
The following example demonstrates how to use a configuration file to define the instruments available to pybench. | ||
|
||
We will use the following configuration file ("bench.yaml") to define the instruments available to pybench: | ||
```yaml | ||
siggen: | ||
address: "TCPIP::192.168.1.2::inst0::INSTR" | ||
type: SMA100A | ||
``` | ||
|
||
Next we will use the configuration file to create an instance of the signal generator instrument. By default pybench will look in the local directory for the configuration file. If the configuration file is not found, pybench will look in the global configuration directory based on the class property *config_locations*. | ||
```python | ||
siggen = SMA100A.from_config(use_config_file=True) | ||
|
||
# Set the frequency to 1 GHz | ||
siggen.frequency = 1e9 | ||
|
||
# Set the output power to -10 dBm | ||
siggen.level = -10 | ||
|
||
# Enable the output | ||
siggen.output_enable = True | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# pytest | ||
|
||
pybench can be integrated with pytest by either directly using instrument classes or by leveraging the `pytest` fixtures provided by pybench. The fixtures are designed to help manage the lifecycle of the instrument and the data acquisition process. This also includes requiring instruments for tests, or making them interchangeable based on what a user has physical access to. | ||
|
||
## CLI options | ||
|
||
The following CLI options are available for use with pytest: | ||
|
||
- `--confifile`: Path to the configuration file to use for the test run. If not provided, the default configuration file will be used. This is the configuration that defines which instruments are available and their addresses. | ||
|
||
## Available fixtures | ||
|
||
The following fixtures are available for use in your tests: | ||
|
||
- `instrument_addresses`: A fixture that returns a list of all available instruments of those specified in the configuration file. | ||
- `instrument_address_session`: A fixture that returns a session-scoped instrument address. This is useful for tests that require an instrument to be available for the duration of all tests. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.