Not Complete - Still Adding Feedbacks, Bridge, and JoinMaps

This commit is contained in:
Trevor Payne
2020-05-14 17:20:19 -05:00
parent 7882210eaf
commit aef491855c
3 changed files with 182 additions and 117 deletions

View File

@@ -53,7 +53,7 @@ namespace PepperDash.Essentials.Core
public ConfigSnippetAttribute(string configSnippet) public ConfigSnippetAttribute(string configSnippet)
{ {
Debug.Console(2, "Setting Description {0}", configSnippet); Debug.Console(2, "Setting Config Snippet {0}", configSnippet);
_ConfigSnippet = configSnippet; _ConfigSnippet = configSnippet;
} }
@@ -83,8 +83,9 @@ namespace PepperDash.Essentials.Core
foreach (var typeName in TypeNames) foreach (var typeName in TypeNames)
{ {
Debug.Console(2, "Getting Description Attribute from class: '{0}'", typeof(T).FullName); Debug.Console(2, "Getting Description Attribute from class: '{0}'", typeof(T).FullName);
var attributes = typeof(T).GetCustomAttributes(typeof(DescriptionAttribute), true) as DescriptionAttribute[]; var descriptionAttribute = typeof(T).GetCustomAttributes(typeof(DescriptionAttribute), true) as DescriptionAttribute[];
string description = attributes[0].Description; string description = descriptionAttribute[0].Description;
var snippetAttribute = typeof(T).GetCustomAttributes(typeof(ConfigSnippetAttribute), true) as ConfigSnippetAttribute[];
DeviceFactory.AddFactoryForType(typeName.ToLower(), description, typeof(T), BuildDevice); DeviceFactory.AddFactoryForType(typeName.ToLower(), description, typeof(T), BuildDevice);
} }
} }

View File

