From e5d4ba48fb7b32fdd8638a82400276c10bcc2e5d Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Mon, 10 Aug 2020 10:11:54 -0600 Subject: [PATCH 01/10] Updates conditional check to allow for the highes numbered IR port to be used. --- .../Comm and IR/IRPortHelper.cs | 316 +++++++++--------- 1 file changed, 158 insertions(+), 158 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 28a7eb9f..64a1577f 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/IRPortHelper.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/IRPortHelper.cs @@ -1,83 +1,83 @@ -using System; -using System.Collections.Generic; -using Crestron.SimplSharp; -using Crestron.SimplSharp.CrestronIO; -using Crestron.SimplSharpPro; - -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using PepperDash.Core; -using PepperDash.Essentials.Core.Config; - -namespace PepperDash.Essentials.Core -{ - /// - /// - /// - public static class IRPortHelper - { - public static string IrDriverPathPrefix - { - get - { - return Global.FilePathPrefix + "IR" + Global.DirectorySeparator; - } - } - - /// - /// Finds either the ControlSystem or a device controller that contains IR ports and - /// returns a port from the hardware device - /// - /// - /// IrPortConfig object. The port and or filename will be empty/null - /// if valid values don't exist on config - public static IrOutPortConfig GetIrPort(JToken propsToken) - { - var control = propsToken["control"]; - if (control == null) - return null; - if (control["method"].Value() != "ir") - { - Debug.Console(0, "IRPortHelper called with non-IR properties"); - return null; - } - - var port = new IrOutPortConfig(); - - var portDevKey = control.Value("controlPortDevKey"); - var portNum = control.Value("controlPortNumber"); - if (portDevKey == null || portNum == 0) - { - Debug.Console(1, "WARNING: Properties is missing port device or port number"); - return port; - } - - IIROutputPorts irDev = null; - if (portDevKey.Equals("controlSystem", StringComparison.OrdinalIgnoreCase) - || portDevKey.Equals("processor", StringComparison.OrdinalIgnoreCase)) - irDev = Global.ControlSystem; - else - irDev = DeviceManager.GetDeviceForKey(portDevKey) as IIROutputPorts; - - if (irDev == null) - { - Debug.Console(1, "[Config] Error, device with IR ports '{0}' not found", portDevKey); - return port; - } - - if (portNum <= irDev.NumberOfIROutputPorts) // success! - { - var file = IrDriverPathPrefix + control["irFile"].Value(); - port.Port = irDev.IROutputPorts[portNum]; - port.FileName = file; - return port; // new IrOutPortConfig { Port = irDev.IROutputPorts[portNum], FileName = file }; - } - else - { - Debug.Console(1, "[Config] Error, device '{0}' IR port {1} out of range", - portDevKey, portNum); - return port; - } +using System; +using System.Collections.Generic; +using Crestron.SimplSharp; +using Crestron.SimplSharp.CrestronIO; +using Crestron.SimplSharpPro; + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using PepperDash.Core; +using PepperDash.Essentials.Core.Config; + +namespace PepperDash.Essentials.Core +{ + /// + /// + /// + public static class IRPortHelper + { + public static string IrDriverPathPrefix + { + get + { + return Global.FilePathPrefix + "IR" + Global.DirectorySeparator; + } + } + + /// + /// Finds either the ControlSystem or a device controller that contains IR ports and + /// returns a port from the hardware device + /// + /// + /// IrPortConfig object. The port and or filename will be empty/null + /// if valid values don't exist on config + public static IrOutPortConfig GetIrPort(JToken propsToken) + { + var control = propsToken["control"]; + if (control == null) + return null; + if (control["method"].Value() != "ir") + { + Debug.Console(0, "IRPortHelper called with non-IR properties"); + return null; + } + + var port = new IrOutPortConfig(); + + var portDevKey = control.Value("controlPortDevKey"); + var portNum = control.Value("controlPortNumber"); + if (portDevKey == null || portNum == 0) + { + Debug.Console(1, "WARNING: Properties is missing port device or port number"); + return port; + } + + IIROutputPorts irDev = null; + if (portDevKey.Equals("controlSystem", StringComparison.OrdinalIgnoreCase) + || portDevKey.Equals("processor", StringComparison.OrdinalIgnoreCase)) + irDev = Global.ControlSystem; + else + irDev = DeviceManager.GetDeviceForKey(portDevKey) as IIROutputPorts; + + if (irDev == null) + { + Debug.Console(1, "[Config] Error, device with IR ports '{0}' not found", portDevKey); + return port; + } + + if (portNum <= irDev.NumberOfIROutputPorts) // success! + { + var file = IrDriverPathPrefix + control["irFile"].Value(); + port.Port = irDev.IROutputPorts[portNum]; + port.FileName = file; + return port; // new IrOutPortConfig { Port = irDev.IROutputPorts[portNum], FileName = file }; + } + else + { + Debug.Console(1, "[Config] Error, device '{0}' IR port {1} out of range", + portDevKey, portNum); + return port; + } } public static IROutputPort GetIrOutputPort(DeviceConfig dc) @@ -124,7 +124,7 @@ namespace PepperDash.Essentials.Core Debug.Console(0, "WARNING: device with IR ports '{0}' not found", portDevKey); return null; } - if (portNum >= irDev.NumberOfIROutputPorts) + if (portNum > irDev.NumberOfIROutputPorts) { Debug.Console(0, "WARNING: device '{0}' IR port {1} out of range", portDevKey, portNum); @@ -154,82 +154,82 @@ namespace PepperDash.Essentials.Core return irDevice; } - /* - /// - /// Returns a ready-to-go IrOutputPortController from a DeviceConfig object. - /// - public static IrOutputPortController GetIrOutputPortController(DeviceConfig devConf) - { - var irControllerKey = devConf.Key + "-ir"; - if (devConf.Properties == null) - { - Debug.Console(0, "[{0}] WARNING: Device config does not include properties. IR will not function.", devConf.Key); - return new IrOutputPortController(irControllerKey, null, ""); - } - - var control = devConf.Properties["control"]; - if (control == null) - { - var c = new IrOutputPortController(irControllerKey, null, ""); - Debug.Console(0, c, "WARNING: Device config does not include control properties. IR will not function"); - return c; - } - - var portDevKey = control.Value("controlPortDevKey"); - var portNum = control.Value("controlPortNumber"); - IIROutputPorts irDev = null; - - if (portDevKey == null) - { - var c = new IrOutputPortController(irControllerKey, null, ""); - Debug.Console(0, c, "WARNING: control properties is missing ir device"); - return c; - } - - if (portNum == 0) - { - var c = new IrOutputPortController(irControllerKey, null, ""); - Debug.Console(0, c, "WARNING: control properties is missing ir port number"); - return c; - } - - if (portDevKey.Equals("controlSystem", StringComparison.OrdinalIgnoreCase) - || portDevKey.Equals("processor", StringComparison.OrdinalIgnoreCase)) - irDev = Global.ControlSystem; - else - irDev = DeviceManager.GetDeviceForKey(portDevKey) as IIROutputPorts; - - if (irDev == null) - { - var c = new IrOutputPortController(irControllerKey, null, ""); - Debug.Console(0, c, "WARNING: device with IR ports '{0}' not found", portDevKey); - return c; - } - - if (portNum <= irDev.NumberOfIROutputPorts) // success! - return new IrOutputPortController(irControllerKey, irDev.IROutputPorts[portNum], - IrDriverPathPrefix + control["irFile"].Value()); - else - { - var c = new IrOutputPortController(irControllerKey, null, ""); - Debug.Console(0, c, "WARNING: device '{0}' IR port {1} out of range", - portDevKey, portNum); - return c; - } + /* + /// + /// Returns a ready-to-go IrOutputPortController from a DeviceConfig object. + /// + public static IrOutputPortController GetIrOutputPortController(DeviceConfig devConf) + { + var irControllerKey = devConf.Key + "-ir"; + if (devConf.Properties == null) + { + Debug.Console(0, "[{0}] WARNING: Device config does not include properties. IR will not function.", devConf.Key); + return new IrOutputPortController(irControllerKey, null, ""); + } + + var control = devConf.Properties["control"]; + if (control == null) + { + var c = new IrOutputPortController(irControllerKey, null, ""); + Debug.Console(0, c, "WARNING: Device config does not include control properties. IR will not function"); + return c; + } + + var portDevKey = control.Value("controlPortDevKey"); + var portNum = control.Value("controlPortNumber"); + IIROutputPorts irDev = null; + + if (portDevKey == null) + { + var c = new IrOutputPortController(irControllerKey, null, ""); + Debug.Console(0, c, "WARNING: control properties is missing ir device"); + return c; + } + + if (portNum == 0) + { + var c = new IrOutputPortController(irControllerKey, null, ""); + Debug.Console(0, c, "WARNING: control properties is missing ir port number"); + return c; + } + + if (portDevKey.Equals("controlSystem", StringComparison.OrdinalIgnoreCase) + || portDevKey.Equals("processor", StringComparison.OrdinalIgnoreCase)) + irDev = Global.ControlSystem; + else + irDev = DeviceManager.GetDeviceForKey(portDevKey) as IIROutputPorts; + + if (irDev == null) + { + var c = new IrOutputPortController(irControllerKey, null, ""); + Debug.Console(0, c, "WARNING: device with IR ports '{0}' not found", portDevKey); + return c; + } + + if (portNum <= irDev.NumberOfIROutputPorts) // success! + return new IrOutputPortController(irControllerKey, irDev.IROutputPorts[portNum], + IrDriverPathPrefix + control["irFile"].Value()); + else + { + var c = new IrOutputPortController(irControllerKey, null, ""); + Debug.Console(0, c, "WARNING: device '{0}' IR port {1} out of range", + portDevKey, portNum); + return c; + } }*/ - } - - /// - /// Wrapper to help in IR port creation - /// - public class IrOutPortConfig - { - public IROutputPort Port { get; set; } - public string FileName { get; set; } - - public IrOutPortConfig() - { - FileName = ""; - } - } + } + + /// + /// Wrapper to help in IR port creation + /// + public class IrOutPortConfig + { + public IROutputPort Port { get; set; } + public string FileName { get; set; } + + public IrOutPortConfig() + { + FileName = ""; + } + } } \ No newline at end of file From 1b7dd2dd2a2770c3dec2d4d4e02749c77bcc5784 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Mon, 10 Aug 2020 12:01:04 -0600 Subject: [PATCH 02/10] Addse debug statements for RunRouteAction --- PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs b/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs index 1440b82f..c13cdd5b 100644 --- a/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs +++ b/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs @@ -409,10 +409,14 @@ namespace PepperDash.Essentials { if (string.IsNullOrEmpty(sourceListKey)) { + Debug.Console(1, this, "No sourceListKey present. RunRouteAction assumes default source list."); RunRouteAction(routeKey, new Action(() => { })); } else + { + Debug.Console(1, this, "sourceListKey present but not yet implemented"); throw new NotImplementedException(); + } } /// From 84099b1d0bb9140aa3e2381f190238ffafd5428c Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Mon, 10 Aug 2020 12:08:06 -0600 Subject: [PATCH 03/10] Fixes #362 and #363 issue with duplicate device key when adding an IRPortController --- .../PepperDashEssentialsBase/Comm and IR/IRPortHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 64a1577f..2bb53f14 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/IRPortHelper.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/IRPortHelper.cs @@ -149,7 +149,7 @@ namespace PepperDash.Essentials.Core return null; } - var irDevice = new IrOutputPortController(config.Key, GetIrOutputPort, config); + var irDevice = new IrOutputPortController(config.Key + "-irController", GetIrOutputPort, config); return irDevice; } From d0a2ccd7d6e5ebd19eb8bfcc2ecb9b527ff937c2 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Tue, 11 Aug 2020 22:59:26 -0600 Subject: [PATCH 04/10] Fixes #362 by addressing issues with Loading IR driver as post activation action --- .../Comm and IR/IRPortHelper.cs | 7 +- .../Devices/IrOutputPortController.cs | 244 +++++++++--------- 2 files changed, 129 insertions(+), 122 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 2bb53f14..b965a379 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/IRPortHelper.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/IRPortHelper.cs @@ -134,7 +134,9 @@ namespace PepperDash.Essentials.Core var port = irDev.IROutputPorts[portNum]; - port.LoadIRDriver(Global.FilePathPrefix + "IR" + Global.DirectorySeparator + control["irFile"].Value()); + var filePath = Global.FilePathPrefix + "ir" + Global.DirectorySeparator + control["irFile"].Value(); + Debug.Console(1, "*************Attemting to load IR file: {0}***************", filePath); + port.LoadIRDriver(filePath); return port; @@ -149,7 +151,8 @@ namespace PepperDash.Essentials.Core return null; } - var irDevice = new IrOutputPortController(config.Key + "-irController", GetIrOutputPort, config); + var postActivationFunc = new Func (GetIrOutputPort); + var irDevice = new IrOutputPortController(config.Key + "-ir", postActivationFunc, config); return irDevice; } diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IrOutputPortController.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IrOutputPortController.cs index ecfca4f8..7e024f0b 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IrOutputPortController.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IrOutputPortController.cs @@ -1,45 +1,45 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; +using System; +using System.Collections.Generic; +using System.Linq; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro; using Crestron.SimplSharpPro.DeviceSupport; using Newtonsoft.Json.Linq; -using PepperDash.Essentials.Core.Config; - - -using PepperDash.Core; - -namespace PepperDash.Essentials.Core -{ - - /// - /// IR port wrapper. May act standalone - /// - public class IrOutputPortController : Device - { - uint IrPortUid; - IROutputPort IrPort; - - public ushort StandardIrPulseTime { get; set; } - public string DriverFilepath { get; private set; } - public bool DriverIsLoaded { 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. - /// - public IrOutputPortController(string key, IROutputPort port, string irDriverFilepath) - : base(key) - { - //if (port == null) throw new ArgumentNullException("port"); - IrPort = port; - if (port == null) - { - Debug.Console(0, this, "WARNING No valid IR Port assigned to controller. IR will not function"); - return; - } - LoadDriver(irDriverFilepath); +using PepperDash.Essentials.Core.Config; + + +using PepperDash.Core; + +namespace PepperDash.Essentials.Core +{ + + /// + /// IR port wrapper. May act standalone + /// + public class IrOutputPortController : Device + { + uint IrPortUid; + IROutputPort IrPort; + + public ushort StandardIrPulseTime { get; set; } + public string DriverFilepath { get; private set; } + public bool DriverIsLoaded { 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. + /// + public IrOutputPortController(string key, IROutputPort port, string irDriverFilepath) + : base(key) + { + //if (port == null) throw new ArgumentNullException("port"); + IrPort = port; + if (port == null) + { + Debug.Console(0, this, "WARNING No valid IR Port assigned to controller. IR will not function"); + return; + } + LoadDriver(irDriverFilepath); } public IrOutputPortController(string key, Func postActivationFunc, @@ -49,90 +49,94 @@ namespace PepperDash.Essentials.Core AddPostActivationAction(() => { IrPort = postActivationFunc(config); + if (IrPort != null) + { + DriverIsLoaded = true; + } }); } - /// - /// Loads the IR driver at path - /// - /// - public void LoadDriver(string path) - { - if (string.IsNullOrEmpty(path)) path = DriverFilepath; - try - { - IrPortUid = IrPort.LoadIRDriver(path); - DriverFilepath = path; - StandardIrPulseTime = 200; - DriverIsLoaded = true; - } - catch - { - DriverIsLoaded = false; - var message = string.Format("WARNING IR Driver '{0}' failed to load", path); - Debug.Console(0, this, message); - ErrorLog.Error(message); - } - } - - - /// - /// Starts and stops IR command on driver. Safe for missing commands - /// - public virtual void PressRelease(string command, bool state) - { - Debug.Console(2, this, "IR:'{0}'={1}", command, state); - if (IrPort == null) - { - Debug.Console(2, this, "WARNING No IR Port assigned to controller"); - return; - } - if (!DriverIsLoaded) - { - Debug.Console(2, this, "WARNING IR driver is not loaded"); - return; - } - if (state) - { - if (IrPort.IsIRCommandAvailable(IrPortUid, command)) - IrPort.Press(IrPortUid, command); - else - NoIrCommandError(command); - } - else - IrPort.Release(); - } - - /// - /// Pulses a command on driver. Safe for missing commands - /// - public virtual void Pulse(string command, ushort time) - { - if (IrPort == null) - { - Debug.Console(2, this, "WARNING No IR Port assigned to controller"); - return; - } - if (!DriverIsLoaded) - { - Debug.Console(2, this, "WARNING IR driver is not loaded"); - return; - } - if (IrPort.IsIRCommandAvailable(IrPortUid, command)) - IrPort.PressAndRelease(IrPortUid, command, time); - else - NoIrCommandError(command); - } - - /// - /// Notifies the console when a bad command is used. - /// - protected void NoIrCommandError(string command) - { - Debug.Console(2, this, "Device {0}: IR Driver {1} does not contain command {2}", - Key, IrPort.IRDriverFileNameByIRDriverId(IrPortUid), command); + /// + /// Loads the IR driver at path + /// + /// + public void LoadDriver(string path) + { + if (string.IsNullOrEmpty(path)) path = DriverFilepath; + try + { + IrPortUid = IrPort.LoadIRDriver(path); + DriverFilepath = path; + StandardIrPulseTime = 200; + DriverIsLoaded = true; + } + catch + { + DriverIsLoaded = false; + var message = string.Format("WARNING IR Driver '{0}' failed to load", path); + Debug.Console(0, this, message); + ErrorLog.Error(message); + } } - } + + + /// + /// Starts and stops IR command on driver. Safe for missing commands + /// + public virtual void PressRelease(string command, bool state) + { + Debug.Console(2, this, "IR:'{0}'={1}", command, state); + if (IrPort == null) + { + Debug.Console(2, this, "WARNING No IR Port assigned to controller"); + return; + } + if (!DriverIsLoaded) + { + Debug.Console(2, this, "WARNING IR driver is not loaded"); + return; + } + if (state) + { + if (IrPort.IsIRCommandAvailable(IrPortUid, command)) + IrPort.Press(IrPortUid, command); + else + NoIrCommandError(command); + } + else + IrPort.Release(); + } + + /// + /// Pulses a command on driver. Safe for missing commands + /// + public virtual void Pulse(string command, ushort time) + { + if (IrPort == null) + { + Debug.Console(2, this, "WARNING No IR Port assigned to controller"); + return; + } + if (!DriverIsLoaded) + { + Debug.Console(2, this, "WARNING IR driver is not loaded"); + return; + } + if (IrPort.IsIRCommandAvailable(IrPortUid, command)) + IrPort.PressAndRelease(IrPortUid, command, time); + else + NoIrCommandError(command); + } + + /// + /// Notifies the console when a bad command is used. + /// + protected void NoIrCommandError(string command) + { + Debug.Console(2, this, "Device {0}: IR Driver {1} does not contain command {2}", + Key, IrPort.IRDriverFileNameByIRDriverId(IrPortUid), command); + } + } } \ No newline at end of file From a30062db7123f116d3a487402f6740213f0ea3c3 Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Tue, 18 Aug 2020 14:46:13 -0600 Subject: [PATCH 05/10] add static class for IR Command values and use them --- .../Streaming/AppleTV.cs | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Streaming/AppleTV.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Streaming/AppleTV.cs index 1db187f8..26fb1223 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Streaming/AppleTV.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Streaming/AppleTV.cs @@ -39,32 +39,32 @@ namespace PepperDash.Essentials.Devices.Common public void Up(bool pressRelease) { - IrPort.PressRelease("+", pressRelease); + IrPort.PressRelease(AppleTvIrCommands.Up, pressRelease); } public void Down(bool pressRelease) { - IrPort.PressRelease("-", pressRelease); + IrPort.PressRelease(AppleTvIrCommands.Down, pressRelease); } public void Left(bool pressRelease) { - IrPort.PressRelease(IROutputStandardCommands.IROut_TRACK_MINUS, pressRelease); + IrPort.PressRelease(AppleTvIrCommands.Left, pressRelease); } public void Right(bool pressRelease) { - IrPort.PressRelease(IROutputStandardCommands.IROut_TRACK_PLUS, pressRelease); + IrPort.PressRelease(AppleTvIrCommands.Right, pressRelease); } public void Select(bool pressRelease) { - IrPort.PressRelease(IROutputStandardCommands.IROut_ENTER, pressRelease); + IrPort.PressRelease(AppleTvIrCommands.Enter, pressRelease); } public void Menu(bool pressRelease) { - IrPort.PressRelease("Menu", pressRelease); + IrPort.PressRelease(AppleTvIrCommands.Menu, pressRelease); } public void Exit(bool pressRelease) @@ -78,12 +78,12 @@ namespace PepperDash.Essentials.Devices.Common public void Play(bool pressRelease) { - IrPort.PressRelease("PLAY/PAUSE", pressRelease); + IrPort.PressRelease(AppleTvIrCommands.PlayPause, pressRelease); } public void Pause(bool pressRelease) { - IrPort.PressRelease("PLAY/PAUSE", pressRelease); + IrPort.PressRelease(AppleTvIrCommands.PlayPause, pressRelease); } /// @@ -190,4 +190,16 @@ namespace PepperDash.Essentials.Devices.Common } } + public static class AppleTvIrCommands + { + public const string Up = "UP_ARROW"; + public const string Down = "DOWN_ARROW"; + public const string Left = "LEFT_ARROW"; + public const string Right = "RIGHT_ARROW"; + public const string Enter = "SELECT"; + public const string PlayPause = "PLAY_PAUSE"; + public const string Rewind = "REWIND"; + public const string Menu = "MENU"; + public const string FastForward = "FASTFORWARD"; + } } \ No newline at end of file From 468aff6e3f24c8ba2198ca5a9d38d6699f4568ba Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Tue, 18 Aug 2020 16:34:24 -0600 Subject: [PATCH 06/10] move load file to end of postactivation action and change to use the IrPortController's loadFile method add printing of available IR Commands in the loaded file. --- .../Comm and IR/IRPortHelper.cs | 5 +-- .../Devices/IrOutputPortController.cs | 32 +++++++++++++------ 2 files changed, 24 insertions(+), 13 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 b965a379..c75630e4 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/IRPortHelper.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Comm and IR/IRPortHelper.cs @@ -134,12 +134,9 @@ namespace PepperDash.Essentials.Core var port = irDev.IROutputPorts[portNum]; - var filePath = Global.FilePathPrefix + "ir" + Global.DirectorySeparator + control["irFile"].Value(); - Debug.Console(1, "*************Attemting to load IR file: {0}***************", filePath); - port.LoadIRDriver(filePath); + return port; - } public static IrOutputPortController GetIrOutputPortController(DeviceConfig config) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IrOutputPortController.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IrOutputPortController.cs index 7e024f0b..12142cf4 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IrOutputPortController.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IrOutputPortController.cs @@ -49,9 +49,22 @@ namespace PepperDash.Essentials.Core AddPostActivationAction(() => { IrPort = postActivationFunc(config); - if (IrPort != null) + + if (IrPort == null) { - DriverIsLoaded = true; + Debug.Console(0, this, "WARNING No valid IR Port assigned to controller. IR will not function"); + return; + } + + var filePath = Global.FilePathPrefix + "ir" + Global.DirectorySeparator + config.Properties["control"]["irFile"].Value(); + Debug.Console(1, "*************Attemting to load IR file: {0}***************", filePath); + + LoadDriver(filePath); + + Debug.Console(2, this, "Available IR Commands in IR File {0}",IrPortUid); + foreach (var cmd in IrPort.AvailableIRCmds()) + { + Debug.Console(2, this, "{0}", cmd); } }); } @@ -64,14 +77,15 @@ namespace PepperDash.Essentials.Core /// public void LoadDriver(string path) { + Debug.Console(2, this, "***Loading IR File***"); if (string.IsNullOrEmpty(path)) path = DriverFilepath; - try - { - IrPortUid = IrPort.LoadIRDriver(path); - DriverFilepath = path; - StandardIrPulseTime = 200; - DriverIsLoaded = true; - } + try + { + IrPortUid = IrPort.LoadIRDriver(path); + DriverFilepath = path; + StandardIrPulseTime = 200; + DriverIsLoaded = true; + } catch { DriverIsLoaded = false; From 277886b092601e2c70ddaccd67285b8962a22d71 Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Mon, 31 Aug 2020 10:23:51 -0600 Subject: [PATCH 07/10] add property to get IrFile commands --- .../PepperDashEssentialsBase/Devices/IrOutputPortController.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IrOutputPortController.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IrOutputPortController.cs index 12142cf4..b24991aa 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IrOutputPortController.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IrOutputPortController.cs @@ -25,6 +25,8 @@ namespace PepperDash.Essentials.Core public string DriverFilepath { get; private set; } public bool DriverIsLoaded { get; private set; } + public string[] IrFileCommands { get { return IrPort.AvailableStandardIRCmds(IrPortUid); } } + /// /// Constructor for IrDevice base class. If a null port is provided, this class will /// still function without trying to talk to a port. From 6fe13b6a927e8f715325d26b6d69693ee642b2d7 Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Mon, 31 Aug 2020 14:48:06 -0600 Subject: [PATCH 08/10] Add methods to print IR functions --- .../Devices/IrOutputPortController.cs | 14 ++++++--- .../Streaming/AppleTV.cs | 31 +++++++++++++------ 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IrOutputPortController.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IrOutputPortController.cs index b24991aa..ff884007 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IrOutputPortController.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IrOutputPortController.cs @@ -63,14 +63,18 @@ namespace PepperDash.Essentials.Core LoadDriver(filePath); - Debug.Console(2, this, "Available IR Commands in IR File {0}",IrPortUid); - foreach (var cmd in IrPort.AvailableIRCmds()) - { - Debug.Console(2, this, "{0}", cmd); - } + PrintAvailableCommands(); }); } + public void PrintAvailableCommands() + { + Debug.Console(2, this, "Available IR Commands in IR File {0}", IrPortUid); + foreach (var cmd in IrPort.AvailableIRCmds()) + { + Debug.Console(2, this, "{0}", cmd); + } + } /// diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Streaming/AppleTV.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Streaming/AppleTV.cs index 26fb1223..143b48bb 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Streaming/AppleTV.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Streaming/AppleTV.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; +using Crestron.SimplSharp.Reflection; using Crestron.SimplSharpPro; using Crestron.SimplSharpPro.DeviceSupport; using Newtonsoft.Json; @@ -34,8 +35,17 @@ namespace PepperDash.Essentials.Devices.Common OutputPorts = new RoutingPortCollection { HdmiOut, AnyAudioOut }; } + public void PrintExpectedIrCommands() + { + var cmds = typeof (AppleTvIrCommands).GetCType().GetFields(BindingFlags.Public | BindingFlags.Static); - #region IDPad Members + foreach (var value in cmds.Select(cmd => cmd.GetValue(null)).OfType()) + { + Debug.Console(2, this, "Expected IR Function Name: {0}", value); + } + } + + #region IDPad Members public void Up(bool pressRelease) { @@ -192,14 +202,15 @@ namespace PepperDash.Essentials.Devices.Common public static class AppleTvIrCommands { - public const string Up = "UP_ARROW"; - public const string Down = "DOWN_ARROW"; - public const string Left = "LEFT_ARROW"; - public const string Right = "RIGHT_ARROW"; - public const string Enter = "SELECT"; - public const string PlayPause = "PLAY_PAUSE"; - public const string Rewind = "REWIND"; - public const string Menu = "MENU"; - public const string FastForward = "FASTFORWARD"; + + public static string Up = "+"; + public static string Down = "-"; + public static string Left = IROutputStandardCommands.IROut_TRACK_MINUS; + public static string Right = IROutputStandardCommands.IROut_TRACK_PLUS; + public static string Enter = IROutputStandardCommands.IROut_ENTER; + public static string PlayPause = "PLAY/PAUSE"; + public static string Rewind = "REWIND"; + public static string Menu = "Menu"; + public static string FastForward = "FASTFORWARD"; } } \ No newline at end of file From 0af944176aab56773fc9dfaafd0f5a6b5ab95ce3 Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Mon, 31 Aug 2020 15:31:41 -0600 Subject: [PATCH 09/10] update .gitignore for nuget --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 5ba628b2..effc64e7 100644 --- a/.gitignore +++ b/.gitignore @@ -23,5 +23,6 @@ SIMPLSharpLogs/ *.projectinfo essentials-framework/EssentialDMTestConfig/ output/ +packages/ PepperDashEssentials-0.0.0-buildType-test.zip From 635b4d2432a318f508390a73078987680ab4da4f Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Tue, 1 Sep 2020 09:27:36 -0600 Subject: [PATCH 10/10] called the method to print expected IR values --- .../Essentials Devices Common/Streaming/AppleTV.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Streaming/AppleTV.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Streaming/AppleTV.cs index 143b48bb..709afb72 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Streaming/AppleTV.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Streaming/AppleTV.cs @@ -33,6 +33,8 @@ namespace PepperDash.Essentials.Devices.Common AnyAudioOut = new RoutingOutputPort(RoutingPortNames.AnyAudioOut, eRoutingSignalType.Audio, eRoutingPortConnectionType.DigitalAudio, null, this); OutputPorts = new RoutingPortCollection { HdmiOut, AnyAudioOut }; + + PrintExpectedIrCommands(); } public void PrintExpectedIrCommands()