- added signal handlöer for plotting
git-svn-id: http://moon:8086/svn/projects/HendiControl@204 fda53097-d464-4ada-af97-ba876c37ca34
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import time
|
||||
import numpy as np
|
||||
from matplotlib.pyplot import figure, clf, plot, xlabel, ylabel, xlim, ylim, title, grid, axes, show, subplot
|
||||
@@ -59,27 +61,32 @@ class TempLogger():
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
def tempPlot(result):
|
||||
figure(1)
|
||||
plot(result[0]/60, result[1], 'b-', linewidth=1)
|
||||
|
||||
ylabel('°C/min')
|
||||
xlabel('t/min')
|
||||
show()
|
||||
|
||||
def handler(signum, frame):
|
||||
print('Signal handler called with signal', signum)
|
||||
|
||||
if signum == signal.SIGINT:
|
||||
logger.stop()
|
||||
|
||||
if signum == signal.SIGHUP:
|
||||
tempPlot(logger.result())
|
||||
|
||||
signal.signal(signal.SIGINT, handler)
|
||||
signal.signal(signal.SIGHUP, handler)
|
||||
|
||||
# sensor = Max31865()
|
||||
sensor = TempSensorSim("FakeTemp")
|
||||
logger = TempLogger(sensor)
|
||||
logger.start(0.1, 10)
|
||||
logger.start(1.0, 10)
|
||||
logger.wait()
|
||||
result = logger.result()
|
||||
|
||||
figure(1)
|
||||
plot(result[0]/60, result[1], 'b-', linewidth=1)
|
||||
|
||||
ylabel('°C/min')
|
||||
xlabel('t/min')
|
||||
show()
|
||||
tempPlot(logger.result())
|
||||
|
||||
print("End of program")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user