diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/HdMdNxM4kEControllerJoinMap.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/HdMdNxM4kEControllerJoinMap.cs
new file mode 100644
index 00000000..87a0643a
--- /dev/null
+++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/HdMdNxM4kEControllerJoinMap.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Crestron.SimplSharp;
+using PepperDash.Essentials.Core;
+
+namespace PepperDash.Essentials.Core.Bridges
+{
+ public class HdMdNxM4kEControllerJoinMap : JoinMapBaseAdvanced
+ {
+ [JoinName("Name")]
+ public JoinDataComplete Name = new JoinDataComplete(new JoinData() { JoinNumber = 1, JoinSpan = 1 },
+ new JoinMetadata() { Label = "Device Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial });
+
+ [JoinName("InputName")]
+ public JoinDataComplete InputName = new JoinDataComplete(new JoinData() { JoinNumber = 2, JoinSpan = 8 },
+ new JoinMetadata() { Label = "Device Input Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial });
+
+ [JoinName("InputSync")]
+ public JoinDataComplete InputSync = new JoinDataComplete(new JoinData() { JoinNumber = 2, JoinSpan = 8 },
+ new JoinMetadata() { Label = "Device Input Sync", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital });
+
+ [JoinName("OutputName")]
+ public JoinDataComplete OutputName = new JoinDataComplete(new JoinData() { JoinNumber = 11, JoinSpan = 2 },
+ new JoinMetadata() { Label = "Device Output Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial });
+
+ [JoinName("OutputRoute")]
+ public JoinDataComplete OutputRoute = new JoinDataComplete(new JoinData() { JoinNumber = 11, JoinSpan = 2 },
+ new JoinMetadata() { Label = "Device Output Route Set/Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog });
+
+ [JoinName("OutputRoutedName")]
+ public JoinDataComplete OutputRoutedName = new JoinDataComplete(new JoinData() { JoinNumber = 16, JoinSpan = 2 },
+ new JoinMetadata() { Label = "Device Output Route Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial });
+
+ [JoinName("EnableInputHdcp")]
+ public JoinDataComplete EnableInputHdcp = new JoinDataComplete(new JoinData() { JoinNumber = 11, JoinSpan = 8 },
+ new JoinMetadata() { Label = "Device Enable Input Hdcp", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital });
+
+ [JoinName("DisableInputHdcp")]
+ public JoinDataComplete DisableInputHdcp = new JoinDataComplete(new JoinData() { JoinNumber = 21, JoinSpan = 8 },
+ new JoinMetadata() { Label = "Device Disnable Input Hdcp", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital });
+
+ [JoinName("IsOnline")]
+ public JoinDataComplete IsOnline = new JoinDataComplete(new JoinData() { JoinNumber = 30, JoinSpan = 1 },
+ new JoinMetadata() { Label = "Device Onlne", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital });
+
+ public HdMdNxM4kEControllerJoinMap(uint joinStart)
+ : base(joinStart, typeof(HdMdNxM4kEControllerJoinMap))
+ {
+ }
+ }
+}
\ No newline at end of file
diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj
index 00db3b08..63b7f580 100644
--- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj
+++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj
@@ -129,6 +129,7 @@
+
diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdMdNxM4kEController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdMdNxM4kEController.cs
index fc30c1aa..e2f5ff2c 100644
--- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdMdNxM4kEController.cs
+++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdMdNxM4kEController.cs
@@ -1,24 +1,30 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Newtonsoft.Json;
-using Crestron.SimplSharp;
-using Crestron.SimplSharpPro.DM;
-
-using PepperDash.Core;
-using PepperDash.Essentials.Core;
-using PepperDash.Essentials.DM.Config;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Newtonsoft.Json;
+using Crestron.SimplSharp;
+using Crestron.SimplSharpPro.DeviceSupport;
+using Crestron.SimplSharpPro.DM;
+
+using PepperDash.Core;
+using PepperDash.Essentials.Core;
+using PepperDash.Essentials.DM.Config;
using PepperDash.Essentials.Core.Bridges;
using PepperDash.Essentials.Core.Config;
-
namespace PepperDash.Essentials.DM.Chassis
{
- public class HdMdNxM4kEController : EssentialsBridgeableDevice, IRoutingInputsOutputs, IRouting
+ [Description("Wrapper class for all HdMdNxM4E switchers")]
+ public class HdMdNxM4kEController : CrestronGenericBridgeableBaseDevice, IRoutingInputsOutputs, IRouting, IHasFeedback
{
public HdMdNxM Chassis { get; private set; }
+ public string DeviceName { get; private set; }
+
+ public Dictionary InputNames { get; set; }
+ public Dictionary OutputNames { get; set; }
+
public RoutingPortCollection InputPorts { get; private set; }
public RoutingPortCollection OutputPorts { get; private set; }
@@ -27,68 +33,262 @@ namespace PepperDash.Essentials.DM.Chassis
public FeedbackCollection InputNameFeedbacks { get; private set; }
public FeedbackCollection OutputNameFeedbacks { get; private set; }
public FeedbackCollection OutputRouteNameFeedbacks { get; private set; }
+ public FeedbackCollection InputHdcpEnableFeedback { get; private set; }
+ public FeedbackCollection DeviceNameFeedback { get; private set; }
+ #region Constructor
- ///
- ///
- ///
- ///
- ///
- ///
public HdMdNxM4kEController(string key, string name, HdMdNxM chassis,
HdMdNxM4kEPropertiesConfig props)
- : base(key, name)
+ : base(key, name, chassis)
{
Chassis = chassis;
-
var _props = props;
+ DeviceName = name;
+
+ InputNames = props.Inputs;
+ OutputNames = props.Outputs;
+
VideoInputSyncFeedbacks = new FeedbackCollection();
VideoOutputRouteFeedbacks = new FeedbackCollection();
InputNameFeedbacks = new FeedbackCollection();
OutputNameFeedbacks = new FeedbackCollection();
OutputRouteNameFeedbacks = new FeedbackCollection();
+ InputHdcpEnableFeedback = new FeedbackCollection();
+ DeviceNameFeedback = new FeedbackCollection();
- // logical ports
InputPorts = new RoutingPortCollection();
+ OutputPorts = new RoutingPortCollection();
+
+ DeviceNameFeedback.Add(new StringFeedback("DeviceName", () => DeviceName));
+
for (uint i = 1; i <= Chassis.NumberOfInputs; i++)
{
- InputPorts.Add(new RoutingInputPort("hdmiIn" + i, eRoutingSignalType.AudioVideo,
+ var inputName = InputNames[i];
+ Chassis.Inputs[i].Name.StringValue = inputName;
+
+ InputPorts.Add(new RoutingInputPort(inputName, eRoutingSignalType.AudioVideo,
eRoutingPortConnectionType.Hdmi, i, this));
- VideoInputSyncFeedbacks.Add(new BoolFeedback(i.ToString(), () => Chassis.Inputs[i].VideoDetectedFeedback.BoolValue));
- InputNameFeedbacks.Add(new StringFeedback(i.ToString, () => _props.Inputs[i - 1].Name));
+ VideoInputSyncFeedbacks.Add(new BoolFeedback(inputName, () => Chassis.Inputs[i].VideoDetectedFeedback.BoolValue));
+ InputNameFeedbacks.Add(new StringFeedback(inputName, () => Chassis.Inputs[i].Name.StringValue));
+ InputHdcpEnableFeedback.Add(new BoolFeedback(inputName, () => Chassis.HdmiInputs[i].HdmiInputPort.HdcpSupportOnFeedback.BoolValue));
+
}
- OutputPorts = new RoutingPortCollection();
for (uint i = 1; i <= Chassis.NumberOfOutputs; i++)
{
- OutputPorts.Add(new RoutingOutputPort("hdmiOut" + i, eRoutingSignalType.AudioVideo,
+ var outputName = OutputNames[i];
+ Chassis.Outputs[i].Name.StringValue = outputName;
+
+ OutputPorts.Add(new RoutingOutputPort(outputName, eRoutingSignalType.AudioVideo,
eRoutingPortConnectionType.Hdmi, i, this));
- VideoOutputRouteFeedbacks.Add(new IntFeedback(i.ToString(), () => (int)Chassis.Outputs[i].VideoOutFeedback.Number));
- }
-
- // physical settings
- if (props != null && props.Inputs != null)
- {
- foreach (var kvp in props.Inputs)
- {
- // strip "hdmiIn"
- var inputNum = Convert.ToUInt32(kvp.Key.Substring(6));
-
- var port = chassis.HdmiInputs[inputNum].HdmiInputPort;
- // set hdcp disables
- if (kvp.Value.DisableHdcp)
- {
- Debug.Console(0, this, "Configuration disables HDCP support on {0}", kvp.Key);
- port.HdcpSupportOff();
- }
- else
- port.HdcpSupportOn();
- }
+ VideoOutputRouteFeedbacks.Add(new IntFeedback(outputName, () => (int)Chassis.Outputs[i].VideoOutFeedback.Number));
+ OutputNameFeedbacks.Add(new StringFeedback(outputName, () => Chassis.Outputs[i].Name.StringValue));
+ OutputRouteNameFeedbacks.Add(new StringFeedback(outputName, () => Chassis.Outputs[i].VideoOutFeedback.NameFeedback.StringValue));
}
Chassis.DMInputChange += new DMInputEventHandler(Chassis_DMInputChange);
Chassis.DMOutputChange += new DMOutputEventHandler(Chassis_DMOutputChange);
+
+ AddPostActivationAction(AddFeedbackCollections);
+ }
+
+ #endregion
+
+ #region Methods
+
+ public void EnableHdcp(uint port)
+ {
+ if (port <= Chassis.HdmiInputs.Count)
+ {
+ Chassis.HdmiInputs[port].HdmiInputPort.HdcpSupportOn();
+ InputHdcpEnableFeedback[InputNames[port]].FireUpdate();
+ }
+ }
+
+ public void DisableHdcp(uint port)
+ {
+ if (port <= Chassis.HdmiInputs.Count)
+ {
+ Chassis.HdmiInputs[port].HdmiInputPort.HdcpSupportOff();
+ InputHdcpEnableFeedback[InputNames[port]].FireUpdate();
+ }
+ }
+
+ #region PostActivate
+
+ public void AddFeedbackCollections()
+ {
+ AddCollectionsToList(VideoInputSyncFeedbacks, InputHdcpEnableFeedback);
+ AddCollectionsToList(VideoOutputRouteFeedbacks);
+ AddCollectionsToList(InputNameFeedbacks, OutputNameFeedbacks, OutputRouteNameFeedbacks, DeviceNameFeedback);
+ }
+
+ #endregion
+
+ #region FeedbackCollection Methods
+
+ //Add arrays of collections
+ public void AddCollectionsToList(params FeedbackCollection[] newFbs)
+ {
+ foreach (FeedbackCollection fbCollection in newFbs)
+ {
+ foreach (var item in newFbs)
+ {
+ AddCollectionToList(item);
+ }
+ }
+ }
+ public void AddCollectionsToList(params FeedbackCollection[] newFbs)
+ {
+ foreach (FeedbackCollection fbCollection in newFbs)
+ {
+ foreach (var item in newFbs)
+ {
+ AddCollectionToList(item);
+ }
+ }
+ }
+
+ public void AddCollectionsToList(params FeedbackCollection[] newFbs)
+ {
+ foreach (FeedbackCollection fbCollection in newFbs)
+ {
+ foreach (var item in newFbs)
+ {
+ AddCollectionToList(item);
+ }
+ }
+ }
+
+ //Add Collections
+ public void AddCollectionToList(FeedbackCollection newFbs)
+ {
+ foreach (var f in newFbs)
+ {
+ if (f == null) continue;
+
+ AddFeedbackToList(f);
+ }
+ }
+
+ public void AddCollectionToList(FeedbackCollection newFbs)
+ {
+ foreach (var f in newFbs)
+ {
+ if (f == null) continue;
+
+ AddFeedbackToList(f);
+ }
+ }
+
+ public void AddCollectionToList(FeedbackCollection newFbs)
+ {
+ foreach (var f in newFbs)
+ {
+ if (f == null) continue;
+
+ AddFeedbackToList(f);
+ }
+ }
+
+ //Add Individual Feedbacks
+ public void AddFeedbackToList(PepperDash.Essentials.Core.Feedback newFb)
+ {
+ if (newFb == null) return;
+
+ if (!Feedbacks.Contains(newFb))
+ {
+ Feedbacks.Add(newFb);
+ }
+ }
+
+ #endregion
+
+ #region IRouting Members
+
+ public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType)
+ {
+ // Try to make switch only when necessary. The unit appears to toggle when already selected.
+ var current = Chassis.HdmiOutputs[(uint)outputSelector].VideoOut;
+ if (current != Chassis.HdmiInputs[(uint)inputSelector])
+ Chassis.HdmiOutputs[(uint)outputSelector].VideoOut = Chassis.HdmiInputs[(uint)inputSelector];
+ }
+
+ #endregion
+
+ #endregion
+
+ #region Bridge Linking
+
+ public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
+ {
+ var joinMap = new HdMdNxM4kEControllerJoinMap(joinStart);
+
+ var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey);
+
+ if (!string.IsNullOrEmpty(joinMapSerialized))
+ joinMap = JsonConvert.DeserializeObject(joinMapSerialized);
+
+ bridge.AddJoinMap(Key, joinMap);
+
+ IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]);
+ DeviceNameFeedback["DeviceName"].LinkInputSig(trilist.StringInput[joinMap.Name.JoinNumber]);
+
+ for (uint i = 1; i < Chassis.Inputs.Count; i++)
+ {
+ var joinIndex = i - 1;
+ //Digital
+ VideoInputSyncFeedbacks[InputNames[i]].LinkInputSig(trilist.BooleanInput[joinMap.InputSync.JoinNumber + joinIndex]);
+ InputHdcpEnableFeedback[InputNames[i]].LinkInputSig(trilist.BooleanInput[joinMap.EnableInputHdcp.JoinNumber + joinIndex]);
+ InputHdcpEnableFeedback[InputNames[i]].LinkComplementInputSig(trilist.BooleanInput[joinMap.DisableInputHdcp.JoinNumber + joinIndex]);
+ trilist.SetSigTrueAction(joinMap.EnableInputHdcp.JoinNumber + joinIndex, () => EnableHdcp(i));
+ trilist.SetSigTrueAction(joinMap.DisableInputHdcp.JoinNumber + joinIndex, () => DisableHdcp(i));
+
+ //Serial
+ InputNameFeedbacks[InputNames[i]].LinkInputSig(trilist.StringInput[joinMap.InputName.JoinNumber + joinIndex]);
+ }
+
+ for (uint i = 1; i < Chassis.Outputs.Count; i++)
+ {
+ var joinIndex = i - 1;
+ //Analog
+ VideoOutputRouteFeedbacks[OutputNames[i]].LinkInputSig(trilist.UShortInput[joinMap.OutputRoute.JoinNumber + joinIndex]);
+ trilist.SetUShortSigAction(joinMap.OutputRoute.JoinNumber + joinIndex, (a) => ExecuteSwitch(a, i, eRoutingSignalType.AudioVideo));
+
+ //Serial
+ OutputNameFeedbacks[OutputNames[i]].LinkInputSig(trilist.StringInput[joinMap.OutputName.JoinNumber + joinIndex]);
+ OutputRouteNameFeedbacks[OutputNames[i]].LinkInputSig(trilist.StringInput[joinMap.OutputRoutedName.JoinNumber + joinIndex]);
+ }
+
+ Chassis.OnlineStatusChange += new Crestron.SimplSharpPro.OnlineStatusChangeEventHandler(Chassis_OnlineStatusChange);
+ }
+
+
+ #endregion
+
+ #region Events
+
+ void Chassis_OnlineStatusChange(Crestron.SimplSharpPro.GenericBase currentDevice, Crestron.SimplSharpPro.OnlineOfflineEventArgs args)
+ {
+ if (args.DeviceOnLine)
+ {
+ for (uint i = 1; i <= Chassis.NumberOfInputs; i++)
+ {
+ Chassis.Inputs[i].Name.StringValue = InputNames[i];
+ }
+ for (uint i = 1; i <= Chassis.NumberOfOutputs; i++)
+ {
+ Chassis.Outputs[i].Name.StringValue = OutputNames[i];
+ }
+
+ foreach (var feedback in Feedbacks)
+ {
+ feedback.FireUpdate();
+ }
+ }
+
}
void Chassis_DMOutputChange(Switch device, DMOutputEventArgs args)
@@ -113,36 +313,9 @@ namespace PepperDash.Essentials.DM.Chassis
}
}
- public override bool CustomActivate()
- {
- var result = Chassis.Register();
- if (result != Crestron.SimplSharpPro.eDeviceRegistrationUnRegistrationResponse.Success)
- {
- Debug.Console(0, this, "Device registration failed: {0}", result);
- return false;
- }
-
-
-
- return base.CustomActivate();
- }
-
-
-
- #region IRouting Members
-
- public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType)
- {
- // Try to make switch only when necessary. The unit appears to toggle when already selected.
- var current = Chassis.HdmiOutputs[(uint)outputSelector].VideoOut;
- if (current != Chassis.HdmiInputs[(uint)inputSelector])
- Chassis.HdmiOutputs[(uint)outputSelector].VideoOut = Chassis.HdmiInputs[(uint)inputSelector];
- }
-
#endregion
- /////////////////////////////////////////////////////
-
+ #region Factory
public class HdMdNxM4kEControllerFactory : EssentialsDeviceFactory
{
@@ -182,5 +355,8 @@ namespace PepperDash.Essentials.DM.Chassis
return null;
}
}
+
+ #endregion
+
}
}
\ No newline at end of file
diff --git a/essentials-framework/Essentials DM/Essentials_DM/Config/HdMdNxM4kEPropertiesConfig.cs b/essentials-framework/Essentials DM/Essentials_DM/Config/HdMdNxM4kEPropertiesConfig.cs
index 78794671..4dc79b65 100644
--- a/essentials-framework/Essentials DM/Essentials_DM/Config/HdMdNxM4kEPropertiesConfig.cs
+++ b/essentials-framework/Essentials DM/Essentials_DM/Config/HdMdNxM4kEPropertiesConfig.cs
@@ -18,9 +18,9 @@ namespace PepperDash.Essentials.DM.Config
public ControlPropertiesConfig Control { get; set; }
[JsonProperty("inputs")]
- public Dictionary Inputs { get; set; }
-
- [JsonProperty("outputs"]
- public Dictionary
+ public Dictionary Inputs { get; set; }
+
+ [JsonProperty("outputs")]
+ public Dictionary Outputs { get; set; }
}
}
\ No newline at end of file
diff --git a/essentials-framework/Essentials DM/Essentials_DM/Config/InputPropertiesConfig.cs b/essentials-framework/Essentials DM/Essentials_DM/Config/InputPropertiesConfig.cs
deleted file mode 100644
index 40f958ec..00000000
--- a/essentials-framework/Essentials DM/Essentials_DM/Config/InputPropertiesConfig.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Crestron.SimplSharp;
-
-namespace PepperDash.Essentials.DM.Config
-{
- public class InputPropertiesConfig
- {
- public string Name { get; set; }
-
- public bool DisableHdcp { get; set; }
- }
-}
\ No newline at end of file
diff --git a/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj b/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj
index 7fc4f24d..e5a04158 100644
--- a/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj
+++ b/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj
@@ -112,7 +112,6 @@
-