Beispiel #1
0
 public void VisitHardware(IHardware hardware)
 {
     hardware.Update();
       foreach (IHardware sub in hardware.SubHardware) {
     sub.Accept (this);
       }
 }
 private void HardwareAdded(IHardware hardware)
 {
     foreach (IHardware subHardware in hardware.SubHardware)
     {
         // System.Console.WriteLine(subHardware.Name);
     }
 }
Beispiel #3
0
 private void HardwareAdded(IHardware hardware) {
   foreach (ISensor sensor in hardware.Sensors)
     SensorAdded(sensor);
   hardware.SensorAdded += SensorAdded;
   hardware.SensorRemoved += SensorRemoved;
   foreach (IHardware subHardware in hardware.SubHardware)
     HardwareAdded(subHardware);
 }
 private void HardwareRemoved(IHardware hardware)
 {
     WeiboString.log(hardware.Name);
     foreach (IHardware subHardware in hardware.SubHardware)
     {
         // System.Console.WriteLine(subHardware.Name);
     }
 }
 public Hardware(IHardware hardware) {
   Name = hardware.Name;
   Identifier = hardware.Identifier.ToString();
   HardwareType = hardware.HardwareType.ToString();
   Parent = (hardware.Parent != null)
     ? hardware.Parent.Identifier.ToString()
     : "";
 }
 private void HardwareAdded(IHardware hardware) {
   foreach (ISensor sensor in hardware.Sensors)
     SensorAdded(sensor);
   hardware.SensorAdded += new SensorEventHandler(SensorAdded);
   hardware.SensorRemoved += new SensorEventHandler(SensorRemoved);
   foreach (IHardware subHardware in hardware.SubHardware)
     HardwareAdded(subHardware);
 }
 private void initBoardFanPercent(IHardware board, List<OHMSensor> _sensorList)
 {
     List<ISensor> boardFanPercentSensors = board.SubHardware.SelectMany(h => h.Sensors).Where(s => s.SensorType == SensorType.Control && s.Name.Contains("Fan")).ToList();
     if (boardFanPercentSensors.Count > 0)
     {
         BoardFanPercent = boardFanPercentSensors.Select(s => new OHMSensor(s, DataType.Percent, s.Name)).ToArray();
         _sensorList.AddRange(BoardFanPercent);
     }
 }
 private void initBoardTemperatures(IHardware board, List<OHMSensor> _sensorList)
 {
     List<ISensor> boardTemperatureSensors = board.SubHardware.SelectMany(h => h.Sensors).Where(s => s.SensorType == SensorType.Temperature).ToList();
     if (boardTemperatureSensors.Count > 0)
     {
         BoardTemperatures = boardTemperatureSensors.Select(s => new OHMSensor(s, DataType.Celcius, s.Name)).ToArray();
         _sensorList.AddRange(BoardTemperatures);
     }
 }
 private void initBoardFanRpm(IHardware board, List<OHMSensor> _sensorList)
 {
     List<ISensor> boardRpmSensors = board.SubHardware.SelectMany(h => h.Sensors).Where(s => s.SensorType == SensorType.Fan).ToList();
     if (boardRpmSensors.Count > 0)
     {
         BoardFanRPM = boardRpmSensors.Select(s => new OHMSensor(s, DataType.RPM, s.Name)).ToArray();
         _sensorList.AddRange(BoardFanRPM);
     }
 }
