Skip to content

Commit a7afba9

Browse files
committed
Automatic merge of T1.5.1-719-g89833d44e and 17 pull requests
- Pull request #570 at c59c788: Experimental glTF 2.0 support with PBR lighting - Pull request #839 at d00beb9: First phase of https://blueprints.launchpad.net/or/+spec/additional-cruise-control-parameters - Pull request #865 at 67014b7: Dispatcher window improvements - Pull request #874 at f8dbeab: Dynamic brake controller refactoring - Pull request #875 at 43bf33e: Bug fix for https://bugs.launchpad.net/or/+bug/2036346 Player train switching doesn't work with 3D cabs - Pull request #876 at f92de76: docs: add source for documents previously on website to source Documentation folder - Pull request #882 at be39fc9: Blueprint/train car operations UI window - Pull request #883 at edcc2dd: SwitchPanel disconnect/connect handling - Pull request #885 at c81447b: feat: Add notifications to Menu - Pull request #886 at cd452ee: Scene viewer extension to TrackViewer - Pull request #888 at d7daf62: docs: Document player application model - Pull request #890 at 39a9fa4: Allow depart early - Pull request #892 at 1f5ba4c: Signal Function OPP_SIG_ID_TRAINPATH - Pull request #893 at bf8876b: Signal errors - Pull request #894 at 794fddf: Correct Decrease Colour - Pull request #896 at 5866028: First implementation of https://blueprints.launchpad.net/or/+spec/specific-sounds-for-ai-trains - Pull request #897 at 0a9d939: feat: Improved system information collection
19 parents 78adf32 + 89833d4 + c59c788 + d00beb9 + 67014b7 + f8dbeab + 43bf33e + f92de76 + be39fc9 + edcc2dd + c81447b + cd452ee + d7daf62 + 39a9fa4 + 1f5ba4c + bf8876b + 794fddf + 5866028 + 0a9d939 commit a7afba9

File tree

1 file changed

+45
-23
lines changed

1 file changed

+45
-23
lines changed

Source/ORTS.Common/SystemInfo.cs

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
using System.Text.RegularExpressions;
2424
using System.Collections.Generic;
2525
using System.Globalization;
26+
using System.Diagnostics;
2627

2728
namespace ORTS.Common
2829
{
@@ -50,34 +51,55 @@ static SystemInfo()
5051
Version = runtime.Groups[2].Value,
5152
};
5253

53-
// Almost nothing will correctly identify Windows 11 at this point, so we have to use WMI.
54-
var operatingSystem = new ManagementClass("Win32_OperatingSystem").GetInstances().Cast<ManagementObject>().First();
55-
OperatingSystem = new Platform
54+
try
5655
{
57-
Name = (string)operatingSystem["Caption"],
58-
Version = (string)operatingSystem["Version"],
59-
Architecture = RuntimeInformation.OSArchitecture.ToString(),
60-
Language = CultureInfo.CurrentUICulture.IetfLanguageTag,
61-
Languages = (string[])operatingSystem["MUILanguages"],
62-
};
56+
// Almost nothing will correctly identify Windows 11 at this point, so we have to use WMI.
57+
var operatingSystem = new ManagementClass("Win32_OperatingSystem").GetInstances().Cast<ManagementObject>().First();
58+
OperatingSystem = new Platform
59+
{
60+
Name = (string)operatingSystem["Caption"],
61+
Version = (string)operatingSystem["Version"],
62+
Architecture = RuntimeInformation.OSArchitecture.ToString(),
63+
Language = CultureInfo.CurrentUICulture.IetfLanguageTag,
64+
Languages = (string[])operatingSystem["MUILanguages"],
65+
};
66+
}
67+
catch (ManagementException error)
68+
{
69+
Trace.WriteLine(error);
70+
}
6371

6472
NativeMethods.GlobalMemoryStatusEx(MemoryStatusExtended);
6573
InstalledMemoryMB = (int)(MemoryStatusExtended.TotalPhysical / 1024 / 1024);
6674

