mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-15 04:34:56 +00:00
Merge branch 'feature-2.0.0/interface-updates' of https://github.com/PepperDash/Essentials into feature-2.0.0/interface-updates
This commit is contained in:
@@ -1,11 +1,24 @@
|
|||||||
using System;
|
using PepperDash.Core;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
|
namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
|
||||||
{
|
{
|
||||||
public interface IHasInputs
|
|
||||||
|
/// <summary>
|
||||||
|
/// Describes a device that has selectable inputs
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TKey">the type to use as the key for each input item. Most likely an enum or string</typeparam>\
|
||||||
|
/// <example>
|
||||||
|
/// See MockDisplay for example implemntation
|
||||||
|
/// </example>
|
||||||
|
public interface IHasInputs<TKey, TSelector>: IKeyName
|
||||||
{
|
{
|
||||||
event EventHandler InputsUpdated;
|
ISelectableItems<TKey> Inputs { get; }
|
||||||
IDictionary<string, IInput> Inputs { get; }
|
|
||||||
|
void SetInput(TSelector selector);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
using PepperDash.Core;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Describes a device that has selectable surround sound modes
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TKey">the type to use as the key for each input item. Most likely an enum or string</typeparam>
|
||||||
|
public interface IHasSurroundSoundModes<TKey, TSelector>: IKeyName
|
||||||
|
{
|
||||||
|
ISelectableItems<TKey> SurroundSoundModes { get; }
|
||||||
|
|
||||||
|
void SetSurroundSoundMode(TSelector selector);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
using System;
|
|
||||||
using PepperDash.Core;
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
|
|
||||||
{
|
|
||||||
public interface IInput : IKeyName
|
|
||||||
{
|
|
||||||
event EventHandler InputUpdated;
|
|
||||||
bool IsSelected { get; }
|
|
||||||
void Select();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using PepperDash.Core;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Describes an item that can be selected
|
||||||
|
/// </summary>
|
||||||
|
public interface ISelectableItem : IKeyName
|
||||||
|
{
|
||||||
|
event EventHandler ItemUpdated;
|
||||||
|
|
||||||
|
[JsonProperty("isSelected")]
|
||||||
|
bool IsSelected { get; set; }
|
||||||
|
void Select();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Describes a collection of items that can be selected
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TKey">type for the keys in the collection. Probably a string or enum</typeparam>
|
||||||
|
public interface ISelectableItems<TKey>
|
||||||
|
{
|
||||||
|
event EventHandler ItemsUpdated;
|
||||||
|
event EventHandler CurrentItemChanged;
|
||||||
|
|
||||||
|
[JsonProperty("items")]
|
||||||
|
Dictionary<TKey, ISelectableItem> Items { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("currentItem")]
|
||||||
|
string CurrentItem { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -371,9 +371,9 @@ namespace PepperDash.Essentials
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Debug.Console(0, $"Checking if type {type.Name} is IPluginDeviceFactory");
|
//Debug.Console(0, $"Checking if type {type.Name} is IPluginDeviceFactory");
|
||||||
|
|
||||||
Debug.Console(0, $"{type.Name} is plugin factory: {typeof(IPluginDeviceFactory).IsAssignableFrom(type) && !type.IsAbstract}");
|
//Debug.Console(0, $"{type.Name} is plugin factory: {typeof(IPluginDeviceFactory).IsAssignableFrom(type) && !type.IsAbstract}");
|
||||||
|
|
||||||
if (typeof (IPluginDeviceFactory).IsAssignableFrom(type) && !type.IsAbstract)
|
if (typeof (IPluginDeviceFactory).IsAssignableFrom(type) && !type.IsAbstract)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,10 +8,16 @@ using PepperDash.Essentials.Core;
|
|||||||
using PepperDash.Essentials.Core.Bridges;
|
using PepperDash.Essentials.Core.Bridges;
|
||||||
using Feedback = PepperDash.Essentials.Core.Feedback;
|
using Feedback = PepperDash.Essentials.Core.Feedback;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Devices.Common.Displays
|
namespace PepperDash.Essentials.Devices.Common.Displays
|
||||||
{
|
{
|
||||||
public abstract class DisplayBase : EssentialsDevice, IHasFeedback, IRoutingSinkWithSwitching, IHasPowerControl, IWarmingCooling, IUsageTracking
|
public abstract class DisplayBase : EssentialsDevice
|
||||||
|
, IHasFeedback
|
||||||
|
, IRoutingSinkWithSwitching
|
||||||
|
, IHasPowerControl
|
||||||
|
, IWarmingCooling
|
||||||
|
, IUsageTracking
|
||||||
{
|
{
|
||||||
public event SourceInfoChangeHandler CurrentSourceChange;
|
public event SourceInfoChangeHandler CurrentSourceChange;
|
||||||
|
|
||||||
|
|||||||
@@ -1,21 +1,19 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
using Crestron.SimplSharpPro.DeviceSupport;
|
using Crestron.SimplSharpPro.DeviceSupport;
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using PepperDash.Essentials.Core;
|
using PepperDash.Essentials.Core;
|
||||||
using PepperDash.Essentials.Core.Bridges;
|
using PepperDash.Essentials.Core.Bridges;
|
||||||
|
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
|
||||||
using PepperDash.Essentials.Core.Routing;
|
using PepperDash.Essentials.Core.Routing;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Devices.Common.Displays
|
namespace PepperDash.Essentials.Devices.Common.Displays
|
||||||
{
|
{
|
||||||
public class MockDisplay : TwoWayDisplayBase, IBasicVolumeWithFeedback, IBridgeAdvanced
|
public class MockDisplay : TwoWayDisplayBase, IBasicVolumeWithFeedback, IBridgeAdvanced, IHasInputs<string, string>
|
||||||
|
|
||||||
{
|
{
|
||||||
public RoutingInputPort HdmiIn1 { get; private set; }
|
public ISelectableItems<string> Inputs { get; private set; }
|
||||||
public RoutingInputPort HdmiIn2 { get; private set; }
|
|
||||||
public RoutingInputPort HdmiIn3 { get; private set; }
|
|
||||||
public RoutingInputPort ComponentIn1 { get; private set; }
|
|
||||||
public RoutingInputPort VgaIn1 { get; private set; }
|
|
||||||
|
|
||||||
bool _PowerIsOn;
|
bool _PowerIsOn;
|
||||||
bool _IsWarmingUp;
|
bool _IsWarmingUp;
|
||||||
@@ -53,7 +51,7 @@ namespace PepperDash.Essentials.Devices.Common.Displays
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected override Func<string> CurrentInputFeedbackFunc { get { return () => "Not Implemented"; } }
|
protected override Func<string> CurrentInputFeedbackFunc { get { return () => Inputs.CurrentItem; } }
|
||||||
|
|
||||||
int VolumeHeldRepeatInterval = 200;
|
int VolumeHeldRepeatInterval = 200;
|
||||||
ushort VolumeInterval = 655;
|
ushort VolumeInterval = 655;
|
||||||
@@ -63,17 +61,31 @@ namespace PepperDash.Essentials.Devices.Common.Displays
|
|||||||
public MockDisplay(string key, string name)
|
public MockDisplay(string key, string name)
|
||||||
: base(key, name)
|
: base(key, name)
|
||||||
{
|
{
|
||||||
HdmiIn1 = new RoutingInputPort(RoutingPortNames.HdmiIn1, eRoutingSignalType.Audio | eRoutingSignalType.Video,
|
Inputs = new MockDisplayInputs
|
||||||
eRoutingPortConnectionType.Hdmi, null, this);
|
{
|
||||||
HdmiIn2 = new RoutingInputPort(RoutingPortNames.HdmiIn2, eRoutingSignalType.Audio | eRoutingSignalType.Video,
|
Items = new Dictionary<string, ISelectableItem>
|
||||||
eRoutingPortConnectionType.Hdmi, null, this);
|
{
|
||||||
HdmiIn3 = new RoutingInputPort(RoutingPortNames.HdmiIn3, eRoutingSignalType.Audio | eRoutingSignalType.Video,
|
{ "HDMI1", new MockDisplayInput ( "HDMI1", "HDMI 1",this ) },
|
||||||
eRoutingPortConnectionType.Hdmi, null, this);
|
{ "HDMI2", new MockDisplayInput ("HDMI2", "HDMI 2",this ) },
|
||||||
ComponentIn1 = new RoutingInputPort(RoutingPortNames.ComponentIn, eRoutingSignalType.Video,
|
{ "HDMI3", new MockDisplayInput ("HDMI3", "HDMI 3",this ) },
|
||||||
eRoutingPortConnectionType.Component, null, this);
|
{ "HDMI4", new MockDisplayInput ("HDMI4", "HDMI 4",this )},
|
||||||
VgaIn1 = new RoutingInputPort(RoutingPortNames.VgaIn, eRoutingSignalType.Video,
|
{ "DP", new MockDisplayInput ("DP", "DisplayPort", this ) }
|
||||||
eRoutingPortConnectionType.Composite, null, this);
|
}
|
||||||
InputPorts.AddRange(new[] { HdmiIn1, HdmiIn2, HdmiIn3, ComponentIn1, VgaIn1 });
|
};
|
||||||
|
|
||||||
|
Inputs.CurrentItemChanged += (o, a) => CurrentInputFeedback.FireUpdate();
|
||||||
|
|
||||||
|
var hdmiIn1 = new RoutingInputPort(RoutingPortNames.HdmiIn1, eRoutingSignalType.AudioVideo,
|
||||||
|
eRoutingPortConnectionType.Hdmi, "HDMI1", this);
|
||||||
|
var hdmiIn2 = new RoutingInputPort(RoutingPortNames.HdmiIn2, eRoutingSignalType.AudioVideo,
|
||||||
|
eRoutingPortConnectionType.Hdmi, "HDMI2", this);
|
||||||
|
var hdmiIn3 = new RoutingInputPort(RoutingPortNames.HdmiIn3, eRoutingSignalType.AudioVideo,
|
||||||
|
eRoutingPortConnectionType.Hdmi, "HDMI3", this);
|
||||||
|
var hdmiIn4 = new RoutingInputPort(RoutingPortNames.ComponentIn, eRoutingSignalType.AudioVideo,
|
||||||
|
eRoutingPortConnectionType.Hdmi, "HDMI4", this);
|
||||||
|
var dpIn = new RoutingInputPort(RoutingPortNames.DisplayPortIn, eRoutingSignalType.AudioVideo,
|
||||||
|
eRoutingPortConnectionType.DisplayPort, "DP", this);
|
||||||
|
InputPorts.AddRange(new[] { hdmiIn1, hdmiIn2, hdmiIn3, hdmiIn4, dpIn });
|
||||||
|
|
||||||
VolumeLevelFeedback = new IntFeedback(() => { return _FakeVolumeLevel; });
|
VolumeLevelFeedback = new IntFeedback(() => { return _FakeVolumeLevel; });
|
||||||
MuteFeedback = new BoolFeedback("MuteOn", () => _IsMuted);
|
MuteFeedback = new BoolFeedback("MuteOn", () => _IsMuted);
|
||||||
@@ -135,13 +147,43 @@ namespace PepperDash.Essentials.Devices.Common.Displays
|
|||||||
{
|
{
|
||||||
PowerOn();
|
PowerOn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!Inputs.Items.TryGetValue(selector.ToString(), out var input))
|
||||||
|
return;
|
||||||
|
|
||||||
|
input.Select();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetInput(string selector)
|
||||||
|
{
|
||||||
|
ISelectableItem currentInput = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
currentInput = Inputs.Items.SingleOrDefault(Inputs => Inputs.Value.IsSelected).Value;
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
|
||||||
|
|
||||||
|
if (currentInput != null)
|
||||||
|
{
|
||||||
|
Debug.Console(2, this, "SetInput: {0}", selector);
|
||||||
|
currentInput.IsSelected = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Inputs.Items.TryGetValue(selector, out var input))
|
||||||
|
return;
|
||||||
|
|
||||||
|
input.IsSelected = true;
|
||||||
|
|
||||||
|
Inputs.CurrentItem = selector;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#region IBasicVolumeWithFeedback Members
|
|
||||||
|
|
||||||
public IntFeedback VolumeLevelFeedback { get; private set; }
|
#region IBasicVolumeWithFeedback Members
|
||||||
|
|
||||||
|
public IntFeedback VolumeLevelFeedback { get; private set; }
|
||||||
|
|
||||||
public void SetVolume(ushort level)
|
public void SetVolume(ushort level)
|
||||||
{
|
{
|
||||||
@@ -163,11 +205,12 @@ namespace PepperDash.Essentials.Devices.Common.Displays
|
|||||||
|
|
||||||
public BoolFeedback MuteFeedback { get; private set; }
|
public BoolFeedback MuteFeedback { get; private set; }
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region IBasicVolumeControls Members
|
#endregion
|
||||||
|
|
||||||
public void VolumeUp(bool pressRelease)
|
#region IBasicVolumeControls Members
|
||||||
|
|
||||||
|
public void VolumeUp(bool pressRelease)
|
||||||
{
|
{
|
||||||
//while (pressRelease)
|
//while (pressRelease)
|
||||||
//{
|
//{
|
||||||
@@ -207,5 +250,7 @@ namespace PepperDash.Essentials.Devices.Common.Displays
|
|||||||
{
|
{
|
||||||
LinkDisplayToApi(this, trilist, joinStart, joinMapKey, bridge);
|
LinkDisplayToApi(this, trilist, joinStart, joinMapKey, bridge);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Devices.Common.Displays
|
||||||
|
{
|
||||||
|
public class MockDisplayInputs : ISelectableItems<string>
|
||||||
|
{
|
||||||
|
private Dictionary<string, ISelectableItem> _items;
|
||||||
|
|
||||||
|
public Dictionary<string, ISelectableItem> Items
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _items;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_items == value)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_items = value;
|
||||||
|
|
||||||
|
ItemsUpdated?.Invoke(this, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string _currentItem;
|
||||||
|
|
||||||
|
public string CurrentItem
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _currentItem;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_currentItem == value)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_currentItem = value;
|
||||||
|
|
||||||
|
CurrentItemChanged?.Invoke(this, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public event EventHandler ItemsUpdated;
|
||||||
|
public event EventHandler CurrentItemChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MockDisplayInput : ISelectableItem
|
||||||
|
{
|
||||||
|
private IHasInputs<string, string> _parent;
|
||||||
|
|
||||||
|
|
||||||
|
private bool _isSelected;
|
||||||
|
|
||||||
|
public bool IsSelected
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _isSelected;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_isSelected == value)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_isSelected = value;
|
||||||
|
|
||||||
|
ItemUpdated?.Invoke(this, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
public string Key { get; set; }
|
||||||
|
|
||||||
|
public event EventHandler ItemUpdated;
|
||||||
|
|
||||||
|
public MockDisplayInput(string key, string name, MockDisplay parent)
|
||||||
|
{
|
||||||
|
Key = key;
|
||||||
|
Name = name;
|
||||||
|
_parent = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Select()
|
||||||
|
{
|
||||||
|
_parent.SetInput(Key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user