diff --git a/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj b/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj index ab03ff44..0e115543 100644 --- a/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj +++ b/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj @@ -142,6 +142,7 @@ + diff --git a/Essentials Core/PepperDashEssentialsBase/Room/Room.cs b/Essentials Core/PepperDashEssentialsBase/Room/Room.cs index 20947d95..2f1594ed 100644 --- a/Essentials Core/PepperDashEssentialsBase/Room/Room.cs +++ b/Essentials Core/PepperDashEssentialsBase/Room/Room.cs @@ -16,7 +16,7 @@ namespace PepperDash.Essentials.Core { public abstract BoolFeedback RoomIsOnFeedback { get; protected set; } public abstract BoolFeedback IsCoolingDownFeedback { get; protected set; } - public abstract BoolFeedback IsWarmingUpFeedback { get; protected set; } + public abstract BoolFeedback IsWarmingUpFeedback { get; protected set; } // In concrete classes, these should be computed from the relevant devices public virtual uint CooldownTime { get { return 10000; } } diff --git a/Essentials Core/PepperDashEssentialsBase/Room/iHasOccupancyAwareness.cs b/Essentials Core/PepperDashEssentialsBase/Room/iHasOccupancyAwareness.cs new file mode 100644 index 00000000..d6165d6c --- /dev/null +++ b/Essentials Core/PepperDashEssentialsBase/Room/iHasOccupancyAwareness.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro.GeneralIO; + +namespace PepperDash.Essentials.Core.Room +{ + public interface IHasOccupancyAwareness + { + OccupancyStatus RoomOccupancy { get; } + + } + + public class OccupancyStatus + { + BoolFeedback RoomIsOccupied { get; } + + + } + + +} \ No newline at end of file diff --git a/Essentials Devices Common/Essentials Devices Common/Codec/iHasScheduleAwareness.cs b/Essentials Devices Common/Essentials Devices Common/Codec/iHasScheduleAwareness.cs index a641328c..49c5c645 100644 --- a/Essentials Devices Common/Essentials Devices Common/Codec/iHasScheduleAwareness.cs +++ b/Essentials Devices Common/Essentials Devices Common/Codec/iHasScheduleAwareness.cs @@ -6,6 +6,15 @@ using Crestron.SimplSharp; namespace PepperDash.Essentials.Devices.Common.Codec { + public enum eMeetingEventChangeType + { + Unkown = 0, + MeetingStartWarning, + MeetingStart, + MeetingEndWarning, + MeetingEnd + } + public interface IHasScheduleAwareness { CodecScheduleAwareness CodecSchedule { get; } @@ -13,11 +22,70 @@ namespace PepperDash.Essentials.Devices.Common.Codec public class CodecScheduleAwareness { - public List Meetings { get; set; } + List _Meetings; + + public event EventHandler MeetingEventChange; + + public event EventHandler MeetingsListHasChanged; + + public List Meetings + { + get + { + return _Meetings; + } + set + { + _Meetings = value; + + var handler = MeetingsListHasChanged; + if (handler != null) + { + handler(this, new EventArgs()); + } + } + } + + private CTimer ScheduleChecker; public CodecScheduleAwareness() { Meetings = new List(); + + ScheduleChecker = new CTimer(CheckSchedule, null, 1000, 1000); + } + + private void OnMeetingChange(eMeetingEventChangeType changeType, Meeting meeting) + { + var handler = MeetingEventChange; + if (handler != null) + { + handler(this, new MeetingEventArgs() { ChangeType = changeType, Meeting = meeting }); + } + } + + private void CheckSchedule(object o) + { + // Iterate the meeting list and check if any meeting need to do anythingk + + foreach (Meeting m in Meetings) + { + eMeetingEventChangeType changeType = eMeetingEventChangeType.Unkown; + + if (m.TimeToMeetingStart.TotalMinutes == m.MeetingWarningMinutes.TotalMinutes) // Meeting is about to start + changeType = eMeetingEventChangeType.MeetingStartWarning; + else if (m.TimeToMeetingStart.TotalMinutes == 0) // Meeting Start + changeType = eMeetingEventChangeType.MeetingStart; + else if (m.TimeToMeetingEnd.TotalMinutes == m.MeetingWarningMinutes.TotalMinutes) // Meeting is about to end + changeType = eMeetingEventChangeType.MeetingEndWarning; + else if (m.TimeToMeetingEnd.TotalMinutes == 0) // Meeting has ended + changeType = eMeetingEventChangeType.MeetingEnd; + + if (changeType != eMeetingEventChangeType.Unkown) + OnMeetingChange(changeType, m); + } + + } } @@ -26,10 +94,26 @@ namespace PepperDash.Essentials.Devices.Common.Codec /// public class Meeting { + public TimeSpan MeetingWarningMinutes = TimeSpan.FromMinutes(5); + public string Id { get; set; } public string Organizer { get; set; } public string Title { get; set; } public string Agenda { get; set; } + public TimeSpan TimeToMeetingStart + { + get + { + return StartTime - DateTime.Now; + } + } + public TimeSpan TimeToMeetingEnd + { + get + { + return EndTime - DateTime.Now; + } + } public DateTime StartTime { get; set; } public DateTime EndTime { get; set; } public TimeSpan Duration @@ -44,11 +128,18 @@ namespace PepperDash.Essentials.Devices.Common.Codec { get { - return StartTime.AddMinutes(-5) <= DateTime.Now - && DateTime.Now <= EndTime.AddMinutes(-5); + return StartTime.AddMinutes(-5) <= DateTime.Now + && DateTime.Now <= EndTime.AddMinutes(-5); } } public string ConferenceNumberToDial { get; set; } public string ConferencePassword { get; set; } } -} \ No newline at end of file + + public class MeetingEventArgs : EventArgs + { + public eMeetingEventChangeType ChangeType { get; set; } + public Meeting Meeting { get; set; } + } + +} 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 3dcbcc6c..d0a854b3 100644 --- a/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj +++ b/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj @@ -130,6 +130,8 @@ + + diff --git a/Essentials Devices Common/Essentials Devices Common/Occupancy/GlsOirCsmExBatt.cs b/Essentials Devices Common/Essentials Devices Common/Occupancy/GlsOirCsmExBatt.cs new file mode 100644 index 00000000..c2aa7ed9 --- /dev/null +++ b/Essentials Devices Common/Essentials Devices Common/Occupancy/GlsOirCsmExBatt.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro.GeneralIO; + +namespace PepperDash.Essentials.Devices.Common.Occupancy +{ + public class EssentialsGlsOirCsmExBatt : GlsOccupancySensorBase, IOccupancyStatusProvider + { + public GlsOirCsmExBatt OccSensor { get; set; } + + + } +} \ No newline at end of file diff --git a/Essentials Devices Common/Essentials Devices Common/Occupancy/iOccupancyStatusProvider.cs b/Essentials Devices Common/Essentials Devices Common/Occupancy/iOccupancyStatusProvider.cs new file mode 100644 index 00000000..8f019fd6 --- /dev/null +++ b/Essentials Devices Common/Essentials Devices Common/Occupancy/iOccupancyStatusProvider.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +namespace PepperDash.Essentials.Devices.Common.Occupancy +{ + public interface IOccupancyStatusProvider + { + // Need to define a common interface that can be applied to Crestron Occ sensor as well as 3rd party devices. How to accomplish? + } +} \ No newline at end of file diff --git a/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/BookingsDataClasses.cs b/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/BookingsDataClasses.cs index 19c54028..2905f285 100644 --- a/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/BookingsDataClasses.cs +++ b/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/BookingsDataClasses.cs @@ -288,8 +288,6 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec meetings.OrderBy(m => m.StartTime); - - return meetings; } } 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 b702a5f6..16bf5f38 100644 --- a/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoCodec.cs +++ b/Essentials Devices Common/Essentials Devices Common/VideoCodec/CiscoCodec/CiscoCodec.cs @@ -6,6 +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; @@ -34,6 +35,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco public BoolFeedback RoomIsOccupiedFeedback { get; private set; } + //public BoolOutputSig OccupancyDetectedFeedback { get; private set; } + public IntFeedback PeopleCountFeedback { get; private set; } public BoolFeedback SpeakerTrackIsOnFeedback { get; private set; } @@ -628,6 +631,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco JsonConvert.PopulateObject(response, codecBookings); CodecSchedule.Meetings = CiscoCodecBookings.GetGenericMeetingsFromBookingResult(codecBookings.CommandResponse.BookingsListResult.Booking); + + } }