コード例 #1
0
ファイル: SuperIO.cs プロジェクト: KratosFu/TempServe
        public IEnumerable <Sample> GetData()
        {
            if (!available)
            {
                yield break;
            }

            foreach (var handle in handles)
            {
                string name;
                NVAPI.NvAPI_GPU_GetFullName(handle, out name);

                NvGPUThermalSettings settings = GetThermalSettings(handle);

                for (int i = 0; i < settings.Count; i++)
                {
                    NvSensor sensor = settings.Sensor[i];
                    switch (sensor.Target)
                    {
                    case NvThermalTarget.BOARD:
                        name = "GPU Board";
                        break;

                    case NvThermalTarget.GPU:
                        name = "GPU Core";
                        break;

                    case NvThermalTarget.MEMORY:
                        name = "GPU Memory";
                        break;

                    case NvThermalTarget.POWER_SUPPLY:
                        name = "GPU Power Supply";
                        break;

                    case NvThermalTarget.UNKNOWN:
                        name = "GPU Unknown";
                        break;

                    default:
                        name = "GPU";
                        break;
                    }

                    yield return(Sample.Temperature(name, sensor.CurrentTemp, true));
                }

                int value;
                if (NVAPI.NvAPI_GPU_GetTachReading != null &&
                    NVAPI.NvAPI_GPU_GetTachReading(handle, out value) == NvStatus.OK)
                {
                    yield return(Sample.FanSpeed("GPU Fan", value, true));
                }
            }
        }
コード例 #2
0
ファイル: SuperIO.cs プロジェクト: KratosFu/TempServe
        public IEnumerable <Sample> GetData()
        {
            if (available)
            {
                yield return(Sample.Temperature("Water", water, true));

                yield return(Sample.Temperature("Air", air, true));

                yield return(Sample.Temperature("Room", room, true));

                yield return(Sample.Temperature("Outside", outside, true));
            }
        }
コード例 #3
0
        void LoadPersistedData()
        {
            var cs = "Data Source=Log.sdf;Max Database Size=4091";

            using (var con = new SqlCeConnection(cs))
            {
                var cmd = con.CreateCommand();
                cmd.CommandText = "SELECT * FROM Sample WHERE [Time] > @time";
                cmd.Parameters.Add("@time", DateTime.Now.AddMinutes(-5));

                con.Open();

                using (var dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        var dic = new Dictionary <string, Sample>();

                        var time = dr.GetDateTime(0);

                        for (int i = 1; i < dr.FieldCount; i++)
                        {
                            var name  = dr.GetName(i);
                            var value = dr.GetDouble(i);

                            // :(
                            var s = Sample.Other(name, value, false);
                            s.Time    = time;
                            dic[name] = s;
                        }

                        double[] temps = { dic["CORE 1"].Value, dic["CORE 2"].Value, dic["CORE 3"].Value, dic["CORE 4"].Value };

                        var cpuavg = Sample.Temperature("CORE AVG", temps.Average(), false);
                        cpuavg.Time = time;

                        dic["CORE AVG"] = cpuavg;

                        var cpumax = Sample.Temperature("CORE MAX", temps.Max(), false);
                        cpumax.Time = time;

                        dic["CORE MAX"] = cpumax;

                        avg5.Enqueue(dic);
                    }
                }

                con.Close();
            }
        }
