From cd79087cde23323bfabfd55226f6e398207366a7 Mon Sep 17 00:00:00 2001
From: muellerp <Philipp1.Mueller@Student.Reutlingen-University.de>
Date: Thu, 2 Jan 2025 16:36:30 +0100
Subject: [PATCH] add a dummy value to the distraction and total time to allow
starting in stage 4 instead of 1
---
.../Services/ProcessMonitor.cs | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Services/ProcessMonitor.cs b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Services/ProcessMonitor.cs
index 0d3b804..7312695 100644
--- a/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Services/ProcessMonitor.cs
+++ b/InnoLabProjektDektopApp/InnoLabProjektDektopApp/Services/ProcessMonitor.cs
@@ -58,10 +58,14 @@ namespace InnoLabProjektDektopApp.Services
public void CalculateCurrentDistractionStage(DateTime endTime)
{
+
TimeSpan totalDistractionTime = CalculateTotalDistractionTime();
Debug.WriteLine("Total distraction time: {0}", totalDistractionTime);
- double totalMinutes = (endTime - startTime).TotalMinutes;
- double distractedMinutes = totalDistractionTime.TotalMinutes;
+
+ // Adds a dummy value to the distractedMinutes and totalMinutes so the stage starts in the middle
+ double dummyTimeInMinutes = 8;
+ double totalMinutes = (endTime - startTime).TotalMinutes + 2 * dummyTimeInMinutes;
+ double distractedMinutes = totalDistractionTime.TotalMinutes + dummyTimeInMinutes;
double distractionFraction = (distractedMinutes / totalMinutes);
int stage = (int)Math.Ceiling(distractionFraction * 7);
Debug.WriteLine($"Distraction stage: {stage}");
@@ -71,10 +75,8 @@ namespace InnoLabProjektDektopApp.Services
{
var processName = Path.GetFileNameWithoutExtension((string)((ManagementBaseObject)e["TargetInstance"])["Name"]);
- if (processStartTimes.TryGetValue(processName, out _))
- {
- return;
- }
+ // Check if the process is already being tracked
+ if (processStartTimes.TryGetValue(processName, out _)) return;
processStartTimes[processName] = DateTime.Now;
--
GitLab