kopia lustrzana https://github.com/jamesgao/kiln_controller
JSON has immense hatred of NaN values
rodzic
61721b936a
commit
4230a71665
|
@ -152,6 +152,9 @@ class Profile(threading.Thread):
|
||||||
self.pid.setPoint(setpoint)
|
self.pid.setPoint(setpoint)
|
||||||
|
|
||||||
temp = self.therm.temperature.temp
|
temp = self.therm.temperature.temp
|
||||||
|
if temp == -1:
|
||||||
|
continue #skip invalid temperature readings
|
||||||
|
|
||||||
pid_out = self.pid.update(temp)
|
pid_out = self.pid.update(temp)
|
||||||
if pid_out < 0: pid_out = 0
|
if pid_out < 0: pid_out = 0
|
||||||
if pid_out > 1: pid_out = 1
|
if pid_out > 1: pid_out = 1
|
||||||
|
|
|
@ -5,7 +5,6 @@ import os
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
import json
|
import json
|
||||||
import math
|
|
||||||
import traceback
|
import traceback
|
||||||
import inspect
|
import inspect
|
||||||
|
|
||||||
|
@ -39,7 +38,7 @@ class MainHandler(ManagerHandler):
|
||||||
|
|
||||||
return self.render(os.path.join(paths.html_templates, "main.html"),
|
return self.render(os.path.join(paths.html_templates, "main.html"),
|
||||||
state=self.manager.state.__class__.__name__,
|
state=self.manager.state.__class__.__name__,
|
||||||
state_data=json.dumps(self.manager.state.status, allow_nan=False),
|
state_data=json.dumps(self.manager.state.status),
|
||||||
profiles=profiles,
|
profiles=profiles,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -120,7 +119,7 @@ class WebApp(object):
|
||||||
self.port = port
|
self.port = port
|
||||||
|
|
||||||
def send(self, data):
|
def send(self, data):
|
||||||
jsondat = json.dumps(data, allow_nan=False)
|
jsondat = json.dumps(data)
|
||||||
for sock in self.clients:
|
for sock in self.clients:
|
||||||
sock.write_message(jsondat)
|
sock.write_message(jsondat)
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import datetime
|
||||||
import logging
|
import logging
|
||||||
import threading
|
import threading
|
||||||
from collections import deque, namedtuple
|
from collections import deque, namedtuple
|
||||||
|
from math import isnan
|
||||||
|
|
||||||
logger = logging.getLogger("thermo")
|
logger = logging.getLogger("thermo")
|
||||||
|
|
||||||
|
@ -82,11 +83,12 @@ class Breakout(object):
|
||||||
|
|
||||||
def get(self):
|
def get(self):
|
||||||
time.sleep(.25)
|
time.sleep(.25)
|
||||||
return tempsample(time.time(), self.device.temperature)
|
temp = self.device.temperature if not isnan(self.device.temperature) else -1
|
||||||
|
return tempsample(time.time(), temp)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def temperature(self):
|
def temperature(self):
|
||||||
return self.device.temperature
|
return self.device.temperature if not isnan(self.device.temperature) else -1
|
||||||
|
|
||||||
class Monitor(threading.Thread):
|
class Monitor(threading.Thread):
|
||||||
def __init__(self, cls=MAX31850, **kwargs):
|
def __init__(self, cls=MAX31850, **kwargs):
|
||||||
|
|
Ładowanie…
Reference in New Issue