void DisplayUpdate() { const int timeoutSeconds = 60; if (lastSignalReceived.IsOver(seconds: timeoutSeconds).InPastComparedTo(World.UtcNow)) { if (lastUpdate.IsOver(seconds: 1).InPastComparedTo(World.UtcNow)) { lastUpdate = World.UtcNow; var backupLastSingalReceived = lastSignalReceived; client.EraseDisplay(); client.WriteLine(); client.WriteLine(); if (backupLastSingalReceived == DateTime.MinValue) { client.WriteLine("no signal received"); } else { client.WriteLine("last signal received " + World.UtcNow.Subtract(backupLastSingalReceived).TotalSeconds.Round().ToInt() + " seconds ago"); } client.WriteLine("debug info:"); client.WriteLine(" current time: "+ World.UtcNow.ToString("yyyy-MM-dd HH:mm:ss")); client.WriteLine(" columns: "+ device.ColumnsCount); client.WriteLine(" rows: "+ device.RowsCount); client.WriteLine(); client.WriteLine(); lastSignalReceived = backupLastSingalReceived; } } myWriteStream.UnityUpdate(); UpdateTextArea(); }
bool TryExecuteInbuilt(string name, params string[] arguments) { if (name == "clr" || name == "clear" || name == "cls") { var client = new StdLib.Ecma48.Client(Console.Out); client.EraseDisplay(); } else if (name == "help" || name == "man" || name == "?") { var d = Directory.GetDirEntry("/bin/"); Console.WriteLine("list of programs or command you can run:"); Console.WriteLine("\tshell commands:"); foreach (var i in new string[] { "clr", "help", "cd", "logout", "who", "instal" }) { Console.WriteLine("\t\t" + i); } Console.WriteLine("\tprograms from " + d.FullName + ":"); foreach (var f in d.EnumerateFiles()) { Console.WriteLine("\t\t" + f.Name); } } else if (name == "cd") { if (arguments.Length != 1) { throw new Error("one argument required"); } var p = arguments[0]; var d = Directory.GetDirEntry(p); if (!d.Exists) { throw new Error("directory '" + p + "' ('" + d.FullName + "') doesnt exist"); } Environment.CurrentDirectory = d.FullName; } else if (name == "logout") { TryExecuteInbuilt("clear", null); shouldContinue = false; } else if (name == "who") { //To see list of logged in user type who or w command: Console.WriteLine(this.Environment.UserName); } else if (name == "instal") { var p = "/"; if (arguments.Length == 1) { p = Path.GetFullPath(arguments[0]); } new InitializeFileSystem().Install(Session, p); } else { return(false); } return(true); }