Add SCPI command dataclass

Defines SCPICommand dataclass for parsed SCPI commands with:
- header: command header (e.g., "TEMP:SETPOINT")
- arguments: list of command arguments
- is_query: whether command is a query
- keyword property: header without trailing '?'
This commit is contained in:
2025-04-16 23:08:32 +00:00
parent 9e9c8b55f5
commit b309645f60

View File

@@ -0,0 +1,32 @@
"""SCPI command parsing.
This module provides SCPI (Standard Commands for Programmable Instruments)
command parsing for instrument communication. It handles IEEE 488.2 common
commands (*IDN?, *RST, etc.) and instrument-specific commands.
"""
from dataclasses import dataclass
@dataclass
class SCPICommand:
"""Parsed SCPI command.
Attributes:
header: The command header (e.g., "TEMP:SETPOINT" or "*IDN").
arguments: List of command arguments (e.g., ["85.0"]).
is_query: True if the command ends with '?' (query command).
"""
header: str
arguments: list[str]
is_query: bool
@property
def keyword(self) -> str:
"""Return the command keyword without '?'.
For query commands like "TEMP:SETPOINT?", returns "TEMP:SETPOINT".
For regular commands like "VOLT", returns "VOLT".
"""
return self.header.rstrip("?")