diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/Dge100Controller.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/Dge100Controller.cs index ea220a13..1130f654 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/Dge100Controller.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/Dge100Controller.cs @@ -17,11 +17,12 @@ using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Config; using Crestron.SimplSharpPro.DeviceSupport; using PepperDash.Essentials.Core.DeviceInfo; +using PepperDash.Essentials.Core.Bridges; namespace PepperDash.Essentials.DM.Endpoints.DGEs { [Description("Wrapper class for DGE-100")] - public class Dge100Controller : CrestronGenericBaseDevice, IComPorts, IIROutputPorts, IHasBasicTriListWithSmartObject, ICec, IDeviceInfoProvider + public class Dge100Controller : CrestronGenericBaseDevice, IComPorts, IIROutputPorts, IHasBasicTriListWithSmartObject, ICec, IDeviceInfoProvider, IBridgeAdvanced { private const int CtpPort = 41795; private readonly Dge100 _dge; @@ -30,9 +31,12 @@ namespace PepperDash.Essentials.DM.Endpoints.DGEs public BasicTriListWithSmartObject Panel { get { return _dge; } } - private DeviceConfig _dc; + private DeviceConfig _dc; + + public VideoStatusOutputs VideoStatusFeedbacks { get; private set; } + + CrestronTouchpanelPropertiesConfig PropertiesConfig; - CrestronTouchpanelPropertiesConfig PropertiesConfig; public Dge100Controller(string key, string name, Dge100 device, DeviceConfig dc, CrestronTouchpanelPropertiesConfig props) :base(key, name, device) @@ -48,8 +52,20 @@ namespace PepperDash.Essentials.DM.Endpoints.DGEs _dc = dc; - PropertiesConfig = props; - } + PropertiesConfig = props; + + var videoStatusFuncs = new VideoStatusFuncsWrapper + { + HdcpActiveFeedbackFunc = () => _dge.HdmiIn.HdcpSupportOnFeedback.BoolValue, + VideoResolutionFeedbackFunc = () => _dge.HdmiIn.VideoAttributes.GetVideoResolutionString(), + VideoSyncFeedbackFunc = () => _dge.HdmiIn.SyncDetectedFeedback.BoolValue, + }; + + VideoStatusFeedbacks = new VideoStatusOutputs(videoStatusFuncs); + + _dge.HdmiIn.StreamChange += (s,a) => VideoStatusFeedbacks.FireAll(); + _dge.HdmiIn.VideoAttributes.AttributeChange += (o, a) => VideoStatusFeedbacks.FireAll(); + } #region IComPorts Members @@ -187,6 +203,58 @@ namespace PepperDash.Essentials.DM.Endpoints.DGEs handler(this, new DeviceInfoEventArgs(DeviceInfo)); } + #endregion + + #region IBridgeAdvanced Members + + public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + var joinMap = new DgeJoinMap(joinStart); + + var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + if (bridge != null) + { + bridge.AddJoinMap(Key, joinMap); + } + else + { + Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); + } + + Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + + //Presses + trilist.SetSigTrueAction(joinMap.HdmiInHdcpOn.JoinNumber, () => _dge.HdmiIn.HdcpSupportOn()); + trilist.SetSigTrueAction(joinMap.HdmiInHdcpOff.JoinNumber,() => _dge.HdmiIn.HdcpSupportOff()); + trilist.SetSigTrueAction(joinMap.HdmiInHdcpToggle.JoinNumber, () => { + if(_dge.HdmiIn.HdcpSupportOnFeedback.BoolValue) + { + _dge.HdmiIn.HdcpSupportOff(); + return; + } + + _dge.HdmiIn.HdcpSupportOn(); + }); + + + // Feedbacks + VideoStatusFeedbacks.HdcpActiveFeedback.LinkInputSig(trilist.BooleanInput[joinMap.HdmiInHdcpOn.JoinNumber]); + VideoStatusFeedbacks.HdcpActiveFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.HdmiInHdcpOff.JoinNumber]); + + trilist.OnlineStatusChange += (o, a) => + { + if (!a.DeviceOnLine) return; + + VideoStatusFeedbacks.FireAll(); + }; + } + + + #endregion }