From f2e27384e21676ab92664c9e8d99f46a20816195 Mon Sep 17 00:00:00 2001 From: Sebastian Steuer Date: Sat, 30 Nov 2013 01:42:35 +0100 Subject: [PATCH] backlog ui --- ovenWatcher.py | 16 ++++++++++++++-- picoreflowd.py | 2 +- public/assets/js/picoreflow.js | 15 +++++++++++++-- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/ovenWatcher.py b/ovenWatcher.py index 1dce6a4..a242eac 100644 --- a/ovenWatcher.py +++ b/ovenWatcher.py @@ -11,6 +11,7 @@ class OvenWatcher(threading.Thread): self.observers = [] threading.Thread.__init__(self) self.daemon = True + self.log_skip_counter = 0 self.oven = oven self.start() @@ -20,10 +21,12 @@ class OvenWatcher(threading.Thread): oven_state = self.oven.get_state() if oven_state.get("state") == Oven.STATE_RUNNING: - self.last_log.append(oven_state) + if self.log_skip_counter==0: + self.last_log.append(oven_state) else: self.recording = False self.notify_all(oven_state) + self.log_skip_counter = (self.log_skip_counter +1)%20 time.sleep(0.5) def record(self, profile): @@ -33,9 +36,18 @@ class OvenWatcher(threading.Thread): self.recording = True def add_observer(self,observer): + if self.last_profile: + p = { + "name": self.last_profile.name, + "data": self.last_profile.data, + "type" : "profile" + } + else: + p = None + backlog = { 'type': "backlog", - 'profile': self.last_profile, + 'profile': p, 'log': self.last_log, #'started': self.started } diff --git a/picoreflowd.py b/picoreflowd.py index f4bab2e..68cc6cd 100644 --- a/picoreflowd.py +++ b/picoreflowd.py @@ -55,7 +55,7 @@ def handle_control(): profile_json = json.dumps(profile_obj) profile = Profile(profile_json) oven.run_profile(profile) - ovenWatcher.record(profile_json) + ovenWatcher.record(profile) elif msgdict.get("cmd") == "STOP": log.info("Stop command received") oven.abort_run() diff --git a/public/assets/js/picoreflow.js b/public/assets/js/picoreflow.js index 4c997b3..d80349e 100644 --- a/public/assets/js/picoreflow.js +++ b/public/assets/js/picoreflow.js @@ -181,8 +181,7 @@ function getOptions() font: { size: 12, - lineHeight: 14, - weight: "normal", + lineHeight: 14, weight: "normal", family: "LCDN", variant: "small-caps", color: "rgba(216, 211, 197, 0.85)" @@ -276,6 +275,18 @@ $(document).ready(function() { x = JSON.parse(e.data); + if (x.type == "backlog") + { + if (x.profile) + { + selected_profile_name = x.profile.name; + } + + $.each(x.log, function(i,v) { + graph.live.data.push([v.runtime, v.temperature]); + graph.plot = $.plot("#graph_container", [ graph.profile, graph.live ] , getOptions()); + }); + } if(state!="EDIT") { state = x.state;