コード例 #4
0
ファイル: SuperIO.cs プロジェクト: KratosFu/TempServe
        public IEnumerable <Sample> GetData()
        {
            if (device == DeviceType.Unknown || device == DeviceType.NotPresent)
            {
                yield break;
            }

            double
                cpufanout0rpm   = 0,
                sysfanoutrpm    = 0,
                auxfanout0rpm   = 0,
                cpufanout1rpm   = 0,
                motherboardtemp = 0,
                cputin          = 0xFF,
                systin          = 0xFF,
                auxtin          = 0xFF;

            var cs = Read(BankSelect);

            while (cputin >= 99 || cputin <= -55)
            {
                Select(1);
                cputin = (sbyte)Read(0x50) + (Read(0x51) >> 7) * 0.5;
            }

            while (auxtin >= 99 || auxtin <= -55)
            {
                Select(2);
                auxtin = (sbyte)Read(0x50) + (Read(0x51) >> 7) * 0.5;
            }

            while (systin >= 99 || systin <= -55)
            {
                Select(0);
                systin = (sbyte)Read(0x27);
            }

            if (manufacturer == "ASUSTeK Computer INC." && product.StartsWith("P7P55D"))
            {
                // only on ASUS P7P55D
                var sio = new SuperIO {
                    BaseAddress = sioport
                };

                sio.Enter();
                var css = sio.Read(sio.BankSelect);
                sio.Select(0xc);
                var cr20 = sio.Read(0x20);
                sio.Select(css);
                sio.Exit();

                if (cr20 == 0xb3)
                {
                    Select(0);
                    Write(0x7d, 0); // seems to be some other values in 1,2,3,4
                    motherboardtemp = Read(0x7e);
                }
                else
                {
                    motherboardtemp = systin;
                }
            }

            var cputinavg = double.IsNaN(lastcputin) ? cputin : (cputin + lastcputin) / 2;

            lastcputin = cputin;

            var cpufanspeed0 = CalculateFanSpeed(motherboardtemp, cputinavg, fansettings["CPUFAN0"]);
            var sysfanspeed  = CalculateFanSpeed(motherboardtemp, cputinavg, fansettings["SYSFAN"]);

            Select(0);
            Write(0x4, 0);
            Write(1, sysfanspeed);
            Write(3, cpufanspeed0);

            var cpufanout0 = Read(0x29);

            int failcount = 0;

            while ((cpufanout0 == 0xff || cpufanout0 == 0) && failcount < 5)
            {
                Thread.Sleep(failcount);
                cpufanout0 = Read(0x29);
                failcount++;
            }

            if (failcount < 5 && cpufanout0 > 0 && cpufanout0 < 255)
            {
                var cpufanout0div = ((Read(0x47) >> 6) & 3) | (((Read(0x5d) >> 6) & 1) << 2);
                cpufanout0rpm = GetRPM(cpufanout0, cpufanout0div);
            }

            failcount = 0;

            var sysfanout = Read(0x28);

            while ((sysfanout == 0xff || sysfanout == 0) && failcount < 5)
            {
                Thread.Sleep(failcount);
                sysfanout = Read(0x28);
                failcount++;
            }

            if (failcount < 5 && sysfanout > 0 && sysfanout < 255)
            {
                var sysfanoutdiv = ((Read(0x47) >> 4) & 3) | (((Read(0x5d) >> 5) & 1) << 2);
                sysfanoutrpm = GetRPM(sysfanout, sysfanoutdiv);
            }

            failcount = 0;

            var auxfanout0 = Read(0x2a);

            while ((auxfanout0 == 0xff || auxfanout0 == 0) && failcount < 5)
            {
                Thread.Sleep(failcount);
                auxfanout0 = Read(0x2a);
                failcount++;
            }

            if (failcount < 5 && auxfanout0 > 0 && auxfanout0 < 255)
            {
                var auxfanout0div = ((Read(0x4b) >> 6) & 3) | (((Read(0x5d) >> 7) & 1) << 2);
                auxfanout0rpm = GetRPM(auxfanout0, auxfanout0div);
            }

            failcount = 0;

            var cpufanout1 = Read(0x3f);

            while ((cpufanout1 == 0xff || cpufanout1 == 0) && failcount < 5)
            {
                Thread.Sleep(failcount);
                cpufanout1 = Read(0x3f);
                failcount++;
            }

            if (failcount < 5 && cpufanout1 > 0 && cpufanout1 < 255)
            {
                var cpufanout1div = ((Read(0x59) >> 0) & 3) | (((Read(0x4c) >> 7) & 1) << 2);
                cpufanout1rpm = GetRPM(cpufanout1, cpufanout1div);

                Debug.Assert(cpufanout1rpm < 100000);
            }

            failcount = 0;

            var vcore    = Read(0x20) * 0.008;
            var vin0_12v = Read(0x21) * 0.008 * 7; //guess
            //var avcc = Read(0x22) * 0.008;
            var vcc_3_3v = Read(0x23) * 0.008 * 2; //guess
            var vin1_5v  = Read(0x24) * 0.008 * 3; //guess

            //var vin2_2_5v = Read(0x25) * 0.008;
            //var vin3 = Read(0x26) * 0.008;

            Select(cs);

            yield return(Sample.Temperature("CPUTIN", cputin, true));

            yield return(Sample.Temperature("SYSTIN", systin, false));

            yield return(Sample.Temperature("AUXTIN", auxtin, true));

            if (motherboardtemp > 0)
            {
                yield return(Sample.Temperature("Motherboard", motherboardtemp, true));
            }

            yield return(Sample.FanSpeed("CPUFAN0", cpufanout0rpm, true));

            yield return(Sample.FanSpeed("CPUFAN1", cpufanout1rpm, true));

            yield return(Sample.FanSpeed("SYSFAN", sysfanoutrpm, true));

            yield return(Sample.FanSpeed("AUXFAN", auxfanout0rpm, true));

            yield return(Sample.Voltage("VCORE", vcore, true));

            yield return(Sample.Voltage("12V", vin0_12v, false));

            yield return(Sample.Voltage("5V", vin1_5v, false));

            yield return(Sample.Voltage("3.3V", vcc_3_3v, false));
        }
