diff --git a/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IHasInputs.cs b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IHasInputs.cs
index a9f59c35..ef806d9a 100644
--- a/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IHasInputs.cs
+++ b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IHasInputs.cs
@@ -1,4 +1,5 @@
-using System;
+using PepperDash.Core;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -10,8 +11,14 @@ namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
///
/// Describes a device that has selectable inputs
///
- public interface IHasInputs
+ /// the type to use as the key for each input item. Most likely an enum or string\
+ ///
+ /// See MockDisplay for example implemntation
+ ///
+ public interface IHasInputs: IKeyName
{
- ISelectableItems Inputs { get; }
+ ISelectableItems Inputs { get; }
+
+ void SetInput(TSelector selector);
}
}
diff --git a/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IHasSurroundSoundModes.cs b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IHasSurroundSoundModes.cs
index 83e48105..85b01319 100644
--- a/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IHasSurroundSoundModes.cs
+++ b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/IHasSurroundSoundModes.cs
@@ -1,4 +1,5 @@
-using System;
+using PepperDash.Core;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -10,7 +11,7 @@ namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
/// Describes a device that has selectable surround sound modes
///
/// the type to use as the key for each input item. Most likely an enum or string
- public interface IHasSurroundSoundModes
+ public interface IHasSurroundSoundModes: IKeyName
{
ISelectableItems SurroundSoundModes { get; }
}
diff --git a/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/ISelectableItem.cs b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/ISelectableItem.cs
index 525581d3..0f7408f6 100644
--- a/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/ISelectableItem.cs
+++ b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/ISelectableItem.cs
@@ -13,7 +13,7 @@ namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
event EventHandler ItemUpdated;
[JsonProperty("isSelected")]
- bool IsSelected { get; }
+ bool IsSelected { get; set; }
void Select();
}
}
\ No newline at end of file
diff --git a/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/ISelectableItems.cs b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/ISelectableItems.cs
index ba936963..7d64ff10 100644
--- a/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/ISelectableItems.cs
+++ b/src/PepperDash.Essentials.Core/DeviceTypeInterfaces/ISelectableItems.cs
@@ -14,9 +14,9 @@ namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
event EventHandler CurrentItemChanged;
- Dictionary Items { get; }
+ Dictionary Items { get; set; }
[JsonProperty("currentItem")]
- string CurrentItem { get; }
+ string CurrentItem { get; set; }
}
}
\ No newline at end of file
diff --git a/src/PepperDash.Essentials.Devices.Common/Displays/DisplayBase.cs b/src/PepperDash.Essentials.Devices.Common/Displays/DisplayBase.cs
index 76e04405..17edfad0 100644
--- a/src/PepperDash.Essentials.Devices.Common/Displays/DisplayBase.cs
+++ b/src/PepperDash.Essentials.Devices.Common/Displays/DisplayBase.cs
@@ -8,10 +8,16 @@ using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Bridges;
using Feedback = PepperDash.Essentials.Core.Feedback;
using Newtonsoft.Json;
+using PepperDash.Essentials.Core.DeviceTypeInterfaces;
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;
diff --git a/src/PepperDash.Essentials.Devices.Common/Displays/MockDisplay.cs b/src/PepperDash.Essentials.Devices.Common/Displays/MockDisplay.cs
index ffbb00cd..a183b1d6 100644
--- a/src/PepperDash.Essentials.Devices.Common/Displays/MockDisplay.cs
+++ b/src/PepperDash.Essentials.Devices.Common/Displays/MockDisplay.cs
@@ -1,21 +1,19 @@
using System;
+using System.Collections.Generic;
+using System.Linq;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Bridges;
+using PepperDash.Essentials.Core.DeviceTypeInterfaces;
using PepperDash.Essentials.Core.Routing;
namespace PepperDash.Essentials.Devices.Common.Displays
{
- public class MockDisplay : TwoWayDisplayBase, IBasicVolumeWithFeedback, IBridgeAdvanced
-
+ public class MockDisplay : TwoWayDisplayBase, IBasicVolumeWithFeedback, IBridgeAdvanced, IHasInputs
{
- public RoutingInputPort HdmiIn1 { 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; }
+ public ISelectableItems Inputs { get; private set; }
bool _PowerIsOn;
bool _IsWarmingUp;
@@ -53,7 +51,7 @@ namespace PepperDash.Essentials.Devices.Common.Displays
};
}
}
- protected override Func CurrentInputFeedbackFunc { get { return () => "Not Implemented"; } }
+ protected override Func CurrentInputFeedbackFunc { get { return () => Inputs.CurrentItem; } }
int VolumeHeldRepeatInterval = 200;
ushort VolumeInterval = 655;
@@ -63,17 +61,31 @@ namespace PepperDash.Essentials.Devices.Common.Displays
public MockDisplay(string key, string name)
: base(key, name)
{
- HdmiIn1 = new RoutingInputPort(RoutingPortNames.HdmiIn1, eRoutingSignalType.Audio | eRoutingSignalType.Video,
- eRoutingPortConnectionType.Hdmi, null, this);
- HdmiIn2 = new RoutingInputPort(RoutingPortNames.HdmiIn2, eRoutingSignalType.Audio | eRoutingSignalType.Video,
- eRoutingPortConnectionType.Hdmi, null, this);
- HdmiIn3 = new RoutingInputPort(RoutingPortNames.HdmiIn3, eRoutingSignalType.Audio | eRoutingSignalType.Video,
- eRoutingPortConnectionType.Hdmi, null, this);
- ComponentIn1 = new RoutingInputPort(RoutingPortNames.ComponentIn, eRoutingSignalType.Video,
- eRoutingPortConnectionType.Component, null, this);
- VgaIn1 = new RoutingInputPort(RoutingPortNames.VgaIn, eRoutingSignalType.Video,
- eRoutingPortConnectionType.Composite, null, this);
- InputPorts.AddRange(new[] { HdmiIn1, HdmiIn2, HdmiIn3, ComponentIn1, VgaIn1 });
+ Inputs = new MockDisplayInputs
+ {
+ Items = new Dictionary
+ {
+ { "HDMI1", new MockDisplayInput ( "HDMI1", "HDMI 1",this ) },
+ { "HDMI2", new MockDisplayInput ("HDMI2", "HDMI 2",this ) },
+ { "HDMI3", new MockDisplayInput ("HDMI3", "HDMI 3",this ) },
+ { "HDMI4", new MockDisplayInput ("HDMI4", "HDMI 4",this )},
+ { "DP", new MockDisplayInput ("DP", "DisplayPort", this ) }
+ }
+ };
+
+ 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; });
MuteFeedback = new BoolFeedback("MuteOn", () => _IsMuted);
@@ -135,13 +147,43 @@ namespace PepperDash.Essentials.Devices.Common.Displays
{
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)
{
@@ -163,11 +205,12 @@ namespace PepperDash.Essentials.Devices.Common.Displays
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)
//{
@@ -207,5 +250,7 @@ namespace PepperDash.Essentials.Devices.Common.Displays
{
LinkDisplayToApi(this, trilist, joinStart, joinMapKey, bridge);
}
- }
+
+
+ }
}
\ No newline at end of file
diff --git a/src/PepperDash.Essentials.Devices.Common/Displays/MockDisplayInputs.cs b/src/PepperDash.Essentials.Devices.Common/Displays/MockDisplayInputs.cs
new file mode 100644
index 00000000..9035508a
--- /dev/null
+++ b/src/PepperDash.Essentials.Devices.Common/Displays/MockDisplayInputs.cs
@@ -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
+ {
+ private Dictionary _inputs;
+
+ public Dictionary Items
+ {
+ get
+ {
+ return _inputs;
+ }
+ set
+ {
+ if (_inputs == value)
+ return;
+
+ _inputs = 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 _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);
+ }
+ }
+}