Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 55x 55x 55x 55x 46x 4x 4x 4x 4x 4x 4x 4x 4x 41x 41x 41x 41x 41x 82x 41x 41x 41x 41x 41x 41x 41x 41x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 49x 49x 49x 49x 49x 49x 49x 49x 49x 49x 49x 49x 8x 41x 49x 19x 19x 19x 19x 19x 19x 19x 49x 49x 49x 49x 49x 49x 49x 30x 30x 30x 19x 19x 1x 1x 1x 18x 18x 18x 18x 49x 49x 49x 49x 30x 30x 26x 4x 30x 19x 18x 17x 17x 2x 2x 2x 15x 15x 3x 3x 3x 3x 3x 3x 12x 12x 12x 11x 1x 12x 1x 11x 12x 49x 49x 49x 4x 4x 49x 49x 49x 49x 49x 2x 2x 1x 1x 1x 1x 1x 1x 1x 49x 49x 49x 30x 19x 2x 17x 3x 14x 49x 49x 49x 49x 49x 49x 49x 49x 49x 49x 49x 49x 49x 49x | import type { FilamentPlanResponseV1 } from '@eink/print-dialog'
import type { FilamentCatalog } from './abacus-catalog'
import { INFILL_OPTIONS, type InfillLevel, infillOption, resolveInfill } from './abacus-infill'
import {
bumperLabel,
type FilamentMap,
frameW,
isModular,
matchBumper,
outerD,
type Params,
} from './abacus-model'
import { moduleKitPlan } from './abacus-module-kit'
import { type PrintPlan, roleShifted } from './abacus-plan'
import type { FeetSupportGate } from './abacus-print-panel-state'
export type CommitmentKey =
| 'pieces'
| 'filaments'
| 'supports'
| 'feet'
| 'infill'
| 'jobs'
| 'time'
export const COMMITMENT_ORDER: readonly CommitmentKey[] = [
'pieces',
'filaments',
'supports',
'feet',
'infill',
'jobs',
'time',
]
export const COMMITMENT_LABELS: Record<CommitmentKey, string> = {
pieces: 'pieces',
filaments: 'filaments',
supports: 'supports',
feet: 'feet',
infill: 'infill',
jobs: 'jobs',
time: 'time',
}
export interface CommitmentLine {
value: string
note?: string
}
export type CommitmentSummary = Record<CommitmentKey, CommitmentLine>
export interface FilamentPlanFacts {
loaded: number
used: number
shifted: number
}
export type CommitmentPlan = FilamentPlanResponseV1 | PrintPlan
const isMaterialized = (plan: CommitmentPlan): plan is PrintPlan => 'catalogSource' in plan
export function filamentPlanFacts(
catalog: FilamentCatalog,
plan: CommitmentPlan | null
): FilamentPlanFacts {
if (!plan) return { loaded: catalog.spools.length, used: 0, shifted: 0 }
if (isMaterialized(plan)) {
return {
loaded: catalog.spools.length,
used: new Set(plan.assignments.filter((a) => a.spoolIndex >= 0).map((a) => a.spoolId)).size,
shifted: plan.assignments.filter(
(a) => ['frame', 'bead', 'text'].includes(a.role.kind) && roleShifted(a)
).length,
}
}
return {
loaded: catalog.spools.length,
used: new Set(
plan.assignments
.flatMap((a) =>
a.filament ? [a.filament.slotId ?? (a.filament.external ? 'external' : '')] : []
)
.filter(Boolean)
).size,
shifted: plan.assignments.filter(
(a) => /^(frame|bead-|text-)/.test(a.paletteId) && a.deltaE00 !== null && a.deltaE00 > 10
).length,
}
}
export type CommitmentPrinter =
| { kind: 'unpaired' }
| {
kind: 'paired'
bedMm: { x: number; y: number } | null
monochromeExternal: boolean
supports: { enabled: boolean; interface: string | null }
feetGate: FeetSupportGate
/** `feetOnly`: the experimental variant (Gitea #45) — Stage A prints only
* the feet, Stage B prints PLA supports around them. */
twoStage: { on: boolean; feetSpool: string | null; feetOnly?: boolean }
kit: 'none' | 'pending' | 'fits' | 'spills'
}
export interface CommitmentInput {
params: Params
filamentMap: FilamentMap
catalog: FilamentCatalog
plan: CommitmentPlan | null
printer: CommitmentPrinter
}
export const TIME_BAND: Record<InfillLevel, string> = {
light: 'Quick print — light infill is the fastest frame.',
standard: 'Baseline print time.',
sturdy: 'Longer print — a sturdy frame adds roughly a quarter.',
solid: 'Long print — a solid frame roughly doubles the baseline.',
}
void INFILL_OPTIONS
export function commitmentSummary({
params,
filamentMap,
catalog,
plan,
printer,
}: CommitmentInput): CommitmentSummary {
const modular = isModular(params)
const kitPlan = modular ? moduleKitPlan(params, filamentMap) : []
const modules = kitPlan.reduce((total, entry) => total + entry.count, 0)
const facts = filamentPlanFacts(catalog, plan)
const plural = (n: number, word: string) => `${n} ${word}${n === 1 ? '' : 's'}`
let pieces = modular
? `${plural(modules, 'module')} · ${plural(kitPlan.length, 'file')}`
: `One piece · ${frameW(params).toFixed(1)} × ${outerD(params).toFixed(1)} mm`
if (printer.kind === 'paired') {
if (!modular && printer.bedMm) pieces += ` on a ${printer.bedMm.x} × ${printer.bedMm.y} mm bed`
if (modular && printer.kit === 'fits') pieces = `${plural(modules, 'module')} on one plate`
if (modular && printer.kit === 'pending')
pieces = `${plural(modules, 'module')} · fitting the plate…`
if (modular && printer.kit === 'spills')
pieces = `${plural(modules, 'module')} · more than one plate`
}
const piecesLine: CommitmentLine = { value: pieces }
if (printer.kind === 'paired' && modular && printer.kit === 'spills')
piecesLine.note = 'The plate preview below says which modules spill.'
let filaments: CommitmentLine
if (printer.kind === 'unpaired')
filaments = {
value: plural(plan ? facts.used : facts.loaded, 'filament'),
note: 'Load them in your slicer.',
}
else if (printer.monochromeExternal)
filaments = {
value: `No AMS · one color: ${catalog.spools[0]?.name ?? 'the loaded spool'}`,
note: 'Your multi-color design collapses to one filament.',
}
else
filaments = {
value: `${plural(facts.loaded, 'filament')} loaded · ${facts.shifted === 0 ? 'prints true' : `${plural(facts.shifted, 'color')} shift`}`,
}
let supports: CommitmentLine
if (printer.kind === 'unpaired')
supports = {
value: 'set in your slicer',
...(params.feet_mode === 'printed' && params.show_frame
? { note: 'Printed feet stand the abacus off the bed, so the bottom face needs supports.' }
: {}),
}
else if (printer.feetGate.blocked) supports = { value: 'off — needed for printed feet' }
else if (!printer.supports.enabled) supports = { value: 'off' }
else if (printer.twoStage.on && printer.twoStage.feetOnly)
supports = {
value: `on · PLA from the frame spool, printed in the body stage around the standing feet${printer.supports.interface ? `, interface in ${printer.supports.interface}` : ''}`,
note: 'Experimental: nothing but the feet is TPU on the plate — the supports pop off and the feet peel.',
}
else if (printer.twoStage.on)
supports = {
value: `on · interface in the feet filament${printer.twoStage.feetSpool ? ` (${printer.twoStage.feetSpool})` : ''}, printed in the feet stage`,
// the floor's plate contact is a sparse comb (two-stage-print.ts), which
// is why it comes off the plate at all — worth one line here since the
// paragraph that used to say so is gone
note: 'Its floor is a sparse comb against the plate, so it peels off instead of bonding.',
}
else
supports = {
value: printer.supports.interface
? `on · interface in ${printer.supports.interface}`
: 'on · same filament as the model',
...(printer.feetGate.missing.includes('support_on_build_plate_only')
? { note: 'Allowed to touch the model — see below.' }
: {}),
}
let feet = 'none'
if (params.show_frame && params.feet_mode === 'printed') feet = 'printed TPU feet · always solid'
else if (params.show_frame && params.feet_mode === 'adhesive')
feet = `pockets for ${matchBumper(params) ? bumperLabel(matchBumper(params)!) : 'stick-on bumpers'}`
const infill = resolveInfill(params)
let infillLine: CommitmentLine
if (params.infill_linked)
infillLine = { value: `${infillOption(infill.frame).label} — frame and beads` }
else if (params.color_scheme === 'monochrome')
infillLine = {
value: `frame ${infillOption(infill.frame).label} · beads follow the frame`,
note: "One filament means one body, so the beads take the frame's infill.",
}
else
infillLine = {
value: `frame ${infillOption(infill.frame).label} · beads ${infillOption(infill.beads).label}`,
}
const jobs =
printer.kind === 'unpaired'
? 'set in your slicer'
: printer.twoStage.on && printer.twoStage.feetOnly
? 'two jobs · only the feet from the external spool, then supports and the body after a spool swap'
: printer.twoStage.on
? 'two jobs · feet first from the external spool, then the body after a spool swap'
: 'one job'
let time = TIME_BAND[infill.frame]
if (modular) time += ' Many small pieces add travel.'
if (printer.kind === 'paired' && printer.twoStage.on)
time += ' Two jobs, with a spool swap between.'
return {
pieces: piecesLine,
filaments,
supports,
feet: { value: feet },
infill: infillLine,
jobs: { value: jobs },
time: { value: time },
}
}
|