|
|
|
@ -476,31 +476,57 @@ async def update_equipment_for_simulation(
|
|
|
|
# ---- CUSTOM INPUT HAS PRIORITY ----
|
|
|
|
# ---- CUSTOM INPUT HAS PRIORITY ----
|
|
|
|
if eq_name in custom_map:
|
|
|
|
if eq_name in custom_map:
|
|
|
|
custom_param = custom_map[eq_name]
|
|
|
|
custom_param = custom_map[eq_name]
|
|
|
|
|
|
|
|
level = custom_param.get("level")
|
|
|
|
|
|
|
|
|
|
|
|
mttr = custom_param.get("mttr")
|
|
|
|
mttr = custom_param.get("mttr")
|
|
|
|
failure_rate = custom_param.get("failure_rate")
|
|
|
|
failure_rate = custom_param.get("failure_rate")
|
|
|
|
|
|
|
|
|
|
|
|
if mttr is None or failure_rate is None:
|
|
|
|
# Hard-coded states for specific levels
|
|
|
|
log.warning(
|
|
|
|
if level == "NoFailure":
|
|
|
|
"Custom input incomplete for %s, skipping",
|
|
|
|
log.info("Applying NoFailure state for %s", eq_name_raw)
|
|
|
|
eq_name_raw
|
|
|
|
mttr = 0
|
|
|
|
)
|
|
|
|
eq["relDisType"] = "Fixed"
|
|
|
|
continue
|
|
|
|
eq["relDisP1"] = 1000000000.0 # Effectively never fails
|
|
|
|
|
|
|
|
eq["relDisP2"] = 0
|
|
|
|
if failure_rate == 0:
|
|
|
|
eq["cmDisP1"] = 0
|
|
|
|
MTBF = 1000000
|
|
|
|
eq["cmDisType"] = "Fixed"
|
|
|
|
else:
|
|
|
|
elif level == "Out of Service":
|
|
|
|
MTBF = 1e6 / float(failure_rate)
|
|
|
|
log.info("Applying Out of Service (Always Fail) state for %s", eq_name_raw)
|
|
|
|
|
|
|
|
mttr = 1000000000.0
|
|
|
|
eq["cmDisP1"] = mttr
|
|
|
|
eq["relDisType"] = "Fixed"
|
|
|
|
eq["relDisType"] = custom_param.get("distribution", "Fixed")
|
|
|
|
eq["relDisP1"] = 0.0001 # Fails immediately
|
|
|
|
|
|
|
|
|
|
|
|
if eq["relDisType"] == "Fixed":
|
|
|
|
|
|
|
|
eq["relDisP1"] = MTBF
|
|
|
|
|
|
|
|
eq["relDisP2"] = 0
|
|
|
|
eq["relDisP2"] = 0
|
|
|
|
|
|
|
|
eq["cmDisP1"] = mttr
|
|
|
|
|
|
|
|
eq["cmDisType"] = "Fixed"
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
eq["relDisP1"] = 1
|
|
|
|
if mttr is None or failure_rate is None:
|
|
|
|
eq["relDisP2"] = MTBF
|
|
|
|
log.warning(
|
|
|
|
|
|
|
|
"Custom input incomplete for %s, skipping",
|
|
|
|
|
|
|
|
eq_name_raw
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Handle failure_rate being an array (Numeric array in DB)
|
|
|
|
|
|
|
|
if isinstance(failure_rate, list):
|
|
|
|
|
|
|
|
rate_val = float(failure_rate[0]) if failure_rate else 1.0
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
rate_val = float(failure_rate)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if rate_val <= 0:
|
|
|
|
|
|
|
|
MTBF = 1000000000.0
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
MTBF = 1e6 / rate_val
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
eq["cmDisP1"] = mttr
|
|
|
|
|
|
|
|
eq["relDisType"] = custom_param.get("distribution", "Fixed")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if eq["relDisType"] == "Fixed":
|
|
|
|
|
|
|
|
eq["relDisP1"] = MTBF
|
|
|
|
|
|
|
|
eq["relDisP2"] = 0
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
# For Weibull, use P1 as beta (1.0 default) and P2 as eta (MTBF)
|
|
|
|
|
|
|
|
eq["relDisP1"] = 1.0
|
|
|
|
|
|
|
|
eq["relDisP2"] = MTBF
|
|
|
|
|
|
|
|
|
|
|
|
eq["ohDisP1"] = overhaul_duration
|
|
|
|
eq["ohDisP1"] = overhaul_duration
|
|
|
|
eq["ohDisUnitCode"] = "UHour"
|
|
|
|
eq["ohDisUnitCode"] = "UHour"
|
|
|
|
|