1. Safety
- Use Disable every connected channel before changing cabling.
- Software disconnect does not guarantee a physical output is off.
- This application is not a safety-rated interlock.
- Global enable requires confirmation; disable and disconnect controls are red.
2. Install and launch
py -m pip install cds_rigol_dg1022z
cds_rigol_dg1022z_state_manager
This second application is included beside the full control GUI, cds_rigol_dg1022z_gui. Its title shows the installed package version. The same dedicated three-AWG artwork is used for the GUI window, taskbar, and executable icon. Transparent PB LAB and Chip Design Systems marks are integrated into the bottom of the main GUI, with PB LAB aligned left and CDS aligned right.
3. AWG Control tab
A copyable Saved files path is always displayed at the top of the GUI. It points to %USERPROFILE%\PB_LAB\DG1022Z_Control, which contains the logs, reports, and SCPI Examples folders. Select Open folder to open that location in Windows Explorer.
First launch creates compact AWG cards. Each card has a clean connection bar with editable name, transport, endpoint, status, connect, and remove controls. Repeated field labels were replaced by tooltips. The RSF and output action bar stays hidden while disconnected and appears only after that AWG connects, greatly reducing visual clutter. Add more cards with Add AWG.
- Name the AWG.
- Select Ethernet or USB.
- Select a discovered endpoint or enter an Ethernet IP.
- Connect. Endpoint controls lock until red Disconnect is used.
- Refresh/recall an RSF or operate the outputs.
Connect all attempts every disconnected card sequentially and shows connected and failed counts. Global enable and disable likewise show a final result; individual failures are displayed immediately and retained in the live console.
Automatic control states
Every action follows its prerequisites. Unavailable actions stay visible but are greyed out: Connect requires a valid Ethernet address or discovered USB unit; disconnect locks transport, endpoint, and removal; RSF recall/export require a connected AWG and selected state; global output buttons require a connection; Run all requires a connected AWG with a loaded script; flash import requires a listed file; and Send requires a connected AWG plus a command. Tooltips explain what is missing.
The window scales from available screen geometry. On a typical 1920×1080 display, at least four compact AWG controls fit comfortably; additional cards remain scrollable.
Cards can be removed only while disconnected. Duplicate live USB serials and Ethernet addresses are rejected.
4. Discovery and connections
USB and Ethernet scans run automatically after startup. Scan USB and Ethernet repeats both scans at any time.
Ethernet discovery probes local and saved-address IPv4 /24 networks on SCPI port 5555 and verifies *IDN?. Routed networks may require a manual IP. USB discovery combines VISA/UltraSigma and direct USB-TMC, preferring VISA when it owns the Windows interface.
from cds_rigol_dg1022z import DG1022Z, discover_ethernet, discover_usb_connections
print(discover_ethernet())
print(discover_usb_connections())
awg = DG1022Z.ethernet("192.168.1.100")
awg.open()
5. SCPI Scripts tab
The second tab contains one script row for every configured AWG. Click Load TXT file, select a UTF-8 .txt file, connect the intended AWG, and click Run on this AWG. The path is saved with that AWG card and restored at the next launch.
Run all loaded scripts executes every connected AWG's saved script sequentially after one confirmation, reports failed AWGs, and refreshes the output-state strip. Individual script execution also refreshes state.
Per-AWG Run buttons are grey until that AWG is connected and has a remembered TXT path. Run all remains grey until at least one connected AWG is ready.
Click Open example scripts folder for editable examples covering read-only status, CH1 sine, CH2 square, dual-channel sine, AM, sweep, burst, and disabling all outputs/modes. Packaged examples are copied without overwriting existing files to %USERPROFILE%\PB_LAB\DG1022Z_Control\SCPI Examples.
Commands execute sequentially. Blank lines and lines beginning with # or // are comments. A command ending in ? is queried and its response appears in the live console. Other commands are writes. Execution stops at the first failure and reports its source line.
# Configure CH1 but leave its output safely disabled
:OUTP1 OFF
:SOUR1:APPL:SIN 1000,2,0,0
:SOUR1:FREQ?
:SYST:ERR?
from cds_rigol_dg1022z import load_scpi_script, execute_scpi_script
commands = load_scpi_script("rack_left.txt")
results = execute_scpi_script(awg, commands)
for item in results:
if item.response is not None:
print(item.line_number, item.command, item.response)
6. Searchable SCPI command reference
The Scripts tab includes a searchable command-and-description table. Replace <n> with channel 1 or 2. It covers IEEE common commands, status/errors, output/load/polarity, waveform setup, frequency, voltage, offset, phase, square/ramp/pulse controls, modulation, sweep, burst, trigger, counter, internal state, and flash-drive memory commands.
It is hidden initially to save space. A prominent blue Show SCPI Quick Reference button opens it and changes to an amber Hide SCPI Quick Reference button while expanded. The same independent searchable reference is available in both the SCPI Scripts and SCPI Command Sender tabs.
SCPI is case-insensitive; uppercase letters indicate the accepted abbreviation. Thus :SOURce1:FREQuency and :SOUR1:FREQ are equivalent. Separate parameters from the header with a space. Queries end in ?.
The embedded list describes all commands exercised by this application plus its common raw-SCPI workflows. Firmware can expose additional specialist commands; Rigol's DG1000Z Programming Guide is authoritative for complete firmware-specific grammar, ranges, defaults, and return formats.
5. Internal RSF states
After connection, Refresh RSF files lists populated USER1-USER10 slots. Select one and choose Recall selected RSF. The warning defaults to cancel. The selected RSF is remembered separately for each AWG and is automatically reselected after restart, reconnection, and the next successful RSF refresh.
states = awg.internal_state_files()
for state in states:
print(state.slot, state.filename)
awg.recall_internal_state(states[0].slot)
The generator front panel is authoritative because an RSF may contain settings outside this focused GUI.
Recall and export are separate
Recall RSF only applies the selected internal state and waits for completion, then immediately refreshes both output states. Generate settings TXT does not recall anything. It reads the AWG's current settings once and creates an editable SCPI reconstruction file. This separation makes recall fast and prevents an accidental second recall.
TXT capture covers outputs, load, polarity, waveform, frequency, amplitude, offset, phase, square/ramp/pulse parameters, AM/FM/PM, sweep, burst, and counter state. The filename includes the selected RSF name and the connected AWG serial number, for example 2026-08-02_12-30-00_My-Setup_DG1ZA123456789_settings.txt.
Because the capture requires many individual queries, it runs in a background worker. The GUI controls lock, a modal Generating settings TXT progress window remains visible, and controls unlock only after success or failure. One capture produces three matching files: HTML current-settings report, JSON data, and a reusable SCPI TXT. The TXT forces outputs off first, applies successfully queried settings, restores captured output states last, and ends with completion/error queries.
from cds_rigol_dg1022z import save_current_settings_txt
report = save_current_settings_txt(
awg,
rsf_name="My Setup.RSF",
serial_number=awg.identify().serial_number,
awg_name="Rack Left",
)
print(report.scpi_path)
Files are stored under %USERPROFILE%\PB_LAB\DG1022Z_Control\reports. Review a generated script before reuse because unsupported queries are omitted.
6. Output controls
The bottom-most GUI strip shows every AWG, connection state, and verified CH1/CH2 output state. It queries immediately after connection, recall, scripts, manual commands, and Refresh state. ON and OFF are based on device responses; a failed query displays ? instead of incorrectly showing OFF. It does not continuously query a dead network session, which could otherwise freeze the interface for repeated transport timeouts.
| Control | Scope and behavior |
|---|---|
| CH1 / CH2 | One channel on one AWG; reported state is verified. |
| Enable both | One AWG; confirmation required. |
| Disable both | One AWG; red immediate control. |
| Enable every connected channel | All AWGs; one confirmation. |
| Disable every connected channel | All AWGs; red immediate control. |
for awg in connected_awgs:
awg.channel(1).output_enabled = True
awg.channel(2).output_enabled = True
for awg in connected_awgs:
awg.outputs_off()
7. Flash RSF Import tab
- Insert a flash drive into the selected Rigol USB host port.
- Select a connected AWG.
- Enter
D:\or a starting folder. - List files; the GUI recursively searches that folder and subfolders such as
D:\RIGOL. - Select an RSF and USER destination.
- Select Load RSF and save internally and confirm.
files = awg.external_state_files("D:\\STATES")
selected = files[0]
awg.import_external_state(selected.filename, slot=4, directory=selected.directory)
*SAV USERn.After saving, the GUI renames the internal state from the default ScpiN.RSF to the USB filename and queries the name back to verify it. DG1000Z internal basenames are limited to nine uppercase letters or numbers, so a compatible name such as SETUP.RSF remains SETUP.RSF, while My Setup.RSF becomes MYSETUP.RSF. The confirmation dialog shows the resulting internal filename before import.
8. Saved application settings
Card names, order, transport, USB identifier or Ethernet address, last SCPI script, and last selected internal RSF are saved in per-user Qt settings whenever they change and during clean shutdown. They return on restart. If a saved device is powered off, its identifier remains assigned to the same card and is shown as unavailable. After it is powered on, the next scan automatically reselects it on that same card; connecting and refreshing RSF files restores that card's remembered RSF selection.
Connections and outputs deliberately do not reactivate automatically. Removing a card removes it from the next launch. With no saved configuration, three cards are created.
9. SCPI Command Sender tab
The live console below every tab and directly above the bottom AWG state strip captures GUI actions, SCPI writes, queries, responses, failures, connections, scripts, RSF operations, and output operations. Drag the thick blue horizontal divider to resize it; it turns amber on hover and the chosen size is restored next launch. Clearing the console does not delete log files.
Select a connected AWG, enter one command, and press Send command or Enter. A trailing ? sends a query and displays its response; other commands are writes. Failures appear in the sender history and live console. Read error queue drains that AWG's errors.
Use the high-visibility Show SCPI Quick Reference button below the sender history to open a searchable command table without leaving this tab.
%USERPROFILE%\PB_LAB\DG1022Z_Control\logs
Open reports folder opens saved RSF JSON/HTML comparisons. Open documentation displays this exact HTML page in the GUI.
10. Complete three-AWG Python workflow
from contextlib import ExitStack
from cds_rigol_dg1022z import DG1022Z
addresses = ["192.168.1.101", "192.168.1.102", "192.168.1.103"]
with ExitStack() as stack:
awgs = [stack.enter_context(DG1022Z.ethernet(ip)) for ip in addresses]
for awg in awgs:
print(awg.identify())
states = awg.internal_state_files()
if states:
awg.recall_internal_state(states[0].slot)
try:
for awg in awgs:
awg.channel(1).output_enabled = True
finally:
for awg in awgs:
awg.outputs_off()
11. Standalone executable
py -m pip install -e ".[build]"
pyinstaller --noconfirm AWG_State_Manager.spec
The build produces dist\PB-LAB-AWG-State-Manager.exe with Python, Qt, icon, HTML/PDF documentation, and USB dependencies. Ethernet needs no driver. USB still requires a compatible Windows interface or VISA runtime.
12. Troubleshooting
AWG not discovered
Rescan, verify the rear USB Device connection or Ethernet port 5555, and enter a known IP manually.
Flash drive not found or catalog times out
Use the Rigol front-panel USB host port, confirm the drive appears on its front panel, and start with D:\. Some firmware returns clipped display names for long folders. The recursive scanner checks shorter folder names first and skips an individual unreadable or clipped subfolder instead of discarding RSF files found elsewhere. A root-directory timeout is still reported as a flash catalog problem and is separate from internal RSF recall or settings TXT generation. For the most reliable instrument access, keep RSF filenames and their folder names short.
Import fails
Query errors; verify the RSF, directory, attached drive, and that the internal destination is unlocked.
Unexpected output
Use physical output keys and the red global disable control, then inspect the selected AWG log and error queue.