Пример #1
0
 /// <summary>
 /// 强制更新CPU信息
 /// </summary>
 public void Update()
 {
     if (c.GetData())
     {
         Changed("CPUTemplater");
         Changed("CPULoad");
         Changed("Frequency");
         Changed("InnerFrequency");
         Changed("CPUName");
         Changed("FrequencyLock");
         Changed("CoreCount");
     }
 }
Пример #2
0
        private void OnTimer(object sender, ElapsedEventArgs e)
        {
            //Attempt to read shared memory.
            bool readSuccess = coreTempInfo.GetData();

            //If read was successful the post the new info on the console.
            if (readSuccess)
            {
                var temps   = coreTempInfo.GetTemp;
                var maxTemp = temps.Max();
                logWriter.WriteLine("Tmax {0}", maxTemp);
            }
            else
            {
                eventLog.WriteEntry("Internal error name: " + coreTempInfo.GetLastError);
                eventLog.WriteEntry("Internal error message: " + coreTempInfo.GetErrorMessage(coreTempInfo.GetLastError));
            }
        }
Пример #3
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            CTInfo.GetData();
            if (port.IsOpen)
            {
                label3.Text = (int.Parse(label3.Text) + 1).ToString();
                port.Write("r");
                int cpuusage = (int)Math.Round(performanceCounter1.NextValue(), 0);
                int gpuusage = (int)Math.Round(gpuz.GetUsage(), 0);

                string usage = cpuusage + "," + gpuusage + "%";

                port.Write(usage);

                int UsedRam = GetUsedRam();

                string ram = UsedRam + "Mb";
                for (int i = 1; i <= 16 - usage.Length - ram.Length; i++)
                {
                    port.Write(" ");
                }
                port.Write(ram);
                port.Write("n");
                int kbs = (int)Math.Round(performanceCounter3.NextValue() / 1024f, 0);

                string kbsec = kbs + "Kb";
                totalbytes += performanceCounter3.NextValue();
                port.Write(kbsec);
                int    cputemp = (int)Math.Round(CTInfo.GetTemp[0], 0);
                int    gputemp = (int)Math.Round(gpuz.GetTemp(), 0);
                string temp    = " " + cputemp + "," + gputemp + "C";

                port.Write(temp);
                string totalmega = Math.Round((totalbytes / 1024f) / 1024f, 0).ToString() + "Mb";
                for (int i = 1; i <= 16 - temp.Length - kbsec.Length - totalmega.Length; i++)
                {
                    port.Write(" ");
                }
                port.Write(totalmega);

                CPUusage_Graph.AddValue(cpuusage);
                GPUusage_Graph.AddValue(gpuusage);

                if (UsedRam > RamUsed_Graph.highest)
                {
                    RamUsed_Graph.highest = UsedRam;
                    RamUsed_Graph.mid     = (int)Math.Round((double)UsedRam / 2, 0);
                }

                RamUsed_Graph.AddValue(UsedRam);

                if (kbs > Downloadspeed_Graph.highest)
                {
                    Downloadspeed_Graph.highest = kbs;
                    Downloadspeed_Graph.mid     = (int)Math.Round((double)kbs / 2, 0);
                }

                Downloadspeed_Graph.AddValue(kbs);

                if (cputemp > CPUtemp_Graph.highest)
                {
                    CPUtemp_Graph.highest = cputemp;
                    CPUtemp_Graph.mid     = (int)Math.Round((double)cputemp / 2, 0);
                }

                CPUtemp_Graph.AddValue(cputemp);

                if (gputemp > GPUtemp_Graph.highest)
                {
                    GPUtemp_Graph.highest = gputemp;
                    GPUtemp_Graph.mid     = (int)Math.Round((double)gputemp / 2, 0);
                }

                GPUtemp_Graph.AddValue(gputemp);
            }
        }
