forked from M-Labs/thermostat
Compare commits
4 Commits
54296c88b4
...
1fc5f7d5ae
Author | SHA1 | Date | |
---|---|---|---|
1fc5f7d5ae | |||
c632a85ce8 | |||
9af86be674 | |||
eabc7f6a12 |
14
flake.nix
14
flake.nix
@ -57,10 +57,22 @@
|
|||||||
dontFixup = true;
|
dontFixup = true;
|
||||||
auditable = false;
|
auditable = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pytec = pkgs.python3Packages.buildPythonPackage {
|
||||||
|
pname = "pytec";
|
||||||
|
version = "0.0.0";
|
||||||
|
src = "${self}/pytec";
|
||||||
|
|
||||||
|
propagatedBuildInputs =
|
||||||
|
with pkgs.python3Packages; [
|
||||||
|
numpy
|
||||||
|
matplotlib
|
||||||
|
];
|
||||||
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
packages.x86_64-linux = {
|
packages.x86_64-linux = {
|
||||||
inherit thermostat;
|
inherit thermostat pytec;
|
||||||
default = thermostat;
|
default = thermostat;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import time
|
||||||
from pytec.client import Client
|
from pytec.client import Client
|
||||||
|
|
||||||
tec = Client() #(host="localhost", port=6667)
|
tec = Client() #(host="localhost", port=6667)
|
||||||
@ -7,5 +8,6 @@ print(tec.get_pid())
|
|||||||
print(tec.get_output())
|
print(tec.get_output())
|
||||||
print(tec.get_postfilter())
|
print(tec.get_postfilter())
|
||||||
print(tec.get_b_parameter())
|
print(tec.get_b_parameter())
|
||||||
for data in tec.report_mode():
|
while True:
|
||||||
print(data)
|
print(tec.get_report())
|
||||||
|
time.sleep(0.05)
|
||||||
|
@ -4,6 +4,8 @@ import matplotlib.animation as animation
|
|||||||
from threading import Thread, Lock
|
from threading import Thread, Lock
|
||||||
from pytec.client import Client
|
from pytec.client import Client
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
TIME_WINDOW = 300.0
|
TIME_WINDOW = 300.0
|
||||||
|
|
||||||
tec = Client()
|
tec = Client()
|
||||||
@ -116,7 +118,7 @@ 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()
|
||||||
|
|
||||||
@ -126,3 +128,7 @@ ani = animation.FuncAnimation(
|
|||||||
plt.show()
|
plt.show()
|
||||||
quit = True
|
quit = True
|
||||||
thread.join()
|
thread.join()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import socket
|
import socket
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import time
|
|
||||||
|
|
||||||
class CommandError(Exception):
|
class CommandError(Exception):
|
||||||
pass
|
pass
|
||||||
@ -147,36 +147,6 @@ class Client:
|
|||||||
"""Get Thermostat hardware revision"""
|
"""Get Thermostat hardware revision"""
|
||||||
return self._command("hwrev")
|
return self._command("hwrev")
|
||||||
|
|
||||||
def report_mode(self):
|
|
||||||
"""Start reporting measurement values
|
|
||||||
|
|
||||||
Example of yielded data::
|
|
||||||
{'channel': 0,
|
|
||||||
'time': 2302524,
|
|
||||||
'adc': 0.6199188965423515,
|
|
||||||
'sens': 6138.519310282602,
|
|
||||||
'temperature': 36.87032392655527,
|
|
||||||
'pid_engaged': True,
|
|
||||||
'i_set': 2.0635816680889123,
|
|
||||||
'vref': 1.494,
|
|
||||||
'dac_value': 2.527790834044456,
|
|
||||||
'dac_feedback': 2.523,
|
|
||||||
'i_tec': 2.331,
|
|
||||||
'tec_i': 2.0925,
|
|
||||||
'tec_u_meas': 2.5340000000000003,
|
|
||||||
'pid_output': 2.067581958092247}
|
|
||||||
"""
|
|
||||||
while True:
|
|
||||||
self._socket.sendall("report\n".encode('utf-8'))
|
|
||||||
line = self._read_line()
|
|
||||||
if not line:
|
|
||||||
break
|
|
||||||
try:
|
|
||||||
yield json.loads(line)
|
|
||||||
except json.decoder.JSONDecodeError:
|
|
||||||
pass
|
|
||||||
time.sleep(0.05)
|
|
||||||
|
|
||||||
def set_param(self, topic, channel, field="", value=""):
|
def set_param(self, topic, channel, field="", value=""):
|
||||||
"""Set configuration parameters
|
"""Set configuration parameters
|
||||||
|
|
||||||
|
@ -9,4 +9,11 @@ setup(
|
|||||||
license="GPLv3",
|
license="GPLv3",
|
||||||
install_requires=["setuptools"],
|
install_requires=["setuptools"],
|
||||||
packages=find_packages(),
|
packages=find_packages(),
|
||||||
|
entry_points={
|
||||||
|
"gui_scripts": [
|
||||||
|
"thermostat_autotune = autotune:main",
|
||||||
|
"thermostat_plot = plot:main",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
py_modules=["autotune", "plot"],
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user