Compare commits

...

3 Commits

Author SHA1 Message Date
Andrew Welker
00f4635cec chore: Mark non-bridgeable class obsolete
Also add a debug message to give the new type to use.
2021-07-30 10:44:26 -06:00
Andrew Welker
d61401c9a9 fix: Remove reference to DMOutput name sig
the HD-MD series of switchers appears to not populate the Name sig of the DMOutput, leading to a NullSig exception when attempting to set output names. This is probably because those names can't be set on the device itself, but some experimentation with hardware may be required to determine that completely.
2021-07-30 10:30:32 -06:00
Jason DeVito
7af8f0d087 Updates to HdMdNxM4kEController.cs to implement regex pattern in place of substring on input definitions. Updated HdMdNxM4kEBridgeableController.cs to handle exception when constructing the device. 2021-07-29 17:19:54 -05:00
2 changed files with 450 additions and 420 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,442 @@ 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 FeedbackCollection<StringFeedback> DeviceNameFeedback { get; private set; }
public FeedbackCollection<BoolFeedback> AutoRouteFeedback { get; private set; } public FeedbackCollection<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;
if (props == null)
InputNames = props.Inputs; {
OutputNames = props.Outputs; Debug.Console(1, this, "HdMdNx4keBridgeableController properties are null, failed to build the device");
return;
VideoInputSyncFeedbacks = new FeedbackCollection<BoolFeedback>(); }
VideoOutputRouteFeedbacks = new FeedbackCollection<IntFeedback>();
InputNameFeedbacks = new FeedbackCollection<StringFeedback>();
OutputNameFeedbacks = new FeedbackCollection<StringFeedback>(); if (props.Inputs != null)
OutputRouteNameFeedbacks = new FeedbackCollection<StringFeedback>(); {
InputHdcpEnableFeedback = new FeedbackCollection<BoolFeedback>(); foreach (var kvp in props.Inputs)
DeviceNameFeedback = new FeedbackCollection<StringFeedback>(); {
AutoRouteFeedback = new FeedbackCollection<BoolFeedback>(); Debug.Console(0, this, "props.Inputs: {0}-{1}", kvp.Key, kvp.Value);
}
InputPorts = new RoutingPortCollection<RoutingInputPort>(); InputNames = props.Inputs;
OutputPorts = new RoutingPortCollection<RoutingOutputPort>(); }
if (props.Outputs != null)
DeviceNameFeedback.Add(new StringFeedback(this.Name, () => this.Name)); {
foreach (var kvp in props.Outputs)
if (_Chassis.NumberOfInputs == 1) {
{ Debug.Console(0, this, "props.Outputs: {0}-{1}", kvp.Key, kvp.Value);
_Chassis4x1 = _Chassis as HdMd4x14kE; }
AutoRouteFeedback.Add(new BoolFeedback(this.Name + "-" + InputNames[1], () => _Chassis4x1.AutoModeOnFeedback.BoolValue)); OutputNames = props.Outputs;
} }
for (uint i = 1; i <= _Chassis.NumberOfInputs; i++) VideoInputSyncFeedbacks = new FeedbackCollection<BoolFeedback>();
{ VideoOutputRouteFeedbacks = new FeedbackCollection<IntFeedback>();
var index = i; InputNameFeedbacks = new FeedbackCollection<StringFeedback>();
var inputName = InputNames[index]; OutputNameFeedbacks = new FeedbackCollection<StringFeedback>();
_Chassis.Inputs[index].Name.StringValue = inputName; OutputRouteNameFeedbacks = new FeedbackCollection<StringFeedback>();
InputHdcpEnableFeedback = new FeedbackCollection<BoolFeedback>();
InputPorts.Add(new RoutingInputPort(inputName, eRoutingSignalType.AudioVideo, DeviceNameFeedback = new FeedbackCollection<StringFeedback>();
eRoutingPortConnectionType.Hdmi, index, this) AutoRouteFeedback = new FeedbackCollection<BoolFeedback>();
{
FeedbackMatchObject = _Chassis.HdmiInputs[index] InputPorts = new RoutingPortCollection<RoutingInputPort>();
}); OutputPorts = new RoutingPortCollection<RoutingOutputPort>();
VideoInputSyncFeedbacks.Add(new BoolFeedback(inputName, () => _Chassis.Inputs[index].VideoDetectedFeedback.BoolValue));
InputNameFeedbacks.Add(new StringFeedback(inputName, () => _Chassis.Inputs[index].Name.StringValue)); var deviceName = string.IsNullOrEmpty(this.Name) ? name : this.Name;
InputHdcpEnableFeedback.Add(new BoolFeedback(inputName, () => _Chassis.HdmiInputs[index].HdmiInputPort.HdcpSupportOnFeedback.BoolValue)); DeviceNameFeedback.Add(new StringFeedback(deviceName, () => deviceName));
}
if (_Chassis.NumberOfInputs == 1)
for (uint i = 1; i <= _Chassis.NumberOfOutputs; i++) {
{ _Chassis4x1 = _Chassis as HdMd4x14kE;
var index = i; AutoRouteFeedback.Add(new BoolFeedback(deviceName + "-" + InputNames[1], () => _Chassis4x1.AutoModeOnFeedback.BoolValue));
var outputName = OutputNames[index]; }
_Chassis.Outputs[i].Name.StringValue = outputName;
for (uint i = 1; i <= _Chassis.NumberOfInputs; i++)
OutputPorts.Add(new RoutingOutputPort(outputName, eRoutingSignalType.AudioVideo, {
eRoutingPortConnectionType.Hdmi, index, this) var index = i;
{ var inputName = InputNames[index];
FeedbackMatchObject = _Chassis.HdmiOutputs[index] _Chassis.Inputs[index].Name.StringValue = inputName;
});
VideoOutputRouteFeedbacks.Add(new IntFeedback(outputName, () => (int)_Chassis.Outputs[index].VideoOutFeedback.Number)); InputPorts.Add(new RoutingInputPort(inputName, eRoutingSignalType.AudioVideo,
OutputNameFeedbacks.Add(new StringFeedback(outputName, () => _Chassis.Outputs[index].Name.StringValue)); eRoutingPortConnectionType.Hdmi, index, this)
OutputRouteNameFeedbacks.Add(new StringFeedback(outputName, () => _Chassis.Outputs[index].VideoOutFeedback.NameFeedback.StringValue)); {
} FeedbackMatchObject = _Chassis.HdmiInputs[index]
});
_Chassis.DMInputChange += new DMInputEventHandler(Chassis_DMInputChange); VideoInputSyncFeedbacks.Add(new BoolFeedback(inputName, () => _Chassis.Inputs[index].VideoDetectedFeedback.BoolValue));
_Chassis.DMOutputChange += new DMOutputEventHandler(Chassis_DMOutputChange); InputNameFeedbacks.Add(new StringFeedback(inputName, () => _Chassis.Inputs[index].Name.StringValue));
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[i].Name.StringValue = outputName;
/// <summary>
/// Raise an event when the status of a switch object changes. OutputPorts.Add(new RoutingOutputPort(outputName, eRoutingSignalType.AudioVideo,
/// </summary> eRoutingPortConnectionType.Hdmi, index, this)
/// <param name="e">Arguments defined as IKeyName sender, output, input, and eRoutingSignalType</param> {
private void OnSwitchChange(RoutingNumericEventArgs e) FeedbackMatchObject = _Chassis.HdmiOutputs[index]
{ });
var newEvent = NumericSwitchChange; VideoOutputRouteFeedbacks.Add(new IntFeedback(outputName, () => (int)_Chassis.Outputs[index].VideoOutFeedback.Number));
if (newEvent != null) newEvent(this, e); OutputNameFeedbacks.Add(new StringFeedback(outputName, () => OutputNames[index]));
} OutputRouteNameFeedbacks.Add(new StringFeedback(outputName, () => _Chassis.Outputs[index].VideoOutFeedback.NameFeedback.StringValue));
}
public void EnableHdcp(uint port)
{ _Chassis.DMInputChange += Chassis_DMInputChange;
if (port > _Chassis.NumberOfInputs) return; _Chassis.DMOutputChange += Chassis_DMOutputChange;
if (port <= 0) return;
AddPostActivationAction(AddFeedbackCollections);
_Chassis.HdmiInputs[port].HdmiInputPort.HdcpSupportOn(); }
InputHdcpEnableFeedback[InputNames[port]].FireUpdate();
} #endregion
public void DisableHdcp(uint port) #region Methods
{
if (port > _Chassis.NumberOfInputs) return; /// <summary>
if (port <= 0) return; /// Raise an event when the status of a switch object changes.
/// </summary>
_Chassis.HdmiInputs[port].HdmiInputPort.HdcpSupportOff(); /// <param name="e">Arguments defined as IKeyName sender, output, input, and eRoutingSignalType</param>
InputHdcpEnableFeedback[InputNames[port]].FireUpdate(); private void OnSwitchChange(RoutingNumericEventArgs e)
} {
var newEvent = NumericSwitchChange;
public void EnableAutoRoute() if (newEvent != null) newEvent(this, e);
{ }
if (_Chassis.NumberOfInputs != 1) return;
public void EnableHdcp(uint port)
if (_Chassis4x1 == null) return; {
if (port > _Chassis.NumberOfInputs) return;
_Chassis4x1.AutoModeOn(); if (port <= 0) return;
}
_Chassis.HdmiInputs[port].HdmiInputPort.HdcpSupportOn();
public void DisableAutoRoute() InputHdcpEnableFeedback[InputNames[port]].FireUpdate();
{ }
if (_Chassis.NumberOfInputs != 1) return;
public void DisableHdcp(uint port)
if (_Chassis4x1 == null) return; {
if (port > _Chassis.NumberOfInputs) return;
_Chassis4x1.AutoModeOff(); if (port <= 0) return;
}
_Chassis.HdmiInputs[port].HdmiInputPort.HdcpSupportOff();
#region PostActivate InputHdcpEnableFeedback[InputNames[port]].FireUpdate();
}
public void AddFeedbackCollections()
{ public void EnableAutoRoute()
AddCollectionsToList(VideoInputSyncFeedbacks, InputHdcpEnableFeedback); {
AddCollectionsToList(VideoOutputRouteFeedbacks); if (_Chassis.NumberOfInputs != 1) return;
AddCollectionsToList(InputNameFeedbacks, OutputNameFeedbacks, OutputRouteNameFeedbacks, DeviceNameFeedback);
} if (_Chassis4x1 == null) return;
#endregion _Chassis4x1.AutoModeOn();
}
#region FeedbackCollection Methods
public void DisableAutoRoute()
//Add arrays of collections {
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 AddFeedbackCollections()
public void AddCollectionsToList(params FeedbackCollection<IntFeedback>[] newFbs) {
{ AddCollectionsToList(VideoInputSyncFeedbacks, InputHdcpEnableFeedback);
foreach (FeedbackCollection<IntFeedback> fbCollection in newFbs) AddCollectionsToList(VideoOutputRouteFeedbacks);
{ AddCollectionsToList(InputNameFeedbacks, OutputNameFeedbacks, OutputRouteNameFeedbacks, DeviceNameFeedback);
foreach (var item in newFbs) }
{
AddCollectionToList(item); #endregion
}
} #region FeedbackCollection Methods
}
//Add arrays of collections
public void AddCollectionsToList(params FeedbackCollection<StringFeedback>[] newFbs) public void AddCollectionsToList(params FeedbackCollection<BoolFeedback>[] newFbs)
{ {
foreach (FeedbackCollection<StringFeedback> fbCollection in newFbs) foreach (FeedbackCollection<BoolFeedback> fbCollection in newFbs)
{ {
foreach (var item in newFbs) foreach (var item in newFbs)
{ {
AddCollectionToList(item); AddCollectionToList(item);
} }
} }
} }
public void AddCollectionsToList(params FeedbackCollection<IntFeedback>[] newFbs)
//Add Collections {
public void AddCollectionToList(FeedbackCollection<BoolFeedback> newFbs) foreach (FeedbackCollection<IntFeedback> fbCollection in newFbs)
{ {
foreach (var f in newFbs) foreach (var item in newFbs)
{ {
if (f == null) continue; AddCollectionToList(item);
}
AddFeedbackToList(f); }
} }
}
public void AddCollectionsToList(params FeedbackCollection<StringFeedback>[] newFbs)
public void AddCollectionToList(FeedbackCollection<IntFeedback> newFbs) {
{ foreach (FeedbackCollection<StringFeedback> fbCollection in newFbs)
foreach (var f in newFbs) {
{ foreach (var item in newFbs)
if (f == null) continue; {
AddCollectionToList(item);
AddFeedbackToList(f); }
} }
} }
public void AddCollectionToList(FeedbackCollection<StringFeedback> newFbs) //Add Collections
{ public void AddCollectionToList(FeedbackCollection<BoolFeedback> newFbs)
foreach (var f in newFbs) {
{ foreach (var f in newFbs)
if (f == null) continue; {
if (f == null) continue;
AddFeedbackToList(f);
} AddFeedbackToList(f);
} }
}
//Add Individual Feedbacks
public void AddFeedbackToList(PepperDash.Essentials.Core.Feedback newFb) public void AddCollectionToList(FeedbackCollection<IntFeedback> newFbs)
{ {
if (newFb == null) return; foreach (var f in newFbs)
{
if (!Feedbacks.Contains(newFb)) if (f == null) continue;
{
Feedbacks.Add(newFb); AddFeedbackToList(f);
} }
} }
#endregion public void AddCollectionToList(FeedbackCollection<StringFeedback> newFbs)
{
#region IRouting Members foreach (var f in newFbs)
{
public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) if (f == null) continue;
{
// Try to make switch only when necessary. The unit appears to toggle when already selected. AddFeedbackToList(f);
var current = _Chassis.HdmiOutputs[(uint)outputSelector].VideoOut; }
if (current != _Chassis.HdmiInputs[(uint)inputSelector]) }
_Chassis.HdmiOutputs[(uint)outputSelector].VideoOut = _Chassis.HdmiInputs[(uint)inputSelector];
} //Add Individual Feedbacks
public void AddFeedbackToList(PepperDash.Essentials.Core.Feedback newFb)
#endregion {
if (newFb == null) return;
#region IRoutingNumeric Members
if (!Feedbacks.Contains(newFb))
public void ExecuteNumericSwitch(ushort inputSelector, ushort outputSelector, eRoutingSignalType signalType) {
{ Feedbacks.Add(newFb);
ExecuteSwitch(inputSelector, outputSelector, signalType); }
} }
#endregion #endregion
#endregion #region IRouting Members
#region Bridge Linking public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType)
{
public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) // Try to make switch only when necessary. The unit appears to toggle when already selected.
{ var current = _Chassis.HdmiOutputs[(uint)outputSelector].VideoOut;
var joinMap = new HdMdNxM4kEControllerJoinMap(joinStart); if (current != _Chassis.HdmiInputs[(uint)inputSelector])
_Chassis.HdmiOutputs[(uint)outputSelector].VideoOut = _Chassis.HdmiInputs[(uint)inputSelector];
var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); }
if (!string.IsNullOrEmpty(joinMapSerialized)) #endregion
joinMap = JsonConvert.DeserializeObject<HdMdNxM4kEControllerJoinMap>(joinMapSerialized);
#region IRoutingNumeric Members
if (bridge != null)
{ public void ExecuteNumericSwitch(ushort inputSelector, ushort outputSelector, eRoutingSignalType signalType)
bridge.AddJoinMap(Key, joinMap); {
} ExecuteSwitch(inputSelector, outputSelector, signalType);
else }
{
Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); #endregion
}
#endregion
IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]);
DeviceNameFeedback[this.Name].LinkInputSig(trilist.StringInput[joinMap.Name.JoinNumber]); #region Bridge Linking
if (_Chassis4x1 != null) public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
{ {
trilist.SetSigTrueAction(joinMap.EnableAutoRoute.JoinNumber, () => _Chassis4x1.AutoModeOn()); var joinMap = new HdMdNxM4kEControllerJoinMap(joinStart);
trilist.SetSigFalseAction(joinMap.EnableAutoRoute.JoinNumber, () => _Chassis4x1.AutoModeOff());
AutoRouteFeedback[this.Name + "-" + InputNames[1]].LinkInputSig(trilist.BooleanInput[joinMap.EnableAutoRoute.JoinNumber]); var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey);
}
if (!string.IsNullOrEmpty(joinMapSerialized))
for (uint i = 1; i <= _Chassis.NumberOfInputs; i++) joinMap = JsonConvert.DeserializeObject<HdMdNxM4kEControllerJoinMap>(joinMapSerialized);
{
var joinIndex = i - 1; if (bridge != null)
//Digital {
VideoInputSyncFeedbacks[InputNames[i]].LinkInputSig(trilist.BooleanInput[joinMap.InputSync.JoinNumber + joinIndex]); bridge.AddJoinMap(Key, joinMap);
InputHdcpEnableFeedback[InputNames[i]].LinkInputSig(trilist.BooleanInput[joinMap.EnableInputHdcp.JoinNumber + joinIndex]); }
InputHdcpEnableFeedback[InputNames[i]].LinkComplementInputSig(trilist.BooleanInput[joinMap.DisableInputHdcp.JoinNumber + joinIndex]); else
trilist.SetSigTrueAction(joinMap.EnableInputHdcp.JoinNumber + joinIndex, () => EnableHdcp(i)); {
trilist.SetSigTrueAction(joinMap.DisableInputHdcp.JoinNumber + joinIndex, () => DisableHdcp(i)); Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
}
//Serial
InputNameFeedbacks[InputNames[i]].LinkInputSig(trilist.StringInput[joinMap.InputName.JoinNumber + joinIndex]); IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]);
} DeviceNameFeedback[this.Name].LinkInputSig(trilist.StringInput[joinMap.Name.JoinNumber]);
for (uint i = 1; i <= _Chassis.NumberOfOutputs; i++) if (_Chassis4x1 != null)
{ {
var joinIndex = i - 1; trilist.SetSigTrueAction(joinMap.EnableAutoRoute.JoinNumber, () => _Chassis4x1.AutoModeOn());
//Analog trilist.SetSigFalseAction(joinMap.EnableAutoRoute.JoinNumber, () => _Chassis4x1.AutoModeOff());
VideoOutputRouteFeedbacks[OutputNames[i]].LinkInputSig(trilist.UShortInput[joinMap.OutputRoute.JoinNumber + joinIndex]); AutoRouteFeedback[this.Name + "-" + InputNames[1]].LinkInputSig(trilist.BooleanInput[joinMap.EnableAutoRoute.JoinNumber]);
trilist.SetUShortSigAction(joinMap.OutputRoute.JoinNumber + joinIndex, (a) => ExecuteSwitch(a, i, eRoutingSignalType.AudioVideo)); }
//Serial for (uint i = 1; i <= _Chassis.NumberOfInputs; i++)
OutputNameFeedbacks[OutputNames[i]].LinkInputSig(trilist.StringInput[joinMap.OutputName.JoinNumber + joinIndex]); {
OutputRouteNameFeedbacks[OutputNames[i]].LinkInputSig(trilist.StringInput[joinMap.OutputRoutedName.JoinNumber + joinIndex]); var joinIndex = i - 1;
} //Digital
VideoInputSyncFeedbacks[InputNames[i]].LinkInputSig(trilist.BooleanInput[joinMap.InputSync.JoinNumber + joinIndex]);
_Chassis.OnlineStatusChange += new Crestron.SimplSharpPro.OnlineStatusChangeEventHandler(Chassis_OnlineStatusChange); InputHdcpEnableFeedback[InputNames[i]].LinkInputSig(trilist.BooleanInput[joinMap.EnableInputHdcp.JoinNumber + joinIndex]);
InputHdcpEnableFeedback[InputNames[i]].LinkComplementInputSig(trilist.BooleanInput[joinMap.DisableInputHdcp.JoinNumber + joinIndex]);
trilist.OnlineStatusChange += new Crestron.SimplSharpPro.OnlineStatusChangeEventHandler((d, args) => trilist.SetSigTrueAction(joinMap.EnableInputHdcp.JoinNumber + joinIndex, () => EnableHdcp(i));
{ trilist.SetSigTrueAction(joinMap.DisableInputHdcp.JoinNumber + joinIndex, () => DisableHdcp(i));
if (args.DeviceOnLine)
{ //Serial
foreach (var feedback in Feedbacks) InputNameFeedbacks[InputNames[i]].LinkInputSig(trilist.StringInput[joinMap.InputName.JoinNumber + joinIndex]);
{ }
feedback.FireUpdate();
} for (uint i = 1; i <= _Chassis.NumberOfOutputs; 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));
#endregion
//Serial
#region Events OutputNameFeedbacks[OutputNames[i]].LinkInputSig(trilist.StringInput[joinMap.OutputName.JoinNumber + joinIndex]);
OutputRouteNameFeedbacks[OutputNames[i]].LinkInputSig(trilist.StringInput[joinMap.OutputRoutedName.JoinNumber + joinIndex]);
void Chassis_OnlineStatusChange(Crestron.SimplSharpPro.GenericBase currentDevice, Crestron.SimplSharpPro.OnlineOfflineEventArgs args) }
{
if (!args.DeviceOnLine) return; _Chassis.OnlineStatusChange += Chassis_OnlineStatusChange;
for (uint i = 1; i <= _Chassis.NumberOfInputs; i++)
{ trilist.OnlineStatusChange += (d, args) =>
_Chassis.Inputs[i].Name.StringValue = InputNames[i]; {
} if (args.DeviceOnLine)
for (uint i = 1; i <= _Chassis.NumberOfOutputs; i++) {
{ foreach (var feedback in Feedbacks)
_Chassis.Outputs[i].Name.StringValue = OutputNames[i]; {
} feedback.FireUpdate();
}
foreach (var feedback in Feedbacks) }
{ };
feedback.FireUpdate(); }
}
}
#endregion
void Chassis_DMOutputChange(Switch device, DMOutputEventArgs args)
{ #region Events
if (args.EventId != DMOutputEventIds.VideoOutEventId) return;
void Chassis_OnlineStatusChange(Crestron.SimplSharpPro.GenericBase currentDevice, Crestron.SimplSharpPro.OnlineOfflineEventArgs args)
for (var i = 0; i < VideoOutputRouteFeedbacks.Count; i++) {
{ if (!args.DeviceOnLine) return;
var index = i; for (uint i = 1; i <= _Chassis.NumberOfInputs; i++)
var localInputPort = InputPorts.FirstOrDefault(p => (DMInput)p.FeedbackMatchObject == _Chassis.HdmiOutputs[(uint)index + 1].VideoOutFeedback); {
var localOutputPort = _Chassis.Inputs[i].Name.StringValue = InputNames[i];
OutputPorts.FirstOrDefault(p => (DMOutput)p.FeedbackMatchObject == _Chassis.HdmiOutputs[(uint)index + 1]); }
for (uint i = 1; i <= _Chassis.NumberOfOutputs; i++)
{
VideoOutputRouteFeedbacks[i].FireUpdate(); _Chassis.Outputs[i].Name.StringValue = OutputNames[i];
OnSwitchChange(new RoutingNumericEventArgs((ushort)i, VideoOutputRouteFeedbacks[i].UShortValue, localOutputPort, localInputPort, eRoutingSignalType.AudioVideo)); }
}
} foreach (var feedback in Feedbacks)
{
void Chassis_DMInputChange(Switch device, DMInputEventArgs args) feedback.FireUpdate();
{ }
if (args.EventId != DMInputEventIds.VideoDetectedEventId) return; }
foreach (var item in VideoInputSyncFeedbacks)
{ void Chassis_DMOutputChange(Switch device, DMOutputEventArgs args)
item.FireUpdate(); {
} if (args.EventId != DMOutputEventIds.VideoOutEventId) return;
}
for (var i = 0; i < VideoOutputRouteFeedbacks.Count; i++)
#endregion {
var index = i;
#region Factory var localInputPort = InputPorts.FirstOrDefault(p => (DMInput)p.FeedbackMatchObject == _Chassis.HdmiOutputs[(uint)index + 1].VideoOutFeedback);
var localOutputPort =
public class HdMdNxM4kEControllerFactory : EssentialsDeviceFactory<HdMdNxM4kEBridgeableController> OutputPorts.FirstOrDefault(p => (DMOutput)p.FeedbackMatchObject == _Chassis.HdmiOutputs[(uint)index + 1]);
{
public HdMdNxM4kEControllerFactory()
{ VideoOutputRouteFeedbacks[i].FireUpdate();
TypeNames = new List<string>() { "hdmd4x14ke-bridgeable", "hdmd4x24ke", "hdmd6x24ke" }; OnSwitchChange(new RoutingNumericEventArgs((ushort)i, VideoOutputRouteFeedbacks[i].UShortValue, localOutputPort, localInputPort, eRoutingSignalType.AudioVideo));
} }
}
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"); {
if (args.EventId != DMInputEventIds.VideoDetectedEventId) return;
var props = JsonConvert.DeserializeObject<HdMdNxM4kEBridgeablePropertiesConfig>(dc.Properties.ToString()); foreach (var item in VideoInputSyncFeedbacks)
{
var type = dc.Type.ToLower(); item.FireUpdate();
var control = props.Control; }
var ipid = control.IpIdInt; }
var address = control.TcpSshProperties.Address;
#endregion
switch (type)
{ #region Factory
case ("hdmd4x14ke-bridgeable"):
return new HdMdNxM4kEBridgeableController(dc.Key, dc.Name, new HdMd4x14kE(ipid, address, Global.ControlSystem), props); public class HdMdNxM4kEControllerFactory : EssentialsDeviceFactory<HdMdNxM4kEBridgeableController>
case ("hdmd4x24ke"): {
return new HdMdNxM4kEBridgeableController(dc.Key, dc.Name, new HdMd4x24kE(ipid, address, Global.ControlSystem), props); public HdMdNxM4kEControllerFactory()
case ("hdmd6x24ke"): {
return new HdMdNxM4kEBridgeableController(dc.Key, dc.Name, new HdMd6x24kE(ipid, address, Global.ControlSystem), props); TypeNames = new List<string>() { "hdmd4x14ke-bridgeable", "hdmd4x24ke", "hdmd6x24ke" };
default: }
return null;
} public override EssentialsDevice BuildDevice(DeviceConfig dc)
} {
} Debug.Console(1, "Factory Attempting to create new HD-MD-NxM-4K-E Device");
#endregion 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