Esempio n. 1
0
        static void Main(string[] args)
        {
            //enforces a nice cleanup
            //just hitting X or Ctrl+C normally won't actually dispose the using() below
            ExitHandler.Init(ctrlType => {
                Console.WriteLine("\nCleaning up and exiting...");
                return(true); //cancel event
            });

            ///////////////////////////////////////////////////////////////////

            Console.WriteLine("Current OSD entries:");
            var osdEntries = OSD.GetOSDEntries();

            foreach (var osd in osdEntries)
            {
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine(osd.Owner);
                Console.ResetColor();
                Console.WriteLine("{0}\n", osd.Text);
            }

            ///////////////////////////////////////////////////////////////////

            Console.WriteLine("Current app entries with GPU contexts:");
            var appEntries = OSD.GetAppEntries().Where(x => (x.Flags & AppFlags.MASK) != AppFlags.None).ToArray();

            foreach (var app in appEntries)
            {
                Console.ForegroundColor = ConsoleColor.Magenta;
                Console.WriteLine("{0}:{1}", app.ProcessId, app.Name);
                Console.ResetColor();
                Console.WriteLine("{0}, {1}FPS", app.Flags, app.InstantaneousFrames);
            }
            Console.WriteLine();

            ///////////////////////////////////////////////////////////////////

            using (var osd = new OSD("RTSSDemo"))
                while (true)
                {
                    Console.WriteLine("Enter some text:");
                    var text = Console.ReadLine();

                    //if we hit Ctrl+C while waiting for ReadLine, it returns null
                    if (text == null)
                    {
                        break;
                    }

                    osd.Update(text);
                }
        }
Esempio n. 2
0
        //Monitoring Function
        private void Status()
        {
            foreach (var hardware in c.Hardware)
            {
                //TEST GPU
                if (hardware.HardwareType == HardwareType.GpuNvidia)
                {
                    hardware.Update();
                    foreach (var sensor in hardware.Sensors)
                    {
                        if (sensor.SensorType == SensorType.Temperature && sensor.Name.Contains("GPU Core"))
                        {
                            value2 = sensor.Value.GetValueOrDefault();
                        }
                        if (sensor.SensorType == SensorType.Clock && sensor.Name.Contains("GPU Core"))
                        {
                            value3 = Math.Round(sensor.Value.GetValueOrDefault(), 0);
                        }
                        if (sensor.SensorType == SensorType.Clock && sensor.Name.Contains("GPU Memory"))
                        {
                            value5 = Math.Round(sensor.Value.GetValueOrDefault(), 0);
                        }
                        if (sensor.SensorType == SensorType.Load && sensor.Name.Contains("GPU Core"))
                        {
                            value6 = sensor.Value.GetValueOrDefault();
                        }
                        if (sensor.SensorType == SensorType.SmallData && sensor.Name.Contains("GPU Memory Total"))
                        {
                            value7 = sensor.Value.GetValueOrDefault();
                        }
                        if (sensor.SensorType == SensorType.SmallData && sensor.Name.Contains("GPU Memory Used"))
                        {
                            value8 = sensor.Value.GetValueOrDefault();
                        }
                    }
                }

                //TEST CPU
                if (hardware.HardwareType == HardwareType.Cpu)
                {
                    hardware.Update();
                    foreach (var sensor in hardware.Sensors)
                    {
                        for (int i = 0; i < 16; i++)
                        {
                            if (sensor.SensorType == SensorType.Load && sensor.Name.Equals("CPU Core #" + (i + 1)))
                            {
                                cpuloadvalue[i] = (int)Math.Round(sensor.Value.GetValueOrDefault(), 0);
                            }
                            if (sensor.SensorType == SensorType.Clock && sensor.Name.Equals("Core #" + (i + 1)))
                            {
                                cpumhzvalue[i] = (int)Math.Round(sensor.Value.GetValueOrDefault(), 0);
                            }
                        }
                        if (sensor.SensorType == SensorType.Temperature && sensor.Name.Contains("Core (Tctl/Tdie)"))
                        {
                            value1 = Math.Round(sensor.Value.GetValueOrDefault(), 0);
                        }
                        if (sensor.SensorType == SensorType.Load && sensor.Name.Contains("CPU Total"))
                        {
                            value4 = Math.Round(sensor.Value.GetValueOrDefault(), 0);
                        }
                    }
                }

                //Average Ghz Core
                double mhzSum = cpumhzvalue.Average() / 1000;
                double ghzAvg = Math.Round(mhzSum, 1);

                //VRAM Usage %
                int vramPercentage = (int)(value8 * 100 / value7);

                //RivaTuner Shared Memory Inizialization
                var appEntries = OSD.GetAppEntries().Where(x => (x.Flags & AppFlags.MASK) != AppFlags.None).ToArray();

                fps1 = 0;

                foreach (var app in appEntries)
                {
                    if (app.InstantaneousFrames != 0)
                    {
                        fps1 = checked ((int)app.InstantaneousFrames);
                    }
                }
                try
                {
                    port.Write(cpuloadvalue[0] + "a" + cpuloadvalue[1] + "b" + cpuloadvalue[2] + "c" + cpuloadvalue[3] + "d" + cpuloadvalue[4] + "e" + cpuloadvalue[5] + "f" + cpuloadvalue[6] + "g" + cpuloadvalue[7] + "h" + cpuloadvalue[8] + "k" + cpuloadvalue[9] + "j" + cpuloadvalue[10] + "l" + cpuloadvalue[11] + "m" + cpuloadvalue[12] + "n" + cpuloadvalue[13] + "o" + cpuloadvalue[14] + "p" + cpuloadvalue[15] + "q" + fps1 + "r" + value1 + "s" + value2 + "t" + value4 + "u" + ghzAvg.ToString() + "v" + value3 + "w" + value5 + "x" + value6 + "y" + vramPercentage + "z");
                }
                catch (Exception ex)
                {
                    timer1.Stop();
                    MessageBox.Show(ex.Message);
                }
            }
        }