Split the sensors and parameter report tree.
1.1 --- a/Hardware/Computer.cs Thu Jul 01 20:25:38 2010 +0000
1.2 +++ b/Hardware/Computer.cs Sat Jul 03 12:08:51 2010 +0000
1.3 @@ -125,25 +125,52 @@
1.4 writer.WriteLine();
1.5 }
1.6
1.7 - private void ReportHardwareTree(IHardware hardware, TextWriter w,
1.8 + private int CompareSensor(ISensor a, ISensor b) {
1.9 + int c = a.SensorType.CompareTo(b.SensorType);
1.10 + if (c == 0)
1.11 + return a.Index.CompareTo(b.Index);
1.12 + else
1.13 + return c;
1.14 + }
1.15 +
1.16 + private void ReportHardwareSensorTree(IHardware hardware, TextWriter w,
1.17 string space) {
1.18 w.WriteLine("{0}|", space);
1.19 w.WriteLine("{0}+-+ {1} ({2})",
1.20 space, hardware.Name, hardware.Identifier);
1.21 - foreach (ISensor sensor in hardware.Sensors) {
1.22 - w.WriteLine("{0}| +- {1} : {2} : {3} : {4}",
1.23 - space, sensor.SensorType, sensor.Index, sensor.Name,
1.24 + ISensor[] sensors = hardware.Sensors;
1.25 + Array.Sort<ISensor>(sensors, CompareSensor);
1.26 + foreach (ISensor sensor in sensors) {
1.27 + w.WriteLine("{0}| +- {1}[{2}] : {3} : {4}",
1.28 + space, sensor.SensorType, sensor.Index,
1.29 string.Format(CultureInfo.InvariantCulture, "{0} : {1} : {2}",
1.30 - sensor.Value, sensor.Min, sensor.Max));
1.31 - foreach (IParameter parameter in sensor.Parameters) {
1.32 - w.WriteLine("{0}| +- {1} : {2} : {3}",
1.33 - space, parameter.Name, parameter.IsDefault,
1.34 - string.Format(CultureInfo.InvariantCulture, "{0} : {1}",
1.35 - parameter.DefaultValue, parameter.Value));
1.36 + sensor.Value, sensor.Min, sensor.Max), sensor.Name);
1.37 + }
1.38 + foreach (IHardware subHardware in hardware.SubHardware)
1.39 + ReportHardwareSensorTree(subHardware, w, "| ");
1.40 + }
1.41 +
1.42 + private void ReportHardwareParameterTree(IHardware hardware, TextWriter w,
1.43 + string space) {
1.44 + w.WriteLine("{0}|", space);
1.45 + w.WriteLine("{0}+-+ {1} ({2})",
1.46 + space, hardware.Name, hardware.Identifier);
1.47 + ISensor[] sensors = hardware.Sensors;
1.48 + Array.Sort<ISensor>(sensors, CompareSensor);
1.49 + foreach (ISensor sensor in sensors) {
1.50 + if (sensor.Parameters.Length > 0) {
1.51 + w.WriteLine("{0}| +- {1}[{2}] : {3}",
1.52 + space, sensor.SensorType, sensor.Index, sensor.Name);
1.53 + foreach (IParameter parameter in sensor.Parameters) {
1.54 + w.WriteLine("{0}| +- {1} : {2}",
1.55 + space, parameter.Name,
1.56 + string.Format(CultureInfo.InvariantCulture, "{0} : {1}",
1.57 + parameter.DefaultValue, parameter.Value));
1.58 + }
1.59 }
1.60 }
1.61 foreach (IHardware subHardware in hardware.SubHardware)
1.62 - ReportHardwareTree(subHardware, w, "| ");
1.63 + ReportHardwareParameterTree(subHardware, w, "| ");
1.64 }
1.65
1.66 private void ReportHardware(IHardware hardware, TextWriter w) {
1.67 @@ -180,9 +207,20 @@
1.68 w.WriteLine();
1.69
1.70 NewSection(w);
1.71 + w.WriteLine("Sensors");
1.72 + w.WriteLine();
1.73 foreach (IGroup group in groups) {
1.74 foreach (IHardware hardware in group.Hardware)
1.75 - ReportHardwareTree(hardware, w, "");
1.76 + ReportHardwareSensorTree(hardware, w, "");
1.77 + }
1.78 + w.WriteLine();
1.79 +
1.80 + NewSection(w);
1.81 + w.WriteLine("Parameters");
1.82 + w.WriteLine();
1.83 + foreach (IGroup group in groups) {
1.84 + foreach (IHardware hardware in group.Hardware)
1.85 + ReportHardwareParameterTree(hardware, w, "");
1.86 }
1.87 w.WriteLine();
1.88