From f5626fcd8b75fd77637160052b0f1da5b9b08f0e Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Tue, 17 Oct 2017 21:10:23 -0600 Subject: [PATCH] Commit before merging in Heath's branch --- .../Codec/iHasScheduleAwareness.cs | 2 + .../VideoCodec/CiscoCodec/CiscoSparkCodec.cs | 8 + .../VideoCodec/MockVC/MockVC.cs | 5 + .../VideoCodec/VideoCodecBase.cs | 2 +- .../PepperDashEssentials/ControlSystem.cs | 2 +- ...ntialsHuddleSpaceFusionSystemController.cs | 68 ++++- .../Room/Config/EssentialsRoomConfig.cs | 6 +- .../Room/Types/EssentialsRoomBase.cs | 266 +++++++++--------- ...entialsHuddleVtc1PanelAvFunctionsDriver.cs | 3 + 9 files changed, 214 insertions(+), 148 deletions(-) diff --git a/Essentials Devices Common/Essentials Devices Common/Codec/iHasScheduleAwareness.cs b/Essentials Devices Common/Essentials Devices Common/Codec/iHasScheduleAwareness.cs index cfd00de9..d756d2eb 100644 --- a/Essentials Devices Common/Essentials Devices Common/Codec/iHasScheduleAwareness.cs +++ b/Essentials Devices Common/Essentials Devices Common/Codec/iHasScheduleAwareness.cs @@ -18,6 +18,8 @@ namespace PepperDash.Essentials.Devices.Common.Codec public interface IHasScheduleAwareness { CodecScheduleAwareness CodecSchedule { get; } + + void GetSchedule(); } public class CodecScheduleAwareness diff --git a/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoSparkCodec.cs b/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoSparkCodec.cs index 4212f478..3193b753 100644 --- a/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoSparkCodec.cs +++ b/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoSparkCodec.cs @@ -767,6 +767,14 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco SendText("xCommand CallHistory Recents Limit: 20 Order: OccurrenceTime"); } + /// + /// Required for IHasScheduleAwareness + /// + public void GetSchedule() + { + GetBookings(null); + } + /// /// Gets the bookings for today /// diff --git a/Essentials Devices Common/Essentials Devices Common/VideoCodec/MockVC/MockVC.cs b/Essentials Devices Common/Essentials Devices Common/VideoCodec/MockVC/MockVC.cs index 24441891..d9b91ade 100644 --- a/Essentials Devices Common/Essentials Devices Common/VideoCodec/MockVC/MockVC.cs +++ b/Essentials Devices Common/Essentials Devices Common/VideoCodec/MockVC/MockVC.cs @@ -340,6 +340,11 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec #region IHasScheduleAwareness Members + public void GetSchedule() + { + + } + public CodecScheduleAwareness CodecSchedule { get { diff --git a/Essentials Devices Common/Essentials Devices Common/VideoCodec/VideoCodecBase.cs b/Essentials Devices Common/Essentials Devices Common/VideoCodec/VideoCodecBase.cs index a72b713d..23d14888 100644 --- a/Essentials Devices Common/Essentials Devices Common/VideoCodec/VideoCodecBase.cs +++ b/Essentials Devices Common/Essentials Devices Common/VideoCodec/VideoCodecBase.cs @@ -12,7 +12,7 @@ using PepperDash.Essentials.Devices.Common.Codec; namespace PepperDash.Essentials.Devices.Common.VideoCodec { public abstract class VideoCodecBase : Device, IRoutingInputsOutputs, - IUsageTracking, IHasDialer, IHasSharing, ICodecAudio, iCodecInfo + IUsageTracking, IHasDialer, IHasSharing, ICodecAudio, iCodecInfo //, ICommunicationMonitor { /// /// Fires when the status of any active, dialing, or incoming call changes or is new diff --git a/Essentials/PepperDashEssentials/ControlSystem.cs b/Essentials/PepperDashEssentials/ControlSystem.cs index 9c7c7813..0e68d23c 100644 --- a/Essentials/PepperDashEssentials/ControlSystem.cs +++ b/Essentials/PepperDashEssentials/ControlSystem.cs @@ -189,7 +189,7 @@ namespace PepperDash.Essentials DeviceManager.AddDevice(room); Debug.Console(1, "Room is EssentialsHuddleSpaceRoom, attempting to add to DeviceManager with Fusion"); - DeviceManager.AddDevice(new EssentialsHuddleSpaceFusionSystemController((EssentialsHuddleSpaceRoom)room, 0xf1)); + DeviceManager.AddDevice(new EssentialsHuddleSpaceFusionSystemControllerBase((EssentialsHuddleSpaceRoom)room, 0xf1)); var cotija = DeviceManager.GetDeviceForKey("cotijaServer") as CotijaSystemController; diff --git a/Essentials/PepperDashEssentials/OTHER/Fusion/EssentialsHuddleSpaceFusionSystemController.cs b/Essentials/PepperDashEssentials/OTHER/Fusion/EssentialsHuddleSpaceFusionSystemController.cs index 1bcccf51..b89d2c5a 100644 --- a/Essentials/PepperDashEssentials/OTHER/Fusion/EssentialsHuddleSpaceFusionSystemController.cs +++ b/Essentials/PepperDashEssentials/OTHER/Fusion/EssentialsHuddleSpaceFusionSystemController.cs @@ -17,13 +17,14 @@ using Newtonsoft.Json.Linq; using PepperDash.Core; using PepperDash.Essentials; using PepperDash.Essentials.Core; -using PepperDash.Essentials.Devices.Common; +using PepperDash.Essentials.Devices.Common; +using PepperDash.Essentials.Devices.Common.Occupancy; namespace PepperDash.Essentials.Fusion { - public class EssentialsHuddleSpaceFusionSystemController : Device + public class EssentialsHuddleSpaceFusionSystemControllerBase : Device, IOccupancyStatusProvider { public event EventHandler ScheduleChange; //public event EventHandler MeetingEndWarning; @@ -34,8 +35,6 @@ namespace PepperDash.Essentials.Fusion Dictionary SourceToFeedbackSigs = new Dictionary(); - //BooleanSigData OccupancyStatusSig; - StatusMonitorCollection ErrorMessageRollUp; StringSigData CurrentRoomSourceNameSig; @@ -103,13 +102,27 @@ namespace PepperDash.Essentials.Fusion public long PushNotificationTimeout = 5000; - Dictionary FusionStaticAssets; - - FusionOccupancySensorAsset FusionOccSensor; + Dictionary FusionStaticAssets; + + // For use with local occ sensor devices which will relay to Fusion the current occupancy status + FusionRemoteOccupancySensor FusionRemoteOccSensor; + + // For use with occ sensor attached to a scheduling panel in Fusion + FusionOccupancySensorAsset FusionOccSensor; + + public BoolFeedback RoomIsOccupiedFeedback { get; private set; } + + protected Func RoomIsOccupiedFeedbackFunc + { + get + { + return () => FusionRemoteOccSensor.RoomOccupied.OutputSig.BoolValue; + } + } //ScheduleResponseEvent NextMeeting; - public EssentialsHuddleSpaceFusionSystemController(EssentialsHuddleSpaceRoom room, uint ipId) + public EssentialsHuddleSpaceFusionSystemControllerBase(EssentialsHuddleSpaceRoom room, uint ipId) : base(room.Key + "-fusion") { @@ -143,8 +156,17 @@ namespace PepperDash.Essentials.Fusion SetUpCommunitcationMonitors(); SetUpDisplay(); SetUpError(); - //SetUpOccupancy(); - + + if(Room.RoomOccupancy != null) + { + if(Room.OccupancyStatusProviderIsRemote) + SetUpRemoteOccupancy(); + else + { + SetUpLocalOccupancy(); + } + } + // Make it so! FusionRVI.GenerateFileForAllFusionDevices(); @@ -1174,9 +1196,27 @@ namespace PepperDash.Essentials.Fusion FusionRoom.ErrorMessage.InputSig.StringValue = ErrorMessageRollUp.Message; }; - } + } + + /// + /// Sets up a local occupancy sensor, such as one attached to a Fusion Scheduling panel. The occupancy status of the room will be read from Fusion + /// + void SetUpLocalOccupancy() + { + RoomIsOccupiedFeedback = new BoolFeedback(RoomIsOccupiedFeedbackFunc); + + // Build Occupancy Asset? + // Link sigs? + + Room.SetRoomOccupancy(this); + + + } - void SetUpOccupancy() + /// + /// Sets up remote occupancy that will relay the occupancy status determined by local system devices to Fusion + /// + void SetUpRemoteOccupancy() { // Need to have the room occupancy object first and somehow determine the slot number of the Occupancy asset but will not be able to use the UID from config likely. @@ -1195,7 +1235,7 @@ namespace PepperDash.Essentials.Fusion var occSensorAsset = FusionRoom.CreateOccupancySensorAsset(tempOccAsset.SlotNumber, tempOccAsset.Name, "Occupancy Sensor", tempOccAsset.InstanceId); - occSensorAsset.RoomOccupied.AddSigToRVIFile = true; + occSensorAsset.RoomOccupied.AddSigToRVIFile = true; var occSensorShutdownMinutes = FusionRoom.CreateOffsetUshortSig(70, "Occ Shutdown - Minutes", eSigIoMask.InputOutputSig); @@ -1203,7 +1243,7 @@ namespace PepperDash.Essentials.Fusion //occSensorShutdownMinutes.OutputSig.UserObject(new Action(ushort)(b => Room.OccupancyObj.SetShutdownMinutes(b)); - // use Room.OccObject.RoomOccupiedFeedback.LinkInputSig(occSensorAsset.InputSig); + Room.RoomOccupancy.RoomIsOccupiedFeedback.LinkInputSig(occSensorAsset.RoomOccupied.InputSig); //} } diff --git a/Essentials/PepperDashEssentials/Room/Config/EssentialsRoomConfig.cs b/Essentials/PepperDashEssentials/Room/Config/EssentialsRoomConfig.cs index 386ce7c9..115b9e62 100644 --- a/Essentials/PepperDashEssentials/Room/Config/EssentialsRoomConfig.cs +++ b/Essentials/PepperDashEssentials/Room/Config/EssentialsRoomConfig.cs @@ -64,8 +64,10 @@ namespace PepperDash.Essentials.Room.Config PepperDash.Essentials.Devices.Common.VideoCodec.VideoCodecBase; var rm = new EssentialsHuddleVtc1Room(Key, Name, disp, codec, codec, props); - // Add Occupancy object from config -#warning Add in occupancy object from config if found and link up device to occupancy feedback + // Add Occupancy object from config + + if (props.Occupancy != null) + rm.SetRoomOccupancy(DeviceManager.GetDeviceForKey(props.Occupancy.DeviceKey) as PepperDash.Essentials.Devices.Common.Occupancy.IOccupancyStatusProvider); rm.LogoUrl = props.Logo.GetUrl(); rm.SourceListKey = props.SourceListKey; rm.DefaultSourceItem = props.DefaultSourceItem; diff --git a/Essentials/PepperDashEssentials/Room/Types/EssentialsRoomBase.cs b/Essentials/PepperDashEssentials/Room/Types/EssentialsRoomBase.cs index 58bcf5a7..75d819d4 100644 --- a/Essentials/PepperDashEssentials/Room/Types/EssentialsRoomBase.cs +++ b/Essentials/PepperDashEssentials/Room/Types/EssentialsRoomBase.cs @@ -1,54 +1,56 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using PepperDash.Core; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using PepperDash.Core; using PepperDash.Essentials.Core; -using PepperDash.Essentials.Devices.Common.Occupancy; - -namespace PepperDash.Essentials -{ - /// - /// - /// - public interface IHasCurrentSourceInfoChange - { - event SourceInfoChangeHandler CurrentSingleSourceChange; - } - - /// - /// - /// - public abstract class EssentialsRoomBase : Device - { - /// - /// - /// - public BoolFeedback OnFeedback { get; private set; } - - public BoolFeedback IsWarmingUpFeedback { get; private set; } +using PepperDash.Essentials.Devices.Common.Occupancy; + +namespace PepperDash.Essentials +{ + /// + /// + /// + public interface IHasCurrentSourceInfoChange + { + event SourceInfoChangeHandler CurrentSingleSourceChange; + } + + /// + /// + /// + public abstract class EssentialsRoomBase : Device + { + /// + /// + /// + public BoolFeedback OnFeedback { get; private set; } + + public BoolFeedback IsWarmingUpFeedback { get; private set; } public BoolFeedback IsCoolingDownFeedback { get; private set; } - public IOccupancyStatusProvider RoomOccupancy { get; private set; } - - protected abstract Func IsWarmingFeedbackFunc { get; } - protected abstract Func IsCoolingFeedbackFunc { get; } - - /// - /// 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 eShutdownType ShutdownType { get; private set; } - - public PepperDash.Essentials.Room.EssentialsRoomEmergencyBase Emergency { get; set; } - + public IOccupancyStatusProvider RoomOccupancy { get; private set; } + + public bool OccupancyStatusProviderIsRemote { get; private set; } + + protected abstract Func IsWarmingFeedbackFunc { get; } + protected abstract Func IsCoolingFeedbackFunc { get; } + + /// + /// 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 eShutdownType ShutdownType { get; private set; } + + public PepperDash.Essentials.Room.EssentialsRoomEmergencyBase Emergency { get; set; } + public string LogoUrl { get; set; } protected SecondsCountdownTimer RoomVacancyShutdownTimer { get; private set; } @@ -63,49 +65,49 @@ namespace PepperDash.Essentials /// /// Seconds after vacancy detected until prompt is displayed /// - protected int RoomVacancyShutdownPromptSeconds; - - /// - /// - /// - protected abstract Func OnFeedbackFunc { get; } - - /// - /// - /// - /// - /// - 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 = eShutdownType.None; + protected int RoomVacancyShutdownPromptSeconds; + + /// + /// + /// + protected abstract Func OnFeedbackFunc { get; } + + /// + /// + /// + /// + /// + 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 = eShutdownType.None; }; - ShutdownPromptTimer.HasFinished += (o, a) => Shutdown(); // Shutdown is triggered - - ShutdownPromptSeconds = 60; - ShutdownVacancySeconds = 120; + ShutdownPromptTimer.HasFinished += (o, a) => Shutdown(); // Shutdown is triggered + + ShutdownPromptSeconds = 60; + ShutdownVacancySeconds = 120; ShutdownType = eShutdownType.None; - RoomVacancyShutdownTimer = new SecondsCountdownTimer(Key + "-vacancyOffTimer"); - //RoomVacancyShutdownTimer.IsRunningFeedback.OutputChange += (o, a) => + RoomVacancyShutdownTimer = new SecondsCountdownTimer(Key + "-vacancyOffTimer"); + //RoomVacancyShutdownTimer.IsRunningFeedback.OutputChange += (o, a) => //{ // if (!RoomVacancyShutdownTimer.IsRunningFeedback.BoolValue) - // ShutdownType = ShutdownType.Vacancy; + // 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); + VacancyMode = eVacancyMode.None; + + OnFeedback = new BoolFeedback(OnFeedbackFunc); + + IsWarmingUpFeedback = new BoolFeedback(IsWarmingFeedbackFunc); + IsCoolingDownFeedback = new BoolFeedback(IsCoolingFeedbackFunc); } void RoomVacancyShutdownPromptTimer_HasFinished(object sender, EventArgs e) @@ -124,22 +126,22 @@ namespace PepperDash.Essentials default: break; } - } - - /// - /// - /// - /// - public void StartShutdown(eShutdownType type) - { - // Check for shutdowns running. Manual should override other shutdowns - - if (type == eShutdownType.Manual) - ShutdownPromptTimer.SecondsToCount = ShutdownPromptSeconds; - else if (type == eShutdownType.Vacancy) - ShutdownPromptTimer.SecondsToCount = ShutdownVacancySeconds; - ShutdownType = type; - ShutdownPromptTimer.Start(); + } + + /// + /// + /// + /// + public void StartShutdown(eShutdownType type) + { + // Check for shutdowns running. Manual should override other shutdowns + + if (type == eShutdownType.Manual) + ShutdownPromptTimer.SecondsToCount = ShutdownPromptSeconds; + else if (type == eShutdownType.Vacancy) + ShutdownPromptTimer.SecondsToCount = ShutdownVacancySeconds; + ShutdownType = type; + ShutdownPromptTimer.Start(); } public void StartRoomVacancyTimer(eVacancyMode mode) @@ -150,11 +152,11 @@ namespace PepperDash.Essentials RoomVacancyShutdownTimer.SecondsToCount = RoomVacancyShutdownSeconds; VacancyMode = mode; RoomVacancyShutdownTimer.Start(); - } - - /// - /// Resets the vacancy mode and shutsdwon the room - /// + } + + /// + /// Resets the vacancy mode and shutsdwon the room + /// public void Shutdown() { VacancyMode = eVacancyMode.None; @@ -166,11 +168,11 @@ namespace PepperDash.Essentials /// 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 - /// + + + /// + /// Override this to implement a default volume level(s) method + /// public abstract void SetDefaultLevels(); /// @@ -179,6 +181,10 @@ namespace PepperDash.Essentials /// public void SetRoomOccupancy(IOccupancyStatusProvider statusProvider) { + // If status provider is fusion, set flag to remote + if (statusProvider is PepperDash.Essentials.Fusion.EssentialsHuddleSpaceFusionSystemControllerBase) + OccupancyStatusProviderIsRemote = true; + RoomOccupancy = statusProvider; RoomOccupancy.RoomIsOccupiedFeedback.OutputChange += new EventHandler(RoomIsOccupiedFeedback_OutputChange); @@ -203,18 +209,18 @@ namespace PepperDash.Essentials /// Executes when RoomVacancyShutdownTimer expires. Used to trigger specific room actions as needed. Must nullify the timer object when executed /// /// - public abstract void RoomVacatedForTimeoutPeriod(object o); - } - - /// - /// To describe the various ways a room may be shutting down - /// - public enum eShutdownType - { - None = 0, - External, - Manual, - Vacancy + public abstract void RoomVacatedForTimeoutPeriod(object o); + } + + /// + /// To describe the various ways a room may be shutting down + /// + public enum eShutdownType + { + None = 0, + External, + Manual, + Vacancy } public enum eVacancyMode @@ -222,15 +228,15 @@ namespace PepperDash.Essentials None = 0, InInitialVacancy, InShutdownWarning - } - - /// - /// - /// - public enum eWarmingCoolingMode - { - None, - Warming, - Cooling - } + } + + /// + /// + /// + public enum eWarmingCoolingMode + { + None, + Warming, + Cooling + } } \ No newline at end of file diff --git a/Essentials/PepperDashEssentials/UIDrivers/EssentialsHuddleVTC/EssentialsHuddleVtc1PanelAvFunctionsDriver.cs b/Essentials/PepperDashEssentials/UIDrivers/EssentialsHuddleVTC/EssentialsHuddleVtc1PanelAvFunctionsDriver.cs index 3765e437..acff8f3b 100644 --- a/Essentials/PepperDashEssentials/UIDrivers/EssentialsHuddleVTC/EssentialsHuddleVtc1PanelAvFunctionsDriver.cs +++ b/Essentials/PepperDashEssentials/UIDrivers/EssentialsHuddleVTC/EssentialsHuddleVtc1PanelAvFunctionsDriver.cs @@ -1017,6 +1017,9 @@ namespace PepperDash.Essentials /// void RefreshMeetingsList() { + // See if this is helpful or if the callback response in the codec class maybe doesn't come it time? + CurrentRoom.ScheduleSource.GetSchedule(); + TriList.SetString(UIStringJoin.MeetingsOrContactMethodListIcon, "Calendar"); TriList.SetString(UIStringJoin.MeetingsOrContactMethodListTitleText, "Today's Meetings");