#!/usr/bin/env python3
# Generate ISO 26262 Part 6 compliance matrix skeleton from clause list
import openpyxl
from openpyxl.styles import PatternFill, Font
wb = openpyxl.Workbook()
ws = wb.active
ws.title = "ISO 26262 Part 6"
headers = ["Req ID", "Clause", "Requirement Summary", "ASIL",
"Responsible", "Work Product", "Status", "Evidence Ref", "Tailoring Note"]
for col, h in enumerate(headers, 1):
ws.cell(1, col, h).font = Font(bold=True)
ws.cell(1, col).fill = PatternFill("solid", fgColor="1F4E79")
ws.cell(1, col).font = Font(bold=True, color="FFFFFF")
# Key ISO 26262 Part 6 requirements
requirements = [
("ISO26262-6:7.4.3", "7.4.3", "Software Safety Requirements derived from TSR", "C", "Safety Eng", "SW Safety Requirements Spec", "In Progress", "", ""),
("ISO26262-6:7.4.4", "7.4.4", "Software safety requirements are testable", "C", "Test Eng", "SW Safety Req Spec + Test Spec", "Planned", "", ""),
("ISO26262-6:8.4.2", "8.4.2", "SW architecture supports ASIL decomposition", "C", "SW Architect", "SW Architecture Design Document", "In Progress", "", ""),
("ISO26262-6:8.4.5", "8.4.5", "Freedom from Interference between ASIL partitions", "C", "SW Architect", "FFI Analysis Report", "Planned", "", ""),
("ISO26262-6:9.4.2", "9.4.2", "Defensive implementation techniques applied", "C", "SW Developer", "Code Review Checklist + Source Code", "Planned", "", ""),
("ISO26262-6:9.4.3", "9.4.3", "MISRA C:2012 applied", "C", "SW Developer", "Static Analysis Report (Helix QAC)", "In Progress", "", ""),
("ISO26262-6:9.4.5", "9.4.5", "Robust programming techniques (range checks)", "C", "SW Developer", "Code Review Records", "Planned", "", ""),
("ISO26262-6:11.4.3", "11.4.3", "MC/DC coverage criteria for ASIL C/D", "C", "Test Eng", "Unit Test Coverage Report (TESSY)", "Planned", "", ""),
("ISO26262-6:12.4.4", "12.4.4", "SW integration test covers component interactions", "C", "Test Eng", "SW Integration Test Report", "Planned", "", ""),
]
for row, req in enumerate(requirements, 2):
for col, val in enumerate(req, 1):
ws.cell(row, col, val)
# Colour-code status
status = req[6]
colour = {"Complete":"70AD47", "In Progress":"FFC000", "Planned":"BFBFBF"}.get(status, "FF0000")
ws.cell(row, 6).fill = PatternFill("solid", fgColor=colour)
wb.save("ISO26262_Part6_Compliance_Matrix.xlsx")
print("Matrix generated: ISO26262_Part6_Compliance_Matrix.xlsx")