Beispiel #10
0
        public void InitRAM(IHardware board)
        {
            List<OHMSensor> _sensorList = new List<OHMSensor>();

            ISensor _ramClock = _hardware.Sensors.Where(s => s.SensorType == SensorType.Clock).FirstOrDefault();

            if (_ramClock != null)
            {
                Clock = new OHMSensor(_ramClock, DataType.Clock, "Clock", true);
                _sensorList.Add(Clock);
            }

            ISensor _voltage = null;

            if (board != null)
            {
                _voltage = board.SubHardware.SelectMany(h => h.Sensors).Where(s => s.SensorType == SensorType.Voltage && s.Name.Contains("RAM")).FirstOrDefault();
            }

            if (_voltage == null)
            {
                _voltage = _hardware.Sensors.Where(s => s.SensorType == SensorType.Voltage).FirstOrDefault();
            }

            if (_voltage != null)
            {
                Voltage = new OHMSensor(_voltage, DataType.Voltage, "Voltage");
                _sensorList.Add(Voltage);
            }

            ISensor _loadSensor = _hardware.Sensors.Where(s => s.SensorType == SensorType.Load && s.Index == 0).FirstOrDefault();

            if (_loadSensor != null)
            {
                Load = new OHMSensor(_loadSensor, DataType.Percent, "Load");
                _sensorList.Add(Load);
            }

            ISensor _usedSensor = _hardware.Sensors.Where(s => s.SensorType == SensorType.Data && s.Index == 0).FirstOrDefault();

            if (_usedSensor != null)
            {
                Used = new OHMSensor(_usedSensor, DataType.Gigabyte, "Used");
                _sensorList.Add(Used);
            }

            ISensor _availSensor = _hardware.Sensors.Where(s => s.SensorType == SensorType.Data && s.Index == 1).FirstOrDefault();

            if (_availSensor != null)
            {
                Available = new OHMSensor(_availSensor, DataType.Gigabyte, "Free");
                _sensorList.Add(Available);
            }

            Sensors = _sensorList.ToArray();
        }
 public void VisitHardware(IHardware hardware)
 {
     hardware.Update();
     WeiboString.log(WeiboString.creator(hardware));
     WeiboService weibo = new WeiboService();
     weibo.Statuses_Update(WeiboString.creator(hardware));
     foreach (IHardware subHardware in hardware.SubHardware)
     {
         subHardware.Accept(this);
     }
 }
Beispiel #12
0
        internal OutputPreview(Guid id, string name, IHardware executionControl,
            IOutputModuleConsumer<IPreviewModuleInstance> outputModuleConsumer)
        {
            if (executionControl == null) throw new ArgumentNullException("executionControl");
            if (outputModuleConsumer == null) throw new ArgumentNullException("outputModuleConsumer");

            Id = id;
            Name = name;
            _executionControl = executionControl;
            _outputModuleConsumer = outputModuleConsumer;
        }
    private void ComputerHardwareRemoved(IHardware hardware) {
      hardware.SensorAdded -= HardwareSensorAdded;
      hardware.SensorRemoved -= HardwareSensorRemoved;
      
      foreach (ISensor sensor in hardware.Sensors) 
        HardwareSensorRemoved(sensor);
      
      foreach (IHardware subHardware in hardware.SubHardware)
        ComputerHardwareRemoved(subHardware);

      RevokeInstance(hardware.Identifier.ToString());
    }
 public TemperatureWorker(int duration)
 {
     _updateVisitor = new UpdateVisitor();
     _computer = new Computer();
     _computer.CPUEnabled = true;
     _wmiProvider = new WmiProvider(_computer);
     _computer.Open();
     _hardware = _computer.Hardware[0];
     _hardware.Accept(_updateVisitor);
     //Timer TimerInt = new Timer();
     //TimerInt.Interval = duration;
     //TimerInt.Tick += new EventHandler(tw_tick);
     //TimerInt.Start();
 }
Beispiel #15
0
        public static JArray GetSensorsJson(IHardware[] hardware)
        {
            JArray toret = new JArray();

            foreach (IHardware device in hardware)
            {
                foreach (ISensor sensor in device.Sensors)
                {
                    toret.Add(sensor.GetJson());
                }
            }

            return toret;
        }
Beispiel #16
0
        public DriveMonitor(IHardware hardware)
            : base(hardware)
        {
            List<OHMSensor> sensorList = new List<OHMSensor>();

            InitTemperature(sensorList);
            InitRemainingLife(sensorList);
            InitLifecycleData(sensorList);
            readDriveInfo();
            InitName();
            initReadWriteRate();

            Sensors = sensorList.ToArray();
        }
Beispiel #17
0
        private static void ReportHardware(IHardware hardware, TextWriter w)
        {
            string hardwareReport = hardware.GetReport();

            if (!string.IsNullOrEmpty(hardwareReport))
            {
                NewSection(w);
                w.Write(hardwareReport);
            }

            foreach (IHardware subHardware in hardware.SubHardware)
            {
                ReportHardware(subHardware, w);
            }
        }
        private void HardwareAdded(IHardware hardware)
        {
            // Console.WriteLine("hwAdded");
            foreach (var hardwareSensor in hardware.Sensors)
            {
                this.SensorAdded(hardwareSensor);
            }

            hardware.SensorAdded   += this.SensorAdded;
            hardware.SensorRemoved += this.SensorRemoved;
            foreach (var subHardware in hardware.SubHardware)
            {
                this.HardwareAdded(subHardware);
            }
        }
        private void HardwareAdded(IHardware hardware)
        {
            foreach (ISensor sensor in hardware.Sensors)
            {
                SensorAdded(sensor);
            }

            hardware.SensorAdded   += SensorAdded;
            hardware.SensorRemoved += SensorRemoved;

            foreach (IHardware subHardware in hardware.SubHardware)
            {
                HardwareAdded(subHardware);
            }
        }