コード例 #5
0
ファイル: SuperIO.cs プロジェクト: KratosFu/TempServe
        public IEnumerable <Sample> GetData()
        {
            if (reader == null)
            {
                available = GetCPUInfo();

                if (available)
                {
                    //rtcloop = new Thread(RTCLoop);
                    //rtcloop.IsBackground = true;
                    //rtcloop.Start();

                    tscloop = new Thread(TSCLoop);
                    tscloop.IsBackground = true;
                    tscloop.Start();

                    reader = new Thread(ReadLoop);
                    reader.IsBackground = true;
                    reader.Start();

                    Thread.Sleep(1100);
                }
            }

            if (available)
            {
                var data = samples.Clone() as uint[, ];

                int  r = 0;
                uint eax = 0, edx = 0;

                var temps = new List <double>();

                double multiplier = 0;

                // get max multipler, only works up to max 4 core turbo multiplier
                for (int i = 0; i < CORE_COUNT; i++)
                {
                    UIntPtr mask = (UIntPtr)(1 << (i * UIntPtr.Size / 4));
                    r           = Ols.RdmsrPx(0x198, ref eax, ref edx, mask);
                    multiplier += eax & 0xff;
                }

                multiplier /= CORE_COUNT;

                // MSR_PLATFORM_INFO
                // used for speed calculations
                r = Ols.Rdmsr(0xce, ref eax, ref edx);
                var maxnoturboratio = (eax >> 8) & 0xff;

                var fsb    = speed / maxnoturboratio;
                var rtcfsb = (rtcspeed == 0 ? speed : rtcspeed) / maxnoturboratio;

                for (int i = 0; i < CORE_COUNT; i++)
                {
                    double sample = 0;
                    for (int j = 0; j < SAMPLE_RATE; j++)
                    {
                        sample += GetTemp(data[j, i]);
                    }

                    temps.Add(sample / SAMPLE_RATE);
                }

                // in Windows we trust...
                yield return(Sample.Other("CPU Load", pc.NextValue(), true));

                yield return(Sample.Other("Multiplier", multiplier, true));

                yield return(Sample.Other("FSB (TSC)", fsb, true));

                //yield return Sample.Other("FSB (RTC)", rtcfsb, false);

                for (int i = 0; i < temps.Count; i++)
                {
                    yield return(Sample.Temperature("CORE " + (i + 1), temps[i], true));
                }

                yield return(Sample.Temperature("CORE AVG", temps.Average(), false));

                yield return(Sample.Temperature("CORE MAX", temps.Max(), false));
            }
        }