PyThermostat: Add entry points to runnable scripts #149
@ -5,13 +5,15 @@ import matplotlib.animation as animation
|
|||||||
from threading import Thread, Lock
|
from threading import Thread, Lock
|
||||||
from pythermostat.client import Client
|
from pythermostat.client import Client
|
||||||
|
|
||||||
TIME_WINDOW = 300.0
|
|
||||||
|
|
||||||
tec = Client()
|
def main():
|
||||||
target_temperature = tec.get_pid()[0]['target']
|
TIME_WINDOW = 300.0
|
||||||
print("Channel 0 target temperature: {:.3f}".format(target_temperature))
|
|
||||||
|
|
||||||
class Series:
|
tec = Client()
|
||||||
|
target_temperature = tec.get_pid()[0]['target']
|
||||||
|
print("Channel 0 target temperature: {:.3f}".format(target_temperature))
|
||||||
|
|
||||||
|
class Series:
|
||||||
def __init__(self, conv=lambda x: x):
|
def __init__(self, conv=lambda x: x):
|
||||||
self.conv = conv
|
self.conv = conv
|
||||||
self.x_data = []
|
self.x_data = []
|
||||||
@ -28,7 +30,7 @@ class Series:
|
|||||||
self.x_data = self.x_data[drop:]
|
self.x_data = self.x_data[drop:]
|
||||||
self.y_data = self.y_data[drop:]
|
self.y_data = self.y_data[drop:]
|
||||||
|
|
||||||
series = {
|
series = {
|
||||||
# 'adc': Series(),
|
# 'adc': Series(),
|
||||||
# 'sens': Series(lambda x: x * 0.0001),
|
# 'sens': Series(lambda x: x * 0.0001),
|
||||||
'temperature': Series(),
|
'temperature': Series(),
|
||||||
@ -41,12 +43,12 @@ series = {
|
|||||||
'tec_i': Series(),
|
'tec_i': Series(),
|
||||||
'tec_u_meas': Series(),
|
'tec_u_meas': Series(),
|
||||||
# 'interval': Series(),
|
# 'interval': Series(),
|
||||||
}
|
}
|
||||||
series_lock = Lock()
|
series_lock = Lock()
|
||||||
|
|
||||||
quit = False
|
quit = False
|
||||||
|
|
||||||
def recv_data(tec):
|
def recv_data(tec):
|
||||||
global last_packet_time
|
global last_packet_time
|
||||||
while True:
|
while True:
|
||||||
data = tec.get_report()
|
data = tec.get_report()
|
||||||
@ -65,16 +67,16 @@ def recv_data(tec):
|
|||||||
break
|
break
|
||||||
time.sleep(0.05)
|
time.sleep(0.05)
|
||||||
|
|
||||||
thread = Thread(target=recv_data, args=(tec,))
|
thread = Thread(target=recv_data, args=(tec,))
|
||||||
thread.start()
|
thread.start()
|
||||||
|
|
||||||
fig, ax = plt.subplots()
|
fig, ax = plt.subplots()
|
||||||
|
|
||||||
for k, s in series.items():
|
for k, s in series.items():
|
||||||
s.plot, = ax.plot([], [], label=k)
|
s.plot, = ax.plot([], [], label=k)
|
||||||
legend = ax.legend()
|
legend = ax.legend()
|
||||||
|
|
||||||
def animate(i):
|
def animate(i):
|
||||||
min_x, max_x, min_y, max_y = None, None, None, None
|
min_x, max_x, min_y, max_y = None, None, None, None
|
||||||
|
|
||||||
series_lock.acquire()
|
series_lock.acquire()
|
||||||
@ -119,13 +121,17 @@ def animate(i):
|
|||||||
margin_y = 0.01 * (max_y - min_y)
|
margin_y = 0.01 * (max_y - min_y)
|
||||||
ax.set_ylim(min_y - margin_y, max_y + margin_y)
|
ax.set_ylim(min_y - margin_y, max_y + margin_y)
|
||||||
|
|
||||||
global legend
|
nonlocal legend
|
||||||
legend.remove()
|
legend.remove()
|
||||||
legend = ax.legend()
|
legend = ax.legend()
|
||||||
|
|
||||||
ani = animation.FuncAnimation(
|
ani = animation.FuncAnimation(
|
||||||
fig, animate, interval=1, blit=False, save_count=50)
|
fig, animate, interval=1, blit=False, save_count=50)
|
||||||
|
|
||||||
plt.show()
|
plt.show()
|
||||||
quit = True
|
quit = True
|
||||||
thread.join()
|
thread.join()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
@ -9,4 +9,13 @@ setup(
|
|||||||
license="GPLv3",
|
license="GPLv3",
|
||||||
install_requires=["setuptools"],
|
install_requires=["setuptools"],
|
||||||
packages=find_packages(),
|
packages=find_packages(),
|
||||||
|
entry_points={
|
||||||
|
"gui_scripts": [
|
||||||
|
"thermostat_plot = pythermostat.plot:main",
|
||||||
|
],
|
||||||
|
"console_scripts": [
|
||||||
|
"thermostat_autotune = pythermostat.autotune:main",
|
||||||
|
"thermostat_test = pythermostat.test:main",
|
||||||
|
]
|
||||||
|
},
|
||||||
)
|
)
|
||||||
atse marked this conversation as resolved
Outdated
|
|||||||
|
Loading…
Reference in New Issue
Block a user
Looks suspicious to me that ARTIQ also has several entry points but does not use
py_modules
and the entry points are prefixed withartiq.
.Fixed, no need for
py_modules
now but depends on #155.