Exemplo n.º 1
0
        private static HDDtemperatures GetHDDTemperature()
        {
            Program.computer.HDDEnabled = true;
            Program.computer.Accept(Program.visitor);

            Program.tempInfo = string.Empty;

            HDDtemperatures returnHDDtemp = new HDDtemperatures();

            int k = 0;

            for (int i = 0; i < computer.Hardware.Length; i++)
            {
                if (computer.Hardware[i].HardwareType == HardwareType.HDD)
                {
                    for (int j = 0; j < computer.Hardware[i].Sensors.Length; j++)
                    {
                        if (computer.Hardware[i].Sensors[j].SensorType == SensorType.Temperature)
                        {
                            returnHDDtemp.HDDtemp[k] = computer.Hardware[i].Sensors[j].Value;
                            k++;
                        }
                    }
                }
            }
            for (int i = k; i < 4; i++)
            {
                returnHDDtemp.HDDtemp[i] = 0;
            }

            return(returnHDDtemp);
        }
Exemplo n.º 2
0
 private static void startGetHDDTemperatureFuncThread()
 {
     while (true)
     {
         HDDtemperatures getRetrnedHDDTemps = new HDDtemperatures();
         getRetrnedHDDTemps = GetHDDTemperature();
         Thread.Sleep(100);
         using (StreamWriter sw = new StreamWriter("temperatures.txt", true, System.Text.Encoding.Default))
         {
             for (int i = 0; i < 4; i++)
             {
                 if (getRetrnedHDDTemps.HDDtemp[i] != 0)
                 {
                     sw.WriteLine(getRetrnedHDDTemps.HDDtemp[i]);
                 }
             }
         }
         Thread.Sleep(1900);
     }
 }