예제 #1
0
        public double GpuTemp(ComputerObj comp)
        {
            int gpuindex = 0;

            for (int i = 0; i < comp.Computer.Hardware.Length; i++)
            {
                String tempGPU = comp.Computer.Hardware[i].HardwareType.ToString();
                if (tempGPU.Contains("gpu") || tempGPU.Contains("Gpu") || tempGPU.Contains("GPU"))
                {
                    gpuindex = i;
                }
            }
            var    mygpu     = comp.Computer.Hardware[gpuindex];
            double tempTotal = 0;
            int    numTotal  = 0;

            for (int i = 0; i < mygpu.Sensors.Length; i++)
            {
                if (mygpu.Sensors[i].SensorType.ToString().Equals("Temperature"))
                {
                    if (mygpu.Sensors[i].Value != null)
                    {
                        numTotal++;
                        tempTotal += Convert.ToDouble(mygpu.Sensors[i].Value.ToString());
                    }
                }
            }

            return(tempTotal / numTotal);
        }
예제 #2
0
        public void UpdateValues(ComputerObj comp)
        {
            Hardware hw      = new Hardware();
            data     NewData = new data();

            NewData.CpuTemp = hw.CpuTemp(comp);
            NewData.GpuTemp = hw.GpuTemp(comp);
            NewData.Cpu     = comp.TotalCpu;
            NewData.Gpu     = comp.TotalGpu;
            NewData.Memory  = comp.TotalMemory;
            NewData.Network = comp.TotalNetwork;
            NewData.Disk    = comp.TotalDisk;
            List <ProcessEntry> currList = new List <ProcessEntry>(comp.ProcessList);
            List <ProcessEntry> newList  = new List <ProcessEntry>();

            foreach (int somePid in myPids)
            {
                if (currList.Exists(x => x.Pid == somePid))
                {
                    newList.Add(currList.Find(x => x.Pid == somePid));
                }
            }
            NewData.ProcessList = newList;
            mypayload.mydata.Add(NewData);
            mypayload.mytimes.Add(DateTime.Now);
        }
예제 #3
0
        public double CpuTemp(ComputerObj comp)
        {
            int cpuindex = 0;

            for (int i = 0; i < comp.Computer.Hardware.Length; i++)
            {
                if (comp.Computer.Hardware[i].HardwareType.ToString().Equals("CPU"))
                {
                    cpuindex = i;
                }
            }
            var    mycpu     = comp.Computer.Hardware[cpuindex];
            double tempTotal = 0;
            int    numTotal  = 0;

            for (int i = 0; i < mycpu.Sensors.Length; i++)
            {
                if (mycpu.Sensors[i].SensorType.ToString().Equals("Temperature"))
                {
                    if (mycpu.Sensors[i].Value != null)
                    {
                        numTotal++;
                        tempTotal += Convert.ToDouble(mycpu.Sensors[i].Value.ToString());
                    }
                }
            }

            return(tempTotal / numTotal);
        }
예제 #4
0
        public void Read(ComputerObj comp)
        {
            var   now   = DateTime.Now;
            Trend trend = GetTrend(comp);

            AddChartValues(trend, now);
            SetAxisLimits(now);
            ClearChartValues();
        }
예제 #5
0
 public void UpdateValues(ComputerObj comp)
 {
     this.Dispatcher.Invoke(() =>
     {
         t1.Text     = $"CPU: {comp.TotalCpu}%";
         t2.Text     = $"GPU: {comp.TotalGpu}%";
         t3.Text     = $"Memory: {comp.TotalMemory}%";
         TotalMemory = comp.TotalMemory;
     });
 }
예제 #6
0
        public void UpdateList(ComputerObj comp)
        {
            this.Dispatcher.Invoke(() =>
            {
                if (comp.ProcessTree != null)
                {
                    procListTreeView = new ObservableCollection <ProcessEntry>(comp.ProcessTree.OrderByDescending(p => p.Cpu));
                    Loading.Text     = "";
                }

                UpdateProcessTreeView();
            });
        }
