diff --git a/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs b/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs index ca137a27..20c8ae3d 100644 --- a/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs +++ b/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs @@ -424,10 +424,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(); + } } /// diff --git a/PepperDashEssentials/UI/JoinConstants/UIBoolJoin.cs b/PepperDashEssentials/UI/JoinConstants/UIBoolJoin.cs index 3897afa5..23ab797e 100644 --- a/PepperDashEssentials/UI/JoinConstants/UIBoolJoin.cs +++ b/PepperDashEssentials/UI/JoinConstants/UIBoolJoin.cs @@ -272,6 +272,20 @@ namespace PepperDash.Essentials public const uint VCCameraPreset3 = 1283; + /// + /// 1291 + /// + public const uint VCCameraPreset1Visible = 1291; + /// + /// 1292 + /// + public const uint VCCameraPreset2Visible = 1292; + /// + /// 1293 + /// + public const uint VCCameraPreset3Visible = 1293; + + // Letter joins start at 2921; //****************************************************** diff --git a/PepperDashEssentials/UIDrivers/Essentials/EssentialsPanelMainInterfaceDriver.cs b/PepperDashEssentials/UIDrivers/Essentials/EssentialsPanelMainInterfaceDriver.cs index ab4ff3aa..9b92fc41 100644 --- a/PepperDashEssentials/UIDrivers/Essentials/EssentialsPanelMainInterfaceDriver.cs +++ b/PepperDashEssentials/UIDrivers/Essentials/EssentialsPanelMainInterfaceDriver.cs @@ -1,80 +1,81 @@ -using System; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.UI; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.SmartObjects; - -namespace PepperDash.Essentials -{ - /// - /// - /// - public class EssentialsPanelMainInterfaceDriver : PanelDriverBase - { - CTimer InactivityTimer; - - /// - /// Assign the appropriate A/V driver. - /// Want to keep the AvDriver alive, because it may hold states - /// - public IAVDriver AvDriver { get; set; } - - public EssentialsHeaderDriver HeaderDriver { get; set; } - - public EssentialsEnvironmentDriver EnvironmentDriver { get; set; } - - public PanelDriverBase CurrentChildDriver { get; private set; } - +using System; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro.DeviceSupport; +using Crestron.SimplSharpPro.UI; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.SmartObjects; + +namespace PepperDash.Essentials +{ + /// + /// + /// + public class EssentialsPanelMainInterfaceDriver : PanelDriverBase, IHasScreenSaverController + { + CTimer InactivityTimer; + + /// + /// Assign the appropriate A/V driver. + /// Want to keep the AvDriver alive, because it may hold states + /// + public IAVDriver AvDriver { get; set;} + + public EssentialsHeaderDriver HeaderDriver { get; set; } + + public EssentialsEnvironmentDriver EnvironmentDriver { get; set; } + + public PanelDriverBase CurrentChildDriver { get; private set; } + public ScreenSaverController ScreenSaverController { get; set; } - private readonly long _timeoutMs; - - CrestronTouchpanelPropertiesConfig Config; - - /// - /// The main interlock for popups - /// - //public JoinedSigInterlock PopupInterlock { get; private set; } - - public EssentialsPanelMainInterfaceDriver(BasicTriListWithSmartObject trilist, - CrestronTouchpanelPropertiesConfig config) - : base(trilist) - { - Config = config; - - _timeoutMs = Config.ScreenSaverTimeoutMin * 60 * 1000; - - var tsx52or60 = trilist as Tswx52ButtonVoiceControl; - + private readonly long _timeoutMs; + + CrestronTouchpanelPropertiesConfig Config; + + /// + /// The main interlock for popups + /// + //public JoinedSigInterlock PopupInterlock { get; private set; } + + public EssentialsPanelMainInterfaceDriver(BasicTriListWithSmartObject trilist, + CrestronTouchpanelPropertiesConfig config) + : base(trilist) + { + Config = config; + + _timeoutMs = Config.ScreenSaverTimeoutMin * 60 * 1000; + + var tsx52or60 = trilist as Tswx52ButtonVoiceControl; + if (tsx52or60 != null) { tsx52or60.ExtenderTouchDetectionReservedSigs.Use(); tsx52or60.ExtenderTouchDetectionReservedSigs.DeviceExtenderSigChange += ExtenderTouchDetectionReservedSigs_DeviceExtenderSigChange; tsx52or60.ExtenderTouchDetectionReservedSigs.Time.UShortValue = 1; ManageInactivityTimer(); - - } - else - { - var tswx70 = trilist as TswX70Base; - if (tswx70 != null) + + } + else + { + var tswx70 = trilist as TswX70Base; + if (tswx70 != null) { tswx70.ExtenderTouchDetectionReservedSigs.Use(); tswx70.ExtenderTouchDetectionReservedSigs.DeviceExtenderSigChange += ExtenderTouchDetectionReservedSigs_DeviceExtenderSigChange; tswx70.ExtenderTouchDetectionReservedSigs.Time.UShortValue = 1; - ManageInactivityTimer(); - } - } - } - - void ExtenderTouchDetectionReservedSigs_DeviceExtenderSigChange(Crestron.SimplSharpPro.DeviceExtender currentDeviceExtender, Crestron.SimplSharpPro.SigEventArgs args) - { - + ManageInactivityTimer(); + } + } + } + + void ExtenderTouchDetectionReservedSigs_DeviceExtenderSigChange(Crestron.SimplSharpPro.DeviceExtender currentDeviceExtender, Crestron.SimplSharpPro.SigEventArgs args) + { + if (args.Sig.BoolValue) { ManageInactivityTimer(); - } + } } private void ManageInactivityTimer() @@ -87,46 +88,52 @@ namespace PepperDash.Essentials { InactivityTimer = new CTimer((o) => InactivityTimerExpired(), _timeoutMs); } - } - - void InactivityTimerExpired() - { - InactivityTimer.Stop(); - InactivityTimer.Dispose(); - InactivityTimer = null; - - ScreenSaverController.Show(); - } - - public override void Show() - { - CurrentChildDriver = null; - ShowSubDriver(AvDriver as PanelDriverBase); - base.Show(); - } - - public override void Hide() - { - TriList.BooleanInput[AvDriver.StartPageVisibleJoin].BoolValue = false; - base.Hide(); - } - - void ShowSubDriver(PanelDriverBase driver) - { - CurrentChildDriver = driver; - if (driver == null) - return; - this.Hide(); - driver.Show(); - } - - /// - /// - /// - public override void BackButtonPressed() - { - if(CurrentChildDriver != null) - CurrentChildDriver.BackButtonPressed(); - } - } + } + + void InactivityTimerExpired() + { + InactivityTimer.Stop(); + InactivityTimer.Dispose(); + InactivityTimer = null; + + ScreenSaverController.Show(); + } + + public override void Show() + { + CurrentChildDriver = null; + ShowSubDriver(AvDriver as PanelDriverBase); + + base.Show(); + } + + public override void Hide() + { + TriList.BooleanInput[AvDriver.StartPageVisibleJoin].BoolValue = false; + base.Hide(); + } + + void ShowSubDriver(PanelDriverBase driver) + { + CurrentChildDriver = driver; + if (driver == null) + return; + this.Hide(); + driver.Show(); + } + + /// + /// + /// + public override void BackButtonPressed() + { + if(CurrentChildDriver != null) + CurrentChildDriver.BackButtonPressed(); + } + } + + public interface IHasScreenSaverController + { + ScreenSaverController ScreenSaverController { get; } + } } \ No newline at end of file diff --git a/PepperDashEssentials/UIDrivers/EssentialsHuddle/EssentialsHuddlePanelAvFunctionsDriver.cs b/PepperDashEssentials/UIDrivers/EssentialsHuddle/EssentialsHuddlePanelAvFunctionsDriver.cs index 42b2cf5c..a2a80af3 100644 --- a/PepperDashEssentials/UIDrivers/EssentialsHuddle/EssentialsHuddlePanelAvFunctionsDriver.cs +++ b/PepperDashEssentials/UIDrivers/EssentialsHuddle/EssentialsHuddlePanelAvFunctionsDriver.cs @@ -114,7 +114,7 @@ namespace PepperDash.Essentials /// /// The parent driver for this /// - PanelDriverBase Parent; + public PanelDriverBase Parent { get; private set; } /// /// All children attached to this driver. For hiding and showing as a group. diff --git a/PepperDashEssentials/UIDrivers/EssentialsHuddleVTC/EssentialsHuddleVtc1PanelAvFunctionsDriver.cs b/PepperDashEssentials/UIDrivers/EssentialsHuddleVTC/EssentialsHuddleVtc1PanelAvFunctionsDriver.cs index 5a99f6e4..d8af370b 100644 --- a/PepperDashEssentials/UIDrivers/EssentialsHuddleVTC/EssentialsHuddleVtc1PanelAvFunctionsDriver.cs +++ b/PepperDashEssentials/UIDrivers/EssentialsHuddleVTC/EssentialsHuddleVtc1PanelAvFunctionsDriver.cs @@ -72,7 +72,7 @@ namespace PepperDash.Essentials /// /// The parent driver for this /// - PanelDriverBase Parent; + public PanelDriverBase Parent { get; private set; } /// /// All children attached to this driver. For hiding and showing as a group. @@ -1430,6 +1430,7 @@ namespace PepperDash.Essentials /// public interface IAVDriver { + PanelDriverBase Parent { get; } JoinedSigInterlock PopupInterlock { get; } void ShowNotificationRibbon(string message, int timeout); void HideNotificationRibbon(); diff --git a/PepperDashEssentials/UIDrivers/ScreenSaverController.cs b/PepperDashEssentials/UIDrivers/ScreenSaverController.cs index 9f973113..e6d60d5b 100644 --- a/PepperDashEssentials/UIDrivers/ScreenSaverController.cs +++ b/PepperDashEssentials/UIDrivers/ScreenSaverController.cs @@ -21,6 +21,8 @@ namespace PepperDash.Essentials private readonly EssentialsPanelMainInterfaceDriver _parent; + private JoinedSigInterlock PositionInterlock; + CTimer PositionTimer; uint PositionTimeoutMs; @@ -38,7 +40,9 @@ namespace PepperDash.Essentials PositionJoins = new List() { UIBoolJoin.MCScreenSaverPosition1Visible, UIBoolJoin.MCScreenSaverPosition2Visible, UIBoolJoin.MCScreenSaverPosition3Visible, UIBoolJoin.MCScreenSaverPosition4Visible }; - var cmdName = String.Format("shwscrsvr-{0}", config.IpId); + PositionInterlock = new JoinedSigInterlock(parent.TriList); + + var cmdName = String.Format("shwscrsvr-{0}", parent.TriList.ID); CrestronConsole.AddNewConsoleCommand((o) => Show(), cmdName, "Shows Panel Screensaver", ConsoleAccessLevelEnum.AccessOperator); @@ -47,10 +51,13 @@ namespace PepperDash.Essentials public override void Show() { - _parent.AvDriver.PopupInterlock.ShowInterlockedWithToggle(UIBoolJoin.MCScreenSaverVisible); + if (_parent.AvDriver != null) + { + _parent.AvDriver.PopupInterlock.ShowInterlocked(UIBoolJoin.MCScreenSaverVisible); + } CurrentPositionIndex = 0; - SetCurrentPosition(); + ShowCurrentPosition(); StartPositionTimer(); base.Show(); @@ -58,6 +65,8 @@ namespace PepperDash.Essentials public override void Hide() { + Debug.Console(1, "Hiding ScreenSaverController"); + if (PositionTimer != null) { PositionTimer.Stop(); @@ -67,7 +76,10 @@ namespace PepperDash.Essentials ClearAllPositions(); - _parent.AvDriver.PopupInterlock.HideAndClear(); + if (_parent.AvDriver != null) + { + _parent.AvDriver.PopupInterlock.HideAndClear(); + } base.Hide(); } @@ -89,7 +101,7 @@ namespace PepperDash.Essentials { IncrementPositionIndex(); - SetCurrentPosition(); + ShowCurrentPosition(); StartPositionTimer(); } @@ -109,20 +121,16 @@ namespace PepperDash.Essentials } // - void SetCurrentPosition() + void ShowCurrentPosition() { - ClearAllPositions(); - // Set based on current index - TriList.SetBool(PositionJoins[CurrentPositionIndex], true); + PositionInterlock.ShowInterlocked(PositionJoins[CurrentPositionIndex]); } void ClearAllPositions() { - foreach (var join in PositionJoins) - { - TriList.SetBool(join, false); - } + Debug.Console(1, "Hiding all screensaver positions"); + PositionInterlock.HideAndClear(); } } diff --git a/PepperDashEssentials/UIDrivers/VC/EssentialsVideoCodecUiDriver.cs b/PepperDashEssentials/UIDrivers/VC/EssentialsVideoCodecUiDriver.cs index 0c219426..5642d757 100644 --- a/PepperDashEssentials/UIDrivers/VC/EssentialsVideoCodecUiDriver.cs +++ b/PepperDashEssentials/UIDrivers/VC/EssentialsVideoCodecUiDriver.cs @@ -398,6 +398,8 @@ namespace PepperDash.Essentials.UIDrivers.VC /// void ShowIncomingModal(CodecActiveCallItem call) { + Debug.Console(1, "Showing Incoming Call Modal"); + (Parent as IAVWithVCDriver).PrepareForCodecIncomingCall(); IncomingCallModal = new ModalDialog(TriList); string msg; @@ -413,13 +415,19 @@ namespace PepperDash.Essentials.UIDrivers.VC msg = string.Format("Incoming video call from: {0}", call.Name); } - if (Parent.PopupInterlock.IsShown) + + // Hide screensaver + var screenSaverParent = Parent.Parent as IHasScreenSaverController; + + if (screenSaverParent != null) { - if (Parent.PopupInterlock.CurrentJoin == UIBoolJoin.MCScreenSaverVisible) - { - Parent.PopupInterlock.HideAndClear(); - } + screenSaverParent.ScreenSaverController.Hide(); } + else + { + Debug.Console(1, "Parent.Parent is null or does not implement IHasScreenSaverController"); + } + IncomingCallModal.PresentModalDialog(2, "Incoming Call", icon, msg, "Ignore", "Accept", false, false, b => @@ -709,17 +717,45 @@ namespace PepperDash.Essentials.UIDrivers.VC uint holdTime = 5000; presetsCodec.CodecRoomPresetsListHasChanged += new EventHandler(presetsCodec_CodecRoomPresetsListHasChanged); - TriList.BooleanOutput[UIBoolJoin.VCCameraPreset1].SetSigHeldAction( - holdTime, () => presetsCodec.CodecRoomPresetStore(1, presetsCodec.NearEndPresets[0].Description), ShowPresetStoreFeedback, () => presetsCodec.CodecRoomPresetSelect(1)); - TriList.BooleanOutput[UIBoolJoin.VCCameraPreset2].SetSigHeldAction( - holdTime, () => presetsCodec.CodecRoomPresetStore(2, presetsCodec.NearEndPresets[1].Description), ShowPresetStoreFeedback, () => presetsCodec.CodecRoomPresetSelect(2)); - TriList.BooleanOutput[UIBoolJoin.VCCameraPreset3].SetSigHeldAction( - holdTime, () => presetsCodec.CodecRoomPresetStore(3, presetsCodec.NearEndPresets[2].Description), ShowPresetStoreFeedback, () => presetsCodec.CodecRoomPresetSelect(3)); + var preset = 1; + if (presetsCodec.NearEndPresets[preset - 1] != null && presetsCodec.NearEndPresets[preset - 1].Defined) + { + TriList.SetBool(UIBoolJoin.VCCameraPreset1Visible, true); + TriList.BooleanOutput[UIBoolJoin.VCCameraPreset1].SetSigHeldAction( + holdTime, ShowPresetStoreFeedback,() => presetsCodec.CodecRoomPresetStore(preset, presetsCodec.NearEndPresets[preset - 1].Description), + () => presetsCodec.CodecRoomPresetSelect(preset)); + TriList.StringInput[UIStringJoin.VCCameraPresetLabel1].StringValue = presetsCodec.NearEndPresets[preset - 1].Description; + } + else + { + TriList.SetBool(UIBoolJoin.VCCameraPreset1Visible, false); + } - TriList.StringInput[UIStringJoin.VCCameraPresetLabel1].StringValue = presetsCodec.NearEndPresets[0].Description; - TriList.StringInput[UIStringJoin.VCCameraPresetLabel2].StringValue = presetsCodec.NearEndPresets[1].Description; - TriList.StringInput[UIStringJoin.VCCameraPresetLabel3].StringValue = presetsCodec.NearEndPresets[2].Description; + if (presetsCodec.NearEndPresets[1] != null && presetsCodec.NearEndPresets[1].Defined) + { + TriList.SetBool(UIBoolJoin.VCCameraPreset2Visible, true); + TriList.BooleanOutput[UIBoolJoin.VCCameraPreset2].SetSigHeldAction( + holdTime, ShowPresetStoreFeedback, () => presetsCodec.CodecRoomPresetStore(preset, presetsCodec.NearEndPresets[preset - 1].Description), + () => presetsCodec.CodecRoomPresetSelect(preset)); + TriList.StringInput[UIStringJoin.VCCameraPresetLabel2].StringValue = presetsCodec.NearEndPresets[1].Description; + } + else + { + TriList.SetBool(UIBoolJoin.VCCameraPreset2Visible, false); + } + if (presetsCodec.NearEndPresets[2] != null && presetsCodec.NearEndPresets[2].Defined) + { + TriList.SetBool(UIBoolJoin.VCCameraPreset3Visible, true); + TriList.BooleanOutput[UIBoolJoin.VCCameraPreset3].SetSigHeldAction( + holdTime, ShowPresetStoreFeedback, () => presetsCodec.CodecRoomPresetStore(preset, presetsCodec.NearEndPresets[preset - 1].Description), + () => presetsCodec.CodecRoomPresetSelect(preset)); + TriList.StringInput[UIStringJoin.VCCameraPresetLabel3].StringValue = presetsCodec.NearEndPresets[2].Description; + } + else + { + TriList.SetBool(UIBoolJoin.VCCameraPreset3Visible, false); + } } } 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..c75630e4 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); @@ -134,10 +134,9 @@ namespace PepperDash.Essentials.Core var port = irDev.IROutputPorts[portNum]; - port.LoadIRDriver(Global.FilePathPrefix + "IR" + Global.DirectorySeparator + control["irFile"].Value()); + return port; - } public static IrOutputPortController GetIrOutputPortController(DeviceConfig config) @@ -149,87 +148,88 @@ namespace PepperDash.Essentials.Core return null; } - var irDevice = new IrOutputPortController(config.Key, GetIrOutputPort, config); + var postActivationFunc = new Func (GetIrOutputPort); + var irDevice = new IrOutputPortController(config.Key + "-ir", postActivationFunc, config); 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 diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IrOutputPortController.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Devices/IrOutputPortController.cs index 83241e79..ff884007 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. @@ -49,9 +51,30 @@ namespace PepperDash.Essentials.Core AddPostActivationAction(() => { IrPort = postActivationFunc(config); + + if (IrPort == null) + { + 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); + + 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); + } + } /// @@ -60,14 +83,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; 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..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 @@ -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; @@ -32,39 +33,50 @@ 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() + { + 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) { - 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 +90,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 +202,17 @@ namespace PepperDash.Essentials.Devices.Common } } + public static class AppleTvIrCommands + { + + 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