-
Notifications
You must be signed in to change notification settings - Fork 1
/
equipment.cljc
403 lines (301 loc) · 14.4 KB
/
equipment.cljc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
(ns common-beer-format.equipment
"The definition of an equipment record used in BeerXML."
{:added "2.0"}
(:require [clojure.spec.alpha :as spec]
[common-beer-format.impl :as impl]
[common-beer-format.primitives :as prim]
[spec-tools.core :as st])
(:refer-clojure :exclude [name]))
(def equipment
"A map representing the brewing equipment used during the mash."
:equipment)
(def equipments
"A vector of equipment records."
:equipments)
(def name
"The name of the equipment record."
:name)
(def version
"The version of the BeerXML specification used to create the equipment record."
:version)
(def boil-size
"The pre-boil volume for the equipment setup."
:boil-size)
(def batch-size
"The target volume of the batch at the start of fermentation."
:batch-size)
(def tun-volume
"The volume of the of the mash tun in liters."
:tun-volume)
(def tun-weight
"The weight of the of the mash tun in kilograms."
:tun-weight)
(def tun-specific-heat
"The specific heat of the mash tun in Calories per gram-degree Celsius."
:tun-specific-heat)
(def top-up-water
"The volume of top-up water added before fermentation in liters."
:top-up-water)
(def trub-chiller-loss
"The volume of wort lost during transition from the boiler to primary fermentation vessel."
:trub-chiller-loss)
(def evap-rate
"The percentage of wort lost to evaporation per hour of the boil."
:evap-rate)
(def boil-time
"The normal amount of time one boils for this equipment setup. This can be used with the evaporation rate to calculate the evaporation loss."
:boil-time)
(def calc-boil-volume
"A boolean denoting whether or not programs reading this equipment record should calculate the boil size."
:calc-boil-volume)
(def lauter-deadspace
"The volume of wort lost to deadspace in the mash tun."
:lauter-deadspace)
(def top-up-kettle
"The volume of wort lost to deadspace in the kettle."
:top-up-kettle)
(def hop-utilization
"The percentage of hops that are utilized in the boil."
:hop-utilization)
(def notes
"A string containing notes about the equipment setup."
:notes)
(def display-boil-size
"The pre-boil volume for the equipment setup in a human-readable format."
:display-boil-size)
(def display-batch-size
"The target volume of the batch at the start of fermentation in a human-readable format."
:display-batch-size)
(def display-tun-volume
"The volume of the of the mash tun in liters in a human-readable format."
:display-tun-volume)
(def display-tun-weight
"The weight of the of the mash tun in kilograms in a human-readable format."
:display-tun-weight)
(def display-top-up-water
"The volume of top-up water added before fermentation in liters in a human-readable format."
:display-top-up-water)
(def display-trub-chiller-loss
"The volume of wort lost during transition from the boiler to primary fermentation vessel in a human-readable format."
:display-trub-chiller-loss)
(def display-lauter-deadspace
"The volume of wort lost to deadspace in the mash tun in a human-readable format."
:display-lauter-deadspace)
(def display-top-up-kettle
"The volume of wort lost to deadspace in the kettle in a human-readable format."
:display-top-up-kettle)
(spec/def ::boil-size
(st/spec
{:type :double
:spec ::prim/liter
impl/beer-xml-type-key impl/beer-xml-floating-point
impl/beer-xml-units-key impl/beer-xml-liter
:description "A non-negative IEEE-754 floating point number representing the pre-boil volume for the equipment setup."
:json-schema/example 10.8}))
(spec/def ::batch-size
(st/spec
{:type :double
:spec ::prim/liter
impl/beer-xml-type-key impl/beer-xml-floating-point
impl/beer-xml-units-key impl/beer-xml-liter
:description "A non-negative IEEE-754 floating point number representing the target volume of the batch at the start of fermentation."
:json-schema/example 5.8}))
(spec/def ::tun-volume
(st/spec
{:type :double
:spec ::prim/liter
impl/beer-xml-type-key impl/beer-xml-floating-point
impl/beer-xml-units-key impl/beer-xml-liter
:description "A non-negative IEEE-754 floating point number representing the volume of the of the mash tun in liters."
:json-schema/example 15.0}))
(spec/def ::tun-weight
(st/spec
{:type :double
:spec ::prim/kilogram
impl/beer-xml-type-key impl/beer-xml-floating-point
impl/beer-xml-units-key impl/beer-xml-kilogram
:description "A non-negative IEEE-754 floating point number representing the weight of the of the mash tun in kilograms."
:json-schema/example 15.0}))
(spec/def ::tun-specific-heat
(st/spec
{:type :double
:spec ::prim/non-negative-number
:gen impl/real-positive-double-generator
impl/beer-xml-type-key impl/beer-xml-floating-point
impl/beer-xml-units-key impl/beer-xml-calories-per-gram-degree-celsius
:description "A non-negative IEEE-754 floating point number representing the specific heat of the mash tun in Calories per gram-degree Celsius."
:json-schema/example 0.2}))
(spec/def ::top-up-water
(st/spec
{:type :double
:spec ::prim/liter
impl/beer-xml-type-key impl/beer-xml-floating-point
impl/beer-xml-units-key impl/beer-xml-liter
:description "A non-negative IEEE-754 floating point number representing the volume of top-up water added before fermentation in liters."
:json-schema/example 2.1}))
(spec/def ::trub-chiller-loss
(st/spec
{:type :double
:spec ::prim/liter
impl/beer-xml-type-key impl/beer-xml-floating-point
impl/beer-xml-units-key impl/beer-xml-liter
:description "A non-negative IEEE-754 floating point number representing the volume of wort lost during transition from the boiler to primary fermentation vessel."
:json-schema/example 0.1}))
(spec/def ::evap-rate
(st/spec
{:type :double
:spec ::prim/percent
impl/display-name-key "Evaporation Rate"
impl/beer-xml-type-key impl/beer-xml-percentage
impl/beer-xml-units-key impl/beer-xml-percent-per-hour
:description "A non-negative IEEE-754 floating point number representing the percentage of wort lost to evaporation per hour of the boil."
:json-schema/example 1.2}))
(spec/def ::boil-time
(st/spec
{:type :double
:spec ::prim/minute
impl/beer-xml-type-key impl/beer-xml-floating-point
impl/beer-xml-units-key impl/beer-xml-minute
:description "A non-negative IEEE-754 floating point number representing the normal amount of time one boils for this equipment setup. This can be used with the evaporation rate to calculate the evaporation loss."
:json-schema/example 15}))
(spec/def ::calc-boil-volume
(st/spec
{:spec ::prim/boolean
impl/display-name-key "Calculate Boil Volume"
impl/beer-xml-type-key impl/beer-xml-boolean
:description (impl/multiline "A boolean denoting whether or not programs reading this equipment record should calculate the boil size."
"When absent, assume false."
"When true, then boil-size = `(batch-size - top-up-water - trub-chiller-loss) * (1 + boil-time * evap-rate)`")
:json-schema/example true
:decode/string impl/decode-boolean
:encode/string impl/encode-boolean}))
(spec/def ::lauter-deadspace
(st/spec
{:type :double
:spec ::prim/liter
impl/beer-xml-type-key impl/beer-xml-floating-point
impl/beer-xml-units-key impl/beer-xml-liter
:description "A non-negative IEEE-754 floating point number representing the volume of wort lost to the lauter tun."
:json-schema/example 0.1}))
(spec/def ::top-up-kettle
(st/spec
{:type :double
:spec ::prim/liter
impl/beer-xml-type-key impl/beer-xml-floating-point
impl/beer-xml-units-key impl/beer-xml-liter
:description "A non-negative IEEE-754 floating point number representing the volume of top-up water added to the boil kettle before the boil begins."
:json-schema/example 2.1}))
(spec/def ::hop-utilization
(st/spec
{:type :double
:spec ::prim/percent
impl/beer-xml-type-key impl/beer-xml-percentage
:description "A non-negative IEEE-754 floating point number representing the percentage of large batch hop utilization."
:json-schema/example 1.2}))
(spec/def ::display-boil-size
(st/spec
{:type :string
:spec ::prim/text
impl/beer-xml-type-key impl/beer-xml-text
:description "A non-empty string denoting a display value for the pre-boil volume formatted for display in arbitrary units."
:json-schema/example "5.0 gallons"}))
(spec/def ::display-batch-size
(st/spec
{:type :string
:spec ::prim/text
impl/beer-xml-type-key impl/beer-xml-text
:description "A non-empty string denoting a display value for the pre-fermentation volume formatted for display in arbitrary units."
:json-schema/example "4.5 gallons"}))
(spec/def ::display-tun-volume
(st/spec
{:type :string
:spec ::prim/text
impl/beer-xml-type-key impl/beer-xml-text
:description "A non-empty string denoting a display value for the volume capacity of the mash tun formatted for display in arbitrary units."
:json-schema/example "20 liters"}))
(spec/def ::display-tun-weight
(st/spec
{:type :string
:spec ::prim/text
impl/beer-xml-type-key impl/beer-xml-text
:description "A non-empty string denoting a display value for the empty weight of the mash tun formatted for display in arbitrary units."
:json-schema/example "5.5 pounds"}))
(spec/def ::display-top-up-water
(st/spec
{:type :string
:spec ::prim/text
impl/beer-xml-type-key impl/beer-xml-text
:description "A non-empty string denoting a display value for the volume of top-up water added before fermentation formatted for display in arbitrary units."
:json-schema/example "2.2 liters"}))
(spec/def ::display-trub-chiller-loss
(st/spec
{:type :string
:spec ::prim/text
impl/beer-xml-type-key impl/beer-xml-text
:description "A non-empty string denoting a display value for the volume of wort lost in transition between boiler and fermentation vessel formatted for display in arbitrary units."
:json-schema/example "2.2 liters"}))
(spec/def ::display-lauter-deadspace
(st/spec
{:type :string
:spec ::prim/text
impl/beer-xml-type-key impl/beer-xml-text
:description "A non-empty string denoting a display value for the volume of wort lost in the lauter vessel formatted for display in arbitrary units."
:json-schema/example "2.2 liters"}))
(spec/def ::display-top-up-kettle
(st/spec
{:type :string
:spec ::prim/text
impl/beer-xml-type-key impl/beer-xml-text
:description "A non-empty string denoting a display value for the top-up water added to the pre-boil stage of the kettle formatted for display in arbitrary units."
:json-schema/example "2.2 liters"}))
(spec/def ::equipment
(st/spec
{:type :map
:description "A record representing the brewing equipment used in brewing."
:spec (spec/keys :req-un [::prim/name
::prim/version
::boil-size
::batch-size]
:opt-un [::tun-volume
::tun-weight
::tun-specific-heat
::top-up-water
::trub-chiller-loss
::evap-rate
::boil-time
::calc-boil-volume
::lauter-deadspace
::top-up-kettle
::hop-utilization
::prim/notes
::display-boil-size
::display-batch-size
::display-tun-volume
::display-tun-weight
::display-top-up-water
::display-trub-chiller-loss
::display-lauter-deadspace
::display-top-up-kettle])}))
(spec/def ::equipment-wrapper
(st/spec
{:type :map
impl/wrapper-spec-key true
impl/beer-xml-type-key impl/beer-xml-record
:description "An `::equipment` record wrapped in an `:equipment` map."
:spec (spec/keys :req-un [::equipment])
:decode/string #(impl/decode-wrapper %1 ::equipment %2)
:encode/string #(impl/encode-wrapper %1 ::equipment %2)}))
(spec/def ::equipments
(st/spec
{:type :vector
:description "A vector of valid `::equipment-wrapper` records."
:spec (spec/coll-of ::equipment-wrapper :into [] :kind vector?)
:decode/string #(impl/decode-sequence %1 ::equipment-wrapper %2)
:encode/string #(impl/encode-sequence %1 ::equipment-wrapper %2)}))
(spec/def ::equipments-wrapper
(st/spec
{:type :map
impl/wrapper-spec-key true
impl/beer-xml-type-key impl/beer-xml-record-set
:description "An `::equipment-wrapper` record set."
:spec (spec/keys :req-un [::equipments])}))