From 2e61d8d7096aeec6fe882c10c0c9e8a42bf06bde Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Tue, 21 May 2024 16:49:13 -0600 Subject: [PATCH] fix: Changes LevelControlLists to AudioControlPointLists and modified IHasDspPresets --- .../Config/AudioControlPointListItem.cs | 19 ++++++++ .../Config/BasicConfig.cs | 18 ++++---- .../Devices/AudioControlListItemBase.cs | 36 +++++++++++++++ .../Devices/IDspPreset.cs | 17 ------- .../Devices/IDspPresets.cs | 12 +++++ .../Devices/LevelControlListItem.cs | 30 +++---------- .../Devices/PresetListItem.cs | 45 +++++++++++++++++++ .../PepperDash.Essentials.Core.csproj | 2 +- ...epperDash.Essentials.Devices.Common.csproj | 2 +- .../PepperDash.Essentials.csproj | 2 +- 10 files changed, 130 insertions(+), 53 deletions(-) create mode 100644 src/PepperDash.Essentials.Core/Config/AudioControlPointListItem.cs create mode 100644 src/PepperDash.Essentials.Core/Devices/AudioControlListItemBase.cs delete mode 100644 src/PepperDash.Essentials.Core/Devices/IDspPreset.cs create mode 100644 src/PepperDash.Essentials.Core/Devices/IDspPresets.cs create mode 100644 src/PepperDash.Essentials.Core/Devices/PresetListItem.cs diff --git a/src/PepperDash.Essentials.Core/Config/AudioControlPointListItem.cs b/src/PepperDash.Essentials.Core/Config/AudioControlPointListItem.cs new file mode 100644 index 00000000..e58b9ee7 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Config/AudioControlPointListItem.cs @@ -0,0 +1,19 @@ +using Crestron.SimplSharpPro; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PepperDash.Essentials.Core.Config +{ + public class AudioControlPointListItem + { + [JsonProperty("levelControls")] + public Dictionary LevelControls { get; set; } + + [JsonProperty("presets")] + public Dictionary Presets { get; set; } + } +} diff --git a/src/PepperDash.Essentials.Core/Config/BasicConfig.cs b/src/PepperDash.Essentials.Core/Config/BasicConfig.cs index 32ee4ce7..4917e250 100644 --- a/src/PepperDash.Essentials.Core/Config/BasicConfig.cs +++ b/src/PepperDash.Essentials.Core/Config/BasicConfig.cs @@ -25,8 +25,8 @@ namespace PepperDash.Essentials.Core.Config [JsonProperty("destinationLists")] public Dictionary> DestinationLists { get; set; } - [JsonProperty("levelControlLists")] - public Dictionary> LevelControlLists { get; set; } + [JsonProperty("audioControlPointLists")] + public Dictionary> AudioControlPointLists { get; set; } [JsonProperty("tieLines")] public List TieLines { get; set; } @@ -40,7 +40,7 @@ namespace PepperDash.Essentials.Core.Config Devices = new List(); SourceLists = new Dictionary>(); DestinationLists = new Dictionary>(); - LevelControlLists = new Dictionary>(); + AudioControlPointLists = new Dictionary>(); TieLines = new List(); JoinMaps = new Dictionary(); } @@ -69,19 +69,19 @@ namespace PepperDash.Essentials.Core.Config } return DestinationLists[key]; - } + } /// - /// Retrieves a LevelControlList based on the key + /// Retrieves a AudioControlPointList based on the key /// /// key of the list to retrieve - /// LevelControlList if the key exists, null otherwise - public Dictionary GetLevelControlListForKey(string key) + /// AudioControlPointList if the key exists, null otherwise + public Dictionary GetAudioControlPointListForKey(string key) { - if (string.IsNullOrEmpty(key) || !LevelControlLists.ContainsKey(key)) + if (string.IsNullOrEmpty(key) || !AudioControlPointLists.ContainsKey(key)) return null; - return LevelControlLists[key]; + return AudioControlPointLists[key]; } /// diff --git a/src/PepperDash.Essentials.Core/Devices/AudioControlListItemBase.cs b/src/PepperDash.Essentials.Core/Devices/AudioControlListItemBase.cs new file mode 100644 index 00000000..920c2d14 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/AudioControlListItemBase.cs @@ -0,0 +1,36 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PepperDash.Essentials.Core +{ + public abstract class AudioControlListItemBase + { + [JsonProperty("parentDeviceKey")] + public string ParentDeviceKey { get; set; } + + [JsonProperty("itemKey")] + public string ItemKey { get; set; } + + /// + /// A name that will override the items's name on the UI + /// + [JsonProperty("name")] + public string Name { get; set; } + + /// + /// Indicates if the item should be included in the user accessible list + /// + [JsonProperty("includeInUserList")] + public bool IncludeInUserList { get; set; } + + /// + /// Used to specify the order of the items in the source list when displayed + /// + [JsonProperty("order")] + public int Order { get; set; } + } +} diff --git a/src/PepperDash.Essentials.Core/Devices/IDspPreset.cs b/src/PepperDash.Essentials.Core/Devices/IDspPreset.cs deleted file mode 100644 index 645339bb..00000000 --- a/src/PepperDash.Essentials.Core/Devices/IDspPreset.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Collections.Generic; - -namespace PepperDash.Essentials.Core -{ - public interface IHasDspPresets - { - List Presets { get; } - - void RecallPreset(IDspPreset preset); - - } - - public interface IDspPreset - { - string Name { get; } - } -} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/IDspPresets.cs b/src/PepperDash.Essentials.Core/Devices/IDspPresets.cs new file mode 100644 index 00000000..94bc3929 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/IDspPresets.cs @@ -0,0 +1,12 @@ +using PepperDash.Core; +using System.Collections.Generic; + +namespace PepperDash.Essentials.Core +{ + public interface IDspPresets + { + Dictionary Presets { get; } + + void RecallPreset(string key); + } +} \ No newline at end of file diff --git a/src/PepperDash.Essentials.Core/Devices/LevelControlListItem.cs b/src/PepperDash.Essentials.Core/Devices/LevelControlListItem.cs index fb18eb69..bb23e632 100644 --- a/src/PepperDash.Essentials.Core/Devices/LevelControlListItem.cs +++ b/src/PepperDash.Essentials.Core/Devices/LevelControlListItem.cs @@ -5,13 +5,13 @@ using System.Text; using System.Threading.Tasks; using Newtonsoft.Json; using PepperDash.Core; +using PepperDash.Essentials.Core.Devices; namespace PepperDash.Essentials.Core { - public class LevelControlListItem + public class LevelControlListItem : AudioControlListItemBase { - [JsonProperty("deviceKey")] - public string DeviceKey { get; set; } + [JsonIgnore] public IBasicVolumeWithFeedback LevelControl @@ -19,7 +19,7 @@ namespace PepperDash.Essentials.Core get { if (_levelControl == null) - _levelControl = DeviceManager.GetDeviceForKey(DeviceKey) as IBasicVolumeWithFeedback; + _levelControl = DeviceManager.GetDeviceForKey(ParentDeviceKey) as IBasicVolumeWithFeedback; return _levelControl; } } @@ -34,8 +34,8 @@ namespace PepperDash.Essentials.Core get { if (!string.IsNullOrEmpty(Name)) return Name; - else - { + else + { if (LevelControl is IKeyName namedLevelControl) { if (namedLevelControl == null) @@ -47,24 +47,6 @@ namespace PepperDash.Essentials.Core } } - /// - /// A name that will override the items's name on the UI - /// - [JsonProperty("name")] - public string Name { get; set; } - - /// - /// Indicates if the item should be included in the user accessible list - /// - [JsonProperty("includeInUserList")] - public bool IncludeInUserList { get; set; } - - /// - /// Used to specify the order of the items in the source list when displayed - /// - [JsonProperty("order")] - public int Order { get; set; } - /// /// Indicates if the item is a level, mute , or both /// diff --git a/src/PepperDash.Essentials.Core/Devices/PresetListItem.cs b/src/PepperDash.Essentials.Core/Devices/PresetListItem.cs new file mode 100644 index 00000000..f539d718 --- /dev/null +++ b/src/PepperDash.Essentials.Core/Devices/PresetListItem.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Newtonsoft.Json; +using PepperDash.Core; + + +namespace PepperDash.Essentials.Core +{ + public class PresetListItem : AudioControlListItemBase + { + [JsonIgnore] + public IKeyName Preset + { + get + { + if (_preset == null) + { + var parent = DeviceManager.GetDeviceForKey(ParentDeviceKey) as IDspPresets; + if (parent == null || !parent.Presets.ContainsKey(ItemKey)) + return null; + _preset = parent.Presets[ItemKey]; + } + return _preset; + } + } + private IKeyName _preset; + + /// + /// Gets the name from the device if it implements IKeyName or else returns the Name property + /// + [JsonProperty("preferredName")] + public string PreferredName + { + get + { + if (!string.IsNullOrEmpty(Name)) return Name; + + else return Preset.Name; + } + } + } +} diff --git a/src/PepperDash.Essentials.Core/PepperDash.Essentials.Core.csproj b/src/PepperDash.Essentials.Core/PepperDash.Essentials.Core.csproj index 4646a0cc..6c1a058e 100644 --- a/src/PepperDash.Essentials.Core/PepperDash.Essentials.Core.csproj +++ b/src/PepperDash.Essentials.Core/PepperDash.Essentials.Core.csproj @@ -23,7 +23,7 @@ - + diff --git a/src/PepperDash.Essentials.Devices.Common/PepperDash.Essentials.Devices.Common.csproj b/src/PepperDash.Essentials.Devices.Common/PepperDash.Essentials.Devices.Common.csproj index 6e179d3a..c34ec280 100644 --- a/src/PepperDash.Essentials.Devices.Common/PepperDash.Essentials.Devices.Common.csproj +++ b/src/PepperDash.Essentials.Devices.Common/PepperDash.Essentials.Devices.Common.csproj @@ -27,6 +27,6 @@ - + \ No newline at end of file diff --git a/src/PepperDash.Essentials/PepperDash.Essentials.csproj b/src/PepperDash.Essentials/PepperDash.Essentials.csproj index 5aa6d143..3d85afd5 100644 --- a/src/PepperDash.Essentials/PepperDash.Essentials.csproj +++ b/src/PepperDash.Essentials/PepperDash.Essentials.csproj @@ -47,7 +47,7 @@ - +