Beispiel #1
0
            public IEnumerable <Sample> GetData()
            {
                if (check)
                {
                    check = false;

                    if (smbus.Available)
                    {
                        int MFR_MODEL = smbus.GetReg(ADDRESS, 0x9a, 2);
                        available = MFR_MODEL == 0x3298;
                    }
                    else
                    {
                        available = false;
                    }
                }

                if (available)
                {
                    int VOUT = smbus.GetReg(ADDRESS, 0x8b, 2);
                    int IOUT = smbus.GetReg(ADDRESS, 0x8c, 2);
                    int POUT = smbus.GetReg(ADDRESS, 0x96, 2);

                    var VID     = GetVID(VOUT);
                    var Power   = ReadLiteral(POUT);
                    var Current = ReadLiteral(IOUT);

                    yield return(Sample.Voltage("CPU VID", VID, true));

                    yield return(Sample.Other("CPU Current", Current, true));

                    yield return(Sample.Other("CPU Power", Power, true));
                }
            }
Beispiel #2
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();
            }
        }
Beispiel #3
0
        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));
            }
        }