brewer 0.0.43 → 0.0.45

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 601c53153ee16990ac2e6e1d3612a25d896ebd5d
4
- data.tar.gz: 0806645dc59bbf7b181dddc65b4b0785982e95a9
3
+ metadata.gz: f16b7b9fb27e3bf8745e0f9ca0f676075dd61ec4
4
+ data.tar.gz: f666d434d21a5b920abdfc3919805b9cb2ec8bfc
5
5
  SHA512:
6
- metadata.gz: a196fec395deb7cd4df18349d22d112cb88a21d62d1257b4c916bf605c7e39df1364f0dedecb0cc6ddc2de166d85244da24f0aead567ab04d06679ba38823cfc
7
- data.tar.gz: 4a8d7e9d46852cc2a5de94074099fc66977b10e70992d055d40cea6f0cff23c30a7757575ea543e12d3b79a72e516daf64028a84d54ea54689d4222801566ed2
6
+ metadata.gz: 13fceb77a1f0bee56f8239218ab2461f89045ddf372f9b67304bbacc601bab59200acd7d1ce9b9dafd1c4cf6f6e0f7274813d4fcb91664f95646c0392fcd34e8
7
+ data.tar.gz: 5c92be2304da69a1f59209da50ccc03b76d8423c8698db9fad605a7dd550c54a676236ae7a2f8d4d63b57b5761fe86be477c6fb5e90285e33e7f2947a5f56b44
data/bin/brewer CHANGED
@@ -17,7 +17,7 @@ end
17
17
  # Refresh to make sure we have the lastest version of adaptibrew
18
18
  adaptibrew = Adaptibrew.new
19
19
  if network?
20
- adaptibrew.refresh
20
+ adaptibrew.clone
21
21
  end
22
22
  brewer = Brewer.new
23
23
 
data/brewer.gemspec CHANGED
@@ -2,7 +2,7 @@ require 'rake'
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "brewer"
5
- s.version = "0.0.43"
5
+ s.version = "0.0.45"
6
6
  s.default_executable = "brewer"
7
7
 
8
8
  s.authors = ["Luke Sweeney"]
data/lib/brewer.rb CHANGED
@@ -1,23 +1,26 @@
1
1
  require_relative 'helpers'
2
2
  require_relative 'adaptibrew'
3
+ require_relative 'settings'
3
4
 
4
5
  include Helpers
5
6
 
6
7
  class Brewer
7
8
 
8
9
  attr_reader :base_path
9
- attr_accessor :out, :log
10
+ attr_accessor :out, :log, :temps
10
11
 
11
12
  def initialize
12
13
  @base_path = Dir.pwd
13
14
  # Output of adaptibrew
14
15
  @out = []
15
16
  @log = @base_path + '/logs/output'
17
+ @temps = {}
16
18
  end
17
19
 
18
20
  public
19
21
 
20
- # General methods
22
+ # Brewer methods ------------------------------------------------------
23
+ # general utilities for the brewer class
21
24
 
22
25
  def wait(time=30)
23
26
  sleep(time)
@@ -37,6 +40,8 @@ class Brewer
37
40
 
38
41
  # Runs an adaptibrew script
39
42
  # Output will be stored in @out
43
+ # you may see `echo` quite a bit. This will almost always be directly after calling a script
44
+ # It will be set to the output of the last script. I can't just return the output because i need to return self
40
45
  def script(script, params=nil)
41
46
  @out.unshift(`python #{@base_path}/adaptibrew/#{script}.py #{params}`.chomp)
42
47
  self
@@ -50,16 +55,24 @@ class Brewer
50
55
  self
51
56
  end
52
57
 
58
+ # This lil' divider is default for large return blocks
59
+ def echo(string=nil)
60
+ if string == nil
61
+ return @out.first
62
+ end
63
+ string
64
+ end
65
+
53
66
 
54
- # Adaptibrew methods
67
+ # Adaptibrew methods ----------------------------------------------
68
+ # for working with the rig
55
69
 
56
70
  def pump(state=0)
57
71
  if state == 1
58
- state_string = "on"
72
+ script("set_pump_on")
59
73
  else
60
- state_string = "off"
74
+ script("set_pump_off")
61
75
  end
62
- script("set_pump_#{state_string}")
63
76
  self
64
77
  end
65
78
 
@@ -71,13 +84,18 @@ class Brewer
71
84
  # Turns PID on or off, or gets state if no arg is provided
72
85
  def pid(state="status")
73
86
  if state == "status"
87
+ echo('----------')
74
88
  script("is_pid_running")
75
- puts @out.first
89
+ puts "PID is running? " + echo
90
+ sv.echo
91
+ pv.echo
76
92
  end
77
93
 
78
94
  if state == 1
79
95
  script('set_pid_on')
80
96
  puts "PID is now on"
97
+ pump(1)
98
+ puts "Pump is now on"
81
99
  elsif state == 0
