- updated test
git-svn-id: http://moon:8086/svn/projects/HendiControl@192 fda53097-d464-4ada-af97-ba876c37ca34
This commit is contained in:
@@ -1,26 +1,43 @@
|
|||||||
import time
|
import time
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from max31865 import Max31865
|
|
||||||
from matplotlib.pyplot import figure, clf, plot, xlabel, ylabel, xlim, ylim, title, grid, axes, show, subplot
|
from matplotlib.pyplot import figure, clf, plot, xlabel, ylabel, xlim, ylim, title, grid, axes, show, subplot
|
||||||
|
|
||||||
|
from tempSensorSim import TempSensorSim
|
||||||
|
|
||||||
class TempLogger():
|
class TempLogger():
|
||||||
def __init__(self):
|
def __init__(self, sensor):
|
||||||
self.sensor = Max31865()
|
self.sensor = sensor
|
||||||
self.temps = np.empty(0)
|
self.temps = np.empty(0)
|
||||||
|
self.times = np.empty(0)
|
||||||
|
self.count = 0
|
||||||
|
|
||||||
def run(self, dt, duration):
|
def run(self, dt, duration):
|
||||||
|
|
||||||
for t in range(0, duration):
|
for t in range(0, duration):
|
||||||
temp = self.sensor.getTemperature()
|
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.temps = np.append(self.temps, temp)
|
self.temps = np.append(self.temps, temp)
|
||||||
|
self.count += 1
|
||||||
time.sleep(dt)
|
time.sleep(dt)
|
||||||
|
|
||||||
|
return self.result()
|
||||||
|
|
||||||
|
def result(self):
|
||||||
|
return self.times, self.temps
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
logger = TempLogger()
|
sensor = TempSensorSim("FakeTemp")
|
||||||
logger.run(1, 10)
|
logger = TempLogger(sensor)
|
||||||
|
result = logger.run(1, 10)
|
||||||
|
|
||||||
|
figure(1)
|
||||||
|
plot(result[0]/60, result[1], 'b-', linewidth=1)
|
||||||
|
|
||||||
|
ylabel('°C/min')
|
||||||
|
xlabel('t/min')
|
||||||
|
show()
|
||||||
|
|
||||||
print("End of program")
|
print("End of program")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user