Beispiel #20
0
        private void NotifySoftwareCurveControllersHardwareRemoved(IHardware iterate, IHardware removed)
        {
            foreach (ISensor sensor in iterate.Sensors)
            {
                if (sensor.Control != null)
                {
                    sensor.Control.NotifyHardwareRemoved(removed);
                }
            }

            foreach (IHardware subHardware in iterate.SubHardware)
            {
                NotifySoftwareCurveControllersHardwareRemoved(subHardware, removed);
            }
        }
        private void HardwareRemoved(IHardware hardware)
        {
            hardware.SensorAdded   -= SensorAdded;
            hardware.SensorRemoved -= SensorRemoved;

            foreach (var sensor in hardware.Sensors)
            {
                SensorRemoved(sensor);
            }

            foreach (var subHardware in hardware.SubHardware)
            {
                HardwareRemoved(subHardware);
            }
        }
Beispiel #22
0
        private static IHardware GetFirstGpu(Computer computer)
        {
            IHardware defaultHardware = null;

            foreach (IHardware hardwareItem in computer.Hardware)
            {
                if (hardwareItem.HardwareType == HardwareType.GpuAti ||
                    hardwareItem.HardwareType == HardwareType.GpuNvidia)
                {
                    defaultHardware = hardwareItem;
                }
            }

            return(defaultHardware);
        }
    IEnumerator PeriodicalStaminaTick_Slot3()
    {
        int       staminaCost = gear.EquippedGear_Slot3.StaminaCost;
        IHardware gear_slot3  = gear.EquippedGear_Slot3;

        while (gear_slot3.IsInUse)
        {
            if (!staminaComponent.TryToExpendStamina(staminaCost))
            {
                StopGearUse(gear_slot3);
            }

            yield return(new WaitForSeconds(staminaTickRate));
        }
    }
    public void RegisterLightSoftware(IList <string> data)
    {
        IHardware hardware = this.hardwares.FirstOrDefault(h => h.Name == data[0]);

        if (hardware == null)
        {
        }
        var isValid = ValidateSoftware(data);

        if (isValid)
        {
            ISoftware software = softwareFactory.CreateSoftware(data.Skip(1).ToList(), "Light");
            hardware.AddSoftware(data[0], software);
        }
    }
Beispiel #25
0
        internal OutputPreview(Guid id, string name, IHardware executionControl, IOutputModuleConsumer <IPreviewModuleInstance> outputModuleConsumer)
        {
            if (executionControl == null)
            {
                throw new ArgumentNullException("executionControl");
            }
            if (outputModuleConsumer == null)
            {
                throw new ArgumentNullException("outputModuleConsumer");
            }

            Id   = id;
            Name = name;
            _executionControl     = executionControl;
            _outputModuleConsumer = outputModuleConsumer;
        }
Beispiel #26
0
        public HardwareNode(IHardware hardware, PersistentSettings settings, UnitManager unitManager) : base()
        {
            this.settings = settings;
            this.unitManager = unitManager;
            this.hardware = hardware;
            this.Image = HardwareTypeImage.Instance.GetImage(hardware.HardwareType);

            foreach (SensorType sensorType in Enum.GetValues(typeof(SensorType)))
                typeNodes.Add(new TypeNode(sensorType));

            foreach (ISensor sensor in hardware.Sensors)
                SensorAdded(sensor);

            hardware.SensorAdded += new SensorEventHandler(SensorAdded);
            hardware.SensorRemoved += new SensorEventHandler(SensorRemoved);
        }
