1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/Hardware/RAM/GenericRAM.cs Mon Jul 23 21:54:35 2012 +0000
1.3 @@ -0,0 +1,47 @@
1.4 +/*
1.5 +
1.6 + This Source Code Form is subject to the terms of the Mozilla Public
1.7 + License, v. 2.0. If a copy of the MPL was not distributed with this
1.8 + file, You can obtain one at http://mozilla.org/MPL/2.0/.
1.9 +
1.10 + Copyright (C) 2012 Michael Möller <mmoeller@openhardwaremonitor.org>
1.11 +
1.12 +*/
1.13 +
1.14 +using Microsoft.VisualBasic.Devices;
1.15 +
1.16 +namespace OpenHardwareMonitor.Hardware.RAM {
1.17 + internal class GenericRAM : Hardware {
1.18 +
1.19 + private Sensor loadSensor;
1.20 + private Sensor availableMemory;
1.21 +
1.22 + private ComputerInfo computerInfo;
1.23 +
1.24 + public GenericRAM(string name, ISettings settings)
1.25 + : base(name, new Identifier("ram"), settings)
1.26 + {
1.27 + computerInfo = new ComputerInfo();
1.28 + loadSensor = new Sensor("Memory", 0, SensorType.Load, this, settings);
1.29 + ActivateSensor(loadSensor);
1.30 +
1.31 + availableMemory = new Sensor("Available Memory", 0, SensorType.Data, this, settings);
1.32 + ActivateSensor(availableMemory);
1.33 + }
1.34 +
1.35 + public override HardwareType HardwareType {
1.36 + get {
1.37 + return HardwareType.RAM;
1.38 + }
1.39 + }
1.40 +
1.41 + public override void Update() {
1.42 + loadSensor.Value = 100.0f -
1.43 + (100.0f * computerInfo.AvailablePhysicalMemory) /
1.44 + computerInfo.TotalPhysicalMemory;
1.45 +
1.46 + availableMemory.Value = (float)computerInfo.AvailablePhysicalMemory /
1.47 + (1024 * 1024 * 1024);
1.48 + }
1.49 + }
1.50 +}