Merge pull request #1331 from PepperDash/dev-list-fix

This commit is contained in:
Neil Dorin
2025-09-17 08:36:04 -06:00
committed by GitHub
7 changed files with 396 additions and 390 deletions

View File

@@ -2,14 +2,12 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Crestron.SimplSharp;
using System.Reflection; using System.Reflection;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro; using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DeviceSupport;
using Crestron.SimplSharpPro.EthernetCommunication; using Crestron.SimplSharpPro.EthernetCommunication;
using Newtonsoft.Json; using Newtonsoft.Json;
using PepperDash.Core; using PepperDash.Core;
using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Config;
using Serilog.Events; using Serilog.Events;
@@ -355,22 +353,22 @@ namespace PepperDash.Essentials.Core.Bridges
/// </summary> /// </summary>
public class EiscApiPropertiesConfig public class EiscApiPropertiesConfig
{ {
[JsonProperty("control")]
/// <summary> /// <summary>
/// Gets or sets the Control /// Gets or sets the Control
/// </summary> /// </summary>
[JsonProperty("control")]
public EssentialsControlPropertiesConfig Control { get; set; } public EssentialsControlPropertiesConfig Control { get; set; }
[JsonProperty("devices")]
/// <summary> /// <summary>
/// Gets or sets the Devices /// Gets or sets the Devices
/// </summary> /// </summary>
[JsonProperty("devices")]
public List<ApiDevicePropertiesConfig> Devices { get; set; } public List<ApiDevicePropertiesConfig> Devices { get; set; }
[JsonProperty("rooms")]
/// <summary> /// <summary>
/// Gets or sets the Rooms /// Gets or sets the Rooms
/// </summary> /// </summary>
[JsonProperty("rooms")]
public List<ApiRoomPropertiesConfig> Rooms { get; set; } public List<ApiRoomPropertiesConfig> Rooms { get; set; }
@@ -379,22 +377,22 @@ namespace PepperDash.Essentials.Core.Bridges
/// </summary> /// </summary>
public class ApiDevicePropertiesConfig public class ApiDevicePropertiesConfig
{ {
[JsonProperty("deviceKey")]
/// <summary> /// <summary>
/// Gets or sets the DeviceKey /// Gets or sets the DeviceKey
/// </summary> /// </summary>
[JsonProperty("deviceKey")]
public string DeviceKey { get; set; } public string DeviceKey { get; set; }
[JsonProperty("joinStart")]
/// <summary> /// <summary>
/// Gets or sets the JoinStart /// Gets or sets the JoinStart
/// </summary> /// </summary>
[JsonProperty("joinStart")]
public uint JoinStart { get; set; } public uint JoinStart { get; set; }
[JsonProperty("joinMapKey")]
/// <summary> /// <summary>
/// Gets or sets the JoinMapKey /// Gets or sets the JoinMapKey
/// </summary> /// </summary>
[JsonProperty("joinMapKey")]
public string JoinMapKey { get; set; } public string JoinMapKey { get; set; }
} }
@@ -403,22 +401,22 @@ namespace PepperDash.Essentials.Core.Bridges
/// </summary> /// </summary>
public class ApiRoomPropertiesConfig public class ApiRoomPropertiesConfig
{ {
[JsonProperty("roomKey")]
/// <summary> /// <summary>
/// Gets or sets the RoomKey /// Gets or sets the RoomKey
/// </summary> /// </summary>
[JsonProperty("roomKey")]
public string RoomKey { get; set; } public string RoomKey { get; set; }
[JsonProperty("joinStart")]
/// <summary> /// <summary>
/// Gets or sets the JoinStart /// Gets or sets the JoinStart
/// </summary> /// </summary>
[JsonProperty("joinStart")]
public uint JoinStart { get; set; } public uint JoinStart { get; set; }
[JsonProperty("joinMapKey")]
/// <summary> /// <summary>
/// Gets or sets the JoinMapKey /// Gets or sets the JoinMapKey
/// </summary> /// </summary>
[JsonProperty("joinMapKey")]
public string JoinMapKey { get; set; } public string JoinMapKey { get; set; }
} }

View File

@@ -18,41 +18,41 @@ namespace PepperDash.Essentials.Core.Config
/// </summary> /// </summary>
public class DeviceConfig public class DeviceConfig
{ {
[JsonProperty("key")]
/// <summary> /// <summary>
/// Gets or sets the Key /// Gets or sets the Key
/// </summary> /// </summary>
[JsonProperty("key")]
public string Key { get; set; } public string Key { get; set; }
[JsonProperty("uid")]
/// <summary> /// <summary>
/// Gets or sets the Uid /// Gets or sets the Uid
/// </summary> /// </summary>
[JsonProperty("uid")]
public int Uid { get; set; } public int Uid { get; set; }
[JsonProperty("name")]
/// <summary> /// <summary>
/// Gets or sets the Name /// Gets or sets the Name
/// </summary> /// </summary>
[JsonProperty("name")]
public string Name { get; set; } public string Name { get; set; }
[JsonProperty("group")]
/// <summary> /// <summary>
/// Gets or sets the Group /// Gets or sets the Group
/// </summary> /// </summary>
[JsonProperty("group")]
public string Group { get; set; } public string Group { get; set; }
[JsonProperty("type")]
/// <summary> /// <summary>
/// Gets or sets the Type /// Gets or sets the Type
/// </summary> /// </summary>
[JsonProperty("type")]
public string Type { get; set; } public string Type { get; set; }
[JsonProperty("properties")]
[JsonConverter(typeof(DevicePropertiesConverter))]
/// <summary> /// <summary>
/// Gets or sets the Properties /// Gets or sets the Properties
/// </summary> /// </summary>
[JsonProperty("properties")]
[JsonConverter(typeof(DevicePropertiesConverter))]
public JToken Properties { get; set; } public JToken Properties { get; set; }
public DeviceConfig(DeviceConfig dc) public DeviceConfig(DeviceConfig dc)

View File

@@ -202,7 +202,7 @@ namespace PepperDash.Essentials.Core
private static void ListDevices(string s) private static void ListDevices(string s)
{ {
CrestronConsole.ConsoleCommandResponse($"{Devices.Count} Devices registered with Device Manager:"); CrestronConsole.ConsoleCommandResponse($"{Devices.Count} Devices registered with Device Manager:\r\n");
var sorted = Devices.Values.ToList(); var sorted = Devices.Values.ToList();
sorted.Sort((a, b) => a.Key.CompareTo(b.Key)); sorted.Sort((a, b) => a.Key.CompareTo(b.Key));
@@ -210,7 +210,7 @@ namespace PepperDash.Essentials.Core
foreach (var d in sorted) foreach (var d in sorted)
{ {
var name = d is IKeyName ? (d as IKeyName).Name : "---"; var name = d is IKeyName ? (d as IKeyName).Name : "---";
CrestronConsole.ConsoleCommandResponse($" [{d.Key}] {name}"); CrestronConsole.ConsoleCommandResponse($" [{d.Key}] {name}\r\n");
} }
} }
@@ -219,28 +219,17 @@ namespace PepperDash.Essentials.Core
var dev = GetDeviceForKey(devKey); var dev = GetDeviceForKey(devKey);
if (dev == null) if (dev == null)
{ {
Debug.LogMessage(LogEventLevel.Information, "Device '{0}' not found", devKey); CrestronConsole.ConsoleCommandResponse($"Device '{devKey}' not found\r\n");
return; return;
} }
if (!(dev is IHasFeedback statusDev)) if (!(dev is IHasFeedback statusDev))
{ {
Debug.LogMessage(LogEventLevel.Information, "Device '{0}' does not have visible feedbacks", devKey); CrestronConsole.ConsoleCommandResponse($"Device '{devKey}' does not have visible feedbacks\r\n");
return; return;
} }
statusDev.DumpFeedbacksToConsole(true); statusDev.DumpFeedbacksToConsole(true);
} }
//static void ListDeviceCommands(string devKey)
//{
// var dev = GetDeviceForKey(devKey);
// if (dev == null)
// {
// Debug.LogMessage(LogEventLevel.Information, "Device '{0}' not found", devKey);
// return;
// }
// Debug.LogMessage(LogEventLevel.Information, "This needs to be reworked. Stay tuned.", devKey);
//}
private static void ListDeviceCommStatuses(string input) private static void ListDeviceCommStatuses(string input)
{ {
@@ -250,12 +239,6 @@ namespace PepperDash.Essentials.Core
} }
} }
//static void DoDeviceCommand(string command)
//{
// Debug.LogMessage(LogEventLevel.Information, "Not yet implemented. Stay tuned");
//}
/// <summary> /// <summary>
/// AddDevice method /// AddDevice method
/// </summary> /// </summary>

