internal static void WriteHistory(IEnumerable <IEvent> history, RoomieCommandInterpreter interpreter) { var headers = new[] { "Time Stamp", "Entity", "Type", "Source", "" }; var tableBuilder = new TextTable(new int[] { Math.Max(history.Max(x => x.TimeStamp.ToLocalTime().ToString().Length), headers[0].Length), Math.Max(history.Max(x => ((x.Entity == null || x.Entity.Name == null) ? string.Empty : x.Entity.Name).Length), headers[1].Length), Math.Max(history.Max(x => ((x.Type == null) ? string.Empty : x.Type.Name).Length), headers[2].Length), Math.Max(history.Max(x => ((x.Source == null || x.Source.Name == null) ? string.Empty : x.Source.Name).Length), headers[3].Length), ExtraLength(history) }); interpreter.WriteEvent(tableBuilder.StartOfTable(headers)); foreach (var @event in history) { var extra = GetExtra(@event); var line = tableBuilder.ContentLine( @event.TimeStamp.ToLocalTime().ToString(), (@event.Entity == null) ? string.Empty : @event.Entity.Name, (@event.Type == null) ? string.Empty : @event.Type.Name, (@event.Source == null) ? string.Empty : @event.Source.Name, extra ); interpreter.WriteEvent(line); } interpreter.WriteEvent(tableBuilder.EndOfTable()); }
private void ListValue(RoomieCommandInterpreter interpreter, ZWaveDevice device, byte i) { var parameter = device.BackingObject.ConfigurationParameters[i]; interpreter.WriteEvent(i + ": " + parameter.Value); }