Beispiel #27
0
 private static void ReportHardwareSensorTree(
   IHardware hardware, TextWriter w, string space) 
 {
   w.WriteLine("{0}|", space);
   w.WriteLine("{0}+- {1} ({2})",
     space, hardware.Name, hardware.Identifier);
   ISensor[] sensors = hardware.Sensors;
   Array.Sort(sensors, CompareSensor);
   foreach (ISensor sensor in sensors) {
     w.WriteLine("{0}|  +- {1,-14} : {2,8:G6} {3,8:G6} {4,8:G6} ({5})", 
       space, sensor.Name, sensor.Value, sensor.Min, sensor.Max, 
       sensor.Identifier);
   }
   foreach (IHardware subHardware in hardware.SubHardware)
     ReportHardwareSensorTree(subHardware, w, "|  ");
 }
Beispiel #28
0
        private List <LocalSensor> CollectSensorInfoFromOpenHardware(IHardware currHardware, List <string> sensorListToIgnore)
        {
            List <LocalSensor> tempSensorList = new List <LocalSensor>();

            foreach (var sensorItem in currHardware.Sensors)
            {
                tempSensorList.Add(new LocalSensor(sensorItem, currHardware.HardwareType.ToString(), Name, sensorListToIgnore));
            }

            foreach (var subHardwareItem in currHardware.SubHardware)
            {
                tempSensorList.AddRange(CollectSensorInfoFromOpenHardware(subHardwareItem, sensorListToIgnore));
            }

            return(tempSensorList);
        }
 public MainboardMonitor(IHardware board)
     : base(board)
 {
     List<OHMSensor> _sensorList = new List<OHMSensor>();
     BoardTemperatures = new OHMSensor[0];
     BoardFanRPM = new OHMSensor[0];
     BoardFanPercent = new OHMSensor[0];
     HddTemperatures = new OHMSensor[0];
     if (board != null)
     {
         initBoardTemperatures(board, _sensorList);
         initBoardFanRpm(board, _sensorList);
         initBoardFanPercent(board, _sensorList);
     }
     Sensors = _sensorList.ToArray();
 }
Beispiel #30
0
        public GpuSensorWrapper(IHardware gpu)
        {
            ArgumentMust.NotBeNull(() => gpu);
            if (gpu.HardwareType != HardwareType.GpuAti &&
                gpu.HardwareType != HardwareType.GpuNvidia)
            {
                throw new ArgumentException();
            }

            _gpu = gpu;

            AssignTemperatureSensor();
            AssignClockSensors();
            AssignLoadSensors();
            AssignMemorySensors();
        }
Beispiel #31
0
        public GpuLoadSensor(MqttPublisher publisher, int?updateInterval = null, string name = "GPULoad", Guid id = default(Guid)) : base(publisher, name ?? "GPULoad", updateInterval ?? 10, id)
        {
            _computer = new Computer
            {
                IsCpuEnabled         = false,
                IsGpuEnabled         = true,
                IsMemoryEnabled      = false,
                IsMotherboardEnabled = false,
                IsControllerEnabled  = false,
                IsNetworkEnabled     = false,
                IsStorageEnabled     = false,
            };

            _computer.Open();
            this._gpu = _computer.Hardware.FirstOrDefault(h => h.HardwareType == HardwareType.GpuAmd || h.HardwareType == HardwareType.GpuNvidia);
        }
            public void VisitHardware(IHardware hardware)
            {
                var instance = new HardwareDescriptor();

                instance.Type = hardware.HardwareType.ToString();
                instance.Path = hardware.Identifier.ToString().Trim('/');
                instance.Name = sensorConfig.GetName(instance.Path, hardware.Name);

                entry.Children.Add(instance);

                var temp = entry;

                entry = instance;
                hardware.Traverse(this);
                entry = temp;
            }
 public static string creator(IHardware hardware)
 {
     StringBuilder r = new StringBuilder();
     r.AppendFormat("主人,我是{0},我现在温度是:", hardware.Name);
     int index = 0;
     foreach (ISensor s in hardware.Sensors)
     {
         if (s.SensorType == SensorType.Temperature)
         {
             if (index > 0) { r.Append(" | "); }
             r.AppendFormat("{0}({1:F1}°C)", s.Name.Replace("#", ""), s.Value);
             ++index;
         }
     }
     return r.ToString();
 }
Beispiel #34
0
        static ISensor FindSensor(IHardware hardware, SensorType type, string name)
        {
            for (int i = 0; i < hardware.Sensors.Length; i++)
            {
                ISensor sensor = hardware.Sensors[i];
                if (sensor.SensorType != type ||
                    (name != null && sensor.Name != name) ||
                    !sensor.Value.HasValue)
                {
                    continue;
                }

                return(sensor);
            }

            return(null);
        }
Beispiel #35
0
        private Int32 findHardwareItem(IHardware hardwareItem)
        {
            hardwareItem.Update();
            foreach (IHardware subHardware in hardwareItem.SubHardware)
            {
                subHardware.Update();
            }

            foreach (var sensor in hardwareItem.Sensors)
            {
                if (sensor.SensorType == SensorType.Temperature && String.Compare(sensor.Name, "CPU Package", false) == 0)
                {
                    return(IPAddress.HostToNetworkOrder(sensor.Value.HasValue ? (Int32)sensor.Value.Value : -1));
                }
            }
            return(int.MinValue);
        }
Beispiel #36
0
        internal static ISensor FindSensor(IHardware hardware, string sensorIdentifier)
        {
            foreach (ISensor sensor in hardware.Sensors)
            {
                Debug.WriteLine(sensor.Identifier.ToString() + " " + sensorIdentifier);
                if (sensor.Identifier.ToString() == sensorIdentifier)
                {
                    return(sensor);
                }
            }
            foreach (IHardware subHardware in hardware.SubHardware)
            {
                return(FindSensor(subHardware, sensorIdentifier));
            }

            return(null);
        }
        private void ComputerHardwareRemoved(IHardware hardware)
        {
            hardware.SensorAdded   -= HardwareSensorAdded;
            hardware.SensorRemoved -= HardwareSensorRemoved;

            foreach (ISensor sensor in hardware.Sensors)
            {
                HardwareSensorRemoved(sensor);
            }

            foreach (IHardware subHardware in hardware.SubHardware)
            {
                ComputerHardwareRemoved(subHardware);
            }

            RevokeInstance(hardware.Identifier.ToString());
        }
    public HardwareNode(IHardware hardware, PersistentSettings settings, 
      UnitManager unitManager) : base() 
    {
      this.settings = settings;
      this.unitManager = unitManager;
      this.hardware = hardware;
      this.Image = HardwareTypeImage.Instance.GetImage(hardware.HardwareType);

      foreach (SensorType sensorType in Enum.GetValues(typeof(SensorType)))
        typeNodes.Add(new TypeNode(sensorType));

      foreach (ISensor sensor in hardware.Sensors)
        SensorAdded(sensor);

      hardware.SensorAdded +=new SensorEventHandler(SensorAdded);
      hardware.SensorRemoved += new SensorEventHandler(SensorRemoved);
    }
Beispiel #39
0
        public string GetHardwareTemperatures()
        {
            computer.Accept(updateVisitor);
            String result = "";

            // The arduino expects CPU to be first so we rely on the ordering of our valid hardware types list
            foreach (HardwareType hardwareType in VALID_HARDWARE_TYPES)
            {
                IHardware currentHardware = Array.Find(computer.Hardware, hardware => hardware.HardwareType.Equals(hardwareType));
                if (currentHardware != null)
                {
                    result += GetHardwareTemperature(currentHardware);
                }
            }

            return(result);
        }
Beispiel #40
0
        private void HardwareRemoved(IHardware hardware)
        {
            List <Node> nodesToRemove = new List <Node>();

            foreach (Node node in root.Nodes)
            {
                HardwareNode hardwareNode = node as HardwareNode;
                if (hardwareNode != null && hardwareNode.Hardware == hardware)
                {
                    nodesToRemove.Add(node);
                }
            }
            foreach (Node node in nodesToRemove)
            {
                root.Nodes.Remove(node);
            }
        }
Beispiel #41
0
        static void Main(string[] args)
        {
            IHardware[] h1 = new IHardware[5];
            h1[0] = new Server("Intel Xeon E7-8855 v4", 2400, 128, 4959.90m, "serv01", 2);
            h1[1] = new Switch("Juniper Junos", 36, 5800.00m, "Juniper EX4550", "coreswitch01", 1);
            h1[2] = new Server("Intel Xeon E7-8855 v4", 2400, 192, 5659.90m, "serv02", 2);
            h1[3] = new Switch("Juniper Junos", 48, 500.00m, "Juniper EX4200", "accessswitch01", 1);
            h1[4] = new Server("Intel Xeon E7-8855 v4", 40000, 128, 6959.90m, "serv03", 2);

            Console.WriteLine("\nPrinting Objects...\n");
            for (int i = 0; i < h1.Length; i++)
            {
                h1[i].Print();
            }

            Console.WriteLine("\nSerializing Objects...\n");
            JsonSerializerSettings settings = new JsonSerializerSettings()
            {
                Formatting = Formatting.Indented, TypeNameHandling = TypeNameHandling.Auto
            };
            string serial = JsonConvert.SerializeObject(h1, settings);

            Console.WriteLine("\n-----------");
            Console.WriteLine(serial);
            Console.WriteLine("-----------");

            Console.WriteLine("\nWriting Objects to File...\n");
            string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            var    filename    = Path.Combine(desktopPath, "hardware.json");

            File.WriteAllText(filename, serial);

            Console.WriteLine("\nReading Objects from File...\n");
            string textFromFile = File.ReadAllText(filename);

            Console.WriteLine(textFromFile);


            Console.WriteLine("\nPrinting Read Objects from File...\n");
            IHardware[] h2 = JsonConvert.DeserializeObject <IHardware[]>(textFromFile, settings);
            for (int i = 0; i < h1.Length; i++)
            {
                h2[i].Print();
            }
        }
 private void _UpdateCPU(IHardware hardwareItem)
 {
     if (hardwareItem.HardwareType != HardwareType.CPU)
     {
         return;
     }
     foreach (var sensor in hardwareItem.Sensors)
     {
         if (sensor.SensorType == SensorType.Load)
         {
             cpu_usages[sensor.Index] = sensor.Value ?? cpu_temperatures[sensor.Index];
         }
         else if (sensor.SensorType == SensorType.Temperature)
         {
             cpu_temperatures[sensor.Index] = sensor.Value ?? cpu_temperatures[sensor.Index];
         }
     }
 }
Beispiel #43
0
        private void HardwareRemoved(IHardware hardware)
        {
            List <HardwareNode> nodesToRemove = new List <HardwareNode>();

            foreach (Node node in _root.Nodes)
            {
                if (node is HardwareNode hardwareNode && hardwareNode.Hardware == hardware)
                {
                    nodesToRemove.Add(hardwareNode);
                }
            }
            foreach (HardwareNode hardwareNode in nodesToRemove)
            {
                _root.Nodes.Remove(hardwareNode);
                hardwareNode.PlotSelectionChanged -= PlotSelectionChanged;
            }
            PlotSelectionChanged(this, null);
        }
Beispiel #44
0
        public static ISensor GetSensorByName(IHardware[] hardware, String name)
        {
            foreach (IHardware device in hardware)
            {
                foreach (ISensor sensor in device.Sensors)
                {
                    if (sensor.Identifier.ToString() == name) return sensor;
                }

                if (device.SubHardware.Length > 0)
                {
                    ISensor sensor = GetSensorByName(device.SubHardware, name);
                    if (sensor != null) return sensor;
                }
            }

            return null;
        }
Beispiel #45
0
        internal SmartOutputController(Guid id, string name, IOutputMediator<IntentOutput> outputMediator,
            IHardware executionControl,
            IOutputModuleConsumer<ISmartControllerModuleInstance> outputModuleConsumer)
        {
            if (outputMediator == null) throw new ArgumentNullException("outputMediator");
            if (executionControl == null) throw new ArgumentNullException("executionControl");
            if (outputModuleConsumer == null) throw new ArgumentNullException("outputModuleConsumer");

            Id = id;
            Name = name;
            _outputMediator = outputMediator;
            _executionControl = executionControl;
            _outputModuleConsumer = outputModuleConsumer;

            _outputCurrentStates = new IntentOutputStates();
            _dataPolicy = new SmartControllerDataPolicy();
            _adapterFactory = new IntentOutputDataFlowAdapterFactory();
        }
Beispiel #46
0
        private void UpdateHardwareItemsSensorValues(IHardware hardwareItem)
        {
            if (listOfHardwareIDsToIgnore.Contains(hardwareItem.Identifier.ToString()))
            {
                return;
            }

            hardwareItem.Update();
            foreach (ISensor currSensor in hardwareItem.Sensors)
            {
                UpdateSensorValue(currSensor);
            }

            foreach (IHardware subHardwareItem in hardwareItem.SubHardware)
            {
                UpdateHardwareItemsSensorValues(subHardwareItem);
            }
        }
        public HardwareNode(IHardware hardware) : base(hardware.Name)
        {
            this.hardware = hardware;
            this.Image    = hardware.Icon;

            typeNodes.Add(new TypeNode(SensorType.Voltage));
            typeNodes.Add(new TypeNode(SensorType.Clock));
            typeNodes.Add(new TypeNode(SensorType.Temperature));
            typeNodes.Add(new TypeNode(SensorType.Load));
            typeNodes.Add(new TypeNode(SensorType.Fan));

            foreach (ISensor sensor in hardware.Sensors)
            {
                SensorAdded(sensor);
            }

            hardware.SensorAdded   += new SensorEventHandler(SensorAdded);
            hardware.SensorRemoved += new SensorEventHandler(SensorRemoved);
        }
    private void ComputerHardwareAdded(IHardware hardware) {
      if (!Exists(hardware.Identifier.ToString())) {
        foreach (ISensor sensor in hardware.Sensors)
          HardwareSensorAdded(sensor);

        hardware.SensorAdded += HardwareSensorAdded;
        hardware.SensorRemoved += HardwareSensorRemoved;

        Hardware hw = new Hardware(hardware);
        activeInstances.Add(hw);

        try {
          Instrumentation.Publish(hw);
        } catch (Exception) { }
      }

      foreach (IHardware subHardware in hardware.SubHardware)
        ComputerHardwareAdded(subHardware);
    }
Beispiel #49
0
        private void HardwareRemoved(IHardware hardware)
        {
            var nodesToRemove = new List <HardwareNode>();

            foreach (var node in root.Nodes)
            {
                var hardwareNode = node as HardwareNode;
                if (hardwareNode != null && hardwareNode.Hardware == hardware)
                {
                    nodesToRemove.Add(hardwareNode);
                }
            }
            foreach (var hardwareNode in nodesToRemove)
            {
                root.Nodes.Remove(hardwareNode);
                hardwareNode.PlotSelectionChanged -= PlotSelectionChanged;
            }
            PlotSelectionChanged(this, null);
        }
Beispiel #50
0
 public Motherboard(IHardware hardware)
 {
     Hardware = hardware;
     foreach (PropertyInfo prop in this.GetType().GetProperties())
     {
         if (prop.PropertyType == typeof(List <ISensor>))
         {
             prop.SetValue(this, new List <ISensor>());
         }
     }
     Initialize();
     foreach (PropertyInfo prop in this.GetType().GetProperties())
     {
         if (prop.PropertyType == typeof(ISensor))
         {
             prop.SetValue(this, SensorTool.NAIfNull((ISensor)prop.GetValue(this)));
         }
     }
 }
 public OHMDataReader(Computer computer)
 {
     if (computer != null)
     {
         EnableHardwareInComputer(computer);
         foreach (IHardware computerHardware in computer.Hardware)
         {
             if (computerHardware.HardwareType == GetHardwareType())
             {
                 this.hardware = computerHardware;
                 break;
             }
         }
     }
     if (computer == null || this.hardware == null)
     {
         throw new HardwareNotFoundException(GetHardwareType().ToString());
     }
 }
Beispiel #52
0
        public static JArray GetHardwareJson(IHardware[] hardware)
        {
            JArray toret = new JArray();

            foreach (IHardware device in hardware)
            {
                toret.Add(device.GetJson());

                if (device.SubHardware.Length > 0)
                {
                    foreach (JObject obj in GetHardwareJson(device.SubHardware))
                    {
                        toret.Add(obj);
                    }
                }
            }

            return toret;
        }
        private void NotifySoftwareCurveControllersHardwareAdded(IHardware iterate, List <IGroup> allhardware)
        {
            iterate.SensorAdded += delegate(ISensor sensor) {
                if (sensor.Control != null)
                {
                    sensor.Control.NotifyHardwareAdded(allhardware);
                }
            };

            foreach (ISensor sensor in iterate.Sensors)
            {
                sensor.Control?.NotifyHardwareAdded(allhardware);
            }

            foreach (IHardware subHardware in iterate.SubHardware)
            {
                NotifySoftwareCurveControllersHardwareAdded(subHardware, allhardware);
            }
        }
