42 lines
1.1 KiB
C#
42 lines
1.1 KiB
C#
using ElevatorDiag;
|
|
using Spectre.Console;
|
|
|
|
namespace ElevatorDiag;
|
|
|
|
class Program
|
|
{
|
|
static void Main(string[] args)
|
|
{
|
|
var elevator = new Elevator();
|
|
var diag = new ElevatorDiagnostics(elevator);
|
|
|
|
AnsiConsole.MarkupLine("[bold blue]Elevator Simulation Starting...[/]");
|
|
|
|
elevator.RequestFloor(3);
|
|
elevator.RequestFloor(5);
|
|
|
|
for (int i = 0; i < 15; i++)
|
|
{
|
|
elevator.Update();
|
|
var report = diag.GetStatusReport();
|
|
AnsiConsole.MarkupLine($"[grey]Tick {i:D2}:[/] {report.Replace("[Elevator Report]", "").Trim()}");
|
|
|
|
if (i == 10)
|
|
{
|
|
AnsiConsole.MarkupLine("[bold red]! Simulating Fault ![/]");
|
|
elevator.TriggerFault("Door Obstruction");
|
|
}
|
|
|
|
if (i == 13)
|
|
{
|
|
AnsiConsole.MarkupLine("[bold green]! Clearing Fault ![/]");
|
|
elevator.ResetFault();
|
|
}
|
|
|
|
Thread.Sleep(100);
|
|
}
|
|
|
|
AnsiConsole.MarkupLine("[bold blue]Simulation Finished.[/]");
|
|
}
|
|
}
|