From 0becff5320f36bf676979b7fb161bd3157ddaa40 Mon Sep 17 00:00:00 2001 From: Heath Volmer Date: Sat, 19 Aug 2017 11:41:30 -0600 Subject: [PATCH] Working on adding shutdown timing to room, not UI --- .../PepperDash_Essentials_Core.projectinfo | Bin 1283 -> 1279 bytes .../Timers/CountdownTimer.cs | 22 ++--- .../PepperDashEssentials/ControlSystem.cs | 2 +- .../Room/EssentialsHuddleSpaceRoom.cs | 12 +++ .../Room/EssentialsPresentationRoom.cs | 11 +++ .../Room/EssentialsRoomBase.cs | 74 ++++++++++++--- .../Room/EssentialsRoomConfig.cs | 12 +++ .../EssentialsHuddlePanelAvFunctionsDriver.cs | 87 ++++++++++++++---- devjson commands.json | 4 + 9 files changed, 177 insertions(+), 47 deletions(-) diff --git a/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.projectinfo b/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.projectinfo index 6abf237925f82ee420beef68d9d5e3ad8dab34bc..2093c1610978cc2eaa2b6e099fc992e54f3a71db 100644 GIT binary patch delta 748 zcmV)o|Ka&gmfzbaIh~V~0zZE_NkBe1c(}W}cQDzV-Da8$ z$Y5@60r&&w#&rAt)(LrVs|h)6=Xt%%Te4S+^|F{|uzXE8N%ua@KmGLH{=)~m5AW~p z@8tQX=ev{rd@{X%@BDtAJ-EdrZR{qPxLb7gVH39zmH)R+=E1Ed^Hsj6+PpJ++4
t z3#Vr1;NiX9y=-SX*_rI$zxQD0!QPBmeed3W{$MxXxy{sAkio3n0`P~;itYCQtrN1l z6V8Y?PS5+W#^OPq?LFArJ>Nag^7H-ko&0|Oa7KTI{G7bBhf{wZ;($7~=SFb1q<*}! z|JTxdH>9~^nHTw0OG>sn?|5ksr#la)_hTl@r|Fu)FH#7yW^79grb+tTOws{R=gmaPKJ3l|jXOl^Gus@y79_-$~ zKY4%n@L)gx^uhkY!6fjQZv!@%lv@CQ?@1Z%`v0}Fb8l#NUjM}NZ|5cTGB7#kJ5$Oo z%x3v?c91k2cO;pj1INB zWcoHiq|XlS9ZYt14zhda+4;fr(>%+w+1`V_$^K+EIoR2O=8}oJ)rgepH#dA?Q*l3>ij$h=x~`Vv*TrI0zMg0Gillb@G`}pS`Rny+ zRn@HmRO(K%EZ?8(@7)uBm}Tdm?mpbP|L}Y#%Sl8Z+?$h-0zZHG-tH`)96a3J-8-1< z&TcbJ24pZdw*dTsb7Q*wf9r%ixYdN5w)4DR<}KN)#d=vxGg!VRoTPi7=AV*gd-!1Y z;r-qHojm{ae0Q>+Pp0?po!`&12e+7{jokzjcZ<$GY~nVe^8eP!Jh;_lzRDL>n|Ed} zJKy^>-u5qGxEK5&v(zW{Cxj>C%>ORoRNPaKi|D~{&4EgLmW`Y_S^{W zmeh}T_WxR%?}jvYEb}72YDvjf=N&KY;dJNW^#1JL&MeDkv)TEIG6+;^KHNelX45-?>#BQUH`v!cJ2+$&g-9e{_VV^UIr%T zd}n%p=l*P#PiF_&gM)js{mFy-d%F+r@9a(|lLrHnGYB=9n_Iws@3|T5`Tu28)A_(o z)c(*!Jh73&xq0QJ$Nu=JYodAHKjX* ijG*^RzW+;p31=vZb9HfPoa?fcVgEl8Sjjmb6#xKt5Uk4p diff --git a/Essentials Core/PepperDashEssentialsBase/Timers/CountdownTimer.cs b/Essentials Core/PepperDashEssentialsBase/Timers/CountdownTimer.cs index 81d27f58..73d853e3 100644 --- a/Essentials Core/PepperDashEssentialsBase/Timers/CountdownTimer.cs +++ b/Essentials Core/PepperDashEssentialsBase/Timers/CountdownTimer.cs @@ -10,6 +10,8 @@ namespace PepperDash.Essentials.Core { public class SecondsCountdownTimer: IKeyed { + public event EventHandler WasCancelled; + public string Key { get; private set; } public BoolFeedback IsRunningFeedback { get; private set; } @@ -21,12 +23,10 @@ namespace PepperDash.Essentials.Core public bool CountsDown { get; set; } public int SecondsToCount { get; set; } - public Action CompletionAction { get; set; } - public Action CancelAction { get; set; } - - CTimer SecondTimer; public DateTime StartTime { get; private set; } public DateTime FinishTime { get; private set; } + + CTimer SecondTimer; /// /// @@ -78,10 +78,10 @@ namespace PepperDash.Essentials.Core public void Cancel() { - CleanUp(); - var a = CancelAction; + Finish(); + var a = WasCancelled; if (a != null) - a(); + a(this, new EventArgs()); } public void Reset() @@ -91,14 +91,6 @@ namespace PepperDash.Essentials.Core } public void Finish() - { - CleanUp(); - var a = CompletionAction; - if (a != null) - a(); - } - - void CleanUp() { if (SecondTimer != null) SecondTimer.Stop(); diff --git a/Essentials/PepperDashEssentials/ControlSystem.cs b/Essentials/PepperDashEssentials/ControlSystem.cs index bdfbca8e..febcaa1b 100644 --- a/Essentials/PepperDashEssentials/ControlSystem.cs +++ b/Essentials/PepperDashEssentials/ControlSystem.cs @@ -76,7 +76,7 @@ namespace PepperDash.Essentials #warning Remove these test things: var cdt = new SecondsCountdownTimer("timer") { SecondsToCount = 20 }; - cdt.CompletionAction = () => Debug.Console(0, "TIMER DONE FOOLS!"); + cdt.WasCancelled += (o,a) => Debug.Console(0, "TIMER CANCELLED FOOLS!"); cdt.IsRunningFeedback.OutputChange += (o, a) => Debug.Console(0, "TIMER Running={0}", cdt.IsRunningFeedback); cdt.PercentFeedback.OutputChange += (o, a) => Debug.Console(0, "TIMER {0}%", cdt.PercentFeedback); cdt.TimeRemainingFeedback.OutputChange += (o,a) => Debug.Console(0, "TIMER time: {0}", cdt.TimeRemainingFeedback); diff --git a/Essentials/PepperDashEssentials/Room/EssentialsHuddleSpaceRoom.cs b/Essentials/PepperDashEssentials/Room/EssentialsHuddleSpaceRoom.cs index c06bb06c..e8b96659 100644 --- a/Essentials/PepperDashEssentials/Room/EssentialsHuddleSpaceRoom.cs +++ b/Essentials/PepperDashEssentials/Room/EssentialsHuddleSpaceRoom.cs @@ -144,6 +144,18 @@ namespace PepperDash.Essentials EnablePowerOnToLastSource = true; } + /// + /// + /// + public override void Shutdown() + { + RunRouteAction("roomoff"); + } + + /// + /// + /// + /// public void RunRouteAction(string routeKey) { RunRouteAction(routeKey, null); diff --git a/Essentials/PepperDashEssentials/Room/EssentialsPresentationRoom.cs b/Essentials/PepperDashEssentials/Room/EssentialsPresentationRoom.cs index f91e00f9..c022575a 100644 --- a/Essentials/PepperDashEssentials/Room/EssentialsPresentationRoom.cs +++ b/Essentials/PepperDashEssentials/Room/EssentialsPresentationRoom.cs @@ -255,7 +255,18 @@ namespace PepperDash.Essentials }, 0); } + /// + /// + /// + public override void Shutdown() + { + RunRouteAction("roomoff"); + } + /// + /// + /// + /// public void RunRouteAction(string routeKey) { RunRouteAction(routeKey, null); diff --git a/Essentials/PepperDashEssentials/Room/EssentialsRoomBase.cs b/Essentials/PepperDashEssentials/Room/EssentialsRoomBase.cs index 6697bca6..b7c4093c 100644 --- a/Essentials/PepperDashEssentials/Room/EssentialsRoomBase.cs +++ b/Essentials/PepperDashEssentials/Room/EssentialsRoomBase.cs @@ -30,33 +30,79 @@ namespace PepperDash.Essentials public BoolFeedback IsWarmingFeedback { get; private set; } public BoolFeedback IsCoolingFeedback { get; private set; } - public BoolFeedback PowerOffPendingFeedback { get; private set; } - public IntFeedback PowerOffPendingTimerPercentFeedback { get; private set; } - public StringFeedback PowerOffPendingTimeStringFeedback { get; private set; } - bool _PowerOffPending; - public int PowerOffDelaySeconds { get; set; } + //public BoolFeedback PowerOffPendingFeedback { get; private set; } + //bool _PowerOffPending; + //public IntFeedback PowerOffPendingTimerPercentFeedback { get; private set; } + //public StringFeedback PowerOffPendingTimeStringFeedback { get; private set; } - public BoolFeedback VacancyPowerDownFeedback { get; private set; } + /// + /// Timer used for informing the UIs of a shutdown + /// + public SecondsCountdownTimer ShutdownPromptTimer { get; private set; } + /// + /// + /// + public int ShutdownPromptSeconds { get; set; } + public int ShutdownVacancySeconds { get; set; } + public ShutdownType ShutdownType { get; private set; } + + /// + /// + /// protected abstract Func OnFeedbackFunc { get; } + /// + /// + /// + /// + /// public EssentialsRoomBase(string key, string name) : base(key, name) { + ShutdownPromptTimer = new SecondsCountdownTimer(Key + "-offTimer"); + ShutdownPromptTimer.IsRunningFeedback.OutputChange += (o, a) => + { + if (!ShutdownPromptTimer.IsRunningFeedback.BoolValue) + ShutdownType = ShutdownType.None; + }; + + ShutdownPromptSeconds = 60; + ShutdownVacancySeconds = 120; + OnFeedback = new BoolFeedback(OnFeedbackFunc); - PowerOffPendingFeedback = new BoolFeedback(() => _PowerOffPending); } /// - /// Triggers the shutdown timer + /// /// - public void StartShutdown() + /// + public void StartShutdown(ShutdownType type) { - if (!_PowerOffPending) - { - _PowerOffPending = true; - PowerOffPendingFeedback.FireUpdate(); - } + // Check for shutdowns running. Manual should override other shutdowns + + if (type == ShutdownType.Manual) + ShutdownPromptTimer.SecondsToCount = ShutdownPromptSeconds; + else if (type == ShutdownType.Vacancy) + ShutdownPromptTimer.SecondsToCount = ShutdownVacancySeconds; + ShutdownType = type; + ShutdownPromptTimer.Start(); } + + /// + /// + /// + public abstract void Shutdown(); + } + + /// + /// To describe the various ways a room may be shutting down + /// + public enum ShutdownType + { + None, + External, + Manual, + Vacancy } } \ No newline at end of file diff --git a/Essentials/PepperDashEssentials/Room/EssentialsRoomConfig.cs b/Essentials/PepperDashEssentials/Room/EssentialsRoomConfig.cs index 3e359e44..dc1ebc87 100644 --- a/Essentials/PepperDashEssentials/Room/EssentialsRoomConfig.cs +++ b/Essentials/PepperDashEssentials/Room/EssentialsRoomConfig.cs @@ -63,8 +63,20 @@ namespace PepperDash.Essentials { public string HelpMessage { get; set; } public string Description { get; set; } + public int ShutdownVacancySeconds { get; set; } + public int ShutdownPromptSeconds { get; set; } + public EssentialsRoomOccSensorConfig OccupancySensors { get; set; } } + /// + /// Represents occupancy sensor(s) setup for a room + /// + public class EssentialsRoomOccSensorConfig + { + public string Mode { get; set; } + public List Types { get; set; } + } + /// /// /// diff --git a/Essentials/PepperDashEssentials/UI Drivers/EssentialsHuddlePanelAvFunctionsDriver.cs b/Essentials/PepperDashEssentials/UI Drivers/EssentialsHuddlePanelAvFunctionsDriver.cs index d4c0a775..5c1b9063 100644 --- a/Essentials/PepperDashEssentials/UI Drivers/EssentialsHuddlePanelAvFunctionsDriver.cs +++ b/Essentials/PepperDashEssentials/UI Drivers/EssentialsHuddlePanelAvFunctionsDriver.cs @@ -473,25 +473,75 @@ namespace PepperDash.Essentials { if (!CurrentRoom.OnFeedback.BoolValue) return; - EndMeetingButtonSig.BoolValue = true; - ShareButtonSig.BoolValue = false; - // Timeout or button 1 press will shut down - var modal = new ModalDialog(TriList); - uint time = 60000; - uint seconds = time / 1000; - var message = string.Format("Meeting will end in {0} seconds", seconds); - modal.PresentModalTimerDialog(2, "End Meeting", "Power", message, - "End Meeting Now", "Cancel", time, true, - but => - { - if (but != 2) - CurrentRoom.RunRouteAction("roomOff"); - else - ShareButtonSig.BoolValue = true; // restore Share fb - EndMeetingButtonSig.BoolValue = false; - }); + + //EndMeetingButtonSig.BoolValue = true; + //ShareButtonSig.BoolValue = false; + + CurrentRoom.StartShutdown(ShutdownType.Manual); + + //// Timeout or button 1 press will shut down + //var modal = new ModalDialog(TriList); + //uint time = 60000; + //uint seconds = time / 1000; + //var message = string.Format("Meeting will end in {0} seconds", seconds); + //modal.PresentModalTimerDialog(2, "End Meeting", "Power", message, + // "End Meeting Now", "Cancel", time, true, + // but => + // { + // if (but != 2) + // CurrentRoom.RunRouteAction("roomOff"); + // else + // ShareButtonSig.BoolValue = true; // restore Share fb + // EndMeetingButtonSig.BoolValue = false; + // }); } +#warning WHAT I'M TRYING TO DO WITH SHUTDOWN PROMPTS. SEE COMMENT + // UI should ask room to shutdown + // UI should be attached to room's shutdown timer + // When timer starts, the UI should present a corresponding modal, with the right text + // the modal bar will decrement depending on the timer's percent + // If the user selects "end now" + // Cancel the modal + // Call shutdown on the room (which should cancel any timers) + // Room cancels timer + // Room fires Shutdown event? + // If the UI cancels shutdown + // Call cancel shutdown on room + // Timer will go low + // Fire shutdown cancelled event? + // + + void Shutdown_IsRunningFeedback_OutputChange(object sender, EventArgs e) + { + var timer = CurrentRoom.ShutdownPromptTimer; + if (timer.IsRunningFeedback.BoolValue) + { + EndMeetingButtonSig.BoolValue = true; + ShareButtonSig.BoolValue = false; + + if (CurrentRoom.ShutdownType == ShutdownType.Manual) + { + var modal = new ModalDialog(TriList); + var message = string.Format("Meeting will end in {0} seconds", CurrentRoom.ShutdownPromptSeconds); + modal.PresentModalTimerDialog(2, "End Meeting", "Power", message, + "End Meeting Now", "Cancel", 0, true, + but => + { + if (but != 2) // any button except for End cancels + timer.Cancel(); + else + ShareButtonSig.BoolValue = true; // restore Share fb + EndMeetingButtonSig.BoolValue = false; + }); + } + } + else + { + + } + } + void CancelPowerOffTimer() { if (PowerOffTimer != null) @@ -615,6 +665,9 @@ namespace PepperDash.Essentials TriList.StringInput[UIStringJoin.CurrentRoomName].StringValue = _CurrentRoom.Name; + // Shutdown timer + _CurrentRoom.ShutdownPromptTimer.IsRunningFeedback.OutputChange += Shutdown_IsRunningFeedback_OutputChange; + // Link up all the change events from the room _CurrentRoom.OnFeedback.OutputChange += _CurrentRoom_OnFeedback_OutputChange; _CurrentRoom.CurrentVolumeDeviceChange += _CurrentRoom_CurrentAudioDeviceChange; diff --git a/devjson commands.json b/devjson commands.json index 0587439f..c5e6e194 100644 --- a/devjson commands.json +++ b/devjson commands.json @@ -3,3 +3,7 @@ devjson:1 {"deviceKey":"display-1-comMonitor","methodName":"PrintStatus"} devjson:1 {"deviceKey":"display-1-com","methodName":"SimulateReceive", "params": ["\\x05\\x06taco\\xAA"]} devjson:1 {"deviceKey":"timer","methodName":"Start" } + +devjson:1 {"deviceKey":"timer","methodName":"Cancel" } + +devjson:1 {"deviceKey":"timer","methodName":"Reset" } \ No newline at end of file