/// <summary> /// Event excuted with the timer. /// </summary> /// <param name="source"></param> /// <param name="e"></param> private async void OnTimedEvent(Object source, ElapsedEventArgs e) { int fpsValue = 0; int cpuValue = GetCpuPercentage(); int gpuValue = 0; int ramValue = GetRamPercentage(); int gpuTValue = 0; int cpuTValue = 0; if (settings.UseMsiAfterburner) { var MSIAfterburner = new MSIAfterburnerNET.HM.HardwareMonitor(); fpsValue = (int)MSIAfterburner.GetEntry(MONITORING_SOURCE_ID.FRAMERATE).Data; gpuValue = (int)MSIAfterburner.GetEntry(MONITORING_SOURCE_ID.GPU_USAGE).Data; gpuTValue = (int)MSIAfterburner.GetEntry(MONITORING_SOURCE_ID.GPU_TEMPERATURE).Data; cpuTValue = (int)MSIAfterburner.GetEntry(MONITORING_SOURCE_ID.CPU_TEMPERATURE).Data; } else if (settings.UseHWiNFO) { HWiNFODumper HWinFO = new HWiNFODumper(); List <HWiNFODumper.JsonObj> dataHWinfo = HWinFO.ReadMem(); foreach (var sensorItems in dataHWinfo) { JObject sensorItemsOBJ = JObject.Parse(JsonConvert.SerializeObject(sensorItems)); string sensorsID = "0x" + ((uint)sensorItemsOBJ["szSensorSensorID"]).ToString("X"); // Find sensors fps if (sensorsID.ToLower() == settings.HWiNFO_fps_sensorsID.ToLower()) { // Find data fps foreach (var items in sensorItemsOBJ["sensors"]) { JObject itemOBJ = JObject.Parse(JsonConvert.SerializeObject(items)); string dataID = "0x" + ((uint)itemOBJ["dwSensorID"]).ToString("X"); //logger.Info("----- " + dataID.ToLower() + " - " + settings.HWiNFO_fps_elementID.ToLower()); if (dataID.ToLower() == settings.HWiNFO_fps_elementID.ToLower()) { fpsValue = (int)Math.Round((Double)itemOBJ["Value"]); } } } // Find sensors gpu usage if (sensorsID.ToLower() == settings.HWiNFO_gpu_sensorsID.ToLower()) { // Find data gpu foreach (var items in sensorItemsOBJ["sensors"]) { JObject itemOBJ = JObject.Parse(JsonConvert.SerializeObject(items)); string dataID = "0x" + ((uint)itemOBJ["dwSensorID"]).ToString("X"); //logger.Info("----- " + dataID.ToLower() + " - " + settings.HWiNFO_gpu_elementID.ToLower()); if (dataID.ToLower() == settings.HWiNFO_gpu_elementID.ToLower()) { gpuValue = (int)Math.Round((Double)itemOBJ["Value"]); } } } // Find sensors gpu temp if (sensorsID.ToLower() == settings.HWiNFO_gpuT_sensorsID.ToLower()) { // Find data gpu foreach (var items in sensorItemsOBJ["sensors"]) { JObject itemOBJ = JObject.Parse(JsonConvert.SerializeObject(items)); string dataID = "0x" + ((uint)itemOBJ["dwSensorID"]).ToString("X"); //logger.Info("----- " + dataID.ToLower() + " - " + settings.HWiNFO_gpu_elementID.ToLower()); if (dataID.ToLower() == settings.HWiNFO_gpuT_elementID.ToLower()) { gpuTValue = (int)Math.Round((Double)itemOBJ["Value"]); } } } // Find sensors cpu temp if (sensorsID.ToLower() == settings.HWiNFO_cpuT_sensorsID.ToLower()) { // Find data gpu foreach (var items in sensorItemsOBJ["sensors"]) { JObject itemOBJ = JObject.Parse(JsonConvert.SerializeObject(items)); string dataID = "0x" + ((uint)itemOBJ["dwSensorID"]).ToString("X"); //logger.Info("----- " + dataID.ToLower() + " - " + settings.HWiNFO_gpu_elementID.ToLower()); if (dataID.ToLower() == settings.HWiNFO_cpuT_elementID.ToLower()) { cpuTValue = (int)Math.Round((Double)itemOBJ["Value"]); } } } } } // Listing warnings bool WarningMinFps = false; bool WarningMaxCpuTemp = false; bool WarningMaxGpuTemp = false; bool WarningMaxCpuUsage = false; bool WarningMaxGpuUsage = false; bool WarningMaxRamUsage = false; if (settings.EnableWarning) { if (settings.MinFps != 0 && settings.MinFps >= fpsValue) { WarningMinFps = true; } if (settings.MaxCpuTemp != 0 && settings.MaxCpuTemp <= cpuTValue) { WarningMaxCpuTemp = true; } if (settings.MaxGpuTemp != 0 && settings.MaxGpuTemp <= gpuTValue) { WarningMaxGpuTemp = true; } if (settings.MaxCpuUsage != 0 && settings.MaxCpuUsage <= cpuValue) { WarningMaxCpuUsage = true; } if (settings.MaxGpuUsage != 0 && settings.MaxGpuUsage <= gpuValue) { WarningMaxGpuUsage = true; } if (settings.MaxRamUsage != 0 && settings.MaxRamUsage <= ramValue) { WarningMaxRamUsage = true; } JArray Message = new JArray { new JObject(new JProperty("At", resources.GetString("LOCGameActivityWarningAt") + " " + DateTime.Now.ToString("HH:mm"))), new JObject(new JProperty("Name", resources.GetString("LOCGameActivityFps")), new JProperty("Value", fpsValue), new JProperty("isWarm", WarningMinFps)), new JObject(new JProperty("Name", resources.GetString("LOCGameActivityCpuTemp")), new JProperty("Value", cpuTValue), new JProperty("isWarm", WarningMaxCpuTemp)), new JObject(new JProperty("Name", resources.GetString("LOCGameActivityGpuTemp")), new JProperty("Value", gpuTValue), new JProperty("isWarm", WarningMaxGpuTemp)), new JObject(new JProperty("Name", resources.GetString("LOCGameActivityCpuUsage")), new JProperty("Value", cpuValue), new JProperty("isWarm", WarningMaxCpuUsage)), new JObject(new JProperty("Name", resources.GetString("LOCGameActivityGpuUsage")), new JProperty("Value", gpuValue), new JProperty("isWarm", WarningMaxGpuUsage)), new JObject(new JProperty("Name", resources.GetString("LOCGameActivityRamUsage")), new JProperty("Value", ramValue), new JProperty("isWarm", WarningMaxRamUsage)) }; if (WarningMinFps || WarningMaxCpuTemp || WarningMaxGpuTemp || WarningMaxCpuUsage || WarningMaxGpuUsage) { WarningsMessage.Add(Message); } } JObject Data = new JObject(); Data["datelog"] = DateTime.Now.ToUniversalTime().ToString("o"); Data["fps"] = fpsValue; Data["cpu"] = cpuValue; Data["gpu"] = gpuValue; Data["ram"] = ramValue; Data["gpuT"] = gpuTValue; Data["cpuT"] = cpuTValue; LoggingData.Add(Data); }