Пример #4
0
        // from the core temp demo code
        private void RefreshInfo_Elapsed(object sender, ElapsedEventArgs e)
        {
            //Attempt to read shared memory.
            bool bReadSuccess = CTInfo.GetData();

            if (bReadSuccess)
            {
                uint  index;
                float maxT = 1.0f;
                int   load = 0;
                // get max and avg load for all cpu's + cores
                for (uint i = 0; i < CTInfo.GetCPUCount; i++)
                {
                    for (uint g = 0; g < CTInfo.GetCoreCount; g++)
                    {
                        index = g + (i * CTInfo.GetCoreCount);
                        if (!CTInfo.IsDistanceToTjMax)
                        {
                            if (maxT <= CTInfo.GetTemp[index])
                            {
                                maxT = CTInfo.GetTemp[index];
                            }
                            load += (int)CTInfo.GetCoreLoad[index];
                        }
                    }
                }

                //date string
                string   datePatt = @"HH:mm";
                DateTime saveNow  = DateTime.Now;
                DateTime myDt;
                myDt = DateTime.SpecifyKind(saveNow, DateTimeKind.Local);
                string dtString;


                // setup output string
                // Core Speed, Core Temp, Max Core Temp, Time, Average Load,
                // #.#Ghz,#.#,##:##,###

                dtString = myDt.ToString(datePatt);
                HardwareMonitor mahm = new HardwareMonitor();
                //String output = Math.Round((CTInfo.GetCPUSpeed / 1000), 1) + "Ghz" + ";" + Math.Round(maxT, 1) + ";" + dtString + ";" + +((int)(load / CTInfo.GetCoreCount));
                //String output = "RAM:" + (((totalRam - getAvailableRAM()) * 100 / totalRam)) + "%" + ";" + Math.Round(maxT, 1) + ";" + dtString + ";" + +((int)(load / CTInfo.GetCoreCount)); //CPU
                String output = "0:" + mahm.Entries[0].Data.ToString() + "C;1:" + mahm.Entries[1].Data.ToString() + "C;" + (((totalRam - getAvailableRAM()) * 100 / totalRam)) + ";" + Math.Round(maxT, 0) + "C;" + mahm.Entries[2].Data.ToString() + ";" + ((int)(load / CTInfo.GetCoreCount));
                //update tooltip icon
                ACTnotf.Text = "Module Running - " + output;

                // write com if avail if not notify
                if (comPort.IsOpen)
                {
                    try{
                        comPort.WriteLine(output);
                    }
                    catch (System.IO.IOException argEx)
                    {
                    }
                    try
                    {
                        this.Invoke((MethodInvoker) delegate
                        {                            // added ram to display not to string as arduino is not updated to show it yet.
                            //tbConsole.Text = output + ";" + getAvailableRAM() + ";" + totalRam + ";" + ((getAvailableRAM() * 100 / totalRam))+"%"; // runs on UI thread
                            tbConsole.Text = output; // modificado
                        });
                    }

                    catch (Exception excp)
                    {
                    }
                }
                else // no com available
                {
                    try
                    {
                        this.Invoke((MethodInvoker) delegate
                        {
                            tbConsole.Text = "Com port not available"; // runs on UI thread
                        });
                    }
                    catch (Exception excp)
                    {
                    }
                }
            }
            else // coretemp not avail
            {
                this.Invoke((MethodInvoker) delegate
                {
                    tbConsole.Text = CTInfo.GetErrorMessage(CTInfo.GetLastError); // runs on UI thread
                });
            }
        }
Пример #5
0
        public string FetchCoreTempInfoXml()
        {
            try
            {
                Trace.WriteLine(String.Format("{0} Fetch Core Temp Info", DateTime.Now.ToLongTimeString()));
                //Initiate CoreTempInfo class.
                CoreTempInfo CTInfo = new CoreTempInfo();

                if (!CTInfo.GetData())
                {
                    Trace.WriteLine(String.Format("\tNo CPU Data"));
                    return(null);
                }

                XDocument result = new XDocument(new XElement("CoreTemp",
                                                              new XAttribute("count", CTInfo.GetCoreCount * CTInfo.GetCPUCount),
                                                              new XAttribute("tjmax", CTInfo.GetTjMax[0]),
                                                              new XAttribute("units", CTInfo.IsFahrenheit ? "F" : "C")));

                for (int i = 0; i < CTInfo.GetCoreCount * CTInfo.GetCPUCount; i++)
                {
                    result.Root.Add(new XElement("Core",
                                                 new XAttribute("load", CTInfo.GetCoreLoad[i]),
                                                 new XAttribute("temp", CTInfo.GetTemp[i])));
                    Trace.WriteLine(String.Format("\tCore {0}: temp {1}; load {2}", i, CTInfo.GetCoreLoad[i], CTInfo.GetTemp[i]));
                }

                var gpuz = new GPUZ.GPUZ();

                if (gpuz.OpenView())
                {
                    var data = gpuz.GetData();

                    var gpu = new XElement("GPU");
                    result.Root.Add(gpu);
                    foreach (var sensor in data.sensors)
                    {
                        switch (sensor.name)
                        {
                        case "":
                            break;

                        case "GPU Load":
                            Trace.WriteLine(String.Format("\t{0} = {1}", sensor.name, sensor.value));
                            gpu.Add(new XAttribute("load", Convert.ToInt32(sensor.value)));
                            continue;

                        case "GPU Temperature":
                            Trace.WriteLine(String.Format("\t{0} = {1}", sensor.name, sensor.value));
                            gpu.Add(new XAttribute("temp", Convert.ToInt32(sensor.value)));
                            continue;

                        default:
                            continue;
                        }
                    }
                    gpuz.CloseView();
                }
                else
                {
                    Trace.WriteLine(String.Format("\tNo GPU Data"));
                }

                return(result.ToString());
            }
            catch (System.Exception)
            {
                return(null);
            }
        }