getting things working

This commit is contained in:
Andrew Welker
2020-07-17 13:48:03 -06:00
parent aede5355b7
commit d6a6791e7b
5 changed files with 204 additions and 94 deletions

View File

@@ -1,25 +1,85 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Crestron.SimplSharp;
using System.Linq;
using Crestron.SimplSharpPro;
using PepperDash.Core;
using PepperDash.Essentials;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Core.Devices.Codec;
using PepperDash.Essentials.Core.Devices.VideoCodec;
using PepperDash.Essentials.Core.PageManagers;
using PepperDash.Essentials.Core.Touchpanels.Keyboards;
using PepperDash.Essentials.UIDrivers;
using PepperDash.Essentials.UIDrivers.VC;
using PepperDash.Essentials.Core.Rooms.Config;
namespace PepperDashEssentials.UIDrivers.EssentialsDualDisplay
{
public class EssentialsDualDisplayPanelAvFunctionsDriver : EssentialsHuddleVtc1PanelAvFunctionsDriver
{
private EssentialsDualDisplayRoom _currentRoom;
private BoolInputSig _routeToggleVisibility;
private readonly BoolFeedback _sharingMode;
public EssentialsDualDisplayPanelAvFunctionsDriver(PanelDriverBase parent, CrestronTouchpanelPropertiesConfig config) : base(parent, config)
{
_routeToggleVisibility = parent.TriList.BooleanInput[UIBoolJoin.ToggleSharingModeVisible];
_sharingMode = new BoolFeedback(() => _currentRoom.VideoRoutingBehavior == EVideoBehavior.Advanced);
_sharingMode.LinkInputSig(parent.TriList.BooleanInput[UIBoolJoin.ToggleSharingModePress]);
}
#region Overrides of EssentialsHuddleVtc1PanelAvFunctionsDriver
protected override void SetupSourceList()
{
var inCall = _currentRoom.InCallFeedback.BoolValue;
var sourceLists = ConfigReader.ConfigObject.SourceLists;
if (!sourceLists.ContainsKey(_currentRoom.SourceListKey))
{
return;
}
var sourceList = sourceLists[_currentRoom.SourceListKey].OrderBy(kv => kv.Value.Order);
SourceStagingSrl.Clear();
uint i = 1;
foreach (var src in sourceList.Where(
src =>
src.Value.IncludeInSourceList && (inCall && !src.Value.DisableCodecSharing) &&
(CurrentMode != UiDisplayMode.Call && !src.Value.DisableCodecSharing)))
{
var source = src.Value;
var sourceKey = src.Key;
Debug.Console(1, "**** {0}, {1}, {2}, {3}, {4}", source.PreferredName, source.IncludeInSourceList,
source.DisableCodecSharing, inCall, CurrentMode);
var srlItem = new SubpageReferenceListSourceItem(i++, SourceStagingSrl, src.Value,
b => { if (!b) UiSelectSource(sourceKey); });
SourceStagingSrl.AddItem(srlItem);
srlItem.RegisterForSourceChange(_currentRoom);
}
}
private void RefreshRoom(EssentialsDualDisplayRoom room)
{
RefreshCurrentRoom(room);
_currentRoom = room;
_routeToggleVisibility.BoolValue = _currentRoom.RoomConfig.EnableVideoBehaviorToggle;
_sharingMode.FireUpdate();
}
private void UiSelectSource(string sourceKey)
{
if (_currentRoom.VideoRoutingBehavior == EVideoBehavior.Advanced)
{
_currentRoom.SelectSource(sourceKey, _currentRoom.SourceListKey);
return;
}
_currentRoom.RunRouteAction(sourceKey);
}
#endregion
}
}

View File

