mirror of
https://github.com/ARM-software/devlib.git
synced 2025-01-31 02:00:45 +00:00
instrument: allow specifying channels in reset()
Prior to this commit, measurements to be collected were specified via "sites" and "kinds" parameters. This has the limitation that if you wanted measurments of kind X from site A and kind Y from site B, you'd have to specify them as reset(sites=['A', 'B'], kinds=['X', 'Y']) Which would have the effect of also collecting measurments Y for site A and measurments X for site B. This commit adds the option of specifying individual channels, via thier labels, e.g. reset(channels=['A_X', 'B_Y']) so that only the channels you're interested in will be collected.
This commit is contained in:
parent
d7aac2b5df
commit
390a544a92
@ -195,8 +195,8 @@ class Instrument(object):
|
||||
def teardown(self):
|
||||
pass
|
||||
|
||||
def reset(self, sites=None, kinds=None):
|
||||
if kinds is None and sites is None:
|
||||
def reset(self, sites=None, kinds=None, channels=None):
|
||||
if kinds is None and sites is None and channels is None:
|
||||
self.active_channels = sorted(self.channels.values(), key=lambda x: x.label)
|
||||
else:
|
||||
if isinstance(sites, basestring):
|
||||
@ -204,6 +204,12 @@ class Instrument(object):
|
||||
if isinstance(kinds, basestring):
|
||||
kinds = [kinds]
|
||||
self.active_channels = []
|
||||
for chan_name in (channels or []):
|
||||
try:
|
||||
self.active_channels.append(self.channels[chan_name])
|
||||
except KeyError:
|
||||
msg = 'Unexpected channel "{}"; must be in {}'
|
||||
raise ValueError(msg.format(chan_name, self.channels.keys()))
|
||||
for chan in self.channels.values():
|
||||
if (kinds is None or chan.kind in kinds) and \
|
||||
(sites is None or chan.site in sites):
|
||||
|
@ -60,8 +60,8 @@ class DaqInstrument(Instrument):
|
||||
for kind in ['power', 'voltage']:
|
||||
self.add_channel(label, kind)
|
||||
|
||||
def reset(self, sites=None, kinds=None):
|
||||
super(DaqInstrument, self).reset(sites, kinds)
|
||||
def reset(self, sites=None, kinds=None, channels=None):
|
||||
super(DaqInstrument, self).reset(sites, kinds, channels)
|
||||
self.execute('close')
|
||||
result = self.execute('configure', config=self.device_config)
|
||||
if not result.status == Status.OK: # pylint: disable=no-member
|
||||
|
@ -64,8 +64,8 @@ class EnergyProbeInstrument(Instrument):
|
||||
for kind in self.attributes:
|
||||
self.add_channel(label, kind)
|
||||
|
||||
def reset(self, sites=None, kinds=None):
|
||||
super(EnergyProbeInstrument, self).reset(sites, kinds)
|
||||
def reset(self, sites=None, kinds=None, channels=None):
|
||||
super(EnergyProbeInstrument, self).reset(sites, kinds, channels)
|
||||
self.raw_output_directory = tempfile.mkdtemp(prefix='eprobe-caiman-')
|
||||
parts = ['-r {}:{} '.format(i, int(1000 * rval))
|
||||
for i, rval in enumerate(self.resistor_values)]
|
||||
|
@ -98,8 +98,8 @@ class NetstatsInstrument(Instrument):
|
||||
self.logger.debug('Deploying {} to target'.format(self.package))
|
||||
self.target.install(self.apk)
|
||||
|
||||
def reset(self, sites=None, kinds=None, period=None): # pylint: disable=arguments-differ
|
||||
super(NetstatsInstrument, self).reset(sites, kinds)
|
||||
def reset(self, sites=None, kinds=None, channels=None, period=None): # pylint: disable=arguments-differ
|
||||
super(NetstatsInstrument, self).reset(sites, kinds, channels)
|
||||
period_arg, packages_arg = '', ''
|
||||
self.tag = 'netstats-{}'.format(datetime.now().strftime('%Y%m%d%H%M%s'))
|
||||
tag_arg = ' --es tag {}'.format(self.tag)
|
||||
|
Loading…
x
Reference in New Issue
Block a user