| 1 | using CascadeIDE.Cockpit.DataBus; |
| 2 | using CascadeIDE.Contracts; |
| 3 | using CascadeIDE.Models; |
| 4 | |
| 5 | namespace CascadeIDE.Features.SolutionWarmup.Application; |
| 6 | |
| 7 | /// <summary>Строки HIS для прогрева solution (ADR 0141 phase C).</summary> |
| 8 | [PresentationProjection("solution-warmup-his")] |
| 9 | public static class SolutionWarmupHisPresentationProjection |
| 10 | { |
| 11 | public static string StatusShort(SolutionWarmupStateChanged? last) => |
| 12 | last?.Lifecycle switch |
| 13 | { |
| 14 | null => "—", |
| 15 | SolutionWarmupLifecycle.Idle => "IDLE", |
| 16 | SolutionWarmupLifecycle.Running => "WARM", |
| 17 | SolutionWarmupLifecycle.Ready => "READY", |
| 18 | SolutionWarmupLifecycle.Partial => "PART", |
| 19 | SolutionWarmupLifecycle.Cancelled => "CNCL", |
| 20 | _ => "—", |
| 21 | }; |
| 22 | |
| 23 | public static string StatusLine(SolutionWarmupStateChanged? last) |
| 24 | { |
| 25 | if (last is null) |
| 26 | return "WARM —"; |
| 27 | |
| 28 | var detail = string.IsNullOrWhiteSpace(last.Detail) ? "" : $" ({last.Detail})"; |
| 29 | return $"WARM {StatusShort(last)}{detail}"; |
| 30 | } |
| 31 | |
| 32 | public static AnnunciatorLampItem LampItem(SolutionWarmupStateChanged? last) |
| 33 | { |
| 34 | if (last is null) |
| 35 | { |
| 36 | return new AnnunciatorLampItem( |
| 37 | Id: "warmup", |
| 38 | Title: "Warm-up", |
| 39 | Detail: "No data yet.", |
| 40 | Level: AnnunciatorLampLevel.Advisory, |
| 41 | LampShortLabel: "WARM"); |
| 42 | } |
| 43 | |
| 44 | var (level, detail) = last.Lifecycle switch |
| 45 | { |
| 46 | SolutionWarmupLifecycle.Ready => (AnnunciatorLampLevel.Ok, "Ready"), |
| 47 | SolutionWarmupLifecycle.Running => (AnnunciatorLampLevel.Advisory, "Running"), |
| 48 | SolutionWarmupLifecycle.Partial => (AnnunciatorLampLevel.Caution, last.Detail ?? "Partial"), |
| 49 | SolutionWarmupLifecycle.Cancelled => (AnnunciatorLampLevel.Advisory, "Cancelled"), |
| 50 | _ => (AnnunciatorLampLevel.Advisory, "Idle"), |
| 51 | }; |
| 52 | |
| 53 | return new AnnunciatorLampItem( |
| 54 | Id: "warmup", |
| 55 | Title: "Warm-up", |
| 56 | Detail: detail, |
| 57 | Level: level, |
| 58 | LampShortLabel: "WARM"); |
| 59 | } |
| 60 | } |
| 61 | |