Class: Brewer::Procedures

Inherits:
Object
  • Object
show all
Defined in:
lib/brewer/procedures.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeProcedures

Returns a new instance of Procedures.



8
9
10
11
12
# File 'lib/brewer/procedures.rb', line 8

def initialize
  @controller = Controller.new
  @com = Slacker.new
  @kitchen = Kitchen.new
end

Instance Attribute Details

#brewerObject

Returns the value of attribute brewer.



6
7
8
# File 'lib/brewer/procedures.rb', line 6

def brewer
  @brewer
end

#comObject

Returns the value of attribute com.



6
7
8
# File 'lib/brewer/procedures.rb', line 6

def com
  @com
end

#recipeObject

Returns the value of attribute recipe.



6
7
8
# File 'lib/brewer/procedures.rb', line 6

def recipe
  @recipe
end

Instance Method Details

#boilObject



210
211
212
213
214
215
216
217
218
219
220
221
222
223
# File 'lib/brewer/procedures.rb', line 210

def boil
  puts Rainbow("Timers started for 1 hour... You'll be notified when you need to add hops.").yellow
  @com.ping("starting boil procedure")
  wait(to_seconds(5))
  @com.ping("Add boil hops")
  wait(to_seconds(40))
  @com.ping("Add flovering hops")
  wait(to_seconds(13))
  @com.ping("Add finishing hops")
  wait(30)
  @com.ping("Done.")
  puts Rainbow("Done.").green
  true
end

#bootObject



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/brewer/procedures.rb', line 35

def boot
  puts Rainbow("Booting...").yellow
  @controller.relay_config({
    'pid' => 0,
    'pump' => 0,
    'rims_to' => 'mash',
    'hlt_to' => 'mash'
  })

  puts Rainbow("Boot finished!").green
  @com.ping("🍺 boot finished 🍺")
  true
end

#dough_inObject



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/brewer/procedures.rb', line 103

def dough_in
  @controller.relay_config({
    'pid' => 0,
    'pump' => 0
  })
  wait(3)
  @com.ping("Ready to dough in")
  puts Rainbow("Ready to dough in").green

  # pour in grain

  print Rainbow("Confirm when you're done with dough-in (y): ").yellow
  confirm ? nil : abort
  true
end

#heat_strike_waterObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/brewer/procedures.rb', line 49

def heat_strike_water
  puts Rainbow("About to heat strike water").green

  # Confirm strike water is in the mash tun
  print Rainbow("Is the strike water in the mash tun? ").yellow
  confirm ? nil : abort

  # confirm return manifold is in the mash tun
  print Rainbow("Is the return manifold in the mash tun? ").yellow
  confirm ? nil : abort

  print Rainbow("Is the manual mash tun valve open? ").yellow
  confirm ? nil : abort

  # confirm RIMS relay is on
  @controller.rims_to('mash')

  # turn on pump
  @controller.pump(1)

  print Rainbow("Is the pump running properly? ").yellow
  unless confirm
    puts "restarting pump"
    @controller.pump(0)
    wait(2)
    @controller.pump(1)
  end

  # confirm that strike water is circulating well
  print Rainbow("Is the strike water circulating well? ").yellow
  # -> response
  confirm ? nil : abort


  # calculate strike temp & set PID to strike temp
  # this sets PID SV to calculated strike temp automagically
  @controller.sv(@kitchen.recipe.vars['strike_water_temp'])
  puts "SV has been set to calculated strike water temp"
  # turn on RIMS heater
  @controller.pid(1)

  # measure current strike water temp and save
  @kitchen.recipe.vars['starting_strike_temp'] = @controller.pv
  puts "current strike water temp is #{@controller.pv}."
  puts "Heating to #{@controller.sv}"

  @com.ping("Strike water beginning to heat. This may take a few minutes.")

  # when strike temp is reached, @com.ping slack
  @controller.watch
  puts Rainbow("Strike water heated. Maintaining temp.").green
  true
end

#mashObject



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/brewer/procedures.rb', line 119

def mash
  @controller.sv(@kitchen.recipe.vars['mash_temp'])

  puts Rainbow("Mash started. This will take a while.").green
  @com.ping("Mash started. This will take a while.")

  @controller.relay_config({
    'rims_to' => 'mash',
    'pid'  => 1,
    'pump' => 1
  })

  @controller.watch
  @com.ping("Starting timer for #{to_minutes(@kitchen.recipe.vars['mash_time'])} minutes.")
  wait(@kitchen.recipe.vars['mash_time'])
  @com.ping("🍺 Mash complete 🍺. Check for starch conversion.")
  puts Rainbow("Mash complete").green
  puts "Check for starch conversion"
end

#mashoutObject



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/brewer/procedures.rb', line 139

def mashout
  @com.ping("Start heating sparge water")
  puts Rainbow("start heating sparge water").yellow
  puts Rainbow("Mashout started").green

  @controller.sv(@kitchen.recipe.vars['mashout_temp'])

  @controller.relay_config({
    'pid'  => 1,
    'pump' => 1
  })
  @com.ping("Heating to #{@controller.sv}... this could take a few minutes.")
  puts Rainbow("Heating to #{@controller.sv}... this could take a few minutes.").yellow
  @controller.watch
  @com.ping("Mashout complete.")
  puts Rainbow("Mashout complete").green
end

#masterObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/brewer/procedures.rb', line 14

def master
  puts "Enter a recipe name or nothing to make a new one."
  @kitchen.list_recipes_as_table
  print ">> "
  choice = gets.chomp.strip
  if choice.empty?
    @kitchen.new_recipe
  else
    @kitchen.load(choice)
  end
  boot
  heat_strike_water
  dough_in
  mash
  mashout
  sparge
  top_off
  boil
  true
end

#spargeObject



157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# File 'lib/brewer/procedures.rb', line 157

def sparge
  print Rainbow("Is the sparge water heated to the correct temperature? ").yellow
  confirm ? nil : abort

  puts Rainbow("Sparging started").green

  @controller.relay_config({
    'hlt_to' => 'mash',
    'hlt' => 1
  })

  print "Waiting for 10 seconds. "
  puts Rainbow("Regulate sparge balance.").yellow
  wait(10)

  @controller.relay_config({
    'rims_to' => 'boil',
    'pump' => 1
  })

  @com.ping("Please check the sparge balance and ignite boil tun burner")
  puts Rainbow("Ignite boil tun burner").yellow

  print Rainbow("Waiting for intervention to turn off pump (y): ").yellow
  confirm ? nil : nil

  @controller.relay_config({
    'pid' => 0,
    'pump' => 0,
    'hlt' => 0
  })

  puts Rainbow("Sparging complete").green
  true
end

#top_offObject



193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# File 'lib/brewer/procedures.rb', line 193

def top_off
  puts Rainbow("Top off started").green

  @controller.relay_config({
    'hlt_to' => 'boil',
    'hlt' => 1
  })

  print Rainbow("waiting for intervention to turn off hlt (y): ").yellow
  confirm ? nil : abort

  @controller.hlt(0)

  @com.ping('Topping off complete')
  puts Rainbow("Topping off complete").green
end