Merge pull request #1356 from PepperDash/mc-subscription-logging

Multiple Fixes
This commit is contained in:
Neil Dorin
2025-11-14 15:44:58 -05:00
committed by GitHub
6 changed files with 63 additions and 75 deletions

View File

@@ -91,13 +91,17 @@ namespace PepperDash.Essentials.Core
return; return;
} }
var result = Port.Register();
if (result != eDeviceRegistrationUnRegistrationResponse.Success) if (Port.Parent is CrestronControlSystem || Port.Parent is CenIoCom102)
{ {
this.LogError($"Cannot register {Key} using {Port.Parent.GetType().Name}-comport-{Port.ID} (result == {result})"); var result = Port.Register();
return; if (result != eDeviceRegistrationUnRegistrationResponse.Success)
{
this.LogError($"Cannot register {Key} using {Port.Parent.GetType().Name}-comport-{Port.ID} (result == {result})");
return;
}
this.LogInformation($"Successfully registered {Key} using {Port.Parent.GetType().Name}-comport-{Port.ID} (result == {result})");
} }
this.LogInformation($"Successfully registered {Key} using {Port.Parent.GetType().Name}-comport-{Port.ID} (result == {result})");
var specResult = Port.SetComPortSpec(Spec); var specResult = Port.SetComPortSpec(Spec);
if (specResult != 0) if (specResult != 0)
@@ -107,38 +111,6 @@ namespace PepperDash.Essentials.Core
} }
this.LogInformation($"Successfully set comspec for {Key} using {Port.Parent.GetType().Name}-comport-{Port.ID} (result == {specResult})"); this.LogInformation($"Successfully set comspec for {Key} using {Port.Parent.GetType().Name}-comport-{Port.ID} (result == {specResult})");
// TODO [ ] - Remove debug logging once verified working
// if (Port.Parent is CenIoCom102)
// {
// Port.PropertyChanged += (s, e) =>
// {
// this.LogInformation($@"RegisterAndConfigureComPort: PropertyChanged Fired >>
// comPort-'{Port.ID}',
// Property Changed-'{e.Property}',
// Value Changed-'{e.Value}',
// deviceName-'{Port.DeviceName}',
// parentDevice-'{Port.ParentDevice}',
// parent-`{Port.Parent}`,
// online-`{Port.IsOnline}`,
// present-`{Port.Present}`,
// supportedBaudRates-'{Port.SupportedBaudRates}'");
// };
// Port.ExtendedInformationChanged += (s, e) =>
// {
// this.LogInformation($@"RegisterAndConfigureComPort: ExtendedInformationChanged Fired >>
// comPort-'{Port.ID}',
// {e.Protocol},
// {e.BaudRate},
// {e.Parity},
// {e.DataBits},
// {e.StopBits},
// HW Handshake-'{e.HardwareHandshakeSetting}',
// SW Handshake-'{e.SoftwareHandshakeSetting}'");
// };
// }
Port.SerialDataReceived += Port_SerialDataReceived; Port.SerialDataReceived += Port_SerialDataReceived;
} }

View File

