1 //
2 // Copyright (c) 2010-2020 Antmicro
3 //
4 // This file is licensed under the MIT License.
5 // Full license text is available in 'licenses/MIT.txt'.
6 //
7 using System;
8 using AntShell.Commands;
9 using Antmicro.Renode.Logging;
10 using Antmicro.Renode.Core;
11 
12 namespace Antmicro.Renode.UserInterface.Commands
13 {
14     public class TimeCommand : AutoLoadCommand
15     {
16         [Runnable]
Run(ICommandInteraction writer)17         public void Run(ICommandInteraction writer)
18         {
19             var output = $"Current virtual time: {EmulationManager.Instance.CurrentEmulation.MasterTimeSource.ElapsedVirtualTime}\nCurrent real time: {EmulationManager.Instance.CurrentEmulation.MasterTimeSource.ElapsedHostTime}";
20             writer.WriteLine(output);
21             Logger.LogAs(monitor, LogLevel.Info, output);
22         }
23 
TimeCommand(Monitor monitor)24         public TimeCommand(Monitor monitor) : base(monitor, "currentTime", "prints out and logs the current emulation virtual and real time")
25         {
26         }
27     }
28 }
29