82
100
  script("set_pid_off")
83
101
  puts "PID is now off"
@@ -104,20 +122,57 @@ class Brewer
104
122
  if temp
105
123
  raise "Temperature input needs to be an integer" unless temp.is_a? Integer
106
124
  script('set_sv', temp)
107
- puts "SV set to #{temp}"
108
125
  else
109
126
  script('get_sv')
110
- puts "SV is currently " + @out.first
111
127
  end
112
128
  self
113
129
  end
114
130
 
115
- # Procedures
131
+ def pv
132
+ script('get_pv')
133
+ self
134
+ end
135
+
136
+ def watch
137
+ until pv.out.first.to_i == sv.out.first.to_i do
138
+ wait(8)
139
+ end
140
+ end
141
+
142
+ # WaterVolInQuarts, GrainMassInPounds, GrainTemp, MashTemp
143
+ def get_strike_temp
144
+ print "Input amount of water in quarts: "
145
+ water = gets.chomp
116
146
 
147
+ print "Input amount of grain in lbs: "
148
+ grain = gets.chomp
149
+
150
+ print "Input current grain temp (#{pv.echo}): "
151
+ grain_temp = gets.chomp
152
+ if grain_temp == ""
153
+ grain_temp = pv.echo.to_i
154
+ end
155
+
156
+ print "Input desired mash temp (150): "
157
+ desired_mash_temp = gets.chomp
158
+ if desired_mash_temp == ""
159
+ desired_mash_temp = 150
160
+ end
161
+ @temps['desired_mash'] = desired_mash_temp
162
+
163
+ # this is where the magic happens
164
+ script('get_strike_temp', "#{water} #{grain} #{grain_temp} #{desired_mash_temp}")
165
+ @temps['strike_water_temp'] = @out.first.to_i
166
+ sv(echo.to_i)
167
+ puts "SV has been set to #{sv.echo} degrees"
168
+ end
169
+
170
+ # Master Procedures -----------------------------------------------------
171
+ # The main steps in the brewing proccess
117
172
  def boot
118
173
  # These are the states required for starting. Should be called on boot.
119
174
  # Print PID status at end
120
- pid(0).pump(0).relay(2, 1).all_relays_status
175
+ pid(0).pump(0).relay($settings['rimsToMashRelay'], 1).all_relays_status.pid
121
176
 
122
177
  @out.shift(4)
123
178
  @out.unshift("Boot successful")
@@ -132,18 +187,36 @@ class Brewer
132
187
  print "Is the return manifold in the mash tun? "
133
188
  confirm ? nil : abort
134
189
 
135
- relay(2, 1)
136
- puts "RIMS relay is now on"
190
+ relay($settings['rimsToMashRelay'], 1)
191
+ puts "RIMS-to-mash relay is now on"
137
192
 
138
193
  pump(1)
139
194
  puts "Pump is now on"
140
195
 
141
- puts "Waiting for 30 seconds (ctrl-c to cancel)"
142
- wait(30)
196
+ time = 30
197
+ puts "Waiting for #{time} seconds for strike water to start circulating"
198
+ puts "(ctrl-c to stop now)"
199
+ wait(time)
143
200
 
144
201
  print "Is the strike water circulating well? "
145
202
  confirm ? nil : abort
146
203
 
204
+ @temps['starting_strike_temp'] = pv.out.first.to_i
205
+ pv
206
+ puts "current strike water temp is #{echo}. Saved."
207
+ puts "Warning: if you exit this brewer shell, the strike water temp will be lost"
208
+ puts ""
209
+ puts "--- Calculate strike temp ---"
210
+ # this sets PID to strike temp
211
+ get_strike_temp
212
+ # turn on pid heater
213
+ # XXX: This?
214
+ pid(1)
215
+
216
+ # when strike temp is reached, ping
217
+ watch
218
+ ping("strike water is now at #{pv.echo} degrees")
219
+
147
220
  self
148
221
  end
149
222
 
data/lib/settings.rb ADDED
@@ -0,0 +1,13 @@
1
+ # This just parses the adaptibrew/settings.py
2
+ $settings = {}
3
+
4
+ File.open('adaptibrew/settings.py') do |file|
5
+ file.each_line do |line|
6
+ if line.match(/=/) == nil
7
+ next
8
+ end
9
+ key, value = line.match(/(.+)=(.+)/).captures
10
+ value.slice!(/#.+/)
11
+ $settings[key.strip.chomp] = value.strip.chomp
12
+ end
13
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brewer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.43
4
+ version: 0.0.45
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luke Sweeney
@@ -196,6 +196,7 @@ files:
196
196
  - lib/adaptibrew.rb
197
197
  - lib/brewer.rb
198
198
  - lib/helpers.rb
199
+ - lib/settings.rb
199
200
  - lib/slacker.rb
200
201
  - spec/adaptibrew_spec.rb
201
202
  - spec/brewer_spec.rb