fixed AlarmKnowledgeBase issue
This commit is contained in:
parent
2f8eda5e7e
commit
8de43276a0
|
|
@ -26,7 +26,7 @@ public static class AlarmKnowledgeBase
|
|||
if (GrowattAlarms.TryGetValue(normalized, out var growattDiag))
|
||||
return growattDiag;
|
||||
|
||||
// Try case-insensitive match for Sinexcel (alarm names may vary in casing)
|
||||
// Try case-insensitive match for both Sinexcel and Growatt
|
||||
var lowerDesc = normalized.ToLowerInvariant();
|
||||
foreach (var kvp in SinexcelAlarms)
|
||||
{
|
||||
|
|
@ -34,6 +34,12 @@ public static class AlarmKnowledgeBase
|
|||
return kvp.Value;
|
||||
}
|
||||
|
||||
foreach (var kvp in GrowattAlarms)
|
||||
{
|
||||
if (kvp.Key.ToLowerInvariant() == lowerDesc)
|
||||
return kvp.Value;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -838,6 +838,22 @@ public static class AlarmReviewService
|
|||
foreach (var key in GrowattKeys)
|
||||
AppendEntry(sb, key, improved);
|
||||
sb.AppendLine(" };");
|
||||
sb.AppendLine();
|
||||
|
||||
// Emit the lookup method so the generated file is self-contained and can fully replace AlarmKnowledgeBase.cs
|
||||
sb.AppendLine(" public static DiagnosticResponse? TryGetDiagnosis(string alarmDescription)");
|
||||
sb.AppendLine(" {");
|
||||
sb.AppendLine(" if (string.IsNullOrWhiteSpace(alarmDescription)) return null;");
|
||||
sb.AppendLine(" var normalized = alarmDescription.Trim();");
|
||||
sb.AppendLine(" if (SinexcelAlarms.TryGetValue(normalized, out var s)) return s;");
|
||||
sb.AppendLine(" if (GrowattAlarms.TryGetValue(normalized, out var g)) return g;");
|
||||
sb.AppendLine(" var lower = normalized.ToLowerInvariant();");
|
||||
sb.AppendLine(" foreach (var kvp in SinexcelAlarms)");
|
||||
sb.AppendLine(" if (kvp.Key.ToLowerInvariant() == lower) return kvp.Value;");
|
||||
sb.AppendLine(" foreach (var kvp in GrowattAlarms)");
|
||||
sb.AppendLine(" if (kvp.Key.ToLowerInvariant() == lower) return kvp.Value;");
|
||||
sb.AppendLine(" return null;");
|
||||
sb.AppendLine(" }");
|
||||
sb.AppendLine("}");
|
||||
|
||||
File.WriteAllText(CheckedFilePath, sb.ToString());
|
||||
|
|
|
|||
Loading…
Reference in New Issue