From 0f4bded3801be57b02842c261c84deb35beeddb5 Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Wed, 24 Jun 2020 09:39:25 -0600 Subject: [PATCH] Cleanup for EssentialsRoomBase --- .../Room/EssentialsRoomBase.cs | 64 +++++++++---------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/EssentialsRoomBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/EssentialsRoomBase.cs index bb57941e..3a07994a 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/EssentialsRoomBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/Room/EssentialsRoomBase.cs @@ -1,12 +1,6 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharp.Scheduler; - using PepperDash.Core; -using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Devices; @@ -17,9 +11,6 @@ namespace PepperDash.Essentials.Core /// public abstract class EssentialsRoomBase : ReconfigurableDevice { - /// - /// - /// public BoolFeedback OnFeedback { get; private set; } /// @@ -47,16 +38,13 @@ namespace PepperDash.Essentials.Core /// public SecondsCountdownTimer ShutdownPromptTimer { get; private set; } - /// - /// - /// public int ShutdownPromptSeconds { get; set; } public int ShutdownVacancySeconds { get; set; } public eShutdownType ShutdownType { get; private set; } public EssentialsRoomEmergencyBase Emergency { get; set; } - public Core.Privacy.MicrophonePrivacyController MicrophonePrivacy { get; set; } + public Privacy.MicrophonePrivacyController MicrophonePrivacy { get; set; } public string LogoUrl { get; set; } @@ -87,7 +75,7 @@ namespace PepperDash.Essentials.Core public bool ZeroVolumeWhenSwtichingVolumeDevices { get; private set; } - public EssentialsRoomBase(DeviceConfig config) + protected EssentialsRoomBase(DeviceConfig config) : base(config) { // Setup the ShutdownPromptTimer @@ -110,7 +98,7 @@ namespace PepperDash.Essentials.Core // if (!RoomVacancyShutdownTimer.IsRunningFeedback.BoolValue) // ShutdownType = ShutdownType.Vacancy; //}; - RoomVacancyShutdownTimer.HasFinished += new EventHandler(RoomVacancyShutdownPromptTimer_HasFinished); // Shutdown is triggered + RoomVacancyShutdownTimer.HasFinished += RoomVacancyShutdownPromptTimer_HasFinished; // Shutdown is triggered RoomVacancyShutdownPromptSeconds = 1500; // 25 min to prompt warning RoomVacancyShutdownSeconds = 240; // 4 min after prompt will trigger shutdown prompt @@ -144,8 +132,6 @@ namespace PepperDash.Essentials.Core Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Shutting Down due to vacancy."); break; } - default: - break; } } @@ -157,10 +143,15 @@ namespace PepperDash.Essentials.Core { // Check for shutdowns running. Manual should override other shutdowns - if (type == eShutdownType.Manual) - ShutdownPromptTimer.SecondsToCount = ShutdownPromptSeconds; - else if (type == eShutdownType.Vacancy) - ShutdownPromptTimer.SecondsToCount = ShutdownVacancySeconds; + switch (type) + { + case eShutdownType.Manual: + ShutdownPromptTimer.SecondsToCount = ShutdownPromptSeconds; + break; + case eShutdownType.Vacancy: + ShutdownPromptTimer.SecondsToCount = ShutdownVacancySeconds; + break; + } ShutdownType = type; ShutdownPromptTimer.Start(); @@ -169,12 +160,18 @@ namespace PepperDash.Essentials.Core public void StartRoomVacancyTimer(eVacancyMode mode) { - if (mode == eVacancyMode.None) - RoomVacancyShutdownTimer.SecondsToCount = RoomVacancyShutdownPromptSeconds; - else if (mode == eVacancyMode.InInitialVacancy) - RoomVacancyShutdownTimer.SecondsToCount = RoomVacancyShutdownSeconds; - else if (mode == eVacancyMode.InShutdownWarning) - RoomVacancyShutdownTimer.SecondsToCount = 60; + switch (mode) + { + case eVacancyMode.None: + RoomVacancyShutdownTimer.SecondsToCount = RoomVacancyShutdownPromptSeconds; + break; + case eVacancyMode.InInitialVacancy: + RoomVacancyShutdownTimer.SecondsToCount = RoomVacancyShutdownSeconds; + break; + case eVacancyMode.InShutdownWarning: + RoomVacancyShutdownTimer.SecondsToCount = 60; + break; + } VacancyMode = mode; RoomVacancyShutdownTimer.Start(); @@ -206,19 +203,22 @@ namespace PepperDash.Essentials.Core /// Sets the object to be used as the IOccupancyStatusProvider for the room. Can be an Occupancy Aggregator or a specific device /// /// + /// public void SetRoomOccupancy(IOccupancyStatusProvider statusProvider, int timeoutMinutes) - { - if (statusProvider == null) + { + var provider = statusProvider as IKeyed; + + if (provider == null) { Debug.Console(0, this, "ERROR: Occupancy sensor device is null"); return; } - Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Room Occupancy set to device: '{0}'", (statusProvider as Device).Key); + Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Room Occupancy set to device: '{0}'", provider.Key); Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Timeout Minutes from Config is: {0}", timeoutMinutes); // If status provider is fusion, set flag to remote - if (statusProvider is Core.Fusion.EssentialsHuddleSpaceFusionSystemControllerBase) + if (statusProvider is Fusion.EssentialsHuddleSpaceFusionSystemControllerBase) OccupancyStatusProviderIsRemote = true; if(timeoutMinutes > 0) @@ -307,7 +307,7 @@ namespace PepperDash.Essentials.Core { public string Key { get; private set; } - public EssentialsRoomEmergencyBase(string key) + protected EssentialsRoomEmergencyBase(string key) { Key = key; }