From a39931e1907cdd26ca316f919a2443aeb39dd6d8 Mon Sep 17 00:00:00 2001 From: Jeremy Wright Date: Mon, 21 Oct 2024 18:08:02 -0400 Subject: [PATCH] Added dual SSD assembly --- nimble_build_system/cad/device_placeholder.py | 44 ++++++++++++ nimble_build_system/cad/shelf.py | 72 ++++++++++++++++++- tests/test_rendering.py | 13 ++-- 3 files changed, 121 insertions(+), 8 deletions(-) diff --git a/nimble_build_system/cad/device_placeholder.py b/nimble_build_system/cad/device_placeholder.py index 1468608..f90ff94 100644 --- a/nimble_build_system/cad/device_placeholder.py +++ b/nimble_build_system/cad/device_placeholder.py @@ -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)) # Round the edges placeholder = placeholder.edges("|Z").fillet(3.0) @@ -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) diff --git a/nimble_build_system/cad/shelf.py b/nimble_build_system/cad/shelf.py index abea57a..5600118 100644 --- a/nimble_build_system/cad/shelf.py +++ b/nimble_build_system/cad/shelf.py @@ -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, @@ -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 diff --git a/tests/test_rendering.py b/tests/test_rendering.py index 78f50c5..a3354b5 100644 --- a/tests/test_rendering.py +++ b/tests/test_rendering.py @@ -13,6 +13,7 @@ "Unifi_Switch_Flex", "Hex", # "Western_Digital_Red_HDD" + # "Western_Digital_Blue_SSD" ] @@ -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) @@ -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)