Any interest in allowing responses to be generated by a Python expression? The assumption is that any referenced library, such as numpy and random, would have to be already imported into the simulation library, (or we would need some way to dynamically specify an import list).
Example: Simple inline expression that returns a random value as requested in Random values as response #49
dialogues:
- q: ":MEAS:VOLT?"
r: "{EXPR(random.choice(["AUTO", "NORMAL", "ETC"])}"
Example: Simple inline expression that returns 10 volt sinewave array of 100 points
dialogues:
- q: ":FETCH?"
r: "{EXPR(10 * numpy.sin(2 * numpy.pi * 2.0 * numpy.arange(100) / 100)):.1f}"
Example: Simple inline expression that returns 10 volt sinewave where sample count could reference another property, i.e., {samples}
dialogues:
- q: ":FETCH?"
r: "{EXPR(10 * numpy.sin(2 * numpy.pi * 2.0 * numpy.arange({samples}) / {samples})):.1f}"
properties:
samples:
default: 1
getter:
q: ":SAMP:COUN?"
r: "{:d}"
setter:
q: ":SAMP:COUN {:d}"
specs:
type: int
Any interest in allowing responses to be generated by a Python expression? The assumption is that any referenced library, such as numpy and random, would have to be already imported into the simulation library, (or we would need some way to dynamically specify an import list).
Example: Simple inline expression that returns a random value as requested in Random values as response #49
Example: Simple inline expression that returns 10 volt sinewave array of 100 points
Example: Simple inline expression that returns 10 volt sinewave where sample count could reference another property, i.e., {samples}