Exemplo n.º 1
0
        public AMD19CPU(int processorIndex, CPUID[][] cpuid, ISettings settings, ISensorConfig config)
            : base(processorIndex, cpuid, settings, config)
        {
            this.sensorConfig = config;

            coreTemperature = new Sensor(
                "CPU Package", 0, SensorType.Temperature, this, new[] {
                new ParameterDescription("Offset [°C]", "Temperature offset.", 0)
            }, this.settings);

            tctlTemperature = new Sensor(
                "CPU Tctl", 1, true, SensorType.Temperature, this, new[] {
                new ParameterDescription("Offset [°C]", "Temperature offset.", 0)
            }, this.settings);

            ccdMaxTemperature = new Sensor(
                "CPU CCD Max", 2, SensorType.Temperature, this, this.settings);

            ccdAvgTemperature = new Sensor(
                "CPU CCD Average", 3, SensorType.Temperature, this, this.settings);

            ccdTemperatures = new Sensor[MAX_CCD_COUNT];
            for (int i = 0; i < ccdTemperatures.Length; i++)
            {
                ccdTemperatures[i] = new Sensor(
                    "CPU CCD #" + (i + 1), i + 4, SensorType.Temperature, this,
                    new[] {
                    new ParameterDescription("Offset [°C]", "Temperature offset.", 0)
                }, this.settings);
            }

            if (Ring0.Rdmsr(MSR_RAPL_PWR_UNIT, out uint eax, out _))
            {
                energyUnitMultiplier = 1.0f / (1 << (int)((eax >> 8) & 0x1F));
            }
Exemplo n.º 2
0
        public OverlayEntryProvider(ISensorService sensorService,
                                    IAppConfiguration appConfiguration,
                                    IEventAggregator eventAggregator,
                                    IOnlineMetricService onlineMetricService,
                                    ISystemInfo systemInfo,
                                    IRTSSService rTSSService,
                                    ISensorConfig sensorConfig,
                                    IOverlayEntryCore overlayEntryCore,
                                    ILogger <OverlayEntryProvider> logger)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            _sensorService       = sensorService;
            _appConfiguration    = appConfiguration;
            _eventAggregator     = eventAggregator;
            _onlineMetricService = onlineMetricService;
            _systemInfo          = systemInfo;
            _rTSSService         = rTSSService;
            _sensorConfig        = sensorConfig;
            _overlayEntryCore    = overlayEntryCore;
            _logger = logger;

            _ = Task.Run(async() => await LoadOrSetDefault())
                .ContinueWith(task => _taskCompletionSource.SetResult(true));

            SubscribeToOptionPopupClosed();

            _logger.LogDebug("{componentName} Ready", this.GetType().Name);

            stopwatch.Stop();
            _logger.LogInformation(this.GetType().Name + " {initializationTime}s initialization time",
                                   Math.Round(stopwatch.ElapsedMilliseconds * 1E-03, 1));
        }
Exemplo n.º 3
0
 public void addConfig(ISensorConfig config)
 {
     try
     {
         //if(!IsComposite &&( config.Height==default(double) || config.Orientation==default(double)))
         //{
         //    throw new ApplicationException ("Height or Orientation are missing");
         //}
         if (config.StartDate == default(DateTime) || config.EndDate == default(DateTime))
         {
             throw new ApplicationException("Start or End date of a config can not be null");
         }
         else
         {
             //make sure it does not overlap an exiosting config
             ISensorConfig startConfig = getConfigAtDate(config.StartDate);
             ISensorConfig endConfig   = getConfigAtDate(config.EndDate);
             if (startConfig != null || endConfig != null)
             {
                 _configs.Remove(startConfig);
                 _configs.Add(config);
             }
             else
             {
                 _configs.Add(config);
             }
         }
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
     }
 }
Exemplo n.º 4
0
#pragma warning disable CS3001 // Argumenttyp ist nicht CLS-kompatibel
        public Computer(ISensorConfig config, IRTSSService service)
#pragma warning restore CS3001 // Argumenttyp ist nicht CLS-kompatibel
        {
            this.settings = new Settings();
            sensorConfig  = config;
            rTSSService   = service;
        }
