using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using ThreadPilot.Models;
namespace ThreadPilot.Services
{
///
/// Main orchestration service for process monitoring and power plan management
///
public interface IProcessMonitorManagerService : IDisposable
{
///
/// Event fired when a process-triggered power plan change occurs
///
event EventHandler? ProcessPowerPlanChanged;
///
/// Event fired when the service status changes
///
event EventHandler? ServiceStatusChanged;
///
/// Gets whether the service is currently running
///
bool IsRunning { get; }
///
/// Gets the current service status
///
string Status { get; }
///
/// Gets currently running associated processes
///
IEnumerable RunningAssociatedProcesses { get; }
///
/// Starts the process monitoring and power plan management service
///
Task StartAsync();
///
/// Stops the service
///
Task StopAsync();
///
/// Manually triggers a power plan evaluation for all running processes
///
Task EvaluateCurrentProcessesAsync();
///
/// Forces a return to the default power plan
///
Task ForceDefaultPowerPlanAsync();
///
/// Gets the current active power plan information
///
Task GetCurrentActivePowerPlanAsync();
///
/// Refreshes the configuration from the association service
///
Task RefreshConfigurationAsync();
///
/// Updates the service settings (polling intervals, etc.)
///
void UpdateSettings();
}
///
/// Event arguments for process-triggered power plan changes
///
public class ProcessPowerPlanChangeEventArgs : EventArgs
{
public ProcessModel Process { get; }
public ProcessPowerPlanAssociation Association { get; }
public PowerPlanModel? PreviousPowerPlan { get; }
public PowerPlanModel? NewPowerPlan { get; }
public string Action { get; } // "ProcessStarted", "ProcessStopped", "DefaultRestored"
public DateTime Timestamp { get; }
public ProcessPowerPlanChangeEventArgs(
ProcessModel process,
ProcessPowerPlanAssociation association,
PowerPlanModel? previousPowerPlan,
PowerPlanModel? newPowerPlan,
string action)
{
Process = process;
Association = association;
PreviousPowerPlan = previousPowerPlan;
NewPowerPlan = newPowerPlan;
Action = action;
Timestamp = DateTime.Now;
}
}
///
/// Event arguments for service status changes
///
public class ServiceStatusEventArgs : EventArgs
{
public bool IsRunning { get; }
public string Status { get; }
public string? Details { get; }
public Exception? Error { get; }
public DateTime Timestamp { get; }
public ServiceStatusEventArgs(bool isRunning, string status, string? details = null, Exception? error = null)
{
IsRunning = isRunning;
Status = status;
Details = details;
Error = error;
Timestamp = DateTime.Now;
}
}
}