Save '<time>\t<bit_val>\t<physical_val>\n' records.
"""
- def __init__(self, channels=[0], temperature=False, dt=4,
- comedi_device='/dev/comedi0', data_stream=None, logger=None,
- plotter=None):
+ def __init__(self, channels=[0], temperature=False,
+ ambient_temperature=False, dt=4, comedi_device='/dev/comedi0',
+ data_stream=None, logger=None, plotter=None):
self.channel_indexes = channels
self.with_temperature = temperature
+ self.with_ambient_temperature = ambient_temperature
self.dt = dt
self.comedi_device = comedi_device
self.data_stream = data_stream
self.log(msg='chan {}, dt {}, data_stream {}'.format(
self.channel_indexes, self.dt, self.data_stream))
self._setup_channels()
- self._setup_temperature()
+ if self.with_temperature or self.with_ambient_temperature:
+ self._setup_temperature()
self._make_header()
def _setup_channels(self):
bitval,physical = self._measure_temperature()
bitvals.insert(0, bitval)
physicals.insert(0, physical)
+ if self.with_ambient_temperature:
+ bitval,physical = self._measure_ambient_temperature()
+ bitvals.insert(0, bitval)
+ physicals.insert(0, physical)
self._save_reading(tm, bitvals, physicals)
return (tm, bitvals, physicals)
bitvalue = -1 # self.temperature._read('INPUT_1') # or possibly ACTUALL_2, PROCESS_1, PROCESS_2
return (bitvalue, physical)
+ def _measure_ambient_temperature(self):
+ self.log(msg='measure ambient temperature')
+ physical = self.temperature.get_ambient_pv()
+ bitvalue = self.temperature._read('AMBIENT_A_D_COUNTS')
+ return (bitvalue, physical)
+
def _make_header(self):
'Create the save the data header'
fields = ['time (second)']
for c in self.channels]
if self.with_temperature:
names.insert(0, ('temperature', self.temperature.pv_units))
+ if self.with_ambient_temperature:
+ names.insert(0, ('ambient temperature', self.temperature.pv_units))
for name,unit in name_units:
fields.extend(['{} ({})'.format(name, u) for u in ['bit', unit]])
headline = '#{}'.format('\t'.join(fields))
parser.add_argument(
'-T', '--temperature', dest='temperature',
default=False, action='store_const', const=True,
- help='Also record the temperature')
+ help='Also record the temperature (thermocouple)')
+ parser.add_argument(
+ '-a', '--ambient-temperature', dest='ambient_temperature',
+ default=False, action='store_const', const=True,
+ help='Also record the ambient (room) temperature')
parser.add_argument(
'-p', '--plot', dest='plot',
default=False, action='store_const', const=True,
data_stream = _get_data_stream(data_dir=args.data_dir, logger=logger)
try:
m = Monitor(
- channels=args.channels, temperature=args.temperature, dt=args.dt,
+ channels=args.channels, temperature=args.temperature,
+ ambient_temperature=args.ambient_temperature, dt=args.dt,
data_stream=data_stream, logger=logger, plotter=plotter)
m.run()
finally: