mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-15 20:54:55 +00:00
renamed room -> rooms
started on Dual Display room;
This commit is contained in:
@@ -233,6 +233,9 @@
|
|||||||
<Name>Essentials Devices Common</Name>
|
<Name>Essentials Devices Common</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="UIDrivers\EssentialsDualDisplay\" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CompactFramework.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CompactFramework.CSharp.targets" />
|
||||||
<ProjectExtensions>
|
<ProjectExtensions>
|
||||||
<VisualStudio>
|
<VisualStudio>
|
||||||
|
|||||||
@@ -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
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -16,14 +16,8 @@ namespace PepperDash.Essentials.Core.Rooms.Config
|
|||||||
public string DefaultAudioBehavior { get; set; }
|
public string DefaultAudioBehavior { get; set; }
|
||||||
[JsonProperty("defaultVideoBehavior")]
|
[JsonProperty("defaultVideoBehavior")]
|
||||||
public string DefaultVideoBehavior { get; set; }
|
public string DefaultVideoBehavior { get; set; }
|
||||||
[JsonProperty("displays")]
|
[JsonProperty("destinationListKey")]
|
||||||
public Dictionary<eSourceListItemDestinationTypes, DisplayItem> Displays { get; set; }
|
public string DestinationListKey { get; set; }
|
||||||
|
|
||||||
public EssentialsNDisplayRoomPropertiesConfig()
|
|
||||||
{
|
|
||||||
Displays = new Dictionary<eSourceListItemDestinationTypes, DisplayItem>();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DisplayItem : IKeyName
|
public class DisplayItem : IKeyName
|
||||||
@@ -31,5 +25,4 @@ namespace PepperDash.Essentials.Core.Rooms.Config
|
|||||||
public string Key { get; set; }
|
public string Key { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -47,6 +47,8 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool EnablePowerOnToLastSource { get; set; }
|
public bool EnablePowerOnToLastSource { get; set; }
|
||||||
|
|
||||||
|
public const string DefaultSourceListKey = "default";
|
||||||
|
|
||||||
protected EssentialsRoomBase(DeviceConfig config)
|
protected EssentialsRoomBase(DeviceConfig config)
|
||||||
: base(config)
|
: base(config)
|
||||||
{
|
{
|
||||||
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -47,7 +47,7 @@ namespace PepperDash.Essentials
|
|||||||
CurrentVolumeControls = DefaultVolumeControls;
|
CurrentVolumeControls = DefaultVolumeControls;
|
||||||
|
|
||||||
SourceListKey = String.IsNullOrEmpty(PropertiesConfig.SourceListKey)
|
SourceListKey = String.IsNullOrEmpty(PropertiesConfig.SourceListKey)
|
||||||
? "default"
|
? DefaultSourceListKey
|
||||||
: PropertiesConfig.SourceListKey;
|
: PropertiesConfig.SourceListKey;
|
||||||
|
|
||||||
EnablePowerOnToLastSource = true;
|
EnablePowerOnToLastSource = true;
|
||||||
@@ -66,8 +66,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
StringIncrement = stringIncrement;
|
StringIncrement = stringIncrement;
|
||||||
|
|
||||||
// Count the enable lines to see what max items is
|
// Count the enable lines to see what max items is
|
||||||
MaxDefinedItems = (ushort)SRL.BooleanInput
|
MaxDefinedItems = (ushort)SRL.BooleanInput.Count(s => s.Name.Contains("Enable"));
|
||||||
.Where(s => s.Name.Contains("Enable")).Count();
|
|
||||||
Debug.Console(2, "SRL {0} contains max {1} items", SRL.ID, MaxDefinedItems);
|
Debug.Console(2, "SRL {0} contains max {1} items", SRL.ID, MaxDefinedItems);
|
||||||
|
|
||||||
SRL.SigChange -= new SmartObjectSigChangeEventHandler(SRL_SigChange);
|
SRL.SigChange -= new SmartObjectSigChangeEventHandler(SRL_SigChange);
|
||||||
|
|||||||
Reference in New Issue
Block a user