Skip to content

Instantly share code, notes, and snippets.

@ColinBrosseau
ColinBrosseau / code
Created September 8, 2013 02:26
How to handle asymetric responce from an instrument
global SampleRateUnit
SampleRateUnit = {'Seconds': '0', 'Minutes': '1', 'Hours': '2',
'Days': '3', '%': '4'}
global SamplePeriodUnit
SamplePeriodUnit = {'Seconds': '0', 'Minutes': '1', 'Hours': '2',
'Days': '3', 'Weeks': '4', 'Pulses': '5'}
global TotalDurationUnit
TotalDurationUnit = {'Period': '0', 'Seconds': '1', 'Minutes': '2',
'Hours': '3', 'Days': '4', 'Weeks': '5', 'Continuous': '6',
'predefinded': '7'}
@ColinBrosseau
ColinBrosseau / comments
Created September 9, 2013 20:01
Fake getter/ real setter
Except for 2-3 exception, the Newport 842-PE doesn't have real getter functions, but it has many setters. But is has a function (sta) that read device status for a lot of parameters. The previous file do a fake getter/setter.
def status
returns a dict where the key/value pairs correspond to each device parameter.
At device initialisation, the device's configuration is read and stored in self.DeviceStatus
The getter scale just read corresponding parameter in self.DeviceStatus and return it.
The setter scale actually write to the device to change its state.