"""
Manufacturing drawings and assembly instructions
"""

import numpy as np

class ManufacturingDrawings:
    """Generate manufacturing specifications"""
    
    def __init__(self):
        self.tolerances = {
            'arm_length': '±0.5 mm',
            'sensor_position': '±1.0 mm',
            'angular_alignment': '±0.5°',
            'flatness': '0.1 mm over 500 mm'
        }
        
        self.materials = {
            'arms': '6061-T6 Aluminum',
            'sensor_housing': '316 Stainless Steel',
            'fasteners': 'A4-80 Stainless Steel',
            'insulation': 'Polyurethane foam (50mm)'
        }
    
    def generate_drawings(self):
        """Generate key manufacturing drawings"""
        drawings = {
            'drawing_001': {
                'title': 'Main Tetrahedron Frame',
                'description': 'Aluminum tube assembly',
                'dimensions': {
                    'arm_length': '500.0 ±0.5 mm',
                    'tube_od': '25.0 mm',
                    'tube_wall': '1.5 mm',
                    'bend_radius': 'N/A (straight)',
                    'weight': '~850 g total'
                },
                'machining': [
                    'Cut 4 tubes to 500.0 mm length',
                    'De-burr all edges',
                    'Anodize (black, 25μm)',
                    'Drill mounting holes as per template'
                ]
            },
            
            'drawing_002': {
                'title': 'Sensor Housing',
                'description': 'Stainless steel sensor enclosure',
                'dimensions': {
                    'diameter': '20.0 mm',
                    'height': '30.0 mm',
                    'wall_thickness': '1.0 mm',
                    'ip_rating': 'IP68',
                    'weight': '~45 g each'
                },
                'machining': [
                    'CNC turn from 316 stainless',
                    'Polish to Ra 0.8',
                    'Drill cable entry (M12x1)',
                    'Helium leak test < 10^-6 mbar·L/s'
                ]
            },
            
            'drawing_003': {
                'title': 'Central Hub Assembly',
                'description': 'Main connection point',
                'dimensions': {
                    'diameter': '80.0 mm',
                    'height': '60.0 mm',
                    'mounting_holes': '4x M6 threaded',
                    'cable_ports': '8x M16',
                    'weight': '~320 g'
                },
                'assembly': [
                    'Insert sealed bearings for each arm',
                    'Install cable glands',
                    'Apply thread locker to fasteners',
                    'Pressure test to 2 bar'
                ]
            }
        }
        
        return drawings
    
    def print_assembly_instructions(self):
        """Print step-by-step assembly instructions"""
        print("\n🔧 ASSEMBLY INSTRUCTIONS:")
        print("="*60)
        
        steps = [
            "1. Inspect all components for damage",
            "2. Assemble tetrahedron frame using jig",
            "3. Torque fasteners to 8 N·m",
            "4. Install sensor housings at each vertex",
            "5. Route cables through arms to central hub",
            "6. Connect sensors to electronics board",
            "7. Seal all cable entries with epoxy",
            "8. Install thermal insulation",
            "9. Apply protective coating",
            "10. Perform final calibration"
        ]
        
        for step in steps:
            print(f"  {step}")
        
        print("\n📏 CRITICAL TOLERANCES:")
        for item, tolerance in self.tolerances.items():
            print(f"  {item}: {tolerance}")
        
        print("\n⚙️ REQUIRED TOOLS:")
        tools = [
            "Torque wrench (0-20 N·m)",
            "Multimeter",
            "Crimping tool",
            "Heat gun",
            "Calibration field source",
            "Thermal chamber"
        ]
        
        for tool in tools:
            print(f"  • {tool}")
        
        print("="*60)

# Create the drawings
if __name__ == "__main__":
    drawings = ManufacturingDrawings()
    docs = drawings.generate_drawings()
    
    print("✅ MANUFACTURING DOCUMENTATION GENERATED")
    drawings.print_assembly_instructions()