예제 #7
0
        public void UpdateColumnHeaders(ComputerObj comp)
        {
            listView_gridView.Columns[0].Header = $"Process {comp.ProcessList.Count}";
            listView_gridView.Columns[1].Header = $"CPU {Math.Round(comp.TotalCpu, 2)}%";
            listView_gridView.Columns[2].Header = $"GPU {Math.Round(comp.TotalGpu, 2)}%";
            listView_gridView.Columns[3].Header = $"Memory {Math.Round(comp.TotalMemory, 2)}%";
            listView_gridView.Columns[4].Header = $"Disk {Math.Round(comp.TotalDisk, 2)} Mb/s";
            listView_gridView.Columns[5].Header = $"Network {Math.Round(comp.TotalNetwork, 2)}%";

            if (Math.Round(comp.TotalCpu, 2) > 100)
            {
                listView_gridView.Columns[1].Header = $"CPU 100%";
            }
        }
        private void UpdateValues(ComputerObj comp)
        {
            this.Dispatcher.Invoke(() =>
            {
                Applications         = new ObservableCollection <ProcessEntry>(comp.ProcessList.Where(p => p.IsApplication == true));
                listView.ItemsSource = Applications;

                ProcessEntry selected = SelectedApplication;

                if (SelectedApplication != null)
                {
                    SelectedApplication = Applications.FirstOrDefault(p => p.Pid == selected.Pid);
                }

                listView.SelectedItem = SelectedApplication;
            });
        }
예제 #9
0
        public void UpdateList(ComputerObj comp)
        {
            this.Dispatcher.Invoke(() =>
            {
                ProcessEntry selectedListView = selectedProcessListView;
                ProcessEntry selectedComboBox = selectedProcessComboBox;

                procListListView = new ObservableCollection <ProcessEntry>(comp.ProcessList.OrderByDescending(p => p.Cpu)); // TEMPORARY - sorting to make it easier since most processes use 0%
                procListComboBox = new ObservableCollection <ProcessEntry>(comp.ProcessList.OrderByDescending(p => p.Cpu)); // TEMPORARY - sorting to make it easier since most processes use 0%
                //procListTreeView = new ObservableCollection<ProcessEntry>(comp.ProcessTree.OrderByDescending(p => p.Cpu));
                procListComboBox.Insert(0, system);

                selectedProcessListView = Find(selectedListView, procListListView);
                selectedProcessComboBox = Find(selectedComboBox, procListComboBox);

                UpdateColumnHeaders(comp);
                UpdateProcessTreeView();
            });
        }
예제 #10
0
        private Trend GetTrend(ComputerObj comp)
        {
            Trend    _trend = new Trend();
            Hardware hw     = new Hardware();

            try
            {
                if (ProcessPid > 0)
                {
                    _trend.Cpu     = comp.ProcessList.First(p => p.Pid == ProcessPid).Cpu;
                    _trend.Gpu     = comp.ProcessList.First(p => p.Pid == ProcessPid).Gpu;
                    _trend.Memory  = comp.ProcessList.First(p => p.Pid == ProcessPid).Memory;
                    _trend.Disk    = comp.ProcessList.First(p => p.Pid == ProcessPid).Disk;
                    _trend.Network = comp.ProcessList.First(p => p.Pid == ProcessPid).Network;
                    _trend.CpuTemp = hw.CpuTemp(comp);
                    _trend.GpuTemp = hw.GpuTemp(comp);
                }
                else
                {
                    _trend.Cpu     = comp.TotalCpu;
                    _trend.Gpu     = comp.TotalGpu;
                    _trend.Memory  = comp.TotalMemory;
                    _trend.Disk    = comp.TotalDisk;
                    _trend.Network = comp.TotalNetwork;
                    _trend.CpuTemp = hw.CpuTemp(comp);
                    _trend.GpuTemp = hw.GpuTemp(comp);
                }
            }
            catch (Exception) // Process was killed but still trying to graph.
            {
                _trend.Cpu     = 0;
                _trend.Gpu     = 0;
                _trend.GpuTemp = 0;
                _trend.Memory  = 0;
                _trend.Disk    = 0;
                _trend.Network = 0;
                _trend.CpuTemp = 0;
                _trend.GpuTemp = 0;
            }

            return(_trend);
        }
예제 #11
0
 public void UpdateValues(ComputerObj comp)
 {
     UpdateList(comp);
     return;
 }
예제 #12
0
 private void UpdateValues(ComputerObj comp)
 {
     Read(comp);
 }