@@ -11,11 +11,11 @@ using PepperDash.Core;
namespace PepperDash.Essentials.Core.Config namespace PepperDash.Essentials.Core.Config
{ {
/// <summary> /// <summary>
/// Loads the ConfigObject from the file /// Loads the ConfigObject from the file
/// </summary> /// </summary>
public class EssentialsConfig : BasicConfig public class EssentialsConfig : BasicConfig
{ {
/// <summary> /// <summary>
/// Gets or sets the SystemUrl /// Gets or sets the SystemUrl
/// </summary> /// </summary>
@@ -32,21 +32,22 @@ namespace PepperDash.Essentials.Core.Config
/// Gets the SystemUuid extracted from the SystemUrl /// Gets the SystemUuid extracted from the SystemUrl
/// </summary> /// </summary>
[JsonProperty("systemUuid")] [JsonProperty("systemUuid")]
public string SystemUuid public string SystemUuid
{ {
get get
{ {
if (string.IsNullOrEmpty(SystemUrl)) if (string.IsNullOrEmpty(SystemUrl))
return "missing url"; return "missing url";
if (SystemUrl.Contains("#")) if (SystemUrl.Contains("#"))
{ {
var result = Regex.Match(SystemUrl, @"https?:\/\/.*\/systems\/(.*)\/#.*"); var result = Regex.Match(SystemUrl, @"https?:\/\/.*\/systems\/(.*)\/#.*");
string uuid = result.Groups[1].Value; string uuid = result.Groups[1].Value;
return uuid; return uuid;
} else }
{ else
var result = Regex.Match(SystemUrl, @"https?:\/\/.*\/systems\/(.*)\/.*"); {
var result = Regex.Match(SystemUrl, @"https?:\/\/.*\/systems\/detail\/(.*)\/.*");
string uuid = result.Groups[1].Value; string uuid = result.Groups[1].Value;
return uuid; return uuid;
} }
@@ -57,21 +58,22 @@ namespace PepperDash.Essentials.Core.Config
/// Gets the TemplateUuid extracted from the TemplateUrl /// Gets the TemplateUuid extracted from the TemplateUrl
/// </summary> /// </summary>
[JsonProperty("templateUuid")] [JsonProperty("templateUuid")]
public string TemplateUuid public string TemplateUuid
{ {
get get
{ {
if (string.IsNullOrEmpty(TemplateUrl)) if (string.IsNullOrEmpty(TemplateUrl))
return "missing template url"; return "missing template url";
if (TemplateUrl.Contains("#")) if (TemplateUrl.Contains("#"))
{ {
var result = Regex.Match(TemplateUrl, @"https?:\/\/.*\/templates\/(.*)\/#.*"); var result = Regex.Match(TemplateUrl, @"https?:\/\/.*\/templates\/(.*)\/#.*");
string uuid = result.Groups[1].Value; string uuid = result.Groups[1].Value;
return uuid; return uuid;
} else }
{ else
var result = Regex.Match(TemplateUrl, @"https?:\/\/.*\/system-templates\/(.*)\/system-template-versions\/(.*)\/.*"); {
var result = Regex.Match(TemplateUrl, @"https?:\/\/.*\/system-templates\/detail\/(.*)\/system-template-versions\/detail\/(.*)\/.*");
string uuid = result.Groups[2].Value; string uuid = result.Groups[2].Value;
return uuid; return uuid;
} }
@@ -97,7 +99,7 @@ namespace PepperDash.Essentials.Core.Config
{ {
Rooms = new List<DeviceConfig>(); Rooms = new List<DeviceConfig>();
} }
} }
/// <summary> /// <summary>
/// Represents version data for Essentials and its packages /// Represents version data for Essentials and its packages
@@ -147,7 +149,7 @@ namespace PepperDash.Essentials.Core.Config
/// Represents a SystemTemplateConfigs /// Represents a SystemTemplateConfigs
/// </summary> /// </summary>
public class SystemTemplateConfigs public class SystemTemplateConfigs
{ {
/// <summary> /// <summary>
/// Gets or sets the System /// Gets or sets the System
/// </summary> /// </summary>
@@ -157,5 +159,5 @@ namespace PepperDash.Essentials.Core.Config
/// Gets or sets the Template /// Gets or sets the Template
/// </summary> /// </summary>
public EssentialsConfig Template { get; set; } public EssentialsConfig Template { get; set; }
} }
} }

View File

@@ -98,7 +98,7 @@ namespace PepperDash.Essentials.Core.Routing
/// <param name="inputPort">The currently selected input port on the destination device.</param> /// <param name="inputPort">The currently selected input port on the destination device.</param>
private void UpdateDestination(IRoutingSinkWithSwitching destination, RoutingInputPort inputPort) private void UpdateDestination(IRoutingSinkWithSwitching destination, RoutingInputPort inputPort)
{ {
// Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, "Updating destination {destination} with inputPort {inputPort}", this,destination?.Key, inputPort?.Key); Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, "Updating destination {destination} with inputPort {inputPort}", this, destination?.Key, inputPort?.Key);
if(inputPort == null) if(inputPort == null)
{ {

View File

@@ -9,7 +9,7 @@ namespace PepperDash.Essentials.Devices.Common.Generic
/// <summary> /// <summary>
/// Represents a GenericSink /// Represents a GenericSink
/// </summary> /// </summary>
public class GenericSink : EssentialsDevice, IRoutingSinkWithInputPort public class GenericSink : EssentialsDevice, IRoutingSinkWithSwitchingWithInputPort
{ {
/// <summary> /// <summary>
/// Initializes a new instance of the GenericSink class /// Initializes a new instance of the GenericSink class
@@ -20,7 +20,7 @@ namespace PepperDash.Essentials.Devices.Common.Generic
{ {
InputPorts = new RoutingPortCollection<RoutingInputPort>(); InputPorts = new RoutingPortCollection<RoutingInputPort>();
var inputPort = new RoutingInputPort(RoutingPortNames.AnyVideoIn, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, null, this); var inputPort = new RoutingInputPort(RoutingPortNames.AnyVideoIn, eRoutingSignalType.AudioVideo | eRoutingSignalType.SecondaryAudio, eRoutingPortConnectionType.Hdmi, null, this);
InputPorts.Add(inputPort); InputPorts.Add(inputPort);
} }
@@ -66,6 +66,15 @@ namespace PepperDash.Essentials.Devices.Common.Generic
/// Event fired when the current source changes /// Event fired when the current source changes
/// </summary> /// </summary>
public event SourceInfoChangeHandler CurrentSourceChange; public event SourceInfoChangeHandler CurrentSourceChange;
/// <inheritdoc />
public event InputChangedEventHandler InputChanged;
/// <inheritdoc />
public void ExecuteSwitch(object inputSelector)
{
throw new System.NotImplementedException();
}
} }
/// <summary> /// <summary>

View File

@@ -194,7 +194,6 @@ namespace PepperDash.Essentials.AppServer.Messengers
{ {
if (!enableMessengerSubscriptions) if (!enableMessengerSubscriptions)
{ {
this.LogWarning("Messenger subscriptions not enabled");
return; return;
} }
@@ -218,7 +217,6 @@ namespace PepperDash.Essentials.AppServer.Messengers
{ {
if (!enableMessengerSubscriptions) if (!enableMessengerSubscriptions)
{ {
this.LogWarning("Messenger subscriptions not enabled");
return; return;
} }
@@ -238,7 +236,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
return; return;
} }
this.LogInformation("Client with ID {clientId} unsubscribed", clientId); this.LogDebug("Client with ID {clientId} unsubscribed", clientId);
} }
/// <summary> /// <summary>
@@ -272,7 +270,8 @@ namespace PepperDash.Essentials.AppServer.Messengers
} }
catch (Exception ex) catch (Exception ex)
{ {
this.LogError(ex, "Exception posting status message for {messagePath} to {clientId}", MessagePath, clientId ?? "all clients"); this.LogError("Exception posting status message for {messagePath} to {clientId}: {message}", MessagePath, clientId ?? "all clients", ex.Message);
this.LogDebug(ex, "Stack trace: ");
} }
} }
@@ -301,7 +300,8 @@ namespace PepperDash.Essentials.AppServer.Messengers
} }
catch (Exception ex) catch (Exception ex)
{ {
this.LogError(ex, "Exception posting status message for {type} to {clientId}", type, clientId ?? "all clients"); this.LogError("Exception posting status message for {type} to {clientId}: {message}", type, clientId ?? "all clients", ex.Message);
this.LogDebug(ex, "Stack trace: ");
} }
} }

View File

@@ -1312,6 +1312,11 @@ namespace PepperDash.Essentials
/// <inheritdoc /> /// <inheritdoc />
public override void Initialize() public override void Initialize()
{ {
if (!Config.EnableMessengerSubscriptions)
{
this.LogWarning("Messenger subscriptions disabled. add \"enableMessengerSubscriptions\": true to config for {key} to enable.", Key);
}
foreach (var messenger in _messengers) foreach (var messenger in _messengers)
{ {
try try