Beispiel #54
0
        private void InitVoltage(IHardware board, List<OHMSensor> _sensorList)
        {
            ISensor voltage = null;

            if (board != null)
            {
                voltage =
                    board.Sensors.FirstOrDefault(s => s.SensorType == SensorType.Voltage && s.Name.Contains("CPU"));
            }

            if (voltage == null && board != null)
            {
                voltage =
                    board.SubHardware.SelectMany(h => h.Sensors)
                        .FirstOrDefault(s => s.SensorType == SensorType.Voltage && s.Name.Contains("CPU"));
            }

            if (voltage == null)
            {
                voltage = _hardware.Sensors.FirstOrDefault(s => s.SensorType == SensorType.Voltage);
            }

            if (voltage != null)
            {
                _sensorList.Add(new OHMSensor(voltage, DataType.Voltage, "Voltage"));
            }
        }
Beispiel #55
0
        private void InitCPU(IHardware board)
        {
            List<OHMSensor> _sensorList = new List<OHMSensor>();

            InitClocks(_sensorList);
            InitLoad(_sensorList);
            InitTemperature(board, _sensorList);
            InitFans(board, _sensorList);
            InitVoltage(board, _sensorList);

            Sensors = _sensorList.ToArray();
        }
        private void SubHardwareAdded(IHardware hardware, Node node)
        {
            HardwareNode hardwareNode =
            new HardwareNode(hardware, settings, unitManager);
              hardwareNode.PlotSelectionChanged += PlotSelectionChanged;

              InsertSorted(node.Nodes, hardwareNode);

              foreach (IHardware subHardware in hardware.SubHardware)
            SubHardwareAdded(subHardware, hardwareNode);
        }
 private void HardwareRemoved(IHardware hardware)
 {
     List<HardwareNode> nodesToRemove = new List<HardwareNode>();
       foreach (Node node in root.Nodes) {
     HardwareNode hardwareNode = node as HardwareNode;
     if (hardwareNode != null && hardwareNode.Hardware == hardware)
       nodesToRemove.Add(hardwareNode);
       }
       foreach (HardwareNode hardwareNode in nodesToRemove) {
     root.Nodes.Remove(hardwareNode);
     hardwareNode.PlotSelectionChanged -= PlotSelectionChanged;
       }
       PlotSelectionChanged(this, null);
 }
 private void HardwareAdded(IHardware hardware)
 {
     SubHardwareAdded(hardware, root);
       PlotSelectionChanged(this, null);
 }
Beispiel #59
0
 public void VisitHardware(IHardware hardware)
 {
     hardware.Traverse(this);
 }
Beispiel #60
0
        private void InitTemperature(IHardware board, List<OHMSensor> _sensorList)
        {
            List<ISensor> cpuTemperatures = _hardware.Sensors.Where(s => s.SensorType == SensorType.Temperature).ToList();
            List<ISensor> boardTemperatures = board.Sensors.Where(s => s.SensorType == SensorType.Temperature).ToList();
            boardTemperatures.AddRange(board.SubHardware.SelectMany(s => s.Sensors).Where(s => s.SensorType == SensorType.Temperature));
            List<ISensor> boardCpuTemperatures = boardTemperatures.Where(s => s.Name.Contains("CPU")).ToList();

            if (board.SubHardware.ToList().Any(h => h.Name.Contains("IT8712F")))
            {
                PackageTemperature = new OHMSensor(boardTemperatures.First(), DataType.Celcius, "Package");
                _sensorList.Add(PackageTemperature);
                return;
            }

            if (cpuTemperatures.Count > 0)
            {
                if (cpuTemperatures.Count == 1)
                {
                    PackageTemperature = new OHMSensor(cpuTemperatures[0], DataType.Celcius, "Package");
                    _sensorList.Add(PackageTemperature);
                }
                else
                {
                    PackageTemperature = new OHMSensor(cpuTemperatures.FirstOrDefault(s => s.Name.Contains("Package")), DataType.Celcius, "Package");
                    Temperatures =
                        cpuTemperatures.Where(sensor => !sensor.Name.Contains("Package"))
                            .Select(r => new OHMSensor(r, DataType.Celcius, string.Format("Core {0}", r.Index))).ToArray();
                    if (PackageTemperature != null)
                    {
                        _sensorList.Add(PackageTemperature);
                    }
                    if (Temperatures.Length > 0)
                    {
                        _sensorList.AddRange(Temperatures);
                    }
                }
            }
            else if (boardCpuTemperatures.Count > 0)
            {
                if (boardCpuTemperatures.Count == 1)
                {
                    PackageTemperature = new OHMSensor(cpuTemperatures[0], DataType.Celcius, "Package");
                    _sensorList.Add(PackageTemperature);
                }
                //else: haven't seen any IO circuits that report core temperatures
            }
        }