Merge pull request #833 from PepperDash/hotfix/hd-md-outputname

Hotfix/hd md outputname
This commit is contained in:
Andrew Welker
2021-09-21 16:16:32 -06:00
committed by GitHub
2 changed files with 426 additions and 349 deletions

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Text.RegularExpressions;
using Newtonsoft.Json; using Newtonsoft.Json;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DeviceSupport;
@@ -15,421 +16,489 @@ using PepperDash.Essentials.Core.Config;
namespace PepperDash.Essentials.DM.Chassis namespace PepperDash.Essentials.DM.Chassis
{ {
[Description("Wrapper class for all HdMdNxM4E switchers")] [Description("Wrapper class for all HdMdNxM4E switchers")]
public class HdMdNxM4kEBridgeableController : CrestronGenericBridgeableBaseDevice, IRoutingNumericWithFeedback, IHasFeedback public class HdMdNxM4kEBridgeableController : CrestronGenericBridgeableBaseDevice, IRoutingNumericWithFeedback, IHasFeedback
{ {
private HdMdNxM _Chassis; private HdMdNxM _Chassis;
private HdMd4x14kE _Chassis4x1; private HdMd4x14kE _Chassis4x1;
//IroutingNumericEvent //IroutingNumericEvent
public event EventHandler<RoutingNumericEventArgs> NumericSwitchChange; public event EventHandler<RoutingNumericEventArgs> NumericSwitchChange;
public Dictionary<uint, string> InputNames { get; set; } public Dictionary<uint, string> InputNames { get; set; }
public Dictionary<uint, string> OutputNames { get; set; } public Dictionary<uint, string> OutputNames { get; set; }
public RoutingPortCollection<RoutingInputPort> InputPorts { get; private set; } public RoutingPortCollection<RoutingInputPort> InputPorts { get; private set; }
public RoutingPortCollection<RoutingOutputPort> OutputPorts { get; private set; } public RoutingPortCollection<RoutingOutputPort> OutputPorts { get; private set; }
public FeedbackCollection<BoolFeedback> VideoInputSyncFeedbacks { get; private set; } public FeedbackCollection<BoolFeedback> VideoInputSyncFeedbacks { get; private set; }
public FeedbackCollection<IntFeedback> VideoOutputRouteFeedbacks { get; private set; } public FeedbackCollection<IntFeedback> VideoOutputRouteFeedbacks { get; private set; }
public FeedbackCollection<StringFeedback> InputNameFeedbacks { get; private set; } public FeedbackCollection<StringFeedback> InputNameFeedbacks { get; private set; }
public FeedbackCollection<StringFeedback> OutputNameFeedbacks { get; private set; } public FeedbackCollection<StringFeedback> OutputNameFeedbacks { get; private set; }
public FeedbackCollection<StringFeedback> OutputRouteNameFeedbacks { get; private set; } public FeedbackCollection<StringFeedback> OutputRouteNameFeedbacks { get; private set; }
public FeedbackCollection<BoolFeedback> InputHdcpEnableFeedback { get; private set; } public FeedbackCollection<BoolFeedback> InputHdcpEnableFeedback { get; private set; }
public FeedbackCollection<StringFeedback> DeviceNameFeedback { get; private set; } public StringFeedback DeviceNameFeedback { get; private set; }
public FeedbackCollection<BoolFeedback> AutoRouteFeedback { get; private set; } public BoolFeedback AutoRouteFeedback { get; private set; }
#region Constructor #region Constructor
public HdMdNxM4kEBridgeableController(string key, string name, HdMdNxM chassis, public HdMdNxM4kEBridgeableController(string key, string name, HdMdNxM chassis,
HdMdNxM4kEBridgeablePropertiesConfig props) HdMdNxM4kEBridgeablePropertiesConfig props)
: base(key, name, chassis) : base(key, name, chassis)
{ {
_Chassis = chassis; _Chassis = chassis;
var _props = props; Name = name;
InputNames = props.Inputs; if (props == null)
OutputNames = props.Outputs; {
Debug.Console(1, this, "HdMdNx4keBridgeableController properties are null, failed to build the device");
VideoInputSyncFeedbacks = new FeedbackCollection<BoolFeedback>(); return;
VideoOutputRouteFeedbacks = new FeedbackCollection<IntFeedback>(); }
InputNameFeedbacks = new FeedbackCollection<StringFeedback>();
OutputNameFeedbacks = new FeedbackCollection<StringFeedback>();
OutputRouteNameFeedbacks = new FeedbackCollection<StringFeedback>(); if (props.Inputs != null)
InputHdcpEnableFeedback = new FeedbackCollection<BoolFeedback>(); {
DeviceNameFeedback = new FeedbackCollection<StringFeedback>(); foreach (var kvp in props.Inputs)
AutoRouteFeedback = new FeedbackCollection<BoolFeedback>(); {
Debug.Console(1, this, "props.Inputs: {0}-{1}", kvp.Key, kvp.Value);
InputPorts = new RoutingPortCollection<RoutingInputPort>(); }
OutputPorts = new RoutingPortCollection<RoutingOutputPort>(); InputNames = props.Inputs;
}
DeviceNameFeedback.Add(new StringFeedback(this.Name, () => this.Name)); if (props.Outputs != null)
{
if (_Chassis.NumberOfInputs == 1) foreach (var kvp in props.Outputs)
{ {
_Chassis4x1 = _Chassis as HdMd4x14kE; Debug.Console(1, this, "props.Outputs: {0}-{1}", kvp.Key, kvp.Value);
AutoRouteFeedback.Add(new BoolFeedback(this.Name + "-" + InputNames[1], () => _Chassis4x1.AutoModeOnFeedback.BoolValue)); }
} OutputNames = props.Outputs;
}
for (uint i = 1; i <= _Chassis.NumberOfInputs; i++)
{ DeviceNameFeedback = new StringFeedback(()=>Name);
var index = i;
var inputName = InputNames[index]; VideoInputSyncFeedbacks = new FeedbackCollection<BoolFeedback>();
_Chassis.Inputs[index].Name.StringValue = inputName; VideoOutputRouteFeedbacks = new FeedbackCollection<IntFeedback>();
InputNameFeedbacks = new FeedbackCollection<StringFeedback>();
InputPorts.Add(new RoutingInputPort(inputName, eRoutingSignalType.AudioVideo, OutputNameFeedbacks = new FeedbackCollection<StringFeedback>();
eRoutingPortConnectionType.Hdmi, index, this) OutputRouteNameFeedbacks = new FeedbackCollection<StringFeedback>();
{ InputHdcpEnableFeedback = new FeedbackCollection<BoolFeedback>();
FeedbackMatchObject = _Chassis.HdmiInputs[index]
}); InputPorts = new RoutingPortCollection<RoutingInputPort>();
VideoInputSyncFeedbacks.Add(new BoolFeedback(inputName, () => _Chassis.Inputs[index].VideoDetectedFeedback.BoolValue)); OutputPorts = new RoutingPortCollection<RoutingOutputPort>();
InputNameFeedbacks.Add(new StringFeedback(inputName, () => _Chassis.Inputs[index].Name.StringValue));
InputHdcpEnableFeedback.Add(new BoolFeedback(inputName, () => _Chassis.HdmiInputs[index].HdmiInputPort.HdcpSupportOnFeedback.BoolValue)); if (_Chassis.NumberOfInputs == 1)
} {
_Chassis4x1 = _Chassis as HdMd4x14kE;
for (uint i = 1; i <= _Chassis.NumberOfOutputs; i++) AutoRouteFeedback = new BoolFeedback(() => _Chassis4x1.AutoModeOnFeedback.BoolValue);
{ }
var index = i;
var outputName = OutputNames[index]; for (uint i = 1; i <= _Chassis.NumberOfInputs; i++)
_Chassis.Outputs[i].Name.StringValue = outputName; {
var index = i;
OutputPorts.Add(new RoutingOutputPort(outputName, eRoutingSignalType.AudioVideo, var inputName = InputNames[index];
eRoutingPortConnectionType.Hdmi, index, this) //_Chassis.Inputs[index].Name.StringValue = inputName;
{ _Chassis.HdmiInputs[index].Name.StringValue = inputName;
FeedbackMatchObject = _Chassis.HdmiOutputs[index]
}); InputPorts.Add(new RoutingInputPort(inputName, eRoutingSignalType.AudioVideo,
VideoOutputRouteFeedbacks.Add(new IntFeedback(outputName, () => (int)_Chassis.Outputs[index].VideoOutFeedback.Number)); eRoutingPortConnectionType.Hdmi, _Chassis.HdmiInputs[index], this)
OutputNameFeedbacks.Add(new StringFeedback(outputName, () => _Chassis.Outputs[index].Name.StringValue)); {
OutputRouteNameFeedbacks.Add(new StringFeedback(outputName, () => _Chassis.Outputs[index].VideoOutFeedback.NameFeedback.StringValue)); FeedbackMatchObject = _Chassis.HdmiInputs[index]
} });
VideoInputSyncFeedbacks.Add(new BoolFeedback(inputName, () => _Chassis.Inputs[index].VideoDetectedFeedback.BoolValue));
_Chassis.DMInputChange += new DMInputEventHandler(Chassis_DMInputChange); //InputNameFeedbacks.Add(new StringFeedback(inputName, () => _Chassis.Inputs[index].NameFeedback.StringValue));
_Chassis.DMOutputChange += new DMOutputEventHandler(Chassis_DMOutputChange); InputNameFeedbacks.Add(new StringFeedback(inputName, () => InputNames[index]));
InputHdcpEnableFeedback.Add(new BoolFeedback(inputName, () => _Chassis.HdmiInputs[index].HdmiInputPort.HdcpSupportOnFeedback.BoolValue));
AddPostActivationAction(AddFeedbackCollections); }
}
for (uint i = 1; i <= _Chassis.NumberOfOutputs; i++)
#endregion {
var index = i;
#region Methods var outputName = OutputNames[index];
//_Chassis.Outputs[index].Name.StringValue = outputName;
/// <summary> //_Chassis.HdmiOutputs[index].Name.StringValue = outputName;
/// Raise an event when the status of a switch object changes.
/// </summary> OutputPorts.Add(new RoutingOutputPort(outputName, eRoutingSignalType.AudioVideo,
/// <param name="e">Arguments defined as IKeyName sender, output, input, and eRoutingSignalType</param> eRoutingPortConnectionType.Hdmi, _Chassis.HdmiOutputs[index], this)
private void OnSwitchChange(RoutingNumericEventArgs e) {
{ FeedbackMatchObject = _Chassis.HdmiOutputs[index]
var newEvent = NumericSwitchChange; });
if (newEvent != null) newEvent(this, e); VideoOutputRouteFeedbacks.Add(new IntFeedback(outputName, () => _Chassis.Outputs[index].VideoOutFeedback == null ? 0 : (int)_Chassis.Outputs[index].VideoOutFeedback.Number));
} OutputNameFeedbacks.Add(new StringFeedback(outputName, () => OutputNames[index]));
OutputRouteNameFeedbacks.Add(new StringFeedback(outputName, () => _Chassis.Outputs[index].VideoOutFeedback.NameFeedback.StringValue));
public void EnableHdcp(uint port) }
{
if (port > _Chassis.NumberOfInputs) return; _Chassis.DMInputChange += Chassis_DMInputChange;
if (port <= 0) return; _Chassis.DMOutputChange += Chassis_DMOutputChange;
_Chassis.HdmiInputs[port].HdmiInputPort.HdcpSupportOn(); AddPostActivationAction(AddFeedbackCollections);
InputHdcpEnableFeedback[InputNames[port]].FireUpdate(); }
}
#endregion
public void DisableHdcp(uint port)
{ #region Methods
if (port > _Chassis.NumberOfInputs) return;
if (port <= 0) return; /// <summary>
/// Raise an event when the status of a switch object changes.
_Chassis.HdmiInputs[port].HdmiInputPort.HdcpSupportOff(); /// </summary>
InputHdcpEnableFeedback[InputNames[port]].FireUpdate(); /// <param name="e">Arguments defined as IKeyName sender, output, input, and eRoutingSignalType</param>
} private void OnSwitchChange(RoutingNumericEventArgs e)
{
public void EnableAutoRoute() var newEvent = NumericSwitchChange;
{ if (newEvent != null) newEvent(this, e);
if (_Chassis.NumberOfInputs != 1) return; }
if (_Chassis4x1 == null) return; public void EnableHdcp(uint port)
{
_Chassis4x1.AutoModeOn(); if (port > _Chassis.NumberOfInputs) return;
} if (port <= 0) return;
public void DisableAutoRoute() _Chassis.HdmiInputs[port].HdmiInputPort.HdcpSupportOn();
{ InputHdcpEnableFeedback[InputNames[port]].FireUpdate();
if (_Chassis.NumberOfInputs != 1) return; }
if (_Chassis4x1 == null) return; public void DisableHdcp(uint port)
{
_Chassis4x1.AutoModeOff(); if (port > _Chassis.NumberOfInputs) return;
} if (port <= 0) return;
#region PostActivate _Chassis.HdmiInputs[port].HdmiInputPort.HdcpSupportOff();
InputHdcpEnableFeedback[InputNames[port]].FireUpdate();
public void AddFeedbackCollections() }
{
AddCollectionsToList(VideoInputSyncFeedbacks, InputHdcpEnableFeedback); public void EnableAutoRoute()
AddCollectionsToList(VideoOutputRouteFeedbacks); {
AddCollectionsToList(InputNameFeedbacks, OutputNameFeedbacks, OutputRouteNameFeedbacks, DeviceNameFeedback); if (_Chassis.NumberOfInputs != 1) return;
}
if (_Chassis4x1 == null) return;
#endregion
_Chassis4x1.AutoModeOn();
#region FeedbackCollection Methods }
//Add arrays of collections public void DisableAutoRoute()
public void AddCollectionsToList(params FeedbackCollection<BoolFeedback>[] newFbs) {
{ if (_Chassis.NumberOfInputs != 1) return;
foreach (FeedbackCollection<BoolFeedback> fbCollection in newFbs)
{ if (_Chassis4x1 == null) return;
foreach (var item in newFbs)
{ _Chassis4x1.AutoModeOff();
AddCollectionToList(item); }
}
} #region PostActivate
}
public void AddCollectionsToList(params FeedbackCollection<IntFeedback>[] newFbs) public void AddFeedbackCollections()
{ {
foreach (FeedbackCollection<IntFeedback> fbCollection in newFbs) AddFeedbackToList(DeviceNameFeedback);
{ AddCollectionsToList(VideoInputSyncFeedbacks, InputHdcpEnableFeedback);
foreach (var item in newFbs) AddCollectionsToList(VideoOutputRouteFeedbacks);
{ AddCollectionsToList(InputNameFeedbacks, OutputNameFeedbacks, OutputRouteNameFeedbacks);
AddCollectionToList(item); }
}
} #endregion
}
#region FeedbackCollection Methods
public void AddCollectionsToList(params FeedbackCollection<StringFeedback>[] newFbs)
{ //Add arrays of collections
foreach (FeedbackCollection<StringFeedback> fbCollection in newFbs) public void AddCollectionsToList(params FeedbackCollection<BoolFeedback>[] newFbs)
{ {
foreach (var item in newFbs) foreach (FeedbackCollection<BoolFeedback> fbCollection in newFbs)
{ {
AddCollectionToList(item); foreach (var item in newFbs)
} {
} AddCollectionToList(item);
} }
}
//Add Collections }
public void AddCollectionToList(FeedbackCollection<BoolFeedback> newFbs) public void AddCollectionsToList(params FeedbackCollection<IntFeedback>[] newFbs)
{ {
foreach (var f in newFbs) foreach (FeedbackCollection<IntFeedback> fbCollection in newFbs)
{ {
if (f == null) continue; foreach (var item in newFbs)
{
AddFeedbackToList(f); AddCollectionToList(item);
} }
} }
}
public void AddCollectionToList(FeedbackCollection<IntFeedback> newFbs)
{ public void AddCollectionsToList(params FeedbackCollection<StringFeedback>[] newFbs)
foreach (var f in newFbs) {
{ foreach (FeedbackCollection<StringFeedback> fbCollection in newFbs)
if (f == null) continue; {
foreach (var item in newFbs)
AddFeedbackToList(f); {
} AddCollectionToList(item);
} }
}
public void AddCollectionToList(FeedbackCollection<StringFeedback> newFbs) }
{
foreach (var f in newFbs) //Add Collections
{ public void AddCollectionToList(FeedbackCollection<BoolFeedback> newFbs)
if (f == null) continue; {
foreach (var f in newFbs)
AddFeedbackToList(f); {
} if (f == null) continue;
}
AddFeedbackToList(f);
//Add Individual Feedbacks }
public void AddFeedbackToList(PepperDash.Essentials.Core.Feedback newFb) }
{
if (newFb == null) return; public void AddCollectionToList(FeedbackCollection<IntFeedback> newFbs)
{
if (!Feedbacks.Contains(newFb)) foreach (var f in newFbs)
{ {
Feedbacks.Add(newFb); if (f == null) continue;
}
} AddFeedbackToList(f);
}
#endregion }
#region IRouting Members public void AddCollectionToList(FeedbackCollection<StringFeedback> newFbs)
{
public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) foreach (var f in newFbs)
{ {
// Try to make switch only when necessary. The unit appears to toggle when already selected. if (f == null) continue;
var current = _Chassis.HdmiOutputs[(uint)outputSelector].VideoOut;
if (current != _Chassis.HdmiInputs[(uint)inputSelector]) AddFeedbackToList(f);
_Chassis.HdmiOutputs[(uint)outputSelector].VideoOut = _Chassis.HdmiInputs[(uint)inputSelector]; }
} }
#endregion //Add Individual Feedbacks
public void AddFeedbackToList(PepperDash.Essentials.Core.Feedback newFb)
#region IRoutingNumeric Members {
if (newFb == null) return;
public void ExecuteNumericSwitch(ushort inputSelector, ushort outputSelector, eRoutingSignalType signalType)
{ if (!Feedbacks.Contains(newFb))
ExecuteSwitch(inputSelector, outputSelector, signalType); {
} Feedbacks.Add(newFb);
}
#endregion }
#endregion #endregion
#region Bridge Linking #region IRouting Members
public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType)
{ {
var joinMap = new HdMdNxM4kEControllerJoinMap(joinStart); var input = inputSelector as HdMdNxMHdmiInput; //changed from HdMdNxM4kzEHdmiInput;
var output = outputSelector as HdMdNxMHdmiOutput;
var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); Debug.Console(2, this, "ExecuteSwitch: input={0} output={1}", input, output);
if (!string.IsNullOrEmpty(joinMapSerialized)) if (output == null)
joinMap = JsonConvert.DeserializeObject<HdMdNxM4kEControllerJoinMap>(joinMapSerialized); {
Debug.Console(0, this, "Unable to make switch. output selector is not HdMdNxMHdmiOutput");
if (bridge != null) return;
{ }
bridge.AddJoinMap(Key, joinMap);
} // Try to make switch only when necessary. The unit appears to toggle when already selected.
else var current = output.VideoOut;
{ if (current != input)
Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); output.VideoOut = input;
} }
IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); #endregion
DeviceNameFeedback[this.Name].LinkInputSig(trilist.StringInput[joinMap.Name.JoinNumber]);
#region IRoutingNumeric Members
if (_Chassis4x1 != null)
{ public void ExecuteNumericSwitch(ushort inputSelector, ushort outputSelector, eRoutingSignalType signalType)
trilist.SetSigTrueAction(joinMap.EnableAutoRoute.JoinNumber, () => _Chassis4x1.AutoModeOn()); {
trilist.SetSigFalseAction(joinMap.EnableAutoRoute.JoinNumber, () => _Chassis4x1.AutoModeOff()); var input = inputSelector == 0 ? null : _Chassis.HdmiInputs[inputSelector];
AutoRouteFeedback[this.Name + "-" + InputNames[1]].LinkInputSig(trilist.BooleanInput[joinMap.EnableAutoRoute.JoinNumber]); var output = _Chassis.HdmiOutputs[outputSelector];
}
Debug.Console(2, this, "ExecuteNumericSwitch: input={0} output={1}", input, output);
for (uint i = 1; i <= _Chassis.NumberOfInputs; i++)
{ ExecuteSwitch(input, output, signalType);
var joinIndex = i - 1; }
//Digital
VideoInputSyncFeedbacks[InputNames[i]].LinkInputSig(trilist.BooleanInput[joinMap.InputSync.JoinNumber + joinIndex]); #endregion
InputHdcpEnableFeedback[InputNames[i]].LinkInputSig(trilist.BooleanInput[joinMap.EnableInputHdcp.JoinNumber + joinIndex]);
InputHdcpEnableFeedback[InputNames[i]].LinkComplementInputSig(trilist.BooleanInput[joinMap.DisableInputHdcp.JoinNumber + joinIndex]); #endregion
trilist.SetSigTrueAction(joinMap.EnableInputHdcp.JoinNumber + joinIndex, () => EnableHdcp(i));
trilist.SetSigTrueAction(joinMap.DisableInputHdcp.JoinNumber + joinIndex, () => DisableHdcp(i)); #region Bridge Linking
//Serial public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
InputNameFeedbacks[InputNames[i]].LinkInputSig(trilist.StringInput[joinMap.InputName.JoinNumber + joinIndex]); {
} var joinMap = new HdMdNxM4kEControllerJoinMap(joinStart);
for (uint i = 1; i <= _Chassis.NumberOfOutputs; i++) var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey);
{
var joinIndex = i - 1; if (!string.IsNullOrEmpty(joinMapSerialized))
//Analog joinMap = JsonConvert.DeserializeObject<HdMdNxM4kEControllerJoinMap>(joinMapSerialized);
VideoOutputRouteFeedbacks[OutputNames[i]].LinkInputSig(trilist.UShortInput[joinMap.OutputRoute.JoinNumber + joinIndex]);
trilist.SetUShortSigAction(joinMap.OutputRoute.JoinNumber + joinIndex, (a) => ExecuteSwitch(a, i, eRoutingSignalType.AudioVideo)); if (bridge != null)
{
//Serial bridge.AddJoinMap(Key, joinMap);
OutputNameFeedbacks[OutputNames[i]].LinkInputSig(trilist.StringInput[joinMap.OutputName.JoinNumber + joinIndex]); }
OutputRouteNameFeedbacks[OutputNames[i]].LinkInputSig(trilist.StringInput[joinMap.OutputRoutedName.JoinNumber + joinIndex]); else
} {
Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
_Chassis.OnlineStatusChange += new Crestron.SimplSharpPro.OnlineStatusChangeEventHandler(Chassis_OnlineStatusChange); }
trilist.OnlineStatusChange += new Crestron.SimplSharpPro.OnlineStatusChangeEventHandler((d, args) => IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]);
{ DeviceNameFeedback.LinkInputSig(trilist.StringInput[joinMap.Name.JoinNumber]);
if (args.DeviceOnLine)
{ if (_Chassis4x1 != null)
foreach (var feedback in Feedbacks) {
{ trilist.SetSigTrueAction(joinMap.EnableAutoRoute.JoinNumber, () => _Chassis4x1.AutoModeOn());
feedback.FireUpdate(); trilist.SetSigFalseAction(joinMap.EnableAutoRoute.JoinNumber, () => _Chassis4x1.AutoModeOff());
} AutoRouteFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableAutoRoute.JoinNumber]);
} }
});
} for (uint i = 1; i <= _Chassis.NumberOfInputs; i++)
{
var joinIndex = i - 1;
#endregion var input = i;
//Digital
#region Events VideoInputSyncFeedbacks[InputNames[input]].LinkInputSig(trilist.BooleanInput[joinMap.InputSync.JoinNumber + joinIndex]);
InputHdcpEnableFeedback[InputNames[input]].LinkInputSig(trilist.BooleanInput[joinMap.EnableInputHdcp.JoinNumber + joinIndex]);
void Chassis_OnlineStatusChange(Crestron.SimplSharpPro.GenericBase currentDevice, Crestron.SimplSharpPro.OnlineOfflineEventArgs args) InputHdcpEnableFeedback[InputNames[input]].LinkComplementInputSig(trilist.BooleanInput[joinMap.DisableInputHdcp.JoinNumber + joinIndex]);
{ trilist.SetSigTrueAction(joinMap.EnableInputHdcp.JoinNumber + joinIndex, () => EnableHdcp(input));
if (!args.DeviceOnLine) return; trilist.SetSigTrueAction(joinMap.DisableInputHdcp.JoinNumber + joinIndex, () => DisableHdcp(input));
for (uint i = 1; i <= _Chassis.NumberOfInputs; i++)
{ //Serial
_Chassis.Inputs[i].Name.StringValue = InputNames[i]; InputNameFeedbacks[InputNames[input]].LinkInputSig(trilist.StringInput[joinMap.InputName.JoinNumber + joinIndex]);
} }
for (uint i = 1; i <= _Chassis.NumberOfOutputs; i++)
{ for (uint i = 1; i <= _Chassis.NumberOfOutputs; i++)
_Chassis.Outputs[i].Name.StringValue = OutputNames[i]; {
} var joinIndex = i - 1;
var output = i;
//Analog
VideoOutputRouteFeedbacks[OutputNames[output]].LinkInputSig(trilist.UShortInput[joinMap.OutputRoute.JoinNumber + joinIndex]);
trilist.SetUShortSigAction(joinMap.OutputRoute.JoinNumber + joinIndex, (a) => ExecuteNumericSwitch(a, (ushort) output, eRoutingSignalType.AudioVideo));
//Serial
OutputNameFeedbacks[OutputNames[output]].LinkInputSig(trilist.StringInput[joinMap.OutputName.JoinNumber + joinIndex]);
OutputRouteNameFeedbacks[OutputNames[output]].LinkInputSig(trilist.StringInput[joinMap.OutputRoutedName.JoinNumber + joinIndex]);
}
_Chassis.OnlineStatusChange += Chassis_OnlineStatusChange;
trilist.OnlineStatusChange += (d, args) =>
{
if (!args.DeviceOnLine) return;
// feedback updates was moved to the Chassis_OnlineStatusChange
// due to the amount of time it takes for the device to come online
};
}
#endregion
#region Events
void Chassis_OnlineStatusChange(Crestron.SimplSharpPro.GenericBase currentDevice, Crestron.SimplSharpPro.OnlineOfflineEventArgs args)
{
IsOnline.FireUpdate();
if (!args.DeviceOnLine) return;
foreach (var feedback in Feedbacks) foreach (var feedback in Feedbacks)
{ {
feedback.FireUpdate(); feedback.FireUpdate();
} }
}
void Chassis_DMOutputChange(Switch device, DMOutputEventArgs args) if (_Chassis4x1 != null)
{ AutoRouteFeedback.FireUpdate();
if (args.EventId != DMOutputEventIds.VideoOutEventId) return; }
for (var i = 0; i < VideoOutputRouteFeedbacks.Count; i++) void Chassis_DMOutputChange(Switch device, DMOutputEventArgs args)
{ {
var index = i; if (args.EventId != DMOutputEventIds.VideoOutEventId) return;
var localInputPort = InputPorts.FirstOrDefault(p => (DMInput)p.FeedbackMatchObject == _Chassis.HdmiOutputs[(uint)index + 1].VideoOutFeedback);
var localOutputPort =
OutputPorts.FirstOrDefault(p => (DMOutput)p.FeedbackMatchObject == _Chassis.HdmiOutputs[(uint)index + 1]);
var output = args.Number;
VideoOutputRouteFeedbacks[i].FireUpdate(); var inputNumber = _Chassis.HdmiOutputs[output].VideoOutFeedback == null
OnSwitchChange(new RoutingNumericEventArgs((ushort)i, VideoOutputRouteFeedbacks[i].UShortValue, localOutputPort, localInputPort, eRoutingSignalType.AudioVideo)); ? 0
} : _Chassis.HdmiOutputs[output].VideoOutFeedback.Number;
}
void Chassis_DMInputChange(Switch device, DMInputEventArgs args) var outputName = OutputNames[output];
{
if (args.EventId != DMInputEventIds.VideoDetectedEventId) return;
foreach (var item in VideoInputSyncFeedbacks)
{
item.FireUpdate();
}
}
#endregion var feedback = VideoOutputRouteFeedbacks[outputName];
#region Factory if (feedback == null)
{
return;
}
var inPort =
InputPorts.FirstOrDefault(p => p.FeedbackMatchObject == _Chassis.HdmiOutputs[output].VideoOutFeedback);
var outPort = OutputPorts.FirstOrDefault(p => p.FeedbackMatchObject == _Chassis.HdmiOutputs[output]);
public class HdMdNxM4kEControllerFactory : EssentialsDeviceFactory<HdMdNxM4kEBridgeableController> feedback.FireUpdate();
{ OnSwitchChange(new RoutingNumericEventArgs(output, inputNumber, outPort, inPort, eRoutingSignalType.AudioVideo));
public HdMdNxM4kEControllerFactory() }
{
TypeNames = new List<string>() { "hdmd4x14ke-bridgeable", "hdmd4x24ke", "hdmd6x24ke" };
}
public override EssentialsDevice BuildDevice(DeviceConfig dc) void Chassis_DMInputChange(Switch device, DMInputEventArgs args)
{ {
Debug.Console(1, "Factory Attempting to create new HD-MD-NxM-4K-E Device"); switch (args.EventId)
{
case DMInputEventIds.VideoDetectedEventId:
{
Debug.Console(1, this, "Event ID {0}: Updating VideoInputSyncFeedbacks", args.EventId);
foreach (var item in VideoInputSyncFeedbacks)
{
item.FireUpdate();
}
break;
}
case DMInputEventIds.InputNameFeedbackEventId:
case DMInputEventIds.InputNameEventId:
case DMInputEventIds.NameFeedbackEventId:
{
Debug.Console(1, this, "Event ID {0}: Updating name feedbacks.", args.EventId);
Debug.Console(1, this, "Input {0} Name {1}", args.Number,
_Chassis.HdmiInputs[args.Number].NameFeedback.StringValue);
foreach (var item in InputNameFeedbacks)
{
item.FireUpdate();
}
break;
}
default:
{
Debug.Console(1, this, "Unhandled DM Input Event ID {0}", args.EventId);
break;
}
}
}
var props = JsonConvert.DeserializeObject<HdMdNxM4kEBridgeablePropertiesConfig>(dc.Properties.ToString()); #endregion
var type = dc.Type.ToLower(); #region Factory
var control = props.Control;
var ipid = control.IpIdInt;
var address = control.TcpSshProperties.Address;
switch (type) public class HdMdNxM4kEControllerFactory : EssentialsDeviceFactory<HdMdNxM4kEBridgeableController>
{ {
case ("hdmd4x14ke-bridgeable"): public HdMdNxM4kEControllerFactory()
return new HdMdNxM4kEBridgeableController(dc.Key, dc.Name, new HdMd4x14kE(ipid, address, Global.ControlSystem), props); {
case ("hdmd4x24ke"): TypeNames = new List<string>() { "hdmd4x14ke-bridgeable", "hdmd4x24ke", "hdmd6x24ke" };
return new HdMdNxM4kEBridgeableController(dc.Key, dc.Name, new HdMd4x24kE(ipid, address, Global.ControlSystem), props); }
case ("hdmd6x24ke"):
return new HdMdNxM4kEBridgeableController(dc.Key, dc.Name, new HdMd6x24kE(ipid, address, Global.ControlSystem), props);
default:
return null;
}
}
}
#endregion public override EssentialsDevice BuildDevice(DeviceConfig dc)
{
Debug.Console(1, "Factory Attempting to create new HD-MD-NxM-4K-E Device");
var props = JsonConvert.DeserializeObject<HdMdNxM4kEBridgeablePropertiesConfig>(dc.Properties.ToString());
var type = dc.Type.ToLower();
var control = props.Control;
var ipid = control.IpIdInt;
var address = control.TcpSshProperties.Address;
switch (type)
{
case ("hdmd4x14ke-bridgeable"):
return new HdMdNxM4kEBridgeableController(dc.Key, dc.Name, new HdMd4x14kE(ipid, address, Global.ControlSystem), props);
case ("hdmd4x24ke"):
return new HdMdNxM4kEBridgeableController(dc.Key, dc.Name, new HdMd4x24kE(ipid, address, Global.ControlSystem), props);
case ("hdmd6x24ke"):
return new HdMdNxM4kEBridgeableController(dc.Key, dc.Name, new HdMd6x24kE(ipid, address, Global.ControlSystem), props);
default:
return null;
}
}
}
#endregion
} }
} }

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Text.RegularExpressions;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using Crestron.SimplSharpPro.DM; using Crestron.SimplSharpPro.DM;
using Newtonsoft.Json; using Newtonsoft.Json;
@@ -13,6 +14,7 @@ using PepperDash.Essentials.DM.Config;
namespace PepperDash.Essentials.DM.Chassis namespace PepperDash.Essentials.DM.Chassis
{ {
[Obsolete("Please use HdMdNxM4kEBridgeable Controller")]
public class HdMdNxM4kEController : CrestronGenericBaseDevice, IRoutingInputsOutputs, IRouting public class HdMdNxM4kEController : CrestronGenericBaseDevice, IRoutingInputsOutputs, IRouting
{ {
public HdMdNxM Chassis { get; private set; } public HdMdNxM Chassis { get; private set; }
@@ -31,6 +33,7 @@ namespace PepperDash.Essentials.DM.Chassis
HdMdNxM4kEPropertiesConfig props) HdMdNxM4kEPropertiesConfig props)
: base(key, name, chassis) : base(key, name, chassis)
{ {
Debug.Console(0, this, "Type hdmd4x14ke is obsolete. Please use hdmd4x14ke-bridgeable");
Chassis = chassis; Chassis = chassis;
// logical ports // logical ports
@@ -47,10 +50,15 @@ namespace PepperDash.Essentials.DM.Chassis
// physical settings // physical settings
if (props != null && props.Inputs != null) if (props != null && props.Inputs != null)
{ {
var inputRegex = new Regex(@"(?<InputNum>\d)", RegexOptions.IgnoreCase);
foreach (var kvp in props.Inputs) foreach (var kvp in props.Inputs)
{ {
// strip "hdmiIn" // get numnbers from key and convert to int
var inputNum = Convert.ToUInt32(kvp.Key.Substring(6)); //var inputNum = Convert.ToUInt32(kvp.Key.Substring(6));
var inputMatch = inputRegex.Match(kvp.Key);
if (inputMatch == null) continue;
var inputNum = Convert.ToUInt32(inputMatch.Groups["InputNum"].Value);
var port = chassis.HdmiInputs[inputNum].HdmiInputPort; var port = chassis.HdmiInputs[inputNum].HdmiInputPort;
// set hdcp disables // set hdcp disables