diff --git a/PepperDashEssentials/Bridges/BridgeBase.cs b/PepperDashEssentials/Bridges/BridgeBase.cs index bea29911..73ede03c 100644 --- a/PepperDashEssentials/Bridges/BridgeBase.cs +++ b/PepperDashEssentials/Bridges/BridgeBase.cs @@ -136,6 +136,11 @@ namespace PepperDash.Essentials.Bridges (device as GenericRelayDevice).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); continue; } + else if (device is IRSetTopBoxBase) + { + (device as IRSetTopBoxBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); + continue; + } else if (device is IDigitalInput) { (device as IDigitalInput).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); diff --git a/PepperDashEssentials/Bridges/GlsOccupancySensorBaseControllerBridge.cs b/PepperDashEssentials/Bridges/GlsOccupancySensorBaseControllerBridge.cs index 44250f4c..d905beef 100644 --- a/PepperDashEssentials/Bridges/GlsOccupancySensorBaseControllerBridge.cs +++ b/PepperDashEssentials/Bridges/GlsOccupancySensorBaseControllerBridge.cs @@ -31,6 +31,16 @@ namespace PepperDash.Essentials.Bridges #region Single and Dual Sensor Stuff occController.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]); + trilist.StringInput[joinMap.Name].StringValue = occController.Name; + + trilist.OnlineStatusChange += new Crestron.SimplSharpPro.OnlineStatusChangeEventHandler((d, args) => + { + if (args.DeviceOnLine) + { + trilist.StringInput[joinMap.Name].StringValue = occController.Name; + } + } + ); // Occupied status trilist.SetSigTrueAction(joinMap.ForceOccupied, new Action(() => occController.ForceOccupied())); @@ -38,6 +48,7 @@ namespace PepperDash.Essentials.Bridges occController.RoomIsOccupiedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RoomOccupiedFeedback]); occController.RoomIsOccupiedFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.RoomVacantFeedback]); occController.RawOccupancyFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RawOccupancyFeedback]); + trilist.SetBoolSigAction(joinMap.EnableRawStates, new Action((b) => occController.EnableRawStates(b))); // Timouts trilist.SetUShortSigAction(joinMap.Timeout, new Action((u) => occController.SetRemoteTimeout(u))); diff --git a/PepperDashEssentials/Bridges/IRSetTopBoxBaseBridge.cs b/PepperDashEssentials/Bridges/IRSetTopBoxBaseBridge.cs new file mode 100644 index 00000000..68d765bc --- /dev/null +++ b/PepperDashEssentials/Bridges/IRSetTopBoxBaseBridge.cs @@ -0,0 +1,128 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro.DeviceSupport; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Devices.Common; + +using Newtonsoft.Json; + +namespace PepperDash.Essentials.Bridges +{ + public static class IRSetTopBoxBaseApiExtensions + { + public static void LinkToApi(this PepperDash.Essentials.Devices.Common.IRSetTopBoxBase stbDevice, BasicTriList trilist, uint joinStart, string joinMapKey) + { + SetTopBoxControllerJoinMap joinMap = new SetTopBoxControllerJoinMap(); + var joinMapSerialized = JoinMapHelper.GetJoinMapForDevice(joinMapKey); + + if (!string.IsNullOrEmpty(joinMapSerialized)) + joinMap = JsonConvert.DeserializeObject(joinMapSerialized); + + joinMap.OffsetJoinNumbers(joinStart); + + Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + Debug.Console(0, "Linking to Display: {0}", stbDevice.Name); + + trilist.StringInput[joinMap.Name].StringValue = stbDevice.Name; + + var stbBase = stbDevice as ISetTopBoxControls; + if (stbBase != null) + { + trilist.BooleanInput[joinMap.HasDpad].BoolValue = stbBase.HasDpad; + trilist.BooleanInput[joinMap.HasNumeric].BoolValue = stbBase.HasNumeric; + trilist.BooleanInput[joinMap.HasDvr].BoolValue = stbBase.HasDvr; + trilist.BooleanInput[joinMap.HasPresets].BoolValue = stbBase.HasPresets; + + trilist.SetBoolSigAction(joinMap.DvrList, (b) => stbBase.DvrList(b)); + trilist.SetBoolSigAction(joinMap.Replay, (b) => stbBase.Replay(b)); + + trilist.SetStringSigAction(joinMap.LoadPresets, (s) => stbBase.LoadPresets(s)); + } + + var stbPower = stbDevice as IPower; + if (stbPower != null) + { + trilist.SetSigTrueAction(joinMap.PowerOn, () => stbPower.PowerOn()); + trilist.SetSigTrueAction(joinMap.PowerOff, () => stbPower.PowerOff()); + trilist.SetSigTrueAction(joinMap.PowerToggle, () => stbPower.PowerToggle()); + + } + + var stbDPad = stbDevice as IDPad; + if (stbDPad != null) + { + trilist.SetBoolSigAction(joinMap.Up, (b) => stbDPad.Up(b)); + trilist.SetBoolSigAction(joinMap.Down, (b) => stbDPad.Down(b)); + trilist.SetBoolSigAction(joinMap.Left, (b) => stbDPad.Left(b)); + trilist.SetBoolSigAction(joinMap.Right, (b) => stbDPad.Right(b)); + trilist.SetBoolSigAction(joinMap.Select, (b) => stbDPad.Select(b)); + trilist.SetBoolSigAction(joinMap.Menu, (b) => stbDPad.Menu(b)); + trilist.SetBoolSigAction(joinMap.Exit, (b) => stbDPad.Exit(b)); + } + + var stbChannel = stbDevice as IChannel; + if (stbChannel != null) + { + trilist.SetBoolSigAction(joinMap.ChannelUp, (b) => stbChannel.ChannelUp(b)); + trilist.SetBoolSigAction(joinMap.ChannelDown, (b) => stbChannel.ChannelDown(b)); + trilist.SetBoolSigAction(joinMap.LastChannel, (b) => stbChannel.LastChannel(b)); + trilist.SetBoolSigAction(joinMap.Guide, (b) => stbChannel.Guide(b)); + trilist.SetBoolSigAction(joinMap.Info, (b) => stbChannel.Info(b)); + trilist.SetBoolSigAction(joinMap.Exit, (b) => stbChannel.Exit(b)); + } + + var stbColor = stbDevice as IColor; + if (stbColor != null) + { + trilist.SetBoolSigAction(joinMap.Red, (b) => stbColor.Red(b)); + trilist.SetBoolSigAction(joinMap.Green, (b) => stbColor.Green(b)); + trilist.SetBoolSigAction(joinMap.Yellow, (b) => stbColor.Yellow(b)); + trilist.SetBoolSigAction(joinMap.Blue, (b) => stbColor.Blue(b)); + } + + var stbKeypad = stbDevice as ISetTopBoxNumericKeypad; + if (stbKeypad != null) + { + trilist.StringInput[joinMap.KeypadAccessoryButton1Label].StringValue = stbKeypad.KeypadAccessoryButton1Label; + trilist.StringInput[joinMap.KeypadAccessoryButton2Label].StringValue = stbKeypad.KeypadAccessoryButton2Label; + + trilist.BooleanInput[joinMap.HasKeypadAccessoryButton1].BoolValue = stbKeypad.HasKeypadAccessoryButton1; + trilist.BooleanInput[joinMap.HasKeypadAccessoryButton2].BoolValue = stbKeypad.HasKeypadAccessoryButton2; + + trilist.SetBoolSigAction(joinMap.Digit0, (b) => stbKeypad.Digit0(b)); + trilist.SetBoolSigAction(joinMap.Digit1, (b) => stbKeypad.Digit1(b)); + trilist.SetBoolSigAction(joinMap.Digit2, (b) => stbKeypad.Digit2(b)); + trilist.SetBoolSigAction(joinMap.Digit3, (b) => stbKeypad.Digit3(b)); + trilist.SetBoolSigAction(joinMap.Digit4, (b) => stbKeypad.Digit4(b)); + trilist.SetBoolSigAction(joinMap.Digit5, (b) => stbKeypad.Digit5(b)); + trilist.SetBoolSigAction(joinMap.Digit6, (b) => stbKeypad.Digit6(b)); + trilist.SetBoolSigAction(joinMap.Digit7, (b) => stbKeypad.Digit7(b)); + trilist.SetBoolSigAction(joinMap.Digit8, (b) => stbKeypad.Digit8(b)); + trilist.SetBoolSigAction(joinMap.Digit9, (b) => stbKeypad.Digit9(b)); + trilist.SetBoolSigAction(joinMap.KeypadAccessoryButton1Press, (b) => stbKeypad.KeypadAccessoryButton1(b)); + trilist.SetBoolSigAction(joinMap.KeypadAccessoryButton2Press, (b) => stbKeypad.KeypadAccessoryButton1(b)); + trilist.SetBoolSigAction(joinMap.Dash, (b) => stbKeypad.Dash(b)); + trilist.SetBoolSigAction(joinMap.KeypadEnter, (b) => stbKeypad.KeypadEnter(b)); + } + + var stbTransport = stbDevice as ITransport; + if (stbTransport != null) + { + trilist.SetBoolSigAction(joinMap.Play, (b) => stbTransport.Play(b)); + trilist.SetBoolSigAction(joinMap.Pause, (b) => stbTransport.Pause(b)); + trilist.SetBoolSigAction(joinMap.Rewind, (b) => stbTransport.Rewind(b)); + trilist.SetBoolSigAction(joinMap.FFwd, (b) => stbTransport.FFwd(b)); + trilist.SetBoolSigAction(joinMap.ChapMinus, (b) => stbTransport.ChapMinus(b)); + trilist.SetBoolSigAction(joinMap.ChapPlus, (b) => stbTransport.ChapPlus(b)); + trilist.SetBoolSigAction(joinMap.Stop, (b) => stbTransport.Stop(b)); + trilist.SetBoolSigAction(joinMap.Record, (b) => stbTransport.Record(b)); + + } + + } + } +} \ No newline at end of file diff --git a/PepperDashEssentials/Bridges/JoinMaps/GlsOccupancySensorBaseJoinMap.cs b/PepperDashEssentials/Bridges/JoinMaps/GlsOccupancySensorBaseJoinMap.cs index a48ad0d9..6e19dff2 100644 --- a/PepperDashEssentials/Bridges/JoinMaps/GlsOccupancySensorBaseJoinMap.cs +++ b/PepperDashEssentials/Bridges/JoinMaps/GlsOccupancySensorBaseJoinMap.cs @@ -137,6 +137,10 @@ namespace PepperDash.Essentials.Bridges public uint PirSensitivityInVacantState { get; set; } #endregion + #region Serial + public uint Name { get; set; } + #endregion + public GlsOccupancySensorBaseJoinMap() { IsOnline = 1; @@ -177,7 +181,10 @@ namespace PepperDash.Essentials.Bridges UsSensitivityInOccupiedState = 5; UsSensitivityInVacantState = 6; PirSensitivityInOccupiedState = 7; - PirSensitivityInVacantState = 8; + PirSensitivityInVacantState = 8; + + Name = 1; + } public override void OffsetJoinNumbers(uint joinStart) @@ -206,7 +213,6 @@ namespace PepperDash.Essentials.Bridges DisableUsB = DisableUsB + joinOffset; EnablePir = EnablePir + joinOffset; DisablePir = DisablePir + joinOffset; - DisablePir = DisablePir + joinOffset; IncrementUsInOccupiedState = IncrementUsInOccupiedState + joinOffset; DecrementUsInOccupiedState = DecrementUsInOccupiedState + joinOffset; IncrementUsInVacantState = IncrementUsInVacantState + joinOffset; @@ -224,6 +230,8 @@ namespace PepperDash.Essentials.Bridges UsSensitivityInVacantState = UsSensitivityInVacantState + joinOffset; PirSensitivityInOccupiedState = PirSensitivityInOccupiedState + joinOffset; PirSensitivityInVacantState = PirSensitivityInVacantState + joinOffset; + + Name = Name + joinOffset; } } diff --git a/PepperDashEssentials/Bridges/JoinMaps/SetTopBoxControllerJoinMap.cs b/PepperDashEssentials/Bridges/JoinMaps/SetTopBoxControllerJoinMap.cs new file mode 100644 index 00000000..aa23cb7a --- /dev/null +++ b/PepperDashEssentials/Bridges/JoinMaps/SetTopBoxControllerJoinMap.cs @@ -0,0 +1,212 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using PepperDash.Essentials.Core; +using Crestron.SimplSharp.Reflection; + + +namespace PepperDash.Essentials.Bridges +{ + public class SetTopBoxControllerJoinMap : JoinMapBase + { + #region Digitals + public uint DvrList { get; set; } // + public uint Replay { get; set; } + public uint Up { get; set; } // + public uint Down { get; set; } // + public uint Left { get; set; } // + public uint Right { get; set; } // + public uint Select { get; set; } // + public uint Menu { get; set; } // + public uint Exit { get; set; } // + public uint Digit0 { get; set; } // + public uint Digit1 { get; set; } // + public uint Digit2 { get; set; } // + public uint Digit3 { get; set; } // + public uint Digit4 { get; set; } // + public uint Digit5 { get; set; } // + public uint Digit6 { get; set; } // + public uint Digit7 { get; set; } // + public uint Digit8 { get; set; } // + public uint Digit9 { get; set; } // + public uint Dash { get; set; } // + public uint KeypadEnter { get; set; } // + public uint ChannelUp { get; set; } // + public uint ChannelDown { get; set; } // + public uint LastChannel { get; set; } // + public uint Guide { get; set; } // + public uint Info { get; set; } // + public uint Red { get; set; } // + public uint Green { get; set; } // + public uint Yellow { get; set; } // + public uint Blue { get; set; } // + public uint ChapMinus { get; set; } + public uint ChapPlus { get; set; } + public uint FFwd { get; set; } // + public uint Pause { get; set; } // + public uint Play { get; set; } // + public uint Record { get; set; } + public uint Rewind { get; set; } // + public uint Stop { get; set; } // + + public uint PowerOn { get; set; } // + public uint PowerOff { get; set; } // + public uint PowerToggle { get; set; } // + + public uint HasKeypadAccessoryButton1 { get; set; } + public uint HasKeypadAccessoryButton2 { get; set; } + + public uint KeypadAccessoryButton1Press { get; set; } + public uint KeypadAccessoryButton2Press { get; set; } + + + public uint HasDvr { get; set; } + public uint HasPresets { get; set; } + public uint HasNumeric { get; set; } + public uint HasDpad { get; set; } + + + #endregion + + #region Analogs + + #endregion + + #region Strings + public uint Name { get; set; } + public uint LoadPresets { get; set; } + public uint KeypadAccessoryButton1Label { get; set; } + public uint KeypadAccessoryButton2Label { get; set; } + + #endregion + + public SetTopBoxControllerJoinMap() + { + PowerOn = 1; + PowerOff = 2; + PowerToggle = 3; + + HasDpad = 4; + Up = 4; + Down = 5; + Left = 6; + Right = 7; + Select = 8; + Menu = 9; + Exit = 10; + + HasNumeric = 11; + Digit0 = 11; + Digit1 = 12; + Digit2 = 13; + Digit3 = 14; + Digit4 = 15; + Digit5 = 16; + Digit6 = 17; + Digit7 = 18; + Digit8 = 19; + Digit9 = 20; + Dash = 21; + KeypadEnter = 22; + ChannelUp = 23; + ChannelDown = 24; + LastChannel = 25; + + Guide = 26; + Info = 27; + Red = 28; + Green = 29; + Yellow = 30; + Blue = 31; + + HasDvr = 32; + DvrList = 32; + Play = 33; + Pause = 34; + Stop = 35; + FFwd = 36; + Rewind = 37; + ChapPlus = 38; + ChapMinus = 39; + Replay = 40; + Record = 41; + HasKeypadAccessoryButton1 = 42; + KeypadAccessoryButton1Press = 42; + HasKeypadAccessoryButton2 = 43; + KeypadAccessoryButton2Press = 43; + + Name = 1; + KeypadAccessoryButton1Label = 42; + KeypadAccessoryButton2Label = 43; + + LoadPresets = 50; + } + + public override void OffsetJoinNumbers(uint joinStart) + { + var joinOffset = joinStart - 1; + + PowerOn += joinOffset; + PowerOff += joinOffset; + PowerToggle += joinOffset; + + HasDpad += joinOffset; + Up += joinOffset; + Down += joinOffset; + Left += joinOffset; + Right += joinOffset; + Select += joinOffset; + Menu += joinOffset; + Exit += joinOffset; + + HasNumeric += joinOffset; + Digit0 += joinOffset; + Digit1 += joinOffset; + Digit2 += joinOffset; + Digit3 += joinOffset; + Digit4 += joinOffset; + Digit5 += joinOffset; + Digit6 += joinOffset; + Digit7 += joinOffset; + Digit8 += joinOffset; + Digit9 += joinOffset; + Dash += joinOffset; + KeypadEnter += joinOffset; + ChannelUp += joinOffset; + ChannelDown += joinOffset; + LastChannel += joinOffset; + + Guide += joinOffset; + Info += joinOffset; + Red += joinOffset; + Green += joinOffset; + Yellow += joinOffset; + Blue += joinOffset; + + HasDvr += joinOffset; + DvrList += joinOffset; + Play += joinOffset; + Pause += joinOffset; + Stop += joinOffset; + FFwd += joinOffset; + Rewind += joinOffset; + ChapPlus += joinOffset; + ChapMinus += joinOffset; + Replay += joinOffset; + Record += joinOffset; + HasKeypadAccessoryButton1 += joinOffset; + KeypadAccessoryButton1Press += joinOffset; + HasKeypadAccessoryButton2 += joinOffset; + KeypadAccessoryButton2Press += joinOffset; + + Name += joinOffset; + KeypadAccessoryButton1Label += joinOffset; + KeypadAccessoryButton2Label += joinOffset; + + LoadPresets += joinOffset; + } + + } +} \ No newline at end of file diff --git a/PepperDashEssentials/PepperDashEssentials.csproj b/PepperDashEssentials/PepperDashEssentials.csproj index b7b73cb8..612bdf10 100644 --- a/PepperDashEssentials/PepperDashEssentials.csproj +++ b/PepperDashEssentials/PepperDashEssentials.csproj @@ -123,6 +123,7 @@ + @@ -155,6 +156,7 @@ + diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Timers/CountdownTimer.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Timers/CountdownTimer.cs index 4878a206..aabd6436 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Timers/CountdownTimer.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Timers/CountdownTimer.cs @@ -1,138 +1,149 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; - -using PepperDash.Core; - -namespace PepperDash.Essentials.Core -{ - public class SecondsCountdownTimer: IKeyed - { - public event EventHandler HasStarted; - public event EventHandler HasFinished; - public event EventHandler WasCancelled; - - public string Key { get; private set; } - - public BoolFeedback IsRunningFeedback { get; private set; } - bool _IsRunning; - - public IntFeedback PercentFeedback { get; private set; } - public StringFeedback TimeRemainingFeedback { get; private set; } - - public bool CountsDown { get; set; } - - /// - /// The number of seconds to countdown - /// - public int SecondsToCount { get; set; } - - public DateTime StartTime { get; private set; } - public DateTime FinishTime { get; private set; } - - CTimer SecondTimer; - - /// - /// Constructor - /// - /// - public SecondsCountdownTimer(string key) - { - Key = key; - IsRunningFeedback = new BoolFeedback(() => _IsRunning); - - TimeRemainingFeedback = new StringFeedback(() => - { - // Need to handle up and down here. - - if (StartTime == null || FinishTime == null) - return ""; - var timeSpan = FinishTime - DateTime.Now; - return Math.Round(timeSpan.TotalSeconds).ToString(); - }); - - PercentFeedback = new IntFeedback(() => - { - if (StartTime == null || FinishTime == null) - return 0; - double percent = (FinishTime - DateTime.Now).TotalSeconds - / (FinishTime - StartTime).TotalSeconds - * 100; - return (int)percent; - }); - } - - /// - /// Starts the Timer - /// - public void Start() - { - if (_IsRunning) - return; - StartTime = DateTime.Now; - FinishTime = StartTime + TimeSpan.FromSeconds(SecondsToCount); - - if (SecondTimer != null) - SecondTimer.Stop(); - SecondTimer = new CTimer(SecondElapsedTimerCallback, null, 0, 1000); - _IsRunning = true; - IsRunningFeedback.FireUpdate(); - - var handler = HasStarted; - if (handler != null) - handler(this, new EventArgs()); - } - - /// - /// Restarts the timer - /// - public void Reset() - { - _IsRunning = false; - Start(); - } - - /// - /// Cancels the timer (without triggering it to finish) - /// - public void Cancel() - { - StopHelper(); - - var handler = WasCancelled; - if (handler != null) - handler(this, new EventArgs()); - } - - /// - /// Called upon expiration, or calling this will force timer to finish. - /// - public void Finish() - { - StopHelper(); - - var handler = HasFinished; - if (handler != null) - handler(this, new EventArgs()); - } - - void StopHelper() - { - if (SecondTimer != null) - SecondTimer.Stop(); - _IsRunning = false; - IsRunningFeedback.FireUpdate(); - } - - void SecondElapsedTimerCallback(object o) - { - PercentFeedback.FireUpdate(); - TimeRemainingFeedback.FireUpdate(); - - if (DateTime.Now >= FinishTime) - Finish(); - } - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +using PepperDash.Core; + +namespace PepperDash.Essentials.Core +{ + public class SecondsCountdownTimer: IKeyed + { + public event EventHandler HasStarted; + public event EventHandler HasFinished; + public event EventHandler WasCancelled; + + public string Key { get; private set; } + + public BoolFeedback IsRunningFeedback { get; private set; } + bool _IsRunning; + + public IntFeedback PercentFeedback { get; private set; } + public StringFeedback TimeRemainingFeedback { get; private set; } + + public bool CountsDown { get; set; } + + /// + /// The number of seconds to countdown + /// + public int SecondsToCount { get; set; } + + public DateTime StartTime { get; private set; } + public DateTime FinishTime { get; private set; } + + CTimer SecondTimer; + + /// + /// Constructor + /// + /// + public SecondsCountdownTimer(string key) + { + Key = key; + IsRunningFeedback = new BoolFeedback(() => _IsRunning); + + TimeRemainingFeedback = new StringFeedback(() => + { + // Need to handle up and down here. + + if (StartTime == null || FinishTime == null) + return ""; + var timeSpan = FinishTime - DateTime.Now; + + if (timeSpan.TotalSeconds < 60) + { + return Math.Round(timeSpan.TotalSeconds).ToString(); + } + else + { + Debug.Console(2, this, "timeSpan.Minutes == {0}, timeSpan.Seconds == {1}", timeSpan.Minutes, timeSpan.Seconds); + return String.Format("{0:D2}:{1:D2}", + timeSpan.Minutes, + timeSpan.Seconds); + } + }); + + PercentFeedback = new IntFeedback(() => + { + if (StartTime == null || FinishTime == null) + return 0; + double percent = (FinishTime - DateTime.Now).TotalSeconds + / (FinishTime - StartTime).TotalSeconds + * 100; + return (int)percent; + }); + } + + /// + /// Starts the Timer + /// + public void Start() + { + if (_IsRunning) + return; + StartTime = DateTime.Now; + FinishTime = StartTime + TimeSpan.FromSeconds(SecondsToCount); + + if (SecondTimer != null) + SecondTimer.Stop(); + SecondTimer = new CTimer(SecondElapsedTimerCallback, null, 0, 1000); + _IsRunning = true; + IsRunningFeedback.FireUpdate(); + + var handler = HasStarted; + if (handler != null) + handler(this, new EventArgs()); + } + + /// + /// Restarts the timer + /// + public void Reset() + { + _IsRunning = false; + Start(); + } + + /// + /// Cancels the timer (without triggering it to finish) + /// + public void Cancel() + { + StopHelper(); + + var handler = WasCancelled; + if (handler != null) + handler(this, new EventArgs()); + } + + /// + /// Called upon expiration, or calling this will force timer to finish. + /// + public void Finish() + { + StopHelper(); + + var handler = HasFinished; + if (handler != null) + handler(this, new EventArgs()); + } + + void StopHelper() + { + if (SecondTimer != null) + SecondTimer.Stop(); + _IsRunning = false; + IsRunningFeedback.FireUpdate(); + } + + void SecondElapsedTimerCallback(object o) + { + PercentFeedback.FireUpdate(); + TimeRemainingFeedback.FireUpdate(); + + if (DateTime.Now >= FinishTime) + Finish(); + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials DM/Essentials_DM/AirMedia/AirMediaController.cs b/essentials-framework/Essentials DM/Essentials_DM/AirMedia/AirMediaController.cs index 1624ec5f..28358a51 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/AirMedia/AirMediaController.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/AirMedia/AirMediaController.cs @@ -44,7 +44,10 @@ namespace PepperDash.Essentials.DM.AirMedia DeviceConfig = dc; - PropertiesConfig = props; + PropertiesConfig = props; + + InputPorts = new RoutingPortCollection(); + OutputPorts = new RoutingPortCollection(); InputPorts.Add(new RoutingInputPort(DmPortName.Osd, eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.None, new Action(SelectPinPointUxLandingPage), this)); diff --git a/essentials-framework/Essentials DM/Essentials_DM/Config/DeviceFactory.cs b/essentials-framework/Essentials DM/Essentials_DM/Config/DeviceFactory.cs index d3fda242..2417ce7e 100644 --- a/essentials-framework/Essentials DM/Essentials_DM/Config/DeviceFactory.cs +++ b/essentials-framework/Essentials DM/Essentials_DM/Config/DeviceFactory.cs @@ -30,14 +30,17 @@ namespace PepperDash.Essentials.DM if (typeName.StartsWith("am")) { - var props = JsonConvert.DeserializeObject(properties.ToString()); - AmX00 amDevice = null; - if (typeName == "am200") - amDevice = new Crestron.SimplSharpPro.DM.AirMedia.Am200(props.Control.IpIdInt, Global.ControlSystem); - else if(typeName == "am300") - amDevice = new Crestron.SimplSharpPro.DM.AirMedia.Am300(props.Control.IpIdInt, Global.ControlSystem); + if (typeName == "am200" || typeName == "am300") + { + var props = JsonConvert.DeserializeObject(properties.ToString()); + AmX00 amDevice = null; + if (typeName == "am200") + amDevice = new Crestron.SimplSharpPro.DM.AirMedia.Am200(props.Control.IpIdInt, Global.ControlSystem); + else if (typeName == "am300") + amDevice = new Crestron.SimplSharpPro.DM.AirMedia.Am300(props.Control.IpIdInt, Global.ControlSystem); - return new AirMediaController(key, name, amDevice, dc, props); + return new AirMediaController(key, name, amDevice, dc, props); + } } else if (typeName.StartsWith("dmmd8x") || typeName.StartsWith("dmmd16x") || typeName.StartsWith("dmmd32x")) { diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Occupancy/GlsOccupancySensorBaseController.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Occupancy/GlsOccupancySensorBaseController.cs index a735d9a8..380a090a 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Occupancy/GlsOccupancySensorBaseController.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Occupancy/GlsOccupancySensorBaseController.cs @@ -103,6 +103,18 @@ namespace PepperDash.Essentials.Devices.Common.Occupancy PirSensitivityInOccupiedStateFeedback.FireUpdate(); else if (args.EventId == GlsOccupancySensorBase.PirSensitivityInVacantStateFeedbackEventId) PirSensitivityInVacantStateFeedback.FireUpdate(); + } + + protected virtual void OccSensor_BaseEvent(Crestron.SimplSharpPro.GenericBase device, Crestron.SimplSharpPro.BaseEventArgs args) + { + Debug.Console(2, this, "GlsOccupancySensorChange EventId: {0}", args.EventId); + + if (args.EventId == Crestron.SimplSharpPro.GeneralIO.GlsOccupancySensorBase.RoomOccupiedFeedbackEventId + || args.EventId == Crestron.SimplSharpPro.GeneralIO.GlsOccupancySensorBase.RoomVacantFeedbackEventId) + { + Debug.Console(1, this, "Occupancy State: {0}", OccSensor.OccupancyDetectedFeedback.BoolValue); + RoomIsOccupiedFeedback.FireUpdate(); + } else if (args.EventId == GlsOccupancySensorBase.TimeoutFeedbackEventId) CurrentTimeoutFeedback.FireUpdate(); else if (args.EventId == GlsOccupancySensorBase.TimeoutLocalFeedbackEventId) @@ -117,18 +129,6 @@ namespace PepperDash.Essentials.Devices.Common.Occupancy ExternalPhotoSensorValue.FireUpdate(); } - void OccSensor_BaseEvent(Crestron.SimplSharpPro.GenericBase device, Crestron.SimplSharpPro.BaseEventArgs args) - { - Debug.Console(2, this, "GlsOccupancySensorChange EventId: {0}", args.EventId); - - if (args.EventId == Crestron.SimplSharpPro.GeneralIO.GlsOccupancySensorBase.RoomOccupiedFeedbackEventId - || args.EventId == Crestron.SimplSharpPro.GeneralIO.GlsOccupancySensorBase.RoomVacantFeedbackEventId) - { - Debug.Console(1, this, "Occupancy State: {0}", OccSensor.OccupancyDetectedFeedback.BoolValue); - RoomIsOccupiedFeedback.FireUpdate(); - } - } - public void SetTestMode(bool mode) { InTestMode = mode; diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Occupancy/GlsOdtOccupancySensorController.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Occupancy/GlsOdtOccupancySensorController.cs index 7f034fbe..16e449bf 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/Occupancy/GlsOdtOccupancySensorController.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/Occupancy/GlsOdtOccupancySensorController.cs @@ -1,65 +1,65 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro.GeneralIO; - -using PepperDash.Core; -using PepperDash.Essentials.Core; - -namespace PepperDash.Essentials.Devices.Common.Occupancy -{ - public class GlsOdtOccupancySensorController : GlsOccupancySensorBaseController - { - public new GlsOdtCCn OccSensor { get; private set; } - - public BoolFeedback OrWhenVacatedFeedback { get; private set; } - - public BoolFeedback AndWhenVacatedFeedback { get; private set; } - - public BoolFeedback UltrasonicAEnabledFeedback { get; private set; } - - public BoolFeedback UltrasonicBEnabledFeedback { get; private set; } - - public IntFeedback UltrasonicSensitivityInVacantStateFeedback { get; private set; } - +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro.GeneralIO; + +using PepperDash.Core; +using PepperDash.Essentials.Core; + +namespace PepperDash.Essentials.Devices.Common.Occupancy +{ + public class GlsOdtOccupancySensorController : GlsOccupancySensorBaseController + { + public new GlsOdtCCn OccSensor { get; private set; } + + public BoolFeedback OrWhenVacatedFeedback { get; private set; } + + public BoolFeedback AndWhenVacatedFeedback { get; private set; } + + public BoolFeedback UltrasonicAEnabledFeedback { get; private set; } + + public BoolFeedback UltrasonicBEnabledFeedback { get; private set; } + + public IntFeedback UltrasonicSensitivityInVacantStateFeedback { get; private set; } + public IntFeedback UltrasonicSensitivityInOccupiedStateFeedback { get; private set; } public BoolFeedback RawOccupancyPirFeedback { get; private set; } - public BoolFeedback RawOccupancyUsFeedback { get; private set; } - - - public GlsOdtOccupancySensorController(string key, string name, GlsOdtCCn sensor) - : base(key, name, sensor) - { - OccSensor = sensor; - - AndWhenVacatedFeedback = new BoolFeedback(() => OccSensor.AndWhenVacatedFeedback.BoolValue); - - OrWhenVacatedFeedback = new BoolFeedback(() => OccSensor.OrWhenVacatedFeedback.BoolValue); - - UltrasonicAEnabledFeedback = new BoolFeedback(() => OccSensor.UsAEnabledFeedback.BoolValue); - + public BoolFeedback RawOccupancyUsFeedback { get; private set; } + + + public GlsOdtOccupancySensorController(string key, string name, GlsOdtCCn sensor) + : base(key, name, sensor) + { + OccSensor = sensor; + + AndWhenVacatedFeedback = new BoolFeedback(() => OccSensor.AndWhenVacatedFeedback.BoolValue); + + OrWhenVacatedFeedback = new BoolFeedback(() => OccSensor.OrWhenVacatedFeedback.BoolValue); + + UltrasonicAEnabledFeedback = new BoolFeedback(() => OccSensor.UsAEnabledFeedback.BoolValue); + UltrasonicBEnabledFeedback = new BoolFeedback(() => OccSensor.UsBEnabledFeedback.BoolValue); RawOccupancyPirFeedback = new BoolFeedback(() => OccSensor.RawOccupancyPirFeedback.BoolValue); - RawOccupancyUsFeedback = new BoolFeedback(() => OccSensor.RawOccupancyUsFeedback.BoolValue); - - UltrasonicSensitivityInVacantStateFeedback = new IntFeedback(() => OccSensor.UsSensitivityInVacantStateFeedback.UShortValue); - + RawOccupancyUsFeedback = new BoolFeedback(() => OccSensor.RawOccupancyUsFeedback.BoolValue); + + UltrasonicSensitivityInVacantStateFeedback = new IntFeedback(() => OccSensor.UsSensitivityInVacantStateFeedback.UShortValue); + UltrasonicSensitivityInOccupiedStateFeedback = new IntFeedback(() => OccSensor.UsSensitivityInOccupiedStateFeedback.UShortValue); - } - - /// - /// Overrides the base class event delegate to fire feedbacks for event IDs that pertain to this extended class. - /// Then calls the base delegate method to ensure any common event IDs are captured. - /// - /// - /// - protected override void OccSensor_GlsOccupancySensorChange(GlsOccupancySensorBase device, GlsOccupancySensorChangeEventArgs args) + } + + /// + /// Overrides the base class event delegate to fire feedbacks for event IDs that pertain to this extended class. + /// Then calls the base delegate method to ensure any common event IDs are captured. + /// + /// + /// + protected override void OccSensor_GlsOccupancySensorChange(GlsOccupancySensorBase device, GlsOccupancySensorChangeEventArgs args) { if (args.EventId == GlsOccupancySensorBase.AndWhenVacatedFeedbackEventId) AndWhenVacatedFeedback.FireUpdate(); @@ -69,91 +69,103 @@ namespace PepperDash.Essentials.Devices.Common.Occupancy UltrasonicAEnabledFeedback.FireUpdate(); else if (args.EventId == GlsOccupancySensorBase.UsBEnabledFeedbackEventId) UltrasonicBEnabledFeedback.FireUpdate(); - else if (args.EventId == GlsOccupancySensorBase.RawOccupancyPirFeedbackEventId) - RawOccupancyPirFeedback.FireUpdate(); - else if (args.EventId == GlsOccupancySensorBase.RawOccupancyUsFeedbackEventId) - RawOccupancyUsFeedback.FireUpdate(); else if (args.EventId == GlsOccupancySensorBase.UsSensitivityInOccupiedStateFeedbackEventId) UltrasonicSensitivityInOccupiedStateFeedback.FireUpdate(); else if (args.EventId == GlsOccupancySensorBase.UsSensitivityInVacantStateFeedbackEventId) UltrasonicSensitivityInVacantStateFeedback.FireUpdate(); - - base.OccSensor_GlsOccupancySensorChange(device, args); - } - - /// - /// Sets the OrWhenVacated state - /// - /// - public void SetOrWhenVacatedState(bool state) - { - OccSensor.OrWhenVacated.BoolValue = state; - } - - /// - /// Sets the AndWhenVacated state - /// - /// - public void SetAndWhenVacatedState(bool state) - { - OccSensor.AndWhenVacated.BoolValue = state; - } - - /// - /// Enables or disables the Ultrasonic A sensor - /// - /// - public void SetUsAEnable(bool state) - { - if (state) - { - OccSensor.EnableUsA.BoolValue = state; - OccSensor.DisableUsA.BoolValue = !state; - } - else - { - OccSensor.EnableUsA.BoolValue = state; - OccSensor.DisableUsA.BoolValue = !state; - } - } - - - /// - /// Enables or disables the Ultrasonic B sensor - /// - /// - public void SetUsBEnable(bool state) - { - if (state) - { - OccSensor.EnableUsB.BoolValue = state; - OccSensor.DisableUsB.BoolValue = !state; - } - else - { - OccSensor.EnableUsB.BoolValue = state; - OccSensor.DisableUsB.BoolValue = !state; - } - } - - public void IncrementUsSensitivityInOccupiedState(bool pressRelease) - { - OccSensor.IncrementUsSensitivityInOccupiedState.BoolValue = pressRelease; - } - - public void DecrementUsSensitivityInOccupiedState(bool pressRelease) - { - OccSensor.DecrementUsSensitivityInOccupiedState.BoolValue = pressRelease; - } - - public void IncrementUsSensitivityInVacantState(bool pressRelease) - { - OccSensor.IncrementUsSensitivityInVacantState.BoolValue = pressRelease; - } - - public void DecrementUsSensitivityInVacantState(bool pressRelease) - { - OccSensor.DecrementUsSensitivityInVacantState.BoolValue = pressRelease; - } - } + + base.OccSensor_GlsOccupancySensorChange(device, args); + } + + /// + /// Overrides the base class event delegate to fire feedbacks for event IDs that pertain to this extended class. + /// Then calls the base delegate method to ensure any common event IDs are captured. + /// + /// + /// + protected override void OccSensor_BaseEvent(Crestron.SimplSharpPro.GenericBase device, Crestron.SimplSharpPro.BaseEventArgs args) + { + if (args.EventId == GlsOccupancySensorBase.RawOccupancyPirFeedbackEventId) + RawOccupancyPirFeedback.FireUpdate(); + else if (args.EventId == GlsOccupancySensorBase.RawOccupancyUsFeedbackEventId) + RawOccupancyUsFeedback.FireUpdate(); + + base.OccSensor_BaseEvent(device, args); + } + + /// + /// Sets the OrWhenVacated state + /// + /// + public void SetOrWhenVacatedState(bool state) + { + OccSensor.OrWhenVacated.BoolValue = state; + } + + /// + /// Sets the AndWhenVacated state + /// + /// + public void SetAndWhenVacatedState(bool state) + { + OccSensor.AndWhenVacated.BoolValue = state; + } + + /// + /// Enables or disables the Ultrasonic A sensor + /// + /// + public void SetUsAEnable(bool state) + { + if (state) + { + OccSensor.EnableUsA.BoolValue = state; + OccSensor.DisableUsA.BoolValue = !state; + } + else + { + OccSensor.EnableUsA.BoolValue = state; + OccSensor.DisableUsA.BoolValue = !state; + } + } + + + /// + /// Enables or disables the Ultrasonic B sensor + /// + /// + public void SetUsBEnable(bool state) + { + if (state) + { + OccSensor.EnableUsB.BoolValue = state; + OccSensor.DisableUsB.BoolValue = !state; + } + else + { + OccSensor.EnableUsB.BoolValue = state; + OccSensor.DisableUsB.BoolValue = !state; + } + } + + public void IncrementUsSensitivityInOccupiedState(bool pressRelease) + { + OccSensor.IncrementUsSensitivityInOccupiedState.BoolValue = pressRelease; + } + + public void DecrementUsSensitivityInOccupiedState(bool pressRelease) + { + OccSensor.DecrementUsSensitivityInOccupiedState.BoolValue = pressRelease; + } + + public void IncrementUsSensitivityInVacantState(bool pressRelease) + { + OccSensor.IncrementUsSensitivityInVacantState.BoolValue = pressRelease; + } + + public void DecrementUsSensitivityInVacantState(bool pressRelease) + { + OccSensor.DecrementUsSensitivityInVacantState.BoolValue = pressRelease; + } + } } \ No newline at end of file diff --git a/essentials-framework/Essentials Devices Common/Essentials Devices Common/SetTopBox/IRSetTopBoxBase.cs b/essentials-framework/Essentials Devices Common/Essentials Devices Common/SetTopBox/IRSetTopBoxBase.cs index 5af965fe..78e2ac22 100644 --- a/essentials-framework/Essentials Devices Common/Essentials Devices Common/SetTopBox/IRSetTopBoxBase.cs +++ b/essentials-framework/Essentials Devices Common/Essentials Devices Common/SetTopBox/IRSetTopBoxBase.cs @@ -1,343 +1,371 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; - -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Presets; -using PepperDash.Essentials.Core.Routing; - -namespace PepperDash.Essentials.Devices.Common -{ - public class IRSetTopBoxBase : Device, ISetTopBoxControls, IUiDisplayInfo, IRoutingOutputs, IUsageTracking - { - public IrOutputPortController IrPort { get; private set; } - - public uint DisplayUiType { get { return DisplayUiConstants.TypeDirecTv; } } - - - public bool HasPresets { get; set; } - public bool HasDvr { get; set; } - public bool HasDpad { get; set; } - public bool HasNumeric { get; set; } - - public DevicePresetsModel PresetsModel { get; private set; } - - public IRSetTopBoxBase(string key, string name, IrOutputPortController portCont, - SetTopBoxPropertiesConfig props) - : base(key, name) - { - IrPort = portCont; - DeviceManager.AddDevice(portCont); - - HasPresets = props.HasPresets; - HasDvr = props.HasDvr; - HasDpad = props.HasDpad; - HasNumeric = props.HasNumeric; - - HasKeypadAccessoryButton1 = true; - KeypadAccessoryButton1Command = "Dash"; - KeypadAccessoryButton1Label = "-"; - - HasKeypadAccessoryButton2 = true; - KeypadAccessoryButton2Command = "NumericEnter"; - KeypadAccessoryButton2Label = "Enter"; - - AnyVideoOut = new RoutingOutputPort(RoutingPortNames.AnyVideoOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, - eRoutingPortConnectionType.Hdmi, null, this); - AnyAudioOut = new RoutingOutputPort(RoutingPortNames.AnyAudioOut, eRoutingSignalType.Audio, - eRoutingPortConnectionType.DigitalAudio, null, this); - OutputPorts = new RoutingPortCollection { AnyVideoOut, AnyAudioOut }; - - } - - public void LoadPresets(string filePath) - { - PresetsModel = new DevicePresetsModel(Key + "-presets", this, filePath); - DeviceManager.AddDevice(PresetsModel); - } - - - #region ISetTopBoxControls Members - - public void DvrList(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_DVR, pressRelease); - } - - public void Replay(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_REPLAY, pressRelease); - } - - #endregion - - #region IDPad Members - - public void Up(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_UP_ARROW, pressRelease); - } - - public void Down(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_DN_ARROW, pressRelease); - } - - public void Left(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_LEFT_ARROW, pressRelease); - } - - public void Right(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_RIGHT_ARROW, pressRelease); - } - - public void Select(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_ENTER, pressRelease); - } - - public void Menu(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_MENU, pressRelease); - } - - public void Exit(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_EXIT, pressRelease); - } - - #endregion - - #region INumericKeypad Members - - public void Digit0(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_0, pressRelease); - } - - public void Digit1(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_1, pressRelease); - } - - public void Digit2(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_2, pressRelease); - } - - public void Digit3(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_3, pressRelease); - } - - public void Digit4(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_4, pressRelease); - } - - public void Digit5(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_5, pressRelease); - } - - public void Digit6(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_6, pressRelease); - } - - public void Digit7(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_7, pressRelease); - } - - public void Digit8(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_8, pressRelease); - } - - public void Digit9(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_9, pressRelease); - } - - /// - /// Defaults to true - /// - public bool HasKeypadAccessoryButton1 { get; set; } - - /// - /// Defaults to "-" - /// - public string KeypadAccessoryButton1Label { get; set; } - - - /// - /// Defaults to "Dash" - /// - public string KeypadAccessoryButton1Command { get; set; } - - public void KeypadAccessoryButton1(bool pressRelease) - { - IrPort.PressRelease(KeypadAccessoryButton1Command, pressRelease); - } - - /// - /// Defaults to true - /// - public bool HasKeypadAccessoryButton2 { get; set; } - - /// - /// Defaults to "Enter" - /// - public string KeypadAccessoryButton2Label { get; set; } - - - /// - /// Defaults to "Enter" - /// - public string KeypadAccessoryButton2Command { get; set; } - - public void KeypadAccessoryButton2(bool pressRelease) - { - IrPort.PressRelease(KeypadAccessoryButton2Command, pressRelease); - } - - #endregion - - #region ISetTopBoxNumericKeypad Members - - /// - /// Corresponds to "dash" IR command - /// - public void Dash(bool pressRelease) - { - IrPort.PressRelease("dash", pressRelease); - } - - /// - /// Corresponds to "numericEnter" IR command - /// - public void KeypadEnter(bool pressRelease) - { - IrPort.PressRelease("numericEnter", pressRelease); - } - - #endregion - - #region IChannelFunctions Members - - public void ChannelUp(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_CH_PLUS, pressRelease); - } - - public void ChannelDown(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_CH_MINUS, pressRelease); - } - - public void LastChannel(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_LAST, pressRelease); - } - - public void Guide(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_GUIDE, pressRelease); - } - - public void Info(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_INFO, pressRelease); - } - - #endregion - - #region IColorFunctions Members - - public void Red(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_RED, pressRelease); - } - - public void Green(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_GREEN, pressRelease); - } - - public void Yellow(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_YELLOW, pressRelease); - } - - public void Blue(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_BLUE, pressRelease); - } - - #endregion - - #region IRoutingOutputs Members - - public RoutingOutputPort AnyVideoOut { get; private set; } - public RoutingOutputPort AnyAudioOut { get; private set; } - public RoutingPortCollection OutputPorts { get; private set; } - - #endregion - - #region ITransport Members - - public void ChapMinus(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_REPLAY, pressRelease); - } - - public void ChapPlus(bool pressRelease) - { - } - - public void FFwd(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_FSCAN, pressRelease); - } - - public void Pause(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_RSCAN, pressRelease); - } - - public void Play(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_PLAY, pressRelease); - } - - public void Record(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_RECORD, pressRelease); - } - - public void Rewind(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_RSCAN, pressRelease); - } - - public void Stop(bool pressRelease) - { - IrPort.PressRelease(IROutputStandardCommands.IROut_STOP, pressRelease); - } - - #endregion - - #region IUsageTracking Members - - public UsageTracking UsageTracker { get; set; } - - #endregion - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro; + +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Presets; +using PepperDash.Essentials.Core.Routing; + +namespace PepperDash.Essentials.Devices.Common +{ + public class IRSetTopBoxBase : Device, ISetTopBoxControls, IUiDisplayInfo, IRoutingOutputs, IUsageTracking, IPower + { + public IrOutputPortController IrPort { get; private set; } + + public uint DisplayUiType { get { return DisplayUiConstants.TypeDirecTv; } } + + + public bool HasPresets { get; set; } + public bool HasDvr { get; set; } + public bool HasDpad { get; set; } + public bool HasNumeric { get; set; } + + public DevicePresetsModel PresetsModel { get; private set; } + + public IRSetTopBoxBase(string key, string name, IrOutputPortController portCont, + SetTopBoxPropertiesConfig props) + : base(key, name) + { + IrPort = portCont; + DeviceManager.AddDevice(portCont); + + HasPresets = props.HasPresets; + HasDvr = props.HasDvr; + HasDpad = props.HasDpad; + HasNumeric = props.HasNumeric; + + HasKeypadAccessoryButton1 = true; + KeypadAccessoryButton1Command = "Dash"; + KeypadAccessoryButton1Label = "-"; + + HasKeypadAccessoryButton2 = true; + KeypadAccessoryButton2Command = "NumericEnter"; + KeypadAccessoryButton2Label = "Enter"; + + AnyVideoOut = new RoutingOutputPort(RoutingPortNames.AnyVideoOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, + eRoutingPortConnectionType.Hdmi, null, this); + AnyAudioOut = new RoutingOutputPort(RoutingPortNames.AnyAudioOut, eRoutingSignalType.Audio, + eRoutingPortConnectionType.DigitalAudio, null, this); + OutputPorts = new RoutingPortCollection { AnyVideoOut, AnyAudioOut }; + + } + + public void LoadPresets(string filePath) + { + PresetsModel = new DevicePresetsModel(Key + "-presets", this, filePath); + DeviceManager.AddDevice(PresetsModel); + } + + + #region ISetTopBoxControls Members + + public void DvrList(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_DVR, pressRelease); + } + + public void Replay(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_REPLAY, pressRelease); + } + + #endregion + + #region IDPad Members + + public void Up(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_UP_ARROW, pressRelease); + } + + public void Down(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_DN_ARROW, pressRelease); + } + + public void Left(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_LEFT_ARROW, pressRelease); + } + + public void Right(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_RIGHT_ARROW, pressRelease); + } + + public void Select(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_ENTER, pressRelease); + } + + public void Menu(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_MENU, pressRelease); + } + + public void Exit(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_EXIT, pressRelease); + } + + #endregion + + #region INumericKeypad Members + + public void Digit0(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_0, pressRelease); + } + + public void Digit1(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_1, pressRelease); + } + + public void Digit2(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_2, pressRelease); + } + + public void Digit3(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_3, pressRelease); + } + + public void Digit4(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_4, pressRelease); + } + + public void Digit5(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_5, pressRelease); + } + + public void Digit6(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_6, pressRelease); + } + + public void Digit7(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_7, pressRelease); + } + + public void Digit8(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_8, pressRelease); + } + + public void Digit9(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_9, pressRelease); + } + + /// + /// Defaults to true + /// + public bool HasKeypadAccessoryButton1 { get; set; } + + /// + /// Defaults to "-" + /// + public string KeypadAccessoryButton1Label { get; set; } + + + /// + /// Defaults to "Dash" + /// + public string KeypadAccessoryButton1Command { get; set; } + + public void KeypadAccessoryButton1(bool pressRelease) + { + IrPort.PressRelease(KeypadAccessoryButton1Command, pressRelease); + } + + /// + /// Defaults to true + /// + public bool HasKeypadAccessoryButton2 { get; set; } + + /// + /// Defaults to "Enter" + /// + public string KeypadAccessoryButton2Label { get; set; } + + + /// + /// Defaults to "Enter" + /// + public string KeypadAccessoryButton2Command { get; set; } + + public void KeypadAccessoryButton2(bool pressRelease) + { + IrPort.PressRelease(KeypadAccessoryButton2Command, pressRelease); + } + + #endregion + + #region ISetTopBoxNumericKeypad Members + + /// + /// Corresponds to "dash" IR command + /// + public void Dash(bool pressRelease) + { + IrPort.PressRelease("dash", pressRelease); + } + + /// + /// Corresponds to "numericEnter" IR command + /// + public void KeypadEnter(bool pressRelease) + { + IrPort.PressRelease("numericEnter", pressRelease); + } + + #endregion + + #region IChannelFunctions Members + + public void ChannelUp(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_CH_PLUS, pressRelease); + } + + public void ChannelDown(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_CH_MINUS, pressRelease); + } + + public void LastChannel(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_LAST, pressRelease); + } + + public void Guide(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_GUIDE, pressRelease); + } + + public void Info(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_INFO, pressRelease); + } + + #endregion + + #region IColorFunctions Members + + public void Red(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_RED, pressRelease); + } + + public void Green(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_GREEN, pressRelease); + } + + public void Yellow(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_YELLOW, pressRelease); + } + + public void Blue(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_BLUE, pressRelease); + } + + #endregion + + #region IRoutingOutputs Members + + public RoutingOutputPort AnyVideoOut { get; private set; } + public RoutingOutputPort AnyAudioOut { get; private set; } + public RoutingPortCollection OutputPorts { get; private set; } + + #endregion + + #region ITransport Members + + public void ChapMinus(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_REPLAY, pressRelease); + } + + public void ChapPlus(bool pressRelease) + { + } + + public void FFwd(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_FSCAN, pressRelease); + } + + public void Pause(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_RSCAN, pressRelease); + } + + public void Play(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_PLAY, pressRelease); + } + + public void Record(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_RECORD, pressRelease); + } + + public void Rewind(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_RSCAN, pressRelease); + } + + public void Stop(bool pressRelease) + { + IrPort.PressRelease(IROutputStandardCommands.IROut_STOP, pressRelease); + } + + #endregion + + #region IUsageTracking Members + + public UsageTracking UsageTracker { get; set; } + + #endregion + + #region IPower Members + + public void PowerOn() + { + IrPort.PressRelease(IROutputStandardCommands.IROut_POWER_ON, true); + IrPort.PressRelease(IROutputStandardCommands.IROut_POWER_ON, false); + + } + + public void PowerOff() + { + IrPort.PressRelease(IROutputStandardCommands.IROut_POWER_OFF, true); + IrPort.PressRelease(IROutputStandardCommands.IROut_POWER_OFF, false); + + } + + public void PowerToggle() + { + throw new NotImplementedException(); + } + + public BoolFeedback PowerIsOnFeedback + { + get { throw new NotImplementedException(); } + } + + #endregion + } } \ No newline at end of file