forked from M-Labs/thermostat
Compare commits
1 Commits
adc25c9b2a
...
bc02819fca
Author | SHA1 | Date | |
---|---|---|---|
bc02819fca |
14
flake.nix
14
flake.nix
@ -57,22 +57,10 @@
|
||||
dontFixup = true;
|
||||
auditable = false;
|
||||
};
|
||||
|
||||
pytec = pkgs.python3Packages.buildPythonPackage {
|
||||
pname = "pytec";
|
||||
version = "0.0.0";
|
||||
src = "${self}/pytec";
|
||||
|
||||
propagatedBuildInputs =
|
||||
with pkgs.python3Packages; [
|
||||
numpy
|
||||
matplotlib
|
||||
];
|
||||
};
|
||||
in
|
||||
{
|
||||
packages.x86_64-linux = {
|
||||
inherit thermostat pytec;
|
||||
inherit thermostat;
|
||||
default = thermostat;
|
||||
};
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
import time
|
||||
from pytec.client import Client
|
||||
|
||||
tec = Client() #(host="localhost", port=6667)
|
||||
@ -8,6 +7,5 @@ print(tec.get_pid())
|
||||
print(tec.get_output())
|
||||
print(tec.get_postfilter())
|
||||
print(tec.get_b_parameter())
|
||||
while True:
|
||||
print(tec.get_report())
|
||||
time.sleep(0.05)
|
||||
for data in tec.report_mode():
|
||||
print(data)
|
||||
|
@ -1,7 +1,7 @@
|
||||
import socket
|
||||
import json
|
||||
import logging
|
||||
|
||||
import time
|
||||
|
||||
class CommandError(Exception):
|
||||
pass
|
||||
@ -147,6 +147,36 @@ class Client:
|
||||
"""Get Thermostat hardware revision"""
|
||||
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=""):
|
||||
"""Set configuration parameters
|
||||
|
||||
|
@ -9,8 +9,8 @@ CHANNELS = 2
|
||||
def get_argparser():
|
||||
parser = argparse.ArgumentParser(description="Thermostat hardware testing script")
|
||||
|
||||
parser.add_argument("host", metavar="HOST", default="192.168.1.26", nargs="?")
|
||||
parser.add_argument("port", metavar="PORT", default=23, nargs="?")
|
||||
parser.add_argument("HOST", metavar="host", default="192.168.1.26", nargs="?")
|
||||
parser.add_argument("PORT", metavar="port", default=23, nargs="?")
|
||||
parser.add_argument(
|
||||
"-r",
|
||||
"--testing_resistance",
|
||||
@ -35,7 +35,7 @@ def main():
|
||||
|
||||
print(min_allowed_resistance, max_allowed_resistance)
|
||||
|
||||
thermostat = Client(args.host, args.port)
|
||||
thermostat = Client(args.HOST, args.PORT)
|
||||
for channel in range(CHANNELS):
|
||||
print(f"Channel {channel} is active")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user