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