Cross-posting this reply... i have found a way to get access to some variables for math functions. I can't get any info that isn't passed, but we can use javascript to strip formatting off variables and use them with math functions to make our own variables:
I found a way around this for now... the Beersmith custom report generate uses a webkit which allows javascript to run. That allow us to do some string manipulation and math to get things.
Here's a custom report example I have where I can get some items I wanted:
1) total points = show total gravity points at mash step in case my volumes are off, i can do quick math to figure out top up water or more aggresive boil off rates.
2) Removing " SG" from the gravity readings so they fit better on the sheet... i like to say "Est OG" which is implied SG... this allows fitting more items in a row
3) converting SG to Plato
4) shrinking the water volumes for better cals. For example, endoing boil volume may be 6.5 at flame out but after chilling it should reduce by 4% shrinkage and be 6.25... i need to use 6.25 for math operations as well as confirmation to me that i'm spot on while draining to kettle
5) a function to show actual pre-boil OG. Due to the issues above with how preboil OG is calculated i wrote another function... this one takes points based off "pre boil OG * pre boil volume" which appears correct.. then divides it by the "shrunk" pre-boil volume to get a correct room temp reading for Preboil SG
Place this in the "head" section of your custom report:
Code:
<script>
<script>
var og = '$EST_OG';
var fg = '$EST_FG ';
var pog = '$PRE_BOIL_OG';
var prevol = '$DISPLAY_BOIL_SIZE';
var postvol = '$POST_BOIL_VOLUME';
function remove_sg(item) {
// function to remove " SG" from end of SG so math can be performed
return item.slice(0, 5);
}
function total_points() {
// function to calc total points for use in adhoc math dring brewday
// Unable to use EST_OG here due to later added adjuncts and no ability
// to seperate the PPG of Sugard, etc.
var vol = prevol.split(" ")[0];
var sg = pog.slice(2, 5);
return (vol * sg).toFixed(1)
}
function sg_to_plato(gravity) {
// convert SG to plato for display purposes
// plato = (-1 * 616.868) + (1111.14 * sg) ? (630.272 * sg^2) + (135.997 * sg^3)
var sg = gravity.slice(0, 5);
var plato = (-1 * 616.868) + (1111.14 * sg) - (630.272 * Math.pow(sg, 2)) + (135.997 * Math.pow(sg, 3));
return plato.toFixed(1);
}
function vol_shrink(volume, shrinkage) {
// reduce the "volume" of liquid by the shrinkage amount...
var vol = volume.split(" ")[0]
vol = vol / shrinkage; // take out the 4% that was added due to heat
return vol.toFixed(2);
}
function actual_preog() {
// function to back-calculate the correct preboil SG based
// on total points and a "room temp" sample instead of "hot" sample
var points = remove_sg(pog).slice(2, 5) * prevol.split(" ")[0];
var actualPreOG = points / vol_shrink(prevol, 1.03);
return (actualPreOG / 1000 + 1).toFixed(4);
}
function populate_custom_vars() {
document.getElementById("estOG").innerHTML = remove_sg(og);
document.getElementById("estFG").innerHTML = remove_sg(fg);
document.getElementById("platoOG").innerHTML = sg_to_plato(og);
document.getElementById("platoOG2").innerHTML = sg_to_plato(og);
document.getElementById("platoFG").innerHTML = sg_to_plato(fg);
document.getElementById("plato_preOG").innerHTML = sg_to_plato(actual_preog())
document.getElementById("actual_preOG").innerHTML = actual_preog();
document.getElementById("actual_preOG2").innerHTML =actual_preog();
document.getElementById("preboil_vol_shrinked").innerHTML = vol_shrink(prevol, 1.03) + " gal";
document.getElementById("postboil_vol_shrinked").innerHTML = vol_shrink(postvol, 1.04) + " gal";
document.getElementById("total_points").innerHTML = total_points();
}
</script>
Then you can space the Element-id's around as such:
Code:
<div id="wrapper">
<div id="header">
<div class="logo">
<h1>$NAME</h1>
<h2>$STYLE_NAME ($STYLE_NUMBER $STYLE_LETTER)</h2>
</div>
</div>
<table>
<tr>
<td width="25%">
<div class="col4">
<span class="item">Batch:</span> $DISPLAY_BATCH_SIZE
<span class="item">SRM:</span> $EST_COLOR
<span class="item">IBU:</span> $IBU
<span class="item">Est ABV:</span> $EST_ABV
</div>
</td>
<td width="25%">
<div class="col4">
<span class="item">Packaged Vol:</span> $BOTTLING_VOLUME
<span class="item">Est Mash Eff:</span> $EST_MASH_EFFICIENCY
<span class="item">Est BH Eff:</span> $EFFICIENCY %
<span class="item">Boil time:</span> $BOIL_TIME min
</div>
</td>
<td width="25%">
<div class="col4">
<span class="item">Est OG:</span> <span id="estOG"></span> (<span id="platoOG"></span> P)
<span class="item">Est FG:</span> <span id="estFG"></span> (<span id="platoFG"></span> P)
<span class="item">Preboil Vol:</span> $DISPLAY_BOIL_SIZE
<span class="item">Preboil SG:</span> <span id="actual_preOG"></span> (<span id="plato_preOG"></span> P)
</div>
</td>
<td width="25%">
<div class="col4">
<span class="item">Recipe Date:</span> $DATE
<span class="item">Total Grain:</span> $TOTAL_GRAINS
<span class="item">Brewing Date: _____________</span>
<span class="item">Packaging Date: ___________</span>
</div>
</td>
</tr>
</table>
...
<ul class="checklist">
<li>Switch power off HLT and set BK ALM</li>
<li>$SPARGE_STEPS (Total $SPARGE_VOLUME)</li>
<li>Measure pre-boil gravity _________ (target: $PRE_BOIL_OG, <span id="actual_preOG2"></span> SG, total points <span id="total_points"></span>)</li>
<li>Measure pre-boil volume _________ (target: $DISPLAY_BOIL_SIZE, <span id="preboil_vol_shrinked"></span>)</li>
<li>Sanitize bucket, airlock, o2, all remaining cold side equipment</li>
</ul>
...
This will hold me over for now... i have the BS estimated preboil SG, the actual expected SG, the "expanded" or "hot" volume of preboil water as well as the "cooled" volume if i need to do any quick math (SG * cooled volume = total points, divide by expected volume to get new OG... etc).
This produces outputs like this:
Code:
Batch: 6.25 gal Packaged Vol: 5.00 gal Est OG: 1.056 (13.8 P) Recipe Date: 03/12/20
SRM: 7.0 SRM Est Mash Eff: 80.0 % Est FG: 1.015 (3.8 P) Total Grain: 12.04 lb
IBU: 40.4 IBUs Est BH Eff: 80.00 % Preboil Vol: 8.01 gal Brewing Date: _____________
Est ABV: 5.3 % Boil time: 60 min Preboil SG: 1.0443 (11.0 P) Packaging Date: ___________
*** NOTE, i've chosen to include an extra decimal place in pre-boil OG because that rounding error can be important when using that for math later.