@@ -2,22 +2,32 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using Newtonsoft.Json;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using Crestron.SimplSharpPro.DM; using Crestron.SimplSharpPro.DM;
using PepperDash.Core; using PepperDash.Core;
using PepperDash.Essentials.Core; using PepperDash.Essentials.Core;
using PepperDash.Essentials.DM.Config; using PepperDash.Essentials.DM.Config;
using PepperDash.Essentials.Core.Bridges;
using PepperDash.Essentials.Core.Config;
namespace PepperDash.Essentials.DM.Chassis namespace PepperDash.Essentials.DM.Chassis
{ {
public class HdMdNxM4kEController : Device, IRoutingInputsOutputs, IRouting public class HdMdNxM4kEController : EssentialsBridgeableDevice, IRoutingInputsOutputs, IRouting
{ {
public HdMdNxM Chassis { get; private set; } public HdMdNxM Chassis { get; private 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<IntFeedback> VideoOutputRouteFeedbacks { get; private set; }
public FeedbackCollection<StringFeedback> InputNameFeedbacks { get; private set; }
public FeedbackCollection<StringFeedback> OutputNameFeedbacks { get; private set; }
public FeedbackCollection<StringFeedback> OutputRouteNameFeedbacks { get; private set; }
/// <summary> /// <summary>
/// ///
@@ -31,16 +41,31 @@ namespace PepperDash.Essentials.DM.Chassis
{ {
Chassis = chassis; Chassis = chassis;
var _props = props;
VideoInputSyncFeedbacks = new FeedbackCollection<BoolFeedback>();
VideoOutputRouteFeedbacks = new FeedbackCollection<IntFeedback>();
InputNameFeedbacks = new FeedbackCollection<StringFeedback>();
OutputNameFeedbacks = new FeedbackCollection<StringFeedback>();
OutputRouteNameFeedbacks = new FeedbackCollection<StringFeedback>();
// logical ports // logical ports
InputPorts = new RoutingPortCollection<RoutingInputPort>(); InputPorts = new RoutingPortCollection<RoutingInputPort>();
for (uint i = 1; i <= 4; i++) for (uint i = 1; i <= Chassis.NumberOfInputs; i++)
{ {
InputPorts.Add(new RoutingInputPort("hdmiIn" + i, eRoutingSignalType.Audio | eRoutingSignalType.Video, InputPorts.Add(new RoutingInputPort("hdmiIn" + i, eRoutingSignalType.AudioVideo,
eRoutingPortConnectionType.Hdmi, i, this)); 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));
} }
OutputPorts = new RoutingPortCollection<RoutingOutputPort>(); OutputPorts = new RoutingPortCollection<RoutingOutputPort>();
OutputPorts.Add(new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, for (uint i = 1; i <= Chassis.NumberOfOutputs; i++)
eRoutingPortConnectionType.Hdmi, null, this)); {
OutputPorts.Add(new RoutingOutputPort("hdmiOut" + i, eRoutingSignalType.AudioVideo,
eRoutingPortConnectionType.Hdmi, i, this));
VideoOutputRouteFeedbacks.Add(new IntFeedback(i.ToString(), () => (int)Chassis.Outputs[i].VideoOutFeedback.Number));
}
// physical settings // physical settings
if (props != null && props.Inputs != null) if (props != null && props.Inputs != null)
@@ -61,6 +86,31 @@ namespace PepperDash.Essentials.DM.Chassis
port.HdcpSupportOn(); port.HdcpSupportOn();
} }
} }
Chassis.DMInputChange += new DMInputEventHandler(Chassis_DMInputChange);
Chassis.DMOutputChange += new DMOutputEventHandler(Chassis_DMOutputChange);
}
void Chassis_DMOutputChange(Switch device, DMOutputEventArgs args)
{
if (args.EventId == DMOutputEventIds.VideoOutEventId)
{
foreach (var item in VideoOutputRouteFeedbacks)
{
item.FireUpdate();
}
}
}
void Chassis_DMInputChange(Switch device, DMInputEventArgs args)
{
if (args.EventId == DMInputEventIds.VideoDetectedEventId)
{
foreach (var item in VideoInputSyncFeedbacks)
{
item.FireUpdate();
}
}
} }
public override bool CustomActivate() public override bool CustomActivate()
@@ -72,6 +122,8 @@ namespace PepperDash.Essentials.DM.Chassis
return false; return false;
} }
return base.CustomActivate(); return base.CustomActivate();
} }
@@ -82,42 +134,51 @@ namespace PepperDash.Essentials.DM.Chassis
public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType)
{ {
// Try to make switch only when necessary. The unit appears to toggle when already selected. // Try to make switch only when necessary. The unit appears to toggle when already selected.
var current = Chassis.HdmiOutputs[1].VideoOut; var current = Chassis.HdmiOutputs[(uint)outputSelector].VideoOut;
if (current != Chassis.HdmiInputs[(uint)inputSelector]) if (current != Chassis.HdmiInputs[(uint)inputSelector])
Chassis.HdmiOutputs[1].VideoOut = Chassis.HdmiInputs[(uint)inputSelector]; Chassis.HdmiOutputs[(uint)outputSelector].VideoOut = Chassis.HdmiInputs[(uint)inputSelector];
} }
#endregion #endregion
///////////////////////////////////////////////////// /////////////////////////////////////////////////////
/// <summary>
///
/// </summary>
/// <param name="key"></param>
/// <param name="name"></param>
/// <param name="type"></param>
/// <param name="properties"></param>
/// <returns></returns>
public static HdMdNxM4kEController GetController(string key, string name,
string type, HdMdNxM4kEPropertiesConfig properties)
{
try
{
var ipid = properties.Control.IpIdInt;
var address = properties.Control.TcpSshProperties.Address;
type = type.ToLower(); public class HdMdNxM4kEControllerFactory : EssentialsDeviceFactory<HdMdNxM4kEController>
if (type == "hdmd4x14ke")
{ {
var chassis = new HdMd4x14kE(ipid, address, Global.ControlSystem); public HdMdNxM4kEControllerFactory()
return new HdMdNxM4kEController(key, name, chassis, properties);
}
return null;
}
catch (Exception e)
{ {
Debug.Console(0, "ERROR Creating device key {0}: \r{1}", key, e); TypeNames = new List<string>() { "hdmd4x14ke", "hdmd4x24ke", "hdmd6x24ke" };
}
public override EssentialsDevice BuildDevice(DeviceConfig dc)
{
Debug.Console(1, "Factory Attempting to create new HD-MD-NxM-4K-E Device");
var props = JsonConvert.DeserializeObject<HdMdNxM4kEPropertiesConfig>(dc.Properties.ToString());
var type = dc.Type.ToLower();
var control = props.Control;
var ipid = control.IpIdInt;
var address = control.TcpSshProperties.Address;
if (type.StartsWith("hdmd4x14ke"))
{
return new HdMdNxM4kEController(dc.Key, dc.Name, new HdMd4x14kE(ipid, address, Global.ControlSystem), props);
}
else if (type.StartsWith("hdmd4x24ke"))
{
return new HdMdNxM4kEController(dc.Key, dc.Name, new HdMd4x24kE(ipid, address, Global.ControlSystem), props);
}
else if (type.StartsWith("hdmd6x24ke"))
{
return new HdMdNxM4kEController(dc.Key, dc.Name, new HdMd6x24kE(ipid, address, Global.ControlSystem), props);
}
return null; return null;
} }
} }

View File

@@ -19,5 +19,8 @@ namespace PepperDash.Essentials.DM.Config
[JsonProperty("inputs")] [JsonProperty("inputs")]
public Dictionary<string, InputPropertiesConfig> Inputs { get; set; } public Dictionary<string, InputPropertiesConfig> Inputs { get; set; }
[JsonProperty("outputs"]
public Dictionary<string, OutputPropertiesConfig>
} }
} }