- added log file to tempLogger
git-svn-id: http://moon:8086/svn/projects/HendiControl@202 fda53097-d464-4ada-af97-ba876c37ca34
This commit is contained in:
@@ -8,7 +8,8 @@ from tempSensorSim import TempSensorSim
|
|||||||
#from max31865 import Max31865
|
#from max31865 import Max31865
|
||||||
|
|
||||||
class TempLogger():
|
class TempLogger():
|
||||||
def __init__(self, sensor):
|
def __init__(self, sensor, filename="temp.log"):
|
||||||
|
self.filename = filename
|
||||||
self.sensor = sensor
|
self.sensor = sensor
|
||||||
self.temps = np.empty(0)
|
self.temps = np.empty(0)
|
||||||
self.times = np.empty(0)
|
self.times = np.empty(0)
|
||||||
@@ -33,16 +34,19 @@ class TempLogger():
|
|||||||
dt = args[0]
|
dt = args[0]
|
||||||
duration = args[1]
|
duration = args[1]
|
||||||
|
|
||||||
|
fp = open(self.filename, 'w')
|
||||||
for t in range(0, duration):
|
for t in range(0, duration):
|
||||||
temp = self.sensor.temperature()
|
temp = self.sensor.temperature()
|
||||||
print ("Current temperature is {:0.2f} °C".format(temp))
|
print ("Current temperature is {:0.2f} °C".format(temp))
|
||||||
self.times = np.append(self.times, self.count)
|
self.times = np.append(self.times, self.count)
|
||||||
self.temps = np.append(self.temps, temp)
|
self.temps = np.append(self.temps, temp)
|
||||||
|
fp.write("{:04d} {:0.2f}\n".format(self.count, temp))
|
||||||
self.count += 1
|
self.count += 1
|
||||||
time.sleep(dt)
|
time.sleep(dt)
|
||||||
if self.abort:
|
if self.abort:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
fp.close()
|
||||||
self.sema.release()
|
self.sema.release()
|
||||||
|
|
||||||
def wait(self):
|
def wait(self):
|
||||||
@@ -66,7 +70,7 @@ if __name__ == '__main__':
|
|||||||
# sensor = Max31865()
|
# sensor = Max31865()
|
||||||
sensor = TempSensorSim("FakeTemp")
|
sensor = TempSensorSim("FakeTemp")
|
||||||
logger = TempLogger(sensor)
|
logger = TempLogger(sensor)
|
||||||
logger.start(1.0, 10)
|
logger.start(0.1, 10)
|
||||||
logger.wait()
|
logger.wait()
|
||||||
result = logger.result()
|
result = logger.result()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user