From cae86d1943111c0304530f750a24edd5bd7d0aa4 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Fri, 6 Oct 2017 12:53:34 -0600 Subject: [PATCH] Tied in Room Occupancy Timer to Shutdown timer in EssentialsRoomBase --- .../Essentials Devices Common.csproj | 8 -- .../VideoCodec/CiscoCodec/CiscoCodec.cs | 3 - .../Room/Types/EssentialsHuddleSpaceRoom.cs | 2 +- .../Room/Types/EssentialsHuddleVtc1Room.cs | 4 +- .../Room/Types/EssentialsPresentationRoom.cs | 4 +- .../Room/Types/EssentialsRoomBase.cs | 103 +++++++++++++++--- .../EssentialsHuddlePanelAvFunctionsDriver.cs | 4 +- ...entialsHuddleVtc1PanelAvFunctionsDriver.cs | 10 +- 8 files changed, 98 insertions(+), 40 deletions(-) diff --git a/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj b/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj index ec42d9b5..cc663705 100644 --- a/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj +++ b/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj @@ -46,14 +46,6 @@ off - - False - References\Cisco One Button To Push.dll - - - False - References\Cisco SX80 Corporate Phone Book.dll - False ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DeviceSupport.dll diff --git a/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoCodec.cs b/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoCodec.cs index bd4c5505..77029ad6 100644 --- a/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoCodec.cs +++ b/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoCodec.cs @@ -6,10 +6,7 @@ using Crestron.SimplSharp; using Crestron.SimplSharp.Net.Https; using Crestron.SimplSharp.CrestronXml; using Crestron.SimplSharp.CrestronXml.Serialization; -//using Crestron.SimplSharpPro; using Newtonsoft.Json; -using Cisco_One_Button_To_Push; -using Cisco_SX80_Corporate_Phone_Book; using PepperDash.Core; using PepperDash.Essentials.Core; diff --git a/Essentials/PepperDashEssentials/Room/Types/EssentialsHuddleSpaceRoom.cs b/Essentials/PepperDashEssentials/Room/Types/EssentialsHuddleSpaceRoom.cs index 98662675..32fb01f8 100644 --- a/Essentials/PepperDashEssentials/Room/Types/EssentialsHuddleSpaceRoom.cs +++ b/Essentials/PepperDashEssentials/Room/Types/EssentialsHuddleSpaceRoom.cs @@ -200,7 +200,7 @@ namespace PepperDash.Essentials /// /// /// - public override void Shutdown() + protected override void EndShutdown() { RunRouteAction("roomOff"); } diff --git a/Essentials/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs b/Essentials/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs index 3ffad5ca..ebd0f326 100644 --- a/Essentials/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs +++ b/Essentials/PepperDashEssentials/Room/Types/EssentialsHuddleVtc1Room.cs @@ -260,8 +260,8 @@ namespace PepperDash.Essentials /// /// - /// - public override void Shutdown() + /// + protected override void EndShutdown() { RunRouteAction("roomOff"); VideoCodec.EndAllCalls(); diff --git a/Essentials/PepperDashEssentials/Room/Types/EssentialsPresentationRoom.cs b/Essentials/PepperDashEssentials/Room/Types/EssentialsPresentationRoom.cs index adb35c8f..c784f91a 100644 --- a/Essentials/PepperDashEssentials/Room/Types/EssentialsPresentationRoom.cs +++ b/Essentials/PepperDashEssentials/Room/Types/EssentialsPresentationRoom.cs @@ -261,8 +261,8 @@ namespace PepperDash.Essentials /// /// - /// - public override void Shutdown() + /// + protected override void EndShutdown() { RunRouteAction("roomoff"); } diff --git a/Essentials/PepperDashEssentials/Room/Types/EssentialsRoomBase.cs b/Essentials/PepperDashEssentials/Room/Types/EssentialsRoomBase.cs index 23eeed2b..58bcf5a7 100644 --- a/Essentials/PepperDashEssentials/Room/Types/EssentialsRoomBase.cs +++ b/Essentials/PepperDashEssentials/Room/Types/EssentialsRoomBase.cs @@ -45,15 +45,25 @@ namespace PepperDash.Essentials /// public int ShutdownPromptSeconds { get; set; } public int ShutdownVacancySeconds { get; set; } - public ShutdownType ShutdownType { get; private set; } + public eShutdownType ShutdownType { get; private set; } public PepperDash.Essentials.Room.EssentialsRoomEmergencyBase Emergency { get; set; } public string LogoUrl { get; set; } - protected CTimer RoomVacancyShutdownTimer; + protected SecondsCountdownTimer RoomVacancyShutdownTimer { get; private set; } - protected long RoomVacancyShutdownTimeout = 1800000; // 30 minutes by default + public eVacancyMode VacancyMode { get; private set; } + + /// + /// Seconds after vacancy prompt is displayed until shutdown + /// + protected int RoomVacancyShutdownSeconds; + + /// + /// Seconds after vacancy detected until prompt is displayed + /// + protected int RoomVacancyShutdownPromptSeconds; /// /// @@ -67,44 +77,96 @@ namespace PepperDash.Essentials /// public EssentialsRoomBase(string key, string name) : base(key, name) { + // Setup the ShutdownPromptTimer ShutdownPromptTimer = new SecondsCountdownTimer(Key + "-offTimer"); ShutdownPromptTimer.IsRunningFeedback.OutputChange += (o, a) => { if (!ShutdownPromptTimer.IsRunningFeedback.BoolValue) - ShutdownType = ShutdownType.None; - }; + ShutdownType = eShutdownType.None; + }; ShutdownPromptTimer.HasFinished += (o, a) => Shutdown(); // Shutdown is triggered ShutdownPromptSeconds = 60; ShutdownVacancySeconds = 120; - ShutdownType = ShutdownType.None; + ShutdownType = eShutdownType.None; + + RoomVacancyShutdownTimer = new SecondsCountdownTimer(Key + "-vacancyOffTimer"); + //RoomVacancyShutdownTimer.IsRunningFeedback.OutputChange += (o, a) => + //{ + // if (!RoomVacancyShutdownTimer.IsRunningFeedback.BoolValue) + // ShutdownType = ShutdownType.Vacancy; + //}; + RoomVacancyShutdownTimer.HasFinished += new EventHandler(RoomVacancyShutdownPromptTimer_HasFinished); // Shutdown is triggered + + RoomVacancyShutdownPromptSeconds = 1500; // 25 min to prompt warning + RoomVacancyShutdownSeconds = 240; // 4 min after prompt will trigger shutdown prompt + VacancyMode = eVacancyMode.None; OnFeedback = new BoolFeedback(OnFeedbackFunc); IsWarmingUpFeedback = new BoolFeedback(IsWarmingFeedbackFunc); IsCoolingDownFeedback = new BoolFeedback(IsCoolingFeedbackFunc); + } + + void RoomVacancyShutdownPromptTimer_HasFinished(object sender, EventArgs e) + { + switch (VacancyMode) + { + case eVacancyMode.None: + StartRoomVacancyTimer(eVacancyMode.InInitialVacancy); + break; + case eVacancyMode.InInitialVacancy: + StartRoomVacancyTimer(eVacancyMode.InShutdownWarning); + break; + case eVacancyMode.InShutdownWarning: + StartShutdown(eShutdownType.Vacancy); + break; + default: + break; + } } /// /// /// /// - public void StartShutdown(ShutdownType type) + public void StartShutdown(eShutdownType type) { // Check for shutdowns running. Manual should override other shutdowns - if (type == ShutdownType.Manual) + if (type == eShutdownType.Manual) ShutdownPromptTimer.SecondsToCount = ShutdownPromptSeconds; - else if (type == ShutdownType.Vacancy) + else if (type == eShutdownType.Vacancy) ShutdownPromptTimer.SecondsToCount = ShutdownVacancySeconds; ShutdownType = type; ShutdownPromptTimer.Start(); + } + + public void StartRoomVacancyTimer(eVacancyMode mode) + { + if (mode == eVacancyMode.None) + RoomVacancyShutdownTimer.SecondsToCount = RoomVacancyShutdownPromptSeconds; + else if (mode == eVacancyMode.InInitialVacancy) + RoomVacancyShutdownTimer.SecondsToCount = RoomVacancyShutdownSeconds; + VacancyMode = mode; + RoomVacancyShutdownTimer.Start(); } /// - /// + /// Resets the vacancy mode and shutsdwon the room /// - public abstract void Shutdown(); + public void Shutdown() + { + VacancyMode = eVacancyMode.None; + EndShutdown(); + } + + /// + /// This method is for the derived class to define it's specific shutdown + /// requirements but should not be called directly. It is called by Shutdown() + /// + protected abstract void EndShutdown(); + /// /// Override this to implement a default volume level(s) method @@ -127,13 +189,13 @@ namespace PepperDash.Essentials if ((sender as IOccupancyStatusProvider).RoomIsOccupiedFeedback.BoolValue == false) { // Trigger the timer when the room is vacant - RoomVacancyShutdownTimer = new CTimer(RoomVacatedForTimeoutPeriod, RoomVacancyShutdownTimeout); + StartRoomVacancyTimer(eVacancyMode.InInitialVacancy); } else { // Reset the timer when the room is occupied - if(RoomVacancyShutdownTimer != null) - RoomVacancyShutdownTimer.Reset(RoomVacancyShutdownTimeout); + if(RoomVacancyShutdownTimer.IsRunningFeedback.BoolValue) + RoomVacancyShutdownTimer.Cancel(); } } @@ -147,18 +209,25 @@ namespace PepperDash.Essentials /// /// To describe the various ways a room may be shutting down /// - public enum ShutdownType + public enum eShutdownType { - None, + None = 0, External, Manual, Vacancy + } + + public enum eVacancyMode + { + None = 0, + InInitialVacancy, + InShutdownWarning } /// /// /// - public enum WarmingCoolingMode + public enum eWarmingCoolingMode { None, Warming, diff --git a/Essentials/PepperDashEssentials/UIDrivers/Essentials/EssentialsHuddlePanelAvFunctionsDriver.cs b/Essentials/PepperDashEssentials/UIDrivers/Essentials/EssentialsHuddlePanelAvFunctionsDriver.cs index 1e8a67be..87fac38d 100644 --- a/Essentials/PepperDashEssentials/UIDrivers/Essentials/EssentialsHuddlePanelAvFunctionsDriver.cs +++ b/Essentials/PepperDashEssentials/UIDrivers/Essentials/EssentialsHuddlePanelAvFunctionsDriver.cs @@ -474,7 +474,7 @@ namespace PepperDash.Essentials || CurrentRoom.ShutdownPromptTimer.IsRunningFeedback.BoolValue) return; - CurrentRoom.StartShutdown(ShutdownType.Manual); + CurrentRoom.StartShutdown(eShutdownType.Manual); } /// @@ -489,7 +489,7 @@ namespace PepperDash.Essentials EndMeetingButtonSig.BoolValue = true; ShareButtonSig.BoolValue = false; - if (CurrentRoom.ShutdownType == ShutdownType.Manual) + if (CurrentRoom.ShutdownType == eShutdownType.Manual) { PowerDownModal = new ModalDialog(TriList); var message = string.Format("Meeting will end in {0} seconds", CurrentRoom.ShutdownPromptSeconds); diff --git a/Essentials/PepperDashEssentials/UIDrivers/EssentialsHuddleVTC/EssentialsHuddleVtc1PanelAvFunctionsDriver.cs b/Essentials/PepperDashEssentials/UIDrivers/EssentialsHuddleVTC/EssentialsHuddleVtc1PanelAvFunctionsDriver.cs index 2dbf89a7..f13d1413 100644 --- a/Essentials/PepperDashEssentials/UIDrivers/EssentialsHuddleVTC/EssentialsHuddleVtc1PanelAvFunctionsDriver.cs +++ b/Essentials/PepperDashEssentials/UIDrivers/EssentialsHuddleVTC/EssentialsHuddleVtc1PanelAvFunctionsDriver.cs @@ -473,10 +473,10 @@ namespace PepperDash.Essentials void SetActivityFooterFeedbacks() { CallButtonSig.BoolValue = CurrentMode == UiDisplayMode.Call - && CurrentRoom.ShutdownType == ShutdownType.None; + && CurrentRoom.ShutdownType == eShutdownType.None; ShareButtonSig.BoolValue = CurrentMode == UiDisplayMode.Presentation - && CurrentRoom.ShutdownType == ShutdownType.None; - EndMeetingButtonSig.BoolValue = CurrentRoom.ShutdownType != ShutdownType.None; + && CurrentRoom.ShutdownType == eShutdownType.None; + EndMeetingButtonSig.BoolValue = CurrentRoom.ShutdownType != eShutdownType.None; } /// @@ -600,7 +600,7 @@ namespace PepperDash.Essentials || CurrentRoom.ShutdownPromptTimer.IsRunningFeedback.BoolValue) return; - CurrentRoom.StartShutdown(ShutdownType.Manual); + CurrentRoom.StartShutdown(eShutdownType.Manual); } /// @@ -614,7 +614,7 @@ namespace PepperDash.Essentials var timer = CurrentRoom.ShutdownPromptTimer; SetActivityFooterFeedbacks(); - if (CurrentRoom.ShutdownType == ShutdownType.Manual) + if (CurrentRoom.ShutdownType == eShutdownType.Manual) { PowerDownModal = new ModalDialog(TriList); var message = string.Format("Meeting will end in {0} seconds", CurrentRoom.ShutdownPromptSeconds);