67-
CPUs = new ManagementClass("Win32_Processor").GetInstances().Cast<ManagementObject>().Select(processor => new CPU
75+
try
6876
{
69-
Name = (string)processor["Name"],
70-
Manufacturer = (string)processor["Manufacturer"],
71-
ThreadCount = (uint)processor["ThreadCount"],
72-
MaxClockMHz = (uint)processor["MaxClockSpeed"],
73-
}).ToList();
77+
CPUs = new ManagementClass("Win32_Processor").GetInstances().Cast<ManagementObject>().Select(processor => new CPU
78+
{
79+
Name = (string)processor["Name"],
80+
Manufacturer = (string)processor["Manufacturer"],
81+
ThreadCount = (uint)processor["ThreadCount"],
82+
MaxClockMHz = (uint)processor["MaxClockSpeed"],
83+
}).ToList();
84+
}
85+
catch (ManagementException error)
86+
{
87+
Trace.WriteLine(error);
88+
}
7489

75-
GPUs = new ManagementClass("Win32_VideoController").GetInstances().Cast<ManagementObject>().Select(adapter => new GPU
90+
try
91+
{
92+
GPUs = new ManagementClass("Win32_VideoController").GetInstances().Cast<ManagementObject>().Select(adapter => new GPU
93+
{
94+
Name = (string)adapter["Name"],
95+
Manufacturer = (string)adapter["AdapterCompatibility"],
96+
MemoryMB = (uint?)adapter["AdapterRAM"] / 1024 / 1024 ?? 0,
97+
}).ToList();
98+
}
99+
catch (ManagementException error)
76100
{
77-
Name = (string)adapter["Name"],
78-
Manufacturer = (string)adapter["AdapterCompatibility"],
79-
MemoryMB = (uint)adapter["AdapterRAM"] / 1024 / 1024,
80-
}).ToList();
101+
Trace.WriteLine(error);
102+
}
81103

82104
var featureLevels = new uint[] {
83105
NativeMethods.D3D_FEATURE_LEVEL_12_2,
@@ -108,8 +130,8 @@ static SystemInfo()
108130
public static readonly Platform Runtime;
109131
public static readonly Platform OperatingSystem;
110132
public static readonly int InstalledMemoryMB;
111-
public static readonly List<CPU> CPUs;
112-
public static readonly List<GPU> GPUs;
133+
public static readonly List<CPU> CPUs = new List<CPU>();
134+
public static readonly List<GPU> GPUs = new List<GPU>();
113135
public static readonly List<string> Direct3DFeatureLevels = new List<string>();
114136

115137
public static void WriteSystemDetails(TextWriter output)
@@ -118,7 +140,7 @@ public static void WriteSystemDetails(TextWriter output)
118140
DateTime.Now, DateTime.UtcNow);
119141
output.WriteLine("Application = {0} {1} ({2})", Application.Name, Application.Version, Application.Architecture);
120142
output.WriteLine("Runtime = {0} {1}", Runtime.Name, Runtime.Version);
121-
output.WriteLine("System = {0} {1} ({2}; {3}; {4})", OperatingSystem.Name, OperatingSystem.Version, OperatingSystem.Architecture, OperatingSystem.Language, string.Join(",", OperatingSystem.Languages));
143+
output.WriteLine("System = {0} {1} ({2}; {3}; {4})", OperatingSystem.Name, OperatingSystem.Version, OperatingSystem.Architecture, OperatingSystem.Language, string.Join(",", OperatingSystem.Languages ?? new string[0]));
122144
output.WriteLine("Memory = {0:N0} MB", InstalledMemoryMB);
123145
foreach (var cpu in CPUs) output.WriteLine("CPU = {0} ({1}; {2} threads; {3:N0} MHz)", cpu.Name, cpu.Manufacturer, cpu.ThreadCount, cpu.MaxClockMHz);
124146
foreach (var gpu in GPUs) output.WriteLine("GPU = {0} ({1}; {2:N0} MB)", gpu.Name, gpu.Manufacturer, gpu.MemoryMB);

0 commit comments

Comments
 (0)