Skip to content

Commit

Permalink
Added dual SSD assembly
Browse files Browse the repository at this point in the history
  • Loading branch information
jmwright committed Oct 21, 2024
1 parent 966d888 commit a39931e
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 8 deletions.
44 changes: 44 additions & 0 deletions nimble_build_system/cad/device_placeholder.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,48 @@ def generate_hdd(device_name, width, depth, height):
.workplane()
.pushPoints(hole_locations)
.hole(3.5, depth=5.0))
placeholder = (placeholder
.faces(">Y")
.workplane()
.pushPoints(hole_locations)
.hole(3.5, depth=5.0))

# Round the edges
placeholder = placeholder.edges("|Z").fillet(3.0)

# Add the text of what the device is to the top
placeholder = (placeholder.faces(">Z")
.workplane(centerOption="CenterOfBoundBox")
.text(device_name.replace(" shelf", ""),
fontsize=6,
distance=-0.1))

return placeholder


def generate_ssd(device_name, width, depth, height):
"""
Generates a 2.5" SSD placeholder model.
"""

# The overall shape
placeholder = cq.Workplane().box(width, depth, height)

# Add the holes in the sides
hole_locations = [
((101.6 / 2.0 - 14), 0.0, 0.0),
(-(101.6 / 2.0 - 14), 0.0, 0.0)
]
placeholder = (placeholder
.faces("<Y")
.workplane()
.pushPoints(hole_locations)
.hole(3.5, depth=5.0))
placeholder = (placeholder
.faces(">Y")
.workplane()
.pushPoints(hole_locations)
.hole(3.5, depth=5.0))

# Round the edges
placeholder = placeholder.edges("|Z").fillet(3.0)
Expand Down Expand Up @@ -208,6 +250,8 @@ def generate_placeholder(device_name, width, depth, height):
placeholder = generate_nuc(device_name, width, depth, height)
elif "hdd" in device_name.lower():
placeholder = generate_hdd(device_name, width, depth, height)
elif "ssd" in device_name.lower():
placeholder = generate_ssd(device_name, width, depth, height)
else:
# The overall shape
placeholder = generate_generic(device_name, width, depth, height, smallest_dim)
Expand Down
72 changes: 70 additions & 2 deletions nimble_build_system/cad/shelf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1028,8 +1028,7 @@ def __init__(self,

# Device location settings
self._device_depth_axis = "X"
# self._device_offset = (0.0, 0.0, 0.0)
self._device_explode_translation = (0.0, 0.0, 0.0)
self._device_explode_translation = (0.0, 0.0, 20.0)

self._fasteners = [
Screw(name=None,
Expand Down Expand Up @@ -1118,10 +1117,79 @@ def generate_shelf_model(self) -> cadscript.Body:

return self._shelf_model


class DualSSDShelf(Shelf):
"""
Shelf class for two 2.5" solid state drive devices.
"""

def __init__(self,
device: Device,
assembly_key: str,
position: tuple[float, float, float],
color: str,
rack_params: RackParameters):

super().__init__(device,
assembly_key,
position,
color,
rack_params)

# Device location settings
self._device_depth_axis = "X"
self._device_offset = (0.0, self._device.width / 2.0 + 1.5, 8.5)
self._device_explode_translation = (0.0, 0.0, 30.0)

self._fasteners = [
Screw(name=None,
position=(-self._device.depth / 2.0 - 2.55,
self._device.width - 11.75,
8.65),
explode_translation=(0.0, 0.0, 20.0),
size="#6-32",
fastener_type="asme_b_18.6.3",
axis="-X",
length=6),
Screw(name=None,
position=(-self._device.depth / 2.0 - 2.55,
12.75,
8.65),
explode_translation=(0.0, 0.0, 20.0),
size="#6-32",
fastener_type="asme_b_18.6.3",
axis="-X",
length=6),
Screw(name=None,
position=(self._device.depth / 2.0 + 2.55,
self._device.width - 11.75,
8.65),
explode_translation=(0.0, 0.0, 20.0),
size="#6-32",
fastener_type="asme_b_18.6.3",
axis="X",
length=6),
Screw(name=None,
position=(self._device.depth / 2.0 + 2.55,
12.75,
8.65),
explode_translation=(0.0, 0.0, 20.0),
size="#6-32",
fastener_type="asme_b_18.6.3",
axis="X",
length=6),
]
self.render_options = {
"color_theme": "default", # can also use black_and_white
"view": "front-top-right",
"standard_view": "front-top-right",
"annotated_view": "back-bottom-right",
"add_device_offset": False,
"add_fastener_length": False,
"zoom": 1.15,
}


def generate_shelf_model(self) -> cadscript.Body:
"""
A shelf for two 2.5" SSDs
Expand Down
13 changes: 7 additions & 6 deletions tests/test_rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"Unifi_Switch_Flex",
"Hex",
# "Western_Digital_Red_HDD"
# "Western_Digital_Blue_SSD"
]


Expand All @@ -25,17 +26,17 @@ def test_assembly_png_rendering():
config = NimbleConfiguration(test_config)

# Get the only shelf that we should have to deal with
rpi_shelf = config.shelves[0]
cur_shelf = config.shelves[0]

# Test the generated CAD assembly
shelf_assy = rpi_shelf.generate_assembly_model()
shelf_assy = cur_shelf.generate_assembly_model()

# Set up a temporary path to export the image to
temp_dir = tempfile.gettempdir()
temp_path = os.path.join(temp_dir, "assembly_render_test.png")

# Do a sample render of the shelf assembly
rpi_shelf.get_render(shelf_assy,
cur_shelf.get_render(shelf_assy,
file_path=temp_path)

assert os.path.isfile(temp_path)
Expand All @@ -51,17 +52,17 @@ def test_annotated_assembly_png_rendering():
config = NimbleConfiguration(test_config)

# Get the only shelf that we should have to deal with
rpi_shelf = config.shelves[0]
cur_shelf = config.shelves[0]

# Test the generated CAD assembly
shelf_assy = rpi_shelf.generate_assembly_model(explode=True)
shelf_assy = cur_shelf.generate_assembly_model(explode=True)

# Set up a temporary path to export the image to
temp_dir = tempfile.gettempdir()
temp_path = os.path.join(temp_dir, "assembly_render_test_exploded.png")

# Do a sample render of the shelf assembly
rpi_shelf.get_render(shelf_assy,
cur_shelf.get_render(shelf_assy,
file_path=temp_path,
annotate=True)

Expand Down

0 comments on commit a39931e

Please sign in to comment.