Class: 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.



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

def initialize
  @brewer = Brewer.new
  @com = Communicator.new
  @recipe = Recipe.new(@brewer)
end

Instance Attribute Details

#brewerObject

Returns the value of attribute brewer.



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

def brewer
  @brewer
end

#comObject

Returns the value of attribute com.



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

def com
  @com
end

#recipeObject

Returns the value of attribute recipe.



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

def recipe
  @recipe
end

Instance Method Details

#boilObject



189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/brewer/procedures.rb', line 189

def boil
  @com.ping("starting boil procedure")
  @brewer.wait(to_seconds(5))
  @com.ping("Add boil hops")
  @brewer.wait(to_seconds(40))
  @com.ping("Add flovering hops")
  @brewer.wait(to_seconds(13))
  @com.ping("Add finishing hops")
  @brewer.wait(30)
  @com.ping("Done.")
  puts Rainbow("Done.").green
end

#bootObject



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/brewer/procedures.rb', line 25

def boot
  puts Rainbow("booting...").yellow
  @brewer.pid(0)
  @brewer.pump(0)
  @brewer.rims_to('mash')
  @brewer.hlt_to('mash')
  @brewer.all_relays_status
  puts @brewer.pid

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

#dough_inObject

:nocov:



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

def dough_in
  # turn pump off
  @brewer.pump(0)
  # turn PID off
  @brewer.pid(0)
  @brewer.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

:nocov:



40
41
42
43
44
45
46
47
48
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
# File 'lib/brewer/procedures.rb', line 40

def heat_strike_water
  puts "heat-strike-water procedure started"

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

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

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

  # confirm RIMS relay is on
  @brewer.rims_to('mash')
  puts "RIMS-to-mash relay is now on"

  # turn on pump
  @brewer.pump(1)
  puts "Pump is now on"

  puts Rainbow("Is the pump running properly? ").yellow
  # TODO: Test this
  until confirm
    puts "restarting pump"
    @brewer.pump(0)
    @brewer.wait(2)
    @brewer.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
  @brewer.sv(@recipe.strike_water_temp)
  puts "SV has been set to calculated strike water temp"
  # turn on RIMS heater
  @brewer.pid(1)

  # measure current strike water temp and save
  @recipe.starting_strike_temp = @brewer.pv
  puts "current strike water temp is #{@brewer.pv}. Saved."
  puts "Heating to #{@brewer.sv}"

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

  # when strike temp is reached, @com.ping slack
  @brewer.watch
  @com.ping("Strike water heated to #{@brewer.pv}. Maintaining temperature.")
  puts Rainbow("Strike water heated. Maintaining temp.").green
  true
end

#mashObject



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

def mash
  @brewer.sv(@recipe.mash_temp)

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

  @brewer.rims_to('mash')

  @brewer.pump(1)
  @brewer.pid(1)

  @brewer.watch
  @com.ping("Mash temp (#{@brewer.pv} F) reached. Starting timer for #{@recipe.mash_time} minutes.")
  @brewer.wait(@recipe.mash_time)
  @com.ping("🍺 Mash complete 🍺. Check for starch conversion.")
  puts Rainbow("Mash complete").green
  puts "Check for starch conversion"
end

#mashoutObject



136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/brewer/procedures.rb', line 136

def mashout
  @com.ping("Start heating sparge water")

  @brewer.sv(@recipe.mashout_temp)

  @brewer.pump(1)
  @brewer.pid(1)

  @com.ping("Heating to #{@brewer.sv}... this could take a few minutes.")
  @brewer.watch
  @com.ping("Mashout temperature (#{@brewer.pv}) reached. Mashout complete.")
end

#masterObject



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/brewer/procedures.rb', line 13

def master
  @recipe.get_recipe_vars
  boot
  heat_strike_water
  dough_in
  mash
  mashout
  sparge
  top_off
  boil
end

#spargeObject



149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/brewer/procedures.rb', line 149

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

  @brewer.hlt_to('mash')
  @brewer.hlt(1)

  print "Waiting for 10 seconds. "
  puts Rainbow("Regulate sparge balance.").yellow
  puts "(ctrl-c to abort proccess)"
  @brewer.wait(30)

  @brewer.rims_to('boil')
  @brewer.pump(1)

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

  puts Rainbow("Waiting until intervention to turn off pump (y): ").yellow
  confirm ? nil : abort

  @brewer.pid(0)
  @brewer.pump(0)

  @brewer.hlt(0)
end

#top_offObject



175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'lib/brewer/procedures.rb', line 175

def top_off
  @brewer.hlt_to('boil')

  @brewer.hlt(1)

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

  @brewer.hlt(0)

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