Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple getters and setters for a property? #69

Open
dougthor42 opened this issue Feb 17, 2023 · 1 comment
Open

Multiple getters and setters for a property? #69

dougthor42 opened this issue Feb 17, 2023 · 1 comment

Comments

@dougthor42
Copy link
Contributor

The Keysight and Agilent instrument lines typically implement commands that can have various forms. For example, all of these are the same command:

# Definition:
[:SOURce[c]]:FUNCtion[:SHAPe] shape
shape: PULSe|DC

# Accepted:
:SOURCE1:FUNCTION:SHAPE DC
:SOURCE1:FUNC:SHAP PULS
:SOURCE:FUNC:SHAPE PULSE
:FUNCTION dc
:func:shape pulse
... and many more.

Is there support for multiple getters and setters for a property? A naive implementation would allow just repeating the property name:

properties:
  source_function_shape:
    getter:
      q: ":SOURCE:FUNCTION:SHAPE?"
      r: {}
    setter:
      q: ":SOURCE:FUCTION:SHAPE {}"
    valid: ["DC", "PULS", "PULSE"]
  source_function_shape:  # same property name so that ":SOUR:FUNC:SHAP?" returns the same as ":SOURCE:FUNCTION:SHAPE?"
    getter:
      q: ":SOUR:FUNC:SHAP?"
      r: {}
    setter:
      q: ":SOUR:FUCN:SHAP {}"
    valid: ["DC", "PULS", "PULSE"]

But this ends up being very verbose.

Can regex be used for getter and setter commands?

properties:
  source_function_shape:
    getter:
      q: ':(SOUR(CE)?\d?)?:FUNC(TION)?:SHAPE?\?'
      r: {}
    setter:
      q: ':(SOUR(CE)?\d?)?:FUNC(TION)?:SHAP(E)? \{\}'
    valid: ["DC", "PULS", "PULSE"]
@MatthieuDartiailh
Copy link
Member

Technically we need is to generate a SCPI parser for such cases. The best would be to simply generate the regex from a SCPI string internally but we would need a way to opt in/out of this mechanism. I won't have time to look into this but I will make time to review a PR if you feel like addressing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants