drill-results¶
A drill program comes back from the lab. Each hole is scored on its gram-metres (grade × width, summed over its intervals), graded by guarded rules, and the best hole makes the headline. One message per hole, so the flow shows every hole's own little tree.
Scoring a hole¶
$when drill.score (hole: Object) {
gm = hole.intervals map (i => (i.to - i.from) * i.grade) fold (s = 0.0) (x => s + x)
best = hole.intervals fold (b = 0.0) (i => if i.grade > b then i.grade else b)
payload = {hole: hole.id, gm: gm, best: best, metres: hole.intervals map (i => i.to - i.from) fold (s = 0.0) (x => s + x)}
}
Grading¶
Guards pick exactly one grade for a scored hole.
$when drill.grade (s: Object) if (s.gm >= 50.0) {
payload = s + {grade: "bonanza"}
}
$when drill.grade (s: Object) if (s.gm >= 20.0 and s.gm < 50.0) {
payload = s + {grade: "strong"}
}
$when drill.grade (s: Object) if (s.gm >= 5.0 and s.gm < 20.0) {
payload = s + {grade: "modest"}
}
$when drill.grade (s: Object) if (s.gm < 5.0) {
payload = s + {grade: "dry"}
}
A hole¶
A hole that was abandoned before reaching its target has no assays: that's an error the program catches.
$when drill.hole (hole: Object) {
if (hole.abandoned ?? false) {
diesel.throw (code = "E_ABANDONED", msg = "${hole.id} was abandoned at ${hole.depth} m")
}
scored = drill.score(hole = hole)
payload = drill.grade(s = scored)
}
The program¶
$when drill.program (name: String, holes: Array) {
results = holes map (h => drill.checked(hole = h))
done = results filter (r => r.grade != "abandoned")
top = done fold (b = {gm: -1.0}) (r => if r.gm > b.gm then r else b)
payload = {program: name, holes: sizeOf(holes), hits: sizeOf(done filter (r => r.grade != "dry")), top: top, results: results}
}
$when drill.checked (hole: Object) {
try {
drill.hole (hole)
} catch (e) {
payload = {hole: hole.id, grade: "abandoned", gm: 0.0, why: e.message}
}
}
The news release¶
$when drill.release (program: Object) {
t = program.top
payload = "${program.program}: ${t.hole} returns ${t.gm} gram-metres (best ${t.best} g/t over ${t.metres} m); ${program.hits} of ${program.holes} holes hit"
}
Try it: drill-results, or in the Fiddle.