mirror of
https://github.com/ARM-software/devlib.git
synced 2025-04-18 07:40:04 +01:00
InstrumentChannel: name is now an alias for label
In addition to a label constructed form the combination of site and measurment type, channels had a name that was specified on creation. This proven to be not particularly useful (there only being one instance of the name being set to something materially different from the label); and this has lead to channels being inconsistenly referenced (some times a channel is identified by its label, and sometimes by the name). This commit removes the name from __init__ arguments, and InstrumentChannel.name is now an alias for InstrumentChannel.label.
This commit is contained in:
parent
823ce718bf
commit
9192deb8ee
@ -175,14 +175,12 @@ class MeasurementsCsv(object):
|
|||||||
if entry.endswith(suffix):
|
if entry.endswith(suffix):
|
||||||
site = entry[:-len(suffix)]
|
site = entry[:-len(suffix)]
|
||||||
measure = mt
|
measure = mt
|
||||||
name = '{}_{}'.format(site, measure)
|
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
site = entry
|
site = entry
|
||||||
measure = 'unknown'
|
measure = 'unknown'
|
||||||
name = entry
|
|
||||||
|
|
||||||
chan = InstrumentChannel(name, site, measure)
|
chan = InstrumentChannel(site, measure)
|
||||||
self.channels.append(chan)
|
self.channels.append(chan)
|
||||||
|
|
||||||
|
|
||||||
@ -192,6 +190,8 @@ class InstrumentChannel(object):
|
|||||||
def label(self):
|
def label(self):
|
||||||
return '{}_{}'.format(self.site, self.kind)
|
return '{}_{}'.format(self.site, self.kind)
|
||||||
|
|
||||||
|
name = label
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def kind(self):
|
def kind(self):
|
||||||
return self.measurement_type.name
|
return self.measurement_type.name
|
||||||
@ -200,8 +200,7 @@ class InstrumentChannel(object):
|
|||||||
def units(self):
|
def units(self):
|
||||||
return self.measurement_type.units
|
return self.measurement_type.units
|
||||||
|
|
||||||
def __init__(self, name, site, measurement_type, **attrs):
|
def __init__(self, site, measurement_type, **attrs):
|
||||||
self.name = name
|
|
||||||
self.site = site
|
self.site = site
|
||||||
if isinstance(measurement_type, MeasurementType):
|
if isinstance(measurement_type, MeasurementType):
|
||||||
self.measurement_type = measurement_type
|
self.measurement_type = measurement_type
|
||||||
@ -243,10 +242,8 @@ class Instrument(object):
|
|||||||
measure = measure.name
|
measure = measure.name
|
||||||
return [c for c in self.list_channels() if c.kind == measure]
|
return [c for c in self.list_channels() if c.kind == measure]
|
||||||
|
|
||||||
def add_channel(self, site, measure, name=None, **attrs):
|
def add_channel(self, site, measure, **attrs):
|
||||||
if name is None:
|
chan = InstrumentChannel(site, measure, **attrs)
|
||||||
name = '{}_{}'.format(site, measure)
|
|
||||||
chan = InstrumentChannel(name, site, measure, **attrs)
|
|
||||||
self.channels[chan.label] = chan
|
self.channels[chan.label] = chan
|
||||||
|
|
||||||
# initialization and teardown
|
# initialization and teardown
|
||||||
|
@ -45,7 +45,7 @@ class HwmonInstrument(Instrument):
|
|||||||
measure = self.measure_map.get(ts.kind)[0]
|
measure = self.measure_map.get(ts.kind)[0]
|
||||||
if measure:
|
if measure:
|
||||||
self.logger.debug('\tAdding sensor {}'.format(ts.name))
|
self.logger.debug('\tAdding sensor {}'.format(ts.name))
|
||||||
self.add_channel(_guess_site(ts), measure, name=ts.name, sensor=ts)
|
self.add_channel(_guess_site(ts), measure, sensor=ts)
|
||||||
else:
|
else:
|
||||||
self.logger.debug('\tSkipping sensor {} (unknown kind "{}")'.format(ts.name, ts.kind))
|
self.logger.debug('\tSkipping sensor {} (unknown kind "{}")'.format(ts.name, ts.kind))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
@ -210,22 +210,22 @@ class JunoEnergyInstrument(Instrument):
|
|||||||
mode = CONTINUOUS | INSTANTANEOUS
|
mode = CONTINUOUS | INSTANTANEOUS
|
||||||
|
|
||||||
_channels = [
|
_channels = [
|
||||||
InstrumentChannel('sys_curr', 'sys', 'current'),
|
InstrumentChannel('sys', 'current'),
|
||||||
InstrumentChannel('a57_curr', 'a57', 'current'),
|
InstrumentChannel('a57', 'current'),
|
||||||
InstrumentChannel('a53_curr', 'a53', 'current'),
|
InstrumentChannel('a53', 'current'),
|
||||||
InstrumentChannel('gpu_curr', 'gpu', 'current'),
|
InstrumentChannel('gpu', 'current'),
|
||||||
InstrumentChannel('sys_volt', 'sys', 'voltage'),
|
InstrumentChannel('sys', 'voltage'),
|
||||||
InstrumentChannel('a57_volt', 'a57', 'voltage'),
|
InstrumentChannel('a57', 'voltage'),
|
||||||
InstrumentChannel('a53_volt', 'a53', 'voltage'),
|
InstrumentChannel('a53', 'voltage'),
|
||||||
InstrumentChannel('gpu_volt', 'gpu', 'voltage'),
|
InstrumentChannel('gpu', 'voltage'),
|
||||||
InstrumentChannel('sys_pow', 'sys', 'power'),
|
InstrumentChannel('sys', 'power'),
|
||||||
InstrumentChannel('a57_pow', 'a57', 'power'),
|
InstrumentChannel('a57', 'power'),
|
||||||
InstrumentChannel('a53_pow', 'a53', 'power'),
|
InstrumentChannel('a53', 'power'),
|
||||||
InstrumentChannel('gpu_pow', 'gpu', 'power'),
|
InstrumentChannel('gpu', 'power'),
|
||||||
InstrumentChannel('sys_cenr', 'sys', 'energy'),
|
InstrumentChannel('sys', 'energy'),
|
||||||
InstrumentChannel('a57_cenr', 'a57', 'energy'),
|
InstrumentChannel('a57', 'energy'),
|
||||||
InstrumentChannel('a53_cenr', 'a53', 'energy'),
|
InstrumentChannel('a53', 'energy'),
|
||||||
InstrumentChannel('gpu_cenr', 'gpu', 'energy'),
|
InstrumentChannel('gpu', 'energy'),
|
||||||
]
|
]
|
||||||
|
|
||||||
def __init__(self, target):
|
def __init__(self, target):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user