@@ -67,7 +67,7 @@ namespace PepperDash.Essentials
/// <summary>
/// Smart Object 3200
/// </summary>
private readonly SubpageReferenceList _sourceStagingSrl;
protected readonly SubpageReferenceList SourceStagingSrl;
private readonly CrestronTouchpanelPropertiesConfig _config;
@@ -86,7 +86,7 @@ namespace PepperDash.Essentials
/// <summary>
/// The mode showing. Presentation or call.
/// </summary>
private UiDisplayMode _currentMode = UiDisplayMode.Start;
protected UiDisplayMode CurrentMode = UiDisplayMode.Start;
/// <summary>
/// Current page manager running for a source
@@ -124,7 +124,7 @@ namespace PepperDash.Essentials
/// <summary>
/// The Video codec driver
/// </summary>
private EssentialsVideoCodecUiDriver _vcDriver;
protected EssentialsVideoCodecUiDriver VcDriver;
private EssentialsHuddleVtc1Room _currentRoom;
@@ -144,7 +144,7 @@ namespace PepperDash.Essentials
_stagingBarInterlock = new JoinedSigInterlock(TriList);
_callPagesInterlock = new JoinedSigInterlock(TriList);
_sourceStagingSrl = new SubpageReferenceList(TriList, UISmartObjectJoin.SourceStagingSRL, 3, 3, 3);
SourceStagingSrl = new SubpageReferenceList(TriList, UISmartObjectJoin.SourceStagingSRL, 3, 3, 3);
_activityFooterSrl = new SubpageReferenceList(TriList, UISmartObjectJoin.ActivityFooterSRL, 3, 3, 3);
_callButtonSig = _activityFooterSrl.BoolInputSig(2, 1);
@@ -272,7 +272,7 @@ namespace PepperDash.Essentials
/// </summary>
public void ActivityCallButtonPressed()
{
if (_vcDriver.IsVisible)
if (VcDriver.IsVisible)
{
return;
}
@@ -286,9 +286,9 @@ namespace PepperDash.Essentials
_currentSourcePageManager.Hide();
}
PowerOnFromCall();
_currentMode = UiDisplayMode.Call;
CurrentMode = UiDisplayMode.Call;
SetActivityFooterFeedbacks();
_vcDriver.Show();
VcDriver.Show();
}
/// <summary>
@@ -311,7 +311,7 @@ namespace PepperDash.Essentials
/// <param name="vcd"></param>
public void SetVideoCodecDriver(EssentialsVideoCodecUiDriver vcd)
{
_vcDriver = vcd;
VcDriver = vcd;
}
/// <summary>
@@ -553,7 +553,7 @@ namespace PepperDash.Essentials
/// <summary>
///
/// </summary>
private void HideNextMeetingPopup()
protected void HideNextMeetingPopup()
{
TriList.SetBool(UIBoolJoin.NextMeetingModalVisible, false);
}
@@ -669,9 +669,9 @@ namespace PepperDash.Essentials
/// </summary>
private void SetActivityFooterFeedbacks()
{
_callButtonSig.BoolValue = _currentMode == UiDisplayMode.Call
_callButtonSig.BoolValue = CurrentMode == UiDisplayMode.Call
&& CurrentRoom.ShutdownType == eShutdownType.None;
_shareButtonSig.BoolValue = _currentMode == UiDisplayMode.Presentation
_shareButtonSig.BoolValue = CurrentMode == UiDisplayMode.Presentation
&& CurrentRoom.ShutdownType == eShutdownType.None;
_endMeetingButtonSig.BoolValue = CurrentRoom.ShutdownType != eShutdownType.None;
}
@@ -679,12 +679,12 @@ namespace PepperDash.Essentials
/// <summary>
/// Attached to activity list share button
/// </summary>
private void ActivityShareButtonPressed()
protected virtual void ActivityShareButtonPressed()
{
SetupSourceList();
if (_vcDriver.IsVisible)
if (VcDriver.IsVisible)
{
_vcDriver.Hide();
VcDriver.Hide();
}
HideNextMeetingPopup();
TriList.SetBool(UIBoolJoin.StartPageVisible, false);
@@ -693,13 +693,10 @@ namespace PepperDash.Essentials
// Run default source when room is off and share is pressed
if (!CurrentRoom.OnFeedback.BoolValue)
{
if (!CurrentRoom.OnFeedback.BoolValue)
// If there's no default, show UI elements
if (!CurrentRoom.RunDefaultPresentRoute())
{
// If there's no default, show UI elements
if (!CurrentRoom.RunDefaultPresentRoute())
{
TriList.SetBool(UIBoolJoin.SelectASourceVisible, true);
}
TriList.SetBool(UIBoolJoin.SelectASourceVisible, true);
}
}
else // room is on show what's active or select a source if nothing is yet active
@@ -714,7 +711,7 @@ namespace PepperDash.Essentials
_currentSourcePageManager.Show();
}
}
_currentMode = UiDisplayMode.Presentation;
CurrentMode = UiDisplayMode.Presentation;
SetupSourceList();
SetActivityFooterFeedbacks();
}
@@ -810,7 +807,7 @@ namespace PepperDash.Essentials
private void UiSelectSource(string key)
{
// Run the route and when it calls back, show the source
CurrentRoom.RunRouteAction(key, () => { });
CurrentRoom.RunRouteAction(key);
}
/// <summary>
@@ -979,7 +976,7 @@ namespace PepperDash.Essentials
/// <summary>
/// Helper for property setter. Sets the panel to the given room, latching up all functionality
/// </summary>
private void RefreshCurrentRoom(EssentialsHuddleVtc1Room room)
protected void RefreshCurrentRoom(EssentialsHuddleVtc1Room room)
{
if (_currentRoom != null)
{
@@ -1112,46 +1109,48 @@ namespace PepperDash.Essentials
/// <summary>
///
/// </summary>
private void SetupSourceList()
protected virtual void SetupSourceList()
{
var inCall = _currentRoom.InCallFeedback.BoolValue;
var config = ConfigReader.ConfigObject.SourceLists;
if (config.ContainsKey(_currentRoom.SourceListKey))
if (!config.ContainsKey(_currentRoom.SourceListKey))
{
var srcList = config[_currentRoom.SourceListKey].OrderBy(kv => kv.Value.Order);
// Setup sources list
_sourceStagingSrl.Clear();
uint i = 1; // counter for UI list
foreach (var kvp in srcList)
{
var srcConfig = kvp.Value;
Debug.Console(1, "**** {0}, {1}, {2}, {3}, {4}", srcConfig.PreferredName,
srcConfig.IncludeInSourceList,
srcConfig.DisableCodecSharing, inCall, _currentMode);
// Skip sources marked as not included, and filter list of non-sharable sources when in call
// or on share screen
if (!srcConfig.IncludeInSourceList || (inCall && srcConfig.DisableCodecSharing)
|| _currentMode == UiDisplayMode.Call && srcConfig.DisableCodecSharing)
{
Debug.Console(1, "Skipping {0}", srcConfig.PreferredName);
continue;
}
var routeKey = kvp.Key;
var item = new SubpageReferenceListSourceItem(i++, _sourceStagingSrl, srcConfig,
b =>
{
if (!b)
{
UiSelectSource(routeKey);
}
});
_sourceStagingSrl.AddItem(item); // add to the SRL
item.RegisterForSourceChange(_currentRoom);
}
_sourceStagingSrl.Count = (ushort) (i - 1);
return;
}
var srcList = config[_currentRoom.SourceListKey].OrderBy(kv => kv.Value.Order);
// Setup sources list
SourceStagingSrl.Clear();
uint i = 1; // counter for UI list
foreach (var kvp in srcList)
{
var srcConfig = kvp.Value;
Debug.Console(1, "**** {0}, {1}, {2}, {3}, {4}", srcConfig.PreferredName,
srcConfig.IncludeInSourceList,
srcConfig.DisableCodecSharing, inCall, CurrentMode);
// Skip sources marked as not included, and filter list of non-sharable sources when in call
// or on share screen
if (!srcConfig.IncludeInSourceList || (inCall && srcConfig.DisableCodecSharing)
|| CurrentMode == UiDisplayMode.Call && srcConfig.DisableCodecSharing)
{
Debug.Console(1, "Skipping {0}", srcConfig.PreferredName);
continue;
}
var routeKey = kvp.Key;
var item = new SubpageReferenceListSourceItem(i++, SourceStagingSrl, srcConfig,
b =>
{
if (!b)
{
UiSelectSource(routeKey);
}
});
SourceStagingSrl.AddItem(item); // add to the SRL
item.RegisterForSourceChange(_currentRoom);
}
SourceStagingSrl.Count = (ushort) (i - 1);
}
/// <summary>
@@ -1286,10 +1285,10 @@ namespace PepperDash.Essentials
}
else
{
_currentMode = UiDisplayMode.Start;
if (_vcDriver.IsVisible)
CurrentMode = UiDisplayMode.Start;
if (VcDriver.IsVisible)
{
_vcDriver.Hide();
VcDriver.Hide();
}
SetupActivityFooterWhenRoomOff();
ShowLogo();
@@ -1399,7 +1398,7 @@ namespace PepperDash.Essentials
{
var routeInfo = CurrentRoom.CurrentSourceInfo;
// This will show off popup too
if (IsVisible && !_vcDriver.IsVisible)
if (IsVisible && !VcDriver.IsVisible)
{
ShowCurrentSource();
}

View File

@@ -1,4 +1,5 @@
using PepperDash.Core;
using Newtonsoft.Json.Converters;
using PepperDash.Core;
using Newtonsoft.Json;
namespace PepperDash.Essentials.Core.Rooms.Config
@@ -9,11 +10,15 @@ namespace PepperDash.Essentials.Core.Rooms.Config
public class EssentialsNDisplayRoomPropertiesConfig : EssentialsHuddleVtc1PropertiesConfig
{
[JsonProperty("defaultAudioBehavior")]
public string DefaultAudioBehavior { get; set; }
[JsonConverter(typeof(StringEnumConverter))]
public EAudioBehavior DefaultAudioBehavior { get; set; }
[JsonProperty("defaultVideoBehavior")]
public string DefaultVideoBehavior { get; set; }
[JsonConverter(typeof(StringEnumConverter))]
public EVideoBehavior DefaultVideoBehavior { get; set; }
[JsonProperty("destinationListKey")]
public string DestinationListKey { get; set; }
[JsonProperty("enableVideoBehaviorToggle")]
public bool EnableVideoBehaviorToggle { get; set; }
}
public class DisplayItem : IKeyName
@@ -21,4 +26,17 @@ namespace PepperDash.Essentials.Core.Rooms.Config
public string Key { get; set; }
public string Name { get; set; }
}
public enum EVideoBehavior
{
Basic,
Advanced
}
public enum EAudioBehavior
{
AudioFollowVideo,
ChooseAudioFromDisplay,
AudioFollowVideoWithDeroute
}
}

View File

@@ -474,41 +474,41 @@ namespace PepperDash.Essentials.Core
/// <summary>
///
/// </summary>
/// <param name="routeKey"></param>
public virtual void RunRouteAction(string routeKey)
/// <param name="sourceKey"></param>
public virtual void RunRouteAction(string sourceKey)
{
RunRouteAction(routeKey, String.Empty, () => { });
RunRouteAction(sourceKey, String.Empty, () => { });
}
/// <summary>
/// Gets a source from config list SourceListKey and dynamically build and executes the
/// route or commands
/// </summary>
public virtual void RunRouteAction(string routeKey, Action successCallback)
public virtual void RunRouteAction(string sourceKey, Action successCallback)
{
RunRouteAction(routeKey, String.Empty, successCallback);
RunRouteAction(sourceKey, String.Empty, successCallback);
}
/// <summary>
///
/// </summary>
/// <param name="routeKey"></param>
/// <param name="sourceKey"></param>
/// <param name="sourceListKey"></param>
public virtual void RunRouteAction(string routeKey, string sourceListKey)
public virtual void RunRouteAction(string sourceKey, string sourceListKey)
{
RunRouteAction(routeKey, sourceListKey, () => { });
RunRouteAction(sourceKey, sourceListKey, () => { });
}
/// <summary>
///
/// </summary>
/// <param name="routeKey"></param>
/// <param name="sourceKey"></param>
/// <param name="sourceListKey"></param>
/// <param name="successCallback"></param>
public virtual void RunRouteAction(string routeKey, string sourceListKey, Action successCallback)
public virtual void RunRouteAction(string sourceKey, string sourceListKey, Action successCallback)
{
var routeObject =
new {RouteKey = routeKey, SourceListKey = sourceListKey, SuccessCallback = successCallback};
new {RouteKey = sourceKey, SourceListKey = sourceListKey, SuccessCallback = successCallback};
CrestronInvoke.BeginInvoke(RunRouteAction, routeObject); // end of BeginInvoke
}
@@ -572,14 +572,13 @@ namespace PepperDash.Essentials.Core
SetVolumeControl(item);
// store the name and UI info for routes
CurrentSourceInfoKey = routeObj.RouteKey;
if (item.SourceKey == "$off")
{
CurrentSourceInfoKey = routeObj.RouteKey;
CurrentSourceInfo = null;
}
else if (item.SourceKey != null)
{
CurrentSourceInfoKey = routeObj.RouteKey;
CurrentSourceInfo = item;
}
@@ -657,7 +656,7 @@ namespace PepperDash.Essentials.Core
return dest;
}
private void SetVolumeControl(SourceListItem item)
protected void SetVolumeControl(SourceListItem item)
{
IBasicVolumeControls volDev = null;
// Handle special cases for volume control
@@ -730,7 +729,7 @@ namespace PepperDash.Essentials.Core
}
}
private Dictionary<string, SourceListItem> GetSourceListForKey(string routeKey, string sourceListKey)
protected Dictionary<string, SourceListItem> GetSourceListForKey(string routeKey, string sourceListKey)
{
var slKey = String.IsNullOrEmpty(sourceListKey) ? SourceListKey : sourceListKey;

View File

@@ -15,13 +15,16 @@ namespace PepperDash.Essentials
private const string LeftDestinationKey = "leftDisplay";
private const string RightDestinationKey = "rightDisplay";
private readonly EssentialsDualDisplayRoomPropertiesConfig _config;
public EssentialsDualDisplayRoomPropertiesConfig RoomConfig { get; private set; }
public EAudioBehavior AudioRoutingBehavior { get; set; }
public EVideoBehavior VideoRoutingBehavior { get; set; }
private string _destinationListKey;
public EssentialsDualDisplayRoom(DeviceConfig config) : base(config)
{
_config = config.Properties.ToObject<EssentialsDualDisplayRoomPropertiesConfig>();
RoomConfig = config.Properties.ToObject<EssentialsDualDisplayRoomPropertiesConfig>();
Initialize();
}
@@ -40,9 +43,12 @@ namespace PepperDash.Essentials
{
try
{
_destinationListKey = String.IsNullOrEmpty(_config.DestinationListKey)
_destinationListKey = String.IsNullOrEmpty(RoomConfig.DestinationListKey)
? DefaultDestinationListKey
: _config.DestinationListKey;
: RoomConfig.DestinationListKey;
AudioRoutingBehavior = RoomConfig.DefaultAudioBehavior;
VideoRoutingBehavior = RoomConfig.DefaultVideoBehavior;
InitializeDestinations();
}
@@ -192,5 +198,33 @@ namespace PepperDash.Essentials
DoRoute(routeItem);
}
public void SelectSource(string sourceKey, string sourceListKey)
{
var srcList = GetSourceListForKey(sourceKey, sourceListKey);
var src = srcList[sourceKey];
if (src.SourceKey != "roomoff")
{
LastSourceKey = sourceKey;
}
else
{
CurrentSourceInfoKey = null;
}
SetVolumeControl(src);
if (src.SourceKey == "$off")
{
CurrentSourceInfo = null;
} else if (src.SourceKey != null)
{
CurrentSourceInfo = src;
}
OnFeedback.FireUpdate();
}
}
}