diff --git a/src/Project/Sucrose.Backgroundog/Extension/AudioSession.cs b/src/Project/Sucrose.Backgroundog/Extension/AudioSession.cs index be0f44b48..bf9ede933 100644 --- a/src/Project/Sucrose.Backgroundog/Extension/AudioSession.cs +++ b/src/Project/Sucrose.Backgroundog/Extension/AudioSession.cs @@ -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; diff --git a/src/Project/Sucrose.Backgroundog/Extension/Data.cs b/src/Project/Sucrose.Backgroundog/Extension/Data.cs index d0a7b0081..878254f84 100644 --- a/src/Project/Sucrose.Backgroundog/Extension/Data.cs +++ b/src/Project/Sucrose.Backgroundog/Extension/Data.cs @@ -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 }, @@ -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 }, @@ -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 } }; diff --git a/src/Project/Sucrose.Backgroundog/Helper/Specification.cs b/src/Project/Sucrose.Backgroundog/Helper/Specification.cs index c78df977a..8bc7e3e96 100644 --- a/src/Project/Sucrose.Backgroundog/Helper/Specification.cs +++ b/src/Project/Sucrose.Backgroundog/Helper/Specification.cs @@ -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; @@ -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; @@ -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; } @@ -470,14 +473,25 @@ public static async Task Start() { Hardware.Update(); - List Sensors = new() + List 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); @@ -485,12 +499,15 @@ public static async Task Start() 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: diff --git a/src/Project/Sucrose.Backgroundog/Manage/Internal.cs b/src/Project/Sucrose.Backgroundog/Manage/Internal.cs index 4aeb68a0b..b20e94acc 100644 --- a/src/Project/Sucrose.Backgroundog/Manage/Internal.cs +++ b/src/Project/Sucrose.Backgroundog/Manage/Internal.cs @@ -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, @@ -129,8 +129,8 @@ 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, @@ -138,7 +138,7 @@ internal static class Internal PlaybackState = MediaPlaybackState.Unknown, PropsValid = MediaPlaybackProps.Capabilities, RepeatMode = MediaPlaybackRepeatMode.Unknown, - PlaybackCaps = MediaPlaybackCapabilities.None + //PlaybackCaps = MediaPlaybackCapabilities.None }; public static SBSDMYS MemoryData = new() @@ -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() diff --git a/src/Project/Sucrose.Backgroundog/Struct/Data.cs b/src/Project/Sucrose.Backgroundog/Struct/Data.cs index f8329cc6b..d28a83fbf 100644 --- a/src/Project/Sucrose.Backgroundog/Struct/Data.cs +++ b/src/Project/Sucrose.Backgroundog/Struct/Data.cs @@ -139,7 +139,7 @@ public struct AudioStruct /// /// /// - public uint? PID; + private uint? PID; /// /// /// @@ -147,11 +147,11 @@ public struct AudioStruct /// /// /// - public IntPtr? Hwnd; + public string Title; /// /// /// - public string Title; + private IntPtr? Hwnd; /// /// /// @@ -211,11 +211,11 @@ public struct AudioStruct /// /// /// - public string SourceDeviceId; + private string SourceDeviceId; /// /// /// - public string RenderDeviceId; + private string RenderDeviceId; /// /// /// @@ -255,7 +255,7 @@ public struct AudioStruct /// /// /// - public MediaPlaybackCapabilities PlaybackCaps; + private MediaPlaybackCapabilities PlaybackCaps; } /// @@ -408,6 +408,10 @@ public struct BatteryStruct [StructLayout(LayoutKind.Sequential)] public struct GraphicStruct { + /// + /// + /// + public bool State; /// /// /// diff --git a/src/Project/Sucrose.Backgroundog/Struct/Sensor.cs b/src/Project/Sucrose.Backgroundog/Struct/Sensor.cs new file mode 100644 index 000000000..989222faa --- /dev/null +++ b/src/Project/Sucrose.Backgroundog/Struct/Sensor.cs @@ -0,0 +1,32 @@ +using System.Runtime.InteropServices; + +namespace Sucrose.Backgroundog.Struct.Sensor +{ + /// + /// + /// + [StructLayout(LayoutKind.Sequential)] + public struct SensorStruct + { + /// + /// + /// + public float? Max; + /// + /// + /// + public float? Min; + /// + /// + /// + public float? Now; + /// + /// + /// + public string Name; + /// + /// + /// + public string Type; + } +} \ No newline at end of file diff --git a/src/Shared/Engine/Sucrose.Shared.Engine/Helper/System.cs b/src/Shared/Engine/Sucrose.Shared.Engine/Helper/System.cs index 880add52f..8305ca8e5 100644 --- a/src/Shared/Engine/Sucrose.Shared.Engine/Helper/System.cs +++ b/src/Shared/Engine/Sucrose.Shared.Engine/Helper/System.cs @@ -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; }