renamed room -> rooms

started on Dual Display room;
This commit is contained in:
Andrew Welker
2020-06-30 00:34:24 -06:00
parent 35388ddf66
commit ddb1f254e6
22 changed files with 201 additions and 34 deletions

View File

@@ -1,22 +0,0 @@
using System;
using System.Linq;
using Crestron.SimplSharp;
using Newtonsoft.Json;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Core.Rooms;
using PepperDash.Essentials.Core.Rooms.Config;
using PepperDash.Essentials.Core.Devices.Codec;
using PepperDash.Essentials.Core.Devices.VideoCodec;
using PepperDash.Essentials.Core.Devices.AudioCodec;
namespace PepperDash.Essentials
{
public class EssentialsDualDisplayRoom
{
}
}

View File

@@ -16,14 +16,8 @@ namespace PepperDash.Essentials.Core.Rooms.Config
public string DefaultAudioBehavior { get; set; }
[JsonProperty("defaultVideoBehavior")]
public string DefaultVideoBehavior { get; set; }
[JsonProperty("displays")]
public Dictionary<eSourceListItemDestinationTypes, DisplayItem> Displays { get; set; }
public EssentialsNDisplayRoomPropertiesConfig()
{
Displays = new Dictionary<eSourceListItemDestinationTypes, DisplayItem>();
}
[JsonProperty("destinationListKey")]
public string DestinationListKey { get; set; }
}
public class DisplayItem : IKeyName
@@ -31,5 +25,4 @@ namespace PepperDash.Essentials.Core.Rooms.Config
public string Key { get; set; }
public string Name { get; set; }
}
}

View File

