Skip to content

Commit

Permalink
Preparing Backgroundog
Browse files Browse the repository at this point in the history
  • Loading branch information
Taiizor committed Sep 25, 2023
1 parent 7db5da5 commit 3955d5c
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 34 deletions.
10 changes: 5 additions & 5 deletions src/Project/Sucrose.Backgroundog/Extension/AudioSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,17 @@ private static void SetCurrentSession()
SBMI.AudioData.AlbumTrackCount = MediaDetails.AlbumTrackCount;
SBMI.AudioData.MediaType = MediaPlaybackDataSource.MediaSchemaToMediaPlaybackMode(MediaDetails.MediaClassPrimaryID);

SBMI.AudioData.PID = SBMI.PlayingSession?.PID;
SBMI.AudioData.Hwnd = SBMI.PlayingSession?.Hwnd;
//SBMI.AudioData.PID = SBMI.PlayingSession?.PID;
//SBMI.AudioData.Hwnd = SBMI.PlayingSession?.Hwnd;
SBMI.AudioData.SourceAppId = SBMI.PlayingSession?.SourceAppId;
SBMI.AudioData.SourceDeviceId = SBMI.PlayingSession?.SourceDeviceId;
SBMI.AudioData.RenderDeviceId = SBMI.PlayingSession?.RenderDeviceId;
//SBMI.AudioData.SourceDeviceId = SBMI.PlayingSession?.SourceDeviceId;
//SBMI.AudioData.RenderDeviceId = SBMI.PlayingSession?.RenderDeviceId;

SBMI.AudioData.RepeatMode = MediaPlaybackInfo.RepeatMode;
SBMI.AudioData.PropsValid = MediaPlaybackInfo.PropsValid;
SBMI.AudioData.PlaybackRate = MediaPlaybackInfo.PlaybackRate;
SBMI.AudioData.PlaybackMode = MediaPlaybackInfo.PlaybackMode;
SBMI.AudioData.PlaybackCaps = MediaPlaybackInfo.PlaybackCaps;
//SBMI.AudioData.PlaybackCaps = MediaPlaybackInfo.PlaybackCaps;
SBMI.AudioData.PlaybackState = MediaPlaybackInfo.PlaybackState;
SBMI.AudioData.ShuffleEnabled = MediaPlaybackInfo.ShuffleEnabled;
SBMI.AudioData.LastPlayingFileTime = MediaPlaybackInfo.LastPlayingFileTime;
Expand Down
11 changes: 6 additions & 5 deletions src/Project/Sucrose.Backgroundog/Extension/Data.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ public static JObject GetAudioInfo()
{
return new JObject
{
{ "PID", SBMI.AudioData.PID },
//{ "PID", SBMI.AudioData.PID },
{ "State", SBMI.AudioData.State },
{ "Title", SBMI.AudioData.Title },
{ "Artist", SBMI.AudioData.Artist },
{ "Hwnd", $"{SBMI.AudioData.Hwnd}" },
//{ "Hwnd", $"{SBMI.AudioData.Hwnd}" },
{ "Subtitle", SBMI.AudioData.Subtitle },
{ "AlbumTitle", SBMI.AudioData.AlbumTitle },
{ "TrackNumber", SBMI.AudioData.TrackNumber },
Expand All @@ -69,10 +69,10 @@ public static JObject GetAudioInfo()
{ "PlaybackRate", SBMI.AudioData.PlaybackRate },
{ "PropsValid", $"{SBMI.AudioData.PropsValid}" },
{ "RepeatMode", $"{SBMI.AudioData.RepeatMode}" },
{ "SourceDeviceId", SBMI.AudioData.SourceDeviceId },
{ "RenderDeviceId", SBMI.AudioData.RenderDeviceId },
//{ "SourceDeviceId", SBMI.AudioData.SourceDeviceId },
//{ "RenderDeviceId", SBMI.AudioData.RenderDeviceId },
{ "ShuffleEnabled", SBMI.AudioData.ShuffleEnabled },
{ "PlaybackCaps", $"{SBMI.AudioData.PlaybackCaps}" },
//{ "PlaybackCaps", $"{SBMI.AudioData.PlaybackCaps}" },
{ "PlaybackMode", $"{SBMI.AudioData.PlaybackMode}" },
{ "ThumbnailString", SBMI.AudioData.ThumbnailString },
{ "AlbumTrackCount", SBMI.AudioData.AlbumTrackCount },
Expand Down Expand Up @@ -139,6 +139,7 @@ public static JObject GetGraphicInfo()
return new JObject
{
{ "Amd", SBMI.GraphicData.Amd },
{ "State", SBMI.GraphicData.State },
{ "Intel", SBMI.GraphicData.Intel },
{ "Nvidia", SBMI.GraphicData.Nvidia }
};
Expand Down
41 changes: 29 additions & 12 deletions src/Project/Sucrose.Backgroundog/Helper/Specification.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
using LibreHardwareMonitor.Hardware;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Skylark.Enum;
using Skylark.Helper;
using Skylark.Standard.Extension.Ping;
using Skylark.Standard.Extension.Storage;
using System.Management;
using System.Text;
using SBEAS = Sucrose.Backgroundog.Extension.AudioSession;
using SBER = Sucrose.Backgroundog.Extension.Remote;
using SBEUV = Sucrose.Backgroundog.Extension.UpdateVisitor;
using SBMI = Sucrose.Backgroundog.Manage.Internal;
using SBSSSS = Sucrose.Backgroundog.Struct.Sensor.SensorStruct;
using SECNT = Skylark.Enum.ClearNumericType;
using SEMST = Skylark.Enum.ModeStorageType;
using SEST = Skylark.Enum.StorageType;
using SHN = Skylark.Helper.Numeric;
using SMC = Sucrose.Memory.Constant;
using SMMI = Sucrose.Manager.Manage.Internal;
using SMMM = Sucrose.Manager.Manage.Manager;
using SSDSHS = Sucrose.Shared.Dependency.Struct.HostStruct;
using SSEPPE = Skylark.Standard.Extension.Ping.PingExtension;
using SSESSE = Skylark.Standard.Extension.Storage.StorageExtension;
using SSMMS = Skylark.Struct.Monitor.MonitorStruct;
using SSSHG = Sucrose.Shared.Space.Helper.Graphic;
using SSSHN = Sucrose.Shared.Space.Helper.Network;
Expand Down Expand Up @@ -169,7 +172,7 @@ public static async Task Start()
{
if (SMMM.PingType == Host.Name)
{
SBMI.NetworkData.PingData = PingExtension.Send(Host.Address, 1000);
SBMI.NetworkData.PingData = SSEPPE.Send(Host.Address, 1000);

SBMI.NetworkData.Host = Host.Address;
SBMI.NetworkData.Ping = SBMI.NetworkData.PingData.RoundTrip;
Expand Down Expand Up @@ -231,11 +234,11 @@ public static async Task Start()
SBMI.NetworkData.Upload = SBMI.UploadCounter.NextValue();
SBMI.NetworkData.Download = SBMI.DownloadCounter.NextValue();

SBMI.NetworkData.UploadData = StorageExtension.AutoConvert(SBMI.NetworkData.Upload, StorageType.Byte, ModeStorageType.Palila);
SBMI.NetworkData.DownloadData = StorageExtension.AutoConvert(SBMI.NetworkData.Download, StorageType.Byte, ModeStorageType.Palila);
SBMI.NetworkData.UploadData = SSESSE.AutoConvert(SBMI.NetworkData.Upload, SEST.Byte, SEMST.Palila);
SBMI.NetworkData.DownloadData = SSESSE.AutoConvert(SBMI.NetworkData.Download, SEST.Byte, SEMST.Palila);

SBMI.NetworkData.FormatUploadData = Numeric.Numeral(SBMI.NetworkData.UploadData.Value, true, true, 2, '0', ClearNumericType.None) + " " + SBMI.NetworkData.UploadData.Text;
SBMI.NetworkData.FormatDownloadData = Numeric.Numeral(SBMI.NetworkData.DownloadData.Value, true, true, 2, '0', ClearNumericType.None) + " " + SBMI.NetworkData.DownloadData.Text;
SBMI.NetworkData.FormatUploadData = SHN.Numeral(SBMI.NetworkData.UploadData.Value, true, true, 2, '0', SECNT.None) + " " + SBMI.NetworkData.UploadData.Text;
SBMI.NetworkData.FormatDownloadData = SHN.Numeral(SBMI.NetworkData.DownloadData.Value, true, true, 2, '0', SECNT.None) + " " + SBMI.NetworkData.DownloadData.Text;

break;
}
Expand Down Expand Up @@ -470,27 +473,41 @@ public static async Task Start()
{
Hardware.Update();

List<string> Sensors = new()
List<SBSSSS> Sensors = new()
{
$"Name: {Hardware.Name}"
new SBSSSS
{
Name = Hardware.Name,
Type = $"{Hardware.HardwareType}"
}
};

foreach (ISensor Sensor in Hardware.Sensors)
{
Sensors.Add($"Sensor: {Sensor.Name}, Type: {Sensor.SensorType}, Max: {Sensor.Max}, Min: {Sensor.Min}, Now: {Sensor.Value}");
Sensors.Add(new SBSSSS
{
Max = Sensor.Max,
Min = Sensor.Min,
Name = Sensor.Name,
Now = Sensor.Value,
Type = $"{Sensor.SensorType}"
});
}

string Result = JsonConvert.SerializeObject(Sensors, Formatting.Indented);

switch (Hardware.HardwareType)
{
case HardwareType.GpuAmd:
SBMI.GraphicData.State = true;
SBMI.GraphicData.Amd = JArray.Parse(Result);
break;
case HardwareType.GpuIntel:
SBMI.GraphicData.State = true;
SBMI.GraphicData.Intel = JArray.Parse(Result);
break;
case HardwareType.GpuNvidia:
SBMI.GraphicData.State = true;
SBMI.GraphicData.Nvidia = JArray.Parse(Result);
break;
default:
Expand Down
13 changes: 7 additions & 6 deletions src/Project/Sucrose.Backgroundog/Manage/Internal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ internal static class Internal

public static SBSDAS AudioData = new()
{
PID = 0,
//PID = 0,
State = false,
TrackNumber = 0,
PlaybackRate = 0d,
Hwnd = IntPtr.Zero,
//Hwnd = IntPtr.Zero,
AlbumTrackCount = 0,
Title = string.Empty,
Artist = string.Empty,
Expand All @@ -129,16 +129,16 @@ internal static class Internal
MaxSeekTime = TimeSpan.Zero,
LastPlayingFileTime = new(),
PositionSetFileTime = new(),
SourceDeviceId = string.Empty,
RenderDeviceId = string.Empty,
//SourceDeviceId = string.Empty,
//RenderDeviceId = string.Empty,
ThumbnailString = string.Empty,
ThumbnailAddress = string.Empty,
MediaType = MediaPlaybackMode.Unknown,
PlaybackMode = MediaPlaybackMode.Unknown,
PlaybackState = MediaPlaybackState.Unknown,
PropsValid = MediaPlaybackProps.Capabilities,
RepeatMode = MediaPlaybackRepeatMode.Unknown,
PlaybackCaps = MediaPlaybackCapabilities.None
//PlaybackCaps = MediaPlaybackCapabilities.None
};

public static SBSDMYS MemoryData = new()
Expand Down Expand Up @@ -169,8 +169,9 @@ internal static class Internal
public static SBSDGS GraphicData = new()
{
Amd = new(),
State = false,
Intel = new(),
Nvidia = new(),
Nvidia = new()
};

public static SBSDNS NetworkData = new()
Expand Down
16 changes: 10 additions & 6 deletions src/Project/Sucrose.Backgroundog/Struct/Data.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,19 +139,19 @@ public struct AudioStruct
/// <summary>
///
/// </summary>
public uint? PID;
private uint? PID;
/// <summary>
///
/// </summary>
public bool State;
/// <summary>
///
/// </summary>
public IntPtr? Hwnd;
public string Title;
/// <summary>
///
/// </summary>
public string Title;
private IntPtr? Hwnd;
/// <summary>
///
/// </summary>
Expand Down Expand Up @@ -211,11 +211,11 @@ public struct AudioStruct
/// <summary>
///
/// </summary>
public string SourceDeviceId;
private string SourceDeviceId;
/// <summary>
///
/// </summary>
public string RenderDeviceId;
private string RenderDeviceId;
/// <summary>
///
/// </summary>
Expand Down Expand Up @@ -255,7 +255,7 @@ public struct AudioStruct
/// <summary>
///
/// </summary>
public MediaPlaybackCapabilities PlaybackCaps;
private MediaPlaybackCapabilities PlaybackCaps;
}

/// <summary>
Expand Down Expand Up @@ -408,6 +408,10 @@ public struct BatteryStruct
[StructLayout(LayoutKind.Sequential)]
public struct GraphicStruct
{
/// <summary>
///
/// </summary>
public bool State;
/// <summary>
///
/// </summary>
Expand Down
32 changes: 32 additions & 0 deletions src/Project/Sucrose.Backgroundog/Struct/Sensor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System.Runtime.InteropServices;

namespace Sucrose.Backgroundog.Struct.Sensor
{
/// <summary>
///
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct SensorStruct
{
/// <summary>
///
/// </summary>
public float? Max;
/// <summary>
///
/// </summary>
public float? Min;
/// <summary>
///
/// </summary>
public float? Now;
/// <summary>
///
/// </summary>
public string Name;
/// <summary>
///
/// </summary>
public string Type;
}
}
1 change: 1 addition & 0 deletions src/Shared/Engine/Sucrose.Shared.Engine/Helper/System.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ public static async void GetSystem()
SSEMI.AudioData = string.Empty;
SSEMI.MemoryData = string.Empty;
SSEMI.BatteryData = string.Empty;
SSEMI.GraphicData = string.Empty;
SSEMI.NetworkData = string.Empty;
SSEMI.MotherboardData = string.Empty;
}
Expand Down

0 comments on commit 3955d5c

Please sign in to comment.