moel@370: /* moel@370: moel@370: This Source Code Form is subject to the terms of the Mozilla Public moel@370: License, v. 2.0. If a copy of the MPL was not distributed with this moel@370: file, You can obtain one at http://mozilla.org/MPL/2.0/. moel@370: moel@370: Copyright (C) 2012 Michael Möller moel@370: moel@370: */ moel@370: moel@370: using Microsoft.VisualBasic.Devices; moel@370: moel@370: namespace OpenHardwareMonitor.Hardware.RAM { moel@370: internal class GenericRAM : Hardware { moel@370: moel@370: private Sensor loadSensor; moel@370: private Sensor availableMemory; moel@370: moel@370: private ComputerInfo computerInfo; moel@370: moel@370: public GenericRAM(string name, ISettings settings) moel@370: : base(name, new Identifier("ram"), settings) moel@370: { moel@370: computerInfo = new ComputerInfo(); moel@370: loadSensor = new Sensor("Memory", 0, SensorType.Load, this, settings); moel@370: ActivateSensor(loadSensor); moel@370: moel@370: availableMemory = new Sensor("Available Memory", 0, SensorType.Data, this, settings); moel@370: ActivateSensor(availableMemory); moel@370: } moel@370: moel@370: public override HardwareType HardwareType { moel@370: get { moel@370: return HardwareType.RAM; moel@370: } moel@370: } moel@370: moel@370: public override void Update() { moel@370: loadSensor.Value = 100.0f - moel@370: (100.0f * computerInfo.AvailablePhysicalMemory) / moel@370: computerInfo.TotalPhysicalMemory; moel@370: moel@370: availableMemory.Value = (float)computerInfo.AvailablePhysicalMemory / moel@370: (1024 * 1024 * 1024); moel@370: } moel@370: } moel@370: }