Exemplo n.º 5
0
        public SortedDictionary <double, ISessionColumn> GetColumnsByType(SessionColumnType coltype
                                                                          , DateTime date)
        {
            try
            {
                SortedDictionary <double, ISessionColumn> resultDictionary
                    = new SortedDictionary <double, ISessionColumn>();
                //find
                var result = from ISessionColumn s in _columns.AsEnumerable()
                             where s.ColumnType.Equals(coltype)
                             select s;
                foreach (var v in result)
                {
                    //get config at each date
                    ISensorConfig config = v.getConfigAtDate(date);

                    if (config != null && !resultDictionary.ContainsKey(config.Height))
                    {
                        resultDictionary.Add(config.Height, (ISessionColumn)v);
                    }
                }

                return(resultDictionary);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemplo n.º 6
0
        public RAMGroup(ISettings settings, ISensorConfig sensorConfig, IRTSSService rTSSService)
        {
            // No implementation for RAM on Unix systems
            int p = (int)Environment.OSVersion.Platform;

            if ((p == 4) || (p == 128))
            {
                hardware = new Hardware[0];
                return;
            }

            hardware = new Hardware[] { new GenericRAM("Generic Memory", settings, sensorConfig, rTSSService) };
        }
Exemplo n.º 7
0
 public CaptureManager(ICaptureService presentMonCaptureService,
                       ISensorService sensorService,
                       IOverlayService overlayService,
                       SoundManager soundManager,
                       IRecordManager recordManager,
                       ILogger <CaptureManager> logger,
                       IAppConfiguration appConfiguration,
                       IRTSSService rtssService,
                       ISensorConfig sensorConfig)
 {
     _presentMonCaptureService = presentMonCaptureService;
     _sensorService            = sensorService;
     _overlayService           = overlayService;
     _soundManager             = soundManager;
     _recordManager            = recordManager;
     _logger           = logger;
     _appConfiguration = appConfiguration;
     _rtssService      = rtssService;
     _sensorConfig     = sensorConfig;
     _presentMonCaptureService.IsCaptureModeActiveStream.OnNext(false);
 }
        public Dictionary <double, int> DerivedColumns(DateTime date)
        {
            //return dictionary of key height, value colindex
            Dictionary <double, int> resultDictionary
                = new Dictionary <double, int>();
            //find
            var result = from ISessionColumn s in _columns.AsEnumerable()
                         where s.ColumnType.Equals(SessionColumnType.WSAvgShear) && s.IsCalculated.Equals(true)
                         select s;

            foreach (var v in result)
            {
                //get config at each date
                ISensorConfig config = v.getConfigAtDate(date);

                if (config != null && !resultDictionary.ContainsKey(config.Height))
                {
                    resultDictionary.Add(config.Height, v.ColIndex);
                }
            }

            return(resultDictionary);
        }
Exemplo n.º 9
0
        public NvidiaGPU(int adapterIndex, NvPhysicalGpuHandle handle,
                         NvDisplayHandle?displayHandle, ISettings settings, ISensorConfig config, IRTSSService rTSSService)
            : base(GetName(handle), new Identifier("nvidiagpu",
                                                   adapterIndex.ToString(CultureInfo.InvariantCulture)), settings, rTSSService)
        {
            this.adapterIndex  = adapterIndex;
            this.handle        = handle;
            this.displayHandle = displayHandle;
            this.sensorConfig  = config;
            this.stopwatch     = new Stopwatch();

            NvGPUThermalSettings thermalSettings = GetThermalSettings();

            temperatures = new Sensor[thermalSettings.Count];
            for (int i = 0; i < temperatures.Length; i++)
            {
                NvSensor sensor = thermalSettings.Sensor[i];
                string   name;
                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;
                }
                temperatures[i] = new Sensor(name, i, SensorType.Temperature, this,
                                             new ParameterDescription[0], settings);
                ActivateSensor(temperatures[i]);
            }

            clocks    = new Sensor[3];
            clocks[0] = new Sensor("GPU Core", 0, SensorType.Clock, this, settings);
            clocks[1] = new Sensor("GPU Memory", 1, SensorType.Clock, this, settings);
            clocks[2] = new Sensor("GPU Shader", 2, SensorType.Clock, this, settings);

            for (int i = 0; i < clocks.Length; i++)
            {
                ActivateSensor(clocks[i]);
            }

            loads                       = new Sensor[4];
            loads[0]                    = new Sensor("GPU Core", 0, SensorType.Load, this, settings);
            loads[1]                    = new Sensor("GPU Frame Buffer", 1, SensorType.Load, this, settings);
            loads[2]                    = new Sensor("GPU Video Engine", 2, SensorType.Load, this, settings);
            loads[3]                    = new Sensor("GPU Bus Interface", 3, SensorType.Load, this, settings);
            memoryLoad                  = new Sensor("GPU Memory", 4, SensorType.Load, this, settings);
            memoryFree                  = new Sensor("GPU Memory Free", 1, SensorType.Data, this, settings);
            memoryUsed                  = new Sensor("GPU Memory Used", 2, SensorType.Data, this, settings);
            memoryAvail                 = new Sensor("GPU Memory Total", 3, SensorType.Data, this, settings);
            memoryUsageDedicated        = new Sensor("GPU Memory Dedicated", 4, SensorType.Data, this, settings);
            memoryUsageShared           = new Sensor("GPU Memory Shared", 5, SensorType.Data, this, settings);
            processMemoryUsageDedicated = new Sensor("GPU Memory Dedicated Game", 6, SensorType.Data, this, settings);
            processMemoryUsageShared    = new Sensor("GPU Memory Shared Game", 7, SensorType.Data, this, settings);

            fan     = new Sensor("GPU Fan", 0, SensorType.Fan, this, settings);
            control = new Sensor("GPU Fan", 1, SensorType.Control, this, settings);
            voltage = new Sensor("GPU Voltage", 0, SensorType.Voltage, this, settings);
            power   = new Sensor("GPU Power", 0, SensorType.Power, this, settings);

            NvGPUCoolerSettings coolerSettings = GetCoolerSettings();

            if (coolerSettings.Count > 0)
            {
                fanControl = new Control(control, settings,
                                         coolerSettings.Cooler[0].DefaultMin,
                                         coolerSettings.Cooler[0].DefaultMax);
                fanControl.ControlModeChanged          += ControlModeChanged;
                fanControl.SoftwareControlValueChanged += SoftwareControlValueChanged;
                ControlModeChanged(fanControl);
                control.Control = fanControl;
            }

            monitorRefreshRate = new Sensor("Monitor Refresh Rate", 0, SensorType.Frequency, this, settings);

            if (NVML.IsInitialized)
            {
                if (NVAPI.NvAPI_GPU_GetBusId != null &&
                    NVAPI.NvAPI_GPU_GetBusId(handle, out uint busId) == NvStatus.OK)
                {
                    if (NVML.NvmlDeviceGetHandleByPciBusId != null &&
                        NVML.NvmlDeviceGetHandleByPciBusId(
                            "0000:" + busId.ToString("X2") + ":00.0", out var result)
                        == NVML.NvmlReturn.Success)
                    {
                        device           = result;
                        pcieThroughputRx = new Sensor("GPU PCIE Rx", 0,
                                                      SensorType.Throughput, this, settings);
                        pcieThroughputTx = new Sensor("GPU PCIE Tx", 1,
                                                      SensorType.Throughput, this, settings);
                    }
                }
            }

            Update();
        }
Exemplo n.º 10
0
        public ATIGPU(string name, int adapterIndex, int busNumber,
                      int deviceNumber, IntPtr context, ISettings settings, ISensorConfig config, IRTSSService rTSSService)
            : base(name, new Identifier("atigpu",
                                        adapterIndex.ToString(CultureInfo.InvariantCulture)), settings, rTSSService)
        {
            this.adapterIndex = adapterIndex;
            this.busNumber    = busNumber;
            this.deviceNumber = deviceNumber;
            this.sensorConfig = config;

            this.context = context;

            if (ADL.ADL_Overdrive_Caps(adapterIndex, out _, out _,
                                       out overdriveVersion) != ADL.ADL_OK)
            {
                overdriveVersion = -1;
            }

            this.temperatureCore =
                new Sensor("GPU Core", 0, SensorType.Temperature, this, settings);
            this.temperatureMemory =
                new Sensor("GPU Memory", 1, SensorType.Temperature, this, settings);
            this.temperatureVrmCore =
                new Sensor("GPU VRM Core", 2, SensorType.Temperature, this, settings);
            this.temperatureVrmMemory =
                new Sensor("GPU VRM Memory", 3, SensorType.Temperature, this, settings);
            //this.temperatureVrmMemory0 =
            //  new Sensor("GPU VRM Memory #1", 4, SensorType.Temperature, this, settings);
            //this.temperatureVrmMemory1 =
            //  new Sensor("GPU VRM Memory #2", 5, SensorType.Temperature, this, settings);
            this.temperatureVrmSoc =
                new Sensor("GPU VRM SOC", 6, SensorType.Temperature, this, settings);
            this.temperatureLiquid =
                new Sensor("GPU Liquid", 7, SensorType.Temperature, this, settings);
            this.temperaturePlx =
                new Sensor("GPU PLX", 8, SensorType.Temperature, this, settings);
            this.temperatureHotSpot =
                new Sensor("GPU Hot Spot", 9, SensorType.Temperature, this, settings);

            this.powerTotal  = new Sensor("GPU Total", 0, SensorType.Power, this, settings);
            this.powerCore   = new Sensor("GPU Core", 1, SensorType.Power, this, settings);
            this.powerPpt    = new Sensor("GPU PPT", 2, SensorType.Power, this, settings);
            this.powerSocket = new Sensor("GPU Socket", 3, SensorType.Power, this, settings);
            this.powerSoc    = new Sensor("GPU SOC", 4, SensorType.Power, this, settings);

            this.fan = new Sensor("GPU Fan", 0, SensorType.Fan, this, settings);

            this.coreClock   = new Sensor("GPU Core", 0, SensorType.Clock, this, settings);
            this.memoryClock = new Sensor("GPU Memory", 1, SensorType.Clock, this, settings);
            this.socClock    = new Sensor("GPU SOC", 2, SensorType.Clock, this, settings);

            this.coreVoltage   = new Sensor("GPU Core", 0, SensorType.Voltage, this, settings);
            this.memoryVoltage = new Sensor("GPU Memory", 1, SensorType.Voltage, this, settings);
            this.socVoltage    = new Sensor("GPU SOC", 2, SensorType.Voltage, this, settings);

            this.coreLoad             = new Sensor("GPU Core", 0, SensorType.Load, this, settings);
            this.memoryControllerLoad = new Sensor("GPU Memory Controller", 1, SensorType.Load, this, settings);

            this.controlSensor = new Sensor("GPU Fan", 0, SensorType.Control, this, settings);

            this.memoryUsed                  = new Sensor("GPU Memory Used", 4, SensorType.Data, this, settings);
            this.memoryUsageDedicated        = new Sensor("GPU Memory Dedicated", 0, SensorType.Data, this, settings);
            this.memoryUsageShared           = new Sensor("GPU Memory Shared", 1, SensorType.Data, this, settings);
            this.processMemoryUsageDedicated = new Sensor("GPU Memory Dedicated Game", 2, SensorType.Data, this, settings);
            this.processMemoryUsageShared    = new Sensor("GPU Memory Shared Game", 3, SensorType.Data, this, settings);

            ADLFanSpeedInfo afsi = new ADLFanSpeedInfo();

            if (ADL.ADL_Overdrive5_FanSpeedInfo_Get(adapterIndex, 0, ref afsi)
                != ADL.ADL_OK)
            {
                afsi.MaxPercent = 100;
                afsi.MinPercent = 0;
            }

            this.fanControl = new Control(controlSensor, settings, afsi.MinPercent,
                                          afsi.MaxPercent);
            this.fanControl.ControlModeChanged          += ControlModeChanged;
            this.fanControl.SoftwareControlValueChanged +=
                SoftwareControlValueChanged;
            ControlModeChanged(fanControl);
            this.controlSensor.Control = fanControl;
            Update();
        }
Exemplo n.º 11
0
        public GenericRAM(string name, ISettings settings, ISensorConfig config, IRTSSService service)
            : base(name, new Identifier("ram"), settings)
        {
            sensorConfig = config;

            try
            {
                if (PerformanceCounterCategory.Exists("Process"))
                {
                    service
                    .ProcessIdStream
                    .DistinctUntilChanged()
                    .Subscribe(id =>
                    {
                        lock (_performanceCounterLock)
                        {
                            try
                            {
                                if (id == 0)
                                {
                                    ramUsageGamePerformanceCounter         = null;
                                    ramAndCacheUsageGamePerformanceCounter = null;
                                    return;
                                }

                                var process = Process.GetProcessById(id);
                                if (process != null)
                                {
                                    var validInstanceName = GetValidInstanceName(process);
                                    Log.Logger.Information("Valid instance name for memory performance counter: {instanceName}", validInstanceName);

                                    // Working Set - Private
                                    ramUsageGamePerformanceCounter = new PerformanceCounter("Process", "Working Set - Private", validInstanceName, true);
                                    // Working Set (private + resources)
                                    ramAndCacheUsageGamePerformanceCounter = new PerformanceCounter("Process", "Working Set", validInstanceName, true);
                                }
                                else
                                {
                                    Log.Logger.Error("Failed to get process by Id={Id}.", id);
                                    ramUsageGamePerformanceCounter         = null;
                                    ramAndCacheUsageGamePerformanceCounter = null;
                                }
                            }
                            catch
                            {
                                ramUsageGamePerformanceCounter         = null;
                                ramAndCacheUsageGamePerformanceCounter = null;
                                Log.Logger.Error("Failed to create performance counter Working Set or Working Set - Private");
                            }
                        }
                    });
                }
                else
                {
                    Log.Logger.Error("Failed to create memory performance counter. Category Process does not exist.");
                }
            }
            catch (Exception ex)
            {
                Log.Logger.Error(ex, "Failed to create memory performance counter.");
            }

            loadSensor = new Sensor("Memory", 0, SensorType.Load, this, settings);
            ActivateSensor(loadSensor);

            usedMemory = new Sensor("Used Memory", 0, SensorType.Data, this,
                                    settings);
            ActivateSensor(usedMemory);

            availableMemory = new Sensor("Available Memory", 1, SensorType.Data, this,
                                         settings);
            ActivateSensor(availableMemory);

            usedMemoryProcess = new Sensor("Used Memory Game", 2, SensorType.Data, this,
                                           settings);
            ActivateSensor(usedMemoryProcess);

            usedMemoryAndCacheProcess = new Sensor("Memory + Cache Game", 3, SensorType.Data, this,
                                                   settings);
            ActivateSensor(usedMemoryAndCacheProcess);
        }
Exemplo n.º 12
0
        public CPUGroup(ISettings settings, ISensorConfig sensorConfig)
        {
            Log.Logger.Information("Start creating CPU group.");

            CPUID[][] processorThreads = GetProcessorThreads();
            this.threads = new CPUID[processorThreads.Length][][];

            if (!processorThreads.Any() || processorThreads[0].Length == 0)
            {
                Log.Logger.Error("Error getting infos from core 0.");
            }
            else
            {
                Log.Logger.Information("CPUID vendor info: {vendor}.", processorThreads[0][0].Vendor.ToString());
                Log.Logger.Information("CPUID family code: {family}.", processorThreads[0][0].Family.ToString());
            }

            int index = 0;

            foreach (CPUID[] threads in processorThreads)
            {
                if (threads.Length == 0)
                {
                    continue;
                }

                CPUID[][] coreThreads = GroupThreadsByCore(threads);

                this.threads[index] = coreThreads;

                switch (threads[0].Vendor)
                {
                case Vendor.Intel:
                    hardware.Add(new IntelCPU(index, coreThreads, settings, sensorConfig));
                    break;

                case Vendor.AMD:
                    switch (threads[0].Family)
                    {
                    case 0x0F:
                        hardware.Add(new AMD0FCPU(index, coreThreads, settings, sensorConfig));
                        break;

                    case 0x10:
                    case 0x11:
                    case 0x12:
                    case 0x14:
                    case 0x15:
                    case 0x16:
                        hardware.Add(new AMD10CPU(index, coreThreads, settings, sensorConfig));
                        break;

                    case 0x17:
                        hardware.Add(new AMD17CPU(index, coreThreads, settings, sensorConfig));
                        break;

                    case 0x19:
                        hardware.Add(new AMD19CPU(index, coreThreads, settings, sensorConfig));
                        break;

                    default:
                        hardware.Add(new GenericCPU(index, coreThreads, settings, sensorConfig));
                        break;
                    }
                    break;

                default:
                    hardware.Add(new GenericCPU(index, coreThreads, settings, sensorConfig));
                    break;
                }

                index++;
            }
        }
Exemplo n.º 13
0
        public AMD0FCPU(int processorIndex, CPUID[][] cpuid, ISettings settings, ISensorConfig config)
            : base(processorIndex, cpuid, settings, config)
        {
            this.sensorConfig = config;

            float offset = -49.0f;

            // AM2+ 65nm +21 offset
            uint model = cpuid[0][0].Model;

            if (model >= 0x69 && model != 0xc1 && model != 0x6c && model != 0x7c)
            {
                offset += 21;
            }

            if (model < 40)
            {
                // AMD Athlon 64 Processors
                thermSenseCoreSelCPU0 = 0x0;
                thermSenseCoreSelCPU1 = 0x4;
            }
            else
            {
                // AMD NPT Family 0Fh Revision F, G have the core selection swapped
                thermSenseCoreSelCPU0 = 0x4;
                thermSenseCoreSelCPU1 = 0x0;
            }

            // check if processor supports a digital thermal sensor
            if (cpuid[0][0].ExtData.GetLength(0) > 7 &&
                (cpuid[0][0].ExtData[7, 3] & 1) != 0)
            {
                coreTemperatures = new Sensor[coreCount];
                for (int i = 0; i < coreCount; i++)
                {
                    coreTemperatures[i] =
                        new Sensor("Core #" + (i + 1), i, SensorType.Temperature,
                                   this, new[] { new ParameterDescription("Offset [°C]",
                                                                          "Temperature offset of the thermal sensor.\n" +
                                                                          "Temperature = Value + Offset.", offset) }, settings);
                }
            }
            else
            {
                coreTemperatures = new Sensor[0];
            }

            miscellaneousControlAddress = GetPciAddress(
                MISCELLANEOUS_CONTROL_FUNCTION, MISCELLANEOUS_CONTROL_DEVICE_ID);

            busClock   = new Sensor("Bus Speed", 0, SensorType.Clock, this, settings);
            coreClocks = new Sensor[coreCount];
            for (int i = 0; i < coreClocks.Length; i++)
            {
                coreClocks[i] = new Sensor(CoreString(i), i + 1, SensorType.Clock,
                                           this, settings);
                if (HasTimeStampCounter)
                {
                    ActivateSensor(coreClocks[i]);
                }
            }

            coreMaxClocks = new Sensor("CPU Max Clock", coreClocks.Length + 1, SensorType.Clock, this, settings);
            ActivateSensor(coreMaxClocks);

            Update();
        }
Exemplo n.º 14
0
        public ATIGroup(ISettings settings, ISensorConfig sensorConfig, IRTSSService rTSSService)
        {
            try
            {
                int adlStatus  = ADL.ADL_Main_Control_Create(1);
                int adl2Status = ADL.ADL2_Main_Control_Create(1, out context);

                report.AppendLine("AMD Display Library");
                report.AppendLine();
                report.Append("ADL Status: ");
                report.AppendLine(adlStatus == ADL.ADL_OK ? "OK" :
                                  adlStatus.ToString(CultureInfo.InvariantCulture));
                report.Append("ADL2 Status: ");
                report.AppendLine(adl2Status == ADL.ADL_OK ? "OK" :
                                  adl2Status.ToString(CultureInfo.InvariantCulture));
                report.AppendLine();

                if (adlStatus == ADL.ADL_OK)
                {
                    int numberOfAdapters = 0;
                    ADL.ADL_Adapter_NumberOfAdapters_Get(ref numberOfAdapters);

                    report.Append("Number of adapters: ");
                    report.AppendLine(numberOfAdapters.ToString(CultureInfo.InvariantCulture));
                    report.AppendLine();

                    if (numberOfAdapters > 0)
                    {
                        ADLAdapterInfo[] adapterInfo = new ADLAdapterInfo[numberOfAdapters];
                        if (ADL.ADL_Adapter_AdapterInfo_Get(adapterInfo) == ADL.ADL_OK)
                        {
                            for (int i = 0; i < numberOfAdapters; i++)
                            {
                                int isActive;
                                ADL.ADL_Adapter_Active_Get(adapterInfo[i].AdapterIndex,
                                                           out isActive);
                                int adapterID;
                                ADL.ADL_Adapter_ID_Get(adapterInfo[i].AdapterIndex,
                                                       out adapterID);

                                report.Append("AdapterIndex: ");
                                report.AppendLine(i.ToString(CultureInfo.InvariantCulture));
                                report.Append("isActive: ");
                                report.AppendLine(isActive.ToString(CultureInfo.InvariantCulture));
                                report.Append("AdapterName: ");
                                report.AppendLine(adapterInfo[i].AdapterName);
                                report.Append("UDID: ");
                                report.AppendLine(adapterInfo[i].UDID);
                                report.Append("Present: ");
                                report.AppendLine(adapterInfo[i].Present.ToString(
                                                      CultureInfo.InvariantCulture));
                                report.Append("VendorID: 0x");
                                report.AppendLine(adapterInfo[i].VendorID.ToString("X",
                                                                                   CultureInfo.InvariantCulture));
                                report.Append("BusNumber: ");
                                report.AppendLine(adapterInfo[i].BusNumber.ToString(
                                                      CultureInfo.InvariantCulture));
                                report.Append("DeviceNumber: ");
                                report.AppendLine(adapterInfo[i].DeviceNumber.ToString(
                                                      CultureInfo.InvariantCulture));
                                report.Append("FunctionNumber: ");
                                report.AppendLine(adapterInfo[i].FunctionNumber.ToString(
                                                      CultureInfo.InvariantCulture));
                                report.Append("AdapterID: 0x");
                                report.AppendLine(adapterID.ToString("X",
                                                                     CultureInfo.InvariantCulture));

                                if (!string.IsNullOrEmpty(adapterInfo[i].UDID) &&
                                    adapterInfo[i].VendorID == ADL.ATI_VENDOR_ID)
                                {
                                    bool found = false;
                                    foreach (ATIGPU gpu in hardware)
                                    {
                                        if (gpu.BusNumber == adapterInfo[i].BusNumber &&
                                            gpu.DeviceNumber == adapterInfo[i].DeviceNumber)
                                        {
                                            found = true;
                                            break;
                                        }
                                    }
                                    if (!found)
                                    {
                                        hardware.Add(new ATIGPU(
                                                         adapterInfo[i].AdapterName.Trim(),
                                                         adapterInfo[i].AdapterIndex,
                                                         adapterInfo[i].BusNumber,
                                                         adapterInfo[i].DeviceNumber,
                                                         context, settings,
                                                         sensorConfig,
                                                         rTSSService));
                                    }
                                }

                                report.AppendLine();
                            }
                        }
                    }
                }
            }
            catch (DllNotFoundException) { }
            catch (EntryPointNotFoundException e)
            {
                report.AppendLine();
                report.AppendLine(e.ToString());
                report.AppendLine();
            }
        }
Exemplo n.º 15
0
        public AMD10CPU(int processorIndex, CPUID[][] cpuid, ISettings settings, ISensorConfig config)
            : base(processorIndex, cpuid, settings, config)
        {
            this.sensorConfig = config;

            // AMD family 1Xh processors support only one temperature sensor
            coreTemperature = new Sensor(
                "Core" + (coreCount > 1 ? " #1 - #" + coreCount : ""), 0,
                SensorType.Temperature, this, new[] {
                new ParameterDescription("Offset [°C]", "Temperature offset.", 0)
            }, settings);

            switch (family)
            {
            case 0x10:
                miscellaneousControlDeviceId =
                    FAMILY_10H_MISCELLANEOUS_CONTROL_DEVICE_ID; break;

            case 0x11:
                miscellaneousControlDeviceId =
                    FAMILY_11H_MISCELLANEOUS_CONTROL_DEVICE_ID; break;

            case 0x12:
                miscellaneousControlDeviceId =
                    FAMILY_12H_MISCELLANEOUS_CONTROL_DEVICE_ID; break;

            case 0x14:
                miscellaneousControlDeviceId =
                    FAMILY_14H_MISCELLANEOUS_CONTROL_DEVICE_ID; break;

            case 0x15:
                switch (model & 0xF0)
                {
                case 0x00:
                    miscellaneousControlDeviceId =
                        FAMILY_15H_MODEL_00_MISC_CONTROL_DEVICE_ID; break;

                case 0x10:
                    miscellaneousControlDeviceId =
                        FAMILY_15H_MODEL_10_MISC_CONTROL_DEVICE_ID; break;

                case 0x30:
                    miscellaneousControlDeviceId =
                        FAMILY_15H_MODEL_30_MISC_CONTROL_DEVICE_ID; break;

                case 0x60:
                    miscellaneousControlDeviceId =
                        FAMILY_15H_MODEL_60_MISC_CONTROL_DEVICE_ID;
                    hasSmuTemperatureRegister = true;
                    break;

                case 0x70:
                    miscellaneousControlDeviceId =
                        FAMILY_15H_MODEL_70_MISC_CONTROL_DEVICE_ID;
                    hasSmuTemperatureRegister = true;
                    break;

                default: miscellaneousControlDeviceId = 0; break;
                }
                break;

            case 0x16:
                switch (model & 0xF0)
                {
                case 0x00:
                    miscellaneousControlDeviceId =
                        FAMILY_16H_MODEL_00_MISC_CONTROL_DEVICE_ID; break;

                case 0x30:
                    miscellaneousControlDeviceId =
                        FAMILY_16H_MODEL_30_MISC_CONTROL_DEVICE_ID; break;

                default: miscellaneousControlDeviceId = 0; break;
                }
                break;

            default: miscellaneousControlDeviceId = 0; break;
            }

            // get the pci address for the Miscellaneous Control registers
            miscellaneousControlAddress = GetPciAddress(
                MISCELLANEOUS_CONTROL_FUNCTION, miscellaneousControlDeviceId);

            busClock   = new Sensor("Bus Speed", 0, SensorType.Clock, this, settings);
            coreClocks = new Sensor[coreCount];
            for (int i = 0; i < coreClocks.Length; i++)
            {
                coreClocks[i] = new Sensor(CoreString(i), i + 1, SensorType.Clock,
                                           this, settings);
                if (HasTimeStampCounter)
                {
                    ActivateSensor(coreClocks[i]);
                }
            }

            coreMaxClocks = new Sensor("CPU Max Clock", coreClocks.Length + 1, SensorType.Clock, this, settings);
            ActivateSensor(coreMaxClocks);

            corePerformanceBoostSupport = (cpuid[0][0].ExtData[7, 3] & (1 << 9)) > 0;

            // set affinity to the first thread for all frequency estimations
            var previousAffinity = ThreadAffinity.Set(cpuid[0][0].Affinity);

            // disable core performance boost
            uint hwcrEax, hwcrEdx;

            Ring0.Rdmsr(HWCR, out hwcrEax, out hwcrEdx);
            if (corePerformanceBoostSupport)
            {
                Ring0.Wrmsr(HWCR, hwcrEax | (1 << 25), hwcrEdx);
            }

            uint ctlEax, ctlEdx;

            Ring0.Rdmsr(PERF_CTL_0, out ctlEax, out ctlEdx);
            uint ctrEax, ctrEdx;

            Ring0.Rdmsr(PERF_CTR_0, out ctrEax, out ctrEdx);

            timeStampCounterMultiplier = EstimateTimeStampCounterMultiplier();

            // restore the performance counter registers
            Ring0.Wrmsr(PERF_CTL_0, ctlEax, ctlEdx);
            Ring0.Wrmsr(PERF_CTR_0, ctrEax, ctrEdx);

            // restore core performance boost
            if (corePerformanceBoostSupport)
            {
                Ring0.Wrmsr(HWCR, hwcrEax, hwcrEdx);
            }

            // restore the thread affinity.
            ThreadAffinity.Set(previousAffinity);

            // the file reader for lm-sensors support on Linux
            temperatureStream = null;
            if (OperatingSystem.IsUnix)
            {
                string[] devicePaths = Directory.GetDirectories("/sys/class/hwmon/");
                foreach (string path in devicePaths)
                {
                    string name = null;
                    try
                    {
                        using (StreamReader reader = new StreamReader(path + "/device/name"))
                            name = reader.ReadLine();
                    }
                    catch (IOException) { }
                    switch (name)
                    {
                    case "k10temp":
                        temperatureStream = new FileStream(path + "/device/temp1_input",
                                                           FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                        break;
                    }
                }
            }

            Update();
        }
Exemplo n.º 16
0
        public GenericCPU(int processorIndex, CPUID[][] cpuid, ISettings settings, ISensorConfig config)
            : base(cpuid[0][0].Name, CreateIdentifier(cpuid[0][0].Vendor, processorIndex), settings)
        {
            this.sensorConfig = config;
            this.cpuid        = cpuid;

            this.vendor = cpuid[0][0].Vendor;

            this.family   = cpuid[0][0].Family;
            this.model    = cpuid[0][0].Model;
            this.stepping = cpuid[0][0].Stepping;

            Log.Logger.Information("CPUID core count: {coreCount}.", cpuid.Length);
            Log.Logger.Information("CPUID thread count per core: {coreThreadCount}.", cpuid[0].Length);

            this.processorIndex  = processorIndex;
            this.coreCount       = cpuid.Length;
            this.coreThreadCount = cpuid[0].Length;

            // check if processor has MSRs
            if (cpuid[0][0].Data.GetLength(0) > 1 &&
                (cpuid[0][0].Data[1, 3] & 0x20) != 0)
            {
                HasModelSpecificRegisters = true;
            }
            else
            {
                HasModelSpecificRegisters = false;
            }

            // check if processor has a TSC
            if (cpuid[0][0].Data.GetLength(0) > 1 &&
                (cpuid[0][0].Data[1, 3] & 0x10) != 0)
            {
                HasTimeStampCounter = true;
            }
            else
            {
                HasTimeStampCounter = false;
            }

            // check if processor supports an invariant TSC
            if (cpuid[0][0].ExtData.GetLength(0) > 7 &&
                (cpuid[0][0].ExtData[7, 3] & 0x100) != 0)
            {
                isInvariantTimeStampCounter = true;
            }
            else
            {
                isInvariantTimeStampCounter = false;
            }

            if (coreCount > 1 || coreThreadCount > 1)
            {
                totalLoad = new Sensor("CPU Total", 0, SensorType.Load, this, settings);
            }
            else
            {
                totalLoad = null;
            }
            coreLoads = new Sensor[coreCount * coreThreadCount];
            for (int i = 0; i < coreLoads.Length; i++)
            {
                coreLoads[i] = new Sensor(CoreThreadString(i), i + 1,
                                          SensorType.Load, this, settings);
            }
            maxLoad = new Sensor("CPU Max", coreLoads.Length + 1, SensorType.Load, this, settings);
            cpuLoad = new CPULoad(cpuid);

            if (cpuLoad.IsAvailable)
            {
                foreach (Sensor sensor in coreLoads)
                {
                    ActivateSensor(sensor);
                }
                if (totalLoad != null)
                {
                    ActivateSensor(totalLoad);
                }
                if (maxLoad != null)
                {
                    ActivateSensor(maxLoad);
                }
            }

            if (HasTimeStampCounter)
            {
                var previousAffinity = ThreadAffinity.Set(cpuid[0][0].Affinity);

                EstimateTimeStampCounterFrequency(
                    out estimatedTimeStampCounterFrequency,
                    out estimatedTimeStampCounterFrequencyError);

                ThreadAffinity.Set(previousAffinity);
            }
            else
            {
                estimatedTimeStampCounterFrequency = 0;
            }

            TimeStampCounterFrequency = estimatedTimeStampCounterFrequency;
        }
Exemplo n.º 17
0
 public SensorEntryProvider(ISensorService sensorService,
                            ISensorConfig sensorConfig)
 {
     _sensorService = sensorService;
     _sensorConfig  = sensorConfig;
 }
Exemplo n.º 18
0
        public NvidiaGroup(ISettings settings, ISensorConfig sensorConfig, IRTSSService rTSSService)
        {
            if (!NVAPI.IsAvailable)
            {
                return;
            }

            report.AppendLine("NVAPI");
            report.AppendLine();

            if (NVAPI.NvAPI_GetInterfaceVersionString(out string version) == NvStatus.OK)
            {
                report.Append(" Version: ");
                report.AppendLine(version);
            }

            NvPhysicalGpuHandle[] handles =
                new NvPhysicalGpuHandle[NVAPI.MAX_PHYSICAL_GPUS];
            int count;

            if (NVAPI.NvAPI_EnumPhysicalGPUs == null)
            {
                report.AppendLine(" Error: NvAPI_EnumPhysicalGPUs not available");
                report.AppendLine();
                return;
            }
            else
            {
                NvStatus status = NVAPI.NvAPI_EnumPhysicalGPUs(handles, out count);
                if (status != NvStatus.OK)
                {
                    report.AppendLine(" Status: " + status);
                    report.AppendLine();
                    return;
                }
            }

            var result = NVML.NvmlInit();

            report.AppendLine();
            report.AppendLine("NVML");
            report.AppendLine();
            report.AppendLine(" Status: " + result);
            report.AppendLine();

            IDictionary <NvPhysicalGpuHandle, NvDisplayHandle> displayHandles =
                new Dictionary <NvPhysicalGpuHandle, NvDisplayHandle>();

            if (NVAPI.NvAPI_EnumNvidiaDisplayHandle != null &&
                NVAPI.NvAPI_GetPhysicalGPUsFromDisplay != null)
            {
                NvStatus status = NvStatus.OK;
                int      i      = 0;
                while (status == NvStatus.OK)
                {
                    NvDisplayHandle displayHandle = new NvDisplayHandle();
                    status = NVAPI.NvAPI_EnumNvidiaDisplayHandle(i, ref displayHandle);
                    i++;

                    if (status == NvStatus.OK)
                    {
                        NvPhysicalGpuHandle[] handlesFromDisplay =
                            new NvPhysicalGpuHandle[NVAPI.MAX_PHYSICAL_GPUS];

                        if (NVAPI.NvAPI_GetPhysicalGPUsFromDisplay(displayHandle,
                                                                   handlesFromDisplay, out uint countFromDisplay) == NvStatus.OK)
                        {
                            for (int j = 0; j < countFromDisplay; j++)
                            {
                                if (!displayHandles.ContainsKey(handlesFromDisplay[j]))
                                {
                                    displayHandles.Add(handlesFromDisplay[j], displayHandle);
                                }
                            }
                        }
                    }
                }
            }

            report.Append("Number of GPUs: ");
            report.AppendLine(count.ToString(CultureInfo.InvariantCulture));

            for (int i = 0; i < count; i++)
            {
                displayHandles.TryGetValue(handles[i], out NvDisplayHandle displayHandle);
                hardware.Add(new NvidiaGPU(i, handles[i], displayHandle, settings, sensorConfig, rTSSService));
            }

            report.AppendLine();
        }
Exemplo n.º 19
0
        public List <IConfig> GetConfigs()
        {
            //determines configurations in column collection by evaluating changes in sensor HT
            //adds columns with the same ht in the date  of the config to a collection within each config
            //does not provide speicifc configs but guarentess that the columns provided have the hts returned at
            //the time of each config
            try
            {
                List <DateTime> Dates  = new List <DateTime>();
                List <IConfig>  result = new List <IConfig>();

                foreach (ISessionColumn col in _collection.Columns)
                {
                    foreach (ISensorConfig c in col.Configs)//create distinct ht and date listing
                    {
                        //Console.WriteLine(c.StartDate + " " + c.Height);
                        Dates.Add(c.StartDate);
                    }
                }
                List <DateTime> distinctDates = Dates.AsEnumerable().Distinct().ToList();
                distinctDates.Sort();

                //find different configs based on ht
                foreach (DateTime d in distinctDates)
                {
                    //create new config for the distinct date which is based on a differing  ht
                    HeightConfig thisConfig = new HeightConfig();

                    thisConfig.StartDate = d;

                    if (distinctDates.IndexOf(d) + 1 > distinctDates.Count - 1)
                    {
                        //end date is now if end of array
                        thisConfig.EndDate = DateTime.Now;
                    }
                    else
                    {
                        //end date is next date -1 second if not at end of array
                        thisConfig.EndDate = distinctDates[distinctDates.IndexOf(d) + 1].AddSeconds(-1);
                    }

                    //find all columns with this ht at this date

                    foreach (ISessionColumn col in _collection.Columns)
                    {
                        //don't process this column if it is a composite
                        if (col.IsComposite)
                        {
                            break;
                        }
                        ISensorConfig workConfig = col.getConfigAtDate(d);

                        if (workConfig != null)
                        {
                            //if ht is already in dictionary add the column to that hts list
                            if (!thisConfig.Columns.ContainsKey(workConfig.Height))
                            {
                                //Console.WriteLine(col.ColName + " is ws " + (col.ColumnType == SessionColumnType.WSAvg));
                                IList <ISessionColumn> newcols = new List <ISessionColumn>();
                                newcols.Add(col);
                                thisConfig.Columns.Add(workConfig.Height, newcols);
                            }
                            else
                            {
                                thisConfig.Columns[workConfig.Height].Add(col);
                            }
                        }
                    }

                    result.Add(thisConfig);
                }
                return(result);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemplo n.º 20
0
 public AMDCPU(int processorIndex, CPUID[][] cpuid, ISettings settings, ISensorConfig config)
     : base(processorIndex, cpuid, settings, config)
 {
 }