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:
32
src/py_dvt_ate/instruments/scpi.py
Normal file
32
src/py_dvt_ate/instruments/scpi.py
Normal 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("?")
|
||||||
Reference in New Issue
Block a user