From 112a2b7382534ae813c0bc0642fb4e8c06ef45c7 Mon Sep 17 00:00:00 2001 From: jta Date: Tue, 20 Dec 2022 15:16:18 -0500 Subject: [PATCH 01/96] feature: fileio now uses Global.FilePathPrefix as its directory All read wirtes now use the current working essentials directory. This resolves issues between 3 series, 4 series, and VC-4 --- .../PepperDashEssentialsBase/File/FileIO.cs | 63 ++++++++++--------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/File/FileIO.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/File/FileIO.cs index 51d64230..6cc83fb7 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/File/FileIO.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/File/FileIO.cs @@ -21,35 +21,37 @@ namespace PepperDash.Essentials.Core /// /// /// - public static FileInfo[] GetFiles(string fileName) - { - DirectoryInfo dirInfo = new DirectoryInfo(Path.GetDirectoryName(fileName)); - var files = dirInfo.GetFiles(Path.GetFileName(fileName)); - Debug.Console(0, "FileIO found: {0}, {1}", files.Count(), fileName); - if (files.Count() > 0) - { - return files; - } - else - { - return null; - } - } + public static FileInfo[] GetFiles(string fileName) + { + string fullFilePath = Global.FilePathPrefix + "/" + fileName; + DirectoryInfo dirInfo = new DirectoryInfo(Path.GetDirectoryName(fullFilePath)); + var files = dirInfo.GetFiles(Path.GetFileName(fullFilePath)); + Debug.Console(0, "FileIO found: {0}, {1}", files.Count(), fullFilePath); + if (files.Count() > 0) + { + return files; + } + else + { + return null; + } + } - public static FileInfo GetFile(string fileName) - { - DirectoryInfo dirInfo = new DirectoryInfo(Path.GetDirectoryName(fileName)); - var files = dirInfo.GetFiles(Path.GetFileName(fileName)); - Debug.Console(0, "FileIO found: {0}, {1}", files.Count(), fileName); - if (files.Count() > 0) - { - return files.FirstOrDefault(); - } - else - { - return null; - } - } + public static FileInfo GetFile(string fileName) + { + string fullFilePath = Global.FilePathPrefix + "/" + fileName; + DirectoryInfo dirInfo = new DirectoryInfo(Path.GetDirectoryName(fullFilePath)); + var files = dirInfo.GetFiles(Path.GetFileName(fullFilePath)); + Debug.Console(0, "FileIO found: {0}, {1}", files.Count(), fullFilePath); + if (files.Count() > 0) + { + return files.FirstOrDefault(); + } + else + { + return null; + } + } /// @@ -202,7 +204,7 @@ namespace PepperDash.Essentials.Core public static void WriteDataToFile(string data, string filePath) { Thread _WriteFileThread; - _WriteFileThread = new Thread((O) => _WriteFileMethod(data, filePath), null, Thread.eThreadStartOptions.CreateSuspended); + _WriteFileThread = new Thread((O) => _WriteFileMethod(data, Global.FilePathPrefix + "/" + filePath), null, Thread.eThreadStartOptions.CreateSuspended); _WriteFileThread.Priority = Thread.eThreadPriority.LowestPriority; _WriteFileThread.Start(); Debug.Console(0, Debug.ErrorLogLevel.Notice, "New WriteFile Thread"); @@ -217,7 +219,8 @@ namespace PepperDash.Essentials.Core { if (fileLock.TryEnter()) { - using (StreamWriter sw = new StreamWriter(filePath)) + + using (StreamWriter sw = new StreamWriter(filePath)) { sw.Write(data); sw.Flush(); From 3b2fa8aec53dde0cbc8d306698491dddaba9b3f5 Mon Sep 17 00:00:00 2001 From: jta Date: Mon, 9 Jan 2023 17:16:03 -0500 Subject: [PATCH 02/96] fix: issue with file path on four sereis refactor: remove redundnet / --- .../Essentials Core/PepperDashEssentialsBase/File/FileIO.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/File/FileIO.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/File/FileIO.cs index 6cc83fb7..49b70a0c 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/File/FileIO.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/File/FileIO.cs @@ -23,7 +23,7 @@ namespace PepperDash.Essentials.Core /// public static FileInfo[] GetFiles(string fileName) { - string fullFilePath = Global.FilePathPrefix + "/" + fileName; + string fullFilePath = Global.FilePathPrefix + fileName; DirectoryInfo dirInfo = new DirectoryInfo(Path.GetDirectoryName(fullFilePath)); var files = dirInfo.GetFiles(Path.GetFileName(fullFilePath)); Debug.Console(0, "FileIO found: {0}, {1}", files.Count(), fullFilePath); @@ -39,7 +39,7 @@ namespace PepperDash.Essentials.Core public static FileInfo GetFile(string fileName) { - string fullFilePath = Global.FilePathPrefix + "/" + fileName; + string fullFilePath = Global.FilePathPrefix + fileName; DirectoryInfo dirInfo = new DirectoryInfo(Path.GetDirectoryName(fullFilePath)); var files = dirInfo.GetFiles(Path.GetFileName(fullFilePath)); Debug.Console(0, "FileIO found: {0}, {1}", files.Count(), fullFilePath); @@ -83,7 +83,7 @@ namespace PepperDash.Essentials.Core { if (fileLock.TryEnter()) { - DirectoryInfo dirInfo = new DirectoryInfo(file.Name); + DirectoryInfo dirInfo = new DirectoryInfo(file.DirectoryName); Debug.Console(2, "FileIO Getting Data {0}", file.FullName); if (File.Exists(file.FullName)) From 5de4382cd0009ad413fe3566807e5dbe8bfc034c Mon Sep 17 00:00:00 2001 From: Alex Johnson Date: Wed, 18 Jan 2023 15:45:42 -0500 Subject: [PATCH 03/96] Fixes for hdbaset endpoints on DMPS3 non-4k chassis. Adds ability to connect Essentials room volumes to DMPS volume control. --- .../Audio/EssentialsVolumeLevelConfig.cs | 23 +++++- .../Endpoints/Receivers/DmRmcHelper.cs | 72 ++++++++++++------- .../Endpoints/Transmitters/DmTxHelpers.cs | 37 +++++++--- 3 files changed, 96 insertions(+), 36 deletions(-) diff --git a/PepperDashEssentials/Audio/EssentialsVolumeLevelConfig.cs b/PepperDashEssentials/Audio/EssentialsVolumeLevelConfig.cs index 12108564..d8af5a55 100644 --- a/PepperDashEssentials/Audio/EssentialsVolumeLevelConfig.cs +++ b/PepperDashEssentials/Audio/EssentialsVolumeLevelConfig.cs @@ -55,7 +55,7 @@ namespace PepperDash.Essentials return null; } - // DSP format: deviceKey--levelName, biampTesira-1--master + // DSP/DMPS format: deviceKey--levelName, biampTesira-1--master match = Regex.Match(DeviceKey, @"([-_\w]+)--(.+)"); if (match.Success) { @@ -67,6 +67,27 @@ namespace PepperDash.Essentials if (dsp.LevelControlPoints.ContainsKey(levelTag)) // should always... return dsp.LevelControlPoints[levelTag]; } + + var dmps = DeviceManager.GetDeviceForKey(devKey) as DmpsAudioOutputController; + if (dmps != null) + { + var levelTag = match.Groups[2].Value; + switch (levelTag) + { + case "master": + return dmps.MasterVolumeLevel; + case "source": + return dmps.SourceVolumeLevel; + case "micsmaster": + return dmps.MicsMasterVolumeLevel; + case "codec1": + return dmps.Codec1VolumeLevel; + case "codec2": + return dmps.Codec2VolumeLevel; + default: + return dmps.MasterVolumeLevel; + } + } // No volume for some reason. We have failed as developers return null; } diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs index 5d644a2a..e237c3a5 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs @@ -329,6 +329,9 @@ namespace PepperDash.Essentials.DM DmRmcPropertiesConfig props, string pKey, uint ipid) { var parentDev = DeviceManager.GetDeviceForKey(pKey); + CrestronGenericBaseDevice rx; + bool useChassisForOfflineFeedback = false; + if (parentDev is DmpsRoutingController) { var dmps = parentDev as DmpsRoutingController; @@ -342,22 +345,33 @@ namespace PepperDash.Essentials.DM return null; } // Must use different constructor for DMPS4K types. No IPID - if (Global.ControlSystemIsDmps4kType || typeName == "hdbasetrx" || typeName == "dmrmc4k100c1g") + if (Global.ControlSystemIsDmps4kType) { - var rmc = GetDmRmcControllerForDmps4k(key, name, typeName, dmps, props.ParentOutputNumber); - Debug.Console(0, "DM endpoint output {0} is for Dmps4k, changing online feedback to chassis", num); - rmc.IsOnline.SetValueFunc(() => dmps.OutputEndpointOnlineFeedbacks[num].BoolValue); + rx = GetDmRmcControllerForDmps4k(key, name, typeName, dmps, props.ParentOutputNumber); + useChassisForOfflineFeedback = true; + } + else + { + rx = GetDmRmcControllerForDmps(key, name, typeName, ipid, dmps, props.ParentOutputNumber); + if (typeName == "hdbasetrx" || typeName == "dmrmc4k100c1g") + { + useChassisForOfflineFeedback = true; + } + } + if (useChassisForOfflineFeedback) + { + Debug.Console(0, "DM endpoint output {0} does not have direct online feedback, changing online feedback to chassis", num); + rx.IsOnline.SetValueFunc(() => dmps.OutputEndpointOnlineFeedbacks[num].BoolValue); dmps.OutputEndpointOnlineFeedbacks[num].OutputChange += (o, a) => { - foreach (var feedback in rmc.Feedbacks) + foreach (var feedback in rx.Feedbacks) { if (feedback != null) feedback.FireUpdate(); } }; - return rmc; } - return GetDmRmcControllerForDmps(key, name, typeName, ipid, dmps, props.ParentOutputNumber); + return rx; } else if (parentDev is DmChassisController) { @@ -380,23 +394,33 @@ namespace PepperDash.Essentials.DM if (chassis is DmMd8x8Cpu3 || chassis is DmMd16x16Cpu3 || chassis is DmMd32x32Cpu3 || chassis is DmMd8x8Cpu3rps || chassis is DmMd16x16Cpu3rps || chassis is DmMd32x32Cpu3rps || - chassis is DmMd128x128 || chassis is DmMd64x64 - || typeName == "hdbasetrx" || typeName == "dmrmc4k100c1g") + chassis is DmMd128x128 || chassis is DmMd64x64) { - var rmc = GetDmRmcControllerForCpu3Chassis(key, name, typeName, chassis, num, parentDev); - Debug.Console(0, "DM endpoint output {0} is for Cpu3, changing online feedback to chassis", num); - rmc.IsOnline.SetValueFunc(() => controller.OutputEndpointOnlineFeedbacks[num].BoolValue); - controller.OutputEndpointOnlineFeedbacks[num].OutputChange += (o, a) => - { - foreach (var feedback in rmc.Feedbacks) - { - if (feedback != null) - feedback.FireUpdate(); - } - }; - return rmc; + rx = GetDmRmcControllerForCpu3Chassis(key, name, typeName, chassis, num, parentDev); + useChassisForOfflineFeedback = true; } - return GetDmRmcControllerForCpu2Chassis(key, name, typeName, ipid, chassis, num, parentDev); + else + { + rx = GetDmRmcControllerForCpu2Chassis(key, name, typeName, ipid, chassis, num, parentDev); + if (typeName == "hdbasetrx" || typeName == "dmrmc4k100c1g") + { + useChassisForOfflineFeedback = true; + } + } + if (useChassisForOfflineFeedback) + { + Debug.Console(0, "DM endpoint output {0} does not have direct online feedback, changing online feedback to chassis", num); + rx.IsOnline.SetValueFunc(() => controller.OutputEndpointOnlineFeedbacks[num].BoolValue); + controller.OutputEndpointOnlineFeedbacks[num].OutputChange += (o, a) => + { + foreach (var feedback in rx.Feedbacks) + { + if (feedback != null) + feedback.FireUpdate(); + } + }; + } + return rx; } catch (Exception e) { @@ -499,9 +523,7 @@ namespace PepperDash.Essentials.DM Debug.Console(0, "[{0}] WARNING: Cannot create DM-RMC device: {1}", key, e.Message); return null; } - } - - + } } public class DmRmcControllerFactory : EssentialsDeviceFactory diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTxHelpers.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTxHelpers.cs index d707ebd3..86160ced 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTxHelpers.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTxHelpers.cs @@ -126,6 +126,7 @@ namespace PepperDash.Essentials.DM var parentDev = DeviceManager.GetDeviceForKey(pKey); DMInput dmInput; BasicDmTxControllerBase tx; + bool useChassisForOfflineFeedback = false; if (parentDev is DmChassisController) { @@ -155,15 +156,23 @@ namespace PepperDash.Essentials.DM chassis is DmMd128x128 || chassis is DmMd64x64) { tx = GetDmTxForChassisWithoutIpId(key, name, typeName, dmInput); - Debug.Console(0, "DM endpoint output {0} is for Cpu3, changing online feedback to chassis", num); - tx.IsOnline.SetValueFunc(() => switchDev.InputEndpointOnlineFeedbacks[num].BoolValue); - switchDev.InputEndpointOnlineFeedbacks[num].OutputChange += (o, a) => tx.IsOnline.FireUpdate(); - return tx; + useChassisForOfflineFeedback = true; } else { - return GetDmTxForChassisWithIpId(key, name, typeName, ipid, dmInput); + tx = GetDmTxForChassisWithIpId(key, name, typeName, ipid, dmInput); + if (typeName == "hdbasettx" || typeName == "dmtx4k100c1g") + { + useChassisForOfflineFeedback = true; + } } + if (useChassisForOfflineFeedback) + { + Debug.Console(0, "DM endpoint output {0} does not have direct online feedback, changing online feedback to chassis", num); + tx.IsOnline.SetValueFunc(() => switchDev.InputEndpointOnlineFeedbacks[num].BoolValue); + switchDev.InputEndpointOnlineFeedbacks[num].OutputChange += (o, a) => tx.IsOnline.FireUpdate(); + } + return tx; } catch (Exception e) { @@ -203,15 +212,23 @@ namespace PepperDash.Essentials.DM if(Global.ControlSystemIsDmps4kType) { tx = GetDmTxForChassisWithoutIpId(key, name, typeName, dmInput); - Debug.Console(0, "DM endpoint output {0} is for DMPS3-4K, changing online feedback to chassis", num); - tx.IsOnline.SetValueFunc(() => dmpsDev.InputEndpointOnlineFeedbacks[num].BoolValue); - dmpsDev.InputEndpointOnlineFeedbacks[num].OutputChange += (o, a) => tx.IsOnline.FireUpdate(); - return tx; + useChassisForOfflineFeedback = true; } else { - return GetDmTxForChassisWithIpId(key, name, typeName, ipid, dmInput); + tx = GetDmTxForChassisWithIpId(key, name, typeName, ipid, dmInput); + if (typeName == "hdbasettx" || typeName == "dmtx4k100c1g") + { + useChassisForOfflineFeedback = true; + } } + if (useChassisForOfflineFeedback) + { + Debug.Console(0, "DM endpoint output {0} does not have direct online feedback, changing online feedback to chassis", num); + tx.IsOnline.SetValueFunc(() => dmpsDev.InputEndpointOnlineFeedbacks[num].BoolValue); + dmpsDev.InputEndpointOnlineFeedbacks[num].OutputChange += (o, a) => tx.IsOnline.FireUpdate(); + } + return tx; } catch (Exception e) { From 4919a863c33c0e4298f34c8a60fa276fb8b2b840 Mon Sep 17 00:00:00 2001 From: jdevito Date: Thu, 2 Feb 2023 17:58:08 -0600 Subject: [PATCH 04/96] System Monitor Bridge updates Add processor reboot to join map and controller class. Add program reset to join map and controller class. --- .../Bridges/JoinMaps/SystemMonitorJoinMap.cs | 19 ++++++- .../Monitoring/SystemMonitorController.cs | 52 +++++++++++++++++-- 2 files changed, 67 insertions(+), 4 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/SystemMonitorJoinMap.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/SystemMonitorJoinMap.cs index 363d389b..8e352bc5 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/SystemMonitorJoinMap.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/SystemMonitorJoinMap.cs @@ -47,7 +47,7 @@ namespace PepperDash.Essentials.Core.Bridges [JoinName("ProgramOffsetJoin")] public JoinDataComplete ProgramOffsetJoin = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 5 }, new JoinMetadata { Description = "All Program Data is offset between slots by 5 - First Joins Start at 11", JoinCapabilities = eJoinCapabilities.None, JoinType = eJoinType.None }); - + [JoinName("ProgramStart")] public JoinDataComplete ProgramStart = new JoinDataComplete(new JoinData { JoinNumber = 11, JoinSpan = 1 }, new JoinMetadata { Description = "Processor Program Start / Fb", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); @@ -132,6 +132,23 @@ namespace PepperDash.Essentials.Core.Bridges public JoinDataComplete DhcpStatus = new JoinDataComplete(new JoinData { JoinNumber = 86, JoinSpan = 1 }, new JoinMetadata { Description = "Processor Ethernet Dhcp Status", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + [JoinName("ProcessorRebot")] + public JoinDataComplete ProcessorReboot = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "Reboot processor", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("IsAppliance")] + public JoinDataComplete IsAppliance = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "Is appliance Fb", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("IsServer")] + public JoinDataComplete IsServer = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, + new JoinMetadata { Description = "Is server Fb", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("ProgramReset")] + public JoinDataComplete ProgramReset = new JoinDataComplete(new JoinData { JoinNumber = 15, JoinSpan = 1 }, + new JoinMetadata { Description = "Resets the program", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + /// /// Constructor to use when instantiating this Join Map without inheriting from it /// diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Monitoring/SystemMonitorController.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Monitoring/SystemMonitorController.cs index 056686b1..319a0a3c 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Monitoring/SystemMonitorController.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Monitoring/SystemMonitorController.cs @@ -43,7 +43,20 @@ namespace PepperDash.Essentials.Core.Monitoring public StringFeedback UptimeFeedback { get; set; } public StringFeedback LastStartFeedback { get; set; } - public SystemMonitorController(string key) + public BoolFeedback IsApplianceFeedback { get; protected set; } + private bool _isApplianceFb + { + get { return CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance; } + } + + public BoolFeedback IsServerFeedback { get; protected set; } + private bool _isServerFb + { + get { return CrestronEnvironment.DevicePlatform == eDevicePlatform.Server; } + } + + + public SystemMonitorController(string key) : base(key) { Debug.Console(2, this, "Adding SystemMonitorController."); @@ -63,6 +76,9 @@ namespace PepperDash.Essentials.Core.Monitoring UptimeFeedback = new StringFeedback(() => _uptime); LastStartFeedback = new StringFeedback(()=> _lastStart); + IsApplianceFeedback = new BoolFeedback(() => _isApplianceFb); + IsServerFeedback = new BoolFeedback(() => _isServerFb); + ProgramStatusFeedbackCollection = new Dictionary(); foreach (var prog in SystemMonitor.ProgramCollection) @@ -123,6 +139,26 @@ namespace PepperDash.Essentials.Core.Monitoring _uptime = uptimeRaw.Substring(forIndex + 4); } + private static void ProcessorReboot() + { + if (CrestronEnvironment.DevicePlatform == eDevicePlatform.Server) return; + + var response = string.Empty; + CrestronConsole.SendControlSystemCommand("reboot", ref response); + } + + private static void ProgramReset(uint index) + { + if (CrestronEnvironment.DevicePlatform == eDevicePlatform.Server) return; + + if (index <= 0 || index > 10) return; + + var cmd = string.Format("progreset -p:{0}", index); + + var response = string.Empty; + CrestronConsole.SendControlSystemCommand(cmd, ref response); + } + private void CrestronEnvironmentOnEthernetEventHandler(EthernetEventArgs ethernetEventArgs) { if (ethernetEventArgs.EthernetEventType != eEthernetEventType.LinkUp) return; @@ -185,6 +221,9 @@ namespace PepperDash.Essentials.Core.Monitoring SerialNumberFeedback.FireUpdate(); ModelFeedback.FireUpdate(); + IsApplianceFeedback.FireUpdate(); + IsServerFeedback.FireUpdate(); + OnSystemMonitorPropertiesChanged(); } @@ -237,6 +276,11 @@ namespace PepperDash.Essentials.Core.Monitoring UptimeFeedback.LinkInputSig(trilist.StringInput[joinMap.Uptime.JoinNumber]); LastStartFeedback.LinkInputSig(trilist.StringInput[joinMap.LastBoot.JoinNumber]); + trilist.SetSigHeldAction(joinMap.ProcessorReboot.JoinNumber, 10000, ProcessorReboot); + + IsApplianceFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsAppliance.JoinNumber]); + IsServerFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsServer.JoinNumber]); + // iterate the program status feedback collection and map all the joins LinkProgramInfoJoins(this, trilist, joinMap); @@ -301,11 +345,13 @@ namespace PepperDash.Essentials.Core.Monitoring p.Value.AggregatedProgramInfoFeedback.LinkInputSig( trilist.StringInput[programSlotJoinStart + joinMap.AggregatedProgramInfo.JoinNumber]); + trilist.SetSigHeldAction(programSlotJoinStart + joinMap.ProgramReset.JoinNumber, 10000, () => ProgramReset(programNumber)); + programSlotJoinStart = programSlotJoinStart + joinMap.ProgramOffsetJoin.JoinSpan; } - } + } - //// Sets the time zone + //// Sets the time zone //public void SetTimeZone(int timeZone) //{ // SystemMonitor.TimeZoneInformation.TimeZoneNumber = timeZone; From 8cc6cfafe9294c89972663bdd45050d468f0f741 Mon Sep 17 00:00:00 2001 From: Alex Johnson Date: Wed, 8 Feb 2023 16:19:17 -0500 Subject: [PATCH 05/96] Fixes CEvent in InitializeSystem() to properly wait for initialization until all devices are registered, if the system is a DMPS. This fixes an issue where HDBaseT type endpoints were not working on a DMPS3 non-4K unit. --- PepperDashEssentials/ControlSystem.cs | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/PepperDashEssentials/ControlSystem.cs b/PepperDashEssentials/ControlSystem.cs index 1ab3b28e..296065b5 100644 --- a/PepperDashEssentials/ControlSystem.cs +++ b/PepperDashEssentials/ControlSystem.cs @@ -46,28 +46,29 @@ namespace PepperDash.Essentials /// public override void InitializeSystem() { - _startTimer = new CTimer(StartSystem,StartupTime); - - // If the control system is a DMPS type, we need to wait to exit this method until all devices have had time to activate // to allow any HD-BaseT DM endpoints to register first. - if (Global.ControlSystemIsDmpsType) + bool preventInitializationComplete = Global.ControlSystemIsDmpsType; + if (preventInitializationComplete) { Debug.Console(1, "******************* InitializeSystem() Entering **********************"); - - _initializeEvent = new CEvent(); - + _startTimer = new CTimer(StartSystem, preventInitializationComplete, StartupTime); + _initializeEvent = new CEvent(true, false); DeviceManager.AllDevicesRegistered += (o, a) => { _initializeEvent.Set(); - Debug.Console(1, "******************* InitializeSystem() Exiting **********************"); }; - _initializeEvent.Wait(30000); + Debug.Console(1, "******************* InitializeSystem() Exiting **********************"); + SystemMonitor.ProgramInitialization.ProgramInitializationComplete = true; + } + else + { + _startTimer = new CTimer(StartSystem, preventInitializationComplete, StartupTime); } } - private void StartSystem(object obj) + private void StartSystem(object preventInitialization) { DeterminePlatform(); @@ -124,7 +125,10 @@ namespace PepperDash.Essentials return; } - SystemMonitor.ProgramInitialization.ProgramInitializationComplete = true; + if (!(bool)preventInitialization) + { + SystemMonitor.ProgramInitialization.ProgramInitializationComplete = true; + } } /// From cef29af1ba764725d50b6280e759c56bf83f4058 Mon Sep 17 00:00:00 2001 From: Alex Johnson Date: Wed, 8 Feb 2023 20:59:30 -0500 Subject: [PATCH 06/96] Add register for basic DM endpoints to constructor stage due to requirement they are registered before parent devices. --- .../Endpoints/Receivers/DmHdBaseTEndpointController.cs | 2 ++ .../Endpoints/Receivers/DmRmc4k100C1GController.cs | 4 +++- .../Endpoints/Transmitters/DmTx4k100Controller.cs | 2 ++ .../Endpoints/Transmitters/DmTx4kz100Controller.cs | 1 + .../Endpoints/Transmitters/HDBaseTTxController.cs | 3 +++ 5 files changed, 11 insertions(+), 1 deletion(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmHdBaseTEndpointController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmHdBaseTEndpointController.cs index ec3553a1..bfea158e 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmHdBaseTEndpointController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmHdBaseTEndpointController.cs @@ -28,6 +28,8 @@ namespace PepperDash.Essentials.DM InputPorts = new RoutingPortCollection {DmIn}; OutputPorts = new RoutingPortCollection {HDBaseTSink}; + PreventRegistration = true; + rmc.Register(); } public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4k100C1GController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4k100C1GController.cs index 529f740a..d92d9620 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4k100C1GController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4k100C1GController.cs @@ -32,7 +32,9 @@ namespace PepperDash.Essentials.DM eRoutingPortConnectionType.Hdmi, null, this) {Port = _rmc}; InputPorts = new RoutingPortCollection {DmIn}; - OutputPorts = new RoutingPortCollection {HdmiOut}; + OutputPorts = new RoutingPortCollection {HdmiOut}; + PreventRegistration = true; + rmc.Register(); } public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k100Controller.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k100Controller.cs index 5bbf5fd5..3c7ffffa 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k100Controller.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k100Controller.cs @@ -78,6 +78,8 @@ namespace PepperDash.Essentials.DM IsOnline.SetValueFunc(() => controller.InputEndpointOnlineFeedbacks[num].BoolValue); controller.InputEndpointOnlineFeedbacks[num].OutputChange += (o, a) => IsOnline.FireUpdate(); } + PreventRegistration = true; + tx.Register(); } public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4kz100Controller.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4kz100Controller.cs index c1a5cec7..bb7d9e3d 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4kz100Controller.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4kz100Controller.cs @@ -72,6 +72,7 @@ namespace PepperDash.Essentials.DM HdmiIn.Port = Tx; PreventRegistration = true; + tx.Register(); } public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/HDBaseTTxController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/HDBaseTTxController.cs index bedf1aad..a40ee68b 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/HDBaseTTxController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/HDBaseTTxController.cs @@ -52,6 +52,9 @@ namespace PepperDash.Essentials.DM IsOnline.SetValueFunc(() => controller.InputEndpointOnlineFeedbacks[num].BoolValue); controller.InputEndpointOnlineFeedbacks[num].OutputChange += (o, a) => IsOnline.FireUpdate(); } + + PreventRegistration = true; + tx.Register(); } #region IRoutingInputs Members From 772369bcd6c111ee88f5c742c2fa5be3e74a90dc Mon Sep 17 00:00:00 2001 From: thombrooks Date: Tue, 14 Feb 2023 20:16:01 -0600 Subject: [PATCH 07/96] Delete IEssentialsHuddleSpaceRoom.cs Redundant - correct definitions are in the Interfaces subfolder. --- .../Room/Types/IEssentialsHuddleSpaceRoom.cs | 44 ------------------- 1 file changed, 44 deletions(-) delete mode 100644 PepperDashEssentials/Room/Types/IEssentialsHuddleSpaceRoom.cs diff --git a/PepperDashEssentials/Room/Types/IEssentialsHuddleSpaceRoom.cs b/PepperDashEssentials/Room/Types/IEssentialsHuddleSpaceRoom.cs deleted file mode 100644 index 45074fb7..00000000 --- a/PepperDashEssentials/Room/Types/IEssentialsHuddleSpaceRoom.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; - -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.DeviceTypeInterfaces; -using PepperDash.Essentials.Room.Config; -using PepperDash.Essentials.Core.Devices; -using PepperDash.Essentials.Devices.Common.Codec; -using PepperDash.Essentials.Devices.Common.VideoCodec; -using PepperDash.Essentials.Devices.Common.AudioCodec; - - -using PepperDash.Core; - -namespace PepperDash.Essentials -{ - public interface IEssentialsHuddleSpaceRoom : IEssentialsRoom, IHasCurrentSourceInfoChange, IRunRouteAction, IHasDefaultDisplay - { - bool ExcludeFromGlobalFunctions { get; } - - void RunRouteAction(string routeKey); - - EssentialsHuddleRoomPropertiesConfig PropertiesConfig { get; } - - IBasicVolumeControls CurrentVolumeControls { get; } - - event EventHandler CurrentVolumeDeviceChange; - } - - public interface IEssentialsHuddleVtc1Room : IEssentialsRoom, IHasCurrentSourceInfoChange, - IHasCurrentVolumeControls, IRunRouteAction, IRunDefaultCallRoute, IHasVideoCodec, IHasAudioCodec, IHasDefaultDisplay - { - EssentialsHuddleVtc1PropertiesConfig PropertiesConfig { get; } - - void RunRouteAction(string routeKey); - - IHasScheduleAwareness ScheduleSource { get; } - - string DefaultCodecRouteString { get; } - } -} \ No newline at end of file From 88f843250a3aa41c8cae17ed982f30151bb9cc2e Mon Sep 17 00:00:00 2001 From: Trevor Payne Date: Fri, 17 Feb 2023 00:47:50 -0600 Subject: [PATCH 08/96] feat: cleanup getjoinmap console return resolves: Issue #928 --- .../JoinMaps/JoinMapBase.cs | 80 +++++++++---------- 1 file changed, 36 insertions(+), 44 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs index 67a5740f..8f484121 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs @@ -1,9 +1,7 @@ using System; using System.Collections.Generic; -using System.Data; using System.Globalization; using System.Linq; -using System.Runtime.InteropServices; using System.Text; using Crestron.SimplSharp.Reflection; using Crestron.SimplSharp.CrestronIO; @@ -236,25 +234,45 @@ namespace PepperDash.Essentials.Core /// public void PrintJoinMapInfo() { - Debug.Console(0, "{0}:\n", GetType().Name); + var sb = JoinmapStringBuilder(); + + CrestronConsole.ConsoleCommandResponse(sb.ToString()); + } + + private StringBuilder JoinmapStringBuilder() + { + var sb = new StringBuilder(); // Get the joins of each type and print them - Debug.Console(0, "Digitals:"); - var digitals = Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Digital) == eJoinType.Digital).ToDictionary(j => j.Key, j => j.Value); - Debug.Console(2, "Found {0} Digital Joins", digitals.Count); - PrintJoinList(GetSortedJoins(digitals)); + sb.AppendLine(String.Format("# {0}", GetType().Name)); + sb.AppendLine(); + sb.AppendLine("## Digitals"); + sb.AppendLine(); + // Get the joins of each type and print them + var digitals = + Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Digital) == eJoinType.Digital) + .ToDictionary(j => j.Key, j => j.Value); + var digitalSb = AppendJoinList(GetSortedJoins(digitals)); + digitalSb.AppendLine("## Analogs"); + digitalSb.AppendLine(); - Debug.Console(0, "Analogs:"); - var analogs = Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Analog) == eJoinType.Analog).ToDictionary(j => j.Key, j => j.Value); - Debug.Console(2, "Found {0} Analog Joins", analogs.Count); - PrintJoinList(GetSortedJoins(analogs)); + var analogs = + Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Analog) == eJoinType.Analog) + .ToDictionary(j => j.Key, j => j.Value); + var analogSb = AppendJoinList(GetSortedJoins(analogs)); + analogSb.AppendLine("## Serials"); + analogSb.AppendLine(); - Debug.Console(0, "Serials:"); - var serials = Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Serial) == eJoinType.Serial).ToDictionary(j => j.Key, j => j.Value); - Debug.Console(2, "Found {0} Serial Joins", serials.Count); - PrintJoinList(GetSortedJoins(serials)); + var serials = + Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Serial) == eJoinType.Serial) + .ToDictionary(j => j.Key, j => j.Value); + var serialSb = AppendJoinList(GetSortedJoins(serials)); + sb.EnsureCapacity(sb.Length + digitalSb.Length + analogSb.Length + serialSb.Length); + sb.Append(digitalSb).Append(analogSb).Append(serialSb); + return sb; } + /// /// Prints the join information to console /// @@ -264,35 +282,9 @@ namespace PepperDash.Essentials.Core Debug.Console(0, "{0}:\n", pluginType); - var sb = new StringBuilder(); - sb.AppendLine(String.Format("# {0}", GetType().Name)); - sb.AppendLine(String.Format("Generated from '{0}' on bridge '{1}'", deviceKey, bridgeKey)); - sb.AppendLine(); - sb.AppendLine("## Digitals"); - // Get the joins of each type and print them - var digitals = Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Digital) == eJoinType.Digital).ToDictionary(j => j.Key, j => j.Value); - Debug.Console(2, "Found {0} Digital Joins", digitals.Count); - var digitalSb = AppendJoinList(GetSortedJoins(digitals)); - digitalSb.AppendLine("## Analogs"); - digitalSb.AppendLine(); - Debug.Console(0, "Analogs:"); - var analogs = Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Analog) == eJoinType.Analog).ToDictionary(j => j.Key, j => j.Value); - Debug.Console(2, "Found {0} Analog Joins", analogs.Count); - var analogSb = AppendJoinList(GetSortedJoins(analogs)); - analogSb.AppendLine("## Serials"); - analogSb.AppendLine(); - - Debug.Console(0, "Serials:"); - var serials = Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Serial) == eJoinType.Serial).ToDictionary(j => j.Key, j => j.Value); - Debug.Console(2, "Found {0} Serial Joins", serials.Count); - var serialSb = AppendJoinList(GetSortedJoins(serials)); - - sb.EnsureCapacity(sb.Length + digitalSb.Length + analogSb.Length + serialSb.Length); - sb.Append(digitalSb).Append(analogSb).Append(serialSb); - - WriteJoinmapMarkdown(sb, pluginType, bridgeKey, deviceKey); + WriteJoinmapMarkdown(JoinmapStringBuilder(), pluginType, bridgeKey, deviceKey); } @@ -313,7 +305,7 @@ namespace PepperDash.Essentials.Core /// /// /// - List> GetSortedJoins(Dictionary joins) + static List> GetSortedJoins(Dictionary joins) { var sortedJoins = joins.ToList(); @@ -322,7 +314,7 @@ namespace PepperDash.Essentials.Core return sortedJoins; } - void PrintJoinList(List> joins) + void PrintJoinList(IEnumerable> joins) { foreach (var join in joins) { From e005a30383f18933b5fed47966302c79502d3172 Mon Sep 17 00:00:00 2001 From: Trevor Payne Date: Fri, 17 Feb 2023 22:59:20 -0600 Subject: [PATCH 09/96] feat: improved console responses in JoinMapBase --- .../JoinMaps/JoinMapBase.cs | 34 ++++++------------- 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs index 8f484121..60aa6275 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs @@ -101,22 +101,22 @@ namespace PepperDash.Essentials.Core /// public void PrintJoinMapInfo() { - Debug.Console(0, "{0}:\n", GetType().Name); + CrestronConsole.ConsoleCommandResponse("{0}:\n", GetType().Name); // Get the joins of each type and print them - Debug.Console(0, "Digitals:"); + CrestronConsole.ConsoleCommandResponse("Digitals:"); var digitals = Joins.Where(j => (j.Value.JoinType & eJoinType.Digital) == eJoinType.Digital).ToDictionary(j => j.Key, j => j.Value); - Debug.Console(2, "Found {0} Digital Joins", digitals.Count); + CrestronConsole.ConsoleCommandResponse("Found {0} Digital Joins", digitals.Count); PrintJoinList(GetSortedJoins(digitals)); - Debug.Console(0, "Analogs:"); + CrestronConsole.ConsoleCommandResponse("Analogs:"); var analogs = Joins.Where(j => (j.Value.JoinType & eJoinType.Analog) == eJoinType.Analog).ToDictionary(j => j.Key, j => j.Value); - Debug.Console(2, "Found {0} Analog Joins", analogs.Count); + CrestronConsole.ConsoleCommandResponse("Found {0} Analog Joins", analogs.Count); PrintJoinList(GetSortedJoins(analogs)); - Debug.Console(0, "Serials:"); + CrestronConsole.ConsoleCommandResponse("Serials:"); var serials = Joins.Where(j => (j.Value.JoinType & eJoinType.Serial) == eJoinType.Serial).ToDictionary(j => j.Key, j => j.Value); - Debug.Console(2, "Found {0} Serial Joins", serials.Count); + CrestronConsole.ConsoleCommandResponse("Found {0} Serial Joins", serials.Count); PrintJoinList(GetSortedJoins(serials)); } @@ -139,7 +139,7 @@ namespace PepperDash.Essentials.Core { foreach (var join in joins) { - Debug.Console(0, + CrestronConsole.ConsoleCommandResponse( @"Join Number: {0} | Label: '{1}' | JoinSpan: '{2}' | Type: '{3}' | Capabilities: '{4}'", join.Value.JoinNumber, join.Value.Label, @@ -280,7 +280,7 @@ namespace PepperDash.Essentials.Core { var pluginType = GetType().Name; - Debug.Console(0, "{0}:\n", pluginType); + CrestronConsole.ConsoleCommandResponse("{0}:\n", pluginType); @@ -295,7 +295,7 @@ namespace PepperDash.Essentials.Core using (var sw = new StreamWriter(fileName)) { sw.WriteLine(stringBuilder.ToString()); - Debug.Console(0, "Joinmap Readme generated and written to {0}", fileName); + CrestronConsole.ConsoleCommandResponse("Joinmap Readme generated and written to {0}", fileName); } } @@ -314,20 +314,6 @@ namespace PepperDash.Essentials.Core return sortedJoins; } - void PrintJoinList(IEnumerable> joins) - { - foreach (var join in joins) - { - Debug.Console(0, - @"Join Number: {0} | JoinSpan: '{1}' | JoinName: {2} | Description: '{3}' | Type: '{4}' | Capabilities: '{5}'", - join.Value.JoinNumber, - join.Value.JoinSpan, - join.Key, - String.IsNullOrEmpty(join.Value.AttributeName) ? join.Value.Metadata.Label : join.Value.AttributeName, - join.Value.Metadata.JoinType.ToString(), - join.Value.Metadata.JoinCapabilities.ToString()); - } - } static StringBuilder AppendJoinList(List> joins) { From 1920d37488836d4dc47f0f94262d9e00180763a1 Mon Sep 17 00:00:00 2001 From: Trevor Payne Date: Fri, 17 Feb 2023 23:02:54 -0600 Subject: [PATCH 10/96] feat: update reportVersions command to use ConsoleResponse feat: update gettypes to use ConsoleResponse --- PepperDashEssentials/ControlSystem.cs | 2 +- .../Factory/DeviceFactory.cs | 19 ++++++------------- .../Plugins/PluginLoader.cs | 5 +++-- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/PepperDashEssentials/ControlSystem.cs b/PepperDashEssentials/ControlSystem.cs index 736a250f..e40cce4e 100644 --- a/PepperDashEssentials/ControlSystem.cs +++ b/PepperDashEssentials/ControlSystem.cs @@ -80,7 +80,7 @@ namespace PepperDash.Essentials CrestronConsole.AddNewConsoleCommand(PluginLoader.ReportAssemblyVersions, "reportversions", "Reports the versions of the loaded assemblies", ConsoleAccessLevelEnum.AccessOperator); - CrestronConsole.AddNewConsoleCommand(PepperDash.Essentials.Core.DeviceFactory.GetDeviceFactoryTypes, "gettypes", "Gets the device types that can be built. Accepts a filter string.", ConsoleAccessLevelEnum.AccessOperator); + CrestronConsole.AddNewConsoleCommand(Core.DeviceFactory.GetDeviceFactoryTypes, "gettypes", "Gets the device types that can be built. Accepts a filter string.", ConsoleAccessLevelEnum.AccessOperator); CrestronConsole.AddNewConsoleCommand(BridgeHelper.PrintJoinMap, "getjoinmap", "map(s) for bridge or device on bridge [brKey [devKey]]", ConsoleAccessLevelEnum.AccessOperator); diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/DeviceFactory.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/DeviceFactory.cs index bad3e531..793ff34a 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/DeviceFactory.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/DeviceFactory.cs @@ -172,21 +172,14 @@ namespace PepperDash.Essentials.Core /// /// Prints the type names and associated metadata from the FactoryMethods collection. /// - /// + /// public static void GetDeviceFactoryTypes(string filter) { - Dictionary types = new Dictionary(); + var types = !string.IsNullOrEmpty(filter) + ? FactoryMethods.Where(k => k.Key.Contains(filter)).ToDictionary(k => k.Key, k => k.Value) + : FactoryMethods; - if (!string.IsNullOrEmpty(filter)) - { - types = FactoryMethods.Where(k => k.Key.Contains(filter)).ToDictionary(k => k.Key, k => k.Value); - } - else - { - types = FactoryMethods; - } - - Debug.Console(0, "Device Types:"); + CrestronConsole.ConsoleCommandResponse("Device Types:"); foreach (var type in types.OrderBy(t => t.Key)) { @@ -198,7 +191,7 @@ namespace PepperDash.Essentials.Core cType = type.Value.CType.FullName; } - Debug.Console(0, + CrestronConsole.ConsoleCommandResponse( @"Type: '{0}' CType: '{1}' Description: {2}", type.Key, cType, description); diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/PluginLoader.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/PluginLoader.cs index 9da843b8..f69d35d0 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/PluginLoader.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/PluginLoader.cs @@ -194,10 +194,11 @@ namespace PepperDash.Essentials /// public static void ReportAssemblyVersions(string command) { - Debug.Console(0, "Loaded Assemblies:"); + + CrestronConsole.ConsoleCommandResponse("Loaded Assemblies:"); foreach (var assembly in LoadedAssemblies) { - Debug.Console(0, "{0} Version: {1}", assembly.Name, assembly.Version); + CrestronConsole.ConsoleCommandResponse("{0} Version: {1}", assembly.Name, assembly.Version); } } From b057d3de187518c6760f5f8f8f95d500c1a806f8 Mon Sep 17 00:00:00 2001 From: Trevor Payne Date: Fri, 17 Feb 2023 23:06:15 -0600 Subject: [PATCH 11/96] feat: update GetRoutingPorts to use ConsoleResponse --- .../Devices/DeviceManager.cs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DeviceManager.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DeviceManager.cs index 57bf2287..3f12af68 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DeviceManager.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DeviceManager.cs @@ -388,20 +388,18 @@ namespace PepperDash.Essentials.Core var outputPorts = ((device as IRoutingOutputs) != null) ? (device as IRoutingOutputs).OutputPorts : null; if (inputPorts != null) { - Debug.Console(0, "Device {0} has {1} Input Ports:", s, inputPorts.Count); + CrestronConsole.ConsoleCommandResponse("Device {0} has {1} Input Ports:", s, inputPorts.Count); foreach (var routingInputPort in inputPorts) { - Debug.Console(0, "{0}", routingInputPort.Key); - } - } - if (outputPorts != null) - { - Debug.Console(0, "Device {0} has {1} Output Ports:", s, outputPorts.Count); - foreach (var routingOutputPort in outputPorts) - { - Debug.Console(0, "{0}", routingOutputPort.Key); + CrestronConsole.ConsoleCommandResponse("{0}", routingInputPort.Key); } } + if (outputPorts == null) return; + CrestronConsole.ConsoleCommandResponse("Device {0} has {1} Output Ports:", s, outputPorts.Count); + foreach (var routingOutputPort in outputPorts) + { + CrestronConsole.ConsoleCommandResponse("{0}", routingOutputPort.Key); + } } /// From cad677ae89d458ff1e50ffdd12947f7e48ac5cb6 Mon Sep 17 00:00:00 2001 From: Trevor Payne Date: Fri, 17 Feb 2023 23:07:16 -0600 Subject: [PATCH 12/96] feat: updated all console responses in SetDeviceStreamDebugging to use ConsoleResponse --- .../PepperDashEssentialsBase/Devices/DeviceManager.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DeviceManager.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DeviceManager.cs index 3f12af68..65efd0b9 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DeviceManager.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DeviceManager.cs @@ -433,7 +433,7 @@ namespace PepperDash.Essentials.Core if (device == null) { - Debug.Console(0, "Unable to get device with key: {0}", deviceKey); + CrestronConsole.ConsoleCommandResponse("Unable to get device with key: {0}", deviceKey); return; } @@ -445,7 +445,7 @@ namespace PepperDash.Essentials.Core } catch { - Debug.Console(0, "Unable to convert setting value. Please use off/rx/tx/both"); + CrestronConsole.ConsoleCommandResponse("Unable to convert setting value. Please use off/rx/tx/both"); return; } @@ -456,18 +456,18 @@ namespace PepperDash.Essentials.Core var min = Convert.ToUInt32(timeout); device.StreamDebugging.SetDebuggingWithSpecificTimeout(debugSetting, min); - Debug.Console(0, "Device: '{0}' debug level set to {1} for {2} minutes", deviceKey, debugSetting, min); + CrestronConsole.ConsoleCommandResponse("Device: '{0}' debug level set to {1} for {2} minutes", deviceKey, debugSetting, min); } catch (Exception e) { - Debug.Console(0, "Unable to convert minutes or settings value. Please use an integer value for minutes. Errro: {0}", e); + CrestronConsole.ConsoleCommandResponse("Unable to convert minutes or settings value. Please use an integer value for minutes. Error: {0}", e); } } else { device.StreamDebugging.SetDebuggingWithDefaultTimeout(debugSetting); - Debug.Console(0, "Device: '{0}' debug level set to {1} for default time (30 minutes)", deviceKey, debugSetting); + CrestronConsole.ConsoleCommandResponse("Device: '{0}' debug level set to {1} for default time (30 minutes)", deviceKey, debugSetting); } } From f55ecdb67e7ac66f32ab918280940811f08de744 Mon Sep 17 00:00:00 2001 From: jdevito Date: Mon, 20 Feb 2023 15:46:57 -0600 Subject: [PATCH 13/96] fix: updated debug constants --- .../PepperDashEssentialsBase/Web/EssemtialsWebApi.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/EssemtialsWebApi.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/EssemtialsWebApi.cs index 973b303b..fb999756 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/EssemtialsWebApi.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/EssemtialsWebApi.cs @@ -3,9 +3,6 @@ using System.Collections.Generic; using System.Linq; using Crestron.SimplSharp; using Crestron.SimplSharp.WebScripting; -using Crestron.SimplSharpPro.Diagnostics; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; using PepperDash.Core; using PepperDash.Core.Web; using PepperDash.Essentials.Core.Web.RequestHandlers; @@ -25,8 +22,8 @@ namespace PepperDash.Essentials.Core.Web // TODO [ ] Reset debug levels to proper value Trace = 0, Info = 1, Verbose = 2 private const int DebugTrace = 0; - private const int DebugInfo = 0; - private const int DebugVerbose = 0; + private const int DebugInfo = 1; + private const int DebugVerbose = 2; /// /// CWS base path From e8cdf3a63b90fa1fd827ff68a44aaa26ee5d5184 Mon Sep 17 00:00:00 2001 From: jdevito Date: Mon, 20 Feb 2023 16:44:11 -0600 Subject: [PATCH 14/96] fix: updated handlers, removed handler methods that are not implemented, added constructor to implement CORS support --- .../Web/EssemtialsWebApi.cs | 21 +--- .../RequestHandlers/AppDebugRequestHandler.cs | 90 +++--------------- .../RequestHandlers/DefaultRequestHandler.cs | 11 +++ .../RequestHandlers/DevJsonRequestHandler.cs | 95 +++---------------- .../RequestHandlers/DevPropsRequestHandler.cs | 92 ++---------------- .../DisableAllStreamDebugRequestHandler.cs | 89 ++--------------- .../GetFeedbacksForDeviceRequestHandler.cs | 89 ++--------------- .../GetJoinMapForBridgeKeyRequestHandler.cs | 93 ++---------------- .../GetJoinMapForDeviceKeyRequestHandler.cs | 89 ++--------------- .../GetTypesByFilterRequestHandler.cs | 89 ++--------------- .../RequestHandlers/GetTypesRequestHandler.cs | 89 ++--------------- .../ReportVersionsRequestHandler.cs | 89 ++--------------- .../ShowConfigRequestHandler.cs | 89 ++--------------- packages.config | 2 +- 14 files changed, 93 insertions(+), 934 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/EssemtialsWebApi.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/EssemtialsWebApi.cs index fb999756..dd2ade1a 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/EssemtialsWebApi.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/EssemtialsWebApi.cs @@ -17,10 +17,10 @@ namespace PepperDash.Essentials.Core.Web /// http(s)://{ipaddress}/cws/{basePath} /// http(s)://{ipaddress}/VirtualControl/Rooms/{roomId}/cws/{basePath} /// - private readonly string _defaultBasePath = - CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance ? string.Format("/app{0:00}/api", InitialParametersClass.ApplicationNumber) : "/api"; + private readonly string _defaultBasePath = CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance + ? string.Format("/app{0:00}/api", InitialParametersClass.ApplicationNumber) + : "/api"; - // TODO [ ] Reset debug levels to proper value Trace = 0, Info = 1, Verbose = 2 private const int DebugTrace = 0; private const int DebugInfo = 1; private const int DebugVerbose = 2; @@ -95,11 +95,6 @@ namespace PepperDash.Essentials.Core.Web Name = "DevProps", RouteHandler = new DevPropsRequestHandler() }, - //new HttpCwsRoute("devprops/{key}") - //{ - // Name = "DevProps", - // RouteHandler = new DevPropsRequestHandler() - //}, new HttpCwsRoute("devjson") { Name = "DevJson", @@ -110,11 +105,6 @@ namespace PepperDash.Essentials.Core.Web Name = "SetDeviceStreamDebug", RouteHandler = new SetDeviceStreamDebugRequestHandler() }, - //new HttpCwsRoute("setdevicestreamdebug/{deviceKey}/{state}") - //{ - // Name = "SetDeviceStreamDebug", - // RouteHandler = new SetDeviceStreamDebugRequestHandler() - //}, new HttpCwsRoute("disableallstreamdebug") { Name = "DisableAllStreamDebug", @@ -170,12 +160,7 @@ namespace PepperDash.Essentials.Core.Web if (CrestronEnvironment.DevicePlatform == eDevicePlatform.Appliance) { /* - RMC4> WEBSERVER [ON | OFF | TIMEOUT | MAXSESSIONSPERUSER ] - WEBSERVER [TIMEOUT] will display current session timeout value - WEBSERVER MAXSESSIONSPERUSER will display current max web sessions per user - WEBSERVER ALLOWSHAREDSESSION will display whether 'samesite = none' would be set on cookies - No parameter - displays current setting */ var response = string.Empty; CrestronConsole.SendControlSystemCommand("webserver", ref response); diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/AppDebugRequestHandler.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/AppDebugRequestHandler.cs index f80f9f7f..bbe4bd22 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/AppDebugRequestHandler.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/AppDebugRequestHandler.cs @@ -1,6 +1,4 @@ -using System; -using System.Text; -using Crestron.SimplSharp.WebScripting; +using Crestron.SimplSharp.WebScripting; using Newtonsoft.Json; using PepperDash.Core; using PepperDash.Core.Web.RequestHandlers; @@ -10,25 +8,14 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers public class AppDebugRequestHandler : WebApiBaseRequestHandler { /// - /// Handles CONNECT method requests + /// Constructor /// - /// - protected override void HandleConnect(HttpCwsContext context) + /// + /// base(true) enables CORS support by default + /// + public AppDebugRequestHandler() + : base(true) { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles DELETE method requests - /// - /// - protected override void HandleDelete(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); } /// @@ -37,7 +24,7 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers /// protected override void HandleGet(HttpCwsContext context) { - var appDebug = new AppDebug {Level = Debug.Level}; + var appDebug = new AppDebug { Level = Debug.Level }; var body = JsonConvert.SerializeObject(appDebug, Formatting.Indented); @@ -46,40 +33,7 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers context.Response.Write(body, false); context.Response.End(); } - - /// - /// Handles HEAD method requests - /// - /// - protected override void HandleHead(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles OPTIONS method requests - /// - /// - protected override void HandleOptions(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles PATCH method requests - /// - /// - protected override void HandlePatch(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - + /// /// Handles POST method requests /// @@ -107,7 +61,7 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers var appDebug = new AppDebug(); var requestBody = JsonConvert.DeserializeAnonymousType(data, appDebug); - + Debug.SetDebugLevel(requestBody.Level); appDebug.Level = Debug.Level; @@ -118,33 +72,11 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers context.Response.Write(responseBody, false); context.Response.End(); } - - /// - /// Handles PUT method requests - /// - /// - protected override void HandlePut(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles TRACE method requests - /// - /// - protected override void HandleTrace(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } } public class AppDebug { [JsonProperty("level", NullValueHandling = NullValueHandling.Ignore)] - public int Level { get; set; } + public int Level { get; set; } } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DefaultRequestHandler.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DefaultRequestHandler.cs index 4ffa500a..786962f5 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DefaultRequestHandler.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DefaultRequestHandler.cs @@ -5,6 +5,17 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers { public class DefaultRequestHandler : WebApiBaseRequestHandler { + /// + /// Constructor + /// + /// + /// base(true) enables CORS support by default + /// + public DefaultRequestHandler() + : base(true) + { + } + /// /// Handles CONNECT method requests /// diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DevJsonRequestHandler.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DevJsonRequestHandler.cs index 6080465b..7a9162bd 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DevJsonRequestHandler.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DevJsonRequestHandler.cs @@ -1,6 +1,6 @@ using System; -using System.Text; using Crestron.SimplSharp.WebScripting; +using PepperDash.Core; using PepperDash.Core.Web.RequestHandlers; namespace PepperDash.Essentials.Core.Web.RequestHandlers @@ -8,69 +8,14 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers public class DevJsonRequestHandler : WebApiBaseRequestHandler { /// - /// Handles CONNECT method requests + /// Constructor /// - /// - protected override void HandleConnect(HttpCwsContext context) + /// + /// base(true) enables CORS support by default + /// + public DevJsonRequestHandler() + : base(true) { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles DELETE method requests - /// - /// - protected override void HandleDelete(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles GET method requests - /// - /// - protected override void HandleGet(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles HEAD method requests - /// - /// - protected override void HandleHead(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles OPTIONS method requests - /// - /// - protected override void HandleOptions(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles PATCH method requests - /// - /// - protected override void HandlePatch(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); } /// @@ -108,32 +53,14 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers } catch (Exception ex) { + Debug.Console(1, "Exception Message: {0}", ex.Message); + Debug.Console(2, "Exception Stack Trace: {0}", ex.StackTrace); + if(ex.InnerException != null) Debug.Console(2, "Exception Inner: {0}", ex.InnerException); + context.Response.StatusCode = 400; context.Response.StatusDescription = "Bad Request"; context.Response.End(); } } - - /// - /// Handles PUT method requests - /// - /// - protected override void HandlePut(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles TRACE method requests - /// - /// - protected override void HandleTrace(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DevPropsRequestHandler.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DevPropsRequestHandler.cs index b7dcc511..be8d154d 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DevPropsRequestHandler.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DevPropsRequestHandler.cs @@ -1,5 +1,4 @@ -using System; -using System.Text; +using System.Text; using Crestron.SimplSharp.WebScripting; using Newtonsoft.Json; using PepperDash.Core.Web.RequestHandlers; @@ -9,69 +8,14 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers public class DevPropsRequestHandler : WebApiBaseRequestHandler { /// - /// Handles CONNECT method requests + /// Constructor /// - /// - protected override void HandleConnect(HttpCwsContext context) + /// + /// base(true) enables CORS support by default + /// + public DevPropsRequestHandler() + : base(true) { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles DELETE method requests - /// - /// - protected override void HandleDelete(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles GET method requests - /// - /// - protected override void HandleGet(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles HEAD method requests - /// - /// - protected override void HandleHead(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles OPTIONS method requests - /// - /// - protected override void HandleOptions(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles PATCH method requests - /// - /// - protected override void HandlePatch(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); } /// @@ -128,27 +72,5 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers context.Response.Write(deviceProps, false); context.Response.End(); } - - /// - /// Handles PUT method requests - /// - /// - protected override void HandlePut(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles TRACE method requests - /// - /// - protected override void HandleTrace(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DisableAllStreamDebugRequestHandler.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DisableAllStreamDebugRequestHandler.cs index 8cfc7315..2e4546f4 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DisableAllStreamDebugRequestHandler.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DisableAllStreamDebugRequestHandler.cs @@ -6,69 +6,14 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers public class DisableAllStreamDebugRequestHandler : WebApiBaseRequestHandler { /// - /// Handles CONNECT method requests + /// Constructor /// - /// - protected override void HandleConnect(HttpCwsContext context) + /// + /// base(true) enables CORS support by default + /// + public DisableAllStreamDebugRequestHandler() + : base(true) { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles DELETE method requests - /// - /// - protected override void HandleDelete(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles GET method requests - /// - /// - protected override void HandleGet(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles HEAD method requests - /// - /// - protected override void HandleHead(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles OPTIONS method requests - /// - /// - protected override void HandleOptions(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles PATCH method requests - /// - /// - protected override void HandlePatch(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); } /// @@ -83,27 +28,5 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers context.Response.StatusDescription = "OK"; context.Response.End(); } - - /// - /// Handles PUT method requests - /// - /// - protected override void HandlePut(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles TRACE method requests - /// - /// - protected override void HandleTrace(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetFeedbacksForDeviceRequestHandler.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetFeedbacksForDeviceRequestHandler.cs index 2f892f2b..5d76bc73 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetFeedbacksForDeviceRequestHandler.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetFeedbacksForDeviceRequestHandler.cs @@ -8,25 +8,14 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers public class GetFeedbacksForDeviceRequestHandler : WebApiBaseRequestHandler { /// - /// Handles CONNECT method requests + /// Constructor /// - /// - protected override void HandleConnect(HttpCwsContext context) + /// + /// base(true) enables CORS support by default + /// + public GetFeedbacksForDeviceRequestHandler() + : base(true) { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles DELETE method requests - /// - /// - protected override void HandleDelete(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); } /// @@ -109,71 +98,5 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers context.Response.Write(js, false); context.Response.End(); } - - /// - /// Handles HEAD method requests - /// - /// - protected override void HandleHead(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles OPTIONS method requests - /// - /// - protected override void HandleOptions(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles PATCH method requests - /// - /// - protected override void HandlePatch(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles POST method requests - /// - /// - protected override void HandlePost(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles PUT method requests - /// - /// - protected override void HandlePut(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles TRACE method requests - /// - /// - protected override void HandleTrace(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetJoinMapForBridgeKeyRequestHandler.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetJoinMapForBridgeKeyRequestHandler.cs index d037b9e6..7e15fd5e 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetJoinMapForBridgeKeyRequestHandler.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetJoinMapForBridgeKeyRequestHandler.cs @@ -9,25 +9,14 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers public class GetJoinMapForBridgeKeyRequestHandler : WebApiBaseRequestHandler { /// - /// Handles CONNECT method requests + /// Constructor /// - /// - protected override void HandleConnect(HttpCwsContext context) + /// + /// base(true) enables CORS support by default + /// + public GetJoinMapForBridgeKeyRequestHandler() + : base(true) { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles DELETE method requests - /// - /// - protected override void HandleDelete(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); } /// @@ -84,74 +73,6 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers context.Response.ContentEncoding = System.Text.Encoding.UTF8; context.Response.Write(js, false); context.Response.End(); - } - - /// - /// Handles HEAD method requests - /// - /// - protected override void HandleHead(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles OPTIONS method requests - /// - /// - protected override void HandleOptions(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles PATCH method requests - /// - /// - protected override void HandlePatch(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles POST method requests - /// - /// - protected override void HandlePost(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles PUT method requests - /// - /// - protected override void HandlePut(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles TRACE method requests - /// - /// - protected override void HandleTrace(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - + } } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetJoinMapForDeviceKeyRequestHandler.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetJoinMapForDeviceKeyRequestHandler.cs index 63ca47a0..77d7f8ea 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetJoinMapForDeviceKeyRequestHandler.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetJoinMapForDeviceKeyRequestHandler.cs @@ -8,25 +8,14 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers public class GetJoinMapForDeviceKeyRequestHandler : WebApiBaseRequestHandler { /// - /// Handles CONNECT method requests + /// Constructor /// - /// - protected override void HandleConnect(HttpCwsContext context) + /// + /// base(true) enables CORS support by default + /// + public GetJoinMapForDeviceKeyRequestHandler() + : base(true) { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles DELETE method requests - /// - /// - protected override void HandleDelete(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); } /// @@ -102,71 +91,5 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers context.Response.Write(js, false); context.Response.End(); } - - /// - /// Handles HEAD method requests - /// - /// - protected override void HandleHead(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles OPTIONS method requests - /// - /// - protected override void HandleOptions(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles PATCH method requests - /// - /// - protected override void HandlePatch(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles POST method requests - /// - /// - protected override void HandlePost(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles PUT method requests - /// - /// - protected override void HandlePut(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles TRACE method requests - /// - /// - protected override void HandleTrace(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetTypesByFilterRequestHandler.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetTypesByFilterRequestHandler.cs index be7347fb..706793e7 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetTypesByFilterRequestHandler.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetTypesByFilterRequestHandler.cs @@ -8,25 +8,14 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers public class GetTypesByFilterRequestHandler : WebApiBaseRequestHandler { /// - /// Handles CONNECT method requests + /// Constructor /// - /// - protected override void HandleConnect(HttpCwsContext context) + /// + /// base(true) enables CORS support by default + /// + public GetTypesByFilterRequestHandler() + : base(true) { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles DELETE method requests - /// - /// - protected override void HandleDelete(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); } /// @@ -75,71 +64,5 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers context.Response.Write(js, false); context.Response.End(); } - - /// - /// Handles HEAD method requests - /// - /// - protected override void HandleHead(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles OPTIONS method requests - /// - /// - protected override void HandleOptions(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles PATCH method requests - /// - /// - protected override void HandlePatch(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles POST method requests - /// - /// - protected override void HandlePost(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles PUT method requests - /// - /// - protected override void HandlePut(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles TRACE method requests - /// - /// - protected override void HandleTrace(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetTypesRequestHandler.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetTypesRequestHandler.cs index f2630063..9d5f1150 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetTypesRequestHandler.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/GetTypesRequestHandler.cs @@ -8,25 +8,14 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers public class GetTypesRequestHandler : WebApiBaseRequestHandler { /// - /// Handles CONNECT method requests + /// Constructor /// - /// - protected override void HandleConnect(HttpCwsContext context) + /// + /// base(true) enables CORS support by default + /// + public GetTypesRequestHandler() + : base(true) { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles DELETE method requests - /// - /// - protected override void HandleDelete(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); } /// @@ -65,71 +54,5 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers context.Response.Write(js, false); context.Response.End(); } - - /// - /// Handles HEAD method requests - /// - /// - protected override void HandleHead(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles OPTIONS method requests - /// - /// - protected override void HandleOptions(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles PATCH method requests - /// - /// - protected override void HandlePatch(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles POST method requests - /// - /// - protected override void HandlePost(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles PUT method requests - /// - /// - protected override void HandlePut(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles TRACE method requests - /// - /// - protected override void HandleTrace(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/ReportVersionsRequestHandler.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/ReportVersionsRequestHandler.cs index 6ba3cb7a..e6fb45f1 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/ReportVersionsRequestHandler.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/ReportVersionsRequestHandler.cs @@ -8,25 +8,14 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers public class ReportVersionsRequestHandler : WebApiBaseRequestHandler { /// - /// Handles CONNECT method requests + /// Constructor /// - /// - protected override void HandleConnect(HttpCwsContext context) + /// + /// base(true) enables CORS support by default + /// + public ReportVersionsRequestHandler() + : base(true) { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles DELETE method requests - /// - /// - protected override void HandleDelete(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); } /// @@ -56,71 +45,5 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers context.Response.Write(js, false); context.Response.End(); } - - /// - /// Handles HEAD method requests - /// - /// - protected override void HandleHead(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles OPTIONS method requests - /// - /// - protected override void HandleOptions(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles PATCH method requests - /// - /// - protected override void HandlePatch(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles POST method requests - /// - /// - protected override void HandlePost(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles PUT method requests - /// - /// - protected override void HandlePut(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles TRACE method requests - /// - /// - protected override void HandleTrace(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/ShowConfigRequestHandler.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/ShowConfigRequestHandler.cs index 4dded8b5..89da86b3 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/ShowConfigRequestHandler.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/ShowConfigRequestHandler.cs @@ -8,25 +8,14 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers public class ShowConfigRequestHandler : WebApiBaseRequestHandler { /// - /// Handles CONNECT method requests + /// Constructor /// - /// - protected override void HandleConnect(HttpCwsContext context) + /// + /// base(true) enables CORS support by default + /// + public ShowConfigRequestHandler() + : base(true) { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles DELETE method requests - /// - /// - protected override void HandleDelete(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); } /// @@ -44,71 +33,5 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers context.Response.Write(config, false); context.Response.End(); } - - /// - /// Handles HEAD method requests - /// - /// - protected override void HandleHead(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles OPTIONS method requests - /// - /// - protected override void HandleOptions(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles PATCH method requests - /// - /// - protected override void HandlePatch(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles POST method requests - /// - /// - protected override void HandlePost(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles PUT method requests - /// - /// - protected override void HandlePut(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles TRACE method requests - /// - /// - protected override void HandleTrace(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } } } \ No newline at end of file diff --git a/packages.config b/packages.config index 87f5b8c1..e9ea5933 100644 --- a/packages.config +++ b/packages.config @@ -1,3 +1,3 @@ - + \ No newline at end of file From c9eaff6fcef692c39575bdbef56ec43aad10bec6 Mon Sep 17 00:00:00 2001 From: jdevito Date: Mon, 20 Feb 2023 16:59:05 -0600 Subject: [PATCH 15/96] fix: updated Devlist handler to add constructor enabling CORS support --- .../RequestHandlers/DevListRequestHandler.cs | 89 ++----------------- 1 file changed, 6 insertions(+), 83 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DevListRequestHandler.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DevListRequestHandler.cs index c34542e2..cf2a1e78 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DevListRequestHandler.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Web/RequestHandlers/DevListRequestHandler.cs @@ -8,25 +8,14 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers public class DevListRequestHandler : WebApiBaseRequestHandler { /// - /// Handles CONNECT method requests + /// Constructor /// - /// - protected override void HandleConnect(HttpCwsContext context) + /// + /// base(true) enables CORS support by default + /// + public DevListRequestHandler() + : base(true) { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles DELETE method requests - /// - /// - protected override void HandleDelete(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); } /// @@ -58,71 +47,5 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers context.Response.Write(js, false); context.Response.End(); } - - /// - /// Handles HEAD method requests - /// - /// - protected override void HandleHead(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles OPTIONS method requests - /// - /// - protected override void HandleOptions(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles PATCH method requests - /// - /// - protected override void HandlePatch(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles POST method requests - /// - /// - protected override void HandlePost(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles PUT method requests - /// - /// - protected override void HandlePut(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } - - /// - /// Handles TRACE method requests - /// - /// - protected override void HandleTrace(HttpCwsContext context) - { - context.Response.StatusCode = 501; - context.Response.StatusDescription = "Not Implemented"; - context.Response.End(); - } } } \ No newline at end of file From 701513d30e3a6df5ec6f43e809b7a41d1cb53dde Mon Sep 17 00:00:00 2001 From: Trevor Payne Date: Thu, 16 Mar 2023 17:11:44 -0500 Subject: [PATCH 16/96] feat: add AM3200 to AirMediaController factory type list fix: adjust event callback to recognize events thrown by AM3x00 devices --- .../AirMedia/AirMediaController.cs | 37 ++-- .../Receivers/DmRmc150SController.cs | 194 +++++++++--------- 2 files changed, 121 insertions(+), 110 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/AirMedia/AirMediaController.cs b/essentials-framework/Essentials DM/Essentials_DM/AirMedia/AirMediaController.cs index ce2204fe..ad1cef9d 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/AirMedia/AirMediaController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/AirMedia/AirMediaController.cs @@ -19,7 +19,7 @@ namespace PepperDash.Essentials.DM.AirMedia [Description("Wrapper class for an AM-200 or AM-300")] public class AirMediaController : CrestronGenericBridgeableBaseDevice, IRoutingNumericWithFeedback, IIROutputPorts, IComPorts { - public AmX00 AirMedia { get; private set; } + public Am3x00 AirMedia { get; private set; } public DeviceConfig DeviceConfig { get; private set; } @@ -44,7 +44,7 @@ namespace PepperDash.Essentials.DM.AirMedia public StringFeedback SerialNumberFeedback { get; private set; } public BoolFeedback AutomaticInputRoutingEnabledFeedback { get; private set; } - public AirMediaController(string key, string name, AmX00 device, DeviceConfig dc, AirMediaPropertiesConfig props) + public AirMediaController(string key, string name, Am3x00 device, DeviceConfig dc, AirMediaPropertiesConfig props) : base(key, name, device) { @@ -181,7 +181,7 @@ namespace PepperDash.Essentials.DM.AirMedia { var newEvent = NumericSwitchChange; if (newEvent != null) newEvent(this, e); - } + } void AirMedia_AirMediaChange(object sender, Crestron.SimplSharpPro.DeviceSupport.GenericEventArgs args) @@ -202,8 +202,6 @@ namespace PepperDash.Essentials.DM.AirMedia void DisplayControl_DisplayControlChange(object sender, Crestron.SimplSharpPro.DeviceSupport.GenericEventArgs args) { - if (args.EventId == AmX00.VideoOutFeedbackEventId) - { VideoOutFeedback.FireUpdate(); var localInputPort = @@ -211,8 +209,7 @@ namespace PepperDash.Essentials.DM.AirMedia OnSwitchChange(new RoutingNumericEventArgs(1, VideoOutFeedback.UShortValue, OutputPorts.First(), localInputPort, eRoutingSignalType.AudioVideo)); - } - else if (args.EventId == AmX00.EnableAutomaticRoutingFeedbackEventId) + AutomaticInputRoutingEnabledFeedback.FireUpdate(); } @@ -342,7 +339,7 @@ namespace PepperDash.Essentials.DM.AirMedia { public AirMediaControllerFactory() { - TypeNames = new List() { "am200", "am300" }; + TypeNames = new List() { "am200", "am300", "am3200" }; } public override EssentialsDevice BuildDevice(DeviceConfig dc) @@ -352,11 +349,25 @@ namespace PepperDash.Essentials.DM.AirMedia Debug.Console(1, "Factory Attempting to create new AirMedia Device"); var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); - AmX00 amDevice = null; - if (type == "am200") - amDevice = new Crestron.SimplSharpPro.DM.AirMedia.Am200(props.Control.IpIdInt, Global.ControlSystem); - else if (type == "am300") - amDevice = new Crestron.SimplSharpPro.DM.AirMedia.Am300(props.Control.IpIdInt, Global.ControlSystem); + Am3x00 amDevice = null; + switch (type) + { + case "am200" : + { + amDevice = new Am200(props.Control.IpIdInt, Global.ControlSystem); + break; + } + case "am300" : + { + amDevice = new Am300(props.Control.IpIdInt, Global.ControlSystem); + break; + } + case "am3200" : + { + amDevice = new Am3200(props.Control.IpIdInt, Global.ControlSystem); + break; + } + } return new AirMediaController(dc.Key, dc.Name, amDevice, dc, props); diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc150SController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc150SController.cs index f33dd5be..0753ed4a 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc150SController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc150SController.cs @@ -1,99 +1,99 @@ -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Endpoints.Receivers; - -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; - -namespace PepperDash.Essentials.DM -{ - /// - /// Builds a controller for basic DM-RMCs with Com and IR ports and no control functions - /// +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.DM; +using Crestron.SimplSharpPro.DM.Endpoints.Receivers; + +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; + +namespace PepperDash.Essentials.DM +{ + /// + /// Builds a controller for basic DM-RMCs with Com and IR ports and no control functions + /// /// - [Description("Wrapper Class for DM-RMC-150-S")] - public class DmRmc150SController : DmRmcControllerBase, IRoutingInputsOutputs, - IIROutputPorts, IComPorts, ICec - { - private readonly DmRmc150S _rmc; - - public RoutingInputPort DmIn { get; private set; } - public RoutingOutputPort HdmiOut { get; private set; } - - public RoutingPortCollection InputPorts - { - get; private set; - } - - public RoutingPortCollection OutputPorts - { - get; - private set ; - } - - /// - /// Make a Crestron RMC and put it in here - /// - public DmRmc150SController(string key, string name, DmRmc150S rmc) - : base(key, name, rmc) - { - _rmc = rmc; - DmIn = new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.DmCat, 0, this); - HdmiOut = new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.Hdmi, null, this); - - EdidManufacturerFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.Manufacturer.StringValue); - EdidNameFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.Name.StringValue); - EdidPreferredTimingFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.PreferredTiming.StringValue); - EdidSerialNumberFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.SerialNumber.StringValue); - - InputPorts = new RoutingPortCollection {DmIn}; - OutputPorts = new RoutingPortCollection {HdmiOut}; - - _rmc.HdmiOutput.ConnectedDevice.DeviceInformationChange += ConnectedDevice_DeviceInformationChange; - - // Set Ports for CEC - HdmiOut.Port = _rmc.HdmiOutput; - } - - void ConnectedDevice_DeviceInformationChange(ConnectedDeviceInformation connectedDevice, ConnectedDeviceEventArgs args) - { - switch (args.EventId) - { - case ConnectedDeviceEventIds.ManufacturerEventId: - EdidManufacturerFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.NameEventId: - EdidNameFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.PreferredTimingEventId: - EdidPreferredTimingFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.SerialNumberEventId: - EdidSerialNumberFeedback.FireUpdate(); - break; - } - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - LinkDmRmcToApi(this, trilist, joinStart, joinMapKey, bridge); - } - - #region IIROutputPorts Members - public CrestronCollection IROutputPorts { get { return _rmc.IROutputPorts; } } - public int NumberOfIROutputPorts { get { return _rmc.NumberOfIROutputPorts; } } - #endregion - - #region IComPorts Members - public CrestronCollection ComPorts { get { return _rmc.ComPorts; } } - public int NumberOfComPorts { get { return _rmc.NumberOfComPorts; } } - #endregion - - #region ICec Members - public Cec StreamCec { get { return _rmc.HdmiOutput.StreamCec; } } - #endregion - } + [Description("Wrapper Class for DM-RMC-150-S")] + public class DmRmc150SController : DmRmcControllerBase, IRoutingInputsOutputs, + IIROutputPorts, IComPorts, ICec + { + private readonly DmRmc150S _rmc; + + public RoutingInputPort DmIn { get; private set; } + public RoutingOutputPort HdmiOut { get; private set; } + + public RoutingPortCollection InputPorts + { + get; private set; + } + + public RoutingPortCollection OutputPorts + { + get; + private set ; + } + + /// + /// Make a Crestron RMC and put it in here + /// + public DmRmc150SController(string key, string name, DmRmc150S rmc) + : base(key, name, rmc) + { + _rmc = rmc; + DmIn = new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.AudioVideo, + eRoutingPortConnectionType.DmCat, 0, this); + HdmiOut = new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.AudioVideo, + eRoutingPortConnectionType.Hdmi, null, this); + + EdidManufacturerFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.Manufacturer.StringValue); + EdidNameFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.Name.StringValue); + EdidPreferredTimingFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.PreferredTiming.StringValue); + EdidSerialNumberFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.SerialNumber.StringValue); + + InputPorts = new RoutingPortCollection {DmIn}; + OutputPorts = new RoutingPortCollection {HdmiOut}; + + _rmc.HdmiOutput.ConnectedDevice.DeviceInformationChange += ConnectedDevice_DeviceInformationChange; + + // Set Ports for CEC + HdmiOut.Port = _rmc.HdmiOutput; + } + + void ConnectedDevice_DeviceInformationChange(ConnectedDeviceInformation connectedDevice, ConnectedDeviceEventArgs args) + { + switch (args.EventId) + { + case ConnectedDeviceEventIds.ManufacturerEventId: + EdidManufacturerFeedback.FireUpdate(); + break; + case ConnectedDeviceEventIds.NameEventId: + EdidNameFeedback.FireUpdate(); + break; + case ConnectedDeviceEventIds.PreferredTimingEventId: + EdidPreferredTimingFeedback.FireUpdate(); + break; + case ConnectedDeviceEventIds.SerialNumberEventId: + EdidSerialNumberFeedback.FireUpdate(); + break; + } + } + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + LinkDmRmcToApi(this, trilist, joinStart, joinMapKey, bridge); + } + + #region IIROutputPorts Members + public CrestronCollection IROutputPorts { get { return _rmc.IROutputPorts; } } + public int NumberOfIROutputPorts { get { return _rmc.NumberOfIROutputPorts; } } + #endregion + + #region IComPorts Members + public CrestronCollection ComPorts { get { return _rmc.ComPorts; } } + public int NumberOfComPorts { get { return _rmc.NumberOfComPorts; } } + #endregion + + #region ICec Members + public Cec StreamCec { get { return _rmc.HdmiOutput.StreamCec; } } + #endregion + } } \ No newline at end of file From 961af69aaee6666b65c0c50a8c28f240278e86ff Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Wed, 22 Mar 2023 10:35:48 -0600 Subject: [PATCH 17/96] chore: update PD Core version --- .../PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj | 2 +- packages.config | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj index c8ecbde6..e0859077 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj @@ -94,7 +94,7 @@ False - ..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCWSHelperInterface.dll + ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCWSHelperInterface.dll False diff --git a/packages.config b/packages.config index ea9f8e18..104d002d 100644 --- a/packages.config +++ b/packages.config @@ -1,3 +1,3 @@ - + \ No newline at end of file From d0688cbc16dc2f1f62ffa0ac6e81dcfcb15232cd Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Wed, 22 Mar 2023 10:36:10 -0600 Subject: [PATCH 18/96] refactor: simplify feedback & event subscription --- .../AirMedia/AirMediaController.cs | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/AirMedia/AirMediaController.cs b/essentials-framework/Essentials DM/Essentials_DM/AirMedia/AirMediaController.cs index ad1cef9d..cfedbdb5 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/AirMedia/AirMediaController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/AirMedia/AirMediaController.cs @@ -95,24 +95,24 @@ namespace PepperDash.Essentials.DM.AirMedia AirMedia.AirMedia.AirMediaChange += new Crestron.SimplSharpPro.DeviceSupport.GenericEventHandler(AirMedia_AirMediaChange); - IsInSessionFeedback = new BoolFeedback(new Func(() => AirMedia.AirMedia.StatusFeedback.UShortValue == 0)); - ErrorFeedback = new IntFeedback(new Func(() => AirMedia.AirMedia.ErrorFeedback.UShortValue)); - NumberOfUsersConnectedFeedback = new IntFeedback(new Func(() => AirMedia.AirMedia.NumberOfUsersConnectedFeedback.UShortValue)); - LoginCodeFeedback = new IntFeedback(new Func(() => AirMedia.AirMedia.LoginCodeFeedback.UShortValue)); - ConnectionAddressFeedback = new StringFeedback(new Func(() => AirMedia.AirMedia.ConnectionAddressFeedback.StringValue)); - HostnameFeedback = new StringFeedback(new Func(() => AirMedia.AirMedia.HostNameFeedback.StringValue)); + IsInSessionFeedback = new BoolFeedback(() => AirMedia.AirMedia.StatusFeedback.UShortValue == 0); + ErrorFeedback = new IntFeedback(() => AirMedia.AirMedia.ErrorFeedback.UShortValue); + NumberOfUsersConnectedFeedback = new IntFeedback(() => AirMedia.AirMedia.NumberOfUsersConnectedFeedback.UShortValue); + LoginCodeFeedback = new IntFeedback(() => AirMedia.AirMedia.LoginCodeFeedback.UShortValue); + ConnectionAddressFeedback = new StringFeedback(() => AirMedia.AirMedia.ConnectionAddressFeedback.StringValue); + HostnameFeedback = new StringFeedback(() => AirMedia.AirMedia.HostNameFeedback.StringValue); // TODO: Figure out if we can actually get the TSID/Serial - SerialNumberFeedback = new StringFeedback(new Func(() => "unknown")); + SerialNumberFeedback = new StringFeedback(() => "unknown"); - AirMedia.DisplayControl.DisplayControlChange += new Crestron.SimplSharpPro.DeviceSupport.GenericEventHandler(DisplayControl_DisplayControlChange); + AirMedia.DisplayControl.DisplayControlChange += DisplayControl_DisplayControlChange; - VideoOutFeedback = new IntFeedback(new Func(() => Convert.ToInt16(AirMedia.DisplayControl.VideoOutFeedback))); - AutomaticInputRoutingEnabledFeedback = new BoolFeedback(new Func(() => AirMedia.DisplayControl.EnableAutomaticRoutingFeedback.BoolValue)); + VideoOutFeedback = new IntFeedback(() => Convert.ToInt16(AirMedia.DisplayControl.VideoOutFeedback)); + AutomaticInputRoutingEnabledFeedback = new BoolFeedback(() => AirMedia.DisplayControl.EnableAutomaticRoutingFeedback.BoolValue); - AirMedia.HdmiIn.StreamChange += new Crestron.SimplSharpPro.DeviceSupport.StreamEventHandler(HdmiIn_StreamChange); + AirMedia.HdmiIn.StreamChange += HdmiIn_StreamChange; - HdmiVideoSyncDetectedFeedback = new BoolFeedback(new Func(() => AirMedia.HdmiIn.SyncDetectedFeedback.BoolValue)); + HdmiVideoSyncDetectedFeedback = new BoolFeedback(() => AirMedia.HdmiIn.SyncDetectedFeedback.BoolValue); } public override bool CustomActivate() @@ -348,7 +348,7 @@ namespace PepperDash.Essentials.DM.AirMedia Debug.Console(1, "Factory Attempting to create new AirMedia Device"); - var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); + var props = dc.Properties.ToObject(); Am3x00 amDevice = null; switch (type) { From e04f6d039677ce23c22c0260fdd163e7dd80a61a Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Wed, 22 Mar 2023 10:53:36 -0600 Subject: [PATCH 19/96] refactor: move to switch for event --- .../AirMedia/AirMediaController.cs | 54 +++++++++++++------ 1 file changed, 39 insertions(+), 15 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/AirMedia/AirMediaController.cs b/essentials-framework/Essentials DM/Essentials_DM/AirMedia/AirMediaController.cs index cfedbdb5..b7770352 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/AirMedia/AirMediaController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/AirMedia/AirMediaController.cs @@ -122,7 +122,7 @@ namespace PepperDash.Essentials.DM.AirMedia else AirMedia.DisplayControl.DisableAutomaticRouting(); - return base.CustomActivate(); + return true; } public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) @@ -179,25 +179,49 @@ namespace PepperDash.Essentials.DM.AirMedia /// Arguments defined as IKeyName sender, output, input, and eRoutingSignalType private void OnSwitchChange(RoutingNumericEventArgs e) { - var newEvent = NumericSwitchChange; - if (newEvent != null) newEvent(this, e); + var handler = NumericSwitchChange; + + if (handler == null) return; + + handler(this, e); } void AirMedia_AirMediaChange(object sender, Crestron.SimplSharpPro.DeviceSupport.GenericEventArgs args) { - if (args.EventId == AirMediaInputSlot.AirMediaStatusFeedbackEventId) - IsInSessionFeedback.FireUpdate(); - else if (args.EventId == AirMediaInputSlot.AirMediaErrorFeedbackEventId) - ErrorFeedback.FireUpdate(); - else if (args.EventId == AirMediaInputSlot.AirMediaNumberOfUserConnectedEventId) - NumberOfUsersConnectedFeedback.FireUpdate(); - else if (args.EventId == AirMediaInputSlot.AirMediaLoginCodeEventId) - LoginCodeFeedback.FireUpdate(); - else if (args.EventId == AirMediaInputSlot.AirMediaConnectionAddressFeedbackEventId) - ConnectionAddressFeedback.FireUpdate(); - else if (args.EventId == AirMediaInputSlot.AirMediaHostNameFeedbackEventId) - HostnameFeedback.FireUpdate(); + switch (args.EventId) + { + case AirMediaInputSlot.AirMediaStatusFeedbackEventId: + { + IsInSessionFeedback.FireUpdate(); + break; + } + case AirMediaInputSlot.AirMediaErrorFeedbackEventId: + { + ErrorFeedback.FireUpdate(); + break; + } + case AirMediaInputSlot.AirMediaNumberOfUserConnectedEventId: + { + NumberOfUsersConnectedFeedback.FireUpdate(); + break; + } + case AirMediaInputSlot.AirMediaLoginCodeEventId: + { + LoginCodeFeedback.FireUpdate(); + break; + } + case AirMediaInputSlot.AirMediaConnectionAddressFeedbackEventId: + { + ConnectionAddressFeedback.FireUpdate(); + break; + } + case AirMediaInputSlot.AirMediaHostNameFeedbackEventId: + { + HostnameFeedback.FireUpdate(); + break; + } + } } void DisplayControl_DisplayControlChange(object sender, Crestron.SimplSharpPro.DeviceSupport.GenericEventArgs args) From f253abd0ae199fc784a511480b25d5bc9adb478b Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Wed, 22 Mar 2023 10:53:57 -0600 Subject: [PATCH 20/96] fix; add check for HdmiIn being null Not all Airmedia devices that might use this class have an HDMI input. This check should prevent null ref exceptions from happening. --- .../Essentials_DM/AirMedia/AirMediaController.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/AirMedia/AirMediaController.cs b/essentials-framework/Essentials DM/Essentials_DM/AirMedia/AirMediaController.cs index b7770352..ff07a54b 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/AirMedia/AirMediaController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/AirMedia/AirMediaController.cs @@ -110,9 +110,16 @@ namespace PepperDash.Essentials.DM.AirMedia VideoOutFeedback = new IntFeedback(() => Convert.ToInt16(AirMedia.DisplayControl.VideoOutFeedback)); AutomaticInputRoutingEnabledFeedback = new BoolFeedback(() => AirMedia.DisplayControl.EnableAutomaticRoutingFeedback.BoolValue); - AirMedia.HdmiIn.StreamChange += HdmiIn_StreamChange; + // Not all AirMedia versions support HDMI In like the 3200 + if (AirMedia.HdmiIn != null) + { + AirMedia.HdmiIn.StreamChange += HdmiIn_StreamChange; + HdmiVideoSyncDetectedFeedback = new BoolFeedback(() => AirMedia.HdmiIn.SyncDetectedFeedback.BoolValue); + return; + } - HdmiVideoSyncDetectedFeedback = new BoolFeedback(() => AirMedia.HdmiIn.SyncDetectedFeedback.BoolValue); + // Return false if the AirMedia device doesn't support HDMI Input + HdmiVideoSyncDetectedFeedback = new BoolFeedback(() => false); } public override bool CustomActivate() From 243c7cc3ee92fc8c38230f729839fe6ee6bb656b Mon Sep 17 00:00:00 2001 From: Trevor Payne Date: Fri, 17 Mar 2023 18:23:20 -0500 Subject: [PATCH 21/96] feat: Add HDCP capability feedback and setting to Displayport Input on 4xz302 endpoint feat: Resolve #1073 --- .../Bridges/JoinMaps/DmTxControllerJoinMap.cs | 5 + .../Receivers/DmRmc200CController.cs | 214 ++--- .../Transmitters/DmTx200Controller.cs | 732 +++++++++--------- .../Transmitters/DmTx201CController.cs | 614 +++++++-------- .../Transmitters/DmTx4k302CController.cs | 730 ++++++++--------- .../Transmitters/DmTx4kz302CController.cs | 14 +- .../Endpoints/Transmitters/DmTxHelpers.cs | 34 + 7 files changed, 1197 insertions(+), 1146 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmTxControllerJoinMap.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmTxControllerJoinMap.cs index 6d783639..11e20375 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmTxControllerJoinMap.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmTxControllerJoinMap.cs @@ -64,6 +64,11 @@ namespace PepperDash.Essentials.Core.Bridges public JoinDataComplete VgaContrast = new JoinDataComplete(new JoinData { JoinNumber = 7, JoinSpan = 1 }, new JoinMetadata { Description = "DM TX Online", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + [JoinName("Port3HdcpState")] + public JoinDataComplete Port3HdcpState = new JoinDataComplete(new JoinData { JoinNumber = 8, JoinSpan = 1 }, + new JoinMetadata { Description = "DM TX Port 3 HDCP State Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + /// /// Constructor to use when instantiating this Join Map without inheriting from it /// diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc200CController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc200CController.cs index ed5bd378..df39e4ee 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc200CController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc200CController.cs @@ -1,111 +1,111 @@ -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Endpoints; -using Crestron.SimplSharpPro.DM.Endpoints.Receivers; - -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; - -namespace PepperDash.Essentials.DM -{ - /// - /// Builds a controller for basic DM-RMCs with Com and IR ports and no control functions - /// +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.DM; +using Crestron.SimplSharpPro.DM.Endpoints; +using Crestron.SimplSharpPro.DM.Endpoints.Receivers; + +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; + +namespace PepperDash.Essentials.DM +{ + /// + /// Builds a controller for basic DM-RMCs with Com and IR ports and no control functions + /// /// [Description("Wrapper Class for DM-RMC-200-C")] - public class DmRmc200CController : DmRmcControllerBase, IRoutingInputsOutputs, - IIROutputPorts, IComPorts, ICec - { - private readonly DmRmc200C _rmc; - - public RoutingInputPort DmIn { get; private set; } + public class DmRmc200CController : DmRmcControllerBase, IRoutingInputsOutputs, + IIROutputPorts, IComPorts, ICec + { + private readonly DmRmc200C _rmc; + + public RoutingInputPort DmIn { get; private set; } public RoutingOutputPort HdmiOut { get; private set; } - - public RoutingPortCollection InputPorts - { - get; private set; - } - - public RoutingPortCollection OutputPorts - { - get; private set; - } - - /// - /// Make a Crestron RMC and put it in here - /// - public DmRmc200CController(string key, string name, DmRmc200C rmc) - : base(key, name, rmc) - { - _rmc = rmc; - DmIn = new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.DmCat, 0, this); - HdmiOut = new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.Hdmi, null, this); - - EdidManufacturerFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.Manufacturer.StringValue); - EdidNameFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.Name.StringValue); - EdidPreferredTimingFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.PreferredTiming.StringValue); - EdidSerialNumberFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.SerialNumber.StringValue); - - VideoOutputResolutionFeedback = new StringFeedback(() => _rmc.HdmiOutput.GetVideoResolutionString()); - - _rmc.HdmiOutput.OutputStreamChange += HdmiOutput_OutputStreamChange; - _rmc.HdmiOutput.ConnectedDevice.DeviceInformationChange += ConnectedDevice_DeviceInformationChange; - - InputPorts = new RoutingPortCollection {DmIn}; - OutputPorts = new RoutingPortCollection {HdmiOut}; - - // Set Ports for CEC - HdmiOut.Port = _rmc.HdmiOutput; - } - - void HdmiOutput_OutputStreamChange(EndpointOutputStream outputStream, EndpointOutputStreamEventArgs args) - { - if (args.EventId == EndpointOutputStreamEventIds.HorizontalResolutionFeedbackEventId || args.EventId == EndpointOutputStreamEventIds.VerticalResolutionFeedbackEventId || - args.EventId == EndpointOutputStreamEventIds.FramesPerSecondFeedbackEventId) - { - VideoOutputResolutionFeedback.FireUpdate(); - } - } - - void ConnectedDevice_DeviceInformationChange(ConnectedDeviceInformation connectedDevice, ConnectedDeviceEventArgs args) - { - switch (args.EventId) - { - case ConnectedDeviceEventIds.ManufacturerEventId: - EdidManufacturerFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.NameEventId: - EdidNameFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.PreferredTimingEventId: - EdidPreferredTimingFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.SerialNumberEventId: - EdidSerialNumberFeedback.FireUpdate(); - break; - } - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - LinkDmRmcToApi(this, trilist, joinStart, joinMapKey, bridge); - } - - #region IIROutputPorts Members - public CrestronCollection IROutputPorts { get { return _rmc.IROutputPorts; } } - public int NumberOfIROutputPorts { get { return _rmc.NumberOfIROutputPorts; } } - #endregion - - #region IComPorts Members - public CrestronCollection ComPorts { get { return _rmc.ComPorts; } } - public int NumberOfComPorts { get { return _rmc.NumberOfComPorts; } } - #endregion - - #region ICec Members - public Cec StreamCec { get { return _rmc.HdmiOutput.StreamCec; } } - #endregion - } + + public RoutingPortCollection InputPorts + { + get; private set; + } + + public RoutingPortCollection OutputPorts + { + get; private set; + } + + /// + /// Make a Crestron RMC and put it in here + /// + public DmRmc200CController(string key, string name, DmRmc200C rmc) + : base(key, name, rmc) + { + _rmc = rmc; + DmIn = new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.AudioVideo, + eRoutingPortConnectionType.DmCat, 0, this); + HdmiOut = new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.AudioVideo, + eRoutingPortConnectionType.Hdmi, null, this); + + EdidManufacturerFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.Manufacturer.StringValue); + EdidNameFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.Name.StringValue); + EdidPreferredTimingFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.PreferredTiming.StringValue); + EdidSerialNumberFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.SerialNumber.StringValue); + + VideoOutputResolutionFeedback = new StringFeedback(() => _rmc.HdmiOutput.GetVideoResolutionString()); + + _rmc.HdmiOutput.OutputStreamChange += HdmiOutput_OutputStreamChange; + _rmc.HdmiOutput.ConnectedDevice.DeviceInformationChange += ConnectedDevice_DeviceInformationChange; + + InputPorts = new RoutingPortCollection {DmIn}; + OutputPorts = new RoutingPortCollection {HdmiOut}; + + // Set Ports for CEC + HdmiOut.Port = _rmc.HdmiOutput; + } + + void HdmiOutput_OutputStreamChange(EndpointOutputStream outputStream, EndpointOutputStreamEventArgs args) + { + if (args.EventId == EndpointOutputStreamEventIds.HorizontalResolutionFeedbackEventId || args.EventId == EndpointOutputStreamEventIds.VerticalResolutionFeedbackEventId || + args.EventId == EndpointOutputStreamEventIds.FramesPerSecondFeedbackEventId) + { + VideoOutputResolutionFeedback.FireUpdate(); + } + } + + void ConnectedDevice_DeviceInformationChange(ConnectedDeviceInformation connectedDevice, ConnectedDeviceEventArgs args) + { + switch (args.EventId) + { + case ConnectedDeviceEventIds.ManufacturerEventId: + EdidManufacturerFeedback.FireUpdate(); + break; + case ConnectedDeviceEventIds.NameEventId: + EdidNameFeedback.FireUpdate(); + break; + case ConnectedDeviceEventIds.PreferredTimingEventId: + EdidPreferredTimingFeedback.FireUpdate(); + break; + case ConnectedDeviceEventIds.SerialNumberEventId: + EdidSerialNumberFeedback.FireUpdate(); + break; + } + } + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + LinkDmRmcToApi(this, trilist, joinStart, joinMapKey, bridge); + } + + #region IIROutputPorts Members + public CrestronCollection IROutputPorts { get { return _rmc.IROutputPorts; } } + public int NumberOfIROutputPorts { get { return _rmc.NumberOfIROutputPorts; } } + #endregion + + #region IComPorts Members + public CrestronCollection ComPorts { get { return _rmc.ComPorts; } } + public int NumberOfComPorts { get { return _rmc.NumberOfComPorts; } } + #endregion + + #region ICec Members + public Cec StreamCec { get { return _rmc.HdmiOutput.StreamCec; } } + #endregion + } } \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx200Controller.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx200Controller.cs index fe4454b9..10507c4d 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx200Controller.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx200Controller.cs @@ -1,41 +1,41 @@ using System; using System.Linq; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Endpoints; -using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; - -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; - -namespace PepperDash.Essentials.DM -{ - // using eVst = Crestron.SimplSharpPro.DeviceSupport.eX02VideoSourceType; - - /// - /// Controller class for all DM-TX-201C/S/F transmitters +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.DM; +using Crestron.SimplSharpPro.DM.Endpoints; +using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; + +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; + +namespace PepperDash.Essentials.DM +{ + // using eVst = Crestron.SimplSharpPro.DeviceSupport.eX02VideoSourceType; + + /// + /// Controller class for all DM-TX-201C/S/F transmitters /// [Description("Wrapper class for DM-TX-200-C")] - public class DmTx200Controller : DmTxControllerBase, ITxRoutingWithFeedback, IHasFreeRun, IVgaBrightnessContrastControls - { - public DmTx200C2G Tx { get; private set; } - - public RoutingInputPortWithVideoStatuses HdmiInput { get; private set; } - public RoutingInputPortWithVideoStatuses VgaInput { get; private set; } - public RoutingOutputPort DmOutput { get; private set; } - - public override StringFeedback ActiveVideoInputFeedback { get; protected set; } - public IntFeedback VideoSourceNumericFeedback { get; protected set; } - public IntFeedback AudioSourceNumericFeedback { get; protected set; } - public IntFeedback HdmiInHdcpCapabilityFeedback { get; protected set; } //actually state - public BoolFeedback HdmiVideoSyncFeedback { get; protected set; } - public BoolFeedback VgaVideoSyncFeedback { get; protected set; } - - public BoolFeedback FreeRunEnabledFeedback { get; protected set; } - - public IntFeedback VgaBrightnessFeedback { get; protected set; } + public class DmTx200Controller : DmTxControllerBase, ITxRoutingWithFeedback, IHasFreeRun, IVgaBrightnessContrastControls + { + public DmTx200C2G Tx { get; private set; } + + public RoutingInputPortWithVideoStatuses HdmiInput { get; private set; } + public RoutingInputPortWithVideoStatuses VgaInput { get; private set; } + public RoutingOutputPort DmOutput { get; private set; } + + public override StringFeedback ActiveVideoInputFeedback { get; protected set; } + public IntFeedback VideoSourceNumericFeedback { get; protected set; } + public IntFeedback AudioSourceNumericFeedback { get; protected set; } + public IntFeedback HdmiInHdcpCapabilityFeedback { get; protected set; } //actually state + public BoolFeedback HdmiVideoSyncFeedback { get; protected set; } + public BoolFeedback VgaVideoSyncFeedback { get; protected set; } + + public BoolFeedback FreeRunEnabledFeedback { get; protected set; } + + public IntFeedback VgaBrightnessFeedback { get; protected set; } public IntFeedback VgaContrastFeedback { get; protected set; } //IroutingNumericEvent @@ -49,57 +49,57 @@ namespace PepperDash.Essentials.DM { var newEvent = NumericSwitchChange; if (newEvent != null) newEvent(this, e); - } - - - /// - /// Helps get the "real" inputs, including when in Auto - /// - public DmTx200Base.eSourceSelection ActualActiveVideoInput - { - get - { - if (Tx.VideoSourceFeedback == DmTx200Base.eSourceSelection.Digital || - Tx.VideoSourceFeedback == DmTx200Base.eSourceSelection.Analog || - Tx.VideoSourceFeedback == DmTx200Base.eSourceSelection.Disable) - return Tx.VideoSourceFeedback; - if (Tx.HdmiInput.SyncDetectedFeedback.BoolValue) - return DmTx200Base.eSourceSelection.Digital; - - return Tx.VgaInput.SyncDetectedFeedback.BoolValue ? DmTx200Base.eSourceSelection.Analog : DmTx200Base.eSourceSelection.Disable; - } - } - - public RoutingPortCollection InputPorts - { - get - { - return new RoutingPortCollection - { - HdmiInput, - VgaInput, - AnyVideoInput - }; - } - } - - public RoutingPortCollection OutputPorts - { - get - { - return new RoutingPortCollection { DmOutput }; - } - } - - /// - /// - /// - /// - /// - /// - public DmTx200Controller(string key, string name, DmTx200C2G tx, bool preventRegistration) - : base(key, name, tx) - { + } + + + /// + /// Helps get the "real" inputs, including when in Auto + /// + public DmTx200Base.eSourceSelection ActualActiveVideoInput + { + get + { + if (Tx.VideoSourceFeedback == DmTx200Base.eSourceSelection.Digital || + Tx.VideoSourceFeedback == DmTx200Base.eSourceSelection.Analog || + Tx.VideoSourceFeedback == DmTx200Base.eSourceSelection.Disable) + return Tx.VideoSourceFeedback; + if (Tx.HdmiInput.SyncDetectedFeedback.BoolValue) + return DmTx200Base.eSourceSelection.Digital; + + return Tx.VgaInput.SyncDetectedFeedback.BoolValue ? DmTx200Base.eSourceSelection.Analog : DmTx200Base.eSourceSelection.Disable; + } + } + + public RoutingPortCollection InputPorts + { + get + { + return new RoutingPortCollection + { + HdmiInput, + VgaInput, + AnyVideoInput + }; + } + } + + public RoutingPortCollection OutputPorts + { + get + { + return new RoutingPortCollection { DmOutput }; + } + } + + /// + /// + /// + /// + /// + /// + public DmTx200Controller(string key, string name, DmTx200C2G tx, bool preventRegistration) + : base(key, name, tx) + { Tx = tx; PreventRegistration = preventRegistration; @@ -116,300 +116,300 @@ namespace PepperDash.Essentials.DM VideoStatusHelper.GetVgaInputStatusFuncs(tx.VgaInput)) { FeedbackMatchObject = DmTx200Base.eSourceSelection.Analog - }; - - ActiveVideoInputFeedback = new StringFeedback("ActiveVideoInput", - () => ActualActiveVideoInput.ToString()); - - Tx.HdmiInput.InputStreamChange += InputStreamChangeEvent; - Tx.VgaInput.InputStreamChange += VgaInputOnInputStreamChange; - Tx.BaseEvent += Tx_BaseEvent; - Tx.OnlineStatusChange += Tx_OnlineStatusChange; - - VideoSourceNumericFeedback = new IntFeedback(() => (int)Tx.VideoSourceFeedback); - AudioSourceNumericFeedback = new IntFeedback(() => (int)Tx.AudioSourceFeedback); - + }; + + ActiveVideoInputFeedback = new StringFeedback("ActiveVideoInput", + () => ActualActiveVideoInput.ToString()); + + Tx.HdmiInput.InputStreamChange += InputStreamChangeEvent; + Tx.VgaInput.InputStreamChange += VgaInputOnInputStreamChange; + Tx.BaseEvent += Tx_BaseEvent; + Tx.OnlineStatusChange += Tx_OnlineStatusChange; + + VideoSourceNumericFeedback = new IntFeedback(() => (int)Tx.VideoSourceFeedback); + AudioSourceNumericFeedback = new IntFeedback(() => (int)Tx.AudioSourceFeedback); + HdmiInHdcpCapabilityFeedback = new IntFeedback("HdmiInHdcpCapability", () => tx.HdmiInput.HdcpSupportOnFeedback.BoolValue ? 1 : 0); //setting this on the base class so that we can get it easily on the chassis. - HdcpStateFeedback = HdmiInHdcpCapabilityFeedback; - - HdcpSupportCapability = eHdcpCapabilityType.HdcpAutoSupport; - - HdmiVideoSyncFeedback = new BoolFeedback(() => tx.HdmiInput.SyncDetectedFeedback.BoolValue); - - VgaVideoSyncFeedback = new BoolFeedback(() => tx.VgaInput.SyncDetectedFeedback.BoolValue); - - FreeRunEnabledFeedback = new BoolFeedback(() => tx.VgaInput.FreeRunFeedback == eDmFreeRunSetting.Enabled); - - VgaBrightnessFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.BrightnessFeedback.UShortValue); - VgaContrastFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.ContrastFeedback.UShortValue); - - tx.VgaInput.VideoControls.ControlChange += VideoControls_ControlChange; - - - var combinedFuncs = new VideoStatusFuncsWrapper - { - HdcpActiveFeedbackFunc = () => - (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital - && tx.HdmiInput.VideoAttributes.HdcpActiveFeedback.BoolValue), - - HdcpStateFeedbackFunc = () => ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital ? tx.HdmiInput.VideoAttributes.HdcpStateFeedback.ToString() : "", - - VideoResolutionFeedbackFunc = () => - { - if (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital) - return tx.HdmiInput.VideoAttributes.GetVideoResolutionString(); - return ActualActiveVideoInput == DmTx200Base.eSourceSelection.Analog ? tx.VgaInput.VideoAttributes.GetVideoResolutionString() : ""; - }, - VideoSyncFeedbackFunc = () => - (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital - && tx.HdmiInput.SyncDetectedFeedback.BoolValue) - || (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Analog - && tx.VgaInput.SyncDetectedFeedback.BoolValue) - || (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Auto - && (tx.VgaInput.SyncDetectedFeedback.BoolValue || tx.HdmiInput.SyncDetectedFeedback.BoolValue)) - - }; - - AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.None, 0, this, combinedFuncs); - - DmOutput = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.DmCat, null, this); - - AddToFeedbackList(ActiveVideoInputFeedback, VideoSourceNumericFeedback, AudioSourceNumericFeedback, - AnyVideoInput.VideoStatus.HasVideoStatusFeedback, AnyVideoInput.VideoStatus.HdcpActiveFeedback, - AnyVideoInput.VideoStatus.HdcpStateFeedback, AnyVideoInput.VideoStatus.VideoResolutionFeedback, - AnyVideoInput.VideoStatus.VideoSyncFeedback, HdmiInHdcpCapabilityFeedback, HdmiVideoSyncFeedback, - VgaVideoSyncFeedback); - - // Set Ports for CEC - HdmiInput.Port = Tx.HdmiInput; - VgaInput.Port = Tx.VgaInput; - DmOutput.Port = Tx.DmOutput; - } - - private void VgaInputOnInputStreamChange(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) - { - switch (args.EventId) - { - case EndpointInputStreamEventIds.FreeRunFeedbackEventId: - FreeRunEnabledFeedback.FireUpdate(); - break; - case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: - VgaVideoSyncFeedback.FireUpdate(); - break; - } - } - - void VideoControls_ControlChange(object sender, GenericEventArgs args) - { - var id = args.EventId; - Debug.Console(2, this, "EventId {0}", args.EventId); - - switch (id) - { - case VideoControlsEventIds.BrightnessFeedbackEventId: - VgaBrightnessFeedback.FireUpdate(); - break; - case VideoControlsEventIds.ContrastFeedbackEventId: - VgaContrastFeedback.FireUpdate(); - break; - } - } - + HdcpStateFeedback = HdmiInHdcpCapabilityFeedback; + + HdcpSupportCapability = eHdcpCapabilityType.HdcpAutoSupport; + + HdmiVideoSyncFeedback = new BoolFeedback(() => tx.HdmiInput.SyncDetectedFeedback.BoolValue); + + VgaVideoSyncFeedback = new BoolFeedback(() => tx.VgaInput.SyncDetectedFeedback.BoolValue); + + FreeRunEnabledFeedback = new BoolFeedback(() => tx.VgaInput.FreeRunFeedback == eDmFreeRunSetting.Enabled); + + VgaBrightnessFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.BrightnessFeedback.UShortValue); + VgaContrastFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.ContrastFeedback.UShortValue); + + tx.VgaInput.VideoControls.ControlChange += VideoControls_ControlChange; + + + var combinedFuncs = new VideoStatusFuncsWrapper + { + HdcpActiveFeedbackFunc = () => + (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital + && tx.HdmiInput.VideoAttributes.HdcpActiveFeedback.BoolValue), + + HdcpStateFeedbackFunc = () => ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital ? tx.HdmiInput.VideoAttributes.HdcpStateFeedback.ToString() : "", + + VideoResolutionFeedbackFunc = () => + { + if (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital) + return tx.HdmiInput.VideoAttributes.GetVideoResolutionString(); + return ActualActiveVideoInput == DmTx200Base.eSourceSelection.Analog ? tx.VgaInput.VideoAttributes.GetVideoResolutionString() : ""; + }, + VideoSyncFeedbackFunc = () => + (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital + && tx.HdmiInput.SyncDetectedFeedback.BoolValue) + || (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Analog + && tx.VgaInput.SyncDetectedFeedback.BoolValue) + || (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Auto + && (tx.VgaInput.SyncDetectedFeedback.BoolValue || tx.HdmiInput.SyncDetectedFeedback.BoolValue)) + + }; + + AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn, + eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.None, 0, this, combinedFuncs); + + DmOutput = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.DmCat, null, this); + + AddToFeedbackList(ActiveVideoInputFeedback, VideoSourceNumericFeedback, AudioSourceNumericFeedback, + AnyVideoInput.VideoStatus.HasVideoStatusFeedback, AnyVideoInput.VideoStatus.HdcpActiveFeedback, + AnyVideoInput.VideoStatus.HdcpStateFeedback, AnyVideoInput.VideoStatus.VideoResolutionFeedback, + AnyVideoInput.VideoStatus.VideoSyncFeedback, HdmiInHdcpCapabilityFeedback, HdmiVideoSyncFeedback, + VgaVideoSyncFeedback); + + // Set Ports for CEC + HdmiInput.Port = Tx.HdmiInput; + VgaInput.Port = Tx.VgaInput; + DmOutput.Port = Tx.DmOutput; + } + + private void VgaInputOnInputStreamChange(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) + { + switch (args.EventId) + { + case EndpointInputStreamEventIds.FreeRunFeedbackEventId: + FreeRunEnabledFeedback.FireUpdate(); + break; + case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: + VgaVideoSyncFeedback.FireUpdate(); + break; + } + } + + void VideoControls_ControlChange(object sender, GenericEventArgs args) + { + var id = args.EventId; + Debug.Console(2, this, "EventId {0}", args.EventId); + + switch (id) + { + case VideoControlsEventIds.BrightnessFeedbackEventId: + VgaBrightnessFeedback.FireUpdate(); + break; + case VideoControlsEventIds.ContrastFeedbackEventId: + VgaContrastFeedback.FireUpdate(); + break; + } + } + void Tx_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) { var localVideoInputPort = InputPorts.FirstOrDefault(p => (DmTx200Base.eSourceSelection) p.Selector == Tx.VideoSourceFeedback); var localAudioInputPort = - InputPorts.FirstOrDefault(p => (DmTx200Base.eSourceSelection) p.Selector == Tx.AudioSourceFeedback); - - - ActiveVideoInputFeedback.FireUpdate(); - VideoSourceNumericFeedback.FireUpdate(); + InputPorts.FirstOrDefault(p => (DmTx200Base.eSourceSelection) p.Selector == Tx.AudioSourceFeedback); + + + ActiveVideoInputFeedback.FireUpdate(); + VideoSourceNumericFeedback.FireUpdate(); AudioSourceNumericFeedback.FireUpdate(); OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); - OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localAudioInputPort, eRoutingSignalType.Audio)); - } - - public override bool CustomActivate() - { - - Tx.HdmiInput.InputStreamChange += (o, a) => FowardInputStreamChange(HdmiInput, a.EventId); - Tx.HdmiInput.VideoAttributes.AttributeChange += (o, a) => FireVideoAttributeChange(HdmiInput, a.EventId); - - Tx.VgaInput.InputStreamChange += (o, a) => FowardInputStreamChange(VgaInput, a.EventId); - Tx.VgaInput.VideoAttributes.AttributeChange += (o, a) => FireVideoAttributeChange(VgaInput, a.EventId); - - // Base does register and sets up comm monitoring. - return base.CustomActivate(); - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = GetDmTxJoinMap(joinStart, joinMapKey); - - if (HdmiVideoSyncFeedback != null) - { - HdmiVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input1VideoSyncStatus.JoinNumber]); - } - if (VgaVideoSyncFeedback != null) - { - VgaVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input2VideoSyncStatus.JoinNumber]); - } - - LinkDmTxToApi(this, trilist, joinMap, bridge); - } - - /// - /// Enables or disables free run - /// - /// - public void SetFreeRunEnabled(bool enable) - { - Tx.VgaInput.FreeRun = enable ? eDmFreeRunSetting.Enabled : eDmFreeRunSetting.Disabled; - } - - /// - /// Sets the VGA brightness level - /// - /// - public void SetVgaBrightness(ushort level) - { - Tx.VgaInput.VideoControls.Brightness.UShortValue = level; - } - - /// - /// Sets the VGA contrast level - /// - /// - public void SetVgaContrast(ushort level) - { - Tx.VgaInput.VideoControls.Contrast.UShortValue = level; - } - - public void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type) - { - Debug.Console(2, this, "Executing Numeric Switch to input {0}.", input); - - switch (input) - { - case 0: - { - ExecuteSwitch(DmTx200Base.eSourceSelection.Auto, null, type); - break; - } - case 1: - { - ExecuteSwitch(HdmiInput.Selector, null, type); - break; - } - case 2: - { - ExecuteSwitch(VgaInput.Selector, null, type); - break; - } - case 3: - { - ExecuteSwitch(DmTx200Base.eSourceSelection.Disable, null, type); - break; - } - } - } - - public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) - { - if ((signalType | eRoutingSignalType.Video) == eRoutingSignalType.Video) - Tx.VideoSource = (DmTx200Base.eSourceSelection)inputSelector; - if ((signalType | eRoutingSignalType.Audio) == eRoutingSignalType.Audio) - Tx.AudioSource = (DmTx200Base.eSourceSelection)inputSelector; - } - - void Tx_BaseEvent(GenericBase device, BaseEventArgs args) - { - var id = args.EventId; - Debug.Console(2, this, "EventId {0}", args.EventId); - - switch (id) - { + OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localAudioInputPort, eRoutingSignalType.Audio)); + } + + public override bool CustomActivate() + { + + Tx.HdmiInput.InputStreamChange += (o, a) => FowardInputStreamChange(HdmiInput, a.EventId); + Tx.HdmiInput.VideoAttributes.AttributeChange += (o, a) => FireVideoAttributeChange(HdmiInput, a.EventId); + + Tx.VgaInput.InputStreamChange += (o, a) => FowardInputStreamChange(VgaInput, a.EventId); + Tx.VgaInput.VideoAttributes.AttributeChange += (o, a) => FireVideoAttributeChange(VgaInput, a.EventId); + + // Base does register and sets up comm monitoring. + return base.CustomActivate(); + } + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + var joinMap = GetDmTxJoinMap(joinStart, joinMapKey); + + if (HdmiVideoSyncFeedback != null) + { + HdmiVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input1VideoSyncStatus.JoinNumber]); + } + if (VgaVideoSyncFeedback != null) + { + VgaVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input2VideoSyncStatus.JoinNumber]); + } + + LinkDmTxToApi(this, trilist, joinMap, bridge); + } + + /// + /// Enables or disables free run + /// + /// + public void SetFreeRunEnabled(bool enable) + { + Tx.VgaInput.FreeRun = enable ? eDmFreeRunSetting.Enabled : eDmFreeRunSetting.Disabled; + } + + /// + /// Sets the VGA brightness level + /// + /// + public void SetVgaBrightness(ushort level) + { + Tx.VgaInput.VideoControls.Brightness.UShortValue = level; + } + + /// + /// Sets the VGA contrast level + /// + /// + public void SetVgaContrast(ushort level) + { + Tx.VgaInput.VideoControls.Contrast.UShortValue = level; + } + + public void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type) + { + Debug.Console(2, this, "Executing Numeric Switch to input {0}.", input); + + switch (input) + { + case 0: + { + ExecuteSwitch(DmTx200Base.eSourceSelection.Auto, null, type); + break; + } + case 1: + { + ExecuteSwitch(HdmiInput.Selector, null, type); + break; + } + case 2: + { + ExecuteSwitch(VgaInput.Selector, null, type); + break; + } + case 3: + { + ExecuteSwitch(DmTx200Base.eSourceSelection.Disable, null, type); + break; + } + } + } + + public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) + { + if ((signalType | eRoutingSignalType.Video) == eRoutingSignalType.Video) + Tx.VideoSource = (DmTx200Base.eSourceSelection)inputSelector; + if ((signalType | eRoutingSignalType.Audio) == eRoutingSignalType.Audio) + Tx.AudioSource = (DmTx200Base.eSourceSelection)inputSelector; + } + + void Tx_BaseEvent(GenericBase device, BaseEventArgs args) + { + var id = args.EventId; + Debug.Console(2, this, "EventId {0}", args.EventId); + + switch (id) + { case EndpointTransmitterBase.VideoSourceFeedbackEventId: - var localVideoInputPort = InputPorts.FirstOrDefault(p => (DmTx200Base.eSourceSelection)p.Selector == Tx.VideoSourceFeedback); - Debug.Console(2, this, " Video Source: {0}", Tx.VideoSourceFeedback); - VideoSourceNumericFeedback.FireUpdate(); + var localVideoInputPort = InputPorts.FirstOrDefault(p => (DmTx200Base.eSourceSelection)p.Selector == Tx.VideoSourceFeedback); + Debug.Console(2, this, " Video Source: {0}", Tx.VideoSourceFeedback); + VideoSourceNumericFeedback.FireUpdate(); ActiveVideoInputFeedback.FireUpdate(); OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); - break; + break; case EndpointTransmitterBase.AudioSourceFeedbackEventId: - var localInputAudioPort = InputPorts.FirstOrDefault(p => (DmTx200Base.eSourceSelection)p.Selector == Tx.AudioSourceFeedback); - Debug.Console(2, this, " Audio Source: {0}", Tx.AudioSourceFeedback); + var localInputAudioPort = InputPorts.FirstOrDefault(p => (DmTx200Base.eSourceSelection)p.Selector == Tx.AudioSourceFeedback); + Debug.Console(2, this, " Audio Source: {0}", Tx.AudioSourceFeedback); AudioSourceNumericFeedback.FireUpdate(); - OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localInputAudioPort, eRoutingSignalType.Audio)); - break; - } - } - - void InputStreamChangeEvent(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) - { - Debug.Console(2, "{0} event {1} stream {2}", Tx.ToString(), inputStream.ToString(), args.EventId.ToString()); - - switch (args.EventId) - { - case EndpointInputStreamEventIds.HdcpSupportOffFeedbackEventId: - HdmiInHdcpCapabilityFeedback.FireUpdate(); - break; - case EndpointInputStreamEventIds.HdcpSupportOnFeedbackEventId: - HdmiInHdcpCapabilityFeedback.FireUpdate(); - break; - case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: - HdmiVideoSyncFeedback.FireUpdate(); - break; - } - } - - /// - /// Relays the input stream change to the appropriate RoutingInputPort. - /// - void FowardInputStreamChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) - { - if (eventId != EndpointInputStreamEventIds.SyncDetectedFeedbackEventId) - { - return; - } - inputPort.VideoStatus.VideoSyncFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoSyncFeedback.FireUpdate(); - } - - /// - /// Relays the VideoAttributes change to a RoutingInputPort - /// - void FireVideoAttributeChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) - { - //// LOCATION: Crestron.SimplSharpPro.DM.VideoAttributeEventIds - //Debug.Console(2, this, "VideoAttributes_AttributeChange event id={0} from {1}", - // args.EventId, (sender as VideoAttributesEnhanced).Owner.GetType()); - switch (eventId) - { - case VideoAttributeEventIds.HdcpActiveFeedbackEventId: - inputPort.VideoStatus.HdcpActiveFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.HdcpActiveFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.HdcpStateFeedbackEventId: - inputPort.VideoStatus.HdcpStateFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.HdcpStateFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.HorizontalResolutionFeedbackEventId: - case VideoAttributeEventIds.VerticalResolutionFeedbackEventId: - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.FramesPerSecondFeedbackEventId: - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); - break; - } - } - - } + OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localInputAudioPort, eRoutingSignalType.Audio)); + break; + } + } + + void InputStreamChangeEvent(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) + { + Debug.Console(2, "{0} event {1} stream {2}", Tx.ToString(), inputStream.ToString(), args.EventId.ToString()); + + switch (args.EventId) + { + case EndpointInputStreamEventIds.HdcpSupportOffFeedbackEventId: + HdmiInHdcpCapabilityFeedback.FireUpdate(); + break; + case EndpointInputStreamEventIds.HdcpSupportOnFeedbackEventId: + HdmiInHdcpCapabilityFeedback.FireUpdate(); + break; + case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: + HdmiVideoSyncFeedback.FireUpdate(); + break; + } + } + + /// + /// Relays the input stream change to the appropriate RoutingInputPort. + /// + void FowardInputStreamChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) + { + if (eventId != EndpointInputStreamEventIds.SyncDetectedFeedbackEventId) + { + return; + } + inputPort.VideoStatus.VideoSyncFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.VideoSyncFeedback.FireUpdate(); + } + + /// + /// Relays the VideoAttributes change to a RoutingInputPort + /// + void FireVideoAttributeChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) + { + //// LOCATION: Crestron.SimplSharpPro.DM.VideoAttributeEventIds + //Debug.Console(2, this, "VideoAttributes_AttributeChange event id={0} from {1}", + // args.EventId, (sender as VideoAttributesEnhanced).Owner.GetType()); + switch (eventId) + { + case VideoAttributeEventIds.HdcpActiveFeedbackEventId: + inputPort.VideoStatus.HdcpActiveFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.HdcpActiveFeedback.FireUpdate(); + break; + case VideoAttributeEventIds.HdcpStateFeedbackEventId: + inputPort.VideoStatus.HdcpStateFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.HdcpStateFeedback.FireUpdate(); + break; + case VideoAttributeEventIds.HorizontalResolutionFeedbackEventId: + case VideoAttributeEventIds.VerticalResolutionFeedbackEventId: + inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); + break; + case VideoAttributeEventIds.FramesPerSecondFeedbackEventId: + inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); + break; + } + } + + } } \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx201CController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx201CController.cs index 660d2fec..ae3dd7fc 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx201CController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx201CController.cs @@ -8,33 +8,33 @@ using System.Linq; using PepperDash.Core; using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; - -namespace PepperDash.Essentials.DM -{ - /// - /// Controller class for all DM-TX-201C/S/F transmitters +using PepperDash.Essentials.Core.Bridges; + +namespace PepperDash.Essentials.DM +{ + /// + /// Controller class for all DM-TX-201C/S/F transmitters /// [Description("Wrapper class for DM-TX-201-C")] - public class DmTx201CController : DmTxControllerBase, ITxRoutingWithFeedback, IHasFreeRun, IVgaBrightnessContrastControls - { - public DmTx201C Tx { get; private set; } - - public RoutingInputPortWithVideoStatuses HdmiInput { get; private set; } - public RoutingInputPortWithVideoStatuses VgaInput { get; private set; } - public RoutingOutputPort DmOutput { get; private set; } - public RoutingOutputPort HdmiLoopOut { get; private set; } - - public override StringFeedback ActiveVideoInputFeedback { get; protected set; } - public IntFeedback VideoSourceNumericFeedback { get; protected set; } - public IntFeedback AudioSourceNumericFeedback { get; protected set; } - public IntFeedback HdmiInHdcpCapabilityFeedback { get; protected set; } - public BoolFeedback HdmiVideoSyncFeedback { get; protected set; } - public BoolFeedback VgaVideoSyncFeedback { get; protected set; } - - public BoolFeedback FreeRunEnabledFeedback { get; protected set; } - - public IntFeedback VgaBrightnessFeedback { get; protected set; } + public class DmTx201CController : DmTxControllerBase, ITxRoutingWithFeedback, IHasFreeRun, IVgaBrightnessContrastControls + { + public DmTx201C Tx { get; private set; } + + public RoutingInputPortWithVideoStatuses HdmiInput { get; private set; } + public RoutingInputPortWithVideoStatuses VgaInput { get; private set; } + public RoutingOutputPort DmOutput { get; private set; } + public RoutingOutputPort HdmiLoopOut { get; private set; } + + public override StringFeedback ActiveVideoInputFeedback { get; protected set; } + public IntFeedback VideoSourceNumericFeedback { get; protected set; } + public IntFeedback AudioSourceNumericFeedback { get; protected set; } + public IntFeedback HdmiInHdcpCapabilityFeedback { get; protected set; } + public BoolFeedback HdmiVideoSyncFeedback { get; protected set; } + public BoolFeedback VgaVideoSyncFeedback { get; protected set; } + + public BoolFeedback FreeRunEnabledFeedback { get; protected set; } + + public IntFeedback VgaBrightnessFeedback { get; protected set; } public IntFeedback VgaContrastFeedback { get; protected set; } //IroutingNumericEvent @@ -48,61 +48,61 @@ namespace PepperDash.Essentials.DM { var newEvent = NumericSwitchChange; if (newEvent != null) newEvent(this, e); - } - - /// - /// Helps get the "real" inputs, including when in Auto - /// - public DmTx200Base.eSourceSelection ActualActiveVideoInput - { - get - { - if (Tx.VideoSourceFeedback == DmTx200Base.eSourceSelection.Digital || - Tx.VideoSourceFeedback == DmTx200Base.eSourceSelection.Analog || - Tx.VideoSourceFeedback == DmTx200Base.eSourceSelection.Disable) - return Tx.VideoSourceFeedback; - else // auto - { - if (Tx.HdmiInput.SyncDetectedFeedback.BoolValue) - return DmTx200Base.eSourceSelection.Digital; - else if (Tx.VgaInput.SyncDetectedFeedback.BoolValue) - return DmTx200Base.eSourceSelection.Analog; - else - return DmTx200Base.eSourceSelection.Disable; - } - } - } - - public RoutingPortCollection InputPorts - { - get - { - return new RoutingPortCollection - { - HdmiInput, - VgaInput, - AnyVideoInput - }; - } - } - - public RoutingPortCollection OutputPorts - { - get - { - return new RoutingPortCollection { DmOutput, HdmiLoopOut }; - } - } - - /// - /// - /// - /// - /// + } + + /// + /// Helps get the "real" inputs, including when in Auto + /// + public DmTx200Base.eSourceSelection ActualActiveVideoInput + { + get + { + if (Tx.VideoSourceFeedback == DmTx200Base.eSourceSelection.Digital || + Tx.VideoSourceFeedback == DmTx200Base.eSourceSelection.Analog || + Tx.VideoSourceFeedback == DmTx200Base.eSourceSelection.Disable) + return Tx.VideoSourceFeedback; + else // auto + { + if (Tx.HdmiInput.SyncDetectedFeedback.BoolValue) + return DmTx200Base.eSourceSelection.Digital; + else if (Tx.VgaInput.SyncDetectedFeedback.BoolValue) + return DmTx200Base.eSourceSelection.Analog; + else + return DmTx200Base.eSourceSelection.Disable; + } + } + } + + public RoutingPortCollection InputPorts + { + get + { + return new RoutingPortCollection + { + HdmiInput, + VgaInput, + AnyVideoInput + }; + } + } + + public RoutingPortCollection OutputPorts + { + get + { + return new RoutingPortCollection { DmOutput, HdmiLoopOut }; + } + } + + /// + /// + /// + /// + /// /// - public DmTx201CController(string key, string name, DmTx201C tx, bool preventRegistration) - : base(key, name, tx) - { + public DmTx201CController(string key, string name, DmTx201C tx, bool preventRegistration) + : base(key, name, tx) + { Tx = tx; PreventRegistration = preventRegistration; @@ -119,89 +119,89 @@ namespace PepperDash.Essentials.DM VideoStatusHelper.GetVgaInputStatusFuncs(tx.VgaInput)) { FeedbackMatchObject = DmTx200Base.eSourceSelection.Analog - }; - - ActiveVideoInputFeedback = new StringFeedback("ActiveVideoInput", - () => ActualActiveVideoInput.ToString()); - + }; + + ActiveVideoInputFeedback = new StringFeedback("ActiveVideoInput", + () => ActualActiveVideoInput.ToString()); + Tx.HdmiInput.InputStreamChange += InputStreamChangeEvent; - Tx.VgaInput.InputStreamChange += VgaInputOnInputStreamChange; - Tx.BaseEvent += Tx_BaseEvent; - Tx.OnlineStatusChange += new OnlineStatusChangeEventHandler(Tx_OnlineStatusChange); - - VideoSourceNumericFeedback = new IntFeedback(() => (int)Tx.VideoSourceFeedback); - + Tx.VgaInput.InputStreamChange += VgaInputOnInputStreamChange; + Tx.BaseEvent += Tx_BaseEvent; + Tx.OnlineStatusChange += new OnlineStatusChangeEventHandler(Tx_OnlineStatusChange); + + VideoSourceNumericFeedback = new IntFeedback(() => (int)Tx.VideoSourceFeedback); + AudioSourceNumericFeedback = new IntFeedback(() => (int)Tx.AudioSourceFeedback); HdmiInHdcpCapabilityFeedback = new IntFeedback("HdmiInHdcpCapability", () => (tx.HdmiInput.HdcpSupportOnFeedback.BoolValue ? 1 : 0)); - HdcpStateFeedback = HdmiInHdcpCapabilityFeedback; - - HdmiVideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInput.SyncDetectedFeedback.BoolValue); - - VgaVideoSyncFeedback = new BoolFeedback(() => (bool)tx.VgaInput.SyncDetectedFeedback.BoolValue); - - FreeRunEnabledFeedback = new BoolFeedback(() => tx.VgaInput.FreeRunFeedback == eDmFreeRunSetting.Enabled); - - VgaBrightnessFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.BrightnessFeedback.UShortValue); - - VgaContrastFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.ContrastFeedback.UShortValue); - - tx.VgaInput.VideoControls.ControlChange += VideoControls_ControlChange; - - HdcpSupportCapability = eHdcpCapabilityType.HdcpAutoSupport; - - var combinedFuncs = new VideoStatusFuncsWrapper - { - HdcpActiveFeedbackFunc = () => - (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital - && tx.HdmiInput.VideoAttributes.HdcpActiveFeedback.BoolValue), + HdcpStateFeedback = HdmiInHdcpCapabilityFeedback; - HdcpStateFeedbackFunc = () => ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital ? - tx.HdmiInput.VideoAttributes.HdcpStateFeedback.ToString() : "", - - VideoResolutionFeedbackFunc = () => - { - if (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital) - return tx.HdmiInput.VideoAttributes.GetVideoResolutionString(); - return ActualActiveVideoInput == DmTx200Base.eSourceSelection.Analog ? - tx.VgaInput.VideoAttributes.GetVideoResolutionString() : ""; - }, - - VideoSyncFeedbackFunc = () => - (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital - && tx.HdmiInput.SyncDetectedFeedback.BoolValue) - || (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Analog - && tx.VgaInput.SyncDetectedFeedback.BoolValue) - || (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Auto - && (tx.VgaInput.SyncDetectedFeedback.BoolValue || tx.HdmiInput.SyncDetectedFeedback.BoolValue)) - - }; - - AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.None, 0, this, combinedFuncs); - - DmOutput = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmCat, null, this); - HdmiLoopOut = new RoutingOutputPort(DmPortName.HdmiLoopOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, null, this); - - AddToFeedbackList(ActiveVideoInputFeedback, VideoSourceNumericFeedback, AudioSourceNumericFeedback, - AnyVideoInput.VideoStatus.HasVideoStatusFeedback, AnyVideoInput.VideoStatus.HdcpActiveFeedback, - AnyVideoInput.VideoStatus.HdcpStateFeedback, AnyVideoInput.VideoStatus.VideoResolutionFeedback, - AnyVideoInput.VideoStatus.VideoSyncFeedback, HdmiInHdcpCapabilityFeedback, HdmiVideoSyncFeedback, - VgaVideoSyncFeedback); - - // Set Ports for CEC - HdmiInput.Port = Tx.HdmiInput; - VgaInput.Port = Tx.VgaInput; - HdmiLoopOut.Port = Tx.HdmiOutput; - DmOutput.Port = Tx.DmOutput; - } - - void VideoControls_ControlChange(object sender, Crestron.SimplSharpPro.DeviceSupport.GenericEventArgs args) - { - var id = args.EventId; + HdmiVideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInput.SyncDetectedFeedback.BoolValue); + + VgaVideoSyncFeedback = new BoolFeedback(() => (bool)tx.VgaInput.SyncDetectedFeedback.BoolValue); + + FreeRunEnabledFeedback = new BoolFeedback(() => tx.VgaInput.FreeRunFeedback == eDmFreeRunSetting.Enabled); + + VgaBrightnessFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.BrightnessFeedback.UShortValue); + + VgaContrastFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.ContrastFeedback.UShortValue); + + tx.VgaInput.VideoControls.ControlChange += VideoControls_ControlChange; + + HdcpSupportCapability = eHdcpCapabilityType.HdcpAutoSupport; + + var combinedFuncs = new VideoStatusFuncsWrapper + { + HdcpActiveFeedbackFunc = () => + (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital + && tx.HdmiInput.VideoAttributes.HdcpActiveFeedback.BoolValue), + + HdcpStateFeedbackFunc = () => ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital ? + tx.HdmiInput.VideoAttributes.HdcpStateFeedback.ToString() : "", + + VideoResolutionFeedbackFunc = () => + { + if (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital) + return tx.HdmiInput.VideoAttributes.GetVideoResolutionString(); + return ActualActiveVideoInput == DmTx200Base.eSourceSelection.Analog ? + tx.VgaInput.VideoAttributes.GetVideoResolutionString() : ""; + }, + + VideoSyncFeedbackFunc = () => + (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Digital + && tx.HdmiInput.SyncDetectedFeedback.BoolValue) + || (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Analog + && tx.VgaInput.SyncDetectedFeedback.BoolValue) + || (ActualActiveVideoInput == DmTx200Base.eSourceSelection.Auto + && (tx.VgaInput.SyncDetectedFeedback.BoolValue || tx.HdmiInput.SyncDetectedFeedback.BoolValue)) + + }; + + AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn, + eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.None, 0, this, combinedFuncs); + + DmOutput = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmCat, null, this); + HdmiLoopOut = new RoutingOutputPort(DmPortName.HdmiLoopOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Hdmi, null, this); + + AddToFeedbackList(ActiveVideoInputFeedback, VideoSourceNumericFeedback, AudioSourceNumericFeedback, + AnyVideoInput.VideoStatus.HasVideoStatusFeedback, AnyVideoInput.VideoStatus.HdcpActiveFeedback, + AnyVideoInput.VideoStatus.HdcpStateFeedback, AnyVideoInput.VideoStatus.VideoResolutionFeedback, + AnyVideoInput.VideoStatus.VideoSyncFeedback, HdmiInHdcpCapabilityFeedback, HdmiVideoSyncFeedback, + VgaVideoSyncFeedback); + + // Set Ports for CEC + HdmiInput.Port = Tx.HdmiInput; + VgaInput.Port = Tx.VgaInput; + HdmiLoopOut.Port = Tx.HdmiOutput; + DmOutput.Port = Tx.DmOutput; + } + + void VideoControls_ControlChange(object sender, Crestron.SimplSharpPro.DeviceSupport.GenericEventArgs args) + { + var id = args.EventId; Debug.Console(2, this, "EventId {0}", args.EventId); switch (id) @@ -212,7 +212,7 @@ namespace PepperDash.Essentials.DM case VideoControlsEventIds.ContrastFeedbackEventId: VgaContrastFeedback.FireUpdate(); break; - } + } } void Tx_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) @@ -228,7 +228,7 @@ namespace PepperDash.Essentials.DM AudioSourceNumericFeedback.FireUpdate(); OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video)); OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localAudioInputPort, eRoutingSignalType.Audio)); - } + } private void VgaInputOnInputStreamChange(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) { @@ -241,107 +241,107 @@ namespace PepperDash.Essentials.DM VgaVideoSyncFeedback.FireUpdate(); break; } - } - - public override bool CustomActivate() - { - Tx.HdmiInput.InputStreamChange += (o, a) => FowardInputStreamChange(HdmiInput, a.EventId); - Tx.HdmiInput.VideoAttributes.AttributeChange += (o, a) => FireVideoAttributeChange(HdmiInput, a.EventId); - - Tx.VgaInput.InputStreamChange += (o, a) => FowardInputStreamChange(VgaInput, a.EventId); - Tx.VgaInput.VideoAttributes.AttributeChange += (o, a) => FireVideoAttributeChange(VgaInput, a.EventId); - - // Base does register and sets up comm monitoring. - return base.CustomActivate(); - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = GetDmTxJoinMap(joinStart, joinMapKey); - - if (HdmiVideoSyncFeedback != null) - { - HdmiVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input1VideoSyncStatus.JoinNumber]); - } - if (VgaVideoSyncFeedback != null) - { - VgaVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input2VideoSyncStatus.JoinNumber]); - } - - LinkDmTxToApi(this, trilist, joinMap, bridge); - } - - /// - /// Enables or disables free run - /// - /// - public void SetFreeRunEnabled(bool enable) + } + + public override bool CustomActivate() + { + Tx.HdmiInput.InputStreamChange += (o, a) => FowardInputStreamChange(HdmiInput, a.EventId); + Tx.HdmiInput.VideoAttributes.AttributeChange += (o, a) => FireVideoAttributeChange(HdmiInput, a.EventId); + + Tx.VgaInput.InputStreamChange += (o, a) => FowardInputStreamChange(VgaInput, a.EventId); + Tx.VgaInput.VideoAttributes.AttributeChange += (o, a) => FireVideoAttributeChange(VgaInput, a.EventId); + + // Base does register and sets up comm monitoring. + return base.CustomActivate(); + } + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) { - Tx.VgaInput.FreeRun = enable ? eDmFreeRunSetting.Enabled : eDmFreeRunSetting.Disabled; - } - - /// - /// Sets the VGA brightness level - /// - /// - public void SetVgaBrightness(ushort level) - { - Tx.VgaInput.VideoControls.Brightness.UShortValue = level; - } - - /// - /// Sets the VGA contrast level - /// - /// - public void SetVgaContrast(ushort level) - { - Tx.VgaInput.VideoControls.Contrast.UShortValue = level; - } - - /// - /// Switches the audio/video source based on the integer value (0-Auto, 1-HDMI, 2-VGA, 3-Disable) - /// - /// - /// - /// - public void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type) - { - Debug.Console(2, this, "Executing Numeric Switch to input {0}.", input); - - switch (input) - { - case 0: - { - ExecuteSwitch(DmTx200Base.eSourceSelection.Auto, null, type); - break; - } - case 1: - { - ExecuteSwitch(HdmiInput.Selector, null, type); - break; - } - case 2: - { - ExecuteSwitch(VgaInput.Selector, null, type); - break; - } - case 3: - { - ExecuteSwitch(DmTx200Base.eSourceSelection.Disable, null, type); - break; - } - } - } - - public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) - { - if((signalType | eRoutingSignalType.Video) == eRoutingSignalType.Video) - Tx.VideoSource = (DmTx200Base.eSourceSelection)inputSelector; - if ((signalType | eRoutingSignalType.Audio) == eRoutingSignalType.Audio) - Tx.AudioSource = (DmTx200Base.eSourceSelection)inputSelector; - } - - void Tx_BaseEvent(GenericBase device, BaseEventArgs args) + var joinMap = GetDmTxJoinMap(joinStart, joinMapKey); + + if (HdmiVideoSyncFeedback != null) + { + HdmiVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input1VideoSyncStatus.JoinNumber]); + } + if (VgaVideoSyncFeedback != null) + { + VgaVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input2VideoSyncStatus.JoinNumber]); + } + + LinkDmTxToApi(this, trilist, joinMap, bridge); + } + + /// + /// Enables or disables free run + /// + /// + public void SetFreeRunEnabled(bool enable) + { + Tx.VgaInput.FreeRun = enable ? eDmFreeRunSetting.Enabled : eDmFreeRunSetting.Disabled; + } + + /// + /// Sets the VGA brightness level + /// + /// + public void SetVgaBrightness(ushort level) + { + Tx.VgaInput.VideoControls.Brightness.UShortValue = level; + } + + /// + /// Sets the VGA contrast level + /// + /// + public void SetVgaContrast(ushort level) + { + Tx.VgaInput.VideoControls.Contrast.UShortValue = level; + } + + /// + /// Switches the audio/video source based on the integer value (0-Auto, 1-HDMI, 2-VGA, 3-Disable) + /// + /// + /// + /// + public void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type) + { + Debug.Console(2, this, "Executing Numeric Switch to input {0}.", input); + + switch (input) + { + case 0: + { + ExecuteSwitch(DmTx200Base.eSourceSelection.Auto, null, type); + break; + } + case 1: + { + ExecuteSwitch(HdmiInput.Selector, null, type); + break; + } + case 2: + { + ExecuteSwitch(VgaInput.Selector, null, type); + break; + } + case 3: + { + ExecuteSwitch(DmTx200Base.eSourceSelection.Disable, null, type); + break; + } + } + } + + public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) + { + if((signalType | eRoutingSignalType.Video) == eRoutingSignalType.Video) + Tx.VideoSource = (DmTx200Base.eSourceSelection)inputSelector; + if ((signalType | eRoutingSignalType.Audio) == eRoutingSignalType.Audio) + Tx.AudioSource = (DmTx200Base.eSourceSelection)inputSelector; + } + + void Tx_BaseEvent(GenericBase device, BaseEventArgs args) { var id = args.EventId; Debug.Console(2, this, "EventId {0}", args.EventId); @@ -361,11 +361,11 @@ namespace PepperDash.Essentials.DM AudioSourceNumericFeedback.FireUpdate(); OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localInputAudioPort, eRoutingSignalType.Audio)); break; - } - } - - void InputStreamChangeEvent(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) - { + } + } + + void InputStreamChangeEvent(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) + { Debug.Console(2, "{0} event {1} stream {2}", Tx.ToString(), inputStream.ToString(), args.EventId.ToString()); switch (args.EventId) @@ -379,52 +379,52 @@ namespace PepperDash.Essentials.DM case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: HdmiVideoSyncFeedback.FireUpdate(); break; - } - - } - - /// - /// Relays the input stream change to the appropriate RoutingInputPort. - /// - void FowardInputStreamChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) - { - if (eventId != EndpointInputStreamEventIds.SyncDetectedFeedbackEventId) + } + + } + + /// + /// Relays the input stream change to the appropriate RoutingInputPort. + /// + void FowardInputStreamChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) + { + if (eventId != EndpointInputStreamEventIds.SyncDetectedFeedbackEventId) { - return; + return; } inputPort.VideoStatus.VideoSyncFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoSyncFeedback.FireUpdate(); - } - - /// - /// Relays the VideoAttributes change to a RoutingInputPort - /// - void FireVideoAttributeChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) - { - //// LOCATION: Crestron.SimplSharpPro.DM.VideoAttributeEventIds - //Debug.Console(2, this, "VideoAttributes_AttributeChange event id={0} from {1}", - // args.EventId, (sender as VideoAttributesEnhanced).Owner.GetType()); - switch (eventId) - { - case VideoAttributeEventIds.HdcpActiveFeedbackEventId: - inputPort.VideoStatus.HdcpActiveFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.HdcpActiveFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.HdcpStateFeedbackEventId: - inputPort.VideoStatus.HdcpStateFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.HdcpStateFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.HorizontalResolutionFeedbackEventId: - case VideoAttributeEventIds.VerticalResolutionFeedbackEventId: - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.FramesPerSecondFeedbackEventId: - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); - break; - } - } - - } + AnyVideoInput.VideoStatus.VideoSyncFeedback.FireUpdate(); + } + + /// + /// Relays the VideoAttributes change to a RoutingInputPort + /// + void FireVideoAttributeChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) + { + //// LOCATION: Crestron.SimplSharpPro.DM.VideoAttributeEventIds + //Debug.Console(2, this, "VideoAttributes_AttributeChange event id={0} from {1}", + // args.EventId, (sender as VideoAttributesEnhanced).Owner.GetType()); + switch (eventId) + { + case VideoAttributeEventIds.HdcpActiveFeedbackEventId: + inputPort.VideoStatus.HdcpActiveFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.HdcpActiveFeedback.FireUpdate(); + break; + case VideoAttributeEventIds.HdcpStateFeedbackEventId: + inputPort.VideoStatus.HdcpStateFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.HdcpStateFeedback.FireUpdate(); + break; + case VideoAttributeEventIds.HorizontalResolutionFeedbackEventId: + case VideoAttributeEventIds.VerticalResolutionFeedbackEventId: + inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); + break; + case VideoAttributeEventIds.FramesPerSecondFeedbackEventId: + inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); + break; + } + } + + } } \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k302CController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k302CController.cs index 87906735..c03a2291 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k302CController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k302CController.cs @@ -1,49 +1,49 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -//using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Endpoints; -using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; - -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.DM.Config; - -namespace PepperDash.Essentials.DM -{ - using eVst = Crestron.SimplSharpPro.DeviceSupport.eX02VideoSourceType; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro; +//using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.DM; +using Crestron.SimplSharpPro.DM.Endpoints; +using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; + +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; +using PepperDash.Essentials.DM.Config; + +namespace PepperDash.Essentials.DM +{ + using eVst = Crestron.SimplSharpPro.DeviceSupport.eX02VideoSourceType; using eAst = Crestron.SimplSharpPro.DeviceSupport.eX02AudioSourceType; [Description("Wrapper class for DM-TX-4K-302-C")] - public class DmTx4k302CController : DmTxControllerBase, ITxRoutingWithFeedback, IHasFeedback, - IIROutputPorts, IComPorts, IHasFreeRun, IVgaBrightnessContrastControls - { - public DmTx4k302C Tx { get; private set; } - - public RoutingInputPortWithVideoStatuses HdmiIn1 { get; private set; } - public RoutingInputPortWithVideoStatuses HdmiIn2 { get; private set; } - public RoutingInputPortWithVideoStatuses VgaIn { get; private set; } - public RoutingOutputPort DmOut { get; private set; } - public RoutingOutputPort HdmiLoopOut { get; private set; } - - public override StringFeedback ActiveVideoInputFeedback { get; protected set; } - public IntFeedback VideoSourceNumericFeedback { get; protected set; } - public IntFeedback AudioSourceNumericFeedback { get; protected set; } - public IntFeedback HdmiIn1HdcpCapabilityFeedback { get; protected set; } - public IntFeedback HdmiIn2HdcpCapabilityFeedback { get; protected set; } - public BoolFeedback Hdmi1VideoSyncFeedback { get; protected set; } - public BoolFeedback Hdmi2VideoSyncFeedback { get; protected set; } - public BoolFeedback VgaVideoSyncFeedback { get; protected set; } - - public BoolFeedback FreeRunEnabledFeedback { get; protected set; } - - public IntFeedback VgaBrightnessFeedback { get; protected set; } + public class DmTx4k302CController : DmTxControllerBase, ITxRoutingWithFeedback, IHasFeedback, + IIROutputPorts, IComPorts, IHasFreeRun, IVgaBrightnessContrastControls + { + public DmTx4k302C Tx { get; private set; } + + public RoutingInputPortWithVideoStatuses HdmiIn1 { get; private set; } + public RoutingInputPortWithVideoStatuses HdmiIn2 { get; private set; } + public RoutingInputPortWithVideoStatuses VgaIn { get; private set; } + public RoutingOutputPort DmOut { get; private set; } + public RoutingOutputPort HdmiLoopOut { get; private set; } + + public override StringFeedback ActiveVideoInputFeedback { get; protected set; } + public IntFeedback VideoSourceNumericFeedback { get; protected set; } + public IntFeedback AudioSourceNumericFeedback { get; protected set; } + public IntFeedback HdmiIn1HdcpCapabilityFeedback { get; protected set; } + public IntFeedback HdmiIn2HdcpCapabilityFeedback { get; protected set; } + public BoolFeedback Hdmi1VideoSyncFeedback { get; protected set; } + public BoolFeedback Hdmi2VideoSyncFeedback { get; protected set; } + public BoolFeedback VgaVideoSyncFeedback { get; protected set; } + + public BoolFeedback FreeRunEnabledFeedback { get; protected set; } + + public IntFeedback VgaBrightnessFeedback { get; protected set; } public IntFeedback VgaContrastFeedback { get; protected set; } //IroutingNumericEvent @@ -57,92 +57,92 @@ namespace PepperDash.Essentials.DM { var newEvent = NumericSwitchChange; if (newEvent != null) newEvent(this, e); - } - - - /// - /// Helps get the "real" inputs, including when in Auto - /// - public Crestron.SimplSharpPro.DeviceSupport.eX02VideoSourceType ActualActiveVideoInput - { - get - { - if (Tx.VideoSourceFeedback != eVst.Auto) - return Tx.VideoSourceFeedback; - else // auto - { - if (Tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue) - return eVst.Hdmi1; - else if (Tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue) - return eVst.Hdmi2; - else if (Tx.VgaInput.SyncDetectedFeedback.BoolValue) - return eVst.Vga; - else - return eVst.AllDisabled; - } - } - } - public RoutingPortCollection InputPorts - { - get - { - return new RoutingPortCollection - { - HdmiIn1, - HdmiIn2, - VgaIn, - AnyVideoInput - }; - } - } - public RoutingPortCollection OutputPorts - { - get - { - return new RoutingPortCollection { DmOut, HdmiLoopOut }; - } + } + + + /// + /// Helps get the "real" inputs, including when in Auto + /// + public Crestron.SimplSharpPro.DeviceSupport.eX02VideoSourceType ActualActiveVideoInput + { + get + { + if (Tx.VideoSourceFeedback != eVst.Auto) + return Tx.VideoSourceFeedback; + else // auto + { + if (Tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue) + return eVst.Hdmi1; + else if (Tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue) + return eVst.Hdmi2; + else if (Tx.VgaInput.SyncDetectedFeedback.BoolValue) + return eVst.Vga; + else + return eVst.AllDisabled; + } + } } - public DmTx4k302CController(string key, string name, DmTx4k302C tx, bool preventRegistration) - : base(key, name, tx) - { + public RoutingPortCollection InputPorts + { + get + { + return new RoutingPortCollection + { + HdmiIn1, + HdmiIn2, + VgaIn, + AnyVideoInput + }; + } + } + public RoutingPortCollection OutputPorts + { + get + { + return new RoutingPortCollection { DmOut, HdmiLoopOut }; + } + } + public DmTx4k302CController(string key, string name, DmTx4k302C tx, bool preventRegistration) + : base(key, name, tx) + { Tx = tx; - PreventRegistration = preventRegistration; - - HdmiIn1 = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn1, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.Hdmi1, this, + PreventRegistration = preventRegistration; + + HdmiIn1 = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn1, + eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.Hdmi1, this, VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInputs[1])) { FeedbackMatchObject = eVst.Hdmi1 - }; - HdmiIn2 = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn2, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.Hdmi2, this, + }; + HdmiIn2 = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn2, + eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.Hdmi2, this, VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInputs[2])) { FeedbackMatchObject = eVst.Hdmi2 }; - - VgaIn = new RoutingInputPortWithVideoStatuses(DmPortName.VgaIn, - eRoutingSignalType.Video, eRoutingPortConnectionType.Vga, eVst.Vga, this, + + VgaIn = new RoutingInputPortWithVideoStatuses(DmPortName.VgaIn, + eRoutingSignalType.Video, eRoutingPortConnectionType.Vga, eVst.Vga, this, VideoStatusHelper.GetVgaInputStatusFuncs(tx.VgaInput)) { FeedbackMatchObject = eVst.Vga }; - - ActiveVideoInputFeedback = new StringFeedback("ActiveVideoInput", - () => ActualActiveVideoInput.ToString()); - - Tx.HdmiInputs[1].InputStreamChange += InputStreamChangeEvent; + + ActiveVideoInputFeedback = new StringFeedback("ActiveVideoInput", + () => ActualActiveVideoInput.ToString()); + + Tx.HdmiInputs[1].InputStreamChange += InputStreamChangeEvent; Tx.HdmiInputs[2].InputStreamChange += InputStreamChangeEvent; - Tx.VgaInput.InputStreamChange += VgaInputOnInputStreamChange; - Tx.BaseEvent += Tx_BaseEvent; - - Tx.OnlineStatusChange += Tx_OnlineStatusChange; - - VideoSourceNumericFeedback = new IntFeedback(() => (int)Tx.VideoSourceFeedback); - AudioSourceNumericFeedback = new IntFeedback(() => (int)Tx.AudioSourceFeedback); - - HdmiIn1HdcpCapabilityFeedback = new IntFeedback("HdmiIn1HdcpCapability", () => (int)tx.HdmiInputs[1].HdcpCapabilityFeedback); - + Tx.VgaInput.InputStreamChange += VgaInputOnInputStreamChange; + Tx.BaseEvent += Tx_BaseEvent; + + Tx.OnlineStatusChange += Tx_OnlineStatusChange; + + VideoSourceNumericFeedback = new IntFeedback(() => (int)Tx.VideoSourceFeedback); + AudioSourceNumericFeedback = new IntFeedback(() => (int)Tx.AudioSourceFeedback); + + HdmiIn1HdcpCapabilityFeedback = new IntFeedback("HdmiIn1HdcpCapability", () => (int)tx.HdmiInputs[1].HdcpCapabilityFeedback); + HdmiIn2HdcpCapabilityFeedback = new IntFeedback("HdmiIn2HdcpCapability", () => (int)tx.HdmiInputs[2].HdcpCapabilityFeedback); HdcpStateFeedback = @@ -150,77 +150,77 @@ namespace PepperDash.Essentials.DM () => tx.HdmiInputs[1].HdcpCapabilityFeedback > tx.HdmiInputs[2].HdcpCapabilityFeedback ? (int)tx.HdmiInputs[1].HdcpCapabilityFeedback - : (int)tx.HdmiInputs[2].HdcpCapabilityFeedback); - - HdcpSupportCapability = eHdcpCapabilityType.Hdcp2_2Support; - - Hdmi1VideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue); - - Hdmi2VideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue); - - VgaVideoSyncFeedback = new BoolFeedback(() => (bool)tx.VgaInput.SyncDetectedFeedback.BoolValue); - - FreeRunEnabledFeedback = new BoolFeedback(() => tx.VgaInput.FreeRunFeedback == eDmFreeRunSetting.Enabled); - - VgaBrightnessFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.BrightnessFeedback.UShortValue); - VgaContrastFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.ContrastFeedback.UShortValue); - - tx.VgaInput.VideoControls.ControlChange += new Crestron.SimplSharpPro.DeviceSupport.GenericEventHandler(VideoControls_ControlChange); - - - var combinedFuncs = new VideoStatusFuncsWrapper - { - HdcpActiveFeedbackFunc = () => - (ActualActiveVideoInput == eVst.Hdmi1 - && tx.HdmiInputs[1].VideoAttributes.HdcpActiveFeedback.BoolValue) - || (ActualActiveVideoInput == eVst.Hdmi2 - && tx.HdmiInputs[2].VideoAttributes.HdcpActiveFeedback.BoolValue), - - HdcpStateFeedbackFunc = () => - { - if (ActualActiveVideoInput == eVst.Hdmi1) - return tx.HdmiInputs[1].VideoAttributes.HdcpStateFeedback.ToString(); + : (int)tx.HdmiInputs[2].HdcpCapabilityFeedback); + + HdcpSupportCapability = eHdcpCapabilityType.Hdcp2_2Support; + + Hdmi1VideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue); + + Hdmi2VideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue); + + VgaVideoSyncFeedback = new BoolFeedback(() => (bool)tx.VgaInput.SyncDetectedFeedback.BoolValue); + + FreeRunEnabledFeedback = new BoolFeedback(() => tx.VgaInput.FreeRunFeedback == eDmFreeRunSetting.Enabled); + + VgaBrightnessFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.BrightnessFeedback.UShortValue); + VgaContrastFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.ContrastFeedback.UShortValue); + + tx.VgaInput.VideoControls.ControlChange += new Crestron.SimplSharpPro.DeviceSupport.GenericEventHandler(VideoControls_ControlChange); + + + var combinedFuncs = new VideoStatusFuncsWrapper + { + HdcpActiveFeedbackFunc = () => + (ActualActiveVideoInput == eVst.Hdmi1 + && tx.HdmiInputs[1].VideoAttributes.HdcpActiveFeedback.BoolValue) + || (ActualActiveVideoInput == eVst.Hdmi2 + && tx.HdmiInputs[2].VideoAttributes.HdcpActiveFeedback.BoolValue), + + HdcpStateFeedbackFunc = () => + { + if (ActualActiveVideoInput == eVst.Hdmi1) + return tx.HdmiInputs[1].VideoAttributes.HdcpStateFeedback.ToString(); return ActualActiveVideoInput == eVst.Hdmi2 ? tx.HdmiInputs[2].VideoAttributes.HdcpStateFeedback.ToString() : ""; - }, - - VideoResolutionFeedbackFunc = () => - { - if (ActualActiveVideoInput == eVst.Hdmi1) - return tx.HdmiInputs[1].VideoAttributes.GetVideoResolutionString(); - if (ActualActiveVideoInput == eVst.Hdmi2) - return tx.HdmiInputs[2].VideoAttributes.GetVideoResolutionString(); + }, + + VideoResolutionFeedbackFunc = () => + { + if (ActualActiveVideoInput == eVst.Hdmi1) + return tx.HdmiInputs[1].VideoAttributes.GetVideoResolutionString(); + if (ActualActiveVideoInput == eVst.Hdmi2) + return tx.HdmiInputs[2].VideoAttributes.GetVideoResolutionString(); return ActualActiveVideoInput == eVst.Vga ? tx.VgaInput.VideoAttributes.GetVideoResolutionString() : ""; - }, - VideoSyncFeedbackFunc = () => - (ActualActiveVideoInput == eVst.Hdmi1 - && tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue) - || (ActualActiveVideoInput == eVst.Hdmi2 - && tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue) - || (ActualActiveVideoInput == eVst.Vga - && tx.VgaInput.SyncDetectedFeedback.BoolValue) - - }; - - AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.None, 0, this, combinedFuncs); - - DmOut = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.DmCat, null, this); - HdmiLoopOut = new RoutingOutputPort(DmPortName.HdmiLoopOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, null, this); - - - AddToFeedbackList(ActiveVideoInputFeedback, VideoSourceNumericFeedback, AudioSourceNumericFeedback, - AnyVideoInput.VideoStatus.HasVideoStatusFeedback, AnyVideoInput.VideoStatus.HdcpActiveFeedback, - AnyVideoInput.VideoStatus.HdcpStateFeedback, AnyVideoInput.VideoStatus.VideoResolutionFeedback, - AnyVideoInput.VideoStatus.VideoSyncFeedback, HdmiIn1HdcpCapabilityFeedback, HdmiIn2HdcpCapabilityFeedback, - Hdmi1VideoSyncFeedback, Hdmi2VideoSyncFeedback, VgaVideoSyncFeedback); - - // Set Ports for CEC - HdmiIn1.Port = Tx.HdmiInputs[1]; - HdmiIn2.Port = Tx.HdmiInputs[2]; - HdmiLoopOut.Port = Tx.HdmiOutput; - DmOut.Port = Tx.DmOutput; + }, + VideoSyncFeedbackFunc = () => + (ActualActiveVideoInput == eVst.Hdmi1 + && tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue) + || (ActualActiveVideoInput == eVst.Hdmi2 + && tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue) + || (ActualActiveVideoInput == eVst.Vga + && tx.VgaInput.SyncDetectedFeedback.BoolValue) + + }; + + AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn, + eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.None, 0, this, combinedFuncs); + + DmOut = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.DmCat, null, this); + HdmiLoopOut = new RoutingOutputPort(DmPortName.HdmiLoopOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Hdmi, null, this); + + + AddToFeedbackList(ActiveVideoInputFeedback, VideoSourceNumericFeedback, AudioSourceNumericFeedback, + AnyVideoInput.VideoStatus.HasVideoStatusFeedback, AnyVideoInput.VideoStatus.HdcpActiveFeedback, + AnyVideoInput.VideoStatus.HdcpStateFeedback, AnyVideoInput.VideoStatus.VideoResolutionFeedback, + AnyVideoInput.VideoStatus.VideoSyncFeedback, HdmiIn1HdcpCapabilityFeedback, HdmiIn2HdcpCapabilityFeedback, + Hdmi1VideoSyncFeedback, Hdmi2VideoSyncFeedback, VgaVideoSyncFeedback); + + // Set Ports for CEC + HdmiIn1.Port = Tx.HdmiInputs[1]; + HdmiIn2.Port = Tx.HdmiInputs[2]; + HdmiLoopOut.Port = Tx.HdmiOutput; + DmOut.Port = Tx.DmOutput; } void VgaInputOnInputStreamChange(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) @@ -234,13 +234,13 @@ namespace PepperDash.Essentials.DM VgaVideoSyncFeedback.FireUpdate(); break; } - } - - void VideoControls_ControlChange(object sender, Crestron.SimplSharpPro.DeviceSupport.GenericEventArgs args) - { - var id = args.EventId; - Debug.Console(2, this, "EventId {0}", args.EventId); - + } + + void VideoControls_ControlChange(object sender, Crestron.SimplSharpPro.DeviceSupport.GenericEventArgs args) + { + var id = args.EventId; + Debug.Console(2, this, "EventId {0}", args.EventId); + switch (id) { case VideoControlsEventIds.BrightnessFeedbackEventId: @@ -249,76 +249,76 @@ namespace PepperDash.Essentials.DM case VideoControlsEventIds.ContrastFeedbackEventId: VgaContrastFeedback.FireUpdate(); break; - } - } - - - - public override bool CustomActivate() - { - // Link up all of these damned events to the various RoutingPorts via a helper handler - Tx.HdmiInputs[1].InputStreamChange += (o, a) => FowardInputStreamChange(HdmiIn1, a.EventId); - Tx.HdmiInputs[1].VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn1, a.EventId); - - Tx.HdmiInputs[2].InputStreamChange += (o, a) => FowardInputStreamChange(HdmiIn2, a.EventId); - Tx.HdmiInputs[2].VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn2, a.EventId); - - Tx.VgaInput.InputStreamChange += (o, a) => FowardInputStreamChange(VgaIn, a.EventId); - Tx.VgaInput.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(VgaIn, a.EventId); - - // Base does register and sets up comm monitoring. - return base.CustomActivate(); - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = GetDmTxJoinMap(joinStart, joinMapKey); - - if (Hdmi1VideoSyncFeedback != null) + } + } + + + + public override bool CustomActivate() + { + // Link up all of these damned events to the various RoutingPorts via a helper handler + Tx.HdmiInputs[1].InputStreamChange += (o, a) => FowardInputStreamChange(HdmiIn1, a.EventId); + Tx.HdmiInputs[1].VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn1, a.EventId); + + Tx.HdmiInputs[2].InputStreamChange += (o, a) => FowardInputStreamChange(HdmiIn2, a.EventId); + Tx.HdmiInputs[2].VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn2, a.EventId); + + Tx.VgaInput.InputStreamChange += (o, a) => FowardInputStreamChange(VgaIn, a.EventId); + Tx.VgaInput.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(VgaIn, a.EventId); + + // Base does register and sets up comm monitoring. + return base.CustomActivate(); + } + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + var joinMap = GetDmTxJoinMap(joinStart, joinMapKey); + + if (Hdmi1VideoSyncFeedback != null) { - Hdmi1VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input1VideoSyncStatus.JoinNumber]); - } - if (Hdmi2VideoSyncFeedback != null) + Hdmi1VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input1VideoSyncStatus.JoinNumber]); + } + if (Hdmi2VideoSyncFeedback != null) { - Hdmi2VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input2VideoSyncStatus.JoinNumber]); - } - if (VgaVideoSyncFeedback != null) + Hdmi2VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input2VideoSyncStatus.JoinNumber]); + } + if (VgaVideoSyncFeedback != null) { - VgaVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input3VideoSyncStatus.JoinNumber]); - } - - LinkDmTxToApi(this, trilist, joinMap, bridge); - } - - /// - /// Enables or disables free run - /// - /// + VgaVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input3VideoSyncStatus.JoinNumber]); + } + + LinkDmTxToApi(this, trilist, joinMap, bridge); + } + + /// + /// Enables or disables free run + /// + /// public void SetFreeRunEnabled(bool enable) { Tx.VgaInput.FreeRun = enable ? eDmFreeRunSetting.Enabled : eDmFreeRunSetting.Disabled; } - /// - /// Sets the VGA brightness level - /// - /// - public void SetVgaBrightness(ushort level) - { - Tx.VgaInput.VideoControls.Brightness.UShortValue = level; - } - - /// - /// Sets the VGA contrast level - /// - /// - public void SetVgaContrast(ushort level) - { - Tx.VgaInput.VideoControls.Contrast.UShortValue = level; - } - - - + /// + /// Sets the VGA brightness level + /// + /// + public void SetVgaBrightness(ushort level) + { + Tx.VgaInput.VideoControls.Brightness.UShortValue = level; + } + + /// + /// Sets the VGA contrast level + /// + /// + public void SetVgaContrast(ushort level) + { + Tx.VgaInput.VideoControls.Contrast.UShortValue = level; + } + + + public void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type) { Debug.Console(2, this, "Executing Numeric Switch to input {0}.", input); @@ -326,76 +326,76 @@ namespace PepperDash.Essentials.DM switch (type) { case eRoutingSignalType.Video: - switch (input) - { - case 0: - { - ExecuteSwitch(eVst.Auto, null, type); - break; - } - case 1: - { - ExecuteSwitch(HdmiIn1.Selector, null, type); - break; - } - case 2: - { - ExecuteSwitch(HdmiIn2.Selector, null, type); - break; - } - case 3: - { - ExecuteSwitch(VgaIn.Selector, null, type); - break; - } - case 4: - { - ExecuteSwitch(eVst.AllDisabled, null, type); - break; - } + switch (input) + { + case 0: + { + ExecuteSwitch(eVst.Auto, null, type); + break; + } + case 1: + { + ExecuteSwitch(HdmiIn1.Selector, null, type); + break; + } + case 2: + { + ExecuteSwitch(HdmiIn2.Selector, null, type); + break; + } + case 3: + { + ExecuteSwitch(VgaIn.Selector, null, type); + break; + } + case 4: + { + ExecuteSwitch(eVst.AllDisabled, null, type); + break; + } } break; case eRoutingSignalType.Audio: - switch (input) - { - case 0: - { - ExecuteSwitch(eAst.Auto, null, type); - break; - } - case 1: - { - ExecuteSwitch(eAst.Hdmi1, null, type); - break; - } - case 2: - { - ExecuteSwitch(eAst.Hdmi2, null, type); - break; - } - case 3: - { - ExecuteSwitch(eAst.AudioIn, null, type); - break; - } - case 4: - { - ExecuteSwitch(eAst.AllDisabled, null, type); - break; - } + switch (input) + { + case 0: + { + ExecuteSwitch(eAst.Auto, null, type); + break; + } + case 1: + { + ExecuteSwitch(eAst.Hdmi1, null, type); + break; + } + case 2: + { + ExecuteSwitch(eAst.Hdmi2, null, type); + break; + } + case 3: + { + ExecuteSwitch(eAst.AudioIn, null, type); + break; + } + case 4: + { + ExecuteSwitch(eAst.AllDisabled, null, type); + break; + } } break; } } - public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) - { - if ((signalType | eRoutingSignalType.Video) == eRoutingSignalType.Video) - Tx.VideoSource = (eVst)inputSelector; - if ((signalType | eRoutingSignalType.Audio) == eRoutingSignalType.Audio) - Tx.AudioSource = (eAst)inputSelector; - } - + public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) + { + if ((signalType | eRoutingSignalType.Video) == eRoutingSignalType.Video) + Tx.VideoSource = (eVst)inputSelector; + if ((signalType | eRoutingSignalType.Audio) == eRoutingSignalType.Audio) + Tx.AudioSource = (eAst)inputSelector; + } + void InputStreamChangeEvent(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) { Debug.Console(2, "{0} event {1} stream {2}", this.Tx.ToString(), inputStream.ToString(), args.EventId.ToString()); @@ -405,7 +405,7 @@ namespace PepperDash.Essentials.DM case EndpointInputStreamEventIds.HdcpSupportOffFeedbackEventId: case EndpointInputStreamEventIds.HdcpSupportOnFeedbackEventId: case EndpointInputStreamEventIds.HdcpCapabilityFeedbackEventId: - if (inputStream == Tx.HdmiInputs[1]) HdmiIn1HdcpCapabilityFeedback.FireUpdate(); + if (inputStream == Tx.HdmiInputs[1]) HdmiIn1HdcpCapabilityFeedback.FireUpdate(); if (inputStream == Tx.HdmiInputs[2]) HdmiIn2HdcpCapabilityFeedback.FireUpdate(); HdcpStateFeedback.FireUpdate(); break; @@ -450,57 +450,57 @@ namespace PepperDash.Essentials.DM OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localInputAudioPort, eRoutingSignalType.Audio)); break; } - } + } - /// - /// Relays the input stream change to the appropriate RoutingInputPort. - /// - void FowardInputStreamChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) + /// + /// Relays the input stream change to the appropriate RoutingInputPort. + /// + void FowardInputStreamChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) { if (eventId != EndpointInputStreamEventIds.SyncDetectedFeedbackEventId) return; - inputPort.VideoStatus.VideoSyncFeedback.FireUpdate(); + inputPort.VideoStatus.VideoSyncFeedback.FireUpdate(); AnyVideoInput.VideoStatus.VideoSyncFeedback.FireUpdate(); - } - - /// - /// Relays the VideoAttributes change to a RoutingInputPort - /// - void ForwardVideoAttributeChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) - { - //// LOCATION: Crestron.SimplSharpPro.DM.VideoAttributeEventIds - //Debug.Console(2, this, "VideoAttributes_AttributeChange event id={0} from {1}", - // args.EventId, (sender as VideoAttributesEnhanced).Owner.GetType()); - switch (eventId) - { - case VideoAttributeEventIds.HdcpActiveFeedbackEventId: - inputPort.VideoStatus.HdcpActiveFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.HdcpActiveFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.HdcpStateFeedbackEventId: - inputPort.VideoStatus.HdcpStateFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.HdcpStateFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.HorizontalResolutionFeedbackEventId: - case VideoAttributeEventIds.VerticalResolutionFeedbackEventId: - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.FramesPerSecondFeedbackEventId: - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); - break; - } - } - - - #region IIROutputPorts Members - public CrestronCollection IROutputPorts { get { return Tx.IROutputPorts; } } - public int NumberOfIROutputPorts { get { return Tx.NumberOfIROutputPorts; } } - #endregion - - #region IComPorts Members - public CrestronCollection ComPorts { get { return Tx.ComPorts; } } - public int NumberOfComPorts { get { return Tx.NumberOfComPorts; } } - #endregion - } + } + + /// + /// Relays the VideoAttributes change to a RoutingInputPort + /// + void ForwardVideoAttributeChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) + { + //// LOCATION: Crestron.SimplSharpPro.DM.VideoAttributeEventIds + //Debug.Console(2, this, "VideoAttributes_AttributeChange event id={0} from {1}", + // args.EventId, (sender as VideoAttributesEnhanced).Owner.GetType()); + switch (eventId) + { + case VideoAttributeEventIds.HdcpActiveFeedbackEventId: + inputPort.VideoStatus.HdcpActiveFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.HdcpActiveFeedback.FireUpdate(); + break; + case VideoAttributeEventIds.HdcpStateFeedbackEventId: + inputPort.VideoStatus.HdcpStateFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.HdcpStateFeedback.FireUpdate(); + break; + case VideoAttributeEventIds.HorizontalResolutionFeedbackEventId: + case VideoAttributeEventIds.VerticalResolutionFeedbackEventId: + inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); + break; + case VideoAttributeEventIds.FramesPerSecondFeedbackEventId: + inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); + break; + } + } + + + #region IIROutputPorts Members + public CrestronCollection IROutputPorts { get { return Tx.IROutputPorts; } } + public int NumberOfIROutputPorts { get { return Tx.NumberOfIROutputPorts; } } + #endregion + + #region IComPorts Members + public CrestronCollection ComPorts { get { return Tx.ComPorts; } } + public int NumberOfComPorts { get { return Tx.NumberOfComPorts; } } + #endregion + } } \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4kz302CController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4kz302CController.cs index de60d80e..63343522 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4kz302CController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4kz302CController.cs @@ -18,7 +18,7 @@ namespace PepperDash.Essentials.DM [Description("Wrapper class for DM-TX-4K-Z-302-C")] - public class DmTx4kz302CController : DmTxControllerBase, ITxRoutingWithFeedback, IHasFeedback, + public class DmTx4kz302CController : DmTxControllerBase, ITxRoutingWithFeedback, IIROutputPorts, IComPorts { public DmTx4kz302C Tx { get; private set; } @@ -34,6 +34,7 @@ namespace PepperDash.Essentials.DM public IntFeedback AudioSourceNumericFeedback { get; protected set; } public IntFeedback HdmiIn1HdcpCapabilityFeedback { get; protected set; } public IntFeedback HdmiIn2HdcpCapabilityFeedback { get; protected set; } + public IntFeedback DisplayPortInHdcpCapabilityFeedback { get; protected set; } public BoolFeedback Hdmi1VideoSyncFeedback { get; protected set; } public BoolFeedback Hdmi2VideoSyncFeedback { get; protected set; } public BoolFeedback DisplayPortVideoSyncFeedback { get; protected set; } @@ -131,12 +132,23 @@ namespace PepperDash.Essentials.DM HdmiIn2HdcpCapabilityFeedback = new IntFeedback("HdmiIn2HdcpCapability", () => (int)tx.HdmiInputs[2].HdcpCapabilityFeedback); + DisplayPortInHdcpCapabilityFeedback = new IntFeedback("DisplayPortHdcpCapability", + () => (int) tx.DisplayPortInput.HdcpCapabilityFeedback); + + + /* HdcpStateFeedback = new IntFeedback( () => tx.HdmiInputs[1].HdcpCapabilityFeedback > tx.HdmiInputs[2].HdcpCapabilityFeedback ? (int)tx.HdmiInputs[1].HdcpCapabilityFeedback : (int)tx.HdmiInputs[2].HdcpCapabilityFeedback); + */ + + //yeah this is gross - but it's the quickest way to do this... + HdcpStateFeedback = new IntFeedback(() => Math.Max((int) tx.DisplayPortInput.HdcpCapabilityFeedback, + Math.Max((int) tx.HdmiInputs[1].HdcpCapabilityFeedback, + (int) tx.HdmiInputs[2].HdcpCapabilityFeedback))); HdcpSupportCapability = eHdcpCapabilityType.Hdcp2_2Support; diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTxHelpers.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTxHelpers.cs index 86160ced..771864d6 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTxHelpers.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTxHelpers.cs @@ -394,6 +394,26 @@ namespace PepperDash.Essentials.DM } } + if (txR.InputPorts[DmPortName.DisplayPortIn] != null) + { + var inputPort = txR.InputPorts[DmPortName.DisplayPortIn]; + + if (tx.Feedbacks["DisplayPortInHdcpCapability"] != null) + { + var intFeedback = tx.Feedbacks["DisplayPortInHdcpCapability"] as IntFeedback; + if (intFeedback != null) + intFeedback.LinkInputSig(trilist.UShortInput[joinMap.Port3HdcpState.JoinNumber]); + } + + if (inputPort.ConnectionType == eRoutingPortConnectionType.Hdmi && inputPort.Port != null) + { + var port = inputPort.Port as EndpointDisplayPortInput; + + SetHdcpCapabilityAction(hdcpTypeSimple, port, joinMap.Port3HdcpState.JoinNumber, trilist); + } + + } + } var txFreeRun = tx as IHasFreeRun; @@ -441,6 +461,20 @@ namespace PepperDash.Essentials.DM }); } } + + private void SetHdcpCapabilityAction(bool hdcpTypeSimple, EndpointDisplayPortInput port, uint join, + BasicTriList trilist) + { + + + trilist.SetUShortSigAction(join, + s => + { + port.HdcpCapability = (eHdcpCapabilityType) s; + }); + + } + } public class DmTxControllerFactory : EssentialsDeviceFactory From e623c482a93ed7e9230778316eb210cf14a820a4 Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Wed, 22 Mar 2023 11:37:28 -0600 Subject: [PATCH 22/96] refactor: modify feedback for HDCP capability --- .../Endpoints/Transmitters/DmTx4kz302CController.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4kz302CController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4kz302CController.cs index 63343522..4d77a7fc 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4kz302CController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4kz302CController.cs @@ -146,9 +146,11 @@ namespace PepperDash.Essentials.DM */ //yeah this is gross - but it's the quickest way to do this... - HdcpStateFeedback = new IntFeedback(() => Math.Max((int) tx.DisplayPortInput.HdcpCapabilityFeedback, - Math.Max((int) tx.HdmiInputs[1].HdcpCapabilityFeedback, - (int) tx.HdmiInputs[2].HdcpCapabilityFeedback))); + HdcpStateFeedback = new IntFeedback(() => { + var states = new[] {(int) tx.DisplayPortInput.HdcpCapabilityFeedback, (int) tx.HdmiInputs[1].HdcpCapabilityFeedback, (int) tx.HdmiInputs[2].HdcpCapabilityFeedback}; + + return states.Max(); + }); HdcpSupportCapability = eHdcpCapabilityType.Hdcp2_2Support; @@ -158,7 +160,6 @@ namespace PepperDash.Essentials.DM DisplayPortVideoSyncFeedback = new BoolFeedback(() => (bool)tx.DisplayPortInput.SyncDetectedFeedback.BoolValue); - var combinedFuncs = new VideoStatusFuncsWrapper { HdcpActiveFeedbackFunc = () => @@ -423,8 +424,7 @@ namespace PepperDash.Essentials.DM AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); break; } - } - + } #region IIROutputPorts Members public CrestronCollection IROutputPorts { get { return Tx.IROutputPorts; } } From b2646f50cbd726b320595857e44489d3370d8b3e Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Mon, 27 Mar 2023 13:57:25 -0600 Subject: [PATCH 23/96] feat: add DGE Join map --- .../Endpoints/DGEs/DgeJoinMap.cs | 50 +++++++++++++++++++ .../PepperDash_Essentials_DM.csproj | 1 + 2 files changed, 51 insertions(+) create mode 100644 essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/DgeJoinMap.cs diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/DgeJoinMap.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/DgeJoinMap.cs new file mode 100644 index 00000000..f53e9383 --- /dev/null +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/DgeJoinMap.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using PepperDash.Essentials.Core; + +namespace PepperDash.Essentials.DM.Endpoints.DGEs +{ + public class DgeJoinMap : JoinMapBaseAdvanced + { + [JoinName("IsOnline")] + public JoinDataComplete IsOnline = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "DGE Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("CurrentInputResolution")] + public JoinDataComplete CurrentInputResolution = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, + new JoinMetadata { Description = "DGE Current Input Resolution", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); + + [JoinName("SyncDetected")] + public JoinDataComplete SyncDetected = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, + new JoinMetadata { Description = "DGE Sync Detected", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("HdmiHdcpOn")] + public JoinDataComplete HdmiInHdcpOn = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, + new JoinMetadata { Description = "DGE HDMI HDCP State On", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("HdmiHdcpOff")] + public JoinDataComplete HdmiInHdcpOff = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, + new JoinMetadata { Description = "DGE HDMI HDCP State Off", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("HdmiHdcpToggle")] + public JoinDataComplete HdmiInHdcpToggle = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, + new JoinMetadata { Description = "DGE HDMI HDCP State Toggle", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + + public DgeJoinMap(uint joinStart) + : this(joinStart, typeof(DgeJoinMap)) + { + } + + /// + /// Constructor to use when extending this Join map + /// + /// Join this join map will start at + /// Type of the child join map + protected DgeJoinMap(uint joinStart, Type type) : base(joinStart, type) + { + } + } +} \ 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 41b07237..0135334e 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj +++ b/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj @@ -105,6 +105,7 @@ + From bc64ee37cb82750373b805706bec550830cb1303 Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Mon, 27 Mar 2023 13:58:46 -0600 Subject: [PATCH 24/96] feat: Add bridging & HDCP support for DGE --- .../Endpoints/DGEs/Dge100Controller.cs | 78 +++++++++++++++++-- 1 file changed, 73 insertions(+), 5 deletions(-) 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 } From a9fe8bbb10118efb7cd03fc6e402e8eb82b242bb Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Mon, 27 Mar 2023 13:59:13 -0600 Subject: [PATCH 25/96] refactor: move DGE200 factory out of DGE200 class --- .../Endpoints/DGEs/DmDge200CController.cs | 64 +++++++++---------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/DmDge200CController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/DmDge200CController.cs index 31da45b2..d5df7dc6 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/DmDge200CController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/DmDge200CController.cs @@ -58,37 +58,37 @@ namespace PepperDash.Essentials.DM.Endpoints.DGEs HdmiOut.Port = _dge.HdmiOut; ; } - - public class DmDge200CControllerFactory : EssentialsDeviceFactory - { - public DmDge200CControllerFactory() - { - TypeNames = new List() { "dmdge200c" }; - } - - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - var typeName = dc.Type.ToLower(); - var comm = CommFactory.GetControlPropertiesConfig(dc); - var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); - - Debug.Console(1, "Factory Attempting to create new DgeController Device"); - - DmDge200C dgeDevice = null; - - if (typeName == "dmdge200c") - dgeDevice = new DmDge200C(comm.IpIdInt, Global.ControlSystem); - - if (dgeDevice == null) - { - Debug.Console(1, "Unable to create DGE device"); - return null; - } - - var dgeController = new DmDge200CController(dc.Key , dc.Name, dgeDevice, dc, props); - - return dgeController; - } - } } + + public class DmDge200CControllerFactory : EssentialsDeviceFactory + { + public DmDge200CControllerFactory() + { + TypeNames = new List() { "dmdge200c" }; + } + + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + var typeName = dc.Type.ToLower(); + var comm = CommFactory.GetControlPropertiesConfig(dc); + var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); + + Debug.Console(1, "Factory Attempting to create new DgeController Device"); + + DmDge200C dgeDevice = null; + + if (typeName == "dmdge200c") + dgeDevice = new DmDge200C(comm.IpIdInt, Global.ControlSystem); + + if (dgeDevice == null) + { + Debug.Console(1, "Unable to create DGE device"); + return null; + } + + var dgeController = new DmDge200CController(dc.Key, dc.Name, dgeDevice, dc, props); + + return dgeController; + } + } } \ No newline at end of file From ba511067d3781debdee54d5359c58ef863a7955e Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Mon, 27 Mar 2023 14:13:15 -0600 Subject: [PATCH 26/96] fix: add missing feedback links --- .../Essentials_DM/Endpoints/DGEs/Dge100Controller.cs | 5 +++++ 1 file changed, 5 insertions(+) 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 1130f654..6b0cdf28 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/Dge100Controller.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/DGEs/Dge100Controller.cs @@ -245,6 +245,11 @@ namespace PepperDash.Essentials.DM.Endpoints.DGEs VideoStatusFeedbacks.HdcpActiveFeedback.LinkInputSig(trilist.BooleanInput[joinMap.HdmiInHdcpOn.JoinNumber]); VideoStatusFeedbacks.HdcpActiveFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.HdmiInHdcpOff.JoinNumber]); + VideoStatusFeedbacks.VideoResolutionFeedback.LinkInputSig(trilist.StringInput[joinMap.CurrentInputResolution.JoinNumber]); + VideoStatusFeedbacks.VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.SyncDetected.JoinNumber]); + + IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); + trilist.OnlineStatusChange += (o, a) => { if (!a.DeviceOnLine) return; From 51bd95937aa02cecc7737c3e3f0d9cea7108348f Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Fri, 7 Apr 2023 11:20:08 -0600 Subject: [PATCH 27/96] build: update PD Core version SSH issues were found in PD Core 1.2.0 that were causing issues with manual disconnection/reconnection instead of using the autoreconnect timer. The fix for this issue was added in PD COre 1.2.1 --- packages.config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages.config b/packages.config index 104d002d..35ed241d 100644 --- a/packages.config +++ b/packages.config @@ -1,3 +1,3 @@ - - \ No newline at end of file + + From 55ad92e2f6179f09ced92f6bef63a73733f88bbc Mon Sep 17 00:00:00 2001 From: Trevor Payne Date: Fri, 14 Apr 2023 11:41:32 -0500 Subject: [PATCH 28/96] feature: enhance 4K DM Endpoint HDCP functionality feature: add bridge join to report number of HDCP inputs feature: Resolve #1088 feature: Resolve #1089 --- .../JoinMaps/DmRmcControllerJoinMap.cs | 25 +- .../Bridges/JoinMaps/DmTxControllerJoinMap.cs | 8 +- .../Endpoints/EndpointInterfaces.cs | 91 +++ .../Receivers/DmRmc4KScalerCController.cs | 412 +++++++------- .../Receivers/DmRmc4kScalerCDspController.cs | 36 +- .../Receivers/DmRmc4kZScalerCController.cs | 70 ++- .../Endpoints/Receivers/DmRmcHelper.cs | 277 ++++++---- .../Transmitters/DmTx4k202CController.cs | 519 +++++++++--------- .../Transmitters/DmTx4k302CController.cs | 397 +++++++------- .../Transmitters/DmTx4kz302CController.cs | 71 +-- .../Endpoints/Transmitters/DmTxHelpers.cs | 166 +++--- .../PepperDash_Essentials_DM.csproj | 1 + 12 files changed, 1187 insertions(+), 886 deletions(-) create mode 100644 essentials-framework/Essentials DM/Essentials_DM/Endpoints/EndpointInterfaces.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmRmcControllerJoinMap.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmRmcControllerJoinMap.cs index ec4661a4..cff5bffe 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmRmcControllerJoinMap.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmRmcControllerJoinMap.cs @@ -36,6 +36,28 @@ namespace PepperDash.Essentials.Core.Bridges public JoinDataComplete AudioVideoSource = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, new JoinMetadata { Description = "DM RMC Audio Video Source Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + [JoinName("HdcpSupportCapability")] + public JoinDataComplete HdcpSupportCapability = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, + new JoinMetadata { Description = "DM RMC HDCP Support Capability", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("Port1HdcpState")] + public JoinDataComplete Port1HdcpState = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, + new JoinMetadata { Description = "DM RMC Port 1 (DM) HDCP State Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("Port2HdcpState")] + public JoinDataComplete Port2HdcpState = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, + new JoinMetadata { Description = "DM TX Port 2 (HDMI) HDCP State Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + + [JoinName("HdmiInputSync")] + public JoinDataComplete HdmiInputSync = new JoinDataComplete(new JoinData { JoinNumber = 2, JoinSpan = 1 }, + new JoinMetadata { Description = "DM RMC HDMI Input Sync", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("HdcpInputPortCount")] + public JoinDataComplete HdcpInputPortCount = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, + new JoinMetadata { Description = "Number of Input Ports that support HDCP", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); + + + /// /// Constructor to use when instantiating this Join Map without inheriting from it /// @@ -50,7 +72,8 @@ namespace PepperDash.Essentials.Core.Bridges /// /// Join this join map will start at /// Type of the child join map - protected DmRmcControllerJoinMap(uint joinStart, Type type) : base(joinStart, type) + protected DmRmcControllerJoinMap(uint joinStart, Type type) + : base(joinStart, type) { } } diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmTxControllerJoinMap.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmTxControllerJoinMap.cs index 11e20375..d75d0dad 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmTxControllerJoinMap.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmTxControllerJoinMap.cs @@ -68,6 +68,11 @@ namespace PepperDash.Essentials.Core.Bridges public JoinDataComplete Port3HdcpState = new JoinDataComplete(new JoinData { JoinNumber = 8, JoinSpan = 1 }, new JoinMetadata { Description = "DM TX Port 3 HDCP State Set / Get", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog }); + [JoinName("HdcpInputPortCount")] + public JoinDataComplete HdcpInputPortCount = new JoinDataComplete(new JoinData { JoinNumber = 9, JoinSpan = 1 }, + new JoinMetadata { Description = "Number of Input Ports that support HDCP", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Analog }); + + /// /// Constructor to use when instantiating this Join Map without inheriting from it @@ -83,7 +88,8 @@ namespace PepperDash.Essentials.Core.Bridges /// /// Join this join map will start at /// Type of the child join map - protected DmTxControllerJoinMap(uint joinStart, Type type) : base(joinStart, type) + protected DmTxControllerJoinMap(uint joinStart, Type type) + : base(joinStart, type) { } } diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/EndpointInterfaces.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/EndpointInterfaces.cs new file mode 100644 index 00000000..085d379b --- /dev/null +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/EndpointInterfaces.cs @@ -0,0 +1,91 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro.DM; +using Crestron.SimplSharpPro.DM.Endpoints; +using PepperDash.Essentials.Core; + +namespace PepperDash_Essentials_DM +{ + public interface IHasDmInHdcpSet + { + void SetDmInHdcpState(eHdcpCapabilityType hdcpState); + } + + public interface IHasDmInHdcpGet + { + IntFeedback DmInHdcpStateFeedback { get; } + } + + public interface IHasDmInHdcp : IHasDmInHdcpGet, IHasDmInHdcpSet + { + eHdcpCapabilityType DmInHdcpCapability { get; } + } + + + public interface IHasHdmiInHdcpSet + { + void SetHdmiInHdcpState(eHdcpCapabilityType hdcpState); + } + + public interface IHasHdmiInHdcpGet + { + IntFeedback HdmiInHdcpStateFeedback { get; } + } + + public interface IHasHdmiInHdcp : IHasHdmiInHdcpGet, IHasHdmiInHdcpSet + { + eHdcpCapabilityType HdmiInHdcpCapability { get; } + } + + + public interface IHasHdmiIn1HdcpSet + { + void SetHdmiIn1HdcpState(eHdcpCapabilityType hdcpState); + } + + public interface IHasHdmiIn1HdcpGet + { + IntFeedback HdmiIn1HdcpStateFeedback { get; } + } + + public interface IHasHdmiIn1Hdcp : IHasHdmiIn1HdcpGet, IHasHdmiIn1HdcpSet + { + eHdcpCapabilityType HdmiIn1HdcpCapability { get; } + } + + + public interface IHasHdmiIn2HdcpSet + { + void SetHdmiIn2HdcpState(eHdcpCapabilityType hdcpState); + } + + public interface IHasHdmiIn2HdcpGet + { + IntFeedback HdmiInIn2HdcpStateFeedback { get; } + } + + public interface IHasHdmi2InHdcp : IHasHdmiIn2HdcpGet, IHasHdmiIn2HdcpSet + { + eHdcpCapabilityType Hdmi2InHdcpCapability { get; } + } + + + + public interface IHasDisplayPortInHdcpGet + { + IntFeedback DisplayPortInHdcpStateFeedback { get; } + } + + public interface IHasDisplayPortInHdcpSet + { + void SetDisplayPortInHdcpState(eHdcpCapabilityType hdcpState); + } + + public interface IHasDisplayPortInHdcp : IHasDisplayPortInHdcpGet, IHasDisplayPortInHdcpSet + { + eHdcpCapabilityType DisplayPortInHdcpCapability { get; } + } +} \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4KScalerCController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4KScalerCController.cs index 052f0726..79069430 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4KScalerCController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4KScalerCController.cs @@ -1,196 +1,220 @@ -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Endpoints; -using Crestron.SimplSharpPro.DM.Endpoints.Receivers; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; - -namespace PepperDash.Essentials.DM -{ - /// - /// Builds a controller for basic DM-RMCs with Com and IR ports and no control functions - /// - /// +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.DM; +using Crestron.SimplSharpPro.DM.Endpoints; +using Crestron.SimplSharpPro.DM.Endpoints.Receivers; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; +using PepperDash_Essentials_DM; + +namespace PepperDash.Essentials.DM +{ + /// + /// Builds a controller for basic DM-RMCs with Com and IR ports and no control functions + /// + /// [Description("Wrapper Class for DM-RMC-4K-SCALER-C")] - public class DmRmc4kScalerCController : DmRmcControllerBase, IRoutingInputsOutputs, IBasicVolumeWithFeedback, - IIROutputPorts, IComPorts, ICec, IRelayPorts - { - private readonly DmRmc4kScalerC _rmc; - - public RoutingInputPort DmIn { get; private set; } - public RoutingOutputPort HdmiOut { get; private set; } - public RoutingOutputPort BalancedAudioOut { get; private set; } - - public RoutingPortCollection InputPorts { get; private set; } - - public RoutingPortCollection OutputPorts { get; private set; } - - /// - /// Make a Crestron RMC and put it in here - /// - public DmRmc4kScalerCController(string key, string name, DmRmc4kScalerC rmc) - : base(key, name, rmc) - { - _rmc = rmc; - - DmIn = new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.DmCat, 0, this); - HdmiOut = new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.Hdmi, null, this); - BalancedAudioOut = new RoutingOutputPort(DmPortName.BalancedAudioOut, eRoutingSignalType.Audio, - eRoutingPortConnectionType.LineAudio, null, this); - - MuteFeedback = new BoolFeedback(() => false); - - VolumeLevelFeedback = new IntFeedback("MainVolumeLevelFeedback", () => - rmc.AudioOutput.VolumeFeedback.UShortValue); - - EdidManufacturerFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.Manufacturer.StringValue); - EdidNameFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.Name.StringValue); - EdidPreferredTimingFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.PreferredTiming.StringValue); - EdidSerialNumberFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.SerialNumber.StringValue); - - InputPorts = new RoutingPortCollection {DmIn}; - OutputPorts = new RoutingPortCollection {HdmiOut, BalancedAudioOut}; - - VideoOutputResolutionFeedback = new StringFeedback(() => _rmc.HdmiOutput.GetVideoResolutionString()); - - _rmc.HdmiOutput.OutputStreamChange += HdmiOutput_OutputStreamChange; - _rmc.HdmiOutput.ConnectedDevice.DeviceInformationChange += ConnectedDevice_DeviceInformationChange; - - // Set Ports for CEC - HdmiOut.Port = _rmc.HdmiOutput; - } - - void HdmiOutput_OutputStreamChange(EndpointOutputStream outputStream, EndpointOutputStreamEventArgs args) - { - if (args.EventId == EndpointOutputStreamEventIds.HorizontalResolutionFeedbackEventId || args.EventId == EndpointOutputStreamEventIds.VerticalResolutionFeedbackEventId || - args.EventId == EndpointOutputStreamEventIds.FramesPerSecondFeedbackEventId) - { - VideoOutputResolutionFeedback.FireUpdate(); - } - } - - void ConnectedDevice_DeviceInformationChange(ConnectedDeviceInformation connectedDevice, ConnectedDeviceEventArgs args) - { - switch (args.EventId) - { - case ConnectedDeviceEventIds.ManufacturerEventId: - EdidManufacturerFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.NameEventId: - EdidNameFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.PreferredTimingEventId: - EdidPreferredTimingFeedback.FireUpdate(); - break; - case ConnectedDeviceEventIds.SerialNumberEventId: - EdidSerialNumberFeedback.FireUpdate(); - break; - } - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - LinkDmRmcToApi(this, trilist, joinStart, joinMapKey, bridge); - } - - #region IIROutputPorts Members - public CrestronCollection IROutputPorts { get { return _rmc.IROutputPorts; } } - public int NumberOfIROutputPorts { get { return _rmc.NumberOfIROutputPorts; } } - #endregion - - #region IComPorts Members - public CrestronCollection ComPorts { get { return _rmc.ComPorts; } } - public int NumberOfComPorts { get { return _rmc.NumberOfComPorts; } } - #endregion - - #region ICec Members - /// - /// Gets the CEC stream directly from the HDMI port. - /// - public Cec StreamCec { get { return _rmc.HdmiOutput.StreamCec; } } - #endregion - - #region IRelayPorts Members - - public int NumberOfRelayPorts - { - get { return _rmc.NumberOfRelayPorts; } - } - - public CrestronCollection RelayPorts - { - get { return _rmc.RelayPorts; } - } - - #endregion - - #region IBasicVolumeWithFeedback Members - - public BoolFeedback MuteFeedback - { - get; - private set; - } - - /// - /// Not implemented - /// - public void MuteOff() - { - Debug.Console(2, this, "DM Endpoint {0} does not have a mute function", Key); - } - - /// - /// Not implemented - /// - public void MuteOn() - { - Debug.Console(2, this, "DM Endpoint {0} does not have a mute function", Key); - } - - public void SetVolume(ushort level) - { - _rmc.AudioOutput.Volume.UShortValue = level; - } - - public IntFeedback VolumeLevelFeedback - { - get; - private set; - } - - #endregion - - #region IBasicVolumeControls Members - - /// - /// Not implemented - /// - public void MuteToggle() - { - Debug.Console(2, this, "DM Endpoint {0} does not have a mute function", Key); - } - - public void VolumeDown(bool pressRelease) - { - if (pressRelease) - SigHelper.RampTimeScaled(_rmc.AudioOutput.Volume, 0, 4000); - else - _rmc.AudioOutput.Volume.StopRamp(); - } - - public void VolumeUp(bool pressRelease) - { - if (pressRelease) - SigHelper.RampTimeScaled(_rmc.AudioOutput.Volume, 65535, 4000); - else - _rmc.AudioOutput.Volume.StopRamp(); - } - - #endregion - } + public class DmRmc4kScalerCController : DmRmcControllerBase, IRoutingInputsOutputs, IBasicVolumeWithFeedback, + IIROutputPorts, IComPorts, ICec, IRelayPorts, IHasDmInHdcp + { + private readonly DmRmc4kScalerC _rmc; + + public RoutingInputPort DmIn { get; private set; } + public RoutingOutputPort HdmiOut { get; private set; } + public RoutingOutputPort BalancedAudioOut { get; private set; } + + public RoutingPortCollection InputPorts { get; private set; } + + public RoutingPortCollection OutputPorts { get; private set; } + + public EndpointDmInputStreamWithCec DmInput { get; private set; } + + public IntFeedback DmInHdcpStateFeedback { get; private set; } + + + + /// + /// Make a Crestron RMC and put it in here + /// + public DmRmc4kScalerCController(string key, string name, DmRmc4kScalerC rmc) + : base(key, name, rmc) + { + _rmc = rmc; + + DmIn = new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.AudioVideo, + eRoutingPortConnectionType.DmCat, 0, this); + HdmiOut = new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.AudioVideo, + eRoutingPortConnectionType.Hdmi, null, this); + BalancedAudioOut = new RoutingOutputPort(DmPortName.BalancedAudioOut, eRoutingSignalType.Audio, + eRoutingPortConnectionType.LineAudio, null, this); + + MuteFeedback = new BoolFeedback(() => false); + + VolumeLevelFeedback = new IntFeedback("MainVolumeLevelFeedback", () => + rmc.AudioOutput.VolumeFeedback.UShortValue); + + EdidManufacturerFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.Manufacturer.StringValue); + EdidNameFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.Name.StringValue); + EdidPreferredTimingFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.PreferredTiming.StringValue); + EdidSerialNumberFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.SerialNumber.StringValue); + + InputPorts = new RoutingPortCollection { DmIn }; + OutputPorts = new RoutingPortCollection { HdmiOut, BalancedAudioOut }; + + VideoOutputResolutionFeedback = new StringFeedback(() => _rmc.HdmiOutput.GetVideoResolutionString()); + DmInHdcpStateFeedback = new IntFeedback("DmInHdcpCapability", + () => (int)_rmc.DmInput.HdcpCapabilityFeedback); + + AddToFeedbackList(DmInHdcpStateFeedback); + + + _rmc.HdmiOutput.OutputStreamChange += HdmiOutput_OutputStreamChange; + _rmc.HdmiOutput.ConnectedDevice.DeviceInformationChange += ConnectedDevice_DeviceInformationChange; + + // Set Ports for CEC + HdmiOut.Port = _rmc.HdmiOutput; + } + + void HdmiOutput_OutputStreamChange(EndpointOutputStream outputStream, EndpointOutputStreamEventArgs args) + { + if (args.EventId == EndpointOutputStreamEventIds.HorizontalResolutionFeedbackEventId || args.EventId == EndpointOutputStreamEventIds.VerticalResolutionFeedbackEventId || + args.EventId == EndpointOutputStreamEventIds.FramesPerSecondFeedbackEventId) + { + VideoOutputResolutionFeedback.FireUpdate(); + } + } + + void ConnectedDevice_DeviceInformationChange(ConnectedDeviceInformation connectedDevice, ConnectedDeviceEventArgs args) + { + switch (args.EventId) + { + case ConnectedDeviceEventIds.ManufacturerEventId: + EdidManufacturerFeedback.FireUpdate(); + break; + case ConnectedDeviceEventIds.NameEventId: + EdidNameFeedback.FireUpdate(); + break; + case ConnectedDeviceEventIds.PreferredTimingEventId: + EdidPreferredTimingFeedback.FireUpdate(); + break; + case ConnectedDeviceEventIds.SerialNumberEventId: + EdidSerialNumberFeedback.FireUpdate(); + break; + } + } + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + LinkDmRmcToApi(this, trilist, joinStart, joinMapKey, bridge); + } + + #region IIROutputPorts Members + public CrestronCollection IROutputPorts { get { return _rmc.IROutputPorts; } } + public int NumberOfIROutputPorts { get { return _rmc.NumberOfIROutputPorts; } } + #endregion + + #region IComPorts Members + public CrestronCollection ComPorts { get { return _rmc.ComPorts; } } + public int NumberOfComPorts { get { return _rmc.NumberOfComPorts; } } + #endregion + + #region ICec Members + /// + /// Gets the CEC stream directly from the HDMI port. + /// + public Cec StreamCec { get { return _rmc.HdmiOutput.StreamCec; } } + #endregion + + #region IRelayPorts Members + + public int NumberOfRelayPorts + { + get { return _rmc.NumberOfRelayPorts; } + } + + public CrestronCollection RelayPorts + { + get { return _rmc.RelayPorts; } + } + + #endregion + + #region IBasicVolumeWithFeedback Members + + public BoolFeedback MuteFeedback + { + get; + private set; + } + + /// + /// Not implemented + /// + public void MuteOff() + { + Debug.Console(2, this, "DM Endpoint {0} does not have a mute function", Key); + } + + /// + /// Not implemented + /// + public void MuteOn() + { + Debug.Console(2, this, "DM Endpoint {0} does not have a mute function", Key); + } + + public void SetVolume(ushort level) + { + _rmc.AudioOutput.Volume.UShortValue = level; + } + + public IntFeedback VolumeLevelFeedback + { + get; + private set; + } + + #endregion + + #region IBasicVolumeControls Members + + /// + /// Not implemented + /// + public void MuteToggle() + { + Debug.Console(2, this, "DM Endpoint {0} does not have a mute function", Key); + } + + public void VolumeDown(bool pressRelease) + { + if (pressRelease) + SigHelper.RampTimeScaled(_rmc.AudioOutput.Volume, 0, 4000); + else + _rmc.AudioOutput.Volume.StopRamp(); + } + + public void VolumeUp(bool pressRelease) + { + if (pressRelease) + SigHelper.RampTimeScaled(_rmc.AudioOutput.Volume, 65535, 4000); + else + _rmc.AudioOutput.Volume.StopRamp(); + } + + #endregion + + public eHdcpCapabilityType DmInHdcpCapability + { + get { return eHdcpCapabilityType.Hdcp2_2Support; } + } + + public void SetDmInHdcpState(eHdcpCapabilityType hdcpState) + { + if (_rmc == null) return; + _rmc.DmInput.HdcpCapability = hdcpState; + } + + } } \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kScalerCDspController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kScalerCDspController.cs index a7c83e35..99bc35fd 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kScalerCDspController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kScalerCDspController.cs @@ -5,8 +5,9 @@ using Crestron.SimplSharpPro.DM.Endpoints; using Crestron.SimplSharpPro.DM.Endpoints.Receivers; using PepperDash.Core; using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; - +using PepperDash.Essentials.Core.Bridges; +using PepperDash_Essentials_DM; + namespace PepperDash.Essentials.DM { /// @@ -15,7 +16,7 @@ namespace PepperDash.Essentials.DM /// [Description("Wrapper Class for DM-RMC-4K-SCALER-C-DSP")] public class DmRmc4kScalerCDspController : DmRmcControllerBase, IRoutingInputsOutputs, IBasicVolumeWithFeedback, - IIROutputPorts, IComPorts, ICec, IRelayPorts + IIROutputPorts, IComPorts, ICec, IRelayPorts, IHasDmInHdcp { private readonly DmRmc4kScalerCDsp _rmc; @@ -25,7 +26,12 @@ namespace PepperDash.Essentials.DM public RoutingPortCollection InputPorts { get; private set; } - public RoutingPortCollection OutputPorts { get; private set; } + public RoutingPortCollection OutputPorts { get; private set; } + + public EndpointDmInputStreamWithCec DmInput { get; private set; } + + public IntFeedback DmInHdcpStateFeedback { get; private set; } + /// /// Make a Crestron RMC and put it in here @@ -51,7 +57,13 @@ namespace PepperDash.Essentials.DM EdidPreferredTimingFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.PreferredTiming.StringValue); EdidSerialNumberFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.SerialNumber.StringValue); - VideoOutputResolutionFeedback = new StringFeedback(() => _rmc.HdmiOutput.GetVideoResolutionString()); + VideoOutputResolutionFeedback = new StringFeedback(() => _rmc.HdmiOutput.GetVideoResolutionString()); + + DmInHdcpStateFeedback = new IntFeedback("DmInHdcpCapability", + () => (int) _rmc.DmInput.HdcpCapabilityFeedback); + + AddToFeedbackList(DmInHdcpStateFeedback); + InputPorts = new RoutingPortCollection {DmIn}; OutputPorts = new RoutingPortCollection {HdmiOut, BalancedAudioOut}; @@ -190,6 +202,18 @@ namespace PepperDash.Essentials.DM _rmc.AudioOutput.Volume.StopRamp(); } - #endregion + #endregion + + public eHdcpCapabilityType DmInHdcpCapability + { + get { return eHdcpCapabilityType.Hdcp2_2Support; } + } + + public void SetDmInHdcpState(eHdcpCapabilityType hdcpState) + { + if (_rmc == null) return; + _rmc.DmInput.HdcpCapability = hdcpState; + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kZScalerCController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kZScalerCController.cs index 73dd59b9..fd48a904 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kZScalerCController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4kZScalerCController.cs @@ -9,12 +9,13 @@ using Crestron.SimplSharpPro.DM.Endpoints.Receivers; using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Bridges; using PepperDash.Core; +using PepperDash_Essentials_DM; namespace PepperDash.Essentials.DM { [Description("Wrapper Class for DM-RMC-4K-Z-SCALER-C")] public class DmRmc4kZScalerCController : DmRmcControllerBase, IRmcRoutingWithFeedback, - IIROutputPorts, IComPorts, ICec, IRelayPorts + IIROutputPorts, IComPorts, ICec, IRelayPorts, IHasDmInHdcp, IHasHdmiInHdcp { private readonly DmRmc4kzScalerC _rmc; @@ -22,6 +23,13 @@ namespace PepperDash.Essentials.DM public RoutingInputPort HdmiIn { get; private set; } public RoutingOutputPort HdmiOut { get; private set; } + public IntFeedback DmInHdcpStateFeedback { get; private set; } + public IntFeedback HdmiInHdcpStateFeedback { get; private set; } + + public BoolFeedback HdmiVideoSyncFeedback { get; private set; } + + + /// /// The value of the current video source for the HDMI output on the receiver /// @@ -42,13 +50,13 @@ namespace PepperDash.Essentials.DM { var newEvent = NumericSwitchChange; if (newEvent != null) newEvent(this, e); - } - + } public DmRmc4kZScalerCController(string key, string name, DmRmc4kzScalerC rmc) : base(key, name, rmc) { _rmc = rmc; + DmIn = new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.DmCat, 0, this) { @@ -62,6 +70,16 @@ namespace PepperDash.Essentials.DM HdmiOut = new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, null, this); + HdmiInHdcpStateFeedback = new IntFeedback("HdmiInHdcpCapability", + () => (int)_rmc.HdmiIn.HdcpCapabilityFeedback); + DmInHdcpStateFeedback = new IntFeedback("DmInHdcpCapability", + () => (int)_rmc.DmInput.HdcpCapabilityFeedback); + HdmiVideoSyncFeedback = new BoolFeedback("HdmiInVideoSync", + () => _rmc.HdmiIn.SyncDetectedFeedback.BoolValue); + + AddToFeedbackList(HdmiInHdcpStateFeedback, DmInHdcpStateFeedback, HdmiVideoSyncFeedback); + + EdidManufacturerFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.Manufacturer.StringValue); EdidNameFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.Name.StringValue); EdidPreferredTimingFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.PreferredTiming.StringValue); @@ -69,11 +87,13 @@ namespace PepperDash.Essentials.DM VideoOutputResolutionFeedback = new StringFeedback(() => _rmc.HdmiOutput.GetVideoResolutionString()); - InputPorts = new RoutingPortCollection {DmIn, HdmiIn}; - OutputPorts = new RoutingPortCollection {HdmiOut}; + InputPorts = new RoutingPortCollection { DmIn, HdmiIn }; + OutputPorts = new RoutingPortCollection { HdmiOut }; _rmc.HdmiOutput.OutputStreamChange += HdmiOutput_OutputStreamChange; _rmc.HdmiOutput.ConnectedDevice.DeviceInformationChange += ConnectedDevice_DeviceInformationChange; + _rmc.HdmiIn.InputStreamChange += InputStreamChangeEvent; + _rmc.DmInput.InputStreamChange += InputStreamChangeEvent; _rmc.OnlineStatusChange += _rmc_OnlineStatusChange; @@ -83,6 +103,20 @@ namespace PepperDash.Essentials.DM AudioVideoSourceNumericFeedback = new IntFeedback(() => (ushort)(_rmc.SelectedSourceFeedback)); } + void InputStreamChangeEvent(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) + { + switch (args.EventId) + { + case EndpointInputStreamEventIds.HdcpCapabilityFeedbackEventId: + if (inputStream == _rmc.HdmiIn) HdmiInHdcpStateFeedback.FireUpdate(); + if (inputStream == _rmc.DmInput) DmInHdcpStateFeedback.FireUpdate(); + break; + case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: + if (inputStream == _rmc.HdmiIn) HdmiVideoSyncFeedback.FireUpdate(); + break; + } + } + private void _rmc_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) { AudioVideoSourceNumericFeedback.FireUpdate(); @@ -181,5 +215,31 @@ namespace PepperDash.Essentials.DM } #endregion + + + public eHdcpCapabilityType DmInHdcpCapability + { + get { return eHdcpCapabilityType.Hdcp2_2Support; } + } + + public void SetDmInHdcpState(eHdcpCapabilityType hdcpState) + { + + if (_rmc == null) return; + _rmc.DmInput.HdcpCapability = hdcpState; + } + + + public eHdcpCapabilityType HdmiInHdcpCapability + { + get { return eHdcpCapabilityType.Hdcp2_2Support; } + } + + public void SetHdmiInHdcpState(eHdcpCapabilityType hdcpState) + { + if (_rmc == null) return; + _rmc.HdmiIn.HdcpCapability = hdcpState; + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs index e237c3a5..bb8aec65 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DM; using Crestron.SimplSharpPro.DM.Cards; @@ -11,11 +12,12 @@ using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.DeviceInfo; using PepperDash.Essentials.DM.Config; using PepperDash.Essentials.Core.Config; +using PepperDash_Essentials_DM; namespace PepperDash.Essentials.DM { [Description("Wrapper class for all DM-RMC variants")] - public abstract class DmRmcControllerBase : CrestronGenericBridgeableBaseDevice, IDeviceInfoProvider + public abstract class DmRmcControllerBase : CrestronGenericBridgeableBaseDevice, IDeviceInfoProvider { private const int CtpPort = 41795; private readonly EndpointReceiverBase _rmc; //kept here just in case. Only property or method on this class that's not device-specific is the DMOutput that it's attached to. @@ -27,15 +29,15 @@ namespace PepperDash.Essentials.DM public StringFeedback EdidSerialNumberFeedback { get; protected set; } protected DmRmcControllerBase(string key, string name, EndpointReceiverBase device) - : base(key, name, device) + : base(key, name, device) { _rmc = device; - // if wired to a chassis, skip registration step in base class + // if wired to a chassis, skip registration step in base class PreventRegistration = _rmc.DMOutput != null; - + AddToFeedbackList(VideoOutputResolutionFeedback, EdidManufacturerFeedback, EdidSerialNumberFeedback, EdidNameFeedback, EdidPreferredTimingFeedback); - + DeviceInfo = new DeviceInfo(); IsOnline.OutputChange += (currentDevice, args) => { if (args.BoolValue) UpdateDeviceInfo(); }; @@ -73,19 +75,80 @@ namespace PepperDash.Essentials.DM rmc.EdidPreferredTimingFeedback.LinkInputSig(trilist.StringInput[joinMap.EdidPrefferedTiming.JoinNumber]); if (rmc.EdidSerialNumberFeedback != null) rmc.EdidSerialNumberFeedback.LinkInputSig(trilist.StringInput[joinMap.EdidSerialNumber.JoinNumber]); - + + //If the device is an DM-RMC-4K-Z-SCALER-C - var routing = rmc as IRmcRouting; + var routing = rmc as IRoutingInputsOutputs; + + trilist.UShortInput[joinMap.HdcpInputPortCount.JoinNumber].UShortValue = (ushort)(routing == null + ? 1 + : routing.InputPorts.Count); if (routing == null) { return; } + var hdcpCapability = eHdcpCapabilityType.HdcpSupportOff; + if (routing.InputPorts[DmPortName.HdmiIn] != null) + { + var hdmiInHdcp = routing as IHasHdmiInHdcp; + if (hdmiInHdcp != null) + { + if (rmc.Feedbacks["HdmiInHdcpCapability"] != null) + { + var intFeedback = rmc.Feedbacks["HdmiInHdcpCapability"] as IntFeedback; + if (intFeedback != null) + intFeedback.LinkInputSig(trilist.UShortInput[joinMap.Port1HdcpState.JoinNumber]); + } + if (rmc.Feedbacks["HdmiInVideoSync"] != null) + { + var boolFeedback = rmc.Feedbacks["HdmiInVideoSync"] as BoolFeedback; + if (boolFeedback != null) + boolFeedback.LinkInputSig(trilist.BooleanInput[joinMap.HdmiInputSync.JoinNumber]); + } + hdcpCapability = hdmiInHdcp.HdmiInHdcpCapability > hdcpCapability + ? hdmiInHdcp.HdmiInHdcpCapability + : hdcpCapability; - if (routing.AudioVideoSourceNumericFeedback != null) - routing.AudioVideoSourceNumericFeedback.LinkInputSig(trilist.UShortInput[joinMap.AudioVideoSource.JoinNumber]); + trilist.SetUShortSigAction(joinMap.Port1HdcpState.JoinNumber, a => hdmiInHdcp.SetHdmiInHdcpState((eHdcpCapabilityType)a)); + } + } + if (routing.InputPorts[DmPortName.DmIn] != null) + { + var dmInHdcp = rmc as IHasDmInHdcp; - trilist.SetUShortSigAction(joinMap.AudioVideoSource.JoinNumber, a => routing.ExecuteNumericSwitch(a, 1, eRoutingSignalType.AudioVideo)); + if (dmInHdcp != null) + { + if (rmc.Feedbacks["DmInHdcpCapability"] != null) + { + var intFeedback = rmc.Feedbacks["DmInHdcpCapability"] as IntFeedback; + if (intFeedback != null) + intFeedback.LinkInputSig(trilist.UShortInput[joinMap.Port2HdcpState.JoinNumber]); + } + + hdcpCapability = dmInHdcp.DmInHdcpCapability > hdcpCapability + ? dmInHdcp.DmInHdcpCapability + : hdcpCapability; + + + trilist.SetUShortSigAction(joinMap.Port2HdcpState.JoinNumber, a => dmInHdcp.SetDmInHdcpState((eHdcpCapabilityType)a)); + } + } + + trilist.UShortInput[joinMap.HdcpSupportCapability.JoinNumber].UShortValue = (ushort)hdcpCapability; + + trilist.UShortInput[joinMap.HdcpInputPortCount.JoinNumber].UShortValue = (ushort)routing.InputPorts.Count; + + var routingWithFeedback = routing as IRmcRouting; + if (routingWithFeedback == null) return; + + if (routingWithFeedback.AudioVideoSourceNumericFeedback != null) + routingWithFeedback.AudioVideoSourceNumericFeedback.LinkInputSig( + trilist.UShortInput[joinMap.AudioVideoSource.JoinNumber]); + + + trilist.SetUShortSigAction(joinMap.AudioVideoSource.JoinNumber, + a => routingWithFeedback.ExecuteNumericSwitch(a, 1, eRoutingSignalType.AudioVideo)); } #region Implementation of IDeviceInfoProvider @@ -143,13 +206,13 @@ namespace PepperDash.Essentials.DM return; } - + if (args.Text.ToLower().Contains("host")) { DeviceInfo.HostName = args.Text.Split(':')[1].Trim(); tcpClient.SendText("maca\r\n"); - + return; } @@ -202,17 +265,17 @@ namespace PepperDash.Essentials.DM } } - public class DmRmcHelper - { - private static readonly Dictionary> ProcessorFactoryDict; - private static readonly Dictionary> ChassisCpu3Dict; + public class DmRmcHelper + { + private static readonly Dictionary> ProcessorFactoryDict; + private static readonly Dictionary> ChassisCpu3Dict; - private static readonly Dictionary> - ChassisDict; + private static readonly Dictionary> + ChassisDict; - static DmRmcHelper() - { - ProcessorFactoryDict = new Dictionary> + static DmRmcHelper() + { + ProcessorFactoryDict = new Dictionary> { {"dmrmc100c", (k, n, i) => new DmRmcX100CController(k, n, new DmRmc100C(i, Global.ControlSystem))}, {"dmrmc100s", (k, n, i) => new DmRmc100SController(k, n, new DmRmc100S(i, Global.ControlSystem))}, @@ -306,34 +369,34 @@ namespace PepperDash.Essentials.DM {"dmrmc4k100c1g", (k,n,i,d) => new DmRmc4k100C1GController(k,n, new DmRmc4K100C1G(i, d))} }; } - /// - /// A factory method for various DmRmcControllers - /// - /// device key. Used to uniquely identify device - /// device name - /// device type name. Used to retrived the correct device - /// Config from config file - /// - public static CrestronGenericBaseDevice GetDmRmcController(string key, string name, string typeName, DmRmcPropertiesConfig props) - { - typeName = typeName.ToLower(); - var ipid = props.Control.IpIdInt; + /// + /// A factory method for various DmRmcControllers + /// + /// device key. Used to uniquely identify device + /// device name + /// device type name. Used to retrived the correct device + /// Config from config file + /// + public static CrestronGenericBaseDevice GetDmRmcController(string key, string name, string typeName, DmRmcPropertiesConfig props) + { + typeName = typeName.ToLower(); + var ipid = props.Control.IpIdInt; - var pKey = props.ParentDeviceKey.ToLower(); + var pKey = props.ParentDeviceKey.ToLower(); - // Non-DM-chassis endpoints - return pKey == "processor" ? GetDmRmcControllerForProcessor(key, name, typeName, ipid) : GetDmRmcControllerForChassis(key, name, typeName, props, pKey, ipid); - } + // Non-DM-chassis endpoints + return pKey == "processor" ? GetDmRmcControllerForProcessor(key, name, typeName, ipid) : GetDmRmcControllerForChassis(key, name, typeName, props, pKey, ipid); + } - private static CrestronGenericBaseDevice GetDmRmcControllerForChassis(string key, string name, string typeName, - DmRmcPropertiesConfig props, string pKey, uint ipid) - { - var parentDev = DeviceManager.GetDeviceForKey(pKey); + private static CrestronGenericBaseDevice GetDmRmcControllerForChassis(string key, string name, string typeName, + DmRmcPropertiesConfig props, string pKey, uint ipid) + { + var parentDev = DeviceManager.GetDeviceForKey(pKey); CrestronGenericBaseDevice rx; bool useChassisForOfflineFeedback = false; - if (parentDev is DmpsRoutingController) - { + if (parentDev is DmpsRoutingController) + { var dmps = parentDev as DmpsRoutingController; //Check that the input is within range of this chassis' possible inputs var num = props.ParentOutputNumber; @@ -348,9 +411,9 @@ namespace PepperDash.Essentials.DM if (Global.ControlSystemIsDmps4kType) { rx = GetDmRmcControllerForDmps4k(key, name, typeName, dmps, props.ParentOutputNumber); - useChassisForOfflineFeedback = true; + useChassisForOfflineFeedback = true; } - else + else { rx = GetDmRmcControllerForDmps(key, name, typeName, ipid, dmps, props.ParentOutputNumber); if (typeName == "hdbasetrx" || typeName == "dmrmc4k100c1g") @@ -372,7 +435,7 @@ namespace PepperDash.Essentials.DM }; } return rx; - } + } else if (parentDev is DmChassisController) { var controller = parentDev as DmChassisController; @@ -385,7 +448,7 @@ namespace PepperDash.Essentials.DM Debug.Console(0, "Cannot create DM device '{0}'. Output number '{1}' is out of range", key, num); return null; - } + } controller.RxDictionary.Add(num, key); // Catch constructor failures, mainly dues to IPID try @@ -434,31 +497,31 @@ namespace PepperDash.Essentials.DM key, pKey); return null; } - } + } - private static CrestronGenericBaseDevice GetDmRmcControllerForCpu2Chassis(string key, string name, string typeName, - uint ipid, Switch chassis, uint num, IKeyed parentDev) - { - Func handler; - if (ChassisDict.TryGetValue(typeName.ToLower(), out handler)) - { - return handler(key, name, ipid, chassis.Outputs[num]); - } - Debug.Console(0, "Cannot create DM-RMC of type '{0}' with parent device {1}", typeName, parentDev.Key); - return null; - } + private static CrestronGenericBaseDevice GetDmRmcControllerForCpu2Chassis(string key, string name, string typeName, + uint ipid, Switch chassis, uint num, IKeyed parentDev) + { + Func handler; + if (ChassisDict.TryGetValue(typeName.ToLower(), out handler)) + { + return handler(key, name, ipid, chassis.Outputs[num]); + } + Debug.Console(0, "Cannot create DM-RMC of type '{0}' with parent device {1}", typeName, parentDev.Key); + return null; + } - private static CrestronGenericBaseDevice GetDmRmcControllerForCpu3Chassis(string key, string name, string typeName, - Switch chassis, uint num, IKeyed parentDev) - { - Func cpu3Handler; - if (ChassisCpu3Dict.TryGetValue(typeName.ToLower(), out cpu3Handler)) - { - return cpu3Handler(key, name, chassis.Outputs[num]); - } - Debug.Console(0, "Cannot create DM-RMC of type '{0}' with parent device {1}", typeName, parentDev.Key); - return null; - } + private static CrestronGenericBaseDevice GetDmRmcControllerForCpu3Chassis(string key, string name, string typeName, + Switch chassis, uint num, IKeyed parentDev) + { + Func cpu3Handler; + if (ChassisCpu3Dict.TryGetValue(typeName.ToLower(), out cpu3Handler)) + { + return cpu3Handler(key, name, chassis.Outputs[num]); + } + Debug.Console(0, "Cannot create DM-RMC of type '{0}' with parent device {1}", typeName, parentDev.Key); + return null; + } private static CrestronGenericBaseDevice GetDmRmcControllerForDmps(string key, string name, string typeName, uint ipid, DmpsRoutingController controller, uint num) @@ -482,49 +545,49 @@ namespace PepperDash.Essentials.DM return null; } - private static CrestronGenericBaseDevice GetDmRmcControllerForDmps4k(string key, string name, string typeName, - DmpsRoutingController controller, uint num) - { - Func dmps4kHandler; - if (ChassisCpu3Dict.TryGetValue(typeName.ToLower(), out dmps4kHandler)) - { - var output = controller.Dmps.SwitcherOutputs[num] as DMOutput; + private static CrestronGenericBaseDevice GetDmRmcControllerForDmps4k(string key, string name, string typeName, + DmpsRoutingController controller, uint num) + { + Func dmps4kHandler; + if (ChassisCpu3Dict.TryGetValue(typeName.ToLower(), out dmps4kHandler)) + { + var output = controller.Dmps.SwitcherOutputs[num] as DMOutput; - if (output != null) - { - return dmps4kHandler(key, name, output); - } - Debug.Console(0, Debug.ErrorLogLevel.Error, - "Cannot attach DM-RMC of type '{0}' to output {1} on DMPS-4K chassis. Output is not a DM Output.", - typeName, num); - return null; - } + if (output != null) + { + return dmps4kHandler(key, name, output); + } + Debug.Console(0, Debug.ErrorLogLevel.Error, + "Cannot attach DM-RMC of type '{0}' to output {1} on DMPS-4K chassis. Output is not a DM Output.", + typeName, num); + return null; + } Debug.Console(0, Debug.ErrorLogLevel.Error, "Cannot create DM-RMC of type '{0}' to output {1} on DMPS-4K chassis", typeName, num); - return null; - } + return null; + } - private static CrestronGenericBaseDevice GetDmRmcControllerForProcessor(string key, string name, string typeName, uint ipid) - { - try - { - Func handler; + private static CrestronGenericBaseDevice GetDmRmcControllerForProcessor(string key, string name, string typeName, uint ipid) + { + try + { + Func handler; - if (ProcessorFactoryDict.TryGetValue(typeName.ToLower(), out handler)) - { - return handler(key, name, ipid); - } - Debug.Console(0, "Cannot create DM-RMC of type: '{0}'", typeName); + if (ProcessorFactoryDict.TryGetValue(typeName.ToLower(), out handler)) + { + return handler(key, name, ipid); + } + Debug.Console(0, "Cannot create DM-RMC of type: '{0}'", typeName); - return null; - } - catch (Exception e) - { - Debug.Console(0, "[{0}] WARNING: Cannot create DM-RMC device: {1}", key, e.Message); return null; - } - } - } + } + catch (Exception e) + { + Debug.Console(0, "[{0}] WARNING: Cannot create DM-RMC device: {1}", key, e.Message); + return null; + } + } + } public class DmRmcControllerFactory : EssentialsDeviceFactory { @@ -544,7 +607,7 @@ namespace PepperDash.Essentials.DM var props = JsonConvert.DeserializeObject (dc.Properties.ToString()); - return DmRmcHelper.GetDmRmcController(dc.Key, dc.Name, type, props); + return DmRmcHelper.GetDmRmcController(dc.Key, dc.Name, type, props); } } diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k202CController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k202CController.cs index 387562e4..6614bcb4 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k202CController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k202CController.cs @@ -1,42 +1,42 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -//using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Endpoints; -using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; - -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.DM.Config; - -namespace PepperDash.Essentials.DM -{ - using eVst = Crestron.SimplSharpPro.DeviceSupport.eX02VideoSourceType; - using eAst = Crestron.SimplSharpPro.DeviceSupport.eX02AudioSourceType; - +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro; +//using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.DM; +using Crestron.SimplSharpPro.DM.Endpoints; +using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; + +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; +using PepperDash.Essentials.DM.Config; + +namespace PepperDash.Essentials.DM +{ + using eVst = Crestron.SimplSharpPro.DeviceSupport.eX02VideoSourceType; + using eAst = Crestron.SimplSharpPro.DeviceSupport.eX02AudioSourceType; + [Description("Wrapper class for DM-TX-4K-202-C")] - public class DmTx4k202CController : DmTxControllerBase, ITxRoutingWithFeedback, IHasFeedback, - IIROutputPorts, IComPorts - { - public DmTx4k202C Tx { get; private set; } - - public RoutingInputPortWithVideoStatuses HdmiIn1 { get; private set; } - public RoutingInputPortWithVideoStatuses HdmiIn2 { get; private set; } - public RoutingOutputPort DmOut { get; private set; } - public RoutingOutputPort HdmiLoopOut { get; private set; } - - public override StringFeedback ActiveVideoInputFeedback { get; protected set; } - public IntFeedback VideoSourceNumericFeedback { get; protected set; } - public IntFeedback AudioSourceNumericFeedback { get; protected set; } - public IntFeedback HdmiIn1HdcpCapabilityFeedback { get; protected set; } - public IntFeedback HdmiIn2HdcpCapabilityFeedback { get; protected set; } - public BoolFeedback Hdmi1VideoSyncFeedback { get; protected set; } + public class DmTx4k202CController : DmTxControllerBase, ITxRoutingWithFeedback, IHasFeedback, + IIROutputPorts, IComPorts + { + public DmTx4k202C Tx { get; private set; } + + public RoutingInputPortWithVideoStatuses HdmiIn1 { get; private set; } + public RoutingInputPortWithVideoStatuses HdmiIn2 { get; private set; } + public RoutingOutputPort DmOut { get; private set; } + public RoutingOutputPort HdmiLoopOut { get; private set; } + + public override StringFeedback ActiveVideoInputFeedback { get; protected set; } + public IntFeedback VideoSourceNumericFeedback { get; protected set; } + public IntFeedback AudioSourceNumericFeedback { get; protected set; } + public IntFeedback HdmiIn1HdcpCapabilityFeedback { get; protected set; } + public IntFeedback HdmiIn2HdcpCapabilityFeedback { get; protected set; } + public BoolFeedback Hdmi1VideoSyncFeedback { get; protected set; } public BoolFeedback Hdmi2VideoSyncFeedback { get; protected set; } //IroutingNumericEvent @@ -50,50 +50,50 @@ namespace PepperDash.Essentials.DM { var newEvent = NumericSwitchChange; if (newEvent != null) newEvent(this, e); - } - - - //public override IntFeedback HdcpSupportAllFeedback { get; protected set; } - //public override ushort HdcpSupportCapability { get; protected set; } - - /// - /// Helps get the "real" inputs, including when in Auto - /// - public Crestron.SimplSharpPro.DeviceSupport.eX02VideoSourceType ActualActiveVideoInput - { - get - { - if (Tx.VideoSourceFeedback != eVst.Auto) - return Tx.VideoSourceFeedback; - else // auto - { - if (Tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue) - return eVst.Hdmi1; - else if (Tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue) - return eVst.Hdmi2; - else - return eVst.AllDisabled; - } - } - } - public RoutingPortCollection InputPorts - { - get - { + } + + + //public override IntFeedback HdcpSupportAllFeedback { get; protected set; } + //public override ushort HdcpSupportCapability { get; protected set; } + + /// + /// Helps get the "real" inputs, including when in Auto + /// + public Crestron.SimplSharpPro.DeviceSupport.eX02VideoSourceType ActualActiveVideoInput + { + get + { + if (Tx.VideoSourceFeedback != eVst.Auto) + return Tx.VideoSourceFeedback; + else // auto + { + if (Tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue) + return eVst.Hdmi1; + else if (Tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue) + return eVst.Hdmi2; + else + return eVst.AllDisabled; + } + } + } + public RoutingPortCollection InputPorts + { + get + { return new RoutingPortCollection { HdmiIn1, HdmiIn2, AnyVideoInput - }; - } - } - public RoutingPortCollection OutputPorts - { - get - { - return new RoutingPortCollection { DmOut, HdmiLoopOut }; - } + }; + } + } + public RoutingPortCollection OutputPorts + { + get + { + return new RoutingPortCollection { DmOut, HdmiLoopOut }; + } } public DmTx4k202CController(string key, string name, DmTx4k202C tx, bool preventRegistration) @@ -127,28 +127,23 @@ namespace PepperDash.Essentials.DM Tx.OnlineStatusChange += Tx_OnlineStatusChange; - VideoSourceNumericFeedback = new IntFeedback(() => (int) Tx.VideoSourceFeedback); + VideoSourceNumericFeedback = new IntFeedback(() => (int)Tx.VideoSourceFeedback); - AudioSourceNumericFeedback = new IntFeedback(() => (int) Tx.AudioSourceFeedback); + AudioSourceNumericFeedback = new IntFeedback(() => (int)Tx.AudioSourceFeedback); HdmiIn1HdcpCapabilityFeedback = new IntFeedback("HdmiIn1HdcpCapability", - () => (int) tx.HdmiInputs[1].HdcpCapabilityFeedback); + () => (int)tx.HdmiInputs[1].HdcpCapabilityFeedback); HdmiIn2HdcpCapabilityFeedback = new IntFeedback("HdmiIn2HdcpCapability", - () => (int) tx.HdmiInputs[2].HdcpCapabilityFeedback); - - HdcpStateFeedback = - new IntFeedback( - () => - tx.HdmiInputs[1].HdcpCapabilityFeedback > tx.HdmiInputs[2].HdcpCapabilityFeedback - ? (int) tx.HdmiInputs[1].HdcpCapabilityFeedback - : (int) tx.HdmiInputs[2].HdcpCapabilityFeedback); + () => (int)tx.HdmiInputs[2].HdcpCapabilityFeedback); HdcpSupportCapability = eHdcpCapabilityType.Hdcp2_2Support; - Hdmi1VideoSyncFeedback = new BoolFeedback(() => (bool) tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue); + HdcpStateFeedback = new IntFeedback(() => (int)HdcpSupportCapability); - Hdmi2VideoSyncFeedback = new BoolFeedback(() => (bool) tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue); + Hdmi1VideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue); + + Hdmi2VideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue); var combinedFuncs = new VideoStatusFuncsWrapper { @@ -210,120 +205,120 @@ namespace PepperDash.Essentials.DM - public override bool CustomActivate() - { - // Link up all of these damned events to the various RoutingPorts via a helper handler - Tx.HdmiInputs[1].InputStreamChange += (o, a) => FowardInputStreamChange(HdmiIn1, a.EventId); - Tx.HdmiInputs[1].VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn1, a.EventId); - - Tx.HdmiInputs[2].InputStreamChange += (o, a) => FowardInputStreamChange(HdmiIn2, a.EventId); - Tx.HdmiInputs[2].VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn2, a.EventId); - - // Base does register and sets up comm monitoring. - return base.CustomActivate(); - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = GetDmTxJoinMap(joinStart, joinMapKey); - - if (Hdmi1VideoSyncFeedback != null) - { - Hdmi1VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input1VideoSyncStatus.JoinNumber]); - } - if (Hdmi2VideoSyncFeedback != null) - { - Hdmi2VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input2VideoSyncStatus.JoinNumber]); - } - - LinkDmTxToApi(this, trilist, joinMap, bridge); - } - - public void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type) - { - Debug.Console(2, this, "Executing Numeric Switch to input {0}.", input); - - switch (type) - { - case eRoutingSignalType.Video: - switch (input) - { - case 0: - { - ExecuteSwitch(eVst.Auto, null, type); - break; - } - case 1: - { - ExecuteSwitch(HdmiIn1.Selector, null, type); - break; - } - case 2: - { - ExecuteSwitch(HdmiIn2.Selector, null, type); - break; - } - case 3: - { - ExecuteSwitch(eVst.AllDisabled, null, type); - break; - } - } - break; - case eRoutingSignalType.Audio: - switch (input) - { - case 0: - { - ExecuteSwitch(eAst.Auto, null, type); - break; - } - case 1: - { - ExecuteSwitch(eAst.Hdmi1, null, type); - break; - } - case 2: - { - ExecuteSwitch(eAst.Hdmi2, null, type); - break; - } - case 3: - { - ExecuteSwitch(eAst.AllDisabled, null, type); - break; - } - } - break; - } - } - - public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) - { - if ((signalType | eRoutingSignalType.Video) == eRoutingSignalType.Video) - Tx.VideoSource = (eVst)inputSelector; - if ((signalType | eRoutingSignalType.Audio) == eRoutingSignalType.Audio) - Tx.AudioSource = (eAst)inputSelector; - } - - void InputStreamChangeEvent(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) - { - Debug.Console(2, "{0} event {1} stream {2}", this.Tx.ToString(), inputStream.ToString(), args.EventId.ToString()); - - switch (args.EventId) - { - case EndpointInputStreamEventIds.HdcpSupportOffFeedbackEventId: - case EndpointInputStreamEventIds.HdcpSupportOnFeedbackEventId: - case EndpointInputStreamEventIds.HdcpCapabilityFeedbackEventId: - if (inputStream == Tx.HdmiInputs[1]) HdmiIn1HdcpCapabilityFeedback.FireUpdate(); - if (inputStream == Tx.HdmiInputs[2]) HdmiIn2HdcpCapabilityFeedback.FireUpdate(); - HdcpStateFeedback.FireUpdate(); - break; - case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: - if (inputStream == Tx.HdmiInputs[1]) Hdmi1VideoSyncFeedback.FireUpdate(); - if (inputStream == Tx.HdmiInputs[2]) Hdmi2VideoSyncFeedback.FireUpdate(); - break; - } + public override bool CustomActivate() + { + // Link up all of these damned events to the various RoutingPorts via a helper handler + Tx.HdmiInputs[1].InputStreamChange += (o, a) => FowardInputStreamChange(HdmiIn1, a.EventId); + Tx.HdmiInputs[1].VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn1, a.EventId); + + Tx.HdmiInputs[2].InputStreamChange += (o, a) => FowardInputStreamChange(HdmiIn2, a.EventId); + Tx.HdmiInputs[2].VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn2, a.EventId); + + // Base does register and sets up comm monitoring. + return base.CustomActivate(); + } + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + var joinMap = GetDmTxJoinMap(joinStart, joinMapKey); + + if (Hdmi1VideoSyncFeedback != null) + { + Hdmi1VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input1VideoSyncStatus.JoinNumber]); + } + if (Hdmi2VideoSyncFeedback != null) + { + Hdmi2VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input2VideoSyncStatus.JoinNumber]); + } + + LinkDmTxToApi(this, trilist, joinMap, bridge); + } + + public void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type) + { + Debug.Console(2, this, "Executing Numeric Switch to input {0}.", input); + + switch (type) + { + case eRoutingSignalType.Video: + switch (input) + { + case 0: + { + ExecuteSwitch(eVst.Auto, null, type); + break; + } + case 1: + { + ExecuteSwitch(HdmiIn1.Selector, null, type); + break; + } + case 2: + { + ExecuteSwitch(HdmiIn2.Selector, null, type); + break; + } + case 3: + { + ExecuteSwitch(eVst.AllDisabled, null, type); + break; + } + } + break; + case eRoutingSignalType.Audio: + switch (input) + { + case 0: + { + ExecuteSwitch(eAst.Auto, null, type); + break; + } + case 1: + { + ExecuteSwitch(eAst.Hdmi1, null, type); + break; + } + case 2: + { + ExecuteSwitch(eAst.Hdmi2, null, type); + break; + } + case 3: + { + ExecuteSwitch(eAst.AllDisabled, null, type); + break; + } + } + break; + } + } + + public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) + { + if ((signalType | eRoutingSignalType.Video) == eRoutingSignalType.Video) + Tx.VideoSource = (eVst)inputSelector; + if ((signalType | eRoutingSignalType.Audio) == eRoutingSignalType.Audio) + Tx.AudioSource = (eAst)inputSelector; + } + + void InputStreamChangeEvent(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) + { + Debug.Console(2, "{0} event {1} stream {2}", this.Tx.ToString(), inputStream.ToString(), args.EventId.ToString()); + + switch (args.EventId) + { + case EndpointInputStreamEventIds.HdcpSupportOffFeedbackEventId: + case EndpointInputStreamEventIds.HdcpSupportOnFeedbackEventId: + case EndpointInputStreamEventIds.HdcpCapabilityFeedbackEventId: + if (inputStream == Tx.HdmiInputs[1]) HdmiIn1HdcpCapabilityFeedback.FireUpdate(); + if (inputStream == Tx.HdmiInputs[2]) HdmiIn2HdcpCapabilityFeedback.FireUpdate(); + HdcpStateFeedback.FireUpdate(); + break; + case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: + if (inputStream == Tx.HdmiInputs[1]) Hdmi1VideoSyncFeedback.FireUpdate(); + if (inputStream == Tx.HdmiInputs[2]) Hdmi2VideoSyncFeedback.FireUpdate(); + break; + } } void Tx_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) @@ -361,62 +356,62 @@ namespace PepperDash.Essentials.DM OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localInputAudioPort, eRoutingSignalType.Audio)); break; } - } - - /// - /// Relays the input stream change to the appropriate RoutingInputPort. - /// - void FowardInputStreamChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) - { - if (eventId != EndpointInputStreamEventIds.SyncDetectedFeedbackEventId) - { - return; - } - inputPort.VideoStatus.VideoSyncFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoSyncFeedback.FireUpdate(); - } - - /// - /// Relays the VideoAttributes change to a RoutingInputPort - /// - void ForwardVideoAttributeChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) - { - //// LOCATION: Crestron.SimplSharpPro.DM.VideoAttributeEventIds - //Debug.Console(2, this, "VideoAttributes_AttributeChange event id={0} from {1}", - // args.EventId, (sender as VideoAttributesEnhanced).Owner.GetType()); - switch (eventId) - { - case VideoAttributeEventIds.HdcpActiveFeedbackEventId: - inputPort.VideoStatus.HdcpActiveFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.HdcpActiveFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.HdcpStateFeedbackEventId: - inputPort.VideoStatus.HdcpStateFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.HdcpStateFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.HorizontalResolutionFeedbackEventId: - case VideoAttributeEventIds.VerticalResolutionFeedbackEventId: - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.FramesPerSecondFeedbackEventId: - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); - break; - } - } - - - - - #region IIROutputPorts Members - public CrestronCollection IROutputPorts { get { return Tx.IROutputPorts; } } - public int NumberOfIROutputPorts { get { return Tx.NumberOfIROutputPorts; } } - #endregion - - #region IComPorts Members - public CrestronCollection ComPorts { get { return Tx.ComPorts; } } - public int NumberOfComPorts { get { return Tx.NumberOfComPorts; } } - #endregion - } + } + + /// + /// Relays the input stream change to the appropriate RoutingInputPort. + /// + void FowardInputStreamChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) + { + if (eventId != EndpointInputStreamEventIds.SyncDetectedFeedbackEventId) + { + return; + } + inputPort.VideoStatus.VideoSyncFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.VideoSyncFeedback.FireUpdate(); + } + + /// + /// Relays the VideoAttributes change to a RoutingInputPort + /// + void ForwardVideoAttributeChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) + { + //// LOCATION: Crestron.SimplSharpPro.DM.VideoAttributeEventIds + //Debug.Console(2, this, "VideoAttributes_AttributeChange event id={0} from {1}", + // args.EventId, (sender as VideoAttributesEnhanced).Owner.GetType()); + switch (eventId) + { + case VideoAttributeEventIds.HdcpActiveFeedbackEventId: + inputPort.VideoStatus.HdcpActiveFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.HdcpActiveFeedback.FireUpdate(); + break; + case VideoAttributeEventIds.HdcpStateFeedbackEventId: + inputPort.VideoStatus.HdcpStateFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.HdcpStateFeedback.FireUpdate(); + break; + case VideoAttributeEventIds.HorizontalResolutionFeedbackEventId: + case VideoAttributeEventIds.VerticalResolutionFeedbackEventId: + inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); + break; + case VideoAttributeEventIds.FramesPerSecondFeedbackEventId: + inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); + break; + } + } + + + + + #region IIROutputPorts Members + public CrestronCollection IROutputPorts { get { return Tx.IROutputPorts; } } + public int NumberOfIROutputPorts { get { return Tx.NumberOfIROutputPorts; } } + #endregion + + #region IComPorts Members + public CrestronCollection ComPorts { get { return Tx.ComPorts; } } + public int NumberOfComPorts { get { return Tx.NumberOfComPorts; } } + #endregion + } } \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k302CController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k302CController.cs index c03a2291..0a5532bf 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k302CController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4k302CController.cs @@ -17,22 +17,22 @@ using PepperDash.Essentials.DM.Config; namespace PepperDash.Essentials.DM { - using eVst = Crestron.SimplSharpPro.DeviceSupport.eX02VideoSourceType; + using eVst = Crestron.SimplSharpPro.DeviceSupport.eX02VideoSourceType; using eAst = Crestron.SimplSharpPro.DeviceSupport.eX02AudioSourceType; [Description("Wrapper class for DM-TX-4K-302-C")] - public class DmTx4k302CController : DmTxControllerBase, ITxRoutingWithFeedback, IHasFeedback, - IIROutputPorts, IComPorts, IHasFreeRun, IVgaBrightnessContrastControls - { - public DmTx4k302C Tx { get; private set; } + public class DmTx4k302CController : DmTxControllerBase, ITxRoutingWithFeedback, IHasFeedback, + IIROutputPorts, IComPorts, IHasFreeRun, IVgaBrightnessContrastControls + { + public DmTx4k302C Tx { get; private set; } - public RoutingInputPortWithVideoStatuses HdmiIn1 { get; private set; } - public RoutingInputPortWithVideoStatuses HdmiIn2 { get; private set; } - public RoutingInputPortWithVideoStatuses VgaIn { get; private set; } - public RoutingOutputPort DmOut { get; private set; } - public RoutingOutputPort HdmiLoopOut { get; private set; } + public RoutingInputPortWithVideoStatuses HdmiIn1 { get; private set; } + public RoutingInputPortWithVideoStatuses HdmiIn2 { get; private set; } + public RoutingInputPortWithVideoStatuses VgaIn { get; private set; } + public RoutingOutputPort DmOut { get; private set; } + public RoutingOutputPort HdmiLoopOut { get; private set; } - public override StringFeedback ActiveVideoInputFeedback { get; protected set; } + public override StringFeedback ActiveVideoInputFeedback { get; protected set; } public IntFeedback VideoSourceNumericFeedback { get; protected set; } public IntFeedback AudioSourceNumericFeedback { get; protected set; } public IntFeedback HdmiIn1HdcpCapabilityFeedback { get; protected set; } @@ -60,78 +60,78 @@ namespace PepperDash.Essentials.DM } - /// - /// Helps get the "real" inputs, including when in Auto - /// - public Crestron.SimplSharpPro.DeviceSupport.eX02VideoSourceType ActualActiveVideoInput - { - get - { - if (Tx.VideoSourceFeedback != eVst.Auto) - return Tx.VideoSourceFeedback; - else // auto - { - if (Tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue) - return eVst.Hdmi1; - else if (Tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue) - return eVst.Hdmi2; - else if (Tx.VgaInput.SyncDetectedFeedback.BoolValue) - return eVst.Vga; - else - return eVst.AllDisabled; - } - } - } - public RoutingPortCollection InputPorts - { - get - { - return new RoutingPortCollection + /// + /// Helps get the "real" inputs, including when in Auto + /// + public Crestron.SimplSharpPro.DeviceSupport.eX02VideoSourceType ActualActiveVideoInput + { + get + { + if (Tx.VideoSourceFeedback != eVst.Auto) + return Tx.VideoSourceFeedback; + else // auto + { + if (Tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue) + return eVst.Hdmi1; + else if (Tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue) + return eVst.Hdmi2; + else if (Tx.VgaInput.SyncDetectedFeedback.BoolValue) + return eVst.Vga; + else + return eVst.AllDisabled; + } + } + } + public RoutingPortCollection InputPorts + { + get + { + return new RoutingPortCollection { HdmiIn1, HdmiIn2, VgaIn, AnyVideoInput }; - } - } - public RoutingPortCollection OutputPorts - { - get - { - return new RoutingPortCollection { DmOut, HdmiLoopOut }; - } - } + } + } + public RoutingPortCollection OutputPorts + { + get + { + return new RoutingPortCollection { DmOut, HdmiLoopOut }; + } + } public DmTx4k302CController(string key, string name, DmTx4k302C tx, bool preventRegistration) - : base(key, name, tx) - { - Tx = tx; + : base(key, name, tx) + { + Tx = tx; PreventRegistration = preventRegistration; - HdmiIn1 = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn1, + HdmiIn1 = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn1, eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.Hdmi1, this, - VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInputs[1])) - { - FeedbackMatchObject = eVst.Hdmi1 - }; - HdmiIn2 = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn2, + VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInputs[1])) + { + FeedbackMatchObject = eVst.Hdmi1 + }; + HdmiIn2 = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn2, eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.Hdmi2, this, - VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInputs[2])) + VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInputs[2])) { FeedbackMatchObject = eVst.Hdmi2 }; - - VgaIn = new RoutingInputPortWithVideoStatuses(DmPortName.VgaIn, - eRoutingSignalType.Video, eRoutingPortConnectionType.Vga, eVst.Vga, this, - VideoStatusHelper.GetVgaInputStatusFuncs(tx.VgaInput)) + + VgaIn = new RoutingInputPortWithVideoStatuses(DmPortName.VgaIn, + eRoutingSignalType.Video, eRoutingPortConnectionType.Vga, eVst.Vga, this, + VideoStatusHelper.GetVgaInputStatusFuncs(tx.VgaInput)) { FeedbackMatchObject = eVst.Vga }; - ActiveVideoInputFeedback = new StringFeedback("ActiveVideoInput", - () => ActualActiveVideoInput.ToString()); + ActiveVideoInputFeedback = new StringFeedback("ActiveVideoInput", + () => ActualActiveVideoInput.ToString()); - Tx.HdmiInputs[1].InputStreamChange += InputStreamChangeEvent; + Tx.HdmiInputs[1].InputStreamChange += InputStreamChangeEvent; Tx.HdmiInputs[2].InputStreamChange += InputStreamChangeEvent; Tx.VgaInput.InputStreamChange += VgaInputOnInputStreamChange; Tx.BaseEvent += Tx_BaseEvent; @@ -145,15 +145,10 @@ namespace PepperDash.Essentials.DM HdmiIn2HdcpCapabilityFeedback = new IntFeedback("HdmiIn2HdcpCapability", () => (int)tx.HdmiInputs[2].HdcpCapabilityFeedback); - HdcpStateFeedback = - new IntFeedback( - () => - tx.HdmiInputs[1].HdcpCapabilityFeedback > tx.HdmiInputs[2].HdcpCapabilityFeedback - ? (int)tx.HdmiInputs[1].HdcpCapabilityFeedback - : (int)tx.HdmiInputs[2].HdcpCapabilityFeedback); - HdcpSupportCapability = eHdcpCapabilityType.Hdcp2_2Support; + HdcpStateFeedback = new IntFeedback(() => (int)HdcpSupportCapability); + Hdmi1VideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue); Hdmi2VideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue); @@ -168,46 +163,46 @@ namespace PepperDash.Essentials.DM tx.VgaInput.VideoControls.ControlChange += new Crestron.SimplSharpPro.DeviceSupport.GenericEventHandler(VideoControls_ControlChange); - var combinedFuncs = new VideoStatusFuncsWrapper - { - HdcpActiveFeedbackFunc = () => - (ActualActiveVideoInput == eVst.Hdmi1 - && tx.HdmiInputs[1].VideoAttributes.HdcpActiveFeedback.BoolValue) - || (ActualActiveVideoInput == eVst.Hdmi2 - && tx.HdmiInputs[2].VideoAttributes.HdcpActiveFeedback.BoolValue), + var combinedFuncs = new VideoStatusFuncsWrapper + { + HdcpActiveFeedbackFunc = () => + (ActualActiveVideoInput == eVst.Hdmi1 + && tx.HdmiInputs[1].VideoAttributes.HdcpActiveFeedback.BoolValue) + || (ActualActiveVideoInput == eVst.Hdmi2 + && tx.HdmiInputs[2].VideoAttributes.HdcpActiveFeedback.BoolValue), - HdcpStateFeedbackFunc = () => - { - if (ActualActiveVideoInput == eVst.Hdmi1) - return tx.HdmiInputs[1].VideoAttributes.HdcpStateFeedback.ToString(); - return ActualActiveVideoInput == eVst.Hdmi2 ? tx.HdmiInputs[2].VideoAttributes.HdcpStateFeedback.ToString() : ""; - }, + HdcpStateFeedbackFunc = () => + { + if (ActualActiveVideoInput == eVst.Hdmi1) + return tx.HdmiInputs[1].VideoAttributes.HdcpStateFeedback.ToString(); + return ActualActiveVideoInput == eVst.Hdmi2 ? tx.HdmiInputs[2].VideoAttributes.HdcpStateFeedback.ToString() : ""; + }, - VideoResolutionFeedbackFunc = () => - { - if (ActualActiveVideoInput == eVst.Hdmi1) - return tx.HdmiInputs[1].VideoAttributes.GetVideoResolutionString(); - if (ActualActiveVideoInput == eVst.Hdmi2) - return tx.HdmiInputs[2].VideoAttributes.GetVideoResolutionString(); - return ActualActiveVideoInput == eVst.Vga ? tx.VgaInput.VideoAttributes.GetVideoResolutionString() : ""; - }, - VideoSyncFeedbackFunc = () => - (ActualActiveVideoInput == eVst.Hdmi1 - && tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue) - || (ActualActiveVideoInput == eVst.Hdmi2 - && tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue) - || (ActualActiveVideoInput == eVst.Vga - && tx.VgaInput.SyncDetectedFeedback.BoolValue) - - }; + VideoResolutionFeedbackFunc = () => + { + if (ActualActiveVideoInput == eVst.Hdmi1) + return tx.HdmiInputs[1].VideoAttributes.GetVideoResolutionString(); + if (ActualActiveVideoInput == eVst.Hdmi2) + return tx.HdmiInputs[2].VideoAttributes.GetVideoResolutionString(); + return ActualActiveVideoInput == eVst.Vga ? tx.VgaInput.VideoAttributes.GetVideoResolutionString() : ""; + }, + VideoSyncFeedbackFunc = () => + (ActualActiveVideoInput == eVst.Hdmi1 + && tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue) + || (ActualActiveVideoInput == eVst.Hdmi2 + && tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue) + || (ActualActiveVideoInput == eVst.Vga + && tx.VgaInput.SyncDetectedFeedback.BoolValue) - AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn, - eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.None, 0, this, combinedFuncs); + }; - DmOut = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.DmCat, null, this); - HdmiLoopOut = new RoutingOutputPort(DmPortName.HdmiLoopOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, null, this); + AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn, + eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.None, 0, this, combinedFuncs); + + DmOut = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.DmCat, null, this); + HdmiLoopOut = new RoutingOutputPort(DmPortName.HdmiLoopOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Hdmi, null, this); AddToFeedbackList(ActiveVideoInputFeedback, VideoSourceNumericFeedback, AudioSourceNumericFeedback, @@ -221,7 +216,7 @@ namespace PepperDash.Essentials.DM HdmiIn2.Port = Tx.HdmiInputs[2]; HdmiLoopOut.Port = Tx.HdmiOutput; DmOut.Port = Tx.DmOutput; - } + } void VgaInputOnInputStreamChange(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) { @@ -254,21 +249,21 @@ namespace PepperDash.Essentials.DM - public override bool CustomActivate() - { - // Link up all of these damned events to the various RoutingPorts via a helper handler - Tx.HdmiInputs[1].InputStreamChange += (o, a) => FowardInputStreamChange(HdmiIn1, a.EventId); - Tx.HdmiInputs[1].VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn1, a.EventId); + public override bool CustomActivate() + { + // Link up all of these damned events to the various RoutingPorts via a helper handler + Tx.HdmiInputs[1].InputStreamChange += (o, a) => FowardInputStreamChange(HdmiIn1, a.EventId); + Tx.HdmiInputs[1].VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn1, a.EventId); - Tx.HdmiInputs[2].InputStreamChange += (o, a) => FowardInputStreamChange(HdmiIn2, a.EventId); - Tx.HdmiInputs[2].VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn2, a.EventId); + Tx.HdmiInputs[2].InputStreamChange += (o, a) => FowardInputStreamChange(HdmiIn2, a.EventId); + Tx.HdmiInputs[2].VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn2, a.EventId); - Tx.VgaInput.InputStreamChange += (o, a) => FowardInputStreamChange(VgaIn, a.EventId); - Tx.VgaInput.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(VgaIn, a.EventId); + Tx.VgaInput.InputStreamChange += (o, a) => FowardInputStreamChange(VgaIn, a.EventId); + Tx.VgaInput.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(VgaIn, a.EventId); - // Base does register and sets up comm monitoring. - return base.CustomActivate(); - } + // Base does register and sets up comm monitoring. + return base.CustomActivate(); + } public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) { @@ -329,60 +324,60 @@ namespace PepperDash.Essentials.DM switch (input) { case 0: - { - ExecuteSwitch(eVst.Auto, null, type); - break; - } + { + ExecuteSwitch(eVst.Auto, null, type); + break; + } case 1: - { - ExecuteSwitch(HdmiIn1.Selector, null, type); - break; - } + { + ExecuteSwitch(HdmiIn1.Selector, null, type); + break; + } case 2: - { - ExecuteSwitch(HdmiIn2.Selector, null, type); - break; - } + { + ExecuteSwitch(HdmiIn2.Selector, null, type); + break; + } case 3: - { - ExecuteSwitch(VgaIn.Selector, null, type); - break; - } + { + ExecuteSwitch(VgaIn.Selector, null, type); + break; + } case 4: - { - ExecuteSwitch(eVst.AllDisabled, null, type); - break; - } + { + ExecuteSwitch(eVst.AllDisabled, null, type); + break; + } } break; case eRoutingSignalType.Audio: switch (input) { case 0: - { - ExecuteSwitch(eAst.Auto, null, type); - break; - } + { + ExecuteSwitch(eAst.Auto, null, type); + break; + } case 1: - { - ExecuteSwitch(eAst.Hdmi1, null, type); - break; - } + { + ExecuteSwitch(eAst.Hdmi1, null, type); + break; + } case 2: - { - ExecuteSwitch(eAst.Hdmi2, null, type); - break; - } + { + ExecuteSwitch(eAst.Hdmi2, null, type); + break; + } case 3: - { - ExecuteSwitch(eAst.AudioIn, null, type); - break; - } + { + ExecuteSwitch(eAst.AudioIn, null, type); + break; + } case 4: - { - ExecuteSwitch(eAst.AllDisabled, null, type); - break; - } + { + ExecuteSwitch(eAst.AllDisabled, null, type); + break; + } } break; } @@ -453,54 +448,54 @@ namespace PepperDash.Essentials.DM } /// - /// Relays the input stream change to the appropriate RoutingInputPort. - /// - void FowardInputStreamChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) - { + /// Relays the input stream change to the appropriate RoutingInputPort. + /// + void FowardInputStreamChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) + { if (eventId != EndpointInputStreamEventIds.SyncDetectedFeedbackEventId) return; inputPort.VideoStatus.VideoSyncFeedback.FireUpdate(); AnyVideoInput.VideoStatus.VideoSyncFeedback.FireUpdate(); - } - - /// - /// Relays the VideoAttributes change to a RoutingInputPort - /// - void ForwardVideoAttributeChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) - { - //// LOCATION: Crestron.SimplSharpPro.DM.VideoAttributeEventIds - //Debug.Console(2, this, "VideoAttributes_AttributeChange event id={0} from {1}", - // args.EventId, (sender as VideoAttributesEnhanced).Owner.GetType()); - switch (eventId) - { - case VideoAttributeEventIds.HdcpActiveFeedbackEventId: - inputPort.VideoStatus.HdcpActiveFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.HdcpActiveFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.HdcpStateFeedbackEventId: - inputPort.VideoStatus.HdcpStateFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.HdcpStateFeedback.FireUpdate(); - break; - case VideoAttributeEventIds.HorizontalResolutionFeedbackEventId: - case VideoAttributeEventIds.VerticalResolutionFeedbackEventId: - inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); - AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); - break; + } + + /// + /// Relays the VideoAttributes change to a RoutingInputPort + /// + void ForwardVideoAttributeChange(RoutingInputPortWithVideoStatuses inputPort, int eventId) + { + //// LOCATION: Crestron.SimplSharpPro.DM.VideoAttributeEventIds + //Debug.Console(2, this, "VideoAttributes_AttributeChange event id={0} from {1}", + // args.EventId, (sender as VideoAttributesEnhanced).Owner.GetType()); + switch (eventId) + { + case VideoAttributeEventIds.HdcpActiveFeedbackEventId: + inputPort.VideoStatus.HdcpActiveFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.HdcpActiveFeedback.FireUpdate(); + break; + case VideoAttributeEventIds.HdcpStateFeedbackEventId: + inputPort.VideoStatus.HdcpStateFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.HdcpStateFeedback.FireUpdate(); + break; + case VideoAttributeEventIds.HorizontalResolutionFeedbackEventId: + case VideoAttributeEventIds.VerticalResolutionFeedbackEventId: + inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); + AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); + break; case VideoAttributeEventIds.FramesPerSecondFeedbackEventId: inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate(); AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); break; - } - } + } + } - #region IIROutputPorts Members - public CrestronCollection IROutputPorts { get { return Tx.IROutputPorts; } } - public int NumberOfIROutputPorts { get { return Tx.NumberOfIROutputPorts; } } - #endregion + #region IIROutputPorts Members + public CrestronCollection IROutputPorts { get { return Tx.IROutputPorts; } } + public int NumberOfIROutputPorts { get { return Tx.NumberOfIROutputPorts; } } + #endregion - #region IComPorts Members - public CrestronCollection ComPorts { get { return Tx.ComPorts; } } - public int NumberOfComPorts { get { return Tx.NumberOfComPorts; } } - #endregion - } -} \ No newline at end of file + #region IComPorts Members + public CrestronCollection ComPorts { get { return Tx.ComPorts; } } + public int NumberOfComPorts { get { return Tx.NumberOfComPorts; } } + #endregion + } +} \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4kz302CController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4kz302CController.cs index 4d77a7fc..d96698f7 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4kz302CController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4kz302CController.cs @@ -133,9 +133,9 @@ namespace PepperDash.Essentials.DM HdmiIn2HdcpCapabilityFeedback = new IntFeedback("HdmiIn2HdcpCapability", () => (int)tx.HdmiInputs[2].HdcpCapabilityFeedback); DisplayPortInHdcpCapabilityFeedback = new IntFeedback("DisplayPortHdcpCapability", - () => (int) tx.DisplayPortInput.HdcpCapabilityFeedback); + () => (int)tx.DisplayPortInput.HdcpCapabilityFeedback); + - /* HdcpStateFeedback = new IntFeedback( @@ -146,13 +146,18 @@ namespace PepperDash.Essentials.DM */ //yeah this is gross - but it's the quickest way to do this... + /* HdcpStateFeedback = new IntFeedback(() => { var states = new[] {(int) tx.DisplayPortInput.HdcpCapabilityFeedback, (int) tx.HdmiInputs[1].HdcpCapabilityFeedback, (int) tx.HdmiInputs[2].HdcpCapabilityFeedback}; return states.Max(); }); + */ HdcpSupportCapability = eHdcpCapabilityType.Hdcp2_2Support; + // I feel like we have had this as a misnomer for so long, that it really needed to be fixed + // All we were doing was reporting the best of the current statuses - not the actual capability of the device. + HdcpStateFeedback = new IntFeedback(() => (int)HdcpSupportCapability); Hdmi1VideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue); @@ -269,41 +274,41 @@ namespace PepperDash.Essentials.DM { Debug.Console(2, this, "Executing Numeric Switch to input {0}.", input); - switch (input) - { - case 0: - { - ExecuteSwitch(eVst.Auto, null, type); - break; - } - case 1: - { - ExecuteSwitch(HdmiIn1.Selector, null, type); - break; - } - case 2: - { - ExecuteSwitch(HdmiIn2.Selector, null, type); - break; - } - case 3: - { - ExecuteSwitch(DisplayPortIn.Selector, null, type); - break; - } - case 4: - { - ExecuteSwitch(eVst.AllDisabled, null, type); - break; - } - default: + switch (input) + { + case 0: + { + ExecuteSwitch(eVst.Auto, null, type); + break; + } + case 1: + { + ExecuteSwitch(HdmiIn1.Selector, null, type); + break; + } + case 2: + { + ExecuteSwitch(HdmiIn2.Selector, null, type); + break; + } + case 3: + { + ExecuteSwitch(DisplayPortIn.Selector, null, type); + break; + } + case 4: + { + ExecuteSwitch(eVst.AllDisabled, null, type); + break; + } + default: { Debug.Console(2, this, "Unable to execute numeric switch to input {0}", input); break; } - } - + } + } @@ -424,7 +429,7 @@ namespace PepperDash.Essentials.DM AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate(); break; } - } + } #region IIROutputPorts Members public CrestronCollection IROutputPorts { get { return Tx.IROutputPorts; } } diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTxHelpers.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTxHelpers.cs index 771864d6..25f8c8d1 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTxHelpers.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTxHelpers.cs @@ -18,8 +18,8 @@ using PepperDash.Essentials.Core.Config; namespace PepperDash.Essentials.DM { - public class DmTxHelper - { + public class DmTxHelper + { public static BasicDmTxControllerBase GetDmTxForChassisWithoutIpId(string key, string name, string typeName, DMInput dmInput) { @@ -77,31 +77,31 @@ namespace PepperDash.Essentials.DM return null; } - /// - /// A factory method for various DmTxControllers - /// - /// - /// - /// - /// + /// + /// A factory method for various DmTxControllers + /// + /// + /// + /// + /// public static BasicDmTxControllerBase GetDmTxController(string key, string name, string typeName, DmTxPropertiesConfig props) - { - // switch on type name... later... + { + // switch on type name... later... - typeName = typeName.ToLower(); - //uint ipid = Convert.ToUInt16(props.Id, 16); - var ipid = props.Control.IpIdInt; - var pKey = props.ParentDeviceKey.ToLower(); + typeName = typeName.ToLower(); + //uint ipid = Convert.ToUInt16(props.Id, 16); + var ipid = props.Control.IpIdInt; + var pKey = props.ParentDeviceKey.ToLower(); if (pKey == "processor") - { - // Catch constructor failures, mainly dues to IPID - try - { - if(typeName.StartsWith("dmtx200")) + { + // Catch constructor failures, mainly dues to IPID + try + { + if (typeName.StartsWith("dmtx200")) return new DmTx200Controller(key, name, new DmTx200C2G(ipid, Global.ControlSystem), false); - if (typeName.StartsWith("dmtx201c")) - return new DmTx201CController(key, name, new DmTx201C(ipid, Global.ControlSystem), false); + if (typeName.StartsWith("dmtx201c")) + return new DmTx201CController(key, name, new DmTx201C(ipid, Global.ControlSystem), false); if (typeName.StartsWith("dmtx201s")) return new DmTx201SController(key, name, new DmTx201S(ipid, Global.ControlSystem), false); if (typeName.StartsWith("dmtx4k202")) @@ -112,36 +112,36 @@ namespace PepperDash.Essentials.DM return new DmTx4k302CController(key, name, new DmTx4k302C(ipid, Global.ControlSystem), false); if (typeName.StartsWith("dmtx4kz302")) return new DmTx4kz302CController(key, name, new DmTx4kz302C(ipid, Global.ControlSystem), false); - if (typeName.StartsWith("dmtx401")) + if (typeName.StartsWith("dmtx401")) return new DmTx401CController(key, name, new DmTx401C(ipid, Global.ControlSystem), false); - Debug.Console(0, "{1} WARNING: Cannot create DM-TX of type: '{0}'", typeName, key); - } - catch (Exception e) - { - Debug.Console(0, "[{0}] WARNING: Cannot create DM-TX device: {1}", key, e); - } + Debug.Console(0, "{1} WARNING: Cannot create DM-TX of type: '{0}'", typeName, key); + } + catch (Exception e) + { + Debug.Console(0, "[{0}] WARNING: Cannot create DM-TX device: {1}", key, e); + } return null; - } + } var parentDev = DeviceManager.GetDeviceForKey(pKey); DMInput dmInput; BasicDmTxControllerBase tx; bool useChassisForOfflineFeedback = false; - if (parentDev is DmChassisController) + if (parentDev is DmChassisController) { // Get the Crestron chassis and link stuff up - var switchDev = (parentDev as DmChassisController); - var chassis = switchDev.Chassis; + var switchDev = (parentDev as DmChassisController); + var chassis = switchDev.Chassis; //Check that the input is within range of this chassis' possible inputs - var num = props.ParentInputNumber; - if (num <= 0 || num > chassis.NumberOfInputs) - { - Debug.Console(0, "Cannot create DM device '{0}'. Input number '{1}' is out of range", - key, num); - return null; - } + var num = props.ParentInputNumber; + if (num <= 0 || num > chassis.NumberOfInputs) + { + Debug.Console(0, "Cannot create DM device '{0}'. Input number '{1}' is out of range", + key, num); + return null; + } switchDev.TxDictionary.Add(num, key); dmInput = chassis.Inputs[num]; @@ -164,7 +164,7 @@ namespace PepperDash.Essentials.DM if (typeName == "hdbasettx" || typeName == "dmtx4k100c1g") { useChassisForOfflineFeedback = true; - } + } } if (useChassisForOfflineFeedback) { @@ -180,7 +180,7 @@ namespace PepperDash.Essentials.DM return null; } } - else if(parentDev is DmpsRoutingController) + else if (parentDev is DmpsRoutingController) { // Get the DMPS chassis and link stuff up var dmpsDev = (parentDev as DmpsRoutingController); @@ -209,7 +209,7 @@ namespace PepperDash.Essentials.DM try { - if(Global.ControlSystemIsDmps4kType) + if (Global.ControlSystemIsDmps4kType) { tx = GetDmTxForChassisWithoutIpId(key, name, typeName, dmInput); useChassisForOfflineFeedback = true; @@ -220,7 +220,7 @@ namespace PepperDash.Essentials.DM if (typeName == "hdbasettx" || typeName == "dmtx4k100c1g") { useChassisForOfflineFeedback = true; - } + } } if (useChassisForOfflineFeedback) { @@ -234,16 +234,16 @@ namespace PepperDash.Essentials.DM { Debug.Console(0, "[{0}] WARNING: Cannot create DM-TX device for dmps: {1}", key, e); return null; - } + } } else { - Debug.Console(0, "Cannot create DM device '{0}'. '{1}' is not a processor, DM Chassis or DMPS.", key, pKey); - return null; - } - } - } + Debug.Console(0, "Cannot create DM device '{0}'. '{1}' is not a processor, DM Chassis or DMPS.", key, pKey); + return null; + } + } + } public abstract class BasicDmTxControllerBase : CrestronGenericBridgeableBaseDevice { @@ -254,21 +254,21 @@ namespace PepperDash.Essentials.DM } } - /// - /// - /// + /// + /// + /// [Description("Wrapper class for all DM-TX variants")] - public abstract class DmTxControllerBase : BasicDmTxControllerBase - { + public abstract class DmTxControllerBase : BasicDmTxControllerBase + { public virtual void SetPortHdcpCapability(eHdcpCapabilityType hdcpMode, uint port) { } public virtual eHdcpCapabilityType HdcpSupportCapability { get; protected set; } public abstract StringFeedback ActiveVideoInputFeedback { get; protected set; } public RoutingInputPortWithVideoStatuses AnyVideoInput { get; protected set; } public IntFeedback HdcpStateFeedback { get; protected set; } - protected DmTxControllerBase(string key, string name, EndpointTransmitterBase hardware) - : base(key, name, hardware) - { + protected DmTxControllerBase(string key, string name, EndpointTransmitterBase hardware) + : base(key, name, hardware) + { AddToFeedbackList(ActiveVideoInputFeedback); IsOnline.OutputChange += (currentDevice, args) => @@ -279,11 +279,12 @@ namespace PepperDash.Essentials.DM feedback.FireUpdate(); } }; - } + } - protected DmTxControllerBase(string key, string name, DmHDBasedTEndPoint hardware) : base(key, name, hardware) - { - } + protected DmTxControllerBase(string key, string name, DmHDBasedTEndPoint hardware) + : base(key, name, hardware) + { + } protected DmTxControllerJoinMap GetDmTxJoinMap(uint joinStart, string joinMapKey) { @@ -297,8 +298,8 @@ namespace PepperDash.Essentials.DM return joinMap; } - protected void LinkDmTxToApi(DmTxControllerBase tx, BasicTriList trilist, DmTxControllerJoinMap joinMap, EiscApiAdvanced bridge) - { + protected void LinkDmTxToApi(DmTxControllerBase tx, BasicTriList trilist, DmTxControllerJoinMap joinMap, EiscApiAdvanced bridge) + { if (bridge != null) { bridge.AddJoinMap(Key, joinMap); @@ -308,7 +309,7 @@ namespace PepperDash.Essentials.DM Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); } - Debug.Console(1, tx, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + Debug.Console(1, tx, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); tx.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); tx.AnyVideoInput.VideoStatus.VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.VideoSyncStatus.JoinNumber]); @@ -411,9 +412,22 @@ namespace PepperDash.Essentials.DM SetHdcpCapabilityAction(hdcpTypeSimple, port, joinMap.Port3HdcpState.JoinNumber, trilist); } - } + + var hdcpInputPortCount = + (ushort) + txR.InputPorts.Where( + x => (x.Type == eRoutingSignalType.Video) || (x.Type == eRoutingSignalType.AudioVideo)) + .Where( + x => + (x.ConnectionType == eRoutingPortConnectionType.DmCat) || + (x.ConnectionType == eRoutingPortConnectionType.Hdmi) || + (x.ConnectionType == eRoutingPortConnectionType.DisplayPort)) + .ToList().Count(); + + trilist.SetUshort(joinMap.HdcpInputPortCount.JoinNumber, hdcpInputPortCount); + } var txFreeRun = tx as IHasFreeRun; @@ -462,20 +476,20 @@ namespace PepperDash.Essentials.DM } } - private void SetHdcpCapabilityAction(bool hdcpTypeSimple, EndpointDisplayPortInput port, uint join, - BasicTriList trilist) - { + private void SetHdcpCapabilityAction(bool hdcpTypeSimple, EndpointDisplayPortInput port, uint join, + BasicTriList trilist) + { - trilist.SetUShortSigAction(join, - s => - { - port.HdcpCapability = (eHdcpCapabilityType) s; - }); + trilist.SetUShortSigAction(join, + s => + { + port.HdcpCapability = (eHdcpCapabilityType)s; + }); - } + } - } + } public class DmTxControllerFactory : EssentialsDeviceFactory { 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 0135334e..068d39cf 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj +++ b/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj @@ -105,6 +105,7 @@ + From dfa55ab9f8d3706b3013d1e658367324f91ac3ca Mon Sep 17 00:00:00 2001 From: Trevor Payne Date: Fri, 14 Apr 2023 12:18:06 -0500 Subject: [PATCH 29/96] fix: update console responses to properly use explicit NewLine characters fix: Resolve #1084 --- PepperDashEssentials/ControlSystem.cs | 21 +++---- .../Bridges/BridgeBase.cs | 56 +++++++++---------- .../Devices/DeviceManager.cs | 28 +++++----- .../Factory/DeviceFactory.cs | 8 +-- .../Plugins/PluginLoader.cs | 5 +- 5 files changed, 59 insertions(+), 59 deletions(-) diff --git a/PepperDashEssentials/ControlSystem.cs b/PepperDashEssentials/ControlSystem.cs index 8f3be4e1..f24cb828 100644 --- a/PepperDashEssentials/ControlSystem.cs +++ b/PepperDashEssentials/ControlSystem.cs @@ -93,27 +93,28 @@ namespace PepperDash.Essentials CrestronConsole.AddNewConsoleCommand(s => { foreach (var tl in TieLineCollection.Default) - CrestronConsole.ConsoleCommandResponse(" {0}\r\n", tl); + CrestronConsole.ConsoleCommandResponse(" {0}{1}", tl, CrestronEnvironment.NewLine); }, "listtielines", "Prints out all tie lines", ConsoleAccessLevelEnum.AccessOperator); CrestronConsole.AddNewConsoleCommand(s => { CrestronConsole.ConsoleCommandResponse - ("Current running configuration. This is the merged system and template configuration"); + ("Current running configuration. This is the merged system and template configuration" + CrestronEnvironment.NewLine); CrestronConsole.ConsoleCommandResponse(Newtonsoft.Json.JsonConvert.SerializeObject (ConfigReader.ConfigObject, Newtonsoft.Json.Formatting.Indented)); }, "showconfig", "Shows the current running merged config", ConsoleAccessLevelEnum.AccessOperator); - CrestronConsole.AddNewConsoleCommand(s => + CrestronConsole.AddNewConsoleCommand(s => CrestronConsole.ConsoleCommandResponse( - "This system can be found at the following URLs:\r\n" + - "System URL: {0}\r\n" + - "Template URL: {1}", - ConfigReader.ConfigObject.SystemUrl, - ConfigReader.ConfigObject.TemplateUrl), - "portalinfo", - "Shows portal URLS from configuration", + "This system can be found at the following URLs:{2}" + + "System URL: {0}{2}" + + "Template URL: {1}{2}", + ConfigReader.ConfigObject.SystemUrl, + ConfigReader.ConfigObject.TemplateUrl, + CrestronEnvironment.NewLine), + "portalinfo", + "Shows portal URLS from configuration", ConsoleAccessLevelEnum.AccessOperator); diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/BridgeBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/BridgeBase.cs index cb937235..5073d957 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/BridgeBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/BridgeBase.cs @@ -165,7 +165,7 @@ namespace PepperDash.Essentials.Core.Bridges Debug.Console(1, this, "Linking Device: '{0}'", device.Key); - if (!typeof (IBridgeAdvanced).IsAssignableFrom(device.GetType().GetCType())) + if (!typeof(IBridgeAdvanced).IsAssignableFrom(device.GetType().GetCType())) { Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "{0} is not compatible with this bridge type. Please use 'eiscapi' instead, or updae the device.", @@ -409,7 +409,7 @@ namespace PepperDash.Essentials.Core.Bridges public List Devices { get; set; } [JsonProperty("rooms")] - public List Rooms { get; set; } + public List Rooms { get; set; } public class ApiDevicePropertiesConfig @@ -442,7 +442,7 @@ namespace PepperDash.Essentials.Core.Bridges { public EiscApiAdvancedFactory() { - TypeNames = new List { "eiscapiadv", "eiscapiadvanced", "eiscapiadvancedserver", "eiscapiadvancedclient", "vceiscapiadv", "vceiscapiadvanced" }; + TypeNames = new List { "eiscapiadv", "eiscapiadvanced", "eiscapiadvancedserver", "eiscapiadvancedclient", "vceiscapiadv", "vceiscapiadvanced" }; } public override EssentialsDevice BuildDevice(DeviceConfig dc) @@ -457,34 +457,34 @@ namespace PepperDash.Essentials.Core.Bridges { case "eiscapiadv": case "eiscapiadvanced": - { - eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(controlProperties.IpIdInt, - controlProperties.TcpSshProperties.Address, Global.ControlSystem); - break; - } - case "eiscapiadvancedserver": - { - eisc = new EISCServer(controlProperties.IpIdInt, Global.ControlSystem); - break; - } - case "eiscapiadvancedclient": - { - eisc = new EISCClient(controlProperties.IpIdInt, controlProperties.TcpSshProperties.Address, Global.ControlSystem); - break; - } - case "vceiscapiadv": - case "vceiscapiadvanced": - { - if (string.IsNullOrEmpty(controlProperties.RoomId)) { - Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to build VC-4 EISC Client for device {0}. Room ID is missing or empty", dc.Key); - eisc = null; + eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(controlProperties.IpIdInt, + controlProperties.TcpSshProperties.Address, Global.ControlSystem); + break; + } + case "eiscapiadvancedserver": + { + eisc = new EISCServer(controlProperties.IpIdInt, Global.ControlSystem); + break; + } + case "eiscapiadvancedclient": + { + eisc = new EISCClient(controlProperties.IpIdInt, controlProperties.TcpSshProperties.Address, Global.ControlSystem); + break; + } + case "vceiscapiadv": + case "vceiscapiadvanced": + { + if (string.IsNullOrEmpty(controlProperties.RoomId)) + { + Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to build VC-4 EISC Client for device {0}. Room ID is missing or empty", dc.Key); + eisc = null; + break; + } + eisc = new VirtualControlEISCClient(controlProperties.IpIdInt, controlProperties.RoomId, + Global.ControlSystem); break; } - eisc = new VirtualControlEISCClient(controlProperties.IpIdInt, controlProperties.RoomId, - Global.ControlSystem); - break; - } default: eisc = null; break; diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DeviceManager.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DeviceManager.cs index 65efd0b9..55237496 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DeviceManager.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/DeviceManager.cs @@ -379,28 +379,28 @@ namespace PepperDash.Essentials.Core /// Prints a list of routing inputs and outputs by device key. /// /// Device key from which to report data - public static void GetRoutingPorts(string s) - { - var device = GetDeviceForKey(s); + public static void GetRoutingPorts(string s) + { + var device = GetDeviceForKey(s); if (device == null) return; var inputPorts = ((device as IRoutingInputs) != null) ? (device as IRoutingInputs).InputPorts : null; var outputPorts = ((device as IRoutingOutputs) != null) ? (device as IRoutingOutputs).OutputPorts : null; - if (inputPorts != null) - { - CrestronConsole.ConsoleCommandResponse("Device {0} has {1} Input Ports:", s, inputPorts.Count); - foreach (var routingInputPort in inputPorts) - { - CrestronConsole.ConsoleCommandResponse("{0}", routingInputPort.Key); - } - } + if (inputPorts != null) + { + CrestronConsole.ConsoleCommandResponse("Device {0} has {1} Input Ports:{2}", s, inputPorts.Count, CrestronEnvironment.NewLine); + foreach (var routingInputPort in inputPorts) + { + CrestronConsole.ConsoleCommandResponse("{0}{1}", routingInputPort.Key, CrestronEnvironment.NewLine); + } + } if (outputPorts == null) return; - CrestronConsole.ConsoleCommandResponse("Device {0} has {1} Output Ports:", s, outputPorts.Count); + CrestronConsole.ConsoleCommandResponse("Device {0} has {1} Output Ports:{2}", s, outputPorts.Count, CrestronEnvironment.NewLine); foreach (var routingOutputPort in outputPorts) { - CrestronConsole.ConsoleCommandResponse("{0}", routingOutputPort.Key); + CrestronConsole.ConsoleCommandResponse("{0}{1}", routingOutputPort.Key, CrestronEnvironment.NewLine); } - } + } /// /// Attempts to set the debug level of a device diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/DeviceFactory.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/DeviceFactory.cs index 793ff34a..5948de2b 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/DeviceFactory.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Factory/DeviceFactory.cs @@ -175,8 +175,8 @@ namespace PepperDash.Essentials.Core /// public static void GetDeviceFactoryTypes(string filter) { - var types = !string.IsNullOrEmpty(filter) - ? FactoryMethods.Where(k => k.Key.Contains(filter)).ToDictionary(k => k.Key, k => k.Value) + var types = !string.IsNullOrEmpty(filter) + ? FactoryMethods.Where(k => k.Key.Contains(filter)).ToDictionary(k => k.Key, k => k.Value) : FactoryMethods; CrestronConsole.ConsoleCommandResponse("Device Types:"); @@ -186,12 +186,12 @@ namespace PepperDash.Essentials.Core var description = type.Value.Description; var cType = "Not Specified by Plugin"; - if(type.Value.CType != null) + if (type.Value.CType != null) { cType = type.Value.CType.FullName; } - CrestronConsole.ConsoleCommandResponse( + CrestronConsole.ConsoleCommandResponse( @"Type: '{0}' CType: '{1}' Description: {2}", type.Key, cType, description); diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/PluginLoader.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/PluginLoader.cs index f69d35d0..dcc492df 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/PluginLoader.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Plugins/PluginLoader.cs @@ -195,13 +195,12 @@ namespace PepperDash.Essentials public static void ReportAssemblyVersions(string command) { - CrestronConsole.ConsoleCommandResponse("Loaded Assemblies:"); + CrestronConsole.ConsoleCommandResponse("Loaded Assemblies:" + CrestronEnvironment.NewLine); foreach (var assembly in LoadedAssemblies) { - CrestronConsole.ConsoleCommandResponse("{0} Version: {1}", assembly.Name, assembly.Version); + CrestronConsole.ConsoleCommandResponse("{0} Version: {1}" + CrestronEnvironment.NewLine, assembly.Name, assembly.Version); } } - /// /// Moves any .dll assemblies not already loaded from the plugins folder to loadedPlugins folder /// From 9656269826fd604e0081c45b93399eb679ad0466 Mon Sep 17 00:00:00 2001 From: Trevor Payne Date: Mon, 17 Apr 2023 22:27:56 -0500 Subject: [PATCH 30/96] fix: resolve issue where displayport hdcp event not registered properly fix: resolve issue where feedback from Displayport HDCP capability was improperly named --- .../Transmitters/DmTx4kz302CController.cs | 44 ++++++------- .../Endpoints/Transmitters/DmTxHelpers.cs | 63 ++++++++++--------- 2 files changed, 58 insertions(+), 49 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4kz302CController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4kz302CController.cs index d96698f7..bd74bf5a 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4kz302CController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTx4kz302CController.cs @@ -121,7 +121,7 @@ namespace PepperDash.Essentials.DM Tx.HdmiInputs[1].InputStreamChange += InputStreamChangeEvent; Tx.HdmiInputs[2].InputStreamChange += InputStreamChangeEvent; - Tx.DisplayPortInput.InputStreamChange += DisplayPortInputStreamChange; + Tx.DisplayPortInput.InputStreamChange += InputStreamChangeEvent; Tx.BaseEvent += Tx_BaseEvent; Tx.OnlineStatusChange += Tx_OnlineStatusChange; @@ -131,8 +131,7 @@ namespace PepperDash.Essentials.DM HdmiIn1HdcpCapabilityFeedback = new IntFeedback("HdmiIn1HdcpCapability", () => (int)tx.HdmiInputs[1].HdcpCapabilityFeedback); HdmiIn2HdcpCapabilityFeedback = new IntFeedback("HdmiIn2HdcpCapability", () => (int)tx.HdmiInputs[2].HdcpCapabilityFeedback); - - DisplayPortInHdcpCapabilityFeedback = new IntFeedback("DisplayPortHdcpCapability", + DisplayPortInHdcpCapabilityFeedback = new IntFeedback("DisplayPortInHdcpCapability", () => (int)tx.DisplayPortInput.HdcpCapabilityFeedback); @@ -171,13 +170,19 @@ namespace PepperDash.Essentials.DM (ActualActiveVideoInput == eVst.Hdmi1 && tx.HdmiInputs[1].VideoAttributes.HdcpActiveFeedback.BoolValue) || (ActualActiveVideoInput == eVst.Hdmi2 - && tx.HdmiInputs[2].VideoAttributes.HdcpActiveFeedback.BoolValue), + && tx.HdmiInputs[2].VideoAttributes.HdcpActiveFeedback.BoolValue) + || (ActualActiveVideoInput == eVst.DisplayPort + && tx.DisplayPortInput.VideoAttributes.HdcpActiveFeedback.BoolValue), HdcpStateFeedbackFunc = () => { if (ActualActiveVideoInput == eVst.Hdmi1) - return tx.HdmiInputs[1].VideoAttributes.HdcpStateFeedback.ToString(); - return ActualActiveVideoInput == eVst.Hdmi2 ? tx.HdmiInputs[2].VideoAttributes.HdcpStateFeedback.ToString() : ""; + return tx.HdmiInputs[1].VideoAttributes.HdcpStateFeedback.ToString(); + if (ActualActiveVideoInput == eVst.Hdmi2) + return tx.HdmiInputs[2].VideoAttributes.HdcpStateFeedback.ToString(); + return ActualActiveVideoInput == eVst.DisplayPort + ? tx.DisplayPortInput.VideoAttributes.HdcpStateFeedback.ToString() + : ""; }, VideoResolutionFeedbackFunc = () => @@ -186,6 +191,8 @@ namespace PepperDash.Essentials.DM return tx.HdmiInputs[1].VideoAttributes.GetVideoResolutionString(); if (ActualActiveVideoInput == eVst.Hdmi2) return tx.HdmiInputs[2].VideoAttributes.GetVideoResolutionString(); + if (ActualActiveVideoInput == eVst.DisplayPort) + return tx.DisplayPortInput.VideoAttributes.GetVideoResolutionString(); return ActualActiveVideoInput == eVst.Vga ? tx.DisplayPortInput.VideoAttributes.GetVideoResolutionString() : ""; }, VideoSyncFeedbackFunc = () => @@ -193,6 +200,8 @@ namespace PepperDash.Essentials.DM && tx.HdmiInputs[1].SyncDetectedFeedback.BoolValue) || (ActualActiveVideoInput == eVst.Hdmi2 && tx.HdmiInputs[2].SyncDetectedFeedback.BoolValue) + || (ActualActiveVideoInput == eVst.DisplayPort + && tx.DisplayPortInput.SyncDetectedFeedback.BoolValue) || (ActualActiveVideoInput == eVst.Vga && tx.DisplayPortInput.SyncDetectedFeedback.BoolValue) @@ -211,28 +220,15 @@ namespace PepperDash.Essentials.DM AnyVideoInput.VideoStatus.HasVideoStatusFeedback, AnyVideoInput.VideoStatus.HdcpActiveFeedback, AnyVideoInput.VideoStatus.HdcpStateFeedback, AnyVideoInput.VideoStatus.VideoResolutionFeedback, AnyVideoInput.VideoStatus.VideoSyncFeedback, HdmiIn1HdcpCapabilityFeedback, HdmiIn2HdcpCapabilityFeedback, - Hdmi1VideoSyncFeedback, Hdmi2VideoSyncFeedback, DisplayPortVideoSyncFeedback); + Hdmi1VideoSyncFeedback, Hdmi2VideoSyncFeedback, DisplayPortVideoSyncFeedback, DisplayPortInHdcpCapabilityFeedback); - // Set Ports for CEC HdmiIn1.Port = Tx.HdmiInputs[1]; HdmiIn2.Port = Tx.HdmiInputs[2]; + DisplayPortIn.Port = Tx.DisplayPortInput; HdmiLoopOut.Port = Tx.HdmiOutput; DmOut.Port = Tx.DmOutput; } - void DisplayPortInputStreamChange(EndpointInputStream inputStream, EndpointInputStreamEventArgs args) - { - Debug.Console(2, "{0} event {1} stream {2}", Tx.ToString(), inputStream.ToString(), args.EventId.ToString()); - - switch (args.EventId) - { - case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: - DisplayPortVideoSyncFeedback.FireUpdate(); - break; - } - } - - public override bool CustomActivate() { @@ -344,11 +340,17 @@ namespace PepperDash.Essentials.DM case EndpointInputStreamEventIds.HdcpCapabilityFeedbackEventId: if (inputStream == Tx.HdmiInputs[1]) HdmiIn1HdcpCapabilityFeedback.FireUpdate(); if (inputStream == Tx.HdmiInputs[2]) HdmiIn2HdcpCapabilityFeedback.FireUpdate(); + if (inputStream == Tx.DisplayPortInput) DisplayPortInHdcpCapabilityFeedback.FireUpdate(); + + Debug.Console(2, this, "DisplayPortHDCP Mode Trigger = {0}", + DisplayPortInHdcpCapabilityFeedback.IntValue); + HdcpStateFeedback.FireUpdate(); break; case EndpointInputStreamEventIds.SyncDetectedFeedbackEventId: if (inputStream == Tx.HdmiInputs[1]) Hdmi1VideoSyncFeedback.FireUpdate(); if (inputStream == Tx.HdmiInputs[2]) Hdmi2VideoSyncFeedback.FireUpdate(); + if (inputStream == Tx.DisplayPortInput) DisplayPortVideoSyncFeedback.FireUpdate(); break; } } diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTxHelpers.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTxHelpers.cs index 25f8c8d1..84007032 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTxHelpers.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTxHelpers.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using Crestron.SimplSharp; using Crestron.SimplSharpPro; using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DM; @@ -44,7 +42,7 @@ namespace PepperDash.Essentials.DM if (typeName.StartsWith("dmtx401")) return new DmTx401CController(key, name, new DmTx401C(dmInput), true); if (typeName.StartsWith("hdbasettx")) - new HDBaseTTxController(key, name, new HDTx3CB(dmInput)); + return new HDBaseTTxController(key, name, new HDTx3CB(dmInput)); return null; } @@ -83,6 +81,7 @@ namespace PepperDash.Essentials.DM /// /// /// + /// /// public static BasicDmTxControllerBase GetDmTxController(string key, string name, string typeName, DmTxPropertiesConfig props) { @@ -180,7 +179,7 @@ namespace PepperDash.Essentials.DM return null; } } - else if (parentDev is DmpsRoutingController) + if (parentDev is DmpsRoutingController) { // Get the DMPS chassis and link stuff up var dmpsDev = (parentDev as DmpsRoutingController); @@ -237,11 +236,8 @@ namespace PepperDash.Essentials.DM } } - else - { - Debug.Console(0, "Cannot create DM device '{0}'. '{1}' is not a processor, DM Chassis or DMPS.", key, pKey); - return null; - } + Debug.Console(0, "Cannot create DM device '{0}'. '{1}' is not a processor, DM Chassis or DMPS.", key, pKey); + return null; } } @@ -336,8 +332,6 @@ namespace PepperDash.Essentials.DM txR.VideoSourceNumericFeedback.LinkInputSig(trilist.UShortInput[joinMap.VideoInput.JoinNumber]); txR.AudioSourceNumericFeedback.LinkInputSig(trilist.UShortInput[joinMap.AudioInput.JoinNumber]); - trilist.UShortInput[joinMap.HdcpSupportCapability.JoinNumber].UShortValue = (ushort)tx.HdcpSupportCapability; - if (txR.InputPorts[DmPortName.HdmiIn] != null) { var inputPort = txR.InputPorts[DmPortName.HdmiIn]; @@ -384,7 +378,7 @@ namespace PepperDash.Essentials.DM { var intFeedback = tx.Feedbacks["HdmiIn2HdcpCapability"] as IntFeedback; if (intFeedback != null) - intFeedback.LinkInputSig(trilist.UShortInput[joinMap.Port1HdcpState.JoinNumber]); + intFeedback.LinkInputSig(trilist.UShortInput[joinMap.Port2HdcpState.JoinNumber]); } if (inputPort.ConnectionType == eRoutingPortConnectionType.Hdmi && inputPort.Port != null) @@ -401,16 +395,17 @@ namespace PepperDash.Essentials.DM if (tx.Feedbacks["DisplayPortInHdcpCapability"] != null) { + var intFeedback = tx.Feedbacks["DisplayPortInHdcpCapability"] as IntFeedback; if (intFeedback != null) + intFeedback.LinkInputSig(trilist.UShortInput[joinMap.Port3HdcpState.JoinNumber]); - } - if (inputPort.ConnectionType == eRoutingPortConnectionType.Hdmi && inputPort.Port != null) - { - var port = inputPort.Port as EndpointDisplayPortInput; - - SetHdcpCapabilityAction(hdcpTypeSimple, port, joinMap.Port3HdcpState.JoinNumber, trilist); + if (inputPort.ConnectionType == eRoutingPortConnectionType.DisplayPort && inputPort.Port != null) + { + var port = inputPort.Port as EndpointDisplayPortInput; + SetHdcpCapabilityAction(port, joinMap.Port3HdcpState.JoinNumber, trilist); + } } } @@ -467,7 +462,7 @@ namespace PepperDash.Essentials.DM }); } else - { + { trilist.SetUShortSigAction(join, s => { @@ -476,17 +471,15 @@ namespace PepperDash.Essentials.DM } } - private void SetHdcpCapabilityAction(bool hdcpTypeSimple, EndpointDisplayPortInput port, uint join, + private void SetHdcpCapabilityAction(EndpointDisplayPortInput port, uint join, BasicTriList trilist) { - - trilist.SetUShortSigAction(join, s => { - port.HdcpCapability = (eHdcpCapabilityType)s; + Debug.Console(0, this, "Trying to set HDCP to {0} on port {1}", s, port.ToString()); + port.HdcpCapability = (eHdcpCapabilityType) s; }); - } } @@ -495,8 +488,22 @@ namespace PepperDash.Essentials.DM { public DmTxControllerFactory() { - TypeNames = new List() { "dmtx200c", "dmtx201c", "dmtx201s", "dmtx4k100c", "dmtx4k202c", "dmtx4kz202c", "dmtx4k302c", "dmtx4kz302c", - "dmtx401c", "dmtx401s", "dmtx4k100c1g", "dmtx4kz100c1g", "hdbasettx" }; + TypeNames = new List + { + "dmtx200c", + "dmtx201c", + "dmtx201s", + "dmtx4k100c", + "dmtx4k202c", + "dmtx4kz202c", + "dmtx4k302c", + "dmtx4kz302c", + "dmtx401c", + "dmtx401s", + "dmtx4k100c1g", + "dmtx4kz100c1g", + "hdbasettx" + }; } public override EssentialsDevice BuildDevice(DeviceConfig dc) @@ -506,8 +513,8 @@ namespace PepperDash.Essentials.DM Debug.Console(1, "Factory Attempting to create new DM-TX Device"); var props = JsonConvert.DeserializeObject - (dc.Properties.ToString()); - return PepperDash.Essentials.DM.DmTxHelper.GetDmTxController(dc.Key, dc.Name, type, props); + (dc.Properties.ToString()); + return DmTxHelper.GetDmTxController(dc.Key, dc.Name, type, props); } } From 898dab1d9a2499872d2960c27d4323afbae46475 Mon Sep 17 00:00:00 2001 From: Trevor Payne Date: Thu, 20 Apr 2023 12:21:45 -0500 Subject: [PATCH 31/96] feature: add several interfaces for battery status on devices refactor: mark existing PDU interfaces in PepperDash_Essentials_Core.Devices as obsolete refactor: replicate existing PDU interfaces in PepperDash.Essentials.Core --- .../Devices/PduInterfaces.cs | 5 +- .../Devices/PowerInterfaces.cs | 87 +++++++++++++++++++ .../PepperDash_Essentials_Core.csproj | 1 + 3 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PowerInterfaces.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PduInterfaces.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PduInterfaces.cs index 0f3b3fbf..94aa71ac 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PduInterfaces.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PduInterfaces.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using Crestron.SimplSharp; using PepperDash.Core; using PepperDash.Essentials.Core; @@ -8,6 +9,7 @@ namespace PepperDash_Essentials_Core.Devices /// /// Interface for any device that is able to control it'spower and has a configurable reboot time /// + [Obsolete("PepperDash_Essentials_Core.Devices is Deprecated - use PepperDash.Essentials.Core")] public interface IHasPowerCycle : IKeyName, IHasPowerControlWithFeedback { /// @@ -24,6 +26,7 @@ namespace PepperDash_Essentials_Core.Devices /// /// Interface for any device that contains a collection of IHasPowerReboot Devices /// + [Obsolete("PepperDash_Essentials_Core.Devices is Deprecated - use PepperDash.Essentials.Core")] public interface IHasControlledPowerOutlets : IKeyName { /// diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PowerInterfaces.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PowerInterfaces.cs new file mode 100644 index 00000000..bbb9460b --- /dev/null +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PowerInterfaces.cs @@ -0,0 +1,87 @@ +using Crestron.SimplSharp; +using PepperDash.Core; + +namespace PepperDash.Essentials.Core +{ + /// + /// Interface for any device that has a battery that can be monitored + /// + public interface IHasBatteryStats : IKeyName + { + int BatteryPercentage { get; } + int BatteryCautionThresholdPercentage { get; } + int BatteryWarningThresholdPercentage { get; } + BoolFeedback BatteryIsWarningFeedback { get; } + BoolFeedback BatteryIsCautionFeedback { get; } + BoolFeedback BatteryIsOkFeedback { get; } + IntFeedback BatteryPercentageFeedback { get; } + } + + /// + /// Interface for any device that has a battery that can be monitored and the ability to charge and discharge + /// + public interface IHasBatteryCharging : IHasBatteryStats + { + BoolFeedback BatteryIsCharging { get; } + } + + /// + /// Interface for any device that has multiple batteries that can be monitored + /// + public interface IHasBatteries : IKeyName + { + ReadOnlyDictionary Batteries { get; } + } + + public interface IHasBatteryStatsExtended : IHasBatteryStats + { + int InputVoltage { get; } + int OutputVoltage { get; } + int InptuCurrent { get; } + int OutputCurrent { get; } + + IntFeedback InputVoltageFeedback { get; } + IntFeedback OutputVoltageFeedback { get; } + IntFeedback InputCurrentFeedback { get; } + IntFeedback OutputCurrentFeedback { get; } + } + + /// + /// Interface for any device that is able to control its power, has a configurable reboot time, and has batteries that can be monitored + /// + public interface IHasPowerCycleWithBatteries : IHasPowerCycle + { + + } + + /// + /// Interface for any device that is able to control it's power and has a configurable reboot time + /// + public interface IHasPowerCycle : IKeyName, IHasPowerControlWithFeedback + { + /// + /// Delay between power off and power on for reboot + /// + int PowerCycleTimeMs { get; } + + /// + /// Reboot outlet + /// + void PowerCycle(); + } + + /// + /// Interface for any device that contains a collection of IHasPowerReboot Devices + /// + public interface IHasControlledPowerOutlets : IKeyName + { + /// + /// Collection of IPduOutlets + /// + ReadOnlyDictionary PduOutlets { get; } + + } + + + +} \ 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 e0859077..7930f49e 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj @@ -200,6 +200,7 @@ + From 7c7f0878983c45b7b4c226bd3e3951bd281b9a41 Mon Sep 17 00:00:00 2001 From: Trevor Payne Date: Thu, 20 Apr 2023 12:29:34 -0500 Subject: [PATCH 32/96] feature: added additional parameters to IHasPowerCycleWithBatteries --- .../PepperDashEssentialsBase/Devices/PowerInterfaces.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PowerInterfaces.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PowerInterfaces.cs index bbb9460b..06cb9ddb 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PowerInterfaces.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PowerInterfaces.cs @@ -49,7 +49,7 @@ namespace PepperDash.Essentials.Core /// /// Interface for any device that is able to control its power, has a configurable reboot time, and has batteries that can be monitored /// - public interface IHasPowerCycleWithBatteries : IHasPowerCycle + public interface IHasPowerCycleWithBatteries : IHasPowerCycle, IHasBatteryStats { } From 7f916d1d2feebc30f14a176c882677ab2d939ffe Mon Sep 17 00:00:00 2001 From: Trevor Payne Date: Thu, 20 Apr 2023 12:31:50 -0500 Subject: [PATCH 33/96] refactor: change IHasPowerCycleWithBatteries to IHasPowerCycleWithBattery for clarity --- .../PepperDashEssentialsBase/Devices/PowerInterfaces.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PowerInterfaces.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PowerInterfaces.cs index 06cb9ddb..1fc6672a 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PowerInterfaces.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/PowerInterfaces.cs @@ -49,7 +49,7 @@ namespace PepperDash.Essentials.Core /// /// Interface for any device that is able to control its power, has a configurable reboot time, and has batteries that can be monitored /// - public interface IHasPowerCycleWithBatteries : IHasPowerCycle, IHasBatteryStats + public interface IHasPowerCycleWithBattery : IHasPowerCycle, IHasBatteryStats { } From 6ddbdd90c7b9ebc503044b176156e1c48461bba6 Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Wed, 26 Apr 2023 13:32:18 -0600 Subject: [PATCH 34/96] feat: add new interface and update Chassis controllers --- .../Essentials_DM/Chassis/DmBladeChassisController.cs | 2 +- .../Essentials_DM/Chassis/DmChassisController.cs | 2 +- .../Essentials DM/Essentials_DM/IDmSwitch.cs | 9 ++++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmBladeChassisController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmBladeChassisController.cs index 412dee6b..3898201d 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmBladeChassisController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmBladeChassisController.cs @@ -22,7 +22,7 @@ namespace PepperDash.Essentials.DM /// Builds a controller for basic DM-RMCs with Com and IR ports and no control functions /// /// - public class DmBladeChassisController : CrestronGenericBridgeableBaseDevice, IDmSwitch, IRoutingNumericWithFeedback + public class DmBladeChassisController : CrestronGenericBridgeableBaseDevice, IDmSwitchWithEndpointOnlineFeedback, IRoutingNumericWithFeedback { private const string NonePortKey = "inputCard0--None"; diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs index 60ef9d69..ca8b3dd8 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/DmChassisController.cs @@ -23,7 +23,7 @@ namespace PepperDash.Essentials.DM /// /// [Description("Wrapper class for all DM-MD chassis variants from 8x8 to 32x32")] - public class DmChassisController : CrestronGenericBridgeableBaseDevice, IDmSwitch, IRoutingNumericWithFeedback + public class DmChassisController : CrestronGenericBridgeableBaseDevice, IDmSwitchWithEndpointOnlineFeedback, IRoutingNumericWithFeedback { private const string NonePortKey = "inputCard0--None"; public DMChassisPropertiesConfig PropertiesConfig { get; set; } diff --git a/essentials-framework/Essentials DM/Essentials_DM/IDmSwitch.cs b/essentials-framework/Essentials DM/Essentials_DM/IDmSwitch.cs index fdbe4956..cf3f963e 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/IDmSwitch.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/IDmSwitch.cs @@ -16,10 +16,17 @@ using PepperDash.Essentials.Core; using PepperDash.Essentials.DM.Config; namespace PepperDash.Essentials.DM { - public interface IDmSwitch { + public interface IDmSwitch + { Switch Chassis { get; } Dictionary TxDictionary { get; } Dictionary RxDictionary { get; } } + + public interface IDmSwitchWithEndpointOnlineFeedback : IDmSwitch + { + Dictionary InputEndpointOnlineFeedbacks { get; } + Dictionary OutputEndpointOnlineFeedbacks { get; } + } } \ No newline at end of file From 0df315426b1f0064cfa0dcfe19a4822b13e73059 Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Wed, 26 Apr 2023 13:32:49 -0600 Subject: [PATCH 35/96] fix: use new interface for parentDev The GetDmRmcController & GetDmTxController methods were previously ignoring the `DmBladeChassisController` type. This was causing transmitters connected to a DM blade chassis to not be built, --- .../Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs | 4 ++-- .../Essentials_DM/Endpoints/Transmitters/DmTxHelpers.cs | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs index bb8aec65..57f522fd 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs @@ -436,9 +436,9 @@ namespace PepperDash.Essentials.DM } return rx; } - else if (parentDev is DmChassisController) + else if (parentDev is IDmSwitchWithEndpointOnlineFeedback) { - var controller = parentDev as DmChassisController; + var controller = parentDev as IDmSwitchWithEndpointOnlineFeedback; var chassis = controller.Chassis; var num = props.ParentOutputNumber; Debug.Console(1, "Creating DM Chassis device '{0}'. Output number '{1}'.", key, num); diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTxHelpers.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTxHelpers.cs index 84007032..140f0f45 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTxHelpers.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Transmitters/DmTxHelpers.cs @@ -127,10 +127,10 @@ namespace PepperDash.Essentials.DM BasicDmTxControllerBase tx; bool useChassisForOfflineFeedback = false; - if (parentDev is DmChassisController) + if (parentDev is IDmSwitchWithEndpointOnlineFeedback) { // Get the Crestron chassis and link stuff up - var switchDev = (parentDev as DmChassisController); + var switchDev = (parentDev as IDmSwitchWithEndpointOnlineFeedback); var chassis = switchDev.Chassis; //Check that the input is within range of this chassis' possible inputs @@ -179,6 +179,7 @@ namespace PepperDash.Essentials.DM return null; } } + if (parentDev is DmpsRoutingController) { // Get the DMPS chassis and link stuff up From c0d78e897828d9f6680fb95b85456cfe302c91f1 Mon Sep 17 00:00:00 2001 From: Jason T Alborough Date: Thu, 27 Apr 2023 13:59:36 -0400 Subject: [PATCH 36/96] Delete add-issues-to-project.yml --- .github/workflows/add-issues-to-project.yml | 37 --------------------- 1 file changed, 37 deletions(-) delete mode 100644 .github/workflows/add-issues-to-project.yml diff --git a/.github/workflows/add-issues-to-project.yml b/.github/workflows/add-issues-to-project.yml deleted file mode 100644 index 8811c0cc..00000000 --- a/.github/workflows/add-issues-to-project.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: Add bugs to bugs project - -on: - issues: - types: - - opened - - labeled - -jobs: - check-secret: - runs-on: ubuntu-latest - outputs: - my-key: ${{ steps.my-key.outputs.defined }} - steps: - - id: my-key - if: "${{ env.MY_KEY != '' }}" - run: echo "::set-output name=defined::true" - env: - MY_KEY: ${{ secrets.PROJECT_URL }} - throw-error: - name: Check - runs-on: ubuntu-latest - needs: [check-secret] - if: needs.check-secret.outputs.my-key != 'true' - steps: - - run: echo "The Project URL Repo Secret is empty" - add-to-project: - name: Add issue to project - runs-on: ubuntu-latest - needs: [check-secret] - if: needs.check-secret.outputs.my-key == 'true' - steps: - - uses: actions/add-to-project@main - with: - project-url: ${{ secrets.PROJECT_URL }} - github-token: ${{ secrets.GH_PROJECTS_PASSWORD }} - From 0f3b0580f052650474a330362143f014ba639c45 Mon Sep 17 00:00:00 2001 From: mhengeli Date: Wed, 7 Jun 2023 09:45:25 -0400 Subject: [PATCH 37/96] feat: add videomute on/off for rmc scaler c --- .../PepperDashEssentials.csproj | 2 +- .../JoinMaps/DmRmcControllerJoinMap.cs | 12 ++++++ .../PepperDash_Essentials_Core.csproj | 2 +- .../Receivers/DmRmc4KScalerCController.cs | 43 ++++++++++++++++++- .../Endpoints/Receivers/DmRmcHelper.cs | 21 ++++++++- .../PepperDash_Essentials_DM.csproj | 5 ++- .../Essentials Devices Common.csproj | 2 +- 7 files changed, 79 insertions(+), 8 deletions(-) diff --git a/PepperDashEssentials/PepperDashEssentials.csproj b/PepperDashEssentials/PepperDashEssentials.csproj index e4a0cff6..f406d8be 100644 --- a/PepperDashEssentials/PepperDashEssentials.csproj +++ b/PepperDashEssentials/PepperDashEssentials.csproj @@ -73,7 +73,7 @@ False - ..\packages\PepperDashCore\lib\net35\PepperDash_Core.dll + ..\..\PepperDashCore\Pepperdash Core\Pepperdash Core\bin\PepperDash_Core.dll False diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmRmcControllerJoinMap.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmRmcControllerJoinMap.cs index cff5bffe..c0e7141f 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmRmcControllerJoinMap.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/DmRmcControllerJoinMap.cs @@ -8,6 +8,18 @@ namespace PepperDash.Essentials.Core.Bridges public JoinDataComplete IsOnline = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, new JoinMetadata { Description = "DM RMC Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + [JoinName("VideoMuteOn")] + public JoinDataComplete VideoMuteOn = new JoinDataComplete(new JoinData { JoinNumber = 3, JoinSpan = 1 }, + new JoinMetadata { Description = "DM RMC Mute Video", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("VideoMuteOff")] + public JoinDataComplete VideoMuteOff = new JoinDataComplete(new JoinData { JoinNumber = 4, JoinSpan = 1 }, + new JoinMetadata { Description = "DM RMC UnMute Video", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital }); + + [JoinName("VideoMuteToggle")] + public JoinDataComplete VideoMuteToggle = new JoinDataComplete(new JoinData { JoinNumber = 5, JoinSpan = 1 }, + new JoinMetadata { Description = "DM RMC Mute Video Toggle", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("CurrentOutputResolution")] public JoinDataComplete CurrentOutputResolution = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, new JoinMetadata { Description = "DM RMC Current Output Resolution", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial }); diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj index e0859077..e87ac31d 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj @@ -85,7 +85,7 @@ False - ..\..\..\packages\PepperDashCore\lib\net35\PepperDash_Core.dll + ..\..\..\..\PepperDashCore\Pepperdash Core\Pepperdash Core\bin\PepperDash_Core.dll False diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4KScalerCController.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4KScalerCController.cs index 79069430..79debd63 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4KScalerCController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmc4KScalerCController.cs @@ -7,6 +7,7 @@ using PepperDash.Core; using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Bridges; using PepperDash_Essentials_DM; +using System.Collections.Generic; namespace PepperDash.Essentials.DM { @@ -16,7 +17,7 @@ namespace PepperDash.Essentials.DM /// [Description("Wrapper Class for DM-RMC-4K-SCALER-C")] public class DmRmc4kScalerCController : DmRmcControllerBase, IRoutingInputsOutputs, IBasicVolumeWithFeedback, - IIROutputPorts, IComPorts, ICec, IRelayPorts, IHasDmInHdcp + IIROutputPorts, IComPorts, ICec, IRelayPorts, IHasDmInHdcp, IBasicVideoMuteWithFeedback { private readonly DmRmc4kScalerC _rmc; @@ -68,6 +69,7 @@ namespace PepperDash.Essentials.DM AddToFeedbackList(DmInHdcpStateFeedback); + VideoMuteIsOn = new BoolFeedback("HdmiOutputVideoMuteIsOn", () => _rmc.HdmiOutput.BlankEnabledFeedback.BoolValue); _rmc.HdmiOutput.OutputStreamChange += HdmiOutput_OutputStreamChange; _rmc.HdmiOutput.ConnectedDevice.DeviceInformationChange += ConnectedDevice_DeviceInformationChange; @@ -83,6 +85,10 @@ namespace PepperDash.Essentials.DM { VideoOutputResolutionFeedback.FireUpdate(); } + else if (args.EventId == EndpointOutputStreamEventIds.BlankEnabledFeedbackEventId) + { + VideoMuteIsOn.FireUpdate(); + } } void ConnectedDevice_DeviceInformationChange(ConnectedDeviceInformation connectedDevice, ConnectedDeviceEventArgs args) @@ -216,5 +222,40 @@ namespace PepperDash.Essentials.DM _rmc.DmInput.HdcpCapability = hdcpState; } + + #region IBasicVideoMuteWithFeedback Members + + public BoolFeedback VideoMuteIsOn + { + get; + private set; + } + + public void VideoMuteOn() + { + Debug.Console(2, this, "Video Mute On"); + _rmc.HdmiOutput.BlankEnabled(); + } + + public void VideoMuteOff() + { + Debug.Console(2, this, "Video Mute Off"); + _rmc.HdmiOutput.BlankDisabled(); + } + + #endregion + + #region IBasicVideoMute Members + + public void VideoMuteToggle() + { + Debug.Console(2, this, "Video Mute Toggle"); + if (_rmc.HdmiOutput.BlankEnabledFeedback.BoolValue == true) + VideoMuteOff(); + else + VideoMuteOn(); + } + + #endregion } } \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs index 57f522fd..ef0c15a3 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs @@ -59,8 +59,13 @@ namespace PepperDash.Essentials.DM else { Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device."); - } + } + + LinkDmRmcToApi(rmc, trilist, joinMap); + } + protected void LinkDmRmcToApi(DmRmcControllerBase rmc, BasicTriList trilist, DmRmcControllerJoinMap joinMap) + { Debug.Console(1, rmc, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); @@ -137,7 +142,18 @@ namespace PepperDash.Essentials.DM trilist.UShortInput[joinMap.HdcpSupportCapability.JoinNumber].UShortValue = (ushort)hdcpCapability; - trilist.UShortInput[joinMap.HdcpInputPortCount.JoinNumber].UShortValue = (ushort)routing.InputPorts.Count; + trilist.UShortInput[joinMap.HdcpInputPortCount.JoinNumber].UShortValue = (ushort)routing.InputPorts.Count; + + var dmRmcScalerCBasicVideoMuteWithFeedback = rmc as IBasicVideoMuteWithFeedback; + + if (dmRmcScalerCBasicVideoMuteWithFeedback != null) + { + Debug.Console(1, this, "Device is IBasicVideoMuteWithFeedback, linking video mute"); + trilist.SetSigTrueAction(joinMap.VideoMuteToggle.JoinNumber, () => dmRmcScalerCBasicVideoMuteWithFeedback.VideoMuteToggle()); + trilist.SetSigTrueAction(joinMap.VideoMuteOn.JoinNumber, () => dmRmcScalerCBasicVideoMuteWithFeedback.VideoMuteOn()); + trilist.SetSigTrueAction(joinMap.VideoMuteOff.JoinNumber, () => dmRmcScalerCBasicVideoMuteWithFeedback.VideoMuteOff()); + dmRmcScalerCBasicVideoMuteWithFeedback.VideoMuteIsOn.LinkInputSig(trilist.BooleanInput[joinMap.VideoMuteOn.JoinNumber]); + } var routingWithFeedback = routing as IRmcRouting; if (routingWithFeedback == null) return; @@ -149,6 +165,7 @@ namespace PepperDash.Essentials.DM trilist.SetUShortSigAction(joinMap.AudioVideoSource.JoinNumber, a => routingWithFeedback.ExecuteNumericSwitch(a, 1, eRoutingSignalType.AudioVideo)); + } #region Implementation of IDeviceInfoProvider 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 068d39cf..85447e03 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj +++ b/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj @@ -59,9 +59,9 @@ ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.UI.dll - + False - ..\..\..\packages\PepperDashCore\lib\net35\PepperDash_Core.dll + ..\..\..\..\PepperDashCore\Pepperdash Core\Pepperdash Core\bin\PepperDash_Core.dll False @@ -153,6 +153,7 @@ + diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj index a1cc37f2..a59b663f 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj @@ -65,7 +65,7 @@ False - ..\..\..\packages\PepperDashCore\lib\net35\PepperDash_Core.dll + ..\..\..\..\PepperDashCore\Pepperdash Core\Pepperdash Core\bin\PepperDash_Core.dll False From 16ea7a88be4b8a5397d565d9061460960131ad07 Mon Sep 17 00:00:00 2001 From: mhengeli Date: Wed, 7 Jun 2023 12:22:03 -0400 Subject: [PATCH 38/96] fix: updated Core references --- PepperDashEssentials/PepperDashEssentials.csproj | 4 ++-- .../PepperDash_Essentials_Core.csproj | 4 ++-- .../Essentials_DM/PepperDash_Essentials_DM.csproj | 4 ++-- .../Essentials Devices Common.csproj | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/PepperDashEssentials/PepperDashEssentials.csproj b/PepperDashEssentials/PepperDashEssentials.csproj index f406d8be..05c20381 100644 --- a/PepperDashEssentials/PepperDashEssentials.csproj +++ b/PepperDashEssentials/PepperDashEssentials.csproj @@ -71,9 +71,9 @@ ..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.UI.dll - + False - ..\..\PepperDashCore\Pepperdash Core\Pepperdash Core\bin\PepperDash_Core.dll + ..\.packages\PepperDashCore\lib\net35\PepperDash_Core.dll False diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj index e87ac31d..db967390 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj @@ -83,9 +83,9 @@ ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.UI.dll - + False - ..\..\..\..\PepperDashCore\Pepperdash Core\Pepperdash Core\bin\PepperDash_Core.dll + ..\..\..\.packages\PepperDashCore\lib\net35\PepperDash_Core.dll False 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 85447e03..a089dccf 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj +++ b/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj @@ -59,9 +59,9 @@ ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.UI.dll - + False - ..\..\..\..\PepperDashCore\Pepperdash Core\Pepperdash Core\bin\PepperDash_Core.dll + ..\..\..\.packages\PepperDashCore\lib\net35\PepperDash_Core.dll False diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj index a59b663f..104026b0 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj @@ -63,9 +63,9 @@ ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.Lighting.dll - + False - ..\..\..\..\PepperDashCore\Pepperdash Core\Pepperdash Core\bin\PepperDash_Core.dll + ..\..\..\.packages\PepperDashCore\lib\net35\PepperDash_Core.dll False From 515ffd07f067735a36fb9623ecfb74d48d16d402 Mon Sep 17 00:00:00 2001 From: mhengeli Date: Wed, 7 Jun 2023 13:16:06 -0400 Subject: [PATCH 39/96] fix: added complimentary link for mute off. fix: Update references --- PepperDashEssentials/PepperDashEssentials.csproj | 2 +- .../PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj | 2 +- .../Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs | 1 + .../Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj | 2 +- .../Essentials Devices Common/Essentials Devices Common.csproj | 2 +- 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/PepperDashEssentials/PepperDashEssentials.csproj b/PepperDashEssentials/PepperDashEssentials.csproj index 05c20381..66a20f72 100644 --- a/PepperDashEssentials/PepperDashEssentials.csproj +++ b/PepperDashEssentials/PepperDashEssentials.csproj @@ -73,7 +73,7 @@ False - ..\.packages\PepperDashCore\lib\net35\PepperDash_Core.dll + ..\packages\PepperDashCore\lib\net35\PepperDash_Core.dll False diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj index db967390..ba59a085 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj @@ -85,7 +85,7 @@ False - ..\..\..\.packages\PepperDashCore\lib\net35\PepperDash_Core.dll + ..\..\..\packages\PepperDashCore\lib\net35\PepperDash_Core.dll False diff --git a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs index ef0c15a3..ee423436 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Endpoints/Receivers/DmRmcHelper.cs @@ -153,6 +153,7 @@ namespace PepperDash.Essentials.DM trilist.SetSigTrueAction(joinMap.VideoMuteOn.JoinNumber, () => dmRmcScalerCBasicVideoMuteWithFeedback.VideoMuteOn()); trilist.SetSigTrueAction(joinMap.VideoMuteOff.JoinNumber, () => dmRmcScalerCBasicVideoMuteWithFeedback.VideoMuteOff()); dmRmcScalerCBasicVideoMuteWithFeedback.VideoMuteIsOn.LinkInputSig(trilist.BooleanInput[joinMap.VideoMuteOn.JoinNumber]); + dmRmcScalerCBasicVideoMuteWithFeedback.VideoMuteIsOn.LinkComplementInputSig(trilist.BooleanInput[joinMap.VideoMuteOff.JoinNumber]); } var routingWithFeedback = routing as IRmcRouting; 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 a089dccf..adfddbe3 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj +++ b/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj @@ -61,7 +61,7 @@ False - ..\..\..\.packages\PepperDashCore\lib\net35\PepperDash_Core.dll + ..\..\..\packages\PepperDashCore\lib\net35\PepperDash_Core.dll False diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj index 104026b0..845b61ef 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj @@ -65,7 +65,7 @@ False - ..\..\..\.packages\PepperDashCore\lib\net35\PepperDash_Core.dll + ..\..\..\packages\PepperDashCore\lib\net35\PepperDash_Core.dll False From 43f06d216786701a10edfb152f6b459b1f6e8552 Mon Sep 17 00:00:00 2001 From: Trevor Payne Date: Fri, 16 Jun 2023 14:26:52 -0500 Subject: [PATCH 40/96] feature: Add USB-C as eRoutingPortConnectionType option --- .../PepperDashEssentialsBase/Routing/RoutingPort.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingPort.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingPort.cs index 79dd4eda..8dc8fc4e 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingPort.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingPort.cs @@ -42,7 +42,7 @@ namespace PepperDash.Essentials.Core public enum eRoutingPortConnectionType { None, BackplaneOnly, DisplayPort, Dvi, Hdmi, Rgb, Vga, LineAudio, DigitalAudio, Sdi, - Composite, Component, DmCat, DmMmFiber, DmSmFiber, Speaker, Streaming + Composite, Component, DmCat, DmMmFiber, DmSmFiber, Speaker, Streaming, UsbC } /// From 0ee6322684e62e1dec9b9d01a0eb0a4f3518e4e9 Mon Sep 17 00:00:00 2001 From: Trevor Payne Date: Fri, 16 Jun 2023 14:50:10 -0500 Subject: [PATCH 41/96] feature: Add USBCIn and Out Names for RoutingPortNames --- .../Routing/RoutingPortNames.cs | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingPortNames.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingPortNames.cs index 00e85191..beef0dae 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingPortNames.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingPortNames.cs @@ -199,5 +199,37 @@ namespace PepperDash.Essentials.Core.Routing /// MediaPlayer /// public const string MediaPlayer = "mediaPlayer"; - } + /// + /// UsbCIn + /// + public const string UsbCIn = "usbCIn"; + /// + /// UsbCIn1 + /// + public const string UsbCIn1 = "usbCIn1"; + /// + /// UsbCIn2 + /// + public const string UsbCIn2 = "usbCIn2"; + /// + /// UsbCIn3 + /// + public const string UsbCIn3 = "usbCIn3"; + /// + /// UsbCOut + /// + public const string UsbCOut = "usbCOut"; + /// + /// UsbCOut1 + /// + public const string UsbCOut1 = "usbCOut1"; + /// + /// UsbCOut2 + /// + public const string UsbCOut2 = "usbCOut2"; + /// + /// UsbCOut3 + /// + public const string UsbCOut3 = "usbCOut3"; + } } \ No newline at end of file From a04bfd1fcb172d20ef73fd31a08a3bb937fadada Mon Sep 17 00:00:00 2001 From: Trevor Payne Date: Fri, 16 Jun 2023 14:56:21 -0500 Subject: [PATCH 42/96] feature: Add HdBaseTIn and HdBaseTOut as RoutingPortNames --- .../PepperDashEssentialsBase/Routing/RoutingPortNames.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingPortNames.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingPortNames.cs index beef0dae..7029443b 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingPortNames.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingPortNames.cs @@ -231,5 +231,13 @@ namespace PepperDash.Essentials.Core.Routing /// UsbCOut3 /// public const string UsbCOut3 = "usbCOut3"; + /// + /// HdBaseTIn + /// + public const string HdBaseTIn = "hdBaseTIn"; + /// + /// HdBaseTOut + /// + public const string HdBaseTOut = "hdBaseTOut"; } } \ No newline at end of file From f4af1b6e7c853dc1df0e4f9d9319f3e64e190c8e Mon Sep 17 00:00:00 2001 From: Trevor Payne Date: Fri, 16 Jun 2023 14:57:48 -0500 Subject: [PATCH 43/96] feature: Add HdBaseT as a eRoutingPortConnectionType --- .../PepperDashEssentialsBase/Routing/RoutingPort.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingPort.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingPort.cs index 8dc8fc4e..ab64f15e 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingPort.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingPort.cs @@ -42,7 +42,7 @@ namespace PepperDash.Essentials.Core public enum eRoutingPortConnectionType { None, BackplaneOnly, DisplayPort, Dvi, Hdmi, Rgb, Vga, LineAudio, DigitalAudio, Sdi, - Composite, Component, DmCat, DmMmFiber, DmSmFiber, Speaker, Streaming, UsbC + Composite, Component, DmCat, DmMmFiber, DmSmFiber, Speaker, Streaming, UsbC, HdBaseT } /// From cab0b01a089f790c46509f0c0cd54a280b3ea93f Mon Sep 17 00:00:00 2001 From: jdevito Date: Tue, 27 Jun 2023 15:20:01 -0500 Subject: [PATCH 44/96] fix: updates systemMonitor class to append Essentials version number to the ProgramName that is passed across the bridge --- .../Monitoring/SystemMonitorController.cs | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Monitoring/SystemMonitorController.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Monitoring/SystemMonitorController.cs index 319a0a3c..8a7f379a 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Monitoring/SystemMonitorController.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Monitoring/SystemMonitorController.cs @@ -563,11 +563,11 @@ namespace PepperDash.Essentials.Core.Monitoring ProgramUnregisteredFeedback = new BoolFeedback(() => Program.RegistrationState == eProgramRegistrationState.Unregister); ProgramUnregisteredFeedback.FireUpdate(); - - ProgramNameFeedback = new StringFeedback(() => ProgramInfo.ProgramFile); + + ProgramNameFeedback = new StringFeedback(() => ProgramInfo.ProgramFile); + CrestronDataBaseVersionFeedback = new StringFeedback(() => ProgramInfo.CrestronDb); + EnvironmentVersionFeedback = new StringFeedback(() => ProgramInfo.Environment); ProgramCompileTimeFeedback = new StringFeedback(() => ProgramInfo.CompileTime); - CrestronDataBaseVersionFeedback = new StringFeedback(() => ProgramInfo.CrestronDb); - EnvironmentVersionFeedback = new StringFeedback(() => ProgramInfo.Environment); AggregatedProgramInfoFeedback = new StringFeedback(() => JsonConvert.SerializeObject(ProgramInfo)); GetProgramInfo(); @@ -620,9 +620,9 @@ namespace PepperDash.Essentials.Core.Monitoring // Assume no valid program info. Constructing a new object will wipe all properties ProgramInfo = new ProgramInfo(Program.Number) { - OperatingState = Program.OperatingState, + OperatingState = Program.OperatingState, RegistrationState = Program.RegistrationState - }; + }; UpdateFeedbacks(); @@ -639,13 +639,20 @@ namespace PepperDash.Essentials.Core.Monitoring if (ProgramInfo.ProgramFile.Contains(".dll")) { - // SSP Program + // SSP Program ProgramInfo.FriendlyName = ParseConsoleData(response, "Friendly Name", ": ", "\n"); ProgramInfo.ApplicationName = ParseConsoleData(response, "Application Name", ": ", "\n"); ProgramInfo.ProgramTool = ParseConsoleData(response, "Program Tool", ": ", "\n"); ProgramInfo.MinFirmwareVersion = ParseConsoleData(response, "Min Firmware Version", ": ", "\n"); ProgramInfo.PlugInVersion = ParseConsoleData(response, "PlugInVersion", ": ", "\n"); + + ProgramInfo.ProgramFile += string.Format(" {0}.{1}.{2}", + ProgramInfo.CompilerRevisionInfo.Major, + ProgramInfo.CompilerRevisionInfo.Minor, + ProgramInfo.CompilerRevisionInfo.Build); + + ProgramInfo.Environment = ProgramInfo.ProgramTool; } else if (ProgramInfo.ProgramFile.Contains(".smw")) { @@ -736,6 +743,15 @@ namespace PepperDash.Essentials.Core.Monitoring [JsonProperty("compilerRevision")] public string CompilerRevision { get; set; } + [JsonIgnore] + public Version CompilerRevisionInfo + { + get + { + return new Version(CompilerRevision); + } + } + [JsonProperty("compileTime")] public string CompileTime { get; set; } @@ -776,7 +792,7 @@ namespace PepperDash.Essentials.Core.Monitoring ProgramFile = ""; FriendlyName = ""; CompilerRevision = ""; - CompileTime = ""; + CompileTime = ""; Include4Dat = ""; SystemName = ""; From 3f6b2f05a28dab2bf0e394bf70d9c4d428cf1921 Mon Sep 17 00:00:00 2001 From: Trevor Payne Date: Tue, 4 Jul 2023 23:53:31 -0500 Subject: [PATCH 45/96] feature: Add Static Class to assist with getting network information about connected devices feature: Add overload to 'Contains' extension method to allow for some more verbose comparisons feature: Add 'TrimAll' string extension method to TrimStart and TrimEnd with an overload to set the character to trim docs: improve XML summary comments for string extensions --- .../Device Info/NetworkDeviceHelpers.cs | 218 ++++++++++++++++++ .../Extensions/StringExtensions.cs | 54 +++++ .../PepperDash_Essentials_Core.csproj | 1 + 3 files changed, 273 insertions(+) create mode 100644 essentials-framework/Essentials Core/PepperDashEssentialsBase/Device Info/NetworkDeviceHelpers.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Device Info/NetworkDeviceHelpers.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Device Info/NetworkDeviceHelpers.cs new file mode 100644 index 00000000..04e697c9 --- /dev/null +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Device Info/NetworkDeviceHelpers.cs @@ -0,0 +1,218 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using PepperDash.Core; +using Crestron.SimplSharp; +using PepperDash.Essentials.Core; + +namespace PepperDash.Essentials.Core.DeviceInfo +{ + public static class NetworkDeviceHelpers + { + /// + /// Event raised when ArpTable changes + /// + public static event ArpTableEventHandler ArpTableUpdated; + + /// + /// Delegate called by ArpTableUpdated + /// + /// contains the entire ARP table and a bool to note if there was an error in retrieving the data + public delegate void ArpTableEventHandler(ArpTableEventArgs args); + + private static readonly char NewLineSplitter = CrestronEnvironment.NewLine.ToCharArray().First(); + private static readonly string NewLine = CrestronEnvironment.NewLine; + + private static readonly CCriticalSection Lock = new CCriticalSection(); + + /// + /// Last resolved ARP table - it is recommended to refresh the arp before using this. + /// + public static List ArpTable { get; private set; } + + /// + /// Force recheck of ARP table + /// + public static void RefreshArp() + { + var error = false; + try + { + Lock.Enter(); + var consoleResponse = string.Empty; + if (!CrestronConsole.SendControlSystemCommand("showarptable", ref consoleResponse)) return; + if (string.IsNullOrEmpty(consoleResponse)) + { + error = true; + return; + } + ArpTable.Clear(); + + Debug.Console(2, "ConsoleResponse of 'showarptable' : {0}{1}", NewLine, consoleResponse); + + var myLines = + consoleResponse.Split(NewLineSplitter) + .ToList() + .Where(o => (o.Contains(':') && !o.Contains("Type", StringComparison.OrdinalIgnoreCase))) + .ToList(); + foreach (var line in myLines) + { + var item = line; + var seperator = item.Contains('\t') ? '\t' : ' '; + var dataPoints = item.Split(seperator); + if (dataPoints == null || dataPoints.Length < 2) continue; + var ipAddress = SanitizeIpAddress(dataPoints.First().TrimAll()); + var macAddress = dataPoints.Last(); + ArpTable.Add(new ArpEntry(ipAddress, macAddress)); + } + } + catch (Exception ex) + { + Debug.Console(0, "Exception in \"RefreshArp\" : {0}", ex.Message); + error = true; + } + finally + { + Lock.Leave(); + OnArpTableUpdated(new ArpTableEventArgs(ArpTable, error)); + } + } + + + private static void OnArpTableUpdated(ArpTableEventArgs args) + { + if (args == null) return; + var handler = ArpTableUpdated; + if (handler == null) return; + handler.Invoke(args); + } + + static NetworkDeviceHelpers() + { + ArpTable = new List(); + } + + /// + /// Removes leading zeros, leading whitespace, and trailing whitespace from an IPAddress string + /// + /// Ip Address to Santitize + /// Sanitized Ip Address + public static string SanitizeIpAddress(string ipAddressIn) + { + try + { + var ipAddress = IPAddress.Parse(ipAddressIn.TrimStart('0')); + return ipAddress.ToString(); + } + catch (Exception ex) + { + Debug.Console(0, "Unable to Santize Ip : {0}", ex.Message); + return ipAddressIn; + } + } + + /// + /// Resolves a hostname by IP Address using DNS + /// + /// IP Address to resolve from + /// Resolved Hostname - on failure to determine hostname, will return IP Address + public static string ResolveHostnameFromIp(string ipAddress) + { + try + { + var santitizedIp = SanitizeIpAddress(ipAddress); + var hostEntry = Dns.GetHostEntry(santitizedIp); + return hostEntry == null ? ipAddress : hostEntry.HostName; + } + catch (Exception ex) + { + Debug.Console(0, "Exception Resolving Hostname from IP Address : {0}", ex.Message); + return ipAddress; + } + } + + /// + /// Resolves an IP Address by hostname using DNS + /// + /// Hostname to resolve from + /// Resolved IP Address - on a failure to determine IP Address, will return hostname + public static string ResolveIpFromHostname(string hostName) + { + try + { + var hostEntry = Dns.GetHostEntry(hostName); + return hostEntry == null ? hostName : hostEntry.AddressList.First().ToString(); + } + catch (Exception ex) + { + Debug.Console(0, "Exception Resolving IP Address from Hostname : {0}", ex.Message); + return hostName; + } + } + + } + + /// + /// Object to hold data about an arp entry + /// + public class ArpEntry + { + public readonly IPAddress IpAddress; + public readonly string MacAddress; + + /// + /// Constructs new ArpEntry object + /// + /// string formatted as ipv4 address + /// mac address string - format is unimportant + public ArpEntry(string ipAddress, string macAddress) + { + if (string.IsNullOrEmpty(ipAddress)) + { + throw new ArgumentException("\"ipAddress\" cannot be null or empty"); + } + if (string.IsNullOrEmpty(macAddress)) + { + throw new ArgumentException("\"macAddress\" cannot be null or empty"); + } + IpAddress = IPAddress.Parse(ipAddress.TrimStart().TrimStart('0').TrimEnd()); + MacAddress = macAddress; + } + } + + /// + /// Arguments passed by the ArpTableUpdated event + /// + public class ArpTableEventArgs : EventArgs + { + /// + /// The retrieved ARP Table + /// + public readonly List ArpTable; + /// + /// True if there was a problem retrieving the ARP Table + /// + public readonly bool Error; + + /// + /// Constructor for ArpTableEventArgs + /// + /// The entirety of the retrieved ARP table + /// True of an error was encountered updating the ARP table + public ArpTableEventArgs(List arpTable, bool error) + { + ArpTable = arpTable; + Error = error; + } + + /// + /// Constructor for ArpTableEventArgs - assumes no error encountered in retrieving ARP Table + /// + /// The entirety of the retrieved ARP table + public ArpTableEventArgs(List arpTable) + { + ArpTable = arpTable; + Error = false; + } + } +} \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Extensions/StringExtensions.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Extensions/StringExtensions.cs index 39501387..7bf8d5a5 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Extensions/StringExtensions.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Extensions/StringExtensions.cs @@ -1,4 +1,5 @@ using System; +using System.ComponentModel; using System.Collections.Generic; using System.Linq; using System.Text; @@ -8,17 +9,70 @@ namespace PepperDash.Essentials.Core { public static class StringExtensions { + /// + /// Returns null if a string is empty, otherwise returns the string + /// + /// string input + /// null if the string is emtpy, otherwise returns the string public static string NullIfEmpty(this string s) { return string.IsNullOrEmpty(s) ? null : s; } + + /// + /// Returns null if a string is empty or made of only whitespace characters, otherwise returns the string + /// + /// string input + /// null if the string is wempty or made of only whitespace characters, otherwise returns the string public static string NullIfWhiteSpace(this string s) { return string.IsNullOrEmpty(s.Trim()) ? null : s; } + + /// + /// Returns a replacement string if the input string is empty or made of only whitespace characters, otherwise returns the input string + /// + /// input string + /// string to replace with if input string is empty or whitespace + /// returns newString if s is null, emtpy, or made of whitespace characters, otherwise returns s public static string ReplaceIfNullOrEmpty(this string s, string newString) { return string.IsNullOrEmpty(s) ? newString : s; } + + /// + /// Overload for Contains that allows setting an explicit String Comparison + /// + /// Source String + /// String to check in Source String + /// Comparison parameters + /// true of string contains "toCheck" + public static bool Contains(this string source, string toCheck, StringComparison comp) + { + if (string.IsNullOrEmpty(source)) return false; + return source.IndexOf(toCheck, comp) >= 0; + } + + /// + /// Performs TrimStart() and TrimEnd() on source string + /// + /// String to Trim + /// Trimmed String + public static string TrimAll(this string source) + { + return string.IsNullOrEmpty(source) ? string.Empty : source.TrimStart().TrimEnd(); + } + + /// + /// Performs TrimStart(chars char[]) and TrimEnd(chars char[]) on source string. + /// + /// String to Trim + /// Char Array to trim from string + /// Trimmed String + public static string TrimAll(this string source, char[] chars) + { + return string.IsNullOrEmpty(source) ? string.Empty : source.TrimStart(chars).TrimEnd(chars); + } + } } \ 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 7930f49e..aff99ea7 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj @@ -200,6 +200,7 @@ + From c3ba6d5c2851b65d7e874135601b494a867320a4 Mon Sep 17 00:00:00 2001 From: Trevor Payne Date: Wed, 12 Jul 2023 12:27:38 -0500 Subject: [PATCH 46/96] fix: fix issue where the customactivate for the base class was beig suppressed in airmedia controllers --- .../Essentials DM/Essentials_DM/AirMedia/AirMediaController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/AirMedia/AirMediaController.cs b/essentials-framework/Essentials DM/Essentials_DM/AirMedia/AirMediaController.cs index ff07a54b..b1fa3186 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/AirMedia/AirMediaController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/AirMedia/AirMediaController.cs @@ -129,7 +129,7 @@ namespace PepperDash.Essentials.DM.AirMedia else AirMedia.DisplayControl.DisableAutomaticRouting(); - return true; + return base.CustomActivate(); } public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) From f0ae0094dcc359ef1481f900cd42e18a722512bf Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Wed, 19 Jul 2023 09:50:48 -0600 Subject: [PATCH 47/96] Adds optional enable property to partition sensor config and defaults to enable --- .../GlsPartitionSensorController.cs | 36 +++++++++++++------ .../GlsPartitionSensorPropertiesConfig.cs | 5 ++- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PartitionSensor/GlsPartitionSensorController.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PartitionSensor/GlsPartitionSensorController.cs index 16b2f265..73f15cf2 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PartitionSensor/GlsPartitionSensorController.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PartitionSensor/GlsPartitionSensorController.cs @@ -85,18 +85,32 @@ namespace PepperDash.Essentials.Core { if (_partitionSensor.IsOnline == false) return; - Debug.Console(1, this, "Attempting to apply settings to sensor from config"); + // Default to enable + _partitionSensor.Enable.BoolValue = true; - if (PropertiesConfig.Sensitivity != null) - { - Debug.Console(1, this, "Sensitivity found, attempting to set value '{0}' from config", - PropertiesConfig.Sensitivity); - _partitionSensor.Sensitivity.UShortValue = (ushort) PropertiesConfig.Sensitivity; - } - else - { - Debug.Console(1, this, "Sensitivity null, no value specified in config"); - } + Debug.Console(1, this, "Attempting to apply settings to sensor from config"); + + if (PropertiesConfig.Sensitivity != null) + { + Debug.Console(1, this, "Sensitivity found, attempting to set value '{0}' from config", + PropertiesConfig.Sensitivity); + _partitionSensor.Sensitivity.UShortValue = (ushort)PropertiesConfig.Sensitivity; + } + else + { + Debug.Console(1, this, "Sensitivity null, no value specified in config"); + } + + if (PropertiesConfig.Enable != null) + { + Debug.Console(1, this, "Enable found, attempting to set value '{0}' from config", + PropertiesConfig.Enable); + _partitionSensor.Enable.BoolValue = (bool)PropertiesConfig.Enable; + } + else + { + Debug.Console(1, this, "Enable null, no value specified in config"); + } } diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PartitionSensor/GlsPartitionSensorPropertiesConfig.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PartitionSensor/GlsPartitionSensorPropertiesConfig.cs index 8a303662..c9f715b5 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PartitionSensor/GlsPartitionSensorPropertiesConfig.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PartitionSensor/GlsPartitionSensorPropertiesConfig.cs @@ -16,6 +16,9 @@ namespace PepperDash_Essentials_Core.PartitionSensor /// The sensitivity range shall be between 1(lowest) to 10 (highest). /// [JsonProperty("sensitivity")] - public ushort? Sensitivity { get; set; } + public ushort? Sensitivity { get; set; } + + [JsonProperty("enable")] + public bool? Enable { get; set; } } } \ No newline at end of file From a787be6ccc70f82acdeb1d63f38830a1830898f9 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Wed, 19 Jul 2023 15:28:24 -0600 Subject: [PATCH 48/96] Updates Vtc1 room types to allow for deactivation/activation --- .gitignore | 1 + .../Types/EssentialsCombinedHuddleVtc1Room.cs | 298 +++++++++++++----- .../Room/Types/EssentialsHuddleVtc1Room.cs | 296 ++++++++++------- 3 files changed, 399 insertions(+), 196 deletions(-) diff --git a/.gitignore b/.gitignore index 94b7d400..739a60ab 100644 --- a/.gitignore +++ b/.gitignore @@ -389,3 +389,4 @@ MigrationBackup/ # Fody - auto-generated XML schema FodyWeavers.xsd essentials-framework/Essentials Interfaces/PepperDash_Essentials_Interfaces/PepperDash_Essentials_Interfaces.csproj +.DS_Store diff --git a/PepperDashEssentials/Room/Types/EssentialsCombinedHuddleVtc1Room.cs b/PepperDashEssentials/Room/Types/EssentialsCombinedHuddleVtc1Room.cs index 50186d0b..3ed0946d 100644 --- a/PepperDashEssentials/Room/Types/EssentialsCombinedHuddleVtc1Room.cs +++ b/PepperDashEssentials/Room/Types/EssentialsCombinedHuddleVtc1Room.cs @@ -226,66 +226,66 @@ namespace PepperDash.Essentials } } - void Initialize() + public override void Initialize() { try { - if (DefaultAudioDevice is IBasicVolumeControls) - DefaultVolumeControls = DefaultAudioDevice as IBasicVolumeControls; - else if (DefaultAudioDevice is IHasVolumeDevice) - DefaultVolumeControls = (DefaultAudioDevice as IHasVolumeDevice).VolumeDevice; - CurrentVolumeControls = DefaultVolumeControls; + //if (DefaultAudioDevice is IBasicVolumeControls) + // DefaultVolumeControls = DefaultAudioDevice as IBasicVolumeControls; + //else if (DefaultAudioDevice is IHasVolumeDevice) + // DefaultVolumeControls = (DefaultAudioDevice as IHasVolumeDevice).VolumeDevice; + //CurrentVolumeControls = DefaultVolumeControls; - // Combines call feedback from both codecs if available - InCallFeedback = new BoolFeedback(() => - { - bool inAudioCall = false; - bool inVideoCall = false; + //// Combines call feedback from both codecs if available + //InCallFeedback = new BoolFeedback(() => + //{ + // bool inAudioCall = false; + // bool inVideoCall = false; - if (AudioCodec != null) - inAudioCall = AudioCodec.IsInCall; + // if (AudioCodec != null) + // inAudioCall = AudioCodec.IsInCall; - if (VideoCodec != null) - inVideoCall = VideoCodec.IsInCall; + // if (VideoCodec != null) + // inVideoCall = VideoCodec.IsInCall; - if (inAudioCall || inVideoCall) - return true; - else - return false; - }); + // if (inAudioCall || inVideoCall) + // return true; + // else + // return false; + //}); - SetupDisplays(); + //SetupDisplays(); - // Get Microphone Privacy object, if any MUST HAPPEN AFTER setting InCallFeedback - this.MicrophonePrivacy = EssentialsRoomConfigHelper.GetMicrophonePrivacy(PropertiesConfig, this); + //// Get Microphone Privacy object, if any MUST HAPPEN AFTER setting InCallFeedback + //this.MicrophonePrivacy = EssentialsRoomConfigHelper.GetMicrophonePrivacy(PropertiesConfig, this); - Debug.Console(2, this, "Microphone Privacy Config evaluated."); + //Debug.Console(2, this, "Microphone Privacy Config evaluated."); - // Get emergency object, if any - this.Emergency = EssentialsRoomConfigHelper.GetEmergency(PropertiesConfig, this); + //// Get emergency object, if any + //this.Emergency = EssentialsRoomConfigHelper.GetEmergency(PropertiesConfig, this); - Debug.Console(2, this, "Emergency Config evaluated."); + //Debug.Console(2, this, "Emergency Config evaluated."); - VideoCodec.CallStatusChange += (o, a) => this.InCallFeedback.FireUpdate(); - VideoCodec.IsReadyChange += (o, a) => { this.SetCodecExternalSources(); SetCodecBranding(); }; + //VideoCodec.CallStatusChange += (o, a) => this.InCallFeedback.FireUpdate(); + //VideoCodec.IsReadyChange += (o, a) => { this.SetCodecExternalSources(); SetCodecBranding(); }; - if (AudioCodec != null) - AudioCodec.CallStatusChange += (o, a) => this.InCallFeedback.FireUpdate(); + //if (AudioCodec != null) + // AudioCodec.CallStatusChange += (o, a) => this.InCallFeedback.FireUpdate(); - IsSharingFeedback = new BoolFeedback(() => VideoCodec.SharingContentIsOnFeedback.BoolValue); - VideoCodec.SharingContentIsOnFeedback.OutputChange += (o, a) => this.IsSharingFeedback.FireUpdate(); + //IsSharingFeedback = new BoolFeedback(() => VideoCodec.SharingContentIsOnFeedback.BoolValue); + //VideoCodec.SharingContentIsOnFeedback.OutputChange += (o, a) => this.IsSharingFeedback.FireUpdate(); - // link privacy to VC (for now?) - PrivacyModeIsOnFeedback = new BoolFeedback(() => VideoCodec.PrivacyModeIsOnFeedback.BoolValue); - VideoCodec.PrivacyModeIsOnFeedback.OutputChange += (o, a) => this.PrivacyModeIsOnFeedback.FireUpdate(); + //// link privacy to VC (for now?) + //PrivacyModeIsOnFeedback = new BoolFeedback(() => VideoCodec.PrivacyModeIsOnFeedback.BoolValue); + //VideoCodec.PrivacyModeIsOnFeedback.OutputChange += (o, a) => this.PrivacyModeIsOnFeedback.FireUpdate(); - CallTypeFeedback = new IntFeedback(() => 0); + //CallTypeFeedback = new IntFeedback(() => 0); SetSourceListKey(); - EnablePowerOnToLastSource = true; + //EnablePowerOnToLastSource = true; } catch (Exception e) { @@ -297,7 +297,9 @@ namespace PepperDash.Essentials { //DefaultDisplay = DeviceManager.GetDeviceForKey(PropertiesConfig.DefaultDisplayKey) as IRoutingSinkWithSwitching; - var destinationList = ConfigReader.ConfigObject.DestinationLists[PropertiesConfig.DestinationListKey]; + var destinationList = ConfigReader.ConfigObject.DestinationLists[PropertiesConfig.DestinationListKey]; + + Displays.Clear(); foreach (var destination in destinationList) { @@ -314,37 +316,54 @@ namespace PepperDash.Essentials // Link power, warming, cooling to display var dispTwoWay = display as IHasPowerControlWithFeedback; if (dispTwoWay != null) - { - dispTwoWay.PowerIsOnFeedback.OutputChange += (o, a) => - { - if (dispTwoWay.PowerIsOnFeedback.BoolValue != OnFeedback.BoolValue) - { - //if (!dispTwoWay.PowerIsOnFeedback.BoolValue) - // CurrentSourceInfo = null; - OnFeedback.FireUpdate(); - } - if (dispTwoWay.PowerIsOnFeedback.BoolValue) - { - SetDefaultLevels(); - } - }; - } - - display.IsWarmingUpFeedback.OutputChange += (o, a) => - { - IsWarmingUpFeedback.FireUpdate(); - if (!IsWarmingUpFeedback.BoolValue) - (CurrentVolumeControls as IBasicVolumeWithFeedback).SetVolume(DefaultVolume); - }; - display.IsCoolingDownFeedback.OutputChange += (o, a) => - { - IsCoolingDownFeedback.FireUpdate(); - }; + { + dispTwoWay.PowerIsOnFeedback.OutputChange -= PowerIsOnFeedback_OutputChange; + dispTwoWay.PowerIsOnFeedback.OutputChange += PowerIsOnFeedback_OutputChange; + + if (dispTwoWay.PowerIsOnFeedback.BoolValue) + { + SetDefaultLevels(); + } + } + + display.IsWarmingUpFeedback.OutputChange -= IsWarmingUpFeedback_OutputChange; + display.IsWarmingUpFeedback.OutputChange += IsWarmingUpFeedback_OutputChange; + + display.IsCoolingDownFeedback.OutputChange -= IsCoolingDownFeedback_OutputChange; + display.IsCoolingDownFeedback.OutputChange += IsCoolingDownFeedback_OutputChange; } } + } + + void IsCoolingDownFeedback_OutputChange(object sender, FeedbackEventArgs e) + { + IsCoolingDownFeedback.FireUpdate(); + } + + void IsWarmingUpFeedback_OutputChange(object sender, FeedbackEventArgs e) + { + IsWarmingUpFeedback.FireUpdate(); + if (!IsWarmingUpFeedback.BoolValue) + (CurrentVolumeControls as IBasicVolumeWithFeedback).SetVolume(DefaultVolume); + } + + void PowerIsOnFeedback_OutputChange(object sender, FeedbackEventArgs e) + { + var dispTwoWay = sender as IHasPowerControlWithFeedback; + + if (dispTwoWay != null && dispTwoWay.PowerIsOnFeedback.BoolValue != OnFeedback.BoolValue) + { + //if (!dispTwoWay.PowerIsOnFeedback.BoolValue) + // CurrentSourceInfo = null; + OnFeedback.FireUpdate(); + } } + + + + private void SetSourceListKey() { if (!string.IsNullOrEmpty(PropertiesConfig.SourceListKey)) @@ -367,26 +386,143 @@ namespace PepperDash.Essentials PropertiesConfig = newPropertiesConfig; ConfigWriter.UpdateRoomConfig(config); + } + + public override bool Deactivate() + { + // Stop listining to this event when room deactivated + VideoCodec.IsReadyChange -= VideoCodec_IsReadyChange; + + return base.Deactivate(); } public override bool CustomActivate() - { - // Add Occupancy object from config - if (PropertiesConfig.Occupancy != null) - { - Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Setting Occupancy Provider for room"); - this.SetRoomOccupancy(DeviceManager.GetDeviceForKey(PropertiesConfig.Occupancy.DeviceKey) as - IOccupancyStatusProvider, PropertiesConfig.Occupancy.TimeoutMinutes); - } - - this.LogoUrlLightBkgnd = PropertiesConfig.LogoLight.GetLogoUrlLight(); - this.LogoUrlDarkBkgnd = PropertiesConfig.LogoDark.GetLogoUrlDark(); - - this.DefaultSourceItem = PropertiesConfig.DefaultSourceItem; - this.DefaultVolume = (ushort)(PropertiesConfig.Volumes.Master.Level * 65535 / 100); - + { + try + { + if (DefaultAudioDevice is IBasicVolumeControls) + DefaultVolumeControls = DefaultAudioDevice as IBasicVolumeControls; + else if (DefaultAudioDevice is IHasVolumeDevice) + DefaultVolumeControls = (DefaultAudioDevice as IHasVolumeDevice).VolumeDevice; + CurrentVolumeControls = DefaultVolumeControls; + + + // Combines call feedback from both codecs if available + InCallFeedback = new BoolFeedback(() => + { + bool inAudioCall = false; + bool inVideoCall = false; + + if (AudioCodec != null) + inAudioCall = AudioCodec.IsInCall; + + if (VideoCodec != null) + inVideoCall = VideoCodec.IsInCall; + + if (inAudioCall || inVideoCall) + return true; + else + return false; + }); + + SetupDisplays(); + + // Get Microphone Privacy object, if any MUST HAPPEN AFTER setting InCallFeedback + this.MicrophonePrivacy = EssentialsRoomConfigHelper.GetMicrophonePrivacy(PropertiesConfig, this); + + Debug.Console(2, this, "Microphone Privacy Config evaluated."); + + // Get emergency object, if any + this.Emergency = EssentialsRoomConfigHelper.GetEmergency(PropertiesConfig, this); + + Debug.Console(2, this, "Emergency Config evaluated."); + + if (AudioCodec != null) + { + AudioCodec.CallStatusChange -= AudioCodec_CallStatusChange; + AudioCodec.CallStatusChange += AudioCodec_CallStatusChange; + } + + VideoCodec.CallStatusChange -= VideoCodec_CallStatusChange; + VideoCodec.CallStatusChange += VideoCodec_CallStatusChange; + + VideoCodec.IsReadyChange -= VideoCodec_IsReadyChange; + VideoCodec.IsReadyChange += VideoCodec_IsReadyChange; + + VideoCodec.SharingContentIsOnFeedback.OutputChange -= SharingContentIsOnFeedback_OutputChange; + VideoCodec.SharingContentIsOnFeedback.OutputChange += SharingContentIsOnFeedback_OutputChange; + + + IsSharingFeedback = new BoolFeedback(() => VideoCodec.SharingContentIsOnFeedback.BoolValue); + + // link privacy to VC (for now?) + PrivacyModeIsOnFeedback = new BoolFeedback(() => VideoCodec.PrivacyModeIsOnFeedback.BoolValue); + + VideoCodec.PrivacyModeIsOnFeedback.OutputChange -= PrivacyModeIsOnFeedback_OutputChange; + VideoCodec.PrivacyModeIsOnFeedback.OutputChange += PrivacyModeIsOnFeedback_OutputChange; + + CallTypeFeedback = new IntFeedback(() => 0); + + SetSourceListKey(); + + EnablePowerOnToLastSource = true; + + + // Add Occupancy object from config + if (PropertiesConfig.Occupancy != null) + { + Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Setting Occupancy Provider for room"); + this.SetRoomOccupancy(DeviceManager.GetDeviceForKey(PropertiesConfig.Occupancy.DeviceKey) as + IOccupancyStatusProvider, PropertiesConfig.Occupancy.TimeoutMinutes); + } + + this.LogoUrlLightBkgnd = PropertiesConfig.LogoLight.GetLogoUrlLight(); + this.LogoUrlDarkBkgnd = PropertiesConfig.LogoDark.GetLogoUrlDark(); + + this.DefaultSourceItem = PropertiesConfig.DefaultSourceItem; + this.DefaultVolume = (ushort)(PropertiesConfig.Volumes.Master.Level * 65535 / 100); + + } + catch (Exception e) + { + Debug.Console(0, this, "Error Activiating Room: {0}", e); + } + return base.CustomActivate(); - } + } + + void AudioCodec_CallStatusChange(object sender, CodecCallStatusItemChangeEventArgs e) + { + InCallFeedback.FireUpdate(); + } + + void PrivacyModeIsOnFeedback_OutputChange(object sender, FeedbackEventArgs e) + { + PrivacyModeIsOnFeedback.FireUpdate(); + } + + void VideoCodec_IsReadyChange(object sender, EventArgs e) + { + SetUpVideoCodec(); + } + + void SetUpVideoCodec() + { + SetCodecExternalSources(); + SetCodecBranding(); + } + + void VideoCodec_CallStatusChange(object sender, CodecCallStatusItemChangeEventArgs e) + { + InCallFeedback.FireUpdate(); + } + + void SharingContentIsOnFeedback_OutputChange(object sender, FeedbackEventArgs e) + { + IsSharingFeedback.FireUpdate(); + } + + /// /// diff --git a/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs b/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs index d04de3cc..457e4ae2 100644 --- a/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs +++ b/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs @@ -19,6 +19,8 @@ namespace PepperDash.Essentials { public class EssentialsHuddleVtc1Room : EssentialsRoomBase, IEssentialsHuddleVtc1Room { + private IEssentialsRoomCombiner _roomCombiner; + private bool _codecExternalSourceChange; public event EventHandler CurrentVolumeDeviceChange; public event SourceInfoChangeHandler CurrentSourceChange; @@ -234,7 +236,7 @@ namespace PepperDash.Essentials throw new ArgumentNullException("DefaultAudioDevice cannot be null"); } - InitializeRoom(); + Initialize(); } catch (Exception e) { @@ -242,109 +244,6 @@ namespace PepperDash.Essentials } } - void InitializeRoom() - { - try - { - if (DefaultAudioDevice is IBasicVolumeControls) - DefaultVolumeControls = DefaultAudioDevice as IBasicVolumeControls; - else if (DefaultAudioDevice is IHasVolumeDevice) - DefaultVolumeControls = (DefaultAudioDevice as IHasVolumeDevice).VolumeDevice; - CurrentVolumeControls = DefaultVolumeControls; - - - // Combines call feedback from both codecs if available - InCallFeedback = new BoolFeedback(() => - { - bool inAudioCall = false; - bool inVideoCall = false; - - if (AudioCodec != null) - inAudioCall = AudioCodec.IsInCall; - - if (VideoCodec != null) - inVideoCall = VideoCodec.IsInCall; - - if (inAudioCall || inVideoCall) - return true; - else - return false; - }); - - var disp = DefaultDisplay as DisplayBase; - if (disp != null) - { - // Link power, warming, cooling to display - var dispTwoWay = disp as IHasPowerControlWithFeedback; - if (dispTwoWay != null) - { - dispTwoWay.PowerIsOnFeedback.OutputChange += (o, a) => - { - if (dispTwoWay.PowerIsOnFeedback.BoolValue != OnFeedback.BoolValue) - { - if (!dispTwoWay.PowerIsOnFeedback.BoolValue) - CurrentSourceInfo = null; - OnFeedback.FireUpdate(); - } - if (dispTwoWay.PowerIsOnFeedback.BoolValue) - { - SetDefaultLevels(); - } - }; - } - - disp.IsWarmingUpFeedback.OutputChange += (o, a) => - { - IsWarmingUpFeedback.FireUpdate(); - if (!IsWarmingUpFeedback.BoolValue) - (CurrentVolumeControls as IBasicVolumeWithFeedback).SetVolume(DefaultVolume); - }; - disp.IsCoolingDownFeedback.OutputChange += (o, a) => - { - IsCoolingDownFeedback.FireUpdate(); - }; - - } - - - - // Get Microphone Privacy object, if any MUST HAPPEN AFTER setting InCallFeedback - this.MicrophonePrivacy = EssentialsRoomConfigHelper.GetMicrophonePrivacy(PropertiesConfig, this); - - Debug.Console(2, this, "Microphone Privacy Config evaluated."); - - // Get emergency object, if any - this.Emergency = EssentialsRoomConfigHelper.GetEmergency(PropertiesConfig, this); - - Debug.Console(2, this, "Emergency Config evaluated."); - - - VideoCodec.CallStatusChange += (o, a) => this.InCallFeedback.FireUpdate(); - VideoCodec.IsReadyChange += (o, a) => { this.SetCodecExternalSources(); SetCodecBranding(); }; - - if (AudioCodec != null) - AudioCodec.CallStatusChange += (o, a) => this.InCallFeedback.FireUpdate(); - - IsSharingFeedback = new BoolFeedback(() => VideoCodec.SharingContentIsOnFeedback.BoolValue); - VideoCodec.SharingContentIsOnFeedback.OutputChange += (o, a) => this.IsSharingFeedback.FireUpdate(); - - // link privacy to VC (for now?) - PrivacyModeIsOnFeedback = new BoolFeedback(() => VideoCodec.PrivacyModeIsOnFeedback.BoolValue); - VideoCodec.PrivacyModeIsOnFeedback.OutputChange += (o, a) => this.PrivacyModeIsOnFeedback.FireUpdate(); - - CallTypeFeedback = new IntFeedback(() => 0); - - SetupEnvironmentalControlDevices(); - - SetSourceListKey(); - - EnablePowerOnToLastSource = true; - } - catch (Exception e) - { - Debug.Console(0, this, "Error Initializing Room: {0}", e); - } - } private void SetupEnvironmentalControlDevices() { @@ -352,6 +251,8 @@ namespace PepperDash.Essentials { if (PropertiesConfig.Environment.Enabled) { + EnvironmentalControlDevices.Clear(); + foreach (var d in PropertiesConfig.Environment.DeviceKeys) { var envDevice = DeviceManager.GetDeviceForKey(d) as EssentialsDevice; @@ -386,25 +287,190 @@ namespace PepperDash.Essentials ConfigWriter.UpdateRoomConfig(config); } + public override bool Deactivate() + { + + // Stop listining to this event when room deactivated + VideoCodec.IsReadyChange -= VideoCodec_IsReadyChange; + + return base.Deactivate(); + } + public override bool CustomActivate() { - // Add Occupancy object from config - if (PropertiesConfig.Occupancy != null) + try { - Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Setting Occupancy Provider for room"); - this.SetRoomOccupancy(DeviceManager.GetDeviceForKey(PropertiesConfig.Occupancy.DeviceKey) as - IOccupancyStatusProvider, PropertiesConfig.Occupancy.TimeoutMinutes); + if (DefaultAudioDevice is IBasicVolumeControls) + DefaultVolumeControls = DefaultAudioDevice as IBasicVolumeControls; + else if (DefaultAudioDevice is IHasVolumeDevice) + DefaultVolumeControls = (DefaultAudioDevice as IHasVolumeDevice).VolumeDevice; + CurrentVolumeControls = DefaultVolumeControls; + + + // Combines call feedback from both codecs if available + InCallFeedback = new BoolFeedback(() => + { + bool inAudioCall = false; + bool inVideoCall = false; + + if (AudioCodec != null) + inAudioCall = AudioCodec.IsInCall; + + if (VideoCodec != null) + inVideoCall = VideoCodec.IsInCall; + + if (inAudioCall || inVideoCall) + return true; + else + return false; + }); + + var disp = DefaultDisplay as DisplayBase; + if (disp != null) + { + // Link power, warming, cooling to display + var dispTwoWay = disp as IHasPowerControlWithFeedback; + if (dispTwoWay != null) + { + dispTwoWay.PowerIsOnFeedback.OutputChange -= PowerIsOnFeedback_OutputChange; + dispTwoWay.PowerIsOnFeedback.OutputChange += PowerIsOnFeedback_OutputChange; + } + + disp.IsWarmingUpFeedback.OutputChange -= IsWarmingUpFeedback_OutputChange; + disp.IsWarmingUpFeedback.OutputChange += IsWarmingUpFeedback_OutputChange; + + disp.IsCoolingDownFeedback.OutputChange -= IsCoolingDownFeedback_OutputChange; + disp.IsCoolingDownFeedback.OutputChange += IsCoolingDownFeedback_OutputChange; + } + + + + // Get Microphone Privacy object, if any MUST HAPPEN AFTER setting InCallFeedback + this.MicrophonePrivacy = EssentialsRoomConfigHelper.GetMicrophonePrivacy(PropertiesConfig, this); + + Debug.Console(2, this, "Microphone Privacy Config evaluated."); + + // Get emergency object, if any + this.Emergency = EssentialsRoomConfigHelper.GetEmergency(PropertiesConfig, this); + + Debug.Console(2, this, "Emergency Config evaluated."); + + if (AudioCodec != null) + { + AudioCodec.CallStatusChange -= AudioCodec_CallStatusChange; + AudioCodec.CallStatusChange += AudioCodec_CallStatusChange; + } + + VideoCodec.CallStatusChange -= VideoCodec_CallStatusChange; + VideoCodec.CallStatusChange += VideoCodec_CallStatusChange; + + VideoCodec.IsReadyChange -= VideoCodec_IsReadyChange; + VideoCodec.IsReadyChange += VideoCodec_IsReadyChange; + + VideoCodec.SharingContentIsOnFeedback.OutputChange -= SharingContentIsOnFeedback_OutputChange; + VideoCodec.SharingContentIsOnFeedback.OutputChange += SharingContentIsOnFeedback_OutputChange; + + + IsSharingFeedback = new BoolFeedback(() => VideoCodec.SharingContentIsOnFeedback.BoolValue); + + // link privacy to VC (for now?) + PrivacyModeIsOnFeedback = new BoolFeedback(() => VideoCodec.PrivacyModeIsOnFeedback.BoolValue); + + VideoCodec.PrivacyModeIsOnFeedback.OutputChange -= PrivacyModeIsOnFeedback_OutputChange; + VideoCodec.PrivacyModeIsOnFeedback.OutputChange += PrivacyModeIsOnFeedback_OutputChange; + + CallTypeFeedback = new IntFeedback(() => 0); + + SetupEnvironmentalControlDevices(); + + SetSourceListKey(); + + EnablePowerOnToLastSource = true; + + + // Add Occupancy object from config + if (PropertiesConfig.Occupancy != null) + { + Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Setting Occupancy Provider for room"); + this.SetRoomOccupancy(DeviceManager.GetDeviceForKey(PropertiesConfig.Occupancy.DeviceKey) as + IOccupancyStatusProvider, PropertiesConfig.Occupancy.TimeoutMinutes); + } + + this.LogoUrlLightBkgnd = PropertiesConfig.LogoLight.GetLogoUrlLight(); + this.LogoUrlDarkBkgnd = PropertiesConfig.LogoDark.GetLogoUrlDark(); + + this.DefaultSourceItem = PropertiesConfig.DefaultSourceItem; + this.DefaultVolume = (ushort)(PropertiesConfig.Volumes.Master.Level * 65535 / 100); + } + catch (Exception e) + { + Debug.Console(0, this, "Error Activiating Room: {0}", e); } - - this.LogoUrlLightBkgnd = PropertiesConfig.LogoLight.GetLogoUrlLight(); - this.LogoUrlDarkBkgnd = PropertiesConfig.LogoDark.GetLogoUrlDark(); - - this.DefaultSourceItem = PropertiesConfig.DefaultSourceItem; - this.DefaultVolume = (ushort)(PropertiesConfig.Volumes.Master.Level * 65535 / 100); return base.CustomActivate(); } + void PrivacyModeIsOnFeedback_OutputChange(object sender, FeedbackEventArgs e) + { + PrivacyModeIsOnFeedback.FireUpdate(); + } + + void SharingContentIsOnFeedback_OutputChange(object sender, FeedbackEventArgs e) + { + IsSharingFeedback.FireUpdate(); + } + + void AudioCodec_CallStatusChange(object sender, CodecCallStatusItemChangeEventArgs e) + { + InCallFeedback.FireUpdate(); + } + + void VideoCodec_IsReadyChange(object sender, EventArgs e) + { + SetUpVideoCodec(); + } + + void SetUpVideoCodec() + { + SetCodecExternalSources(); + SetCodecBranding(); + } + + void VideoCodec_CallStatusChange(object sender, CodecCallStatusItemChangeEventArgs e) + { + InCallFeedback.FireUpdate(); + } + + void IsCoolingDownFeedback_OutputChange(object sender, FeedbackEventArgs e) + { + IsCoolingDownFeedback.FireUpdate(); + } + + void IsWarmingUpFeedback_OutputChange(object sender, FeedbackEventArgs e) + { + IsWarmingUpFeedback.FireUpdate(); + if (!IsWarmingUpFeedback.BoolValue) + (CurrentVolumeControls as IBasicVolumeWithFeedback).SetVolume(DefaultVolume); + + } + + void PowerIsOnFeedback_OutputChange(object sender, FeedbackEventArgs e) + { + var dispTwoWay = DefaultDisplay as IHasPowerControlWithFeedback; + + if (dispTwoWay.PowerIsOnFeedback.BoolValue != OnFeedback.BoolValue) + { + if (!dispTwoWay.PowerIsOnFeedback.BoolValue) + CurrentSourceInfo = null; + OnFeedback.FireUpdate(); + } + if (dispTwoWay.PowerIsOnFeedback.BoolValue) + { + SetDefaultLevels(); + } + + } + /// From f73d6994b8d6d869037d0b6ef50794582640a04b Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Wed, 19 Jul 2023 16:22:20 -0600 Subject: [PATCH 49/96] Additional updates to allow occupancy sensor to be cleared when room not active --- .../Room/Types/EssentialsCombinedHuddleVtc1Room.cs | 7 +++++++ .../Room/Types/EssentialsHuddleVtc1Room.cs | 8 +++++++- .../PepperDashEssentialsBase/Room/EssentialsRoomBase.cs | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/PepperDashEssentials/Room/Types/EssentialsCombinedHuddleVtc1Room.cs b/PepperDashEssentials/Room/Types/EssentialsCombinedHuddleVtc1Room.cs index 3ed0946d..8ffd63e5 100644 --- a/PepperDashEssentials/Room/Types/EssentialsCombinedHuddleVtc1Room.cs +++ b/PepperDashEssentials/Room/Types/EssentialsCombinedHuddleVtc1Room.cs @@ -393,6 +393,11 @@ namespace PepperDash.Essentials // Stop listining to this event when room deactivated VideoCodec.IsReadyChange -= VideoCodec_IsReadyChange; + // Clear occupancy + RoomOccupancy = null; + + Debug.Console(0, this, "Room '{0}' Deactivated", Name); + return base.Deactivate(); } @@ -488,6 +493,8 @@ namespace PepperDash.Essentials Debug.Console(0, this, "Error Activiating Room: {0}", e); } + + Debug.Console(0, this, "Room '{0}' Activated", Name); return base.CustomActivate(); } diff --git a/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs b/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs index 457e4ae2..3df86b9a 100644 --- a/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs +++ b/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs @@ -293,6 +293,11 @@ namespace PepperDash.Essentials // Stop listining to this event when room deactivated VideoCodec.IsReadyChange -= VideoCodec_IsReadyChange; + // Clear occupancy + RoomOccupancy = null; + + Debug.Console(0, this, "Room '{0}' Deactivated", Name); + return base.Deactivate(); } @@ -406,7 +411,8 @@ namespace PepperDash.Essentials { Debug.Console(0, this, "Error Activiating Room: {0}", e); } - + + Debug.Console(0, this, "Room '{0}' Activated", Name); return base.CustomActivate(); } diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/EssentialsRoomBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/EssentialsRoomBase.cs index f5e3dee8..0c7e0de0 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/EssentialsRoomBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/EssentialsRoomBase.cs @@ -35,7 +35,7 @@ namespace PepperDash.Essentials.Core public BoolFeedback IsWarmingUpFeedback { get; private set; } public BoolFeedback IsCoolingDownFeedback { get; private set; } - public IOccupancyStatusProvider RoomOccupancy { get; private set; } + public IOccupancyStatusProvider RoomOccupancy { get; protected set; } public bool OccupancyStatusProviderIsRemote { get; private set; } From c46409dc3ff52235d09fa8455c87ab7f772eabd6 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Wed, 19 Jul 2023 16:55:53 -0600 Subject: [PATCH 50/96] Minor adjustments and added debug messages --- .../Room/Types/EssentialsCombinedHuddleVtc1Room.cs | 10 ++++++---- .../Room/Types/EssentialsHuddleVtc1Room.cs | 4 +++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/PepperDashEssentials/Room/Types/EssentialsCombinedHuddleVtc1Room.cs b/PepperDashEssentials/Room/Types/EssentialsCombinedHuddleVtc1Room.cs index 8ffd63e5..cbe1b579 100644 --- a/PepperDashEssentials/Room/Types/EssentialsCombinedHuddleVtc1Room.cs +++ b/PepperDashEssentials/Room/Types/EssentialsCombinedHuddleVtc1Room.cs @@ -373,9 +373,9 @@ namespace PepperDash.Essentials else { SetSourceListKey(Key); - } - - SetCodecExternalSources(); + } + + SetUpVideoCodec(); } protected override void CustomSetConfig(DeviceConfig config) @@ -922,7 +922,9 @@ namespace PepperDash.Essentials videoCodecWithExternalSwitching.AddExternalSource(codecInputConnectorName, kvp.Key, srcConfig.PreferredName, PepperDash.Essentials.Devices.Common.VideoCodec.Cisco.eExternalSourceType.desktop); videoCodecWithExternalSwitching.SetExternalSourceState(kvp.Key, PepperDash.Essentials.Devices.Common.VideoCodec.Cisco.eExternalSourceMode.Ready); } - } + } + + Debug.Console(1, this, "Successfully set up codec external sources for room: {0}", Name); } catch (Exception e) { diff --git a/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs b/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs index 3df86b9a..2aae2f75 100644 --- a/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs +++ b/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs @@ -274,7 +274,7 @@ namespace PepperDash.Essentials SetSourceListKey(Key); } - SetCodecExternalSources(); + SetUpVideoCodec(); } protected override void CustomSetConfig(DeviceConfig config) @@ -904,6 +904,8 @@ namespace PepperDash.Essentials videoCodecWithExternalSwitching.SetExternalSourceState(kvp.Key, PepperDash.Essentials.Devices.Common.VideoCodec.Cisco.eExternalSourceMode.Ready); } } + Debug.Console(1, this, "Successfully set up codec external sources for room: {0}", Name); + } catch (Exception e) { From 62f175c24a19785806e4df26960c8b6348790db2 Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Tue, 15 Aug 2023 09:38:34 -0600 Subject: [PATCH 51/96] chore: trigger build with new Crestron DBs From b5bf87c634e65a92da041ca8ad9dbb11fefe3147 Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Tue, 15 Aug 2023 10:02:42 -0600 Subject: [PATCH 52/96] build: update PD Core version --- packages.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages.config b/packages.config index 35ed241d..4b9c93be 100644 --- a/packages.config +++ b/packages.config @@ -1,3 +1,3 @@ - + From daf3f321bd49dc444aafc78c2b78e96e3ec126d0 Mon Sep 17 00:00:00 2001 From: Nick Genovese Date: Wed, 16 Aug 2023 10:25:26 -0400 Subject: [PATCH 53/96] fix: bumped core version - bumped core to 1.3.1-hotfix-337 for ssh fixe --- packages.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages.config b/packages.config index 4b9c93be..bf1e451d 100644 --- a/packages.config +++ b/packages.config @@ -1,3 +1,3 @@ - + From da4070bad0c9190b7857ce0cd25ad9d08e7c4b59 Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Mon, 21 Aug 2023 15:23:33 -0600 Subject: [PATCH 54/96] docs: correct PDU Online join name for printing --- .../PepperDashEssentialsBase/Bridges/JoinMaps/PduJoinMapBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/PduJoinMapBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/PduJoinMapBase.cs index 2ac56ff1..0c2e9ed9 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/PduJoinMapBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/PduJoinMapBase.cs @@ -10,7 +10,7 @@ namespace PepperDash.Essentials.Core.Bridges [JoinName("Online")] public JoinDataComplete Online = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, - new JoinMetadata { Description = "PDU Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); + new JoinMetadata { Description = "Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital }); [JoinName("OutletCount")] public JoinDataComplete OutletCount = new JoinDataComplete(new JoinData { JoinNumber = 1, JoinSpan = 1 }, From 4d2ce83e7503dcdc1f82b6b10012f2b8abf3c84f Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Mon, 21 Aug 2023 15:27:25 -0600 Subject: [PATCH 55/96] fix: rework setting custom join data The previous method was causing an Exception to be thrown if a join didn't exist in the default join map for a device. This exception would prevent other devices from linking to a bridge correctly. This method now allows for join names to not be matched and the method will keep going. --- .../PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs index 60aa6275..12df7f14 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs @@ -356,16 +356,18 @@ namespace PepperDash.Essentials.Core { foreach (var customJoinData in joinData) { - var join = Joins[customJoinData.Key]; + JoinDataComplete join; + + if (!Joins.TryGetValue(customJoinData.Key, out join)) + { + Debug.Console(2, "No matching key found in join map for: '{0}'", customJoinData.Key); + continue; + } if (join != null) { join.SetCustomJoinData(customJoinData.Value); } - else - { - Debug.Console(2, "No matching key found in join map for: '{0}'", customJoinData.Key); - } } PrintJoinMapInfo(); From 4c0fb6311bc21319b4ee9595c92075ebf35d6ce2 Mon Sep 17 00:00:00 2001 From: Nick Genovese Date: Thu, 24 Aug 2023 08:15:31 -0400 Subject: [PATCH 56/96] fix: set core version to 1.3.1 --- packages.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages.config b/packages.config index bf1e451d..761b11cb 100644 --- a/packages.config +++ b/packages.config @@ -1,3 +1,3 @@ - + From 93134cae5cdbe59b05ff7fe15714e2e16fbbc123 Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Mon, 28 Aug 2023 15:20:57 -0600 Subject: [PATCH 57/96] fix: add `Dialable` property to Meeting class Previously, the meeting class was determining Dialable based on a meeting ID being "0". This is a Zoom-specific thing, but it has recently become a thing for Cisco codecs to have meetings that aren't necessarily dialable. Adding this property to the `Meeting` class allows the specific codec type to set it correctly based on that codec's needs. --- .../Essentials Devices Common/Codec/iHasScheduleAwareness.cs | 4 ++++ .../VideoCodec/CiscoCodec/BookingsDataClasses.cs | 2 ++ .../Essentials Devices Common/VideoCodec/VideoCodecBase.cs | 2 +- .../VideoCodec/ZoomRoom/ResponseObjects.cs | 2 ++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/iHasScheduleAwareness.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/iHasScheduleAwareness.cs index 9169fd7c..c4473c67 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/iHasScheduleAwareness.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Codec/iHasScheduleAwareness.cs @@ -216,6 +216,10 @@ namespace PepperDash.Essentials.Devices.Common.Codec return joinable; } } + + [JsonProperty("dialable")] + public bool Dialable { get; set; } + //public string ConferenceNumberToDial { get; set; } [JsonProperty("conferencePassword")] public string ConferencePassword { get; set; } diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/BookingsDataClasses.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/BookingsDataClasses.cs index 59823bb9..05456ad4 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/BookingsDataClasses.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/BookingsDataClasses.cs @@ -348,6 +348,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec if (b.DialInfo.ConnectMode.Value.ToLower() == "obtp" || b.DialInfo.ConnectMode.Value.ToLower() == "manual") meeting.IsOneButtonToPushMeeting = true; + meeting.Dialable = b.DialInfo.Calls.Call.Count > 0; + if (b.DialInfo.Calls.Call != null) { foreach (Call c in b.DialInfo.Calls.Call) diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/VideoCodecBase.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/VideoCodecBase.cs index c0048a68..187cc855 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/VideoCodecBase.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/VideoCodecBase.cs @@ -940,7 +940,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec //digitals tokenArray[digitalIndex] = new XSigDigitalToken(digitalIndex + 1, meeting.Joinable); - tokenArray[digitalIndex + 1] = new XSigDigitalToken(digitalIndex + 2, meeting.Id != "0"); + tokenArray[digitalIndex + 1] = new XSigDigitalToken(digitalIndex + 2, meeting.Dialable); //serials tokenArray[stringIndex] = new XSigSerialToken(stringIndex + 1, meeting.Organizer); diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ResponseObjects.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ResponseObjects.cs index 79a5395d..09069146 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ResponseObjects.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/VideoCodec/ZoomRoom/ResponseObjects.cs @@ -1510,6 +1510,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom meeting.Privacy = b.IsPrivate ? eMeetingPrivacy.Private : eMeetingPrivacy.Public; + meeting.Dialable = meeting.Id != "0"; + // No meeting.Calls data exists for Zoom Rooms. Leaving out for now. var now = DateTime.Now; if (meeting.StartTime < now && meeting.EndTime < now) From 759fb1d72949bd88e76cc071249740eb6399327e Mon Sep 17 00:00:00 2001 From: jdevito Date: Wed, 6 Sep 2023 11:22:19 -0500 Subject: [PATCH 58/96] feature: adds support for HdSpXxx switchers WIP: added support for HD-PS401, HD-PS402, HD-PS621 and HD-PS622, pending testing with device. --- .../JoinMaps/HdPsXxxControllerJoinMap.cs | 190 ++++++ .../PepperDash_Essentials_Core.csproj | 1 + .../Chassis/HdPsXxxController.cs | 637 ++++++++++++++++++ .../Config/HdPsXxxPropertiesConfig.cs | 18 + .../PepperDash_Essentials_DM.csproj | 2 + 5 files changed, 848 insertions(+) create mode 100644 essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/HdPsXxxControllerJoinMap.cs create mode 100644 essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs create mode 100644 essentials-framework/Essentials DM/Essentials_DM/Config/HdPsXxxPropertiesConfig.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/HdPsXxxControllerJoinMap.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/HdPsXxxControllerJoinMap.cs new file mode 100644 index 00000000..3f2901c9 --- /dev/null +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/HdPsXxxControllerJoinMap.cs @@ -0,0 +1,190 @@ +using System; +using PepperDash.Essentials.Core; + +namespace PepperDash_Essentials_Core.Bridges +{ + public class HdPsXxxControllerJoinMap : JoinMapBaseAdvanced + { + + #region Digital + + [JoinName("EnableAutoRoute")] + public JoinDataComplete EnableAutoRoute = new JoinDataComplete( + new JoinData + { + JoinNumber = 1, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Enable Automatic Routing on Xx1 Switchers", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Digital + }); + + + [JoinName("InputSync")] + public JoinDataComplete InputSync = new JoinDataComplete( + new JoinData + { + JoinNumber = 2, + JoinSpan = 8 + }, + new JoinMetadata + { + Description = "Device Input Sync", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + + [JoinName("EnableInputHdcp")] + public JoinDataComplete EnableInputHdcp = new JoinDataComplete( + new JoinData + { + JoinNumber = 11, + JoinSpan = 8 + }, + new JoinMetadata + { + Description = "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 + { + Description = "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 + { + Description = "Device Onlne", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + #endregion + + + #region Analog + + [JoinName("OutputRoute")] + public JoinDataComplete OutputRoute = new JoinDataComplete( + new JoinData + { + JoinNumber = 11, + JoinSpan = 2 + }, + new JoinMetadata + { + Description = "Device Output Route Set/Get", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Analog + }); + + #endregion + + + #region Serial + + [JoinName("Name")] + public JoinDataComplete Name = new JoinDataComplete( + new JoinData + { + JoinNumber = 1, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Device Name", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + + [JoinName("InputName")] + public JoinDataComplete InputName = new JoinDataComplete( + new JoinData + { + JoinNumber = 2, + JoinSpan = 8 + }, + new JoinMetadata + { + Description = "Device Input Name", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + + [JoinName("OutputName")] + public JoinDataComplete OutputName = new JoinDataComplete( + new JoinData + { + JoinNumber = 11, + JoinSpan = 2 + }, + new JoinMetadata + { + Description = "Device Output Name", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + + [JoinName("OutputRoutedName")] + public JoinDataComplete OutputRoutedName = new JoinDataComplete( + new JoinData + { + JoinNumber = 16, + JoinSpan = 2 + }, + new JoinMetadata + { + Description = "Device Output Route Name", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + + #endregion + + /// + /// Constructor to use when instantiating this join map without inheriting from it + /// + /// Join this join map will start at + public HdPsXxxControllerJoinMap(uint joinStart) + : this(joinStart, typeof(HdPsXxxControllerJoinMap)) + { + } + + /// + /// Constructor to use when extending this Join map + /// + /// Join this join map will start at + /// Type of the child join map + protected HdPsXxxControllerJoinMap(uint joinStart, Type type) + : base(joinStart, type) + { + } + } +} \ 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 75d4626d..0d9aa9bc 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj @@ -127,6 +127,7 @@ + diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs new file mode 100644 index 00000000..78da7a7b --- /dev/null +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs @@ -0,0 +1,637 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.DM; +using Newtonsoft.Json; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; +using PepperDash.Essentials.Core.Config; +using PepperDash_Essentials_Core.Bridges; +using PepperDash_Essentials_DM.Config; + +namespace PepperDash_Essentials_DM.Chassis +{ + [Description("Wrapper class for all HdPsXxx switchers")] + public class HdPsXxxController : CrestronGenericBridgeableBaseDevice, IRoutingNumericWithFeedback, IHasFeedback + { + + private readonly HdPsXxx _chassis; + private readonly HdPs401 _chassis401; + private readonly HdPs621 _chassis621; + + public RoutingPortCollection InputPorts { get; private set; } + public RoutingPortCollection OutputPorts { get; private set; } + + public Dictionary InputNames { get; set; } + public Dictionary OutputNames { get; set; } + + public FeedbackCollection InputNameFeedbacks { get; private set; } + public FeedbackCollection InputHdcpEnableFeedback { get; private set; } + + public FeedbackCollection OutputNameFeedbacks { get; private set; } + public FeedbackCollection OutputRouteNameFeedback { get; private set; } + + public FeedbackCollection VideoInputSyncFeedbacks { get; private set; } + public FeedbackCollection VideoOutputRouteFeedbacks { get; private set; } + + public StringFeedback DeviceNameFeedback { get; private set; } + public BoolFeedback AutoRouteFeedback { get; private set; } + + public event EventHandler NumericSwitchChange; + + /// + /// Constructor + /// + /// + /// + /// HdPs401 device instance + /// + public HdPsXxxController(string key, string name, HdPsXxx chassis, HdPsXxxPropertiesConfig props) + : base(key, name) + { + _chassis = chassis; + Name = name; + + if (props == null) + { + Debug.Console(1, this, "HdPsXxxController properties are null, failed to build device"); + return; + } + + InputPorts = new RoutingPortCollection(); + InputNames = new Dictionary(); + InputNameFeedbacks = new FeedbackCollection(); + InputHdcpEnableFeedback = new FeedbackCollection(); + + OutputPorts = new RoutingPortCollection(); + OutputNames = new Dictionary(); + OutputNameFeedbacks = new FeedbackCollection(); + OutputRouteNameFeedback = new FeedbackCollection(); + + VideoInputSyncFeedbacks = new FeedbackCollection(); + VideoOutputRouteFeedbacks = new FeedbackCollection(); + + if (_chassis.NumberOfOutputs == 1) + { + if (_chassis is HdPs401) + _chassis401 = _chassis as HdPs401; + if (_chassis is HdPs621) + _chassis621 = _chassis as HdPs621; + + AutoRouteFeedback = new BoolFeedback(() => _chassis401.PriorityRouteOnFeedback.BoolValue); + } + + SetupInputs(props.Inputs); + SetupOutputs(props.Outputs); + + AddPostActivationAction(AddFeedbackCollecitons); + } + + // input setup + private void SetupInputs(Dictionary dict) + { + InputNames = dict; + + for (uint i = 1; i <= _chassis.NumberOfInputs; i++) + { + var index = i; + var name = string.IsNullOrEmpty(InputNames[index]) ? string.Format("Input {0}", index) : InputNames[index]; + var input = _chassis.Inputs[index]; + var hdmiInput = _chassis.HdmiInputs[index]; + var dmLiteInput = _chassis.DmLiteInputs[index]; + + InputNameFeedbacks.Add(new StringFeedback(name, () => InputNames[index])); + + // TODO [ ] verify which input type is needed + input.Name.StringValue = name; + hdmiInput.Name.StringValue = name; + dmLiteInput.Name.StringValue = name; + + var port = new RoutingInputPort(name, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, input, this) + { + FeedbackMatchObject = input + }; + InputPorts.Add(port); + + InputHdcpEnableFeedback.Add(new BoolFeedback(name, () => hdmiInput.InputPort.HdcpSupportOnFeedback.BoolValue)); + + VideoInputSyncFeedbacks.Add(new BoolFeedback(name, () => input.VideoDetectedFeedback.BoolValue)); + } + + _chassis.DMInputChange += _chassis_InputChange; + } + + // output setup + private void SetupOutputs(Dictionary dict) + { + OutputNames = dict; + + for (uint i = 1; i <= _chassis.NumberOfOutputs; i++) + { + var index = i; + var name = string.IsNullOrEmpty(OutputNames[index]) ? string.Format("Output {0}", index) : OutputNames[index]; + var output = _chassis.Outputs[index]; + var hdmiDmLiteOutput = _chassis.HdmiDmLiteOutputs[index]; + + OutputNameFeedbacks.Add(new StringFeedback(name, () => OutputNames[index])); + + // TODO [ ] verify which output type is needed + output.Name.StringValue = name; + hdmiDmLiteOutput.Name.StringValue = name; + + var port = new RoutingOutputPort(name, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, output, this) + { + FeedbackMatchObject = output + }; + OutputPorts.Add(port); + + OutputRouteNameFeedback.Add(new StringFeedback(name, () => output.VideoOutFeedback.NameFeedback.StringValue)); + + VideoOutputRouteFeedbacks.Add(new IntFeedback(name, () => output.VideoOutFeedback == null ? 0 : (int)output.VideoOutFeedback.Number)); + } + + _chassis.DMOutputChange += _chassis_OutputChange; + } + + + #region BridgeLinking + + /// + /// Link device to API + /// + /// + /// + /// + /// + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + var joinMap = new HdPsXxxControllerJoinMap(joinStart); + + 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"); + } + + IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); + DeviceNameFeedback.LinkInputSig(trilist.StringInput[joinMap.Name.JoinNumber]); + + _chassis.OnlineStatusChange += _chassis_OnlineStatusChange; + + if (_chassis401 != null) LinkChassis401ToApi(trilist, joinMap); + + if (_chassis621 != null) LinkChassis621ToApi(trilist, joinMap); + + LinkChassisInputsToApi(trilist, joinMap); + LinkChassisOutputsToApi(trilist, joinMap); + + trilist.OnlineStatusChange += (sender, args) => + { + if (!args.DeviceOnLine) return; + }; + } + + + // links inputs to API + private void LinkChassisInputsToApi(BasicTriList trilist, HdPsXxxControllerJoinMap joinMap) + { + for (uint i = 1; i <= _chassis.NumberOfInputs; i++) + { + var input = i; + var inputName = InputNames[input]; + var indexWithOffset = input - 1; + + trilist.SetSigTrueAction(joinMap.EnableInputHdcp.JoinNumber + indexWithOffset, () => EnableHdcp(input)); + trilist.SetSigTrueAction(joinMap.DisableInputHdcp.JoinNumber + indexWithOffset, () => DisableHdcp(input)); + + InputHdcpEnableFeedback[inputName].LinkInputSig(trilist.BooleanInput[joinMap.EnableInputHdcp.JoinNumber + indexWithOffset]); + InputHdcpEnableFeedback[inputName].LinkComplementInputSig(trilist.BooleanInput[joinMap.EnableInputHdcp.JoinNumber + indexWithOffset]); + + VideoInputSyncFeedbacks[inputName].LinkInputSig(trilist.BooleanInput[joinMap.InputSync.JoinNumber + indexWithOffset]); + + InputNameFeedbacks[inputName].LinkInputSig(trilist.StringInput[joinMap.InputName.JoinNumber + indexWithOffset]); + } + } + + + // links outputs to API + private void LinkChassisOutputsToApi(BasicTriList trilist, HdPsXxxControllerJoinMap joinMap) + { + for (uint i = 1; i <= _chassis.NumberOfOutputs; i++) + { + var output = i; + var outputName = OutputNames[output]; + var indexWithOffset = output - 1; + + trilist.SetUShortSigAction(joinMap.OutputRoute.JoinNumber + indexWithOffset, (a) => + ExecuteNumericSwitch(a, (ushort) output, eRoutingSignalType.AudioVideo)); + + OutputNameFeedbacks[outputName].LinkInputSig(trilist.StringInput[joinMap.OutputName.JoinNumber + indexWithOffset]); + OutputRouteNameFeedback[outputName].LinkInputSig(trilist.StringInput[joinMap.OutputRoutedName.JoinNumber + indexWithOffset]); + + VideoOutputRouteFeedbacks[outputName].LinkInputSig(trilist.UShortInput[joinMap.OutputRoute.JoinNumber + indexWithOffset]); + } + } + + + // links HdPs401 chassis to API + private void LinkChassis401ToApi(BasicTriList trilist, HdPsXxxControllerJoinMap joinMap) + { + trilist.SetSigTrueAction(joinMap.EnableAutoRoute.JoinNumber, () => _chassis401.AutoRouteOn()); + trilist.SetSigFalseAction(joinMap.EnableAutoRoute.JoinNumber, () => _chassis401.AutoRouteOff()); + + AutoRouteFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableAutoRoute.JoinNumber]); + } + + + // links HdPs621 chassis to API + private void LinkChassis621ToApi(BasicTriList trilist, HdPsXxxControllerJoinMap joinMap) + { + trilist.SetSigTrueAction(joinMap.EnableAutoRoute.JoinNumber, () => _chassis621.AutoRouteOn()); + trilist.SetSigFalseAction(joinMap.EnableAutoRoute.JoinNumber, () => _chassis621.AutoRouteOff()); + + AutoRouteFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableAutoRoute.JoinNumber]); + } + + + #endregion + + + /// + /// Executes a device switch using objects + /// + /// + /// + /// + public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) + { + var input = inputSelector as HdPsXxxHdmiInput; + var output = outputSelector as HdPsXxxHdmiOutput; + + Debug.Console(2, this, "ExecuteSwitch: input={0}, output={1}", input, output); + + if (output == null) + { + Debug.Console(0, this, "Unable to make switch, output selector is not HdPsXxxHdmiOutput"); + return; + } + + // TODO [ ] Validate if sending the same input toggles the switch + var current = output.VideoOut; + if (current != input) + output.VideoOut = input; + } + + + /// + /// Executes a device switch using numeric values + /// + /// + /// + /// + public void ExecuteNumericSwitch(ushort inputSelector, ushort outputSelector, eRoutingSignalType signalType) + { + var input = inputSelector == 0 ? null : _chassis.Inputs[inputSelector]; + var output = _chassis.Outputs[outputSelector]; + + Debug.Console(2, this, "ExecuteNumericSwitch: input={0}, output={1}", input, output); + + ExecuteSwitch(input, output, signalType); + } + + + /// + /// Enables Hdcp on the provided port + /// + /// + public void EnableHdcp(uint port) + { + if (port <= 0 || port > _chassis.NumberOfInputs) return; + + _chassis.HdmiInputs[port].InputPort.HdcpSupportOn(); + InputHdcpEnableFeedback[InputNames[port]].FireUpdate(); + } + + + /// + /// Disables Hdcp on the provided port + /// + /// + public void DisableHdcp(uint port) + { + if (port <= 0 || port > _chassis.NumberOfInputs) return; + + _chassis.HdmiInputs[port].InputPort.HdcpSupportOff(); + InputHdcpEnableFeedback[InputNames[port]].FireUpdate(); + } + + + /// + /// Enables switcher auto route + /// + public void EnableAutoRoute() + { + if (_chassis.NumberOfInputs != 1) return; + + if (_chassis401 != null) + { + _chassis401.AutoRouteOn(); + } + + if (_chassis621 != null) + { + _chassis621.AutoRouteOn(); + } + } + + + /// + /// Disables switcher auto route + /// + public void DisableAutoRoute() + { + if (_chassis.NumberOfInputs != 1) return; + + if (_chassis401 != null) + { + _chassis401.AutoRouteOff(); + } + + if (_chassis621 != null) + { + _chassis621.AutoRouteOff(); + } + } + + #region Events + + + // _chassis online/offline event + private void _chassis_OnlineStatusChange(GenericBase currentDevice, + OnlineOfflineEventArgs args) + { + IsOnline.FireUpdate(); + + if (!args.DeviceOnLine) return; + + foreach (var feedback in Feedbacks) + { + feedback.FireUpdate(); + } + } + + + // _chassis input change event + private void _chassis_InputChange(Switch device, DMInputEventArgs args) + { + var eventId = args.EventId; + + switch (eventId) + { + case DMInputEventIds.VideoDetectedEventId: + { + Debug.Console(1, this, "Event ID {0}: Updating VideoInputSyncFeedbacks", 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", eventId); + + var input = args.Number; + var name = _chassis.HdmiInputs[input].NameFeedback.StringValue; + + Debug.Console(1, this, "Input {0} Name {1}", input, name); + break; + } + default: + { + Debug.Console(1, this, "Uhandled DM Input Event ID {0}", eventId); + break; + } + } + } + + + // _chassis output change event + private void _chassis_OutputChange(Switch device, DMOutputEventArgs args) + { + if (args.EventId != DMOutputEventIds.VideoOutEventId) return; + + var output = args.Number; + + var input = _chassis.HdmiDmLiteOutputs[output].VideoOutFeedback == null + ? 0 + : _chassis.HdmiDmLiteOutputs[output].VideoOutFeedback.Number; + + var outputName = OutputNames[output]; + + var feedback = VideoOutputRouteFeedbacks[outputName]; + if (feedback == null) return; + + var inputPort = InputPorts.FirstOrDefault( + p => p.FeedbackMatchObject == _chassis.HdmiDmLiteOutputs[output].VideoOutFeedback); + + var outputPort = OutputPorts.FirstOrDefault( + p => p.FeedbackMatchObject == _chassis.HdmiDmLiteOutputs[output]); + + feedback.FireUpdate(); + + OnSwitchChange(new RoutingNumericEventArgs( + output, input, outputPort, inputPort, eRoutingSignalType.AudioVideo)); + } + + + /// + /// Raise an event when the status of a switch object changes. + /// + /// Argumetns defined as IKeyName sender, output, input, & eRoutingSignalType + private void OnSwitchChange(RoutingNumericEventArgs args) + { + var newEvent = NumericSwitchChange; + if (newEvent != null) newEvent(this, args); + } + + + #endregion + + + #region FeedbacksAndFeedbackCollections + + + /// + /// Add feedback colleciton arrays to feedback collections + /// + /// BoolFeedback[] arrays + public void AddCollectionsToList(params FeedbackCollection[] feedbackCollections) + { + foreach (var item in feedbackCollections.SelectMany(feedbackCollection => feedbackCollections)) + { + AddCollectionsToList(item); + } + } + + + /// + /// Add feedback colleciton arrays to feedback collections + /// + /// IntFeedback[] arrays + public void AddCollectionsToList(params FeedbackCollection[] feedbackCollections) + { + foreach (var item in feedbackCollections.SelectMany(feedbackCollection => feedbackCollections)) + { + AddCollectionsToList(item); + } + } + + + /// + /// Add feedback colleciton arrays to feedback collections + /// + /// StringFeedback[] arrays + public void AddCollectionsToList(params FeedbackCollection[] feedbackCollections) + { + foreach (var item in feedbackCollections.SelectMany(feedbackCollection => feedbackCollections)) + { + AddCollectionsToList(item); + } + } + + + /// + /// Adds feedback colleciton to feedback collections + /// + /// BoolFeedback + public void AddCollectionToList(FeedbackCollection feedbackCollection) + { + foreach (var item in feedbackCollection.Where(item => item != null)) + { + AddFeedbackToList(item); + } + } + + + /// + /// Adds feedback colleciton to feedback collections + /// + /// IntFeedback + public void AddCollectionToList(FeedbackCollection feedbackCollection) + { + foreach (var item in feedbackCollection.Where(item => item != null)) + { + AddFeedbackToList(item); + } + } + + + /// + /// Adds feedback colleciton to feedback collections + /// + /// StringFeedback + public void AddCollectionToList(FeedbackCollection feedbackCollection) + { + foreach (var item in feedbackCollection.Where(item => item != null)) + { + AddFeedbackToList(item); + } + } + + + /// + /// Adds individual feedbacks to feedback collection + /// + /// Feedback + public void AddFeedbackToList(PepperDash.Essentials.Core.Feedback fb) + { + if (fb == null || Feedbacks.Contains(fb)) return; + + Feedbacks.Add(fb); + } + + + /// + /// Adds provided feedbacks to feedback collection list + /// + public void AddFeedbackCollecitons() + { + AddFeedbackToList(DeviceNameFeedback); + AddCollectionsToList(VideoInputSyncFeedbacks, InputHdcpEnableFeedback); + AddCollectionsToList(VideoOutputRouteFeedbacks); + AddCollectionsToList(InputNameFeedbacks, OutputNameFeedbacks, OutputRouteNameFeedback); + } + + + #endregion + + + #region Factory + + + public class HdSp401ControllerFactory : EssentialsDeviceFactory + { + public HdSp401ControllerFactory() + { + TypeNames = new List() { "hdsp401", "hdsp402", "hdsp621", "hdsp622" }; + } + public override EssentialsDevice BuildDevice(DeviceConfig dc) + { + Debug.Console(1, "Factory Attempting to create new HD-PSXxx device"); + + var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); + if (props == null) + { + Debug.Console(1, "Factory failed to create new HD-PSXxx device, properties config was null"); + return null; + } + + var key = dc.Key; + var name = dc.Name; + var type = dc.Type.ToLower(); + var control = props.Control; + var ipid = control.IpIdInt; + var address = control.TcpSshProperties.Address; + + switch (type) + { + case ("hdps401"): + { + return new HdPsXxxController(key, name, new HdPs401(ipid, Global.ControlSystem), props); + } + case ("hdsp402"): + { + return new HdPsXxxController(key, name, new HdPs402(ipid, Global.ControlSystem), props); + } + case ("hdsp621"): + { + return new HdPsXxxController(key, name, new HdPs621(ipid, Global.ControlSystem), props); + } + case ("hdsp622"): + { + return new HdPsXxxController(key, name, new HdPs622(ipid, Global.ControlSystem), props); + } + default: + { + Debug.Console(1, "Factory failed to create new {0} device", type); + return null; + } + } + } + } + + + #endregion + } +} \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Config/HdPsXxxPropertiesConfig.cs b/essentials-framework/Essentials DM/Essentials_DM/Config/HdPsXxxPropertiesConfig.cs new file mode 100644 index 00000000..b521facf --- /dev/null +++ b/essentials-framework/Essentials DM/Essentials_DM/Config/HdPsXxxPropertiesConfig.cs @@ -0,0 +1,18 @@ +using System.Collections.Generic; +using Newtonsoft.Json; +using PepperDash.Core; + +namespace PepperDash_Essentials_DM.Config +{ + public class HdPsXxxPropertiesConfig + { + [JsonProperty("control")] + public ControlPropertiesConfig Control { get; set; } + + [JsonProperty("inputs")] + 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/PepperDash_Essentials_DM.csproj b/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj index adfddbe3..0011c305 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj +++ b/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj @@ -104,6 +104,8 @@ + + From b06d0c0debd2a75245f2105b563625dc5f45758f Mon Sep 17 00:00:00 2001 From: Jason DeVito Date: Thu, 7 Sep 2023 18:37:21 -0500 Subject: [PATCH 59/96] fix: resolves typo of hdpsXxx type name in the factory --- .../Essentials_DM/Chassis/HdPsXxxController.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs index 78da7a7b..499dd865 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs @@ -52,7 +52,7 @@ namespace PepperDash_Essentials_DM.Chassis /// HdPs401 device instance /// public HdPsXxxController(string key, string name, HdPsXxx chassis, HdPsXxxPropertiesConfig props) - : base(key, name) + : base(key, name, chassis) { _chassis = chassis; Name = name; @@ -584,7 +584,7 @@ namespace PepperDash_Essentials_DM.Chassis { public HdSp401ControllerFactory() { - TypeNames = new List() { "hdsp401", "hdsp402", "hdsp621", "hdsp622" }; + TypeNames = new List() { "hdps401", "hdps402", "hdps621", "hdps622" }; } public override EssentialsDevice BuildDevice(DeviceConfig dc) { @@ -610,15 +610,15 @@ namespace PepperDash_Essentials_DM.Chassis { return new HdPsXxxController(key, name, new HdPs401(ipid, Global.ControlSystem), props); } - case ("hdsp402"): + case ("hdps402"): { return new HdPsXxxController(key, name, new HdPs402(ipid, Global.ControlSystem), props); } - case ("hdsp621"): + case ("hdps621"): { return new HdPsXxxController(key, name, new HdPs621(ipid, Global.ControlSystem), props); } - case ("hdsp622"): + case ("hdps622"): { return new HdPsXxxController(key, name, new HdPs622(ipid, Global.ControlSystem), props); } From d74c5de65130c1fe03db44394a65b9dc3cb96c64 Mon Sep 17 00:00:00 2001 From: Jason DeVito Date: Fri, 8 Sep 2023 10:51:19 -0500 Subject: [PATCH 60/96] wip: updates to HdPsXxx class while test implementation to resolve exceptions --- .../Chassis/HdPsXxxController.cs | 28 ++++++++++++++++--- .../Config/HdPsXxxPropertiesConfig.cs | 14 +++++++++- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs index 499dd865..d923949e 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs @@ -63,15 +63,17 @@ namespace PepperDash_Essentials_DM.Chassis return; } - InputPorts = new RoutingPortCollection(); - InputNames = new Dictionary(); + InputPorts = new RoutingPortCollection(); InputNameFeedbacks = new FeedbackCollection(); InputHdcpEnableFeedback = new FeedbackCollection(); + InputNames = new Dictionary(); + //InputNames = props.Inputs; OutputPorts = new RoutingPortCollection(); - OutputNames = new Dictionary(); OutputNameFeedbacks = new FeedbackCollection(); OutputRouteNameFeedback = new FeedbackCollection(); + OutputNames = new Dictionary(); + //OutputNames = props.Outputs; VideoInputSyncFeedbacks = new FeedbackCollection(); VideoOutputRouteFeedbacks = new FeedbackCollection(); @@ -95,6 +97,15 @@ namespace PepperDash_Essentials_DM.Chassis // input setup private void SetupInputs(Dictionary dict) { + if (dict == null) + { + Debug.Console(1, this, "Failed to setup inputs, properties are null"); + return; + } + foreach (var kvp in dict) + { + Debug.Console(1, this, "props.Input[{0}]: {1}", kvp.Key, kvp.Value); + } InputNames = dict; for (uint i = 1; i <= _chassis.NumberOfInputs; i++) @@ -129,6 +140,15 @@ namespace PepperDash_Essentials_DM.Chassis // output setup private void SetupOutputs(Dictionary dict) { + if (dict == null) + { + Debug.Console(1, this, "Failed to setup outputs, properties are null"); + return; + } + foreach (var kvp in dict) + { + Debug.Console(1, this, "props.Output[{0}]: {1}", kvp.Key, kvp.Value); + } OutputNames = dict; for (uint i = 1; i <= _chassis.NumberOfOutputs; i++) @@ -602,7 +622,7 @@ namespace PepperDash_Essentials_DM.Chassis var type = dc.Type.ToLower(); var control = props.Control; var ipid = control.IpIdInt; - var address = control.TcpSshProperties.Address; + //var address = control.TcpSshProperties.Address; switch (type) { diff --git a/essentials-framework/Essentials DM/Essentials_DM/Config/HdPsXxxPropertiesConfig.cs b/essentials-framework/Essentials DM/Essentials_DM/Config/HdPsXxxPropertiesConfig.cs index b521facf..c02fc511 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Config/HdPsXxxPropertiesConfig.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Config/HdPsXxxPropertiesConfig.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using Newtonsoft.Json; using PepperDash.Core; +using PepperDash.Essentials.DM.Config; namespace PepperDash_Essentials_DM.Config { @@ -10,9 +11,20 @@ namespace PepperDash_Essentials_DM.Config public ControlPropertiesConfig Control { get; set; } [JsonProperty("inputs")] + //public Dictionary Inputs { get; set; } public Dictionary Inputs { get; set; } [JsonProperty("outputs")] - public Dictionary Outputs { get; set; } + //public Dictionary Outputs { get; set; } + public Dictionary Outputs { get; set; } + + public HdPsXxxPropertiesConfig() + { + //Inputs = new Dictionary(); + //Outputs = new Dictionary(); + + Inputs = new Dictionary(); + Outputs = new Dictionary(); + } } } \ No newline at end of file From 527457baf54d557f5c5991330335d0be894165b2 Mon Sep 17 00:00:00 2001 From: Jason DeVito Date: Fri, 8 Sep 2023 13:00:27 -0500 Subject: [PATCH 61/96] refactor(wip): MPC3 class refactor constructor --- PepperDashEssentials/ControlSystem.cs | 48 ++-- .../Touchpanels/Mpc3Touchpanel.cs | 231 +++++++++++------- 2 files changed, 169 insertions(+), 110 deletions(-) diff --git a/PepperDashEssentials/ControlSystem.cs b/PepperDashEssentials/ControlSystem.cs index f24cb828..0ebfd927 100644 --- a/PepperDashEssentials/ControlSystem.cs +++ b/PepperDashEssentials/ControlSystem.cs @@ -392,50 +392,45 @@ namespace PepperDash.Essentials { Debug.Console(2, "Adding DmpsRoutingController for {0} to Device Manager.", this.ControllerPrompt); - var propertiesConfig = JsonConvert.DeserializeObject(devConf.Properties.ToString()); + var propertiesConfig = JsonConvert.DeserializeObject(devConf.Properties.ToString()) ?? + new DM.Config.DmpsRoutingPropertiesConfig(); - if(propertiesConfig == null) - propertiesConfig = new DM.Config.DmpsRoutingPropertiesConfig(); - - DeviceManager.AddDevice(DmpsRoutingController.GetDmpsRoutingController("processor-avRouting", this.ControllerPrompt, propertiesConfig)); + DeviceManager.AddDevice(DmpsRoutingController.GetDmpsRoutingController("processor-avRouting", this.ControllerPrompt, propertiesConfig)); } else if (this.ControllerPrompt.IndexOf("mpc3", StringComparison.OrdinalIgnoreCase) > -1) { Debug.Console(2, "MPC3 processor type detected. Adding Mpc3TouchpanelController."); var butToken = devConf.Properties["buttons"]; - if (butToken != null) - { - var buttons = butToken.ToObject>(); - var tpController = new Essentials.Core.Touchpanels.Mpc3TouchpanelController(devConf.Key, devConf.Name, Global.ControlSystem, buttons); - DeviceManager.AddDevice(tpController); - } - else - { - Debug.Console(0, Debug.ErrorLogLevel.Error, "Error: Unable to deserialize buttons collection for device: {0}", devConf.Key); - } - + if (butToken == null) + { + Debug.Console(0, Debug.ErrorLogLevel.Error, + "Error: Unable to deserialize buttons collection for device: {0}", devConf.Key); + continue; + } + + var buttons = butToken.ToObject>(); + var tpController = new Core.Touchpanels.Mpc3TouchpanelController( + string.Format("{0}-keypadButtons", devConf.Key), devConf.Name, Global.ControlSystem, buttons); + + DeviceManager.AddDevice(tpController); } else { Debug.Console(2, "************Processor is not DMPS type***************"); } - - continue; } // Try local factories first - IKeyed newDev = null; + var newDev = null ?? PepperDash.Essentials.Core.DeviceFactory.GetDevice(devConf); - if (newDev == null) - newDev = PepperDash.Essentials.Core.DeviceFactory.GetDevice(devConf); - - if (newDev != null) - DeviceManager.AddDevice(newDev); - else - Debug.Console(0, Debug.ErrorLogLevel.Error, "ERROR: Cannot load unknown device type '{0}', key '{1}'.", devConf.Type, devConf.Key); + if (newDev == null) + Debug.Console(0, Debug.ErrorLogLevel.Error, "ERROR: Cannot load unknown device type '{0}', key '{1}'.", + devConf.Type, devConf.Key); + else + DeviceManager.AddDevice(newDev); } catch (Exception e) { @@ -443,7 +438,6 @@ namespace PepperDash.Essentials } } Debug.Console(0, Debug.ErrorLogLevel.Notice, "All Devices Loaded."); - } diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Mpc3Touchpanel.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Mpc3Touchpanel.cs index c9a5f605..97a18d50 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Mpc3Touchpanel.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Mpc3Touchpanel.cs @@ -1,12 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; +using System.Collections.Generic; +using System.Globalization; using Crestron.SimplSharpPro; - +using Newtonsoft.Json; using PepperDash.Core; -using PepperDash.Essentials.Core; namespace PepperDash.Essentials.Core.Touchpanels { @@ -16,82 +12,147 @@ namespace PepperDash.Essentials.Core.Touchpanels /// public class Mpc3TouchpanelController : Device { - MPC3Basic _Touchpanel; + readonly MPC3Basic _touchpanel; - Dictionary _Buttons; + readonly Dictionary _buttons; public Mpc3TouchpanelController(string key, string name, CrestronControlSystem processor, Dictionary buttons) : base(key, name) { - _Touchpanel = processor.ControllerTouchScreenSlotDevice as MPC3Basic; - _Buttons = buttons; + _touchpanel = processor.ControllerTouchScreenSlotDevice as MPC3Basic; + if (_touchpanel == null) + { + Debug.Console(1, this, "Failed to construct {0}, check configuration", key); + return; + } + + _touchpanel.ButtonStateChange += _touchpanel_ButtonStateChange; + _buttons = buttons; - _Touchpanel.ButtonStateChange += new Crestron.SimplSharpPro.DeviceSupport.ButtonEventHandler(_Touchpanel_ButtonStateChange); + AddPostActivationAction(() => + { + // Link up the button feedbacks to the specified BoolFeedbacks + foreach (var button in _buttons) + { + var buttonKey = button.Key.ToLower(); + var buttonConfig = button.Value; + if (buttonConfig == null) + { + Debug.Console(1, this, "Unable to get button config for {0}-{1}", Key, button.Key); + continue; + } - AddPostActivationAction(() => - { - // Link up the button feedbacks to the specified BoolFeedbacks - foreach (var button in _Buttons) - { - var feedbackConfig = button.Value.Feedback; - var device = DeviceManager.GetDeviceForKey(feedbackConfig.DeviceKey) as Device; - if (device != null) - { - var bKey = button.Key.ToLower(); + int buttonNumber; + if (TryParseInt(buttonKey, out buttonNumber)) + { + Debug.Console(0, this, "buttonFeedback: tryIntParse successful, buttonNumber = {0}", buttonNumber); + _touchpanel.EnableNumericalButton((uint)buttonNumber); + } + else + { + Debug.Console(0, this, "buttonFeedback: tryIntParse failed, buttonKey = {0}", buttonKey); + } - var feedback = device.GetFeedbackProperty(feedbackConfig.FeedbackName); + //var buttonEventTypes = buttonConfig.EventTypes; - var bFeedback = feedback as BoolFeedback; - var iFeedback = feedback as IntFeedback; - if (bFeedback != null) - { + var buttonFeedback = buttonConfig.Feedback; + if (buttonFeedback == null) + { + Debug.Console(1, this, "Button '{0}' feedback not configured, feedback will not be implemented", buttonKey); + continue; + } + + var device = DeviceManager.GetDeviceForKey(buttonFeedback.DeviceKey) as Device; + if (device == null) + { + Debug.Console(1, this, "Unable to get device with key {0}, feedback will not be implemented", + buttonFeedback.DeviceKey); + continue; + } - if (bKey == "power") - { - bFeedback.LinkCrestronFeedback(_Touchpanel.FeedbackPower); - continue; - } - else if (bKey == "mute") - { - bFeedback.LinkCrestronFeedback(_Touchpanel.FeedbackMute); - continue; - } + var deviceFeedback = device.GetFeedbackProperty(buttonFeedback.FeedbackName); + Debug.Console(0, this, "deviceFeedback.GetType().Name: {0}", deviceFeedback.GetType().Name); + //switch (feedback.GetType().Name.ToLower()) + //{ + // case("boolfeedback"): + // { - // Link to the Crestron Feedback corresponding to the button number - bFeedback.LinkCrestronFeedback(_Touchpanel.Feedbacks[UInt16.Parse(button.Key)]); - } - else if (iFeedback != null) - { - if (bKey == "volumefeedback") - { - var volFeedback = feedback as IntFeedback; - // TODO: Figure out how to subsribe to a volume IntFeedback and link it to the voluem - volFeedback.LinkInputSig(_Touchpanel.VolumeBargraph); - } - } - else - { - Debug.Console(1, this, "Unable to get BoolFeedback with name: {0} from device: {1}", feedbackConfig.FeedbackName, device.Key); - } - } - else - { - Debug.Console(1, this, "Unable to get device with key: {0}", feedbackConfig.DeviceKey); - } - } - }); + // break; + // } + // case("intfeedback"): + // { + + // break; + // } + //} + + var boolFeedback = deviceFeedback as BoolFeedback; + var intFeedback = deviceFeedback as IntFeedback; + + switch (buttonKey) + { + case ("power"): + { + if (boolFeedback != null) boolFeedback.LinkCrestronFeedback(_touchpanel.FeedbackPower); + break; + } + case ("volumeup"): + { + break; + } + case ("volumedown"): + { + break; + } + case ("volumefeedback"): + { + if (intFeedback != null) + { + var volumeFeedback = intFeedback; + volumeFeedback.LinkInputSig(_touchpanel.VolumeBargraph); + } + break; + } + case ("mute"): + { + if (boolFeedback != null) boolFeedback.LinkCrestronFeedback(_touchpanel.FeedbackMute); + break; + } + default: + { + if (boolFeedback != null) boolFeedback.LinkCrestronFeedback(_touchpanel.Feedbacks[(uint)buttonNumber]); + break; + } + } + } + }); } - void _Touchpanel_ButtonStateChange(GenericBase device, Crestron.SimplSharpPro.DeviceSupport.ButtonEventArgs args) + public bool TryParseInt(string str, out int result) + { + result = 0; + + foreach (var c in str) + { + if(c < '0' || c > '9') + return false; + + result = result*10 + (c - '0'); + } + + return true; + } + + void _touchpanel_ButtonStateChange(GenericBase device, Crestron.SimplSharpPro.DeviceSupport.ButtonEventArgs args) { Debug.Console(1, this, "Button {0} ({1}), {2}", args.Button.Number, args.Button.Name, args.NewButtonState); var type = args.NewButtonState.ToString(); - if (_Buttons.ContainsKey(args.Button.Number.ToString())) + if (_buttons.ContainsKey(args.Button.Number.ToString(CultureInfo.InvariantCulture))) { - Press(args.Button.Number.ToString(), type); + Press(args.Button.Number.ToString(CultureInfo.InvariantCulture), type); } - else if(_Buttons.ContainsKey(args.Button.Name.ToString())) + else if(_buttons.ContainsKey(args.Button.Name.ToString())) { Press(args.Button.Name.ToString(), type); } @@ -101,29 +162,30 @@ namespace PepperDash.Essentials.Core.Touchpanels /// Runs the function associated with this button/type. One of the following strings: /// Pressed, Released, Tapped, DoubleTapped, Held, HeldReleased /// - /// + /// /// - public void Press(string number, string type) + public void Press(string buttonKey, string type) { // TODO: In future, consider modifying this to generate actions at device activation time // to prevent the need to dynamically call the method via reflection on each button press - if (!_Buttons.ContainsKey(number)) { return; } - var but = _Buttons[number]; - if (but.EventTypes.ContainsKey(type)) - { - foreach (var a in but.EventTypes[type]) { DeviceJsonApi.DoDeviceAction(a); } - } + if (!_buttons.ContainsKey(buttonKey)) return; + + var button = _buttons[buttonKey]; + if (!button.EventTypes.ContainsKey(type)) return; + + foreach (var eventType in button.EventTypes[type]) DeviceJsonApi.DoDeviceAction(eventType); } - - } /// - /// Represents the configuration of a keybad buggon + /// Represents the configuration of a keypad button /// public class KeypadButton { + [JsonProperty("eventTypes")] public Dictionary EventTypes { get; set; } + + [JsonProperty("feedback")] public KeypadButtonFeedback Feedback { get; set; } public KeypadButton() @@ -133,12 +195,15 @@ namespace PepperDash.Essentials.Core.Touchpanels } } - /// - /// - /// - public class KeypadButtonFeedback - { - public string DeviceKey { get; set; } - public string FeedbackName { get; set; } - } + /// + /// Represents the configuration of a keypad button feedback + /// + public class KeypadButtonFeedback + { + [JsonProperty("deviceKey")] + public string DeviceKey { get; set; } + + [JsonProperty("feedbackName")] + public string FeedbackName { get; set; } + } } \ No newline at end of file From 13df52ab497f785cb114aaf7dbeea427e77fe012 Mon Sep 17 00:00:00 2001 From: Jason DeVito Date: Fri, 8 Sep 2023 13:47:34 -0500 Subject: [PATCH 62/96] refactor(wip): updates constructor postActiviate call to seperate methods for enabling/disabling buttons and feedbacks --- .../Touchpanels/Mpc3Touchpanel.cs | 574 +++++++++++++----- 1 file changed, 413 insertions(+), 161 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Mpc3Touchpanel.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Mpc3Touchpanel.cs index 97a18d50..2cab16e6 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Mpc3Touchpanel.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Mpc3Touchpanel.cs @@ -1,199 +1,451 @@ using System.Collections.Generic; using System.Globalization; +using System.Linq; using Crestron.SimplSharpPro; using Newtonsoft.Json; using PepperDash.Core; namespace PepperDash.Essentials.Core.Touchpanels { - /// - /// A wrapper class for the touchpanel portion of an MPC3 class process to allow for configurable - /// behavior of the keybad buttons - /// - public class Mpc3TouchpanelController : Device - { - readonly MPC3Basic _touchpanel; + /// + /// A wrapper class for the touchpanel portion of an MPC3 class process to allow for configurable + /// behavior of the keybad buttons + /// + public class Mpc3TouchpanelController : Device + { + readonly MPC3Basic _touchpanel; - readonly Dictionary _buttons; + readonly Dictionary _buttons; + + public Mpc3TouchpanelController(string key, string name, CrestronControlSystem processor, Dictionary buttons) + : base(key, name) + { + _touchpanel = processor.ControllerTouchScreenSlotDevice as MPC3Basic; + if (_touchpanel == null) + { + Debug.Console(1, this, "Failed to construct MPC3 Touchpanel Controller with key {0}, check configuration", key); + return; + } - public Mpc3TouchpanelController(string key, string name, CrestronControlSystem processor, Dictionary buttons) - : base(key, name) - { - _touchpanel = processor.ControllerTouchScreenSlotDevice as MPC3Basic; - if (_touchpanel == null) - { - Debug.Console(1, this, "Failed to construct {0}, check configuration", key); - return; - } - _touchpanel.ButtonStateChange += _touchpanel_ButtonStateChange; _buttons = buttons; - AddPostActivationAction(() => - { - // Link up the button feedbacks to the specified BoolFeedbacks - foreach (var button in _buttons) - { - var buttonKey = button.Key.ToLower(); - var buttonConfig = button.Value; - if (buttonConfig == null) - { - Debug.Console(1, this, "Unable to get button config for {0}-{1}", Key, button.Key); - continue; - } + AddPostActivationAction(() => + { + SetupButtonsForEvents(); + SetupButtonFeedbacks(); - int buttonNumber; - if (TryParseInt(buttonKey, out buttonNumber)) + // check button config + //foreach (var button in _buttons) + //{ + // var buttonKey = button.Key.ToLower(); + // var buttonConfig = button.Value; + // if (buttonConfig == null) + // { + // Debug.Console(1, this, "Unable to get button config for {0}-{1}", Key, button.Key); + // continue; + // } + + // int buttonNumber; + // if (TryParseInt(buttonKey, out buttonNumber)) + // Debug.Console(0, this, "buttonFeedback: tryIntParse successful, buttonNumber = {0}", buttonNumber); + // else + // Debug.Console(0, this, "buttonFeedback: tryIntParse failed, buttonKey = {0}", buttonKey); + + + // // button event type configuration enables/disables keypad button + // var buttonEventTypes = buttonConfig.EventTypes; + // switch (buttonKey) + // { + // case ("power"): + // { + // if (buttonEventTypes == null) + // _touchpanel.DisablePowerButton(); + // else + // _touchpanel.EnablePowerButton(); + + // break; + // } + // case ("volumeup"): + // { + // if (buttonEventTypes == null) + // _touchpanel.DisableVolumeUpButton(); + + // break; + // } + // case ("volumedown"): + // { + // if(buttonEventTypes == null) + // _touchpanel.DisableVolumeDownButton(); + + // break; + // } + // case ("volumefeedback"): + // { + + // break; + // } + // case ("mute"): + // { + // if(buttonEventTypes == null) + // _touchpanel.DisableMuteButton(); + // else + // _touchpanel.EnableMuteButton(); + + // break; + // } + // default: + // { + // if(buttonNumber == 0) + // break; + + // if (buttonEventTypes == null) + // _touchpanel.DisableNumericalButton((uint)buttonNumber); + // else + // _touchpanel.EnableNumericalButton((uint)buttonNumber); + + // break; + // } + // } + + + // // Link up the button feedbacks to the specified device feedback + // var buttonFeedback = buttonConfig.Feedback; + // if (buttonFeedback == null) + // { + // Debug.Console(1, this, "Button '{0}' feedback not configured, feedback will not be implemented", buttonKey); + // continue; + // } + + // var device = DeviceManager.GetDeviceForKey(buttonFeedback.DeviceKey) as Device; + // if (device == null) + // { + // Debug.Console(1, this, "Unable to get device with key {0}, feedback will not be implemented", + // buttonFeedback.DeviceKey); + // continue; + // } + + // var deviceFeedback = device.GetFeedbackProperty(buttonFeedback.FeedbackName); + // Debug.Console(0, this, "deviceFeedback.GetType().Name: {0}", deviceFeedback.GetType().Name); + // //switch (feedback.GetType().Name.ToLower()) + // //{ + // // case("boolfeedback"): + // // { + + // // break; + // // } + // // case("intfeedback"): + // // { + + // // break; + // // } + // //} + + // var boolFeedback = deviceFeedback as BoolFeedback; + // var intFeedback = deviceFeedback as IntFeedback; + + // switch (buttonKey) + // { + // case ("power"): + // { + // if (boolFeedback != null) boolFeedback.LinkCrestronFeedback(_touchpanel.FeedbackPower); + // break; + // } + // case ("volumeup"): + // { + // break; + // } + // case ("volumedown"): + // { + // break; + // } + // case ("volumefeedback"): + // { + // if (intFeedback != null) + // { + // var volumeFeedback = intFeedback; + // volumeFeedback.LinkInputSig(_touchpanel.VolumeBargraph); + // } + // break; + // } + // case ("mute"): + // { + // if (boolFeedback != null) boolFeedback.LinkCrestronFeedback(_touchpanel.FeedbackMute); + // break; + // } + // default: + // { + // if (boolFeedback != null) boolFeedback.LinkCrestronFeedback(_touchpanel.Feedbacks[(uint)buttonNumber]); + // break; + // } + // } + //} + }); + } + + public void SetupButtonsForEvents() + { + if (_buttons == null) + { + Debug.Console(1, this, "Button properties are null, failed to setup buttons for events. Verify button configuraiton."); + return; + } + + // check button config + foreach (var button in _buttons) + { + var buttonKey = button.Key.ToLower(); + var buttonConfig = button.Value; + if (buttonConfig == null) + { + Debug.Console(1, this, "Unable to get button config for {0}-{1}", Key, button.Key); + continue; + } + + int buttonNumber; + if (TryParseInt(buttonKey, out buttonNumber)) + Debug.Console(0, this, "buttonFeedback: tryIntParse successful, buttonNumber = {0}", buttonNumber); + else + Debug.Console(0, this, "buttonFeedback: tryIntParse failed, buttonKey = {0}", buttonKey); + + + // button event type configuration enables/disables keypad button + var buttonEventTypes = buttonConfig.EventTypes; + switch (buttonKey) + { + case ("power"): { - Debug.Console(0, this, "buttonFeedback: tryIntParse successful, buttonNumber = {0}", buttonNumber); - _touchpanel.EnableNumericalButton((uint)buttonNumber); + if (buttonEventTypes == null) + _touchpanel.DisablePowerButton(); + else + _touchpanel.EnablePowerButton(); + + break; } - else + case ("volumeup"): { - Debug.Console(0, this, "buttonFeedback: tryIntParse failed, buttonKey = {0}", buttonKey); + if (buttonEventTypes == null) + _touchpanel.DisableVolumeUpButton(); + + break; } - - //var buttonEventTypes = buttonConfig.EventTypes; - - var buttonFeedback = buttonConfig.Feedback; - if (buttonFeedback == null) - { - Debug.Console(1, this, "Button '{0}' feedback not configured, feedback will not be implemented", buttonKey); - continue; - } - - var device = DeviceManager.GetDeviceForKey(buttonFeedback.DeviceKey) as Device; - if (device == null) - { - Debug.Console(1, this, "Unable to get device with key {0}, feedback will not be implemented", - buttonFeedback.DeviceKey); - continue; - } - - var deviceFeedback = device.GetFeedbackProperty(buttonFeedback.FeedbackName); - Debug.Console(0, this, "deviceFeedback.GetType().Name: {0}", deviceFeedback.GetType().Name); - //switch (feedback.GetType().Name.ToLower()) - //{ - // case("boolfeedback"): - // { - - // break; - // } - // case("intfeedback"): - // { - - // break; - // } - //} - - var boolFeedback = deviceFeedback as BoolFeedback; - var intFeedback = deviceFeedback as IntFeedback; - - switch (buttonKey) + case ("volumedown"): { - case ("power"): + if (buttonEventTypes == null) + _touchpanel.DisableVolumeDownButton(); + + break; + } + case ("volumefeedback"): + { + + break; + } + case ("mute"): + { + if (buttonEventTypes == null) + _touchpanel.DisableMuteButton(); + else + _touchpanel.EnableMuteButton(); + + break; + } + default: + { + if (buttonNumber == 0) + break; + + if (buttonEventTypes == null) + _touchpanel.DisableNumericalButton((uint) buttonNumber); + else + _touchpanel.EnableNumericalButton((uint) buttonNumber); + + break; + } + } + } + } + + public void SetupButtonFeedbacks() + { + if (_buttons == null) + { + Debug.Console(1, this, "Button properties are null, failed to setup buttons for events. Verify button configuraiton."); + return; + } + + // check button config + foreach (var button in _buttons) + { + var buttonKey = button.Key.ToLower(); + var buttonConfig = button.Value; + if (buttonConfig == null) + { + Debug.Console(1, this, "Unable to get button config for {0}-{1}", Key, button.Key); + continue; + } + + int buttonNumber; + if (TryParseInt(buttonKey, out buttonNumber)) + Debug.Console(0, this, "buttonFeedback: tryIntParse successful, buttonNumber = {0}", buttonNumber); + else + Debug.Console(0, this, "buttonFeedback: tryIntParse failed, buttonKey = {0}", buttonKey); + + // Link up the button feedbacks to the specified device feedback + var buttonFeedback = buttonConfig.Feedback; + if (buttonFeedback == null) + { + Debug.Console(1, this, "Button '{0}' feedback not configured, feedback will not be implemented", buttonKey); + continue; + } + + var device = DeviceManager.GetDeviceForKey(buttonFeedback.DeviceKey) as Device; + if (device == null) + { + Debug.Console(1, this, "Unable to get device with key {0}, feedback will not be implemented", + buttonFeedback.DeviceKey); + continue; + } + + var deviceFeedback = device.GetFeedbackProperty(buttonFeedback.FeedbackName); + Debug.Console(0, this, "deviceFeedback.GetType().Name: {0}", deviceFeedback.GetType().Name); + //switch (feedback.GetType().Name.ToLower()) + //{ + // case("boolfeedback"): + // { + + // break; + // } + // case("intfeedback"): + // { + + // break; + // } + //} + + var boolFeedback = deviceFeedback as BoolFeedback; + var intFeedback = deviceFeedback as IntFeedback; + + switch (buttonKey) + { + case ("power"): + { + if (boolFeedback != null) boolFeedback.LinkCrestronFeedback(_touchpanel.FeedbackPower); + break; + } + case ("volumeup"): + { + break; + } + case ("volumedown"): + { + break; + } + case ("volumefeedback"): + { + if (intFeedback != null) { - if (boolFeedback != null) boolFeedback.LinkCrestronFeedback(_touchpanel.FeedbackPower); - break; + var volumeFeedback = intFeedback; + volumeFeedback.LinkInputSig(_touchpanel.VolumeBargraph); } - case ("volumeup"): - { - break; - } - case ("volumedown"): - { - break; - } - case ("volumefeedback"): - { - if (intFeedback != null) - { - var volumeFeedback = intFeedback; - volumeFeedback.LinkInputSig(_touchpanel.VolumeBargraph); - } - break; - } - case ("mute"): - { - if (boolFeedback != null) boolFeedback.LinkCrestronFeedback(_touchpanel.FeedbackMute); - break; - } - default: - { - if (boolFeedback != null) boolFeedback.LinkCrestronFeedback(_touchpanel.Feedbacks[(uint)buttonNumber]); - break; - } - } - } - }); - } + break; + } + case ("mute"): + { + if (boolFeedback != null) boolFeedback.LinkCrestronFeedback(_touchpanel.FeedbackMute); + break; + } + default: + { + if (boolFeedback != null) boolFeedback.LinkCrestronFeedback(_touchpanel.Feedbacks[(uint)buttonNumber]); + break; + } + } + } + } - public bool TryParseInt(string str, out int result) - { - result = 0; + public bool TryParseInt(string str, out int result) + { + try + { + result = int.Parse(str); + return true; + } + catch + { + result = 0; + return false; + } + } - foreach (var c in str) - { - if(c < '0' || c > '9') - return false; + public bool TryExtractInt(string str, out int result) + { + result = str.Where(c => c >= '0' && c <= '9').Aggregate(0, (current, c) => current * 10 + (c - '0')); - result = result*10 + (c - '0'); - } + //foreach (var c in str) + //{ + // if(c < '0' || c > '9') + // //return false + // continue; - return true; - } + // result = result*10 + (c - '0'); + //} - void _touchpanel_ButtonStateChange(GenericBase device, Crestron.SimplSharpPro.DeviceSupport.ButtonEventArgs args) - { - Debug.Console(1, this, "Button {0} ({1}), {2}", args.Button.Number, args.Button.Name, args.NewButtonState); - var type = args.NewButtonState.ToString(); + Debug.Console(0, this, "TryParseInt: str-'{0}', result-'{1}'", str, result); + return result != 0; + } - if (_buttons.ContainsKey(args.Button.Number.ToString(CultureInfo.InvariantCulture))) - { - Press(args.Button.Number.ToString(CultureInfo.InvariantCulture), type); - } - else if(_buttons.ContainsKey(args.Button.Name.ToString())) - { - Press(args.Button.Name.ToString(), type); - } - } + void _touchpanel_ButtonStateChange(GenericBase device, Crestron.SimplSharpPro.DeviceSupport.ButtonEventArgs args) + { + Debug.Console(1, this, "Button {0} ({1}), {2}", args.Button.Number, args.Button.Name, args.NewButtonState); + var type = args.NewButtonState.ToString(); - /// - /// Runs the function associated with this button/type. One of the following strings: - /// Pressed, Released, Tapped, DoubleTapped, Held, HeldReleased - /// - /// - /// - public void Press(string buttonKey, string type) - { - // TODO: In future, consider modifying this to generate actions at device activation time - // to prevent the need to dynamically call the method via reflection on each button press - if (!_buttons.ContainsKey(buttonKey)) return; + if (_buttons.ContainsKey(args.Button.Number.ToString(CultureInfo.InvariantCulture))) + { + Press(args.Button.Number.ToString(CultureInfo.InvariantCulture), type); + } + else if (_buttons.ContainsKey(args.Button.Name.ToString())) + { + Press(args.Button.Name.ToString(), type); + } + } - var button = _buttons[buttonKey]; - if (!button.EventTypes.ContainsKey(type)) return; + /// + /// Runs the function associated with this button/type. One of the following strings: + /// Pressed, Released, Tapped, DoubleTapped, Held, HeldReleased + /// + /// + /// + public void Press(string buttonKey, string type) + { + // TODO: In future, consider modifying this to generate actions at device activation time + // to prevent the need to dynamically call the method via reflection on each button press + if (!_buttons.ContainsKey(buttonKey)) return; - foreach (var eventType in button.EventTypes[type]) DeviceJsonApi.DoDeviceAction(eventType); - } - } + var button = _buttons[buttonKey]; + if (!button.EventTypes.ContainsKey(type)) return; - /// - /// Represents the configuration of a keypad button - /// - public class KeypadButton - { + foreach (var eventType in button.EventTypes[type]) DeviceJsonApi.DoDeviceAction(eventType); + } + } + + /// + /// Represents the configuration of a keypad button + /// + public class KeypadButton + { [JsonProperty("eventTypes")] - public Dictionary EventTypes { get; set; } + public Dictionary EventTypes { get; set; } [JsonProperty("feedback")] - public KeypadButtonFeedback Feedback { get; set; } + public KeypadButtonFeedback Feedback { get; set; } - public KeypadButton() - { - EventTypes = new Dictionary(); - Feedback = new KeypadButtonFeedback(); - } - } + public KeypadButton() + { + EventTypes = new Dictionary(); + Feedback = new KeypadButtonFeedback(); + } + } /// /// Represents the configuration of a keypad button feedback From 316d545bda853569792c2e56b337470a4661c576 Mon Sep 17 00:00:00 2001 From: Jason DeVito Date: Fri, 8 Sep 2023 15:20:29 -0500 Subject: [PATCH 63/96] refactor(wip): updates keypad initializeFeedbacks method --- .../Touchpanels/Mpc3Touchpanel.cs | 402 +++++------------- 1 file changed, 118 insertions(+), 284 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Mpc3Touchpanel.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Mpc3Touchpanel.cs index 2cab16e6..f4611a70 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Mpc3Touchpanel.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Mpc3Touchpanel.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using System.Globalization; -using System.Linq; using Crestron.SimplSharpPro; using Newtonsoft.Json; using PepperDash.Core; @@ -29,191 +28,47 @@ namespace PepperDash.Essentials.Core.Touchpanels _touchpanel.ButtonStateChange += _touchpanel_ButtonStateChange; _buttons = buttons; - - AddPostActivationAction(() => - { - SetupButtonsForEvents(); - SetupButtonFeedbacks(); - - // check button config - //foreach (var button in _buttons) - //{ - // var buttonKey = button.Key.ToLower(); - // var buttonConfig = button.Value; - // if (buttonConfig == null) - // { - // Debug.Console(1, this, "Unable to get button config for {0}-{1}", Key, button.Key); - // continue; - // } - - // int buttonNumber; - // if (TryParseInt(buttonKey, out buttonNumber)) - // Debug.Console(0, this, "buttonFeedback: tryIntParse successful, buttonNumber = {0}", buttonNumber); - // else - // Debug.Console(0, this, "buttonFeedback: tryIntParse failed, buttonKey = {0}", buttonKey); - - - // // button event type configuration enables/disables keypad button - // var buttonEventTypes = buttonConfig.EventTypes; - // switch (buttonKey) - // { - // case ("power"): - // { - // if (buttonEventTypes == null) - // _touchpanel.DisablePowerButton(); - // else - // _touchpanel.EnablePowerButton(); - - // break; - // } - // case ("volumeup"): - // { - // if (buttonEventTypes == null) - // _touchpanel.DisableVolumeUpButton(); - - // break; - // } - // case ("volumedown"): - // { - // if(buttonEventTypes == null) - // _touchpanel.DisableVolumeDownButton(); - - // break; - // } - // case ("volumefeedback"): - // { - - // break; - // } - // case ("mute"): - // { - // if(buttonEventTypes == null) - // _touchpanel.DisableMuteButton(); - // else - // _touchpanel.EnableMuteButton(); - - // break; - // } - // default: - // { - // if(buttonNumber == 0) - // break; - - // if (buttonEventTypes == null) - // _touchpanel.DisableNumericalButton((uint)buttonNumber); - // else - // _touchpanel.EnableNumericalButton((uint)buttonNumber); - - // break; - // } - // } - - - // // Link up the button feedbacks to the specified device feedback - // var buttonFeedback = buttonConfig.Feedback; - // if (buttonFeedback == null) - // { - // Debug.Console(1, this, "Button '{0}' feedback not configured, feedback will not be implemented", buttonKey); - // continue; - // } - - // var device = DeviceManager.GetDeviceForKey(buttonFeedback.DeviceKey) as Device; - // if (device == null) - // { - // Debug.Console(1, this, "Unable to get device with key {0}, feedback will not be implemented", - // buttonFeedback.DeviceKey); - // continue; - // } - - // var deviceFeedback = device.GetFeedbackProperty(buttonFeedback.FeedbackName); - // Debug.Console(0, this, "deviceFeedback.GetType().Name: {0}", deviceFeedback.GetType().Name); - // //switch (feedback.GetType().Name.ToLower()) - // //{ - // // case("boolfeedback"): - // // { - - // // break; - // // } - // // case("intfeedback"): - // // { - - // // break; - // // } - // //} - - // var boolFeedback = deviceFeedback as BoolFeedback; - // var intFeedback = deviceFeedback as IntFeedback; - - // switch (buttonKey) - // { - // case ("power"): - // { - // if (boolFeedback != null) boolFeedback.LinkCrestronFeedback(_touchpanel.FeedbackPower); - // break; - // } - // case ("volumeup"): - // { - // break; - // } - // case ("volumedown"): - // { - // break; - // } - // case ("volumefeedback"): - // { - // if (intFeedback != null) - // { - // var volumeFeedback = intFeedback; - // volumeFeedback.LinkInputSig(_touchpanel.VolumeBargraph); - // } - // break; - // } - // case ("mute"): - // { - // if (boolFeedback != null) boolFeedback.LinkCrestronFeedback(_touchpanel.FeedbackMute); - // break; - // } - // default: - // { - // if (boolFeedback != null) boolFeedback.LinkCrestronFeedback(_touchpanel.Feedbacks[(uint)buttonNumber]); - // break; - // } - // } - //} - }); - } - - public void SetupButtonsForEvents() - { if (_buttons == null) { - Debug.Console(1, this, "Button properties are null, failed to setup buttons for events. Verify button configuraiton."); + Debug.Console(1, this, + "Button properties are null, failed to setup MPC3 Touch Controller, check configuration"); return; } - // check button config - foreach (var button in _buttons) + AddPostActivationAction(() => { - var buttonKey = button.Key.ToLower(); - var buttonConfig = button.Value; - if (buttonConfig == null) + foreach (var button in _buttons) { - Debug.Console(1, this, "Unable to get button config for {0}-{1}", Key, button.Key); - continue; + var buttonKey = button.Key.ToLower(); + var buttonConfig = button.Value; + + InitializeButton(buttonKey, buttonConfig); + InitializeButtonFeedback(buttonKey, buttonConfig); } + }); + } - int buttonNumber; - if (TryParseInt(buttonKey, out buttonNumber)) - Debug.Console(0, this, "buttonFeedback: tryIntParse successful, buttonNumber = {0}", buttonNumber); - else - Debug.Console(0, this, "buttonFeedback: tryIntParse failed, buttonKey = {0}", buttonKey); + /// + /// Enables/disables buttons based on event type configuration + /// + /// + /// + public void InitializeButton(string key, KeypadButton config) + { + if (config == null) + { + Debug.Console(1, this, "Button '{0}' config is null, unable to initialize", key); + return; + } + int buttonNumber; + TryParseInt(key, out buttonNumber); - // button event type configuration enables/disables keypad button - var buttonEventTypes = buttonConfig.EventTypes; - switch (buttonKey) - { - case ("power"): + var buttonEventTypes = config.EventTypes; + + switch (key) + { + case ("power"): { if (buttonEventTypes == null) _touchpanel.DisablePowerButton(); @@ -222,26 +77,26 @@ namespace PepperDash.Essentials.Core.Touchpanels break; } - case ("volumeup"): + case ("volumeup"): { if (buttonEventTypes == null) _touchpanel.DisableVolumeUpButton(); break; } - case ("volumedown"): + case ("volumedown"): { if (buttonEventTypes == null) _touchpanel.DisableVolumeDownButton(); break; } - case ("volumefeedback"): + case ("volumefeedback"): { break; } - case ("mute"): + case ("mute"): { if (buttonEventTypes == null) _touchpanel.DisableMuteButton(); @@ -250,120 +105,116 @@ namespace PepperDash.Essentials.Core.Touchpanels break; } - default: + default: { if (buttonNumber == 0) break; if (buttonEventTypes == null) - _touchpanel.DisableNumericalButton((uint) buttonNumber); + _touchpanel.DisableNumericalButton((uint)buttonNumber); else - _touchpanel.EnableNumericalButton((uint) buttonNumber); + _touchpanel.EnableNumericalButton((uint)buttonNumber); break; } - } } + + Debug.Console(1, this, "Button '{0}' {1}", key, buttonEventTypes == null + ? "is disabled, verify eventTypes are configured." + : "is enabled"); } - public void SetupButtonFeedbacks() + /// + /// Links button feedback if configured + /// + /// + /// + public void InitializeButtonFeedback(string key, KeypadButton config) { - if (_buttons == null) + if (config == null) { - Debug.Console(1, this, "Button properties are null, failed to setup buttons for events. Verify button configuraiton."); + Debug.Console(1, this, "Button '{0}' config is null, unable to initialize feedback", key); return; } - // check button config - foreach (var button in _buttons) + int buttonNumber; + TryParseInt(key, out buttonNumber); + + // Link up the button feedbacks to the specified device feedback + var buttonFeedback = config.Feedback; + if (buttonFeedback == null) { - var buttonKey = button.Key.ToLower(); - var buttonConfig = button.Value; - if (buttonConfig == null) - { - Debug.Console(1, this, "Unable to get button config for {0}-{1}", Key, button.Key); - continue; - } + Debug.Console(1, this, "Button '{0}' feedback not configured and will not be implemented. Verify feedback is configured if required.", key); + return; + } - int buttonNumber; - if (TryParseInt(buttonKey, out buttonNumber)) - Debug.Console(0, this, "buttonFeedback: tryIntParse successful, buttonNumber = {0}", buttonNumber); - else - Debug.Console(0, this, "buttonFeedback: tryIntParse failed, buttonKey = {0}", buttonKey); + var device = DeviceManager.GetDeviceForKey(buttonFeedback.DeviceKey) as Device; + if (device == null) + { + Debug.Console(1, this, "Button '{0}' feedback device with key '{0}' not found, feedback will not be implemented. Verify feedback deviceKey is properly configured.", + buttonFeedback.DeviceKey); + return; + } - // Link up the button feedbacks to the specified device feedback - var buttonFeedback = buttonConfig.Feedback; - if (buttonFeedback == null) - { - Debug.Console(1, this, "Button '{0}' feedback not configured, feedback will not be implemented", buttonKey); - continue; - } + // TODO [ ] verify if this can replace the current method + var deviceFeedback = device.GetFeedbackProperty(buttonFeedback.FeedbackName); + Debug.Console(0, this, "deviceFeedback.GetType().Name: '{0}'", deviceFeedback.GetType().Name); + //switch (feedback.GetType().Name.ToLower()) + //{ + // case("boolfeedback"): + // { + // break; + // } + // case("intfeedback"): + // { + // break; + // } + // case("stringfeedback"): + // { + // break; + // } + //} - var device = DeviceManager.GetDeviceForKey(buttonFeedback.DeviceKey) as Device; - if (device == null) - { - Debug.Console(1, this, "Unable to get device with key {0}, feedback will not be implemented", - buttonFeedback.DeviceKey); - continue; - } + var boolFeedback = deviceFeedback as BoolFeedback; + var intFeedback = deviceFeedback as IntFeedback; - var deviceFeedback = device.GetFeedbackProperty(buttonFeedback.FeedbackName); - Debug.Console(0, this, "deviceFeedback.GetType().Name: {0}", deviceFeedback.GetType().Name); - //switch (feedback.GetType().Name.ToLower()) - //{ - // case("boolfeedback"): - // { - - // break; - // } - // case("intfeedback"): - // { - - // break; - // } - //} - - var boolFeedback = deviceFeedback as BoolFeedback; - var intFeedback = deviceFeedback as IntFeedback; - - switch (buttonKey) - { - case ("power"): + switch (key) + { + case ("power"): + { + if (boolFeedback != null) boolFeedback.LinkCrestronFeedback(_touchpanel.FeedbackPower); + break; + } + case ("volumeup"): + case ("volumedown"): + case ("volumefeedback"): + { + if (intFeedback != null) { - if (boolFeedback != null) boolFeedback.LinkCrestronFeedback(_touchpanel.FeedbackPower); - break; + var volumeFeedback = intFeedback; + volumeFeedback.LinkInputSig(_touchpanel.VolumeBargraph); } - case ("volumeup"): - { - break; - } - case ("volumedown"): - { - break; - } - case ("volumefeedback"): - { - if (intFeedback != null) - { - var volumeFeedback = intFeedback; - volumeFeedback.LinkInputSig(_touchpanel.VolumeBargraph); - } - break; - } - case ("mute"): - { - if (boolFeedback != null) boolFeedback.LinkCrestronFeedback(_touchpanel.FeedbackMute); - break; - } - default: - { - if (boolFeedback != null) boolFeedback.LinkCrestronFeedback(_touchpanel.Feedbacks[(uint)buttonNumber]); - break; - } - } + break; + } + case ("mute"): + { + if (boolFeedback != null) boolFeedback.LinkCrestronFeedback(_touchpanel.FeedbackMute); + break; + } + default: + { + if (boolFeedback != null) boolFeedback.LinkCrestronFeedback(_touchpanel.Feedbacks[(uint)buttonNumber]); + break; + } } } + /// + /// Try parse int helper method + /// + /// + /// + /// public bool TryParseInt(string str, out int result) { try @@ -378,24 +229,7 @@ namespace PepperDash.Essentials.Core.Touchpanels } } - public bool TryExtractInt(string str, out int result) - { - result = str.Where(c => c >= '0' && c <= '9').Aggregate(0, (current, c) => current * 10 + (c - '0')); - - //foreach (var c in str) - //{ - // if(c < '0' || c > '9') - // //return false - // continue; - - // result = result*10 + (c - '0'); - //} - - Debug.Console(0, this, "TryParseInt: str-'{0}', result-'{1}'", str, result); - return result != 0; - } - - void _touchpanel_ButtonStateChange(GenericBase device, Crestron.SimplSharpPro.DeviceSupport.ButtonEventArgs args) + private void _touchpanel_ButtonStateChange(GenericBase device, Crestron.SimplSharpPro.DeviceSupport.ButtonEventArgs args) { Debug.Console(1, this, "Button {0} ({1}), {2}", args.Button.Number, args.Button.Name, args.NewButtonState); var type = args.NewButtonState.ToString(); From 97c0bddb48aa4ed3dbdc82cd2fc231c7daa3ae86 Mon Sep 17 00:00:00 2001 From: Jason DeVito Date: Mon, 11 Sep 2023 14:49:46 -0500 Subject: [PATCH 64/96] fix(wip): refactors SetupInputs() and SetupOutputs() to handle io types --- .../Chassis/HdPsXxxController.cs | 192 ++++++++---------- 1 file changed, 80 insertions(+), 112 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs index d923949e..9884be8e 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs @@ -21,8 +21,6 @@ namespace PepperDash_Essentials_DM.Chassis { private readonly HdPsXxx _chassis; - private readonly HdPs401 _chassis401; - private readonly HdPs621 _chassis621; public RoutingPortCollection InputPorts { get; private set; } public RoutingPortCollection OutputPorts { get; private set; } @@ -63,33 +61,35 @@ namespace PepperDash_Essentials_DM.Chassis return; } - InputPorts = new RoutingPortCollection(); + InputPorts = new RoutingPortCollection(); InputNameFeedbacks = new FeedbackCollection(); InputHdcpEnableFeedback = new FeedbackCollection(); - InputNames = new Dictionary(); - //InputNames = props.Inputs; + InputNames = new Dictionary(); OutputPorts = new RoutingPortCollection(); OutputNameFeedbacks = new FeedbackCollection(); OutputRouteNameFeedback = new FeedbackCollection(); OutputNames = new Dictionary(); - //OutputNames = props.Outputs; VideoInputSyncFeedbacks = new FeedbackCollection(); VideoOutputRouteFeedbacks = new FeedbackCollection(); if (_chassis.NumberOfOutputs == 1) { - if (_chassis is HdPs401) - _chassis401 = _chassis as HdPs401; - if (_chassis is HdPs621) - _chassis621 = _chassis as HdPs621; + //if (_chassis is HdPs401) + // _chassis401 = _chassis as HdPs401; + //if (_chassis is HdPs621) + // _chassis621 = _chassis as HdPs621; - AutoRouteFeedback = new BoolFeedback(() => _chassis401.PriorityRouteOnFeedback.BoolValue); + AutoRouteFeedback = new BoolFeedback(() => _chassis.PriorityRouteOnFeedback.BoolValue); } - SetupInputs(props.Inputs); - SetupOutputs(props.Outputs); + + InputNames = props.Inputs; + SetupInputs(InputNames); + + OutputNames = props.Outputs; + SetupOutputs(OutputNames); AddPostActivationAction(AddFeedbackCollecitons); } @@ -106,35 +106,49 @@ namespace PepperDash_Essentials_DM.Chassis { Debug.Console(1, this, "props.Input[{0}]: {1}", kvp.Key, kvp.Value); } - InputNames = dict; - for (uint i = 1; i <= _chassis.NumberOfInputs; i++) + foreach (var item in _chassis.HdmiInputs) { - var index = i; - var name = string.IsNullOrEmpty(InputNames[index]) ? string.Format("Input {0}", index) : InputNames[index]; - var input = _chassis.Inputs[index]; - var hdmiInput = _chassis.HdmiInputs[index]; - var dmLiteInput = _chassis.DmLiteInputs[index]; - + var input = item; + var index = item.Number; + var name = string.IsNullOrEmpty(InputNames[index]) ? string.Format("HDMI Input {0}", index) : InputNames[index]; + InputNameFeedbacks.Add(new StringFeedback(name, () => InputNames[index])); - // TODO [ ] verify which input type is needed - input.Name.StringValue = name; - hdmiInput.Name.StringValue = name; - dmLiteInput.Name.StringValue = name; - var port = new RoutingInputPort(name, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, input, this) { FeedbackMatchObject = input }; InputPorts.Add(port); - InputHdcpEnableFeedback.Add(new BoolFeedback(name, () => hdmiInput.InputPort.HdcpSupportOnFeedback.BoolValue)); + InputHdcpEnableFeedback.Add(new BoolFeedback(name, () => input.InputPort.HdcpSupportOnFeedback.BoolValue)); VideoInputSyncFeedbacks.Add(new BoolFeedback(name, () => input.VideoDetectedFeedback.BoolValue)); } - _chassis.DMInputChange += _chassis_InputChange; + foreach (var item in _chassis.DmLiteInputs) + { + var input = item; + var index = item.Number; + + var name = string.IsNullOrEmpty(InputNames[index]) ? string.Format("DM Input {0}", index) : InputNames[index]; + input.Name.StringValue = name; + + InputNameFeedbacks.Add(new StringFeedback(name, () => InputNames[index])); + + var port = new RoutingInputPort(name, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, input, this) + { + FeedbackMatchObject = input + }; + InputPorts.Add(port); + + + InputHdcpEnableFeedback.Add(new BoolFeedback(name, () => input.InputPort.HdcpSupportOnFeedback.BoolValue)); + + VideoInputSyncFeedbacks.Add(new BoolFeedback(name, () => input.VideoDetectedFeedback.BoolValue)); + } + + _chassis.DMInputChange += _chassis_InputChange; } // output setup @@ -149,20 +163,14 @@ namespace PepperDash_Essentials_DM.Chassis { Debug.Console(1, this, "props.Output[{0}]: {1}", kvp.Key, kvp.Value); } - OutputNames = dict; - for (uint i = 1; i <= _chassis.NumberOfOutputs; i++) + foreach (var item in _chassis.HdmiDmLiteOutputs) { - var index = i; + var output = item; + var index = item.Number; + var name = string.IsNullOrEmpty(OutputNames[index]) ? string.Format("Output {0}", index) : OutputNames[index]; - var output = _chassis.Outputs[index]; - var hdmiDmLiteOutput = _chassis.HdmiDmLiteOutputs[index]; - - OutputNameFeedbacks.Add(new StringFeedback(name, () => OutputNames[index])); - - // TODO [ ] verify which output type is needed output.Name.StringValue = name; - hdmiDmLiteOutput.Name.StringValue = name; var port = new RoutingOutputPort(name, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, output, this) { @@ -206,10 +214,6 @@ namespace PepperDash_Essentials_DM.Chassis _chassis.OnlineStatusChange += _chassis_OnlineStatusChange; - if (_chassis401 != null) LinkChassis401ToApi(trilist, joinMap); - - if (_chassis621 != null) LinkChassis621ToApi(trilist, joinMap); - LinkChassisInputsToApi(trilist, joinMap); LinkChassisOutputsToApi(trilist, joinMap); @@ -252,36 +256,17 @@ namespace PepperDash_Essentials_DM.Chassis var indexWithOffset = output - 1; trilist.SetUShortSigAction(joinMap.OutputRoute.JoinNumber + indexWithOffset, (a) => - ExecuteNumericSwitch(a, (ushort) output, eRoutingSignalType.AudioVideo)); + ExecuteNumericSwitch(a, (ushort)output, eRoutingSignalType.AudioVideo)); OutputNameFeedbacks[outputName].LinkInputSig(trilist.StringInput[joinMap.OutputName.JoinNumber + indexWithOffset]); OutputRouteNameFeedback[outputName].LinkInputSig(trilist.StringInput[joinMap.OutputRoutedName.JoinNumber + indexWithOffset]); VideoOutputRouteFeedbacks[outputName].LinkInputSig(trilist.UShortInput[joinMap.OutputRoute.JoinNumber + indexWithOffset]); } - } - - - // links HdPs401 chassis to API - private void LinkChassis401ToApi(BasicTriList trilist, HdPsXxxControllerJoinMap joinMap) - { - trilist.SetSigTrueAction(joinMap.EnableAutoRoute.JoinNumber, () => _chassis401.AutoRouteOn()); - trilist.SetSigFalseAction(joinMap.EnableAutoRoute.JoinNumber, () => _chassis401.AutoRouteOff()); AutoRouteFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableAutoRoute.JoinNumber]); } - - // links HdPs621 chassis to API - private void LinkChassis621ToApi(BasicTriList trilist, HdPsXxxControllerJoinMap joinMap) - { - trilist.SetSigTrueAction(joinMap.EnableAutoRoute.JoinNumber, () => _chassis621.AutoRouteOn()); - trilist.SetSigFalseAction(joinMap.EnableAutoRoute.JoinNumber, () => _chassis621.AutoRouteOff()); - - AutoRouteFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableAutoRoute.JoinNumber]); - } - - #endregion @@ -359,17 +344,9 @@ namespace PepperDash_Essentials_DM.Chassis /// public void EnableAutoRoute() { - if (_chassis.NumberOfInputs != 1) return; + if (_chassis.NumberOfInputs == 1) return; - if (_chassis401 != null) - { - _chassis401.AutoRouteOn(); - } - - if (_chassis621 != null) - { - _chassis621.AutoRouteOn(); - } + _chassis.AutoRouteOn(); } @@ -378,20 +355,12 @@ namespace PepperDash_Essentials_DM.Chassis /// public void DisableAutoRoute() { - if (_chassis.NumberOfInputs != 1) return; + if (_chassis.NumberOfInputs == 1) return; - if (_chassis401 != null) - { - _chassis401.AutoRouteOff(); - } - - if (_chassis621 != null) - { - _chassis621.AutoRouteOff(); - } + _chassis.AutoRouteOff(); } - #region Events + #region Events // _chassis online/offline event @@ -417,31 +386,31 @@ namespace PepperDash_Essentials_DM.Chassis switch (eventId) { case DMInputEventIds.VideoDetectedEventId: - { - Debug.Console(1, this, "Event ID {0}: Updating VideoInputSyncFeedbacks", eventId); - foreach (var item in VideoInputSyncFeedbacks) { - item.FireUpdate(); + Debug.Console(1, this, "Event ID {0}: Updating VideoInputSyncFeedbacks", eventId); + foreach (var item in VideoInputSyncFeedbacks) + { + item.FireUpdate(); + } + break; } - break; - } case DMInputEventIds.InputNameFeedbackEventId: case DMInputEventIds.InputNameEventId: case DMInputEventIds.NameFeedbackEventId: - { - Debug.Console(1, this, "Event ID {0}: Updating name feedbacks", eventId); + { + Debug.Console(1, this, "Event ID {0}: Updating name feedbacks", eventId); - var input = args.Number; - var name = _chassis.HdmiInputs[input].NameFeedback.StringValue; + var input = args.Number; + var name = _chassis.HdmiInputs[input].NameFeedback.StringValue; - Debug.Console(1, this, "Input {0} Name {1}", input, name); - break; - } + Debug.Console(1, this, "Input {0} Name {1}", input, name); + break; + } default: - { - Debug.Console(1, this, "Uhandled DM Input Event ID {0}", eventId); - break; - } + { + Debug.Console(1, this, "Uhandled DM Input Event ID {0}", eventId); + break; + } } } @@ -493,7 +462,7 @@ namespace PepperDash_Essentials_DM.Chassis /// - /// Add feedback colleciton arrays to feedback collections + /// Add feedback collection arrays to feedback collections /// /// BoolFeedback[] arrays public void AddCollectionsToList(params FeedbackCollection[] feedbackCollections) @@ -587,10 +556,10 @@ namespace PepperDash_Essentials_DM.Chassis /// public void AddFeedbackCollecitons() { - AddFeedbackToList(DeviceNameFeedback); - AddCollectionsToList(VideoInputSyncFeedbacks, InputHdcpEnableFeedback); - AddCollectionsToList(VideoOutputRouteFeedbacks); - AddCollectionsToList(InputNameFeedbacks, OutputNameFeedbacks, OutputRouteNameFeedback); + //AddFeedbackToList(DeviceNameFeedback); + //AddCollectionsToList(VideoInputSyncFeedbacks, InputHdcpEnableFeedback); + //AddCollectionsToList(VideoOutputRouteFeedbacks); + //AddCollectionsToList(InputNameFeedbacks, OutputNameFeedbacks, OutputRouteNameFeedback); } @@ -608,7 +577,11 @@ namespace PepperDash_Essentials_DM.Chassis } public override EssentialsDevice BuildDevice(DeviceConfig dc) { - Debug.Console(1, "Factory Attempting to create new HD-PSXxx device"); + var key = dc.Key; + var name = dc.Name; + var type = dc.Type.ToLower(); + + Debug.Console(1, "Factory Attempting to create new {0} device", type); var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); if (props == null) @@ -617,12 +590,7 @@ namespace PepperDash_Essentials_DM.Chassis return null; } - var key = dc.Key; - var name = dc.Name; - var type = dc.Type.ToLower(); - var control = props.Control; - var ipid = control.IpIdInt; - //var address = control.TcpSshProperties.Address; + var ipid = props.Control.IpIdInt; switch (type) { From 08af6370a6124800aacca276b4ec6a56d597e64f Mon Sep 17 00:00:00 2001 From: Jason DeVito Date: Mon, 11 Sep 2023 15:48:34 -0500 Subject: [PATCH 65/96] fix(wip): adds Debug.Console() statements to identify keys per input; adds ICec interface, pending implementation --- .../Chassis/HdPsXxxController.cs | 164 +++++------------- 1 file changed, 41 insertions(+), 123 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs index 9884be8e..f4c725f0 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs @@ -17,7 +17,7 @@ using PepperDash_Essentials_DM.Config; namespace PepperDash_Essentials_DM.Chassis { [Description("Wrapper class for all HdPsXxx switchers")] - public class HdPsXxxController : CrestronGenericBridgeableBaseDevice, IRoutingNumericWithFeedback, IHasFeedback + public class HdPsXxxController : CrestronGenericBridgeableBaseDevice, IRoutingNumericWithFeedback, ICec, IHasHdmiInHdcp, IHasFeedback { private readonly HdPsXxx _chassis; @@ -75,15 +75,7 @@ namespace PepperDash_Essentials_DM.Chassis VideoOutputRouteFeedbacks = new FeedbackCollection(); if (_chassis.NumberOfOutputs == 1) - { - //if (_chassis is HdPs401) - // _chassis401 = _chassis as HdPs401; - //if (_chassis is HdPs621) - // _chassis621 = _chassis as HdPs621; - AutoRouteFeedback = new BoolFeedback(() => _chassis.PriorityRouteOnFeedback.BoolValue); - } - InputNames = props.Inputs; SetupInputs(InputNames); @@ -91,7 +83,7 @@ namespace PepperDash_Essentials_DM.Chassis OutputNames = props.Outputs; SetupOutputs(OutputNames); - AddPostActivationAction(AddFeedbackCollecitons); + //AddPostActivationAction(); } // input setup @@ -107,6 +99,20 @@ namespace PepperDash_Essentials_DM.Chassis Debug.Console(1, this, "props.Input[{0}]: {1}", kvp.Key, kvp.Value); } + // TODO [ ] testing + var hdmiKeys = _chassis.HdmiInputs.Keys; + foreach (var key in hdmiKeys) + { + Debug.Console(0, this, "HDMI Input key-'{0}'", key); + } + + var dmKeys = _chassis.DmLiteInputs.Keys; + foreach (var key in dmKeys) + { + Debug.Console(0, this, "DM Input key-'{0}'", key); + } + + foreach (var item in _chassis.HdmiInputs) { var input = item; @@ -123,7 +129,7 @@ namespace PepperDash_Essentials_DM.Chassis InputHdcpEnableFeedback.Add(new BoolFeedback(name, () => input.InputPort.HdcpSupportOnFeedback.BoolValue)); - VideoInputSyncFeedbacks.Add(new BoolFeedback(name, () => input.VideoDetectedFeedback.BoolValue)); + VideoInputSyncFeedbacks.Add(new BoolFeedback(name, () => input.VideoDetectedFeedback.BoolValue)); } foreach (var item in _chassis.DmLiteInputs) @@ -164,9 +170,17 @@ namespace PepperDash_Essentials_DM.Chassis Debug.Console(1, this, "props.Output[{0}]: {1}", kvp.Key, kvp.Value); } + + // TODO [ ] testing + var keys = _chassis.HdmiDmLiteOutputs.Keys; + foreach (var key in keys) + { + Debug.Console(0, this, "HdmiDmLite Output key-'{0}'", key); + } + foreach (var item in _chassis.HdmiDmLiteOutputs) { - var output = item; + var output = item; var index = item.Number; var name = string.IsNullOrEmpty(OutputNames[index]) ? string.Format("Output {0}", index) : OutputNames[index]; @@ -182,7 +196,7 @@ namespace PepperDash_Essentials_DM.Chassis VideoOutputRouteFeedbacks.Add(new IntFeedback(name, () => output.VideoOutFeedback == null ? 0 : (int)output.VideoOutFeedback.Number)); } - + _chassis.DMOutputChange += _chassis_OutputChange; } @@ -268,7 +282,7 @@ namespace PepperDash_Essentials_DM.Chassis } #endregion - + /// /// Executes a device switch using objects @@ -455,115 +469,7 @@ namespace PepperDash_Essentials_DM.Chassis } - #endregion - - - #region FeedbacksAndFeedbackCollections - - - /// - /// Add feedback collection arrays to feedback collections - /// - /// BoolFeedback[] arrays - public void AddCollectionsToList(params FeedbackCollection[] feedbackCollections) - { - foreach (var item in feedbackCollections.SelectMany(feedbackCollection => feedbackCollections)) - { - AddCollectionsToList(item); - } - } - - - /// - /// Add feedback colleciton arrays to feedback collections - /// - /// IntFeedback[] arrays - public void AddCollectionsToList(params FeedbackCollection[] feedbackCollections) - { - foreach (var item in feedbackCollections.SelectMany(feedbackCollection => feedbackCollections)) - { - AddCollectionsToList(item); - } - } - - - /// - /// Add feedback colleciton arrays to feedback collections - /// - /// StringFeedback[] arrays - public void AddCollectionsToList(params FeedbackCollection[] feedbackCollections) - { - foreach (var item in feedbackCollections.SelectMany(feedbackCollection => feedbackCollections)) - { - AddCollectionsToList(item); - } - } - - - /// - /// Adds feedback colleciton to feedback collections - /// - /// BoolFeedback - public void AddCollectionToList(FeedbackCollection feedbackCollection) - { - foreach (var item in feedbackCollection.Where(item => item != null)) - { - AddFeedbackToList(item); - } - } - - - /// - /// Adds feedback colleciton to feedback collections - /// - /// IntFeedback - public void AddCollectionToList(FeedbackCollection feedbackCollection) - { - foreach (var item in feedbackCollection.Where(item => item != null)) - { - AddFeedbackToList(item); - } - } - - - /// - /// Adds feedback colleciton to feedback collections - /// - /// StringFeedback - public void AddCollectionToList(FeedbackCollection feedbackCollection) - { - foreach (var item in feedbackCollection.Where(item => item != null)) - { - AddFeedbackToList(item); - } - } - - - /// - /// Adds individual feedbacks to feedback collection - /// - /// Feedback - public void AddFeedbackToList(PepperDash.Essentials.Core.Feedback fb) - { - if (fb == null || Feedbacks.Contains(fb)) return; - - Feedbacks.Add(fb); - } - - - /// - /// Adds provided feedbacks to feedback collection list - /// - public void AddFeedbackCollecitons() - { - //AddFeedbackToList(DeviceNameFeedback); - //AddCollectionsToList(VideoInputSyncFeedbacks, InputHdcpEnableFeedback); - //AddCollectionsToList(VideoOutputRouteFeedbacks); - //AddCollectionsToList(InputNameFeedbacks, OutputNameFeedbacks, OutputRouteNameFeedback); - } - - - #endregion + #endregion #region Factory @@ -621,5 +527,17 @@ namespace PepperDash_Essentials_DM.Chassis #endregion + + // TODO [ ] Implement CEC control + // return _chassis.HdmiDmLiteOutputs[0].DmLiteOutput.DmLiteOutputPort.StreamCec; + public Cec StreamCec { get; private set; } + + public IntFeedback HdmiInHdcpStateFeedback { get; private set; } + public void SetHdmiInHdcpState(eHdcpCapabilityType hdcpState) + { + throw new NotImplementedException(); + } + + public eHdcpCapabilityType HdmiInHdcpCapability { get; private set; } } } \ No newline at end of file From 4e33743f5015742798a556096b61d47905a777eb Mon Sep 17 00:00:00 2001 From: Jason DeVito Date: Mon, 11 Sep 2023 19:24:21 -0500 Subject: [PATCH 66/96] refactor: SetupInput() and SetupOutput() methods to set standard keys for ports that are instantiated --- .../Chassis/HdPsXxxController.cs | 56 ++++++++----------- 1 file changed, 23 insertions(+), 33 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs index f4c725f0..8bfab826 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using Crestron.SimplSharp; using Crestron.SimplSharpPro; using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DM; @@ -19,7 +17,6 @@ namespace PepperDash_Essentials_DM.Chassis [Description("Wrapper class for all HdPsXxx switchers")] public class HdPsXxxController : CrestronGenericBridgeableBaseDevice, IRoutingNumericWithFeedback, ICec, IHasHdmiInHdcp, IHasFeedback { - private readonly HdPsXxx _chassis; public RoutingPortCollection InputPorts { get; private set; } @@ -99,32 +96,20 @@ namespace PepperDash_Essentials_DM.Chassis Debug.Console(1, this, "props.Input[{0}]: {1}", kvp.Key, kvp.Value); } - // TODO [ ] testing - var hdmiKeys = _chassis.HdmiInputs.Keys; - foreach (var key in hdmiKeys) - { - Debug.Console(0, this, "HDMI Input key-'{0}'", key); - } - - var dmKeys = _chassis.DmLiteInputs.Keys; - foreach (var key in dmKeys) - { - Debug.Console(0, this, "DM Input key-'{0}'", key); - } - - foreach (var item in _chassis.HdmiInputs) { var input = item; var index = item.Number; + var key = string.Format("hdmiIn{0}", index); var name = string.IsNullOrEmpty(InputNames[index]) ? string.Format("HDMI Input {0}", index) : InputNames[index]; InputNameFeedbacks.Add(new StringFeedback(name, () => InputNames[index])); - var port = new RoutingInputPort(name, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, input, this) + var port = new RoutingInputPort(key, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, input, this) { FeedbackMatchObject = input }; + Debug.Console(1, this, "Adding HDMI Input port: {0}", port.Key); InputPorts.Add(port); InputHdcpEnableFeedback.Add(new BoolFeedback(name, () => input.InputPort.HdcpSupportOnFeedback.BoolValue)); @@ -136,7 +121,7 @@ namespace PepperDash_Essentials_DM.Chassis { var input = item; var index = item.Number; - + var key = string.Format("dmLiteIn{0}", index); var name = string.IsNullOrEmpty(InputNames[index]) ? string.Format("DM Input {0}", index) : InputNames[index]; input.Name.StringValue = name; @@ -146,8 +131,8 @@ namespace PepperDash_Essentials_DM.Chassis { FeedbackMatchObject = input }; + Debug.Console(0, this, "Adding DM Input port: {0}",port.Key); InputPorts.Add(port); - InputHdcpEnableFeedback.Add(new BoolFeedback(name, () => input.InputPort.HdcpSupportOnFeedback.BoolValue)); @@ -170,26 +155,22 @@ namespace PepperDash_Essentials_DM.Chassis Debug.Console(1, this, "props.Output[{0}]: {1}", kvp.Key, kvp.Value); } - - // TODO [ ] testing - var keys = _chassis.HdmiDmLiteOutputs.Keys; - foreach (var key in keys) - { - Debug.Console(0, this, "HdmiDmLite Output key-'{0}'", key); - } - foreach (var item in _chassis.HdmiDmLiteOutputs) { - var output = item; + var output = item; var index = item.Number; - + var key = string.Format("hdmiDmLiteOut{0}", index); var name = string.IsNullOrEmpty(OutputNames[index]) ? string.Format("Output {0}", index) : OutputNames[index]; output.Name.StringValue = name; - var port = new RoutingOutputPort(name, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, output, this) + var port = new RoutingOutputPort(key, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, output, this) { - FeedbackMatchObject = output + FeedbackMatchObject = output, + // set port for CEC + Port = output }; + Debug.Console(0, this, "Adding HdmiDmLite Output port: {0} {1}", + port.Key, port.ParentDevice); OutputPorts.Add(port); OutputRouteNameFeedback.Add(new StringFeedback(name, () => output.VideoOutFeedback.NameFeedback.StringValue)); @@ -530,7 +511,16 @@ namespace PepperDash_Essentials_DM.Chassis // TODO [ ] Implement CEC control // return _chassis.HdmiDmLiteOutputs[0].DmLiteOutput.DmLiteOutputPort.StreamCec; - public Cec StreamCec { get; private set; } + public Cec StreamCec + { + get + { + return _chassis.NumberOfOutputs == 1 + //? _chassis.HdmiDmLiteOutputs[0].DmLiteOutput.DmLiteOutputPort.StreamCec + ? _chassis.HdmiDmLiteOutputs[0].HdmiOutput.HdmiOutputPort.StreamCec + : null; + } + } public IntFeedback HdmiInHdcpStateFeedback { get; private set; } public void SetHdmiInHdcpState(eHdcpCapabilityType hdcpState) From 27bac4e83dfd83fdc46a861c1f113f072e73e76e Mon Sep 17 00:00:00 2001 From: Jason DeVito Date: Tue, 12 Sep 2023 10:09:37 -0500 Subject: [PATCH 67/96] fix(wip): updates stream cec implementation to handle switchers with multiple outputs --- .../Chassis/HdPsXxxController.cs | 76 +++++++++++-------- 1 file changed, 43 insertions(+), 33 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs index 8bfab826..c7ef719c 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs @@ -15,7 +15,7 @@ using PepperDash_Essentials_DM.Config; namespace PepperDash_Essentials_DM.Chassis { [Description("Wrapper class for all HdPsXxx switchers")] - public class HdPsXxxController : CrestronGenericBridgeableBaseDevice, IRoutingNumericWithFeedback, ICec, IHasHdmiInHdcp, IHasFeedback + public class HdPsXxxController : CrestronGenericBridgeableBaseDevice, IRoutingNumericWithFeedback { private readonly HdPsXxx _chassis; @@ -61,7 +61,7 @@ namespace PepperDash_Essentials_DM.Chassis InputPorts = new RoutingPortCollection(); InputNameFeedbacks = new FeedbackCollection(); InputHdcpEnableFeedback = new FeedbackCollection(); - InputNames = new Dictionary(); + InputNames = new Dictionary(); OutputPorts = new RoutingPortCollection(); OutputNameFeedbacks = new FeedbackCollection(); @@ -79,8 +79,6 @@ namespace PepperDash_Essentials_DM.Chassis OutputNames = props.Outputs; SetupOutputs(OutputNames); - - //AddPostActivationAction(); } // input setup @@ -102,19 +100,19 @@ namespace PepperDash_Essentials_DM.Chassis var index = item.Number; var key = string.Format("hdmiIn{0}", index); var name = string.IsNullOrEmpty(InputNames[index]) ? string.Format("HDMI Input {0}", index) : InputNames[index]; - + InputNameFeedbacks.Add(new StringFeedback(name, () => InputNames[index])); var port = new RoutingInputPort(key, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, input, this) { FeedbackMatchObject = input }; - Debug.Console(1, this, "Adding HDMI Input port: {0}", port.Key); + Debug.Console(1, this, "Adding Input port: {0}", port.Key); InputPorts.Add(port); InputHdcpEnableFeedback.Add(new BoolFeedback(name, () => input.InputPort.HdcpSupportOnFeedback.BoolValue)); - VideoInputSyncFeedbacks.Add(new BoolFeedback(name, () => input.VideoDetectedFeedback.BoolValue)); + VideoInputSyncFeedbacks.Add(new BoolFeedback(name, () => input.VideoDetectedFeedback.BoolValue)); } foreach (var item in _chassis.DmLiteInputs) @@ -127,13 +125,13 @@ namespace PepperDash_Essentials_DM.Chassis InputNameFeedbacks.Add(new StringFeedback(name, () => InputNames[index])); - var port = new RoutingInputPort(name, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, input, this) + var port = new RoutingInputPort(key, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, input, this) { FeedbackMatchObject = input }; - Debug.Console(0, this, "Adding DM Input port: {0}",port.Key); + Debug.Console(0, this, "Adding Input port: {0}", port.Key); InputPorts.Add(port); - + InputHdcpEnableFeedback.Add(new BoolFeedback(name, () => input.InputPort.HdcpSupportOnFeedback.BoolValue)); VideoInputSyncFeedbacks.Add(new BoolFeedback(name, () => input.VideoDetectedFeedback.BoolValue)); @@ -169,15 +167,35 @@ namespace PepperDash_Essentials_DM.Chassis // set port for CEC Port = output }; - Debug.Console(0, this, "Adding HdmiDmLite Output port: {0} {1}", - port.Key, port.ParentDevice); + Debug.Console(0, this, "Adding Output port: {0}", port.Key); OutputPorts.Add(port); OutputRouteNameFeedback.Add(new StringFeedback(name, () => output.VideoOutFeedback.NameFeedback.StringValue)); VideoOutputRouteFeedbacks.Add(new IntFeedback(name, () => output.VideoOutFeedback == null ? 0 : (int)output.VideoOutFeedback.Number)); + + // TODO [ ] Investigate setting input priorities per output + // {{in1-priority-level}, {in2-priority-level}, .... {in6-priority-level}} + // default priority level input 1-4 ascending + output.OutputPort.InputPriorities(new byte[] { 1, 2, 3, 4 }); + + if (port.Port == null) continue; + + var hdmiOutputStreamCec = output.HdmiOutput.HdmiOutputPort.StreamCec; + if (hdmiOutputStreamCec != null) + { + var streamCec = new StreamCecWrapper(string.Format("{0}-hdmiOut{1}-streamCec", Key, index), hdmiOutputStreamCec); + DeviceManager.AddDevice(streamCec); + } + + var dmLiteOutputStreamCec = output.DmLiteOutput.DmLiteOutputPort.StreamCec; + if (dmLiteOutputStreamCec != null) + { + var streamCec = new StreamCecWrapper(string.Format("{0}-dmLiteOut{1}-streamCec", Key, index), dmLiteOutputStreamCec); + DeviceManager.AddDevice(streamCec); + } } - + _chassis.DMOutputChange += _chassis_OutputChange; } @@ -263,7 +281,7 @@ namespace PepperDash_Essentials_DM.Chassis } #endregion - + /// /// Executes a device switch using objects @@ -450,7 +468,7 @@ namespace PepperDash_Essentials_DM.Chassis } - #endregion + #endregion #region Factory @@ -508,26 +526,18 @@ namespace PepperDash_Essentials_DM.Chassis #endregion + } - // TODO [ ] Implement CEC control - // return _chassis.HdmiDmLiteOutputs[0].DmLiteOutput.DmLiteOutputPort.StreamCec; - public Cec StreamCec + + public class StreamCecWrapper : IKeyed, ICec + { + public string Key { get; private set; } + public Cec StreamCec { get; private set; } + + public StreamCecWrapper(string key, Cec streamCec) { - get - { - return _chassis.NumberOfOutputs == 1 - //? _chassis.HdmiDmLiteOutputs[0].DmLiteOutput.DmLiteOutputPort.StreamCec - ? _chassis.HdmiDmLiteOutputs[0].HdmiOutput.HdmiOutputPort.StreamCec - : null; - } + Key = key; + StreamCec = streamCec; } - - public IntFeedback HdmiInHdcpStateFeedback { get; private set; } - public void SetHdmiInHdcpState(eHdcpCapabilityType hdcpState) - { - throw new NotImplementedException(); - } - - public eHdcpCapabilityType HdmiInHdcpCapability { get; private set; } } } \ No newline at end of file From 1aa95905872d5007f11ed7c55ba33184c30fa63c Mon Sep 17 00:00:00 2001 From: Jason DeVito Date: Tue, 12 Sep 2023 13:23:18 -0500 Subject: [PATCH 68/96] feature: adds DmInputChange event --- .../Essentials_DM/Chassis/HdPsXxxController.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs index c7ef719c..1c6f8781 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs @@ -38,6 +38,7 @@ namespace PepperDash_Essentials_DM.Chassis public BoolFeedback AutoRouteFeedback { get; private set; } public event EventHandler NumericSwitchChange; + public event EventHandler DmInputChange; /// /// Constructor @@ -425,6 +426,8 @@ namespace PepperDash_Essentials_DM.Chassis break; } } + + OnDmInputChange(args); } @@ -457,16 +460,20 @@ namespace PepperDash_Essentials_DM.Chassis } - /// - /// Raise an event when the status of a switch object changes. - /// - /// Argumetns defined as IKeyName sender, output, input, & eRoutingSignalType + // Raise an event when the status of a switch object changes. private void OnSwitchChange(RoutingNumericEventArgs args) { var newEvent = NumericSwitchChange; if (newEvent != null) newEvent(this, args); } + // Raise an event when the DM input changes. + private void OnDmInputChange(DMInputEventArgs args) + { + var newEvent = DmInputChange; + if (newEvent != null) newEvent(this, args); + } + #endregion From 2afa9df705ffb5d6e473861968da0e886825253b Mon Sep 17 00:00:00 2001 From: Jason DeVito Date: Tue, 12 Sep 2023 14:08:20 -0500 Subject: [PATCH 69/96] fix: removes HdPsXxx controller, propertiesConfig and join map --- PepperDashEssentials/ControlSystem.cs | 49 +- .../JoinMaps/HdPsXxxControllerJoinMap.cs | 190 ----- .../PepperDash_Essentials_Core.csproj | 1 - .../Chassis/HdPsXxxController.cs | 657 ------------------ .../Config/HdPsXxxPropertiesConfig.cs | 30 - .../PepperDash_Essentials_DM.csproj | 2 - 6 files changed, 28 insertions(+), 901 deletions(-) delete mode 100644 essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/HdPsXxxControllerJoinMap.cs delete mode 100644 essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs delete mode 100644 essentials-framework/Essentials DM/Essentials_DM/Config/HdPsXxxPropertiesConfig.cs diff --git a/PepperDashEssentials/ControlSystem.cs b/PepperDashEssentials/ControlSystem.cs index 0ebfd927..1bafbbac 100644 --- a/PepperDashEssentials/ControlSystem.cs +++ b/PepperDashEssentials/ControlSystem.cs @@ -392,45 +392,51 @@ namespace PepperDash.Essentials { Debug.Console(2, "Adding DmpsRoutingController for {0} to Device Manager.", this.ControllerPrompt); - var propertiesConfig = JsonConvert.DeserializeObject(devConf.Properties.ToString()) ?? - new DM.Config.DmpsRoutingPropertiesConfig(); + var propertiesConfig = JsonConvert.DeserializeObject(devConf.Properties.ToString()); - DeviceManager.AddDevice(DmpsRoutingController.GetDmpsRoutingController("processor-avRouting", this.ControllerPrompt, propertiesConfig)); + if(propertiesConfig == null) + propertiesConfig = new DM.Config.DmpsRoutingPropertiesConfig(); + + DeviceManager.AddDevice(DmpsRoutingController.GetDmpsRoutingController("processor-avRouting", this.ControllerPrompt, propertiesConfig)); } else if (this.ControllerPrompt.IndexOf("mpc3", StringComparison.OrdinalIgnoreCase) > -1) { - Debug.Console(2, "MPC3 processor type detected. Adding Mpc3TouchpanelController."); + Debug.Console(2, "MPC3 processor type detected. Adding Mpc3TouchpanelController."); - var butToken = devConf.Properties["buttons"]; - if (butToken == null) - { - Debug.Console(0, Debug.ErrorLogLevel.Error, - "Error: Unable to deserialize buttons collection for device: {0}", devConf.Key); + var butToken = devConf.Properties["buttons"]; + if (butToken == null) + { + Debug.Console(0, Debug.ErrorLogLevel.Error, + "Error: Unable to deserialize buttons collection for device: {0}", devConf.Key); continue; - } - - var buttons = butToken.ToObject>(); - var tpController = new Core.Touchpanels.Mpc3TouchpanelController( - string.Format("{0}-keypadButtons", devConf.Key), devConf.Name, Global.ControlSystem, buttons); + } - DeviceManager.AddDevice(tpController); + var buttons = butToken.ToObject>(); + var tpController = new Core.Touchpanels.Mpc3TouchpanelController( + string.Format("{0}-keypadButtons", devConf.Key), devConf.Name, Global.ControlSystem, buttons); + + DeviceManager.AddDevice(tpController); } else { Debug.Console(2, "************Processor is not DMPS type***************"); } + + continue; } // Try local factories first - var newDev = null ?? PepperDash.Essentials.Core.DeviceFactory.GetDevice(devConf); + IKeyed newDev = null; - if (newDev == null) - Debug.Console(0, Debug.ErrorLogLevel.Error, "ERROR: Cannot load unknown device type '{0}', key '{1}'.", - devConf.Type, devConf.Key); - else - DeviceManager.AddDevice(newDev); + if (newDev == null) + newDev = PepperDash.Essentials.Core.DeviceFactory.GetDevice(devConf); + + if (newDev != null) + DeviceManager.AddDevice(newDev); + else + Debug.Console(0, Debug.ErrorLogLevel.Error, "ERROR: Cannot load unknown device type '{0}', key '{1}'.", devConf.Type, devConf.Key); } catch (Exception e) { @@ -438,6 +444,7 @@ namespace PepperDash.Essentials } } Debug.Console(0, Debug.ErrorLogLevel.Notice, "All Devices Loaded."); + } diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/HdPsXxxControllerJoinMap.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/HdPsXxxControllerJoinMap.cs deleted file mode 100644 index 3f2901c9..00000000 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/HdPsXxxControllerJoinMap.cs +++ /dev/null @@ -1,190 +0,0 @@ -using System; -using PepperDash.Essentials.Core; - -namespace PepperDash_Essentials_Core.Bridges -{ - public class HdPsXxxControllerJoinMap : JoinMapBaseAdvanced - { - - #region Digital - - [JoinName("EnableAutoRoute")] - public JoinDataComplete EnableAutoRoute = new JoinDataComplete( - new JoinData - { - JoinNumber = 1, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Enable Automatic Routing on Xx1 Switchers", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Digital - }); - - - [JoinName("InputSync")] - public JoinDataComplete InputSync = new JoinDataComplete( - new JoinData - { - JoinNumber = 2, - JoinSpan = 8 - }, - new JoinMetadata - { - Description = "Device Input Sync", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - - [JoinName("EnableInputHdcp")] - public JoinDataComplete EnableInputHdcp = new JoinDataComplete( - new JoinData - { - JoinNumber = 11, - JoinSpan = 8 - }, - new JoinMetadata - { - Description = "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 - { - Description = "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 - { - Description = "Device Onlne", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - #endregion - - - #region Analog - - [JoinName("OutputRoute")] - public JoinDataComplete OutputRoute = new JoinDataComplete( - new JoinData - { - JoinNumber = 11, - JoinSpan = 2 - }, - new JoinMetadata - { - Description = "Device Output Route Set/Get", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Analog - }); - - #endregion - - - #region Serial - - [JoinName("Name")] - public JoinDataComplete Name = new JoinDataComplete( - new JoinData - { - JoinNumber = 1, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Device Name", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - - [JoinName("InputName")] - public JoinDataComplete InputName = new JoinDataComplete( - new JoinData - { - JoinNumber = 2, - JoinSpan = 8 - }, - new JoinMetadata - { - Description = "Device Input Name", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - - [JoinName("OutputName")] - public JoinDataComplete OutputName = new JoinDataComplete( - new JoinData - { - JoinNumber = 11, - JoinSpan = 2 - }, - new JoinMetadata - { - Description = "Device Output Name", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - - [JoinName("OutputRoutedName")] - public JoinDataComplete OutputRoutedName = new JoinDataComplete( - new JoinData - { - JoinNumber = 16, - JoinSpan = 2 - }, - new JoinMetadata - { - Description = "Device Output Route Name", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - - #endregion - - /// - /// Constructor to use when instantiating this join map without inheriting from it - /// - /// Join this join map will start at - public HdPsXxxControllerJoinMap(uint joinStart) - : this(joinStart, typeof(HdPsXxxControllerJoinMap)) - { - } - - /// - /// Constructor to use when extending this Join map - /// - /// Join this join map will start at - /// Type of the child join map - protected HdPsXxxControllerJoinMap(uint joinStart, Type type) - : base(joinStart, type) - { - } - } -} \ 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 0d9aa9bc..75d4626d 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj @@ -127,7 +127,6 @@ - diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs deleted file mode 100644 index d923949e..00000000 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs +++ /dev/null @@ -1,657 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.DM; -using Newtonsoft.Json; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.Core.Config; -using PepperDash_Essentials_Core.Bridges; -using PepperDash_Essentials_DM.Config; - -namespace PepperDash_Essentials_DM.Chassis -{ - [Description("Wrapper class for all HdPsXxx switchers")] - public class HdPsXxxController : CrestronGenericBridgeableBaseDevice, IRoutingNumericWithFeedback, IHasFeedback - { - - private readonly HdPsXxx _chassis; - private readonly HdPs401 _chassis401; - private readonly HdPs621 _chassis621; - - public RoutingPortCollection InputPorts { get; private set; } - public RoutingPortCollection OutputPorts { get; private set; } - - public Dictionary InputNames { get; set; } - public Dictionary OutputNames { get; set; } - - public FeedbackCollection InputNameFeedbacks { get; private set; } - public FeedbackCollection InputHdcpEnableFeedback { get; private set; } - - public FeedbackCollection OutputNameFeedbacks { get; private set; } - public FeedbackCollection OutputRouteNameFeedback { get; private set; } - - public FeedbackCollection VideoInputSyncFeedbacks { get; private set; } - public FeedbackCollection VideoOutputRouteFeedbacks { get; private set; } - - public StringFeedback DeviceNameFeedback { get; private set; } - public BoolFeedback AutoRouteFeedback { get; private set; } - - public event EventHandler NumericSwitchChange; - - /// - /// Constructor - /// - /// - /// - /// HdPs401 device instance - /// - public HdPsXxxController(string key, string name, HdPsXxx chassis, HdPsXxxPropertiesConfig props) - : base(key, name, chassis) - { - _chassis = chassis; - Name = name; - - if (props == null) - { - Debug.Console(1, this, "HdPsXxxController properties are null, failed to build device"); - return; - } - - InputPorts = new RoutingPortCollection(); - InputNameFeedbacks = new FeedbackCollection(); - InputHdcpEnableFeedback = new FeedbackCollection(); - InputNames = new Dictionary(); - //InputNames = props.Inputs; - - OutputPorts = new RoutingPortCollection(); - OutputNameFeedbacks = new FeedbackCollection(); - OutputRouteNameFeedback = new FeedbackCollection(); - OutputNames = new Dictionary(); - //OutputNames = props.Outputs; - - VideoInputSyncFeedbacks = new FeedbackCollection(); - VideoOutputRouteFeedbacks = new FeedbackCollection(); - - if (_chassis.NumberOfOutputs == 1) - { - if (_chassis is HdPs401) - _chassis401 = _chassis as HdPs401; - if (_chassis is HdPs621) - _chassis621 = _chassis as HdPs621; - - AutoRouteFeedback = new BoolFeedback(() => _chassis401.PriorityRouteOnFeedback.BoolValue); - } - - SetupInputs(props.Inputs); - SetupOutputs(props.Outputs); - - AddPostActivationAction(AddFeedbackCollecitons); - } - - // input setup - private void SetupInputs(Dictionary dict) - { - if (dict == null) - { - Debug.Console(1, this, "Failed to setup inputs, properties are null"); - return; - } - foreach (var kvp in dict) - { - Debug.Console(1, this, "props.Input[{0}]: {1}", kvp.Key, kvp.Value); - } - InputNames = dict; - - for (uint i = 1; i <= _chassis.NumberOfInputs; i++) - { - var index = i; - var name = string.IsNullOrEmpty(InputNames[index]) ? string.Format("Input {0}", index) : InputNames[index]; - var input = _chassis.Inputs[index]; - var hdmiInput = _chassis.HdmiInputs[index]; - var dmLiteInput = _chassis.DmLiteInputs[index]; - - InputNameFeedbacks.Add(new StringFeedback(name, () => InputNames[index])); - - // TODO [ ] verify which input type is needed - input.Name.StringValue = name; - hdmiInput.Name.StringValue = name; - dmLiteInput.Name.StringValue = name; - - var port = new RoutingInputPort(name, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, input, this) - { - FeedbackMatchObject = input - }; - InputPorts.Add(port); - - InputHdcpEnableFeedback.Add(new BoolFeedback(name, () => hdmiInput.InputPort.HdcpSupportOnFeedback.BoolValue)); - - VideoInputSyncFeedbacks.Add(new BoolFeedback(name, () => input.VideoDetectedFeedback.BoolValue)); - } - - _chassis.DMInputChange += _chassis_InputChange; - } - - // output setup - private void SetupOutputs(Dictionary dict) - { - if (dict == null) - { - Debug.Console(1, this, "Failed to setup outputs, properties are null"); - return; - } - foreach (var kvp in dict) - { - Debug.Console(1, this, "props.Output[{0}]: {1}", kvp.Key, kvp.Value); - } - OutputNames = dict; - - for (uint i = 1; i <= _chassis.NumberOfOutputs; i++) - { - var index = i; - var name = string.IsNullOrEmpty(OutputNames[index]) ? string.Format("Output {0}", index) : OutputNames[index]; - var output = _chassis.Outputs[index]; - var hdmiDmLiteOutput = _chassis.HdmiDmLiteOutputs[index]; - - OutputNameFeedbacks.Add(new StringFeedback(name, () => OutputNames[index])); - - // TODO [ ] verify which output type is needed - output.Name.StringValue = name; - hdmiDmLiteOutput.Name.StringValue = name; - - var port = new RoutingOutputPort(name, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, output, this) - { - FeedbackMatchObject = output - }; - OutputPorts.Add(port); - - OutputRouteNameFeedback.Add(new StringFeedback(name, () => output.VideoOutFeedback.NameFeedback.StringValue)); - - VideoOutputRouteFeedbacks.Add(new IntFeedback(name, () => output.VideoOutFeedback == null ? 0 : (int)output.VideoOutFeedback.Number)); - } - - _chassis.DMOutputChange += _chassis_OutputChange; - } - - - #region BridgeLinking - - /// - /// Link device to API - /// - /// - /// - /// - /// - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = new HdPsXxxControllerJoinMap(joinStart); - - 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"); - } - - IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); - DeviceNameFeedback.LinkInputSig(trilist.StringInput[joinMap.Name.JoinNumber]); - - _chassis.OnlineStatusChange += _chassis_OnlineStatusChange; - - if (_chassis401 != null) LinkChassis401ToApi(trilist, joinMap); - - if (_chassis621 != null) LinkChassis621ToApi(trilist, joinMap); - - LinkChassisInputsToApi(trilist, joinMap); - LinkChassisOutputsToApi(trilist, joinMap); - - trilist.OnlineStatusChange += (sender, args) => - { - if (!args.DeviceOnLine) return; - }; - } - - - // links inputs to API - private void LinkChassisInputsToApi(BasicTriList trilist, HdPsXxxControllerJoinMap joinMap) - { - for (uint i = 1; i <= _chassis.NumberOfInputs; i++) - { - var input = i; - var inputName = InputNames[input]; - var indexWithOffset = input - 1; - - trilist.SetSigTrueAction(joinMap.EnableInputHdcp.JoinNumber + indexWithOffset, () => EnableHdcp(input)); - trilist.SetSigTrueAction(joinMap.DisableInputHdcp.JoinNumber + indexWithOffset, () => DisableHdcp(input)); - - InputHdcpEnableFeedback[inputName].LinkInputSig(trilist.BooleanInput[joinMap.EnableInputHdcp.JoinNumber + indexWithOffset]); - InputHdcpEnableFeedback[inputName].LinkComplementInputSig(trilist.BooleanInput[joinMap.EnableInputHdcp.JoinNumber + indexWithOffset]); - - VideoInputSyncFeedbacks[inputName].LinkInputSig(trilist.BooleanInput[joinMap.InputSync.JoinNumber + indexWithOffset]); - - InputNameFeedbacks[inputName].LinkInputSig(trilist.StringInput[joinMap.InputName.JoinNumber + indexWithOffset]); - } - } - - - // links outputs to API - private void LinkChassisOutputsToApi(BasicTriList trilist, HdPsXxxControllerJoinMap joinMap) - { - for (uint i = 1; i <= _chassis.NumberOfOutputs; i++) - { - var output = i; - var outputName = OutputNames[output]; - var indexWithOffset = output - 1; - - trilist.SetUShortSigAction(joinMap.OutputRoute.JoinNumber + indexWithOffset, (a) => - ExecuteNumericSwitch(a, (ushort) output, eRoutingSignalType.AudioVideo)); - - OutputNameFeedbacks[outputName].LinkInputSig(trilist.StringInput[joinMap.OutputName.JoinNumber + indexWithOffset]); - OutputRouteNameFeedback[outputName].LinkInputSig(trilist.StringInput[joinMap.OutputRoutedName.JoinNumber + indexWithOffset]); - - VideoOutputRouteFeedbacks[outputName].LinkInputSig(trilist.UShortInput[joinMap.OutputRoute.JoinNumber + indexWithOffset]); - } - } - - - // links HdPs401 chassis to API - private void LinkChassis401ToApi(BasicTriList trilist, HdPsXxxControllerJoinMap joinMap) - { - trilist.SetSigTrueAction(joinMap.EnableAutoRoute.JoinNumber, () => _chassis401.AutoRouteOn()); - trilist.SetSigFalseAction(joinMap.EnableAutoRoute.JoinNumber, () => _chassis401.AutoRouteOff()); - - AutoRouteFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableAutoRoute.JoinNumber]); - } - - - // links HdPs621 chassis to API - private void LinkChassis621ToApi(BasicTriList trilist, HdPsXxxControllerJoinMap joinMap) - { - trilist.SetSigTrueAction(joinMap.EnableAutoRoute.JoinNumber, () => _chassis621.AutoRouteOn()); - trilist.SetSigFalseAction(joinMap.EnableAutoRoute.JoinNumber, () => _chassis621.AutoRouteOff()); - - AutoRouteFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableAutoRoute.JoinNumber]); - } - - - #endregion - - - /// - /// Executes a device switch using objects - /// - /// - /// - /// - public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) - { - var input = inputSelector as HdPsXxxHdmiInput; - var output = outputSelector as HdPsXxxHdmiOutput; - - Debug.Console(2, this, "ExecuteSwitch: input={0}, output={1}", input, output); - - if (output == null) - { - Debug.Console(0, this, "Unable to make switch, output selector is not HdPsXxxHdmiOutput"); - return; - } - - // TODO [ ] Validate if sending the same input toggles the switch - var current = output.VideoOut; - if (current != input) - output.VideoOut = input; - } - - - /// - /// Executes a device switch using numeric values - /// - /// - /// - /// - public void ExecuteNumericSwitch(ushort inputSelector, ushort outputSelector, eRoutingSignalType signalType) - { - var input = inputSelector == 0 ? null : _chassis.Inputs[inputSelector]; - var output = _chassis.Outputs[outputSelector]; - - Debug.Console(2, this, "ExecuteNumericSwitch: input={0}, output={1}", input, output); - - ExecuteSwitch(input, output, signalType); - } - - - /// - /// Enables Hdcp on the provided port - /// - /// - public void EnableHdcp(uint port) - { - if (port <= 0 || port > _chassis.NumberOfInputs) return; - - _chassis.HdmiInputs[port].InputPort.HdcpSupportOn(); - InputHdcpEnableFeedback[InputNames[port]].FireUpdate(); - } - - - /// - /// Disables Hdcp on the provided port - /// - /// - public void DisableHdcp(uint port) - { - if (port <= 0 || port > _chassis.NumberOfInputs) return; - - _chassis.HdmiInputs[port].InputPort.HdcpSupportOff(); - InputHdcpEnableFeedback[InputNames[port]].FireUpdate(); - } - - - /// - /// Enables switcher auto route - /// - public void EnableAutoRoute() - { - if (_chassis.NumberOfInputs != 1) return; - - if (_chassis401 != null) - { - _chassis401.AutoRouteOn(); - } - - if (_chassis621 != null) - { - _chassis621.AutoRouteOn(); - } - } - - - /// - /// Disables switcher auto route - /// - public void DisableAutoRoute() - { - if (_chassis.NumberOfInputs != 1) return; - - if (_chassis401 != null) - { - _chassis401.AutoRouteOff(); - } - - if (_chassis621 != null) - { - _chassis621.AutoRouteOff(); - } - } - - #region Events - - - // _chassis online/offline event - private void _chassis_OnlineStatusChange(GenericBase currentDevice, - OnlineOfflineEventArgs args) - { - IsOnline.FireUpdate(); - - if (!args.DeviceOnLine) return; - - foreach (var feedback in Feedbacks) - { - feedback.FireUpdate(); - } - } - - - // _chassis input change event - private void _chassis_InputChange(Switch device, DMInputEventArgs args) - { - var eventId = args.EventId; - - switch (eventId) - { - case DMInputEventIds.VideoDetectedEventId: - { - Debug.Console(1, this, "Event ID {0}: Updating VideoInputSyncFeedbacks", 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", eventId); - - var input = args.Number; - var name = _chassis.HdmiInputs[input].NameFeedback.StringValue; - - Debug.Console(1, this, "Input {0} Name {1}", input, name); - break; - } - default: - { - Debug.Console(1, this, "Uhandled DM Input Event ID {0}", eventId); - break; - } - } - } - - - // _chassis output change event - private void _chassis_OutputChange(Switch device, DMOutputEventArgs args) - { - if (args.EventId != DMOutputEventIds.VideoOutEventId) return; - - var output = args.Number; - - var input = _chassis.HdmiDmLiteOutputs[output].VideoOutFeedback == null - ? 0 - : _chassis.HdmiDmLiteOutputs[output].VideoOutFeedback.Number; - - var outputName = OutputNames[output]; - - var feedback = VideoOutputRouteFeedbacks[outputName]; - if (feedback == null) return; - - var inputPort = InputPorts.FirstOrDefault( - p => p.FeedbackMatchObject == _chassis.HdmiDmLiteOutputs[output].VideoOutFeedback); - - var outputPort = OutputPorts.FirstOrDefault( - p => p.FeedbackMatchObject == _chassis.HdmiDmLiteOutputs[output]); - - feedback.FireUpdate(); - - OnSwitchChange(new RoutingNumericEventArgs( - output, input, outputPort, inputPort, eRoutingSignalType.AudioVideo)); - } - - - /// - /// Raise an event when the status of a switch object changes. - /// - /// Argumetns defined as IKeyName sender, output, input, & eRoutingSignalType - private void OnSwitchChange(RoutingNumericEventArgs args) - { - var newEvent = NumericSwitchChange; - if (newEvent != null) newEvent(this, args); - } - - - #endregion - - - #region FeedbacksAndFeedbackCollections - - - /// - /// Add feedback colleciton arrays to feedback collections - /// - /// BoolFeedback[] arrays - public void AddCollectionsToList(params FeedbackCollection[] feedbackCollections) - { - foreach (var item in feedbackCollections.SelectMany(feedbackCollection => feedbackCollections)) - { - AddCollectionsToList(item); - } - } - - - /// - /// Add feedback colleciton arrays to feedback collections - /// - /// IntFeedback[] arrays - public void AddCollectionsToList(params FeedbackCollection[] feedbackCollections) - { - foreach (var item in feedbackCollections.SelectMany(feedbackCollection => feedbackCollections)) - { - AddCollectionsToList(item); - } - } - - - /// - /// Add feedback colleciton arrays to feedback collections - /// - /// StringFeedback[] arrays - public void AddCollectionsToList(params FeedbackCollection[] feedbackCollections) - { - foreach (var item in feedbackCollections.SelectMany(feedbackCollection => feedbackCollections)) - { - AddCollectionsToList(item); - } - } - - - /// - /// Adds feedback colleciton to feedback collections - /// - /// BoolFeedback - public void AddCollectionToList(FeedbackCollection feedbackCollection) - { - foreach (var item in feedbackCollection.Where(item => item != null)) - { - AddFeedbackToList(item); - } - } - - - /// - /// Adds feedback colleciton to feedback collections - /// - /// IntFeedback - public void AddCollectionToList(FeedbackCollection feedbackCollection) - { - foreach (var item in feedbackCollection.Where(item => item != null)) - { - AddFeedbackToList(item); - } - } - - - /// - /// Adds feedback colleciton to feedback collections - /// - /// StringFeedback - public void AddCollectionToList(FeedbackCollection feedbackCollection) - { - foreach (var item in feedbackCollection.Where(item => item != null)) - { - AddFeedbackToList(item); - } - } - - - /// - /// Adds individual feedbacks to feedback collection - /// - /// Feedback - public void AddFeedbackToList(PepperDash.Essentials.Core.Feedback fb) - { - if (fb == null || Feedbacks.Contains(fb)) return; - - Feedbacks.Add(fb); - } - - - /// - /// Adds provided feedbacks to feedback collection list - /// - public void AddFeedbackCollecitons() - { - AddFeedbackToList(DeviceNameFeedback); - AddCollectionsToList(VideoInputSyncFeedbacks, InputHdcpEnableFeedback); - AddCollectionsToList(VideoOutputRouteFeedbacks); - AddCollectionsToList(InputNameFeedbacks, OutputNameFeedbacks, OutputRouteNameFeedback); - } - - - #endregion - - - #region Factory - - - public class HdSp401ControllerFactory : EssentialsDeviceFactory - { - public HdSp401ControllerFactory() - { - TypeNames = new List() { "hdps401", "hdps402", "hdps621", "hdps622" }; - } - public override EssentialsDevice BuildDevice(DeviceConfig dc) - { - Debug.Console(1, "Factory Attempting to create new HD-PSXxx device"); - - var props = JsonConvert.DeserializeObject(dc.Properties.ToString()); - if (props == null) - { - Debug.Console(1, "Factory failed to create new HD-PSXxx device, properties config was null"); - return null; - } - - var key = dc.Key; - var name = dc.Name; - var type = dc.Type.ToLower(); - var control = props.Control; - var ipid = control.IpIdInt; - //var address = control.TcpSshProperties.Address; - - switch (type) - { - case ("hdps401"): - { - return new HdPsXxxController(key, name, new HdPs401(ipid, Global.ControlSystem), props); - } - case ("hdps402"): - { - return new HdPsXxxController(key, name, new HdPs402(ipid, Global.ControlSystem), props); - } - case ("hdps621"): - { - return new HdPsXxxController(key, name, new HdPs621(ipid, Global.ControlSystem), props); - } - case ("hdps622"): - { - return new HdPsXxxController(key, name, new HdPs622(ipid, Global.ControlSystem), props); - } - default: - { - Debug.Console(1, "Factory failed to create new {0} device", type); - return null; - } - } - } - } - - - #endregion - } -} \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Config/HdPsXxxPropertiesConfig.cs b/essentials-framework/Essentials DM/Essentials_DM/Config/HdPsXxxPropertiesConfig.cs deleted file mode 100644 index c02fc511..00000000 --- a/essentials-framework/Essentials DM/Essentials_DM/Config/HdPsXxxPropertiesConfig.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.Collections.Generic; -using Newtonsoft.Json; -using PepperDash.Core; -using PepperDash.Essentials.DM.Config; - -namespace PepperDash_Essentials_DM.Config -{ - public class HdPsXxxPropertiesConfig - { - [JsonProperty("control")] - public ControlPropertiesConfig Control { get; set; } - - [JsonProperty("inputs")] - //public Dictionary Inputs { get; set; } - public Dictionary Inputs { get; set; } - - [JsonProperty("outputs")] - //public Dictionary Outputs { get; set; } - public Dictionary Outputs { get; set; } - - public HdPsXxxPropertiesConfig() - { - //Inputs = new Dictionary(); - //Outputs = new Dictionary(); - - Inputs = new Dictionary(); - Outputs = new Dictionary(); - } - } -} \ 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 0011c305..adfddbe3 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj +++ b/essentials-framework/Essentials DM/Essentials_DM/PepperDash_Essentials_DM.csproj @@ -104,8 +104,6 @@ - - From da5d2d74f29d7be3a02f9147399fe8fb3420f4f8 Mon Sep 17 00:00:00 2001 From: Jason DeVito Date: Tue, 12 Sep 2023 14:36:17 -0500 Subject: [PATCH 70/96] fix: removes OutputPort.InputPriorities reference --- .../Essentials_DM/Chassis/HdPsXxxController.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs index 1c6f8781..7c1e0431 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs @@ -10,6 +10,7 @@ using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Config; using PepperDash_Essentials_Core.Bridges; +using PepperDash_Essentials_DM; using PepperDash_Essentials_DM.Config; namespace PepperDash_Essentials_DM.Chassis @@ -173,12 +174,14 @@ namespace PepperDash_Essentials_DM.Chassis OutputRouteNameFeedback.Add(new StringFeedback(name, () => output.VideoOutFeedback.NameFeedback.StringValue)); - VideoOutputRouteFeedbacks.Add(new IntFeedback(name, () => output.VideoOutFeedback == null ? 0 : (int)output.VideoOutFeedback.Number)); + VideoOutputRouteFeedbacks.Add(new IntFeedback(name, + () => output.VideoOutFeedback == null ? 0 : (int) output.VideoOutFeedback.Number)); // TODO [ ] Investigate setting input priorities per output // {{in1-priority-level}, {in2-priority-level}, .... {in6-priority-level}} - // default priority level input 1-4 ascending - output.OutputPort.InputPriorities(new byte[] { 1, 2, 3, 4 }); + // default priority level input 1-4 ascending + //var priorities = new byte[] {1,2,3,4}; + //output.OutputPort.InputPriorities(priorities); if (port.Port == null) continue; From 189c4706030e4d5cf8c1de496aee94130ef00b02 Mon Sep 17 00:00:00 2001 From: Jason DeVito Date: Tue, 12 Sep 2023 17:10:25 -0500 Subject: [PATCH 71/96] feature(wip): adds inputPriorities configuration property --- .../Chassis/HdPsXxxController.cs | 22 ++++++++++++++----- .../Config/HdPsXxxPropertiesConfig.cs | 12 +++++----- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs index 7c1e0431..2e998133 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs @@ -10,7 +10,6 @@ using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Config; using PepperDash_Essentials_Core.Bridges; -using PepperDash_Essentials_DM; using PepperDash_Essentials_DM.Config; namespace PepperDash_Essentials_DM.Chassis @@ -19,6 +18,7 @@ namespace PepperDash_Essentials_DM.Chassis public class HdPsXxxController : CrestronGenericBridgeableBaseDevice, IRoutingNumericWithFeedback { private readonly HdPsXxx _chassis; + private byte[] _inputPriorityParams; public RoutingPortCollection InputPorts { get; private set; } public RoutingPortCollection OutputPorts { get; private set; } @@ -76,6 +76,12 @@ namespace PepperDash_Essentials_DM.Chassis if (_chassis.NumberOfOutputs == 1) AutoRouteFeedback = new BoolFeedback(() => _chassis.PriorityRouteOnFeedback.BoolValue); + if (props.InputPriorities != null) + { + _inputPriorityParams = new byte[_chassis.NumberOfInputs]; + _inputPriorityParams = GetInputPriorities(props); + } + InputNames = props.Inputs; SetupInputs(InputNames); @@ -83,6 +89,12 @@ namespace PepperDash_Essentials_DM.Chassis SetupOutputs(OutputNames); } + // get input priorities + private byte[] GetInputPriorities(HdPsXxxPropertiesConfig props) + { + throw new NotImplementedException(); + } + // input setup private void SetupInputs(Dictionary dict) { @@ -175,13 +187,13 @@ namespace PepperDash_Essentials_DM.Chassis OutputRouteNameFeedback.Add(new StringFeedback(name, () => output.VideoOutFeedback.NameFeedback.StringValue)); VideoOutputRouteFeedbacks.Add(new IntFeedback(name, - () => output.VideoOutFeedback == null ? 0 : (int) output.VideoOutFeedback.Number)); + () => output.VideoOutFeedback == null ? 0 : (int)output.VideoOutFeedback.Number)); // TODO [ ] Investigate setting input priorities per output // {{in1-priority-level}, {in2-priority-level}, .... {in6-priority-level}} - // default priority level input 1-4 ascending - //var priorities = new byte[] {1,2,3,4}; - //output.OutputPort.InputPriorities(priorities); + // default priority level input 1-4 ascending + if (_inputPriorityParams != null && _inputPriorityParams.Count() > 0) + output.OutputPort.InputPriorities(_inputPriorityParams); if (port.Port == null) continue; diff --git a/essentials-framework/Essentials DM/Essentials_DM/Config/HdPsXxxPropertiesConfig.cs b/essentials-framework/Essentials DM/Essentials_DM/Config/HdPsXxxPropertiesConfig.cs index c02fc511..576b74f0 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Config/HdPsXxxPropertiesConfig.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Config/HdPsXxxPropertiesConfig.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using Newtonsoft.Json; using PepperDash.Core; -using PepperDash.Essentials.DM.Config; namespace PepperDash_Essentials_DM.Config { @@ -11,18 +10,17 @@ namespace PepperDash_Essentials_DM.Config public ControlPropertiesConfig Control { get; set; } [JsonProperty("inputs")] - //public Dictionary Inputs { get; set; } public Dictionary Inputs { get; set; } - + [JsonProperty("outputs")] - //public Dictionary Outputs { get; set; } public Dictionary Outputs { get; set; } + // "inputPriorities": "1,4,3,2" + [JsonProperty("inputPriorities")] + public string InputPriorities { get; set; } + public HdPsXxxPropertiesConfig() { - //Inputs = new Dictionary(); - //Outputs = new Dictionary(); - Inputs = new Dictionary(); Outputs = new Dictionary(); } From e590c7cedb251cf4b324b4e4a43bd49afaf0c85b Mon Sep 17 00:00:00 2001 From: Jason DeVito Date: Tue, 12 Sep 2023 19:26:55 -0500 Subject: [PATCH 72/96] feature(wip): adds inputPriorities configuration property --- .../Essentials_DM/Chassis/HdPsXxxController.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs index 2e998133..bba85d25 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs @@ -18,7 +18,7 @@ namespace PepperDash_Essentials_DM.Chassis public class HdPsXxxController : CrestronGenericBridgeableBaseDevice, IRoutingNumericWithFeedback { private readonly HdPsXxx _chassis; - private byte[] _inputPriorityParams; + //private byte[] _inputPriorityParams; public RoutingPortCollection InputPorts { get; private set; } public RoutingPortCollection OutputPorts { get; private set; } @@ -76,11 +76,11 @@ namespace PepperDash_Essentials_DM.Chassis if (_chassis.NumberOfOutputs == 1) AutoRouteFeedback = new BoolFeedback(() => _chassis.PriorityRouteOnFeedback.BoolValue); - if (props.InputPriorities != null) - { - _inputPriorityParams = new byte[_chassis.NumberOfInputs]; - _inputPriorityParams = GetInputPriorities(props); - } + //if (props.InputPriorities != null) + //{ + // _inputPriorityParams = new byte[_chassis.NumberOfInputs]; + // _inputPriorityParams = GetInputPriorities(props); + //} InputNames = props.Inputs; SetupInputs(InputNames); @@ -192,8 +192,8 @@ namespace PepperDash_Essentials_DM.Chassis // TODO [ ] Investigate setting input priorities per output // {{in1-priority-level}, {in2-priority-level}, .... {in6-priority-level}} // default priority level input 1-4 ascending - if (_inputPriorityParams != null && _inputPriorityParams.Count() > 0) - output.OutputPort.InputPriorities(_inputPriorityParams); + //if (_inputPriorityParams != null && _inputPriorityParams.Count() > 0) + // output.OutputPort.InputPriorities(_inputPriorityParams); if (port.Port == null) continue; From 334a62c32943d80337f9a382fe934a4af337662b Mon Sep 17 00:00:00 2001 From: Jason DeVito Date: Wed, 13 Sep 2023 08:32:07 -0500 Subject: [PATCH 73/96] fix: wraps GetDeviceForKey and GetFeedbackProperty methods in a try/catch --- .../Touchpanels/Mpc3Touchpanel.cs | 73 ++++++++++++------- 1 file changed, 48 insertions(+), 25 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Mpc3Touchpanel.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Mpc3Touchpanel.cs index f4611a70..f1153879 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Mpc3Touchpanel.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Mpc3Touchpanel.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Globalization; using Crestron.SimplSharpPro; using Newtonsoft.Json; @@ -27,6 +28,7 @@ namespace PepperDash.Essentials.Core.Touchpanels } _touchpanel.ButtonStateChange += _touchpanel_ButtonStateChange; + _buttons = buttons; if (_buttons == null) { @@ -55,6 +57,8 @@ namespace PepperDash.Essentials.Core.Touchpanels /// public void InitializeButton(string key, KeypadButton config) { + Debug.Console(1, this, "Initializing button '{0}'...", key); + if (config == null) { Debug.Console(1, this, "Button '{0}' config is null, unable to initialize", key); @@ -131,6 +135,8 @@ namespace PepperDash.Essentials.Core.Touchpanels /// public void InitializeButtonFeedback(string key, KeypadButton config) { + Debug.Console(1, this, "Initializing button '{0}' feedback...", key); + if (config == null) { Debug.Console(1, this, "Button '{0}' config is null, unable to initialize feedback", key); @@ -144,37 +150,54 @@ namespace PepperDash.Essentials.Core.Touchpanels var buttonFeedback = config.Feedback; if (buttonFeedback == null) { - Debug.Console(1, this, "Button '{0}' feedback not configured and will not be implemented. Verify feedback is configured if required.", key); + Debug.Console(1, this, "Button '{0}' feedback not configured and will not be implemented. If feedback is required, verify configuration.", + key); return; } - var device = DeviceManager.GetDeviceForKey(buttonFeedback.DeviceKey) as Device; - if (device == null) + Feedback deviceFeedback = null; + + try { - Debug.Console(1, this, "Button '{0}' feedback device with key '{0}' not found, feedback will not be implemented. Verify feedback deviceKey is properly configured.", - buttonFeedback.DeviceKey); + var device = DeviceManager.GetDeviceForKey(buttonFeedback.DeviceKey) as Device; + if (device == null) + { + Debug.Console(1, this, "Button '{0}' feedback with deviceKey '{1}' not found, feedback will not be implemented. Verify feedback deviceKey is properly configured.", + key, buttonFeedback.DeviceKey); + return; + } + + // TODO [ ] verify if this can replace the current method + deviceFeedback = device.GetFeedbackProperty(buttonFeedback.FeedbackName); + //Debug.Console(0, this, "deviceFeedback.GetType().Name: '{0}'", deviceFeedback.GetType().Name); + //switch (feedback.GetType().Name.ToLower()) + //{ + // case("boolfeedback"): + // { + // break; + // } + // case("intfeedback"): + // { + // break; + // } + // case("stringfeedback"): + // { + // break; + // } + //} + } + catch (Exception ex) + { + Debug.Console(0, this, "Failed to initialize button '{0}' feedback with deviceKey '{1}'. If feedback is required, verify configuration.", + key, buttonFeedback.DeviceKey); + + Debug.Console(1, this, "InitializeButtonFeedback Exception Message: {0}", ex.Message); + Debug.Console(2, this, "InitializeButtonFeedback Exception StackTrace: {0}", ex.StackTrace); + if (ex.InnerException != null) Debug.Console(2, this, "InitializeButtonFeedback Exception InnerExceptioni: {0}", ex.InnerException); + return; } - // TODO [ ] verify if this can replace the current method - var deviceFeedback = device.GetFeedbackProperty(buttonFeedback.FeedbackName); - Debug.Console(0, this, "deviceFeedback.GetType().Name: '{0}'", deviceFeedback.GetType().Name); - //switch (feedback.GetType().Name.ToLower()) - //{ - // case("boolfeedback"): - // { - // break; - // } - // case("intfeedback"): - // { - // break; - // } - // case("stringfeedback"): - // { - // break; - // } - //} - var boolFeedback = deviceFeedback as BoolFeedback; var intFeedback = deviceFeedback as IntFeedback; From 0fad667fabfc1fc5f1776cd6891c228254ed38e0 Mon Sep 17 00:00:00 2001 From: Jason DeVito Date: Wed, 13 Sep 2023 08:56:13 -0500 Subject: [PATCH 74/96] fix: adds additional debug statements when attempting to get feedback property for device --- .../Touchpanels/Mpc3Touchpanel.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Mpc3Touchpanel.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Mpc3Touchpanel.cs index f1153879..296965f9 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Mpc3Touchpanel.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Mpc3Touchpanel.cs @@ -155,7 +155,7 @@ namespace PepperDash.Essentials.Core.Touchpanels return; } - Feedback deviceFeedback = null; + Feedback deviceFeedback; try { @@ -166,9 +166,16 @@ namespace PepperDash.Essentials.Core.Touchpanels key, buttonFeedback.DeviceKey); return; } + + deviceFeedback = device.GetFeedbackProperty(buttonFeedback.FeedbackName); + if (deviceFeedback == null) + { + Debug.Console(1, this, "Button '{0}' feedback failed to get feedback property for '{1}', feedback will not be implemented. Verify feedback deviceKey is properly configured.", + key, buttonFeedback.FeedbackName); + return; + } // TODO [ ] verify if this can replace the current method - deviceFeedback = device.GetFeedbackProperty(buttonFeedback.FeedbackName); //Debug.Console(0, this, "deviceFeedback.GetType().Name: '{0}'", deviceFeedback.GetType().Name); //switch (feedback.GetType().Name.ToLower()) //{ From 5a67a4060db2c715081f05cbb428218b919c9c76 Mon Sep 17 00:00:00 2001 From: Jason DeVito Date: Wed, 13 Sep 2023 09:31:25 -0500 Subject: [PATCH 75/96] feat: adds routing sync provider interface and delegate --- .../PepperDashEssentialsBase/Routing/RoutingInterfaces.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingInterfaces.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingInterfaces.cs index 467bf045..e24480ff 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingInterfaces.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingInterfaces.cs @@ -204,4 +204,11 @@ namespace PepperDash.Essentials.Core SigType = sigType; } } + + public interface IRoutingSyncProvider + { + event RoutingSyncProviderDelegate SyncChanged; + } + + public delegate void RoutingSyncProviderDelegate(uint inputNumber, bool hasSync); } \ No newline at end of file From 8b6a9db7e0a04aac3868e8b31d4883f52de7dc6c Mon Sep 17 00:00:00 2001 From: Jason DeVito Date: Wed, 13 Sep 2023 09:32:44 -0500 Subject: [PATCH 76/96] refactor: refactors GetCecPort method --- .../Comm and IR/CommFactory.cs | 52 +++++++++---------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/CommFactory.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/CommFactory.cs index 9667b5b9..fd5fcfe2 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/CommFactory.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/CommFactory.cs @@ -117,39 +117,37 @@ namespace PepperDash.Essentials.Core { var dev = DeviceManager.GetDeviceForKey(config.ControlPortDevKey); - if (dev != null) - { - if (!String.IsNullOrEmpty(config.ControlPortName)) - { + Debug.Console(0, "GetCecPort: device '{0}' {1}", config.ControlPortDevKey, dev == null + ? "is not valid, failed to create build cec port" + : "found in device manager, attempting to build cec port"); - var inputPort = (dev as IRoutingInputsOutputs).InputPorts[config.ControlPortName]; + if (dev == null) + return null; - if (inputPort != null) - { - if (inputPort.Port is ICec) - return inputPort.Port as ICec; - } + if (String.IsNullOrEmpty(config.ControlPortName)) + { + Debug.Console(0, "GetCecPort: '{0}' - Configuration missing 'ControlPortName'", config.ControlPortDevKey); + return null; + } - var outputPort = (dev as IRoutingInputsOutputs).OutputPorts[config.ControlPortName]; + var inputPort = (dev as IRoutingInputsOutputs).InputPorts[config.ControlPortName]; + if (inputPort != null) + { + if (inputPort.Port is ICec) + return inputPort.Port as ICec; + } - if (outputPort != null) - { - if (outputPort.Port is ICec) - return outputPort.Port as ICec; - } + var outputPort = (dev as IRoutingInputsOutputs).OutputPorts[config.ControlPortName]; + if (outputPort != null) + { + if (outputPort.Port is ICec) + return outputPort.Port as ICec; + } - else - Debug.Console(0, "GetCecPort: Device '{0}' does not have a CEC port called: '{1}'", - config.ControlPortDevKey, config.ControlPortName); - } - else - { - Debug.Console(0, "GetCecPort: '{0}' - Configuration missing 'ControlPortName'", config.ControlPortDevKey); - } - } - Debug.Console(0, "GetCecPort: Device '{0}' is not a valid device.", config.ControlPortDevKey); + Debug.Console(0, "GetCecPort: Device '{0}' does not have a CEC port called: '{1}'", + config.ControlPortDevKey, config.ControlPortName); - return null; + return null; } /// From 9fb16f30b06ec392aa7194dbbacd2a7177c8520a Mon Sep 17 00:00:00 2001 From: Jason DeVito Date: Wed, 13 Sep 2023 10:02:20 -0500 Subject: [PATCH 77/96] refactor: Changes IRoutingHasSync interface - Changed IRoutingHasSync interface to IRoutingHasVideoInputSyncFeedbacks. - Remvoed IRoutingHasSynDelegate - Added interface to HdPsXxxController class --- .../PepperDashEssentialsBase/Routing/RoutingInterfaces.cs | 8 +++----- .../Essentials_DM/Chassis/HdPsXxxController.cs | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingInterfaces.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingInterfaces.cs index e24480ff..45245066 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingInterfaces.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Routing/RoutingInterfaces.cs @@ -205,10 +205,8 @@ namespace PepperDash.Essentials.Core } } - public interface IRoutingSyncProvider + public interface IRoutingHasVideoInputSyncFeedbacks { - event RoutingSyncProviderDelegate SyncChanged; - } - - public delegate void RoutingSyncProviderDelegate(uint inputNumber, bool hasSync); + FeedbackCollection VideoInputSyncFeedbacks { get; } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs index bba85d25..1bf40083 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs @@ -15,7 +15,7 @@ using PepperDash_Essentials_DM.Config; namespace PepperDash_Essentials_DM.Chassis { [Description("Wrapper class for all HdPsXxx switchers")] - public class HdPsXxxController : CrestronGenericBridgeableBaseDevice, IRoutingNumericWithFeedback + public class HdPsXxxController : CrestronGenericBridgeableBaseDevice, IRoutingNumericWithFeedback, IRoutingHasVideoInputSyncFeedbacks { private readonly HdPsXxx _chassis; //private byte[] _inputPriorityParams; From 393033b6c9c4a80778e2c68c3921f97bc592db9d Mon Sep 17 00:00:00 2001 From: Jason DeVito Date: Wed, 13 Sep 2023 10:13:39 -0500 Subject: [PATCH 78/96] refactor: Updates HdPsXxxController class - Modifies `SetupInput()` and `SetupOutput()` - Renames `GetInputPriorities()` to `SetInputPriorities()` --- .../Chassis/HdPsXxxController.cs | 106 ++++++++---------- 1 file changed, 46 insertions(+), 60 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs index 1bf40083..705061d2 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; using Crestron.SimplSharpPro; using Crestron.SimplSharpPro.DeviceSupport; @@ -18,7 +19,6 @@ namespace PepperDash_Essentials_DM.Chassis public class HdPsXxxController : CrestronGenericBridgeableBaseDevice, IRoutingNumericWithFeedback, IRoutingHasVideoInputSyncFeedbacks { private readonly HdPsXxx _chassis; - //private byte[] _inputPriorityParams; public RoutingPortCollection InputPorts { get; private set; } public RoutingPortCollection OutputPorts { get; private set; } @@ -41,6 +41,7 @@ namespace PepperDash_Essentials_DM.Chassis public event EventHandler NumericSwitchChange; public event EventHandler DmInputChange; + /// /// Constructor /// @@ -76,12 +77,6 @@ namespace PepperDash_Essentials_DM.Chassis if (_chassis.NumberOfOutputs == 1) AutoRouteFeedback = new BoolFeedback(() => _chassis.PriorityRouteOnFeedback.BoolValue); - //if (props.InputPriorities != null) - //{ - // _inputPriorityParams = new byte[_chassis.NumberOfInputs]; - // _inputPriorityParams = GetInputPriorities(props); - //} - InputNames = props.Inputs; SetupInputs(InputNames); @@ -90,7 +85,7 @@ namespace PepperDash_Essentials_DM.Chassis } // get input priorities - private byte[] GetInputPriorities(HdPsXxxPropertiesConfig props) + private byte[] SetInputPriorities(HdPsXxxPropertiesConfig props) { throw new NotImplementedException(); } @@ -103,52 +98,59 @@ namespace PepperDash_Essentials_DM.Chassis Debug.Console(1, this, "Failed to setup inputs, properties are null"); return; } - foreach (var kvp in dict) - { - Debug.Console(1, this, "props.Input[{0}]: {1}", kvp.Key, kvp.Value); - } - + + // iterate through HDMI inputs foreach (var item in _chassis.HdmiInputs) { var input = item; var index = item.Number; var key = string.Format("hdmiIn{0}", index); - var name = string.IsNullOrEmpty(InputNames[index]) ? string.Format("HDMI Input {0}", index) : InputNames[index]; + input.Name.StringValue = string.IsNullOrEmpty(InputNames[index]) + ? string.Format("HDMI Input {0}", index) + : InputNames[index]; - InputNameFeedbacks.Add(new StringFeedback(name, () => InputNames[index])); + InputNameFeedbacks.Add(new StringFeedback(index.ToString(CultureInfo.InvariantCulture), + () => InputNames[index])); var port = new RoutingInputPort(key, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, input, this) { FeedbackMatchObject = input }; - Debug.Console(1, this, "Adding Input port: {0}", port.Key); + Debug.Console(1, this, "Adding Input port: {0} - {1}", port.Key, input.Name); InputPorts.Add(port); - InputHdcpEnableFeedback.Add(new BoolFeedback(name, () => input.InputPort.HdcpSupportOnFeedback.BoolValue)); + InputHdcpEnableFeedback.Add(new BoolFeedback(index.ToString(CultureInfo.InvariantCulture), + () => input.InputPort.HdcpSupportOnFeedback.BoolValue)); - VideoInputSyncFeedbacks.Add(new BoolFeedback(name, () => input.VideoDetectedFeedback.BoolValue)); + VideoInputSyncFeedbacks.Add(new BoolFeedback(index.ToString(CultureInfo.InvariantCulture), + () => input.VideoDetectedFeedback.BoolValue)); } + // iterate through DM Lite inputs foreach (var item in _chassis.DmLiteInputs) { var input = item; var index = item.Number; var key = string.Format("dmLiteIn{0}", index); - var name = string.IsNullOrEmpty(InputNames[index]) ? string.Format("DM Input {0}", index) : InputNames[index]; - input.Name.StringValue = name; + input.Name.StringValue = string.IsNullOrEmpty(InputNames[index]) + ? string.Format("DM Input {0}", index) + : InputNames[index]; - InputNameFeedbacks.Add(new StringFeedback(name, () => InputNames[index])); + InputNameFeedbacks.Add(new StringFeedback(index.ToString(CultureInfo.InvariantCulture), + () => InputNames[index])); var port = new RoutingInputPort(key, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, input, this) { FeedbackMatchObject = input }; - Debug.Console(0, this, "Adding Input port: {0}", port.Key); + Debug.Console(0, this, "Adding Input port: {0} - {1}", port.Key, input.Name); InputPorts.Add(port); - InputHdcpEnableFeedback.Add(new BoolFeedback(name, () => input.InputPort.HdcpSupportOnFeedback.BoolValue)); + InputHdcpEnableFeedback.Add(new BoolFeedback(index.ToString(CultureInfo.InvariantCulture), + () => input.InputPort.HdcpSupportOnFeedback.BoolValue)); - VideoInputSyncFeedbacks.Add(new BoolFeedback(name, () => input.VideoDetectedFeedback.BoolValue)); + VideoInputSyncFeedbacks.Add(new BoolFeedback(index.ToString(CultureInfo.InvariantCulture), + () => input.VideoDetectedFeedback.BoolValue)); } _chassis.DMInputChange += _chassis_InputChange; @@ -162,54 +164,38 @@ namespace PepperDash_Essentials_DM.Chassis Debug.Console(1, this, "Failed to setup outputs, properties are null"); return; } - foreach (var kvp in dict) - { - Debug.Console(1, this, "props.Output[{0}]: {1}", kvp.Key, kvp.Value); - } foreach (var item in _chassis.HdmiDmLiteOutputs) { var output = item; var index = item.Number; var key = string.Format("hdmiDmLiteOut{0}", index); - var name = string.IsNullOrEmpty(OutputNames[index]) ? string.Format("Output {0}", index) : OutputNames[index]; - output.Name.StringValue = name; + + output.Name.StringValue = string.IsNullOrEmpty(OutputNames[index]) + ? string.Format("Output {0}", index) + : OutputNames[index]; - var port = new RoutingOutputPort(key, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, output, this) + var hdmiPort = new RoutingOutputPort(key, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, output, this) { FeedbackMatchObject = output, - // set port for CEC - Port = output + Port = output.HdmiOutput.HdmiOutputPort.StreamCec }; - Debug.Console(0, this, "Adding Output port: {0}", port.Key); - OutputPorts.Add(port); + Debug.Console(1, this, "Adding Output port: {0} - {1}", hdmiPort.Key, output.Name); + OutputPorts.Add(hdmiPort); - OutputRouteNameFeedback.Add(new StringFeedback(name, () => output.VideoOutFeedback.NameFeedback.StringValue)); + var dmLitePort = new RoutingOutputPort(key, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.DmCat, output, this) + { + FeedbackMatchObject = output, + Port = output.DmLiteOutput.DmLiteOutputPort.StreamCec + }; + Debug.Console(1, this, "Adding Output port: {0} - {1}", dmLitePort.Key, output.Name); + OutputPorts.Add(dmLitePort); - VideoOutputRouteFeedbacks.Add(new IntFeedback(name, + OutputRouteNameFeedback.Add(new StringFeedback(index.ToString(CultureInfo.InvariantCulture), + () => output.VideoOutFeedback.NameFeedback.StringValue)); + + VideoOutputRouteFeedbacks.Add(new IntFeedback(index.ToString(CultureInfo.InvariantCulture), () => output.VideoOutFeedback == null ? 0 : (int)output.VideoOutFeedback.Number)); - - // TODO [ ] Investigate setting input priorities per output - // {{in1-priority-level}, {in2-priority-level}, .... {in6-priority-level}} - // default priority level input 1-4 ascending - //if (_inputPriorityParams != null && _inputPriorityParams.Count() > 0) - // output.OutputPort.InputPriorities(_inputPriorityParams); - - if (port.Port == null) continue; - - var hdmiOutputStreamCec = output.HdmiOutput.HdmiOutputPort.StreamCec; - if (hdmiOutputStreamCec != null) - { - var streamCec = new StreamCecWrapper(string.Format("{0}-hdmiOut{1}-streamCec", Key, index), hdmiOutputStreamCec); - DeviceManager.AddDevice(streamCec); - } - - var dmLiteOutputStreamCec = output.DmLiteOutput.DmLiteOutputPort.StreamCec; - if (dmLiteOutputStreamCec != null) - { - var streamCec = new StreamCecWrapper(string.Format("{0}-dmLiteOut{1}-streamCec", Key, index), dmLiteOutputStreamCec); - DeviceManager.AddDevice(streamCec); - } } _chassis.DMOutputChange += _chassis_OutputChange; @@ -547,7 +533,7 @@ namespace PepperDash_Essentials_DM.Chassis } - #endregion + #endregion } From 7ecb2ecf6dfeadcf2191d49cca1be0a03e10b54d Mon Sep 17 00:00:00 2001 From: Jason DeVito Date: Wed, 13 Sep 2023 16:43:23 -0500 Subject: [PATCH 79/96] fix: updates SetupOutputs to create a hdmiOutX and dmLiteOutX port --- .../Chassis/HdPsXxxController.cs | 32 +++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs index 705061d2..cbcf2a7c 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs @@ -105,10 +105,12 @@ namespace PepperDash_Essentials_DM.Chassis var input = item; var index = item.Number; var key = string.Format("hdmiIn{0}", index); - input.Name.StringValue = string.IsNullOrEmpty(InputNames[index]) - ? string.Format("HDMI Input {0}", index) + var name = string.IsNullOrEmpty(InputNames[index]) + ? string.Format("HDMI Input {0}", index) : InputNames[index]; + input.Name.StringValue = name; + InputNameFeedbacks.Add(new StringFeedback(index.ToString(CultureInfo.InvariantCulture), () => InputNames[index])); @@ -116,7 +118,7 @@ namespace PepperDash_Essentials_DM.Chassis { FeedbackMatchObject = input }; - Debug.Console(1, this, "Adding Input port: {0} - {1}", port.Key, input.Name); + Debug.Console(1, this, "Adding Input port: {0} - {1}", port.Key, name); InputPorts.Add(port); InputHdcpEnableFeedback.Add(new BoolFeedback(index.ToString(CultureInfo.InvariantCulture), @@ -132,10 +134,12 @@ namespace PepperDash_Essentials_DM.Chassis var input = item; var index = item.Number; var key = string.Format("dmLiteIn{0}", index); - input.Name.StringValue = string.IsNullOrEmpty(InputNames[index]) + var name = string.IsNullOrEmpty(InputNames[index]) ? string.Format("DM Input {0}", index) : InputNames[index]; + input.Name.StringValue = name; + InputNameFeedbacks.Add(new StringFeedback(index.ToString(CultureInfo.InvariantCulture), () => InputNames[index])); @@ -143,7 +147,7 @@ namespace PepperDash_Essentials_DM.Chassis { FeedbackMatchObject = input }; - Debug.Console(0, this, "Adding Input port: {0} - {1}", port.Key, input.Name); + Debug.Console(0, this, "Adding Input port: {0} - {1}", port.Key, name); InputPorts.Add(port); InputHdcpEnableFeedback.Add(new BoolFeedback(index.ToString(CultureInfo.InvariantCulture), @@ -169,26 +173,28 @@ namespace PepperDash_Essentials_DM.Chassis { var output = item; var index = item.Number; - var key = string.Format("hdmiDmLiteOut{0}", index); - - output.Name.StringValue = string.IsNullOrEmpty(OutputNames[index]) + var name = string.IsNullOrEmpty(OutputNames[index]) ? string.Format("Output {0}", index) - : OutputNames[index]; + : OutputNames[index]; + + output.Name.StringValue = name; - var hdmiPort = new RoutingOutputPort(key, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, output, this) + var hdmiKey = string.Format("hdmiOut{0}", index); + var hdmiPort = new RoutingOutputPort(hdmiKey, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, output, this) { FeedbackMatchObject = output, Port = output.HdmiOutput.HdmiOutputPort.StreamCec }; - Debug.Console(1, this, "Adding Output port: {0} - {1}", hdmiPort.Key, output.Name); + Debug.Console(1, this, "Adding Output port: {0} - {1}", hdmiPort.Key, name); OutputPorts.Add(hdmiPort); - var dmLitePort = new RoutingOutputPort(key, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.DmCat, output, this) + var dmLiteKey = string.Format("dmLiteOut{0}", index); + var dmLitePort = new RoutingOutputPort(dmLiteKey, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.DmCat, output, this) { FeedbackMatchObject = output, Port = output.DmLiteOutput.DmLiteOutputPort.StreamCec }; - Debug.Console(1, this, "Adding Output port: {0} - {1}", dmLitePort.Key, output.Name); + Debug.Console(1, this, "Adding Output port: {0} - {1}", dmLitePort.Key, name); OutputPorts.Add(dmLitePort); OutputRouteNameFeedback.Add(new StringFeedback(index.ToString(CultureInfo.InvariantCulture), From 6d020132cfb2283fbcd1fa3bee89f3f4081eedac Mon Sep 17 00:00:00 2001 From: Jason DeVito Date: Wed, 20 Sep 2023 15:38:25 -0500 Subject: [PATCH 80/96] refactor: GetCecPort method to handle exceptions --- .../Comm and IR/CommFactory.cs | 71 +++++++++++-------- 1 file changed, 43 insertions(+), 28 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/CommFactory.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/CommFactory.cs index fd5fcfe2..549404e0 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/CommFactory.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/CommFactory.cs @@ -115,39 +115,54 @@ namespace PepperDash.Essentials.Core /// public static ICec GetCecPort(ControlPropertiesConfig config) { - var dev = DeviceManager.GetDeviceForKey(config.ControlPortDevKey); - - Debug.Console(0, "GetCecPort: device '{0}' {1}", config.ControlPortDevKey, dev == null - ? "is not valid, failed to create build cec port" - : "found in device manager, attempting to build cec port"); - - if (dev == null) - return null; - - if (String.IsNullOrEmpty(config.ControlPortName)) + try { - Debug.Console(0, "GetCecPort: '{0}' - Configuration missing 'ControlPortName'", config.ControlPortDevKey); - return null; + var dev = DeviceManager.GetDeviceForKey(config.ControlPortDevKey); + + Debug.Console(0, "GetCecPort: device '{0}' {1}", config.ControlPortDevKey, dev == null + ? "is not valid, failed to get cec port" + : "found in device manager, attempting to get cec port"); + + if (dev == null) + return null; + + if (String.IsNullOrEmpty(config.ControlPortName)) + { + Debug.Console(0, "GetCecPort: '{0}' - Configuration missing 'ControlPortName'", config.ControlPortDevKey); + return null; + } + + + var inputsOutputs = dev as IRoutingInputsOutputs; + if (inputsOutputs == null) + { + Debug.Console(0, "GetCecPort: Device '{0}' does not support IRoutingInputsOutputs, failed to get CEC port called '{1}'", + config.ControlPortDevKey, config.ControlPortName); + + return null; + } + + var inputPort = inputsOutputs.InputPorts[config.ControlPortName]; + if (inputPort != null && inputPort.Port is ICec) + return inputPort.Port as ICec; + + + var outputPort = inputsOutputs.OutputPorts[config.ControlPortName]; + if (outputPort != null && outputPort.Port is ICec) + return outputPort.Port as ICec; + } + catch (Exception ex) + { + Debug.Console(1, "GetCecPort Exception Message: {0}", ex.Message); + Debug.Console(2, "GetCecPort Exception StackTrace: {0}", ex.StackTrace); + if (ex.InnerException != null) + Debug.Console(0, "GetCecPort Exception InnerException: {0}", ex.InnerException); } - var inputPort = (dev as IRoutingInputsOutputs).InputPorts[config.ControlPortName]; - if (inputPort != null) - { - if (inputPort.Port is ICec) - return inputPort.Port as ICec; - } - - var outputPort = (dev as IRoutingInputsOutputs).OutputPorts[config.ControlPortName]; - if (outputPort != null) - { - if (outputPort.Port is ICec) - return outputPort.Port as ICec; - } - - Debug.Console(0, "GetCecPort: Device '{0}' does not have a CEC port called: '{1}'", + Debug.Console(0, "GetCecPort: Device '{0}' does not have a CEC port called '{1}'", config.ControlPortDevKey, config.ControlPortName); - return null; + return null; } /// From 1569c12450a11c8b99b1b8f6f0d917b0d35a0dde Mon Sep 17 00:00:00 2001 From: Jason DeVito Date: Wed, 20 Sep 2023 15:41:06 -0500 Subject: [PATCH 81/96] fix: Updates SetupOutputs method Corrects the port referencece to exclude `.StreamCec` when building the port. --- .../Essentials_DM/Chassis/HdPsXxxController.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs index cbcf2a7c..bf9f72cc 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs @@ -183,7 +183,7 @@ namespace PepperDash_Essentials_DM.Chassis var hdmiPort = new RoutingOutputPort(hdmiKey, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, output, this) { FeedbackMatchObject = output, - Port = output.HdmiOutput.HdmiOutputPort.StreamCec + Port = output.HdmiOutput.HdmiOutputPort }; Debug.Console(1, this, "Adding Output port: {0} - {1}", hdmiPort.Key, name); OutputPorts.Add(hdmiPort); @@ -192,13 +192,13 @@ namespace PepperDash_Essentials_DM.Chassis var dmLitePort = new RoutingOutputPort(dmLiteKey, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.DmCat, output, this) { FeedbackMatchObject = output, - Port = output.DmLiteOutput.DmLiteOutputPort.StreamCec + Port = output.DmLiteOutput.DmLiteOutputPort }; Debug.Console(1, this, "Adding Output port: {0} - {1}", dmLitePort.Key, name); OutputPorts.Add(dmLitePort); - + OutputRouteNameFeedback.Add(new StringFeedback(index.ToString(CultureInfo.InvariantCulture), - () => output.VideoOutFeedback.NameFeedback.StringValue)); + () => output.VideoOutFeedback.NameFeedback.StringValue)); VideoOutputRouteFeedbacks.Add(new IntFeedback(index.ToString(CultureInfo.InvariantCulture), () => output.VideoOutFeedback == null ? 0 : (int)output.VideoOutFeedback.Number)); From b9fd9f23a4e5fcae2c7b941572c47c02ce3fbd74 Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Tue, 4 Oct 2022 17:42:58 -0600 Subject: [PATCH 82/96] refactor: break IEssentialsRoom down further In order to allow for easier composition of interfaces for room plugins, the IEssentialsRoom interface needed to be broken down further to the simplest components a room would need to function. The interfaces are composited in the huddle space and the Huddle VTC interfaces. --- .../Interfaces/IEssentialsHuddleSpaceRoom.cs | 3 +- .../Interfaces/IEssentialsHuddleVtc1Room.cs | 3 +- .../Devices/IVolumeAndAudioInterfaces.cs | 4 +++ ...lsHuddleSpaceFusionSystemControllerBase.cs | 28 ++++++++++------ .../RoomOnToDefaultSourceWhenOccupied.cs | 25 +++++++++++---- .../Room/IEssentialsRoom.cs | 32 ++++--------------- .../Room/Interfaces.cs | 27 +++++++++++++++- 7 files changed, 77 insertions(+), 45 deletions(-) diff --git a/PepperDashEssentials/Room/Types/Interfaces/IEssentialsHuddleSpaceRoom.cs b/PepperDashEssentials/Room/Types/Interfaces/IEssentialsHuddleSpaceRoom.cs index 41616d96..dccae06a 100644 --- a/PepperDashEssentials/Room/Types/Interfaces/IEssentialsHuddleSpaceRoom.cs +++ b/PepperDashEssentials/Room/Types/Interfaces/IEssentialsHuddleSpaceRoom.cs @@ -7,7 +7,8 @@ using PepperDash.Essentials.Room.Config; namespace PepperDash.Essentials { - public interface IEssentialsHuddleSpaceRoom : IEssentialsRoom, IHasCurrentSourceInfoChange, IRunRouteAction, IRunDefaultPresentRoute, IHasDefaultDisplay, IHasCurrentVolumeControls + public interface IEssentialsHuddleSpaceRoom : IEssentialsRoom, IHasCurrentSourceInfoChange, IRunRouteAction, IRunDefaultPresentRoute, IHasDefaultDisplay, IHasCurrentVolumeControls, IRoomOccupancy, + IEmergency, IMicrophonePrivacy { bool ExcludeFromGlobalFunctions { get; } diff --git a/PepperDashEssentials/Room/Types/Interfaces/IEssentialsHuddleVtc1Room.cs b/PepperDashEssentials/Room/Types/Interfaces/IEssentialsHuddleVtc1Room.cs index 03f7340b..85937828 100644 --- a/PepperDashEssentials/Room/Types/Interfaces/IEssentialsHuddleVtc1Room.cs +++ b/PepperDashEssentials/Room/Types/Interfaces/IEssentialsHuddleVtc1Room.cs @@ -8,7 +8,8 @@ using PepperDash.Essentials.Devices.Common.AudioCodec; namespace PepperDash.Essentials { public interface IEssentialsHuddleVtc1Room : IEssentialsRoom, IHasCurrentSourceInfoChange, - IPrivacy, IHasCurrentVolumeControls, IRunRouteAction, IRunDefaultCallRoute, IHasVideoCodec, IHasAudioCodec, IHasDefaultDisplay, IHasInCallFeedback + IPrivacy, IHasCurrentVolumeControls, IRunRouteAction, IRunDefaultCallRoute, IHasVideoCodec, IHasAudioCodec, IHasDefaultDisplay, IHasInCallFeedback, + IRoomOccupancy, IEmergency, IMicrophonePrivacy { EssentialsHuddleVtc1PropertiesConfig PropertiesConfig { get; } diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IVolumeAndAudioInterfaces.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IVolumeAndAudioInterfaces.cs index c8a5df39..c8033b92 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IVolumeAndAudioInterfaces.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IVolumeAndAudioInterfaces.cs @@ -72,6 +72,10 @@ namespace PepperDash.Essentials.Core { IBasicVolumeControls CurrentVolumeControls { get; } event EventHandler CurrentVolumeDeviceChange; + + void SetDefaultLevels(); + + bool ZeroVolumeWhenSwtichingVolumeDevices { get; } } diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Fusion/EssentialsHuddleSpaceFusionSystemControllerBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Fusion/EssentialsHuddleSpaceFusionSystemControllerBase.cs index 1bf925d6..a675f765 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Fusion/EssentialsHuddleSpaceFusionSystemControllerBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Fusion/EssentialsHuddleSpaceFusionSystemControllerBase.cs @@ -148,15 +148,20 @@ namespace PepperDash.Essentials.Core.Fusion ReadGuidFile(guidFilePath); } - if (Room.RoomOccupancy != null) + var occupancyRoom = Room as IRoomOccupancy; + + if (occupancyRoom != null) { - if (Room.OccupancyStatusProviderIsRemote) + if (occupancyRoom.RoomOccupancy != null) { - SetUpRemoteOccupancy(); - } - else - { - SetUpLocalOccupancy(); + if (occupancyRoom.OccupancyStatusProviderIsRemote) + { + SetUpRemoteOccupancy(); + } + else + { + SetUpLocalOccupancy(); + } } } @@ -1523,10 +1528,15 @@ namespace PepperDash.Essentials.Core.Fusion // Tie to method on occupancy object //occSensorShutdownMinutes.OutputSig.UserObject(new Action(ushort)(b => Room.OccupancyObj.SetShutdownMinutes(b)); + var occRoom = Room as IRoomOccupancy; + if (occRoom != null) + { + occRoom.RoomOccupancy.RoomIsOccupiedFeedback.LinkInputSig(occSensorAsset.RoomOccupied.InputSig); + occRoom.RoomOccupancy.RoomIsOccupiedFeedback.OutputChange += RoomIsOccupiedFeedback_OutputChange; + } RoomOccupancyRemoteStringFeedback = new StringFeedback(() => _roomOccupancyRemoteString); - Room.RoomOccupancy.RoomIsOccupiedFeedback.LinkInputSig(occSensorAsset.RoomOccupied.InputSig); - Room.RoomOccupancy.RoomIsOccupiedFeedback.OutputChange += RoomIsOccupiedFeedback_OutputChange; + RoomOccupancyRemoteStringFeedback.LinkInputSig(occSensorAsset.RoomOccupancyInfo.InputSig); //} diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Behaviours/RoomOnToDefaultSourceWhenOccupied.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Behaviours/RoomOnToDefaultSourceWhenOccupied.cs index 81cbff9e..b7440213 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Behaviours/RoomOnToDefaultSourceWhenOccupied.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Behaviours/RoomOnToDefaultSourceWhenOccupied.cs @@ -38,7 +38,7 @@ namespace PepperDash.Essentials.Core ScheduledEventGroup FeatureEventGroup; - public IEssentialsRoom Room { get; private set; } + public IRoomOccupancy Room { get; private set; } private Fusion.EssentialsHuddleSpaceFusionSystemControllerBase FusionRoom; @@ -84,7 +84,7 @@ namespace PepperDash.Essentials.Core /// void SetUpDevice() { - Room = DeviceManager.GetDeviceForKey(PropertiesConfig.RoomKey) as IEssentialsRoom; + Room = DeviceManager.GetDeviceForKey(PropertiesConfig.RoomKey) as IRoomOccupancy; if (Room != null) { @@ -235,12 +235,23 @@ namespace PepperDash.Essentials.Core if (FeatureEnabled) { - // Check room power state first - if (!Room.OnFeedback.BoolValue) - { - Debug.Console(1, this, "Powering Room on to default source"); - Room.RunDefaultPresentRoute(); + var essentialsRoom = Room as IEssentialsRoom; + + if (essentialsRoom != null) { + if (!essentialsRoom.OnFeedback.BoolValue) + { + Debug.Console(1, this, "Powering Room on to default source"); + + var defaultRouteRoom = Room as IRunDefaultPresentRoute; + + if (defaultRouteRoom != null) + { + defaultRouteRoom.RunDefaultPresentRoute(); + } + } } + // Check room power state first + } } } diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/IEssentialsRoom.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/IEssentialsRoom.cs index 2273690f..9a70f980 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/IEssentialsRoom.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/IEssentialsRoom.cs @@ -17,15 +17,10 @@ namespace PepperDash.Essentials.Core /// public interface IEssentialsRoom : IKeyName, IReconfigurableDevice, IRunDefaultPresentRoute, IEnvironmentalControls { - BoolFeedback OnFeedback { get; } - - event EventHandler RoomOccupancyIsSet; + BoolFeedback OnFeedback { get; } BoolFeedback IsWarmingUpFeedback { get; } - BoolFeedback IsCoolingDownFeedback { get; } - - IOccupancyStatusProvider RoomOccupancy { get; } - bool OccupancyStatusProviderIsRemote { get; } + BoolFeedback IsCoolingDownFeedback { get; } bool IsMobileControlEnabled { get; } IMobileControlRoomBridge MobileControlRoomBridge { get; } @@ -35,31 +30,16 @@ namespace PepperDash.Essentials.Core SecondsCountdownTimer ShutdownPromptTimer { get; } int ShutdownPromptSeconds { get; } int ShutdownVacancySeconds { get; } - eShutdownType ShutdownType { get; } - - EssentialsRoomEmergencyBase Emergency { get; } - - Core.Privacy.MicrophonePrivacyController MicrophonePrivacy { get; } + eShutdownType ShutdownType { get; } string LogoUrlLightBkgnd { get; } string LogoUrlDarkBkgnd { get; } - eVacancyMode VacancyMode { get; } + void StartShutdown(eShutdownType type); - bool ZeroVolumeWhenSwtichingVolumeDevices { get; } + void Shutdown(); - void StartShutdown(eShutdownType type); - void StartRoomVacancyTimer(eVacancyMode mode); - - void Shutdown(); - - void SetRoomOccupancy(IOccupancyStatusProvider statusProvider, int timeoutMinutes); - - void PowerOnToDefaultOrLastSource(); - - void SetDefaultLevels(); - - void RoomVacatedForTimeoutPeriod(object o); + void PowerOnToDefaultOrLastSource(); } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Interfaces.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Interfaces.cs index b5121e9c..e962e604 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Interfaces.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/Interfaces.cs @@ -41,7 +41,6 @@ namespace PepperDash.Essentials.Core void RunRouteAction(string routeKey, string sourceListKey); void RunRouteAction(string routeKey, string sourceListKey, Action successCallback); - } /// @@ -78,4 +77,30 @@ namespace PepperDash.Essentials.Core bool HasEnvironmentalControlDevices { get; } } + public interface IRoomOccupancy:IKeyed + { + IOccupancyStatusProvider RoomOccupancy { get; } + bool OccupancyStatusProviderIsRemote { get; } + + void SetRoomOccupancy(IOccupancyStatusProvider statusProvider, int timeoutMinutes); + + void RoomVacatedForTimeoutPeriod(object o); + + void StartRoomVacancyTimer(eVacancyMode mode); + + eVacancyMode VacancyMode { get; } + + event EventHandler RoomOccupancyIsSet; + } + + public interface IEmergency + { + EssentialsRoomEmergencyBase Emergency { get; } + } + + public interface IMicrophonePrivacy + { + Core.Privacy.MicrophonePrivacyController MicrophonePrivacy { get; } + } + } \ No newline at end of file From c0b0b35f6df42b05b1114d2ebaedff3bc2be4ac2 Mon Sep 17 00:00:00 2001 From: jdevito Date: Sat, 7 Oct 2023 16:51:27 -0500 Subject: [PATCH 83/96] feat(wip): seeds feature for IR signal bridge map --- .../Comm and IR/IRPortHelper.cs | 8 ++- .../Devices/GenericIRController.cs | 60 +++++++++++-------- .../Devices/IrOutputPortController.cs | 4 ++ .../PepperDash_Essentials_Core.csproj | 1 + 4 files changed, 48 insertions(+), 25 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/IRPortHelper.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/IRPortHelper.cs index c75630e4..80ee2a2c 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/IRPortHelper.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/IRPortHelper.cs @@ -224,12 +224,18 @@ namespace PepperDash.Essentials.Core /// public class IrOutPortConfig { + [JsonProperty("port")] public IROutputPort Port { get; set; } + + [JsonProperty("fileName")] public string FileName { get; set; } + [JsonProperty("useBridgeJoinMap")] + public bool UseBridgeJoinMap { get; set; } + public IrOutPortConfig() { - FileName = ""; + FileName = ""; } } } \ No newline at end of file diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/GenericIRController.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/GenericIRController.cs index 409562a2..959b334b 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/GenericIRController.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/GenericIRController.cs @@ -1,11 +1,11 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; +using System.Linq; using Crestron.SimplSharpPro.DeviceSupport; using Newtonsoft.Json; using PepperDash.Core; -using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Bridges; using PepperDash.Essentials.Core.Config; +using PepperDash_Essentials_Core.Bridges.JoinMaps; namespace PepperDash.Essentials.Core.Devices { @@ -21,9 +21,12 @@ namespace PepperDash.Essentials.Core.Devices public string[] IrCommands {get { return _port.IrFileCommands; }} + public Dictionary BridgeJoins; + public GenericIrController(string key, string name, IrOutputPortController irPort) : base(key, name) { _port = irPort; + if(_port.UseBridgeJoinMap) BridgeJoins = new Dictionary(); if (_port == null) { @@ -71,23 +74,39 @@ namespace PepperDash.Essentials.Core.Devices if (!string.IsNullOrEmpty(joinMapSerialized)) joinMap = JsonConvert.DeserializeObject(joinMapSerialized); - for (uint i = 0; i < _port.IrFileCommands.Length; i++) - { - var cmd = _port.IrFileCommands[i]; - var joinData = new JoinDataComplete(new JoinData {JoinNumber = i, JoinSpan = 1}, - new JoinMetadata - { - Description = cmd, - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); + if (_port.UseBridgeJoinMap) + { + Debug.Console(0, this, "Using new IR bridge join map"); - joinData.SetJoinOffset(joinStart); + var joins = BridgeJoins.Where((kv) => _port.IrFileCommands.Any(cmd => cmd == kv.Key)).ToDictionary(kv => kv.Key, kv=> kv.Value); + foreach (var join in joins) + { + Debug.Console(0, this, "_useBridgeJoinMap: {0}: {1}", join.Key, join.Value); + } + //joinMap.Joins = joins.Select(kv => kv.Value.SetJoinOffset(joinStart)).ToString(); + } + else + { + Debug.Console(0, this, "Using legacy IR join mapping based on available IR commands"); - joinMap.Joins.Add(cmd,joinData); + for (uint i = 0; i < _port.IrFileCommands.Length; i++) + { + var cmd = _port.IrFileCommands[i]; + var joinData = new JoinDataComplete(new JoinData { JoinNumber = i, JoinSpan = 1 }, + new JoinMetadata + { + Description = cmd, + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); - trilist.SetBoolSigAction(joinData.JoinNumber, (b) => Press(cmd, b)); - } + joinData.SetJoinOffset(joinStart); + + joinMap.Joins.Add(cmd, joinData); + + trilist.SetBoolSigAction(joinData.JoinNumber, (b) => Press(cmd, b)); + } + } joinMap.PrintJoinMapInfo(); @@ -109,13 +128,6 @@ namespace PepperDash.Essentials.Core.Devices } } - public sealed class GenericIrControllerJoinMap : JoinMapBaseAdvanced - { - public GenericIrControllerJoinMap(uint joinStart) : base(joinStart) - { - } - } - public class GenericIrControllerFactory : EssentialsDeviceFactory { public GenericIrControllerFactory() diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IrOutputPortController.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IrOutputPortController.cs index cce1d46e..5ce7a779 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IrOutputPortController.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IrOutputPortController.cs @@ -29,6 +29,8 @@ namespace PepperDash.Essentials.Core public string[] IrFileCommands { get { return IrPort.AvailableStandardIRCmds(IrPortUid); } } + public bool UseBridgeJoinMap { get; private set; } + /// /// Constructor for IrDevice base class. If a null port is provided, this class will /// still function without trying to talk to a port. @@ -62,6 +64,8 @@ namespace PepperDash.Essentials.Core Debug.Console(0, this, "WARNING No valid IR Port assigned to controller. IR will not function"); return; } + + UseBridgeJoinMap = config.Properties["control"]["useBridgeJoinMap"].Value(); var filePath = Global.FilePathPrefix + "ir" + Global.DirectorySeparator + config.Properties["control"]["irFile"].Value(); Debug.Console(1, "*************Attempting to load IR file: {0}***************", filePath); diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj index 75d4626d..c1445edb 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj @@ -127,6 +127,7 @@ + From 1a123ab6dc895c454e458a2089c7e8f6e804d58f Mon Sep 17 00:00:00 2001 From: jdevito Date: Sat, 7 Oct 2023 16:54:29 -0500 Subject: [PATCH 84/96] feat: adds GenericIrControllerJoinMap --- .../JoinMaps/GenericIrControllerJoinMap.cs | 757 ++++++++++++++++++ 1 file changed, 757 insertions(+) create mode 100644 essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericIrControllerJoinMap.cs diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericIrControllerJoinMap.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericIrControllerJoinMap.cs new file mode 100644 index 00000000..00257c9f --- /dev/null +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericIrControllerJoinMap.cs @@ -0,0 +1,757 @@ +using PepperDash.Essentials.Core; + +namespace PepperDash_Essentials_Core.Bridges.JoinMaps +{ + public sealed class GenericIrControllerJoinMap : JoinMapBaseAdvanced + { + [JoinName("POWER")] + public JoinDataComplete Power = new JoinDataComplete( + new JoinData + { + JoinNumber = 1, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Power Toggle", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("POWER_ON")] + public JoinDataComplete PowerOn = new JoinDataComplete( + new JoinData + { + JoinNumber = 2, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Discrete Power On", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("POWER_OFF")] + public JoinDataComplete PowerOff = new JoinDataComplete( + new JoinData + { + JoinNumber = 3, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Discrete Power Off", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("PLAY")] + public JoinDataComplete Play = new JoinDataComplete( + new JoinData + { + JoinNumber = 4, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Transport Play", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("PLAY_PAUSE")] + public JoinDataComplete PlayPause = new JoinDataComplete( + new JoinData + { + JoinNumber = 5, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Transport Play/Pause", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("STOP")] + public JoinDataComplete Stop = new JoinDataComplete( + new JoinData + { + JoinNumber = 6, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Transport Stop", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("PAUSE")] + public JoinDataComplete Pause = new JoinDataComplete( + new JoinData + { + JoinNumber = 7, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Transport Pause", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("FSCAN")] + public JoinDataComplete ForwardScan = new JoinDataComplete( + new JoinData + { + JoinNumber = 9, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Transport Forward Scan", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("F_SRCH")] + public JoinDataComplete ForwardSearch = new JoinDataComplete( + new JoinData + { + JoinNumber = 10, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Transport Forward Search", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("F_SKIP")] + public JoinDataComplete ForwardSkip = new JoinDataComplete( + new JoinData + { + JoinNumber = 11, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Transport Forward Skip/Next", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("RSCAN")] + public JoinDataComplete ReverseScan = new JoinDataComplete( + new JoinData + { + JoinNumber = 12, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Transport Reverse Scan", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("R_SRCH")] + public JoinDataComplete ReverseSearch = new JoinDataComplete( + new JoinData + { + JoinNumber = 13, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Transport Reverse Search", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("R_SKIP")] + public JoinDataComplete ReverseSkip = new JoinDataComplete( + new JoinData + { + JoinNumber = 14, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Transport Reverse Skip/Previous", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("TRACK+")] + public JoinDataComplete TrackPlus = new JoinDataComplete( + new JoinData + { + JoinNumber = 15, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Transport Track +", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("TRACK-")] + public JoinDataComplete TrackMinus = new JoinDataComplete( + new JoinData + { + JoinNumber = 16, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Transport Track -", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + + [JoinName("0")] + public JoinDataComplete Kp0 = new JoinDataComplete( + new JoinData + { + JoinNumber = 20, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Keypad 0", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("1")] + public JoinDataComplete Kp1 = new JoinDataComplete( + new JoinData + { + JoinNumber = 21, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Keypad 1", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("2")] + public JoinDataComplete Kp2 = new JoinDataComplete( + new JoinData + { + JoinNumber = 22, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Keypad 2", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("3")] + public JoinDataComplete Kp3 = new JoinDataComplete( + new JoinData + { + JoinNumber = 23, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Keypad 3", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("4")] + public JoinDataComplete Kp4 = new JoinDataComplete( + new JoinData + { + JoinNumber = 24, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Keypad 4", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("5")] + public JoinDataComplete Kp5 = new JoinDataComplete( + new JoinData + { + JoinNumber = 25, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Keypad 5", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("6")] + public JoinDataComplete Kp6 = new JoinDataComplete( + new JoinData + { + JoinNumber = 26, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Keypad 6", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("7")] + public JoinDataComplete Kp7 = new JoinDataComplete( + new JoinData + { + JoinNumber = 27, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Keypad 7", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("8")] + public JoinDataComplete Kp8 = new JoinDataComplete( + new JoinData + { + JoinNumber = 28, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Keypad 8", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("9")] + public JoinDataComplete Kp9 = new JoinDataComplete( + new JoinData + { + JoinNumber = 29, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Keypad 9", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("#")] + public JoinDataComplete KpPound = new JoinDataComplete( + new JoinData + { + JoinNumber = 30, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Keypad #", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("*")] + public JoinDataComplete KpStar = new JoinDataComplete( + new JoinData + { + JoinNumber = 31, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Keypad Star", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("A")] + public JoinDataComplete KpA = new JoinDataComplete( + new JoinData + { + JoinNumber = 32, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Keypad A", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("B")] + public JoinDataComplete KpB = new JoinDataComplete( + new JoinData + { + JoinNumber = 33, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Keypad B", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("C")] + public JoinDataComplete KpC = new JoinDataComplete( + new JoinData + { + JoinNumber = 34, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Keypad C", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("D")] + public JoinDataComplete KpD = new JoinDataComplete( + new JoinData + { + JoinNumber = 35, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Keypad D", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("RED")] + public JoinDataComplete KpRed = new JoinDataComplete( + new JoinData + { + JoinNumber = 36, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Keypad Red", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("GREEN")] + public JoinDataComplete KpGreen = new JoinDataComplete( + new JoinData + { + JoinNumber = 37, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Keypad Green", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("YELLOW")] + public JoinDataComplete KpYellow = new JoinDataComplete( + new JoinData + { + JoinNumber = 38, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Keypad Yellow", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("BLUE")] + public JoinDataComplete KpBlue = new JoinDataComplete( + new JoinData + { + JoinNumber = 39, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Keypad Blue", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + + [JoinName("MENU")] + public JoinDataComplete Menu = new JoinDataComplete( + new JoinData + { + JoinNumber = 41, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Menu", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("GUIDE")] + public JoinDataComplete Guide = new JoinDataComplete( + new JoinData + { + JoinNumber = 42, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Guide", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("DVR")] + public JoinDataComplete Dvr = new JoinDataComplete( + new JoinData + { + JoinNumber = 43, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Dvr", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("OPTIONS")] + public JoinDataComplete Options = new JoinDataComplete( + new JoinData + { + JoinNumber = 44, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Options", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("ON_DEMAND")] + public JoinDataComplete OnDemand = new JoinDataComplete( + new JoinData + { + JoinNumber = 45, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "On Demand", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + + [JoinName("UP_ARROW")] + public JoinDataComplete DpadUp = new JoinDataComplete( + new JoinData + { + JoinNumber = 46, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Dpad Up", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("DN_ARROW")] + public JoinDataComplete DpadDown = new JoinDataComplete( + new JoinData + { + JoinNumber = 47, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Dpad Down", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("LEFT_ARROW")] + public JoinDataComplete DpadLeft = new JoinDataComplete( + new JoinData + { + JoinNumber = 48, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Dpad Left", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("RIGHT_ARROW")] + public JoinDataComplete DpadRight = new JoinDataComplete( + new JoinData + { + JoinNumber = 49, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Dpad Right", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("SELECT")] + public JoinDataComplete DpadSelect = new JoinDataComplete( + new JoinData + { + JoinNumber = 50, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Dpad Select", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("RETURN")] + public JoinDataComplete Return = new JoinDataComplete( + new JoinData + { + JoinNumber = 51, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Return", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("BACK")] + public JoinDataComplete Back = new JoinDataComplete( + new JoinData + { + JoinNumber = 52, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Back", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("HOME")] + public JoinDataComplete Home = new JoinDataComplete( + new JoinData + { + JoinNumber = 53, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Home", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("CH+")] + public JoinDataComplete ChannelUp = new JoinDataComplete( + new JoinData + { + JoinNumber = 54, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Channel Up", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("CH-")] + public JoinDataComplete ChannelDown = new JoinDataComplete( + new JoinData + { + JoinNumber = 55, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Channel Down", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("LAST")] + public JoinDataComplete Last = new JoinDataComplete( + new JoinData + { + JoinNumber = 56, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Last", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("PAGE_UP")] + public JoinDataComplete PageUp = new JoinDataComplete( + new JoinData + { + JoinNumber = 57, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Page Up", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("PAGE_DOWN")] + public JoinDataComplete PageDown = new JoinDataComplete( + new JoinData + { + JoinNumber = 58, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Page Down", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + public GenericIrControllerJoinMap(uint joinStart) + : base(joinStart, typeof(GenericIrControllerJoinMap)) + { + } + } +} \ No newline at end of file From a3561bc89b3077c6464357acceda21389311e20d Mon Sep 17 00:00:00 2001 From: jdevito Date: Sat, 7 Oct 2023 19:16:03 -0500 Subject: [PATCH 85/96] feat(wip): updates GenericIrController and IrOutputPortController to implement bridge map --- .../Devices/GenericIRController.cs | 76 ++++++++++++++++--- .../Devices/IrOutputPortController.cs | 9 +-- 2 files changed, 69 insertions(+), 16 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/GenericIRController.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/GenericIRController.cs index 959b334b..b7a25d47 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/GenericIRController.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/GenericIRController.cs @@ -19,15 +19,11 @@ namespace PepperDash.Essentials.Core.Devices private readonly IrOutputPortController _port; - public string[] IrCommands {get { return _port.IrFileCommands; }} - - public Dictionary BridgeJoins; + public string[] IrCommands {get { return _port.IrFileCommands; }} public GenericIrController(string key, string name, IrOutputPortController irPort) : base(key, name) { _port = irPort; - if(_port.UseBridgeJoinMap) BridgeJoins = new Dictionary(); - if (_port == null) { Debug.Console(0, this, Debug.ErrorLogLevel.Error, "IR Port is null, device will not function"); @@ -78,17 +74,75 @@ namespace PepperDash.Essentials.Core.Devices { Debug.Console(0, this, "Using new IR bridge join map"); - var joins = BridgeJoins.Where((kv) => _port.IrFileCommands.Any(cmd => cmd == kv.Key)).ToDictionary(kv => kv.Key, kv=> kv.Value); - foreach (var join in joins) - { - Debug.Console(0, this, "_useBridgeJoinMap: {0}: {1}", join.Key, join.Value); - } - //joinMap.Joins = joins.Select(kv => kv.Value.SetJoinOffset(joinStart)).ToString(); + var bridgeJoins = joinMap.Joins.Where((kv) => _port.IrFileCommands.Any(cmd => cmd == kv.Key)).ToDictionary(kv => kv.Key); + if (bridgeJoins == null) + { + Debug.Console(0, this, Debug.ErrorLogLevel.Error, "Failed to link new IR bridge join map"); + return; + } + foreach (var bridgeJoin in bridgeJoins) + { + Debug.Console(0, this, @"bridgeJoin: Key-'{0}' +Value.Key-'{1}' +Value.JoinNumber-'{2}' +Value.Metadata.Description-'{3}'", + bridgeJoin.Key, + bridgeJoin.Value.Key, + bridgeJoin.Value.Value.JoinNumber, + bridgeJoin.Value.Value.Metadata.Description); + + var joinNumber = bridgeJoin.Value.Value.JoinNumber; + var joinCmd = bridgeJoin.Key; + + trilist.SetBoolSigAction(joinNumber, (b) => Press(joinCmd, b)); + } + + //foreach (var irFileCommand in _port.IrFileCommands) + //{ + // var cmd = irFileCommand; + // JoinDataComplete joinDataComplete; + // if (joinMap.Joins.TryGetValue(cmd, out joinDataComplete)) + // { + // Debug.Console(0, this, "joinDataComplete: attributeName-'{0}', joinNumber-'{1}', joinSpan-'{2}', metadata.description-'{3}'", + // joinDataComplete.AttributeName, joinDataComplete.JoinNumber, joinDataComplete.JoinSpan, joinDataComplete.Metadata.Description); + + // trilist.SetBoolSigAction(joinDataComplete.JoinNumber, (b) => Press(cmd, b)); + // } + // else + // { + // Debug.Console(0, this, "GenericIrController join map does not contain support for IR command '{0}', verify IR file.", cmd); + // } + + + + + // //if (joinMap.Joins.ContainsKey(cmd)) + // //{ + // // Debug.Console(0, this, "joinData: key-'{0}', joinNumber-'{1}', joinSpan-'{2}', description-'{3}'", + // // joinData.Key, joinData.Value.JoinNumber, joinData.Value.JoinSpan, joinData.Value.Metadata.Description); + // //} + + // //Debug.Console(0, this, "_port.IrFileCommand: {0}", irFileCommand); + // //var joinData = joinMap.Joins.FirstOrDefault(j => j.Key == cmd); + + // //if (joinData.Value == null) continue; + + // //joinData.Value.SetJoinOffset(joinStart); + + // //Debug.Console(0, this, "joinData: key-'{0}', joinNumber-'{1}', joinSpan-'{2}', description-'{3}'", + // // joinData.Key, joinData.Value.JoinNumber, joinData.Value.JoinSpan, joinData.Value.Metadata.Description); + + // //joinMap.Joins.Add(joinData.Key, joinData.Value); + + // //trilist.SetBoolSigAction(joinData.Value.JoinNumber, (b) => Press(joinData.Key, b)); + //} } else { Debug.Console(0, this, "Using legacy IR join mapping based on available IR commands"); + joinMap.Joins.Clear(); + for (uint i = 0; i < _port.IrFileCommands.Length; i++) { var cmd = _port.IrFileCommands[i]; diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IrOutputPortController.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IrOutputPortController.cs index 5ce7a779..a20f06aa 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IrOutputPortController.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IrOutputPortController.cs @@ -55,24 +55,23 @@ namespace PepperDash.Essentials.Core : base(key) { DriverLoaded = new BoolFeedback(() => DriverIsLoaded); + UseBridgeJoinMap = config.Properties["control"].Value("useBridgeJoinMap"); AddPostActivationAction(() => { - IrPort = postActivationFunc(config); + IrPort = postActivationFunc(config); if (IrPort == null) { Debug.Console(0, this, "WARNING No valid IR Port assigned to controller. IR will not function"); return; } - - UseBridgeJoinMap = config.Properties["control"]["useBridgeJoinMap"].Value(); var filePath = Global.FilePathPrefix + "ir" + Global.DirectorySeparator + config.Properties["control"]["irFile"].Value(); Debug.Console(1, "*************Attempting to load IR file: {0}***************", filePath); LoadDriver(filePath); - - PrintAvailableCommands(); + + if(!UseBridgeJoinMap) PrintAvailableCommands(); }); } From 55af6a96f60e2c00c69e4c2c1f614f3c06cf40c7 Mon Sep 17 00:00:00 2001 From: jdevito Date: Sat, 7 Oct 2023 19:25:04 -0500 Subject: [PATCH 86/96] feat(wip): updates bridge join map descriptions Updated bridge join map descriptions to match the IR standard command name. --- .../JoinMaps/GenericIrControllerJoinMap.cs | 106 +++++++++--------- 1 file changed, 53 insertions(+), 53 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericIrControllerJoinMap.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericIrControllerJoinMap.cs index 00257c9f..661ea460 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericIrControllerJoinMap.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericIrControllerJoinMap.cs @@ -13,7 +13,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Power Toggle", + Description = "POWER", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -27,7 +27,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Discrete Power On", + Description = "POWER_ON", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -41,7 +41,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Discrete Power Off", + Description = "POWER_OFF", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -55,7 +55,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Transport Play", + Description = "PLAY", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -69,7 +69,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Transport Play/Pause", + Description = "PLAY_PAUSE", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -83,7 +83,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Transport Stop", + Description = "STOP", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -97,7 +97,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Transport Pause", + Description = "PAUSE", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -111,7 +111,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Transport Forward Scan", + Description = "FSCAN", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -125,7 +125,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Transport Forward Search", + Description = "F_SRCH", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -139,7 +139,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Transport Forward Skip/Next", + Description = "F_SKIP", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -153,7 +153,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Transport Reverse Scan", + Description = "RSCAN", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -167,7 +167,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Transport Reverse Search", + Description = "R_SRCH", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -181,7 +181,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Transport Reverse Skip/Previous", + Description = "R_SKIP", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -195,7 +195,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Transport Track +", + Description = "TRACK+", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -209,7 +209,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Transport Track -", + Description = "TRACK-", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -224,7 +224,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Keypad 0", + Description = "0", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -238,7 +238,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Keypad 1", + Description = "1", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -252,7 +252,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Keypad 2", + Description = "2", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -266,7 +266,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Keypad 3", + Description = "3", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -280,7 +280,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Keypad 4", + Description = "4", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -294,7 +294,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Keypad 5", + Description = "5", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -308,7 +308,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Keypad 6", + Description = "6", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -322,7 +322,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Keypad 7", + Description = "7", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -336,7 +336,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Keypad 8", + Description = "8", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -350,7 +350,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Keypad 9", + Description = "9", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -364,7 +364,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Keypad #", + Description = "#", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -378,7 +378,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Keypad Star", + Description = "*", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -392,7 +392,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Keypad A", + Description = "A", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -406,7 +406,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Keypad B", + Description = "B", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -420,7 +420,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Keypad C", + Description = "C", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -434,7 +434,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Keypad D", + Description = "D", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -448,7 +448,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Keypad Red", + Description = "RED", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -462,7 +462,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Keypad Green", + Description = "GREEN", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -476,7 +476,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Keypad Yellow", + Description = "YELLOW", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -490,7 +490,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Keypad Blue", + Description = "BLUE", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -505,7 +505,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Menu", + Description = "MENU", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -519,7 +519,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Guide", + Description = "GUIDE", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -533,7 +533,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Dvr", + Description = "DVR", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -547,7 +547,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Options", + Description = "OPTIONS", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -561,7 +561,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "On Demand", + Description = "ON_DEMAND", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -576,7 +576,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Dpad Up", + Description = "UP_ARROW", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -590,7 +590,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Dpad Down", + Description = "DN_ARROW", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -604,7 +604,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Dpad Left", + Description = "LEFT_ARROW", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -618,7 +618,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Dpad Right", + Description = "RIGHT_ARROW", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -632,7 +632,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Dpad Select", + Description = "SELECT", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -646,7 +646,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Return", + Description = "RETURN", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -660,7 +660,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Back", + Description = "BACK", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -674,7 +674,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Home", + Description = "HOME", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -688,7 +688,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Channel Up", + Description = "CH+", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -702,7 +702,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Channel Down", + Description = "CH-", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -716,7 +716,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Last", + Description = "LAST", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -730,7 +730,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Page Up", + Description = "PAGE_UP", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); @@ -744,7 +744,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "Page Down", + Description = "PAGE_DOWN", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); From ff04d49a1b30753c1915ed99242a713bf4c1d909 Mon Sep 17 00:00:00 2001 From: jdevito Date: Sat, 7 Oct 2023 19:26:14 -0500 Subject: [PATCH 87/96] fix: updates debug level and removes unused code --- .../Devices/GenericIRController.cs | 44 +------------------ 1 file changed, 2 insertions(+), 42 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/GenericIRController.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/GenericIRController.cs index b7a25d47..d549948c 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/GenericIRController.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/GenericIRController.cs @@ -82,7 +82,7 @@ namespace PepperDash.Essentials.Core.Devices } foreach (var bridgeJoin in bridgeJoins) { - Debug.Console(0, this, @"bridgeJoin: Key-'{0}' + Debug.Console(2, this, @"bridgeJoin: Key-'{0}' Value.Key-'{1}' Value.JoinNumber-'{2}' Value.Metadata.Description-'{3}'", @@ -95,47 +95,7 @@ Value.Metadata.Description-'{3}'", var joinCmd = bridgeJoin.Key; trilist.SetBoolSigAction(joinNumber, (b) => Press(joinCmd, b)); - } - - //foreach (var irFileCommand in _port.IrFileCommands) - //{ - // var cmd = irFileCommand; - // JoinDataComplete joinDataComplete; - // if (joinMap.Joins.TryGetValue(cmd, out joinDataComplete)) - // { - // Debug.Console(0, this, "joinDataComplete: attributeName-'{0}', joinNumber-'{1}', joinSpan-'{2}', metadata.description-'{3}'", - // joinDataComplete.AttributeName, joinDataComplete.JoinNumber, joinDataComplete.JoinSpan, joinDataComplete.Metadata.Description); - - // trilist.SetBoolSigAction(joinDataComplete.JoinNumber, (b) => Press(cmd, b)); - // } - // else - // { - // Debug.Console(0, this, "GenericIrController join map does not contain support for IR command '{0}', verify IR file.", cmd); - // } - - - - - // //if (joinMap.Joins.ContainsKey(cmd)) - // //{ - // // Debug.Console(0, this, "joinData: key-'{0}', joinNumber-'{1}', joinSpan-'{2}', description-'{3}'", - // // joinData.Key, joinData.Value.JoinNumber, joinData.Value.JoinSpan, joinData.Value.Metadata.Description); - // //} - - // //Debug.Console(0, this, "_port.IrFileCommand: {0}", irFileCommand); - // //var joinData = joinMap.Joins.FirstOrDefault(j => j.Key == cmd); - - // //if (joinData.Value == null) continue; - - // //joinData.Value.SetJoinOffset(joinStart); - - // //Debug.Console(0, this, "joinData: key-'{0}', joinNumber-'{1}', joinSpan-'{2}', description-'{3}'", - // // joinData.Key, joinData.Value.JoinNumber, joinData.Value.JoinSpan, joinData.Value.Metadata.Description); - - // //joinMap.Joins.Add(joinData.Key, joinData.Value); - - // //trilist.SetBoolSigAction(joinData.Value.JoinNumber, (b) => Press(joinData.Key, b)); - //} + } } else { From 8b3bc523d21a66c91364fd539a060d12fc863e91 Mon Sep 17 00:00:00 2001 From: jdevito Date: Sat, 7 Oct 2023 19:39:58 -0500 Subject: [PATCH 88/96] fix: removes `if` blocking PrintAvailableCommands --- .../PepperDashEssentialsBase/Devices/IrOutputPortController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IrOutputPortController.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IrOutputPortController.cs index a20f06aa..d404b3ea 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IrOutputPortController.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IrOutputPortController.cs @@ -71,7 +71,7 @@ namespace PepperDash.Essentials.Core LoadDriver(filePath); - if(!UseBridgeJoinMap) PrintAvailableCommands(); + PrintAvailableCommands(); }); } From 5a5e24a92131a193e3f3741d12d01ad9fc2742d8 Mon Sep 17 00:00:00 2001 From: jdevito Date: Sat, 7 Oct 2023 19:54:56 -0500 Subject: [PATCH 89/96] fix: clears joinMap.Joins and rebuilds with matching IR commands of the file loaded --- .../Devices/GenericIRController.cs | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/GenericIRController.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/GenericIRController.cs index d549948c..df76b726 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/GenericIRController.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/GenericIRController.cs @@ -80,21 +80,29 @@ namespace PepperDash.Essentials.Core.Devices Debug.Console(0, this, Debug.ErrorLogLevel.Error, "Failed to link new IR bridge join map"); return; } + + joinMap.Joins.Clear(); + foreach (var bridgeJoin in bridgeJoins) { + var key = bridgeJoin.Key; + var joinDataKey = bridgeJoin.Value.Key; + var joinDataValue = bridgeJoin.Value.Value; + var joinNumber = bridgeJoin.Value.Value.JoinNumber; + Debug.Console(2, this, @"bridgeJoin: Key-'{0}' Value.Key-'{1}' Value.JoinNumber-'{2}' Value.Metadata.Description-'{3}'", - bridgeJoin.Key, - bridgeJoin.Value.Key, - bridgeJoin.Value.Value.JoinNumber, - bridgeJoin.Value.Value.Metadata.Description); + key, + joinDataKey, + joinNumber, + joinDataValue.Metadata.Description); - var joinNumber = bridgeJoin.Value.Value.JoinNumber; - var joinCmd = bridgeJoin.Key; - trilist.SetBoolSigAction(joinNumber, (b) => Press(joinCmd, b)); + joinMap.Joins.Add(key, joinDataValue); + + trilist.SetBoolSigAction(joinNumber, (b) => Press(key, b)); } } else From de6f8c7896c96a58fbd303553e91ba85880c7781 Mon Sep 17 00:00:00 2001 From: jdevito Date: Tue, 10 Oct 2023 06:07:37 -0500 Subject: [PATCH 90/96] feat: adds secureTcpClient to comm factory --- .../PepperDashEssentialsBase/Comm and IR/CommFactory.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/CommFactory.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/CommFactory.cs index 9667b5b9..1742fac4 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/CommFactory.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/CommFactory.cs @@ -81,6 +81,15 @@ namespace PepperDash.Essentials.Core } case eControlMethod.Telnet: break; + case eControlMethod.SecureTcpIp: + { + var secureTcp = new GenericSecureTcpIpClient(deviceConfig.Key + "-secureTcp", c.Address, c.Port, c.BufferSize); + secureTcp.AutoReconnect = c.AutoReconnect; + if (secureTcp.AutoReconnect) + secureTcp.AutoReconnectIntervalMs = c.AutoReconnectIntervalMs; + comm = secureTcp; + break; + } default: break; } From 922119fdd6101bcebfa893f29fc9ad86282c5e59 Mon Sep 17 00:00:00 2001 From: Jason DeVito Date: Sat, 14 Oct 2023 22:20:11 -0500 Subject: [PATCH 91/96] refactor: updated IR joins. --- .../JoinMaps/GenericIrControllerJoinMap.cs | 608 ++++++++++-------- 1 file changed, 343 insertions(+), 265 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericIrControllerJoinMap.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericIrControllerJoinMap.cs index 661ea460..a4a90a01 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericIrControllerJoinMap.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericIrControllerJoinMap.cs @@ -4,53 +4,11 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps { public sealed class GenericIrControllerJoinMap : JoinMapBaseAdvanced { - [JoinName("POWER")] - public JoinDataComplete Power = new JoinDataComplete( - new JoinData - { - JoinNumber = 1, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "POWER", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("POWER_ON")] - public JoinDataComplete PowerOn = new JoinDataComplete( - new JoinData - { - JoinNumber = 2, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "POWER_ON", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("POWER_OFF")] - public JoinDataComplete PowerOff = new JoinDataComplete( - new JoinData - { - JoinNumber = 3, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "POWER_OFF", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - [JoinName("PLAY")] public JoinDataComplete Play = new JoinDataComplete( new JoinData { - JoinNumber = 4, + JoinNumber = 1, JoinSpan = 1 }, new JoinMetadata @@ -60,25 +18,11 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps JoinType = eJoinType.Digital }); - [JoinName("PLAY_PAUSE")] - public JoinDataComplete PlayPause = new JoinDataComplete( - new JoinData - { - JoinNumber = 5, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "PLAY_PAUSE", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - [JoinName("STOP")] public JoinDataComplete Stop = new JoinDataComplete( new JoinData { - JoinNumber = 6, + JoinNumber = 2, JoinSpan = 1 }, new JoinMetadata @@ -92,7 +36,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps public JoinDataComplete Pause = new JoinDataComplete( new JoinData { - JoinNumber = 7, + JoinNumber = 3, JoinSpan = 1 }, new JoinMetadata @@ -106,7 +50,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps public JoinDataComplete ForwardScan = new JoinDataComplete( new JoinData { - JoinNumber = 9, + JoinNumber = 4, JoinSpan = 1 }, new JoinMetadata @@ -115,40 +59,12 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("F_SRCH")] - public JoinDataComplete ForwardSearch = new JoinDataComplete( - new JoinData - { - JoinNumber = 10, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "F_SRCH", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("F_SKIP")] - public JoinDataComplete ForwardSkip = new JoinDataComplete( - new JoinData - { - JoinNumber = 11, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "F_SKIP", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - + [JoinName("RSCAN")] public JoinDataComplete ReverseScan = new JoinDataComplete( new JoinData { - JoinNumber = 12, + JoinNumber = 5, JoinSpan = 1 }, new JoinMetadata @@ -158,25 +74,25 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps JoinType = eJoinType.Digital }); - [JoinName("R_SRCH")] - public JoinDataComplete ReverseSearch = new JoinDataComplete( + [JoinName("F_SKIP")] + public JoinDataComplete ForwardSkip = new JoinDataComplete( new JoinData { - JoinNumber = 13, + JoinNumber = 6, JoinSpan = 1 }, new JoinMetadata { - Description = "R_SRCH", + Description = "F_SKIP", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - + [JoinName("R_SKIP")] public JoinDataComplete ReverseSkip = new JoinDataComplete( new JoinData { - JoinNumber = 14, + JoinNumber = 7, JoinSpan = 1 }, new JoinMetadata @@ -186,40 +102,39 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps JoinType = eJoinType.Digital }); - [JoinName("TRACK+")] - public JoinDataComplete TrackPlus = new JoinDataComplete( + [JoinName("RECORD")] + public JoinDataComplete ForwardSearch = new JoinDataComplete( new JoinData { - JoinNumber = 15, + JoinNumber = 8, JoinSpan = 1 }, new JoinMetadata { - Description = "TRACK+", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("TRACK-")] - public JoinDataComplete TrackMinus = new JoinDataComplete( - new JoinData - { - JoinNumber = 16, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "TRACK-", + Description = "RECORD", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("POWER")] + public JoinDataComplete Power = new JoinDataComplete( + new JoinData + { + JoinNumber = 9, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "POWER", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - [JoinName("0")] public JoinDataComplete Kp0 = new JoinDataComplete( new JoinData { - JoinNumber = 20, + JoinNumber = 10, JoinSpan = 1 }, new JoinMetadata @@ -233,7 +148,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps public JoinDataComplete Kp1 = new JoinDataComplete( new JoinData { - JoinNumber = 21, + JoinNumber = 11, JoinSpan = 1 }, new JoinMetadata @@ -247,7 +162,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps public JoinDataComplete Kp2 = new JoinDataComplete( new JoinData { - JoinNumber = 22, + JoinNumber = 12, JoinSpan = 1 }, new JoinMetadata @@ -261,7 +176,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps public JoinDataComplete Kp3 = new JoinDataComplete( new JoinData { - JoinNumber = 23, + JoinNumber = 13, JoinSpan = 1 }, new JoinMetadata @@ -275,7 +190,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps public JoinDataComplete Kp4 = new JoinDataComplete( new JoinData { - JoinNumber = 24, + JoinNumber = 14, JoinSpan = 1 }, new JoinMetadata @@ -289,7 +204,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps public JoinDataComplete Kp5 = new JoinDataComplete( new JoinData { - JoinNumber = 25, + JoinNumber = 15, JoinSpan = 1 }, new JoinMetadata @@ -303,7 +218,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps public JoinDataComplete Kp6 = new JoinDataComplete( new JoinData { - JoinNumber = 26, + JoinNumber = 16, JoinSpan = 1 }, new JoinMetadata @@ -317,7 +232,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps public JoinDataComplete Kp7 = new JoinDataComplete( new JoinData { - JoinNumber = 27, + JoinNumber = 17, JoinSpan = 1 }, new JoinMetadata @@ -331,7 +246,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps public JoinDataComplete Kp8 = new JoinDataComplete( new JoinData { - JoinNumber = 28, + JoinNumber = 18, JoinSpan = 1 }, new JoinMetadata @@ -345,7 +260,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps public JoinDataComplete Kp9 = new JoinDataComplete( new JoinData { - JoinNumber = 29, + JoinNumber = 19, JoinSpan = 1 }, new JoinMetadata @@ -355,25 +270,67 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps JoinType = eJoinType.Digital }); - [JoinName("#")] - public JoinDataComplete KpPound = new JoinDataComplete( + // [JoinName("+10")] + // public JoinDataComplete Kp9 = new JoinDataComplete( + // new JoinData + // { + // JoinNumber = 20, + // JoinSpan = 1 + // }, + // new JoinMetadata + // { + // Description = "+10", + // JoinCapabilities = eJoinCapabilities.FromSIMPL, + // JoinType = eJoinType.Digital + // }); + + [JoinName("ENTER")] + public JoinDataComplete ChannelUp = new JoinDataComplete( new JoinData { - JoinNumber = 30, + JoinNumber = 21, JoinSpan = 1 }, new JoinMetadata { - Description = "#", + Description = "ENTER", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("CH+")] + public JoinDataComplete ChannelUp = new JoinDataComplete( + new JoinData + { + JoinNumber = 22, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "CH+", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("CH-")] + public JoinDataComplete ChannelDown = new JoinDataComplete( + new JoinData + { + JoinNumber = 23, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "CH-", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + [JoinName("*")] public JoinDataComplete KpStar = new JoinDataComplete( new JoinData { - JoinNumber = 31, + JoinNumber = 24, JoinSpan = 1 }, new JoinMetadata @@ -383,121 +340,106 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps JoinType = eJoinType.Digital }); - [JoinName("A")] - public JoinDataComplete KpA = new JoinDataComplete( + [JoinName("#")] + public JoinDataComplete KpPound = new JoinDataComplete( new JoinData { - JoinNumber = 32, + JoinNumber = 25, JoinSpan = 1 }, new JoinMetadata { - Description = "A", + Description = "#", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - [JoinName("B")] - public JoinDataComplete KpB = new JoinDataComplete( + // [JoinName(".")] + // public JoinDataComplete KpPound = new JoinDataComplete( + // new JoinData + // { + // JoinNumber = 26, + // JoinSpan = 1 + // }, + // new JoinMetadata + // { + // Description = ".", + // JoinCapabilities = eJoinCapabilities.FromSIMPL, + // JoinType = eJoinType.Digital + // }); + + [JoinName("POWER_ON")] + public JoinDataComplete PowerOn = new JoinDataComplete( new JoinData { - JoinNumber = 33, + JoinNumber = 27, JoinSpan = 1 }, new JoinMetadata { - Description = "B", + Description = "POWER_ON", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - [JoinName("C")] - public JoinDataComplete KpC = new JoinDataComplete( + [JoinName("POWER_OFF")] + public JoinDataComplete PowerOff = new JoinDataComplete( new JoinData { - JoinNumber = 34, + JoinNumber = 28, JoinSpan = 1 }, new JoinMetadata { - Description = "C", + Description = "POWER_OFF", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - [JoinName("D")] - public JoinDataComplete KpD = new JoinDataComplete( + [JoinName("PLAY_PAUSE")] + public JoinDataComplete PlayPause = new JoinDataComplete( new JoinData { - JoinNumber = 35, + JoinNumber = 29, JoinSpan = 1 }, new JoinMetadata { - Description = "D", + Description = "PLAY_PAUSE", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - [JoinName("RED")] - public JoinDataComplete KpRed = new JoinDataComplete( + [JoinName("LAST")] + public JoinDataComplete Last = new JoinDataComplete( new JoinData { - JoinNumber = 36, + JoinNumber = 30, JoinSpan = 1 }, new JoinMetadata { - Description = "RED", + Description = "LAST", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("GREEN")] - public JoinDataComplete KpGreen = new JoinDataComplete( + + [JoinName("HOME")] + public JoinDataComplete Home = new JoinDataComplete( new JoinData { - JoinNumber = 37, + JoinNumber = 40, JoinSpan = 1 }, new JoinMetadata { - Description = "GREEN", + Description = "HOME", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("YELLOW")] - public JoinDataComplete KpYellow = new JoinDataComplete( - new JoinData - { - JoinNumber = 38, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "YELLOW", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("BLUE")] - public JoinDataComplete KpBlue = new JoinDataComplete( - new JoinData - { - JoinNumber = 39, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "BLUE", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - - [JoinName("MENU")] - public JoinDataComplete Menu = new JoinDataComplete( + + [JoinName("BACK")] + public JoinDataComplete Back = new JoinDataComplete( new JoinData { JoinNumber = 41, @@ -505,11 +447,12 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "MENU", + Description = "BACK", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("GUIDE")] public JoinDataComplete Guide = new JoinDataComplete( new JoinData @@ -524,8 +467,8 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps JoinType = eJoinType.Digital }); - [JoinName("DVR")] - public JoinDataComplete Dvr = new JoinDataComplete( + [JoinName("INFO")] + public JoinDataComplete Guide = new JoinDataComplete( new JoinData { JoinNumber = 43, @@ -533,13 +476,13 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "DVR", + Description = "INFO", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - [JoinName("OPTIONS")] - public JoinDataComplete Options = new JoinDataComplete( + [JoinName("MENU")] + public JoinDataComplete Menu = new JoinDataComplete( new JoinData { JoinNumber = 44, @@ -547,31 +490,16 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "OPTIONS", + Description = "MENU", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - [JoinName("ON_DEMAND")] - public JoinDataComplete OnDemand = new JoinDataComplete( - new JoinData - { - JoinNumber = 45, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "ON_DEMAND", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("UP_ARROW")] public JoinDataComplete DpadUp = new JoinDataComplete( new JoinData { - JoinNumber = 46, + JoinNumber = 45, JoinSpan = 1 }, new JoinMetadata @@ -585,7 +513,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps public JoinDataComplete DpadDown = new JoinDataComplete( new JoinData { - JoinNumber = 47, + JoinNumber = 46, JoinSpan = 1 }, new JoinMetadata @@ -599,7 +527,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps public JoinDataComplete DpadLeft = new JoinDataComplete( new JoinData { - JoinNumber = 48, + JoinNumber = 47, JoinSpan = 1 }, new JoinMetadata @@ -613,7 +541,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps public JoinDataComplete DpadRight = new JoinDataComplete( new JoinData { - JoinNumber = 49, + JoinNumber = 48, JoinSpan = 1 }, new JoinMetadata @@ -627,7 +555,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps public JoinDataComplete DpadSelect = new JoinDataComplete( new JoinData { - JoinNumber = 50, + JoinNumber = 49, JoinSpan = 1 }, new JoinMetadata @@ -637,6 +565,20 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps JoinType = eJoinType.Digital }); + [JoinName("OPTIONS")] + public JoinDataComplete Options = new JoinDataComplete( + new JoinData + { + JoinNumber = 50, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "OPTIONS", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + [JoinName("RETURN")] public JoinDataComplete Return = new JoinDataComplete( new JoinData @@ -650,9 +592,9 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - [JoinName("BACK")] - public JoinDataComplete Back = new JoinDataComplete( + + [JoinName("DVR")] + public JoinDataComplete Dvr = new JoinDataComplete( new JoinData { JoinNumber = 52, @@ -660,13 +602,14 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "BACK", + Description = "DVR", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + - [JoinName("HOME")] - public JoinDataComplete Home = new JoinDataComplete( + [JoinName("ON_DEMAND")] + public JoinDataComplete OnDemand = new JoinDataComplete( new JoinData { JoinNumber = 53, @@ -674,58 +617,17 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }, new JoinMetadata { - Description = "HOME", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("CH+")] - public JoinDataComplete ChannelUp = new JoinDataComplete( - new JoinData - { - JoinNumber = 54, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "CH+", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("CH-")] - public JoinDataComplete ChannelDown = new JoinDataComplete( - new JoinData - { - JoinNumber = 55, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "CH-", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("LAST")] - public JoinDataComplete Last = new JoinDataComplete( - new JoinData - { - JoinNumber = 56, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "LAST", + Description = "ON_DEMAND", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); + [JoinName("PAGE_UP")] public JoinDataComplete PageUp = new JoinDataComplete( new JoinData { - JoinNumber = 57, + JoinNumber = 54, JoinSpan = 1 }, new JoinMetadata @@ -739,7 +641,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps public JoinDataComplete PageDown = new JoinDataComplete( new JoinData { - JoinNumber = 58, + JoinNumber = 55, JoinSpan = 1 }, new JoinMetadata @@ -749,6 +651,182 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps JoinType = eJoinType.Digital }); + [JoinName("F_SRCH")] + public JoinDataComplete ForwardSearch = new JoinDataComplete( + new JoinData + { + JoinNumber = 56, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "F_SRCH", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("R_SRCH")] + public JoinDataComplete ReverseSearch = new JoinDataComplete( + new JoinData + { + JoinNumber = 57, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "R_SRCH", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("TRACK+")] + public JoinDataComplete TrackPlus = new JoinDataComplete( + new JoinData + { + JoinNumber = 58, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "TRACK+", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("TRACK-")] + public JoinDataComplete TrackMinus = new JoinDataComplete( + new JoinData + { + JoinNumber = 59, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "TRACK-", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + + + + + + + + + [JoinName("A")] + public JoinDataComplete KpA = new JoinDataComplete( + new JoinData + { + JoinNumber = 61, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "A", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("B")] + public JoinDataComplete KpB = new JoinDataComplete( + new JoinData + { + JoinNumber = 62, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "B", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("C")] + public JoinDataComplete KpC = new JoinDataComplete( + new JoinData + { + JoinNumber = 63, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "C", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("D")] + public JoinDataComplete KpD = new JoinDataComplete( + new JoinData + { + JoinNumber = 64, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "D", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("RED")] + public JoinDataComplete KpRed = new JoinDataComplete( + new JoinData + { + JoinNumber = 65, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "RED", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("GREEN")] + public JoinDataComplete KpGreen = new JoinDataComplete( + new JoinData + { + JoinNumber = 66, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "GREEN", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("YELLOW")] + public JoinDataComplete KpYellow = new JoinDataComplete( + new JoinData + { + JoinNumber = 67, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "YELLOW", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("BLUE")] + public JoinDataComplete KpBlue = new JoinDataComplete( + new JoinData + { + JoinNumber = 68, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "BLUE", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + public GenericIrControllerJoinMap(uint joinStart) : base(joinStart, typeof(GenericIrControllerJoinMap)) { From 6c41b8e19de5a4b0a6af374afa6c83598d1dff1e Mon Sep 17 00:00:00 2001 From: Jason DeVito Date: Tue, 24 Oct 2023 15:24:44 -0500 Subject: [PATCH 92/96] fix: updates executeSwitch, add helper method 1. Updated executeSwitch object casting to resolve routing issues. 2. Added ListRoutingPorts method. --- .../Chassis/HdPsXxxController.cs | 39 ++++++++++++++++++- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs index bf9f72cc..216f3d19 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs @@ -208,6 +208,38 @@ namespace PepperDash_Essentials_DM.Chassis } + public void ListRoutingPorts() + { + try + { + foreach (var port in InputPorts) + { + Debug.Console(0, this, @"Input Port Key: {0} +Port: {1} +Type: {2} +ConnectionType: {3} +Selector: {4} +", port.Key, port.Port, port.Type, port.ConnectionType, port.Selector); + } + + foreach (var port in OutputPorts) + { + Debug.Console(0, this, @"Output Port Key: {0} +Port: {1} +Type: {2} +ConnectionType: {3} +Selector: {4} +", port.Key, port.Port, port.Type, port.ConnectionType, port.Selector); + } + } + catch (Exception ex) + { + Debug.Console(0, this, "ListRoutingPorts Exception Message: {0}", ex.Message); + Debug.Console(0, this, "ListRoutingPorts Exception StackTrace: {0}", ex.StackTrace); + if (ex.InnerException != null) Debug.Console(0, this, "ListRoutingPorts InnerException: {0}", ex.InnerException); + } + } + #region BridgeLinking /// @@ -299,9 +331,12 @@ namespace PepperDash_Essentials_DM.Chassis /// public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) { - var input = inputSelector as HdPsXxxHdmiInput; - var output = outputSelector as HdPsXxxHdmiOutput; + //var input = inputSelector as HdPsXxxHdmiInput; + //var output = outputSelector as HdPsXxxHdmiOutput; + var input = inputSelector as HdPsXxxInput; + var output = outputSelector as HdPsXxxOutput; + Debug.Console(2, this, "ExecuteSwitch: input={0}, output={1}", input, output); if (output == null) From 53b96d54e69e2108ac9c8aa67c6f35437a3b514c Mon Sep 17 00:00:00 2001 From: Jason DeVito Date: Tue, 24 Oct 2023 15:36:04 -0500 Subject: [PATCH 93/96] fix: removes old selector casting statements --- .../Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs index 216f3d19..36e99bc6 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Chassis/HdPsXxxController.cs @@ -331,9 +331,6 @@ Selector: {4} /// public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType) { - //var input = inputSelector as HdPsXxxHdmiInput; - //var output = outputSelector as HdPsXxxHdmiOutput; - var input = inputSelector as HdPsXxxInput; var output = outputSelector as HdPsXxxOutput; From 6698dcb46e7cdc6824d5725ecf9528385e5fe03a Mon Sep 17 00:00:00 2001 From: Jason DeVito Date: Wed, 25 Oct 2023 15:26:42 -0500 Subject: [PATCH 94/96] refactor: update init methods and add events - Updated InitializeButton method to enable/disable buttons based on config. - Updated InitializeButtonFeedback method debug statements. - Added BaseEvent event subscription. - Added PanelStateChnage event subscription. --- .../Touchpanels/Mpc3Touchpanel.cs | 109 +++++++++++------- 1 file changed, 68 insertions(+), 41 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Mpc3Touchpanel.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Mpc3Touchpanel.cs index 296965f9..2d36fe49 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Mpc3Touchpanel.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Mpc3Touchpanel.cs @@ -27,7 +27,15 @@ namespace PepperDash.Essentials.Core.Touchpanels return; } + if (_touchpanel.Registerable) + { + _touchpanel.Register(); + Debug.Console(0, this, ""); + } + + _touchpanel.BaseEvent += _touchpanel_BaseEvent; _touchpanel.ButtonStateChange += _touchpanel_ButtonStateChange; + _touchpanel.PanelStateChange += _touchpanel_PanelStateChange; _buttons = buttons; if (_buttons == null) @@ -57,8 +65,6 @@ namespace PepperDash.Essentials.Core.Touchpanels /// public void InitializeButton(string key, KeypadButton config) { - Debug.Console(1, this, "Initializing button '{0}'...", key); - if (config == null) { Debug.Console(1, this, "Button '{0}' config is null, unable to initialize", key); @@ -69,63 +75,72 @@ namespace PepperDash.Essentials.Core.Touchpanels TryParseInt(key, out buttonNumber); var buttonEventTypes = config.EventTypes; + BoolOutputSig enabledFb = null; + BoolOutputSig disabledFb = null; switch (key) { case ("power"): { - if (buttonEventTypes == null) + if (buttonEventTypes == null || buttonEventTypes.Keys == null) _touchpanel.DisablePowerButton(); else _touchpanel.EnablePowerButton(); - break; - } - case ("volumeup"): - { - if (buttonEventTypes == null) - _touchpanel.DisableVolumeUpButton(); - - break; - } - case ("volumedown"): - { - if (buttonEventTypes == null) - _touchpanel.DisableVolumeDownButton(); - - break; - } - case ("volumefeedback"): - { + + enabledFb = _touchpanel.PowerButtonEnabledFeedBack; + disabledFb = _touchpanel.PowerButtonDisabledFeedBack; break; } + //case ("volumeup"): + // { + // break; + // } + //case ("volumedown"): + // { + // break; + // } + //case ("volumefeedback"): + // { + // break; + // } case ("mute"): { - if (buttonEventTypes == null) + if (buttonEventTypes == null || buttonEventTypes.Keys == null) _touchpanel.DisableMuteButton(); else _touchpanel.EnableMuteButton(); + + enabledFb = _touchpanel.MuteButtonEnabledFeedBack; + disabledFb = _touchpanel.MuteButtonDisabledFeedBack; + break; } default: { - if (buttonNumber == 0) + if (buttonNumber == 0 || buttonNumber > 9) break; - if (buttonEventTypes == null) + if (buttonEventTypes == null || buttonEventTypes.Keys == null) _touchpanel.DisableNumericalButton((uint)buttonNumber); else _touchpanel.EnableNumericalButton((uint)buttonNumber); + + if (_touchpanel.NumericalButtonEnabledFeedBack != null) + enabledFb = _touchpanel.NumericalButtonEnabledFeedBack[(uint)buttonNumber]; + + if (_touchpanel.NumericalButtonDisabledFeedBack != null) + disabledFb = _touchpanel.NumericalButtonDisabledFeedBack[(uint)buttonNumber]; + break; } } - Debug.Console(1, this, "Button '{0}' {1}", key, buttonEventTypes == null - ? "is disabled, verify eventTypes are configured." - : "is enabled"); + Debug.Console(0, this, "InitializeButton: key-'{0}' enabledFb-'{1}', disabledFb-'{2}'", + key, enabledFb ?? (object)"null", disabledFb ?? (object)"null"); } /// @@ -135,11 +150,11 @@ namespace PepperDash.Essentials.Core.Touchpanels /// public void InitializeButtonFeedback(string key, KeypadButton config) { - Debug.Console(1, this, "Initializing button '{0}' feedback...", key); + //Debug.Console(1, this, "Initializing button '{0}' feedback...", key); if (config == null) { - Debug.Console(1, this, "Button '{0}' config is null, unable to initialize feedback", key); + Debug.Console(1, this, "Button '{0}' config is null, skipping.", key); return; } @@ -148,9 +163,9 @@ namespace PepperDash.Essentials.Core.Touchpanels // Link up the button feedbacks to the specified device feedback var buttonFeedback = config.Feedback; - if (buttonFeedback == null) + if (buttonFeedback == null || string.IsNullOrEmpty(buttonFeedback.DeviceKey)) { - Debug.Console(1, this, "Button '{0}' feedback not configured and will not be implemented. If feedback is required, verify configuration.", + Debug.Console(1, this, "Button '{0}' feedback not configured, skipping.", key); return; } @@ -162,15 +177,15 @@ namespace PepperDash.Essentials.Core.Touchpanels var device = DeviceManager.GetDeviceForKey(buttonFeedback.DeviceKey) as Device; if (device == null) { - Debug.Console(1, this, "Button '{0}' feedback with deviceKey '{1}' not found, feedback will not be implemented. Verify feedback deviceKey is properly configured.", + Debug.Console(1, this, "Button '{0}' feedback deviceKey '{1}' not found.", key, buttonFeedback.DeviceKey); return; } - + deviceFeedback = device.GetFeedbackProperty(buttonFeedback.FeedbackName); if (deviceFeedback == null) { - Debug.Console(1, this, "Button '{0}' feedback failed to get feedback property for '{1}', feedback will not be implemented. Verify feedback deviceKey is properly configured.", + Debug.Console(1, this, "Button '{0}' feedbackName property '{1}' not found.", key, buttonFeedback.FeedbackName); return; } @@ -195,12 +210,12 @@ namespace PepperDash.Essentials.Core.Touchpanels } catch (Exception ex) { - Debug.Console(0, this, "Failed to initialize button '{0}' feedback with deviceKey '{1}'. If feedback is required, verify configuration.", - key, buttonFeedback.DeviceKey); - - Debug.Console(1, this, "InitializeButtonFeedback Exception Message: {0}", ex.Message); - Debug.Console(2, this, "InitializeButtonFeedback Exception StackTrace: {0}", ex.StackTrace); - if (ex.InnerException != null) Debug.Console(2, this, "InitializeButtonFeedback Exception InnerExceptioni: {0}", ex.InnerException); + Debug.Console(1, this, "InitializeButtonFeedback (button '{1}', deviceKey '{2}') Exception Message: {0}", + ex.Message, key, buttonFeedback.DeviceKey); + Debug.Console(2, this, "InitializeButtonFeedback (button '{1}', deviceKey '{2}') Exception StackTrace: {0}", + ex.StackTrace, key, buttonFeedback.DeviceKey); + if (ex.InnerException != null) Debug.Console(2, this, "InitializeButtonFeedback (button '{1}', deviceKey '{2}') InnerException: {0}", + ex.InnerException, key, buttonFeedback.DeviceKey); return; } @@ -259,9 +274,14 @@ namespace PepperDash.Essentials.Core.Touchpanels } } + private void _touchpanel_BaseEvent(GenericBase device, BaseEventArgs args) + { + Debug.Console(1, this, "BaseEvent: eventId-'{0}', index-'{1}'", args.EventId, args.Index); + } + private void _touchpanel_ButtonStateChange(GenericBase device, Crestron.SimplSharpPro.DeviceSupport.ButtonEventArgs args) { - Debug.Console(1, this, "Button {0} ({1}), {2}", args.Button.Number, args.Button.Name, args.NewButtonState); + Debug.Console(1, this, "ButtonStateChange: buttonNumber-'{0}' buttonName-'{1}', buttonState-'{2}'", args.Button.Number, args.Button.Name, args.NewButtonState); var type = args.NewButtonState.ToString(); if (_buttons.ContainsKey(args.Button.Number.ToString(CultureInfo.InvariantCulture))) @@ -274,6 +294,11 @@ namespace PepperDash.Essentials.Core.Touchpanels } } + private void _touchpanel_PanelStateChange(GenericBase device, BaseEventArgs args) + { + Debug.Console(1, this, "PanelStateChange: eventId-'{0}', index-'{1}'", args.EventId, args.Index); + } + /// /// Runs the function associated with this button/type. One of the following strings: /// Pressed, Released, Tapped, DoubleTapped, Held, HeldReleased @@ -282,6 +307,8 @@ namespace PepperDash.Essentials.Core.Touchpanels /// public void Press(string buttonKey, string type) { + Debug.Console(2, this, "Press: buttonKey-'{0}', type-'{1}'", buttonKey, type); + // TODO: In future, consider modifying this to generate actions at device activation time // to prevent the need to dynamically call the method via reflection on each button press if (!_buttons.ContainsKey(buttonKey)) return; From d1d1d81165ce61ad21c7c4563ceff801c2184c30 Mon Sep 17 00:00:00 2001 From: Jason DeVito Date: Wed, 25 Oct 2023 15:44:39 -0500 Subject: [PATCH 95/96] fix: update registration debug statement to include response --- .../PepperDashEssentialsBase/Touchpanels/Mpc3Touchpanel.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Mpc3Touchpanel.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Mpc3Touchpanel.cs index 2d36fe49..2f6074dd 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Mpc3Touchpanel.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Touchpanels/Mpc3Touchpanel.cs @@ -29,8 +29,8 @@ namespace PepperDash.Essentials.Core.Touchpanels if (_touchpanel.Registerable) { - _touchpanel.Register(); - Debug.Console(0, this, ""); + var registrationResponse = _touchpanel.Register(); + Debug.Console(0, this, "touchpanel registration response: {0}", registrationResponse); } _touchpanel.BaseEvent += _touchpanel_BaseEvent; From 4f64022623adc409184fc6cfbf57cfddfa59b374 Mon Sep 17 00:00:00 2001 From: jkdevito Date: Wed, 25 Oct 2023 17:25:14 -0500 Subject: [PATCH 96/96] fix: update duplicate joinMap prooperties causing build errors --- .../Bridges/JoinMaps/GenericIrControllerJoinMap.cs | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericIrControllerJoinMap.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericIrControllerJoinMap.cs index a4a90a01..288141bb 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericIrControllerJoinMap.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Bridges/JoinMaps/GenericIrControllerJoinMap.cs @@ -103,7 +103,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }); [JoinName("RECORD")] - public JoinDataComplete ForwardSearch = new JoinDataComplete( + public JoinDataComplete Record = new JoinDataComplete( new JoinData { JoinNumber = 8, @@ -285,7 +285,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps // }); [JoinName("ENTER")] - public JoinDataComplete ChannelUp = new JoinDataComplete( + public JoinDataComplete Enter = new JoinDataComplete( new JoinData { JoinNumber = 21, @@ -468,7 +468,7 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps }); [JoinName("INFO")] - public JoinDataComplete Guide = new JoinDataComplete( + public JoinDataComplete Info = new JoinDataComplete( new JoinData { JoinNumber = 43, @@ -706,14 +706,6 @@ namespace PepperDash_Essentials_Core.Bridges.JoinMaps JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital }); - - - - - - - - [JoinName("A")] public JoinDataComplete KpA = new JoinDataComplete(