View File

@@ -1,6 +1,6 @@
using System; using System;
using System.Linq; using System.Linq;
using Crestron.SimplSharp;
using PepperDash.Core; using PepperDash.Core;
using Serilog.Events; using Serilog.Events;
@@ -19,47 +19,72 @@ namespace PepperDash.Essentials.Core
} }
/// <summary>
/// Extension methods for IHasFeedback
/// </summary>
public static class IHasFeedbackExtensions public static class IHasFeedbackExtensions
{ {
/// <summary>
/// Gets the feedback type name for sorting purposes
/// </summary>
/// <param name="feedback">The feedback to get the type name for</param>
/// <returns>A string representing the feedback type</returns>
private static string GetFeedbackTypeName(Feedback feedback)
{
if (feedback is BoolFeedback)
return "boolean";
else if (feedback is IntFeedback)
return "integer";
else if (feedback is StringFeedback)
return "string";
else
return feedback.GetType().Name;
}
/// <summary>
/// Dumps the feedbacks to the console
/// </summary>
/// <param name="source"></param>
/// <param name="getCurrentStates"></param>
public static void DumpFeedbacksToConsole(this IHasFeedback source, bool getCurrentStates) public static void DumpFeedbacksToConsole(this IHasFeedback source, bool getCurrentStates)
{ {
Type t = source.GetType();
// get the properties and set them into a new collection of NameType wrappers
var props = t.GetProperties().Select(p => new PropertyNameType(p, t));
var feedbacks = source.Feedbacks; var feedbacks = source.Feedbacks;
if (feedbacks != null)
if (feedbacks == null || feedbacks.Count == 0)
{ {
Debug.LogMessage(LogEventLevel.Information, source, "\n\nAvailable feedbacks:"); CrestronConsole.ConsoleCommandResponse("No available feedbacks\r\n");
foreach (var f in feedbacks) return;
}
CrestronConsole.ConsoleCommandResponse("Available feedbacks:\r\n");
// Sort feedbacks by type first, then by key
var sortedFeedbacks = feedbacks.OrderBy(f => GetFeedbackTypeName(f)).ThenBy(f => string.IsNullOrEmpty(f.Key) ? "" : f.Key);
foreach (var feedback in sortedFeedbacks)
{ {
string val = ""; string value = "";
string type = ""; string type = "";
if (getCurrentStates) if (getCurrentStates)
{ {
if (f is BoolFeedback) if (feedback is BoolFeedback)
{ {
val = f.BoolValue.ToString(); value = feedback.BoolValue.ToString();
type = "boolean"; type = "boolean";
} }
else if (f is IntFeedback) else if (feedback is IntFeedback)
{ {
val = f.IntValue.ToString(); value = feedback.IntValue.ToString();
type = "integer"; type = "integer";
} }
else if (f is StringFeedback) else if (feedback is StringFeedback)
{ {
val = f.StringValue; value = feedback.StringValue;
type = "string"; type = "string";
} }
} }
Debug.LogMessage(LogEventLevel.Information, "{0,-12} {1, -25} {2}", type, CrestronConsole.ConsoleCommandResponse($" {type,-12} {(string.IsNullOrEmpty(feedback.Key) ? "-no key-" : feedback.Key),-25} {value}\r\n");
(string.IsNullOrEmpty(f.Key) ? "-no key-" : f.Key), val); }
}
}
else
Debug.LogMessage(LogEventLevel.Information, source, "No available outputs:");
} }
} }
} }

