- Timestamp:
- 02/21/11 18:35:41 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/ConfigManager.cs
r5404 r5531 22 22 using System; 23 23 using System.Collections.Generic; 24 using HeuristicLab.Services.Hive.Common; 25 using HeuristicLab.Clients.Hive.Slave; 24 using System.Diagnostics; 25 using System.Management; 26 using HeuristicLab.Clients.Hive.Slave.Properties; 26 27 using HeuristicLab.Services.Hive.Common.DataTransfer; 27 using HeuristicLab.Clients.Hive.Slave.Properties;28 using System.Management;29 using System.Diagnostics;30 28 31 29 … … 47 45 public Core Core { get; set; } 48 46 private HeuristicLab.Services.Hive.Common.DataTransfer.Slave slave; 49 47 50 48 /// <summary> 51 49 /// Constructor for the singleton, must recover Guid, Calendar, ... … … 59 57 slave.CpuArchitecture = Environment.Is64BitOperatingSystem ? CpuArchitecture.x64 : CpuArchitecture.x86; 60 58 slave.OperatingSystem = Environment.OSVersion.VersionString; 59 slave.CpuSpeed = GetCpuSpeed(); 60 slave.FreeMemory = GetFreeMemory(); 61 61 } 62 62 … … 136 136 } 137 137 138 public static int GetPhysicalMemory() { 139 return 1024; // todo 138 private static int? GetPhysicalMemory() { 139 int? res = GetWMIValue("Win32_ComputerSystem", "TotalPhysicalMemory"); 140 if (res != null) 141 return res / 1024 / 1024; 142 else 143 return null; 144 } 145 146 private static int? GetCpuSpeed() { 147 return GetWMIValue("Win32_Processor", "MaxClockSpeed"); 148 } 149 150 private static int? GetWMIValue(string Class, string Property) { 151 ManagementClass mgtClass = new ManagementClass(Class); 152 ManagementObjectCollection mgtCol = mgtClass.GetInstances(); 153 154 foreach (ManagementObject mgtObj in mgtCol) { 155 foreach (var prop in mgtObj.Properties) { 156 if (prop.Value != null && prop.Name == Property) { 157 try { 158 return int.Parse(prop.Value.ToString()); 159 } 160 catch { 161 return null; 162 } 163 } 164 } 165 } 166 return null; 140 167 } 141 168
Note: See TracChangeset
for help on using the changeset viewer.