SoraV2Utils/SoraV2Utils_Service/SoraV2UtilsService.cs
krjan02 26cde137c9
Some checks failed
Build and Relase / build-release (push) Failing after 38s
Build and Relase / create-release (push) Failing after 10s
Initial commit (1.0.0)
2025-01-13 16:27:29 +01:00

65 lines
1.8 KiB
C#

using EasyPipes;
using IniParser.Model;
using SoraV2Tools;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
namespace SoraV2Utils_Service
{
public partial class SoraV2UtilsService : ServiceBase
{
Timer timer = new Timer();
DeviceTracker deviceTracker = new DeviceTracker();
public SoraV2UtilsService()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
ServiceLogger.Instance.Log("Started SoraV2Utils_Service");
Notification.SingleLine("SoraV2 Utils running...");
timer.Elapsed += new ElapsedEventHandler(OnElapsedTime);
timer.Interval = ServiceSettings.Instance.intervall;
timer.Enabled = true;
OnElapsedTime(null, null);
}
protected override void OnStop()
{
ServiceLogger.Instance.Log("Stopped SoraV2Utils_Service");
Notification.SingleLine("SoraV2 Utils stopped...");
}
private void OnElapsedTime(object source, ElapsedEventArgs e)
{
var ds = SoraV2Interface.GetDeviceStatus();
//byte charging = 0;
//byte battery = 0;
//new ServiceSettings().TryParseConfig<byte>("debug", "charging", ref charging);
//new ServiceSettings().TryParseConfig<byte>("debug", "battery", ref battery);
//ds.Charging = charging;
//ds.Battery = battery;
deviceTracker.processMouseData(ds);
}
public void OnDebug()
{
OnStart(null);
}
}
}