File size: 1,695 Bytes
a44ef87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import logging
logger = logging.getLogger("rules_engine")

def check_structural_safety(results: dict):
    element_type = results.get("type", "beam")

    if element_type == "beam":
        return check_beam_safety(results)
    elif element_type == "slab":
        return check_slab_safety(results)

    return {"is_safe": True, "warnings": [], "suggestions": []}

def check_beam_safety(results: dict):
    warnings = []
    suggestions = []
    is_safe = True

    steel_ratio = results.get("steel_ratio_percent", 0)
    depth = results.get("depth_mm", 0)
    length = results.get("length_m", 0)

    if steel_ratio > 2.5:
        warnings.append(f"⚠️ تحذير: نسبة التسليح عالية جداً ({steel_ratio}%)، قد تحدث تشققات.")
        suggestions.append("💰 اقتراح: زيادة عمق الكمرة لتقليل نسبة الحديد.")
        is_safe = False
    elif steel_ratio < 0.2:
        warnings.append("⚠️ تحذير: نسبة التسليح منخفضة جداً.")
        suggestions.append("💡 اقتراح: مراجعة الحسابات أو إضافة حديد إضافي.")

    if length > 0 and depth > 0:
        depth_span_ratio = depth / (length * 1000)
        if depth_span_ratio < 1/15:
            warnings.append("⚠️ الكمرة نحيفة جداً (نسبة العمق/الطول صغيرة).")
            suggestions.append("📏 اقتراح: زيادة العمق لتحسين المقاومة.")
            is_safe = False

    return {"is_safe": is_safe, "warnings": warnings, "suggestions": suggestions}

def check_slab_safety(results: dict):
    return {"is_safe": True, "warnings": [], "suggestions": []}