A simple application that requires a function generator and an oscilloscope.
| 26 | |
| 27 | |
| 28 | class AmplitudeScanner(Backend): |
| 29 | """A simple application that requires a function generator and an |
| 30 | oscilloscope. |
| 31 | """ |
| 32 | |
| 33 | # Enumerate drivers required by the backend marking them with InstrumentSlot |
| 34 | fungen = InstrumentSlot |
| 35 | osci = InstrumentSlot |
| 36 | |
| 37 | def scan_amplitude(self, amplitudes): |
| 38 | """For each amplitude: |
| 39 | - scan the amplitude of the function generator. |
| 40 | - sleeps .3 seconds. |
| 41 | - measures the trace of the oscilloscope. |
| 42 | - yields amplitude, data for each amplitude. |
| 43 | |
| 44 | :param amplitudes: iterable of amplitudes. |
| 45 | """ |
| 46 | for amplitude in amplitudes: |
| 47 | self.fungen.amplitude = amplitude |
| 48 | time.sleep(.3) |
| 49 | data = self.osci.measure() |
| 50 | yield amplitude, data |
| 51 | |
| 52 | def _scan_amplitude(self, amplitudes): |
| 53 | """Because scan_amplitude is a generator, this helper functions is used |
| 54 | to iterate over all the items. |
| 55 | """ |
| 56 | return list(self.scan_amplitude(amplitudes)) |
| 57 | |
| 58 | def default_scan(self): |
| 59 | """A linear scan from 1 to 19 Volts. |
| 60 | """ |
| 61 | return list(self.scan_amplitude(Q_(list(range(1, 20)), 'volt'))) |
| 62 | |
| 63 | |
| 64 | class AmplitudeScannerUi(Frontend): |
no outgoing calls
no test coverage detected