Skip to content

Commit

Permalink
fixed fps screen not working
Browse files Browse the repository at this point in the history
  • Loading branch information
hedihadi committed Apr 7, 2024
1 parent c25d98b commit 747017d
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 49 deletions.
104 changes: 58 additions & 46 deletions zal_program/Zal/Backend/HelperFunctions/FpsDataGetter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,69 +96,81 @@ private async Task parseIncomingPresentmonData()

while (!reader.EndOfStream)
{
if (isDisposed) break;
//Thread.Sleep(30);
string line = reader.ReadLine();
if (shouldLog) Logger.Log($"fpsData:{line}");
var msBetweenPresents = "";
try
{
msBetweenPresents = line.Split(',')[9];
}
catch
{
Logger.Log("skipped line, msBetweenPresents failed");
continue;
}
if (isDisposed)
{
Logger.Log("presentmon disposed, stopping fps");
break;
}
//Thread.Sleep(30);
string line = reader.ReadLine();
if (shouldLog) Logger.Log($"fpsData:{line}");
var msBetweenPresents = "";
try
{
msBetweenPresents = line.Split(',')[9];
}
catch
{
Logger.Log("skipped line, msBetweenPresents failed");
continue;
}

uint? processId = null;
String? processName = line.Split(',')[0];
try
{
processId = uint.Parse(line.Split(',')[1]);
}
catch
{
Logger.Log("skipped line, processId failed");
}
if (processName == "<error>")
{
Logger.Log("skipped line, error line");
continue;
}
uint? processId = null;
String? processName = line.Split(',')[0];
try
{
processId = uint.Parse(line.Split(',')[1]);
}
catch
{
Logger.Log("skipped line, processId failed");
}
if (processName == "<error>")
{
Logger.Log("skipped line, error line");
continue;
}

if (processId != null)
{
var time = getTimestamp();
if (msBetweenPresents.Any(char.IsDigit))
if (processId != null)
{
var doubledMsBetweenPresents = double.Parse(msBetweenPresents);
fpsDatas.Add((1000 / doubledMsBetweenPresents));
var time = getTimestamp();
if (msBetweenPresents.Any(char.IsDigit))
{
var doubledMsBetweenPresents = double.Parse(msBetweenPresents, System.Globalization.NumberStyles.AllowDecimalPoint, System.Globalization.NumberFormatInfo.InvariantInfo);
fpsDatas.Add((1000 / doubledMsBetweenPresents));


if (fpsDatas.Count > 10)
{
try
{
sendFpsData.Invoke(null, fpsDatas);
}
catch (Exception exc)
if (fpsDatas.Count > 10)
{
Logger.LogError("error sending fps data", exc);
try
{
sendFpsData.Invoke(null, fpsDatas);
}
catch (Exception exc)
{
Logger.LogError("error sending fps data", exc);
}
fpsDatas.Clear();
}
fpsDatas.Clear();
continue;
}
else
{
Logger.Log("msBetweenPresents not digits");
}
continue;
}
else
{
Logger.Log("msBetweenPresents not digits");
Logger.Log("processId is null");
}
}
else
catch (Exception exc)
{
Logger.Log("processId is null");
Logger.LogError("error during fps", exc);
}

}

}
Expand Down
6 changes: 3 additions & 3 deletions zal_program/Zal/Zal.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
<TargetFramework>net7.0-windows10.0.17763.0</TargetFramework>
<UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
<FileVersion>1.7.5</FileVersion>
<FileVersion>1.7.6</FileVersion>
<ApplicationIcon>white.ico</ApplicationIcon>
<LangVersion>preview</LangVersion>
<SignAssembly>False</SignAssembly>
<PlatformTarget>AnyCPU</PlatformTarget>
<Version>1.7.5</Version>
<AssemblyVersion>1.7.5</AssemblyVersion>
<Version>1.7.6</Version>
<AssemblyVersion>1.7.6</AssemblyVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<WarningLevel>9999</WarningLevel>
Expand Down

0 comments on commit 747017d

Please sign in to comment.