public
Rubygem
Description: Ruby gem to control a Rock's Bar-B-Que Stoker
Clone URL: git://github.com/tbuser/stoker.git
Click here to lend your support to: stoker and make a donation at www.pledgie.com !
more work on cook adjustments (something not working right as it doesn't 
create all the initial adjustments...)
tbuser (author)
Mon Jul 07 11:47:04 -0700 2008
commit  e036d5df2b3d9b88bec26e6e7eb162296c3ecbcf
tree    7fbc4e2f63aa8266d7a03b0d7e4fde0414bcc4d8
parent  45cca037d20c903e09c50304381a45a3d48aa22a
...
1
2
3
 
4
5
6
...
1
2
3
4
5
6
7
0
@@ -1,6 +1,7 @@
0
 web/log/*.log
0
 web/db/*.db
0
 web/db/*.sqlite3
0
+web/db/*.sqlite3-journal
0
 tmp/**/*
0
 web/doc/api
0
 web/doc/app
...
12
13
14
 
15
16
17
...
12
13
14
15
16
17
18
0
@@ -12,6 +12,7 @@ class CooksController < ApplicationController
0
   end
0
 
0
   def show
0
+ @adjustments = @cook.adjustments.find(:all, :order => "created_at DESC")
0
     @refresh = true
0
     
0
     params[:range] ||= @cook.running? ? "last" : "all"
...
8
9
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
12
13
...
22
23
24
25
 
26
...
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
...
40
41
42
 
43
44
0
@@ -8,6 +8,24 @@ class Adjustment < ActiveRecord::Base
0
   
0
   before_create :update_sensor
0
   
0
+ def differences
0
+ differences = {}
0
+
0
+ last_adjustment = self.sensor.adjustments.find(:first, :conditions => ["created_at < ?", self.created_at], :order => "created_at DESC")
0
+
0
+ [:target, :alarm, :low, :high, :blower].each do |setting|
0
+ if last_adjustment
0
+ if self.send(setting) != last_adjustment.send(setting)
0
+ differences[setting] = {:old => last_adjustment.send(setting), :new => self.send(setting)}
0
+ end
0
+ else
0
+ differences[setting] = {:old => "unknown", :new => self.send(setting)} unless self.send(setting) == nil
0
+ end
0
+ end
0
+
0
+ differences
0
+ end
0
+
0
   private
0
   
0
   def update_sensor
0
@@ -22,5 +40,5 @@ class Adjustment < ActiveRecord::Base
0
       errors.add_to_base "Failed to update sensor"
0
       false
0
     end
0
- end
0
+ end
0
 end
...
9
10
11
 
 
 
 
12
13
14
...
9
10
11
12
13
14
15
16
17
18
0
@@ -9,6 +9,10 @@ class Blower < ActiveRecord::Base
0
 
0
   before_update :update_net_stoker
0
 
0
+ def to_s
0
+ self.name
0
+ end
0
+
0
   def update_net_stoker
0
     if !Stoker.skip_update and (self.changed & ["name", "sensor_id"]).size > 0
0
       # spawn do
...
46
47
48
 
49
50
51
...
46
47
48
49
50
51
52
0
@@ -46,6 +46,7 @@ class Cook < ActiveRecord::Base
0
     Stoker.no_update do
0
       Cook.transaction do
0
         begin
0
+ puts "--------------> #{self.sensors.size}"
0
           self.sensors.each do |sensor|
0
             adjustment = self.adjustments.build(
0
               :sensor_id => sensor.id,
...
22
23
24
25
26
 
27
28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
30
31
...
22
23
24
 
 
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
0
@@ -22,10 +22,23 @@
0
 </p>
0
 
0
 <% if @cook.running? -%>
0
- <%= render :partial => "/sensors/list", :locals => {:sensors => @cook.sensors, :cook => @cook} %>
0
- <br/>
0
+ <p><%= render :partial => "/sensors/list", :locals => {:sensors => @cook.sensors, :cook => @cook} %></p>
0
 <% end -%>
0
 
0
+<p id="show_adjustments">
0
+ <%= link_to_function "Show Adjustments", "$('adjustments').show();$('show_adjustments').hide();" %>
0
+</p>
0
+
0
+<div id="adjustments" style="display:none">
0
+ <p id="hide_adjustments">
0
+ <%= link_to_function "Hide Adjustments", "$('adjustments').hide();$('show_adjustments').show();" %>
0
+ </p>
0
+
0
+ <hr/>
0
+
0
+ <%= render :partial => "adjustment", :collection => @adjustments %>
0
+</div>
0
+
0
 <% form_tag cook_path(@cook), :method => :get do %>
0
   <%= radio_button_tag :range, "last", params[:range] == "last", :onclick => "$('range_select').hide();" %> Last <%= text_field_tag :hours, params[:hours], :size => "2", :maxlength => "2" %> Hours
0
   <%= radio_button_tag :range, "all", params[:range] == "all", :onclick => "$('range_select').hide();" %> All

Comments

    No one has commented yet.