lockerKeys/key_bittings.py

74 lines
2.0 KiB
Python

from dataclasses import dataclass
MM_PER_IN = 25.4
# A progression of root depths, decreasing by a constant amount each step.
def linear_depths(start, end, base, increment):
return {str(depth): base - (depth - start) * increment
for depth in range(start, end + 1)}
def depths_in_to_mm(depths):
return {name: depth * MM_PER_IN for name, depth in depths.items()}
@dataclass
class BittingSpecification:
key_thickness: float
root_cut: float
included_angle: float
positions: int
TFC: float # To First Cut (center)
BCC: float # Between Cut Centers
depths: dict[str, float]
# https://www.lockreference.com/wp-content/uploads/2019/03/Yale-Disc-Tumbler.pdf
yale_disc = BittingSpecification(
key_thickness=0, # TODO
root_cut=.044 * MM_PER_IN,
included_angle=90,
positions=5,
TFC=.125 * MM_PER_IN,
BCC=.095 * MM_PER_IN,
depths=depths_in_to_mm({
"1": .250,
"2": .230,
"X": .220, # also called "7"
"3": .210,
"4": .190,
"5": .170,
}))
# https://www.lockreference.com/wp-content/uploads/2018/01/Yale-.019.pdf
yale_019 = BittingSpecification(
key_thickness=0, # TODO
root_cut=.054 * MM_PER_IN,
included_angle=95, # 110, 95, or 86
positions=7,
TFC=.200 * MM_PER_IN,
BCC=.165 * MM_PER_IN,
depths=depths_in_to_mm(linear_depths(0, 9, .320, .019)))
# https://www.lockreference.com/wp-content/uploads/2018/01/Yale-.025.pdf
yale_025 = BittingSpecification(
key_thickness=0, # TODO
root_cut=.054 * MM_PER_IN,
included_angle=95, # 110, 95, or 86
positions=7,
TFC=.200 * MM_PER_IN,
BCC=.165 * MM_PER_IN,
depths=depths_in_to_mm(linear_depths(0, 7, .320, .025)))
# https://www.lockreference.com/wp-content/uploads/2018/09/National-Disc-Tumbler-Single-Sided.pdf
national_disc_tumbler = BittingSpecification(
key_thickness=2,
root_cut=.044 * MM_PER_IN,
included_angle=90,
positions=6,
TFC=.156 * MM_PER_IN,
BCC=.093 * MM_PER_IN,
depths=depths_in_to_mm(linear_depths(1, 4, .250, .025)))