@@ -47,6 +47,8 @@ namespace PepperDash.Essentials.Core
/// </summary>
public bool EnablePowerOnToLastSource { get; set; }
public const string DefaultSourceListKey = "default";
protected EssentialsRoomBase(DeviceConfig config)
: base(config)
{

View File

@@ -0,0 +1,192 @@
using System;
using System.Collections.Generic;
using System.Linq;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Core.Rooms.Config;
using PepperDash_Essentials_Core.Devices;
namespace PepperDash.Essentials
{
public class EssentialsDualDisplayRoom : EssentialsRoomBase
{
public const string DefaultDestinationListKey = "default";
private const string LeftDestinationKey = "leftDisplay";
private const string RightDestinationKey = "rightDisplay";
private readonly EssentialsDualDisplayRoomPropertiesConfig _config;
private string _destinationListKey;
public EssentialsDualDisplayRoom(DeviceConfig config) : base(config)
{
_config = config.Properties.ToObject<EssentialsDualDisplayRoomPropertiesConfig>();
DefaultDisplay = DeviceManager.GetDeviceForKey(_config.DefaultDisplayKey) as IRoutingSinkWithSwitching;
DefaultAudioDevice = DeviceManager.GetDeviceForKey(_config.DefaultAudioKey) as IRoutingSinkWithSwitching;
Initialize();
}
public Dictionary<string, DestinationListItem> DestinationList { get; private set; }
public BoolFeedback LeftDisplayIsWarmingUpFeedback { get; private set; }
public BoolFeedback RightDisplayIsWarmingUpFeedback { get; private set; }
public BoolFeedback LeftDisplayIsCoolingDownFeedback { get; private set; }
public BoolFeedback RightDisplayIsCoolingDownFeedback { get; private set; }
public IRoutingSinkWithSwitching LeftDisplay { get; private set; }
public IRoutingSinkWithSwitching RightDisplay { get; private set; }
private void Initialize()
{
if (DefaultAudioDevice is IBasicVolumeControls)
{
DefaultVolumeControls = DefaultAudioDevice as IBasicVolumeControls;
}
else if (DefaultAudioDevice is IHasVolumeDevice)
{
DefaultVolumeControls = (DefaultAudioDevice as IHasVolumeDevice).VolumeDevice;
}
CurrentVolumeControls = DefaultVolumeControls;
_destinationListKey = String.IsNullOrEmpty(_config.DestinationListKey)
? DefaultDestinationListKey
: _config.DestinationListKey;
SourceListKey = String.IsNullOrEmpty(_config.SourceListKey) ? DefaultSourceListKey : _config.SourceListKey;
InitializeDestinations();
}
private void InitializeDestinations()
{
DestinationList = ConfigReader.ConfigObject.GetDestinationListForKey(_destinationListKey);
if (DestinationList == null)
{
Debug.Console(0, Debug.ErrorLogLevel.Error, "No destination list with key {0} found",
_destinationListKey);
return;
}
//left destination is defined as the display on the 0 surface, at location 0,0 (h, v)
var leftDest = GetDestinationForKey(LeftDestinationKey);
//not found by key, check by expected location
if (leftDest == null)
{
DestinationList.Values.FirstOrDefault(
(li) => li.SurfaceLocation == 0 && li.HorizontalLocation == 0 && li.VerticalLocation == 0);
}
//right destination is defined as the display on the 0 surface, at location 0,0 (h, v)
var rightDest = GetDestinationForKey(RightDestinationKey);
//not found by key, check by expected location
if (rightDest == null)
{
DestinationList.Values.FirstOrDefault(
(li) => li.SurfaceLocation == 0 && li.HorizontalLocation == 1 && li.VerticalLocation == 0);
}
if (leftDest == null || rightDest == null)
{
Debug.Console(0, Debug.ErrorLogLevel.Error, "Dual destinations not defined. Please check configuration");
return;
}
var leftDisplay = leftDest.SinkDevice as DisplayBase;
var rightDisplay = rightDest.SinkDevice as DisplayBase;
if (leftDisplay == null || rightDisplay == null)
{
Debug.Console(0, Debug.ErrorLogLevel.Error,
"Display for key {0} && key {1} not found. Please check configurattion");
Debug.Console(0, Debug.ErrorLogLevel.Error, "LeftDisplay: {0}\r\nRightDisplay: {1}", leftDest.SinkKey,
rightDest.SinkKey);
return;
}
//need displays as DisplayBase later instead of IRoutingSinkWithSwtich
LeftDisplay = leftDisplay;
RightDisplay = rightDisplay;
//TODO: Check this definition for on for dual display rooms
OnFeedbackFunc = () => CurrentSourceInfo != null && CurrentSourceInfo.Type == eSourceListItemType.Route;
IsWarmingFeedbackFunc =
() => leftDisplay.IsWarmingUpFeedback.BoolValue || rightDisplay.IsWarmingUpFeedback.BoolValue;
IsCoolingFeedbackFunc = () => leftDisplay.IsWarmingUpFeedback.BoolValue ||
rightDisplay.IsCoolingDownFeedback.BoolValue;
LeftDisplayIsWarmingUpFeedback = new BoolFeedback(() => leftDisplay.IsWarmingUpFeedback.BoolValue);
LeftDisplayIsCoolingDownFeedback = new BoolFeedback(() => leftDisplay.IsCoolingDownFeedback.BoolValue);
RightDisplayIsWarmingUpFeedback = new BoolFeedback(() => rightDisplay.IsWarmingUpFeedback.BoolValue);
RightDisplayIsCoolingDownFeedback = new BoolFeedback(() => rightDisplay.IsCoolingDownFeedback.BoolValue);
InitializeDisplay(leftDisplay);
InitializeDisplay(rightDisplay);
}
private DestinationListItem GetDestinationForKey(string key)
{
DestinationListItem returnValue;
DestinationList.TryGetValue(key, out returnValue);
return returnValue;
}
protected override void IsCoolingDownFeedbackOnOutputChange(object sender, FeedbackEventArgs args)
{
IsCoolingDownFeedback.FireUpdate();
LeftDisplayIsCoolingDownFeedback.FireUpdate();
RightDisplayIsCoolingDownFeedback.FireUpdate();
}
public override void RoomVacatedForTimeoutPeriod(object o)
{
throw new NotImplementedException();
}
protected override void IsWarmingUpFeedbackOnOutputChange(object sender, FeedbackEventArgs args)
{
IsWarmingUpFeedback.FireUpdate();
LeftDisplayIsWarmingUpFeedback.FireUpdate();
RightDisplayIsWarmingUpFeedback.FireUpdate();
}
protected override void PowerIsOnFeedbackOnOutputChange(object sender, FeedbackEventArgs args)
{
var ld = LeftDisplay as DisplayBase;
var rd = RightDisplay as DisplayBase;
if (ld == null || rd == null)
{
return;
}
//if room is already on and either display is still on, no need to fire update
if (OnFeedback.BoolValue && (ld.PowerIsOnFeedback.BoolValue || rd.PowerIsOnFeedback.BoolValue))
{
return;
}
//if both displays are off, room is off, clear the current source
if (!ld.PowerIsOnFeedback.BoolValue && !rd.PowerIsOnFeedback.BoolValue)
{
CurrentSourceInfo = null;
}
OnFeedback.FireUpdate();
}
}
}

View File

@@ -47,7 +47,7 @@ namespace PepperDash.Essentials
CurrentVolumeControls = DefaultVolumeControls;
SourceListKey = String.IsNullOrEmpty(PropertiesConfig.SourceListKey)
? "default"
? DefaultSourceListKey
: PropertiesConfig.SourceListKey;
EnablePowerOnToLastSource = true;

View File

@@ -66,8 +66,7 @@ namespace PepperDash.Essentials.Core
StringIncrement = stringIncrement;
// Count the enable lines to see what max items is
MaxDefinedItems = (ushort)SRL.BooleanInput
.Where(s => s.Name.Contains("Enable")).Count();
MaxDefinedItems = (ushort)SRL.BooleanInput.Count(s => s.Name.Contains("Enable"));
Debug.Console(2, "SRL {0} contains max {1} items", SRL.ID, MaxDefinedItems);
SRL.SigChange -= new SmartObjectSigChangeEventHandler(SRL_SigChange);