View File

@@ -114,16 +114,16 @@ namespace PepperDash.Essentials.Room.Config
[JsonProperty("emergency")] [JsonProperty("emergency")]
public EssentialsRoomEmergencyConfig Emergency { get; set; } public EssentialsRoomEmergencyConfig Emergency { get; set; }
[JsonProperty("help")]
/// <summary> /// <summary>
/// Gets or sets the Help /// Gets or sets the Help
/// </summary> /// </summary>
[JsonProperty("help")]
public EssentialsHelpPropertiesConfig Help { get; set; } public EssentialsHelpPropertiesConfig Help { get; set; }
[JsonProperty("helpMessage")]
/// <summary> /// <summary>
/// Gets or sets the HelpMessage /// Gets or sets the HelpMessage
/// </summary> /// </summary>
[JsonProperty("helpMessage")]
public string HelpMessage { get; set; } public string HelpMessage { get; set; }
/// <summary> /// <summary>
@@ -144,82 +144,82 @@ namespace PepperDash.Essentials.Room.Config
} }
} }
[JsonProperty("environment")]
/// <summary> /// <summary>
/// Gets or sets the Environment /// Gets or sets the Environment
/// </summary> /// </summary>
[JsonProperty("environment")]
public EssentialsEnvironmentPropertiesConfig Environment { get; set; } public EssentialsEnvironmentPropertiesConfig Environment { get; set; }
[JsonProperty("logo")]
/// <summary> /// <summary>
/// Gets or sets the LogoLight /// Gets or sets the LogoLight
/// </summary> /// </summary>
[JsonProperty("logo")]
public EssentialsLogoPropertiesConfig LogoLight { get; set; } public EssentialsLogoPropertiesConfig LogoLight { get; set; }
[JsonProperty("logoDark")]
/// <summary> /// <summary>
/// Gets or sets the LogoDark /// Gets or sets the LogoDark
/// </summary> /// </summary>
[JsonProperty("logoDark")]
public EssentialsLogoPropertiesConfig LogoDark { get; set; } public EssentialsLogoPropertiesConfig LogoDark { get; set; }
[JsonProperty("microphonePrivacy")]
/// <summary> /// <summary>
/// Gets or sets the MicrophonePrivacy /// Gets or sets the MicrophonePrivacy
/// </summary> /// </summary>
[JsonProperty("microphonePrivacy")]
public EssentialsRoomMicrophonePrivacyConfig MicrophonePrivacy { get; set; } public EssentialsRoomMicrophonePrivacyConfig MicrophonePrivacy { get; set; }
[JsonProperty("occupancy")]
/// <summary> /// <summary>
/// Gets or sets the Occupancy /// Gets or sets the Occupancy
/// </summary> /// </summary>
[JsonProperty("occupancy")]
public EssentialsRoomOccSensorConfig Occupancy { get; set; } public EssentialsRoomOccSensorConfig Occupancy { get; set; }
[JsonProperty("oneButtonMeeting")]
/// <summary> /// <summary>
/// Gets or sets the OneButtonMeeting /// Gets or sets the OneButtonMeeting
/// </summary> /// </summary>
[JsonProperty("oneButtonMeeting")]
public EssentialsOneButtonMeetingPropertiesConfig OneButtonMeeting { get; set; } public EssentialsOneButtonMeetingPropertiesConfig OneButtonMeeting { get; set; }
[JsonProperty("shutdownVacancySeconds")]
/// <summary> /// <summary>
/// Gets or sets the ShutdownVacancySeconds /// Gets or sets the ShutdownVacancySeconds
/// </summary> /// </summary>
[JsonProperty("shutdownVacancySeconds")]
public int ShutdownVacancySeconds { get; set; } public int ShutdownVacancySeconds { get; set; }
[JsonProperty("shutdownPromptSeconds")]
/// <summary> /// <summary>
/// Gets or sets the ShutdownPromptSeconds /// Gets or sets the ShutdownPromptSeconds
/// </summary> /// </summary>
[JsonProperty("shutdownPromptSeconds")]
public int ShutdownPromptSeconds { get; set; } public int ShutdownPromptSeconds { get; set; }
[JsonProperty("tech")]
/// <summary> /// <summary>
/// Gets or sets the Tech /// Gets or sets the Tech
/// </summary> /// </summary>
[JsonProperty("tech")]
public EssentialsRoomTechConfig Tech { get; set; } public EssentialsRoomTechConfig Tech { get; set; }
[JsonProperty("volumes")]
/// <summary> /// <summary>
/// Gets or sets the Volumes /// Gets or sets the Volumes
/// </summary> /// </summary>
[JsonProperty("volumes")]
public EssentialsRoomVolumesConfig Volumes { get; set; } public EssentialsRoomVolumesConfig Volumes { get; set; }
[JsonProperty("fusion")]
/// <summary> /// <summary>
/// Gets or sets the Fusion /// Gets or sets the Fusion
/// </summary> /// </summary>
[JsonProperty("fusion")]
public EssentialsRoomFusionConfig Fusion { get; set; } public EssentialsRoomFusionConfig Fusion { get; set; }
[JsonProperty("essentialsRoomUiBehaviorConfig", NullValueHandling=NullValueHandling.Ignore)]
/// <summary> /// <summary>
/// Gets or sets the UiBehavior /// Gets or sets the UiBehavior
/// </summary> /// </summary>
[JsonProperty("essentialsRoomUiBehaviorConfig", NullValueHandling = NullValueHandling.Ignore)]
public EssentialsRoomUiBehaviorConfig UiBehavior { get; set; } public EssentialsRoomUiBehaviorConfig UiBehavior { get; set; }
[JsonProperty("zeroVolumeWhenSwtichingVolumeDevices")]
/// <summary> /// <summary>
/// Gets or sets the ZeroVolumeWhenSwtichingVolumeDevices /// Gets or sets the ZeroVolumeWhenSwtichingVolumeDevices
/// </summary> /// </summary>
[JsonProperty("zeroVolumeWhenSwtichingVolumeDevices")]
public bool ZeroVolumeWhenSwtichingVolumeDevices { get; set; } public bool ZeroVolumeWhenSwtichingVolumeDevices { get; set; }
/// <summary> /// <summary>

View File

@@ -15,9 +15,9 @@ using Serilog.Events;
namespace PepperDash.Essentials.Core namespace PepperDash.Essentials.Core
{ {
////***************************************************************************** ////*****************************************************************************
/// <summary> ///// <summary>
/// Base class for all subpage reference list controllers ///// Base class for all subpage reference list controllers
/// </summary> ///// </summary>
//public class SubpageReferenceListController //public class SubpageReferenceListController
//{ //{
// public SubpageReferenceList TheList { get; protected set; } // public SubpageReferenceList TheList { get; protected set; }

View File

@@ -44,9 +44,9 @@ namespace PepperDash.Essentials.Core
/// </summary> /// </summary>
public const uint ModalVisibleJoin = 3999; public const uint ModalVisibleJoin = 3999;
/// <summary> ///// <summary>
/// The seconds value of the countdown timer. Ushort join 3991 ///// The seconds value of the countdown timer. Ushort join 3991
/// </summary> ///// </summary>
//public const uint TimerSecondsJoin = 3991; //public const uint TimerSecondsJoin = 3991;
/// <summary> /// <summary>
/// The full ushort value of the countdown timer for a gauge. Ushort join 3992 /// The full ushort value of the countdown timer for a gauge. Ushort join 3992