nibcq.switch.SwitchConfiguration
- class nibcq.switch.SwitchConfiguration
Represents the configuration for the switch system.
- topology
The switch topology being used (can be SwitchTopology enum or string). Only set to string if you know it is a supported topology type for your switch!
- cells
A list of channel connections for the DUTs. Can be either a list of SMUCellData objects or a list of strings, which are DUT channel names, when the device family is DMM.
- get_topology_string() str
Get the topology as a string value.
Converts the topology setting to its string representation, handling both SwitchTopology enum values and raw string values. This is used internally to build the full topology string for switch initialization.
- Returns:
The topology string value suitable for switch configuration
- Return type:
Examples
>>> config = SwitchConfiguration(SwitchTopology.SWITCH_2_WIRE_QUAD_16X1_MUX, ["ch0"]) >>> topology_str = config.get_topology_string() >>> print(topology_str) # "2-Wire Quad 16x1 Mux"
- classmethod from_file(config_path: str | pathlib.Path) SwitchConfiguration
Load switch configuration from a JSON file.
Reads a JSON configuration file and creates a SwitchConfiguration object with the appropriate settings for the switch topology and DUT channel mappings. Supports both DMM and SMU configuration formats.
- Parameters:
config_path (str or Path) – The path to the JSON configuration file. Must be a valid file path pointing to a properly formatted switch configuration JSON file.
- Returns:
- A new SwitchConfiguration object populated
with the configuration data from the file.
- Return type:
- Raises:
FileNotFoundError – If the configuration file doesn’t exist
json.JSONDecodeError – If the file contains invalid JSON
ValueError – If the file format is not compatible
Examples
>>> config = SwitchConfiguration.from_file("switch_config.json") >>> print(f"Loaded {len(config.cells)} DUT channels") >>> config = SwitchConfiguration.from_file(Path("config/dmm_switch.json"))
- classmethod from_json(data: dict) SwitchConfiguration
Load switch configuration from a JSON dictionary.
Creates a SwitchConfiguration object from a dictionary containing switch configuration data. Automatically detects whether the configuration is for DMM (simple channel list) or SMU (detailed cell data) based on the structure of the cells data.
- Parameters:
data (dict) – The JSON dictionary data containing configuration. Must include “Switches Topology” and “Cells” keys with appropriate values for the target device family.
- Returns:
- A new SwitchConfiguration object with:
List[str] cells for DMM configurations
List[SMUCellData] cells for SMU configurations
Topology as SwitchTopology enum if recognized, string otherwise
- Return type:
- Raises:
KeyError – If required keys are missing from the data dictionary
ValueError – If the data format is invalid or incompatible
Examples
>>> data = { ... "Switches Topology": "2-Wire Quad 16x1 Mux", ... "Cells": ["ch0", "ch1", "ch2"] ... } >>> config = SwitchConfiguration.from_json(data) # DMM format >>> >>> smu_data = { ... "Switches Topology": "2-Wire Quad 16x1 Mux", ... "Cells": [{"Cell Serial Number": "123", ...}] ... } >>> config = SwitchConfiguration.from_json(smu_data) # SMU format