Open phsdv opened 9 years ago
In python-ivi, this was done at the top level by ensuring that there were no naming conflicts. However, this may not necessarily be the best method. The advantage of putting everything at the same level like this is this leverages python's duck typing system. The same instance works both as a scope and as a function generator.
Alex Forencich
On June 10, 2015 8:19:18 AM PDT, Paul notifications@github.com wrote:
Is there a nice way to use instruments in instruments?
For example in an oscilloscope there could be a function generator build in. It would be nice if we can program all the functions of this function generator in a separate file and class. This could than look like this:
with DSOX3000('USB0::0x0957::0x17A6::MY1234567::INSTR') as scope: scope.funcgen.function = "SINE" scope.funcgen.offset = 1.34 * V scope.funcgen.frequency = 23.45e+6 * Hz
Would this be possible and how should we write the funcgen class within the scope class?
Reply to this email directly or view it on GitHub: https://github.com/LabPy/lantz_drivers/issues/8
I guess we are going to hit again an issue similar to the one we had about channels in DC sources. My approach would be to do exactly what @phsdv suggests. The way to it using the lantz_core package is (Note that the BaseOscillope and BaseFuncGen classes does not exist):
class DSX(VisaMessageDriver, BaseOscilloscope):
funcgen = subsystem(BaseFuncGen)
with funcgen as f:
f.frequency = Float('getter string', 'setter string') # you can provide other options
Saddly I have currently no time to document Lantz core but don't hesitate to ask any questions you have.
@phsdv thanks a lot for updating the wiki !!!
I am trying to convert my drivers Lantz. I like the way Lantz works. And it will save time when programming real measurements.
I think it would be good to have a BaseOscilloscope class. As between different brands, there is a lot of same functionality like timebase, trigers, channel settings (V/div and offset) etc. And I would like to use the channel system for it too as almost every scope has 2, 4 or more channels, which uses subsystem, correct? Maybe we should open a new ticket in the driver section to discuss how the BaseOscilloscope class should look like? Or do you already have a discussion ongoing for this?
At the moment I have the funcgen module defined as separate instrument, however I prefer to make it a subsystem. For the subsystem I need the development version of Lantz, correct? It seems that I am not able to download the git repro using PIP into a virtual environment. Can someone tell me the right commands for this?
Opening a discussion about the BaseOscilloscope class is definitively the way to go. As we try to come up with kind of standards, looking first at what IVI does and seeing whether or not we can adapt it should be your first step. Doing the same for the BaseFuncGen would also make sense.
To use subsystems you need the lantz_core package (we are going to split Lantz in several smaller parts to make maintenance easier). To install a repo from git the easiest way to go is :
pip install https://github.com/LabPy/lantz_core/zipball/master
Saddly we have not yet completed the support for VISA based driver. There is an open PR for it. It lacks unit tests but I used it already so it should not be too bad. I will see with the others if we can merge it shortly (otherwise you can install my branch).
Channels are similar to subsytem in how you declare them yes. You need to use the channel object found in https://github.com/LabPy/lantz_core/blob/master/lantz_core/has_features.py, which takes a way to know what are the available channel and the base classes to use. In your case the first argument can simply be a tuple (1, 2) or (1, 2, 3, 4).
Is there a nice way to use instruments in instruments?
For example in an oscilloscope there could be a function generator build in. It would be nice if we can program all the functions of this function generator in a separate file and class. This could than look like this:
Would this be possible and how should we write the funcgen class within the scope class?