mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-04-14 04:57:15 +00:00
refactor: routing interfaces and implementations to support current sources
- Updated ICurrentSources interface to use IRoutingSource instead of SourceListItem. - Introduced CurrentSourcesChangedEventArgs for detailed event notifications. - Modified IRoutingOutputs and IRoutingSource interfaces to include JSON properties for serialization. - Enhanced IRoutingSink and related interfaces to implement ICurrentSources for better source management. - Refactored RoutingFeedbackManager to utilize new current source handling. - Updated GenericAudioOut, GenericSink, and BlueJeansPc classes to implement new current source logic. - Adjusted MobileControl messengers to accommodate changes in current source handling. - Removed deprecated destination handling in MobileControlEssentialsRoomBridge.
This commit is contained in:
parent
43a9661e08
commit
b4d53dbe0e
19 changed files with 439 additions and 350 deletions
|
|
@ -131,12 +131,6 @@ public class GenericTcpIpClient : Device, ISocketStatusWithStreamDebugging, IAut
|
|||
/// </summary>
|
||||
public string ClientStatusText { get { return ClientStatus.ToString(); } }
|
||||
|
||||
/// <summary>
|
||||
/// Ushort representation of client status
|
||||
/// </summary>
|
||||
[Obsolete]
|
||||
public ushort UClientStatus { get { return (ushort)ClientStatus; } }
|
||||
|
||||
/// <summary>
|
||||
/// Connection failure reason
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
using Newtonsoft.Json;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.Core.Routing;
|
||||
|
||||
namespace PepperDash.Essentials.Core;
|
||||
|
||||
|
|
@ -11,23 +12,22 @@ namespace PepperDash.Essentials.Core;
|
|||
/// </summary>
|
||||
public class DestinationListItem
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the key identifier for the sink device that this destination represents.
|
||||
/// </summary>
|
||||
[JsonProperty("sinkKey")]
|
||||
public string SinkKey { get; set; }
|
||||
|
||||
private EssentialsDevice _sinkDevice;
|
||||
private IRoutingSink _sinkDevice;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the actual device instance for this destination.
|
||||
/// Lazily loads the device from the DeviceManager using the SinkKey.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public EssentialsDevice SinkDevice
|
||||
public IRoutingSink SinkDevice
|
||||
{
|
||||
get { return _sinkDevice ?? (_sinkDevice = DeviceManager.GetDeviceForKey(SinkKey) as EssentialsDevice); }
|
||||
get { return _sinkDevice ?? (_sinkDevice = DeviceManager.GetDeviceForKey(SinkKey) as IRoutingSink); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -43,17 +43,17 @@ public class SourceListItem
|
|||
/// Returns the source Device for this, if it exists in DeviceManager
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public Device SourceDevice
|
||||
public IRoutingSource SourceDevice
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_SourceDevice == null)
|
||||
_SourceDevice = DeviceManager.GetDeviceForKey(SourceKey) as Device;
|
||||
_SourceDevice = DeviceManager.GetDeviceForKey<IRoutingSource>(SourceKey);
|
||||
return _SourceDevice;
|
||||
}
|
||||
}
|
||||
|
||||
private Device _SourceDevice;
|
||||
private IRoutingSource _SourceDevice;
|
||||
|
||||
/// <summary>
|
||||
/// Gets either the source's Name or this AlternateName property, if
|
||||
|
|
|
|||
|
|
@ -1236,37 +1236,46 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||
uint i = 0;
|
||||
foreach (var kvp in setTopBoxes)
|
||||
{
|
||||
TryAddRouteActionSigs(JoinMap.Display1SetTopBoxSourceStart.AttributeName + " " + (i + 1), JoinMap.Display1SetTopBoxSourceStart.JoinNumber + i, kvp.Key, kvp.Value.SourceDevice);
|
||||
if (kvp.Value.SourceDevice is Device device)
|
||||
{
|
||||
TryAddRouteActionSigs(JoinMap.Display1SetTopBoxSourceStart.AttributeName + " " + (i + 1), JoinMap.Display1SetTopBoxSourceStart.JoinNumber + i, kvp.Key, device);
|
||||
i++;
|
||||
if (i > JoinMap.Display1SetTopBoxSourceStart.JoinSpan) // We only have five spots
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var discPlayers = dict.Where(d => d.Value.SourceDevice is IDiscPlayerControls);
|
||||
i = 0;
|
||||
foreach (var kvp in discPlayers)
|
||||
{
|
||||
TryAddRouteActionSigs(JoinMap.Display1DiscPlayerSourceStart.AttributeName + " " + (i + 1), JoinMap.Display1DiscPlayerSourceStart.JoinNumber + i, kvp.Key, kvp.Value.SourceDevice);
|
||||
if (kvp.Value.SourceDevice is Device device)
|
||||
{
|
||||
TryAddRouteActionSigs(JoinMap.Display1DiscPlayerSourceStart.AttributeName + " " + (i + 1), JoinMap.Display1DiscPlayerSourceStart.JoinNumber + i, kvp.Key, device);
|
||||
i++;
|
||||
if (i > JoinMap.Display1DiscPlayerSourceStart.JoinSpan) // We only have five spots
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var laptops = dict.Where(d => d.Value.SourceDevice is IRoutingSource);
|
||||
i = 0;
|
||||
foreach (var kvp in laptops)
|
||||
{
|
||||
TryAddRouteActionSigs(JoinMap.Display1LaptopSourceStart.AttributeName + " " + (i + 1), JoinMap.Display1LaptopSourceStart.JoinNumber + i, kvp.Key, kvp.Value.SourceDevice);
|
||||
if (kvp.Value.SourceDevice is Device device)
|
||||
{
|
||||
TryAddRouteActionSigs(JoinMap.Display1LaptopSourceStart.AttributeName + " " + (i + 1), JoinMap.Display1LaptopSourceStart.JoinNumber + i, kvp.Key, device);
|
||||
i++;
|
||||
if (i > JoinMap.Display1LaptopSourceStart.JoinSpan) // We only have ten spots???
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var usageDevice in dict.Select(kvp => kvp.Value.SourceDevice).OfType<IUsageTracking>())
|
||||
{
|
||||
|
|
@ -1745,7 +1754,8 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||
return;
|
||||
}
|
||||
|
||||
var dev = info.SourceDevice;
|
||||
if (info.SourceDevice is Device dev)
|
||||
{
|
||||
if (type == ChangeType.WillChange)
|
||||
{
|
||||
if (_sourceToFeedbackSigs.ContainsKey(dev))
|
||||
|
|
@ -1760,7 +1770,8 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||
_sourceToFeedbackSigs[dev].BoolValue = true;
|
||||
}
|
||||
//var name = (room == null ? "" : room.Name);
|
||||
CurrentRoomSourceNameSig.InputSig.StringValue = info.SourceDevice.Name;
|
||||
CurrentRoomSourceNameSig.InputSig.StringValue = dev.Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,18 +28,6 @@ public interface IHasDefaultDisplay
|
|||
IRoutingSink DefaultDisplay { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// For rooms with multiple displays
|
||||
/// </summary>
|
||||
[Obsolete("This interface is being deprecated in favor of using destination lists for routing to multiple displays.")]
|
||||
public interface IHasMultipleDisplays
|
||||
{
|
||||
/// <summary>
|
||||
/// A dictionary of displays in the room with the key being the type of display (presentation, calling, etc.) and the value being the display device
|
||||
/// </summary>
|
||||
Dictionary<eSourceListItemDestinationTypes, IRoutingSink> Displays { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// For rooms with routing
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ namespace PepperDash.Essentials.Core.Routing
|
|||
/// <summary>
|
||||
/// The current sources for the room, keyed by eRoutingSignalType.
|
||||
/// This allows for multiple sources to be tracked, such as audio and video.
|
||||
/// Intended to be implemented on a DestinationListItem to provide access to the current sources for the room in its context.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This interface is used to provide access to the current sources in a room,
|
||||
|
|
@ -17,7 +18,7 @@ namespace PepperDash.Essentials.Core.Routing
|
|||
/// Gets the current sources for the room, keyed by eRoutingSignalType.
|
||||
/// This dictionary contains the current source for each signal type, such as audio, video, and control signals.
|
||||
/// </summary>
|
||||
Dictionary<eRoutingSignalType, SourceListItem> CurrentSources { get; }
|
||||
Dictionary<eRoutingSignalType, IRoutingSource> CurrentSources { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current source keys for the room, keyed by eRoutingSignalType.
|
||||
|
|
@ -28,16 +29,51 @@ namespace PepperDash.Essentials.Core.Routing
|
|||
/// <summary>
|
||||
/// Event raised when the current sources change.
|
||||
/// </summary>
|
||||
event EventHandler CurrentSourcesChanged;
|
||||
event EventHandler<CurrentSourcesChangedEventArgs> CurrentSourcesChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Sets the current source for a specific signal type.
|
||||
/// This method updates the current source for the specified signal type and notifies any subscribers of the change.
|
||||
/// </summary>
|
||||
/// <param name="signalType">The signal type to update.</param>
|
||||
/// <param name="sourceListKey">The key for the source list.</param>
|
||||
/// <param name="sourceListItem">The source list item to set as the current source.</param>
|
||||
void SetCurrentSource(eRoutingSignalType signalType, string sourceListKey, SourceListItem sourceListItem);
|
||||
/// <param name="sourceDevice">The source device to set as the current source.</param>
|
||||
void SetCurrentSource(eRoutingSignalType signalType, IRoutingSource sourceDevice);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Event arguments for the CurrentSourcesChanged event, providing details about the signal type and the previous and new sources.
|
||||
/// </summary>
|
||||
public class CurrentSourcesChangedEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the signal type for which the current source has changed.
|
||||
/// </summary>
|
||||
public eRoutingSignalType SignalType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the previous source for the signal type before the change occurred.
|
||||
/// </summary>
|
||||
public IRoutingSource PreviousSource { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the new source for the signal type after the change occurred.
|
||||
/// </summary>
|
||||
public IRoutingSource NewSource { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the CurrentSourcesChangedEventArgs class with the specified signal type, previous source, and new source.
|
||||
/// </summary>
|
||||
/// <param name="signalType">The signal type for which the current source has changed.</param>
|
||||
/// <param name="previousSource">The previous source for the signal type before the change occurred.</param>
|
||||
/// <param name="newSource">The new source for the signal type after the change occurred.</param>
|
||||
public CurrentSourcesChangedEventArgs(eRoutingSignalType signalType, IRoutingSource previousSource, IRoutingSource newSource)
|
||||
{
|
||||
SignalType = signalType;
|
||||
PreviousSource = previousSource;
|
||||
NewSource = newSource;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
using PepperDash.Core;
|
||||
using Newtonsoft.Json;
|
||||
using PepperDash.Core;
|
||||
|
||||
|
||||
namespace PepperDash.Essentials.Core;
|
||||
|
|
@ -11,6 +12,7 @@ public interface IRoutingOutputs : IKeyed
|
|||
/// <summary>
|
||||
/// Collection of Output Ports
|
||||
/// </summary>
|
||||
[JsonProperty("outputPorts")]
|
||||
RoutingPortCollection<RoutingOutputPort> OutputPorts { get; }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core.Routing;
|
||||
|
||||
namespace PepperDash.Essentials.Core;
|
||||
|
|
@ -5,7 +6,7 @@ namespace PepperDash.Essentials.Core;
|
|||
/// <summary>
|
||||
/// Defines the contract for IRoutingSink
|
||||
/// </summary>
|
||||
public interface IRoutingSink : IRoutingInputs, IHasCurrentSourceInfoChange
|
||||
public interface IRoutingSink : IRoutingInputs, IKeyName, ICurrentSources
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -20,10 +21,4 @@ public interface IRoutingSinkWithInputPort : IRoutingSink
|
|||
RoutingInputPort CurrentInputPort { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Interface for routing sinks that have access to the current source information.
|
||||
/// </summary>
|
||||
public interface IRoutingSinkWithCurrentSources : IRoutingSink, ICurrentSources
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,8 +5,9 @@
|
|||
/// <summary>
|
||||
/// Defines the contract for IRoutingSinkWithFeedback
|
||||
/// </summary>
|
||||
public interface IRoutingSinkWithFeedback : IRoutingSinkWithSwitching
|
||||
public interface IRoutingSinkWithFeedback : IRoutingSink
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
namespace PepperDash.Essentials.Core;
|
||||
using PepperDash.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Marker interface to identify a device that acts as the origin of a signal path (<see cref="IRoutingOutputs"/>).
|
||||
/// </summary>
|
||||
public interface IRoutingSource : IRoutingOutputs
|
||||
public interface IRoutingSource : IRoutingOutputs, IKeyName
|
||||
{
|
||||
}
|
||||
|
|
@ -59,7 +59,7 @@ public class RoutingFeedbackManager: EssentialsDevice
|
|||
{
|
||||
try
|
||||
{
|
||||
var devices = DeviceManager.AllDevices.OfType<IRoutingSinkWithSwitchingWithInputPort>();
|
||||
var devices = DeviceManager.AllDevices.OfType<IRoutingSinkWithInputPort>();
|
||||
|
||||
foreach (var device in devices)
|
||||
{
|
||||
|
|
@ -96,7 +96,7 @@ public class RoutingFeedbackManager: EssentialsDevice
|
|||
/// </summary>
|
||||
/// <param name="destination">The destination sink device to update.</param>
|
||||
/// <param name="inputPort">The currently selected input port on the destination device.</param>
|
||||
private void UpdateDestination(IRoutingSinkWithSwitching destination, RoutingInputPort inputPort)
|
||||
private void UpdateDestination(IRoutingSink destination, RoutingInputPort inputPort)
|
||||
{
|
||||
// Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, "Updating destination {destination} with inputPort {inputPort}", this,destination?.Key, inputPort?.Key);
|
||||
|
||||
|
|
@ -116,19 +116,10 @@ public class RoutingFeedbackManager: EssentialsDevice
|
|||
if (firstTieLine == null)
|
||||
{
|
||||
Debug.LogMessage(Serilog.Events.LogEventLevel.Information, "No tieline found for inputPort {inputPort}. Clearing current source", this, inputPort);
|
||||
|
||||
var tempSourceListItem = new SourceListItem
|
||||
{
|
||||
SourceKey = "$transient",
|
||||
Name = inputPort.Key,
|
||||
};
|
||||
|
||||
|
||||
destination.CurrentSourceInfo = tempSourceListItem; ;
|
||||
destination.CurrentSourceInfoKey = "$transient";
|
||||
return;
|
||||
}
|
||||
} catch (Exception ex)
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogMessage(ex, "Error getting first tieline: {Exception}", this, ex);
|
||||
return;
|
||||
|
|
@ -136,6 +127,7 @@ public class RoutingFeedbackManager: EssentialsDevice
|
|||
|
||||
// Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, "Getting source for first TieLine {tieLine}", this, firstTieLine);
|
||||
|
||||
|
||||
TieLine sourceTieLine;
|
||||
try
|
||||
{
|
||||
|
|
@ -145,91 +137,34 @@ public class RoutingFeedbackManager: EssentialsDevice
|
|||
{
|
||||
Debug.LogMessage(Serilog.Events.LogEventLevel.Information, "No route found to source for inputPort {inputPort}. Clearing current source", this, inputPort);
|
||||
|
||||
var tempSourceListItem = new SourceListItem
|
||||
{
|
||||
SourceKey = "$transient",
|
||||
Name = "None",
|
||||
};
|
||||
|
||||
destination.CurrentSourceInfo = tempSourceListItem;
|
||||
destination.CurrentSourceInfoKey = string.Empty;
|
||||
destination.SetCurrentSource(sourceTieLine.Type, null);
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
} catch(Exception ex)
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogMessage(ex, "Error getting sourceTieLine: {Exception}", this, ex);
|
||||
return;
|
||||
}
|
||||
|
||||
// Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, "Found root TieLine {tieLine}", this, sourceTieLine);
|
||||
|
||||
// Does not handle combinable scenarios or other scenarios where a display might be part of multiple rooms yet.
|
||||
var room = DeviceManager.AllDevices.OfType<IEssentialsRoom>().FirstOrDefault((r) => {
|
||||
if(r is IHasMultipleDisplays roomMultipleDisplays)
|
||||
{
|
||||
return roomMultipleDisplays.Displays.Any(d => d.Value.Key == destination.Key);
|
||||
}
|
||||
|
||||
if(r is IHasDefaultDisplay roomDefaultDisplay)
|
||||
{
|
||||
return roomDefaultDisplay.DefaultDisplay.Key == destination.Key;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
if(room == null)
|
||||
{
|
||||
Debug.LogMessage(Serilog.Events.LogEventLevel.Warning, "No room found for display {destination}", this, destination.Key);
|
||||
return;
|
||||
}
|
||||
|
||||
// Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, "Found room {room} for destination {destination}", this, room.Key, destination.Key);
|
||||
|
||||
var sourceList = ConfigReader.ConfigObject.GetSourceListForKey(room.SourceListKey);
|
||||
|
||||
if (sourceList == null)
|
||||
{
|
||||
Debug.LogMessage(Serilog.Events.LogEventLevel.Warning, "No source list found for source list key {key}. Unable to find source for tieLine {sourceTieLine}", this, room.SourceListKey, sourceTieLine);
|
||||
return;
|
||||
}
|
||||
|
||||
// Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, "Found sourceList for room {room}", this, room.Key);
|
||||
|
||||
var sourceListItem = sourceList.FirstOrDefault(sli => {
|
||||
//// Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose,
|
||||
// "SourceListItem {sourceListItem}:{sourceKey} tieLine sourceport device key {sourcePortDeviceKey}",
|
||||
// this,
|
||||
// sli.Key,
|
||||
// sli.Value.SourceKey,
|
||||
// sourceTieLine.SourcePort.ParentDevice.Key);
|
||||
|
||||
return sli.Value.SourceKey.Equals(sourceTieLine.SourcePort.ParentDevice.Key,StringComparison.InvariantCultureIgnoreCase);
|
||||
});
|
||||
|
||||
var source = sourceListItem.Value;
|
||||
var sourceKey = sourceListItem.Key;
|
||||
|
||||
if (source == null)
|
||||
if (sourceTieLine.SourcePort.ParentDevice == null)
|
||||
{
|
||||
Debug.LogMessage(Serilog.Events.LogEventLevel.Information, "No source found for device {key}. Creating transient source for {destination}", this, sourceTieLine.SourcePort.ParentDevice.Key, destination);
|
||||
|
||||
var tempSourceListItem = new SourceListItem
|
||||
{
|
||||
SourceKey = "$transient",
|
||||
Name = sourceTieLine.SourcePort.Key,
|
||||
};
|
||||
destination.SetCurrentSource(sourceTieLine.Type, null);
|
||||
|
||||
destination.CurrentSourceInfoKey = "$transient";
|
||||
destination.CurrentSourceInfo = tempSourceListItem;
|
||||
return;
|
||||
}
|
||||
|
||||
//Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, "Got Source {@source} with key {sourceKey}", this, source, sourceKey);
|
||||
|
||||
destination.CurrentSourceInfoKey = sourceKey;
|
||||
destination.CurrentSourceInfo = source;
|
||||
|
||||
if (sourceTieLine.SourcePort.ParentDevice is IRoutingSource sourceDevice)
|
||||
{
|
||||
destination.SetCurrentSource(sourceTieLine.Type, sourceDevice);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -255,7 +190,8 @@ public class RoutingFeedbackManager: EssentialsDevice
|
|||
return null;
|
||||
}
|
||||
|
||||
var currentRoute = midpoint.CurrentRoutes.FirstOrDefault(route => {
|
||||
var currentRoute = midpoint.CurrentRoutes.FirstOrDefault(route =>
|
||||
{
|
||||
//Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, "Checking {route} against {tieLine}", this, route, tieLine);
|
||||
|
||||
return route.OutputPort != null && route.InputPort != null && route.OutputPort?.Key == tieLine.SourcePort.Key && route.OutputPort?.ParentDevice.Key == tieLine.SourcePort.ParentDevice.Key;
|
||||
|
|
@ -269,9 +205,11 @@ public class RoutingFeedbackManager: EssentialsDevice
|
|||
|
||||
//Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, "Found currentRoute {currentRoute} through {midpoint}", this, currentRoute, midpoint);
|
||||
|
||||
nextTieLine = TieLineCollection.Default.FirstOrDefault(tl => {
|
||||
nextTieLine = TieLineCollection.Default.FirstOrDefault(tl =>
|
||||
{
|
||||
//Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, "Checking {route} against {tieLine}", tl.DestinationPort.Key, currentRoute.InputPort.Key);
|
||||
return tl.DestinationPort.Key == currentRoute.InputPort.Key && tl.DestinationPort.ParentDevice.Key == currentRoute.InputPort.ParentDevice.Key; });
|
||||
return tl.DestinationPort.Key == currentRoute.InputPort.Key && tl.DestinationPort.ParentDevice.Key == currentRoute.InputPort.ParentDevice.Key;
|
||||
});
|
||||
|
||||
if (nextTieLine != null)
|
||||
{
|
||||
|
|
@ -298,7 +236,8 @@ public class RoutingFeedbackManager: EssentialsDevice
|
|||
{
|
||||
return GetRootTieLine(nextTieLine);
|
||||
}
|
||||
} catch (Exception ex)
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogMessage(ex, "Error walking tieLines: {Exception}", this, ex);
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Core.Logging;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
|
||||
using PepperDash.Essentials.Core.Routing;
|
||||
using Serilog.Events;
|
||||
|
||||
namespace PepperDash.Essentials.Devices.Common;
|
||||
|
|
@ -13,33 +14,19 @@ namespace PepperDash.Essentials.Devices.Common;
|
|||
/// </summary>
|
||||
public class GenericAudioOut : EssentialsDevice, IRoutingSink
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public RoutingInputPort CurrentInputPort => AnyAudioIn;
|
||||
|
||||
public event SourceInfoChangeHandler CurrentSourceChange;
|
||||
|
||||
public string CurrentSourceInfoKey { get; set; }
|
||||
public SourceListItem CurrentSourceInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
return _CurrentSourceInfo;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == _CurrentSourceInfo) return;
|
||||
/// <inheritdoc/>
|
||||
public Dictionary<eRoutingSignalType, IRoutingSource> CurrentSources { get; private set; }
|
||||
|
||||
var handler = CurrentSourceChange;
|
||||
/// <inheritdoc/>
|
||||
public Dictionary<eRoutingSignalType, string> CurrentSourceKeys { get; private set; }
|
||||
|
||||
if (handler != null)
|
||||
handler(_CurrentSourceInfo, ChangeType.WillChange);
|
||||
/// <inheritdoc />
|
||||
public event System.EventHandler<CurrentSourcesChangedEventArgs> CurrentSourcesChanged;
|
||||
|
||||
_CurrentSourceInfo = value;
|
||||
|
||||
if (handler != null)
|
||||
handler(_CurrentSourceInfo, ChangeType.DidChange);
|
||||
}
|
||||
}
|
||||
SourceListItem _CurrentSourceInfo;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the AnyAudioIn
|
||||
|
|
@ -56,6 +43,66 @@ public class GenericAudioOut : EssentialsDevice, IRoutingSink
|
|||
{
|
||||
AnyAudioIn = new RoutingInputPort(RoutingPortNames.AnyAudioIn, eRoutingSignalType.Audio,
|
||||
eRoutingPortConnectionType.LineAudio, null, this);
|
||||
|
||||
CurrentSources = new Dictionary<eRoutingSignalType, IRoutingSource>
|
||||
{
|
||||
{ eRoutingSignalType.Audio, null },
|
||||
};
|
||||
|
||||
CurrentSourceKeys = new Dictionary<eRoutingSignalType, string>
|
||||
{
|
||||
{ eRoutingSignalType.Audio, string.Empty },
|
||||
};
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual void SetCurrentSource(eRoutingSignalType signalType, IRoutingSource sourceDevice)
|
||||
{
|
||||
foreach (eRoutingSignalType type in System.Enum.GetValues(typeof(eRoutingSignalType)))
|
||||
{
|
||||
var flagValue = System.Convert.ToInt32(type);
|
||||
// Skip if flagValue is 0 or not a power of two (i.e., not a single-bit flag).
|
||||
// (flagValue & (flagValue - 1)) != 0 checks if more than one bit is set.
|
||||
if (flagValue == 0 || (flagValue & (flagValue - 1)) != 0)
|
||||
{
|
||||
this.LogDebug("Skipping {type}", type);
|
||||
continue;
|
||||
}
|
||||
|
||||
this.LogDebug("setting {type}", type);
|
||||
|
||||
var previousSource = CurrentSources[type];
|
||||
|
||||
if (signalType.HasFlag(type))
|
||||
{
|
||||
UpdateCurrentSources(type, previousSource, sourceDevice);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateCurrentSources(eRoutingSignalType signalType, IRoutingSource previousSource, IRoutingSource sourceDevice)
|
||||
{
|
||||
if (CurrentSources.ContainsKey(signalType))
|
||||
{
|
||||
CurrentSources[signalType] = sourceDevice;
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentSources.Add(signalType, sourceDevice);
|
||||
}
|
||||
|
||||
// Update the current source key for the specified signal type
|
||||
if (CurrentSourceKeys.ContainsKey(signalType))
|
||||
{
|
||||
CurrentSourceKeys[signalType] = sourceDevice.Key;
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentSourceKeys.Add(signalType, sourceDevice.Key);
|
||||
}
|
||||
|
||||
// Raise the CurrentSourcesChanged event
|
||||
CurrentSourcesChanged?.Invoke(this, new CurrentSourcesChangedEventArgs(signalType, previousSource, sourceDevice));
|
||||
}
|
||||
|
||||
#region IRoutingInputs Members
|
||||
|
|
@ -116,13 +163,20 @@ public class GenericAudioOutWithVolume : GenericAudioOut, IHasVolumeDevice
|
|||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Factory for creating GenericAudioOutWithVolume devices
|
||||
/// </summary>
|
||||
public class GenericAudioOutWithVolumeFactory : EssentialsDeviceFactory<GenericAudioOutWithVolume>
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor for GenericAudioOutWithVolumeFactory
|
||||
/// </summary>
|
||||
public GenericAudioOutWithVolumeFactory()
|
||||
{
|
||||
TypeNames = new List<string>() { "genericaudiooutwithvolume" };
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
||||
{
|
||||
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new GenericAudioOutWithVolumeFactory Device");
|
||||
|
|
|
|||
|
|
@ -48,48 +48,20 @@ public abstract class DisplayBase : EssentialsDevice, IDisplay, ICurrentSources,
|
|||
/// </summary>
|
||||
public event InputChangedEventHandler InputChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Event that is raised when the current source information changes.
|
||||
/// </summary>
|
||||
public event SourceInfoChangeHandler CurrentSourceChange;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the CurrentSourceInfoKey
|
||||
/// </summary>
|
||||
public string CurrentSourceInfoKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the current source information for the display.
|
||||
/// </summary>
|
||||
public SourceListItem CurrentSourceInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
return _CurrentSourceInfo;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == _CurrentSourceInfo) return;
|
||||
|
||||
var handler = CurrentSourceChange;
|
||||
|
||||
handler?.Invoke(_CurrentSourceInfo, ChangeType.WillChange);
|
||||
|
||||
_CurrentSourceInfo = value;
|
||||
|
||||
handler?.Invoke(_CurrentSourceInfo, ChangeType.DidChange);
|
||||
}
|
||||
}
|
||||
SourceListItem _CurrentSourceInfo;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Dictionary<eRoutingSignalType, SourceListItem> CurrentSources { get; private set; }
|
||||
public Dictionary<eRoutingSignalType, IRoutingSource> CurrentSources { get; private set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Dictionary<eRoutingSignalType, string> CurrentSourceKeys { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public event EventHandler CurrentSourcesChanged;
|
||||
public event EventHandler<CurrentSourcesChangedEventArgs> CurrentSourcesChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Gets feedback indicating whether the display is currently cooling down after being powered off.
|
||||
|
|
@ -163,7 +135,7 @@ public abstract class DisplayBase : EssentialsDevice, IDisplay, ICurrentSources,
|
|||
|
||||
InputPorts = new RoutingPortCollection<RoutingInputPort>();
|
||||
|
||||
CurrentSources = new Dictionary<eRoutingSignalType, SourceListItem>
|
||||
CurrentSources = new Dictionary<eRoutingSignalType, IRoutingSource>
|
||||
{
|
||||
{ eRoutingSignalType.Audio, null },
|
||||
{ eRoutingSignalType.Video, null },
|
||||
|
|
@ -388,7 +360,7 @@ public abstract class DisplayBase : EssentialsDevice, IDisplay, ICurrentSources,
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual void SetCurrentSource(eRoutingSignalType signalType, string sourceListKey, SourceListItem sourceListItem)
|
||||
public virtual void SetCurrentSource(eRoutingSignalType signalType, IRoutingSource sourceDevice)
|
||||
{
|
||||
foreach (eRoutingSignalType type in Enum.GetValues(typeof(eRoutingSignalType)))
|
||||
{
|
||||
|
|
@ -403,35 +375,38 @@ public abstract class DisplayBase : EssentialsDevice, IDisplay, ICurrentSources,
|
|||
|
||||
this.LogDebug("setting {type}", type);
|
||||
|
||||
var previousSource = CurrentSources[type];
|
||||
|
||||
if (signalType.HasFlag(type))
|
||||
{
|
||||
UpdateCurrentSources(type, sourceListKey, sourceListItem);
|
||||
UpdateCurrentSources(type, previousSource, sourceDevice);
|
||||
}
|
||||
}
|
||||
// Raise the CurrentSourcesChanged event
|
||||
CurrentSourcesChanged?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
private void UpdateCurrentSources(eRoutingSignalType signalType, string sourceListKey, SourceListItem sourceListItem)
|
||||
private void UpdateCurrentSources(eRoutingSignalType signalType, IRoutingSource previousSource, IRoutingSource sourceDevice)
|
||||
{
|
||||
if (CurrentSources.ContainsKey(signalType))
|
||||
{
|
||||
CurrentSources[signalType] = sourceListItem;
|
||||
CurrentSources[signalType] = sourceDevice;
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentSources.Add(signalType, sourceListItem);
|
||||
CurrentSources.Add(signalType, sourceDevice);
|
||||
}
|
||||
|
||||
// Update the current source key for the specified signal type
|
||||
if (CurrentSourceKeys.ContainsKey(signalType))
|
||||
{
|
||||
CurrentSourceKeys[signalType] = sourceListKey;
|
||||
CurrentSourceKeys[signalType] = sourceDevice.Key;
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentSourceKeys.Add(signalType, sourceListKey);
|
||||
CurrentSourceKeys.Add(signalType, sourceDevice.Key);
|
||||
}
|
||||
|
||||
// Raise the CurrentSourcesChanged event
|
||||
CurrentSourcesChanged?.Invoke(this, new CurrentSourcesChangedEventArgs(signalType, previousSource, sourceDevice));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,13 +15,13 @@ namespace PepperDash.Essentials.Devices.Common.Generic;
|
|||
public class GenericSink : EssentialsDevice, IRoutingSinkWithSwitchingWithInputPort, ICurrentSources
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public Dictionary<eRoutingSignalType, SourceListItem> CurrentSources { get; private set; }
|
||||
public Dictionary<eRoutingSignalType, IRoutingSource> CurrentSources { get; private set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Dictionary<eRoutingSignalType, string> CurrentSourceKeys { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public event EventHandler CurrentSourcesChanged;
|
||||
public event EventHandler<CurrentSourcesChangedEventArgs> CurrentSourcesChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the GenericSink class
|
||||
|
|
@ -36,7 +36,7 @@ public class GenericSink : EssentialsDevice, IRoutingSinkWithSwitchingWithInputP
|
|||
|
||||
InputPorts.Add(inputPort);
|
||||
|
||||
CurrentSources = new Dictionary<eRoutingSignalType, SourceListItem>
|
||||
CurrentSources = new Dictionary<eRoutingSignalType, IRoutingSource>
|
||||
{
|
||||
{ eRoutingSignalType.Audio, null },
|
||||
{ eRoutingSignalType.Video, null },
|
||||
|
|
@ -50,7 +50,7 @@ public class GenericSink : EssentialsDevice, IRoutingSinkWithSwitchingWithInputP
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void SetCurrentSource(eRoutingSignalType signalType, string sourceListKey, SourceListItem sourceListItem)
|
||||
public virtual void SetCurrentSource(eRoutingSignalType signalType, IRoutingSource sourceDevice)
|
||||
{
|
||||
foreach (eRoutingSignalType type in Enum.GetValues(typeof(eRoutingSignalType)))
|
||||
{
|
||||
|
|
@ -65,19 +65,38 @@ public class GenericSink : EssentialsDevice, IRoutingSinkWithSwitchingWithInputP
|
|||
|
||||
this.LogDebug("setting {type}", type);
|
||||
|
||||
var previousSource = CurrentSources[type];
|
||||
|
||||
if (signalType.HasFlag(type))
|
||||
{
|
||||
UpdateCurrentSources(type, sourceListKey, sourceListItem);
|
||||
UpdateCurrentSources(type, previousSource, sourceDevice);
|
||||
}
|
||||
}
|
||||
// Raise the CurrentSourcesChanged event
|
||||
CurrentSourcesChanged?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
private void UpdateCurrentSources(eRoutingSignalType signalType, string sourceListKey, SourceListItem sourceListItem)
|
||||
private void UpdateCurrentSources(eRoutingSignalType signalType, IRoutingSource previousSource, IRoutingSource sourceDevice)
|
||||
{
|
||||
CurrentSources[signalType] = sourceListItem;
|
||||
CurrentSourceKeys[signalType] = sourceListKey;
|
||||
if (CurrentSources.ContainsKey(signalType))
|
||||
{
|
||||
CurrentSources[signalType] = sourceDevice;
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentSources.Add(signalType, sourceDevice);
|
||||
}
|
||||
|
||||
// Update the current source key for the specified signal type
|
||||
if (CurrentSourceKeys.ContainsKey(signalType))
|
||||
{
|
||||
CurrentSourceKeys[signalType] = sourceDevice.Key;
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentSourceKeys.Add(signalType, sourceDevice.Key);
|
||||
}
|
||||
|
||||
// Raise the CurrentSourcesChanged event
|
||||
CurrentSourcesChanged?.Invoke(this, new CurrentSourcesChangedEventArgs(signalType, previousSource, sourceDevice));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Core.Logging;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
using PepperDash.Essentials.Core.Routing;
|
||||
using PepperDash.Essentials.Devices.Common.Sources;
|
||||
using Serilog.Events;
|
||||
|
||||
|
|
@ -26,6 +29,15 @@ public class BlueJeansPc : InRoomPc, IRunRouteAction, IRoutingSink
|
|||
/// </summary>
|
||||
public RoutingInputPort CurrentInputPort => AnyVideoIn;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Dictionary<eRoutingSignalType, IRoutingSource> CurrentSources { get; private set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Dictionary<eRoutingSignalType, string> CurrentSourceKeys { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public event EventHandler<CurrentSourcesChangedEventArgs> CurrentSourcesChanged;
|
||||
|
||||
#region IRoutingInputs Members
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -47,6 +59,68 @@ public class BlueJeansPc : InRoomPc, IRunRouteAction, IRoutingSink
|
|||
{
|
||||
(AnyVideoIn = new RoutingInputPort(RoutingPortNames.AnyVideoIn, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.None, 0, this))
|
||||
};
|
||||
|
||||
CurrentSources = new Dictionary<eRoutingSignalType, IRoutingSource>
|
||||
{
|
||||
{ eRoutingSignalType.Audio, null },
|
||||
{ eRoutingSignalType.Video, null },
|
||||
};
|
||||
|
||||
CurrentSourceKeys = new Dictionary<eRoutingSignalType, string>
|
||||
{
|
||||
{ eRoutingSignalType.Audio, string.Empty },
|
||||
{ eRoutingSignalType.Video, string.Empty },
|
||||
};
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual void SetCurrentSource(eRoutingSignalType signalType, IRoutingSource sourceDevice)
|
||||
{
|
||||
foreach (eRoutingSignalType type in Enum.GetValues(typeof(eRoutingSignalType)))
|
||||
{
|
||||
var flagValue = Convert.ToInt32(type);
|
||||
// Skip if flagValue is 0 or not a power of two (i.e., not a single-bit flag).
|
||||
// (flagValue & (flagValue - 1)) != 0 checks if more than one bit is set.
|
||||
if (flagValue == 0 || (flagValue & (flagValue - 1)) != 0)
|
||||
{
|
||||
this.LogDebug("Skipping {type}", type);
|
||||
continue;
|
||||
}
|
||||
|
||||
this.LogDebug("setting {type}", type);
|
||||
|
||||
var previousSource = CurrentSources[type];
|
||||
|
||||
if (signalType.HasFlag(type))
|
||||
{
|
||||
UpdateCurrentSources(type, previousSource, sourceDevice);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateCurrentSources(eRoutingSignalType signalType, IRoutingSource previousSource, IRoutingSource sourceDevice)
|
||||
{
|
||||
if (CurrentSources.ContainsKey(signalType))
|
||||
{
|
||||
CurrentSources[signalType] = sourceDevice;
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentSources.Add(signalType, sourceDevice);
|
||||
}
|
||||
|
||||
// Update the current source key for the specified signal type
|
||||
if (CurrentSourceKeys.ContainsKey(signalType))
|
||||
{
|
||||
CurrentSourceKeys[signalType] = sourceDevice.Key;
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentSourceKeys.Add(signalType, sourceDevice.Key);
|
||||
}
|
||||
|
||||
// Raise the CurrentSourcesChanged event
|
||||
CurrentSourcesChanged?.Invoke(this, new CurrentSourcesChangedEventArgs(signalType, previousSource, sourceDevice));
|
||||
}
|
||||
|
||||
#region IRunRouteAction Members
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Core.Logging;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.Core.Routing;
|
||||
using Serilog.Events;
|
||||
|
||||
namespace PepperDash.Essentials.Devices.Common.SoftCodec;
|
||||
|
|
@ -27,6 +30,15 @@ public class GenericSoftCodec : EssentialsDevice, IRoutingSource, IRoutingSinkWi
|
|||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Dictionary<eRoutingSignalType, IRoutingSource> CurrentSources { get; private set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Dictionary<eRoutingSignalType, string> CurrentSourceKeys { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public event System.EventHandler<CurrentSourcesChangedEventArgs> CurrentSourcesChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GenericSoftCodec"/> class
|
||||
/// </summary>
|
||||
|
|
@ -49,6 +61,18 @@ public class GenericSoftCodec : EssentialsDevice, IRoutingSource, IRoutingSinkWi
|
|||
InputPorts.Add(inputPort);
|
||||
}
|
||||
|
||||
CurrentSources = new Dictionary<eRoutingSignalType, IRoutingSource>
|
||||
{
|
||||
{ eRoutingSignalType.Audio, null },
|
||||
{ eRoutingSignalType.Video, null },
|
||||
};
|
||||
|
||||
CurrentSourceKeys = new Dictionary<eRoutingSignalType, string>
|
||||
{
|
||||
{ eRoutingSignalType.Audio, string.Empty },
|
||||
{ eRoutingSignalType.Video, string.Empty },
|
||||
};
|
||||
|
||||
if (!props.HasCameraInputs)
|
||||
{
|
||||
return;
|
||||
|
|
@ -62,6 +86,56 @@ public class GenericSoftCodec : EssentialsDevice, IRoutingSource, IRoutingSinkWi
|
|||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual void SetCurrentSource(eRoutingSignalType signalType, IRoutingSource sourceDevice)
|
||||
{
|
||||
foreach (eRoutingSignalType type in System.Enum.GetValues(typeof(eRoutingSignalType)))
|
||||
{
|
||||
var flagValue = System.Convert.ToInt32(type);
|
||||
// Skip if flagValue is 0 or not a power of two (i.e., not a single-bit flag).
|
||||
// (flagValue & (flagValue - 1)) != 0 checks if more than one bit is set.
|
||||
if (flagValue == 0 || (flagValue & (flagValue - 1)) != 0)
|
||||
{
|
||||
this.LogDebug("Skipping {type}", type);
|
||||
continue;
|
||||
}
|
||||
|
||||
this.LogDebug("setting {type}", type);
|
||||
|
||||
var previousSource = CurrentSources[type];
|
||||
|
||||
if (signalType.HasFlag(type))
|
||||
{
|
||||
UpdateCurrentSources(type, previousSource, sourceDevice);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateCurrentSources(eRoutingSignalType signalType, IRoutingSource previousSource, IRoutingSource sourceDevice)
|
||||
{
|
||||
if (CurrentSources.ContainsKey(signalType))
|
||||
{
|
||||
CurrentSources[signalType] = sourceDevice;
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentSources.Add(signalType, sourceDevice);
|
||||
}
|
||||
|
||||
// Update the current source key for the specified signal type
|
||||
if (CurrentSourceKeys.ContainsKey(signalType))
|
||||
{
|
||||
CurrentSourceKeys[signalType] = sourceDevice.Key;
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentSourceKeys.Add(signalType, sourceDevice.Key);
|
||||
}
|
||||
|
||||
// Raise the CurrentSourcesChanged event
|
||||
CurrentSourcesChanged?.Invoke(this, new CurrentSourcesChangedEventArgs(signalType, previousSource, sourceDevice));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the InputPorts
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -69,7 +69,6 @@ namespace PepperDash.Essentials.AppServer.Messengers
|
|||
/// </summary>
|
||||
public class CurrentSourcesStateMessage : DeviceStateMessageBase
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the CurrentSourceKey
|
||||
/// </summary>
|
||||
|
|
@ -81,6 +80,6 @@ namespace PepperDash.Essentials.AppServer.Messengers
|
|||
/// Gets or sets the CurrentSource
|
||||
/// </summary>
|
||||
[JsonProperty("currentSources")]
|
||||
public Dictionary<eRoutingSignalType, SourceListItem> CurrentSources { get; set; }
|
||||
public Dictionary<eRoutingSignalType, IRoutingSource> CurrentSources { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Core.Logging;
|
||||
using PepperDash.Essentials.Core;
|
||||
|
||||
|
||||
|
|
@ -17,29 +15,22 @@ namespace PepperDash.Essentials.AppServer.Messengers
|
|||
/// </summary>
|
||||
public IRunRouteAction RoutingDevice { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the RunRouteActionMessenger class
|
||||
/// </summary>
|
||||
/// <param name="key">The key.</param>
|
||||
/// <param name="routingDevice">The routing device.</param>
|
||||
/// <param name="messagePath">The message path.</param>
|
||||
/// <exception cref="ArgumentNullException"></exception>
|
||||
public RunRouteActionMessenger(string key, IRunRouteAction routingDevice, string messagePath)
|
||||
: base(key, messagePath, routingDevice as IKeyName)
|
||||
{
|
||||
RoutingDevice = routingDevice ?? throw new ArgumentNullException("routingDevice");
|
||||
|
||||
|
||||
if (RoutingDevice is IRoutingSink routingSink)
|
||||
{
|
||||
routingSink.CurrentSourceChange += RoutingSink_CurrentSourceChange;
|
||||
}
|
||||
}
|
||||
|
||||
private void RoutingSink_CurrentSourceChange(SourceListItem info, ChangeType type)
|
||||
{
|
||||
SendRoutingFullMessageObject();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void RegisterActions()
|
||||
{
|
||||
AddAction("/fullStatus", (id, content) => SendRoutingFullMessageObject(id));
|
||||
|
||||
AddAction("/routingStatus", (id, content) => SendRoutingFullMessageObject(id));
|
||||
|
||||
AddAction("/source", (id, content) =>
|
||||
{
|
||||
var c = content.ToObject<SourceSelectMessageContent>();
|
||||
|
|
@ -55,41 +46,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
|
|||
RoutingDevice.RunRouteAction(c.SourceListItemKey, sourceListKey);
|
||||
});
|
||||
|
||||
if (RoutingDevice is IRoutingSink sinkDevice)
|
||||
{
|
||||
sinkDevice.CurrentSourceChange += (o, a) => SendRoutingFullMessageObject();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper method to update full status of the routing device
|
||||
/// </summary>
|
||||
private void SendRoutingFullMessageObject(string id = null)
|
||||
{
|
||||
if (RoutingDevice is IRoutingSink sinkDevice)
|
||||
{
|
||||
var sourceKey = sinkDevice.CurrentSourceInfoKey;
|
||||
|
||||
if (string.IsNullOrEmpty(sourceKey))
|
||||
sourceKey = "none";
|
||||
|
||||
PostStatusMessage(new RoutingStateMessage
|
||||
{
|
||||
SelectedSourceKey = sourceKey
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a RoutingStateMessage
|
||||
/// </summary>
|
||||
public class RoutingStateMessage : DeviceStateMessageBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the SelectedSourceKey
|
||||
/// </summary>
|
||||
[JsonProperty("selectedSourceKey")]
|
||||
public string SelectedSourceKey { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -719,29 +719,6 @@ namespace PepperDash.Essentials.RoomBridges
|
|||
}
|
||||
}
|
||||
|
||||
if (room is IHasDefaultDisplay defDisplayRoom)
|
||||
{
|
||||
this.LogVerbose("Getting default display config");
|
||||
configuration.DefaultDisplayKey = defDisplayRoom.DefaultDisplay.Key;
|
||||
configuration.Destinations.Add(eSourceListItemDestinationTypes.defaultDisplay, defDisplayRoom.DefaultDisplay.Key);
|
||||
}
|
||||
|
||||
if (room is IHasMultipleDisplays multiDisplayRoom)
|
||||
{
|
||||
this.LogVerbose("Getting multiple display config");
|
||||
|
||||
if (multiDisplayRoom.Displays == null)
|
||||
{
|
||||
this.LogVerbose("Displays collection is null");
|
||||
}
|
||||
else
|
||||
{
|
||||
this.LogVerbose("Displays collection exists");
|
||||
|
||||
configuration.Destinations = multiDisplayRoom.Displays.ToDictionary(kv => kv.Key, kv => kv.Value.Key);
|
||||
}
|
||||
}
|
||||
|
||||
if (room is IHasAccessoryDevices accRoom)
|
||||
{
|
||||
Debug.LogMessage(Serilog.Events.LogEventLevel.Information, "Getting accessory devices config", this);
|
||||
|
|
@ -1015,13 +992,6 @@ namespace PepperDash.Essentials.RoomBridges
|
|||
[JsonProperty("defaultDisplayKey", NullValueHandling = NullValueHandling.Ignore)]
|
||||
public string DefaultDisplayKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the destinations dictionary keyed by destination type
|
||||
/// </summary>
|
||||
[JsonProperty("destinations", NullValueHandling = NullValueHandling.Ignore)]
|
||||
public Dictionary<eSourceListItemDestinationTypes, string> Destinations { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the EnvironmentalDevices
|
||||
/// </summary>
|
||||
|
|
@ -1106,7 +1076,6 @@ namespace PepperDash.Essentials.RoomBridges
|
|||
/// </summary>
|
||||
public RoomConfiguration()
|
||||
{
|
||||
Destinations = new Dictionary<eSourceListItemDestinationTypes, string>();
|
||||
EnvironmentalDevices = new List<EnvironmentalDeviceConfiguration>();
|
||||
SourceList = new Dictionary<string, SourceListItem>();
|
||||
TouchpanelKeys = new List<string>();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue